Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * Universal Interface for Intel High Definition Audio Codec | |
3 | * | |
4 | * HD audio interface patch for ALC 260/880/882 codecs | |
5 | * | |
df694daa KY |
6 | * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw> |
7 | * PeiSen Hou <pshou@realtek.com.tw> | |
1da177e4 | 8 | * Takashi Iwai <tiwai@suse.de> |
7cf51e48 | 9 | * Jonathan Woithe <jwoithe@physics.adelaide.edu.au> |
1da177e4 LT |
10 | * |
11 | * This driver is free software; you can redistribute it and/or modify | |
12 | * it under the terms of the GNU General Public License as published by | |
13 | * the Free Software Foundation; either version 2 of the License, or | |
14 | * (at your option) any later version. | |
15 | * | |
16 | * This driver is distributed in the hope that it will be useful, | |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | * GNU General Public License for more details. | |
20 | * | |
21 | * You should have received a copy of the GNU General Public License | |
22 | * along with this program; if not, write to the Free Software | |
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 | */ | |
25 | ||
1da177e4 LT |
26 | #include <linux/init.h> |
27 | #include <linux/delay.h> | |
28 | #include <linux/slab.h> | |
29 | #include <linux/pci.h> | |
30 | #include <sound/core.h> | |
31 | #include "hda_codec.h" | |
32 | #include "hda_local.h" | |
33 | ||
ccc656ce KY |
34 | #define ALC880_FRONT_EVENT 0x01 |
35 | #define ALC880_DCVOL_EVENT 0x02 | |
36 | #define ALC880_HP_EVENT 0x04 | |
37 | #define ALC880_MIC_EVENT 0x08 | |
1da177e4 LT |
38 | |
39 | /* ALC880 board config type */ | |
40 | enum { | |
1da177e4 LT |
41 | ALC880_3ST, |
42 | ALC880_3ST_DIG, | |
43 | ALC880_5ST, | |
44 | ALC880_5ST_DIG, | |
45 | ALC880_W810, | |
dfc0ff62 | 46 | ALC880_Z71V, |
b6482d48 | 47 | ALC880_6ST, |
16ded525 TI |
48 | ALC880_6ST_DIG, |
49 | ALC880_F1734, | |
50 | ALC880_ASUS, | |
51 | ALC880_ASUS_DIG, | |
52 | ALC880_ASUS_W1V, | |
df694daa | 53 | ALC880_ASUS_DIG2, |
2cf9f0fc | 54 | ALC880_FUJITSU, |
16ded525 | 55 | ALC880_UNIWILL_DIG, |
ccc656ce KY |
56 | ALC880_UNIWILL, |
57 | ALC880_UNIWILL_P53, | |
df694daa KY |
58 | ALC880_CLEVO, |
59 | ALC880_TCL_S700, | |
ae6b813a | 60 | ALC880_LG, |
d681518a | 61 | ALC880_LG_LW, |
df99cd33 | 62 | ALC880_MEDION_RIM, |
e9edcee0 TI |
63 | #ifdef CONFIG_SND_DEBUG |
64 | ALC880_TEST, | |
65 | #endif | |
df694daa | 66 | ALC880_AUTO, |
16ded525 TI |
67 | ALC880_MODEL_LAST /* last tag */ |
68 | }; | |
69 | ||
70 | /* ALC260 models */ | |
71 | enum { | |
72 | ALC260_BASIC, | |
73 | ALC260_HP, | |
3f878308 | 74 | ALC260_HP_DC7600, |
df694daa KY |
75 | ALC260_HP_3013, |
76 | ALC260_FUJITSU_S702X, | |
0bfc90e9 | 77 | ALC260_ACER, |
bc9f98a9 KY |
78 | ALC260_WILL, |
79 | ALC260_REPLACER_672V, | |
7cf51e48 JW |
80 | #ifdef CONFIG_SND_DEBUG |
81 | ALC260_TEST, | |
82 | #endif | |
df694daa | 83 | ALC260_AUTO, |
16ded525 | 84 | ALC260_MODEL_LAST /* last tag */ |
1da177e4 LT |
85 | }; |
86 | ||
df694daa KY |
87 | /* ALC262 models */ |
88 | enum { | |
89 | ALC262_BASIC, | |
ccc656ce KY |
90 | ALC262_HIPPO, |
91 | ALC262_HIPPO_1, | |
834be88d | 92 | ALC262_FUJITSU, |
9c7f852e | 93 | ALC262_HP_BPC, |
cd7509a4 KY |
94 | ALC262_HP_BPC_D7000_WL, |
95 | ALC262_HP_BPC_D7000_WF, | |
66d2a9d6 | 96 | ALC262_HP_TC_T5735, |
8c427226 | 97 | ALC262_HP_RP5700, |
304dcaac | 98 | ALC262_BENQ_ED8, |
272a527c | 99 | ALC262_SONY_ASSAMD, |
83c34218 | 100 | ALC262_BENQ_T31, |
f651b50b | 101 | ALC262_ULTRA, |
0e31daf7 | 102 | ALC262_LENOVO_3000, |
e8f9ae2a | 103 | ALC262_NEC, |
4e555fe5 | 104 | ALC262_TOSHIBA_S06, |
9f99a638 | 105 | ALC262_TOSHIBA_RX1, |
df694daa KY |
106 | ALC262_AUTO, |
107 | ALC262_MODEL_LAST /* last tag */ | |
108 | }; | |
109 | ||
a361d84b KY |
110 | /* ALC268 models */ |
111 | enum { | |
eb5a6621 | 112 | ALC267_QUANTA_IL1, |
a361d84b | 113 | ALC268_3ST, |
d1a991a6 | 114 | ALC268_TOSHIBA, |
d273809e | 115 | ALC268_ACER, |
c238b4f4 | 116 | ALC268_ACER_DMIC, |
8ef355da | 117 | ALC268_ACER_ASPIRE_ONE, |
3866f0b0 | 118 | ALC268_DELL, |
f12462c5 | 119 | ALC268_ZEPTO, |
86c53bd2 JW |
120 | #ifdef CONFIG_SND_DEBUG |
121 | ALC268_TEST, | |
122 | #endif | |
a361d84b KY |
123 | ALC268_AUTO, |
124 | ALC268_MODEL_LAST /* last tag */ | |
125 | }; | |
126 | ||
f6a92248 KY |
127 | /* ALC269 models */ |
128 | enum { | |
129 | ALC269_BASIC, | |
60db6b53 | 130 | ALC269_QUANTA_FL1, |
f53281e6 KY |
131 | ALC269_ASUS_EEEPC_P703, |
132 | ALC269_ASUS_EEEPC_P901, | |
26f5df26 | 133 | ALC269_FUJITSU, |
64154835 | 134 | ALC269_LIFEBOOK, |
f6a92248 KY |
135 | ALC269_AUTO, |
136 | ALC269_MODEL_LAST /* last tag */ | |
137 | }; | |
138 | ||
df694daa KY |
139 | /* ALC861 models */ |
140 | enum { | |
141 | ALC861_3ST, | |
9c7f852e | 142 | ALC660_3ST, |
df694daa KY |
143 | ALC861_3ST_DIG, |
144 | ALC861_6ST_DIG, | |
22309c3e | 145 | ALC861_UNIWILL_M31, |
a53d1aec | 146 | ALC861_TOSHIBA, |
7cdbff94 | 147 | ALC861_ASUS, |
56bb0cab | 148 | ALC861_ASUS_LAPTOP, |
df694daa KY |
149 | ALC861_AUTO, |
150 | ALC861_MODEL_LAST, | |
151 | }; | |
152 | ||
f32610ed JS |
153 | /* ALC861-VD models */ |
154 | enum { | |
155 | ALC660VD_3ST, | |
6963f84c | 156 | ALC660VD_3ST_DIG, |
13c94744 | 157 | ALC660VD_ASUS_V1S, |
f32610ed JS |
158 | ALC861VD_3ST, |
159 | ALC861VD_3ST_DIG, | |
160 | ALC861VD_6ST_DIG, | |
bdd148a3 | 161 | ALC861VD_LENOVO, |
272a527c | 162 | ALC861VD_DALLAS, |
d1a991a6 | 163 | ALC861VD_HP, |
f32610ed JS |
164 | ALC861VD_AUTO, |
165 | ALC861VD_MODEL_LAST, | |
166 | }; | |
167 | ||
bc9f98a9 KY |
168 | /* ALC662 models */ |
169 | enum { | |
170 | ALC662_3ST_2ch_DIG, | |
171 | ALC662_3ST_6ch_DIG, | |
172 | ALC662_3ST_6ch, | |
173 | ALC662_5ST_DIG, | |
174 | ALC662_LENOVO_101E, | |
291702f0 | 175 | ALC662_ASUS_EEEPC_P701, |
8c427226 | 176 | ALC662_ASUS_EEEPC_EP20, |
6dda9f4a KY |
177 | ALC663_ASUS_M51VA, |
178 | ALC663_ASUS_G71V, | |
179 | ALC663_ASUS_H13, | |
180 | ALC663_ASUS_G50V, | |
f1d4e28b KY |
181 | ALC662_ECS, |
182 | ALC663_ASUS_MODE1, | |
183 | ALC662_ASUS_MODE2, | |
184 | ALC663_ASUS_MODE3, | |
185 | ALC663_ASUS_MODE4, | |
186 | ALC663_ASUS_MODE5, | |
187 | ALC663_ASUS_MODE6, | |
bc9f98a9 KY |
188 | ALC662_AUTO, |
189 | ALC662_MODEL_LAST, | |
190 | }; | |
191 | ||
df694daa KY |
192 | /* ALC882 models */ |
193 | enum { | |
194 | ALC882_3ST_DIG, | |
195 | ALC882_6ST_DIG, | |
4b146cb0 | 196 | ALC882_ARIMA, |
bdd148a3 | 197 | ALC882_W2JC, |
272a527c KY |
198 | ALC882_TARGA, |
199 | ALC882_ASUS_A7J, | |
914759b7 | 200 | ALC882_ASUS_A7M, |
9102cd1c | 201 | ALC885_MACPRO, |
87350ad0 | 202 | ALC885_MBP3, |
c54728d8 | 203 | ALC885_IMAC24, |
272a527c | 204 | ALC882_AUTO, |
df694daa KY |
205 | ALC882_MODEL_LAST, |
206 | }; | |
207 | ||
9c7f852e TI |
208 | /* ALC883 models */ |
209 | enum { | |
210 | ALC883_3ST_2ch_DIG, | |
211 | ALC883_3ST_6ch_DIG, | |
212 | ALC883_3ST_6ch, | |
213 | ALC883_6ST_DIG, | |
ccc656ce KY |
214 | ALC883_TARGA_DIG, |
215 | ALC883_TARGA_2ch_DIG, | |
bab282b9 | 216 | ALC883_ACER, |
2880a867 | 217 | ALC883_ACER_ASPIRE, |
5b2d1eca | 218 | ALC888_ACER_ASPIRE_4930G, |
c07584c8 | 219 | ALC883_MEDION, |
ea1fb29a | 220 | ALC883_MEDION_MD2, |
b373bdeb | 221 | ALC883_LAPTOP_EAPD, |
bc9f98a9 | 222 | ALC883_LENOVO_101E_2ch, |
272a527c | 223 | ALC883_LENOVO_NB0763, |
189609ae | 224 | ALC888_LENOVO_MS7195_DIG, |
e2757d5e | 225 | ALC888_LENOVO_SKY, |
ea1fb29a | 226 | ALC883_HAIER_W66, |
4723c022 | 227 | ALC888_3ST_HP, |
5795b9e6 | 228 | ALC888_6ST_DELL, |
a8848bd6 | 229 | ALC883_MITAC, |
0c4cc443 | 230 | ALC883_CLEVO_M720, |
fb97dc67 | 231 | ALC883_FUJITSU_PI2515, |
ef8ef5fb | 232 | ALC888_FUJITSU_XA3530, |
17bba1b7 | 233 | ALC883_3ST_6ch_INTEL, |
e2757d5e KY |
234 | ALC888_ASUS_M90V, |
235 | ALC888_ASUS_EEE1601, | |
3ab90935 | 236 | ALC1200_ASUS_P5Q, |
9c7f852e TI |
237 | ALC883_AUTO, |
238 | ALC883_MODEL_LAST, | |
239 | }; | |
240 | ||
df694daa KY |
241 | /* for GPIO Poll */ |
242 | #define GPIO_MASK 0x03 | |
243 | ||
1da177e4 LT |
244 | struct alc_spec { |
245 | /* codec parameterization */ | |
df694daa | 246 | struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ |
1da177e4 | 247 | unsigned int num_mixers; |
f9e336f6 | 248 | struct snd_kcontrol_new *cap_mixer; /* capture mixer */ |
1da177e4 | 249 | |
df694daa | 250 | const struct hda_verb *init_verbs[5]; /* initialization verbs |
9c7f852e TI |
251 | * don't forget NULL |
252 | * termination! | |
e9edcee0 TI |
253 | */ |
254 | unsigned int num_init_verbs; | |
1da177e4 | 255 | |
16ded525 | 256 | char *stream_name_analog; /* analog PCM stream */ |
1da177e4 LT |
257 | struct hda_pcm_stream *stream_analog_playback; |
258 | struct hda_pcm_stream *stream_analog_capture; | |
6330079f TI |
259 | struct hda_pcm_stream *stream_analog_alt_playback; |
260 | struct hda_pcm_stream *stream_analog_alt_capture; | |
1da177e4 | 261 | |
f12ab1e0 | 262 | char *stream_name_digital; /* digital PCM stream */ |
1da177e4 LT |
263 | struct hda_pcm_stream *stream_digital_playback; |
264 | struct hda_pcm_stream *stream_digital_capture; | |
265 | ||
266 | /* playback */ | |
16ded525 TI |
267 | struct hda_multi_out multiout; /* playback set-up |
268 | * max_channels, dacs must be set | |
269 | * dig_out_nid and hp_nid are optional | |
270 | */ | |
6330079f | 271 | hda_nid_t alt_dac_nid; |
1da177e4 LT |
272 | |
273 | /* capture */ | |
274 | unsigned int num_adc_nids; | |
275 | hda_nid_t *adc_nids; | |
e1406348 | 276 | hda_nid_t *capsrc_nids; |
16ded525 | 277 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
54cbc9ab | 278 | unsigned char is_mix_capture; /* matrix-style capture (non-mux) */ |
1da177e4 LT |
279 | |
280 | /* capture source */ | |
a1e8d2da | 281 | unsigned int num_mux_defs; |
1da177e4 LT |
282 | const struct hda_input_mux *input_mux; |
283 | unsigned int cur_mux[3]; | |
284 | ||
285 | /* channel model */ | |
d2a6d7dc | 286 | const struct hda_channel_mode *channel_mode; |
1da177e4 | 287 | int num_channel_mode; |
4e195a7b | 288 | int need_dac_fix; |
1da177e4 LT |
289 | |
290 | /* PCM information */ | |
4c5186ed | 291 | struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ |
41e41f1f | 292 | |
e9edcee0 TI |
293 | /* dynamic controls, init_verbs and input_mux */ |
294 | struct auto_pin_cfg autocfg; | |
603c4019 | 295 | struct snd_array kctls; |
e9edcee0 | 296 | struct hda_input_mux private_imux; |
41923e44 | 297 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
834be88d | 298 | |
ae6b813a TI |
299 | /* hooks */ |
300 | void (*init_hook)(struct hda_codec *codec); | |
301 | void (*unsol_event)(struct hda_codec *codec, unsigned int res); | |
302 | ||
834be88d TI |
303 | /* for pin sensing */ |
304 | unsigned int sense_updated: 1; | |
305 | unsigned int jack_present: 1; | |
bec15c3a | 306 | unsigned int master_sw: 1; |
cb53c626 | 307 | |
2134ea4f TI |
308 | /* for virtual master */ |
309 | hda_nid_t vmaster_nid; | |
cb53c626 TI |
310 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
311 | struct hda_loopback_check loopback; | |
312 | #endif | |
2c3bf9ab TI |
313 | |
314 | /* for PLL fix */ | |
315 | hda_nid_t pll_nid; | |
316 | unsigned int pll_coef_idx, pll_coef_bit; | |
e044c39a TI |
317 | |
318 | #ifdef SND_HDA_NEEDS_RESUME | |
319 | #define ALC_MAX_PINS 16 | |
320 | unsigned int num_pins; | |
321 | hda_nid_t pin_nids[ALC_MAX_PINS]; | |
322 | unsigned int pin_cfgs[ALC_MAX_PINS]; | |
323 | #endif | |
df694daa KY |
324 | }; |
325 | ||
326 | /* | |
327 | * configuration template - to be copied to the spec instance | |
328 | */ | |
329 | struct alc_config_preset { | |
9c7f852e TI |
330 | struct snd_kcontrol_new *mixers[5]; /* should be identical size |
331 | * with spec | |
332 | */ | |
f9e336f6 | 333 | struct snd_kcontrol_new *cap_mixer; /* capture mixer */ |
df694daa KY |
334 | const struct hda_verb *init_verbs[5]; |
335 | unsigned int num_dacs; | |
336 | hda_nid_t *dac_nids; | |
337 | hda_nid_t dig_out_nid; /* optional */ | |
338 | hda_nid_t hp_nid; /* optional */ | |
339 | unsigned int num_adc_nids; | |
340 | hda_nid_t *adc_nids; | |
e1406348 | 341 | hda_nid_t *capsrc_nids; |
df694daa KY |
342 | hda_nid_t dig_in_nid; |
343 | unsigned int num_channel_mode; | |
344 | const struct hda_channel_mode *channel_mode; | |
4e195a7b | 345 | int need_dac_fix; |
a1e8d2da | 346 | unsigned int num_mux_defs; |
df694daa | 347 | const struct hda_input_mux *input_mux; |
ae6b813a TI |
348 | void (*unsol_event)(struct hda_codec *, unsigned int); |
349 | void (*init_hook)(struct hda_codec *); | |
cb53c626 TI |
350 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
351 | struct hda_amp_list *loopbacks; | |
352 | #endif | |
1da177e4 LT |
353 | }; |
354 | ||
1da177e4 LT |
355 | |
356 | /* | |
357 | * input MUX handling | |
358 | */ | |
9c7f852e TI |
359 | static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, |
360 | struct snd_ctl_elem_info *uinfo) | |
1da177e4 LT |
361 | { |
362 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
363 | struct alc_spec *spec = codec->spec; | |
a1e8d2da JW |
364 | unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id); |
365 | if (mux_idx >= spec->num_mux_defs) | |
366 | mux_idx = 0; | |
367 | return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo); | |
1da177e4 LT |
368 | } |
369 | ||
9c7f852e TI |
370 | static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, |
371 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
372 | { |
373 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
374 | struct alc_spec *spec = codec->spec; | |
375 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
376 | ||
377 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; | |
378 | return 0; | |
379 | } | |
380 | ||
9c7f852e TI |
381 | static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, |
382 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
383 | { |
384 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
385 | struct alc_spec *spec = codec->spec; | |
cd896c33 | 386 | const struct hda_input_mux *imux; |
1da177e4 | 387 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
cd896c33 | 388 | unsigned int mux_idx; |
e1406348 TI |
389 | hda_nid_t nid = spec->capsrc_nids ? |
390 | spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx]; | |
1da177e4 | 391 | |
cd896c33 TI |
392 | mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; |
393 | imux = &spec->input_mux[mux_idx]; | |
394 | ||
54cbc9ab TI |
395 | if (spec->is_mix_capture) { |
396 | /* Matrix-mixer style (e.g. ALC882) */ | |
397 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; | |
398 | unsigned int i, idx; | |
399 | ||
400 | idx = ucontrol->value.enumerated.item[0]; | |
401 | if (idx >= imux->num_items) | |
402 | idx = imux->num_items - 1; | |
403 | if (*cur_val == idx) | |
404 | return 0; | |
405 | for (i = 0; i < imux->num_items; i++) { | |
406 | unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE; | |
407 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, | |
408 | imux->items[i].index, | |
409 | HDA_AMP_MUTE, v); | |
410 | } | |
411 | *cur_val = idx; | |
412 | return 1; | |
413 | } else { | |
414 | /* MUX style (e.g. ALC880) */ | |
cd896c33 | 415 | return snd_hda_input_mux_put(codec, imux, ucontrol, nid, |
54cbc9ab TI |
416 | &spec->cur_mux[adc_idx]); |
417 | } | |
418 | } | |
e9edcee0 | 419 | |
1da177e4 LT |
420 | /* |
421 | * channel mode setting | |
422 | */ | |
9c7f852e TI |
423 | static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, |
424 | struct snd_ctl_elem_info *uinfo) | |
1da177e4 LT |
425 | { |
426 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
427 | struct alc_spec *spec = codec->spec; | |
d2a6d7dc TI |
428 | return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, |
429 | spec->num_channel_mode); | |
1da177e4 LT |
430 | } |
431 | ||
9c7f852e TI |
432 | static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, |
433 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
434 | { |
435 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
436 | struct alc_spec *spec = codec->spec; | |
d2a6d7dc | 437 | return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, |
9c7f852e TI |
438 | spec->num_channel_mode, |
439 | spec->multiout.max_channels); | |
1da177e4 LT |
440 | } |
441 | ||
9c7f852e TI |
442 | static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, |
443 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
444 | { |
445 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
446 | struct alc_spec *spec = codec->spec; | |
4e195a7b TI |
447 | int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, |
448 | spec->num_channel_mode, | |
449 | &spec->multiout.max_channels); | |
bd2033f2 | 450 | if (err >= 0 && spec->need_dac_fix) |
4e195a7b TI |
451 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; |
452 | return err; | |
1da177e4 LT |
453 | } |
454 | ||
a9430dd8 | 455 | /* |
4c5186ed | 456 | * Control the mode of pin widget settings via the mixer. "pc" is used |
ea1fb29a | 457 | * instead of "%" to avoid consequences of accidently treating the % as |
4c5186ed JW |
458 | * being part of a format specifier. Maximum allowed length of a value is |
459 | * 63 characters plus NULL terminator. | |
7cf51e48 JW |
460 | * |
461 | * Note: some retasking pin complexes seem to ignore requests for input | |
462 | * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these | |
463 | * are requested. Therefore order this list so that this behaviour will not | |
464 | * cause problems when mixer clients move through the enum sequentially. | |
a1e8d2da JW |
465 | * NIDs 0x0f and 0x10 have been observed to have this behaviour as of |
466 | * March 2006. | |
4c5186ed JW |
467 | */ |
468 | static char *alc_pin_mode_names[] = { | |
7cf51e48 JW |
469 | "Mic 50pc bias", "Mic 80pc bias", |
470 | "Line in", "Line out", "Headphone out", | |
4c5186ed JW |
471 | }; |
472 | static unsigned char alc_pin_mode_values[] = { | |
7cf51e48 | 473 | PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP, |
4c5186ed JW |
474 | }; |
475 | /* The control can present all 5 options, or it can limit the options based | |
a1e8d2da JW |
476 | * in the pin being assumed to be exclusively an input or an output pin. In |
477 | * addition, "input" pins may or may not process the mic bias option | |
478 | * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to | |
479 | * accept requests for bias as of chip versions up to March 2006) and/or | |
480 | * wiring in the computer. | |
a9430dd8 | 481 | */ |
a1e8d2da JW |
482 | #define ALC_PIN_DIR_IN 0x00 |
483 | #define ALC_PIN_DIR_OUT 0x01 | |
484 | #define ALC_PIN_DIR_INOUT 0x02 | |
485 | #define ALC_PIN_DIR_IN_NOMICBIAS 0x03 | |
486 | #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04 | |
4c5186ed | 487 | |
ea1fb29a | 488 | /* Info about the pin modes supported by the different pin direction modes. |
4c5186ed JW |
489 | * For each direction the minimum and maximum values are given. |
490 | */ | |
a1e8d2da | 491 | static signed char alc_pin_mode_dir_info[5][2] = { |
4c5186ed JW |
492 | { 0, 2 }, /* ALC_PIN_DIR_IN */ |
493 | { 3, 4 }, /* ALC_PIN_DIR_OUT */ | |
494 | { 0, 4 }, /* ALC_PIN_DIR_INOUT */ | |
a1e8d2da JW |
495 | { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */ |
496 | { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */ | |
4c5186ed JW |
497 | }; |
498 | #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0]) | |
499 | #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1]) | |
500 | #define alc_pin_mode_n_items(_dir) \ | |
501 | (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1) | |
502 | ||
9c7f852e TI |
503 | static int alc_pin_mode_info(struct snd_kcontrol *kcontrol, |
504 | struct snd_ctl_elem_info *uinfo) | |
a9430dd8 | 505 | { |
4c5186ed JW |
506 | unsigned int item_num = uinfo->value.enumerated.item; |
507 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; | |
508 | ||
509 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
a9430dd8 | 510 | uinfo->count = 1; |
4c5186ed JW |
511 | uinfo->value.enumerated.items = alc_pin_mode_n_items(dir); |
512 | ||
513 | if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir)) | |
514 | item_num = alc_pin_mode_min(dir); | |
515 | strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]); | |
a9430dd8 JW |
516 | return 0; |
517 | } | |
518 | ||
9c7f852e TI |
519 | static int alc_pin_mode_get(struct snd_kcontrol *kcontrol, |
520 | struct snd_ctl_elem_value *ucontrol) | |
a9430dd8 | 521 | { |
4c5186ed | 522 | unsigned int i; |
a9430dd8 JW |
523 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
524 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
4c5186ed | 525 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
a9430dd8 | 526 | long *valp = ucontrol->value.integer.value; |
9c7f852e TI |
527 | unsigned int pinctl = snd_hda_codec_read(codec, nid, 0, |
528 | AC_VERB_GET_PIN_WIDGET_CONTROL, | |
529 | 0x00); | |
a9430dd8 | 530 | |
4c5186ed JW |
531 | /* Find enumerated value for current pinctl setting */ |
532 | i = alc_pin_mode_min(dir); | |
9c7f852e | 533 | while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir)) |
4c5186ed | 534 | i++; |
9c7f852e | 535 | *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir); |
a9430dd8 JW |
536 | return 0; |
537 | } | |
538 | ||
9c7f852e TI |
539 | static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, |
540 | struct snd_ctl_elem_value *ucontrol) | |
a9430dd8 | 541 | { |
4c5186ed | 542 | signed int change; |
a9430dd8 JW |
543 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
544 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
4c5186ed JW |
545 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
546 | long val = *ucontrol->value.integer.value; | |
9c7f852e TI |
547 | unsigned int pinctl = snd_hda_codec_read(codec, nid, 0, |
548 | AC_VERB_GET_PIN_WIDGET_CONTROL, | |
549 | 0x00); | |
a9430dd8 | 550 | |
f12ab1e0 | 551 | if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir)) |
4c5186ed JW |
552 | val = alc_pin_mode_min(dir); |
553 | ||
554 | change = pinctl != alc_pin_mode_values[val]; | |
cdcd9268 JW |
555 | if (change) { |
556 | /* Set pin mode to that requested */ | |
82beb8fd TI |
557 | snd_hda_codec_write_cache(codec, nid, 0, |
558 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
559 | alc_pin_mode_values[val]); | |
cdcd9268 | 560 | |
ea1fb29a | 561 | /* Also enable the retasking pin's input/output as required |
cdcd9268 JW |
562 | * for the requested pin mode. Enum values of 2 or less are |
563 | * input modes. | |
564 | * | |
565 | * Dynamically switching the input/output buffers probably | |
a1e8d2da JW |
566 | * reduces noise slightly (particularly on input) so we'll |
567 | * do it. However, having both input and output buffers | |
568 | * enabled simultaneously doesn't seem to be problematic if | |
569 | * this turns out to be necessary in the future. | |
cdcd9268 JW |
570 | */ |
571 | if (val <= 2) { | |
47fd830a TI |
572 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
573 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
574 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0, | |
575 | HDA_AMP_MUTE, 0); | |
cdcd9268 | 576 | } else { |
47fd830a TI |
577 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0, |
578 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
579 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, | |
580 | HDA_AMP_MUTE, 0); | |
cdcd9268 JW |
581 | } |
582 | } | |
a9430dd8 JW |
583 | return change; |
584 | } | |
585 | ||
4c5186ed | 586 | #define ALC_PIN_MODE(xname, nid, dir) \ |
a9430dd8 | 587 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ |
4c5186ed JW |
588 | .info = alc_pin_mode_info, \ |
589 | .get = alc_pin_mode_get, \ | |
590 | .put = alc_pin_mode_put, \ | |
591 | .private_value = nid | (dir<<16) } | |
df694daa | 592 | |
5c8f858d JW |
593 | /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged |
594 | * together using a mask with more than one bit set. This control is | |
595 | * currently used only by the ALC260 test model. At this stage they are not | |
596 | * needed for any "production" models. | |
597 | */ | |
598 | #ifdef CONFIG_SND_DEBUG | |
a5ce8890 | 599 | #define alc_gpio_data_info snd_ctl_boolean_mono_info |
f12ab1e0 | 600 | |
9c7f852e TI |
601 | static int alc_gpio_data_get(struct snd_kcontrol *kcontrol, |
602 | struct snd_ctl_elem_value *ucontrol) | |
5c8f858d JW |
603 | { |
604 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
605 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
606 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
607 | long *valp = ucontrol->value.integer.value; | |
9c7f852e TI |
608 | unsigned int val = snd_hda_codec_read(codec, nid, 0, |
609 | AC_VERB_GET_GPIO_DATA, 0x00); | |
5c8f858d JW |
610 | |
611 | *valp = (val & mask) != 0; | |
612 | return 0; | |
613 | } | |
9c7f852e TI |
614 | static int alc_gpio_data_put(struct snd_kcontrol *kcontrol, |
615 | struct snd_ctl_elem_value *ucontrol) | |
5c8f858d JW |
616 | { |
617 | signed int change; | |
618 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
619 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
620 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
621 | long val = *ucontrol->value.integer.value; | |
9c7f852e TI |
622 | unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0, |
623 | AC_VERB_GET_GPIO_DATA, | |
624 | 0x00); | |
5c8f858d JW |
625 | |
626 | /* Set/unset the masked GPIO bit(s) as needed */ | |
9c7f852e TI |
627 | change = (val == 0 ? 0 : mask) != (gpio_data & mask); |
628 | if (val == 0) | |
5c8f858d JW |
629 | gpio_data &= ~mask; |
630 | else | |
631 | gpio_data |= mask; | |
82beb8fd TI |
632 | snd_hda_codec_write_cache(codec, nid, 0, |
633 | AC_VERB_SET_GPIO_DATA, gpio_data); | |
5c8f858d JW |
634 | |
635 | return change; | |
636 | } | |
637 | #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \ | |
638 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
639 | .info = alc_gpio_data_info, \ | |
640 | .get = alc_gpio_data_get, \ | |
641 | .put = alc_gpio_data_put, \ | |
642 | .private_value = nid | (mask<<16) } | |
643 | #endif /* CONFIG_SND_DEBUG */ | |
644 | ||
92621f13 JW |
645 | /* A switch control to allow the enabling of the digital IO pins on the |
646 | * ALC260. This is incredibly simplistic; the intention of this control is | |
647 | * to provide something in the test model allowing digital outputs to be | |
648 | * identified if present. If models are found which can utilise these | |
649 | * outputs a more complete mixer control can be devised for those models if | |
650 | * necessary. | |
651 | */ | |
652 | #ifdef CONFIG_SND_DEBUG | |
a5ce8890 | 653 | #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info |
f12ab1e0 | 654 | |
9c7f852e TI |
655 | static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol, |
656 | struct snd_ctl_elem_value *ucontrol) | |
92621f13 JW |
657 | { |
658 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
659 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
660 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
661 | long *valp = ucontrol->value.integer.value; | |
9c7f852e | 662 | unsigned int val = snd_hda_codec_read(codec, nid, 0, |
3982d17e | 663 | AC_VERB_GET_DIGI_CONVERT_1, 0x00); |
92621f13 JW |
664 | |
665 | *valp = (val & mask) != 0; | |
666 | return 0; | |
667 | } | |
9c7f852e TI |
668 | static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol, |
669 | struct snd_ctl_elem_value *ucontrol) | |
92621f13 JW |
670 | { |
671 | signed int change; | |
672 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
673 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
674 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
675 | long val = *ucontrol->value.integer.value; | |
9c7f852e | 676 | unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0, |
3982d17e | 677 | AC_VERB_GET_DIGI_CONVERT_1, |
9c7f852e | 678 | 0x00); |
92621f13 JW |
679 | |
680 | /* Set/unset the masked control bit(s) as needed */ | |
9c7f852e | 681 | change = (val == 0 ? 0 : mask) != (ctrl_data & mask); |
92621f13 JW |
682 | if (val==0) |
683 | ctrl_data &= ~mask; | |
684 | else | |
685 | ctrl_data |= mask; | |
82beb8fd TI |
686 | snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, |
687 | ctrl_data); | |
92621f13 JW |
688 | |
689 | return change; | |
690 | } | |
691 | #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \ | |
692 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
693 | .info = alc_spdif_ctrl_info, \ | |
694 | .get = alc_spdif_ctrl_get, \ | |
695 | .put = alc_spdif_ctrl_put, \ | |
696 | .private_value = nid | (mask<<16) } | |
697 | #endif /* CONFIG_SND_DEBUG */ | |
698 | ||
f8225f6d JW |
699 | /* A switch control to allow the enabling EAPD digital outputs on the ALC26x. |
700 | * Again, this is only used in the ALC26x test models to help identify when | |
701 | * the EAPD line must be asserted for features to work. | |
702 | */ | |
703 | #ifdef CONFIG_SND_DEBUG | |
704 | #define alc_eapd_ctrl_info snd_ctl_boolean_mono_info | |
705 | ||
706 | static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol, | |
707 | struct snd_ctl_elem_value *ucontrol) | |
708 | { | |
709 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
710 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
711 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
712 | long *valp = ucontrol->value.integer.value; | |
713 | unsigned int val = snd_hda_codec_read(codec, nid, 0, | |
714 | AC_VERB_GET_EAPD_BTLENABLE, 0x00); | |
715 | ||
716 | *valp = (val & mask) != 0; | |
717 | return 0; | |
718 | } | |
719 | ||
720 | static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol, | |
721 | struct snd_ctl_elem_value *ucontrol) | |
722 | { | |
723 | int change; | |
724 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
725 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
726 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
727 | long val = *ucontrol->value.integer.value; | |
728 | unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0, | |
729 | AC_VERB_GET_EAPD_BTLENABLE, | |
730 | 0x00); | |
731 | ||
732 | /* Set/unset the masked control bit(s) as needed */ | |
733 | change = (!val ? 0 : mask) != (ctrl_data & mask); | |
734 | if (!val) | |
735 | ctrl_data &= ~mask; | |
736 | else | |
737 | ctrl_data |= mask; | |
738 | snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, | |
739 | ctrl_data); | |
740 | ||
741 | return change; | |
742 | } | |
743 | ||
744 | #define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \ | |
745 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
746 | .info = alc_eapd_ctrl_info, \ | |
747 | .get = alc_eapd_ctrl_get, \ | |
748 | .put = alc_eapd_ctrl_put, \ | |
749 | .private_value = nid | (mask<<16) } | |
750 | #endif /* CONFIG_SND_DEBUG */ | |
751 | ||
d88897ea TI |
752 | /* |
753 | */ | |
754 | static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix) | |
755 | { | |
756 | if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers))) | |
757 | return; | |
758 | spec->mixers[spec->num_mixers++] = mix; | |
759 | } | |
760 | ||
761 | static void add_verb(struct alc_spec *spec, const struct hda_verb *verb) | |
762 | { | |
763 | if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs))) | |
764 | return; | |
765 | spec->init_verbs[spec->num_init_verbs++] = verb; | |
766 | } | |
767 | ||
daead538 TI |
768 | #ifdef CONFIG_PROC_FS |
769 | /* | |
770 | * hook for proc | |
771 | */ | |
772 | static void print_realtek_coef(struct snd_info_buffer *buffer, | |
773 | struct hda_codec *codec, hda_nid_t nid) | |
774 | { | |
775 | int coeff; | |
776 | ||
777 | if (nid != 0x20) | |
778 | return; | |
779 | coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0); | |
780 | snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff); | |
781 | coeff = snd_hda_codec_read(codec, nid, 0, | |
782 | AC_VERB_GET_COEF_INDEX, 0); | |
783 | snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff); | |
784 | } | |
785 | #else | |
786 | #define print_realtek_coef NULL | |
787 | #endif | |
788 | ||
df694daa KY |
789 | /* |
790 | * set up from the preset table | |
791 | */ | |
9c7f852e TI |
792 | static void setup_preset(struct alc_spec *spec, |
793 | const struct alc_config_preset *preset) | |
df694daa KY |
794 | { |
795 | int i; | |
796 | ||
797 | for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++) | |
d88897ea | 798 | add_mixer(spec, preset->mixers[i]); |
f9e336f6 | 799 | spec->cap_mixer = preset->cap_mixer; |
9c7f852e TI |
800 | for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; |
801 | i++) | |
d88897ea | 802 | add_verb(spec, preset->init_verbs[i]); |
ea1fb29a | 803 | |
df694daa KY |
804 | spec->channel_mode = preset->channel_mode; |
805 | spec->num_channel_mode = preset->num_channel_mode; | |
4e195a7b | 806 | spec->need_dac_fix = preset->need_dac_fix; |
df694daa KY |
807 | |
808 | spec->multiout.max_channels = spec->channel_mode[0].channels; | |
809 | ||
810 | spec->multiout.num_dacs = preset->num_dacs; | |
811 | spec->multiout.dac_nids = preset->dac_nids; | |
812 | spec->multiout.dig_out_nid = preset->dig_out_nid; | |
813 | spec->multiout.hp_nid = preset->hp_nid; | |
ea1fb29a | 814 | |
a1e8d2da | 815 | spec->num_mux_defs = preset->num_mux_defs; |
f12ab1e0 | 816 | if (!spec->num_mux_defs) |
a1e8d2da | 817 | spec->num_mux_defs = 1; |
df694daa KY |
818 | spec->input_mux = preset->input_mux; |
819 | ||
820 | spec->num_adc_nids = preset->num_adc_nids; | |
821 | spec->adc_nids = preset->adc_nids; | |
e1406348 | 822 | spec->capsrc_nids = preset->capsrc_nids; |
df694daa | 823 | spec->dig_in_nid = preset->dig_in_nid; |
ae6b813a TI |
824 | |
825 | spec->unsol_event = preset->unsol_event; | |
826 | spec->init_hook = preset->init_hook; | |
cb53c626 TI |
827 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
828 | spec->loopback.amplist = preset->loopbacks; | |
829 | #endif | |
df694daa KY |
830 | } |
831 | ||
bc9f98a9 KY |
832 | /* Enable GPIO mask and set output */ |
833 | static struct hda_verb alc_gpio1_init_verbs[] = { | |
834 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
835 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
836 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, | |
837 | { } | |
838 | }; | |
839 | ||
840 | static struct hda_verb alc_gpio2_init_verbs[] = { | |
841 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, | |
842 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, | |
843 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, | |
844 | { } | |
845 | }; | |
846 | ||
bdd148a3 KY |
847 | static struct hda_verb alc_gpio3_init_verbs[] = { |
848 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, | |
849 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | |
850 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | |
851 | { } | |
852 | }; | |
853 | ||
2c3bf9ab TI |
854 | /* |
855 | * Fix hardware PLL issue | |
856 | * On some codecs, the analog PLL gating control must be off while | |
857 | * the default value is 1. | |
858 | */ | |
859 | static void alc_fix_pll(struct hda_codec *codec) | |
860 | { | |
861 | struct alc_spec *spec = codec->spec; | |
862 | unsigned int val; | |
863 | ||
864 | if (!spec->pll_nid) | |
865 | return; | |
866 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, | |
867 | spec->pll_coef_idx); | |
868 | val = snd_hda_codec_read(codec, spec->pll_nid, 0, | |
869 | AC_VERB_GET_PROC_COEF, 0); | |
870 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, | |
871 | spec->pll_coef_idx); | |
872 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF, | |
873 | val & ~(1 << spec->pll_coef_bit)); | |
874 | } | |
875 | ||
876 | static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, | |
877 | unsigned int coef_idx, unsigned int coef_bit) | |
878 | { | |
879 | struct alc_spec *spec = codec->spec; | |
880 | spec->pll_nid = nid; | |
881 | spec->pll_coef_idx = coef_idx; | |
882 | spec->pll_coef_bit = coef_bit; | |
883 | alc_fix_pll(codec); | |
884 | } | |
885 | ||
c9b58006 KY |
886 | static void alc_sku_automute(struct hda_codec *codec) |
887 | { | |
888 | struct alc_spec *spec = codec->spec; | |
c9b58006 KY |
889 | unsigned int present; |
890 | unsigned int hp_nid = spec->autocfg.hp_pins[0]; | |
891 | unsigned int sp_nid = spec->autocfg.speaker_pins[0]; | |
892 | ||
893 | /* need to execute and sync at first */ | |
894 | snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0); | |
895 | present = snd_hda_codec_read(codec, hp_nid, 0, | |
896 | AC_VERB_GET_PIN_SENSE, 0); | |
897 | spec->jack_present = (present & 0x80000000) != 0; | |
f6c7e546 TI |
898 | snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
899 | spec->jack_present ? 0 : PIN_OUT); | |
c9b58006 KY |
900 | } |
901 | ||
4605b718 | 902 | #if 0 /* it's broken in some acses -- temporarily disabled */ |
7fb0d78f KY |
903 | static void alc_mic_automute(struct hda_codec *codec) |
904 | { | |
905 | struct alc_spec *spec = codec->spec; | |
906 | unsigned int present; | |
907 | unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC]; | |
908 | unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]; | |
909 | unsigned int mix_nid = spec->capsrc_nids[0]; | |
910 | unsigned int capsrc_idx_mic, capsrc_idx_fmic; | |
911 | ||
912 | capsrc_idx_mic = mic_nid - 0x18; | |
913 | capsrc_idx_fmic = fmic_nid - 0x18; | |
914 | present = snd_hda_codec_read(codec, mic_nid, 0, | |
915 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
916 | snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
917 | 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80)); | |
918 | snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
919 | 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0)); | |
920 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic, | |
921 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
922 | } | |
4605b718 TI |
923 | #else |
924 | #define alc_mic_automute(codec) /* NOP */ | |
925 | #endif /* disabled */ | |
7fb0d78f | 926 | |
c9b58006 KY |
927 | /* unsolicited event for HP jack sensing */ |
928 | static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) | |
929 | { | |
930 | if (codec->vendor_id == 0x10ec0880) | |
931 | res >>= 28; | |
932 | else | |
933 | res >>= 26; | |
7fb0d78f KY |
934 | if (res == ALC880_HP_EVENT) |
935 | alc_sku_automute(codec); | |
c9b58006 | 936 | |
7fb0d78f KY |
937 | if (res == ALC880_MIC_EVENT) |
938 | alc_mic_automute(codec); | |
939 | } | |
940 | ||
941 | static void alc_inithook(struct hda_codec *codec) | |
942 | { | |
c9b58006 | 943 | alc_sku_automute(codec); |
7fb0d78f | 944 | alc_mic_automute(codec); |
c9b58006 KY |
945 | } |
946 | ||
f9423e7a KY |
947 | /* additional initialization for ALC888 variants */ |
948 | static void alc888_coef_init(struct hda_codec *codec) | |
949 | { | |
950 | unsigned int tmp; | |
951 | ||
952 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0); | |
953 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); | |
954 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); | |
955 | if ((tmp & 0xf0) == 2) | |
956 | /* alc888S-VC */ | |
957 | snd_hda_codec_read(codec, 0x20, 0, | |
958 | AC_VERB_SET_PROC_COEF, 0x830); | |
959 | else | |
960 | /* alc888-VB */ | |
961 | snd_hda_codec_read(codec, 0x20, 0, | |
962 | AC_VERB_SET_PROC_COEF, 0x3030); | |
963 | } | |
964 | ||
bc9f98a9 KY |
965 | /* 32-bit subsystem ID for BIOS loading in HD Audio codec. |
966 | * 31 ~ 16 : Manufacture ID | |
967 | * 15 ~ 8 : SKU ID | |
968 | * 7 ~ 0 : Assembly ID | |
969 | * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36 | |
970 | */ | |
971 | static void alc_subsystem_id(struct hda_codec *codec, | |
972 | unsigned int porta, unsigned int porte, | |
973 | unsigned int portd) | |
974 | { | |
c9b58006 KY |
975 | unsigned int ass, tmp, i; |
976 | unsigned nid; | |
977 | struct alc_spec *spec = codec->spec; | |
bc9f98a9 | 978 | |
c9b58006 KY |
979 | ass = codec->subsystem_id & 0xffff; |
980 | if ((ass != codec->bus->pci->subsystem_device) && (ass & 1)) | |
981 | goto do_sku; | |
982 | ||
ea1fb29a | 983 | /* |
c9b58006 KY |
984 | * 31~30 : port conetcivity |
985 | * 29~21 : reserve | |
986 | * 20 : PCBEEP input | |
987 | * 19~16 : Check sum (15:1) | |
988 | * 15~1 : Custom | |
989 | * 0 : override | |
990 | */ | |
991 | nid = 0x1d; | |
992 | if (codec->vendor_id == 0x10ec0260) | |
993 | nid = 0x17; | |
994 | ass = snd_hda_codec_read(codec, nid, 0, | |
995 | AC_VERB_GET_CONFIG_DEFAULT, 0); | |
996 | if (!(ass & 1) && !(ass & 0x100000)) | |
997 | return; | |
998 | if ((ass >> 30) != 1) /* no physical connection */ | |
bc9f98a9 KY |
999 | return; |
1000 | ||
c9b58006 KY |
1001 | /* check sum */ |
1002 | tmp = 0; | |
1003 | for (i = 1; i < 16; i++) { | |
8c427226 | 1004 | if ((ass >> i) & 1) |
c9b58006 KY |
1005 | tmp++; |
1006 | } | |
1007 | if (((ass >> 16) & 0xf) != tmp) | |
1008 | return; | |
1009 | do_sku: | |
1010 | /* | |
1011 | * 0 : override | |
1012 | * 1 : Swap Jack | |
1013 | * 2 : 0 --> Desktop, 1 --> Laptop | |
1014 | * 3~5 : External Amplifier control | |
1015 | * 7~6 : Reserved | |
1016 | */ | |
bc9f98a9 KY |
1017 | tmp = (ass & 0x38) >> 3; /* external Amp control */ |
1018 | switch (tmp) { | |
1019 | case 1: | |
1020 | snd_hda_sequence_write(codec, alc_gpio1_init_verbs); | |
1021 | break; | |
1022 | case 3: | |
1023 | snd_hda_sequence_write(codec, alc_gpio2_init_verbs); | |
1024 | break; | |
bdd148a3 KY |
1025 | case 7: |
1026 | snd_hda_sequence_write(codec, alc_gpio3_init_verbs); | |
1027 | break; | |
c9b58006 | 1028 | case 5: /* set EAPD output high */ |
bdd148a3 | 1029 | switch (codec->vendor_id) { |
c9b58006 KY |
1030 | case 0x10ec0260: |
1031 | snd_hda_codec_write(codec, 0x0f, 0, | |
1032 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
1033 | snd_hda_codec_write(codec, 0x10, 0, | |
1034 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
1035 | break; | |
1036 | case 0x10ec0262: | |
bdd148a3 KY |
1037 | case 0x10ec0267: |
1038 | case 0x10ec0268: | |
c9b58006 | 1039 | case 0x10ec0269: |
c6e8f2da | 1040 | case 0x10ec0272: |
f9423e7a KY |
1041 | case 0x10ec0660: |
1042 | case 0x10ec0662: | |
1043 | case 0x10ec0663: | |
c9b58006 | 1044 | case 0x10ec0862: |
20a3a05d | 1045 | case 0x10ec0889: |
bdd148a3 KY |
1046 | snd_hda_codec_write(codec, 0x14, 0, |
1047 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
1048 | snd_hda_codec_write(codec, 0x15, 0, | |
1049 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
c9b58006 | 1050 | break; |
bdd148a3 | 1051 | } |
c9b58006 KY |
1052 | switch (codec->vendor_id) { |
1053 | case 0x10ec0260: | |
1054 | snd_hda_codec_write(codec, 0x1a, 0, | |
1055 | AC_VERB_SET_COEF_INDEX, 7); | |
1056 | tmp = snd_hda_codec_read(codec, 0x1a, 0, | |
1057 | AC_VERB_GET_PROC_COEF, 0); | |
1058 | snd_hda_codec_write(codec, 0x1a, 0, | |
1059 | AC_VERB_SET_COEF_INDEX, 7); | |
1060 | snd_hda_codec_write(codec, 0x1a, 0, | |
1061 | AC_VERB_SET_PROC_COEF, | |
1062 | tmp | 0x2010); | |
1063 | break; | |
1064 | case 0x10ec0262: | |
1065 | case 0x10ec0880: | |
1066 | case 0x10ec0882: | |
1067 | case 0x10ec0883: | |
1068 | case 0x10ec0885: | |
20a3a05d | 1069 | case 0x10ec0889: |
c9b58006 KY |
1070 | snd_hda_codec_write(codec, 0x20, 0, |
1071 | AC_VERB_SET_COEF_INDEX, 7); | |
1072 | tmp = snd_hda_codec_read(codec, 0x20, 0, | |
1073 | AC_VERB_GET_PROC_COEF, 0); | |
1074 | snd_hda_codec_write(codec, 0x20, 0, | |
ea1fb29a | 1075 | AC_VERB_SET_COEF_INDEX, 7); |
c9b58006 KY |
1076 | snd_hda_codec_write(codec, 0x20, 0, |
1077 | AC_VERB_SET_PROC_COEF, | |
1078 | tmp | 0x2010); | |
1079 | break; | |
f9423e7a | 1080 | case 0x10ec0888: |
1082c748 | 1081 | /*alc888_coef_init(codec);*/ /* called in alc_init() */ |
f9423e7a | 1082 | break; |
c9b58006 KY |
1083 | case 0x10ec0267: |
1084 | case 0x10ec0268: | |
1085 | snd_hda_codec_write(codec, 0x20, 0, | |
1086 | AC_VERB_SET_COEF_INDEX, 7); | |
1087 | tmp = snd_hda_codec_read(codec, 0x20, 0, | |
1088 | AC_VERB_GET_PROC_COEF, 0); | |
1089 | snd_hda_codec_write(codec, 0x20, 0, | |
ea1fb29a | 1090 | AC_VERB_SET_COEF_INDEX, 7); |
c9b58006 KY |
1091 | snd_hda_codec_write(codec, 0x20, 0, |
1092 | AC_VERB_SET_PROC_COEF, | |
1093 | tmp | 0x3000); | |
1094 | break; | |
bc9f98a9 | 1095 | } |
c9b58006 | 1096 | default: |
bc9f98a9 KY |
1097 | break; |
1098 | } | |
ea1fb29a | 1099 | |
8c427226 | 1100 | /* is laptop or Desktop and enable the function "Mute internal speaker |
c9b58006 KY |
1101 | * when the external headphone out jack is plugged" |
1102 | */ | |
8c427226 | 1103 | if (!(ass & 0x8000)) |
c9b58006 KY |
1104 | return; |
1105 | /* | |
1106 | * 10~8 : Jack location | |
1107 | * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered | |
1108 | * 14~13: Resvered | |
1109 | * 15 : 1 --> enable the function "Mute internal speaker | |
1110 | * when the external headphone out jack is plugged" | |
1111 | */ | |
1112 | if (!spec->autocfg.speaker_pins[0]) { | |
8c427226 | 1113 | if (spec->autocfg.line_out_pins[0]) |
c9b58006 | 1114 | spec->autocfg.speaker_pins[0] = |
8c427226 | 1115 | spec->autocfg.line_out_pins[0]; |
c9b58006 KY |
1116 | else |
1117 | return; | |
1118 | } | |
1119 | ||
1120 | if (!spec->autocfg.hp_pins[0]) { | |
1121 | tmp = (ass >> 11) & 0x3; /* HP to chassis */ | |
1122 | if (tmp == 0) | |
1123 | spec->autocfg.hp_pins[0] = porta; | |
1124 | else if (tmp == 1) | |
1125 | spec->autocfg.hp_pins[0] = porte; | |
1126 | else if (tmp == 2) | |
1127 | spec->autocfg.hp_pins[0] = portd; | |
1128 | else | |
1129 | return; | |
1130 | } | |
7fb0d78f KY |
1131 | if (spec->autocfg.hp_pins[0]) |
1132 | snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0, | |
1133 | AC_VERB_SET_UNSOLICITED_ENABLE, | |
1134 | AC_USRSP_EN | ALC880_HP_EVENT); | |
c9b58006 | 1135 | |
4605b718 | 1136 | #if 0 /* it's broken in some acses -- temporarily disabled */ |
7fb0d78f KY |
1137 | if (spec->autocfg.input_pins[AUTO_PIN_MIC] && |
1138 | spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]) | |
1139 | snd_hda_codec_write(codec, | |
1140 | spec->autocfg.input_pins[AUTO_PIN_MIC], 0, | |
1141 | AC_VERB_SET_UNSOLICITED_ENABLE, | |
1142 | AC_USRSP_EN | ALC880_MIC_EVENT); | |
4605b718 | 1143 | #endif /* disabled */ |
ea1fb29a | 1144 | |
c9b58006 | 1145 | spec->unsol_event = alc_sku_unsol_event; |
bc9f98a9 KY |
1146 | } |
1147 | ||
f95474ec TI |
1148 | /* |
1149 | * Fix-up pin default configurations | |
1150 | */ | |
1151 | ||
1152 | struct alc_pincfg { | |
1153 | hda_nid_t nid; | |
1154 | u32 val; | |
1155 | }; | |
1156 | ||
1157 | static void alc_fix_pincfg(struct hda_codec *codec, | |
1158 | const struct snd_pci_quirk *quirk, | |
1159 | const struct alc_pincfg **pinfix) | |
1160 | { | |
1161 | const struct alc_pincfg *cfg; | |
1162 | ||
1163 | quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk); | |
1164 | if (!quirk) | |
1165 | return; | |
1166 | ||
1167 | cfg = pinfix[quirk->value]; | |
1168 | for (; cfg->nid; cfg++) { | |
1169 | int i; | |
1170 | u32 val = cfg->val; | |
1171 | for (i = 0; i < 4; i++) { | |
1172 | snd_hda_codec_write(codec, cfg->nid, 0, | |
1173 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i, | |
1174 | val & 0xff); | |
1175 | val >>= 8; | |
1176 | } | |
1177 | } | |
1178 | } | |
1179 | ||
ef8ef5fb VP |
1180 | /* |
1181 | * ALC888 | |
1182 | */ | |
1183 | ||
1184 | /* | |
1185 | * 2ch mode | |
1186 | */ | |
1187 | static struct hda_verb alc888_4ST_ch2_intel_init[] = { | |
1188 | /* Mic-in jack as mic in */ | |
1189 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
1190 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
1191 | /* Line-in jack as Line in */ | |
1192 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
1193 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
1194 | /* Line-Out as Front */ | |
1195 | { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1196 | { } /* end */ | |
1197 | }; | |
1198 | ||
1199 | /* | |
1200 | * 4ch mode | |
1201 | */ | |
1202 | static struct hda_verb alc888_4ST_ch4_intel_init[] = { | |
1203 | /* Mic-in jack as mic in */ | |
1204 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
1205 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
1206 | /* Line-in jack as Surround */ | |
1207 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1208 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1209 | /* Line-Out as Front */ | |
1210 | { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1211 | { } /* end */ | |
1212 | }; | |
1213 | ||
1214 | /* | |
1215 | * 6ch mode | |
1216 | */ | |
1217 | static struct hda_verb alc888_4ST_ch6_intel_init[] = { | |
1218 | /* Mic-in jack as CLFE */ | |
1219 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1220 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1221 | /* Line-in jack as Surround */ | |
1222 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1223 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1224 | /* Line-Out as CLFE (workaround because Mic-in is not loud enough) */ | |
1225 | { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
1226 | { } /* end */ | |
1227 | }; | |
1228 | ||
1229 | /* | |
1230 | * 8ch mode | |
1231 | */ | |
1232 | static struct hda_verb alc888_4ST_ch8_intel_init[] = { | |
1233 | /* Mic-in jack as CLFE */ | |
1234 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1235 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1236 | /* Line-in jack as Surround */ | |
1237 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1238 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1239 | /* Line-Out as Side */ | |
1240 | { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
1241 | { } /* end */ | |
1242 | }; | |
1243 | ||
1244 | static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = { | |
1245 | { 2, alc888_4ST_ch2_intel_init }, | |
1246 | { 4, alc888_4ST_ch4_intel_init }, | |
1247 | { 6, alc888_4ST_ch6_intel_init }, | |
1248 | { 8, alc888_4ST_ch8_intel_init }, | |
1249 | }; | |
1250 | ||
1251 | /* | |
1252 | * ALC888 Fujitsu Siemens Amillo xa3530 | |
1253 | */ | |
1254 | ||
1255 | static struct hda_verb alc888_fujitsu_xa3530_verbs[] = { | |
1256 | /* Front Mic: set to PIN_IN (empty by default) */ | |
1257 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1258 | /* Connect Internal HP to Front */ | |
1259 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1260 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1261 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1262 | /* Connect Bass HP to Front */ | |
1263 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1264 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1265 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1266 | /* Connect Line-Out side jack (SPDIF) to Side */ | |
1267 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1268 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1269 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
1270 | /* Connect Mic jack to CLFE */ | |
1271 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1272 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1273 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
1274 | /* Connect Line-in jack to Surround */ | |
1275 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1276 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1277 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
1278 | /* Connect HP out jack to Front */ | |
1279 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1280 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1281 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1282 | /* Enable unsolicited event for HP jack and Line-out jack */ | |
1283 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
1284 | {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
1285 | {} | |
1286 | }; | |
1287 | ||
1288 | static void alc888_fujitsu_xa3530_automute(struct hda_codec *codec) | |
1289 | { | |
1290 | unsigned int present; | |
1291 | unsigned int bits; | |
1292 | /* Line out presence */ | |
1293 | present = snd_hda_codec_read(codec, 0x17, 0, | |
1294 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
1295 | /* HP out presence */ | |
1296 | present = present || snd_hda_codec_read(codec, 0x1b, 0, | |
1297 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
1298 | bits = present ? HDA_AMP_MUTE : 0; | |
1299 | /* Toggle internal speakers muting */ | |
1300 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
1301 | HDA_AMP_MUTE, bits); | |
1302 | /* Toggle internal bass muting */ | |
1303 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
1304 | HDA_AMP_MUTE, bits); | |
1305 | } | |
1306 | ||
1307 | static void alc888_fujitsu_xa3530_unsol_event(struct hda_codec *codec, | |
1308 | unsigned int res) | |
1309 | { | |
1310 | if (res >> 26 == ALC880_HP_EVENT) | |
1311 | alc888_fujitsu_xa3530_automute(codec); | |
1312 | } | |
1313 | ||
1314 | ||
5b2d1eca VP |
1315 | /* |
1316 | * ALC888 Acer Aspire 4930G model | |
1317 | */ | |
1318 | ||
1319 | static struct hda_verb alc888_acer_aspire_4930g_verbs[] = { | |
1320 | /* Front Mic: set to PIN_IN (empty by default) */ | |
1321 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1322 | /* Unselect Front Mic by default in input mixer 3 */ | |
1323 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)}, | |
ef8ef5fb | 1324 | /* Enable unsolicited event for HP jack */ |
5b2d1eca VP |
1325 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
1326 | /* Connect Internal HP to front */ | |
1327 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1328 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1329 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1330 | /* Connect HP out to front */ | |
1331 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1332 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1333 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1334 | { } | |
1335 | }; | |
1336 | ||
ef8ef5fb | 1337 | static struct hda_input_mux alc888_2_capture_sources[2] = { |
5b2d1eca VP |
1338 | /* Front mic only available on one ADC */ |
1339 | { | |
1340 | .num_items = 4, | |
1341 | .items = { | |
1342 | { "Mic", 0x0 }, | |
1343 | { "Line", 0x2 }, | |
1344 | { "CD", 0x4 }, | |
1345 | { "Front Mic", 0xb }, | |
1346 | }, | |
1347 | }, | |
1348 | { | |
1349 | .num_items = 3, | |
1350 | .items = { | |
1351 | { "Mic", 0x0 }, | |
1352 | { "Line", 0x2 }, | |
1353 | { "CD", 0x4 }, | |
1354 | }, | |
1355 | } | |
1356 | }; | |
1357 | ||
ef8ef5fb | 1358 | static struct snd_kcontrol_new alc888_base_mixer[] = { |
5b2d1eca VP |
1359 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
1360 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
1361 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1362 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
1363 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, | |
1364 | HDA_OUTPUT), | |
1365 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
1366 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
1367 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
1368 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
1369 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
1370 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
1371 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1372 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1373 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
1374 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1375 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
1376 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1377 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
1378 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
1379 | { } /* end */ | |
1380 | }; | |
1381 | ||
1382 | static void alc888_acer_aspire_4930g_automute(struct hda_codec *codec) | |
1383 | { | |
1384 | unsigned int present; | |
ef8ef5fb | 1385 | unsigned int bits; |
5b2d1eca VP |
1386 | present = snd_hda_codec_read(codec, 0x15, 0, |
1387 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
ef8ef5fb VP |
1388 | bits = present ? HDA_AMP_MUTE : 0; |
1389 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
1390 | HDA_AMP_MUTE, bits); | |
5b2d1eca VP |
1391 | } |
1392 | ||
1393 | static void alc888_acer_aspire_4930g_unsol_event(struct hda_codec *codec, | |
1394 | unsigned int res) | |
1395 | { | |
1396 | if (res >> 26 == ALC880_HP_EVENT) | |
1397 | alc888_acer_aspire_4930g_automute(codec); | |
1398 | } | |
1399 | ||
1da177e4 | 1400 | /* |
e9edcee0 TI |
1401 | * ALC880 3-stack model |
1402 | * | |
1403 | * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e) | |
9c7f852e TI |
1404 | * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, |
1405 | * F-Mic = 0x1b, HP = 0x19 | |
1da177e4 LT |
1406 | */ |
1407 | ||
e9edcee0 TI |
1408 | static hda_nid_t alc880_dac_nids[4] = { |
1409 | /* front, rear, clfe, rear_surr */ | |
1410 | 0x02, 0x05, 0x04, 0x03 | |
1411 | }; | |
1412 | ||
1413 | static hda_nid_t alc880_adc_nids[3] = { | |
1414 | /* ADC0-2 */ | |
1415 | 0x07, 0x08, 0x09, | |
1416 | }; | |
1417 | ||
1418 | /* The datasheet says the node 0x07 is connected from inputs, | |
1419 | * but it shows zero connection in the real implementation on some devices. | |
df694daa | 1420 | * Note: this is a 915GAV bug, fixed on 915GLV |
1da177e4 | 1421 | */ |
e9edcee0 TI |
1422 | static hda_nid_t alc880_adc_nids_alt[2] = { |
1423 | /* ADC1-2 */ | |
1424 | 0x08, 0x09, | |
1425 | }; | |
1426 | ||
1427 | #define ALC880_DIGOUT_NID 0x06 | |
1428 | #define ALC880_DIGIN_NID 0x0a | |
1429 | ||
1430 | static struct hda_input_mux alc880_capture_source = { | |
1431 | .num_items = 4, | |
1432 | .items = { | |
1433 | { "Mic", 0x0 }, | |
1434 | { "Front Mic", 0x3 }, | |
1435 | { "Line", 0x2 }, | |
1436 | { "CD", 0x4 }, | |
1437 | }, | |
1438 | }; | |
1439 | ||
1440 | /* channel source setting (2/6 channel selection for 3-stack) */ | |
1441 | /* 2ch mode */ | |
1442 | static struct hda_verb alc880_threestack_ch2_init[] = { | |
1443 | /* set line-in to input, mute it */ | |
1444 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
1445 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
1446 | /* set mic-in to input vref 80%, mute it */ | |
1447 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
1448 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
1449 | { } /* end */ | |
1450 | }; | |
1451 | ||
1452 | /* 6ch mode */ | |
1453 | static struct hda_verb alc880_threestack_ch6_init[] = { | |
1454 | /* set line-in to output, unmute it */ | |
1455 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1456 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1457 | /* set mic-in to output, unmute it */ | |
1458 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1459 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1460 | { } /* end */ | |
1461 | }; | |
1462 | ||
d2a6d7dc | 1463 | static struct hda_channel_mode alc880_threestack_modes[2] = { |
e9edcee0 TI |
1464 | { 2, alc880_threestack_ch2_init }, |
1465 | { 6, alc880_threestack_ch6_init }, | |
1466 | }; | |
1467 | ||
c8b6bf9b | 1468 | static struct snd_kcontrol_new alc880_three_stack_mixer[] = { |
05acb863 | 1469 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1470 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
05acb863 | 1471 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 1472 | HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT), |
05acb863 TI |
1473 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1474 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1475 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1476 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
1da177e4 LT |
1477 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1478 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1479 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1480 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
1481 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1482 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1483 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT), | |
1484 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT), | |
1485 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
1486 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
e9edcee0 TI |
1487 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT), |
1488 | { | |
1489 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1490 | .name = "Channel Mode", | |
df694daa KY |
1491 | .info = alc_ch_mode_info, |
1492 | .get = alc_ch_mode_get, | |
1493 | .put = alc_ch_mode_put, | |
e9edcee0 TI |
1494 | }, |
1495 | { } /* end */ | |
1496 | }; | |
1497 | ||
1498 | /* capture mixer elements */ | |
f9e336f6 TI |
1499 | static int alc_cap_vol_info(struct snd_kcontrol *kcontrol, |
1500 | struct snd_ctl_elem_info *uinfo) | |
1501 | { | |
1502 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
1503 | struct alc_spec *spec = codec->spec; | |
1504 | int err; | |
1da177e4 | 1505 | |
5a9e02e9 | 1506 | mutex_lock(&codec->control_mutex); |
f9e336f6 TI |
1507 | kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, |
1508 | HDA_INPUT); | |
1509 | err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo); | |
5a9e02e9 | 1510 | mutex_unlock(&codec->control_mutex); |
f9e336f6 TI |
1511 | return err; |
1512 | } | |
1513 | ||
1514 | static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag, | |
1515 | unsigned int size, unsigned int __user *tlv) | |
1516 | { | |
1517 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
1518 | struct alc_spec *spec = codec->spec; | |
1519 | int err; | |
1da177e4 | 1520 | |
5a9e02e9 | 1521 | mutex_lock(&codec->control_mutex); |
f9e336f6 TI |
1522 | kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, |
1523 | HDA_INPUT); | |
1524 | err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv); | |
5a9e02e9 | 1525 | mutex_unlock(&codec->control_mutex); |
f9e336f6 TI |
1526 | return err; |
1527 | } | |
1528 | ||
1529 | typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol, | |
1530 | struct snd_ctl_elem_value *ucontrol); | |
1531 | ||
1532 | static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol, | |
1533 | struct snd_ctl_elem_value *ucontrol, | |
1534 | getput_call_t func) | |
1535 | { | |
1536 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
1537 | struct alc_spec *spec = codec->spec; | |
1538 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
1539 | int err; | |
1540 | ||
5a9e02e9 | 1541 | mutex_lock(&codec->control_mutex); |
f9e336f6 TI |
1542 | kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx], |
1543 | 3, 0, HDA_INPUT); | |
1544 | err = func(kcontrol, ucontrol); | |
5a9e02e9 | 1545 | mutex_unlock(&codec->control_mutex); |
f9e336f6 TI |
1546 | return err; |
1547 | } | |
1548 | ||
1549 | static int alc_cap_vol_get(struct snd_kcontrol *kcontrol, | |
1550 | struct snd_ctl_elem_value *ucontrol) | |
1551 | { | |
1552 | return alc_cap_getput_caller(kcontrol, ucontrol, | |
1553 | snd_hda_mixer_amp_volume_get); | |
1554 | } | |
1555 | ||
1556 | static int alc_cap_vol_put(struct snd_kcontrol *kcontrol, | |
1557 | struct snd_ctl_elem_value *ucontrol) | |
1558 | { | |
1559 | return alc_cap_getput_caller(kcontrol, ucontrol, | |
1560 | snd_hda_mixer_amp_volume_put); | |
1561 | } | |
1562 | ||
1563 | /* capture mixer elements */ | |
1564 | #define alc_cap_sw_info snd_ctl_boolean_stereo_info | |
1565 | ||
1566 | static int alc_cap_sw_get(struct snd_kcontrol *kcontrol, | |
1567 | struct snd_ctl_elem_value *ucontrol) | |
1568 | { | |
1569 | return alc_cap_getput_caller(kcontrol, ucontrol, | |
1570 | snd_hda_mixer_amp_switch_get); | |
1571 | } | |
1572 | ||
1573 | static int alc_cap_sw_put(struct snd_kcontrol *kcontrol, | |
1574 | struct snd_ctl_elem_value *ucontrol) | |
1575 | { | |
1576 | return alc_cap_getput_caller(kcontrol, ucontrol, | |
1577 | snd_hda_mixer_amp_switch_put); | |
1578 | } | |
1579 | ||
1580 | #define DEFINE_CAPMIX(num) \ | |
1581 | static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \ | |
1582 | { \ | |
1583 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
1584 | .name = "Capture Switch", \ | |
1585 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ | |
1586 | .count = num, \ | |
1587 | .info = alc_cap_sw_info, \ | |
1588 | .get = alc_cap_sw_get, \ | |
1589 | .put = alc_cap_sw_put, \ | |
1590 | }, \ | |
1591 | { \ | |
1592 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
1593 | .name = "Capture Volume", \ | |
1594 | .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \ | |
1595 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ | |
1596 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \ | |
1597 | .count = num, \ | |
1598 | .info = alc_cap_vol_info, \ | |
1599 | .get = alc_cap_vol_get, \ | |
1600 | .put = alc_cap_vol_put, \ | |
1601 | .tlv = { .c = alc_cap_vol_tlv }, \ | |
1602 | }, \ | |
3c3e9892 TI |
1603 | { \ |
1604 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
1605 | /* .name = "Capture Source", */ \ | |
1606 | .name = "Input Source", \ | |
1607 | .count = num, \ | |
1608 | .info = alc_mux_enum_info, \ | |
1609 | .get = alc_mux_enum_get, \ | |
1610 | .put = alc_mux_enum_put, \ | |
1611 | }, \ | |
f9e336f6 TI |
1612 | { } /* end */ \ |
1613 | } | |
1614 | ||
1615 | /* up to three ADCs */ | |
1616 | DEFINE_CAPMIX(1); | |
1617 | DEFINE_CAPMIX(2); | |
1618 | DEFINE_CAPMIX(3); | |
e9edcee0 TI |
1619 | |
1620 | ||
1621 | /* | |
1622 | * ALC880 5-stack model | |
1623 | * | |
9c7f852e TI |
1624 | * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), |
1625 | * Side = 0x02 (0xd) | |
e9edcee0 TI |
1626 | * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16 |
1627 | * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19 | |
1628 | */ | |
1629 | ||
1630 | /* additional mixers to alc880_three_stack_mixer */ | |
c8b6bf9b | 1631 | static struct snd_kcontrol_new alc880_five_stack_mixer[] = { |
e9edcee0 | 1632 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1633 | HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT), |
1da177e4 LT |
1634 | { } /* end */ |
1635 | }; | |
1636 | ||
e9edcee0 TI |
1637 | /* channel source setting (6/8 channel selection for 5-stack) */ |
1638 | /* 6ch mode */ | |
1639 | static struct hda_verb alc880_fivestack_ch6_init[] = { | |
1640 | /* set line-in to input, mute it */ | |
1641 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
1642 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
dfc0ff62 TI |
1643 | { } /* end */ |
1644 | }; | |
1645 | ||
e9edcee0 TI |
1646 | /* 8ch mode */ |
1647 | static struct hda_verb alc880_fivestack_ch8_init[] = { | |
1648 | /* set line-in to output, unmute it */ | |
1649 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1650 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1651 | { } /* end */ | |
1652 | }; | |
1653 | ||
d2a6d7dc | 1654 | static struct hda_channel_mode alc880_fivestack_modes[2] = { |
e9edcee0 TI |
1655 | { 6, alc880_fivestack_ch6_init }, |
1656 | { 8, alc880_fivestack_ch8_init }, | |
1657 | }; | |
1658 | ||
1659 | ||
1660 | /* | |
1661 | * ALC880 6-stack model | |
1662 | * | |
9c7f852e TI |
1663 | * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), |
1664 | * Side = 0x05 (0x0f) | |
e9edcee0 TI |
1665 | * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17, |
1666 | * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b | |
1667 | */ | |
1668 | ||
1669 | static hda_nid_t alc880_6st_dac_nids[4] = { | |
1670 | /* front, rear, clfe, rear_surr */ | |
1671 | 0x02, 0x03, 0x04, 0x05 | |
f12ab1e0 | 1672 | }; |
e9edcee0 TI |
1673 | |
1674 | static struct hda_input_mux alc880_6stack_capture_source = { | |
1675 | .num_items = 4, | |
1676 | .items = { | |
1677 | { "Mic", 0x0 }, | |
1678 | { "Front Mic", 0x1 }, | |
1679 | { "Line", 0x2 }, | |
1680 | { "CD", 0x4 }, | |
1681 | }, | |
1682 | }; | |
1683 | ||
1684 | /* fixed 8-channels */ | |
d2a6d7dc | 1685 | static struct hda_channel_mode alc880_sixstack_modes[1] = { |
e9edcee0 TI |
1686 | { 8, NULL }, |
1687 | }; | |
1688 | ||
c8b6bf9b | 1689 | static struct snd_kcontrol_new alc880_six_stack_mixer[] = { |
16ded525 | 1690 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1691 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 1692 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1693 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1694 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1695 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1696 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1697 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
16ded525 | 1698 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 1699 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
16ded525 TI |
1700 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1701 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1702 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1703 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
1704 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1705 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1706 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1707 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1708 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
1709 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
16ded525 TI |
1710 | { |
1711 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1712 | .name = "Channel Mode", | |
df694daa KY |
1713 | .info = alc_ch_mode_info, |
1714 | .get = alc_ch_mode_get, | |
1715 | .put = alc_ch_mode_put, | |
16ded525 TI |
1716 | }, |
1717 | { } /* end */ | |
1718 | }; | |
1719 | ||
e9edcee0 TI |
1720 | |
1721 | /* | |
1722 | * ALC880 W810 model | |
1723 | * | |
1724 | * W810 has rear IO for: | |
1725 | * Front (DAC 02) | |
1726 | * Surround (DAC 03) | |
1727 | * Center/LFE (DAC 04) | |
1728 | * Digital out (06) | |
1729 | * | |
1730 | * The system also has a pair of internal speakers, and a headphone jack. | |
1731 | * These are both connected to Line2 on the codec, hence to DAC 02. | |
ea1fb29a | 1732 | * |
e9edcee0 TI |
1733 | * There is a variable resistor to control the speaker or headphone |
1734 | * volume. This is a hardware-only device without a software API. | |
1735 | * | |
1736 | * Plugging headphones in will disable the internal speakers. This is | |
1737 | * implemented in hardware, not via the driver using jack sense. In | |
1738 | * a similar fashion, plugging into the rear socket marked "front" will | |
1739 | * disable both the speakers and headphones. | |
1740 | * | |
1741 | * For input, there's a microphone jack, and an "audio in" jack. | |
1742 | * These may not do anything useful with this driver yet, because I | |
1743 | * haven't setup any initialization verbs for these yet... | |
1744 | */ | |
1745 | ||
1746 | static hda_nid_t alc880_w810_dac_nids[3] = { | |
1747 | /* front, rear/surround, clfe */ | |
1748 | 0x02, 0x03, 0x04 | |
16ded525 TI |
1749 | }; |
1750 | ||
e9edcee0 | 1751 | /* fixed 6 channels */ |
d2a6d7dc | 1752 | static struct hda_channel_mode alc880_w810_modes[1] = { |
e9edcee0 TI |
1753 | { 6, NULL } |
1754 | }; | |
1755 | ||
1756 | /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */ | |
c8b6bf9b | 1757 | static struct snd_kcontrol_new alc880_w810_base_mixer[] = { |
16ded525 | 1758 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1759 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 1760 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1761 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1762 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1763 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1764 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1765 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
e9edcee0 TI |
1766 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
1767 | { } /* end */ | |
1768 | }; | |
1769 | ||
1770 | ||
1771 | /* | |
1772 | * Z710V model | |
1773 | * | |
1774 | * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d) | |
9c7f852e TI |
1775 | * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), |
1776 | * Line = 0x1a | |
e9edcee0 TI |
1777 | */ |
1778 | ||
1779 | static hda_nid_t alc880_z71v_dac_nids[1] = { | |
1780 | 0x02 | |
1781 | }; | |
1782 | #define ALC880_Z71V_HP_DAC 0x03 | |
1783 | ||
1784 | /* fixed 2 channels */ | |
d2a6d7dc | 1785 | static struct hda_channel_mode alc880_2_jack_modes[1] = { |
e9edcee0 TI |
1786 | { 2, NULL } |
1787 | }; | |
1788 | ||
c8b6bf9b | 1789 | static struct snd_kcontrol_new alc880_z71v_mixer[] = { |
e9edcee0 | 1790 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1791 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
e9edcee0 | 1792 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1793 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1794 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1795 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
16ded525 TI |
1796 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
1797 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
16ded525 TI |
1798 | { } /* end */ |
1799 | }; | |
1800 | ||
e9edcee0 | 1801 | |
e9edcee0 TI |
1802 | /* |
1803 | * ALC880 F1734 model | |
1804 | * | |
1805 | * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d) | |
1806 | * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18 | |
1807 | */ | |
1808 | ||
1809 | static hda_nid_t alc880_f1734_dac_nids[1] = { | |
1810 | 0x03 | |
1811 | }; | |
1812 | #define ALC880_F1734_HP_DAC 0x02 | |
1813 | ||
c8b6bf9b | 1814 | static struct snd_kcontrol_new alc880_f1734_mixer[] = { |
e9edcee0 | 1815 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1816 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), |
2134ea4f TI |
1817 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
1818 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
e9edcee0 TI |
1819 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1820 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
937b4160 TI |
1821 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
1822 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
e9edcee0 TI |
1823 | { } /* end */ |
1824 | }; | |
1825 | ||
937b4160 TI |
1826 | static struct hda_input_mux alc880_f1734_capture_source = { |
1827 | .num_items = 2, | |
1828 | .items = { | |
1829 | { "Mic", 0x1 }, | |
1830 | { "CD", 0x4 }, | |
1831 | }, | |
1832 | }; | |
1833 | ||
e9edcee0 | 1834 | |
e9edcee0 TI |
1835 | /* |
1836 | * ALC880 ASUS model | |
1837 | * | |
1838 | * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) | |
1839 | * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, | |
1840 | * Mic = 0x18, Line = 0x1a | |
1841 | */ | |
1842 | ||
1843 | #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */ | |
1844 | #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */ | |
1845 | ||
c8b6bf9b | 1846 | static struct snd_kcontrol_new alc880_asus_mixer[] = { |
16ded525 | 1847 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1848 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 1849 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1850 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1851 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1852 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1853 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1854 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
16ded525 TI |
1855 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1856 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1857 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1858 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
16ded525 TI |
1859 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
1860 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
16ded525 TI |
1861 | { |
1862 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1863 | .name = "Channel Mode", | |
df694daa KY |
1864 | .info = alc_ch_mode_info, |
1865 | .get = alc_ch_mode_get, | |
1866 | .put = alc_ch_mode_put, | |
16ded525 TI |
1867 | }, |
1868 | { } /* end */ | |
1869 | }; | |
e9edcee0 | 1870 | |
e9edcee0 TI |
1871 | /* |
1872 | * ALC880 ASUS W1V model | |
1873 | * | |
1874 | * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) | |
1875 | * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, | |
1876 | * Mic = 0x18, Line = 0x1a, Line2 = 0x1b | |
1877 | */ | |
1878 | ||
1879 | /* additional mixers to alc880_asus_mixer */ | |
c8b6bf9b | 1880 | static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = { |
e9edcee0 TI |
1881 | HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT), |
1882 | HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT), | |
1883 | { } /* end */ | |
1884 | }; | |
1885 | ||
3c10a9d9 | 1886 | /* additional mixers to alc880_asus_mixer */ |
c8b6bf9b | 1887 | static struct snd_kcontrol_new alc880_pcbeep_mixer[] = { |
3c10a9d9 TI |
1888 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), |
1889 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
1890 | { } /* end */ | |
1891 | }; | |
e9edcee0 | 1892 | |
df694daa KY |
1893 | /* TCL S700 */ |
1894 | static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = { | |
1895 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1896 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
1897 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
1898 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT), | |
1899 | HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT), | |
1900 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT), | |
1901 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT), | |
1902 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
1903 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
df694daa KY |
1904 | { } /* end */ |
1905 | }; | |
1906 | ||
ccc656ce KY |
1907 | /* Uniwill */ |
1908 | static struct snd_kcontrol_new alc880_uniwill_mixer[] = { | |
2134ea4f TI |
1909 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
1910 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1911 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1912 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
ccc656ce KY |
1913 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1914 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
1915 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
1916 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
1917 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
1918 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1919 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1920 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
1921 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1922 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1923 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1924 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1925 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
1926 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
1927 | { | |
1928 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1929 | .name = "Channel Mode", | |
1930 | .info = alc_ch_mode_info, | |
1931 | .get = alc_ch_mode_get, | |
1932 | .put = alc_ch_mode_put, | |
1933 | }, | |
1934 | { } /* end */ | |
1935 | }; | |
1936 | ||
2cf9f0fc TD |
1937 | static struct snd_kcontrol_new alc880_fujitsu_mixer[] = { |
1938 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1939 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1940 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1941 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
1942 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
1943 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1944 | HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1945 | HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1946 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1947 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1948 | { } /* end */ | |
1949 | }; | |
1950 | ||
ccc656ce | 1951 | static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = { |
2134ea4f TI |
1952 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
1953 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1954 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1955 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
ccc656ce KY |
1956 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
1957 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1958 | { } /* end */ | |
1959 | }; | |
1960 | ||
2134ea4f TI |
1961 | /* |
1962 | * virtual master controls | |
1963 | */ | |
1964 | ||
1965 | /* | |
1966 | * slave controls for virtual master | |
1967 | */ | |
1968 | static const char *alc_slave_vols[] = { | |
1969 | "Front Playback Volume", | |
1970 | "Surround Playback Volume", | |
1971 | "Center Playback Volume", | |
1972 | "LFE Playback Volume", | |
1973 | "Side Playback Volume", | |
1974 | "Headphone Playback Volume", | |
1975 | "Speaker Playback Volume", | |
1976 | "Mono Playback Volume", | |
2134ea4f | 1977 | "Line-Out Playback Volume", |
26f5df26 | 1978 | "PCM Playback Volume", |
2134ea4f TI |
1979 | NULL, |
1980 | }; | |
1981 | ||
1982 | static const char *alc_slave_sws[] = { | |
1983 | "Front Playback Switch", | |
1984 | "Surround Playback Switch", | |
1985 | "Center Playback Switch", | |
1986 | "LFE Playback Switch", | |
1987 | "Side Playback Switch", | |
1988 | "Headphone Playback Switch", | |
1989 | "Speaker Playback Switch", | |
1990 | "Mono Playback Switch", | |
edb54a55 | 1991 | "IEC958 Playback Switch", |
2134ea4f TI |
1992 | NULL, |
1993 | }; | |
1994 | ||
1da177e4 | 1995 | /* |
e9edcee0 | 1996 | * build control elements |
1da177e4 | 1997 | */ |
603c4019 TI |
1998 | |
1999 | static void alc_free_kctls(struct hda_codec *codec); | |
2000 | ||
1da177e4 LT |
2001 | static int alc_build_controls(struct hda_codec *codec) |
2002 | { | |
2003 | struct alc_spec *spec = codec->spec; | |
2004 | int err; | |
2005 | int i; | |
2006 | ||
2007 | for (i = 0; i < spec->num_mixers; i++) { | |
2008 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); | |
2009 | if (err < 0) | |
2010 | return err; | |
2011 | } | |
f9e336f6 TI |
2012 | if (spec->cap_mixer) { |
2013 | err = snd_hda_add_new_ctls(codec, spec->cap_mixer); | |
2014 | if (err < 0) | |
2015 | return err; | |
2016 | } | |
1da177e4 | 2017 | if (spec->multiout.dig_out_nid) { |
9c7f852e TI |
2018 | err = snd_hda_create_spdif_out_ctls(codec, |
2019 | spec->multiout.dig_out_nid); | |
1da177e4 LT |
2020 | if (err < 0) |
2021 | return err; | |
9a08160b TI |
2022 | err = snd_hda_create_spdif_share_sw(codec, |
2023 | &spec->multiout); | |
2024 | if (err < 0) | |
2025 | return err; | |
2026 | spec->multiout.share_spdif = 1; | |
1da177e4 LT |
2027 | } |
2028 | if (spec->dig_in_nid) { | |
2029 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); | |
2030 | if (err < 0) | |
2031 | return err; | |
2032 | } | |
2134ea4f TI |
2033 | |
2034 | /* if we have no master control, let's create it */ | |
2035 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { | |
1c82ed1b | 2036 | unsigned int vmaster_tlv[4]; |
2134ea4f | 2037 | snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, |
1c82ed1b | 2038 | HDA_OUTPUT, vmaster_tlv); |
2134ea4f | 2039 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
1c82ed1b | 2040 | vmaster_tlv, alc_slave_vols); |
2134ea4f TI |
2041 | if (err < 0) |
2042 | return err; | |
2043 | } | |
2044 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { | |
2045 | err = snd_hda_add_vmaster(codec, "Master Playback Switch", | |
2046 | NULL, alc_slave_sws); | |
2047 | if (err < 0) | |
2048 | return err; | |
2049 | } | |
2050 | ||
603c4019 | 2051 | alc_free_kctls(codec); /* no longer needed */ |
1da177e4 LT |
2052 | return 0; |
2053 | } | |
2054 | ||
e9edcee0 | 2055 | |
1da177e4 LT |
2056 | /* |
2057 | * initialize the codec volumes, etc | |
2058 | */ | |
2059 | ||
e9edcee0 TI |
2060 | /* |
2061 | * generic initialization of ADC, input mixers and output mixers | |
2062 | */ | |
2063 | static struct hda_verb alc880_volume_init_verbs[] = { | |
2064 | /* | |
2065 | * Unmute ADC0-2 and set the default input to mic-in | |
2066 | */ | |
71fe7b82 | 2067 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 2068 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
71fe7b82 | 2069 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 2070 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
71fe7b82 | 2071 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 2072 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1da177e4 | 2073 | |
e9edcee0 TI |
2074 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
2075 | * mixer widget | |
9c7f852e TI |
2076 | * Note: PASD motherboards uses the Line In 2 as the input for front |
2077 | * panel mic (mic 2) | |
1da177e4 | 2078 | */ |
e9edcee0 | 2079 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ |
cb53c626 TI |
2080 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
2081 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2082 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
2083 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
2084 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
2085 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
2086 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
1da177e4 | 2087 | |
e9edcee0 TI |
2088 | /* |
2089 | * Set up output mixers (0x0c - 0x0f) | |
1da177e4 | 2090 | */ |
e9edcee0 TI |
2091 | /* set vol=0 to output mixers */ |
2092 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2093 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2094 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2095 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2096 | /* set up input amps for analog loopback */ | |
2097 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
05acb863 TI |
2098 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
2099 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
2100 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
2101 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
2102 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
2103 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
2104 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
2105 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 LT |
2106 | |
2107 | { } | |
2108 | }; | |
2109 | ||
e9edcee0 TI |
2110 | /* |
2111 | * 3-stack pin configuration: | |
2112 | * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b | |
2113 | */ | |
2114 | static struct hda_verb alc880_pin_3stack_init_verbs[] = { | |
2115 | /* | |
2116 | * preset connection lists of input pins | |
2117 | * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround | |
2118 | */ | |
2119 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
2120 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
2121 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */ | |
2122 | ||
2123 | /* | |
2124 | * Set pin mode and muting | |
2125 | */ | |
2126 | /* set front pin widgets 0x14 for output */ | |
05acb863 | 2127 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
2128 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
2129 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
2130 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2131 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2132 | /* Mic2 (as headphone out) for HP output */ | |
2133 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2134 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1da177e4 | 2135 | /* Line In pin widget for input */ |
05acb863 | 2136 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 TI |
2137 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
2138 | /* Line2 (as front mic) pin widget for input and vref at 80% */ | |
2139 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2140 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1da177e4 | 2141 | /* CD pin widget for input */ |
05acb863 | 2142 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 2143 | |
e9edcee0 TI |
2144 | { } |
2145 | }; | |
1da177e4 | 2146 | |
e9edcee0 TI |
2147 | /* |
2148 | * 5-stack pin configuration: | |
2149 | * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19, | |
2150 | * line-in/side = 0x1a, f-mic = 0x1b | |
2151 | */ | |
2152 | static struct hda_verb alc880_pin_5stack_init_verbs[] = { | |
2153 | /* | |
2154 | * preset connection lists of input pins | |
2155 | * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround | |
1da177e4 | 2156 | */ |
e9edcee0 TI |
2157 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
2158 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */ | |
1da177e4 | 2159 | |
e9edcee0 TI |
2160 | /* |
2161 | * Set pin mode and muting | |
1da177e4 | 2162 | */ |
e9edcee0 TI |
2163 | /* set pin widgets 0x14-0x17 for output */ |
2164 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2165 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2166 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2167 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2168 | /* unmute pins for output (no gain on this amp) */ | |
2169 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2170 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2171 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2172 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2173 | ||
2174 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
2175 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2176 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2177 | /* Mic2 (as headphone out) for HP output */ | |
2178 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2179 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2180 | /* Line In pin widget for input */ | |
2181 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2182 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2183 | /* Line2 (as front mic) pin widget for input and vref at 80% */ | |
2184 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2185 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2186 | /* CD pin widget for input */ | |
2187 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1da177e4 LT |
2188 | |
2189 | { } | |
2190 | }; | |
2191 | ||
e9edcee0 TI |
2192 | /* |
2193 | * W810 pin configuration: | |
2194 | * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b | |
2195 | */ | |
2196 | static struct hda_verb alc880_pin_w810_init_verbs[] = { | |
2197 | /* hphone/speaker input selector: front DAC */ | |
2198 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
1da177e4 | 2199 | |
05acb863 | 2200 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2201 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 2202 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2203 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 2204 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2205 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 2206 | |
e9edcee0 | 2207 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
05acb863 | 2208 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
1da177e4 | 2209 | |
1da177e4 LT |
2210 | { } |
2211 | }; | |
2212 | ||
e9edcee0 TI |
2213 | /* |
2214 | * Z71V pin configuration: | |
2215 | * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?) | |
2216 | */ | |
2217 | static struct hda_verb alc880_pin_z71v_init_verbs[] = { | |
05acb863 | 2218 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2219 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 2220 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
e9edcee0 | 2221 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
dfc0ff62 | 2222 | |
16ded525 | 2223 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 2224 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
16ded525 | 2225 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 2226 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
16ded525 TI |
2227 | |
2228 | { } | |
2229 | }; | |
2230 | ||
e9edcee0 TI |
2231 | /* |
2232 | * 6-stack pin configuration: | |
9c7f852e TI |
2233 | * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, |
2234 | * f-mic = 0x19, line = 0x1a, HP = 0x1b | |
e9edcee0 TI |
2235 | */ |
2236 | static struct hda_verb alc880_pin_6stack_init_verbs[] = { | |
2237 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
2238 | ||
16ded525 | 2239 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2240 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2241 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2242 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2243 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2244 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2245 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
2246 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
2247 | ||
16ded525 | 2248 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 2249 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 2250 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 2251 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 2252 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 | 2253 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 2254 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
e9edcee0 | 2255 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2256 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
ea1fb29a | 2257 | |
e9edcee0 TI |
2258 | { } |
2259 | }; | |
2260 | ||
ccc656ce KY |
2261 | /* |
2262 | * Uniwill pin configuration: | |
2263 | * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19, | |
2264 | * line = 0x1a | |
2265 | */ | |
2266 | static struct hda_verb alc880_uniwill_init_verbs[] = { | |
2267 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
2268 | ||
2269 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2270 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2271 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2272 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2273 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2274 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2275 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2276 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2277 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
2278 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
2279 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
2280 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
2281 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
2282 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
2283 | ||
2284 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2285 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2286 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2287 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2288 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2289 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2290 | /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */ | |
2291 | /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */ | |
2292 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2293 | ||
2294 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
2295 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
2296 | ||
2297 | { } | |
2298 | }; | |
2299 | ||
2300 | /* | |
2301 | * Uniwill P53 | |
ea1fb29a | 2302 | * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19, |
ccc656ce KY |
2303 | */ |
2304 | static struct hda_verb alc880_uniwill_p53_init_verbs[] = { | |
2305 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
2306 | ||
2307 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2308 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2309 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2310 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2311 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2312 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2313 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
2314 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
2315 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
2316 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
2317 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
2318 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
2319 | ||
2320 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2321 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2322 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2323 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2324 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2325 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2326 | ||
2327 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
2328 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT}, | |
2329 | ||
2330 | { } | |
2331 | }; | |
2332 | ||
2cf9f0fc TD |
2333 | static struct hda_verb alc880_beep_init_verbs[] = { |
2334 | { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) }, | |
2335 | { } | |
2336 | }; | |
2337 | ||
ccc656ce | 2338 | /* toggle speaker-output according to the hp-jack state */ |
458a4fab | 2339 | static void alc880_uniwill_hp_automute(struct hda_codec *codec) |
ccc656ce KY |
2340 | { |
2341 | unsigned int present; | |
f12ab1e0 | 2342 | unsigned char bits; |
ccc656ce KY |
2343 | |
2344 | present = snd_hda_codec_read(codec, 0x14, 0, | |
2345 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
2346 | bits = present ? HDA_AMP_MUTE : 0; |
2347 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
2348 | HDA_AMP_MUTE, bits); | |
2349 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
2350 | HDA_AMP_MUTE, bits); | |
458a4fab TI |
2351 | } |
2352 | ||
2353 | /* auto-toggle front mic */ | |
2354 | static void alc880_uniwill_mic_automute(struct hda_codec *codec) | |
2355 | { | |
2356 | unsigned int present; | |
2357 | unsigned char bits; | |
ccc656ce KY |
2358 | |
2359 | present = snd_hda_codec_read(codec, 0x18, 0, | |
2360 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
2361 | bits = present ? HDA_AMP_MUTE : 0; |
2362 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); | |
458a4fab TI |
2363 | } |
2364 | ||
2365 | static void alc880_uniwill_automute(struct hda_codec *codec) | |
2366 | { | |
2367 | alc880_uniwill_hp_automute(codec); | |
2368 | alc880_uniwill_mic_automute(codec); | |
ccc656ce KY |
2369 | } |
2370 | ||
2371 | static void alc880_uniwill_unsol_event(struct hda_codec *codec, | |
2372 | unsigned int res) | |
2373 | { | |
2374 | /* Looks like the unsol event is incompatible with the standard | |
2375 | * definition. 4bit tag is placed at 28 bit! | |
2376 | */ | |
458a4fab TI |
2377 | switch (res >> 28) { |
2378 | case ALC880_HP_EVENT: | |
2379 | alc880_uniwill_hp_automute(codec); | |
2380 | break; | |
2381 | case ALC880_MIC_EVENT: | |
2382 | alc880_uniwill_mic_automute(codec); | |
2383 | break; | |
2384 | } | |
ccc656ce KY |
2385 | } |
2386 | ||
2387 | static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec) | |
2388 | { | |
2389 | unsigned int present; | |
f12ab1e0 | 2390 | unsigned char bits; |
ccc656ce KY |
2391 | |
2392 | present = snd_hda_codec_read(codec, 0x14, 0, | |
2393 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a | 2394 | bits = present ? HDA_AMP_MUTE : 0; |
64654c2f | 2395 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits); |
ccc656ce KY |
2396 | } |
2397 | ||
2398 | static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) | |
2399 | { | |
2400 | unsigned int present; | |
ea1fb29a | 2401 | |
ccc656ce | 2402 | present = snd_hda_codec_read(codec, 0x21, 0, |
47fd830a TI |
2403 | AC_VERB_GET_VOLUME_KNOB_CONTROL, 0); |
2404 | present &= HDA_AMP_VOLMASK; | |
2405 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, | |
2406 | HDA_AMP_VOLMASK, present); | |
2407 | snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0, | |
2408 | HDA_AMP_VOLMASK, present); | |
ccc656ce | 2409 | } |
47fd830a | 2410 | |
ccc656ce KY |
2411 | static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec, |
2412 | unsigned int res) | |
2413 | { | |
2414 | /* Looks like the unsol event is incompatible with the standard | |
2415 | * definition. 4bit tag is placed at 28 bit! | |
2416 | */ | |
2417 | if ((res >> 28) == ALC880_HP_EVENT) | |
2418 | alc880_uniwill_p53_hp_automute(codec); | |
f12ab1e0 | 2419 | if ((res >> 28) == ALC880_DCVOL_EVENT) |
ccc656ce KY |
2420 | alc880_uniwill_p53_dcvol_automute(codec); |
2421 | } | |
2422 | ||
e9edcee0 TI |
2423 | /* |
2424 | * F1734 pin configuration: | |
2425 | * HP = 0x14, speaker-out = 0x15, mic = 0x18 | |
2426 | */ | |
2427 | static struct hda_verb alc880_pin_f1734_init_verbs[] = { | |
ee7a9c7c | 2428 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x01}, |
16ded525 TI |
2429 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, |
2430 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
2431 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
2432 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
2433 | ||
e9edcee0 | 2434 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
16ded525 | 2435 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
e9edcee0 | 2436 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
16ded525 | 2437 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2438 | |
e9edcee0 TI |
2439 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
2440 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
ee7a9c7c | 2441 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, |
e9edcee0 | 2442 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 2443 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2444 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2445 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2446 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2447 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
dfc0ff62 | 2448 | |
937b4160 TI |
2449 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT}, |
2450 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT}, | |
2451 | ||
dfc0ff62 TI |
2452 | { } |
2453 | }; | |
2454 | ||
e9edcee0 TI |
2455 | /* |
2456 | * ASUS pin configuration: | |
2457 | * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a | |
2458 | */ | |
2459 | static struct hda_verb alc880_pin_asus_init_verbs[] = { | |
16ded525 TI |
2460 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, |
2461 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
2462 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
2463 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
2464 | ||
2465 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
e9edcee0 | 2466 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2467 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2468 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2469 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2470 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2471 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
2472 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
2473 | ||
2474 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2475 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2476 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2477 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2478 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2479 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
16ded525 | 2480 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2481 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2482 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
ea1fb29a | 2483 | |
e9edcee0 TI |
2484 | { } |
2485 | }; | |
16ded525 | 2486 | |
e9edcee0 | 2487 | /* Enable GPIO mask and set output */ |
bc9f98a9 KY |
2488 | #define alc880_gpio1_init_verbs alc_gpio1_init_verbs |
2489 | #define alc880_gpio2_init_verbs alc_gpio2_init_verbs | |
df694daa KY |
2490 | |
2491 | /* Clevo m520g init */ | |
2492 | static struct hda_verb alc880_pin_clevo_init_verbs[] = { | |
2493 | /* headphone output */ | |
2494 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
2495 | /* line-out */ | |
2496 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2497 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2498 | /* Line-in */ | |
2499 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2500 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2501 | /* CD */ | |
2502 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2503 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2504 | /* Mic1 (rear panel) */ | |
2505 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2506 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2507 | /* Mic2 (front panel) */ | |
2508 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2509 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2510 | /* headphone */ | |
2511 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2512 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2513 | /* change to EAPD mode */ | |
2514 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
2515 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, | |
2516 | ||
2517 | { } | |
16ded525 TI |
2518 | }; |
2519 | ||
df694daa | 2520 | static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = { |
4b146cb0 TI |
2521 | /* change to EAPD mode */ |
2522 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
2523 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, | |
2524 | ||
df694daa KY |
2525 | /* Headphone output */ |
2526 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2527 | /* Front output*/ | |
2528 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2529 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
2530 | ||
2531 | /* Line In pin widget for input */ | |
2532 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2533 | /* CD pin widget for input */ | |
2534 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2535 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
2536 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2537 | ||
2538 | /* change to EAPD mode */ | |
2539 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
2540 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
2541 | ||
2542 | { } | |
2543 | }; | |
16ded525 | 2544 | |
e9edcee0 | 2545 | /* |
ae6b813a TI |
2546 | * LG m1 express dual |
2547 | * | |
2548 | * Pin assignment: | |
2549 | * Rear Line-In/Out (blue): 0x14 | |
2550 | * Build-in Mic-In: 0x15 | |
2551 | * Speaker-out: 0x17 | |
2552 | * HP-Out (green): 0x1b | |
2553 | * Mic-In/Out (red): 0x19 | |
2554 | * SPDIF-Out: 0x1e | |
2555 | */ | |
2556 | ||
2557 | /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */ | |
2558 | static hda_nid_t alc880_lg_dac_nids[3] = { | |
2559 | 0x05, 0x02, 0x03 | |
2560 | }; | |
2561 | ||
2562 | /* seems analog CD is not working */ | |
2563 | static struct hda_input_mux alc880_lg_capture_source = { | |
2564 | .num_items = 3, | |
2565 | .items = { | |
2566 | { "Mic", 0x1 }, | |
2567 | { "Line", 0x5 }, | |
2568 | { "Internal Mic", 0x6 }, | |
2569 | }, | |
2570 | }; | |
2571 | ||
2572 | /* 2,4,6 channel modes */ | |
2573 | static struct hda_verb alc880_lg_ch2_init[] = { | |
2574 | /* set line-in and mic-in to input */ | |
2575 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
2576 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
2577 | { } | |
2578 | }; | |
2579 | ||
2580 | static struct hda_verb alc880_lg_ch4_init[] = { | |
2581 | /* set line-in to out and mic-in to input */ | |
2582 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
2583 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
2584 | { } | |
2585 | }; | |
2586 | ||
2587 | static struct hda_verb alc880_lg_ch6_init[] = { | |
2588 | /* set line-in and mic-in to output */ | |
2589 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
2590 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
2591 | { } | |
2592 | }; | |
2593 | ||
2594 | static struct hda_channel_mode alc880_lg_ch_modes[3] = { | |
2595 | { 2, alc880_lg_ch2_init }, | |
2596 | { 4, alc880_lg_ch4_init }, | |
2597 | { 6, alc880_lg_ch6_init }, | |
2598 | }; | |
2599 | ||
2600 | static struct snd_kcontrol_new alc880_lg_mixer[] = { | |
2134ea4f TI |
2601 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
2602 | HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT), | |
ae6b813a TI |
2603 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
2604 | HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT), | |
2605 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), | |
2606 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT), | |
2607 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT), | |
2608 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), | |
2609 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
2610 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
2611 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT), | |
2612 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT), | |
2613 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT), | |
2614 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT), | |
2615 | { | |
2616 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2617 | .name = "Channel Mode", | |
2618 | .info = alc_ch_mode_info, | |
2619 | .get = alc_ch_mode_get, | |
2620 | .put = alc_ch_mode_put, | |
2621 | }, | |
2622 | { } /* end */ | |
2623 | }; | |
2624 | ||
2625 | static struct hda_verb alc880_lg_init_verbs[] = { | |
2626 | /* set capture source to mic-in */ | |
2627 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2628 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2629 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2630 | /* mute all amp mixer inputs */ | |
2631 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)}, | |
cb53c626 TI |
2632 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, |
2633 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
ae6b813a TI |
2634 | /* line-in to input */ |
2635 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2636 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2637 | /* built-in mic */ | |
2638 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2639 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2640 | /* speaker-out */ | |
2641 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2642 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2643 | /* mic-in to input */ | |
2644 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
2645 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2646 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2647 | /* HP-out */ | |
2648 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
2649 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2650 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2651 | /* jack sense */ | |
2652 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, | |
2653 | { } | |
2654 | }; | |
2655 | ||
2656 | /* toggle speaker-output according to the hp-jack state */ | |
2657 | static void alc880_lg_automute(struct hda_codec *codec) | |
2658 | { | |
2659 | unsigned int present; | |
f12ab1e0 | 2660 | unsigned char bits; |
ae6b813a TI |
2661 | |
2662 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
2663 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
2664 | bits = present ? HDA_AMP_MUTE : 0; |
2665 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
2666 | HDA_AMP_MUTE, bits); | |
ae6b813a TI |
2667 | } |
2668 | ||
2669 | static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res) | |
2670 | { | |
2671 | /* Looks like the unsol event is incompatible with the standard | |
2672 | * definition. 4bit tag is placed at 28 bit! | |
2673 | */ | |
2674 | if ((res >> 28) == 0x01) | |
2675 | alc880_lg_automute(codec); | |
2676 | } | |
2677 | ||
d681518a TI |
2678 | /* |
2679 | * LG LW20 | |
2680 | * | |
2681 | * Pin assignment: | |
2682 | * Speaker-out: 0x14 | |
2683 | * Mic-In: 0x18 | |
e4f41da9 CM |
2684 | * Built-in Mic-In: 0x19 |
2685 | * Line-In: 0x1b | |
2686 | * HP-Out: 0x1a | |
d681518a TI |
2687 | * SPDIF-Out: 0x1e |
2688 | */ | |
2689 | ||
d681518a | 2690 | static struct hda_input_mux alc880_lg_lw_capture_source = { |
e4f41da9 | 2691 | .num_items = 3, |
d681518a TI |
2692 | .items = { |
2693 | { "Mic", 0x0 }, | |
2694 | { "Internal Mic", 0x1 }, | |
e4f41da9 | 2695 | { "Line In", 0x2 }, |
d681518a TI |
2696 | }, |
2697 | }; | |
2698 | ||
0a8c5da3 CM |
2699 | #define alc880_lg_lw_modes alc880_threestack_modes |
2700 | ||
d681518a | 2701 | static struct snd_kcontrol_new alc880_lg_lw_mixer[] = { |
0a8c5da3 CM |
2702 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
2703 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
2704 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
2705 | HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT), | |
2706 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
2707 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
2708 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
2709 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
2710 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
2711 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
d681518a TI |
2712 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
2713 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2714 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
2715 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
0a8c5da3 CM |
2716 | { |
2717 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2718 | .name = "Channel Mode", | |
2719 | .info = alc_ch_mode_info, | |
2720 | .get = alc_ch_mode_get, | |
2721 | .put = alc_ch_mode_put, | |
2722 | }, | |
d681518a TI |
2723 | { } /* end */ |
2724 | }; | |
2725 | ||
2726 | static struct hda_verb alc880_lg_lw_init_verbs[] = { | |
0a8c5da3 CM |
2727 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
2728 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
2729 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */ | |
2730 | ||
d681518a TI |
2731 | /* set capture source to mic-in */ |
2732 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2733 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2734 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
cb53c626 | 2735 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, |
d681518a TI |
2736 | /* speaker-out */ |
2737 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2738 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2739 | /* HP-out */ | |
d681518a TI |
2740 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
2741 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2742 | /* mic-in to input */ | |
2743 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2744 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2745 | /* built-in mic */ | |
2746 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2747 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2748 | /* jack sense */ | |
2749 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, | |
2750 | { } | |
2751 | }; | |
2752 | ||
2753 | /* toggle speaker-output according to the hp-jack state */ | |
2754 | static void alc880_lg_lw_automute(struct hda_codec *codec) | |
2755 | { | |
2756 | unsigned int present; | |
f12ab1e0 | 2757 | unsigned char bits; |
d681518a TI |
2758 | |
2759 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
2760 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
2761 | bits = present ? HDA_AMP_MUTE : 0; |
2762 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
2763 | HDA_AMP_MUTE, bits); | |
d681518a TI |
2764 | } |
2765 | ||
2766 | static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res) | |
2767 | { | |
2768 | /* Looks like the unsol event is incompatible with the standard | |
2769 | * definition. 4bit tag is placed at 28 bit! | |
2770 | */ | |
2771 | if ((res >> 28) == 0x01) | |
2772 | alc880_lg_lw_automute(codec); | |
2773 | } | |
2774 | ||
df99cd33 TI |
2775 | static struct snd_kcontrol_new alc880_medion_rim_mixer[] = { |
2776 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
2777 | HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT), | |
2778 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
2779 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2780 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
2781 | HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
2782 | { } /* end */ | |
2783 | }; | |
2784 | ||
2785 | static struct hda_input_mux alc880_medion_rim_capture_source = { | |
2786 | .num_items = 2, | |
2787 | .items = { | |
2788 | { "Mic", 0x0 }, | |
2789 | { "Internal Mic", 0x1 }, | |
2790 | }, | |
2791 | }; | |
2792 | ||
2793 | static struct hda_verb alc880_medion_rim_init_verbs[] = { | |
2794 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
2795 | ||
2796 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2797 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2798 | ||
2799 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
2800 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2801 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2802 | /* Mic2 (as headphone out) for HP output */ | |
2803 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2804 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2805 | /* Internal Speaker */ | |
2806 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2807 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2808 | ||
2809 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
2810 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, | |
2811 | ||
2812 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
2813 | { } | |
2814 | }; | |
2815 | ||
2816 | /* toggle speaker-output according to the hp-jack state */ | |
2817 | static void alc880_medion_rim_automute(struct hda_codec *codec) | |
2818 | { | |
2819 | unsigned int present; | |
2820 | unsigned char bits; | |
2821 | ||
2822 | present = snd_hda_codec_read(codec, 0x14, 0, | |
2823 | AC_VERB_GET_PIN_SENSE, 0) | |
2824 | & AC_PINSENSE_PRESENCE; | |
2825 | bits = present ? HDA_AMP_MUTE : 0; | |
2826 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
2827 | HDA_AMP_MUTE, bits); | |
2828 | if (present) | |
2829 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0); | |
2830 | else | |
2831 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2); | |
2832 | } | |
2833 | ||
2834 | static void alc880_medion_rim_unsol_event(struct hda_codec *codec, | |
2835 | unsigned int res) | |
2836 | { | |
2837 | /* Looks like the unsol event is incompatible with the standard | |
2838 | * definition. 4bit tag is placed at 28 bit! | |
2839 | */ | |
2840 | if ((res >> 28) == ALC880_HP_EVENT) | |
2841 | alc880_medion_rim_automute(codec); | |
2842 | } | |
2843 | ||
cb53c626 TI |
2844 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
2845 | static struct hda_amp_list alc880_loopbacks[] = { | |
2846 | { 0x0b, HDA_INPUT, 0 }, | |
2847 | { 0x0b, HDA_INPUT, 1 }, | |
2848 | { 0x0b, HDA_INPUT, 2 }, | |
2849 | { 0x0b, HDA_INPUT, 3 }, | |
2850 | { 0x0b, HDA_INPUT, 4 }, | |
2851 | { } /* end */ | |
2852 | }; | |
2853 | ||
2854 | static struct hda_amp_list alc880_lg_loopbacks[] = { | |
2855 | { 0x0b, HDA_INPUT, 1 }, | |
2856 | { 0x0b, HDA_INPUT, 6 }, | |
2857 | { 0x0b, HDA_INPUT, 7 }, | |
2858 | { } /* end */ | |
2859 | }; | |
2860 | #endif | |
2861 | ||
ae6b813a TI |
2862 | /* |
2863 | * Common callbacks | |
e9edcee0 TI |
2864 | */ |
2865 | ||
1da177e4 LT |
2866 | static int alc_init(struct hda_codec *codec) |
2867 | { | |
2868 | struct alc_spec *spec = codec->spec; | |
e9edcee0 TI |
2869 | unsigned int i; |
2870 | ||
2c3bf9ab | 2871 | alc_fix_pll(codec); |
1082c748 TI |
2872 | if (codec->vendor_id == 0x10ec0888) |
2873 | alc888_coef_init(codec); | |
2c3bf9ab | 2874 | |
e9edcee0 TI |
2875 | for (i = 0; i < spec->num_init_verbs; i++) |
2876 | snd_hda_sequence_write(codec, spec->init_verbs[i]); | |
ae6b813a TI |
2877 | |
2878 | if (spec->init_hook) | |
2879 | spec->init_hook(codec); | |
2880 | ||
1da177e4 LT |
2881 | return 0; |
2882 | } | |
2883 | ||
ae6b813a TI |
2884 | static void alc_unsol_event(struct hda_codec *codec, unsigned int res) |
2885 | { | |
2886 | struct alc_spec *spec = codec->spec; | |
2887 | ||
2888 | if (spec->unsol_event) | |
2889 | spec->unsol_event(codec, res); | |
2890 | } | |
2891 | ||
cb53c626 TI |
2892 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
2893 | static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid) | |
2894 | { | |
2895 | struct alc_spec *spec = codec->spec; | |
2896 | return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); | |
2897 | } | |
2898 | #endif | |
2899 | ||
1da177e4 LT |
2900 | /* |
2901 | * Analog playback callbacks | |
2902 | */ | |
2903 | static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo, | |
2904 | struct hda_codec *codec, | |
c8b6bf9b | 2905 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2906 | { |
2907 | struct alc_spec *spec = codec->spec; | |
9a08160b TI |
2908 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
2909 | hinfo); | |
1da177e4 LT |
2910 | } |
2911 | ||
2912 | static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | |
2913 | struct hda_codec *codec, | |
2914 | unsigned int stream_tag, | |
2915 | unsigned int format, | |
c8b6bf9b | 2916 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2917 | { |
2918 | struct alc_spec *spec = codec->spec; | |
9c7f852e TI |
2919 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, |
2920 | stream_tag, format, substream); | |
1da177e4 LT |
2921 | } |
2922 | ||
2923 | static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, | |
2924 | struct hda_codec *codec, | |
c8b6bf9b | 2925 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2926 | { |
2927 | struct alc_spec *spec = codec->spec; | |
2928 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); | |
2929 | } | |
2930 | ||
2931 | /* | |
2932 | * Digital out | |
2933 | */ | |
2934 | static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, | |
2935 | struct hda_codec *codec, | |
c8b6bf9b | 2936 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2937 | { |
2938 | struct alc_spec *spec = codec->spec; | |
2939 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); | |
2940 | } | |
2941 | ||
6b97eb45 TI |
2942 | static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
2943 | struct hda_codec *codec, | |
2944 | unsigned int stream_tag, | |
2945 | unsigned int format, | |
2946 | struct snd_pcm_substream *substream) | |
2947 | { | |
2948 | struct alc_spec *spec = codec->spec; | |
2949 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, | |
2950 | stream_tag, format, substream); | |
2951 | } | |
2952 | ||
1da177e4 LT |
2953 | static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
2954 | struct hda_codec *codec, | |
c8b6bf9b | 2955 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2956 | { |
2957 | struct alc_spec *spec = codec->spec; | |
2958 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); | |
2959 | } | |
2960 | ||
2961 | /* | |
2962 | * Analog capture | |
2963 | */ | |
6330079f | 2964 | static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
1da177e4 LT |
2965 | struct hda_codec *codec, |
2966 | unsigned int stream_tag, | |
2967 | unsigned int format, | |
c8b6bf9b | 2968 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2969 | { |
2970 | struct alc_spec *spec = codec->spec; | |
2971 | ||
6330079f | 2972 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1], |
1da177e4 LT |
2973 | stream_tag, 0, format); |
2974 | return 0; | |
2975 | } | |
2976 | ||
6330079f | 2977 | static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
1da177e4 | 2978 | struct hda_codec *codec, |
c8b6bf9b | 2979 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2980 | { |
2981 | struct alc_spec *spec = codec->spec; | |
2982 | ||
888afa15 TI |
2983 | snd_hda_codec_cleanup_stream(codec, |
2984 | spec->adc_nids[substream->number + 1]); | |
1da177e4 LT |
2985 | return 0; |
2986 | } | |
2987 | ||
2988 | ||
2989 | /* | |
2990 | */ | |
2991 | static struct hda_pcm_stream alc880_pcm_analog_playback = { | |
2992 | .substreams = 1, | |
2993 | .channels_min = 2, | |
2994 | .channels_max = 8, | |
e9edcee0 | 2995 | /* NID is set in alc_build_pcms */ |
1da177e4 LT |
2996 | .ops = { |
2997 | .open = alc880_playback_pcm_open, | |
2998 | .prepare = alc880_playback_pcm_prepare, | |
2999 | .cleanup = alc880_playback_pcm_cleanup | |
3000 | }, | |
3001 | }; | |
3002 | ||
3003 | static struct hda_pcm_stream alc880_pcm_analog_capture = { | |
6330079f TI |
3004 | .substreams = 1, |
3005 | .channels_min = 2, | |
3006 | .channels_max = 2, | |
3007 | /* NID is set in alc_build_pcms */ | |
3008 | }; | |
3009 | ||
3010 | static struct hda_pcm_stream alc880_pcm_analog_alt_playback = { | |
3011 | .substreams = 1, | |
3012 | .channels_min = 2, | |
3013 | .channels_max = 2, | |
3014 | /* NID is set in alc_build_pcms */ | |
3015 | }; | |
3016 | ||
3017 | static struct hda_pcm_stream alc880_pcm_analog_alt_capture = { | |
3018 | .substreams = 2, /* can be overridden */ | |
1da177e4 LT |
3019 | .channels_min = 2, |
3020 | .channels_max = 2, | |
e9edcee0 | 3021 | /* NID is set in alc_build_pcms */ |
1da177e4 | 3022 | .ops = { |
6330079f TI |
3023 | .prepare = alc880_alt_capture_pcm_prepare, |
3024 | .cleanup = alc880_alt_capture_pcm_cleanup | |
1da177e4 LT |
3025 | }, |
3026 | }; | |
3027 | ||
3028 | static struct hda_pcm_stream alc880_pcm_digital_playback = { | |
3029 | .substreams = 1, | |
3030 | .channels_min = 2, | |
3031 | .channels_max = 2, | |
3032 | /* NID is set in alc_build_pcms */ | |
3033 | .ops = { | |
3034 | .open = alc880_dig_playback_pcm_open, | |
6b97eb45 TI |
3035 | .close = alc880_dig_playback_pcm_close, |
3036 | .prepare = alc880_dig_playback_pcm_prepare | |
1da177e4 LT |
3037 | }, |
3038 | }; | |
3039 | ||
3040 | static struct hda_pcm_stream alc880_pcm_digital_capture = { | |
3041 | .substreams = 1, | |
3042 | .channels_min = 2, | |
3043 | .channels_max = 2, | |
3044 | /* NID is set in alc_build_pcms */ | |
3045 | }; | |
3046 | ||
4c5186ed | 3047 | /* Used by alc_build_pcms to flag that a PCM has no playback stream */ |
6330079f | 3048 | static struct hda_pcm_stream alc_pcm_null_stream = { |
4c5186ed JW |
3049 | .substreams = 0, |
3050 | .channels_min = 0, | |
3051 | .channels_max = 0, | |
3052 | }; | |
3053 | ||
1da177e4 LT |
3054 | static int alc_build_pcms(struct hda_codec *codec) |
3055 | { | |
3056 | struct alc_spec *spec = codec->spec; | |
3057 | struct hda_pcm *info = spec->pcm_rec; | |
3058 | int i; | |
3059 | ||
3060 | codec->num_pcms = 1; | |
3061 | codec->pcm_info = info; | |
3062 | ||
3063 | info->name = spec->stream_name_analog; | |
4a471b7d | 3064 | if (spec->stream_analog_playback) { |
da3cec35 TI |
3065 | if (snd_BUG_ON(!spec->multiout.dac_nids)) |
3066 | return -EINVAL; | |
4a471b7d TI |
3067 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback); |
3068 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; | |
3069 | } | |
3070 | if (spec->stream_analog_capture) { | |
da3cec35 TI |
3071 | if (snd_BUG_ON(!spec->adc_nids)) |
3072 | return -EINVAL; | |
4a471b7d TI |
3073 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); |
3074 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; | |
3075 | } | |
3076 | ||
3077 | if (spec->channel_mode) { | |
3078 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; | |
3079 | for (i = 0; i < spec->num_channel_mode; i++) { | |
3080 | if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { | |
3081 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; | |
3082 | } | |
1da177e4 LT |
3083 | } |
3084 | } | |
3085 | ||
e08a007d | 3086 | /* SPDIF for stream index #1 */ |
1da177e4 | 3087 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
e08a007d | 3088 | codec->num_pcms = 2; |
c06134d7 | 3089 | info = spec->pcm_rec + 1; |
1da177e4 | 3090 | info->name = spec->stream_name_digital; |
7ba72ba1 | 3091 | info->pcm_type = HDA_PCM_TYPE_SPDIF; |
4a471b7d TI |
3092 | if (spec->multiout.dig_out_nid && |
3093 | spec->stream_digital_playback) { | |
1da177e4 LT |
3094 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback); |
3095 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; | |
3096 | } | |
4a471b7d TI |
3097 | if (spec->dig_in_nid && |
3098 | spec->stream_digital_capture) { | |
1da177e4 LT |
3099 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture); |
3100 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; | |
3101 | } | |
963f803f TI |
3102 | /* FIXME: do we need this for all Realtek codec models? */ |
3103 | codec->spdif_status_reset = 1; | |
1da177e4 LT |
3104 | } |
3105 | ||
e08a007d TI |
3106 | /* If the use of more than one ADC is requested for the current |
3107 | * model, configure a second analog capture-only PCM. | |
3108 | */ | |
3109 | /* Additional Analaog capture for index #2 */ | |
6330079f TI |
3110 | if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) || |
3111 | (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) { | |
e08a007d | 3112 | codec->num_pcms = 3; |
c06134d7 | 3113 | info = spec->pcm_rec + 2; |
e08a007d | 3114 | info->name = spec->stream_name_analog; |
6330079f TI |
3115 | if (spec->alt_dac_nid) { |
3116 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = | |
3117 | *spec->stream_analog_alt_playback; | |
3118 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = | |
3119 | spec->alt_dac_nid; | |
3120 | } else { | |
3121 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = | |
3122 | alc_pcm_null_stream; | |
3123 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; | |
3124 | } | |
3125 | if (spec->num_adc_nids > 1) { | |
3126 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = | |
3127 | *spec->stream_analog_alt_capture; | |
3128 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = | |
3129 | spec->adc_nids[1]; | |
3130 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = | |
3131 | spec->num_adc_nids - 1; | |
3132 | } else { | |
3133 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = | |
3134 | alc_pcm_null_stream; | |
3135 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0; | |
e08a007d TI |
3136 | } |
3137 | } | |
3138 | ||
1da177e4 LT |
3139 | return 0; |
3140 | } | |
3141 | ||
603c4019 TI |
3142 | static void alc_free_kctls(struct hda_codec *codec) |
3143 | { | |
3144 | struct alc_spec *spec = codec->spec; | |
3145 | ||
3146 | if (spec->kctls.list) { | |
3147 | struct snd_kcontrol_new *kctl = spec->kctls.list; | |
3148 | int i; | |
3149 | for (i = 0; i < spec->kctls.used; i++) | |
3150 | kfree(kctl[i].name); | |
3151 | } | |
3152 | snd_array_free(&spec->kctls); | |
3153 | } | |
3154 | ||
1da177e4 LT |
3155 | static void alc_free(struct hda_codec *codec) |
3156 | { | |
e9edcee0 | 3157 | struct alc_spec *spec = codec->spec; |
e9edcee0 | 3158 | |
f12ab1e0 | 3159 | if (!spec) |
e9edcee0 TI |
3160 | return; |
3161 | ||
603c4019 | 3162 | alc_free_kctls(codec); |
e9edcee0 | 3163 | kfree(spec); |
7943a8ab | 3164 | codec->spec = NULL; /* to be sure */ |
1da177e4 LT |
3165 | } |
3166 | ||
e044c39a TI |
3167 | #ifdef SND_HDA_NEEDS_RESUME |
3168 | static void store_pin_configs(struct hda_codec *codec) | |
3169 | { | |
3170 | struct alc_spec *spec = codec->spec; | |
3171 | hda_nid_t nid, end_nid; | |
3172 | ||
3173 | end_nid = codec->start_nid + codec->num_nodes; | |
3174 | for (nid = codec->start_nid; nid < end_nid; nid++) { | |
3175 | unsigned int wid_caps = get_wcaps(codec, nid); | |
3176 | unsigned int wid_type = | |
3177 | (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
3178 | if (wid_type != AC_WID_PIN) | |
3179 | continue; | |
3180 | if (spec->num_pins >= ARRAY_SIZE(spec->pin_nids)) | |
3181 | break; | |
3182 | spec->pin_nids[spec->num_pins] = nid; | |
3183 | spec->pin_cfgs[spec->num_pins] = | |
3184 | snd_hda_codec_read(codec, nid, 0, | |
3185 | AC_VERB_GET_CONFIG_DEFAULT, 0); | |
3186 | spec->num_pins++; | |
3187 | } | |
3188 | } | |
3189 | ||
3190 | static void resume_pin_configs(struct hda_codec *codec) | |
3191 | { | |
3192 | struct alc_spec *spec = codec->spec; | |
3193 | int i; | |
3194 | ||
3195 | for (i = 0; i < spec->num_pins; i++) { | |
3196 | hda_nid_t pin_nid = spec->pin_nids[i]; | |
3197 | unsigned int pin_config = spec->pin_cfgs[i]; | |
3198 | snd_hda_codec_write(codec, pin_nid, 0, | |
3199 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_0, | |
3200 | pin_config & 0x000000ff); | |
3201 | snd_hda_codec_write(codec, pin_nid, 0, | |
3202 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, | |
3203 | (pin_config & 0x0000ff00) >> 8); | |
3204 | snd_hda_codec_write(codec, pin_nid, 0, | |
3205 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, | |
3206 | (pin_config & 0x00ff0000) >> 16); | |
3207 | snd_hda_codec_write(codec, pin_nid, 0, | |
3208 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, | |
3209 | pin_config >> 24); | |
3210 | } | |
3211 | } | |
3212 | ||
3213 | static int alc_resume(struct hda_codec *codec) | |
3214 | { | |
3215 | resume_pin_configs(codec); | |
3216 | codec->patch_ops.init(codec); | |
3217 | snd_hda_codec_resume_amp(codec); | |
3218 | snd_hda_codec_resume_cache(codec); | |
3219 | return 0; | |
3220 | } | |
3221 | #else | |
3222 | #define store_pin_configs(codec) | |
3223 | #endif | |
3224 | ||
1da177e4 LT |
3225 | /* |
3226 | */ | |
3227 | static struct hda_codec_ops alc_patch_ops = { | |
3228 | .build_controls = alc_build_controls, | |
3229 | .build_pcms = alc_build_pcms, | |
3230 | .init = alc_init, | |
3231 | .free = alc_free, | |
ae6b813a | 3232 | .unsol_event = alc_unsol_event, |
e044c39a TI |
3233 | #ifdef SND_HDA_NEEDS_RESUME |
3234 | .resume = alc_resume, | |
3235 | #endif | |
cb53c626 TI |
3236 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
3237 | .check_power_status = alc_check_power_status, | |
3238 | #endif | |
1da177e4 LT |
3239 | }; |
3240 | ||
2fa522be TI |
3241 | |
3242 | /* | |
3243 | * Test configuration for debugging | |
3244 | * | |
3245 | * Almost all inputs/outputs are enabled. I/O pins can be configured via | |
3246 | * enum controls. | |
3247 | */ | |
3248 | #ifdef CONFIG_SND_DEBUG | |
3249 | static hda_nid_t alc880_test_dac_nids[4] = { | |
3250 | 0x02, 0x03, 0x04, 0x05 | |
3251 | }; | |
3252 | ||
3253 | static struct hda_input_mux alc880_test_capture_source = { | |
ae6b813a | 3254 | .num_items = 7, |
2fa522be TI |
3255 | .items = { |
3256 | { "In-1", 0x0 }, | |
3257 | { "In-2", 0x1 }, | |
3258 | { "In-3", 0x2 }, | |
3259 | { "In-4", 0x3 }, | |
3260 | { "CD", 0x4 }, | |
ae6b813a TI |
3261 | { "Front", 0x5 }, |
3262 | { "Surround", 0x6 }, | |
2fa522be TI |
3263 | }, |
3264 | }; | |
3265 | ||
d2a6d7dc | 3266 | static struct hda_channel_mode alc880_test_modes[4] = { |
2fa522be | 3267 | { 2, NULL }, |
fd2c326d | 3268 | { 4, NULL }, |
2fa522be | 3269 | { 6, NULL }, |
fd2c326d | 3270 | { 8, NULL }, |
2fa522be TI |
3271 | }; |
3272 | ||
9c7f852e TI |
3273 | static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, |
3274 | struct snd_ctl_elem_info *uinfo) | |
2fa522be TI |
3275 | { |
3276 | static char *texts[] = { | |
3277 | "N/A", "Line Out", "HP Out", | |
3278 | "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%" | |
3279 | }; | |
3280 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
3281 | uinfo->count = 1; | |
3282 | uinfo->value.enumerated.items = 8; | |
3283 | if (uinfo->value.enumerated.item >= 8) | |
3284 | uinfo->value.enumerated.item = 7; | |
3285 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | |
3286 | return 0; | |
3287 | } | |
3288 | ||
9c7f852e TI |
3289 | static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, |
3290 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
3291 | { |
3292 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
3293 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
3294 | unsigned int pin_ctl, item = 0; | |
3295 | ||
3296 | pin_ctl = snd_hda_codec_read(codec, nid, 0, | |
3297 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | |
3298 | if (pin_ctl & AC_PINCTL_OUT_EN) { | |
3299 | if (pin_ctl & AC_PINCTL_HP_EN) | |
3300 | item = 2; | |
3301 | else | |
3302 | item = 1; | |
3303 | } else if (pin_ctl & AC_PINCTL_IN_EN) { | |
3304 | switch (pin_ctl & AC_PINCTL_VREFEN) { | |
3305 | case AC_PINCTL_VREF_HIZ: item = 3; break; | |
3306 | case AC_PINCTL_VREF_50: item = 4; break; | |
3307 | case AC_PINCTL_VREF_GRD: item = 5; break; | |
3308 | case AC_PINCTL_VREF_80: item = 6; break; | |
3309 | case AC_PINCTL_VREF_100: item = 7; break; | |
3310 | } | |
3311 | } | |
3312 | ucontrol->value.enumerated.item[0] = item; | |
3313 | return 0; | |
3314 | } | |
3315 | ||
9c7f852e TI |
3316 | static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, |
3317 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
3318 | { |
3319 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
3320 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
3321 | static unsigned int ctls[] = { | |
3322 | 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN, | |
3323 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ, | |
3324 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_50, | |
3325 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD, | |
3326 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_80, | |
3327 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_100, | |
3328 | }; | |
3329 | unsigned int old_ctl, new_ctl; | |
3330 | ||
3331 | old_ctl = snd_hda_codec_read(codec, nid, 0, | |
3332 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | |
3333 | new_ctl = ctls[ucontrol->value.enumerated.item[0]]; | |
3334 | if (old_ctl != new_ctl) { | |
82beb8fd TI |
3335 | int val; |
3336 | snd_hda_codec_write_cache(codec, nid, 0, | |
3337 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
3338 | new_ctl); | |
47fd830a TI |
3339 | val = ucontrol->value.enumerated.item[0] >= 3 ? |
3340 | HDA_AMP_MUTE : 0; | |
3341 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, | |
3342 | HDA_AMP_MUTE, val); | |
2fa522be TI |
3343 | return 1; |
3344 | } | |
3345 | return 0; | |
3346 | } | |
3347 | ||
9c7f852e TI |
3348 | static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, |
3349 | struct snd_ctl_elem_info *uinfo) | |
2fa522be TI |
3350 | { |
3351 | static char *texts[] = { | |
3352 | "Front", "Surround", "CLFE", "Side" | |
3353 | }; | |
3354 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
3355 | uinfo->count = 1; | |
3356 | uinfo->value.enumerated.items = 4; | |
3357 | if (uinfo->value.enumerated.item >= 4) | |
3358 | uinfo->value.enumerated.item = 3; | |
3359 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | |
3360 | return 0; | |
3361 | } | |
3362 | ||
9c7f852e TI |
3363 | static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, |
3364 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
3365 | { |
3366 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
3367 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
3368 | unsigned int sel; | |
3369 | ||
3370 | sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0); | |
3371 | ucontrol->value.enumerated.item[0] = sel & 3; | |
3372 | return 0; | |
3373 | } | |
3374 | ||
9c7f852e TI |
3375 | static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, |
3376 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
3377 | { |
3378 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
3379 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
3380 | unsigned int sel; | |
3381 | ||
3382 | sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3; | |
3383 | if (ucontrol->value.enumerated.item[0] != sel) { | |
3384 | sel = ucontrol->value.enumerated.item[0] & 3; | |
82beb8fd TI |
3385 | snd_hda_codec_write_cache(codec, nid, 0, |
3386 | AC_VERB_SET_CONNECT_SEL, sel); | |
2fa522be TI |
3387 | return 1; |
3388 | } | |
3389 | return 0; | |
3390 | } | |
3391 | ||
3392 | #define PIN_CTL_TEST(xname,nid) { \ | |
3393 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
3394 | .name = xname, \ | |
3395 | .info = alc_test_pin_ctl_info, \ | |
3396 | .get = alc_test_pin_ctl_get, \ | |
3397 | .put = alc_test_pin_ctl_put, \ | |
3398 | .private_value = nid \ | |
3399 | } | |
3400 | ||
3401 | #define PIN_SRC_TEST(xname,nid) { \ | |
3402 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
3403 | .name = xname, \ | |
3404 | .info = alc_test_pin_src_info, \ | |
3405 | .get = alc_test_pin_src_get, \ | |
3406 | .put = alc_test_pin_src_put, \ | |
3407 | .private_value = nid \ | |
3408 | } | |
3409 | ||
c8b6bf9b | 3410 | static struct snd_kcontrol_new alc880_test_mixer[] = { |
05acb863 TI |
3411 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
3412 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
3413 | HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT), | |
3414 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
985be54b TI |
3415 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
3416 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
3417 | HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT), | |
3418 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
2fa522be TI |
3419 | PIN_CTL_TEST("Front Pin Mode", 0x14), |
3420 | PIN_CTL_TEST("Surround Pin Mode", 0x15), | |
3421 | PIN_CTL_TEST("CLFE Pin Mode", 0x16), | |
3422 | PIN_CTL_TEST("Side Pin Mode", 0x17), | |
3423 | PIN_CTL_TEST("In-1 Pin Mode", 0x18), | |
3424 | PIN_CTL_TEST("In-2 Pin Mode", 0x19), | |
3425 | PIN_CTL_TEST("In-3 Pin Mode", 0x1a), | |
3426 | PIN_CTL_TEST("In-4 Pin Mode", 0x1b), | |
3427 | PIN_SRC_TEST("In-1 Pin Source", 0x18), | |
3428 | PIN_SRC_TEST("In-2 Pin Source", 0x19), | |
3429 | PIN_SRC_TEST("In-3 Pin Source", 0x1a), | |
3430 | PIN_SRC_TEST("In-4 Pin Source", 0x1b), | |
3431 | HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
3432 | HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
3433 | HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
3434 | HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
3435 | HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT), | |
3436 | HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT), | |
3437 | HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT), | |
3438 | HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT), | |
3439 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT), | |
3440 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT), | |
2fa522be TI |
3441 | { |
3442 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
3443 | .name = "Channel Mode", | |
df694daa KY |
3444 | .info = alc_ch_mode_info, |
3445 | .get = alc_ch_mode_get, | |
3446 | .put = alc_ch_mode_put, | |
2fa522be TI |
3447 | }, |
3448 | { } /* end */ | |
3449 | }; | |
3450 | ||
3451 | static struct hda_verb alc880_test_init_verbs[] = { | |
3452 | /* Unmute inputs of 0x0c - 0x0f */ | |
05acb863 TI |
3453 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
3454 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
3455 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
3456 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
3457 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
3458 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
3459 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
3460 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2fa522be | 3461 | /* Vol output for 0x0c-0x0f */ |
05acb863 TI |
3462 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
3463 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3464 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3465 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2fa522be | 3466 | /* Set output pins 0x14-0x17 */ |
05acb863 TI |
3467 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
3468 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
3469 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
3470 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2fa522be | 3471 | /* Unmute output pins 0x14-0x17 */ |
05acb863 TI |
3472 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
3473 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3474 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3475 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2fa522be | 3476 | /* Set input pins 0x18-0x1c */ |
16ded525 TI |
3477 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
3478 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
05acb863 TI |
3479 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
3480 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
3481 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2fa522be | 3482 | /* Mute input pins 0x18-0x1b */ |
05acb863 TI |
3483 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
3484 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
3485 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
3486 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
71fe7b82 | 3487 | /* ADC set up */ |
05acb863 | 3488 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 3489 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 | 3490 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 3491 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 | 3492 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 3493 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
3494 | /* Analog input/passthru */ |
3495 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3496 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3497 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
3498 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
3499 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
2fa522be TI |
3500 | { } |
3501 | }; | |
3502 | #endif | |
3503 | ||
1da177e4 LT |
3504 | /* |
3505 | */ | |
3506 | ||
f5fcc13c TI |
3507 | static const char *alc880_models[ALC880_MODEL_LAST] = { |
3508 | [ALC880_3ST] = "3stack", | |
3509 | [ALC880_TCL_S700] = "tcl", | |
3510 | [ALC880_3ST_DIG] = "3stack-digout", | |
3511 | [ALC880_CLEVO] = "clevo", | |
3512 | [ALC880_5ST] = "5stack", | |
3513 | [ALC880_5ST_DIG] = "5stack-digout", | |
3514 | [ALC880_W810] = "w810", | |
3515 | [ALC880_Z71V] = "z71v", | |
3516 | [ALC880_6ST] = "6stack", | |
3517 | [ALC880_6ST_DIG] = "6stack-digout", | |
3518 | [ALC880_ASUS] = "asus", | |
3519 | [ALC880_ASUS_W1V] = "asus-w1v", | |
3520 | [ALC880_ASUS_DIG] = "asus-dig", | |
3521 | [ALC880_ASUS_DIG2] = "asus-dig2", | |
3522 | [ALC880_UNIWILL_DIG] = "uniwill", | |
2cf9f0fc TD |
3523 | [ALC880_UNIWILL_P53] = "uniwill-p53", |
3524 | [ALC880_FUJITSU] = "fujitsu", | |
f5fcc13c TI |
3525 | [ALC880_F1734] = "F1734", |
3526 | [ALC880_LG] = "lg", | |
3527 | [ALC880_LG_LW] = "lg-lw", | |
df99cd33 | 3528 | [ALC880_MEDION_RIM] = "medion", |
2fa522be | 3529 | #ifdef CONFIG_SND_DEBUG |
f5fcc13c | 3530 | [ALC880_TEST] = "test", |
2fa522be | 3531 | #endif |
f5fcc13c TI |
3532 | [ALC880_AUTO] = "auto", |
3533 | }; | |
3534 | ||
3535 | static struct snd_pci_quirk alc880_cfg_tbl[] = { | |
ac3e3741 | 3536 | SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810), |
f5fcc13c TI |
3537 | SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG), |
3538 | SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST), | |
3539 | SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG), | |
3540 | SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG), | |
3541 | SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG), | |
3542 | SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG), | |
3543 | SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG), | |
3544 | SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST), | |
f5fcc13c TI |
3545 | SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG), |
3546 | SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST), | |
f5fcc13c TI |
3547 | SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V), |
3548 | SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG), | |
3549 | SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG), | |
3550 | SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG), | |
3551 | SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG), | |
3552 | SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG), | |
3553 | SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V), | |
3554 | /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */ | |
3555 | SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG), | |
3556 | SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG), | |
186c3117 | 3557 | SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG), |
f5fcc13c TI |
3558 | SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG), |
3559 | SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST), | |
3560 | SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST), | |
ac3e3741 | 3561 | SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */ |
f5fcc13c | 3562 | SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST), |
ac3e3741 TI |
3563 | SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST), |
3564 | SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST), | |
f5fcc13c TI |
3565 | SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST), |
3566 | SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST), | |
f5fcc13c TI |
3567 | SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG), |
3568 | SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG), | |
3569 | SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG), | |
3570 | SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG), | |
ac3e3741 TI |
3571 | SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO), |
3572 | SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO), | |
f5fcc13c | 3573 | SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2), |
ac3e3741 | 3574 | SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG), |
f5fcc13c | 3575 | SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG), |
ac3e3741 | 3576 | SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734), |
f5fcc13c TI |
3577 | SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL), |
3578 | SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53), | |
ac3e3741 | 3579 | SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810), |
df99cd33 | 3580 | SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM), |
ac3e3741 | 3581 | SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG), |
f5fcc13c | 3582 | SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG), |
f5fcc13c | 3583 | SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734), |
1d11604e | 3584 | SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU), |
ac3e3741 | 3585 | SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL), |
2cf9f0fc | 3586 | SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU), |
ac3e3741 | 3587 | SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW), |
f5fcc13c TI |
3588 | SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG), |
3589 | SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG), | |
f5fcc13c | 3590 | SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW), |
ac3e3741 TI |
3591 | SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700), |
3592 | SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */ | |
3593 | SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG), | |
3594 | SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG), | |
f5fcc13c TI |
3595 | SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG), |
3596 | SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG), | |
ac3e3741 | 3597 | SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG), |
f5fcc13c | 3598 | SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG), |
ac3e3741 TI |
3599 | SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG), |
3600 | SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG), | |
f5fcc13c TI |
3601 | SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG), |
3602 | SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG), | |
3603 | SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG), | |
ac3e3741 TI |
3604 | SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */ |
3605 | SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG), | |
3606 | SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG), | |
1da177e4 LT |
3607 | {} |
3608 | }; | |
3609 | ||
16ded525 | 3610 | /* |
df694daa | 3611 | * ALC880 codec presets |
16ded525 | 3612 | */ |
16ded525 TI |
3613 | static struct alc_config_preset alc880_presets[] = { |
3614 | [ALC880_3ST] = { | |
e9edcee0 | 3615 | .mixers = { alc880_three_stack_mixer }, |
f12ab1e0 TI |
3616 | .init_verbs = { alc880_volume_init_verbs, |
3617 | alc880_pin_3stack_init_verbs }, | |
16ded525 | 3618 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
16ded525 | 3619 | .dac_nids = alc880_dac_nids, |
16ded525 TI |
3620 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
3621 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 3622 | .need_dac_fix = 1, |
16ded525 TI |
3623 | .input_mux = &alc880_capture_source, |
3624 | }, | |
3625 | [ALC880_3ST_DIG] = { | |
e9edcee0 | 3626 | .mixers = { alc880_three_stack_mixer }, |
f12ab1e0 TI |
3627 | .init_verbs = { alc880_volume_init_verbs, |
3628 | alc880_pin_3stack_init_verbs }, | |
16ded525 | 3629 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
16ded525 TI |
3630 | .dac_nids = alc880_dac_nids, |
3631 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3632 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
3633 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 3634 | .need_dac_fix = 1, |
16ded525 TI |
3635 | .input_mux = &alc880_capture_source, |
3636 | }, | |
df694daa KY |
3637 | [ALC880_TCL_S700] = { |
3638 | .mixers = { alc880_tcl_s700_mixer }, | |
3639 | .init_verbs = { alc880_volume_init_verbs, | |
3640 | alc880_pin_tcl_S700_init_verbs, | |
3641 | alc880_gpio2_init_verbs }, | |
3642 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
3643 | .dac_nids = alc880_dac_nids, | |
f9e336f6 TI |
3644 | .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */ |
3645 | .num_adc_nids = 1, /* single ADC */ | |
df694daa KY |
3646 | .hp_nid = 0x03, |
3647 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
3648 | .channel_mode = alc880_2_jack_modes, | |
3649 | .input_mux = &alc880_capture_source, | |
3650 | }, | |
16ded525 | 3651 | [ALC880_5ST] = { |
f12ab1e0 TI |
3652 | .mixers = { alc880_three_stack_mixer, |
3653 | alc880_five_stack_mixer}, | |
3654 | .init_verbs = { alc880_volume_init_verbs, | |
3655 | alc880_pin_5stack_init_verbs }, | |
16ded525 TI |
3656 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
3657 | .dac_nids = alc880_dac_nids, | |
16ded525 TI |
3658 | .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), |
3659 | .channel_mode = alc880_fivestack_modes, | |
3660 | .input_mux = &alc880_capture_source, | |
3661 | }, | |
3662 | [ALC880_5ST_DIG] = { | |
f12ab1e0 TI |
3663 | .mixers = { alc880_three_stack_mixer, |
3664 | alc880_five_stack_mixer }, | |
3665 | .init_verbs = { alc880_volume_init_verbs, | |
3666 | alc880_pin_5stack_init_verbs }, | |
16ded525 TI |
3667 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
3668 | .dac_nids = alc880_dac_nids, | |
3669 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3670 | .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), |
3671 | .channel_mode = alc880_fivestack_modes, | |
3672 | .input_mux = &alc880_capture_source, | |
3673 | }, | |
b6482d48 TI |
3674 | [ALC880_6ST] = { |
3675 | .mixers = { alc880_six_stack_mixer }, | |
f12ab1e0 TI |
3676 | .init_verbs = { alc880_volume_init_verbs, |
3677 | alc880_pin_6stack_init_verbs }, | |
b6482d48 TI |
3678 | .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), |
3679 | .dac_nids = alc880_6st_dac_nids, | |
3680 | .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), | |
3681 | .channel_mode = alc880_sixstack_modes, | |
3682 | .input_mux = &alc880_6stack_capture_source, | |
3683 | }, | |
16ded525 | 3684 | [ALC880_6ST_DIG] = { |
e9edcee0 | 3685 | .mixers = { alc880_six_stack_mixer }, |
f12ab1e0 TI |
3686 | .init_verbs = { alc880_volume_init_verbs, |
3687 | alc880_pin_6stack_init_verbs }, | |
16ded525 TI |
3688 | .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), |
3689 | .dac_nids = alc880_6st_dac_nids, | |
3690 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3691 | .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), |
3692 | .channel_mode = alc880_sixstack_modes, | |
3693 | .input_mux = &alc880_6stack_capture_source, | |
3694 | }, | |
3695 | [ALC880_W810] = { | |
e9edcee0 | 3696 | .mixers = { alc880_w810_base_mixer }, |
f12ab1e0 TI |
3697 | .init_verbs = { alc880_volume_init_verbs, |
3698 | alc880_pin_w810_init_verbs, | |
b0af0de5 | 3699 | alc880_gpio2_init_verbs }, |
16ded525 TI |
3700 | .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids), |
3701 | .dac_nids = alc880_w810_dac_nids, | |
3702 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3703 | .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), |
3704 | .channel_mode = alc880_w810_modes, | |
3705 | .input_mux = &alc880_capture_source, | |
3706 | }, | |
3707 | [ALC880_Z71V] = { | |
e9edcee0 | 3708 | .mixers = { alc880_z71v_mixer }, |
f12ab1e0 TI |
3709 | .init_verbs = { alc880_volume_init_verbs, |
3710 | alc880_pin_z71v_init_verbs }, | |
16ded525 TI |
3711 | .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids), |
3712 | .dac_nids = alc880_z71v_dac_nids, | |
3713 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3714 | .hp_nid = 0x03, | |
e9edcee0 TI |
3715 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), |
3716 | .channel_mode = alc880_2_jack_modes, | |
16ded525 TI |
3717 | .input_mux = &alc880_capture_source, |
3718 | }, | |
3719 | [ALC880_F1734] = { | |
e9edcee0 | 3720 | .mixers = { alc880_f1734_mixer }, |
f12ab1e0 TI |
3721 | .init_verbs = { alc880_volume_init_verbs, |
3722 | alc880_pin_f1734_init_verbs }, | |
e9edcee0 TI |
3723 | .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids), |
3724 | .dac_nids = alc880_f1734_dac_nids, | |
3725 | .hp_nid = 0x02, | |
3726 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
3727 | .channel_mode = alc880_2_jack_modes, | |
937b4160 TI |
3728 | .input_mux = &alc880_f1734_capture_source, |
3729 | .unsol_event = alc880_uniwill_p53_unsol_event, | |
3730 | .init_hook = alc880_uniwill_p53_hp_automute, | |
16ded525 TI |
3731 | }, |
3732 | [ALC880_ASUS] = { | |
e9edcee0 | 3733 | .mixers = { alc880_asus_mixer }, |
f12ab1e0 TI |
3734 | .init_verbs = { alc880_volume_init_verbs, |
3735 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
3736 | alc880_gpio1_init_verbs }, |
3737 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3738 | .dac_nids = alc880_asus_dac_nids, | |
3739 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), | |
3740 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3741 | .need_dac_fix = 1, |
16ded525 TI |
3742 | .input_mux = &alc880_capture_source, |
3743 | }, | |
3744 | [ALC880_ASUS_DIG] = { | |
e9edcee0 | 3745 | .mixers = { alc880_asus_mixer }, |
f12ab1e0 TI |
3746 | .init_verbs = { alc880_volume_init_verbs, |
3747 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
3748 | alc880_gpio1_init_verbs }, |
3749 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3750 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 3751 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
3752 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
3753 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3754 | .need_dac_fix = 1, |
16ded525 TI |
3755 | .input_mux = &alc880_capture_source, |
3756 | }, | |
df694daa KY |
3757 | [ALC880_ASUS_DIG2] = { |
3758 | .mixers = { alc880_asus_mixer }, | |
f12ab1e0 TI |
3759 | .init_verbs = { alc880_volume_init_verbs, |
3760 | alc880_pin_asus_init_verbs, | |
df694daa KY |
3761 | alc880_gpio2_init_verbs }, /* use GPIO2 */ |
3762 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3763 | .dac_nids = alc880_asus_dac_nids, | |
3764 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3765 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), | |
3766 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3767 | .need_dac_fix = 1, |
df694daa KY |
3768 | .input_mux = &alc880_capture_source, |
3769 | }, | |
16ded525 | 3770 | [ALC880_ASUS_W1V] = { |
e9edcee0 | 3771 | .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer }, |
f12ab1e0 TI |
3772 | .init_verbs = { alc880_volume_init_verbs, |
3773 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
3774 | alc880_gpio1_init_verbs }, |
3775 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3776 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 3777 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
3778 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
3779 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3780 | .need_dac_fix = 1, |
16ded525 TI |
3781 | .input_mux = &alc880_capture_source, |
3782 | }, | |
3783 | [ALC880_UNIWILL_DIG] = { | |
3c10a9d9 | 3784 | .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer }, |
ccc656ce KY |
3785 | .init_verbs = { alc880_volume_init_verbs, |
3786 | alc880_pin_asus_init_verbs }, | |
e9edcee0 TI |
3787 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), |
3788 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 3789 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
3790 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
3791 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3792 | .need_dac_fix = 1, |
16ded525 TI |
3793 | .input_mux = &alc880_capture_source, |
3794 | }, | |
ccc656ce KY |
3795 | [ALC880_UNIWILL] = { |
3796 | .mixers = { alc880_uniwill_mixer }, | |
3797 | .init_verbs = { alc880_volume_init_verbs, | |
3798 | alc880_uniwill_init_verbs }, | |
3799 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3800 | .dac_nids = alc880_asus_dac_nids, | |
3801 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3802 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
3803 | .channel_mode = alc880_threestack_modes, | |
3804 | .need_dac_fix = 1, | |
3805 | .input_mux = &alc880_capture_source, | |
3806 | .unsol_event = alc880_uniwill_unsol_event, | |
3807 | .init_hook = alc880_uniwill_automute, | |
3808 | }, | |
3809 | [ALC880_UNIWILL_P53] = { | |
3810 | .mixers = { alc880_uniwill_p53_mixer }, | |
3811 | .init_verbs = { alc880_volume_init_verbs, | |
3812 | alc880_uniwill_p53_init_verbs }, | |
3813 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3814 | .dac_nids = alc880_asus_dac_nids, | |
3815 | .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), | |
2cf9f0fc TD |
3816 | .channel_mode = alc880_threestack_modes, |
3817 | .input_mux = &alc880_capture_source, | |
3818 | .unsol_event = alc880_uniwill_p53_unsol_event, | |
3819 | .init_hook = alc880_uniwill_p53_hp_automute, | |
3820 | }, | |
3821 | [ALC880_FUJITSU] = { | |
f12ab1e0 | 3822 | .mixers = { alc880_fujitsu_mixer, |
2cf9f0fc TD |
3823 | alc880_pcbeep_mixer, }, |
3824 | .init_verbs = { alc880_volume_init_verbs, | |
3825 | alc880_uniwill_p53_init_verbs, | |
3826 | alc880_beep_init_verbs }, | |
3827 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
3828 | .dac_nids = alc880_dac_nids, | |
d53d7d9e | 3829 | .dig_out_nid = ALC880_DIGOUT_NID, |
2cf9f0fc TD |
3830 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), |
3831 | .channel_mode = alc880_2_jack_modes, | |
ccc656ce KY |
3832 | .input_mux = &alc880_capture_source, |
3833 | .unsol_event = alc880_uniwill_p53_unsol_event, | |
3834 | .init_hook = alc880_uniwill_p53_hp_automute, | |
3835 | }, | |
df694daa KY |
3836 | [ALC880_CLEVO] = { |
3837 | .mixers = { alc880_three_stack_mixer }, | |
3838 | .init_verbs = { alc880_volume_init_verbs, | |
3839 | alc880_pin_clevo_init_verbs }, | |
3840 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
3841 | .dac_nids = alc880_dac_nids, | |
3842 | .hp_nid = 0x03, | |
3843 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
3844 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 3845 | .need_dac_fix = 1, |
df694daa KY |
3846 | .input_mux = &alc880_capture_source, |
3847 | }, | |
ae6b813a TI |
3848 | [ALC880_LG] = { |
3849 | .mixers = { alc880_lg_mixer }, | |
3850 | .init_verbs = { alc880_volume_init_verbs, | |
3851 | alc880_lg_init_verbs }, | |
3852 | .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids), | |
3853 | .dac_nids = alc880_lg_dac_nids, | |
3854 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3855 | .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes), | |
3856 | .channel_mode = alc880_lg_ch_modes, | |
4e195a7b | 3857 | .need_dac_fix = 1, |
ae6b813a TI |
3858 | .input_mux = &alc880_lg_capture_source, |
3859 | .unsol_event = alc880_lg_unsol_event, | |
3860 | .init_hook = alc880_lg_automute, | |
cb53c626 TI |
3861 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
3862 | .loopbacks = alc880_lg_loopbacks, | |
3863 | #endif | |
ae6b813a | 3864 | }, |
d681518a TI |
3865 | [ALC880_LG_LW] = { |
3866 | .mixers = { alc880_lg_lw_mixer }, | |
3867 | .init_verbs = { alc880_volume_init_verbs, | |
3868 | alc880_lg_lw_init_verbs }, | |
0a8c5da3 | 3869 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
d681518a TI |
3870 | .dac_nids = alc880_dac_nids, |
3871 | .dig_out_nid = ALC880_DIGOUT_NID, | |
0a8c5da3 CM |
3872 | .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes), |
3873 | .channel_mode = alc880_lg_lw_modes, | |
d681518a TI |
3874 | .input_mux = &alc880_lg_lw_capture_source, |
3875 | .unsol_event = alc880_lg_lw_unsol_event, | |
3876 | .init_hook = alc880_lg_lw_automute, | |
3877 | }, | |
df99cd33 TI |
3878 | [ALC880_MEDION_RIM] = { |
3879 | .mixers = { alc880_medion_rim_mixer }, | |
3880 | .init_verbs = { alc880_volume_init_verbs, | |
3881 | alc880_medion_rim_init_verbs, | |
3882 | alc_gpio2_init_verbs }, | |
3883 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
3884 | .dac_nids = alc880_dac_nids, | |
3885 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3886 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
3887 | .channel_mode = alc880_2_jack_modes, | |
3888 | .input_mux = &alc880_medion_rim_capture_source, | |
3889 | .unsol_event = alc880_medion_rim_unsol_event, | |
3890 | .init_hook = alc880_medion_rim_automute, | |
3891 | }, | |
16ded525 TI |
3892 | #ifdef CONFIG_SND_DEBUG |
3893 | [ALC880_TEST] = { | |
e9edcee0 TI |
3894 | .mixers = { alc880_test_mixer }, |
3895 | .init_verbs = { alc880_test_init_verbs }, | |
16ded525 TI |
3896 | .num_dacs = ARRAY_SIZE(alc880_test_dac_nids), |
3897 | .dac_nids = alc880_test_dac_nids, | |
3898 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3899 | .num_channel_mode = ARRAY_SIZE(alc880_test_modes), |
3900 | .channel_mode = alc880_test_modes, | |
3901 | .input_mux = &alc880_test_capture_source, | |
3902 | }, | |
3903 | #endif | |
3904 | }; | |
3905 | ||
e9edcee0 TI |
3906 | /* |
3907 | * Automatic parse of I/O pins from the BIOS configuration | |
3908 | */ | |
3909 | ||
e9edcee0 TI |
3910 | enum { |
3911 | ALC_CTL_WIDGET_VOL, | |
3912 | ALC_CTL_WIDGET_MUTE, | |
3913 | ALC_CTL_BIND_MUTE, | |
3914 | }; | |
c8b6bf9b | 3915 | static struct snd_kcontrol_new alc880_control_templates[] = { |
e9edcee0 TI |
3916 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
3917 | HDA_CODEC_MUTE(NULL, 0, 0, 0), | |
985be54b | 3918 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
e9edcee0 TI |
3919 | }; |
3920 | ||
3921 | /* add dynamic controls */ | |
f12ab1e0 TI |
3922 | static int add_control(struct alc_spec *spec, int type, const char *name, |
3923 | unsigned long val) | |
e9edcee0 | 3924 | { |
c8b6bf9b | 3925 | struct snd_kcontrol_new *knew; |
e9edcee0 | 3926 | |
603c4019 TI |
3927 | snd_array_init(&spec->kctls, sizeof(*knew), 32); |
3928 | knew = snd_array_new(&spec->kctls); | |
3929 | if (!knew) | |
3930 | return -ENOMEM; | |
e9edcee0 | 3931 | *knew = alc880_control_templates[type]; |
543537bd | 3932 | knew->name = kstrdup(name, GFP_KERNEL); |
f12ab1e0 | 3933 | if (!knew->name) |
e9edcee0 TI |
3934 | return -ENOMEM; |
3935 | knew->private_value = val; | |
e9edcee0 TI |
3936 | return 0; |
3937 | } | |
3938 | ||
3939 | #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17) | |
3940 | #define alc880_fixed_pin_idx(nid) ((nid) - 0x14) | |
3941 | #define alc880_is_multi_pin(nid) ((nid) >= 0x18) | |
3942 | #define alc880_multi_pin_idx(nid) ((nid) - 0x18) | |
3943 | #define alc880_is_input_pin(nid) ((nid) >= 0x18) | |
3944 | #define alc880_input_pin_idx(nid) ((nid) - 0x18) | |
3945 | #define alc880_idx_to_dac(nid) ((nid) + 0x02) | |
3946 | #define alc880_dac_to_idx(nid) ((nid) - 0x02) | |
3947 | #define alc880_idx_to_mixer(nid) ((nid) + 0x0c) | |
3948 | #define alc880_idx_to_selector(nid) ((nid) + 0x10) | |
3949 | #define ALC880_PIN_CD_NID 0x1c | |
3950 | ||
3951 | /* fill in the dac_nids table from the parsed pin configuration */ | |
f12ab1e0 TI |
3952 | static int alc880_auto_fill_dac_nids(struct alc_spec *spec, |
3953 | const struct auto_pin_cfg *cfg) | |
e9edcee0 TI |
3954 | { |
3955 | hda_nid_t nid; | |
3956 | int assigned[4]; | |
3957 | int i, j; | |
3958 | ||
3959 | memset(assigned, 0, sizeof(assigned)); | |
b0af0de5 | 3960 | spec->multiout.dac_nids = spec->private_dac_nids; |
e9edcee0 TI |
3961 | |
3962 | /* check the pins hardwired to audio widget */ | |
3963 | for (i = 0; i < cfg->line_outs; i++) { | |
3964 | nid = cfg->line_out_pins[i]; | |
3965 | if (alc880_is_fixed_pin(nid)) { | |
3966 | int idx = alc880_fixed_pin_idx(nid); | |
5014f193 | 3967 | spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx); |
e9edcee0 TI |
3968 | assigned[idx] = 1; |
3969 | } | |
3970 | } | |
3971 | /* left pins can be connect to any audio widget */ | |
3972 | for (i = 0; i < cfg->line_outs; i++) { | |
3973 | nid = cfg->line_out_pins[i]; | |
3974 | if (alc880_is_fixed_pin(nid)) | |
3975 | continue; | |
3976 | /* search for an empty channel */ | |
3977 | for (j = 0; j < cfg->line_outs; j++) { | |
f12ab1e0 TI |
3978 | if (!assigned[j]) { |
3979 | spec->multiout.dac_nids[i] = | |
3980 | alc880_idx_to_dac(j); | |
e9edcee0 TI |
3981 | assigned[j] = 1; |
3982 | break; | |
3983 | } | |
3984 | } | |
3985 | } | |
3986 | spec->multiout.num_dacs = cfg->line_outs; | |
3987 | return 0; | |
3988 | } | |
3989 | ||
3990 | /* add playback controls from the parsed DAC table */ | |
df694daa KY |
3991 | static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, |
3992 | const struct auto_pin_cfg *cfg) | |
e9edcee0 TI |
3993 | { |
3994 | char name[32]; | |
f12ab1e0 TI |
3995 | static const char *chname[4] = { |
3996 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
3997 | }; | |
e9edcee0 TI |
3998 | hda_nid_t nid; |
3999 | int i, err; | |
4000 | ||
4001 | for (i = 0; i < cfg->line_outs; i++) { | |
f12ab1e0 | 4002 | if (!spec->multiout.dac_nids[i]) |
e9edcee0 TI |
4003 | continue; |
4004 | nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i])); | |
4005 | if (i == 2) { | |
4006 | /* Center/LFE */ | |
f12ab1e0 TI |
4007 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
4008 | "Center Playback Volume", | |
4009 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, | |
4010 | HDA_OUTPUT)); | |
4011 | if (err < 0) | |
e9edcee0 | 4012 | return err; |
f12ab1e0 TI |
4013 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
4014 | "LFE Playback Volume", | |
4015 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
4016 | HDA_OUTPUT)); | |
4017 | if (err < 0) | |
e9edcee0 | 4018 | return err; |
f12ab1e0 TI |
4019 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
4020 | "Center Playback Switch", | |
4021 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, | |
4022 | HDA_INPUT)); | |
4023 | if (err < 0) | |
e9edcee0 | 4024 | return err; |
f12ab1e0 TI |
4025 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
4026 | "LFE Playback Switch", | |
4027 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, | |
4028 | HDA_INPUT)); | |
4029 | if (err < 0) | |
e9edcee0 TI |
4030 | return err; |
4031 | } else { | |
4032 | sprintf(name, "%s Playback Volume", chname[i]); | |
f12ab1e0 TI |
4033 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
4034 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
4035 | HDA_OUTPUT)); | |
4036 | if (err < 0) | |
e9edcee0 TI |
4037 | return err; |
4038 | sprintf(name, "%s Playback Switch", chname[i]); | |
f12ab1e0 TI |
4039 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
4040 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, | |
4041 | HDA_INPUT)); | |
4042 | if (err < 0) | |
e9edcee0 TI |
4043 | return err; |
4044 | } | |
4045 | } | |
e9edcee0 TI |
4046 | return 0; |
4047 | } | |
4048 | ||
8d88bc3d TI |
4049 | /* add playback controls for speaker and HP outputs */ |
4050 | static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, | |
4051 | const char *pfx) | |
e9edcee0 TI |
4052 | { |
4053 | hda_nid_t nid; | |
4054 | int err; | |
8d88bc3d | 4055 | char name[32]; |
e9edcee0 | 4056 | |
f12ab1e0 | 4057 | if (!pin) |
e9edcee0 TI |
4058 | return 0; |
4059 | ||
4060 | if (alc880_is_fixed_pin(pin)) { | |
4061 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
82bc955f | 4062 | /* specify the DAC as the extra output */ |
f12ab1e0 | 4063 | if (!spec->multiout.hp_nid) |
e9edcee0 | 4064 | spec->multiout.hp_nid = nid; |
82bc955f TI |
4065 | else |
4066 | spec->multiout.extra_out_nid[0] = nid; | |
e9edcee0 TI |
4067 | /* control HP volume/switch on the output mixer amp */ |
4068 | nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin)); | |
8d88bc3d | 4069 | sprintf(name, "%s Playback Volume", pfx); |
f12ab1e0 TI |
4070 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
4071 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
4072 | if (err < 0) | |
e9edcee0 | 4073 | return err; |
8d88bc3d | 4074 | sprintf(name, "%s Playback Switch", pfx); |
f12ab1e0 TI |
4075 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
4076 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); | |
4077 | if (err < 0) | |
e9edcee0 TI |
4078 | return err; |
4079 | } else if (alc880_is_multi_pin(pin)) { | |
4080 | /* set manual connection */ | |
e9edcee0 | 4081 | /* we have only a switch on HP-out PIN */ |
8d88bc3d | 4082 | sprintf(name, "%s Playback Switch", pfx); |
f12ab1e0 TI |
4083 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
4084 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
4085 | if (err < 0) | |
e9edcee0 TI |
4086 | return err; |
4087 | } | |
4088 | return 0; | |
4089 | } | |
4090 | ||
4091 | /* create input playback/capture controls for the given pin */ | |
f12ab1e0 TI |
4092 | static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, |
4093 | const char *ctlname, | |
df694daa | 4094 | int idx, hda_nid_t mix_nid) |
e9edcee0 TI |
4095 | { |
4096 | char name[32]; | |
df694daa | 4097 | int err; |
e9edcee0 TI |
4098 | |
4099 | sprintf(name, "%s Playback Volume", ctlname); | |
f12ab1e0 TI |
4100 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
4101 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); | |
4102 | if (err < 0) | |
e9edcee0 TI |
4103 | return err; |
4104 | sprintf(name, "%s Playback Switch", ctlname); | |
f12ab1e0 TI |
4105 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
4106 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); | |
4107 | if (err < 0) | |
e9edcee0 TI |
4108 | return err; |
4109 | return 0; | |
4110 | } | |
4111 | ||
4112 | /* create playback/capture controls for input pins */ | |
df694daa KY |
4113 | static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, |
4114 | const struct auto_pin_cfg *cfg) | |
e9edcee0 | 4115 | { |
e9edcee0 | 4116 | struct hda_input_mux *imux = &spec->private_imux; |
df694daa | 4117 | int i, err, idx; |
e9edcee0 TI |
4118 | |
4119 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
4120 | if (alc880_is_input_pin(cfg->input_pins[i])) { | |
df694daa | 4121 | idx = alc880_input_pin_idx(cfg->input_pins[i]); |
4a471b7d TI |
4122 | err = new_analog_input(spec, cfg->input_pins[i], |
4123 | auto_pin_cfg_labels[i], | |
df694daa | 4124 | idx, 0x0b); |
e9edcee0 TI |
4125 | if (err < 0) |
4126 | return err; | |
f12ab1e0 TI |
4127 | imux->items[imux->num_items].label = |
4128 | auto_pin_cfg_labels[i]; | |
4129 | imux->items[imux->num_items].index = | |
4130 | alc880_input_pin_idx(cfg->input_pins[i]); | |
e9edcee0 TI |
4131 | imux->num_items++; |
4132 | } | |
4133 | } | |
4134 | return 0; | |
4135 | } | |
4136 | ||
f6c7e546 TI |
4137 | static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid, |
4138 | unsigned int pin_type) | |
4139 | { | |
4140 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4141 | pin_type); | |
4142 | /* unmute pin */ | |
d260cdf6 TI |
4143 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
4144 | AMP_OUT_UNMUTE); | |
f6c7e546 TI |
4145 | } |
4146 | ||
df694daa KY |
4147 | static void alc880_auto_set_output_and_unmute(struct hda_codec *codec, |
4148 | hda_nid_t nid, int pin_type, | |
e9edcee0 TI |
4149 | int dac_idx) |
4150 | { | |
f6c7e546 | 4151 | alc_set_pin_output(codec, nid, pin_type); |
e9edcee0 TI |
4152 | /* need the manual connection? */ |
4153 | if (alc880_is_multi_pin(nid)) { | |
4154 | struct alc_spec *spec = codec->spec; | |
4155 | int idx = alc880_multi_pin_idx(nid); | |
4156 | snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, | |
4157 | AC_VERB_SET_CONNECT_SEL, | |
4158 | alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); | |
4159 | } | |
4160 | } | |
4161 | ||
baba8ee9 TI |
4162 | static int get_pin_type(int line_out_type) |
4163 | { | |
4164 | if (line_out_type == AUTO_PIN_HP_OUT) | |
4165 | return PIN_HP; | |
4166 | else | |
4167 | return PIN_OUT; | |
4168 | } | |
4169 | ||
e9edcee0 TI |
4170 | static void alc880_auto_init_multi_out(struct hda_codec *codec) |
4171 | { | |
4172 | struct alc_spec *spec = codec->spec; | |
4173 | int i; | |
ea1fb29a | 4174 | |
bc9f98a9 | 4175 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
e9edcee0 TI |
4176 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
4177 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 TI |
4178 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
4179 | alc880_auto_set_output_and_unmute(codec, nid, pin_type, i); | |
e9edcee0 TI |
4180 | } |
4181 | } | |
4182 | ||
8d88bc3d | 4183 | static void alc880_auto_init_extra_out(struct hda_codec *codec) |
e9edcee0 TI |
4184 | { |
4185 | struct alc_spec *spec = codec->spec; | |
4186 | hda_nid_t pin; | |
4187 | ||
82bc955f | 4188 | pin = spec->autocfg.speaker_pins[0]; |
8d88bc3d TI |
4189 | if (pin) /* connect to front */ |
4190 | alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
eb06ed8f | 4191 | pin = spec->autocfg.hp_pins[0]; |
e9edcee0 TI |
4192 | if (pin) /* connect to front */ |
4193 | alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
4194 | } | |
4195 | ||
4196 | static void alc880_auto_init_analog_input(struct hda_codec *codec) | |
4197 | { | |
4198 | struct alc_spec *spec = codec->spec; | |
4199 | int i; | |
4200 | ||
4201 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
4202 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
4203 | if (alc880_is_input_pin(nid)) { | |
f12ab1e0 TI |
4204 | snd_hda_codec_write(codec, nid, 0, |
4205 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4206 | i <= AUTO_PIN_FRONT_MIC ? | |
4207 | PIN_VREF80 : PIN_IN); | |
e9edcee0 | 4208 | if (nid != ALC880_PIN_CD_NID) |
f12ab1e0 TI |
4209 | snd_hda_codec_write(codec, nid, 0, |
4210 | AC_VERB_SET_AMP_GAIN_MUTE, | |
e9edcee0 TI |
4211 | AMP_OUT_MUTE); |
4212 | } | |
4213 | } | |
4214 | } | |
4215 | ||
4216 | /* parse the BIOS configuration and set up the alc_spec */ | |
f12ab1e0 TI |
4217 | /* return 1 if successful, 0 if the proper config is not found, |
4218 | * or a negative error code | |
4219 | */ | |
e9edcee0 TI |
4220 | static int alc880_parse_auto_config(struct hda_codec *codec) |
4221 | { | |
4222 | struct alc_spec *spec = codec->spec; | |
4223 | int err; | |
df694daa | 4224 | static hda_nid_t alc880_ignore[] = { 0x1d, 0 }; |
e9edcee0 | 4225 | |
f12ab1e0 TI |
4226 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
4227 | alc880_ignore); | |
4228 | if (err < 0) | |
e9edcee0 | 4229 | return err; |
f12ab1e0 | 4230 | if (!spec->autocfg.line_outs) |
e9edcee0 | 4231 | return 0; /* can't find valid BIOS pin config */ |
df694daa | 4232 | |
f12ab1e0 TI |
4233 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
4234 | if (err < 0) | |
4235 | return err; | |
4236 | err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
4237 | if (err < 0) | |
4238 | return err; | |
4239 | err = alc880_auto_create_extra_out(spec, | |
4240 | spec->autocfg.speaker_pins[0], | |
4241 | "Speaker"); | |
4242 | if (err < 0) | |
4243 | return err; | |
4244 | err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], | |
4245 | "Headphone"); | |
4246 | if (err < 0) | |
4247 | return err; | |
4248 | err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
4249 | if (err < 0) | |
e9edcee0 TI |
4250 | return err; |
4251 | ||
4252 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
4253 | ||
4254 | if (spec->autocfg.dig_out_pin) | |
4255 | spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; | |
4256 | if (spec->autocfg.dig_in_pin) | |
4257 | spec->dig_in_nid = ALC880_DIGIN_NID; | |
4258 | ||
603c4019 | 4259 | if (spec->kctls.list) |
d88897ea | 4260 | add_mixer(spec, spec->kctls.list); |
e9edcee0 | 4261 | |
d88897ea | 4262 | add_verb(spec, alc880_volume_init_verbs); |
e9edcee0 | 4263 | |
a1e8d2da | 4264 | spec->num_mux_defs = 1; |
e9edcee0 TI |
4265 | spec->input_mux = &spec->private_imux; |
4266 | ||
e044c39a | 4267 | store_pin_configs(codec); |
e9edcee0 TI |
4268 | return 1; |
4269 | } | |
4270 | ||
ae6b813a TI |
4271 | /* additional initialization for auto-configuration model */ |
4272 | static void alc880_auto_init(struct hda_codec *codec) | |
e9edcee0 | 4273 | { |
f6c7e546 | 4274 | struct alc_spec *spec = codec->spec; |
e9edcee0 | 4275 | alc880_auto_init_multi_out(codec); |
8d88bc3d | 4276 | alc880_auto_init_extra_out(codec); |
e9edcee0 | 4277 | alc880_auto_init_analog_input(codec); |
f6c7e546 | 4278 | if (spec->unsol_event) |
7fb0d78f | 4279 | alc_inithook(codec); |
e9edcee0 TI |
4280 | } |
4281 | ||
4282 | /* | |
4283 | * OK, here we have finally the patch for ALC880 | |
4284 | */ | |
4285 | ||
f9e336f6 TI |
4286 | static void set_capture_mixer(struct alc_spec *spec) |
4287 | { | |
4288 | static struct snd_kcontrol_new *caps[3] = { | |
4289 | alc_capture_mixer1, | |
4290 | alc_capture_mixer2, | |
4291 | alc_capture_mixer3, | |
4292 | }; | |
30d72e9f | 4293 | if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) |
f9e336f6 TI |
4294 | spec->cap_mixer = caps[spec->num_adc_nids - 1]; |
4295 | } | |
4296 | ||
1da177e4 LT |
4297 | static int patch_alc880(struct hda_codec *codec) |
4298 | { | |
4299 | struct alc_spec *spec; | |
4300 | int board_config; | |
df694daa | 4301 | int err; |
1da177e4 | 4302 | |
e560d8d8 | 4303 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
1da177e4 LT |
4304 | if (spec == NULL) |
4305 | return -ENOMEM; | |
4306 | ||
4307 | codec->spec = spec; | |
4308 | ||
f5fcc13c TI |
4309 | board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST, |
4310 | alc880_models, | |
4311 | alc880_cfg_tbl); | |
4312 | if (board_config < 0) { | |
9c7f852e TI |
4313 | printk(KERN_INFO "hda_codec: Unknown model for ALC880, " |
4314 | "trying auto-probe from BIOS...\n"); | |
e9edcee0 | 4315 | board_config = ALC880_AUTO; |
1da177e4 | 4316 | } |
1da177e4 | 4317 | |
e9edcee0 TI |
4318 | if (board_config == ALC880_AUTO) { |
4319 | /* automatic parse from the BIOS config */ | |
4320 | err = alc880_parse_auto_config(codec); | |
4321 | if (err < 0) { | |
4322 | alc_free(codec); | |
4323 | return err; | |
f12ab1e0 | 4324 | } else if (!err) { |
9c7f852e TI |
4325 | printk(KERN_INFO |
4326 | "hda_codec: Cannot set up configuration " | |
4327 | "from BIOS. Using 3-stack mode...\n"); | |
e9edcee0 TI |
4328 | board_config = ALC880_3ST; |
4329 | } | |
1da177e4 LT |
4330 | } |
4331 | ||
df694daa KY |
4332 | if (board_config != ALC880_AUTO) |
4333 | setup_preset(spec, &alc880_presets[board_config]); | |
1da177e4 LT |
4334 | |
4335 | spec->stream_name_analog = "ALC880 Analog"; | |
4336 | spec->stream_analog_playback = &alc880_pcm_analog_playback; | |
4337 | spec->stream_analog_capture = &alc880_pcm_analog_capture; | |
6330079f | 4338 | spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture; |
1da177e4 LT |
4339 | |
4340 | spec->stream_name_digital = "ALC880 Digital"; | |
4341 | spec->stream_digital_playback = &alc880_pcm_digital_playback; | |
4342 | spec->stream_digital_capture = &alc880_pcm_digital_capture; | |
4343 | ||
f12ab1e0 | 4344 | if (!spec->adc_nids && spec->input_mux) { |
e9edcee0 | 4345 | /* check whether NID 0x07 is valid */ |
54d17403 | 4346 | unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); |
f12ab1e0 TI |
4347 | /* get type */ |
4348 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
e9edcee0 TI |
4349 | if (wcap != AC_WID_AUD_IN) { |
4350 | spec->adc_nids = alc880_adc_nids_alt; | |
4351 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); | |
e9edcee0 TI |
4352 | } else { |
4353 | spec->adc_nids = alc880_adc_nids; | |
4354 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids); | |
e9edcee0 TI |
4355 | } |
4356 | } | |
f9e336f6 | 4357 | set_capture_mixer(spec); |
1da177e4 | 4358 | |
2134ea4f TI |
4359 | spec->vmaster_nid = 0x0c; |
4360 | ||
1da177e4 | 4361 | codec->patch_ops = alc_patch_ops; |
e9edcee0 | 4362 | if (board_config == ALC880_AUTO) |
ae6b813a | 4363 | spec->init_hook = alc880_auto_init; |
cb53c626 TI |
4364 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
4365 | if (!spec->loopback.amplist) | |
4366 | spec->loopback.amplist = alc880_loopbacks; | |
4367 | #endif | |
daead538 | 4368 | codec->proc_widget_hook = print_realtek_coef; |
1da177e4 LT |
4369 | |
4370 | return 0; | |
4371 | } | |
4372 | ||
e9edcee0 | 4373 | |
1da177e4 LT |
4374 | /* |
4375 | * ALC260 support | |
4376 | */ | |
4377 | ||
e9edcee0 TI |
4378 | static hda_nid_t alc260_dac_nids[1] = { |
4379 | /* front */ | |
4380 | 0x02, | |
4381 | }; | |
4382 | ||
4383 | static hda_nid_t alc260_adc_nids[1] = { | |
4384 | /* ADC0 */ | |
4385 | 0x04, | |
4386 | }; | |
4387 | ||
df694daa | 4388 | static hda_nid_t alc260_adc_nids_alt[1] = { |
e9edcee0 TI |
4389 | /* ADC1 */ |
4390 | 0x05, | |
4391 | }; | |
4392 | ||
d57fdac0 JW |
4393 | /* NIDs used when simultaneous access to both ADCs makes sense. Note that |
4394 | * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC. | |
4395 | */ | |
4396 | static hda_nid_t alc260_dual_adc_nids[2] = { | |
4c5186ed JW |
4397 | /* ADC0, ADC1 */ |
4398 | 0x04, 0x05 | |
4399 | }; | |
4400 | ||
e9edcee0 TI |
4401 | #define ALC260_DIGOUT_NID 0x03 |
4402 | #define ALC260_DIGIN_NID 0x06 | |
4403 | ||
4404 | static struct hda_input_mux alc260_capture_source = { | |
4405 | .num_items = 4, | |
4406 | .items = { | |
4407 | { "Mic", 0x0 }, | |
4408 | { "Front Mic", 0x1 }, | |
4409 | { "Line", 0x2 }, | |
4410 | { "CD", 0x4 }, | |
4411 | }, | |
4412 | }; | |
4413 | ||
17e7aec6 | 4414 | /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack, |
a1e8d2da JW |
4415 | * headphone jack and the internal CD lines since these are the only pins at |
4416 | * which audio can appear. For flexibility, also allow the option of | |
4417 | * recording the mixer output on the second ADC (ADC0 doesn't have a | |
4418 | * connection to the mixer output). | |
a9430dd8 | 4419 | */ |
a1e8d2da JW |
4420 | static struct hda_input_mux alc260_fujitsu_capture_sources[2] = { |
4421 | { | |
4422 | .num_items = 3, | |
4423 | .items = { | |
4424 | { "Mic/Line", 0x0 }, | |
4425 | { "CD", 0x4 }, | |
4426 | { "Headphone", 0x2 }, | |
4427 | }, | |
a9430dd8 | 4428 | }, |
a1e8d2da JW |
4429 | { |
4430 | .num_items = 4, | |
4431 | .items = { | |
4432 | { "Mic/Line", 0x0 }, | |
4433 | { "CD", 0x4 }, | |
4434 | { "Headphone", 0x2 }, | |
4435 | { "Mixer", 0x5 }, | |
4436 | }, | |
4437 | }, | |
4438 | ||
a9430dd8 JW |
4439 | }; |
4440 | ||
a1e8d2da JW |
4441 | /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to |
4442 | * the Fujitsu S702x, but jacks are marked differently. | |
0bfc90e9 | 4443 | */ |
a1e8d2da JW |
4444 | static struct hda_input_mux alc260_acer_capture_sources[2] = { |
4445 | { | |
4446 | .num_items = 4, | |
4447 | .items = { | |
4448 | { "Mic", 0x0 }, | |
4449 | { "Line", 0x2 }, | |
4450 | { "CD", 0x4 }, | |
4451 | { "Headphone", 0x5 }, | |
4452 | }, | |
4453 | }, | |
4454 | { | |
4455 | .num_items = 5, | |
4456 | .items = { | |
4457 | { "Mic", 0x0 }, | |
4458 | { "Line", 0x2 }, | |
4459 | { "CD", 0x4 }, | |
4460 | { "Headphone", 0x6 }, | |
4461 | { "Mixer", 0x5 }, | |
4462 | }, | |
0bfc90e9 JW |
4463 | }, |
4464 | }; | |
1da177e4 LT |
4465 | /* |
4466 | * This is just place-holder, so there's something for alc_build_pcms to look | |
4467 | * at when it calculates the maximum number of channels. ALC260 has no mixer | |
4468 | * element which allows changing the channel mode, so the verb list is | |
4469 | * never used. | |
4470 | */ | |
d2a6d7dc | 4471 | static struct hda_channel_mode alc260_modes[1] = { |
1da177e4 LT |
4472 | { 2, NULL }, |
4473 | }; | |
4474 | ||
df694daa KY |
4475 | |
4476 | /* Mixer combinations | |
4477 | * | |
4478 | * basic: base_output + input + pc_beep + capture | |
4479 | * HP: base_output + input + capture_alt | |
4480 | * HP_3013: hp_3013 + input + capture | |
4481 | * fujitsu: fujitsu + capture | |
0bfc90e9 | 4482 | * acer: acer + capture |
df694daa KY |
4483 | */ |
4484 | ||
4485 | static struct snd_kcontrol_new alc260_base_output_mixer[] = { | |
05acb863 | 4486 | HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
985be54b | 4487 | HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), |
05acb863 | 4488 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
985be54b | 4489 | HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), |
05acb863 | 4490 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
985be54b | 4491 | HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), |
1da177e4 | 4492 | { } /* end */ |
f12ab1e0 | 4493 | }; |
1da177e4 | 4494 | |
df694daa | 4495 | static struct snd_kcontrol_new alc260_input_mixer[] = { |
16ded525 TI |
4496 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
4497 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
4498 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4499 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4500 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4501 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4502 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT), | |
4503 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT), | |
df694daa KY |
4504 | { } /* end */ |
4505 | }; | |
4506 | ||
4507 | static struct snd_kcontrol_new alc260_pc_beep_mixer[] = { | |
4508 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT), | |
4509 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT), | |
4510 | { } /* end */ | |
4511 | }; | |
4512 | ||
bec15c3a TI |
4513 | /* update HP, line and mono out pins according to the master switch */ |
4514 | static void alc260_hp_master_update(struct hda_codec *codec, | |
4515 | hda_nid_t hp, hda_nid_t line, | |
4516 | hda_nid_t mono) | |
4517 | { | |
4518 | struct alc_spec *spec = codec->spec; | |
4519 | unsigned int val = spec->master_sw ? PIN_HP : 0; | |
4520 | /* change HP and line-out pins */ | |
30cde0aa | 4521 | snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
bec15c3a | 4522 | val); |
30cde0aa | 4523 | snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
bec15c3a TI |
4524 | val); |
4525 | /* mono (speaker) depending on the HP jack sense */ | |
4526 | val = (val && !spec->jack_present) ? PIN_OUT : 0; | |
30cde0aa | 4527 | snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
bec15c3a TI |
4528 | val); |
4529 | } | |
4530 | ||
4531 | static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol, | |
4532 | struct snd_ctl_elem_value *ucontrol) | |
4533 | { | |
4534 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
4535 | struct alc_spec *spec = codec->spec; | |
4536 | *ucontrol->value.integer.value = spec->master_sw; | |
4537 | return 0; | |
4538 | } | |
4539 | ||
4540 | static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |
4541 | struct snd_ctl_elem_value *ucontrol) | |
4542 | { | |
4543 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
4544 | struct alc_spec *spec = codec->spec; | |
4545 | int val = !!*ucontrol->value.integer.value; | |
4546 | hda_nid_t hp, line, mono; | |
4547 | ||
4548 | if (val == spec->master_sw) | |
4549 | return 0; | |
4550 | spec->master_sw = val; | |
4551 | hp = (kcontrol->private_value >> 16) & 0xff; | |
4552 | line = (kcontrol->private_value >> 8) & 0xff; | |
4553 | mono = kcontrol->private_value & 0xff; | |
4554 | alc260_hp_master_update(codec, hp, line, mono); | |
4555 | return 1; | |
4556 | } | |
4557 | ||
4558 | static struct snd_kcontrol_new alc260_hp_output_mixer[] = { | |
4559 | { | |
4560 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
4561 | .name = "Master Playback Switch", | |
4562 | .info = snd_ctl_boolean_mono_info, | |
4563 | .get = alc260_hp_master_sw_get, | |
4564 | .put = alc260_hp_master_sw_put, | |
4565 | .private_value = (0x0f << 16) | (0x10 << 8) | 0x11 | |
4566 | }, | |
4567 | HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4568 | HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), | |
4569 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), | |
4570 | HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), | |
4571 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, | |
4572 | HDA_OUTPUT), | |
4573 | HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT), | |
4574 | { } /* end */ | |
4575 | }; | |
4576 | ||
4577 | static struct hda_verb alc260_hp_unsol_verbs[] = { | |
4578 | {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
4579 | {}, | |
4580 | }; | |
4581 | ||
4582 | static void alc260_hp_automute(struct hda_codec *codec) | |
4583 | { | |
4584 | struct alc_spec *spec = codec->spec; | |
4585 | unsigned int present; | |
4586 | ||
4587 | present = snd_hda_codec_read(codec, 0x10, 0, | |
4588 | AC_VERB_GET_PIN_SENSE, 0); | |
4589 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; | |
4590 | alc260_hp_master_update(codec, 0x0f, 0x10, 0x11); | |
4591 | } | |
4592 | ||
4593 | static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res) | |
4594 | { | |
4595 | if ((res >> 26) == ALC880_HP_EVENT) | |
4596 | alc260_hp_automute(codec); | |
4597 | } | |
4598 | ||
df694daa | 4599 | static struct snd_kcontrol_new alc260_hp_3013_mixer[] = { |
bec15c3a TI |
4600 | { |
4601 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
4602 | .name = "Master Playback Switch", | |
4603 | .info = snd_ctl_boolean_mono_info, | |
4604 | .get = alc260_hp_master_sw_get, | |
4605 | .put = alc260_hp_master_sw_put, | |
30cde0aa | 4606 | .private_value = (0x15 << 16) | (0x10 << 8) | 0x11 |
bec15c3a | 4607 | }, |
df694daa KY |
4608 | HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
4609 | HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT), | |
4610 | HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT), | |
4611 | HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT), | |
4612 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4613 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
86cd9298 TI |
4614 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
4615 | HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT), | |
16ded525 TI |
4616 | { } /* end */ |
4617 | }; | |
4618 | ||
3f878308 KY |
4619 | static struct hda_bind_ctls alc260_dc7600_bind_master_vol = { |
4620 | .ops = &snd_hda_bind_vol, | |
4621 | .values = { | |
4622 | HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT), | |
4623 | HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT), | |
4624 | HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT), | |
4625 | 0 | |
4626 | }, | |
4627 | }; | |
4628 | ||
4629 | static struct hda_bind_ctls alc260_dc7600_bind_switch = { | |
4630 | .ops = &snd_hda_bind_sw, | |
4631 | .values = { | |
4632 | HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT), | |
4633 | HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | |
4634 | 0 | |
4635 | }, | |
4636 | }; | |
4637 | ||
4638 | static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = { | |
4639 | HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol), | |
4640 | HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch), | |
4641 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT), | |
4642 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT), | |
4643 | { } /* end */ | |
4644 | }; | |
4645 | ||
bec15c3a TI |
4646 | static struct hda_verb alc260_hp_3013_unsol_verbs[] = { |
4647 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
4648 | {}, | |
4649 | }; | |
4650 | ||
4651 | static void alc260_hp_3013_automute(struct hda_codec *codec) | |
4652 | { | |
4653 | struct alc_spec *spec = codec->spec; | |
4654 | unsigned int present; | |
4655 | ||
4656 | present = snd_hda_codec_read(codec, 0x15, 0, | |
4657 | AC_VERB_GET_PIN_SENSE, 0); | |
4658 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; | |
30cde0aa | 4659 | alc260_hp_master_update(codec, 0x15, 0x10, 0x11); |
bec15c3a TI |
4660 | } |
4661 | ||
4662 | static void alc260_hp_3013_unsol_event(struct hda_codec *codec, | |
4663 | unsigned int res) | |
4664 | { | |
4665 | if ((res >> 26) == ALC880_HP_EVENT) | |
4666 | alc260_hp_3013_automute(codec); | |
4667 | } | |
4668 | ||
3f878308 KY |
4669 | static void alc260_hp_3012_automute(struct hda_codec *codec) |
4670 | { | |
4671 | unsigned int present, bits; | |
4672 | ||
4673 | present = snd_hda_codec_read(codec, 0x10, 0, | |
4674 | AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE; | |
4675 | ||
4676 | bits = present ? 0 : PIN_OUT; | |
4677 | snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4678 | bits); | |
4679 | snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4680 | bits); | |
4681 | snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4682 | bits); | |
4683 | } | |
4684 | ||
4685 | static void alc260_hp_3012_unsol_event(struct hda_codec *codec, | |
4686 | unsigned int res) | |
4687 | { | |
4688 | if ((res >> 26) == ALC880_HP_EVENT) | |
4689 | alc260_hp_3012_automute(codec); | |
4690 | } | |
4691 | ||
4692 | /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12, | |
a1e8d2da JW |
4693 | * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10. |
4694 | */ | |
c8b6bf9b | 4695 | static struct snd_kcontrol_new alc260_fujitsu_mixer[] = { |
a9430dd8 | 4696 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
985be54b | 4697 | HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT), |
4c5186ed | 4698 | ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT), |
a9430dd8 JW |
4699 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
4700 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
4701 | HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4702 | HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4c5186ed | 4703 | ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN), |
a9430dd8 JW |
4704 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), |
4705 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
31bffaa9 TI |
4706 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
4707 | HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT), | |
df694daa KY |
4708 | { } /* end */ |
4709 | }; | |
4710 | ||
a1e8d2da JW |
4711 | /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current |
4712 | * versions of the ALC260 don't act on requests to enable mic bias from NID | |
4713 | * 0x0f (used to drive the headphone jack in these laptops). The ALC260 | |
4714 | * datasheet doesn't mention this restriction. At this stage it's not clear | |
4715 | * whether this behaviour is intentional or is a hardware bug in chip | |
4716 | * revisions available in early 2006. Therefore for now allow the | |
4717 | * "Headphone Jack Mode" control to span all choices, but if it turns out | |
4718 | * that the lack of mic bias for this NID is intentional we could change the | |
4719 | * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
4720 | * | |
4721 | * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006 | |
4722 | * don't appear to make the mic bias available from the "line" jack, even | |
4723 | * though the NID used for this jack (0x14) can supply it. The theory is | |
4724 | * that perhaps Acer have included blocking capacitors between the ALC260 | |
4725 | * and the output jack. If this turns out to be the case for all such | |
4726 | * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT | |
4727 | * to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
bd869485 JW |
4728 | * |
4729 | * The C20x Tablet series have a mono internal speaker which is controlled | |
4730 | * via the chip's Mono sum widget and pin complex, so include the necessary | |
4731 | * controls for such models. On models without a "mono speaker" the control | |
4732 | * won't do anything. | |
a1e8d2da | 4733 | */ |
0bfc90e9 JW |
4734 | static struct snd_kcontrol_new alc260_acer_mixer[] = { |
4735 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4736 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT), | |
a1e8d2da | 4737 | ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT), |
31bffaa9 | 4738 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, |
bd869485 | 4739 | HDA_OUTPUT), |
31bffaa9 | 4740 | HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, |
bd869485 | 4741 | HDA_INPUT), |
0bfc90e9 JW |
4742 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
4743 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
4744 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4745 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4746 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
4747 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4748 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4749 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
4750 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), | |
4751 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
4752 | { } /* end */ | |
4753 | }; | |
4754 | ||
bc9f98a9 KY |
4755 | /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12, |
4756 | * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17. | |
4757 | */ | |
4758 | static struct snd_kcontrol_new alc260_will_mixer[] = { | |
4759 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4760 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT), | |
4761 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4762 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4763 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
4764 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4765 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4766 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
4767 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), | |
4768 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
4769 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), | |
4770 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
4771 | { } /* end */ | |
4772 | }; | |
4773 | ||
4774 | /* Replacer 672V ALC260 pin usage: Mic jack = 0x12, | |
4775 | * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f. | |
4776 | */ | |
4777 | static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = { | |
4778 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4779 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT), | |
4780 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4781 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4782 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
4783 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT), | |
4784 | HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT), | |
4785 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4786 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4787 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
4788 | { } /* end */ | |
4789 | }; | |
4790 | ||
df694daa KY |
4791 | /* |
4792 | * initialization verbs | |
4793 | */ | |
1da177e4 LT |
4794 | static struct hda_verb alc260_init_verbs[] = { |
4795 | /* Line In pin widget for input */ | |
05acb863 | 4796 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 4797 | /* CD pin widget for input */ |
05acb863 | 4798 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 4799 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
16ded525 | 4800 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1da177e4 | 4801 | /* Mic2 (front panel) pin widget for input and vref at 80% */ |
16ded525 | 4802 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1da177e4 | 4803 | /* LINE-2 is used for line-out in rear */ |
05acb863 | 4804 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1da177e4 | 4805 | /* select line-out */ |
fd56f2db | 4806 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00}, |
1da177e4 | 4807 | /* LINE-OUT pin */ |
05acb863 | 4808 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1da177e4 | 4809 | /* enable HP */ |
05acb863 | 4810 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
1da177e4 | 4811 | /* enable Mono */ |
05acb863 TI |
4812 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
4813 | /* mute capture amp left and right */ | |
16ded525 | 4814 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1da177e4 LT |
4815 | /* set connection select to line in (default select for this ADC) */ |
4816 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
16ded525 TI |
4817 | /* mute capture amp left and right */ |
4818 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4819 | /* set connection select to line in (default select for this ADC) */ | |
4820 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
05acb863 TI |
4821 | /* set vol=0 Line-Out mixer amp left and right */ |
4822 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4823 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
4824 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4825 | /* set vol=0 HP mixer amp left and right */ | |
4826 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4827 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
4828 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4829 | /* set vol=0 Mono mixer amp left and right */ | |
4830 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4831 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
4832 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4833 | /* unmute LINE-2 out pin */ | |
4834 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
f12ab1e0 TI |
4835 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
4836 | * Line In 2 = 0x03 | |
4837 | */ | |
cb53c626 TI |
4838 | /* mute analog inputs */ |
4839 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4840 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4841 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4842 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4843 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 4844 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
05acb863 TI |
4845 | /* mute Front out path */ |
4846 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4847 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4848 | /* mute Headphone out path */ | |
4849 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4850 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4851 | /* mute Mono out path */ | |
4852 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4853 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 LT |
4854 | { } |
4855 | }; | |
4856 | ||
474167d6 | 4857 | #if 0 /* should be identical with alc260_init_verbs? */ |
df694daa KY |
4858 | static struct hda_verb alc260_hp_init_verbs[] = { |
4859 | /* Headphone and output */ | |
4860 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
4861 | /* mono output */ | |
4862 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
4863 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
4864 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
4865 | /* Mic2 (front panel) pin widget for input and vref at 80% */ | |
4866 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
4867 | /* Line In pin widget for input */ | |
4868 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
4869 | /* Line-2 pin widget for output */ | |
4870 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
4871 | /* CD pin widget for input */ | |
4872 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
4873 | /* unmute amp left and right */ | |
4874 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | |
4875 | /* set connection select to line in (default select for this ADC) */ | |
4876 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
4877 | /* unmute Line-Out mixer amp left and right (volume = 0) */ | |
4878 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
4879 | /* mute pin widget amp left and right (no gain on this amp) */ | |
4880 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
4881 | /* unmute HP mixer amp left and right (volume = 0) */ | |
4882 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
4883 | /* mute pin widget amp left and right (no gain on this amp) */ | |
4884 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
f12ab1e0 TI |
4885 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
4886 | * Line In 2 = 0x03 | |
4887 | */ | |
cb53c626 TI |
4888 | /* mute analog inputs */ |
4889 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4890 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4891 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4892 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4893 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
4894 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
4895 | /* Unmute Front out path */ | |
4896 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4897 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4898 | /* Unmute Headphone out path */ | |
4899 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4900 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4901 | /* Unmute Mono out path */ | |
4902 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4903 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4904 | { } | |
4905 | }; | |
474167d6 | 4906 | #endif |
df694daa KY |
4907 | |
4908 | static struct hda_verb alc260_hp_3013_init_verbs[] = { | |
4909 | /* Line out and output */ | |
4910 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
4911 | /* mono output */ | |
4912 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
4913 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
4914 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
4915 | /* Mic2 (front panel) pin widget for input and vref at 80% */ | |
4916 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
4917 | /* Line In pin widget for input */ | |
4918 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
4919 | /* Headphone pin widget for output */ | |
4920 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
4921 | /* CD pin widget for input */ | |
4922 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
4923 | /* unmute amp left and right */ | |
4924 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | |
4925 | /* set connection select to line in (default select for this ADC) */ | |
4926 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
4927 | /* unmute Line-Out mixer amp left and right (volume = 0) */ | |
4928 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
4929 | /* mute pin widget amp left and right (no gain on this amp) */ | |
4930 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
4931 | /* unmute HP mixer amp left and right (volume = 0) */ | |
4932 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
4933 | /* mute pin widget amp left and right (no gain on this amp) */ | |
4934 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
f12ab1e0 TI |
4935 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
4936 | * Line In 2 = 0x03 | |
4937 | */ | |
cb53c626 TI |
4938 | /* mute analog inputs */ |
4939 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4940 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4941 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4942 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4943 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
4944 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
4945 | /* Unmute Front out path */ | |
4946 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4947 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4948 | /* Unmute Headphone out path */ | |
4949 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4950 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4951 | /* Unmute Mono out path */ | |
4952 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4953 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4954 | { } | |
4955 | }; | |
4956 | ||
a9430dd8 | 4957 | /* Initialisation sequence for ALC260 as configured in Fujitsu S702x |
a1e8d2da JW |
4958 | * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD |
4959 | * audio = 0x16, internal speaker = 0x10. | |
a9430dd8 JW |
4960 | */ |
4961 | static struct hda_verb alc260_fujitsu_init_verbs[] = { | |
4962 | /* Disable all GPIOs */ | |
4963 | {0x01, AC_VERB_SET_GPIO_MASK, 0}, | |
4964 | /* Internal speaker is connected to headphone pin */ | |
4965 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
4966 | /* Headphone/Line-out jack connects to Line1 pin; make it an output */ | |
4967 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
f7ace40d JW |
4968 | /* Mic/Line-in jack is connected to mic1 pin, so make it an input */ |
4969 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
4970 | /* Ensure all other unused pins are disabled and muted. */ | |
4971 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
4972 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
a9430dd8 | 4973 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
f7ace40d | 4974 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
a9430dd8 | 4975 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
f7ace40d JW |
4976 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
4977 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
4978 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4979 | ||
4980 | /* Disable digital (SPDIF) pins */ | |
4981 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
4982 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
a9430dd8 | 4983 | |
ea1fb29a | 4984 | /* Ensure Line1 pin widget takes its input from the OUT1 sum bus |
f7ace40d JW |
4985 | * when acting as an output. |
4986 | */ | |
4987 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
4c5186ed | 4988 | |
f7ace40d | 4989 | /* Start with output sum widgets muted and their output gains at min */ |
8b33a5aa TI |
4990 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
4991 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4992 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4993 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4994 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4995 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4996 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4997 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4998 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
a9430dd8 | 4999 | |
f7ace40d JW |
5000 | /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */ |
5001 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5002 | /* Unmute Line1 pin widget output buffer since it starts as an output. | |
5003 | * If the pin mode is changed by the user the pin mode control will | |
5004 | * take care of enabling the pin's input/output buffers as needed. | |
5005 | * Therefore there's no need to enable the input buffer at this | |
5006 | * stage. | |
cdcd9268 | 5007 | */ |
f7ace40d | 5008 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
ea1fb29a | 5009 | /* Unmute input buffer of pin widget used for Line-in (no equiv |
cdcd9268 JW |
5010 | * mixer ctrl) |
5011 | */ | |
f7ace40d JW |
5012 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
5013 | ||
5014 | /* Mute capture amp left and right */ | |
5015 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
ea1fb29a | 5016 | /* Set ADC connection select to match default mixer setting - line |
f7ace40d JW |
5017 | * in (on mic1 pin) |
5018 | */ | |
5019 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5020 | ||
5021 | /* Do the same for the second ADC: mute capture input amp and | |
5022 | * set ADC connection to line in (on mic1 pin) | |
5023 | */ | |
5024 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5025 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5026 | ||
5027 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
5028 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
5029 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
5030 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
5031 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
5032 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
5033 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
5034 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
5035 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
4a471b7d TI |
5036 | |
5037 | { } | |
a9430dd8 JW |
5038 | }; |
5039 | ||
0bfc90e9 JW |
5040 | /* Initialisation sequence for ALC260 as configured in Acer TravelMate and |
5041 | * similar laptops (adapted from Fujitsu init verbs). | |
5042 | */ | |
5043 | static struct hda_verb alc260_acer_init_verbs[] = { | |
5044 | /* On TravelMate laptops, GPIO 0 enables the internal speaker and | |
5045 | * the headphone jack. Turn this on and rely on the standard mute | |
5046 | * methods whenever the user wants to turn these outputs off. | |
5047 | */ | |
5048 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
5049 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
5050 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, | |
5051 | /* Internal speaker/Headphone jack is connected to Line-out pin */ | |
5052 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5053 | /* Internal microphone/Mic jack is connected to Mic1 pin */ | |
5054 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | |
5055 | /* Line In jack is connected to Line1 pin */ | |
5056 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
bd869485 JW |
5057 | /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */ |
5058 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
0bfc90e9 JW |
5059 | /* Ensure all other unused pins are disabled and muted. */ |
5060 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
5061 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
0bfc90e9 JW |
5062 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
5063 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5064 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
5065 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5066 | /* Disable digital (SPDIF) pins */ | |
5067 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
5068 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
5069 | ||
ea1fb29a | 5070 | /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum |
0bfc90e9 JW |
5071 | * bus when acting as outputs. |
5072 | */ | |
5073 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, | |
5074 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
5075 | ||
5076 | /* Start with output sum widgets muted and their output gains at min */ | |
5077 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5078 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5079 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5080 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5081 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5082 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5083 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5084 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5085 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5086 | ||
f12ab1e0 TI |
5087 | /* Unmute Line-out pin widget amp left and right |
5088 | * (no equiv mixer ctrl) | |
5089 | */ | |
0bfc90e9 | 5090 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
bd869485 JW |
5091 | /* Unmute mono pin widget amp output (no equiv mixer ctrl) */ |
5092 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
0bfc90e9 JW |
5093 | /* Unmute Mic1 and Line1 pin widget input buffers since they start as |
5094 | * inputs. If the pin mode is changed by the user the pin mode control | |
5095 | * will take care of enabling the pin's input/output buffers as needed. | |
5096 | * Therefore there's no need to enable the input buffer at this | |
5097 | * stage. | |
5098 | */ | |
5099 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5100 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5101 | ||
5102 | /* Mute capture amp left and right */ | |
5103 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5104 | /* Set ADC connection select to match default mixer setting - mic | |
5105 | * (on mic1 pin) | |
5106 | */ | |
5107 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5108 | ||
5109 | /* Do similar with the second ADC: mute capture input amp and | |
a1e8d2da | 5110 | * set ADC connection to mic to match ALSA's default state. |
0bfc90e9 JW |
5111 | */ |
5112 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
a1e8d2da | 5113 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, |
0bfc90e9 JW |
5114 | |
5115 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
5116 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
5117 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
5118 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
5119 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
5120 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
5121 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
5122 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
5123 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
5124 | ||
5125 | { } | |
5126 | }; | |
5127 | ||
bc9f98a9 KY |
5128 | static struct hda_verb alc260_will_verbs[] = { |
5129 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5130 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5131 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5132 | {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, | |
5133 | {0x1a, AC_VERB_SET_COEF_INDEX, 0x07}, | |
5134 | {0x1a, AC_VERB_SET_PROC_COEF, 0x3040}, | |
5135 | {} | |
5136 | }; | |
5137 | ||
5138 | static struct hda_verb alc260_replacer_672v_verbs[] = { | |
5139 | {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, | |
5140 | {0x1a, AC_VERB_SET_COEF_INDEX, 0x07}, | |
5141 | {0x1a, AC_VERB_SET_PROC_COEF, 0x3050}, | |
5142 | ||
5143 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
5144 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
5145 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, | |
5146 | ||
5147 | {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
5148 | {} | |
5149 | }; | |
5150 | ||
5151 | /* toggle speaker-output according to the hp-jack state */ | |
5152 | static void alc260_replacer_672v_automute(struct hda_codec *codec) | |
5153 | { | |
5154 | unsigned int present; | |
5155 | ||
5156 | /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */ | |
5157 | present = snd_hda_codec_read(codec, 0x0f, 0, | |
5158 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
5159 | if (present) { | |
82beb8fd TI |
5160 | snd_hda_codec_write_cache(codec, 0x01, 0, |
5161 | AC_VERB_SET_GPIO_DATA, 1); | |
5162 | snd_hda_codec_write_cache(codec, 0x0f, 0, | |
5163 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
5164 | PIN_HP); | |
bc9f98a9 | 5165 | } else { |
82beb8fd TI |
5166 | snd_hda_codec_write_cache(codec, 0x01, 0, |
5167 | AC_VERB_SET_GPIO_DATA, 0); | |
5168 | snd_hda_codec_write_cache(codec, 0x0f, 0, | |
5169 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
5170 | PIN_OUT); | |
bc9f98a9 KY |
5171 | } |
5172 | } | |
5173 | ||
5174 | static void alc260_replacer_672v_unsol_event(struct hda_codec *codec, | |
5175 | unsigned int res) | |
5176 | { | |
5177 | if ((res >> 26) == ALC880_HP_EVENT) | |
5178 | alc260_replacer_672v_automute(codec); | |
5179 | } | |
5180 | ||
3f878308 KY |
5181 | static struct hda_verb alc260_hp_dc7600_verbs[] = { |
5182 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
5183 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
5184 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5185 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5186 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5187 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5188 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
5189 | {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
5190 | {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
5191 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
5192 | {} | |
5193 | }; | |
5194 | ||
7cf51e48 JW |
5195 | /* Test configuration for debugging, modelled after the ALC880 test |
5196 | * configuration. | |
5197 | */ | |
5198 | #ifdef CONFIG_SND_DEBUG | |
5199 | static hda_nid_t alc260_test_dac_nids[1] = { | |
5200 | 0x02, | |
5201 | }; | |
5202 | static hda_nid_t alc260_test_adc_nids[2] = { | |
5203 | 0x04, 0x05, | |
5204 | }; | |
a1e8d2da | 5205 | /* For testing the ALC260, each input MUX needs its own definition since |
ea1fb29a | 5206 | * the signal assignments are different. This assumes that the first ADC |
a1e8d2da | 5207 | * is NID 0x04. |
17e7aec6 | 5208 | */ |
a1e8d2da JW |
5209 | static struct hda_input_mux alc260_test_capture_sources[2] = { |
5210 | { | |
5211 | .num_items = 7, | |
5212 | .items = { | |
5213 | { "MIC1 pin", 0x0 }, | |
5214 | { "MIC2 pin", 0x1 }, | |
5215 | { "LINE1 pin", 0x2 }, | |
5216 | { "LINE2 pin", 0x3 }, | |
5217 | { "CD pin", 0x4 }, | |
5218 | { "LINE-OUT pin", 0x5 }, | |
5219 | { "HP-OUT pin", 0x6 }, | |
5220 | }, | |
5221 | }, | |
5222 | { | |
5223 | .num_items = 8, | |
5224 | .items = { | |
5225 | { "MIC1 pin", 0x0 }, | |
5226 | { "MIC2 pin", 0x1 }, | |
5227 | { "LINE1 pin", 0x2 }, | |
5228 | { "LINE2 pin", 0x3 }, | |
5229 | { "CD pin", 0x4 }, | |
5230 | { "Mixer", 0x5 }, | |
5231 | { "LINE-OUT pin", 0x6 }, | |
5232 | { "HP-OUT pin", 0x7 }, | |
5233 | }, | |
7cf51e48 JW |
5234 | }, |
5235 | }; | |
5236 | static struct snd_kcontrol_new alc260_test_mixer[] = { | |
5237 | /* Output driver widgets */ | |
5238 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), | |
5239 | HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), | |
5240 | HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT), | |
5241 | HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT), | |
5242 | HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
5243 | HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT), | |
5244 | ||
a1e8d2da JW |
5245 | /* Modes for retasking pin widgets |
5246 | * Note: the ALC260 doesn't seem to act on requests to enable mic | |
5247 | * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't | |
5248 | * mention this restriction. At this stage it's not clear whether | |
5249 | * this behaviour is intentional or is a hardware bug in chip | |
5250 | * revisions available at least up until early 2006. Therefore for | |
5251 | * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all | |
5252 | * choices, but if it turns out that the lack of mic bias for these | |
5253 | * NIDs is intentional we could change their modes from | |
5254 | * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
5255 | */ | |
7cf51e48 JW |
5256 | ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT), |
5257 | ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT), | |
5258 | ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT), | |
5259 | ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT), | |
5260 | ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT), | |
5261 | ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT), | |
5262 | ||
5263 | /* Loopback mixer controls */ | |
5264 | HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT), | |
5265 | HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT), | |
5266 | HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT), | |
5267 | HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT), | |
5268 | HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT), | |
5269 | HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT), | |
5270 | HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT), | |
5271 | HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT), | |
5272 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), | |
5273 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
5274 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), | |
5275 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
5276 | HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT), | |
5277 | HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT), | |
5278 | HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT), | |
5279 | HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT), | |
5c8f858d JW |
5280 | |
5281 | /* Controls for GPIO pins, assuming they are configured as outputs */ | |
5282 | ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01), | |
5283 | ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02), | |
5284 | ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04), | |
5285 | ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08), | |
5286 | ||
92621f13 JW |
5287 | /* Switches to allow the digital IO pins to be enabled. The datasheet |
5288 | * is ambigious as to which NID is which; testing on laptops which | |
ea1fb29a | 5289 | * make this output available should provide clarification. |
92621f13 JW |
5290 | */ |
5291 | ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01), | |
5292 | ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01), | |
5293 | ||
f8225f6d JW |
5294 | /* A switch allowing EAPD to be enabled. Some laptops seem to use |
5295 | * this output to turn on an external amplifier. | |
5296 | */ | |
5297 | ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02), | |
5298 | ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02), | |
5299 | ||
7cf51e48 JW |
5300 | { } /* end */ |
5301 | }; | |
5302 | static struct hda_verb alc260_test_init_verbs[] = { | |
5c8f858d JW |
5303 | /* Enable all GPIOs as outputs with an initial value of 0 */ |
5304 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f}, | |
5305 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, | |
5306 | {0x01, AC_VERB_SET_GPIO_MASK, 0x0f}, | |
5307 | ||
7cf51e48 JW |
5308 | /* Enable retasking pins as output, initially without power amp */ |
5309 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5310 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5311 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5312 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5313 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5314 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5315 | ||
92621f13 JW |
5316 | /* Disable digital (SPDIF) pins initially, but users can enable |
5317 | * them via a mixer switch. In the case of SPDIF-out, this initverb | |
5318 | * payload also sets the generation to 0, output to be in "consumer" | |
5319 | * PCM format, copyright asserted, no pre-emphasis and no validity | |
5320 | * control. | |
5321 | */ | |
7cf51e48 JW |
5322 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, |
5323 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
5324 | ||
ea1fb29a | 5325 | /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the |
7cf51e48 JW |
5326 | * OUT1 sum bus when acting as an output. |
5327 | */ | |
5328 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, | |
5329 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0}, | |
5330 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
5331 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0}, | |
5332 | ||
5333 | /* Start with output sum widgets muted and their output gains at min */ | |
5334 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5335 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5336 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5337 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5338 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5339 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5340 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5341 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5342 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5343 | ||
cdcd9268 JW |
5344 | /* Unmute retasking pin widget output buffers since the default |
5345 | * state appears to be output. As the pin mode is changed by the | |
5346 | * user the pin mode control will take care of enabling the pin's | |
5347 | * input/output buffers as needed. | |
5348 | */ | |
7cf51e48 JW |
5349 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
5350 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5351 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5352 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5353 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5354 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5355 | /* Also unmute the mono-out pin widget */ | |
5356 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5357 | ||
7cf51e48 JW |
5358 | /* Mute capture amp left and right */ |
5359 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
f7ace40d JW |
5360 | /* Set ADC connection select to match default mixer setting (mic1 |
5361 | * pin) | |
7cf51e48 JW |
5362 | */ |
5363 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5364 | ||
5365 | /* Do the same for the second ADC: mute capture input amp and | |
f7ace40d | 5366 | * set ADC connection to mic1 pin |
7cf51e48 JW |
5367 | */ |
5368 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5369 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5370 | ||
5371 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
5372 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
5373 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
5374 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
5375 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
5376 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
5377 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
5378 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
5379 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
5380 | ||
5381 | { } | |
5382 | }; | |
5383 | #endif | |
5384 | ||
6330079f TI |
5385 | #define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback |
5386 | #define alc260_pcm_analog_capture alc880_pcm_analog_capture | |
1da177e4 | 5387 | |
a3bcba38 TI |
5388 | #define alc260_pcm_digital_playback alc880_pcm_digital_playback |
5389 | #define alc260_pcm_digital_capture alc880_pcm_digital_capture | |
5390 | ||
df694daa KY |
5391 | /* |
5392 | * for BIOS auto-configuration | |
5393 | */ | |
16ded525 | 5394 | |
df694daa | 5395 | static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid, |
863b4518 | 5396 | const char *pfx, int *vol_bits) |
df694daa KY |
5397 | { |
5398 | hda_nid_t nid_vol; | |
5399 | unsigned long vol_val, sw_val; | |
5400 | char name[32]; | |
5401 | int err; | |
5402 | ||
5403 | if (nid >= 0x0f && nid < 0x11) { | |
5404 | nid_vol = nid - 0x7; | |
5405 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); | |
5406 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); | |
5407 | } else if (nid == 0x11) { | |
5408 | nid_vol = nid - 0x7; | |
5409 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT); | |
5410 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT); | |
5411 | } else if (nid >= 0x12 && nid <= 0x15) { | |
5412 | nid_vol = 0x08; | |
5413 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); | |
5414 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); | |
5415 | } else | |
5416 | return 0; /* N/A */ | |
ea1fb29a | 5417 | |
863b4518 TI |
5418 | if (!(*vol_bits & (1 << nid_vol))) { |
5419 | /* first control for the volume widget */ | |
5420 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); | |
5421 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val); | |
5422 | if (err < 0) | |
5423 | return err; | |
5424 | *vol_bits |= (1 << nid_vol); | |
5425 | } | |
df694daa | 5426 | snprintf(name, sizeof(name), "%s Playback Switch", pfx); |
f12ab1e0 TI |
5427 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val); |
5428 | if (err < 0) | |
df694daa KY |
5429 | return err; |
5430 | return 1; | |
5431 | } | |
5432 | ||
5433 | /* add playback controls from the parsed DAC table */ | |
5434 | static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec, | |
5435 | const struct auto_pin_cfg *cfg) | |
5436 | { | |
5437 | hda_nid_t nid; | |
5438 | int err; | |
863b4518 | 5439 | int vols = 0; |
df694daa KY |
5440 | |
5441 | spec->multiout.num_dacs = 1; | |
5442 | spec->multiout.dac_nids = spec->private_dac_nids; | |
5443 | spec->multiout.dac_nids[0] = 0x02; | |
5444 | ||
5445 | nid = cfg->line_out_pins[0]; | |
5446 | if (nid) { | |
863b4518 | 5447 | err = alc260_add_playback_controls(spec, nid, "Front", &vols); |
df694daa KY |
5448 | if (err < 0) |
5449 | return err; | |
5450 | } | |
5451 | ||
82bc955f | 5452 | nid = cfg->speaker_pins[0]; |
df694daa | 5453 | if (nid) { |
863b4518 | 5454 | err = alc260_add_playback_controls(spec, nid, "Speaker", &vols); |
df694daa KY |
5455 | if (err < 0) |
5456 | return err; | |
5457 | } | |
5458 | ||
eb06ed8f | 5459 | nid = cfg->hp_pins[0]; |
df694daa | 5460 | if (nid) { |
863b4518 TI |
5461 | err = alc260_add_playback_controls(spec, nid, "Headphone", |
5462 | &vols); | |
df694daa KY |
5463 | if (err < 0) |
5464 | return err; | |
5465 | } | |
f12ab1e0 | 5466 | return 0; |
df694daa KY |
5467 | } |
5468 | ||
5469 | /* create playback/capture controls for input pins */ | |
5470 | static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec, | |
5471 | const struct auto_pin_cfg *cfg) | |
5472 | { | |
df694daa KY |
5473 | struct hda_input_mux *imux = &spec->private_imux; |
5474 | int i, err, idx; | |
5475 | ||
5476 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
5477 | if (cfg->input_pins[i] >= 0x12) { | |
5478 | idx = cfg->input_pins[i] - 0x12; | |
4a471b7d | 5479 | err = new_analog_input(spec, cfg->input_pins[i], |
f12ab1e0 TI |
5480 | auto_pin_cfg_labels[i], idx, |
5481 | 0x07); | |
df694daa KY |
5482 | if (err < 0) |
5483 | return err; | |
f12ab1e0 TI |
5484 | imux->items[imux->num_items].label = |
5485 | auto_pin_cfg_labels[i]; | |
df694daa KY |
5486 | imux->items[imux->num_items].index = idx; |
5487 | imux->num_items++; | |
5488 | } | |
f12ab1e0 | 5489 | if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){ |
df694daa | 5490 | idx = cfg->input_pins[i] - 0x09; |
4a471b7d | 5491 | err = new_analog_input(spec, cfg->input_pins[i], |
f12ab1e0 TI |
5492 | auto_pin_cfg_labels[i], idx, |
5493 | 0x07); | |
df694daa KY |
5494 | if (err < 0) |
5495 | return err; | |
f12ab1e0 TI |
5496 | imux->items[imux->num_items].label = |
5497 | auto_pin_cfg_labels[i]; | |
df694daa KY |
5498 | imux->items[imux->num_items].index = idx; |
5499 | imux->num_items++; | |
5500 | } | |
5501 | } | |
5502 | return 0; | |
5503 | } | |
5504 | ||
5505 | static void alc260_auto_set_output_and_unmute(struct hda_codec *codec, | |
5506 | hda_nid_t nid, int pin_type, | |
5507 | int sel_idx) | |
5508 | { | |
f6c7e546 | 5509 | alc_set_pin_output(codec, nid, pin_type); |
df694daa KY |
5510 | /* need the manual connection? */ |
5511 | if (nid >= 0x12) { | |
5512 | int idx = nid - 0x12; | |
5513 | snd_hda_codec_write(codec, idx + 0x0b, 0, | |
5514 | AC_VERB_SET_CONNECT_SEL, sel_idx); | |
df694daa KY |
5515 | } |
5516 | } | |
5517 | ||
5518 | static void alc260_auto_init_multi_out(struct hda_codec *codec) | |
5519 | { | |
5520 | struct alc_spec *spec = codec->spec; | |
5521 | hda_nid_t nid; | |
5522 | ||
bc9f98a9 | 5523 | alc_subsystem_id(codec, 0x10, 0x15, 0x0f); |
f12ab1e0 | 5524 | nid = spec->autocfg.line_out_pins[0]; |
baba8ee9 TI |
5525 | if (nid) { |
5526 | int pin_type = get_pin_type(spec->autocfg.line_out_type); | |
5527 | alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0); | |
5528 | } | |
ea1fb29a | 5529 | |
82bc955f | 5530 | nid = spec->autocfg.speaker_pins[0]; |
df694daa KY |
5531 | if (nid) |
5532 | alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); | |
5533 | ||
eb06ed8f | 5534 | nid = spec->autocfg.hp_pins[0]; |
df694daa | 5535 | if (nid) |
baba8ee9 | 5536 | alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0); |
f12ab1e0 | 5537 | } |
df694daa KY |
5538 | |
5539 | #define ALC260_PIN_CD_NID 0x16 | |
5540 | static void alc260_auto_init_analog_input(struct hda_codec *codec) | |
5541 | { | |
5542 | struct alc_spec *spec = codec->spec; | |
5543 | int i; | |
5544 | ||
5545 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
5546 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
5547 | if (nid >= 0x12) { | |
f12ab1e0 TI |
5548 | snd_hda_codec_write(codec, nid, 0, |
5549 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
5550 | i <= AUTO_PIN_FRONT_MIC ? | |
5551 | PIN_VREF80 : PIN_IN); | |
df694daa | 5552 | if (nid != ALC260_PIN_CD_NID) |
f12ab1e0 TI |
5553 | snd_hda_codec_write(codec, nid, 0, |
5554 | AC_VERB_SET_AMP_GAIN_MUTE, | |
df694daa KY |
5555 | AMP_OUT_MUTE); |
5556 | } | |
5557 | } | |
5558 | } | |
5559 | ||
5560 | /* | |
5561 | * generic initialization of ADC, input mixers and output mixers | |
5562 | */ | |
5563 | static struct hda_verb alc260_volume_init_verbs[] = { | |
5564 | /* | |
5565 | * Unmute ADC0-1 and set the default input to mic-in | |
5566 | */ | |
5567 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5568 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5569 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5570 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
ea1fb29a | 5571 | |
df694daa KY |
5572 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
5573 | * mixer widget | |
f12ab1e0 TI |
5574 | * Note: PASD motherboards uses the Line In 2 as the input for |
5575 | * front panel mic (mic 2) | |
df694daa KY |
5576 | */ |
5577 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
5578 | /* mute analog inputs */ |
5579 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5580 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5581 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5582 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5583 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
5584 | |
5585 | /* | |
5586 | * Set up output mixers (0x08 - 0x0a) | |
5587 | */ | |
5588 | /* set vol=0 to output mixers */ | |
5589 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5590 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5591 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5592 | /* set up input amps for analog loopback */ | |
5593 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
5594 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5595 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5596 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5597 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5598 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5599 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
ea1fb29a | 5600 | |
df694daa KY |
5601 | { } |
5602 | }; | |
5603 | ||
5604 | static int alc260_parse_auto_config(struct hda_codec *codec) | |
5605 | { | |
5606 | struct alc_spec *spec = codec->spec; | |
df694daa KY |
5607 | int err; |
5608 | static hda_nid_t alc260_ignore[] = { 0x17, 0 }; | |
5609 | ||
f12ab1e0 TI |
5610 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
5611 | alc260_ignore); | |
5612 | if (err < 0) | |
df694daa | 5613 | return err; |
f12ab1e0 TI |
5614 | err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg); |
5615 | if (err < 0) | |
4a471b7d | 5616 | return err; |
603c4019 | 5617 | if (!spec->kctls.list) |
df694daa | 5618 | return 0; /* can't find valid BIOS pin config */ |
f12ab1e0 TI |
5619 | err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg); |
5620 | if (err < 0) | |
df694daa KY |
5621 | return err; |
5622 | ||
5623 | spec->multiout.max_channels = 2; | |
5624 | ||
5625 | if (spec->autocfg.dig_out_pin) | |
5626 | spec->multiout.dig_out_nid = ALC260_DIGOUT_NID; | |
603c4019 | 5627 | if (spec->kctls.list) |
d88897ea | 5628 | add_mixer(spec, spec->kctls.list); |
df694daa | 5629 | |
d88897ea | 5630 | add_verb(spec, alc260_volume_init_verbs); |
df694daa | 5631 | |
a1e8d2da | 5632 | spec->num_mux_defs = 1; |
df694daa KY |
5633 | spec->input_mux = &spec->private_imux; |
5634 | ||
e044c39a | 5635 | store_pin_configs(codec); |
df694daa KY |
5636 | return 1; |
5637 | } | |
5638 | ||
ae6b813a TI |
5639 | /* additional initialization for auto-configuration model */ |
5640 | static void alc260_auto_init(struct hda_codec *codec) | |
df694daa | 5641 | { |
f6c7e546 | 5642 | struct alc_spec *spec = codec->spec; |
df694daa KY |
5643 | alc260_auto_init_multi_out(codec); |
5644 | alc260_auto_init_analog_input(codec); | |
f6c7e546 | 5645 | if (spec->unsol_event) |
7fb0d78f | 5646 | alc_inithook(codec); |
df694daa KY |
5647 | } |
5648 | ||
cb53c626 TI |
5649 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
5650 | static struct hda_amp_list alc260_loopbacks[] = { | |
5651 | { 0x07, HDA_INPUT, 0 }, | |
5652 | { 0x07, HDA_INPUT, 1 }, | |
5653 | { 0x07, HDA_INPUT, 2 }, | |
5654 | { 0x07, HDA_INPUT, 3 }, | |
5655 | { 0x07, HDA_INPUT, 4 }, | |
5656 | { } /* end */ | |
5657 | }; | |
5658 | #endif | |
5659 | ||
df694daa KY |
5660 | /* |
5661 | * ALC260 configurations | |
5662 | */ | |
f5fcc13c TI |
5663 | static const char *alc260_models[ALC260_MODEL_LAST] = { |
5664 | [ALC260_BASIC] = "basic", | |
5665 | [ALC260_HP] = "hp", | |
5666 | [ALC260_HP_3013] = "hp-3013", | |
2922c9af | 5667 | [ALC260_HP_DC7600] = "hp-dc7600", |
f5fcc13c TI |
5668 | [ALC260_FUJITSU_S702X] = "fujitsu", |
5669 | [ALC260_ACER] = "acer", | |
bc9f98a9 KY |
5670 | [ALC260_WILL] = "will", |
5671 | [ALC260_REPLACER_672V] = "replacer", | |
7cf51e48 | 5672 | #ifdef CONFIG_SND_DEBUG |
f5fcc13c | 5673 | [ALC260_TEST] = "test", |
7cf51e48 | 5674 | #endif |
f5fcc13c TI |
5675 | [ALC260_AUTO] = "auto", |
5676 | }; | |
5677 | ||
5678 | static struct snd_pci_quirk alc260_cfg_tbl[] = { | |
bd869485 | 5679 | SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER), |
f5fcc13c | 5680 | SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER), |
9720b718 | 5681 | SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013), |
a8a5d067 | 5682 | SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013), |
f5fcc13c | 5683 | SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013), |
34ec8a0a | 5684 | SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013), |
3f878308 | 5685 | SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600), |
f5fcc13c TI |
5686 | SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013), |
5687 | SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP), | |
5688 | SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP), | |
5689 | SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP), | |
5690 | SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC), | |
5691 | SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC), | |
5692 | SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC), | |
5693 | SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X), | |
5694 | SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC), | |
bc9f98a9 | 5695 | SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V), |
ac3e3741 | 5696 | SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL), |
df694daa KY |
5697 | {} |
5698 | }; | |
5699 | ||
5700 | static struct alc_config_preset alc260_presets[] = { | |
5701 | [ALC260_BASIC] = { | |
5702 | .mixers = { alc260_base_output_mixer, | |
5703 | alc260_input_mixer, | |
f9e336f6 | 5704 | alc260_pc_beep_mixer }, |
df694daa KY |
5705 | .init_verbs = { alc260_init_verbs }, |
5706 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5707 | .dac_nids = alc260_dac_nids, | |
f9e336f6 | 5708 | .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), |
df694daa KY |
5709 | .adc_nids = alc260_adc_nids, |
5710 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5711 | .channel_mode = alc260_modes, | |
5712 | .input_mux = &alc260_capture_source, | |
5713 | }, | |
5714 | [ALC260_HP] = { | |
bec15c3a | 5715 | .mixers = { alc260_hp_output_mixer, |
f9e336f6 | 5716 | alc260_input_mixer }, |
bec15c3a TI |
5717 | .init_verbs = { alc260_init_verbs, |
5718 | alc260_hp_unsol_verbs }, | |
df694daa KY |
5719 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), |
5720 | .dac_nids = alc260_dac_nids, | |
f9e336f6 TI |
5721 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt), |
5722 | .adc_nids = alc260_adc_nids_alt, | |
df694daa KY |
5723 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
5724 | .channel_mode = alc260_modes, | |
5725 | .input_mux = &alc260_capture_source, | |
bec15c3a TI |
5726 | .unsol_event = alc260_hp_unsol_event, |
5727 | .init_hook = alc260_hp_automute, | |
df694daa | 5728 | }, |
3f878308 KY |
5729 | [ALC260_HP_DC7600] = { |
5730 | .mixers = { alc260_hp_dc7600_mixer, | |
f9e336f6 | 5731 | alc260_input_mixer }, |
3f878308 KY |
5732 | .init_verbs = { alc260_init_verbs, |
5733 | alc260_hp_dc7600_verbs }, | |
5734 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5735 | .dac_nids = alc260_dac_nids, | |
f9e336f6 TI |
5736 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt), |
5737 | .adc_nids = alc260_adc_nids_alt, | |
3f878308 KY |
5738 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
5739 | .channel_mode = alc260_modes, | |
5740 | .input_mux = &alc260_capture_source, | |
5741 | .unsol_event = alc260_hp_3012_unsol_event, | |
5742 | .init_hook = alc260_hp_3012_automute, | |
5743 | }, | |
df694daa KY |
5744 | [ALC260_HP_3013] = { |
5745 | .mixers = { alc260_hp_3013_mixer, | |
f9e336f6 | 5746 | alc260_input_mixer }, |
bec15c3a TI |
5747 | .init_verbs = { alc260_hp_3013_init_verbs, |
5748 | alc260_hp_3013_unsol_verbs }, | |
df694daa KY |
5749 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), |
5750 | .dac_nids = alc260_dac_nids, | |
f9e336f6 TI |
5751 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt), |
5752 | .adc_nids = alc260_adc_nids_alt, | |
df694daa KY |
5753 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
5754 | .channel_mode = alc260_modes, | |
5755 | .input_mux = &alc260_capture_source, | |
bec15c3a TI |
5756 | .unsol_event = alc260_hp_3013_unsol_event, |
5757 | .init_hook = alc260_hp_3013_automute, | |
df694daa KY |
5758 | }, |
5759 | [ALC260_FUJITSU_S702X] = { | |
f9e336f6 | 5760 | .mixers = { alc260_fujitsu_mixer }, |
df694daa KY |
5761 | .init_verbs = { alc260_fujitsu_init_verbs }, |
5762 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5763 | .dac_nids = alc260_dac_nids, | |
d57fdac0 JW |
5764 | .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), |
5765 | .adc_nids = alc260_dual_adc_nids, | |
df694daa KY |
5766 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
5767 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
5768 | .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources), |
5769 | .input_mux = alc260_fujitsu_capture_sources, | |
df694daa | 5770 | }, |
0bfc90e9 | 5771 | [ALC260_ACER] = { |
f9e336f6 | 5772 | .mixers = { alc260_acer_mixer }, |
0bfc90e9 JW |
5773 | .init_verbs = { alc260_acer_init_verbs }, |
5774 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5775 | .dac_nids = alc260_dac_nids, | |
5776 | .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), | |
5777 | .adc_nids = alc260_dual_adc_nids, | |
5778 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5779 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
5780 | .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources), |
5781 | .input_mux = alc260_acer_capture_sources, | |
0bfc90e9 | 5782 | }, |
bc9f98a9 | 5783 | [ALC260_WILL] = { |
f9e336f6 | 5784 | .mixers = { alc260_will_mixer }, |
bc9f98a9 KY |
5785 | .init_verbs = { alc260_init_verbs, alc260_will_verbs }, |
5786 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5787 | .dac_nids = alc260_dac_nids, | |
5788 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), | |
5789 | .adc_nids = alc260_adc_nids, | |
5790 | .dig_out_nid = ALC260_DIGOUT_NID, | |
5791 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5792 | .channel_mode = alc260_modes, | |
5793 | .input_mux = &alc260_capture_source, | |
5794 | }, | |
5795 | [ALC260_REPLACER_672V] = { | |
f9e336f6 | 5796 | .mixers = { alc260_replacer_672v_mixer }, |
bc9f98a9 KY |
5797 | .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs }, |
5798 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5799 | .dac_nids = alc260_dac_nids, | |
5800 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), | |
5801 | .adc_nids = alc260_adc_nids, | |
5802 | .dig_out_nid = ALC260_DIGOUT_NID, | |
5803 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5804 | .channel_mode = alc260_modes, | |
5805 | .input_mux = &alc260_capture_source, | |
5806 | .unsol_event = alc260_replacer_672v_unsol_event, | |
5807 | .init_hook = alc260_replacer_672v_automute, | |
5808 | }, | |
7cf51e48 JW |
5809 | #ifdef CONFIG_SND_DEBUG |
5810 | [ALC260_TEST] = { | |
f9e336f6 | 5811 | .mixers = { alc260_test_mixer }, |
7cf51e48 JW |
5812 | .init_verbs = { alc260_test_init_verbs }, |
5813 | .num_dacs = ARRAY_SIZE(alc260_test_dac_nids), | |
5814 | .dac_nids = alc260_test_dac_nids, | |
5815 | .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids), | |
5816 | .adc_nids = alc260_test_adc_nids, | |
5817 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5818 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
5819 | .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources), |
5820 | .input_mux = alc260_test_capture_sources, | |
7cf51e48 JW |
5821 | }, |
5822 | #endif | |
df694daa KY |
5823 | }; |
5824 | ||
5825 | static int patch_alc260(struct hda_codec *codec) | |
1da177e4 LT |
5826 | { |
5827 | struct alc_spec *spec; | |
df694daa | 5828 | int err, board_config; |
1da177e4 | 5829 | |
e560d8d8 | 5830 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
1da177e4 LT |
5831 | if (spec == NULL) |
5832 | return -ENOMEM; | |
5833 | ||
5834 | codec->spec = spec; | |
5835 | ||
f5fcc13c TI |
5836 | board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST, |
5837 | alc260_models, | |
5838 | alc260_cfg_tbl); | |
5839 | if (board_config < 0) { | |
9c7f852e TI |
5840 | snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, " |
5841 | "trying auto-probe from BIOS...\n"); | |
df694daa | 5842 | board_config = ALC260_AUTO; |
16ded525 | 5843 | } |
1da177e4 | 5844 | |
df694daa KY |
5845 | if (board_config == ALC260_AUTO) { |
5846 | /* automatic parse from the BIOS config */ | |
5847 | err = alc260_parse_auto_config(codec); | |
5848 | if (err < 0) { | |
5849 | alc_free(codec); | |
5850 | return err; | |
f12ab1e0 | 5851 | } else if (!err) { |
9c7f852e TI |
5852 | printk(KERN_INFO |
5853 | "hda_codec: Cannot set up configuration " | |
5854 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
5855 | board_config = ALC260_BASIC; |
5856 | } | |
a9430dd8 | 5857 | } |
e9edcee0 | 5858 | |
df694daa KY |
5859 | if (board_config != ALC260_AUTO) |
5860 | setup_preset(spec, &alc260_presets[board_config]); | |
1da177e4 LT |
5861 | |
5862 | spec->stream_name_analog = "ALC260 Analog"; | |
5863 | spec->stream_analog_playback = &alc260_pcm_analog_playback; | |
5864 | spec->stream_analog_capture = &alc260_pcm_analog_capture; | |
5865 | ||
a3bcba38 TI |
5866 | spec->stream_name_digital = "ALC260 Digital"; |
5867 | spec->stream_digital_playback = &alc260_pcm_digital_playback; | |
5868 | spec->stream_digital_capture = &alc260_pcm_digital_capture; | |
5869 | ||
4ef0ef19 TI |
5870 | if (!spec->adc_nids && spec->input_mux) { |
5871 | /* check whether NID 0x04 is valid */ | |
5872 | unsigned int wcap = get_wcaps(codec, 0x04); | |
5873 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
5874 | /* get type */ | |
5875 | if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) { | |
5876 | spec->adc_nids = alc260_adc_nids_alt; | |
5877 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt); | |
5878 | } else { | |
5879 | spec->adc_nids = alc260_adc_nids; | |
5880 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); | |
5881 | } | |
5882 | } | |
f9e336f6 TI |
5883 | set_capture_mixer(spec); |
5884 | ||
2134ea4f TI |
5885 | spec->vmaster_nid = 0x08; |
5886 | ||
1da177e4 | 5887 | codec->patch_ops = alc_patch_ops; |
df694daa | 5888 | if (board_config == ALC260_AUTO) |
ae6b813a | 5889 | spec->init_hook = alc260_auto_init; |
cb53c626 TI |
5890 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
5891 | if (!spec->loopback.amplist) | |
5892 | spec->loopback.amplist = alc260_loopbacks; | |
5893 | #endif | |
daead538 | 5894 | codec->proc_widget_hook = print_realtek_coef; |
1da177e4 LT |
5895 | |
5896 | return 0; | |
5897 | } | |
5898 | ||
e9edcee0 | 5899 | |
1da177e4 LT |
5900 | /* |
5901 | * ALC882 support | |
5902 | * | |
5903 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible | |
5904 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
5905 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
5906 | * 6-channel independent captures. | |
5907 | * | |
5908 | * In addition, an independent DAC for the multi-playback (not used in this | |
5909 | * driver yet). | |
5910 | */ | |
df694daa KY |
5911 | #define ALC882_DIGOUT_NID 0x06 |
5912 | #define ALC882_DIGIN_NID 0x0a | |
1da177e4 | 5913 | |
d2a6d7dc | 5914 | static struct hda_channel_mode alc882_ch_modes[1] = { |
1da177e4 LT |
5915 | { 8, NULL } |
5916 | }; | |
5917 | ||
5918 | static hda_nid_t alc882_dac_nids[4] = { | |
5919 | /* front, rear, clfe, rear_surr */ | |
5920 | 0x02, 0x03, 0x04, 0x05 | |
5921 | }; | |
5922 | ||
df694daa KY |
5923 | /* identical with ALC880 */ |
5924 | #define alc882_adc_nids alc880_adc_nids | |
5925 | #define alc882_adc_nids_alt alc880_adc_nids_alt | |
1da177e4 | 5926 | |
e1406348 TI |
5927 | static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 }; |
5928 | static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 }; | |
5929 | ||
1da177e4 LT |
5930 | /* input MUX */ |
5931 | /* FIXME: should be a matrix-type input source selection */ | |
5932 | ||
5933 | static struct hda_input_mux alc882_capture_source = { | |
5934 | .num_items = 4, | |
5935 | .items = { | |
5936 | { "Mic", 0x0 }, | |
5937 | { "Front Mic", 0x1 }, | |
5938 | { "Line", 0x2 }, | |
5939 | { "CD", 0x4 }, | |
5940 | }, | |
5941 | }; | |
272a527c KY |
5942 | /* |
5943 | * 2ch mode | |
5944 | */ | |
5945 | static struct hda_verb alc882_3ST_ch2_init[] = { | |
5946 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
5947 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
5948 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
5949 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
5950 | { } /* end */ | |
5951 | }; | |
5952 | ||
5953 | /* | |
5954 | * 6ch mode | |
5955 | */ | |
5956 | static struct hda_verb alc882_3ST_ch6_init[] = { | |
5957 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5958 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
5959 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
5960 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5961 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
5962 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
5963 | { } /* end */ | |
5964 | }; | |
5965 | ||
5966 | static struct hda_channel_mode alc882_3ST_6ch_modes[2] = { | |
5967 | { 2, alc882_3ST_ch2_init }, | |
5968 | { 6, alc882_3ST_ch6_init }, | |
5969 | }; | |
5970 | ||
df694daa KY |
5971 | /* |
5972 | * 6ch mode | |
5973 | */ | |
5974 | static struct hda_verb alc882_sixstack_ch6_init[] = { | |
5975 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
5976 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5977 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5978 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5979 | { } /* end */ | |
5980 | }; | |
5981 | ||
5982 | /* | |
5983 | * 8ch mode | |
5984 | */ | |
5985 | static struct hda_verb alc882_sixstack_ch8_init[] = { | |
5986 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5987 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5988 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5989 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5990 | { } /* end */ | |
5991 | }; | |
5992 | ||
5993 | static struct hda_channel_mode alc882_sixstack_modes[2] = { | |
5994 | { 6, alc882_sixstack_ch6_init }, | |
5995 | { 8, alc882_sixstack_ch8_init }, | |
5996 | }; | |
5997 | ||
87350ad0 TI |
5998 | /* |
5999 | * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic | |
6000 | */ | |
6001 | ||
6002 | /* | |
6003 | * 2ch mode | |
6004 | */ | |
6005 | static struct hda_verb alc885_mbp_ch2_init[] = { | |
6006 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
6007 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6008 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
6009 | { } /* end */ | |
6010 | }; | |
6011 | ||
6012 | /* | |
6013 | * 6ch mode | |
6014 | */ | |
6015 | static struct hda_verb alc885_mbp_ch6_init[] = { | |
6016 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6017 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6018 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
6019 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6020 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6021 | { } /* end */ | |
6022 | }; | |
6023 | ||
6024 | static struct hda_channel_mode alc885_mbp_6ch_modes[2] = { | |
6025 | { 2, alc885_mbp_ch2_init }, | |
6026 | { 6, alc885_mbp_ch6_init }, | |
6027 | }; | |
6028 | ||
6029 | ||
1da177e4 LT |
6030 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
6031 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
6032 | */ | |
c8b6bf9b | 6033 | static struct snd_kcontrol_new alc882_base_mixer[] = { |
05acb863 | 6034 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 6035 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
05acb863 | 6036 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 6037 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
05acb863 TI |
6038 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
6039 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
6040 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
6041 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
05acb863 | 6042 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 6043 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
1da177e4 LT |
6044 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
6045 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6046 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6047 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6048 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6049 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 6050 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
1da177e4 LT |
6051 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
6052 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 6053 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
1da177e4 LT |
6054 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
6055 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
6056 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
1da177e4 LT |
6057 | { } /* end */ |
6058 | }; | |
6059 | ||
87350ad0 | 6060 | static struct snd_kcontrol_new alc885_mbp3_mixer[] = { |
2134ea4f TI |
6061 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT), |
6062 | HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT), | |
6063 | HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT), | |
6064 | HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT), | |
6065 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6066 | HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
87350ad0 TI |
6067 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT), |
6068 | HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT), | |
2134ea4f | 6069 | HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT), |
87350ad0 TI |
6070 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT), |
6071 | { } /* end */ | |
6072 | }; | |
bdd148a3 KY |
6073 | static struct snd_kcontrol_new alc882_w2jc_mixer[] = { |
6074 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6075 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
6076 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6077 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6078 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6079 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6080 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6081 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
6082 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
6083 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
6084 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
6085 | { } /* end */ | |
6086 | }; | |
6087 | ||
272a527c KY |
6088 | static struct snd_kcontrol_new alc882_targa_mixer[] = { |
6089 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6090 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
6091 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6092 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6093 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6094 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6095 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6096 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6097 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
96fe7cc8 | 6098 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
272a527c KY |
6099 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
6100 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
96fe7cc8 | 6101 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
272a527c KY |
6102 | { } /* end */ |
6103 | }; | |
6104 | ||
6105 | /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ??? | |
6106 | * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c | |
6107 | */ | |
6108 | static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = { | |
6109 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6110 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
6111 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
6112 | HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT), | |
6113 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6114 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6115 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6116 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6117 | HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT), | |
6118 | HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT), | |
6119 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6120 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
96fe7cc8 | 6121 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
272a527c KY |
6122 | { } /* end */ |
6123 | }; | |
6124 | ||
914759b7 TI |
6125 | static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = { |
6126 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6127 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
6128 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
6129 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6130 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6131 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6132 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6133 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6134 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
6135 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
6136 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
6137 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
6138 | { } /* end */ | |
6139 | }; | |
6140 | ||
df694daa KY |
6141 | static struct snd_kcontrol_new alc882_chmode_mixer[] = { |
6142 | { | |
6143 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6144 | .name = "Channel Mode", | |
6145 | .info = alc_ch_mode_info, | |
6146 | .get = alc_ch_mode_get, | |
6147 | .put = alc_ch_mode_put, | |
6148 | }, | |
6149 | { } /* end */ | |
6150 | }; | |
6151 | ||
1da177e4 LT |
6152 | static struct hda_verb alc882_init_verbs[] = { |
6153 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
05acb863 TI |
6154 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
6155 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6156 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 6157 | /* Rear mixer */ |
05acb863 TI |
6158 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
6159 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6160 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 6161 | /* CLFE mixer */ |
05acb863 TI |
6162 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
6163 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6164 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 6165 | /* Side mixer */ |
05acb863 TI |
6166 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
6167 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6168 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 6169 | |
e9edcee0 | 6170 | /* Front Pin: output 0 (0x0c) */ |
05acb863 | 6171 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 6172 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 6173 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 6174 | /* Rear Pin: output 1 (0x0d) */ |
05acb863 | 6175 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 6176 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 6177 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, |
e9edcee0 | 6178 | /* CLFE Pin: output 2 (0x0e) */ |
05acb863 | 6179 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 6180 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 6181 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, |
e9edcee0 | 6182 | /* Side Pin: output 3 (0x0f) */ |
05acb863 | 6183 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 6184 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 6185 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, |
e9edcee0 | 6186 | /* Mic (rear) pin: input vref at 80% */ |
16ded525 | 6187 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 TI |
6188 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
6189 | /* Front Mic pin: input vref at 80% */ | |
16ded525 | 6190 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 TI |
6191 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
6192 | /* Line In pin: input */ | |
05acb863 | 6193 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 TI |
6194 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
6195 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
6196 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6197 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6198 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1da177e4 | 6199 | /* CD pin widget for input */ |
05acb863 | 6200 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 LT |
6201 | |
6202 | /* FIXME: use matrix-type input source selection */ | |
6203 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
6204 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
05acb863 TI |
6205 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
6206 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6207 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6208 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 6209 | /* Input mixer2 */ |
05acb863 TI |
6210 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
6211 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6212 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6213 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 6214 | /* Input mixer3 */ |
05acb863 TI |
6215 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
6216 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6217 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6218 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
6219 | /* ADC1: mute amp left and right */ | |
6220 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 6221 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
6222 | /* ADC2: mute amp left and right */ |
6223 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 6224 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
6225 | /* ADC3: mute amp left and right */ |
6226 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 6227 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
1da177e4 LT |
6228 | |
6229 | { } | |
6230 | }; | |
6231 | ||
4b146cb0 TI |
6232 | static struct hda_verb alc882_eapd_verbs[] = { |
6233 | /* change to EAPD mode */ | |
6234 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
b373bdeb | 6235 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, |
f12ab1e0 | 6236 | { } |
4b146cb0 TI |
6237 | }; |
6238 | ||
9102cd1c TD |
6239 | /* Mac Pro test */ |
6240 | static struct snd_kcontrol_new alc882_macpro_mixer[] = { | |
6241 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6242 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
6243 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT), | |
6244 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
6245 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
6246 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6247 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6248 | { } /* end */ | |
6249 | }; | |
6250 | ||
6251 | static struct hda_verb alc882_macpro_init_verbs[] = { | |
6252 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
6253 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6254 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6255 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
6256 | /* Front Pin: output 0 (0x0c) */ | |
6257 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6258 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6259 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6260 | /* Front Mic pin: input vref at 80% */ | |
6261 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
6262 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
6263 | /* Speaker: output */ | |
6264 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6265 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6266 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04}, | |
6267 | /* Headphone output (output 0 - 0x0c) */ | |
6268 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6269 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6270 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6271 | ||
6272 | /* FIXME: use matrix-type input source selection */ | |
6273 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
6274 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
6275 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6276 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6277 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6278 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
6279 | /* Input mixer2 */ | |
6280 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6281 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6282 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6283 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
6284 | /* Input mixer3 */ | |
6285 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6286 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6287 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6288 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
6289 | /* ADC1: mute amp left and right */ | |
6290 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6291 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6292 | /* ADC2: mute amp left and right */ | |
6293 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6294 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6295 | /* ADC3: mute amp left and right */ | |
6296 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6297 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6298 | ||
6299 | { } | |
6300 | }; | |
f12ab1e0 | 6301 | |
87350ad0 TI |
6302 | /* Macbook Pro rev3 */ |
6303 | static struct hda_verb alc885_mbp3_init_verbs[] = { | |
6304 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
6305 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6306 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6307 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
6308 | /* Rear mixer */ | |
6309 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6310 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6311 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
6312 | /* Front Pin: output 0 (0x0c) */ | |
6313 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6314 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6315 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6316 | /* HP Pin: output 0 (0x0d) */ | |
6317 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, | |
6318 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
6319 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6320 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
6321 | /* Mic (rear) pin: input vref at 80% */ | |
6322 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
6323 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
6324 | /* Front Mic pin: input vref at 80% */ | |
6325 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
6326 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
6327 | /* Line In pin: use output 1 when in LineOut mode */ | |
6328 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
6329 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
6330 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
6331 | ||
6332 | /* FIXME: use matrix-type input source selection */ | |
6333 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
6334 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
6335 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6336 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6337 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6338 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
6339 | /* Input mixer2 */ | |
6340 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6341 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6342 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6343 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
6344 | /* Input mixer3 */ | |
6345 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6346 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6347 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6348 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
6349 | /* ADC1: mute amp left and right */ | |
6350 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6351 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6352 | /* ADC2: mute amp left and right */ | |
6353 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6354 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6355 | /* ADC3: mute amp left and right */ | |
6356 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6357 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6358 | ||
6359 | { } | |
6360 | }; | |
6361 | ||
c54728d8 NF |
6362 | /* iMac 24 mixer. */ |
6363 | static struct snd_kcontrol_new alc885_imac24_mixer[] = { | |
6364 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT), | |
6365 | HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT), | |
6366 | { } /* end */ | |
6367 | }; | |
6368 | ||
6369 | /* iMac 24 init verbs. */ | |
6370 | static struct hda_verb alc885_imac24_init_verbs[] = { | |
6371 | /* Internal speakers: output 0 (0x0c) */ | |
6372 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6373 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6374 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6375 | /* Internal speakers: output 0 (0x0c) */ | |
6376 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6377 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6378 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6379 | /* Headphone: output 0 (0x0c) */ | |
6380 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6381 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6382 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6383 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
6384 | /* Front Mic: input vref at 80% */ | |
6385 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
6386 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
6387 | { } | |
6388 | }; | |
6389 | ||
6390 | /* Toggle speaker-output according to the hp-jack state */ | |
6391 | static void alc885_imac24_automute(struct hda_codec *codec) | |
6392 | { | |
6393 | unsigned int present; | |
6394 | ||
6395 | present = snd_hda_codec_read(codec, 0x14, 0, | |
6396 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
6397 | snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0, |
6398 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
6399 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, | |
6400 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
c54728d8 NF |
6401 | } |
6402 | ||
6403 | /* Processes unsolicited events. */ | |
6404 | static void alc885_imac24_unsol_event(struct hda_codec *codec, | |
6405 | unsigned int res) | |
6406 | { | |
6407 | /* Headphone insertion or removal. */ | |
6408 | if ((res >> 26) == ALC880_HP_EVENT) | |
6409 | alc885_imac24_automute(codec); | |
6410 | } | |
6411 | ||
87350ad0 TI |
6412 | static void alc885_mbp3_automute(struct hda_codec *codec) |
6413 | { | |
6414 | unsigned int present; | |
6415 | ||
6416 | present = snd_hda_codec_read(codec, 0x15, 0, | |
6417 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
6418 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
6419 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
6420 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
6421 | HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE); | |
6422 | ||
6423 | } | |
6424 | static void alc885_mbp3_unsol_event(struct hda_codec *codec, | |
6425 | unsigned int res) | |
6426 | { | |
6427 | /* Headphone insertion or removal. */ | |
6428 | if ((res >> 26) == ALC880_HP_EVENT) | |
6429 | alc885_mbp3_automute(codec); | |
6430 | } | |
6431 | ||
6432 | ||
272a527c KY |
6433 | static struct hda_verb alc882_targa_verbs[] = { |
6434 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6435 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6436 | ||
6437 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6438 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
ea1fb29a | 6439 | |
272a527c KY |
6440 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ |
6441 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
6442 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
6443 | ||
6444 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
6445 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, | |
6446 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | |
6447 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | |
6448 | { } /* end */ | |
6449 | }; | |
6450 | ||
6451 | /* toggle speaker-output according to the hp-jack state */ | |
6452 | static void alc882_targa_automute(struct hda_codec *codec) | |
6453 | { | |
6454 | unsigned int present; | |
ea1fb29a | 6455 | |
272a527c KY |
6456 | present = snd_hda_codec_read(codec, 0x14, 0, |
6457 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
6458 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, |
6459 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
82beb8fd TI |
6460 | snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA, |
6461 | present ? 1 : 3); | |
272a527c KY |
6462 | } |
6463 | ||
6464 | static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res) | |
6465 | { | |
6466 | /* Looks like the unsol event is incompatible with the standard | |
6467 | * definition. 4bit tag is placed at 26 bit! | |
6468 | */ | |
6469 | if (((res >> 26) == ALC880_HP_EVENT)) { | |
6470 | alc882_targa_automute(codec); | |
6471 | } | |
6472 | } | |
6473 | ||
6474 | static struct hda_verb alc882_asus_a7j_verbs[] = { | |
6475 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6476 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6477 | ||
6478 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6479 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6480 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
ea1fb29a | 6481 | |
272a527c KY |
6482 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ |
6483 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
6484 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ | |
6485 | ||
6486 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
6487 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
6488 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
6489 | { } /* end */ | |
6490 | }; | |
6491 | ||
914759b7 TI |
6492 | static struct hda_verb alc882_asus_a7m_verbs[] = { |
6493 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6494 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6495 | ||
6496 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6497 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6498 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
ea1fb29a | 6499 | |
914759b7 TI |
6500 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ |
6501 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
6502 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ | |
6503 | ||
6504 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
6505 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
6506 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
6507 | { } /* end */ | |
6508 | }; | |
6509 | ||
9102cd1c TD |
6510 | static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) |
6511 | { | |
6512 | unsigned int gpiostate, gpiomask, gpiodir; | |
6513 | ||
6514 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, | |
6515 | AC_VERB_GET_GPIO_DATA, 0); | |
6516 | ||
6517 | if (!muted) | |
6518 | gpiostate |= (1 << pin); | |
6519 | else | |
6520 | gpiostate &= ~(1 << pin); | |
6521 | ||
6522 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, | |
6523 | AC_VERB_GET_GPIO_MASK, 0); | |
6524 | gpiomask |= (1 << pin); | |
6525 | ||
6526 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, | |
6527 | AC_VERB_GET_GPIO_DIRECTION, 0); | |
6528 | gpiodir |= (1 << pin); | |
6529 | ||
6530 | ||
6531 | snd_hda_codec_write(codec, codec->afg, 0, | |
6532 | AC_VERB_SET_GPIO_MASK, gpiomask); | |
6533 | snd_hda_codec_write(codec, codec->afg, 0, | |
6534 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); | |
6535 | ||
6536 | msleep(1); | |
6537 | ||
6538 | snd_hda_codec_write(codec, codec->afg, 0, | |
6539 | AC_VERB_SET_GPIO_DATA, gpiostate); | |
6540 | } | |
6541 | ||
7debbe51 TI |
6542 | /* set up GPIO at initialization */ |
6543 | static void alc885_macpro_init_hook(struct hda_codec *codec) | |
6544 | { | |
6545 | alc882_gpio_mute(codec, 0, 0); | |
6546 | alc882_gpio_mute(codec, 1, 0); | |
6547 | } | |
6548 | ||
6549 | /* set up GPIO and update auto-muting at initialization */ | |
6550 | static void alc885_imac24_init_hook(struct hda_codec *codec) | |
6551 | { | |
6552 | alc885_macpro_init_hook(codec); | |
6553 | alc885_imac24_automute(codec); | |
6554 | } | |
6555 | ||
df694daa KY |
6556 | /* |
6557 | * generic initialization of ADC, input mixers and output mixers | |
6558 | */ | |
6559 | static struct hda_verb alc882_auto_init_verbs[] = { | |
6560 | /* | |
6561 | * Unmute ADC0-2 and set the default input to mic-in | |
6562 | */ | |
6563 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6564 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6565 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6566 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6567 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6568 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
1da177e4 | 6569 | |
cb53c626 | 6570 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
df694daa | 6571 | * mixer widget |
f12ab1e0 TI |
6572 | * Note: PASD motherboards uses the Line In 2 as the input for |
6573 | * front panel mic (mic 2) | |
df694daa KY |
6574 | */ |
6575 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
6576 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
6577 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
6578 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6579 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6580 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
e9edcee0 | 6581 | |
df694daa KY |
6582 | /* |
6583 | * Set up output mixers (0x0c - 0x0f) | |
6584 | */ | |
6585 | /* set vol=0 to output mixers */ | |
6586 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6587 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6588 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6589 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6590 | /* set up input amps for analog loopback */ | |
6591 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
6592 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6593 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6594 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6595 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6596 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6597 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6598 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6599 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6600 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6601 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6602 | ||
6603 | /* FIXME: use matrix-type input source selection */ | |
6604 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
6605 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
6606 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
6607 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
6608 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
6609 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
6610 | /* Input mixer2 */ | |
6611 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
6612 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
6613 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
6614 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
6615 | /* Input mixer3 */ | |
6616 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
6617 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
6618 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
6619 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
6620 | ||
6621 | { } | |
6622 | }; | |
6623 | ||
cb53c626 TI |
6624 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
6625 | #define alc882_loopbacks alc880_loopbacks | |
6626 | #endif | |
6627 | ||
df694daa KY |
6628 | /* pcm configuration: identiacal with ALC880 */ |
6629 | #define alc882_pcm_analog_playback alc880_pcm_analog_playback | |
6630 | #define alc882_pcm_analog_capture alc880_pcm_analog_capture | |
6631 | #define alc882_pcm_digital_playback alc880_pcm_digital_playback | |
6632 | #define alc882_pcm_digital_capture alc880_pcm_digital_capture | |
6633 | ||
6634 | /* | |
6635 | * configuration and preset | |
6636 | */ | |
f5fcc13c TI |
6637 | static const char *alc882_models[ALC882_MODEL_LAST] = { |
6638 | [ALC882_3ST_DIG] = "3stack-dig", | |
6639 | [ALC882_6ST_DIG] = "6stack-dig", | |
6640 | [ALC882_ARIMA] = "arima", | |
bdd148a3 | 6641 | [ALC882_W2JC] = "w2jc", |
0438a00e TI |
6642 | [ALC882_TARGA] = "targa", |
6643 | [ALC882_ASUS_A7J] = "asus-a7j", | |
6644 | [ALC882_ASUS_A7M] = "asus-a7m", | |
9102cd1c | 6645 | [ALC885_MACPRO] = "macpro", |
87350ad0 | 6646 | [ALC885_MBP3] = "mbp3", |
c54728d8 | 6647 | [ALC885_IMAC24] = "imac24", |
f5fcc13c TI |
6648 | [ALC882_AUTO] = "auto", |
6649 | }; | |
6650 | ||
6651 | static struct snd_pci_quirk alc882_cfg_tbl[] = { | |
6652 | SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG), | |
272a527c | 6653 | SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J), |
ac8842a0 | 6654 | SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J), |
914759b7 | 6655 | SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M), |
ac3e3741 | 6656 | SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC), |
c5d9f1cd | 6657 | SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG), |
7b9470d8 | 6658 | SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG), |
ac3e3741 | 6659 | SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG), |
4444704c | 6660 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG), |
ac3e3741 TI |
6661 | SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */ |
6662 | SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG), | |
6663 | SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), | |
df694daa KY |
6664 | {} |
6665 | }; | |
6666 | ||
6667 | static struct alc_config_preset alc882_presets[] = { | |
6668 | [ALC882_3ST_DIG] = { | |
6669 | .mixers = { alc882_base_mixer }, | |
6670 | .init_verbs = { alc882_init_verbs }, | |
6671 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6672 | .dac_nids = alc882_dac_nids, | |
6673 | .dig_out_nid = ALC882_DIGOUT_NID, | |
df694daa KY |
6674 | .dig_in_nid = ALC882_DIGIN_NID, |
6675 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | |
6676 | .channel_mode = alc882_ch_modes, | |
4e195a7b | 6677 | .need_dac_fix = 1, |
df694daa KY |
6678 | .input_mux = &alc882_capture_source, |
6679 | }, | |
6680 | [ALC882_6ST_DIG] = { | |
6681 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, | |
6682 | .init_verbs = { alc882_init_verbs }, | |
6683 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6684 | .dac_nids = alc882_dac_nids, | |
6685 | .dig_out_nid = ALC882_DIGOUT_NID, | |
df694daa KY |
6686 | .dig_in_nid = ALC882_DIGIN_NID, |
6687 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), | |
6688 | .channel_mode = alc882_sixstack_modes, | |
6689 | .input_mux = &alc882_capture_source, | |
6690 | }, | |
4b146cb0 TI |
6691 | [ALC882_ARIMA] = { |
6692 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, | |
6693 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs }, | |
6694 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6695 | .dac_nids = alc882_dac_nids, | |
6696 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), | |
6697 | .channel_mode = alc882_sixstack_modes, | |
6698 | .input_mux = &alc882_capture_source, | |
6699 | }, | |
bdd148a3 KY |
6700 | [ALC882_W2JC] = { |
6701 | .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer }, | |
6702 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs, | |
6703 | alc880_gpio1_init_verbs }, | |
6704 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6705 | .dac_nids = alc882_dac_nids, | |
6706 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
6707 | .channel_mode = alc880_threestack_modes, | |
6708 | .need_dac_fix = 1, | |
6709 | .input_mux = &alc882_capture_source, | |
6710 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6711 | }, | |
87350ad0 TI |
6712 | [ALC885_MBP3] = { |
6713 | .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer }, | |
6714 | .init_verbs = { alc885_mbp3_init_verbs, | |
6715 | alc880_gpio1_init_verbs }, | |
6716 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6717 | .dac_nids = alc882_dac_nids, | |
6718 | .channel_mode = alc885_mbp_6ch_modes, | |
6719 | .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes), | |
6720 | .input_mux = &alc882_capture_source, | |
6721 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6722 | .dig_in_nid = ALC882_DIGIN_NID, | |
6723 | .unsol_event = alc885_mbp3_unsol_event, | |
6724 | .init_hook = alc885_mbp3_automute, | |
6725 | }, | |
9102cd1c TD |
6726 | [ALC885_MACPRO] = { |
6727 | .mixers = { alc882_macpro_mixer }, | |
6728 | .init_verbs = { alc882_macpro_init_verbs }, | |
6729 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6730 | .dac_nids = alc882_dac_nids, | |
6731 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6732 | .dig_in_nid = ALC882_DIGIN_NID, | |
6733 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | |
6734 | .channel_mode = alc882_ch_modes, | |
6735 | .input_mux = &alc882_capture_source, | |
7debbe51 | 6736 | .init_hook = alc885_macpro_init_hook, |
9102cd1c | 6737 | }, |
c54728d8 NF |
6738 | [ALC885_IMAC24] = { |
6739 | .mixers = { alc885_imac24_mixer }, | |
6740 | .init_verbs = { alc885_imac24_init_verbs }, | |
6741 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6742 | .dac_nids = alc882_dac_nids, | |
6743 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6744 | .dig_in_nid = ALC882_DIGIN_NID, | |
6745 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | |
6746 | .channel_mode = alc882_ch_modes, | |
6747 | .input_mux = &alc882_capture_source, | |
6748 | .unsol_event = alc885_imac24_unsol_event, | |
7debbe51 | 6749 | .init_hook = alc885_imac24_init_hook, |
c54728d8 | 6750 | }, |
272a527c | 6751 | [ALC882_TARGA] = { |
f9e336f6 | 6752 | .mixers = { alc882_targa_mixer, alc882_chmode_mixer }, |
272a527c KY |
6753 | .init_verbs = { alc882_init_verbs, alc882_targa_verbs}, |
6754 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6755 | .dac_nids = alc882_dac_nids, | |
6756 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6757 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), | |
6758 | .adc_nids = alc882_adc_nids, | |
e1406348 | 6759 | .capsrc_nids = alc882_capsrc_nids, |
272a527c KY |
6760 | .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), |
6761 | .channel_mode = alc882_3ST_6ch_modes, | |
6762 | .need_dac_fix = 1, | |
6763 | .input_mux = &alc882_capture_source, | |
6764 | .unsol_event = alc882_targa_unsol_event, | |
6765 | .init_hook = alc882_targa_automute, | |
6766 | }, | |
6767 | [ALC882_ASUS_A7J] = { | |
f9e336f6 | 6768 | .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer }, |
272a527c KY |
6769 | .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs}, |
6770 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6771 | .dac_nids = alc882_dac_nids, | |
6772 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6773 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), | |
6774 | .adc_nids = alc882_adc_nids, | |
e1406348 | 6775 | .capsrc_nids = alc882_capsrc_nids, |
272a527c KY |
6776 | .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), |
6777 | .channel_mode = alc882_3ST_6ch_modes, | |
6778 | .need_dac_fix = 1, | |
6779 | .input_mux = &alc882_capture_source, | |
ea1fb29a | 6780 | }, |
914759b7 TI |
6781 | [ALC882_ASUS_A7M] = { |
6782 | .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer }, | |
6783 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs, | |
6784 | alc880_gpio1_init_verbs, | |
6785 | alc882_asus_a7m_verbs }, | |
6786 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6787 | .dac_nids = alc882_dac_nids, | |
6788 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6789 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
6790 | .channel_mode = alc880_threestack_modes, | |
6791 | .need_dac_fix = 1, | |
6792 | .input_mux = &alc882_capture_source, | |
ea1fb29a | 6793 | }, |
df694daa KY |
6794 | }; |
6795 | ||
6796 | ||
f95474ec TI |
6797 | /* |
6798 | * Pin config fixes | |
6799 | */ | |
ea1fb29a | 6800 | enum { |
f95474ec TI |
6801 | PINFIX_ABIT_AW9D_MAX |
6802 | }; | |
6803 | ||
6804 | static struct alc_pincfg alc882_abit_aw9d_pinfix[] = { | |
6805 | { 0x15, 0x01080104 }, /* side */ | |
6806 | { 0x16, 0x01011012 }, /* rear */ | |
6807 | { 0x17, 0x01016011 }, /* clfe */ | |
6808 | { } | |
6809 | }; | |
6810 | ||
6811 | static const struct alc_pincfg *alc882_pin_fixes[] = { | |
6812 | [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix, | |
6813 | }; | |
6814 | ||
6815 | static struct snd_pci_quirk alc882_pinfix_tbl[] = { | |
6816 | SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX), | |
6817 | {} | |
6818 | }; | |
6819 | ||
df694daa KY |
6820 | /* |
6821 | * BIOS auto configuration | |
6822 | */ | |
6823 | static void alc882_auto_set_output_and_unmute(struct hda_codec *codec, | |
6824 | hda_nid_t nid, int pin_type, | |
6825 | int dac_idx) | |
6826 | { | |
6827 | /* set as output */ | |
6828 | struct alc_spec *spec = codec->spec; | |
f12ab1e0 TI |
6829 | int idx; |
6830 | ||
f6c7e546 | 6831 | alc_set_pin_output(codec, nid, pin_type); |
df694daa KY |
6832 | if (spec->multiout.dac_nids[dac_idx] == 0x25) |
6833 | idx = 4; | |
6834 | else | |
6835 | idx = spec->multiout.dac_nids[dac_idx] - 2; | |
df694daa KY |
6836 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); |
6837 | ||
6838 | } | |
6839 | ||
6840 | static void alc882_auto_init_multi_out(struct hda_codec *codec) | |
6841 | { | |
6842 | struct alc_spec *spec = codec->spec; | |
6843 | int i; | |
6844 | ||
bc9f98a9 | 6845 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
df694daa | 6846 | for (i = 0; i <= HDA_SIDE; i++) { |
f12ab1e0 | 6847 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
baba8ee9 | 6848 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
df694daa | 6849 | if (nid) |
baba8ee9 | 6850 | alc882_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 6851 | i); |
df694daa KY |
6852 | } |
6853 | } | |
6854 | ||
6855 | static void alc882_auto_init_hp_out(struct hda_codec *codec) | |
6856 | { | |
6857 | struct alc_spec *spec = codec->spec; | |
6858 | hda_nid_t pin; | |
6859 | ||
eb06ed8f | 6860 | pin = spec->autocfg.hp_pins[0]; |
df694daa | 6861 | if (pin) /* connect to front */ |
f12ab1e0 TI |
6862 | /* use dac 0 */ |
6863 | alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
f6c7e546 TI |
6864 | pin = spec->autocfg.speaker_pins[0]; |
6865 | if (pin) | |
6866 | alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
df694daa KY |
6867 | } |
6868 | ||
6869 | #define alc882_is_input_pin(nid) alc880_is_input_pin(nid) | |
6870 | #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID | |
6871 | ||
6872 | static void alc882_auto_init_analog_input(struct hda_codec *codec) | |
6873 | { | |
6874 | struct alc_spec *spec = codec->spec; | |
6875 | int i; | |
6876 | ||
6877 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
6878 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
7194cae6 TI |
6879 | unsigned int vref; |
6880 | if (!nid) | |
6881 | continue; | |
6882 | vref = PIN_IN; | |
6883 | if (1 /*i <= AUTO_PIN_FRONT_MIC*/) { | |
531240ff KY |
6884 | unsigned int pincap; |
6885 | pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); | |
6886 | if ((pincap >> AC_PINCAP_VREF_SHIFT) & | |
7194cae6 TI |
6887 | AC_PINCAP_VREF_80) |
6888 | vref = PIN_VREF80; | |
df694daa | 6889 | } |
7194cae6 TI |
6890 | snd_hda_codec_write(codec, nid, 0, |
6891 | AC_VERB_SET_PIN_WIDGET_CONTROL, vref); | |
6892 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) | |
6893 | snd_hda_codec_write(codec, nid, 0, | |
6894 | AC_VERB_SET_AMP_GAIN_MUTE, | |
6895 | AMP_OUT_MUTE); | |
df694daa KY |
6896 | } |
6897 | } | |
6898 | ||
f511b01c TI |
6899 | static void alc882_auto_init_input_src(struct hda_codec *codec) |
6900 | { | |
6901 | struct alc_spec *spec = codec->spec; | |
6902 | const struct hda_input_mux *imux = spec->input_mux; | |
6903 | int c; | |
6904 | ||
6905 | for (c = 0; c < spec->num_adc_nids; c++) { | |
6906 | hda_nid_t conn_list[HDA_MAX_NUM_INPUTS]; | |
6907 | hda_nid_t nid = spec->capsrc_nids[c]; | |
6908 | int conns, mute, idx, item; | |
6909 | ||
6910 | conns = snd_hda_get_connections(codec, nid, conn_list, | |
6911 | ARRAY_SIZE(conn_list)); | |
6912 | if (conns < 0) | |
6913 | continue; | |
6914 | for (idx = 0; idx < conns; idx++) { | |
6915 | /* if the current connection is the selected one, | |
6916 | * unmute it as default - otherwise mute it | |
6917 | */ | |
6918 | mute = AMP_IN_MUTE(idx); | |
6919 | for (item = 0; item < imux->num_items; item++) { | |
6920 | if (imux->items[item].index == idx) { | |
6921 | if (spec->cur_mux[c] == item) | |
6922 | mute = AMP_IN_UNMUTE(idx); | |
6923 | break; | |
6924 | } | |
6925 | } | |
6926 | snd_hda_codec_write(codec, nid, 0, | |
6927 | AC_VERB_SET_AMP_GAIN_MUTE, mute); | |
6928 | } | |
6929 | } | |
6930 | } | |
6931 | ||
776e184e TI |
6932 | /* add mic boosts if needed */ |
6933 | static int alc_auto_add_mic_boost(struct hda_codec *codec) | |
6934 | { | |
6935 | struct alc_spec *spec = codec->spec; | |
6936 | int err; | |
6937 | hda_nid_t nid; | |
6938 | ||
6939 | nid = spec->autocfg.input_pins[AUTO_PIN_MIC]; | |
ce22e03e | 6940 | if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) { |
776e184e TI |
6941 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
6942 | "Mic Boost", | |
6943 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | |
6944 | if (err < 0) | |
6945 | return err; | |
6946 | } | |
6947 | nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]; | |
ce22e03e | 6948 | if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) { |
776e184e TI |
6949 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
6950 | "Front Mic Boost", | |
6951 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | |
6952 | if (err < 0) | |
6953 | return err; | |
6954 | } | |
6955 | return 0; | |
6956 | } | |
6957 | ||
df694daa KY |
6958 | /* almost identical with ALC880 parser... */ |
6959 | static int alc882_parse_auto_config(struct hda_codec *codec) | |
6960 | { | |
6961 | struct alc_spec *spec = codec->spec; | |
6962 | int err = alc880_parse_auto_config(codec); | |
6963 | ||
6964 | if (err < 0) | |
6965 | return err; | |
776e184e TI |
6966 | else if (!err) |
6967 | return 0; /* no config found */ | |
6968 | ||
6969 | err = alc_auto_add_mic_boost(codec); | |
6970 | if (err < 0) | |
6971 | return err; | |
6972 | ||
6973 | /* hack - override the init verbs */ | |
6974 | spec->init_verbs[0] = alc882_auto_init_verbs; | |
6975 | ||
6976 | return 1; /* config found */ | |
df694daa KY |
6977 | } |
6978 | ||
ae6b813a TI |
6979 | /* additional initialization for auto-configuration model */ |
6980 | static void alc882_auto_init(struct hda_codec *codec) | |
df694daa | 6981 | { |
f6c7e546 | 6982 | struct alc_spec *spec = codec->spec; |
df694daa KY |
6983 | alc882_auto_init_multi_out(codec); |
6984 | alc882_auto_init_hp_out(codec); | |
6985 | alc882_auto_init_analog_input(codec); | |
f511b01c | 6986 | alc882_auto_init_input_src(codec); |
f6c7e546 | 6987 | if (spec->unsol_event) |
7fb0d78f | 6988 | alc_inithook(codec); |
df694daa KY |
6989 | } |
6990 | ||
7943a8ab TI |
6991 | static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */ |
6992 | ||
df694daa KY |
6993 | static int patch_alc882(struct hda_codec *codec) |
6994 | { | |
6995 | struct alc_spec *spec; | |
6996 | int err, board_config; | |
6997 | ||
6998 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
6999 | if (spec == NULL) | |
7000 | return -ENOMEM; | |
7001 | ||
7002 | codec->spec = spec; | |
7003 | ||
f5fcc13c TI |
7004 | board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST, |
7005 | alc882_models, | |
7006 | alc882_cfg_tbl); | |
df694daa KY |
7007 | |
7008 | if (board_config < 0 || board_config >= ALC882_MODEL_LAST) { | |
081d17c4 TD |
7009 | /* Pick up systems that don't supply PCI SSID */ |
7010 | switch (codec->subsystem_id) { | |
7011 | case 0x106b0c00: /* Mac Pro */ | |
7012 | board_config = ALC885_MACPRO; | |
7013 | break; | |
c54728d8 | 7014 | case 0x106b1000: /* iMac 24 */ |
f3911c5a | 7015 | case 0x106b2800: /* AppleTV */ |
3077e44c | 7016 | case 0x106b3e00: /* iMac 24 Aluminium */ |
c54728d8 NF |
7017 | board_config = ALC885_IMAC24; |
7018 | break; | |
c7e0757a | 7019 | case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */ |
9c95c43d | 7020 | case 0x106b00a4: /* MacbookPro4,1 */ |
87350ad0 | 7021 | case 0x106b2c00: /* Macbook Pro rev3 */ |
c7e0757a | 7022 | case 0x106b3600: /* Macbook 3.1 */ |
2a88464c | 7023 | case 0x106b3800: /* MacbookPro4,1 - latter revision */ |
87350ad0 TI |
7024 | board_config = ALC885_MBP3; |
7025 | break; | |
081d17c4 | 7026 | default: |
7943a8ab | 7027 | /* ALC889A is handled better as ALC888-compatible */ |
669faba2 CM |
7028 | if (codec->revision_id == 0x100101 || |
7029 | codec->revision_id == 0x100103) { | |
7943a8ab TI |
7030 | alc_free(codec); |
7031 | return patch_alc883(codec); | |
7032 | } | |
081d17c4 TD |
7033 | printk(KERN_INFO "hda_codec: Unknown model for ALC882, " |
7034 | "trying auto-probe from BIOS...\n"); | |
7035 | board_config = ALC882_AUTO; | |
7036 | } | |
df694daa KY |
7037 | } |
7038 | ||
f95474ec TI |
7039 | alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes); |
7040 | ||
df694daa KY |
7041 | if (board_config == ALC882_AUTO) { |
7042 | /* automatic parse from the BIOS config */ | |
7043 | err = alc882_parse_auto_config(codec); | |
7044 | if (err < 0) { | |
7045 | alc_free(codec); | |
7046 | return err; | |
f12ab1e0 | 7047 | } else if (!err) { |
9c7f852e TI |
7048 | printk(KERN_INFO |
7049 | "hda_codec: Cannot set up configuration " | |
7050 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
7051 | board_config = ALC882_3ST_DIG; |
7052 | } | |
7053 | } | |
7054 | ||
7055 | if (board_config != ALC882_AUTO) | |
7056 | setup_preset(spec, &alc882_presets[board_config]); | |
1da177e4 | 7057 | |
2f893286 KY |
7058 | if (codec->vendor_id == 0x10ec0885) { |
7059 | spec->stream_name_analog = "ALC885 Analog"; | |
7060 | spec->stream_name_digital = "ALC885 Digital"; | |
7061 | } else { | |
7062 | spec->stream_name_analog = "ALC882 Analog"; | |
7063 | spec->stream_name_digital = "ALC882 Digital"; | |
7064 | } | |
7065 | ||
df694daa KY |
7066 | spec->stream_analog_playback = &alc882_pcm_analog_playback; |
7067 | spec->stream_analog_capture = &alc882_pcm_analog_capture; | |
6330079f TI |
7068 | /* FIXME: setup DAC5 */ |
7069 | /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/ | |
7070 | spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture; | |
1da177e4 | 7071 | |
df694daa KY |
7072 | spec->stream_digital_playback = &alc882_pcm_digital_playback; |
7073 | spec->stream_digital_capture = &alc882_pcm_digital_capture; | |
1da177e4 | 7074 | |
54cbc9ab | 7075 | spec->is_mix_capture = 1; /* matrix-style capture */ |
f12ab1e0 | 7076 | if (!spec->adc_nids && spec->input_mux) { |
df694daa | 7077 | /* check whether NID 0x07 is valid */ |
4a471b7d | 7078 | unsigned int wcap = get_wcaps(codec, 0x07); |
f12ab1e0 TI |
7079 | /* get type */ |
7080 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
df694daa KY |
7081 | if (wcap != AC_WID_AUD_IN) { |
7082 | spec->adc_nids = alc882_adc_nids_alt; | |
7083 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt); | |
e1406348 | 7084 | spec->capsrc_nids = alc882_capsrc_nids_alt; |
df694daa KY |
7085 | } else { |
7086 | spec->adc_nids = alc882_adc_nids; | |
7087 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids); | |
e1406348 | 7088 | spec->capsrc_nids = alc882_capsrc_nids; |
df694daa KY |
7089 | } |
7090 | } | |
f9e336f6 | 7091 | set_capture_mixer(spec); |
1da177e4 | 7092 | |
2134ea4f TI |
7093 | spec->vmaster_nid = 0x0c; |
7094 | ||
1da177e4 | 7095 | codec->patch_ops = alc_patch_ops; |
df694daa | 7096 | if (board_config == ALC882_AUTO) |
ae6b813a | 7097 | spec->init_hook = alc882_auto_init; |
cb53c626 TI |
7098 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
7099 | if (!spec->loopback.amplist) | |
7100 | spec->loopback.amplist = alc882_loopbacks; | |
7101 | #endif | |
daead538 | 7102 | codec->proc_widget_hook = print_realtek_coef; |
df694daa KY |
7103 | |
7104 | return 0; | |
7105 | } | |
7106 | ||
7107 | /* | |
9c7f852e TI |
7108 | * ALC883 support |
7109 | * | |
7110 | * ALC883 is almost identical with ALC880 but has cleaner and more flexible | |
7111 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
7112 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
7113 | * 6-channel independent captures. | |
7114 | * | |
7115 | * In addition, an independent DAC for the multi-playback (not used in this | |
7116 | * driver yet). | |
df694daa | 7117 | */ |
9c7f852e TI |
7118 | #define ALC883_DIGOUT_NID 0x06 |
7119 | #define ALC883_DIGIN_NID 0x0a | |
df694daa | 7120 | |
3ab90935 WF |
7121 | #define ALC1200_DIGOUT_NID 0x10 |
7122 | ||
9c7f852e TI |
7123 | static hda_nid_t alc883_dac_nids[4] = { |
7124 | /* front, rear, clfe, rear_surr */ | |
f32a19e3 | 7125 | 0x02, 0x03, 0x04, 0x05 |
9c7f852e | 7126 | }; |
df694daa | 7127 | |
9c7f852e TI |
7128 | static hda_nid_t alc883_adc_nids[2] = { |
7129 | /* ADC1-2 */ | |
7130 | 0x08, 0x09, | |
7131 | }; | |
f12ab1e0 | 7132 | |
f9e336f6 TI |
7133 | static hda_nid_t alc883_adc_nids_alt[1] = { |
7134 | /* ADC1 */ | |
7135 | 0x08, | |
7136 | }; | |
7137 | ||
5b2d1eca VP |
7138 | static hda_nid_t alc883_adc_nids_rev[2] = { |
7139 | /* ADC2-1 */ | |
7140 | 0x09, 0x08 | |
7141 | }; | |
7142 | ||
e1406348 TI |
7143 | static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 }; |
7144 | ||
5b2d1eca VP |
7145 | static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 }; |
7146 | ||
9c7f852e TI |
7147 | /* input MUX */ |
7148 | /* FIXME: should be a matrix-type input source selection */ | |
df694daa | 7149 | |
9c7f852e TI |
7150 | static struct hda_input_mux alc883_capture_source = { |
7151 | .num_items = 4, | |
7152 | .items = { | |
7153 | { "Mic", 0x0 }, | |
7154 | { "Front Mic", 0x1 }, | |
7155 | { "Line", 0x2 }, | |
7156 | { "CD", 0x4 }, | |
7157 | }, | |
7158 | }; | |
bc9f98a9 | 7159 | |
17bba1b7 J |
7160 | static struct hda_input_mux alc883_3stack_6ch_intel = { |
7161 | .num_items = 4, | |
7162 | .items = { | |
7163 | { "Mic", 0x1 }, | |
7164 | { "Front Mic", 0x0 }, | |
7165 | { "Line", 0x2 }, | |
7166 | { "CD", 0x4 }, | |
7167 | }, | |
7168 | }; | |
7169 | ||
bc9f98a9 KY |
7170 | static struct hda_input_mux alc883_lenovo_101e_capture_source = { |
7171 | .num_items = 2, | |
7172 | .items = { | |
7173 | { "Mic", 0x1 }, | |
7174 | { "Line", 0x2 }, | |
7175 | }, | |
7176 | }; | |
7177 | ||
272a527c KY |
7178 | static struct hda_input_mux alc883_lenovo_nb0763_capture_source = { |
7179 | .num_items = 4, | |
7180 | .items = { | |
7181 | { "Mic", 0x0 }, | |
7182 | { "iMic", 0x1 }, | |
7183 | { "Line", 0x2 }, | |
7184 | { "CD", 0x4 }, | |
7185 | }, | |
7186 | }; | |
7187 | ||
fb97dc67 J |
7188 | static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = { |
7189 | .num_items = 2, | |
7190 | .items = { | |
7191 | { "Mic", 0x0 }, | |
7192 | { "Int Mic", 0x1 }, | |
7193 | }, | |
7194 | }; | |
7195 | ||
e2757d5e KY |
7196 | static struct hda_input_mux alc883_lenovo_sky_capture_source = { |
7197 | .num_items = 3, | |
7198 | .items = { | |
7199 | { "Mic", 0x0 }, | |
7200 | { "Front Mic", 0x1 }, | |
7201 | { "Line", 0x4 }, | |
7202 | }, | |
7203 | }; | |
7204 | ||
7205 | static struct hda_input_mux alc883_asus_eee1601_capture_source = { | |
7206 | .num_items = 2, | |
7207 | .items = { | |
7208 | { "Mic", 0x0 }, | |
7209 | { "Line", 0x2 }, | |
7210 | }, | |
7211 | }; | |
7212 | ||
9c7f852e TI |
7213 | /* |
7214 | * 2ch mode | |
7215 | */ | |
7216 | static struct hda_channel_mode alc883_3ST_2ch_modes[1] = { | |
7217 | { 2, NULL } | |
7218 | }; | |
7219 | ||
7220 | /* | |
7221 | * 2ch mode | |
7222 | */ | |
7223 | static struct hda_verb alc883_3ST_ch2_init[] = { | |
7224 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
7225 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7226 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
7227 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7228 | { } /* end */ | |
7229 | }; | |
7230 | ||
b201131c TD |
7231 | /* |
7232 | * 4ch mode | |
7233 | */ | |
7234 | static struct hda_verb alc883_3ST_ch4_init[] = { | |
7235 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
7236 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7237 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7238 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7239 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
7240 | { } /* end */ | |
7241 | }; | |
7242 | ||
9c7f852e TI |
7243 | /* |
7244 | * 6ch mode | |
7245 | */ | |
7246 | static struct hda_verb alc883_3ST_ch6_init[] = { | |
7247 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7248 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7249 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
7250 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7251 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7252 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
7253 | { } /* end */ | |
7254 | }; | |
7255 | ||
b201131c | 7256 | static struct hda_channel_mode alc883_3ST_6ch_modes[3] = { |
9c7f852e | 7257 | { 2, alc883_3ST_ch2_init }, |
b201131c | 7258 | { 4, alc883_3ST_ch4_init }, |
9c7f852e TI |
7259 | { 6, alc883_3ST_ch6_init }, |
7260 | }; | |
7261 | ||
17bba1b7 J |
7262 | /* |
7263 | * 2ch mode | |
7264 | */ | |
7265 | static struct hda_verb alc883_3ST_ch2_intel_init[] = { | |
7266 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
7267 | { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7268 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
7269 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7270 | { } /* end */ | |
7271 | }; | |
7272 | ||
7273 | /* | |
7274 | * 4ch mode | |
7275 | */ | |
7276 | static struct hda_verb alc883_3ST_ch4_intel_init[] = { | |
7277 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
7278 | { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7279 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7280 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7281 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
7282 | { } /* end */ | |
7283 | }; | |
7284 | ||
7285 | /* | |
7286 | * 6ch mode | |
7287 | */ | |
7288 | static struct hda_verb alc883_3ST_ch6_intel_init[] = { | |
7289 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7290 | { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7291 | { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
7292 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7293 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7294 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
7295 | { } /* end */ | |
7296 | }; | |
7297 | ||
7298 | static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = { | |
7299 | { 2, alc883_3ST_ch2_intel_init }, | |
7300 | { 4, alc883_3ST_ch4_intel_init }, | |
7301 | { 6, alc883_3ST_ch6_intel_init }, | |
7302 | }; | |
7303 | ||
9c7f852e TI |
7304 | /* |
7305 | * 6ch mode | |
7306 | */ | |
7307 | static struct hda_verb alc883_sixstack_ch6_init[] = { | |
7308 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
7309 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7310 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7311 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7312 | { } /* end */ | |
7313 | }; | |
7314 | ||
7315 | /* | |
7316 | * 8ch mode | |
7317 | */ | |
7318 | static struct hda_verb alc883_sixstack_ch8_init[] = { | |
7319 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7320 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7321 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7322 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7323 | { } /* end */ | |
7324 | }; | |
7325 | ||
7326 | static struct hda_channel_mode alc883_sixstack_modes[2] = { | |
7327 | { 6, alc883_sixstack_ch6_init }, | |
7328 | { 8, alc883_sixstack_ch8_init }, | |
7329 | }; | |
7330 | ||
b373bdeb AN |
7331 | static struct hda_verb alc883_medion_eapd_verbs[] = { |
7332 | /* eanable EAPD on medion laptop */ | |
7333 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
7334 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
7335 | { } | |
7336 | }; | |
7337 | ||
9c7f852e TI |
7338 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
7339 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
7340 | */ | |
7341 | ||
7342 | static struct snd_kcontrol_new alc883_base_mixer[] = { | |
df694daa | 7343 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9c7f852e TI |
7344 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
7345 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7346 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
7347 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
7348 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
7349 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
7350 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
7351 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
7352 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
7353 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
df694daa KY |
7354 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
7355 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7356 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7357 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7358 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 7359 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
df694daa | 7360 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
9c7f852e | 7361 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
32360416 | 7362 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
7363 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
7364 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
7365 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
df694daa | 7366 | { } /* end */ |
834be88d TI |
7367 | }; |
7368 | ||
a8848bd6 AS |
7369 | static struct snd_kcontrol_new alc883_mitac_mixer[] = { |
7370 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7371 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
7372 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
7373 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
7374 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
7375 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
7376 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
7377 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7378 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7379 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7380 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7381 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
7382 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
a8848bd6 AS |
7383 | { } /* end */ |
7384 | }; | |
7385 | ||
0c4cc443 | 7386 | static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = { |
368c7a95 J |
7387 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
7388 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
7389 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7390 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
7391 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7392 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7393 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7394 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7395 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
7396 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
368c7a95 J |
7397 | { } /* end */ |
7398 | }; | |
7399 | ||
fb97dc67 J |
7400 | static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = { |
7401 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7402 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
7403 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7404 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
7405 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7406 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7407 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7408 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7409 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
7410 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
fb97dc67 J |
7411 | { } /* end */ |
7412 | }; | |
7413 | ||
9c7f852e TI |
7414 | static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = { |
7415 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7416 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
7417 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7418 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7419 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7420 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7421 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7422 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 7423 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
7424 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
7425 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 7426 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
7427 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
7428 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
7429 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
9c7f852e TI |
7430 | { } /* end */ |
7431 | }; | |
df694daa | 7432 | |
9c7f852e TI |
7433 | static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = { |
7434 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7435 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
7436 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7437 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
7438 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
7439 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
7440 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
7441 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
7442 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7443 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7444 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7445 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7446 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7447 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 7448 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
7449 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
7450 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 7451 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
7452 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
7453 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
7454 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
9c7f852e TI |
7455 | { } /* end */ |
7456 | }; | |
7457 | ||
17bba1b7 J |
7458 | static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = { |
7459 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7460 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
7461 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7462 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
7463 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, | |
7464 | HDA_OUTPUT), | |
7465 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
7466 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
7467 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
7468 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
7469 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7470 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7471 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7472 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7473 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7474 | HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT), | |
7475 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
7476 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7477 | HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT), | |
7478 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7479 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
7480 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
17bba1b7 J |
7481 | { } /* end */ |
7482 | }; | |
7483 | ||
d1d985f0 | 7484 | static struct snd_kcontrol_new alc883_fivestack_mixer[] = { |
c07584c8 | 7485 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
0701e064 | 7486 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
c07584c8 | 7487 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
0701e064 | 7488 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
c07584c8 TD |
7489 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
7490 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
0701e064 TI |
7491 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
7492 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
c07584c8 TD |
7493 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
7494 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7495 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7496 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7497 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7498 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 7499 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
c07584c8 TD |
7500 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
7501 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 7502 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
c07584c8 TD |
7503 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
7504 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
7505 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
c07584c8 TD |
7506 | { } /* end */ |
7507 | }; | |
7508 | ||
ccc656ce KY |
7509 | static struct snd_kcontrol_new alc883_tagra_mixer[] = { |
7510 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7511 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7512 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7513 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7514 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
7515 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
7516 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
7517 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
7518 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
7519 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7520 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7521 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7522 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7523 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 7524 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce | 7525 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
ccc656ce | 7526 | { } /* end */ |
f12ab1e0 | 7527 | }; |
ccc656ce KY |
7528 | |
7529 | static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = { | |
7530 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7531 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7532 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7533 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7534 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7535 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 7536 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce | 7537 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
4383fae0 J |
7538 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
7539 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
7540 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
ccc656ce | 7541 | { } /* end */ |
f12ab1e0 | 7542 | }; |
ccc656ce | 7543 | |
bc9f98a9 KY |
7544 | static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = { |
7545 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7546 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
86cd9298 TI |
7547 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
7548 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
bc9f98a9 KY |
7549 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
7550 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7551 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7552 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
bc9f98a9 | 7553 | { } /* end */ |
f12ab1e0 | 7554 | }; |
bc9f98a9 | 7555 | |
272a527c KY |
7556 | static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = { |
7557 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7558 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT), | |
7559 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7560 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7561 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7562 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7563 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7564 | HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7565 | HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
272a527c KY |
7566 | { } /* end */ |
7567 | }; | |
7568 | ||
7569 | static struct snd_kcontrol_new alc883_medion_md2_mixer[] = { | |
7570 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7571 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7572 | HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
7573 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7574 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7575 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7576 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7577 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7578 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
272a527c | 7579 | { } /* end */ |
ea1fb29a | 7580 | }; |
272a527c | 7581 | |
2880a867 | 7582 | static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = { |
d1a991a6 KY |
7583 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
7584 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
2880a867 | 7585 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), |
2880a867 TD |
7586 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
7587 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
d1a991a6 KY |
7588 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
7589 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7590 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2880a867 | 7591 | { } /* end */ |
d1a991a6 | 7592 | }; |
2880a867 | 7593 | |
e2757d5e KY |
7594 | static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = { |
7595 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7596 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
7597 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT), | |
7598 | HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT), | |
7599 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", | |
7600 | 0x0d, 1, 0x0, HDA_OUTPUT), | |
7601 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT), | |
7602 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT), | |
7603 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), | |
7604 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
7605 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
7606 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7607 | HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT), | |
7608 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7609 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7610 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7611 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7612 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7613 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7614 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7615 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7616 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
7617 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
e2757d5e KY |
7618 | { } /* end */ |
7619 | }; | |
7620 | ||
7621 | static struct hda_bind_ctls alc883_bind_cap_vol = { | |
7622 | .ops = &snd_hda_bind_vol, | |
7623 | .values = { | |
7624 | HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT), | |
7625 | HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT), | |
7626 | 0 | |
7627 | }, | |
7628 | }; | |
7629 | ||
7630 | static struct hda_bind_ctls alc883_bind_cap_switch = { | |
7631 | .ops = &snd_hda_bind_sw, | |
7632 | .values = { | |
7633 | HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT), | |
7634 | HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT), | |
7635 | 0 | |
7636 | }, | |
7637 | }; | |
7638 | ||
7639 | static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = { | |
7640 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7641 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
7642 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7643 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7644 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7645 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7646 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7647 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
f9e336f6 TI |
7648 | { } /* end */ |
7649 | }; | |
7650 | ||
7651 | static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = { | |
e2757d5e KY |
7652 | HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol), |
7653 | HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch), | |
7654 | { | |
7655 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7656 | /* .name = "Capture Source", */ | |
7657 | .name = "Input Source", | |
7658 | .count = 1, | |
54cbc9ab TI |
7659 | .info = alc_mux_enum_info, |
7660 | .get = alc_mux_enum_get, | |
7661 | .put = alc_mux_enum_put, | |
e2757d5e KY |
7662 | }, |
7663 | { } /* end */ | |
7664 | }; | |
7665 | ||
9c7f852e TI |
7666 | static struct snd_kcontrol_new alc883_chmode_mixer[] = { |
7667 | { | |
7668 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7669 | .name = "Channel Mode", | |
7670 | .info = alc_ch_mode_info, | |
7671 | .get = alc_ch_mode_get, | |
7672 | .put = alc_ch_mode_put, | |
7673 | }, | |
7674 | { } /* end */ | |
7675 | }; | |
7676 | ||
7677 | static struct hda_verb alc883_init_verbs[] = { | |
7678 | /* ADC1: mute amp left and right */ | |
e2757d5e | 7679 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
df694daa | 7680 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
9c7f852e TI |
7681 | /* ADC2: mute amp left and right */ |
7682 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
df694daa | 7683 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
9c7f852e TI |
7684 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ |
7685 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7686 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7687 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7688 | /* Rear mixer */ | |
7689 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7690 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7691 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7692 | /* CLFE mixer */ | |
7693 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7694 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7695 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7696 | /* Side mixer */ | |
7697 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7698 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7699 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
df694daa | 7700 | |
cb53c626 TI |
7701 | /* mute analog input loopbacks */ |
7702 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7703 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7704 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
7705 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
7706 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa | 7707 | |
9c7f852e TI |
7708 | /* Front Pin: output 0 (0x0c) */ |
7709 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7710 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7711 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7712 | /* Rear Pin: output 1 (0x0d) */ | |
7713 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7714 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7715 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
7716 | /* CLFE Pin: output 2 (0x0e) */ | |
7717 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7718 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7719 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
7720 | /* Side Pin: output 3 (0x0f) */ | |
7721 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7722 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7723 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
7724 | /* Mic (rear) pin: input vref at 80% */ | |
7725 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
7726 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
7727 | /* Front Mic pin: input vref at 80% */ | |
7728 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
7729 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
7730 | /* Line In pin: input */ | |
7731 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
7732 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
7733 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
7734 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7735 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7736 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7737 | /* CD pin widget for input */ | |
7738 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
7739 | ||
7740 | /* FIXME: use matrix-type input source selection */ | |
7741 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
7742 | /* Input mixer2 */ | |
7743 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
e2757d5e KY |
7744 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
7745 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
7746 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9c7f852e TI |
7747 | /* Input mixer3 */ |
7748 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
e2757d5e KY |
7749 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
7750 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
7751 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9c7f852e TI |
7752 | { } |
7753 | }; | |
7754 | ||
a8848bd6 AS |
7755 | /* toggle speaker-output according to the hp-jack state */ |
7756 | static void alc883_mitac_hp_automute(struct hda_codec *codec) | |
7757 | { | |
7758 | unsigned int present; | |
7759 | ||
7760 | present = snd_hda_codec_read(codec, 0x15, 0, | |
7761 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
7762 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
7763 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7764 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
7765 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7766 | } | |
7767 | ||
7768 | /* auto-toggle front mic */ | |
7769 | /* | |
7770 | static void alc883_mitac_mic_automute(struct hda_codec *codec) | |
7771 | { | |
7772 | unsigned int present; | |
7773 | unsigned char bits; | |
7774 | ||
7775 | present = snd_hda_codec_read(codec, 0x18, 0, | |
7776 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
7777 | bits = present ? HDA_AMP_MUTE : 0; | |
7778 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); | |
7779 | } | |
7780 | */ | |
7781 | ||
7782 | static void alc883_mitac_automute(struct hda_codec *codec) | |
7783 | { | |
7784 | alc883_mitac_hp_automute(codec); | |
7785 | /* alc883_mitac_mic_automute(codec); */ | |
7786 | } | |
7787 | ||
7788 | static void alc883_mitac_unsol_event(struct hda_codec *codec, | |
7789 | unsigned int res) | |
7790 | { | |
7791 | switch (res >> 26) { | |
7792 | case ALC880_HP_EVENT: | |
7793 | alc883_mitac_hp_automute(codec); | |
7794 | break; | |
7795 | case ALC880_MIC_EVENT: | |
7796 | /* alc883_mitac_mic_automute(codec); */ | |
7797 | break; | |
7798 | } | |
7799 | } | |
7800 | ||
7801 | static struct hda_verb alc883_mitac_verbs[] = { | |
7802 | /* HP */ | |
7803 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7804 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7805 | /* Subwoofer */ | |
7806 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
7807 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7808 | ||
7809 | /* enable unsolicited event */ | |
7810 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7811 | /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */ | |
7812 | ||
7813 | { } /* end */ | |
7814 | }; | |
7815 | ||
0c4cc443 | 7816 | static struct hda_verb alc883_clevo_m720_verbs[] = { |
368c7a95 J |
7817 | /* HP */ |
7818 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7819 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7820 | /* Int speaker */ | |
7821 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
7822 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7823 | ||
7824 | /* enable unsolicited event */ | |
7825 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
0c4cc443 | 7826 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, |
368c7a95 J |
7827 | |
7828 | { } /* end */ | |
7829 | }; | |
7830 | ||
fb97dc67 J |
7831 | static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = { |
7832 | /* HP */ | |
7833 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7834 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7835 | /* Subwoofer */ | |
7836 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
7837 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7838 | ||
7839 | /* enable unsolicited event */ | |
7840 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7841 | ||
7842 | { } /* end */ | |
7843 | }; | |
7844 | ||
ccc656ce KY |
7845 | static struct hda_verb alc883_tagra_verbs[] = { |
7846 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7847 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7848 | ||
7849 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7850 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
ea1fb29a | 7851 | |
ccc656ce KY |
7852 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ |
7853 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
7854 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
7855 | ||
7856 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
f12ab1e0 TI |
7857 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
7858 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | |
7859 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | |
ccc656ce KY |
7860 | |
7861 | { } /* end */ | |
7862 | }; | |
7863 | ||
bc9f98a9 KY |
7864 | static struct hda_verb alc883_lenovo_101e_verbs[] = { |
7865 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7866 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN}, | |
7867 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN}, | |
7868 | { } /* end */ | |
7869 | }; | |
7870 | ||
272a527c KY |
7871 | static struct hda_verb alc883_lenovo_nb0763_verbs[] = { |
7872 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7873 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7874 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7875 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7876 | { } /* end */ | |
7877 | }; | |
7878 | ||
7879 | static struct hda_verb alc888_lenovo_ms7195_verbs[] = { | |
7880 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7881 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7882 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7883 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN}, | |
7884 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7885 | { } /* end */ | |
7886 | }; | |
7887 | ||
189609ae KY |
7888 | static struct hda_verb alc883_haier_w66_verbs[] = { |
7889 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7890 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7891 | ||
7892 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7893 | ||
7894 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7895 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7896 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7897 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7898 | { } /* end */ | |
7899 | }; | |
7900 | ||
e2757d5e KY |
7901 | static struct hda_verb alc888_lenovo_sky_verbs[] = { |
7902 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7903 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7904 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7905 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7906 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7907 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7908 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7909 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7910 | { } /* end */ | |
7911 | }; | |
7912 | ||
4723c022 | 7913 | static struct hda_verb alc888_3st_hp_verbs[] = { |
8341de60 | 7914 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */ |
f32a19e3 HRK |
7915 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */ |
7916 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */ | |
8341de60 CM |
7917 | { } |
7918 | }; | |
7919 | ||
5795b9e6 | 7920 | static struct hda_verb alc888_6st_dell_verbs[] = { |
5795b9e6 CM |
7921 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
7922 | { } | |
7923 | }; | |
7924 | ||
4723c022 | 7925 | static struct hda_verb alc888_3st_hp_2ch_init[] = { |
8341de60 CM |
7926 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
7927 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7928 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
7929 | { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7930 | { } | |
7931 | }; | |
7932 | ||
4723c022 | 7933 | static struct hda_verb alc888_3st_hp_6ch_init[] = { |
8341de60 CM |
7934 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
7935 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7936 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7937 | { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7938 | { } | |
7939 | }; | |
7940 | ||
4723c022 CM |
7941 | static struct hda_channel_mode alc888_3st_hp_modes[2] = { |
7942 | { 2, alc888_3st_hp_2ch_init }, | |
7943 | { 6, alc888_3st_hp_6ch_init }, | |
8341de60 CM |
7944 | }; |
7945 | ||
272a527c KY |
7946 | /* toggle front-jack and RCA according to the hp-jack state */ |
7947 | static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec) | |
7948 | { | |
7949 | unsigned int present; | |
ea1fb29a | 7950 | |
272a527c KY |
7951 | present = snd_hda_codec_read(codec, 0x1b, 0, |
7952 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
7953 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
7954 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7955 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
7956 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c KY |
7957 | } |
7958 | ||
7959 | /* toggle RCA according to the front-jack state */ | |
7960 | static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec) | |
7961 | { | |
7962 | unsigned int present; | |
ea1fb29a | 7963 | |
272a527c KY |
7964 | present = snd_hda_codec_read(codec, 0x14, 0, |
7965 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
7966 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
7967 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c | 7968 | } |
47fd830a | 7969 | |
272a527c KY |
7970 | static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec, |
7971 | unsigned int res) | |
7972 | { | |
7973 | if ((res >> 26) == ALC880_HP_EVENT) | |
7974 | alc888_lenovo_ms7195_front_automute(codec); | |
7975 | if ((res >> 26) == ALC880_FRONT_EVENT) | |
7976 | alc888_lenovo_ms7195_rca_automute(codec); | |
7977 | } | |
7978 | ||
7979 | static struct hda_verb alc883_medion_md2_verbs[] = { | |
7980 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7981 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7982 | ||
7983 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7984 | ||
7985 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7986 | { } /* end */ | |
7987 | }; | |
7988 | ||
7989 | /* toggle speaker-output according to the hp-jack state */ | |
7990 | static void alc883_medion_md2_automute(struct hda_codec *codec) | |
7991 | { | |
7992 | unsigned int present; | |
ea1fb29a | 7993 | |
272a527c KY |
7994 | present = snd_hda_codec_read(codec, 0x14, 0, |
7995 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
7996 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
7997 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c KY |
7998 | } |
7999 | ||
8000 | static void alc883_medion_md2_unsol_event(struct hda_codec *codec, | |
8001 | unsigned int res) | |
8002 | { | |
8003 | if ((res >> 26) == ALC880_HP_EVENT) | |
8004 | alc883_medion_md2_automute(codec); | |
8005 | } | |
8006 | ||
ccc656ce KY |
8007 | /* toggle speaker-output according to the hp-jack state */ |
8008 | static void alc883_tagra_automute(struct hda_codec *codec) | |
8009 | { | |
8010 | unsigned int present; | |
f12ab1e0 | 8011 | unsigned char bits; |
ccc656ce KY |
8012 | |
8013 | present = snd_hda_codec_read(codec, 0x14, 0, | |
8014 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
8015 | bits = present ? HDA_AMP_MUTE : 0; |
8016 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
8017 | HDA_AMP_MUTE, bits); | |
82beb8fd TI |
8018 | snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA, |
8019 | present ? 1 : 3); | |
ccc656ce KY |
8020 | } |
8021 | ||
8022 | static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res) | |
8023 | { | |
8024 | if ((res >> 26) == ALC880_HP_EVENT) | |
8025 | alc883_tagra_automute(codec); | |
8026 | } | |
8027 | ||
368c7a95 | 8028 | /* toggle speaker-output according to the hp-jack state */ |
0c4cc443 | 8029 | static void alc883_clevo_m720_hp_automute(struct hda_codec *codec) |
368c7a95 J |
8030 | { |
8031 | unsigned int present; | |
8032 | unsigned char bits; | |
8033 | ||
8034 | present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0) | |
8035 | & AC_PINSENSE_PRESENCE; | |
8036 | bits = present ? HDA_AMP_MUTE : 0; | |
8037 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
8038 | HDA_AMP_MUTE, bits); | |
8039 | } | |
8040 | ||
0c4cc443 HRK |
8041 | static void alc883_clevo_m720_mic_automute(struct hda_codec *codec) |
8042 | { | |
8043 | unsigned int present; | |
8044 | ||
8045 | present = snd_hda_codec_read(codec, 0x18, 0, | |
8046 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
8047 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, | |
8048 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
8049 | } | |
8050 | ||
8051 | static void alc883_clevo_m720_automute(struct hda_codec *codec) | |
8052 | { | |
8053 | alc883_clevo_m720_hp_automute(codec); | |
8054 | alc883_clevo_m720_mic_automute(codec); | |
8055 | } | |
8056 | ||
8057 | static void alc883_clevo_m720_unsol_event(struct hda_codec *codec, | |
368c7a95 J |
8058 | unsigned int res) |
8059 | { | |
0c4cc443 HRK |
8060 | switch (res >> 26) { |
8061 | case ALC880_HP_EVENT: | |
8062 | alc883_clevo_m720_hp_automute(codec); | |
8063 | break; | |
8064 | case ALC880_MIC_EVENT: | |
8065 | alc883_clevo_m720_mic_automute(codec); | |
8066 | break; | |
8067 | } | |
368c7a95 J |
8068 | } |
8069 | ||
fb97dc67 J |
8070 | /* toggle speaker-output according to the hp-jack state */ |
8071 | static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec) | |
8072 | { | |
8073 | unsigned int present; | |
8074 | unsigned char bits; | |
8075 | ||
8076 | present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0) | |
8077 | & AC_PINSENSE_PRESENCE; | |
8078 | bits = present ? HDA_AMP_MUTE : 0; | |
8079 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
8080 | HDA_AMP_MUTE, bits); | |
8081 | } | |
8082 | ||
8083 | static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec, | |
8084 | unsigned int res) | |
8085 | { | |
8086 | if ((res >> 26) == ALC880_HP_EVENT) | |
8087 | alc883_2ch_fujitsu_pi2515_automute(codec); | |
8088 | } | |
8089 | ||
189609ae KY |
8090 | static void alc883_haier_w66_automute(struct hda_codec *codec) |
8091 | { | |
8092 | unsigned int present; | |
8093 | unsigned char bits; | |
8094 | ||
8095 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
8096 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
8097 | bits = present ? 0x80 : 0; | |
8098 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
8099 | 0x80, bits); | |
8100 | } | |
8101 | ||
8102 | static void alc883_haier_w66_unsol_event(struct hda_codec *codec, | |
8103 | unsigned int res) | |
8104 | { | |
8105 | if ((res >> 26) == ALC880_HP_EVENT) | |
8106 | alc883_haier_w66_automute(codec); | |
8107 | } | |
8108 | ||
bc9f98a9 KY |
8109 | static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec) |
8110 | { | |
8111 | unsigned int present; | |
f12ab1e0 | 8112 | unsigned char bits; |
bc9f98a9 KY |
8113 | |
8114 | present = snd_hda_codec_read(codec, 0x14, 0, | |
8115 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
8116 | bits = present ? HDA_AMP_MUTE : 0; |
8117 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
8118 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
8119 | } |
8120 | ||
8121 | static void alc883_lenovo_101e_all_automute(struct hda_codec *codec) | |
8122 | { | |
8123 | unsigned int present; | |
f12ab1e0 | 8124 | unsigned char bits; |
bc9f98a9 KY |
8125 | |
8126 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
8127 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
8128 | bits = present ? HDA_AMP_MUTE : 0; |
8129 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
8130 | HDA_AMP_MUTE, bits); | |
8131 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
8132 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
8133 | } |
8134 | ||
8135 | static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec, | |
8136 | unsigned int res) | |
8137 | { | |
8138 | if ((res >> 26) == ALC880_HP_EVENT) | |
8139 | alc883_lenovo_101e_all_automute(codec); | |
8140 | if ((res >> 26) == ALC880_FRONT_EVENT) | |
8141 | alc883_lenovo_101e_ispeaker_automute(codec); | |
8142 | } | |
8143 | ||
676a9b53 TI |
8144 | /* toggle speaker-output according to the hp-jack state */ |
8145 | static void alc883_acer_aspire_automute(struct hda_codec *codec) | |
8146 | { | |
8147 | unsigned int present; | |
ea1fb29a | 8148 | |
676a9b53 TI |
8149 | present = snd_hda_codec_read(codec, 0x14, 0, |
8150 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
8151 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
8152 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
8153 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
8154 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
8155 | } | |
8156 | ||
8157 | static void alc883_acer_aspire_unsol_event(struct hda_codec *codec, | |
8158 | unsigned int res) | |
8159 | { | |
8160 | if ((res >> 26) == ALC880_HP_EVENT) | |
8161 | alc883_acer_aspire_automute(codec); | |
8162 | } | |
8163 | ||
d1a991a6 KY |
8164 | static struct hda_verb alc883_acer_eapd_verbs[] = { |
8165 | /* HP Pin: output 0 (0x0c) */ | |
8166 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
8167 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8168 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8169 | /* Front Pin: output 0 (0x0c) */ | |
676a9b53 TI |
8170 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
8171 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
d1a991a6 | 8172 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
d1a991a6 KY |
8173 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, |
8174 | /* eanable EAPD on medion laptop */ | |
8175 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
8176 | {0x20, AC_VERB_SET_PROC_COEF, 0x3050}, | |
676a9b53 TI |
8177 | /* enable unsolicited event */ |
8178 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
d1a991a6 KY |
8179 | { } |
8180 | }; | |
8181 | ||
5795b9e6 CM |
8182 | static void alc888_6st_dell_front_automute(struct hda_codec *codec) |
8183 | { | |
8184 | unsigned int present; | |
ea1fb29a | 8185 | |
5795b9e6 CM |
8186 | present = snd_hda_codec_read(codec, 0x1b, 0, |
8187 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
8188 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
8189 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
8190 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
8191 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
8192 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
8193 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
8194 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
8195 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
8196 | } | |
8197 | ||
8198 | static void alc888_6st_dell_unsol_event(struct hda_codec *codec, | |
8199 | unsigned int res) | |
8200 | { | |
8201 | switch (res >> 26) { | |
8202 | case ALC880_HP_EVENT: | |
8203 | printk("hp_event\n"); | |
8204 | alc888_6st_dell_front_automute(codec); | |
8205 | break; | |
8206 | } | |
8207 | } | |
8208 | ||
e2757d5e KY |
8209 | static void alc888_lenovo_sky_front_automute(struct hda_codec *codec) |
8210 | { | |
8211 | unsigned int mute; | |
8212 | unsigned int present; | |
8213 | ||
8214 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); | |
8215 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
8216 | AC_VERB_GET_PIN_SENSE, 0); | |
8217 | present = (present & 0x80000000) != 0; | |
8218 | if (present) { | |
8219 | /* mute internal speaker */ | |
8220 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
8221 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
8222 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
8223 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
8224 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
8225 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
8226 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
8227 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
8228 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, | |
8229 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
8230 | } else { | |
8231 | /* unmute internal speaker if necessary */ | |
8232 | mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); | |
8233 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
8234 | HDA_AMP_MUTE, mute); | |
8235 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
8236 | HDA_AMP_MUTE, mute); | |
8237 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
8238 | HDA_AMP_MUTE, mute); | |
8239 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
8240 | HDA_AMP_MUTE, mute); | |
8241 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, | |
8242 | HDA_AMP_MUTE, mute); | |
8243 | } | |
8244 | } | |
8245 | ||
8246 | static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec, | |
8247 | unsigned int res) | |
8248 | { | |
8249 | if ((res >> 26) == ALC880_HP_EVENT) | |
8250 | alc888_lenovo_sky_front_automute(codec); | |
8251 | } | |
8252 | ||
9c7f852e TI |
8253 | /* |
8254 | * generic initialization of ADC, input mixers and output mixers | |
8255 | */ | |
8256 | static struct hda_verb alc883_auto_init_verbs[] = { | |
8257 | /* | |
8258 | * Unmute ADC0-2 and set the default input to mic-in | |
8259 | */ | |
8260 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8261 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8262 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8263 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8264 | ||
cb53c626 | 8265 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
9c7f852e | 8266 | * mixer widget |
f12ab1e0 TI |
8267 | * Note: PASD motherboards uses the Line In 2 as the input for |
8268 | * front panel mic (mic 2) | |
9c7f852e TI |
8269 | */ |
8270 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
8271 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
8272 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
8273 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
8274 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
8275 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9c7f852e TI |
8276 | |
8277 | /* | |
8278 | * Set up output mixers (0x0c - 0x0f) | |
8279 | */ | |
8280 | /* set vol=0 to output mixers */ | |
8281 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8282 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8283 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8284 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8285 | /* set up input amps for analog loopback */ | |
8286 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
8287 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8288 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8289 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8290 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8291 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8292 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8293 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8294 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8295 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8296 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8297 | ||
8298 | /* FIXME: use matrix-type input source selection */ | |
8299 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
8300 | /* Input mixer1 */ | |
8301 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8302 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8303 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 8304 | /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */ |
9c7f852e TI |
8305 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
8306 | /* Input mixer2 */ | |
8307 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8308 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8309 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 8310 | /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */ |
e3cde64a | 8311 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
9c7f852e TI |
8312 | |
8313 | { } | |
8314 | }; | |
8315 | ||
e2757d5e KY |
8316 | static struct hda_verb alc888_asus_m90v_verbs[] = { |
8317 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
8318 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
8319 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8320 | /* enable unsolicited event */ | |
8321 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
8322 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, | |
8323 | { } /* end */ | |
8324 | }; | |
8325 | ||
8326 | static void alc883_nb_mic_automute(struct hda_codec *codec) | |
8327 | { | |
8328 | unsigned int present; | |
8329 | ||
8330 | present = snd_hda_codec_read(codec, 0x18, 0, | |
8331 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
8332 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
8333 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | |
8334 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
8335 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); | |
8336 | } | |
8337 | ||
8338 | static void alc883_M90V_speaker_automute(struct hda_codec *codec) | |
8339 | { | |
8340 | unsigned int present; | |
8341 | unsigned char bits; | |
8342 | ||
8343 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
8344 | AC_VERB_GET_PIN_SENSE, 0) | |
8345 | & AC_PINSENSE_PRESENCE; | |
8346 | bits = present ? 0 : PIN_OUT; | |
8347 | snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8348 | bits); | |
8349 | snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8350 | bits); | |
8351 | snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8352 | bits); | |
8353 | } | |
8354 | ||
8355 | static void alc883_mode2_unsol_event(struct hda_codec *codec, | |
8356 | unsigned int res) | |
8357 | { | |
8358 | switch (res >> 26) { | |
8359 | case ALC880_HP_EVENT: | |
8360 | alc883_M90V_speaker_automute(codec); | |
8361 | break; | |
8362 | case ALC880_MIC_EVENT: | |
8363 | alc883_nb_mic_automute(codec); | |
8364 | break; | |
8365 | } | |
8366 | } | |
8367 | ||
8368 | static void alc883_mode2_inithook(struct hda_codec *codec) | |
8369 | { | |
8370 | alc883_M90V_speaker_automute(codec); | |
8371 | alc883_nb_mic_automute(codec); | |
8372 | } | |
8373 | ||
8374 | static struct hda_verb alc888_asus_eee1601_verbs[] = { | |
8375 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
8376 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
8377 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
8378 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8379 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
8380 | {0x20, AC_VERB_SET_COEF_INDEX, 0x0b}, | |
8381 | {0x20, AC_VERB_SET_PROC_COEF, 0x0838}, | |
8382 | /* enable unsolicited event */ | |
8383 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
8384 | { } /* end */ | |
8385 | }; | |
8386 | ||
8387 | static void alc883_eee1601_speaker_automute(struct hda_codec *codec) | |
8388 | { | |
8389 | unsigned int present; | |
8390 | unsigned char bits; | |
8391 | ||
8392 | present = snd_hda_codec_read(codec, 0x14, 0, | |
8393 | AC_VERB_GET_PIN_SENSE, 0) | |
8394 | & AC_PINSENSE_PRESENCE; | |
8395 | bits = present ? 0 : PIN_OUT; | |
8396 | snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8397 | bits); | |
8398 | } | |
8399 | ||
8400 | static void alc883_eee1601_unsol_event(struct hda_codec *codec, | |
8401 | unsigned int res) | |
8402 | { | |
8403 | switch (res >> 26) { | |
8404 | case ALC880_HP_EVENT: | |
8405 | alc883_eee1601_speaker_automute(codec); | |
8406 | break; | |
8407 | } | |
8408 | } | |
8409 | ||
8410 | static void alc883_eee1601_inithook(struct hda_codec *codec) | |
8411 | { | |
8412 | alc883_eee1601_speaker_automute(codec); | |
8413 | } | |
8414 | ||
cb53c626 TI |
8415 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
8416 | #define alc883_loopbacks alc880_loopbacks | |
8417 | #endif | |
8418 | ||
9c7f852e TI |
8419 | /* pcm configuration: identiacal with ALC880 */ |
8420 | #define alc883_pcm_analog_playback alc880_pcm_analog_playback | |
8421 | #define alc883_pcm_analog_capture alc880_pcm_analog_capture | |
6330079f | 8422 | #define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture |
9c7f852e TI |
8423 | #define alc883_pcm_digital_playback alc880_pcm_digital_playback |
8424 | #define alc883_pcm_digital_capture alc880_pcm_digital_capture | |
8425 | ||
8426 | /* | |
8427 | * configuration and preset | |
8428 | */ | |
f5fcc13c TI |
8429 | static const char *alc883_models[ALC883_MODEL_LAST] = { |
8430 | [ALC883_3ST_2ch_DIG] = "3stack-dig", | |
8431 | [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig", | |
8432 | [ALC883_3ST_6ch] = "3stack-6ch", | |
8433 | [ALC883_6ST_DIG] = "6stack-dig", | |
8434 | [ALC883_TARGA_DIG] = "targa-dig", | |
8435 | [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig", | |
f5fcc13c | 8436 | [ALC883_ACER] = "acer", |
2880a867 | 8437 | [ALC883_ACER_ASPIRE] = "acer-aspire", |
5b2d1eca | 8438 | [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g", |
f5fcc13c | 8439 | [ALC883_MEDION] = "medion", |
272a527c | 8440 | [ALC883_MEDION_MD2] = "medion-md2", |
f5fcc13c | 8441 | [ALC883_LAPTOP_EAPD] = "laptop-eapd", |
bc9f98a9 | 8442 | [ALC883_LENOVO_101E_2ch] = "lenovo-101e", |
272a527c KY |
8443 | [ALC883_LENOVO_NB0763] = "lenovo-nb0763", |
8444 | [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig", | |
e2757d5e | 8445 | [ALC888_LENOVO_SKY] = "lenovo-sky", |
189609ae | 8446 | [ALC883_HAIER_W66] = "haier-w66", |
4723c022 | 8447 | [ALC888_3ST_HP] = "3stack-hp", |
5795b9e6 | 8448 | [ALC888_6ST_DELL] = "6stack-dell", |
a8848bd6 | 8449 | [ALC883_MITAC] = "mitac", |
0c4cc443 | 8450 | [ALC883_CLEVO_M720] = "clevo-m720", |
fb97dc67 | 8451 | [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515", |
ef8ef5fb | 8452 | [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530", |
17bba1b7 | 8453 | [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel", |
3ab90935 | 8454 | [ALC1200_ASUS_P5Q] = "asus-p5q", |
f5fcc13c TI |
8455 | [ALC883_AUTO] = "auto", |
8456 | }; | |
8457 | ||
8458 | static struct snd_pci_quirk alc883_cfg_tbl[] = { | |
8459 | SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG), | |
ac3e3741 | 8460 | SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE), |
69e50282 | 8461 | SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE), |
ac3e3741 TI |
8462 | SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE), |
8463 | SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE), | |
0b18cb18 | 8464 | SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE), |
5b2d1eca VP |
8465 | SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G", |
8466 | ALC888_ACER_ASPIRE_4930G), | |
a8e4f9dd LW |
8467 | SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G", |
8468 | ALC888_ACER_ASPIRE_4930G), | |
8469 | SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G", | |
8470 | ALC888_ACER_ASPIRE_4930G), | |
ac3e3741 | 8471 | SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */ |
5795b9e6 | 8472 | SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL), |
febe3375 | 8473 | SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG), |
ac3e3741 TI |
8474 | SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP), |
8475 | SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP), | |
5d85f8d0 | 8476 | SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG), |
06bf3e15 | 8477 | SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP), |
a01c30cb | 8478 | SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V), |
ac3e3741 | 8479 | SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG), |
3ab90935 | 8480 | SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q), |
e2757d5e | 8481 | SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601), |
97ec710c | 8482 | SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG), |
f5fcc13c | 8483 | SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG), |
2de686d2 | 8484 | SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC), |
ac3e3741 TI |
8485 | SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC), |
8486 | SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD), | |
e2757d5e | 8487 | SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL), |
ac3e3741 | 8488 | SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch), |
57b14f24 | 8489 | SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG), |
6f3bf657 | 8490 | SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG), |
bba8dee7 | 8491 | SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG), |
ac3e3741 | 8492 | SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG), |
4383fae0 | 8493 | SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG), |
dd146a60 | 8494 | SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG), |
82808236 | 8495 | SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG), |
f5fcc13c | 8496 | SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG), |
ac3e3741 | 8497 | SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG), |
f5fcc13c TI |
8498 | SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG), |
8499 | SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG), | |
ac3e3741 | 8500 | SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG), |
64ca1c29 | 8501 | SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG), |
f5fcc13c TI |
8502 | SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG), |
8503 | SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG), | |
8504 | SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG), | |
ac3e3741 TI |
8505 | SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG), |
8506 | SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG), | |
8507 | SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG), | |
ee09543c | 8508 | SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG), |
86d34b7e | 8509 | SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG), |
ac3e3741 TI |
8510 | SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG), |
8511 | SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG), | |
f5fcc13c | 8512 | SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG), |
ac3e3741 | 8513 | SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG), |
0c4cc443 HRK |
8514 | SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720), |
8515 | SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720), | |
ac3e3741 | 8516 | SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD), |
e60623b4 | 8517 | SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch), |
f5fcc13c | 8518 | SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), |
f67d8176 TI |
8519 | SND_PCI_QUIRK(0x1734, 0x1107, "FSC AMILO Xi2550", |
8520 | ALC883_FUJITSU_PI2515), | |
fb97dc67 | 8521 | SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515), |
ef8ef5fb VP |
8522 | SND_PCI_QUIRK(0x1734, 0x113d, "Fujitsu AMILO Xa3530", |
8523 | ALC888_FUJITSU_XA3530), | |
272a527c | 8524 | SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch), |
272a527c | 8525 | SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763), |
ac3e3741 TI |
8526 | SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763), |
8527 | SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763), | |
e2757d5e | 8528 | SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY), |
272a527c | 8529 | SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2), |
959973b9 | 8530 | SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG), |
0b167bf4 | 8531 | SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG), |
189609ae | 8532 | SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66), |
17bba1b7 J |
8533 | SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL), |
8534 | SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL), | |
2de686d2 | 8535 | SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC), |
4b558991 | 8536 | SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL), |
ac3e3741 | 8537 | SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), |
9c7f852e TI |
8538 | {} |
8539 | }; | |
8540 | ||
8541 | static struct alc_config_preset alc883_presets[] = { | |
8542 | [ALC883_3ST_2ch_DIG] = { | |
8543 | .mixers = { alc883_3ST_2ch_mixer }, | |
8544 | .init_verbs = { alc883_init_verbs }, | |
8545 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8546 | .dac_nids = alc883_dac_nids, | |
8547 | .dig_out_nid = ALC883_DIGOUT_NID, | |
9c7f852e TI |
8548 | .dig_in_nid = ALC883_DIGIN_NID, |
8549 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
8550 | .channel_mode = alc883_3ST_2ch_modes, | |
8551 | .input_mux = &alc883_capture_source, | |
8552 | }, | |
8553 | [ALC883_3ST_6ch_DIG] = { | |
8554 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
8555 | .init_verbs = { alc883_init_verbs }, | |
8556 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8557 | .dac_nids = alc883_dac_nids, | |
8558 | .dig_out_nid = ALC883_DIGOUT_NID, | |
9c7f852e TI |
8559 | .dig_in_nid = ALC883_DIGIN_NID, |
8560 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
8561 | .channel_mode = alc883_3ST_6ch_modes, | |
4e195a7b | 8562 | .need_dac_fix = 1, |
9c7f852e | 8563 | .input_mux = &alc883_capture_source, |
f12ab1e0 | 8564 | }, |
9c7f852e TI |
8565 | [ALC883_3ST_6ch] = { |
8566 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
8567 | .init_verbs = { alc883_init_verbs }, | |
8568 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8569 | .dac_nids = alc883_dac_nids, | |
9c7f852e TI |
8570 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), |
8571 | .channel_mode = alc883_3ST_6ch_modes, | |
4e195a7b | 8572 | .need_dac_fix = 1, |
9c7f852e | 8573 | .input_mux = &alc883_capture_source, |
f12ab1e0 | 8574 | }, |
17bba1b7 J |
8575 | [ALC883_3ST_6ch_INTEL] = { |
8576 | .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer }, | |
8577 | .init_verbs = { alc883_init_verbs }, | |
8578 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8579 | .dac_nids = alc883_dac_nids, | |
8580 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8581 | .dig_in_nid = ALC883_DIGIN_NID, | |
8582 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes), | |
8583 | .channel_mode = alc883_3ST_6ch_intel_modes, | |
8584 | .need_dac_fix = 1, | |
8585 | .input_mux = &alc883_3stack_6ch_intel, | |
8586 | }, | |
9c7f852e TI |
8587 | [ALC883_6ST_DIG] = { |
8588 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, | |
8589 | .init_verbs = { alc883_init_verbs }, | |
8590 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8591 | .dac_nids = alc883_dac_nids, | |
8592 | .dig_out_nid = ALC883_DIGOUT_NID, | |
9c7f852e TI |
8593 | .dig_in_nid = ALC883_DIGIN_NID, |
8594 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | |
8595 | .channel_mode = alc883_sixstack_modes, | |
8596 | .input_mux = &alc883_capture_source, | |
8597 | }, | |
ccc656ce KY |
8598 | [ALC883_TARGA_DIG] = { |
8599 | .mixers = { alc883_tagra_mixer, alc883_chmode_mixer }, | |
8600 | .init_verbs = { alc883_init_verbs, alc883_tagra_verbs}, | |
8601 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8602 | .dac_nids = alc883_dac_nids, | |
8603 | .dig_out_nid = ALC883_DIGOUT_NID, | |
ccc656ce KY |
8604 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), |
8605 | .channel_mode = alc883_3ST_6ch_modes, | |
8606 | .need_dac_fix = 1, | |
8607 | .input_mux = &alc883_capture_source, | |
8608 | .unsol_event = alc883_tagra_unsol_event, | |
8609 | .init_hook = alc883_tagra_automute, | |
8610 | }, | |
8611 | [ALC883_TARGA_2ch_DIG] = { | |
8612 | .mixers = { alc883_tagra_2ch_mixer}, | |
8613 | .init_verbs = { alc883_init_verbs, alc883_tagra_verbs}, | |
8614 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8615 | .dac_nids = alc883_dac_nids, | |
f9e336f6 TI |
8616 | .adc_nids = alc883_adc_nids_alt, |
8617 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt), | |
ccc656ce | 8618 | .dig_out_nid = ALC883_DIGOUT_NID, |
ccc656ce KY |
8619 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8620 | .channel_mode = alc883_3ST_2ch_modes, | |
8621 | .input_mux = &alc883_capture_source, | |
8622 | .unsol_event = alc883_tagra_unsol_event, | |
8623 | .init_hook = alc883_tagra_automute, | |
8624 | }, | |
bab282b9 | 8625 | [ALC883_ACER] = { |
676a9b53 | 8626 | .mixers = { alc883_base_mixer }, |
bab282b9 VA |
8627 | /* On TravelMate laptops, GPIO 0 enables the internal speaker |
8628 | * and the headphone jack. Turn this on and rely on the | |
8629 | * standard mute methods whenever the user wants to turn | |
8630 | * these outputs off. | |
8631 | */ | |
8632 | .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs }, | |
8633 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8634 | .dac_nids = alc883_dac_nids, | |
bab282b9 VA |
8635 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8636 | .channel_mode = alc883_3ST_2ch_modes, | |
8637 | .input_mux = &alc883_capture_source, | |
8638 | }, | |
2880a867 | 8639 | [ALC883_ACER_ASPIRE] = { |
676a9b53 | 8640 | .mixers = { alc883_acer_aspire_mixer }, |
d1a991a6 | 8641 | .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs }, |
2880a867 TD |
8642 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
8643 | .dac_nids = alc883_dac_nids, | |
8644 | .dig_out_nid = ALC883_DIGOUT_NID, | |
2880a867 TD |
8645 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8646 | .channel_mode = alc883_3ST_2ch_modes, | |
8647 | .input_mux = &alc883_capture_source, | |
676a9b53 TI |
8648 | .unsol_event = alc883_acer_aspire_unsol_event, |
8649 | .init_hook = alc883_acer_aspire_automute, | |
d1a991a6 | 8650 | }, |
5b2d1eca | 8651 | [ALC888_ACER_ASPIRE_4930G] = { |
ef8ef5fb | 8652 | .mixers = { alc888_base_mixer, |
5b2d1eca VP |
8653 | alc883_chmode_mixer }, |
8654 | .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs, | |
8655 | alc888_acer_aspire_4930g_verbs }, | |
8656 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8657 | .dac_nids = alc883_dac_nids, | |
8658 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev), | |
8659 | .adc_nids = alc883_adc_nids_rev, | |
8660 | .capsrc_nids = alc883_capsrc_nids_rev, | |
8661 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8662 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
8663 | .channel_mode = alc883_3ST_6ch_modes, | |
8664 | .need_dac_fix = 1, | |
8665 | .num_mux_defs = | |
ef8ef5fb VP |
8666 | ARRAY_SIZE(alc888_2_capture_sources), |
8667 | .input_mux = alc888_2_capture_sources, | |
5b2d1eca VP |
8668 | .unsol_event = alc888_acer_aspire_4930g_unsol_event, |
8669 | .init_hook = alc888_acer_aspire_4930g_automute, | |
8670 | }, | |
c07584c8 TD |
8671 | [ALC883_MEDION] = { |
8672 | .mixers = { alc883_fivestack_mixer, | |
8673 | alc883_chmode_mixer }, | |
8674 | .init_verbs = { alc883_init_verbs, | |
b373bdeb | 8675 | alc883_medion_eapd_verbs }, |
c07584c8 TD |
8676 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
8677 | .dac_nids = alc883_dac_nids, | |
f9e336f6 TI |
8678 | .adc_nids = alc883_adc_nids_alt, |
8679 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt), | |
c07584c8 TD |
8680 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), |
8681 | .channel_mode = alc883_sixstack_modes, | |
8682 | .input_mux = &alc883_capture_source, | |
b373bdeb | 8683 | }, |
272a527c KY |
8684 | [ALC883_MEDION_MD2] = { |
8685 | .mixers = { alc883_medion_md2_mixer}, | |
8686 | .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs}, | |
8687 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8688 | .dac_nids = alc883_dac_nids, | |
8689 | .dig_out_nid = ALC883_DIGOUT_NID, | |
272a527c KY |
8690 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8691 | .channel_mode = alc883_3ST_2ch_modes, | |
8692 | .input_mux = &alc883_capture_source, | |
8693 | .unsol_event = alc883_medion_md2_unsol_event, | |
8694 | .init_hook = alc883_medion_md2_automute, | |
ea1fb29a | 8695 | }, |
b373bdeb | 8696 | [ALC883_LAPTOP_EAPD] = { |
676a9b53 | 8697 | .mixers = { alc883_base_mixer }, |
b373bdeb AN |
8698 | .init_verbs = { alc883_init_verbs, alc882_eapd_verbs }, |
8699 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8700 | .dac_nids = alc883_dac_nids, | |
b373bdeb AN |
8701 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8702 | .channel_mode = alc883_3ST_2ch_modes, | |
8703 | .input_mux = &alc883_capture_source, | |
8704 | }, | |
0c4cc443 HRK |
8705 | [ALC883_CLEVO_M720] = { |
8706 | .mixers = { alc883_clevo_m720_mixer }, | |
8707 | .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs }, | |
368c7a95 J |
8708 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
8709 | .dac_nids = alc883_dac_nids, | |
8710 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8711 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
8712 | .channel_mode = alc883_3ST_2ch_modes, | |
8713 | .input_mux = &alc883_capture_source, | |
0c4cc443 HRK |
8714 | .unsol_event = alc883_clevo_m720_unsol_event, |
8715 | .init_hook = alc883_clevo_m720_automute, | |
368c7a95 | 8716 | }, |
bc9f98a9 KY |
8717 | [ALC883_LENOVO_101E_2ch] = { |
8718 | .mixers = { alc883_lenovo_101e_2ch_mixer}, | |
8719 | .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs}, | |
8720 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8721 | .dac_nids = alc883_dac_nids, | |
f9e336f6 TI |
8722 | .adc_nids = alc883_adc_nids_alt, |
8723 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt), | |
bc9f98a9 KY |
8724 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8725 | .channel_mode = alc883_3ST_2ch_modes, | |
8726 | .input_mux = &alc883_lenovo_101e_capture_source, | |
8727 | .unsol_event = alc883_lenovo_101e_unsol_event, | |
8728 | .init_hook = alc883_lenovo_101e_all_automute, | |
8729 | }, | |
272a527c KY |
8730 | [ALC883_LENOVO_NB0763] = { |
8731 | .mixers = { alc883_lenovo_nb0763_mixer }, | |
8732 | .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs}, | |
8733 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8734 | .dac_nids = alc883_dac_nids, | |
272a527c KY |
8735 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8736 | .channel_mode = alc883_3ST_2ch_modes, | |
8737 | .need_dac_fix = 1, | |
8738 | .input_mux = &alc883_lenovo_nb0763_capture_source, | |
8739 | .unsol_event = alc883_medion_md2_unsol_event, | |
8740 | .init_hook = alc883_medion_md2_automute, | |
8741 | }, | |
8742 | [ALC888_LENOVO_MS7195_DIG] = { | |
8743 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
8744 | .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs}, | |
8745 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8746 | .dac_nids = alc883_dac_nids, | |
8747 | .dig_out_nid = ALC883_DIGOUT_NID, | |
272a527c KY |
8748 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), |
8749 | .channel_mode = alc883_3ST_6ch_modes, | |
8750 | .need_dac_fix = 1, | |
8751 | .input_mux = &alc883_capture_source, | |
8752 | .unsol_event = alc883_lenovo_ms7195_unsol_event, | |
8753 | .init_hook = alc888_lenovo_ms7195_front_automute, | |
189609ae KY |
8754 | }, |
8755 | [ALC883_HAIER_W66] = { | |
8756 | .mixers = { alc883_tagra_2ch_mixer}, | |
8757 | .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs}, | |
8758 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8759 | .dac_nids = alc883_dac_nids, | |
8760 | .dig_out_nid = ALC883_DIGOUT_NID, | |
189609ae KY |
8761 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8762 | .channel_mode = alc883_3ST_2ch_modes, | |
8763 | .input_mux = &alc883_capture_source, | |
8764 | .unsol_event = alc883_haier_w66_unsol_event, | |
8765 | .init_hook = alc883_haier_w66_automute, | |
eea6419e | 8766 | }, |
4723c022 | 8767 | [ALC888_3ST_HP] = { |
eea6419e | 8768 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, |
4723c022 | 8769 | .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs }, |
8341de60 CM |
8770 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
8771 | .dac_nids = alc883_dac_nids, | |
4723c022 CM |
8772 | .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes), |
8773 | .channel_mode = alc888_3st_hp_modes, | |
8341de60 CM |
8774 | .need_dac_fix = 1, |
8775 | .input_mux = &alc883_capture_source, | |
8776 | }, | |
5795b9e6 | 8777 | [ALC888_6ST_DELL] = { |
f24dbdc6 | 8778 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, |
5795b9e6 CM |
8779 | .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs }, |
8780 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8781 | .dac_nids = alc883_dac_nids, | |
8782 | .dig_out_nid = ALC883_DIGOUT_NID, | |
5795b9e6 CM |
8783 | .dig_in_nid = ALC883_DIGIN_NID, |
8784 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | |
8785 | .channel_mode = alc883_sixstack_modes, | |
8786 | .input_mux = &alc883_capture_source, | |
8787 | .unsol_event = alc888_6st_dell_unsol_event, | |
8788 | .init_hook = alc888_6st_dell_front_automute, | |
8789 | }, | |
a8848bd6 AS |
8790 | [ALC883_MITAC] = { |
8791 | .mixers = { alc883_mitac_mixer }, | |
8792 | .init_verbs = { alc883_init_verbs, alc883_mitac_verbs }, | |
8793 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8794 | .dac_nids = alc883_dac_nids, | |
a8848bd6 AS |
8795 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8796 | .channel_mode = alc883_3ST_2ch_modes, | |
8797 | .input_mux = &alc883_capture_source, | |
8798 | .unsol_event = alc883_mitac_unsol_event, | |
8799 | .init_hook = alc883_mitac_automute, | |
8800 | }, | |
fb97dc67 J |
8801 | [ALC883_FUJITSU_PI2515] = { |
8802 | .mixers = { alc883_2ch_fujitsu_pi2515_mixer }, | |
8803 | .init_verbs = { alc883_init_verbs, | |
8804 | alc883_2ch_fujitsu_pi2515_verbs}, | |
8805 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8806 | .dac_nids = alc883_dac_nids, | |
8807 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8808 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
8809 | .channel_mode = alc883_3ST_2ch_modes, | |
8810 | .input_mux = &alc883_fujitsu_pi2515_capture_source, | |
8811 | .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event, | |
8812 | .init_hook = alc883_2ch_fujitsu_pi2515_automute, | |
8813 | }, | |
ef8ef5fb VP |
8814 | [ALC888_FUJITSU_XA3530] = { |
8815 | .mixers = { alc888_base_mixer, alc883_chmode_mixer }, | |
8816 | .init_verbs = { alc883_init_verbs, | |
8817 | alc888_fujitsu_xa3530_verbs }, | |
8818 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8819 | .dac_nids = alc883_dac_nids, | |
8820 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev), | |
8821 | .adc_nids = alc883_adc_nids_rev, | |
8822 | .capsrc_nids = alc883_capsrc_nids_rev, | |
8823 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8824 | .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes), | |
8825 | .channel_mode = alc888_4ST_8ch_intel_modes, | |
8826 | .num_mux_defs = | |
8827 | ARRAY_SIZE(alc888_2_capture_sources), | |
8828 | .input_mux = alc888_2_capture_sources, | |
8829 | .unsol_event = alc888_fujitsu_xa3530_unsol_event, | |
8830 | .init_hook = alc888_fujitsu_xa3530_automute, | |
8831 | }, | |
e2757d5e KY |
8832 | [ALC888_LENOVO_SKY] = { |
8833 | .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer }, | |
8834 | .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs}, | |
8835 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8836 | .dac_nids = alc883_dac_nids, | |
8837 | .dig_out_nid = ALC883_DIGOUT_NID, | |
e2757d5e KY |
8838 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), |
8839 | .channel_mode = alc883_sixstack_modes, | |
8840 | .need_dac_fix = 1, | |
8841 | .input_mux = &alc883_lenovo_sky_capture_source, | |
8842 | .unsol_event = alc883_lenovo_sky_unsol_event, | |
8843 | .init_hook = alc888_lenovo_sky_front_automute, | |
8844 | }, | |
8845 | [ALC888_ASUS_M90V] = { | |
8846 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
8847 | .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs }, | |
8848 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8849 | .dac_nids = alc883_dac_nids, | |
8850 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8851 | .dig_in_nid = ALC883_DIGIN_NID, | |
8852 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
8853 | .channel_mode = alc883_3ST_6ch_modes, | |
8854 | .need_dac_fix = 1, | |
8855 | .input_mux = &alc883_fujitsu_pi2515_capture_source, | |
8856 | .unsol_event = alc883_mode2_unsol_event, | |
8857 | .init_hook = alc883_mode2_inithook, | |
8858 | }, | |
8859 | [ALC888_ASUS_EEE1601] = { | |
8860 | .mixers = { alc883_asus_eee1601_mixer }, | |
f9e336f6 | 8861 | .cap_mixer = alc883_asus_eee1601_cap_mixer, |
e2757d5e KY |
8862 | .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs }, |
8863 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8864 | .dac_nids = alc883_dac_nids, | |
8865 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8866 | .dig_in_nid = ALC883_DIGIN_NID, | |
8867 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
8868 | .channel_mode = alc883_3ST_2ch_modes, | |
8869 | .need_dac_fix = 1, | |
8870 | .input_mux = &alc883_asus_eee1601_capture_source, | |
8871 | .unsol_event = alc883_eee1601_unsol_event, | |
8872 | .init_hook = alc883_eee1601_inithook, | |
8873 | }, | |
3ab90935 WF |
8874 | [ALC1200_ASUS_P5Q] = { |
8875 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, | |
8876 | .init_verbs = { alc883_init_verbs }, | |
8877 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8878 | .dac_nids = alc883_dac_nids, | |
8879 | .dig_out_nid = ALC1200_DIGOUT_NID, | |
8880 | .dig_in_nid = ALC883_DIGIN_NID, | |
8881 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | |
8882 | .channel_mode = alc883_sixstack_modes, | |
8883 | .input_mux = &alc883_capture_source, | |
8884 | }, | |
9c7f852e TI |
8885 | }; |
8886 | ||
8887 | ||
8888 | /* | |
8889 | * BIOS auto configuration | |
8890 | */ | |
8891 | static void alc883_auto_set_output_and_unmute(struct hda_codec *codec, | |
8892 | hda_nid_t nid, int pin_type, | |
8893 | int dac_idx) | |
8894 | { | |
8895 | /* set as output */ | |
8896 | struct alc_spec *spec = codec->spec; | |
f12ab1e0 TI |
8897 | int idx; |
8898 | ||
f6c7e546 | 8899 | alc_set_pin_output(codec, nid, pin_type); |
9c7f852e TI |
8900 | if (spec->multiout.dac_nids[dac_idx] == 0x25) |
8901 | idx = 4; | |
8902 | else | |
8903 | idx = spec->multiout.dac_nids[dac_idx] - 2; | |
9c7f852e TI |
8904 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); |
8905 | ||
8906 | } | |
8907 | ||
8908 | static void alc883_auto_init_multi_out(struct hda_codec *codec) | |
8909 | { | |
8910 | struct alc_spec *spec = codec->spec; | |
8911 | int i; | |
8912 | ||
bc9f98a9 | 8913 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
9c7f852e | 8914 | for (i = 0; i <= HDA_SIDE; i++) { |
f12ab1e0 | 8915 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
baba8ee9 | 8916 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
9c7f852e | 8917 | if (nid) |
baba8ee9 | 8918 | alc883_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 8919 | i); |
9c7f852e TI |
8920 | } |
8921 | } | |
8922 | ||
8923 | static void alc883_auto_init_hp_out(struct hda_codec *codec) | |
8924 | { | |
8925 | struct alc_spec *spec = codec->spec; | |
8926 | hda_nid_t pin; | |
8927 | ||
eb06ed8f | 8928 | pin = spec->autocfg.hp_pins[0]; |
9c7f852e TI |
8929 | if (pin) /* connect to front */ |
8930 | /* use dac 0 */ | |
8931 | alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
f6c7e546 TI |
8932 | pin = spec->autocfg.speaker_pins[0]; |
8933 | if (pin) | |
8934 | alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
9c7f852e TI |
8935 | } |
8936 | ||
8937 | #define alc883_is_input_pin(nid) alc880_is_input_pin(nid) | |
8938 | #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID | |
8939 | ||
8940 | static void alc883_auto_init_analog_input(struct hda_codec *codec) | |
8941 | { | |
8942 | struct alc_spec *spec = codec->spec; | |
8943 | int i; | |
8944 | ||
8945 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
8946 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
8947 | if (alc883_is_input_pin(nid)) { | |
8948 | snd_hda_codec_write(codec, nid, 0, | |
8949 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8950 | (i <= AUTO_PIN_FRONT_MIC ? | |
8951 | PIN_VREF80 : PIN_IN)); | |
8952 | if (nid != ALC883_PIN_CD_NID) | |
8953 | snd_hda_codec_write(codec, nid, 0, | |
8954 | AC_VERB_SET_AMP_GAIN_MUTE, | |
8955 | AMP_OUT_MUTE); | |
8956 | } | |
8957 | } | |
8958 | } | |
8959 | ||
f511b01c TI |
8960 | #define alc883_auto_init_input_src alc882_auto_init_input_src |
8961 | ||
9c7f852e TI |
8962 | /* almost identical with ALC880 parser... */ |
8963 | static int alc883_parse_auto_config(struct hda_codec *codec) | |
8964 | { | |
8965 | struct alc_spec *spec = codec->spec; | |
8966 | int err = alc880_parse_auto_config(codec); | |
8967 | ||
8968 | if (err < 0) | |
8969 | return err; | |
776e184e TI |
8970 | else if (!err) |
8971 | return 0; /* no config found */ | |
8972 | ||
8973 | err = alc_auto_add_mic_boost(codec); | |
8974 | if (err < 0) | |
8975 | return err; | |
8976 | ||
8977 | /* hack - override the init verbs */ | |
8978 | spec->init_verbs[0] = alc883_auto_init_verbs; | |
776e184e TI |
8979 | |
8980 | return 1; /* config found */ | |
9c7f852e TI |
8981 | } |
8982 | ||
8983 | /* additional initialization for auto-configuration model */ | |
8984 | static void alc883_auto_init(struct hda_codec *codec) | |
8985 | { | |
f6c7e546 | 8986 | struct alc_spec *spec = codec->spec; |
9c7f852e TI |
8987 | alc883_auto_init_multi_out(codec); |
8988 | alc883_auto_init_hp_out(codec); | |
8989 | alc883_auto_init_analog_input(codec); | |
f511b01c | 8990 | alc883_auto_init_input_src(codec); |
f6c7e546 | 8991 | if (spec->unsol_event) |
7fb0d78f | 8992 | alc_inithook(codec); |
9c7f852e TI |
8993 | } |
8994 | ||
8995 | static int patch_alc883(struct hda_codec *codec) | |
8996 | { | |
8997 | struct alc_spec *spec; | |
8998 | int err, board_config; | |
8999 | ||
9000 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
9001 | if (spec == NULL) | |
9002 | return -ENOMEM; | |
9003 | ||
9004 | codec->spec = spec; | |
9005 | ||
2c3bf9ab TI |
9006 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
9007 | ||
f5fcc13c TI |
9008 | board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST, |
9009 | alc883_models, | |
9010 | alc883_cfg_tbl); | |
9011 | if (board_config < 0) { | |
9c7f852e TI |
9012 | printk(KERN_INFO "hda_codec: Unknown model for ALC883, " |
9013 | "trying auto-probe from BIOS...\n"); | |
9014 | board_config = ALC883_AUTO; | |
9015 | } | |
9016 | ||
9017 | if (board_config == ALC883_AUTO) { | |
9018 | /* automatic parse from the BIOS config */ | |
9019 | err = alc883_parse_auto_config(codec); | |
9020 | if (err < 0) { | |
9021 | alc_free(codec); | |
9022 | return err; | |
f12ab1e0 | 9023 | } else if (!err) { |
9c7f852e TI |
9024 | printk(KERN_INFO |
9025 | "hda_codec: Cannot set up configuration " | |
9026 | "from BIOS. Using base mode...\n"); | |
9027 | board_config = ALC883_3ST_2ch_DIG; | |
9028 | } | |
9029 | } | |
9030 | ||
9031 | if (board_config != ALC883_AUTO) | |
9032 | setup_preset(spec, &alc883_presets[board_config]); | |
9033 | ||
2f893286 KY |
9034 | switch (codec->vendor_id) { |
9035 | case 0x10ec0888: | |
4442608d KY |
9036 | if (codec->revision_id == 0x100101) { |
9037 | spec->stream_name_analog = "ALC1200 Analog"; | |
9038 | spec->stream_name_digital = "ALC1200 Digital"; | |
9039 | } else { | |
9040 | spec->stream_name_analog = "ALC888 Analog"; | |
9041 | spec->stream_name_digital = "ALC888 Digital"; | |
9042 | } | |
2f893286 KY |
9043 | break; |
9044 | case 0x10ec0889: | |
9045 | spec->stream_name_analog = "ALC889 Analog"; | |
9046 | spec->stream_name_digital = "ALC889 Digital"; | |
9047 | break; | |
9048 | default: | |
9049 | spec->stream_name_analog = "ALC883 Analog"; | |
9050 | spec->stream_name_digital = "ALC883 Digital"; | |
9051 | break; | |
9052 | } | |
9053 | ||
9c7f852e TI |
9054 | spec->stream_analog_playback = &alc883_pcm_analog_playback; |
9055 | spec->stream_analog_capture = &alc883_pcm_analog_capture; | |
6330079f | 9056 | spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture; |
9c7f852e | 9057 | |
9c7f852e TI |
9058 | spec->stream_digital_playback = &alc883_pcm_digital_playback; |
9059 | spec->stream_digital_capture = &alc883_pcm_digital_capture; | |
9060 | ||
f9e336f6 TI |
9061 | if (!spec->num_adc_nids) { |
9062 | spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); | |
9063 | spec->adc_nids = alc883_adc_nids; | |
9064 | } | |
9065 | if (!spec->capsrc_nids) | |
9066 | spec->capsrc_nids = alc883_capsrc_nids; | |
54cbc9ab | 9067 | spec->is_mix_capture = 1; /* matrix-style capture */ |
f9e336f6 TI |
9068 | if (!spec->cap_mixer) |
9069 | set_capture_mixer(spec); | |
9c7f852e | 9070 | |
2134ea4f TI |
9071 | spec->vmaster_nid = 0x0c; |
9072 | ||
9c7f852e TI |
9073 | codec->patch_ops = alc_patch_ops; |
9074 | if (board_config == ALC883_AUTO) | |
9075 | spec->init_hook = alc883_auto_init; | |
f9423e7a | 9076 | |
cb53c626 TI |
9077 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
9078 | if (!spec->loopback.amplist) | |
9079 | spec->loopback.amplist = alc883_loopbacks; | |
9080 | #endif | |
daead538 | 9081 | codec->proc_widget_hook = print_realtek_coef; |
9c7f852e TI |
9082 | |
9083 | return 0; | |
9084 | } | |
9085 | ||
9086 | /* | |
9087 | * ALC262 support | |
9088 | */ | |
9089 | ||
9090 | #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID | |
9091 | #define ALC262_DIGIN_NID ALC880_DIGIN_NID | |
9092 | ||
9093 | #define alc262_dac_nids alc260_dac_nids | |
9094 | #define alc262_adc_nids alc882_adc_nids | |
9095 | #define alc262_adc_nids_alt alc882_adc_nids_alt | |
88c71a99 TI |
9096 | #define alc262_capsrc_nids alc882_capsrc_nids |
9097 | #define alc262_capsrc_nids_alt alc882_capsrc_nids_alt | |
9c7f852e TI |
9098 | |
9099 | #define alc262_modes alc260_modes | |
9100 | #define alc262_capture_source alc882_capture_source | |
9101 | ||
4e555fe5 KY |
9102 | static hda_nid_t alc262_dmic_adc_nids[1] = { |
9103 | /* ADC0 */ | |
9104 | 0x09 | |
9105 | }; | |
9106 | ||
9107 | static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 }; | |
9108 | ||
9c7f852e TI |
9109 | static struct snd_kcontrol_new alc262_base_mixer[] = { |
9110 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
9111 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
9112 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
9113 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
9114 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
9115 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
9116 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9117 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 9118 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
9119 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
9120 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 9121 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e | 9122 | /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), |
31bffaa9 | 9123 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */ |
9c7f852e TI |
9124 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT), |
9125 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
9126 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
9127 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | |
9128 | { } /* end */ | |
9129 | }; | |
9130 | ||
ccc656ce KY |
9131 | static struct snd_kcontrol_new alc262_hippo1_mixer[] = { |
9132 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
9133 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
9134 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
9135 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
9136 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
9137 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
9138 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9139 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 9140 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce KY |
9141 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
9142 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 9143 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
ccc656ce | 9144 | /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), |
31bffaa9 | 9145 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */ |
ccc656ce KY |
9146 | /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/ |
9147 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
9148 | { } /* end */ | |
9149 | }; | |
9150 | ||
ce875f07 TI |
9151 | /* update HP, line and mono-out pins according to the master switch */ |
9152 | static void alc262_hp_master_update(struct hda_codec *codec) | |
9153 | { | |
9154 | struct alc_spec *spec = codec->spec; | |
9155 | int val = spec->master_sw; | |
9156 | ||
9157 | /* HP & line-out */ | |
9158 | snd_hda_codec_write_cache(codec, 0x1b, 0, | |
9159 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
9160 | val ? PIN_HP : 0); | |
9161 | snd_hda_codec_write_cache(codec, 0x15, 0, | |
9162 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
9163 | val ? PIN_HP : 0); | |
9164 | /* mono (speaker) depending on the HP jack sense */ | |
9165 | val = val && !spec->jack_present; | |
9166 | snd_hda_codec_write_cache(codec, 0x16, 0, | |
9167 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
9168 | val ? PIN_OUT : 0); | |
9169 | } | |
9170 | ||
9171 | static void alc262_hp_bpc_automute(struct hda_codec *codec) | |
9172 | { | |
9173 | struct alc_spec *spec = codec->spec; | |
9174 | unsigned int presence; | |
9175 | presence = snd_hda_codec_read(codec, 0x1b, 0, | |
9176 | AC_VERB_GET_PIN_SENSE, 0); | |
9177 | spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE); | |
9178 | alc262_hp_master_update(codec); | |
9179 | } | |
9180 | ||
9181 | static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res) | |
9182 | { | |
9183 | if ((res >> 26) != ALC880_HP_EVENT) | |
9184 | return; | |
9185 | alc262_hp_bpc_automute(codec); | |
9186 | } | |
9187 | ||
9188 | static void alc262_hp_wildwest_automute(struct hda_codec *codec) | |
9189 | { | |
9190 | struct alc_spec *spec = codec->spec; | |
9191 | unsigned int presence; | |
9192 | presence = snd_hda_codec_read(codec, 0x15, 0, | |
9193 | AC_VERB_GET_PIN_SENSE, 0); | |
9194 | spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE); | |
9195 | alc262_hp_master_update(codec); | |
9196 | } | |
9197 | ||
9198 | static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec, | |
9199 | unsigned int res) | |
9200 | { | |
9201 | if ((res >> 26) != ALC880_HP_EVENT) | |
9202 | return; | |
9203 | alc262_hp_wildwest_automute(codec); | |
9204 | } | |
9205 | ||
9206 | static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol, | |
9207 | struct snd_ctl_elem_value *ucontrol) | |
9208 | { | |
9209 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
9210 | struct alc_spec *spec = codec->spec; | |
9211 | *ucontrol->value.integer.value = spec->master_sw; | |
9212 | return 0; | |
9213 | } | |
9214 | ||
9215 | static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |
9216 | struct snd_ctl_elem_value *ucontrol) | |
9217 | { | |
9218 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
9219 | struct alc_spec *spec = codec->spec; | |
9220 | int val = !!*ucontrol->value.integer.value; | |
9221 | ||
9222 | if (val == spec->master_sw) | |
9223 | return 0; | |
9224 | spec->master_sw = val; | |
9225 | alc262_hp_master_update(codec); | |
9226 | return 1; | |
9227 | } | |
9228 | ||
9c7f852e | 9229 | static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = { |
ce875f07 TI |
9230 | { |
9231 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9232 | .name = "Master Playback Switch", | |
9233 | .info = snd_ctl_boolean_mono_info, | |
9234 | .get = alc262_hp_master_sw_get, | |
9235 | .put = alc262_hp_master_sw_put, | |
9236 | }, | |
9c7f852e TI |
9237 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9238 | HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
9239 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
ce875f07 TI |
9240 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0, |
9241 | HDA_OUTPUT), | |
9242 | HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0, | |
9243 | HDA_OUTPUT), | |
9c7f852e TI |
9244 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
9245 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 9246 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
9247 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
9248 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 9249 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
9250 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
9251 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
9252 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
9253 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
9254 | HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
9255 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
9256 | HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT), | |
9257 | HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT), | |
9258 | { } /* end */ | |
9259 | }; | |
9260 | ||
cd7509a4 | 9261 | static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = { |
ce875f07 TI |
9262 | { |
9263 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9264 | .name = "Master Playback Switch", | |
9265 | .info = snd_ctl_boolean_mono_info, | |
9266 | .get = alc262_hp_master_sw_get, | |
9267 | .put = alc262_hp_master_sw_put, | |
9268 | }, | |
cd7509a4 KY |
9269 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9270 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
9271 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
9272 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
ce875f07 TI |
9273 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0, |
9274 | HDA_OUTPUT), | |
9275 | HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0, | |
9276 | HDA_OUTPUT), | |
cd7509a4 KY |
9277 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT), |
9278 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
cc69d12d | 9279 | HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT), |
cd7509a4 KY |
9280 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), |
9281 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
9282 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
9283 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
9284 | HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
9285 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
9286 | { } /* end */ | |
9287 | }; | |
9288 | ||
9289 | static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = { | |
9290 | HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9291 | HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 9292 | HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT), |
cd7509a4 KY |
9293 | { } /* end */ |
9294 | }; | |
9295 | ||
66d2a9d6 KY |
9296 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
9297 | static void alc262_hp_t5735_automute(struct hda_codec *codec, int force) | |
9298 | { | |
9299 | struct alc_spec *spec = codec->spec; | |
66d2a9d6 KY |
9300 | |
9301 | if (force || !spec->sense_updated) { | |
9302 | unsigned int present; | |
9303 | present = snd_hda_codec_read(codec, 0x15, 0, | |
9304 | AC_VERB_GET_PIN_SENSE, 0); | |
4bb26130 | 9305 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; |
66d2a9d6 KY |
9306 | spec->sense_updated = 1; |
9307 | } | |
4bb26130 TI |
9308 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE, |
9309 | spec->jack_present ? HDA_AMP_MUTE : 0); | |
66d2a9d6 KY |
9310 | } |
9311 | ||
9312 | static void alc262_hp_t5735_unsol_event(struct hda_codec *codec, | |
9313 | unsigned int res) | |
9314 | { | |
9315 | if ((res >> 26) != ALC880_HP_EVENT) | |
9316 | return; | |
9317 | alc262_hp_t5735_automute(codec, 1); | |
9318 | } | |
9319 | ||
9320 | static void alc262_hp_t5735_init_hook(struct hda_codec *codec) | |
9321 | { | |
9322 | alc262_hp_t5735_automute(codec, 1); | |
9323 | } | |
9324 | ||
9325 | static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = { | |
86cd9298 TI |
9326 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9327 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
66d2a9d6 KY |
9328 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
9329 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
9330 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9331 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9332 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
9333 | { } /* end */ | |
9334 | }; | |
9335 | ||
9336 | static struct hda_verb alc262_hp_t5735_verbs[] = { | |
9337 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9338 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
9339 | ||
9340 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
9341 | { } | |
9342 | }; | |
9343 | ||
8c427226 | 9344 | static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = { |
f2f48e18 TI |
9345 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9346 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
86cd9298 TI |
9347 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT), |
9348 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT), | |
8c427226 KY |
9349 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), |
9350 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
9351 | { } /* end */ | |
9352 | }; | |
9353 | ||
9354 | static struct hda_verb alc262_hp_rp5700_verbs[] = { | |
9355 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9356 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9357 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9358 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9359 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
9360 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9361 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
9362 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
9363 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))}, | |
9364 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))}, | |
9365 | {} | |
9366 | }; | |
9367 | ||
9368 | static struct hda_input_mux alc262_hp_rp5700_capture_source = { | |
9369 | .num_items = 1, | |
9370 | .items = { | |
9371 | { "Line", 0x1 }, | |
9372 | }, | |
9373 | }; | |
9374 | ||
0724ea2a TI |
9375 | /* bind hp and internal speaker mute (with plug check) */ |
9376 | static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol, | |
9377 | struct snd_ctl_elem_value *ucontrol) | |
9378 | { | |
9379 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
9380 | long *valp = ucontrol->value.integer.value; | |
9381 | int change; | |
9382 | ||
9383 | /* change hp mute */ | |
9384 | change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, | |
9385 | HDA_AMP_MUTE, | |
9386 | valp[0] ? 0 : HDA_AMP_MUTE); | |
9387 | change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, | |
9388 | HDA_AMP_MUTE, | |
9389 | valp[1] ? 0 : HDA_AMP_MUTE); | |
9390 | if (change) { | |
9391 | /* change speaker according to HP jack state */ | |
9392 | struct alc_spec *spec = codec->spec; | |
9393 | unsigned int mute; | |
9394 | if (spec->jack_present) | |
9395 | mute = HDA_AMP_MUTE; | |
9396 | else | |
9397 | mute = snd_hda_codec_amp_read(codec, 0x15, 0, | |
9398 | HDA_OUTPUT, 0); | |
9399 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
9400 | HDA_AMP_MUTE, mute); | |
9401 | } | |
9402 | return change; | |
9403 | } | |
5b31954e | 9404 | |
272a527c | 9405 | static struct snd_kcontrol_new alc262_sony_mixer[] = { |
0724ea2a TI |
9406 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9407 | { | |
9408 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9409 | .name = "Master Playback Switch", | |
9410 | .info = snd_hda_mixer_amp_switch_info, | |
9411 | .get = snd_hda_mixer_amp_switch_get, | |
9412 | .put = alc262_sony_master_sw_put, | |
9413 | .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | |
9414 | }, | |
272a527c KY |
9415 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
9416 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9417 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
9418 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
9419 | { } /* end */ | |
9420 | }; | |
9421 | ||
83c34218 KY |
9422 | static struct snd_kcontrol_new alc262_benq_t31_mixer[] = { |
9423 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
9424 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
9425 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
9426 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9427 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9428 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
9429 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
9430 | { } /* end */ | |
9431 | }; | |
272a527c | 9432 | |
9c7f852e TI |
9433 | #define alc262_capture_mixer alc882_capture_mixer |
9434 | #define alc262_capture_alt_mixer alc882_capture_alt_mixer | |
9435 | ||
9436 | /* | |
9437 | * generic initialization of ADC, input mixers and output mixers | |
9438 | */ | |
9439 | static struct hda_verb alc262_init_verbs[] = { | |
9440 | /* | |
9441 | * Unmute ADC0-2 and set the default input to mic-in | |
9442 | */ | |
9443 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9444 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9445 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9446 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9447 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9448 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9449 | ||
cb53c626 | 9450 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
9c7f852e | 9451 | * mixer widget |
f12ab1e0 TI |
9452 | * Note: PASD motherboards uses the Line In 2 as the input for |
9453 | * front panel mic (mic 2) | |
9c7f852e TI |
9454 | */ |
9455 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
9456 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
9457 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
9458 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
9459 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
9460 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9c7f852e TI |
9461 | |
9462 | /* | |
df694daa KY |
9463 | * Set up output mixers (0x0c - 0x0e) |
9464 | */ | |
9465 | /* set vol=0 to output mixers */ | |
9466 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9467 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9468 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9469 | /* set up input amps for analog loopback */ | |
9470 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
9471 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9472 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9473 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9474 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9475 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9476 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9477 | ||
9478 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
9479 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
9480 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
9481 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
9482 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
9483 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
9484 | ||
9485 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
9486 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
9487 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
9488 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
9489 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
ea1fb29a | 9490 | |
df694daa KY |
9491 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, |
9492 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
ea1fb29a | 9493 | |
df694daa KY |
9494 | /* FIXME: use matrix-type input source selection */ |
9495 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
9496 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
9497 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9498 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
9499 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
9500 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
9501 | /* Input mixer2 */ | |
9502 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9503 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
9504 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
9505 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
9506 | /* Input mixer3 */ | |
9507 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9508 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
9509 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
f12ab1e0 | 9510 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
df694daa KY |
9511 | |
9512 | { } | |
9513 | }; | |
1da177e4 | 9514 | |
4e555fe5 KY |
9515 | static struct hda_verb alc262_eapd_verbs[] = { |
9516 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
9517 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
9518 | { } | |
9519 | }; | |
9520 | ||
ccc656ce KY |
9521 | static struct hda_verb alc262_hippo_unsol_verbs[] = { |
9522 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
9523 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
9524 | {} | |
9525 | }; | |
9526 | ||
9527 | static struct hda_verb alc262_hippo1_unsol_verbs[] = { | |
9528 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
9529 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9530 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
9531 | ||
9532 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
9533 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
9534 | {} | |
9535 | }; | |
9536 | ||
272a527c KY |
9537 | static struct hda_verb alc262_sony_unsol_verbs[] = { |
9538 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
9539 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9540 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic | |
9541 | ||
9542 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
9543 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7b1e8795 | 9544 | {} |
272a527c KY |
9545 | }; |
9546 | ||
4e555fe5 KY |
9547 | static struct hda_input_mux alc262_dmic_capture_source = { |
9548 | .num_items = 2, | |
9549 | .items = { | |
9550 | { "Int DMic", 0x9 }, | |
9551 | { "Mic", 0x0 }, | |
9552 | }, | |
9553 | }; | |
9554 | ||
9555 | static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = { | |
9556 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
9557 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
9558 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
9559 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9560 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
4e555fe5 KY |
9561 | { } /* end */ |
9562 | }; | |
9563 | ||
9564 | static struct hda_verb alc262_toshiba_s06_verbs[] = { | |
9565 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
9566 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9567 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
9568 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9569 | {0x22, AC_VERB_SET_CONNECT_SEL, 0x09}, | |
9570 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
9571 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
9572 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
9573 | {} | |
9574 | }; | |
9575 | ||
9576 | static void alc262_dmic_automute(struct hda_codec *codec) | |
9577 | { | |
9578 | unsigned int present; | |
9579 | ||
9580 | present = snd_hda_codec_read(codec, 0x18, 0, | |
9581 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
9582 | snd_hda_codec_write(codec, 0x22, 0, | |
9583 | AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09); | |
9584 | } | |
9585 | ||
9586 | /* toggle speaker-output according to the hp-jack state */ | |
9587 | static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec) | |
9588 | { | |
9589 | unsigned int present; | |
9590 | unsigned char bits; | |
9591 | ||
9592 | present = snd_hda_codec_read(codec, 0x15, 0, | |
9593 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
9594 | bits = present ? 0 : PIN_OUT; | |
9595 | snd_hda_codec_write(codec, 0x14, 0, | |
9596 | AC_VERB_SET_PIN_WIDGET_CONTROL, bits); | |
9597 | } | |
9598 | ||
9599 | ||
9600 | ||
9601 | /* unsolicited event for HP jack sensing */ | |
9602 | static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec, | |
9603 | unsigned int res) | |
9604 | { | |
9605 | if ((res >> 26) == ALC880_HP_EVENT) | |
9606 | alc262_toshiba_s06_speaker_automute(codec); | |
9607 | if ((res >> 26) == ALC880_MIC_EVENT) | |
9608 | alc262_dmic_automute(codec); | |
9609 | ||
9610 | } | |
9611 | ||
9612 | static void alc262_toshiba_s06_init_hook(struct hda_codec *codec) | |
9613 | { | |
9614 | alc262_toshiba_s06_speaker_automute(codec); | |
9615 | alc262_dmic_automute(codec); | |
9616 | } | |
9617 | ||
ccc656ce | 9618 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
5b31954e | 9619 | static void alc262_hippo_automute(struct hda_codec *codec) |
ccc656ce KY |
9620 | { |
9621 | struct alc_spec *spec = codec->spec; | |
9622 | unsigned int mute; | |
5b31954e | 9623 | unsigned int present; |
ccc656ce | 9624 | |
5b31954e TI |
9625 | /* need to execute and sync at first */ |
9626 | snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); | |
9627 | present = snd_hda_codec_read(codec, 0x15, 0, | |
9628 | AC_VERB_GET_PIN_SENSE, 0); | |
9629 | spec->jack_present = (present & 0x80000000) != 0; | |
ccc656ce KY |
9630 | if (spec->jack_present) { |
9631 | /* mute internal speaker */ | |
47fd830a TI |
9632 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
9633 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
ccc656ce KY |
9634 | } else { |
9635 | /* unmute internal speaker if necessary */ | |
9636 | mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0); | |
47fd830a TI |
9637 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
9638 | HDA_AMP_MUTE, mute); | |
ccc656ce KY |
9639 | } |
9640 | } | |
9641 | ||
9642 | /* unsolicited event for HP jack sensing */ | |
9643 | static void alc262_hippo_unsol_event(struct hda_codec *codec, | |
9644 | unsigned int res) | |
9645 | { | |
9646 | if ((res >> 26) != ALC880_HP_EVENT) | |
9647 | return; | |
5b31954e | 9648 | alc262_hippo_automute(codec); |
ccc656ce KY |
9649 | } |
9650 | ||
5b31954e | 9651 | static void alc262_hippo1_automute(struct hda_codec *codec) |
ccc656ce | 9652 | { |
ccc656ce | 9653 | unsigned int mute; |
5b31954e | 9654 | unsigned int present; |
ccc656ce | 9655 | |
5b31954e TI |
9656 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); |
9657 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
9658 | AC_VERB_GET_PIN_SENSE, 0); | |
9659 | present = (present & 0x80000000) != 0; | |
9660 | if (present) { | |
ccc656ce | 9661 | /* mute internal speaker */ |
47fd830a TI |
9662 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
9663 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
ccc656ce KY |
9664 | } else { |
9665 | /* unmute internal speaker if necessary */ | |
9666 | mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); | |
47fd830a TI |
9667 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
9668 | HDA_AMP_MUTE, mute); | |
ccc656ce KY |
9669 | } |
9670 | } | |
9671 | ||
9672 | /* unsolicited event for HP jack sensing */ | |
9673 | static void alc262_hippo1_unsol_event(struct hda_codec *codec, | |
9674 | unsigned int res) | |
9675 | { | |
9676 | if ((res >> 26) != ALC880_HP_EVENT) | |
9677 | return; | |
5b31954e | 9678 | alc262_hippo1_automute(codec); |
ccc656ce KY |
9679 | } |
9680 | ||
e8f9ae2a PT |
9681 | /* |
9682 | * nec model | |
9683 | * 0x15 = headphone | |
9684 | * 0x16 = internal speaker | |
9685 | * 0x18 = external mic | |
9686 | */ | |
9687 | ||
9688 | static struct snd_kcontrol_new alc262_nec_mixer[] = { | |
9689 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
9690 | HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT), | |
9691 | ||
9692 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9693 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9694 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
9695 | ||
9696 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
9697 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
9698 | { } /* end */ | |
9699 | }; | |
9700 | ||
9701 | static struct hda_verb alc262_nec_verbs[] = { | |
9702 | /* Unmute Speaker */ | |
9703 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9704 | ||
9705 | /* Headphone */ | |
9706 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
9707 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9708 | ||
9709 | /* External mic to headphone */ | |
9710 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9711 | /* External mic to speaker */ | |
9712 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9713 | {} | |
9714 | }; | |
9715 | ||
834be88d TI |
9716 | /* |
9717 | * fujitsu model | |
5d9fab2d TV |
9718 | * 0x14 = headphone/spdif-out, 0x15 = internal speaker, |
9719 | * 0x1b = port replicator headphone out | |
834be88d TI |
9720 | */ |
9721 | ||
9722 | #define ALC_HP_EVENT 0x37 | |
9723 | ||
9724 | static struct hda_verb alc262_fujitsu_unsol_verbs[] = { | |
9725 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, | |
9726 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5d9fab2d TV |
9727 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, |
9728 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
834be88d TI |
9729 | {} |
9730 | }; | |
9731 | ||
0e31daf7 J |
9732 | static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = { |
9733 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, | |
9734 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
9735 | {} | |
9736 | }; | |
9737 | ||
834be88d | 9738 | static struct hda_input_mux alc262_fujitsu_capture_source = { |
39d3ed38 | 9739 | .num_items = 3, |
834be88d TI |
9740 | .items = { |
9741 | { "Mic", 0x0 }, | |
39d3ed38 | 9742 | { "Int Mic", 0x1 }, |
834be88d TI |
9743 | { "CD", 0x4 }, |
9744 | }, | |
9745 | }; | |
9746 | ||
9c7f852e TI |
9747 | static struct hda_input_mux alc262_HP_capture_source = { |
9748 | .num_items = 5, | |
9749 | .items = { | |
9750 | { "Mic", 0x0 }, | |
accbe498 | 9751 | { "Front Mic", 0x1 }, |
9c7f852e TI |
9752 | { "Line", 0x2 }, |
9753 | { "CD", 0x4 }, | |
9754 | { "AUX IN", 0x6 }, | |
9755 | }, | |
9756 | }; | |
9757 | ||
accbe498 | 9758 | static struct hda_input_mux alc262_HP_D7000_capture_source = { |
9759 | .num_items = 4, | |
9760 | .items = { | |
9761 | { "Mic", 0x0 }, | |
9762 | { "Front Mic", 0x2 }, | |
9763 | { "Line", 0x1 }, | |
9764 | { "CD", 0x4 }, | |
9765 | }, | |
9766 | }; | |
9767 | ||
ebc7a406 | 9768 | /* mute/unmute internal speaker according to the hp jacks and mute state */ |
834be88d TI |
9769 | static void alc262_fujitsu_automute(struct hda_codec *codec, int force) |
9770 | { | |
9771 | struct alc_spec *spec = codec->spec; | |
9772 | unsigned int mute; | |
9773 | ||
f12ab1e0 | 9774 | if (force || !spec->sense_updated) { |
ebc7a406 | 9775 | unsigned int present; |
834be88d TI |
9776 | /* need to execute and sync at first */ |
9777 | snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); | |
ebc7a406 TI |
9778 | /* check laptop HP jack */ |
9779 | present = snd_hda_codec_read(codec, 0x14, 0, | |
9780 | AC_VERB_GET_PIN_SENSE, 0); | |
9781 | /* need to execute and sync at first */ | |
9782 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); | |
9783 | /* check docking HP jack */ | |
9784 | present |= snd_hda_codec_read(codec, 0x1b, 0, | |
9785 | AC_VERB_GET_PIN_SENSE, 0); | |
9786 | if (present & AC_PINSENSE_PRESENCE) | |
9787 | spec->jack_present = 1; | |
9788 | else | |
9789 | spec->jack_present = 0; | |
834be88d TI |
9790 | spec->sense_updated = 1; |
9791 | } | |
ebc7a406 TI |
9792 | /* unmute internal speaker only if both HPs are unplugged and |
9793 | * master switch is on | |
9794 | */ | |
9795 | if (spec->jack_present) | |
9796 | mute = HDA_AMP_MUTE; | |
9797 | else | |
834be88d | 9798 | mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); |
ebc7a406 TI |
9799 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
9800 | HDA_AMP_MUTE, mute); | |
834be88d TI |
9801 | } |
9802 | ||
9803 | /* unsolicited event for HP jack sensing */ | |
9804 | static void alc262_fujitsu_unsol_event(struct hda_codec *codec, | |
9805 | unsigned int res) | |
9806 | { | |
9807 | if ((res >> 26) != ALC_HP_EVENT) | |
9808 | return; | |
9809 | alc262_fujitsu_automute(codec, 1); | |
9810 | } | |
9811 | ||
ebc7a406 TI |
9812 | static void alc262_fujitsu_init_hook(struct hda_codec *codec) |
9813 | { | |
9814 | alc262_fujitsu_automute(codec, 1); | |
9815 | } | |
9816 | ||
834be88d | 9817 | /* bind volumes of both NID 0x0c and 0x0d */ |
cca3b371 TI |
9818 | static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = { |
9819 | .ops = &snd_hda_bind_vol, | |
9820 | .values = { | |
9821 | HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT), | |
9822 | HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT), | |
9823 | 0 | |
9824 | }, | |
9825 | }; | |
834be88d | 9826 | |
0e31daf7 J |
9827 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
9828 | static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force) | |
9829 | { | |
9830 | struct alc_spec *spec = codec->spec; | |
9831 | unsigned int mute; | |
9832 | ||
9833 | if (force || !spec->sense_updated) { | |
9834 | unsigned int present_int_hp; | |
9835 | /* need to execute and sync at first */ | |
9836 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); | |
9837 | present_int_hp = snd_hda_codec_read(codec, 0x1b, 0, | |
9838 | AC_VERB_GET_PIN_SENSE, 0); | |
9839 | spec->jack_present = (present_int_hp & 0x80000000) != 0; | |
9840 | spec->sense_updated = 1; | |
9841 | } | |
9842 | if (spec->jack_present) { | |
9843 | /* mute internal speaker */ | |
9844 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
9845 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
9846 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
9847 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
9848 | } else { | |
9849 | /* unmute internal speaker if necessary */ | |
9850 | mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); | |
9851 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
9852 | HDA_AMP_MUTE, mute); | |
9853 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
9854 | HDA_AMP_MUTE, mute); | |
9855 | } | |
9856 | } | |
9857 | ||
9858 | /* unsolicited event for HP jack sensing */ | |
9859 | static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec, | |
9860 | unsigned int res) | |
9861 | { | |
9862 | if ((res >> 26) != ALC_HP_EVENT) | |
9863 | return; | |
9864 | alc262_lenovo_3000_automute(codec, 1); | |
9865 | } | |
9866 | ||
834be88d TI |
9867 | /* bind hp and internal speaker mute (with plug check) */ |
9868 | static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol, | |
9869 | struct snd_ctl_elem_value *ucontrol) | |
9870 | { | |
9871 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
9872 | long *valp = ucontrol->value.integer.value; | |
9873 | int change; | |
9874 | ||
5d9fab2d TV |
9875 | change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
9876 | HDA_AMP_MUTE, | |
9877 | valp ? 0 : HDA_AMP_MUTE); | |
9878 | change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
9879 | HDA_AMP_MUTE, | |
9880 | valp ? 0 : HDA_AMP_MUTE); | |
9881 | ||
82beb8fd TI |
9882 | if (change) |
9883 | alc262_fujitsu_automute(codec, 0); | |
834be88d TI |
9884 | return change; |
9885 | } | |
9886 | ||
9887 | static struct snd_kcontrol_new alc262_fujitsu_mixer[] = { | |
cca3b371 | 9888 | HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol), |
834be88d TI |
9889 | { |
9890 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9891 | .name = "Master Playback Switch", | |
9892 | .info = snd_hda_mixer_amp_switch_info, | |
9893 | .get = snd_hda_mixer_amp_switch_get, | |
9894 | .put = alc262_fujitsu_master_sw_put, | |
9895 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
9896 | }, | |
9897 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
9898 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
06a9c30c TV |
9899 | HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT), |
9900 | HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT), | |
834be88d TI |
9901 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9902 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9903 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
39d3ed38 TI |
9904 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), |
9905 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
9906 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
834be88d TI |
9907 | { } /* end */ |
9908 | }; | |
9909 | ||
0e31daf7 J |
9910 | /* bind hp and internal speaker mute (with plug check) */ |
9911 | static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol, | |
9912 | struct snd_ctl_elem_value *ucontrol) | |
9913 | { | |
9914 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
9915 | long *valp = ucontrol->value.integer.value; | |
9916 | int change; | |
9917 | ||
9918 | change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
9919 | HDA_AMP_MUTE, | |
9920 | valp ? 0 : HDA_AMP_MUTE); | |
9921 | ||
9922 | if (change) | |
9923 | alc262_lenovo_3000_automute(codec, 0); | |
9924 | return change; | |
9925 | } | |
9926 | ||
9927 | static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = { | |
9928 | HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol), | |
9929 | { | |
9930 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9931 | .name = "Master Playback Switch", | |
9932 | .info = snd_hda_mixer_amp_switch_info, | |
9933 | .get = snd_hda_mixer_amp_switch_get, | |
9934 | .put = alc262_lenovo_3000_master_sw_put, | |
9935 | .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), | |
9936 | }, | |
9937 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
9938 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
9939 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
9940 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9941 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9942 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
9943 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
9944 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
9945 | { } /* end */ | |
9946 | }; | |
9947 | ||
9f99a638 HM |
9948 | static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = { |
9949 | HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol), | |
9950 | { | |
9951 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9952 | .name = "Master Playback Switch", | |
9953 | .info = snd_hda_mixer_amp_switch_info, | |
9954 | .get = snd_hda_mixer_amp_switch_get, | |
9955 | .put = alc262_sony_master_sw_put, | |
9956 | .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | |
9957 | }, | |
9958 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9959 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9960 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
9961 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
9962 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
9963 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
9964 | { } /* end */ | |
9965 | }; | |
9966 | ||
304dcaac TI |
9967 | /* additional init verbs for Benq laptops */ |
9968 | static struct hda_verb alc262_EAPD_verbs[] = { | |
9969 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
9970 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
9971 | {} | |
9972 | }; | |
9973 | ||
83c34218 KY |
9974 | static struct hda_verb alc262_benq_t31_EAPD_verbs[] = { |
9975 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9976 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
9977 | ||
9978 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
9979 | {0x20, AC_VERB_SET_PROC_COEF, 0x3050}, | |
9980 | {} | |
9981 | }; | |
9982 | ||
f651b50b TD |
9983 | /* Samsung Q1 Ultra Vista model setup */ |
9984 | static struct snd_kcontrol_new alc262_ultra_mixer[] = { | |
bb9f76cd TI |
9985 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9986 | HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT), | |
f651b50b TD |
9987 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
9988 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
9989 | HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT), | |
bb9f76cd | 9990 | HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT), |
f651b50b TD |
9991 | { } /* end */ |
9992 | }; | |
9993 | ||
9994 | static struct hda_verb alc262_ultra_verbs[] = { | |
bb9f76cd TI |
9995 | /* output mixer */ |
9996 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
9997 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
9998 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9999 | /* speaker */ | |
10000 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
10001 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10002 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10003 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10004 | /* HP */ | |
f651b50b | 10005 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
bb9f76cd TI |
10006 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
10007 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10008 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10009 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
10010 | /* internal mic */ | |
10011 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
10012 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10013 | /* ADC, choose mic */ | |
10014 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
10015 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
10016 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10017 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
10018 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
10019 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
10020 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
10021 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
10022 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
10023 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)}, | |
f651b50b TD |
10024 | {} |
10025 | }; | |
10026 | ||
f651b50b TD |
10027 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
10028 | static void alc262_ultra_automute(struct hda_codec *codec) | |
10029 | { | |
10030 | struct alc_spec *spec = codec->spec; | |
10031 | unsigned int mute; | |
f651b50b | 10032 | |
bb9f76cd TI |
10033 | mute = 0; |
10034 | /* auto-mute only when HP is used as HP */ | |
10035 | if (!spec->cur_mux[0]) { | |
10036 | unsigned int present; | |
10037 | /* need to execute and sync at first */ | |
10038 | snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); | |
10039 | present = snd_hda_codec_read(codec, 0x15, 0, | |
10040 | AC_VERB_GET_PIN_SENSE, 0); | |
10041 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; | |
10042 | if (spec->jack_present) | |
10043 | mute = HDA_AMP_MUTE; | |
f651b50b | 10044 | } |
bb9f76cd TI |
10045 | /* mute/unmute internal speaker */ |
10046 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
10047 | HDA_AMP_MUTE, mute); | |
10048 | /* mute/unmute HP */ | |
10049 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
10050 | HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE); | |
f651b50b TD |
10051 | } |
10052 | ||
10053 | /* unsolicited event for HP jack sensing */ | |
10054 | static void alc262_ultra_unsol_event(struct hda_codec *codec, | |
10055 | unsigned int res) | |
10056 | { | |
10057 | if ((res >> 26) != ALC880_HP_EVENT) | |
10058 | return; | |
10059 | alc262_ultra_automute(codec); | |
10060 | } | |
10061 | ||
bb9f76cd TI |
10062 | static struct hda_input_mux alc262_ultra_capture_source = { |
10063 | .num_items = 2, | |
10064 | .items = { | |
10065 | { "Mic", 0x1 }, | |
10066 | { "Headphone", 0x7 }, | |
10067 | }, | |
10068 | }; | |
10069 | ||
10070 | static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol, | |
10071 | struct snd_ctl_elem_value *ucontrol) | |
10072 | { | |
10073 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
10074 | struct alc_spec *spec = codec->spec; | |
10075 | int ret; | |
10076 | ||
54cbc9ab | 10077 | ret = alc_mux_enum_put(kcontrol, ucontrol); |
bb9f76cd TI |
10078 | if (!ret) |
10079 | return 0; | |
10080 | /* reprogram the HP pin as mic or HP according to the input source */ | |
10081 | snd_hda_codec_write_cache(codec, 0x15, 0, | |
10082 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
10083 | spec->cur_mux[0] ? PIN_VREF80 : PIN_HP); | |
10084 | alc262_ultra_automute(codec); /* mute/unmute HP */ | |
10085 | return ret; | |
10086 | } | |
10087 | ||
10088 | static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = { | |
10089 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), | |
10090 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), | |
10091 | { | |
10092 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10093 | .name = "Capture Source", | |
54cbc9ab TI |
10094 | .info = alc_mux_enum_info, |
10095 | .get = alc_mux_enum_get, | |
bb9f76cd TI |
10096 | .put = alc262_ultra_mux_enum_put, |
10097 | }, | |
10098 | { } /* end */ | |
10099 | }; | |
10100 | ||
df694daa | 10101 | /* add playback controls from the parsed DAC table */ |
f12ab1e0 TI |
10102 | static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, |
10103 | const struct auto_pin_cfg *cfg) | |
df694daa KY |
10104 | { |
10105 | hda_nid_t nid; | |
10106 | int err; | |
10107 | ||
10108 | spec->multiout.num_dacs = 1; /* only use one dac */ | |
10109 | spec->multiout.dac_nids = spec->private_dac_nids; | |
10110 | spec->multiout.dac_nids[0] = 2; | |
10111 | ||
10112 | nid = cfg->line_out_pins[0]; | |
10113 | if (nid) { | |
f12ab1e0 TI |
10114 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
10115 | "Front Playback Volume", | |
10116 | HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT)); | |
10117 | if (err < 0) | |
df694daa | 10118 | return err; |
f12ab1e0 TI |
10119 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
10120 | "Front Playback Switch", | |
10121 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
10122 | if (err < 0) | |
df694daa KY |
10123 | return err; |
10124 | } | |
10125 | ||
82bc955f | 10126 | nid = cfg->speaker_pins[0]; |
df694daa KY |
10127 | if (nid) { |
10128 | if (nid == 0x16) { | |
f12ab1e0 TI |
10129 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
10130 | "Speaker Playback Volume", | |
10131 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, | |
10132 | HDA_OUTPUT)); | |
10133 | if (err < 0) | |
df694daa | 10134 | return err; |
f12ab1e0 TI |
10135 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
10136 | "Speaker Playback Switch", | |
10137 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
10138 | HDA_OUTPUT)); | |
10139 | if (err < 0) | |
df694daa KY |
10140 | return err; |
10141 | } else { | |
f12ab1e0 TI |
10142 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
10143 | "Speaker Playback Switch", | |
10144 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
10145 | HDA_OUTPUT)); | |
10146 | if (err < 0) | |
df694daa KY |
10147 | return err; |
10148 | } | |
10149 | } | |
eb06ed8f | 10150 | nid = cfg->hp_pins[0]; |
df694daa KY |
10151 | if (nid) { |
10152 | /* spec->multiout.hp_nid = 2; */ | |
10153 | if (nid == 0x16) { | |
f12ab1e0 TI |
10154 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
10155 | "Headphone Playback Volume", | |
10156 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, | |
10157 | HDA_OUTPUT)); | |
10158 | if (err < 0) | |
df694daa | 10159 | return err; |
f12ab1e0 TI |
10160 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
10161 | "Headphone Playback Switch", | |
10162 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
10163 | HDA_OUTPUT)); | |
10164 | if (err < 0) | |
df694daa KY |
10165 | return err; |
10166 | } else { | |
f12ab1e0 TI |
10167 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
10168 | "Headphone Playback Switch", | |
10169 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
10170 | HDA_OUTPUT)); | |
10171 | if (err < 0) | |
df694daa KY |
10172 | return err; |
10173 | } | |
10174 | } | |
f12ab1e0 | 10175 | return 0; |
df694daa KY |
10176 | } |
10177 | ||
10178 | /* identical with ALC880 */ | |
f12ab1e0 TI |
10179 | #define alc262_auto_create_analog_input_ctls \ |
10180 | alc880_auto_create_analog_input_ctls | |
df694daa KY |
10181 | |
10182 | /* | |
10183 | * generic initialization of ADC, input mixers and output mixers | |
10184 | */ | |
10185 | static struct hda_verb alc262_volume_init_verbs[] = { | |
10186 | /* | |
10187 | * Unmute ADC0-2 and set the default input to mic-in | |
10188 | */ | |
10189 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10190 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10191 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10192 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10193 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10194 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10195 | ||
cb53c626 | 10196 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
df694daa | 10197 | * mixer widget |
f12ab1e0 TI |
10198 | * Note: PASD motherboards uses the Line In 2 as the input for |
10199 | * front panel mic (mic 2) | |
df694daa KY |
10200 | */ |
10201 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
10202 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
10203 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10204 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
10205 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
10206 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
10207 | |
10208 | /* | |
10209 | * Set up output mixers (0x0c - 0x0f) | |
10210 | */ | |
10211 | /* set vol=0 to output mixers */ | |
10212 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10213 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10214 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
ea1fb29a | 10215 | |
df694daa KY |
10216 | /* set up input amps for analog loopback */ |
10217 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
10218 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10219 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10220 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10221 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10222 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10223 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10224 | ||
10225 | /* FIXME: use matrix-type input source selection */ | |
10226 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
10227 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
10228 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
10229 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
10230 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
10231 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
10232 | /* Input mixer2 */ | |
10233 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
10234 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
10235 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
10236 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
10237 | /* Input mixer3 */ | |
10238 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
10239 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
10240 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
10241 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
10242 | ||
10243 | { } | |
10244 | }; | |
10245 | ||
9c7f852e TI |
10246 | static struct hda_verb alc262_HP_BPC_init_verbs[] = { |
10247 | /* | |
10248 | * Unmute ADC0-2 and set the default input to mic-in | |
10249 | */ | |
10250 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10251 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10252 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10253 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10254 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10255 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10256 | ||
cb53c626 | 10257 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
9c7f852e | 10258 | * mixer widget |
f12ab1e0 TI |
10259 | * Note: PASD motherboards uses the Line In 2 as the input for |
10260 | * front panel mic (mic 2) | |
9c7f852e TI |
10261 | */ |
10262 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
10263 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
10264 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10265 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
10266 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
10267 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
10268 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
10269 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
ea1fb29a | 10270 | |
9c7f852e TI |
10271 | /* |
10272 | * Set up output mixers (0x0c - 0x0e) | |
10273 | */ | |
10274 | /* set vol=0 to output mixers */ | |
10275 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10276 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10277 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10278 | ||
10279 | /* set up input amps for analog loopback */ | |
10280 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
10281 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10282 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10283 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10284 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10285 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10286 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10287 | ||
ce875f07 | 10288 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
9c7f852e TI |
10289 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
10290 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
10291 | ||
10292 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
10293 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
10294 | ||
10295 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10296 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10297 | ||
10298 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
10299 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
10300 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
10301 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
10302 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
10303 | ||
10304 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
10305 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10306 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10307 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
10308 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10309 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10310 | ||
10311 | ||
10312 | /* FIXME: use matrix-type input source selection */ | |
10313 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
10314 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
10315 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
10316 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
10317 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
10318 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
10319 | /* Input mixer2 */ | |
10320 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
10321 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
10322 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
10323 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
10324 | /* Input mixer3 */ | |
10325 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
10326 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
10327 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
10328 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
10329 | ||
ce875f07 TI |
10330 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
10331 | ||
9c7f852e TI |
10332 | { } |
10333 | }; | |
10334 | ||
cd7509a4 KY |
10335 | static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = { |
10336 | /* | |
10337 | * Unmute ADC0-2 and set the default input to mic-in | |
10338 | */ | |
10339 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10340 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10341 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10342 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10343 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10344 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10345 | ||
cb53c626 | 10346 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
cd7509a4 KY |
10347 | * mixer widget |
10348 | * Note: PASD motherboards uses the Line In 2 as the input for front | |
10349 | * panel mic (mic 2) | |
10350 | */ | |
10351 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
10352 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
10353 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10354 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
10355 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
10356 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
10357 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
10358 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
10359 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
cd7509a4 KY |
10360 | /* |
10361 | * Set up output mixers (0x0c - 0x0e) | |
10362 | */ | |
10363 | /* set vol=0 to output mixers */ | |
10364 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10365 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10366 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10367 | ||
10368 | /* set up input amps for analog loopback */ | |
10369 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
10370 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10371 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10372 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10373 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10374 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10375 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10376 | ||
10377 | ||
10378 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */ | |
10379 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */ | |
10380 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */ | |
10381 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */ | |
10382 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */ | |
10383 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */ | |
10384 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */ | |
10385 | ||
10386 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
10387 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
10388 | ||
10389 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10390 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
10391 | ||
10392 | /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */ | |
10393 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10394 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10395 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
10396 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10397 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10398 | ||
10399 | /* FIXME: use matrix-type input source selection */ | |
10400 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
10401 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
10402 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/ | |
10403 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/ | |
10404 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/ | |
10405 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/ | |
10406 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/ | |
10407 | /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
10408 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/ | |
10409 | /* Input mixer2 */ | |
10410 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
10411 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
10412 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
10413 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
10414 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
10415 | /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
10416 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, | |
10417 | /* Input mixer3 */ | |
10418 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
10419 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
10420 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
10421 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
10422 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
10423 | /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
10424 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, | |
10425 | ||
ce875f07 TI |
10426 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
10427 | ||
cd7509a4 KY |
10428 | { } |
10429 | }; | |
10430 | ||
9f99a638 HM |
10431 | static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = { |
10432 | ||
10433 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */ | |
10434 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
10435 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
10436 | ||
10437 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */ | |
10438 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */ | |
10439 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) }, | |
10440 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) }, | |
10441 | ||
10442 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */ | |
10443 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10444 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
10445 | {} | |
10446 | }; | |
10447 | ||
10448 | ||
cb53c626 TI |
10449 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
10450 | #define alc262_loopbacks alc880_loopbacks | |
10451 | #endif | |
10452 | ||
df694daa KY |
10453 | /* pcm configuration: identiacal with ALC880 */ |
10454 | #define alc262_pcm_analog_playback alc880_pcm_analog_playback | |
10455 | #define alc262_pcm_analog_capture alc880_pcm_analog_capture | |
10456 | #define alc262_pcm_digital_playback alc880_pcm_digital_playback | |
10457 | #define alc262_pcm_digital_capture alc880_pcm_digital_capture | |
10458 | ||
10459 | /* | |
10460 | * BIOS auto configuration | |
10461 | */ | |
10462 | static int alc262_parse_auto_config(struct hda_codec *codec) | |
10463 | { | |
10464 | struct alc_spec *spec = codec->spec; | |
10465 | int err; | |
10466 | static hda_nid_t alc262_ignore[] = { 0x1d, 0 }; | |
10467 | ||
f12ab1e0 TI |
10468 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
10469 | alc262_ignore); | |
10470 | if (err < 0) | |
df694daa | 10471 | return err; |
f12ab1e0 | 10472 | if (!spec->autocfg.line_outs) |
df694daa | 10473 | return 0; /* can't find valid BIOS pin config */ |
f12ab1e0 TI |
10474 | err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg); |
10475 | if (err < 0) | |
10476 | return err; | |
10477 | err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
10478 | if (err < 0) | |
df694daa KY |
10479 | return err; |
10480 | ||
10481 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
10482 | ||
10483 | if (spec->autocfg.dig_out_pin) | |
10484 | spec->multiout.dig_out_nid = ALC262_DIGOUT_NID; | |
10485 | if (spec->autocfg.dig_in_pin) | |
10486 | spec->dig_in_nid = ALC262_DIGIN_NID; | |
10487 | ||
603c4019 | 10488 | if (spec->kctls.list) |
d88897ea | 10489 | add_mixer(spec, spec->kctls.list); |
df694daa | 10490 | |
d88897ea | 10491 | add_verb(spec, alc262_volume_init_verbs); |
a1e8d2da | 10492 | spec->num_mux_defs = 1; |
df694daa KY |
10493 | spec->input_mux = &spec->private_imux; |
10494 | ||
776e184e TI |
10495 | err = alc_auto_add_mic_boost(codec); |
10496 | if (err < 0) | |
10497 | return err; | |
10498 | ||
e044c39a | 10499 | store_pin_configs(codec); |
df694daa KY |
10500 | return 1; |
10501 | } | |
10502 | ||
10503 | #define alc262_auto_init_multi_out alc882_auto_init_multi_out | |
10504 | #define alc262_auto_init_hp_out alc882_auto_init_hp_out | |
10505 | #define alc262_auto_init_analog_input alc882_auto_init_analog_input | |
f511b01c | 10506 | #define alc262_auto_init_input_src alc882_auto_init_input_src |
df694daa KY |
10507 | |
10508 | ||
10509 | /* init callback for auto-configuration model -- overriding the default init */ | |
ae6b813a | 10510 | static void alc262_auto_init(struct hda_codec *codec) |
df694daa | 10511 | { |
f6c7e546 | 10512 | struct alc_spec *spec = codec->spec; |
df694daa KY |
10513 | alc262_auto_init_multi_out(codec); |
10514 | alc262_auto_init_hp_out(codec); | |
10515 | alc262_auto_init_analog_input(codec); | |
f511b01c | 10516 | alc262_auto_init_input_src(codec); |
f6c7e546 | 10517 | if (spec->unsol_event) |
7fb0d78f | 10518 | alc_inithook(codec); |
df694daa KY |
10519 | } |
10520 | ||
10521 | /* | |
10522 | * configuration and preset | |
10523 | */ | |
f5fcc13c TI |
10524 | static const char *alc262_models[ALC262_MODEL_LAST] = { |
10525 | [ALC262_BASIC] = "basic", | |
10526 | [ALC262_HIPPO] = "hippo", | |
10527 | [ALC262_HIPPO_1] = "hippo_1", | |
10528 | [ALC262_FUJITSU] = "fujitsu", | |
10529 | [ALC262_HP_BPC] = "hp-bpc", | |
cd7509a4 | 10530 | [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000", |
61dc35de | 10531 | [ALC262_HP_TC_T5735] = "hp-tc-t5735", |
8c427226 | 10532 | [ALC262_HP_RP5700] = "hp-rp5700", |
f5fcc13c | 10533 | [ALC262_BENQ_ED8] = "benq", |
0f40502e TI |
10534 | [ALC262_BENQ_T31] = "benq-t31", |
10535 | [ALC262_SONY_ASSAMD] = "sony-assamd", | |
2922c9af | 10536 | [ALC262_TOSHIBA_S06] = "toshiba-s06", |
9f99a638 | 10537 | [ALC262_TOSHIBA_RX1] = "toshiba-rx1", |
f651b50b | 10538 | [ALC262_ULTRA] = "ultra", |
0e31daf7 | 10539 | [ALC262_LENOVO_3000] = "lenovo-3000", |
e8f9ae2a | 10540 | [ALC262_NEC] = "nec", |
f5fcc13c TI |
10541 | [ALC262_AUTO] = "auto", |
10542 | }; | |
10543 | ||
10544 | static struct snd_pci_quirk alc262_cfg_tbl[] = { | |
10545 | SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO), | |
e8f9ae2a | 10546 | SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC), |
f5fcc13c | 10547 | SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC), |
7d87de2d | 10548 | SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC), |
ac3e3741 TI |
10549 | SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC), |
10550 | SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC), | |
7d87de2d | 10551 | SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC), |
b98f9334 | 10552 | SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC), |
b98f9334 | 10553 | SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC), |
b98f9334 | 10554 | SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC), |
cd7509a4 | 10555 | SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL), |
cd7509a4 | 10556 | SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF), |
ac3e3741 | 10557 | SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL), |
cd7509a4 | 10558 | SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF), |
ac3e3741 | 10559 | SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL), |
cd7509a4 | 10560 | SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF), |
ac3e3741 | 10561 | SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL), |
cd7509a4 | 10562 | SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF), |
ac3e3741 TI |
10563 | SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC), |
10564 | SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC), | |
10565 | SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC), | |
66d2a9d6 KY |
10566 | SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735", |
10567 | ALC262_HP_TC_T5735), | |
8c427226 | 10568 | SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700), |
ac3e3741 | 10569 | SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD), |
f5fcc13c | 10570 | SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO), |
5b31954e | 10571 | SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD), |
272a527c | 10572 | SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD), |
ac3e3741 | 10573 | SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD), |
57a5ef48 TI |
10574 | SND_PCI_QUIRK(0x104d, 0x9033, "Sony VAIO VGN-SR19XN", |
10575 | ALC262_SONY_ASSAMD), | |
36ca6e13 | 10576 | SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1", |
9f99a638 | 10577 | ALC262_TOSHIBA_RX1), |
80ffe869 | 10578 | SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06), |
ac3e3741 | 10579 | SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU), |
3f1eeaed | 10580 | SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU), |
f651b50b | 10581 | SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA), |
bb9f76cd | 10582 | SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA), |
3e420e78 | 10583 | SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO), |
0e31daf7 | 10584 | SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000), |
ac3e3741 TI |
10585 | SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8), |
10586 | SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31), | |
10587 | SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1), | |
df694daa KY |
10588 | {} |
10589 | }; | |
10590 | ||
10591 | static struct alc_config_preset alc262_presets[] = { | |
10592 | [ALC262_BASIC] = { | |
10593 | .mixers = { alc262_base_mixer }, | |
10594 | .init_verbs = { alc262_init_verbs }, | |
10595 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10596 | .dac_nids = alc262_dac_nids, | |
10597 | .hp_nid = 0x03, | |
10598 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10599 | .channel_mode = alc262_modes, | |
a3bcba38 | 10600 | .input_mux = &alc262_capture_source, |
df694daa | 10601 | }, |
ccc656ce KY |
10602 | [ALC262_HIPPO] = { |
10603 | .mixers = { alc262_base_mixer }, | |
10604 | .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs}, | |
10605 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10606 | .dac_nids = alc262_dac_nids, | |
10607 | .hp_nid = 0x03, | |
10608 | .dig_out_nid = ALC262_DIGOUT_NID, | |
10609 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10610 | .channel_mode = alc262_modes, | |
10611 | .input_mux = &alc262_capture_source, | |
10612 | .unsol_event = alc262_hippo_unsol_event, | |
5b31954e | 10613 | .init_hook = alc262_hippo_automute, |
ccc656ce KY |
10614 | }, |
10615 | [ALC262_HIPPO_1] = { | |
10616 | .mixers = { alc262_hippo1_mixer }, | |
10617 | .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs}, | |
10618 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10619 | .dac_nids = alc262_dac_nids, | |
10620 | .hp_nid = 0x02, | |
10621 | .dig_out_nid = ALC262_DIGOUT_NID, | |
10622 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10623 | .channel_mode = alc262_modes, | |
10624 | .input_mux = &alc262_capture_source, | |
10625 | .unsol_event = alc262_hippo1_unsol_event, | |
5b31954e | 10626 | .init_hook = alc262_hippo1_automute, |
ccc656ce | 10627 | }, |
834be88d TI |
10628 | [ALC262_FUJITSU] = { |
10629 | .mixers = { alc262_fujitsu_mixer }, | |
39d3ed38 TI |
10630 | .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs, |
10631 | alc262_fujitsu_unsol_verbs }, | |
834be88d TI |
10632 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), |
10633 | .dac_nids = alc262_dac_nids, | |
10634 | .hp_nid = 0x03, | |
10635 | .dig_out_nid = ALC262_DIGOUT_NID, | |
10636 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10637 | .channel_mode = alc262_modes, | |
10638 | .input_mux = &alc262_fujitsu_capture_source, | |
ae6b813a | 10639 | .unsol_event = alc262_fujitsu_unsol_event, |
ebc7a406 | 10640 | .init_hook = alc262_fujitsu_init_hook, |
834be88d | 10641 | }, |
9c7f852e TI |
10642 | [ALC262_HP_BPC] = { |
10643 | .mixers = { alc262_HP_BPC_mixer }, | |
10644 | .init_verbs = { alc262_HP_BPC_init_verbs }, | |
10645 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10646 | .dac_nids = alc262_dac_nids, | |
10647 | .hp_nid = 0x03, | |
10648 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10649 | .channel_mode = alc262_modes, | |
10650 | .input_mux = &alc262_HP_capture_source, | |
ce875f07 TI |
10651 | .unsol_event = alc262_hp_bpc_unsol_event, |
10652 | .init_hook = alc262_hp_bpc_automute, | |
f12ab1e0 | 10653 | }, |
cd7509a4 KY |
10654 | [ALC262_HP_BPC_D7000_WF] = { |
10655 | .mixers = { alc262_HP_BPC_WildWest_mixer }, | |
10656 | .init_verbs = { alc262_HP_BPC_WildWest_init_verbs }, | |
10657 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10658 | .dac_nids = alc262_dac_nids, | |
10659 | .hp_nid = 0x03, | |
10660 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10661 | .channel_mode = alc262_modes, | |
accbe498 | 10662 | .input_mux = &alc262_HP_D7000_capture_source, |
ce875f07 TI |
10663 | .unsol_event = alc262_hp_wildwest_unsol_event, |
10664 | .init_hook = alc262_hp_wildwest_automute, | |
f12ab1e0 | 10665 | }, |
cd7509a4 KY |
10666 | [ALC262_HP_BPC_D7000_WL] = { |
10667 | .mixers = { alc262_HP_BPC_WildWest_mixer, | |
10668 | alc262_HP_BPC_WildWest_option_mixer }, | |
10669 | .init_verbs = { alc262_HP_BPC_WildWest_init_verbs }, | |
10670 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10671 | .dac_nids = alc262_dac_nids, | |
10672 | .hp_nid = 0x03, | |
10673 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10674 | .channel_mode = alc262_modes, | |
accbe498 | 10675 | .input_mux = &alc262_HP_D7000_capture_source, |
ce875f07 TI |
10676 | .unsol_event = alc262_hp_wildwest_unsol_event, |
10677 | .init_hook = alc262_hp_wildwest_automute, | |
f12ab1e0 | 10678 | }, |
66d2a9d6 KY |
10679 | [ALC262_HP_TC_T5735] = { |
10680 | .mixers = { alc262_hp_t5735_mixer }, | |
10681 | .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs }, | |
10682 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10683 | .dac_nids = alc262_dac_nids, | |
10684 | .hp_nid = 0x03, | |
10685 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10686 | .channel_mode = alc262_modes, | |
10687 | .input_mux = &alc262_capture_source, | |
10688 | .unsol_event = alc262_hp_t5735_unsol_event, | |
10689 | .init_hook = alc262_hp_t5735_init_hook, | |
8c427226 KY |
10690 | }, |
10691 | [ALC262_HP_RP5700] = { | |
10692 | .mixers = { alc262_hp_rp5700_mixer }, | |
10693 | .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs }, | |
10694 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10695 | .dac_nids = alc262_dac_nids, | |
10696 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10697 | .channel_mode = alc262_modes, | |
10698 | .input_mux = &alc262_hp_rp5700_capture_source, | |
66d2a9d6 | 10699 | }, |
304dcaac TI |
10700 | [ALC262_BENQ_ED8] = { |
10701 | .mixers = { alc262_base_mixer }, | |
10702 | .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs }, | |
10703 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10704 | .dac_nids = alc262_dac_nids, | |
10705 | .hp_nid = 0x03, | |
10706 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10707 | .channel_mode = alc262_modes, | |
10708 | .input_mux = &alc262_capture_source, | |
f12ab1e0 | 10709 | }, |
272a527c KY |
10710 | [ALC262_SONY_ASSAMD] = { |
10711 | .mixers = { alc262_sony_mixer }, | |
10712 | .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs}, | |
10713 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10714 | .dac_nids = alc262_dac_nids, | |
10715 | .hp_nid = 0x02, | |
10716 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10717 | .channel_mode = alc262_modes, | |
10718 | .input_mux = &alc262_capture_source, | |
10719 | .unsol_event = alc262_hippo_unsol_event, | |
5b31954e | 10720 | .init_hook = alc262_hippo_automute, |
83c34218 KY |
10721 | }, |
10722 | [ALC262_BENQ_T31] = { | |
10723 | .mixers = { alc262_benq_t31_mixer }, | |
10724 | .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs }, | |
10725 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10726 | .dac_nids = alc262_dac_nids, | |
10727 | .hp_nid = 0x03, | |
10728 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10729 | .channel_mode = alc262_modes, | |
10730 | .input_mux = &alc262_capture_source, | |
10731 | .unsol_event = alc262_hippo_unsol_event, | |
5b31954e | 10732 | .init_hook = alc262_hippo_automute, |
ea1fb29a | 10733 | }, |
f651b50b | 10734 | [ALC262_ULTRA] = { |
f9e336f6 TI |
10735 | .mixers = { alc262_ultra_mixer }, |
10736 | .cap_mixer = alc262_ultra_capture_mixer, | |
bb9f76cd | 10737 | .init_verbs = { alc262_ultra_verbs }, |
f651b50b TD |
10738 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), |
10739 | .dac_nids = alc262_dac_nids, | |
f651b50b TD |
10740 | .num_channel_mode = ARRAY_SIZE(alc262_modes), |
10741 | .channel_mode = alc262_modes, | |
10742 | .input_mux = &alc262_ultra_capture_source, | |
bb9f76cd TI |
10743 | .adc_nids = alc262_adc_nids, /* ADC0 */ |
10744 | .capsrc_nids = alc262_capsrc_nids, | |
10745 | .num_adc_nids = 1, /* single ADC */ | |
f651b50b TD |
10746 | .unsol_event = alc262_ultra_unsol_event, |
10747 | .init_hook = alc262_ultra_automute, | |
10748 | }, | |
0e31daf7 J |
10749 | [ALC262_LENOVO_3000] = { |
10750 | .mixers = { alc262_lenovo_3000_mixer }, | |
10751 | .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs, | |
10752 | alc262_lenovo_3000_unsol_verbs }, | |
10753 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10754 | .dac_nids = alc262_dac_nids, | |
10755 | .hp_nid = 0x03, | |
10756 | .dig_out_nid = ALC262_DIGOUT_NID, | |
10757 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10758 | .channel_mode = alc262_modes, | |
10759 | .input_mux = &alc262_fujitsu_capture_source, | |
10760 | .unsol_event = alc262_lenovo_3000_unsol_event, | |
10761 | }, | |
e8f9ae2a PT |
10762 | [ALC262_NEC] = { |
10763 | .mixers = { alc262_nec_mixer }, | |
10764 | .init_verbs = { alc262_nec_verbs }, | |
10765 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10766 | .dac_nids = alc262_dac_nids, | |
10767 | .hp_nid = 0x03, | |
10768 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10769 | .channel_mode = alc262_modes, | |
10770 | .input_mux = &alc262_capture_source, | |
10771 | }, | |
4e555fe5 KY |
10772 | [ALC262_TOSHIBA_S06] = { |
10773 | .mixers = { alc262_toshiba_s06_mixer }, | |
10774 | .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs, | |
10775 | alc262_eapd_verbs }, | |
10776 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10777 | .capsrc_nids = alc262_dmic_capsrc_nids, | |
10778 | .dac_nids = alc262_dac_nids, | |
10779 | .adc_nids = alc262_dmic_adc_nids, /* ADC0 */ | |
10780 | .dig_out_nid = ALC262_DIGOUT_NID, | |
10781 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10782 | .channel_mode = alc262_modes, | |
10783 | .input_mux = &alc262_dmic_capture_source, | |
10784 | .unsol_event = alc262_toshiba_s06_unsol_event, | |
10785 | .init_hook = alc262_toshiba_s06_init_hook, | |
10786 | }, | |
9f99a638 HM |
10787 | [ALC262_TOSHIBA_RX1] = { |
10788 | .mixers = { alc262_toshiba_rx1_mixer }, | |
10789 | .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs }, | |
10790 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10791 | .dac_nids = alc262_dac_nids, | |
10792 | .hp_nid = 0x03, | |
10793 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10794 | .channel_mode = alc262_modes, | |
10795 | .input_mux = &alc262_capture_source, | |
10796 | .unsol_event = alc262_hippo_unsol_event, | |
10797 | .init_hook = alc262_hippo_automute, | |
10798 | }, | |
df694daa KY |
10799 | }; |
10800 | ||
10801 | static int patch_alc262(struct hda_codec *codec) | |
10802 | { | |
10803 | struct alc_spec *spec; | |
10804 | int board_config; | |
10805 | int err; | |
10806 | ||
dc041e0b | 10807 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
df694daa KY |
10808 | if (spec == NULL) |
10809 | return -ENOMEM; | |
10810 | ||
10811 | codec->spec = spec; | |
10812 | #if 0 | |
f12ab1e0 TI |
10813 | /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is |
10814 | * under-run | |
10815 | */ | |
df694daa KY |
10816 | { |
10817 | int tmp; | |
10818 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); | |
10819 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); | |
10820 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); | |
10821 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); | |
10822 | } | |
10823 | #endif | |
10824 | ||
2c3bf9ab TI |
10825 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
10826 | ||
f5fcc13c TI |
10827 | board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST, |
10828 | alc262_models, | |
10829 | alc262_cfg_tbl); | |
cd7509a4 | 10830 | |
f5fcc13c | 10831 | if (board_config < 0) { |
9c7f852e TI |
10832 | printk(KERN_INFO "hda_codec: Unknown model for ALC262, " |
10833 | "trying auto-probe from BIOS...\n"); | |
df694daa KY |
10834 | board_config = ALC262_AUTO; |
10835 | } | |
10836 | ||
10837 | if (board_config == ALC262_AUTO) { | |
10838 | /* automatic parse from the BIOS config */ | |
10839 | err = alc262_parse_auto_config(codec); | |
10840 | if (err < 0) { | |
10841 | alc_free(codec); | |
10842 | return err; | |
f12ab1e0 | 10843 | } else if (!err) { |
9c7f852e TI |
10844 | printk(KERN_INFO |
10845 | "hda_codec: Cannot set up configuration " | |
10846 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
10847 | board_config = ALC262_BASIC; |
10848 | } | |
10849 | } | |
10850 | ||
10851 | if (board_config != ALC262_AUTO) | |
10852 | setup_preset(spec, &alc262_presets[board_config]); | |
10853 | ||
10854 | spec->stream_name_analog = "ALC262 Analog"; | |
10855 | spec->stream_analog_playback = &alc262_pcm_analog_playback; | |
10856 | spec->stream_analog_capture = &alc262_pcm_analog_capture; | |
ea1fb29a | 10857 | |
df694daa KY |
10858 | spec->stream_name_digital = "ALC262 Digital"; |
10859 | spec->stream_digital_playback = &alc262_pcm_digital_playback; | |
10860 | spec->stream_digital_capture = &alc262_pcm_digital_capture; | |
10861 | ||
54cbc9ab | 10862 | spec->is_mix_capture = 1; |
f12ab1e0 | 10863 | if (!spec->adc_nids && spec->input_mux) { |
df694daa | 10864 | /* check whether NID 0x07 is valid */ |
4a471b7d TI |
10865 | unsigned int wcap = get_wcaps(codec, 0x07); |
10866 | ||
f12ab1e0 TI |
10867 | /* get type */ |
10868 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
df694daa KY |
10869 | if (wcap != AC_WID_AUD_IN) { |
10870 | spec->adc_nids = alc262_adc_nids_alt; | |
10871 | spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt); | |
88c71a99 | 10872 | spec->capsrc_nids = alc262_capsrc_nids_alt; |
df694daa KY |
10873 | } else { |
10874 | spec->adc_nids = alc262_adc_nids; | |
10875 | spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids); | |
88c71a99 | 10876 | spec->capsrc_nids = alc262_capsrc_nids; |
df694daa KY |
10877 | } |
10878 | } | |
f9e336f6 TI |
10879 | if (!spec->cap_mixer) |
10880 | set_capture_mixer(spec); | |
df694daa | 10881 | |
2134ea4f TI |
10882 | spec->vmaster_nid = 0x0c; |
10883 | ||
df694daa KY |
10884 | codec->patch_ops = alc_patch_ops; |
10885 | if (board_config == ALC262_AUTO) | |
ae6b813a | 10886 | spec->init_hook = alc262_auto_init; |
cb53c626 TI |
10887 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
10888 | if (!spec->loopback.amplist) | |
10889 | spec->loopback.amplist = alc262_loopbacks; | |
10890 | #endif | |
daead538 | 10891 | codec->proc_widget_hook = print_realtek_coef; |
ea1fb29a | 10892 | |
df694daa KY |
10893 | return 0; |
10894 | } | |
10895 | ||
a361d84b KY |
10896 | /* |
10897 | * ALC268 channel source setting (2 channel) | |
10898 | */ | |
10899 | #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID | |
10900 | #define alc268_modes alc260_modes | |
ea1fb29a | 10901 | |
a361d84b KY |
10902 | static hda_nid_t alc268_dac_nids[2] = { |
10903 | /* front, hp */ | |
10904 | 0x02, 0x03 | |
10905 | }; | |
10906 | ||
10907 | static hda_nid_t alc268_adc_nids[2] = { | |
10908 | /* ADC0-1 */ | |
10909 | 0x08, 0x07 | |
10910 | }; | |
10911 | ||
10912 | static hda_nid_t alc268_adc_nids_alt[1] = { | |
10913 | /* ADC0 */ | |
10914 | 0x08 | |
10915 | }; | |
10916 | ||
e1406348 TI |
10917 | static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 }; |
10918 | ||
a361d84b KY |
10919 | static struct snd_kcontrol_new alc268_base_mixer[] = { |
10920 | /* output mixer control */ | |
10921 | HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT), | |
10922 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
10923 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT), | |
10924 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
33bf17ab TI |
10925 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
10926 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
10927 | HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT), | |
a361d84b KY |
10928 | { } |
10929 | }; | |
10930 | ||
aef9d318 TI |
10931 | /* bind Beep switches of both NID 0x0f and 0x10 */ |
10932 | static struct hda_bind_ctls alc268_bind_beep_sw = { | |
10933 | .ops = &snd_hda_bind_sw, | |
10934 | .values = { | |
10935 | HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT), | |
10936 | HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT), | |
10937 | 0 | |
10938 | }, | |
10939 | }; | |
10940 | ||
10941 | static struct snd_kcontrol_new alc268_beep_mixer[] = { | |
10942 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT), | |
10943 | HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw), | |
10944 | { } | |
10945 | }; | |
10946 | ||
d1a991a6 KY |
10947 | static struct hda_verb alc268_eapd_verbs[] = { |
10948 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
10949 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
10950 | { } | |
10951 | }; | |
10952 | ||
d273809e TI |
10953 | /* Toshiba specific */ |
10954 | #define alc268_toshiba_automute alc262_hippo_automute | |
10955 | ||
10956 | static struct hda_verb alc268_toshiba_verbs[] = { | |
10957 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
10958 | { } /* end */ | |
10959 | }; | |
10960 | ||
8ef355da KY |
10961 | static struct hda_input_mux alc268_acer_lc_capture_source = { |
10962 | .num_items = 2, | |
10963 | .items = { | |
10964 | { "i-Mic", 0x6 }, | |
10965 | { "E-Mic", 0x0 }, | |
10966 | }, | |
10967 | }; | |
10968 | ||
d273809e | 10969 | /* Acer specific */ |
889c4395 | 10970 | /* bind volumes of both NID 0x02 and 0x03 */ |
6bc96857 TI |
10971 | static struct hda_bind_ctls alc268_acer_bind_master_vol = { |
10972 | .ops = &snd_hda_bind_vol, | |
10973 | .values = { | |
10974 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), | |
10975 | HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT), | |
10976 | 0 | |
10977 | }, | |
10978 | }; | |
10979 | ||
889c4395 TI |
10980 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
10981 | static void alc268_acer_automute(struct hda_codec *codec, int force) | |
10982 | { | |
10983 | struct alc_spec *spec = codec->spec; | |
10984 | unsigned int mute; | |
10985 | ||
10986 | if (force || !spec->sense_updated) { | |
10987 | unsigned int present; | |
10988 | present = snd_hda_codec_read(codec, 0x14, 0, | |
10989 | AC_VERB_GET_PIN_SENSE, 0); | |
10990 | spec->jack_present = (present & 0x80000000) != 0; | |
10991 | spec->sense_updated = 1; | |
10992 | } | |
10993 | if (spec->jack_present) | |
10994 | mute = HDA_AMP_MUTE; /* mute internal speaker */ | |
10995 | else /* unmute internal speaker if necessary */ | |
10996 | mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); | |
10997 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
10998 | HDA_AMP_MUTE, mute); | |
10999 | } | |
11000 | ||
11001 | ||
11002 | /* bind hp and internal speaker mute (with plug check) */ | |
11003 | static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol, | |
11004 | struct snd_ctl_elem_value *ucontrol) | |
11005 | { | |
11006 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
11007 | long *valp = ucontrol->value.integer.value; | |
11008 | int change; | |
11009 | ||
11010 | change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, | |
11011 | HDA_AMP_MUTE, | |
11012 | valp[0] ? 0 : HDA_AMP_MUTE); | |
11013 | change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, | |
11014 | HDA_AMP_MUTE, | |
11015 | valp[1] ? 0 : HDA_AMP_MUTE); | |
11016 | if (change) | |
11017 | alc268_acer_automute(codec, 0); | |
11018 | return change; | |
11019 | } | |
d273809e | 11020 | |
8ef355da KY |
11021 | static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = { |
11022 | /* output mixer control */ | |
11023 | HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol), | |
11024 | { | |
11025 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11026 | .name = "Master Playback Switch", | |
11027 | .info = snd_hda_mixer_amp_switch_info, | |
11028 | .get = snd_hda_mixer_amp_switch_get, | |
11029 | .put = alc268_acer_master_sw_put, | |
11030 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
11031 | }, | |
11032 | HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT), | |
11033 | { } | |
11034 | }; | |
11035 | ||
d273809e TI |
11036 | static struct snd_kcontrol_new alc268_acer_mixer[] = { |
11037 | /* output mixer control */ | |
11038 | HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol), | |
11039 | { | |
11040 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11041 | .name = "Master Playback Switch", | |
11042 | .info = snd_hda_mixer_amp_switch_info, | |
11043 | .get = snd_hda_mixer_amp_switch_get, | |
11044 | .put = alc268_acer_master_sw_put, | |
11045 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
11046 | }, | |
33bf17ab TI |
11047 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
11048 | HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT), | |
11049 | HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT), | |
d273809e TI |
11050 | { } |
11051 | }; | |
11052 | ||
c238b4f4 TI |
11053 | static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = { |
11054 | /* output mixer control */ | |
11055 | HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol), | |
11056 | { | |
11057 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11058 | .name = "Master Playback Switch", | |
11059 | .info = snd_hda_mixer_amp_switch_info, | |
11060 | .get = snd_hda_mixer_amp_switch_get, | |
11061 | .put = alc268_acer_master_sw_put, | |
11062 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
11063 | }, | |
11064 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
11065 | HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT), | |
11066 | { } | |
11067 | }; | |
11068 | ||
8ef355da KY |
11069 | static struct hda_verb alc268_acer_aspire_one_verbs[] = { |
11070 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
11071 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
11072 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
11073 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
11074 | {0x23, AC_VERB_SET_CONNECT_SEL, 0x06}, | |
11075 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017}, | |
11076 | { } | |
11077 | }; | |
11078 | ||
d273809e | 11079 | static struct hda_verb alc268_acer_verbs[] = { |
0ccb541c TI |
11080 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */ |
11081 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
d273809e TI |
11082 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
11083 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
0ccb541c TI |
11084 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
11085 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
d273809e TI |
11086 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
11087 | { } | |
11088 | }; | |
11089 | ||
11090 | /* unsolicited event for HP jack sensing */ | |
11091 | static void alc268_toshiba_unsol_event(struct hda_codec *codec, | |
11092 | unsigned int res) | |
11093 | { | |
889c4395 | 11094 | if ((res >> 26) != ALC880_HP_EVENT) |
d273809e TI |
11095 | return; |
11096 | alc268_toshiba_automute(codec); | |
11097 | } | |
11098 | ||
11099 | static void alc268_acer_unsol_event(struct hda_codec *codec, | |
11100 | unsigned int res) | |
11101 | { | |
889c4395 | 11102 | if ((res >> 26) != ALC880_HP_EVENT) |
d273809e TI |
11103 | return; |
11104 | alc268_acer_automute(codec, 1); | |
11105 | } | |
11106 | ||
889c4395 TI |
11107 | static void alc268_acer_init_hook(struct hda_codec *codec) |
11108 | { | |
11109 | alc268_acer_automute(codec, 1); | |
11110 | } | |
11111 | ||
8ef355da KY |
11112 | /* toggle speaker-output according to the hp-jack state */ |
11113 | static void alc268_aspire_one_speaker_automute(struct hda_codec *codec) | |
11114 | { | |
11115 | unsigned int present; | |
11116 | unsigned char bits; | |
11117 | ||
11118 | present = snd_hda_codec_read(codec, 0x15, 0, | |
11119 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
11120 | bits = present ? AMP_IN_MUTE(0) : 0; | |
11121 | snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0, | |
11122 | AMP_IN_MUTE(0), bits); | |
11123 | snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1, | |
11124 | AMP_IN_MUTE(0), bits); | |
11125 | } | |
11126 | ||
11127 | ||
11128 | static void alc268_acer_mic_automute(struct hda_codec *codec) | |
11129 | { | |
11130 | unsigned int present; | |
11131 | ||
11132 | present = snd_hda_codec_read(codec, 0x18, 0, | |
11133 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
11134 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL, | |
11135 | present ? 0x0 : 0x6); | |
11136 | } | |
11137 | ||
11138 | static void alc268_acer_lc_unsol_event(struct hda_codec *codec, | |
11139 | unsigned int res) | |
11140 | { | |
11141 | if ((res >> 26) == ALC880_HP_EVENT) | |
11142 | alc268_aspire_one_speaker_automute(codec); | |
11143 | if ((res >> 26) == ALC880_MIC_EVENT) | |
11144 | alc268_acer_mic_automute(codec); | |
11145 | } | |
11146 | ||
11147 | static void alc268_acer_lc_init_hook(struct hda_codec *codec) | |
11148 | { | |
11149 | alc268_aspire_one_speaker_automute(codec); | |
11150 | alc268_acer_mic_automute(codec); | |
11151 | } | |
11152 | ||
3866f0b0 TI |
11153 | static struct snd_kcontrol_new alc268_dell_mixer[] = { |
11154 | /* output mixer control */ | |
11155 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
11156 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
11157 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
11158 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
11159 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
11160 | HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT), | |
11161 | { } | |
11162 | }; | |
11163 | ||
11164 | static struct hda_verb alc268_dell_verbs[] = { | |
11165 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
11166 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
11167 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
11168 | { } | |
11169 | }; | |
11170 | ||
11171 | /* mute/unmute internal speaker according to the hp jack and mute state */ | |
11172 | static void alc268_dell_automute(struct hda_codec *codec) | |
11173 | { | |
11174 | unsigned int present; | |
11175 | unsigned int mute; | |
11176 | ||
11177 | present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0); | |
11178 | if (present & 0x80000000) | |
11179 | mute = HDA_AMP_MUTE; | |
11180 | else | |
11181 | mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0); | |
11182 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
11183 | HDA_AMP_MUTE, mute); | |
11184 | } | |
11185 | ||
11186 | static void alc268_dell_unsol_event(struct hda_codec *codec, | |
11187 | unsigned int res) | |
11188 | { | |
11189 | if ((res >> 26) != ALC880_HP_EVENT) | |
11190 | return; | |
11191 | alc268_dell_automute(codec); | |
11192 | } | |
11193 | ||
11194 | #define alc268_dell_init_hook alc268_dell_automute | |
11195 | ||
eb5a6621 HRK |
11196 | static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = { |
11197 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT), | |
11198 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
11199 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT), | |
11200 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
11201 | HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT), | |
11202 | HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT), | |
11203 | HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT), | |
11204 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
11205 | { } | |
11206 | }; | |
11207 | ||
11208 | static struct hda_verb alc267_quanta_il1_verbs[] = { | |
11209 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
11210 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, | |
11211 | { } | |
11212 | }; | |
11213 | ||
11214 | static void alc267_quanta_il1_hp_automute(struct hda_codec *codec) | |
11215 | { | |
11216 | unsigned int present; | |
11217 | ||
11218 | present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0) | |
11219 | & AC_PINSENSE_PRESENCE; | |
11220 | snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
11221 | present ? 0 : PIN_OUT); | |
11222 | } | |
11223 | ||
11224 | static void alc267_quanta_il1_mic_automute(struct hda_codec *codec) | |
11225 | { | |
11226 | unsigned int present; | |
11227 | ||
11228 | present = snd_hda_codec_read(codec, 0x18, 0, | |
11229 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
11230 | snd_hda_codec_write(codec, 0x23, 0, | |
11231 | AC_VERB_SET_CONNECT_SEL, | |
11232 | present ? 0x00 : 0x01); | |
11233 | } | |
11234 | ||
11235 | static void alc267_quanta_il1_automute(struct hda_codec *codec) | |
11236 | { | |
11237 | alc267_quanta_il1_hp_automute(codec); | |
11238 | alc267_quanta_il1_mic_automute(codec); | |
11239 | } | |
11240 | ||
11241 | static void alc267_quanta_il1_unsol_event(struct hda_codec *codec, | |
11242 | unsigned int res) | |
11243 | { | |
11244 | switch (res >> 26) { | |
11245 | case ALC880_HP_EVENT: | |
11246 | alc267_quanta_il1_hp_automute(codec); | |
11247 | break; | |
11248 | case ALC880_MIC_EVENT: | |
11249 | alc267_quanta_il1_mic_automute(codec); | |
11250 | break; | |
11251 | } | |
11252 | } | |
11253 | ||
a361d84b KY |
11254 | /* |
11255 | * generic initialization of ADC, input mixers and output mixers | |
11256 | */ | |
11257 | static struct hda_verb alc268_base_init_verbs[] = { | |
11258 | /* Unmute DAC0-1 and set vol = 0 */ | |
11259 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
11260 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11261 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11262 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
11263 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11264 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11265 | ||
11266 | /* | |
11267 | * Set up output mixers (0x0c - 0x0e) | |
11268 | */ | |
11269 | /* set vol=0 to output mixers */ | |
11270 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11271 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11272 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
11273 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
11274 | ||
11275 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11276 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11277 | ||
11278 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
11279 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
11280 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
11281 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
11282 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
11283 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
11284 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
11285 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
11286 | ||
11287 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11288 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11289 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11290 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11291 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11292 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11293 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
aef9d318 TI |
11294 | |
11295 | /* set PCBEEP vol = 0, mute connections */ | |
11296 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11297 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
11298 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
a361d84b | 11299 | |
a9b3aa8a | 11300 | /* Unmute Selector 23h,24h and set the default input to mic-in */ |
ea1fb29a | 11301 | |
a9b3aa8a JZ |
11302 | {0x23, AC_VERB_SET_CONNECT_SEL, 0x00}, |
11303 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11304 | {0x24, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
11305 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
a361d84b | 11306 | |
a361d84b KY |
11307 | { } |
11308 | }; | |
11309 | ||
11310 | /* | |
11311 | * generic initialization of ADC, input mixers and output mixers | |
11312 | */ | |
11313 | static struct hda_verb alc268_volume_init_verbs[] = { | |
11314 | /* set output DAC */ | |
11315 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11316 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11317 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11318 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11319 | ||
11320 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
11321 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
11322 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
11323 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
11324 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
11325 | ||
11326 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
11327 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11328 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11329 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11330 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11331 | ||
11332 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11333 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11334 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11335 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11336 | ||
aef9d318 TI |
11337 | /* set PCBEEP vol = 0, mute connections */ |
11338 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11339 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
11340 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
a361d84b KY |
11341 | |
11342 | { } | |
11343 | }; | |
11344 | ||
a361d84b KY |
11345 | static struct snd_kcontrol_new alc268_capture_alt_mixer[] = { |
11346 | HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), | |
11347 | HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), | |
11348 | { | |
11349 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11350 | /* The multiple "Capture Source" controls confuse alsamixer | |
11351 | * So call somewhat different.. | |
a361d84b KY |
11352 | */ |
11353 | /* .name = "Capture Source", */ | |
11354 | .name = "Input Source", | |
11355 | .count = 1, | |
54cbc9ab TI |
11356 | .info = alc_mux_enum_info, |
11357 | .get = alc_mux_enum_get, | |
11358 | .put = alc_mux_enum_put, | |
a361d84b KY |
11359 | }, |
11360 | { } /* end */ | |
11361 | }; | |
11362 | ||
11363 | static struct snd_kcontrol_new alc268_capture_mixer[] = { | |
11364 | HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), | |
11365 | HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), | |
11366 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT), | |
11367 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT), | |
11368 | { | |
11369 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11370 | /* The multiple "Capture Source" controls confuse alsamixer | |
11371 | * So call somewhat different.. | |
a361d84b KY |
11372 | */ |
11373 | /* .name = "Capture Source", */ | |
11374 | .name = "Input Source", | |
11375 | .count = 2, | |
54cbc9ab TI |
11376 | .info = alc_mux_enum_info, |
11377 | .get = alc_mux_enum_get, | |
11378 | .put = alc_mux_enum_put, | |
a361d84b KY |
11379 | }, |
11380 | { } /* end */ | |
11381 | }; | |
11382 | ||
11383 | static struct hda_input_mux alc268_capture_source = { | |
11384 | .num_items = 4, | |
11385 | .items = { | |
11386 | { "Mic", 0x0 }, | |
11387 | { "Front Mic", 0x1 }, | |
11388 | { "Line", 0x2 }, | |
11389 | { "CD", 0x3 }, | |
11390 | }, | |
11391 | }; | |
11392 | ||
0ccb541c | 11393 | static struct hda_input_mux alc268_acer_capture_source = { |
c238b4f4 TI |
11394 | .num_items = 3, |
11395 | .items = { | |
11396 | { "Mic", 0x0 }, | |
11397 | { "Internal Mic", 0x1 }, | |
11398 | { "Line", 0x2 }, | |
11399 | }, | |
11400 | }; | |
11401 | ||
11402 | static struct hda_input_mux alc268_acer_dmic_capture_source = { | |
0ccb541c TI |
11403 | .num_items = 3, |
11404 | .items = { | |
11405 | { "Mic", 0x0 }, | |
11406 | { "Internal Mic", 0x6 }, | |
11407 | { "Line", 0x2 }, | |
11408 | }, | |
11409 | }; | |
11410 | ||
86c53bd2 JW |
11411 | #ifdef CONFIG_SND_DEBUG |
11412 | static struct snd_kcontrol_new alc268_test_mixer[] = { | |
86c53bd2 JW |
11413 | /* Volume widgets */ |
11414 | HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
11415 | HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
11416 | HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
11417 | HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT), | |
11418 | HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT), | |
11419 | HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT), | |
11420 | HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT), | |
11421 | HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT), | |
11422 | HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT), | |
11423 | HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT), | |
11424 | HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT), | |
11425 | HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT), | |
11426 | HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT), | |
f0747ee6 TI |
11427 | /* The below appears problematic on some hardwares */ |
11428 | /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/ | |
86c53bd2 JW |
11429 | HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT), |
11430 | HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT), | |
11431 | HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT), | |
11432 | HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT), | |
11433 | ||
11434 | /* Modes for retasking pin widgets */ | |
11435 | ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT), | |
11436 | ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT), | |
11437 | ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT), | |
11438 | ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT), | |
11439 | ||
11440 | /* Controls for GPIO pins, assuming they are configured as outputs */ | |
11441 | ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01), | |
11442 | ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02), | |
11443 | ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04), | |
11444 | ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08), | |
11445 | ||
11446 | /* Switches to allow the digital SPDIF output pin to be enabled. | |
11447 | * The ALC268 does not have an SPDIF input. | |
11448 | */ | |
11449 | ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01), | |
11450 | ||
11451 | /* A switch allowing EAPD to be enabled. Some laptops seem to use | |
11452 | * this output to turn on an external amplifier. | |
11453 | */ | |
11454 | ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02), | |
11455 | ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02), | |
11456 | ||
11457 | { } /* end */ | |
11458 | }; | |
11459 | #endif | |
11460 | ||
a361d84b KY |
11461 | /* create input playback/capture controls for the given pin */ |
11462 | static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid, | |
11463 | const char *ctlname, int idx) | |
11464 | { | |
11465 | char name[32]; | |
11466 | int err; | |
11467 | ||
11468 | sprintf(name, "%s Playback Volume", ctlname); | |
11469 | if (nid == 0x14) { | |
11470 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
11471 | HDA_COMPOSE_AMP_VAL(0x02, 3, idx, | |
11472 | HDA_OUTPUT)); | |
11473 | if (err < 0) | |
11474 | return err; | |
11475 | } else if (nid == 0x15) { | |
11476 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
11477 | HDA_COMPOSE_AMP_VAL(0x03, 3, idx, | |
11478 | HDA_OUTPUT)); | |
11479 | if (err < 0) | |
11480 | return err; | |
11481 | } else | |
11482 | return -1; | |
11483 | sprintf(name, "%s Playback Switch", ctlname); | |
11484 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | |
11485 | HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT)); | |
11486 | if (err < 0) | |
11487 | return err; | |
11488 | return 0; | |
11489 | } | |
11490 | ||
11491 | /* add playback controls from the parsed DAC table */ | |
11492 | static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec, | |
11493 | const struct auto_pin_cfg *cfg) | |
11494 | { | |
11495 | hda_nid_t nid; | |
11496 | int err; | |
11497 | ||
11498 | spec->multiout.num_dacs = 2; /* only use one dac */ | |
11499 | spec->multiout.dac_nids = spec->private_dac_nids; | |
11500 | spec->multiout.dac_nids[0] = 2; | |
11501 | spec->multiout.dac_nids[1] = 3; | |
11502 | ||
11503 | nid = cfg->line_out_pins[0]; | |
11504 | if (nid) | |
ea1fb29a | 11505 | alc268_new_analog_output(spec, nid, "Front", 0); |
a361d84b KY |
11506 | |
11507 | nid = cfg->speaker_pins[0]; | |
11508 | if (nid == 0x1d) { | |
11509 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
11510 | "Speaker Playback Volume", | |
11511 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | |
11512 | if (err < 0) | |
11513 | return err; | |
11514 | } | |
11515 | nid = cfg->hp_pins[0]; | |
11516 | if (nid) | |
11517 | alc268_new_analog_output(spec, nid, "Headphone", 0); | |
11518 | ||
11519 | nid = cfg->line_out_pins[1] | cfg->line_out_pins[2]; | |
11520 | if (nid == 0x16) { | |
11521 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
11522 | "Mono Playback Switch", | |
11523 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT)); | |
11524 | if (err < 0) | |
11525 | return err; | |
11526 | } | |
ea1fb29a | 11527 | return 0; |
a361d84b KY |
11528 | } |
11529 | ||
11530 | /* create playback/capture controls for input pins */ | |
11531 | static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec, | |
11532 | const struct auto_pin_cfg *cfg) | |
11533 | { | |
11534 | struct hda_input_mux *imux = &spec->private_imux; | |
11535 | int i, idx1; | |
11536 | ||
11537 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
11538 | switch(cfg->input_pins[i]) { | |
11539 | case 0x18: | |
11540 | idx1 = 0; /* Mic 1 */ | |
11541 | break; | |
11542 | case 0x19: | |
11543 | idx1 = 1; /* Mic 2 */ | |
11544 | break; | |
11545 | case 0x1a: | |
11546 | idx1 = 2; /* Line In */ | |
11547 | break; | |
ea1fb29a | 11548 | case 0x1c: |
a361d84b KY |
11549 | idx1 = 3; /* CD */ |
11550 | break; | |
7194cae6 TI |
11551 | case 0x12: |
11552 | case 0x13: | |
11553 | idx1 = 6; /* digital mics */ | |
11554 | break; | |
a361d84b KY |
11555 | default: |
11556 | continue; | |
11557 | } | |
11558 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; | |
11559 | imux->items[imux->num_items].index = idx1; | |
ea1fb29a | 11560 | imux->num_items++; |
a361d84b KY |
11561 | } |
11562 | return 0; | |
11563 | } | |
11564 | ||
11565 | static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec) | |
11566 | { | |
11567 | struct alc_spec *spec = codec->spec; | |
11568 | hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0]; | |
11569 | hda_nid_t hp_nid = spec->autocfg.hp_pins[0]; | |
11570 | hda_nid_t line_nid = spec->autocfg.line_out_pins[0]; | |
11571 | unsigned int dac_vol1, dac_vol2; | |
11572 | ||
11573 | if (speaker_nid) { | |
11574 | snd_hda_codec_write(codec, speaker_nid, 0, | |
11575 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | |
11576 | snd_hda_codec_write(codec, 0x0f, 0, | |
11577 | AC_VERB_SET_AMP_GAIN_MUTE, | |
11578 | AMP_IN_UNMUTE(1)); | |
11579 | snd_hda_codec_write(codec, 0x10, 0, | |
11580 | AC_VERB_SET_AMP_GAIN_MUTE, | |
11581 | AMP_IN_UNMUTE(1)); | |
11582 | } else { | |
11583 | snd_hda_codec_write(codec, 0x0f, 0, | |
11584 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)); | |
11585 | snd_hda_codec_write(codec, 0x10, 0, | |
11586 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)); | |
11587 | } | |
11588 | ||
11589 | dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */ | |
ea1fb29a | 11590 | if (line_nid == 0x14) |
a361d84b KY |
11591 | dac_vol2 = AMP_OUT_ZERO; |
11592 | else if (line_nid == 0x15) | |
11593 | dac_vol1 = AMP_OUT_ZERO; | |
ea1fb29a | 11594 | if (hp_nid == 0x14) |
a361d84b KY |
11595 | dac_vol2 = AMP_OUT_ZERO; |
11596 | else if (hp_nid == 0x15) | |
11597 | dac_vol1 = AMP_OUT_ZERO; | |
11598 | if (line_nid != 0x16 || hp_nid != 0x16 || | |
11599 | spec->autocfg.line_out_pins[1] != 0x16 || | |
11600 | spec->autocfg.line_out_pins[2] != 0x16) | |
11601 | dac_vol1 = dac_vol2 = AMP_OUT_ZERO; | |
11602 | ||
11603 | snd_hda_codec_write(codec, 0x02, 0, | |
11604 | AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1); | |
11605 | snd_hda_codec_write(codec, 0x03, 0, | |
11606 | AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2); | |
11607 | } | |
11608 | ||
11609 | /* pcm configuration: identiacal with ALC880 */ | |
11610 | #define alc268_pcm_analog_playback alc880_pcm_analog_playback | |
11611 | #define alc268_pcm_analog_capture alc880_pcm_analog_capture | |
6330079f | 11612 | #define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture |
a361d84b KY |
11613 | #define alc268_pcm_digital_playback alc880_pcm_digital_playback |
11614 | ||
11615 | /* | |
11616 | * BIOS auto configuration | |
11617 | */ | |
11618 | static int alc268_parse_auto_config(struct hda_codec *codec) | |
11619 | { | |
11620 | struct alc_spec *spec = codec->spec; | |
11621 | int err; | |
11622 | static hda_nid_t alc268_ignore[] = { 0 }; | |
11623 | ||
11624 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | |
11625 | alc268_ignore); | |
11626 | if (err < 0) | |
11627 | return err; | |
11628 | if (!spec->autocfg.line_outs) | |
11629 | return 0; /* can't find valid BIOS pin config */ | |
11630 | ||
11631 | err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
11632 | if (err < 0) | |
11633 | return err; | |
11634 | err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
11635 | if (err < 0) | |
11636 | return err; | |
11637 | ||
11638 | spec->multiout.max_channels = 2; | |
11639 | ||
11640 | /* digital only support output */ | |
11641 | if (spec->autocfg.dig_out_pin) | |
11642 | spec->multiout.dig_out_nid = ALC268_DIGOUT_NID; | |
11643 | ||
603c4019 | 11644 | if (spec->kctls.list) |
d88897ea | 11645 | add_mixer(spec, spec->kctls.list); |
a361d84b | 11646 | |
aef9d318 | 11647 | if (spec->autocfg.speaker_pins[0] != 0x1d) |
d88897ea | 11648 | add_mixer(spec, alc268_beep_mixer); |
aef9d318 | 11649 | |
d88897ea | 11650 | add_verb(spec, alc268_volume_init_verbs); |
a361d84b KY |
11651 | spec->num_mux_defs = 1; |
11652 | spec->input_mux = &spec->private_imux; | |
11653 | ||
776e184e TI |
11654 | err = alc_auto_add_mic_boost(codec); |
11655 | if (err < 0) | |
11656 | return err; | |
11657 | ||
e044c39a | 11658 | store_pin_configs(codec); |
a361d84b KY |
11659 | return 1; |
11660 | } | |
11661 | ||
11662 | #define alc268_auto_init_multi_out alc882_auto_init_multi_out | |
11663 | #define alc268_auto_init_hp_out alc882_auto_init_hp_out | |
11664 | #define alc268_auto_init_analog_input alc882_auto_init_analog_input | |
11665 | ||
11666 | /* init callback for auto-configuration model -- overriding the default init */ | |
11667 | static void alc268_auto_init(struct hda_codec *codec) | |
11668 | { | |
f6c7e546 | 11669 | struct alc_spec *spec = codec->spec; |
a361d84b KY |
11670 | alc268_auto_init_multi_out(codec); |
11671 | alc268_auto_init_hp_out(codec); | |
11672 | alc268_auto_init_mono_speaker_out(codec); | |
11673 | alc268_auto_init_analog_input(codec); | |
f6c7e546 | 11674 | if (spec->unsol_event) |
7fb0d78f | 11675 | alc_inithook(codec); |
a361d84b KY |
11676 | } |
11677 | ||
11678 | /* | |
11679 | * configuration and preset | |
11680 | */ | |
11681 | static const char *alc268_models[ALC268_MODEL_LAST] = { | |
eb5a6621 | 11682 | [ALC267_QUANTA_IL1] = "quanta-il1", |
a361d84b | 11683 | [ALC268_3ST] = "3stack", |
983f8ae4 | 11684 | [ALC268_TOSHIBA] = "toshiba", |
d273809e | 11685 | [ALC268_ACER] = "acer", |
c238b4f4 | 11686 | [ALC268_ACER_DMIC] = "acer-dmic", |
8ef355da | 11687 | [ALC268_ACER_ASPIRE_ONE] = "acer-aspire", |
3866f0b0 | 11688 | [ALC268_DELL] = "dell", |
f12462c5 | 11689 | [ALC268_ZEPTO] = "zepto", |
86c53bd2 JW |
11690 | #ifdef CONFIG_SND_DEBUG |
11691 | [ALC268_TEST] = "test", | |
11692 | #endif | |
a361d84b KY |
11693 | [ALC268_AUTO] = "auto", |
11694 | }; | |
11695 | ||
11696 | static struct snd_pci_quirk alc268_cfg_tbl[] = { | |
a0b8f7d8 | 11697 | SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER), |
ac3e3741 | 11698 | SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER), |
dafc8357 | 11699 | SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER), |
ac3e3741 | 11700 | SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER), |
29a52c24 | 11701 | SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER), |
8ef355da KY |
11702 | SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One", |
11703 | ALC268_ACER_ASPIRE_ONE), | |
3866f0b0 | 11704 | SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL), |
57d13927 | 11705 | SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL), |
ac3e3741 | 11706 | SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA), |
a361d84b | 11707 | SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST), |
d1a991a6 | 11708 | SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA), |
8e7f00f9 | 11709 | SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA), |
2346d0cd | 11710 | SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA), |
378bd6a5 | 11711 | SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA), |
b875bf3a | 11712 | SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER), |
eb5a6621 | 11713 | SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1), |
f12462c5 | 11714 | SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO), |
a361d84b KY |
11715 | {} |
11716 | }; | |
11717 | ||
11718 | static struct alc_config_preset alc268_presets[] = { | |
eb5a6621 HRK |
11719 | [ALC267_QUANTA_IL1] = { |
11720 | .mixers = { alc267_quanta_il1_mixer }, | |
11721 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, | |
11722 | alc267_quanta_il1_verbs }, | |
11723 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11724 | .dac_nids = alc268_dac_nids, | |
11725 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11726 | .adc_nids = alc268_adc_nids_alt, | |
11727 | .hp_nid = 0x03, | |
11728 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11729 | .channel_mode = alc268_modes, | |
11730 | .input_mux = &alc268_capture_source, | |
11731 | .unsol_event = alc267_quanta_il1_unsol_event, | |
11732 | .init_hook = alc267_quanta_il1_automute, | |
11733 | }, | |
a361d84b | 11734 | [ALC268_3ST] = { |
aef9d318 TI |
11735 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, |
11736 | alc268_beep_mixer }, | |
a361d84b KY |
11737 | .init_verbs = { alc268_base_init_verbs }, |
11738 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11739 | .dac_nids = alc268_dac_nids, | |
11740 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11741 | .adc_nids = alc268_adc_nids_alt, | |
e1406348 | 11742 | .capsrc_nids = alc268_capsrc_nids, |
a361d84b KY |
11743 | .hp_nid = 0x03, |
11744 | .dig_out_nid = ALC268_DIGOUT_NID, | |
11745 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11746 | .channel_mode = alc268_modes, | |
11747 | .input_mux = &alc268_capture_source, | |
11748 | }, | |
d1a991a6 | 11749 | [ALC268_TOSHIBA] = { |
aef9d318 TI |
11750 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, |
11751 | alc268_beep_mixer }, | |
d273809e TI |
11752 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
11753 | alc268_toshiba_verbs }, | |
d1a991a6 KY |
11754 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), |
11755 | .dac_nids = alc268_dac_nids, | |
11756 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11757 | .adc_nids = alc268_adc_nids_alt, | |
e1406348 | 11758 | .capsrc_nids = alc268_capsrc_nids, |
d1a991a6 KY |
11759 | .hp_nid = 0x03, |
11760 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11761 | .channel_mode = alc268_modes, | |
11762 | .input_mux = &alc268_capture_source, | |
d273809e TI |
11763 | .unsol_event = alc268_toshiba_unsol_event, |
11764 | .init_hook = alc268_toshiba_automute, | |
11765 | }, | |
11766 | [ALC268_ACER] = { | |
aef9d318 TI |
11767 | .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer, |
11768 | alc268_beep_mixer }, | |
d273809e TI |
11769 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
11770 | alc268_acer_verbs }, | |
11771 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11772 | .dac_nids = alc268_dac_nids, | |
11773 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11774 | .adc_nids = alc268_adc_nids_alt, | |
e1406348 | 11775 | .capsrc_nids = alc268_capsrc_nids, |
d273809e TI |
11776 | .hp_nid = 0x02, |
11777 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11778 | .channel_mode = alc268_modes, | |
0ccb541c | 11779 | .input_mux = &alc268_acer_capture_source, |
d273809e | 11780 | .unsol_event = alc268_acer_unsol_event, |
889c4395 | 11781 | .init_hook = alc268_acer_init_hook, |
d1a991a6 | 11782 | }, |
c238b4f4 TI |
11783 | [ALC268_ACER_DMIC] = { |
11784 | .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer, | |
11785 | alc268_beep_mixer }, | |
11786 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, | |
11787 | alc268_acer_verbs }, | |
11788 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11789 | .dac_nids = alc268_dac_nids, | |
11790 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11791 | .adc_nids = alc268_adc_nids_alt, | |
11792 | .capsrc_nids = alc268_capsrc_nids, | |
11793 | .hp_nid = 0x02, | |
11794 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11795 | .channel_mode = alc268_modes, | |
11796 | .input_mux = &alc268_acer_dmic_capture_source, | |
11797 | .unsol_event = alc268_acer_unsol_event, | |
11798 | .init_hook = alc268_acer_init_hook, | |
11799 | }, | |
8ef355da KY |
11800 | [ALC268_ACER_ASPIRE_ONE] = { |
11801 | .mixers = { alc268_acer_aspire_one_mixer, | |
11802 | alc268_capture_alt_mixer }, | |
11803 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, | |
11804 | alc268_acer_aspire_one_verbs }, | |
11805 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11806 | .dac_nids = alc268_dac_nids, | |
11807 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11808 | .adc_nids = alc268_adc_nids_alt, | |
11809 | .capsrc_nids = alc268_capsrc_nids, | |
11810 | .hp_nid = 0x03, | |
11811 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11812 | .channel_mode = alc268_modes, | |
11813 | .input_mux = &alc268_acer_lc_capture_source, | |
11814 | .unsol_event = alc268_acer_lc_unsol_event, | |
11815 | .init_hook = alc268_acer_lc_init_hook, | |
11816 | }, | |
3866f0b0 | 11817 | [ALC268_DELL] = { |
aef9d318 | 11818 | .mixers = { alc268_dell_mixer, alc268_beep_mixer }, |
3866f0b0 TI |
11819 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
11820 | alc268_dell_verbs }, | |
11821 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11822 | .dac_nids = alc268_dac_nids, | |
11823 | .hp_nid = 0x02, | |
11824 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11825 | .channel_mode = alc268_modes, | |
11826 | .unsol_event = alc268_dell_unsol_event, | |
11827 | .init_hook = alc268_dell_init_hook, | |
11828 | .input_mux = &alc268_capture_source, | |
11829 | }, | |
f12462c5 | 11830 | [ALC268_ZEPTO] = { |
aef9d318 TI |
11831 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, |
11832 | alc268_beep_mixer }, | |
f12462c5 MT |
11833 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
11834 | alc268_toshiba_verbs }, | |
11835 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11836 | .dac_nids = alc268_dac_nids, | |
11837 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11838 | .adc_nids = alc268_adc_nids_alt, | |
e1406348 | 11839 | .capsrc_nids = alc268_capsrc_nids, |
f12462c5 MT |
11840 | .hp_nid = 0x03, |
11841 | .dig_out_nid = ALC268_DIGOUT_NID, | |
11842 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11843 | .channel_mode = alc268_modes, | |
11844 | .input_mux = &alc268_capture_source, | |
11845 | .unsol_event = alc268_toshiba_unsol_event, | |
11846 | .init_hook = alc268_toshiba_automute | |
11847 | }, | |
86c53bd2 JW |
11848 | #ifdef CONFIG_SND_DEBUG |
11849 | [ALC268_TEST] = { | |
11850 | .mixers = { alc268_test_mixer, alc268_capture_mixer }, | |
11851 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, | |
11852 | alc268_volume_init_verbs }, | |
11853 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11854 | .dac_nids = alc268_dac_nids, | |
11855 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11856 | .adc_nids = alc268_adc_nids_alt, | |
e1406348 | 11857 | .capsrc_nids = alc268_capsrc_nids, |
86c53bd2 JW |
11858 | .hp_nid = 0x03, |
11859 | .dig_out_nid = ALC268_DIGOUT_NID, | |
11860 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11861 | .channel_mode = alc268_modes, | |
11862 | .input_mux = &alc268_capture_source, | |
11863 | }, | |
11864 | #endif | |
a361d84b KY |
11865 | }; |
11866 | ||
11867 | static int patch_alc268(struct hda_codec *codec) | |
11868 | { | |
11869 | struct alc_spec *spec; | |
11870 | int board_config; | |
11871 | int err; | |
11872 | ||
11873 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); | |
11874 | if (spec == NULL) | |
11875 | return -ENOMEM; | |
11876 | ||
11877 | codec->spec = spec; | |
11878 | ||
11879 | board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST, | |
11880 | alc268_models, | |
11881 | alc268_cfg_tbl); | |
11882 | ||
11883 | if (board_config < 0 || board_config >= ALC268_MODEL_LAST) { | |
11884 | printk(KERN_INFO "hda_codec: Unknown model for ALC268, " | |
11885 | "trying auto-probe from BIOS...\n"); | |
11886 | board_config = ALC268_AUTO; | |
11887 | } | |
11888 | ||
11889 | if (board_config == ALC268_AUTO) { | |
11890 | /* automatic parse from the BIOS config */ | |
11891 | err = alc268_parse_auto_config(codec); | |
11892 | if (err < 0) { | |
11893 | alc_free(codec); | |
11894 | return err; | |
11895 | } else if (!err) { | |
11896 | printk(KERN_INFO | |
11897 | "hda_codec: Cannot set up configuration " | |
11898 | "from BIOS. Using base mode...\n"); | |
11899 | board_config = ALC268_3ST; | |
11900 | } | |
11901 | } | |
11902 | ||
11903 | if (board_config != ALC268_AUTO) | |
11904 | setup_preset(spec, &alc268_presets[board_config]); | |
11905 | ||
2f893286 KY |
11906 | if (codec->vendor_id == 0x10ec0267) { |
11907 | spec->stream_name_analog = "ALC267 Analog"; | |
11908 | spec->stream_name_digital = "ALC267 Digital"; | |
11909 | } else { | |
11910 | spec->stream_name_analog = "ALC268 Analog"; | |
11911 | spec->stream_name_digital = "ALC268 Digital"; | |
11912 | } | |
11913 | ||
a361d84b KY |
11914 | spec->stream_analog_playback = &alc268_pcm_analog_playback; |
11915 | spec->stream_analog_capture = &alc268_pcm_analog_capture; | |
6330079f | 11916 | spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture; |
a361d84b | 11917 | |
a361d84b KY |
11918 | spec->stream_digital_playback = &alc268_pcm_digital_playback; |
11919 | ||
aef9d318 TI |
11920 | if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) |
11921 | /* override the amp caps for beep generator */ | |
11922 | snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, | |
11923 | (0x0c << AC_AMPCAP_OFFSET_SHIFT) | | |
11924 | (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) | | |
11925 | (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) | | |
11926 | (0 << AC_AMPCAP_MUTE_SHIFT)); | |
11927 | ||
3866f0b0 TI |
11928 | if (!spec->adc_nids && spec->input_mux) { |
11929 | /* check whether NID 0x07 is valid */ | |
11930 | unsigned int wcap = get_wcaps(codec, 0x07); | |
85860c06 | 11931 | int i; |
3866f0b0 TI |
11932 | |
11933 | /* get type */ | |
11934 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
67ebcb03 | 11935 | if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) { |
3866f0b0 TI |
11936 | spec->adc_nids = alc268_adc_nids_alt; |
11937 | spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt); | |
d88897ea | 11938 | add_mixer(spec, alc268_capture_alt_mixer); |
3866f0b0 TI |
11939 | } else { |
11940 | spec->adc_nids = alc268_adc_nids; | |
11941 | spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids); | |
d88897ea | 11942 | add_mixer(spec, alc268_capture_mixer); |
a361d84b | 11943 | } |
e1406348 | 11944 | spec->capsrc_nids = alc268_capsrc_nids; |
85860c06 TI |
11945 | /* set default input source */ |
11946 | for (i = 0; i < spec->num_adc_nids; i++) | |
11947 | snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i], | |
11948 | 0, AC_VERB_SET_CONNECT_SEL, | |
11949 | spec->input_mux->items[0].index); | |
a361d84b | 11950 | } |
2134ea4f TI |
11951 | |
11952 | spec->vmaster_nid = 0x02; | |
11953 | ||
a361d84b KY |
11954 | codec->patch_ops = alc_patch_ops; |
11955 | if (board_config == ALC268_AUTO) | |
11956 | spec->init_hook = alc268_auto_init; | |
ea1fb29a | 11957 | |
daead538 TI |
11958 | codec->proc_widget_hook = print_realtek_coef; |
11959 | ||
a361d84b KY |
11960 | return 0; |
11961 | } | |
11962 | ||
f6a92248 KY |
11963 | /* |
11964 | * ALC269 channel source setting (2 channel) | |
11965 | */ | |
11966 | #define ALC269_DIGOUT_NID ALC880_DIGOUT_NID | |
11967 | ||
11968 | #define alc269_dac_nids alc260_dac_nids | |
11969 | ||
11970 | static hda_nid_t alc269_adc_nids[1] = { | |
11971 | /* ADC1 */ | |
f53281e6 KY |
11972 | 0x08, |
11973 | }; | |
11974 | ||
e01bf509 TI |
11975 | static hda_nid_t alc269_capsrc_nids[1] = { |
11976 | 0x23, | |
11977 | }; | |
11978 | ||
11979 | /* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24), | |
11980 | * not a mux! | |
11981 | */ | |
11982 | ||
f53281e6 KY |
11983 | static struct hda_input_mux alc269_eeepc_dmic_capture_source = { |
11984 | .num_items = 2, | |
11985 | .items = { | |
11986 | { "i-Mic", 0x5 }, | |
11987 | { "e-Mic", 0x0 }, | |
11988 | }, | |
11989 | }; | |
11990 | ||
11991 | static struct hda_input_mux alc269_eeepc_amic_capture_source = { | |
11992 | .num_items = 2, | |
11993 | .items = { | |
11994 | { "i-Mic", 0x1 }, | |
11995 | { "e-Mic", 0x0 }, | |
11996 | }, | |
f6a92248 KY |
11997 | }; |
11998 | ||
11999 | #define alc269_modes alc260_modes | |
12000 | #define alc269_capture_source alc880_lg_lw_capture_source | |
12001 | ||
12002 | static struct snd_kcontrol_new alc269_base_mixer[] = { | |
12003 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
12004 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
12005 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
12006 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
12007 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
12008 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2005af24 TI |
12009 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT), |
12010 | HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT), | |
f6a92248 KY |
12011 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
12012 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
12013 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
12014 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
12015 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
12016 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | |
12017 | { } /* end */ | |
12018 | }; | |
12019 | ||
60db6b53 KY |
12020 | static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = { |
12021 | /* output mixer control */ | |
12022 | HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol), | |
12023 | { | |
12024 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
12025 | .name = "Master Playback Switch", | |
12026 | .info = snd_hda_mixer_amp_switch_info, | |
12027 | .get = snd_hda_mixer_amp_switch_get, | |
12028 | .put = alc268_acer_master_sw_put, | |
12029 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
12030 | }, | |
12031 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
12032 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
12033 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
12034 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
12035 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
12036 | HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT), | |
12037 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
12038 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
12039 | { } | |
12040 | }; | |
12041 | ||
64154835 TV |
12042 | static struct snd_kcontrol_new alc269_lifebook_mixer[] = { |
12043 | /* output mixer control */ | |
12044 | HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol), | |
12045 | { | |
12046 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
12047 | .name = "Master Playback Switch", | |
12048 | .info = snd_hda_mixer_amp_switch_info, | |
12049 | .get = snd_hda_mixer_amp_switch_get, | |
12050 | .put = alc268_acer_master_sw_put, | |
12051 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
12052 | }, | |
12053 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
12054 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
12055 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
12056 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
12057 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
12058 | HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT), | |
12059 | HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT), | |
12060 | HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT), | |
12061 | HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT), | |
12062 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
12063 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
12064 | { } | |
12065 | }; | |
12066 | ||
f53281e6 KY |
12067 | /* bind volumes of both NID 0x0c and 0x0d */ |
12068 | static struct hda_bind_ctls alc269_epc_bind_vol = { | |
12069 | .ops = &snd_hda_bind_vol, | |
12070 | .values = { | |
12071 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), | |
12072 | HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT), | |
12073 | 0 | |
12074 | }, | |
12075 | }; | |
12076 | ||
12077 | static struct snd_kcontrol_new alc269_eeepc_mixer[] = { | |
12078 | HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
12079 | HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol), | |
12080 | HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
12081 | { } /* end */ | |
12082 | }; | |
12083 | ||
f53281e6 KY |
12084 | /* capture mixer elements */ |
12085 | static struct snd_kcontrol_new alc269_epc_capture_mixer[] = { | |
12086 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
12087 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
26f5df26 TI |
12088 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
12089 | { } /* end */ | |
12090 | }; | |
12091 | ||
12092 | /* FSC amilo */ | |
12093 | static struct snd_kcontrol_new alc269_fujitsu_mixer[] = { | |
12094 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
12095 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
12096 | HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol), | |
f53281e6 KY |
12097 | { } /* end */ |
12098 | }; | |
12099 | ||
2005af24 TI |
12100 | /* beep control */ |
12101 | static struct snd_kcontrol_new alc269_beep_mixer[] = { | |
12102 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT), | |
12103 | HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT), | |
12104 | { } /* end */ | |
12105 | }; | |
12106 | ||
60db6b53 KY |
12107 | static struct hda_verb alc269_quanta_fl1_verbs[] = { |
12108 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
12109 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12110 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
12111 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
12112 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
12113 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12114 | { } | |
12115 | }; | |
f6a92248 | 12116 | |
64154835 TV |
12117 | static struct hda_verb alc269_lifebook_verbs[] = { |
12118 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
12119 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
12120 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12121 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
12122 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
12123 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12124 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
12125 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
12126 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
12127 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12128 | { } | |
12129 | }; | |
12130 | ||
60db6b53 KY |
12131 | /* toggle speaker-output according to the hp-jack state */ |
12132 | static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec) | |
12133 | { | |
12134 | unsigned int present; | |
12135 | unsigned char bits; | |
f6a92248 | 12136 | |
60db6b53 KY |
12137 | present = snd_hda_codec_read(codec, 0x15, 0, |
12138 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
12139 | bits = present ? AMP_IN_MUTE(0) : 0; | |
12140 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
12141 | AMP_IN_MUTE(0), bits); | |
12142 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
12143 | AMP_IN_MUTE(0), bits); | |
f6a92248 | 12144 | |
60db6b53 KY |
12145 | snd_hda_codec_write(codec, 0x20, 0, |
12146 | AC_VERB_SET_COEF_INDEX, 0x0c); | |
12147 | snd_hda_codec_write(codec, 0x20, 0, | |
12148 | AC_VERB_SET_PROC_COEF, 0x680); | |
f6a92248 | 12149 | |
60db6b53 KY |
12150 | snd_hda_codec_write(codec, 0x20, 0, |
12151 | AC_VERB_SET_COEF_INDEX, 0x0c); | |
12152 | snd_hda_codec_write(codec, 0x20, 0, | |
12153 | AC_VERB_SET_PROC_COEF, 0x480); | |
12154 | } | |
f6a92248 | 12155 | |
64154835 TV |
12156 | /* toggle speaker-output according to the hp-jacks state */ |
12157 | static void alc269_lifebook_speaker_automute(struct hda_codec *codec) | |
12158 | { | |
12159 | unsigned int present; | |
12160 | unsigned char bits; | |
12161 | ||
12162 | /* Check laptop headphone socket */ | |
12163 | present = snd_hda_codec_read(codec, 0x15, 0, | |
12164 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
12165 | ||
12166 | /* Check port replicator headphone socket */ | |
12167 | present |= snd_hda_codec_read(codec, 0x1a, 0, | |
12168 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
12169 | ||
12170 | bits = present ? AMP_IN_MUTE(0) : 0; | |
12171 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
12172 | AMP_IN_MUTE(0), bits); | |
12173 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
12174 | AMP_IN_MUTE(0), bits); | |
12175 | ||
12176 | snd_hda_codec_write(codec, 0x20, 0, | |
12177 | AC_VERB_SET_COEF_INDEX, 0x0c); | |
12178 | snd_hda_codec_write(codec, 0x20, 0, | |
12179 | AC_VERB_SET_PROC_COEF, 0x680); | |
12180 | ||
12181 | snd_hda_codec_write(codec, 0x20, 0, | |
12182 | AC_VERB_SET_COEF_INDEX, 0x0c); | |
12183 | snd_hda_codec_write(codec, 0x20, 0, | |
12184 | AC_VERB_SET_PROC_COEF, 0x480); | |
12185 | } | |
12186 | ||
60db6b53 KY |
12187 | static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec) |
12188 | { | |
12189 | unsigned int present; | |
f6a92248 | 12190 | |
60db6b53 KY |
12191 | present = snd_hda_codec_read(codec, 0x18, 0, |
12192 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
12193 | snd_hda_codec_write(codec, 0x23, 0, | |
12194 | AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1); | |
12195 | } | |
f6a92248 | 12196 | |
64154835 TV |
12197 | static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec) |
12198 | { | |
12199 | unsigned int present_laptop; | |
12200 | unsigned int present_dock; | |
12201 | ||
12202 | present_laptop = snd_hda_codec_read(codec, 0x18, 0, | |
12203 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
12204 | ||
12205 | present_dock = snd_hda_codec_read(codec, 0x1b, 0, | |
12206 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
12207 | ||
12208 | /* Laptop mic port overrides dock mic port, design decision */ | |
12209 | if (present_dock) | |
12210 | snd_hda_codec_write(codec, 0x23, 0, | |
12211 | AC_VERB_SET_CONNECT_SEL, 0x3); | |
12212 | if (present_laptop) | |
12213 | snd_hda_codec_write(codec, 0x23, 0, | |
12214 | AC_VERB_SET_CONNECT_SEL, 0x0); | |
12215 | if (!present_dock && !present_laptop) | |
12216 | snd_hda_codec_write(codec, 0x23, 0, | |
12217 | AC_VERB_SET_CONNECT_SEL, 0x1); | |
12218 | } | |
12219 | ||
60db6b53 KY |
12220 | static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec, |
12221 | unsigned int res) | |
12222 | { | |
12223 | if ((res >> 26) == ALC880_HP_EVENT) | |
12224 | alc269_quanta_fl1_speaker_automute(codec); | |
12225 | if ((res >> 26) == ALC880_MIC_EVENT) | |
12226 | alc269_quanta_fl1_mic_automute(codec); | |
12227 | } | |
f6a92248 | 12228 | |
64154835 TV |
12229 | static void alc269_lifebook_unsol_event(struct hda_codec *codec, |
12230 | unsigned int res) | |
12231 | { | |
12232 | if ((res >> 26) == ALC880_HP_EVENT) | |
12233 | alc269_lifebook_speaker_automute(codec); | |
12234 | if ((res >> 26) == ALC880_MIC_EVENT) | |
12235 | alc269_lifebook_mic_autoswitch(codec); | |
12236 | } | |
12237 | ||
60db6b53 KY |
12238 | static void alc269_quanta_fl1_init_hook(struct hda_codec *codec) |
12239 | { | |
12240 | alc269_quanta_fl1_speaker_automute(codec); | |
12241 | alc269_quanta_fl1_mic_automute(codec); | |
12242 | } | |
f6a92248 | 12243 | |
64154835 TV |
12244 | static void alc269_lifebook_init_hook(struct hda_codec *codec) |
12245 | { | |
12246 | alc269_lifebook_speaker_automute(codec); | |
12247 | alc269_lifebook_mic_autoswitch(codec); | |
12248 | } | |
12249 | ||
f53281e6 KY |
12250 | static struct hda_verb alc269_eeepc_dmic_init_verbs[] = { |
12251 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
12252 | {0x23, AC_VERB_SET_CONNECT_SEL, 0x05}, | |
12253 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 }, | |
12254 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))}, | |
12255 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12256 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
12257 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
12258 | {} | |
12259 | }; | |
12260 | ||
12261 | static struct hda_verb alc269_eeepc_amic_init_verbs[] = { | |
12262 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
12263 | {0x23, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
12264 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 }, | |
12265 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))}, | |
12266 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
12267 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
12268 | {} | |
12269 | }; | |
12270 | ||
12271 | /* toggle speaker-output according to the hp-jack state */ | |
12272 | static void alc269_speaker_automute(struct hda_codec *codec) | |
12273 | { | |
12274 | unsigned int present; | |
60db6b53 | 12275 | unsigned char bits; |
f53281e6 KY |
12276 | |
12277 | present = snd_hda_codec_read(codec, 0x15, 0, | |
60db6b53 | 12278 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; |
f53281e6 KY |
12279 | bits = present ? AMP_IN_MUTE(0) : 0; |
12280 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
60db6b53 | 12281 | AMP_IN_MUTE(0), bits); |
f53281e6 | 12282 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, |
60db6b53 | 12283 | AMP_IN_MUTE(0), bits); |
f53281e6 KY |
12284 | } |
12285 | ||
12286 | static void alc269_eeepc_dmic_automute(struct hda_codec *codec) | |
12287 | { | |
12288 | unsigned int present; | |
12289 | ||
60db6b53 KY |
12290 | present = snd_hda_codec_read(codec, 0x18, 0, |
12291 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
12292 | snd_hda_codec_write(codec, 0x23, 0, | |
12293 | AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5)); | |
f53281e6 KY |
12294 | } |
12295 | ||
12296 | static void alc269_eeepc_amic_automute(struct hda_codec *codec) | |
12297 | { | |
12298 | unsigned int present; | |
12299 | ||
60db6b53 KY |
12300 | present = snd_hda_codec_read(codec, 0x18, 0, |
12301 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
f53281e6 | 12302 | snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
60db6b53 | 12303 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); |
f53281e6 | 12304 | snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
60db6b53 | 12305 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); |
f53281e6 KY |
12306 | } |
12307 | ||
12308 | /* unsolicited event for HP jack sensing */ | |
12309 | static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec, | |
60db6b53 | 12310 | unsigned int res) |
f53281e6 KY |
12311 | { |
12312 | if ((res >> 26) == ALC880_HP_EVENT) | |
12313 | alc269_speaker_automute(codec); | |
12314 | ||
12315 | if ((res >> 26) == ALC880_MIC_EVENT) | |
12316 | alc269_eeepc_dmic_automute(codec); | |
12317 | } | |
12318 | ||
12319 | static void alc269_eeepc_dmic_inithook(struct hda_codec *codec) | |
12320 | { | |
12321 | alc269_speaker_automute(codec); | |
12322 | alc269_eeepc_dmic_automute(codec); | |
12323 | } | |
12324 | ||
12325 | /* unsolicited event for HP jack sensing */ | |
12326 | static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec, | |
ea1fb29a | 12327 | unsigned int res) |
f53281e6 KY |
12328 | { |
12329 | if ((res >> 26) == ALC880_HP_EVENT) | |
12330 | alc269_speaker_automute(codec); | |
12331 | ||
12332 | if ((res >> 26) == ALC880_MIC_EVENT) | |
12333 | alc269_eeepc_amic_automute(codec); | |
12334 | } | |
12335 | ||
12336 | static void alc269_eeepc_amic_inithook(struct hda_codec *codec) | |
12337 | { | |
12338 | alc269_speaker_automute(codec); | |
12339 | alc269_eeepc_amic_automute(codec); | |
12340 | } | |
12341 | ||
60db6b53 KY |
12342 | /* |
12343 | * generic initialization of ADC, input mixers and output mixers | |
12344 | */ | |
12345 | static struct hda_verb alc269_init_verbs[] = { | |
12346 | /* | |
12347 | * Unmute ADC0 and set the default input to mic-in | |
12348 | */ | |
12349 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12350 | ||
12351 | /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the | |
12352 | * analog-loopback mixer widget | |
12353 | * Note: PASD motherboards uses the Line In 2 as the input for | |
12354 | * front panel mic (mic 2) | |
12355 | */ | |
12356 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
12357 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
12358 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
12359 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
12360 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
12361 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
12362 | ||
12363 | /* | |
12364 | * Set up output mixers (0x0c - 0x0e) | |
12365 | */ | |
12366 | /* set vol=0 to output mixers */ | |
12367 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
12368 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
12369 | ||
12370 | /* set up input amps for analog loopback */ | |
12371 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
12372 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12373 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12374 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12375 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12376 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12377 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12378 | ||
12379 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
12380 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
12381 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
12382 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
12383 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
12384 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12385 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12386 | ||
12387 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12388 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12389 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12390 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12391 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12392 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12393 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12394 | ||
12395 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
12396 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
12397 | ||
12398 | /* FIXME: use matrix-type input source selection */ | |
12399 | /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */ | |
12400 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
12401 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
12402 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12403 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
12404 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
12405 | ||
12406 | /* set EAPD */ | |
12407 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
12408 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
12409 | { } | |
12410 | }; | |
12411 | ||
f6a92248 KY |
12412 | /* add playback controls from the parsed DAC table */ |
12413 | static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec, | |
12414 | const struct auto_pin_cfg *cfg) | |
12415 | { | |
12416 | hda_nid_t nid; | |
12417 | int err; | |
12418 | ||
12419 | spec->multiout.num_dacs = 1; /* only use one dac */ | |
12420 | spec->multiout.dac_nids = spec->private_dac_nids; | |
12421 | spec->multiout.dac_nids[0] = 2; | |
12422 | ||
12423 | nid = cfg->line_out_pins[0]; | |
12424 | if (nid) { | |
12425 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
12426 | "Front Playback Volume", | |
12427 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT)); | |
12428 | if (err < 0) | |
12429 | return err; | |
12430 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
12431 | "Front Playback Switch", | |
12432 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
12433 | if (err < 0) | |
12434 | return err; | |
12435 | } | |
12436 | ||
12437 | nid = cfg->speaker_pins[0]; | |
12438 | if (nid) { | |
12439 | if (!cfg->line_out_pins[0]) { | |
12440 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
12441 | "Speaker Playback Volume", | |
12442 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, | |
12443 | HDA_OUTPUT)); | |
12444 | if (err < 0) | |
12445 | return err; | |
12446 | } | |
12447 | if (nid == 0x16) { | |
12448 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
12449 | "Speaker Playback Switch", | |
12450 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
12451 | HDA_OUTPUT)); | |
12452 | if (err < 0) | |
12453 | return err; | |
12454 | } else { | |
12455 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
12456 | "Speaker Playback Switch", | |
12457 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
12458 | HDA_OUTPUT)); | |
12459 | if (err < 0) | |
12460 | return err; | |
12461 | } | |
12462 | } | |
12463 | nid = cfg->hp_pins[0]; | |
12464 | if (nid) { | |
12465 | /* spec->multiout.hp_nid = 2; */ | |
12466 | if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) { | |
12467 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
12468 | "Headphone Playback Volume", | |
12469 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, | |
12470 | HDA_OUTPUT)); | |
12471 | if (err < 0) | |
12472 | return err; | |
12473 | } | |
12474 | if (nid == 0x16) { | |
12475 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
12476 | "Headphone Playback Switch", | |
12477 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
12478 | HDA_OUTPUT)); | |
12479 | if (err < 0) | |
12480 | return err; | |
12481 | } else { | |
12482 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
12483 | "Headphone Playback Switch", | |
12484 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
12485 | HDA_OUTPUT)); | |
12486 | if (err < 0) | |
12487 | return err; | |
12488 | } | |
12489 | } | |
12490 | return 0; | |
12491 | } | |
12492 | ||
ee956e09 TI |
12493 | static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec, |
12494 | const struct auto_pin_cfg *cfg) | |
12495 | { | |
12496 | int err; | |
12497 | ||
12498 | err = alc880_auto_create_analog_input_ctls(spec, cfg); | |
12499 | if (err < 0) | |
12500 | return err; | |
12501 | /* digital-mic input pin is excluded in alc880_auto_create..() | |
12502 | * because it's under 0x18 | |
12503 | */ | |
12504 | if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 || | |
12505 | cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) { | |
12506 | struct hda_input_mux *imux = &spec->private_imux; | |
12507 | imux->items[imux->num_items].label = "Int Mic"; | |
12508 | imux->items[imux->num_items].index = 0x05; | |
12509 | imux->num_items++; | |
12510 | } | |
12511 | return 0; | |
12512 | } | |
f6a92248 KY |
12513 | |
12514 | #ifdef CONFIG_SND_HDA_POWER_SAVE | |
12515 | #define alc269_loopbacks alc880_loopbacks | |
12516 | #endif | |
12517 | ||
12518 | /* pcm configuration: identiacal with ALC880 */ | |
12519 | #define alc269_pcm_analog_playback alc880_pcm_analog_playback | |
12520 | #define alc269_pcm_analog_capture alc880_pcm_analog_capture | |
12521 | #define alc269_pcm_digital_playback alc880_pcm_digital_playback | |
12522 | #define alc269_pcm_digital_capture alc880_pcm_digital_capture | |
12523 | ||
12524 | /* | |
12525 | * BIOS auto configuration | |
12526 | */ | |
12527 | static int alc269_parse_auto_config(struct hda_codec *codec) | |
12528 | { | |
12529 | struct alc_spec *spec = codec->spec; | |
2005af24 | 12530 | int i, err; |
f6a92248 KY |
12531 | static hda_nid_t alc269_ignore[] = { 0x1d, 0 }; |
12532 | ||
12533 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | |
12534 | alc269_ignore); | |
12535 | if (err < 0) | |
12536 | return err; | |
12537 | ||
12538 | err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
12539 | if (err < 0) | |
12540 | return err; | |
12541 | err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
12542 | if (err < 0) | |
12543 | return err; | |
12544 | ||
12545 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
12546 | ||
12547 | if (spec->autocfg.dig_out_pin) | |
12548 | spec->multiout.dig_out_nid = ALC269_DIGOUT_NID; | |
12549 | ||
603c4019 | 12550 | if (spec->kctls.list) |
d88897ea | 12551 | add_mixer(spec, spec->kctls.list); |
f6a92248 | 12552 | |
2005af24 TI |
12553 | /* create a beep mixer control if the pin 0x1d isn't assigned */ |
12554 | for (i = 0; i < ARRAY_SIZE(spec->autocfg.input_pins); i++) | |
12555 | if (spec->autocfg.input_pins[i] == 0x1d) | |
12556 | break; | |
12557 | if (i >= ARRAY_SIZE(spec->autocfg.input_pins)) | |
d88897ea | 12558 | add_mixer(spec, alc269_beep_mixer); |
2005af24 | 12559 | |
d88897ea | 12560 | add_verb(spec, alc269_init_verbs); |
f6a92248 KY |
12561 | spec->num_mux_defs = 1; |
12562 | spec->input_mux = &spec->private_imux; | |
e01bf509 TI |
12563 | /* set default input source */ |
12564 | snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0], | |
12565 | 0, AC_VERB_SET_CONNECT_SEL, | |
12566 | spec->input_mux->items[0].index); | |
f6a92248 KY |
12567 | |
12568 | err = alc_auto_add_mic_boost(codec); | |
12569 | if (err < 0) | |
12570 | return err; | |
12571 | ||
f9e336f6 TI |
12572 | if (!spec->cap_mixer) |
12573 | set_capture_mixer(spec); | |
f53281e6 | 12574 | |
e044c39a | 12575 | store_pin_configs(codec); |
f6a92248 KY |
12576 | return 1; |
12577 | } | |
12578 | ||
12579 | #define alc269_auto_init_multi_out alc882_auto_init_multi_out | |
12580 | #define alc269_auto_init_hp_out alc882_auto_init_hp_out | |
12581 | #define alc269_auto_init_analog_input alc882_auto_init_analog_input | |
12582 | ||
12583 | ||
12584 | /* init callback for auto-configuration model -- overriding the default init */ | |
12585 | static void alc269_auto_init(struct hda_codec *codec) | |
12586 | { | |
f6c7e546 | 12587 | struct alc_spec *spec = codec->spec; |
f6a92248 KY |
12588 | alc269_auto_init_multi_out(codec); |
12589 | alc269_auto_init_hp_out(codec); | |
12590 | alc269_auto_init_analog_input(codec); | |
f6c7e546 | 12591 | if (spec->unsol_event) |
7fb0d78f | 12592 | alc_inithook(codec); |
f6a92248 KY |
12593 | } |
12594 | ||
12595 | /* | |
12596 | * configuration and preset | |
12597 | */ | |
12598 | static const char *alc269_models[ALC269_MODEL_LAST] = { | |
60db6b53 | 12599 | [ALC269_BASIC] = "basic", |
2922c9af TI |
12600 | [ALC269_QUANTA_FL1] = "quanta", |
12601 | [ALC269_ASUS_EEEPC_P703] = "eeepc-p703", | |
26f5df26 | 12602 | [ALC269_ASUS_EEEPC_P901] = "eeepc-p901", |
64154835 TV |
12603 | [ALC269_FUJITSU] = "fujitsu", |
12604 | [ALC269_LIFEBOOK] = "lifebook" | |
f6a92248 KY |
12605 | }; |
12606 | ||
12607 | static struct snd_pci_quirk alc269_cfg_tbl[] = { | |
60db6b53 | 12608 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1), |
f53281e6 KY |
12609 | SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", |
12610 | ALC269_ASUS_EEEPC_P703), | |
12611 | SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901", | |
12612 | ALC269_ASUS_EEEPC_P901), | |
60db6b53 KY |
12613 | SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101", |
12614 | ALC269_ASUS_EEEPC_P901), | |
26f5df26 | 12615 | SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU), |
64154835 | 12616 | SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK), |
f6a92248 KY |
12617 | {} |
12618 | }; | |
12619 | ||
12620 | static struct alc_config_preset alc269_presets[] = { | |
12621 | [ALC269_BASIC] = { | |
f9e336f6 | 12622 | .mixers = { alc269_base_mixer }, |
f6a92248 KY |
12623 | .init_verbs = { alc269_init_verbs }, |
12624 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | |
12625 | .dac_nids = alc269_dac_nids, | |
12626 | .hp_nid = 0x03, | |
12627 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | |
12628 | .channel_mode = alc269_modes, | |
12629 | .input_mux = &alc269_capture_source, | |
12630 | }, | |
60db6b53 KY |
12631 | [ALC269_QUANTA_FL1] = { |
12632 | .mixers = { alc269_quanta_fl1_mixer }, | |
12633 | .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs }, | |
12634 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | |
12635 | .dac_nids = alc269_dac_nids, | |
12636 | .hp_nid = 0x03, | |
12637 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | |
12638 | .channel_mode = alc269_modes, | |
12639 | .input_mux = &alc269_capture_source, | |
12640 | .unsol_event = alc269_quanta_fl1_unsol_event, | |
12641 | .init_hook = alc269_quanta_fl1_init_hook, | |
12642 | }, | |
f53281e6 | 12643 | [ALC269_ASUS_EEEPC_P703] = { |
f9e336f6 TI |
12644 | .mixers = { alc269_eeepc_mixer }, |
12645 | .cap_mixer = alc269_epc_capture_mixer, | |
f53281e6 KY |
12646 | .init_verbs = { alc269_init_verbs, |
12647 | alc269_eeepc_amic_init_verbs }, | |
12648 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | |
12649 | .dac_nids = alc269_dac_nids, | |
12650 | .hp_nid = 0x03, | |
12651 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | |
12652 | .channel_mode = alc269_modes, | |
12653 | .input_mux = &alc269_eeepc_amic_capture_source, | |
12654 | .unsol_event = alc269_eeepc_amic_unsol_event, | |
12655 | .init_hook = alc269_eeepc_amic_inithook, | |
12656 | }, | |
12657 | [ALC269_ASUS_EEEPC_P901] = { | |
f9e336f6 TI |
12658 | .mixers = { alc269_eeepc_mixer }, |
12659 | .cap_mixer = alc269_epc_capture_mixer, | |
f53281e6 KY |
12660 | .init_verbs = { alc269_init_verbs, |
12661 | alc269_eeepc_dmic_init_verbs }, | |
12662 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | |
12663 | .dac_nids = alc269_dac_nids, | |
12664 | .hp_nid = 0x03, | |
12665 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | |
12666 | .channel_mode = alc269_modes, | |
12667 | .input_mux = &alc269_eeepc_dmic_capture_source, | |
12668 | .unsol_event = alc269_eeepc_dmic_unsol_event, | |
12669 | .init_hook = alc269_eeepc_dmic_inithook, | |
12670 | }, | |
26f5df26 TI |
12671 | [ALC269_FUJITSU] = { |
12672 | .mixers = { alc269_fujitsu_mixer, alc269_beep_mixer }, | |
12673 | .cap_mixer = alc269_epc_capture_mixer, | |
12674 | .init_verbs = { alc269_init_verbs, | |
12675 | alc269_eeepc_dmic_init_verbs }, | |
12676 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | |
12677 | .dac_nids = alc269_dac_nids, | |
12678 | .hp_nid = 0x03, | |
12679 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | |
12680 | .channel_mode = alc269_modes, | |
12681 | .input_mux = &alc269_eeepc_dmic_capture_source, | |
12682 | .unsol_event = alc269_eeepc_dmic_unsol_event, | |
12683 | .init_hook = alc269_eeepc_dmic_inithook, | |
12684 | }, | |
64154835 TV |
12685 | [ALC269_LIFEBOOK] = { |
12686 | .mixers = { alc269_lifebook_mixer }, | |
12687 | .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs }, | |
12688 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | |
12689 | .dac_nids = alc269_dac_nids, | |
12690 | .hp_nid = 0x03, | |
12691 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | |
12692 | .channel_mode = alc269_modes, | |
12693 | .input_mux = &alc269_capture_source, | |
12694 | .unsol_event = alc269_lifebook_unsol_event, | |
12695 | .init_hook = alc269_lifebook_init_hook, | |
12696 | }, | |
f6a92248 KY |
12697 | }; |
12698 | ||
12699 | static int patch_alc269(struct hda_codec *codec) | |
12700 | { | |
12701 | struct alc_spec *spec; | |
12702 | int board_config; | |
12703 | int err; | |
12704 | ||
12705 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
12706 | if (spec == NULL) | |
12707 | return -ENOMEM; | |
12708 | ||
12709 | codec->spec = spec; | |
12710 | ||
2c3bf9ab TI |
12711 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
12712 | ||
f6a92248 KY |
12713 | board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST, |
12714 | alc269_models, | |
12715 | alc269_cfg_tbl); | |
12716 | ||
12717 | if (board_config < 0) { | |
12718 | printk(KERN_INFO "hda_codec: Unknown model for ALC269, " | |
12719 | "trying auto-probe from BIOS...\n"); | |
12720 | board_config = ALC269_AUTO; | |
12721 | } | |
12722 | ||
12723 | if (board_config == ALC269_AUTO) { | |
12724 | /* automatic parse from the BIOS config */ | |
12725 | err = alc269_parse_auto_config(codec); | |
12726 | if (err < 0) { | |
12727 | alc_free(codec); | |
12728 | return err; | |
12729 | } else if (!err) { | |
12730 | printk(KERN_INFO | |
12731 | "hda_codec: Cannot set up configuration " | |
12732 | "from BIOS. Using base mode...\n"); | |
12733 | board_config = ALC269_BASIC; | |
12734 | } | |
12735 | } | |
12736 | ||
12737 | if (board_config != ALC269_AUTO) | |
12738 | setup_preset(spec, &alc269_presets[board_config]); | |
12739 | ||
12740 | spec->stream_name_analog = "ALC269 Analog"; | |
12741 | spec->stream_analog_playback = &alc269_pcm_analog_playback; | |
12742 | spec->stream_analog_capture = &alc269_pcm_analog_capture; | |
12743 | ||
12744 | spec->stream_name_digital = "ALC269 Digital"; | |
12745 | spec->stream_digital_playback = &alc269_pcm_digital_playback; | |
12746 | spec->stream_digital_capture = &alc269_pcm_digital_capture; | |
12747 | ||
12748 | spec->adc_nids = alc269_adc_nids; | |
12749 | spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids); | |
e01bf509 | 12750 | spec->capsrc_nids = alc269_capsrc_nids; |
f9e336f6 TI |
12751 | if (!spec->cap_mixer) |
12752 | set_capture_mixer(spec); | |
f6a92248 KY |
12753 | |
12754 | codec->patch_ops = alc_patch_ops; | |
12755 | if (board_config == ALC269_AUTO) | |
12756 | spec->init_hook = alc269_auto_init; | |
12757 | #ifdef CONFIG_SND_HDA_POWER_SAVE | |
12758 | if (!spec->loopback.amplist) | |
12759 | spec->loopback.amplist = alc269_loopbacks; | |
12760 | #endif | |
daead538 | 12761 | codec->proc_widget_hook = print_realtek_coef; |
f6a92248 KY |
12762 | |
12763 | return 0; | |
12764 | } | |
12765 | ||
df694daa KY |
12766 | /* |
12767 | * ALC861 channel source setting (2/6 channel selection for 3-stack) | |
12768 | */ | |
12769 | ||
12770 | /* | |
12771 | * set the path ways for 2 channel output | |
12772 | * need to set the codec line out and mic 1 pin widgets to inputs | |
12773 | */ | |
12774 | static struct hda_verb alc861_threestack_ch2_init[] = { | |
12775 | /* set pin widget 1Ah (line in) for input */ | |
12776 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
f12ab1e0 TI |
12777 | /* set pin widget 18h (mic1/2) for input, for mic also enable |
12778 | * the vref | |
12779 | */ | |
df694daa KY |
12780 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
12781 | ||
9c7f852e TI |
12782 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, |
12783 | #if 0 | |
12784 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
12785 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/ | |
12786 | #endif | |
df694daa KY |
12787 | { } /* end */ |
12788 | }; | |
12789 | /* | |
12790 | * 6ch mode | |
12791 | * need to set the codec line out and mic 1 pin widgets to outputs | |
12792 | */ | |
12793 | static struct hda_verb alc861_threestack_ch6_init[] = { | |
12794 | /* set pin widget 1Ah (line in) for output (Back Surround)*/ | |
12795 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12796 | /* set pin widget 18h (mic1) for output (CLFE)*/ | |
12797 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12798 | ||
12799 | { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
9c7f852e | 12800 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa | 12801 | |
9c7f852e TI |
12802 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, |
12803 | #if 0 | |
12804 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
12805 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/ | |
12806 | #endif | |
df694daa KY |
12807 | { } /* end */ |
12808 | }; | |
12809 | ||
12810 | static struct hda_channel_mode alc861_threestack_modes[2] = { | |
12811 | { 2, alc861_threestack_ch2_init }, | |
12812 | { 6, alc861_threestack_ch6_init }, | |
12813 | }; | |
22309c3e TI |
12814 | /* Set mic1 as input and unmute the mixer */ |
12815 | static struct hda_verb alc861_uniwill_m31_ch2_init[] = { | |
12816 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
12817 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
12818 | { } /* end */ | |
12819 | }; | |
12820 | /* Set mic1 as output and mute mixer */ | |
12821 | static struct hda_verb alc861_uniwill_m31_ch4_init[] = { | |
12822 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12823 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
12824 | { } /* end */ | |
12825 | }; | |
12826 | ||
12827 | static struct hda_channel_mode alc861_uniwill_m31_modes[2] = { | |
12828 | { 2, alc861_uniwill_m31_ch2_init }, | |
12829 | { 4, alc861_uniwill_m31_ch4_init }, | |
12830 | }; | |
df694daa | 12831 | |
7cdbff94 MD |
12832 | /* Set mic1 and line-in as input and unmute the mixer */ |
12833 | static struct hda_verb alc861_asus_ch2_init[] = { | |
12834 | /* set pin widget 1Ah (line in) for input */ | |
12835 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
f12ab1e0 TI |
12836 | /* set pin widget 18h (mic1/2) for input, for mic also enable |
12837 | * the vref | |
12838 | */ | |
7cdbff94 MD |
12839 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
12840 | ||
12841 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, | |
12842 | #if 0 | |
12843 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
12844 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/ | |
12845 | #endif | |
12846 | { } /* end */ | |
12847 | }; | |
12848 | /* Set mic1 nad line-in as output and mute mixer */ | |
12849 | static struct hda_verb alc861_asus_ch6_init[] = { | |
12850 | /* set pin widget 1Ah (line in) for output (Back Surround)*/ | |
12851 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12852 | /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */ | |
12853 | /* set pin widget 18h (mic1) for output (CLFE)*/ | |
12854 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12855 | /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */ | |
12856 | { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
12857 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
12858 | ||
12859 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, | |
12860 | #if 0 | |
12861 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
12862 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/ | |
12863 | #endif | |
12864 | { } /* end */ | |
12865 | }; | |
12866 | ||
12867 | static struct hda_channel_mode alc861_asus_modes[2] = { | |
12868 | { 2, alc861_asus_ch2_init }, | |
12869 | { 6, alc861_asus_ch6_init }, | |
12870 | }; | |
12871 | ||
df694daa KY |
12872 | /* patch-ALC861 */ |
12873 | ||
12874 | static struct snd_kcontrol_new alc861_base_mixer[] = { | |
12875 | /* output mixer control */ | |
12876 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
12877 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
12878 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
12879 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
12880 | HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), | |
12881 | ||
12882 | /*Input mixer control */ | |
12883 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
12884 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
12885 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
12886 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
12887 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
12888 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
12889 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
12890 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
12891 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
12892 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 12893 | |
df694daa KY |
12894 | { } /* end */ |
12895 | }; | |
12896 | ||
12897 | static struct snd_kcontrol_new alc861_3ST_mixer[] = { | |
12898 | /* output mixer control */ | |
12899 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
12900 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
12901 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
12902 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
12903 | /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ | |
12904 | ||
12905 | /* Input mixer control */ | |
12906 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
12907 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
12908 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
12909 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
12910 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
12911 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
12912 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
12913 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
12914 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
12915 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 12916 | |
df694daa KY |
12917 | { |
12918 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
12919 | .name = "Channel Mode", | |
12920 | .info = alc_ch_mode_info, | |
12921 | .get = alc_ch_mode_get, | |
12922 | .put = alc_ch_mode_put, | |
12923 | .private_value = ARRAY_SIZE(alc861_threestack_modes), | |
12924 | }, | |
12925 | { } /* end */ | |
a53d1aec TD |
12926 | }; |
12927 | ||
d1d985f0 | 12928 | static struct snd_kcontrol_new alc861_toshiba_mixer[] = { |
a53d1aec TD |
12929 | /* output mixer control */ |
12930 | HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
12931 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
12932 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
ea1fb29a | 12933 | |
a53d1aec | 12934 | { } /* end */ |
f12ab1e0 | 12935 | }; |
a53d1aec | 12936 | |
22309c3e TI |
12937 | static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = { |
12938 | /* output mixer control */ | |
12939 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
12940 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
12941 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
12942 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
12943 | /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ | |
12944 | ||
12945 | /* Input mixer control */ | |
12946 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
12947 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
12948 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
12949 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
12950 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
12951 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
12952 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
12953 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
12954 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
12955 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 12956 | |
22309c3e TI |
12957 | { |
12958 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
12959 | .name = "Channel Mode", | |
12960 | .info = alc_ch_mode_info, | |
12961 | .get = alc_ch_mode_get, | |
12962 | .put = alc_ch_mode_put, | |
12963 | .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes), | |
12964 | }, | |
12965 | { } /* end */ | |
f12ab1e0 | 12966 | }; |
7cdbff94 MD |
12967 | |
12968 | static struct snd_kcontrol_new alc861_asus_mixer[] = { | |
12969 | /* output mixer control */ | |
12970 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
12971 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
12972 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
12973 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
12974 | HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), | |
12975 | ||
12976 | /* Input mixer control */ | |
12977 | HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
12978 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
12979 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
12980 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
12981 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
12982 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
12983 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
12984 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
12985 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
f12ab1e0 TI |
12986 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), |
12987 | ||
7cdbff94 MD |
12988 | { |
12989 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
12990 | .name = "Channel Mode", | |
12991 | .info = alc_ch_mode_info, | |
12992 | .get = alc_ch_mode_get, | |
12993 | .put = alc_ch_mode_put, | |
12994 | .private_value = ARRAY_SIZE(alc861_asus_modes), | |
12995 | }, | |
12996 | { } | |
56bb0cab TI |
12997 | }; |
12998 | ||
12999 | /* additional mixer */ | |
d1d985f0 | 13000 | static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = { |
56bb0cab TI |
13001 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), |
13002 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
13003 | HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT), | |
13004 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT), | |
13005 | { } | |
13006 | }; | |
7cdbff94 | 13007 | |
df694daa KY |
13008 | /* |
13009 | * generic initialization of ADC, input mixers and output mixers | |
13010 | */ | |
13011 | static struct hda_verb alc861_base_init_verbs[] = { | |
13012 | /* | |
13013 | * Unmute ADC0 and set the default input to mic-in | |
13014 | */ | |
13015 | /* port-A for surround (rear panel) */ | |
13016 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
13017 | { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
13018 | /* port-B for mic-in (rear panel) with vref */ | |
13019 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
13020 | /* port-C for line-in (rear panel) */ | |
13021 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
13022 | /* port-D for Front */ | |
13023 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
13024 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
13025 | /* port-E for HP out (front panel) */ | |
13026 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | |
13027 | /* route front PCM to HP */ | |
9dece1d7 | 13028 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa KY |
13029 | /* port-F for mic-in (front panel) with vref */ |
13030 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
13031 | /* port-G for CLFE (rear panel) */ | |
13032 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
13033 | { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
13034 | /* port-H for side (rear panel) */ | |
13035 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
13036 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
13037 | /* CD-in */ | |
13038 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
13039 | /* route front mic to ADC1*/ | |
13040 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
13041 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
ea1fb29a | 13042 | |
df694daa KY |
13043 | /* Unmute DAC0~3 & spdif out*/ |
13044 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13045 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13046 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13047 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13048 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
ea1fb29a | 13049 | |
df694daa KY |
13050 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ |
13051 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13052 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13053 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13054 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
ea1fb29a | 13055 | |
df694daa KY |
13056 | /* Unmute Stereo Mixer 15 */ |
13057 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13058 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13059 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 13060 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
df694daa KY |
13061 | |
13062 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13063 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13064 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13065 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13066 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13067 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13068 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13069 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
13070 | /* hp used DAC 3 (Front) */ |
13071 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
13072 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
13073 | ||
13074 | { } | |
13075 | }; | |
13076 | ||
13077 | static struct hda_verb alc861_threestack_init_verbs[] = { | |
13078 | /* | |
13079 | * Unmute ADC0 and set the default input to mic-in | |
13080 | */ | |
13081 | /* port-A for surround (rear panel) */ | |
13082 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
13083 | /* port-B for mic-in (rear panel) with vref */ | |
13084 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
13085 | /* port-C for line-in (rear panel) */ | |
13086 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
13087 | /* port-D for Front */ | |
13088 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
13089 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
13090 | /* port-E for HP out (front panel) */ | |
13091 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | |
13092 | /* route front PCM to HP */ | |
9dece1d7 | 13093 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa KY |
13094 | /* port-F for mic-in (front panel) with vref */ |
13095 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
13096 | /* port-G for CLFE (rear panel) */ | |
13097 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
13098 | /* port-H for side (rear panel) */ | |
13099 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
13100 | /* CD-in */ | |
13101 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
13102 | /* route front mic to ADC1*/ | |
13103 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
13104 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13105 | /* Unmute DAC0~3 & spdif out*/ | |
13106 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13107 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13108 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13109 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13110 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
ea1fb29a | 13111 | |
df694daa KY |
13112 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ |
13113 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13114 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13115 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13116 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
ea1fb29a | 13117 | |
df694daa KY |
13118 | /* Unmute Stereo Mixer 15 */ |
13119 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13120 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13121 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 13122 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
df694daa KY |
13123 | |
13124 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13125 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13126 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13127 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13128 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13129 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13130 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13131 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
13132 | /* hp used DAC 3 (Front) */ |
13133 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
13134 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
13135 | { } | |
13136 | }; | |
22309c3e TI |
13137 | |
13138 | static struct hda_verb alc861_uniwill_m31_init_verbs[] = { | |
13139 | /* | |
13140 | * Unmute ADC0 and set the default input to mic-in | |
13141 | */ | |
13142 | /* port-A for surround (rear panel) */ | |
13143 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
13144 | /* port-B for mic-in (rear panel) with vref */ | |
13145 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
13146 | /* port-C for line-in (rear panel) */ | |
13147 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
13148 | /* port-D for Front */ | |
13149 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
13150 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
13151 | /* port-E for HP out (front panel) */ | |
f12ab1e0 TI |
13152 | /* this has to be set to VREF80 */ |
13153 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
22309c3e | 13154 | /* route front PCM to HP */ |
9dece1d7 | 13155 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
22309c3e TI |
13156 | /* port-F for mic-in (front panel) with vref */ |
13157 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
13158 | /* port-G for CLFE (rear panel) */ | |
13159 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
13160 | /* port-H for side (rear panel) */ | |
13161 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
13162 | /* CD-in */ | |
13163 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
13164 | /* route front mic to ADC1*/ | |
13165 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
13166 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13167 | /* Unmute DAC0~3 & spdif out*/ | |
13168 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13169 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13170 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13171 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13172 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
ea1fb29a | 13173 | |
22309c3e TI |
13174 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ |
13175 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13176 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13177 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13178 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
ea1fb29a | 13179 | |
22309c3e TI |
13180 | /* Unmute Stereo Mixer 15 */ |
13181 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13182 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13183 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 13184 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
22309c3e TI |
13185 | |
13186 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13187 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13188 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13189 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13190 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13191 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13192 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13193 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
13194 | /* hp used DAC 3 (Front) */ |
13195 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
22309c3e TI |
13196 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
13197 | { } | |
13198 | }; | |
13199 | ||
7cdbff94 MD |
13200 | static struct hda_verb alc861_asus_init_verbs[] = { |
13201 | /* | |
13202 | * Unmute ADC0 and set the default input to mic-in | |
13203 | */ | |
f12ab1e0 TI |
13204 | /* port-A for surround (rear panel) |
13205 | * according to codec#0 this is the HP jack | |
13206 | */ | |
7cdbff94 MD |
13207 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */ |
13208 | /* route front PCM to HP */ | |
13209 | { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
13210 | /* port-B for mic-in (rear panel) with vref */ | |
13211 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
13212 | /* port-C for line-in (rear panel) */ | |
13213 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
13214 | /* port-D for Front */ | |
13215 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
13216 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
13217 | /* port-E for HP out (front panel) */ | |
f12ab1e0 TI |
13218 | /* this has to be set to VREF80 */ |
13219 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
7cdbff94 | 13220 | /* route front PCM to HP */ |
9dece1d7 | 13221 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
7cdbff94 MD |
13222 | /* port-F for mic-in (front panel) with vref */ |
13223 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
13224 | /* port-G for CLFE (rear panel) */ | |
13225 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
13226 | /* port-H for side (rear panel) */ | |
13227 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
13228 | /* CD-in */ | |
13229 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
13230 | /* route front mic to ADC1*/ | |
13231 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
13232 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13233 | /* Unmute DAC0~3 & spdif out*/ | |
13234 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13235 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13236 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13237 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13238 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13239 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
13240 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13241 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13242 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13243 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
ea1fb29a | 13244 | |
7cdbff94 MD |
13245 | /* Unmute Stereo Mixer 15 */ |
13246 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13247 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13248 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 13249 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
7cdbff94 MD |
13250 | |
13251 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13252 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13253 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13254 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13255 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13256 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13257 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13258 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
13259 | /* hp used DAC 3 (Front) */ |
13260 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
7cdbff94 MD |
13261 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
13262 | { } | |
13263 | }; | |
13264 | ||
56bb0cab TI |
13265 | /* additional init verbs for ASUS laptops */ |
13266 | static struct hda_verb alc861_asus_laptop_init_verbs[] = { | |
13267 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */ | |
13268 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */ | |
13269 | { } | |
13270 | }; | |
7cdbff94 | 13271 | |
df694daa KY |
13272 | /* |
13273 | * generic initialization of ADC, input mixers and output mixers | |
13274 | */ | |
13275 | static struct hda_verb alc861_auto_init_verbs[] = { | |
13276 | /* | |
13277 | * Unmute ADC0 and set the default input to mic-in | |
13278 | */ | |
f12ab1e0 | 13279 | /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */ |
df694daa | 13280 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
ea1fb29a | 13281 | |
df694daa KY |
13282 | /* Unmute DAC0~3 & spdif out*/ |
13283 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13284 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13285 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13286 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13287 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
ea1fb29a | 13288 | |
df694daa KY |
13289 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ |
13290 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13291 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13292 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13293 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
ea1fb29a | 13294 | |
df694daa KY |
13295 | /* Unmute Stereo Mixer 15 */ |
13296 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13297 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13298 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
13299 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, | |
13300 | ||
13301 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13302 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13303 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13304 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13305 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13306 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13307 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13308 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13309 | ||
13310 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
13311 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
f12ab1e0 TI |
13312 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
13313 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
13314 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
13315 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
f12ab1e0 TI |
13316 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
13317 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa | 13318 | |
f12ab1e0 | 13319 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */ |
df694daa KY |
13320 | |
13321 | { } | |
13322 | }; | |
13323 | ||
a53d1aec TD |
13324 | static struct hda_verb alc861_toshiba_init_verbs[] = { |
13325 | {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
f12ab1e0 | 13326 | |
a53d1aec TD |
13327 | { } |
13328 | }; | |
13329 | ||
13330 | /* toggle speaker-output according to the hp-jack state */ | |
13331 | static void alc861_toshiba_automute(struct hda_codec *codec) | |
13332 | { | |
13333 | unsigned int present; | |
13334 | ||
13335 | present = snd_hda_codec_read(codec, 0x0f, 0, | |
13336 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
13337 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0, |
13338 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
13339 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3, | |
13340 | HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE); | |
a53d1aec TD |
13341 | } |
13342 | ||
13343 | static void alc861_toshiba_unsol_event(struct hda_codec *codec, | |
13344 | unsigned int res) | |
13345 | { | |
a53d1aec TD |
13346 | if ((res >> 26) == ALC880_HP_EVENT) |
13347 | alc861_toshiba_automute(codec); | |
13348 | } | |
13349 | ||
df694daa KY |
13350 | /* pcm configuration: identiacal with ALC880 */ |
13351 | #define alc861_pcm_analog_playback alc880_pcm_analog_playback | |
13352 | #define alc861_pcm_analog_capture alc880_pcm_analog_capture | |
13353 | #define alc861_pcm_digital_playback alc880_pcm_digital_playback | |
13354 | #define alc861_pcm_digital_capture alc880_pcm_digital_capture | |
13355 | ||
13356 | ||
13357 | #define ALC861_DIGOUT_NID 0x07 | |
13358 | ||
13359 | static struct hda_channel_mode alc861_8ch_modes[1] = { | |
13360 | { 8, NULL } | |
13361 | }; | |
13362 | ||
13363 | static hda_nid_t alc861_dac_nids[4] = { | |
13364 | /* front, surround, clfe, side */ | |
13365 | 0x03, 0x06, 0x05, 0x04 | |
13366 | }; | |
13367 | ||
9c7f852e TI |
13368 | static hda_nid_t alc660_dac_nids[3] = { |
13369 | /* front, clfe, surround */ | |
13370 | 0x03, 0x05, 0x06 | |
13371 | }; | |
13372 | ||
df694daa KY |
13373 | static hda_nid_t alc861_adc_nids[1] = { |
13374 | /* ADC0-2 */ | |
13375 | 0x08, | |
13376 | }; | |
13377 | ||
13378 | static struct hda_input_mux alc861_capture_source = { | |
13379 | .num_items = 5, | |
13380 | .items = { | |
13381 | { "Mic", 0x0 }, | |
13382 | { "Front Mic", 0x3 }, | |
13383 | { "Line", 0x1 }, | |
13384 | { "CD", 0x4 }, | |
13385 | { "Mixer", 0x5 }, | |
13386 | }, | |
13387 | }; | |
13388 | ||
13389 | /* fill in the dac_nids table from the parsed pin configuration */ | |
f12ab1e0 TI |
13390 | static int alc861_auto_fill_dac_nids(struct alc_spec *spec, |
13391 | const struct auto_pin_cfg *cfg) | |
df694daa KY |
13392 | { |
13393 | int i; | |
13394 | hda_nid_t nid; | |
13395 | ||
13396 | spec->multiout.dac_nids = spec->private_dac_nids; | |
13397 | for (i = 0; i < cfg->line_outs; i++) { | |
13398 | nid = cfg->line_out_pins[i]; | |
13399 | if (nid) { | |
13400 | if (i >= ARRAY_SIZE(alc861_dac_nids)) | |
13401 | continue; | |
13402 | spec->multiout.dac_nids[i] = alc861_dac_nids[i]; | |
13403 | } | |
13404 | } | |
13405 | spec->multiout.num_dacs = cfg->line_outs; | |
13406 | return 0; | |
13407 | } | |
13408 | ||
13409 | /* add playback controls from the parsed DAC table */ | |
13410 | static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec, | |
13411 | const struct auto_pin_cfg *cfg) | |
13412 | { | |
13413 | char name[32]; | |
f12ab1e0 TI |
13414 | static const char *chname[4] = { |
13415 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
13416 | }; | |
df694daa KY |
13417 | hda_nid_t nid; |
13418 | int i, idx, err; | |
13419 | ||
13420 | for (i = 0; i < cfg->line_outs; i++) { | |
13421 | nid = spec->multiout.dac_nids[i]; | |
f12ab1e0 | 13422 | if (!nid) |
df694daa KY |
13423 | continue; |
13424 | if (nid == 0x05) { | |
13425 | /* Center/LFE */ | |
f12ab1e0 TI |
13426 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
13427 | "Center Playback Switch", | |
13428 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, | |
13429 | HDA_OUTPUT)); | |
13430 | if (err < 0) | |
df694daa | 13431 | return err; |
f12ab1e0 TI |
13432 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
13433 | "LFE Playback Switch", | |
13434 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
13435 | HDA_OUTPUT)); | |
13436 | if (err < 0) | |
df694daa KY |
13437 | return err; |
13438 | } else { | |
f12ab1e0 TI |
13439 | for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; |
13440 | idx++) | |
df694daa KY |
13441 | if (nid == alc861_dac_nids[idx]) |
13442 | break; | |
13443 | sprintf(name, "%s Playback Switch", chname[idx]); | |
f12ab1e0 TI |
13444 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
13445 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
13446 | HDA_OUTPUT)); | |
13447 | if (err < 0) | |
df694daa KY |
13448 | return err; |
13449 | } | |
13450 | } | |
13451 | return 0; | |
13452 | } | |
13453 | ||
13454 | static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin) | |
13455 | { | |
13456 | int err; | |
13457 | hda_nid_t nid; | |
13458 | ||
f12ab1e0 | 13459 | if (!pin) |
df694daa KY |
13460 | return 0; |
13461 | ||
13462 | if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) { | |
13463 | nid = 0x03; | |
f12ab1e0 TI |
13464 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
13465 | "Headphone Playback Switch", | |
13466 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
13467 | if (err < 0) | |
df694daa KY |
13468 | return err; |
13469 | spec->multiout.hp_nid = nid; | |
13470 | } | |
13471 | return 0; | |
13472 | } | |
13473 | ||
13474 | /* create playback/capture controls for input pins */ | |
f12ab1e0 TI |
13475 | static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, |
13476 | const struct auto_pin_cfg *cfg) | |
df694daa | 13477 | { |
df694daa KY |
13478 | struct hda_input_mux *imux = &spec->private_imux; |
13479 | int i, err, idx, idx1; | |
13480 | ||
13481 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
f12ab1e0 | 13482 | switch (cfg->input_pins[i]) { |
df694daa KY |
13483 | case 0x0c: |
13484 | idx1 = 1; | |
f12ab1e0 | 13485 | idx = 2; /* Line In */ |
df694daa KY |
13486 | break; |
13487 | case 0x0f: | |
13488 | idx1 = 2; | |
f12ab1e0 | 13489 | idx = 2; /* Line In */ |
df694daa KY |
13490 | break; |
13491 | case 0x0d: | |
13492 | idx1 = 0; | |
f12ab1e0 | 13493 | idx = 1; /* Mic In */ |
df694daa | 13494 | break; |
f12ab1e0 | 13495 | case 0x10: |
df694daa | 13496 | idx1 = 3; |
f12ab1e0 | 13497 | idx = 1; /* Mic In */ |
df694daa KY |
13498 | break; |
13499 | case 0x11: | |
13500 | idx1 = 4; | |
f12ab1e0 | 13501 | idx = 0; /* CD */ |
df694daa KY |
13502 | break; |
13503 | default: | |
13504 | continue; | |
13505 | } | |
13506 | ||
4a471b7d TI |
13507 | err = new_analog_input(spec, cfg->input_pins[i], |
13508 | auto_pin_cfg_labels[i], idx, 0x15); | |
df694daa KY |
13509 | if (err < 0) |
13510 | return err; | |
13511 | ||
4a471b7d | 13512 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
df694daa | 13513 | imux->items[imux->num_items].index = idx1; |
f12ab1e0 | 13514 | imux->num_items++; |
df694daa KY |
13515 | } |
13516 | return 0; | |
13517 | } | |
13518 | ||
f12ab1e0 TI |
13519 | static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, |
13520 | hda_nid_t nid, | |
df694daa KY |
13521 | int pin_type, int dac_idx) |
13522 | { | |
564c5bea JL |
13523 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
13524 | pin_type); | |
13525 | snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
13526 | AMP_OUT_UNMUTE); | |
df694daa KY |
13527 | } |
13528 | ||
13529 | static void alc861_auto_init_multi_out(struct hda_codec *codec) | |
13530 | { | |
13531 | struct alc_spec *spec = codec->spec; | |
13532 | int i; | |
13533 | ||
bc9f98a9 | 13534 | alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b); |
df694daa KY |
13535 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
13536 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 13537 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
df694daa | 13538 | if (nid) |
baba8ee9 | 13539 | alc861_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 13540 | spec->multiout.dac_nids[i]); |
df694daa KY |
13541 | } |
13542 | } | |
13543 | ||
13544 | static void alc861_auto_init_hp_out(struct hda_codec *codec) | |
13545 | { | |
13546 | struct alc_spec *spec = codec->spec; | |
13547 | hda_nid_t pin; | |
13548 | ||
eb06ed8f | 13549 | pin = spec->autocfg.hp_pins[0]; |
df694daa | 13550 | if (pin) /* connect to front */ |
f12ab1e0 TI |
13551 | alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, |
13552 | spec->multiout.dac_nids[0]); | |
f6c7e546 TI |
13553 | pin = spec->autocfg.speaker_pins[0]; |
13554 | if (pin) | |
13555 | alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
df694daa KY |
13556 | } |
13557 | ||
13558 | static void alc861_auto_init_analog_input(struct hda_codec *codec) | |
13559 | { | |
13560 | struct alc_spec *spec = codec->spec; | |
13561 | int i; | |
13562 | ||
13563 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
13564 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
f12ab1e0 TI |
13565 | if (nid >= 0x0c && nid <= 0x11) { |
13566 | snd_hda_codec_write(codec, nid, 0, | |
13567 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
13568 | i <= AUTO_PIN_FRONT_MIC ? | |
13569 | PIN_VREF80 : PIN_IN); | |
df694daa KY |
13570 | } |
13571 | } | |
13572 | } | |
13573 | ||
13574 | /* parse the BIOS configuration and set up the alc_spec */ | |
f12ab1e0 TI |
13575 | /* return 1 if successful, 0 if the proper config is not found, |
13576 | * or a negative error code | |
13577 | */ | |
df694daa KY |
13578 | static int alc861_parse_auto_config(struct hda_codec *codec) |
13579 | { | |
13580 | struct alc_spec *spec = codec->spec; | |
13581 | int err; | |
13582 | static hda_nid_t alc861_ignore[] = { 0x1d, 0 }; | |
13583 | ||
f12ab1e0 TI |
13584 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
13585 | alc861_ignore); | |
13586 | if (err < 0) | |
df694daa | 13587 | return err; |
f12ab1e0 | 13588 | if (!spec->autocfg.line_outs) |
df694daa KY |
13589 | return 0; /* can't find valid BIOS pin config */ |
13590 | ||
f12ab1e0 TI |
13591 | err = alc861_auto_fill_dac_nids(spec, &spec->autocfg); |
13592 | if (err < 0) | |
13593 | return err; | |
13594 | err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
13595 | if (err < 0) | |
13596 | return err; | |
13597 | err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); | |
13598 | if (err < 0) | |
13599 | return err; | |
13600 | err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
13601 | if (err < 0) | |
df694daa KY |
13602 | return err; |
13603 | ||
13604 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
13605 | ||
13606 | if (spec->autocfg.dig_out_pin) | |
13607 | spec->multiout.dig_out_nid = ALC861_DIGOUT_NID; | |
13608 | ||
603c4019 | 13609 | if (spec->kctls.list) |
d88897ea | 13610 | add_mixer(spec, spec->kctls.list); |
df694daa | 13611 | |
d88897ea | 13612 | add_verb(spec, alc861_auto_init_verbs); |
df694daa | 13613 | |
a1e8d2da | 13614 | spec->num_mux_defs = 1; |
df694daa KY |
13615 | spec->input_mux = &spec->private_imux; |
13616 | ||
13617 | spec->adc_nids = alc861_adc_nids; | |
13618 | spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); | |
f9e336f6 | 13619 | set_capture_mixer(spec); |
df694daa | 13620 | |
e044c39a | 13621 | store_pin_configs(codec); |
df694daa KY |
13622 | return 1; |
13623 | } | |
13624 | ||
ae6b813a TI |
13625 | /* additional initialization for auto-configuration model */ |
13626 | static void alc861_auto_init(struct hda_codec *codec) | |
df694daa | 13627 | { |
f6c7e546 | 13628 | struct alc_spec *spec = codec->spec; |
df694daa KY |
13629 | alc861_auto_init_multi_out(codec); |
13630 | alc861_auto_init_hp_out(codec); | |
13631 | alc861_auto_init_analog_input(codec); | |
f6c7e546 | 13632 | if (spec->unsol_event) |
7fb0d78f | 13633 | alc_inithook(codec); |
df694daa KY |
13634 | } |
13635 | ||
cb53c626 TI |
13636 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
13637 | static struct hda_amp_list alc861_loopbacks[] = { | |
13638 | { 0x15, HDA_INPUT, 0 }, | |
13639 | { 0x15, HDA_INPUT, 1 }, | |
13640 | { 0x15, HDA_INPUT, 2 }, | |
13641 | { 0x15, HDA_INPUT, 3 }, | |
13642 | { } /* end */ | |
13643 | }; | |
13644 | #endif | |
13645 | ||
df694daa KY |
13646 | |
13647 | /* | |
13648 | * configuration and preset | |
13649 | */ | |
f5fcc13c TI |
13650 | static const char *alc861_models[ALC861_MODEL_LAST] = { |
13651 | [ALC861_3ST] = "3stack", | |
13652 | [ALC660_3ST] = "3stack-660", | |
13653 | [ALC861_3ST_DIG] = "3stack-dig", | |
13654 | [ALC861_6ST_DIG] = "6stack-dig", | |
13655 | [ALC861_UNIWILL_M31] = "uniwill-m31", | |
13656 | [ALC861_TOSHIBA] = "toshiba", | |
13657 | [ALC861_ASUS] = "asus", | |
13658 | [ALC861_ASUS_LAPTOP] = "asus-laptop", | |
13659 | [ALC861_AUTO] = "auto", | |
13660 | }; | |
13661 | ||
13662 | static struct snd_pci_quirk alc861_cfg_tbl[] = { | |
687a47bd | 13663 | SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST), |
f5fcc13c TI |
13664 | SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP), |
13665 | SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP), | |
13666 | SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS), | |
ac3e3741 | 13667 | SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP), |
83c34218 | 13668 | SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG), |
ad5e7737 | 13669 | SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA), |
341d4eb0 TI |
13670 | /* FIXME: the entry below breaks Toshiba A100 (model=auto works!) |
13671 | * Any other models that need this preset? | |
13672 | */ | |
13673 | /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */ | |
ac3e3741 TI |
13674 | SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST), |
13675 | SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST), | |
4147dab6 | 13676 | SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31), |
ac3e3741 TI |
13677 | SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31), |
13678 | SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP), | |
13679 | /* FIXME: the below seems conflict */ | |
13680 | /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */ | |
07e038b3 | 13681 | SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST), |
f5fcc13c | 13682 | SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST), |
df694daa KY |
13683 | {} |
13684 | }; | |
13685 | ||
13686 | static struct alc_config_preset alc861_presets[] = { | |
13687 | [ALC861_3ST] = { | |
13688 | .mixers = { alc861_3ST_mixer }, | |
13689 | .init_verbs = { alc861_threestack_init_verbs }, | |
13690 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
13691 | .dac_nids = alc861_dac_nids, | |
13692 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
13693 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 13694 | .need_dac_fix = 1, |
df694daa KY |
13695 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
13696 | .adc_nids = alc861_adc_nids, | |
13697 | .input_mux = &alc861_capture_source, | |
13698 | }, | |
13699 | [ALC861_3ST_DIG] = { | |
13700 | .mixers = { alc861_base_mixer }, | |
13701 | .init_verbs = { alc861_threestack_init_verbs }, | |
13702 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
13703 | .dac_nids = alc861_dac_nids, | |
13704 | .dig_out_nid = ALC861_DIGOUT_NID, | |
13705 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
13706 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 13707 | .need_dac_fix = 1, |
df694daa KY |
13708 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
13709 | .adc_nids = alc861_adc_nids, | |
13710 | .input_mux = &alc861_capture_source, | |
13711 | }, | |
13712 | [ALC861_6ST_DIG] = { | |
13713 | .mixers = { alc861_base_mixer }, | |
13714 | .init_verbs = { alc861_base_init_verbs }, | |
13715 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
13716 | .dac_nids = alc861_dac_nids, | |
13717 | .dig_out_nid = ALC861_DIGOUT_NID, | |
13718 | .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes), | |
13719 | .channel_mode = alc861_8ch_modes, | |
13720 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
13721 | .adc_nids = alc861_adc_nids, | |
13722 | .input_mux = &alc861_capture_source, | |
13723 | }, | |
9c7f852e TI |
13724 | [ALC660_3ST] = { |
13725 | .mixers = { alc861_3ST_mixer }, | |
13726 | .init_verbs = { alc861_threestack_init_verbs }, | |
13727 | .num_dacs = ARRAY_SIZE(alc660_dac_nids), | |
13728 | .dac_nids = alc660_dac_nids, | |
13729 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
13730 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 13731 | .need_dac_fix = 1, |
9c7f852e TI |
13732 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
13733 | .adc_nids = alc861_adc_nids, | |
13734 | .input_mux = &alc861_capture_source, | |
13735 | }, | |
22309c3e TI |
13736 | [ALC861_UNIWILL_M31] = { |
13737 | .mixers = { alc861_uniwill_m31_mixer }, | |
13738 | .init_verbs = { alc861_uniwill_m31_init_verbs }, | |
13739 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
13740 | .dac_nids = alc861_dac_nids, | |
13741 | .dig_out_nid = ALC861_DIGOUT_NID, | |
13742 | .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes), | |
13743 | .channel_mode = alc861_uniwill_m31_modes, | |
13744 | .need_dac_fix = 1, | |
13745 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
13746 | .adc_nids = alc861_adc_nids, | |
13747 | .input_mux = &alc861_capture_source, | |
13748 | }, | |
a53d1aec TD |
13749 | [ALC861_TOSHIBA] = { |
13750 | .mixers = { alc861_toshiba_mixer }, | |
f12ab1e0 TI |
13751 | .init_verbs = { alc861_base_init_verbs, |
13752 | alc861_toshiba_init_verbs }, | |
a53d1aec TD |
13753 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), |
13754 | .dac_nids = alc861_dac_nids, | |
13755 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
13756 | .channel_mode = alc883_3ST_2ch_modes, | |
13757 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
13758 | .adc_nids = alc861_adc_nids, | |
13759 | .input_mux = &alc861_capture_source, | |
13760 | .unsol_event = alc861_toshiba_unsol_event, | |
13761 | .init_hook = alc861_toshiba_automute, | |
13762 | }, | |
7cdbff94 MD |
13763 | [ALC861_ASUS] = { |
13764 | .mixers = { alc861_asus_mixer }, | |
13765 | .init_verbs = { alc861_asus_init_verbs }, | |
13766 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
13767 | .dac_nids = alc861_dac_nids, | |
13768 | .dig_out_nid = ALC861_DIGOUT_NID, | |
13769 | .num_channel_mode = ARRAY_SIZE(alc861_asus_modes), | |
13770 | .channel_mode = alc861_asus_modes, | |
13771 | .need_dac_fix = 1, | |
13772 | .hp_nid = 0x06, | |
13773 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
13774 | .adc_nids = alc861_adc_nids, | |
13775 | .input_mux = &alc861_capture_source, | |
13776 | }, | |
56bb0cab TI |
13777 | [ALC861_ASUS_LAPTOP] = { |
13778 | .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer }, | |
13779 | .init_verbs = { alc861_asus_init_verbs, | |
13780 | alc861_asus_laptop_init_verbs }, | |
13781 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
13782 | .dac_nids = alc861_dac_nids, | |
13783 | .dig_out_nid = ALC861_DIGOUT_NID, | |
13784 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
13785 | .channel_mode = alc883_3ST_2ch_modes, | |
13786 | .need_dac_fix = 1, | |
13787 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
13788 | .adc_nids = alc861_adc_nids, | |
13789 | .input_mux = &alc861_capture_source, | |
13790 | }, | |
13791 | }; | |
df694daa KY |
13792 | |
13793 | ||
13794 | static int patch_alc861(struct hda_codec *codec) | |
13795 | { | |
13796 | struct alc_spec *spec; | |
13797 | int board_config; | |
13798 | int err; | |
13799 | ||
dc041e0b | 13800 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
df694daa KY |
13801 | if (spec == NULL) |
13802 | return -ENOMEM; | |
13803 | ||
f12ab1e0 | 13804 | codec->spec = spec; |
df694daa | 13805 | |
f5fcc13c TI |
13806 | board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST, |
13807 | alc861_models, | |
13808 | alc861_cfg_tbl); | |
9c7f852e | 13809 | |
f5fcc13c | 13810 | if (board_config < 0) { |
9c7f852e TI |
13811 | printk(KERN_INFO "hda_codec: Unknown model for ALC861, " |
13812 | "trying auto-probe from BIOS...\n"); | |
df694daa KY |
13813 | board_config = ALC861_AUTO; |
13814 | } | |
13815 | ||
13816 | if (board_config == ALC861_AUTO) { | |
13817 | /* automatic parse from the BIOS config */ | |
13818 | err = alc861_parse_auto_config(codec); | |
13819 | if (err < 0) { | |
13820 | alc_free(codec); | |
13821 | return err; | |
f12ab1e0 | 13822 | } else if (!err) { |
9c7f852e TI |
13823 | printk(KERN_INFO |
13824 | "hda_codec: Cannot set up configuration " | |
13825 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
13826 | board_config = ALC861_3ST_DIG; |
13827 | } | |
13828 | } | |
13829 | ||
13830 | if (board_config != ALC861_AUTO) | |
13831 | setup_preset(spec, &alc861_presets[board_config]); | |
13832 | ||
13833 | spec->stream_name_analog = "ALC861 Analog"; | |
13834 | spec->stream_analog_playback = &alc861_pcm_analog_playback; | |
13835 | spec->stream_analog_capture = &alc861_pcm_analog_capture; | |
13836 | ||
13837 | spec->stream_name_digital = "ALC861 Digital"; | |
13838 | spec->stream_digital_playback = &alc861_pcm_digital_playback; | |
13839 | spec->stream_digital_capture = &alc861_pcm_digital_capture; | |
13840 | ||
2134ea4f TI |
13841 | spec->vmaster_nid = 0x03; |
13842 | ||
df694daa KY |
13843 | codec->patch_ops = alc_patch_ops; |
13844 | if (board_config == ALC861_AUTO) | |
ae6b813a | 13845 | spec->init_hook = alc861_auto_init; |
cb53c626 TI |
13846 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
13847 | if (!spec->loopback.amplist) | |
13848 | spec->loopback.amplist = alc861_loopbacks; | |
13849 | #endif | |
daead538 | 13850 | codec->proc_widget_hook = print_realtek_coef; |
ea1fb29a | 13851 | |
1da177e4 LT |
13852 | return 0; |
13853 | } | |
13854 | ||
f32610ed JS |
13855 | /* |
13856 | * ALC861-VD support | |
13857 | * | |
13858 | * Based on ALC882 | |
13859 | * | |
13860 | * In addition, an independent DAC | |
13861 | */ | |
13862 | #define ALC861VD_DIGOUT_NID 0x06 | |
13863 | ||
13864 | static hda_nid_t alc861vd_dac_nids[4] = { | |
13865 | /* front, surr, clfe, side surr */ | |
13866 | 0x02, 0x03, 0x04, 0x05 | |
13867 | }; | |
13868 | ||
13869 | /* dac_nids for ALC660vd are in a different order - according to | |
13870 | * Realtek's driver. | |
13871 | * This should probably tesult in a different mixer for 6stack models | |
13872 | * of ALC660vd codecs, but for now there is only 3stack mixer | |
13873 | * - and it is the same as in 861vd. | |
13874 | * adc_nids in ALC660vd are (is) the same as in 861vd | |
13875 | */ | |
13876 | static hda_nid_t alc660vd_dac_nids[3] = { | |
13877 | /* front, rear, clfe, rear_surr */ | |
13878 | 0x02, 0x04, 0x03 | |
13879 | }; | |
13880 | ||
13881 | static hda_nid_t alc861vd_adc_nids[1] = { | |
13882 | /* ADC0 */ | |
13883 | 0x09, | |
13884 | }; | |
13885 | ||
e1406348 TI |
13886 | static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 }; |
13887 | ||
f32610ed JS |
13888 | /* input MUX */ |
13889 | /* FIXME: should be a matrix-type input source selection */ | |
13890 | static struct hda_input_mux alc861vd_capture_source = { | |
13891 | .num_items = 4, | |
13892 | .items = { | |
13893 | { "Mic", 0x0 }, | |
13894 | { "Front Mic", 0x1 }, | |
13895 | { "Line", 0x2 }, | |
13896 | { "CD", 0x4 }, | |
13897 | }, | |
13898 | }; | |
13899 | ||
272a527c | 13900 | static struct hda_input_mux alc861vd_dallas_capture_source = { |
b419f346 | 13901 | .num_items = 2, |
272a527c | 13902 | .items = { |
b419f346 TD |
13903 | { "Ext Mic", 0x0 }, |
13904 | { "Int Mic", 0x1 }, | |
272a527c KY |
13905 | }, |
13906 | }; | |
13907 | ||
d1a991a6 KY |
13908 | static struct hda_input_mux alc861vd_hp_capture_source = { |
13909 | .num_items = 2, | |
13910 | .items = { | |
13911 | { "Front Mic", 0x0 }, | |
13912 | { "ATAPI Mic", 0x1 }, | |
13913 | }, | |
13914 | }; | |
13915 | ||
f32610ed JS |
13916 | /* |
13917 | * 2ch mode | |
13918 | */ | |
13919 | static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = { | |
13920 | { 2, NULL } | |
13921 | }; | |
13922 | ||
13923 | /* | |
13924 | * 6ch mode | |
13925 | */ | |
13926 | static struct hda_verb alc861vd_6stack_ch6_init[] = { | |
13927 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
13928 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13929 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13930 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13931 | { } /* end */ | |
13932 | }; | |
13933 | ||
13934 | /* | |
13935 | * 8ch mode | |
13936 | */ | |
13937 | static struct hda_verb alc861vd_6stack_ch8_init[] = { | |
13938 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13939 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13940 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13941 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13942 | { } /* end */ | |
13943 | }; | |
13944 | ||
13945 | static struct hda_channel_mode alc861vd_6stack_modes[2] = { | |
13946 | { 6, alc861vd_6stack_ch6_init }, | |
13947 | { 8, alc861vd_6stack_ch8_init }, | |
13948 | }; | |
13949 | ||
13950 | static struct snd_kcontrol_new alc861vd_chmode_mixer[] = { | |
13951 | { | |
13952 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
13953 | .name = "Channel Mode", | |
13954 | .info = alc_ch_mode_info, | |
13955 | .get = alc_ch_mode_get, | |
13956 | .put = alc_ch_mode_put, | |
13957 | }, | |
13958 | { } /* end */ | |
13959 | }; | |
13960 | ||
f32610ed JS |
13961 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
13962 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
13963 | */ | |
13964 | static struct snd_kcontrol_new alc861vd_6st_mixer[] = { | |
13965 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
13966 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
13967 | ||
13968 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
13969 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
13970 | ||
13971 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, | |
13972 | HDA_OUTPUT), | |
13973 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, | |
13974 | HDA_OUTPUT), | |
13975 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
13976 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
13977 | ||
13978 | HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT), | |
13979 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
13980 | ||
13981 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
13982 | ||
13983 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
13984 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
13985 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
13986 | ||
13987 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
13988 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
13989 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
13990 | ||
13991 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
13992 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
13993 | ||
13994 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
13995 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
13996 | ||
13997 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
13998 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
13999 | ||
14000 | { } /* end */ | |
14001 | }; | |
14002 | ||
14003 | static struct snd_kcontrol_new alc861vd_3st_mixer[] = { | |
14004 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
14005 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
14006 | ||
14007 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
14008 | ||
14009 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
14010 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14011 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14012 | ||
14013 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
14014 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14015 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
14016 | ||
14017 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
14018 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
14019 | ||
14020 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
14021 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
14022 | ||
14023 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
14024 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
14025 | ||
14026 | { } /* end */ | |
14027 | }; | |
14028 | ||
bdd148a3 KY |
14029 | static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = { |
14030 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
14031 | /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/ | |
14032 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
14033 | ||
14034 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
14035 | ||
14036 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
14037 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14038 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14039 | ||
14040 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
14041 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14042 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
14043 | ||
14044 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
14045 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
14046 | ||
14047 | { } /* end */ | |
14048 | }; | |
14049 | ||
b419f346 TD |
14050 | /* Pin assignment: Speaker=0x14, HP = 0x15, |
14051 | * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d | |
272a527c KY |
14052 | */ |
14053 | static struct snd_kcontrol_new alc861vd_dallas_mixer[] = { | |
b419f346 TD |
14054 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), |
14055 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT), | |
272a527c KY |
14056 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
14057 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), | |
b419f346 TD |
14058 | HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT), |
14059 | HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14060 | HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14061 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
14062 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14063 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
14064 | HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT), | |
14065 | HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT), | |
272a527c KY |
14066 | { } /* end */ |
14067 | }; | |
14068 | ||
d1a991a6 KY |
14069 | /* Pin assignment: Speaker=0x14, Line-out = 0x15, |
14070 | * Front Mic=0x18, ATAPI Mic = 0x19, | |
14071 | */ | |
14072 | static struct snd_kcontrol_new alc861vd_hp_mixer[] = { | |
14073 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
14074 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
14075 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
14076 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), | |
14077 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14078 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14079 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14080 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
ea1fb29a | 14081 | |
d1a991a6 KY |
14082 | { } /* end */ |
14083 | }; | |
14084 | ||
f32610ed JS |
14085 | /* |
14086 | * generic initialization of ADC, input mixers and output mixers | |
14087 | */ | |
14088 | static struct hda_verb alc861vd_volume_init_verbs[] = { | |
14089 | /* | |
14090 | * Unmute ADC0 and set the default input to mic-in | |
14091 | */ | |
14092 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
14093 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
14094 | ||
14095 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of | |
14096 | * the analog-loopback mixer widget | |
14097 | */ | |
14098 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
14099 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
14100 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
14101 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
14102 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
14103 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
f32610ed JS |
14104 | |
14105 | /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */ | |
bdd148a3 KY |
14106 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
14107 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
14108 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f32610ed | 14109 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
f32610ed JS |
14110 | |
14111 | /* | |
14112 | * Set up output mixers (0x02 - 0x05) | |
14113 | */ | |
14114 | /* set vol=0 to output mixers */ | |
14115 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14116 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14117 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14118 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14119 | ||
14120 | /* set up input amps for analog loopback */ | |
14121 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
14122 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14123 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
14124 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14125 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
14126 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14127 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
14128 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14129 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
14130 | ||
14131 | { } | |
14132 | }; | |
14133 | ||
14134 | /* | |
14135 | * 3-stack pin configuration: | |
14136 | * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b | |
14137 | */ | |
14138 | static struct hda_verb alc861vd_3stack_init_verbs[] = { | |
14139 | /* | |
14140 | * Set pin mode and muting | |
14141 | */ | |
14142 | /* set front pin widgets 0x14 for output */ | |
14143 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
14144 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14145 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
14146 | ||
14147 | /* Mic (rear) pin: input vref at 80% */ | |
14148 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
14149 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
14150 | /* Front Mic pin: input vref at 80% */ | |
14151 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
14152 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
14153 | /* Line In pin: input */ | |
14154 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
14155 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
14156 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
14157 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
14158 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14159 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
14160 | /* CD pin widget for input */ | |
14161 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
14162 | ||
14163 | { } | |
14164 | }; | |
14165 | ||
14166 | /* | |
14167 | * 6-stack pin configuration: | |
14168 | */ | |
14169 | static struct hda_verb alc861vd_6stack_init_verbs[] = { | |
14170 | /* | |
14171 | * Set pin mode and muting | |
14172 | */ | |
14173 | /* set front pin widgets 0x14 for output */ | |
14174 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
14175 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14176 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
14177 | ||
14178 | /* Rear Pin: output 1 (0x0d) */ | |
14179 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
14180 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14181 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
14182 | /* CLFE Pin: output 2 (0x0e) */ | |
14183 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
14184 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14185 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
14186 | /* Side Pin: output 3 (0x0f) */ | |
14187 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
14188 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14189 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
14190 | ||
14191 | /* Mic (rear) pin: input vref at 80% */ | |
14192 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
14193 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
14194 | /* Front Mic pin: input vref at 80% */ | |
14195 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
14196 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
14197 | /* Line In pin: input */ | |
14198 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
14199 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
14200 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
14201 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
14202 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14203 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
14204 | /* CD pin widget for input */ | |
14205 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
14206 | ||
14207 | { } | |
14208 | }; | |
14209 | ||
bdd148a3 KY |
14210 | static struct hda_verb alc861vd_eapd_verbs[] = { |
14211 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
14212 | { } | |
14213 | }; | |
14214 | ||
f9423e7a KY |
14215 | static struct hda_verb alc660vd_eapd_verbs[] = { |
14216 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
14217 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
14218 | { } | |
14219 | }; | |
14220 | ||
bdd148a3 KY |
14221 | static struct hda_verb alc861vd_lenovo_unsol_verbs[] = { |
14222 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
14223 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
14224 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
14225 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
ea1fb29a | 14226 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, |
bdd148a3 KY |
14227 | {} |
14228 | }; | |
14229 | ||
14230 | /* toggle speaker-output according to the hp-jack state */ | |
14231 | static void alc861vd_lenovo_hp_automute(struct hda_codec *codec) | |
14232 | { | |
14233 | unsigned int present; | |
14234 | unsigned char bits; | |
14235 | ||
14236 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
14237 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
14238 | bits = present ? HDA_AMP_MUTE : 0; |
14239 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
14240 | HDA_AMP_MUTE, bits); | |
bdd148a3 KY |
14241 | } |
14242 | ||
14243 | static void alc861vd_lenovo_mic_automute(struct hda_codec *codec) | |
14244 | { | |
14245 | unsigned int present; | |
14246 | unsigned char bits; | |
14247 | ||
14248 | present = snd_hda_codec_read(codec, 0x18, 0, | |
14249 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
14250 | bits = present ? HDA_AMP_MUTE : 0; |
14251 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, | |
14252 | HDA_AMP_MUTE, bits); | |
bdd148a3 KY |
14253 | } |
14254 | ||
14255 | static void alc861vd_lenovo_automute(struct hda_codec *codec) | |
14256 | { | |
14257 | alc861vd_lenovo_hp_automute(codec); | |
14258 | alc861vd_lenovo_mic_automute(codec); | |
14259 | } | |
14260 | ||
14261 | static void alc861vd_lenovo_unsol_event(struct hda_codec *codec, | |
14262 | unsigned int res) | |
14263 | { | |
14264 | switch (res >> 26) { | |
14265 | case ALC880_HP_EVENT: | |
14266 | alc861vd_lenovo_hp_automute(codec); | |
14267 | break; | |
14268 | case ALC880_MIC_EVENT: | |
14269 | alc861vd_lenovo_mic_automute(codec); | |
14270 | break; | |
14271 | } | |
14272 | } | |
14273 | ||
272a527c KY |
14274 | static struct hda_verb alc861vd_dallas_verbs[] = { |
14275 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14276 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14277 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14278 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14279 | ||
14280 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
14281 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
14282 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14283 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
14284 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14285 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
14286 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14287 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
ea1fb29a | 14288 | |
272a527c KY |
14289 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
14290 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14291 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
14292 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14293 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
14294 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14295 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
14296 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14297 | ||
14298 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | |
14299 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
14300 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | |
14301 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
14302 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
14303 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
14304 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
14305 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
14306 | ||
14307 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
14308 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
14309 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
14310 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
14311 | ||
14312 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
ea1fb29a | 14313 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
272a527c KY |
14314 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, |
14315 | ||
14316 | { } /* end */ | |
14317 | }; | |
14318 | ||
14319 | /* toggle speaker-output according to the hp-jack state */ | |
14320 | static void alc861vd_dallas_automute(struct hda_codec *codec) | |
14321 | { | |
14322 | unsigned int present; | |
14323 | ||
14324 | present = snd_hda_codec_read(codec, 0x15, 0, | |
14325 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
14326 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
14327 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c KY |
14328 | } |
14329 | ||
14330 | static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res) | |
14331 | { | |
14332 | if ((res >> 26) == ALC880_HP_EVENT) | |
14333 | alc861vd_dallas_automute(codec); | |
14334 | } | |
14335 | ||
cb53c626 TI |
14336 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
14337 | #define alc861vd_loopbacks alc880_loopbacks | |
14338 | #endif | |
14339 | ||
f32610ed JS |
14340 | /* pcm configuration: identiacal with ALC880 */ |
14341 | #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback | |
14342 | #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture | |
14343 | #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback | |
14344 | #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture | |
14345 | ||
14346 | /* | |
14347 | * configuration and preset | |
14348 | */ | |
14349 | static const char *alc861vd_models[ALC861VD_MODEL_LAST] = { | |
14350 | [ALC660VD_3ST] = "3stack-660", | |
983f8ae4 | 14351 | [ALC660VD_3ST_DIG] = "3stack-660-digout", |
13c94744 | 14352 | [ALC660VD_ASUS_V1S] = "asus-v1s", |
f32610ed JS |
14353 | [ALC861VD_3ST] = "3stack", |
14354 | [ALC861VD_3ST_DIG] = "3stack-digout", | |
14355 | [ALC861VD_6ST_DIG] = "6stack-digout", | |
bdd148a3 | 14356 | [ALC861VD_LENOVO] = "lenovo", |
272a527c | 14357 | [ALC861VD_DALLAS] = "dallas", |
983f8ae4 | 14358 | [ALC861VD_HP] = "hp", |
f32610ed JS |
14359 | [ALC861VD_AUTO] = "auto", |
14360 | }; | |
14361 | ||
14362 | static struct snd_pci_quirk alc861vd_cfg_tbl[] = { | |
ac3e3741 TI |
14363 | SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST), |
14364 | SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP), | |
07e038b3 | 14365 | SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST), |
f32610ed | 14366 | SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST), |
13c94744 | 14367 | SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S), |
6963f84c | 14368 | SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG), |
f32610ed | 14369 | SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST), |
ac3e3741 | 14370 | SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO), |
38baf5ad | 14371 | /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/ |
272a527c | 14372 | SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS), |
542d7c66 | 14373 | SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO), |
b419f346 | 14374 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS), |
39c5d41f | 14375 | SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG), |
ac3e3741 TI |
14376 | SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO), |
14377 | SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO), | |
be321a89 | 14378 | SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 N200", ALC861VD_LENOVO), |
625dc0bf | 14379 | SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG), |
f32610ed JS |
14380 | {} |
14381 | }; | |
14382 | ||
14383 | static struct alc_config_preset alc861vd_presets[] = { | |
14384 | [ALC660VD_3ST] = { | |
14385 | .mixers = { alc861vd_3st_mixer }, | |
14386 | .init_verbs = { alc861vd_volume_init_verbs, | |
14387 | alc861vd_3stack_init_verbs }, | |
14388 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
14389 | .dac_nids = alc660vd_dac_nids, | |
f32610ed JS |
14390 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
14391 | .channel_mode = alc861vd_3stack_2ch_modes, | |
14392 | .input_mux = &alc861vd_capture_source, | |
14393 | }, | |
6963f84c MC |
14394 | [ALC660VD_3ST_DIG] = { |
14395 | .mixers = { alc861vd_3st_mixer }, | |
14396 | .init_verbs = { alc861vd_volume_init_verbs, | |
14397 | alc861vd_3stack_init_verbs }, | |
14398 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
14399 | .dac_nids = alc660vd_dac_nids, | |
14400 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
6963f84c MC |
14401 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
14402 | .channel_mode = alc861vd_3stack_2ch_modes, | |
14403 | .input_mux = &alc861vd_capture_source, | |
14404 | }, | |
f32610ed JS |
14405 | [ALC861VD_3ST] = { |
14406 | .mixers = { alc861vd_3st_mixer }, | |
14407 | .init_verbs = { alc861vd_volume_init_verbs, | |
14408 | alc861vd_3stack_init_verbs }, | |
14409 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
14410 | .dac_nids = alc861vd_dac_nids, | |
14411 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
14412 | .channel_mode = alc861vd_3stack_2ch_modes, | |
14413 | .input_mux = &alc861vd_capture_source, | |
14414 | }, | |
14415 | [ALC861VD_3ST_DIG] = { | |
14416 | .mixers = { alc861vd_3st_mixer }, | |
14417 | .init_verbs = { alc861vd_volume_init_verbs, | |
14418 | alc861vd_3stack_init_verbs }, | |
14419 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
14420 | .dac_nids = alc861vd_dac_nids, | |
14421 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
14422 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
14423 | .channel_mode = alc861vd_3stack_2ch_modes, | |
14424 | .input_mux = &alc861vd_capture_source, | |
14425 | }, | |
14426 | [ALC861VD_6ST_DIG] = { | |
14427 | .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer }, | |
14428 | .init_verbs = { alc861vd_volume_init_verbs, | |
14429 | alc861vd_6stack_init_verbs }, | |
14430 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
14431 | .dac_nids = alc861vd_dac_nids, | |
14432 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
14433 | .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes), | |
14434 | .channel_mode = alc861vd_6stack_modes, | |
14435 | .input_mux = &alc861vd_capture_source, | |
14436 | }, | |
bdd148a3 KY |
14437 | [ALC861VD_LENOVO] = { |
14438 | .mixers = { alc861vd_lenovo_mixer }, | |
14439 | .init_verbs = { alc861vd_volume_init_verbs, | |
14440 | alc861vd_3stack_init_verbs, | |
14441 | alc861vd_eapd_verbs, | |
14442 | alc861vd_lenovo_unsol_verbs }, | |
14443 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
14444 | .dac_nids = alc660vd_dac_nids, | |
bdd148a3 KY |
14445 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
14446 | .channel_mode = alc861vd_3stack_2ch_modes, | |
14447 | .input_mux = &alc861vd_capture_source, | |
14448 | .unsol_event = alc861vd_lenovo_unsol_event, | |
14449 | .init_hook = alc861vd_lenovo_automute, | |
14450 | }, | |
272a527c KY |
14451 | [ALC861VD_DALLAS] = { |
14452 | .mixers = { alc861vd_dallas_mixer }, | |
14453 | .init_verbs = { alc861vd_dallas_verbs }, | |
14454 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
14455 | .dac_nids = alc861vd_dac_nids, | |
272a527c KY |
14456 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
14457 | .channel_mode = alc861vd_3stack_2ch_modes, | |
14458 | .input_mux = &alc861vd_dallas_capture_source, | |
14459 | .unsol_event = alc861vd_dallas_unsol_event, | |
14460 | .init_hook = alc861vd_dallas_automute, | |
d1a991a6 KY |
14461 | }, |
14462 | [ALC861VD_HP] = { | |
14463 | .mixers = { alc861vd_hp_mixer }, | |
14464 | .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs }, | |
14465 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
14466 | .dac_nids = alc861vd_dac_nids, | |
d1a991a6 | 14467 | .dig_out_nid = ALC861VD_DIGOUT_NID, |
d1a991a6 KY |
14468 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
14469 | .channel_mode = alc861vd_3stack_2ch_modes, | |
14470 | .input_mux = &alc861vd_hp_capture_source, | |
14471 | .unsol_event = alc861vd_dallas_unsol_event, | |
14472 | .init_hook = alc861vd_dallas_automute, | |
ea1fb29a | 14473 | }, |
13c94744 TI |
14474 | [ALC660VD_ASUS_V1S] = { |
14475 | .mixers = { alc861vd_lenovo_mixer }, | |
14476 | .init_verbs = { alc861vd_volume_init_verbs, | |
14477 | alc861vd_3stack_init_verbs, | |
14478 | alc861vd_eapd_verbs, | |
14479 | alc861vd_lenovo_unsol_verbs }, | |
14480 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
14481 | .dac_nids = alc660vd_dac_nids, | |
14482 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
14483 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
14484 | .channel_mode = alc861vd_3stack_2ch_modes, | |
14485 | .input_mux = &alc861vd_capture_source, | |
14486 | .unsol_event = alc861vd_lenovo_unsol_event, | |
14487 | .init_hook = alc861vd_lenovo_automute, | |
14488 | }, | |
f32610ed JS |
14489 | }; |
14490 | ||
14491 | /* | |
14492 | * BIOS auto configuration | |
14493 | */ | |
14494 | static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec, | |
14495 | hda_nid_t nid, int pin_type, int dac_idx) | |
14496 | { | |
f6c7e546 | 14497 | alc_set_pin_output(codec, nid, pin_type); |
f32610ed JS |
14498 | } |
14499 | ||
14500 | static void alc861vd_auto_init_multi_out(struct hda_codec *codec) | |
14501 | { | |
14502 | struct alc_spec *spec = codec->spec; | |
14503 | int i; | |
14504 | ||
bc9f98a9 | 14505 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
f32610ed JS |
14506 | for (i = 0; i <= HDA_SIDE; i++) { |
14507 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 14508 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
f32610ed JS |
14509 | if (nid) |
14510 | alc861vd_auto_set_output_and_unmute(codec, nid, | |
baba8ee9 | 14511 | pin_type, i); |
f32610ed JS |
14512 | } |
14513 | } | |
14514 | ||
14515 | ||
14516 | static void alc861vd_auto_init_hp_out(struct hda_codec *codec) | |
14517 | { | |
14518 | struct alc_spec *spec = codec->spec; | |
14519 | hda_nid_t pin; | |
14520 | ||
14521 | pin = spec->autocfg.hp_pins[0]; | |
14522 | if (pin) /* connect to front and use dac 0 */ | |
14523 | alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
f6c7e546 TI |
14524 | pin = spec->autocfg.speaker_pins[0]; |
14525 | if (pin) | |
14526 | alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
f32610ed JS |
14527 | } |
14528 | ||
14529 | #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid) | |
14530 | #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID | |
14531 | ||
14532 | static void alc861vd_auto_init_analog_input(struct hda_codec *codec) | |
14533 | { | |
14534 | struct alc_spec *spec = codec->spec; | |
14535 | int i; | |
14536 | ||
14537 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
14538 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
14539 | if (alc861vd_is_input_pin(nid)) { | |
14540 | snd_hda_codec_write(codec, nid, 0, | |
14541 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
14542 | i <= AUTO_PIN_FRONT_MIC ? | |
14543 | PIN_VREF80 : PIN_IN); | |
14544 | if (nid != ALC861VD_PIN_CD_NID) | |
14545 | snd_hda_codec_write(codec, nid, 0, | |
14546 | AC_VERB_SET_AMP_GAIN_MUTE, | |
14547 | AMP_OUT_MUTE); | |
14548 | } | |
14549 | } | |
14550 | } | |
14551 | ||
f511b01c TI |
14552 | #define alc861vd_auto_init_input_src alc882_auto_init_input_src |
14553 | ||
f32610ed JS |
14554 | #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02) |
14555 | #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c) | |
14556 | ||
14557 | /* add playback controls from the parsed DAC table */ | |
14558 | /* Based on ALC880 version. But ALC861VD has separate, | |
14559 | * different NIDs for mute/unmute switch and volume control */ | |
14560 | static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec, | |
14561 | const struct auto_pin_cfg *cfg) | |
14562 | { | |
14563 | char name[32]; | |
14564 | static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"}; | |
14565 | hda_nid_t nid_v, nid_s; | |
14566 | int i, err; | |
14567 | ||
14568 | for (i = 0; i < cfg->line_outs; i++) { | |
f12ab1e0 | 14569 | if (!spec->multiout.dac_nids[i]) |
f32610ed JS |
14570 | continue; |
14571 | nid_v = alc861vd_idx_to_mixer_vol( | |
14572 | alc880_dac_to_idx( | |
14573 | spec->multiout.dac_nids[i])); | |
14574 | nid_s = alc861vd_idx_to_mixer_switch( | |
14575 | alc880_dac_to_idx( | |
14576 | spec->multiout.dac_nids[i])); | |
14577 | ||
14578 | if (i == 2) { | |
14579 | /* Center/LFE */ | |
f12ab1e0 TI |
14580 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
14581 | "Center Playback Volume", | |
14582 | HDA_COMPOSE_AMP_VAL(nid_v, 1, 0, | |
14583 | HDA_OUTPUT)); | |
14584 | if (err < 0) | |
f32610ed | 14585 | return err; |
f12ab1e0 TI |
14586 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
14587 | "LFE Playback Volume", | |
14588 | HDA_COMPOSE_AMP_VAL(nid_v, 2, 0, | |
14589 | HDA_OUTPUT)); | |
14590 | if (err < 0) | |
f32610ed | 14591 | return err; |
f12ab1e0 TI |
14592 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
14593 | "Center Playback Switch", | |
14594 | HDA_COMPOSE_AMP_VAL(nid_s, 1, 2, | |
14595 | HDA_INPUT)); | |
14596 | if (err < 0) | |
f32610ed | 14597 | return err; |
f12ab1e0 TI |
14598 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
14599 | "LFE Playback Switch", | |
14600 | HDA_COMPOSE_AMP_VAL(nid_s, 2, 2, | |
14601 | HDA_INPUT)); | |
14602 | if (err < 0) | |
f32610ed JS |
14603 | return err; |
14604 | } else { | |
14605 | sprintf(name, "%s Playback Volume", chname[i]); | |
f12ab1e0 TI |
14606 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
14607 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, | |
14608 | HDA_OUTPUT)); | |
14609 | if (err < 0) | |
f32610ed JS |
14610 | return err; |
14611 | sprintf(name, "%s Playback Switch", chname[i]); | |
f12ab1e0 | 14612 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
bdd148a3 | 14613 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, |
f12ab1e0 TI |
14614 | HDA_INPUT)); |
14615 | if (err < 0) | |
f32610ed JS |
14616 | return err; |
14617 | } | |
14618 | } | |
14619 | return 0; | |
14620 | } | |
14621 | ||
14622 | /* add playback controls for speaker and HP outputs */ | |
14623 | /* Based on ALC880 version. But ALC861VD has separate, | |
14624 | * different NIDs for mute/unmute switch and volume control */ | |
14625 | static int alc861vd_auto_create_extra_out(struct alc_spec *spec, | |
14626 | hda_nid_t pin, const char *pfx) | |
14627 | { | |
14628 | hda_nid_t nid_v, nid_s; | |
14629 | int err; | |
14630 | char name[32]; | |
14631 | ||
f12ab1e0 | 14632 | if (!pin) |
f32610ed JS |
14633 | return 0; |
14634 | ||
14635 | if (alc880_is_fixed_pin(pin)) { | |
14636 | nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
14637 | /* specify the DAC as the extra output */ | |
f12ab1e0 | 14638 | if (!spec->multiout.hp_nid) |
f32610ed JS |
14639 | spec->multiout.hp_nid = nid_v; |
14640 | else | |
14641 | spec->multiout.extra_out_nid[0] = nid_v; | |
14642 | /* control HP volume/switch on the output mixer amp */ | |
14643 | nid_v = alc861vd_idx_to_mixer_vol( | |
14644 | alc880_fixed_pin_idx(pin)); | |
14645 | nid_s = alc861vd_idx_to_mixer_switch( | |
14646 | alc880_fixed_pin_idx(pin)); | |
14647 | ||
14648 | sprintf(name, "%s Playback Volume", pfx); | |
f12ab1e0 TI |
14649 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
14650 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT)); | |
14651 | if (err < 0) | |
f32610ed JS |
14652 | return err; |
14653 | sprintf(name, "%s Playback Switch", pfx); | |
f12ab1e0 TI |
14654 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
14655 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT)); | |
14656 | if (err < 0) | |
f32610ed JS |
14657 | return err; |
14658 | } else if (alc880_is_multi_pin(pin)) { | |
14659 | /* set manual connection */ | |
14660 | /* we have only a switch on HP-out PIN */ | |
14661 | sprintf(name, "%s Playback Switch", pfx); | |
f12ab1e0 TI |
14662 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
14663 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
14664 | if (err < 0) | |
f32610ed JS |
14665 | return err; |
14666 | } | |
14667 | return 0; | |
14668 | } | |
14669 | ||
14670 | /* parse the BIOS configuration and set up the alc_spec | |
14671 | * return 1 if successful, 0 if the proper config is not found, | |
14672 | * or a negative error code | |
14673 | * Based on ALC880 version - had to change it to override | |
14674 | * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */ | |
14675 | static int alc861vd_parse_auto_config(struct hda_codec *codec) | |
14676 | { | |
14677 | struct alc_spec *spec = codec->spec; | |
14678 | int err; | |
14679 | static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; | |
14680 | ||
f12ab1e0 TI |
14681 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
14682 | alc861vd_ignore); | |
14683 | if (err < 0) | |
f32610ed | 14684 | return err; |
f12ab1e0 | 14685 | if (!spec->autocfg.line_outs) |
f32610ed JS |
14686 | return 0; /* can't find valid BIOS pin config */ |
14687 | ||
f12ab1e0 TI |
14688 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
14689 | if (err < 0) | |
14690 | return err; | |
14691 | err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
14692 | if (err < 0) | |
14693 | return err; | |
14694 | err = alc861vd_auto_create_extra_out(spec, | |
14695 | spec->autocfg.speaker_pins[0], | |
14696 | "Speaker"); | |
14697 | if (err < 0) | |
14698 | return err; | |
14699 | err = alc861vd_auto_create_extra_out(spec, | |
14700 | spec->autocfg.hp_pins[0], | |
14701 | "Headphone"); | |
14702 | if (err < 0) | |
14703 | return err; | |
14704 | err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
14705 | if (err < 0) | |
f32610ed JS |
14706 | return err; |
14707 | ||
14708 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
14709 | ||
14710 | if (spec->autocfg.dig_out_pin) | |
14711 | spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID; | |
14712 | ||
603c4019 | 14713 | if (spec->kctls.list) |
d88897ea | 14714 | add_mixer(spec, spec->kctls.list); |
f32610ed | 14715 | |
d88897ea | 14716 | add_verb(spec, alc861vd_volume_init_verbs); |
f32610ed JS |
14717 | |
14718 | spec->num_mux_defs = 1; | |
14719 | spec->input_mux = &spec->private_imux; | |
14720 | ||
776e184e TI |
14721 | err = alc_auto_add_mic_boost(codec); |
14722 | if (err < 0) | |
14723 | return err; | |
14724 | ||
e044c39a | 14725 | store_pin_configs(codec); |
f32610ed JS |
14726 | return 1; |
14727 | } | |
14728 | ||
14729 | /* additional initialization for auto-configuration model */ | |
14730 | static void alc861vd_auto_init(struct hda_codec *codec) | |
14731 | { | |
f6c7e546 | 14732 | struct alc_spec *spec = codec->spec; |
f32610ed JS |
14733 | alc861vd_auto_init_multi_out(codec); |
14734 | alc861vd_auto_init_hp_out(codec); | |
14735 | alc861vd_auto_init_analog_input(codec); | |
f511b01c | 14736 | alc861vd_auto_init_input_src(codec); |
f6c7e546 | 14737 | if (spec->unsol_event) |
7fb0d78f | 14738 | alc_inithook(codec); |
f32610ed JS |
14739 | } |
14740 | ||
14741 | static int patch_alc861vd(struct hda_codec *codec) | |
14742 | { | |
14743 | struct alc_spec *spec; | |
14744 | int err, board_config; | |
14745 | ||
14746 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
14747 | if (spec == NULL) | |
14748 | return -ENOMEM; | |
14749 | ||
14750 | codec->spec = spec; | |
14751 | ||
14752 | board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST, | |
14753 | alc861vd_models, | |
14754 | alc861vd_cfg_tbl); | |
14755 | ||
14756 | if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) { | |
14757 | printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/" | |
14758 | "ALC861VD, trying auto-probe from BIOS...\n"); | |
14759 | board_config = ALC861VD_AUTO; | |
14760 | } | |
14761 | ||
14762 | if (board_config == ALC861VD_AUTO) { | |
14763 | /* automatic parse from the BIOS config */ | |
14764 | err = alc861vd_parse_auto_config(codec); | |
14765 | if (err < 0) { | |
14766 | alc_free(codec); | |
14767 | return err; | |
f12ab1e0 | 14768 | } else if (!err) { |
f32610ed JS |
14769 | printk(KERN_INFO |
14770 | "hda_codec: Cannot set up configuration " | |
14771 | "from BIOS. Using base mode...\n"); | |
14772 | board_config = ALC861VD_3ST; | |
14773 | } | |
14774 | } | |
14775 | ||
14776 | if (board_config != ALC861VD_AUTO) | |
14777 | setup_preset(spec, &alc861vd_presets[board_config]); | |
14778 | ||
2f893286 KY |
14779 | if (codec->vendor_id == 0x10ec0660) { |
14780 | spec->stream_name_analog = "ALC660-VD Analog"; | |
14781 | spec->stream_name_digital = "ALC660-VD Digital"; | |
f9423e7a | 14782 | /* always turn on EAPD */ |
d88897ea | 14783 | add_verb(spec, alc660vd_eapd_verbs); |
2f893286 KY |
14784 | } else { |
14785 | spec->stream_name_analog = "ALC861VD Analog"; | |
14786 | spec->stream_name_digital = "ALC861VD Digital"; | |
14787 | } | |
14788 | ||
f32610ed JS |
14789 | spec->stream_analog_playback = &alc861vd_pcm_analog_playback; |
14790 | spec->stream_analog_capture = &alc861vd_pcm_analog_capture; | |
14791 | ||
f32610ed JS |
14792 | spec->stream_digital_playback = &alc861vd_pcm_digital_playback; |
14793 | spec->stream_digital_capture = &alc861vd_pcm_digital_capture; | |
14794 | ||
14795 | spec->adc_nids = alc861vd_adc_nids; | |
14796 | spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids); | |
e1406348 | 14797 | spec->capsrc_nids = alc861vd_capsrc_nids; |
54cbc9ab | 14798 | spec->is_mix_capture = 1; |
f32610ed | 14799 | |
f9e336f6 | 14800 | set_capture_mixer(spec); |
f32610ed | 14801 | |
2134ea4f TI |
14802 | spec->vmaster_nid = 0x02; |
14803 | ||
f32610ed JS |
14804 | codec->patch_ops = alc_patch_ops; |
14805 | ||
14806 | if (board_config == ALC861VD_AUTO) | |
14807 | spec->init_hook = alc861vd_auto_init; | |
cb53c626 TI |
14808 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
14809 | if (!spec->loopback.amplist) | |
14810 | spec->loopback.amplist = alc861vd_loopbacks; | |
14811 | #endif | |
daead538 | 14812 | codec->proc_widget_hook = print_realtek_coef; |
f32610ed JS |
14813 | |
14814 | return 0; | |
14815 | } | |
14816 | ||
bc9f98a9 KY |
14817 | /* |
14818 | * ALC662 support | |
14819 | * | |
14820 | * ALC662 is almost identical with ALC880 but has cleaner and more flexible | |
14821 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
14822 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
14823 | * 6-channel independent captures. | |
14824 | * | |
14825 | * In addition, an independent DAC for the multi-playback (not used in this | |
14826 | * driver yet). | |
14827 | */ | |
14828 | #define ALC662_DIGOUT_NID 0x06 | |
14829 | #define ALC662_DIGIN_NID 0x0a | |
14830 | ||
14831 | static hda_nid_t alc662_dac_nids[4] = { | |
14832 | /* front, rear, clfe, rear_surr */ | |
14833 | 0x02, 0x03, 0x04 | |
14834 | }; | |
14835 | ||
14836 | static hda_nid_t alc662_adc_nids[1] = { | |
14837 | /* ADC1-2 */ | |
14838 | 0x09, | |
14839 | }; | |
e1406348 | 14840 | |
77a261b7 | 14841 | static hda_nid_t alc662_capsrc_nids[1] = { 0x22 }; |
e1406348 | 14842 | |
bc9f98a9 KY |
14843 | /* input MUX */ |
14844 | /* FIXME: should be a matrix-type input source selection */ | |
bc9f98a9 KY |
14845 | static struct hda_input_mux alc662_capture_source = { |
14846 | .num_items = 4, | |
14847 | .items = { | |
14848 | { "Mic", 0x0 }, | |
14849 | { "Front Mic", 0x1 }, | |
14850 | { "Line", 0x2 }, | |
14851 | { "CD", 0x4 }, | |
14852 | }, | |
14853 | }; | |
14854 | ||
14855 | static struct hda_input_mux alc662_lenovo_101e_capture_source = { | |
14856 | .num_items = 2, | |
14857 | .items = { | |
14858 | { "Mic", 0x1 }, | |
14859 | { "Line", 0x2 }, | |
14860 | }, | |
14861 | }; | |
291702f0 KY |
14862 | |
14863 | static struct hda_input_mux alc662_eeepc_capture_source = { | |
14864 | .num_items = 2, | |
14865 | .items = { | |
14866 | { "i-Mic", 0x1 }, | |
14867 | { "e-Mic", 0x0 }, | |
14868 | }, | |
14869 | }; | |
14870 | ||
6dda9f4a KY |
14871 | static struct hda_input_mux alc663_capture_source = { |
14872 | .num_items = 3, | |
14873 | .items = { | |
14874 | { "Mic", 0x0 }, | |
14875 | { "Front Mic", 0x1 }, | |
14876 | { "Line", 0x2 }, | |
14877 | }, | |
14878 | }; | |
14879 | ||
14880 | static struct hda_input_mux alc663_m51va_capture_source = { | |
14881 | .num_items = 2, | |
14882 | .items = { | |
14883 | { "Ext-Mic", 0x0 }, | |
14884 | { "D-Mic", 0x9 }, | |
14885 | }, | |
14886 | }; | |
14887 | ||
bc9f98a9 KY |
14888 | /* |
14889 | * 2ch mode | |
14890 | */ | |
14891 | static struct hda_channel_mode alc662_3ST_2ch_modes[1] = { | |
14892 | { 2, NULL } | |
14893 | }; | |
14894 | ||
14895 | /* | |
14896 | * 2ch mode | |
14897 | */ | |
14898 | static struct hda_verb alc662_3ST_ch2_init[] = { | |
14899 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
14900 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
14901 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
14902 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
14903 | { } /* end */ | |
14904 | }; | |
14905 | ||
14906 | /* | |
14907 | * 6ch mode | |
14908 | */ | |
14909 | static struct hda_verb alc662_3ST_ch6_init[] = { | |
14910 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
14911 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
14912 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
14913 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
14914 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
14915 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
14916 | { } /* end */ | |
14917 | }; | |
14918 | ||
14919 | static struct hda_channel_mode alc662_3ST_6ch_modes[2] = { | |
14920 | { 2, alc662_3ST_ch2_init }, | |
14921 | { 6, alc662_3ST_ch6_init }, | |
14922 | }; | |
14923 | ||
14924 | /* | |
14925 | * 2ch mode | |
14926 | */ | |
14927 | static struct hda_verb alc662_sixstack_ch6_init[] = { | |
14928 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
14929 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
14930 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
14931 | { } /* end */ | |
14932 | }; | |
14933 | ||
14934 | /* | |
14935 | * 6ch mode | |
14936 | */ | |
14937 | static struct hda_verb alc662_sixstack_ch8_init[] = { | |
14938 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
14939 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
14940 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
14941 | { } /* end */ | |
14942 | }; | |
14943 | ||
14944 | static struct hda_channel_mode alc662_5stack_modes[2] = { | |
14945 | { 2, alc662_sixstack_ch6_init }, | |
14946 | { 6, alc662_sixstack_ch8_init }, | |
14947 | }; | |
14948 | ||
14949 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 | |
14950 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
14951 | */ | |
14952 | ||
14953 | static struct snd_kcontrol_new alc662_base_mixer[] = { | |
14954 | /* output mixer control */ | |
14955 | HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT), | |
7055ad8a | 14956 | HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT), |
bc9f98a9 | 14957 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT), |
7055ad8a | 14958 | HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT), |
bc9f98a9 KY |
14959 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), |
14960 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), | |
7055ad8a HRK |
14961 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT), |
14962 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT), | |
bc9f98a9 KY |
14963 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
14964 | ||
14965 | /*Input mixer control */ | |
14966 | HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT), | |
14967 | HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT), | |
14968 | HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT), | |
14969 | HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT), | |
14970 | HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT), | |
14971 | HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT), | |
14972 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT), | |
14973 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT), | |
bc9f98a9 KY |
14974 | { } /* end */ |
14975 | }; | |
14976 | ||
14977 | static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = { | |
14978 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
7055ad8a | 14979 | HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT), |
bc9f98a9 KY |
14980 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
14981 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
14982 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
14983 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
14984 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
14985 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14986 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14987 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14988 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
14989 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
14990 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
bc9f98a9 KY |
14991 | { } /* end */ |
14992 | }; | |
14993 | ||
14994 | static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = { | |
14995 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
7055ad8a | 14996 | HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT), |
bc9f98a9 | 14997 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
7055ad8a | 14998 | HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT), |
bc9f98a9 KY |
14999 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), |
15000 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), | |
7055ad8a HRK |
15001 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT), |
15002 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT), | |
bc9f98a9 KY |
15003 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
15004 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
15005 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
15006 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
15007 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
15008 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15009 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
15010 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
15011 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
15012 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
15013 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
bc9f98a9 KY |
15014 | { } /* end */ |
15015 | }; | |
15016 | ||
15017 | static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = { | |
15018 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
15019 | HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT), | |
86cd9298 TI |
15020 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
15021 | HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT), | |
bc9f98a9 KY |
15022 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
15023 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
15024 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
15025 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
15026 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
bc9f98a9 KY |
15027 | { } /* end */ |
15028 | }; | |
15029 | ||
291702f0 | 15030 | static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = { |
86cd9298 | 15031 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), |
291702f0 | 15032 | |
b4818494 HRK |
15033 | HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT), |
15034 | HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
291702f0 KY |
15035 | |
15036 | HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT), | |
15037 | HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15038 | HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
15039 | ||
15040 | HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT), | |
15041 | HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
15042 | HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
15043 | { } /* end */ | |
15044 | }; | |
15045 | ||
8c427226 | 15046 | static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = { |
31bffaa9 TI |
15047 | HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT), |
15048 | HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
8c427226 KY |
15049 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
15050 | HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT), | |
15051 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), | |
15052 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), | |
15053 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT), | |
15054 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT), | |
86cd9298 | 15055 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
8c427226 KY |
15056 | HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT), |
15057 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
15058 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
15059 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15060 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
15061 | { } /* end */ | |
15062 | }; | |
15063 | ||
f1d4e28b KY |
15064 | static struct hda_bind_ctls alc663_asus_bind_master_vol = { |
15065 | .ops = &snd_hda_bind_vol, | |
15066 | .values = { | |
15067 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), | |
15068 | HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT), | |
15069 | 0 | |
15070 | }, | |
15071 | }; | |
15072 | ||
15073 | static struct hda_bind_ctls alc663_asus_one_bind_switch = { | |
15074 | .ops = &snd_hda_bind_sw, | |
15075 | .values = { | |
15076 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
15077 | HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT), | |
15078 | 0 | |
15079 | }, | |
15080 | }; | |
15081 | ||
6dda9f4a | 15082 | static struct snd_kcontrol_new alc663_m51va_mixer[] = { |
f1d4e28b KY |
15083 | HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol), |
15084 | HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch), | |
15085 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15086 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
15087 | { } /* end */ | |
15088 | }; | |
15089 | ||
15090 | static struct hda_bind_ctls alc663_asus_tree_bind_switch = { | |
15091 | .ops = &snd_hda_bind_sw, | |
15092 | .values = { | |
15093 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
15094 | HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | |
15095 | HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT), | |
15096 | 0 | |
15097 | }, | |
15098 | }; | |
15099 | ||
15100 | static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = { | |
15101 | HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol), | |
15102 | HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch), | |
15103 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15104 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
15105 | HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
15106 | HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
15107 | ||
15108 | { } /* end */ | |
15109 | }; | |
15110 | ||
15111 | static struct hda_bind_ctls alc663_asus_four_bind_switch = { | |
15112 | .ops = &snd_hda_bind_sw, | |
15113 | .values = { | |
15114 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
15115 | HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | |
15116 | HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), | |
15117 | 0 | |
15118 | }, | |
15119 | }; | |
15120 | ||
15121 | static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = { | |
15122 | HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol), | |
15123 | HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch), | |
15124 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15125 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
15126 | HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
15127 | HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
15128 | { } /* end */ | |
15129 | }; | |
15130 | ||
15131 | static struct snd_kcontrol_new alc662_1bjd_mixer[] = { | |
6dda9f4a KY |
15132 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), |
15133 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
f1d4e28b KY |
15134 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
15135 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15136 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
15137 | HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
15138 | HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
15139 | { } /* end */ | |
15140 | }; | |
15141 | ||
15142 | static struct hda_bind_ctls alc663_asus_two_bind_master_vol = { | |
15143 | .ops = &snd_hda_bind_vol, | |
15144 | .values = { | |
15145 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), | |
15146 | HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT), | |
15147 | 0 | |
15148 | }, | |
15149 | }; | |
15150 | ||
15151 | static struct hda_bind_ctls alc663_asus_two_bind_switch = { | |
15152 | .ops = &snd_hda_bind_sw, | |
15153 | .values = { | |
15154 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
15155 | HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT), | |
15156 | 0 | |
15157 | }, | |
15158 | }; | |
15159 | ||
15160 | static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = { | |
15161 | HDA_BIND_VOL("Master Playback Volume", | |
15162 | &alc663_asus_two_bind_master_vol), | |
15163 | HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch), | |
15164 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
6dda9f4a KY |
15165 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT), |
15166 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15167 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
f1d4e28b KY |
15168 | { } /* end */ |
15169 | }; | |
15170 | ||
15171 | static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = { | |
15172 | HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol), | |
15173 | HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch), | |
15174 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
15175 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
15176 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15177 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
6dda9f4a KY |
15178 | { } /* end */ |
15179 | }; | |
15180 | ||
15181 | static struct snd_kcontrol_new alc663_g71v_mixer[] = { | |
15182 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
15183 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
15184 | HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
15185 | HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
15186 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT), | |
15187 | ||
15188 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15189 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
15190 | HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
15191 | HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
15192 | { } /* end */ | |
15193 | }; | |
15194 | ||
15195 | static struct snd_kcontrol_new alc663_g50v_mixer[] = { | |
15196 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
15197 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
15198 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT), | |
15199 | ||
15200 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15201 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
15202 | HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
15203 | HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
15204 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
15205 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
15206 | { } /* end */ | |
15207 | }; | |
15208 | ||
bc9f98a9 KY |
15209 | static struct snd_kcontrol_new alc662_chmode_mixer[] = { |
15210 | { | |
15211 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
15212 | .name = "Channel Mode", | |
15213 | .info = alc_ch_mode_info, | |
15214 | .get = alc_ch_mode_get, | |
15215 | .put = alc_ch_mode_put, | |
15216 | }, | |
15217 | { } /* end */ | |
15218 | }; | |
15219 | ||
15220 | static struct hda_verb alc662_init_verbs[] = { | |
15221 | /* ADC: mute amp left and right */ | |
15222 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
15223 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
15224 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
15225 | ||
cb53c626 TI |
15226 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
15227 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
15228 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
15229 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
15230 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
bc9f98a9 | 15231 | |
b60dd394 KY |
15232 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
15233 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15234 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
15235 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15236 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
15237 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
bc9f98a9 KY |
15238 | |
15239 | /* Front Pin: output 0 (0x0c) */ | |
15240 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
15241 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15242 | ||
15243 | /* Rear Pin: output 1 (0x0d) */ | |
15244 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
15245 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15246 | ||
15247 | /* CLFE Pin: output 2 (0x0e) */ | |
15248 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
15249 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15250 | ||
15251 | /* Mic (rear) pin: input vref at 80% */ | |
15252 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
15253 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
15254 | /* Front Mic pin: input vref at 80% */ | |
15255 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
15256 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
15257 | /* Line In pin: input */ | |
15258 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
15259 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
15260 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
15261 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15262 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15263 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
15264 | /* CD pin widget for input */ | |
15265 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
15266 | ||
15267 | /* FIXME: use matrix-type input source selection */ | |
15268 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
15269 | /* Input mixer */ | |
15270 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
15271 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15272 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
15273 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
291702f0 KY |
15274 | |
15275 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
15276 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15277 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
15278 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
6dda9f4a KY |
15279 | |
15280 | /* always trun on EAPD */ | |
15281 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
15282 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
15283 | ||
bc9f98a9 KY |
15284 | { } |
15285 | }; | |
15286 | ||
15287 | static struct hda_verb alc662_sue_init_verbs[] = { | |
15288 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT}, | |
15289 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT}, | |
291702f0 KY |
15290 | {} |
15291 | }; | |
15292 | ||
15293 | static struct hda_verb alc662_eeepc_sue_init_verbs[] = { | |
15294 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
15295 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
15296 | {} | |
bc9f98a9 KY |
15297 | }; |
15298 | ||
8c427226 KY |
15299 | /* Set Unsolicited Event*/ |
15300 | static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = { | |
15301 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
15302 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
15303 | {} | |
15304 | }; | |
15305 | ||
bc9f98a9 KY |
15306 | /* |
15307 | * generic initialization of ADC, input mixers and output mixers | |
15308 | */ | |
15309 | static struct hda_verb alc662_auto_init_verbs[] = { | |
15310 | /* | |
15311 | * Unmute ADC and set the default input to mic-in | |
15312 | */ | |
15313 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
15314 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
15315 | ||
15316 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | |
15317 | * mixer widget | |
15318 | * Note: PASD motherboards uses the Line In 2 as the input for front | |
15319 | * panel mic (mic 2) | |
15320 | */ | |
15321 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
15322 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
15323 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
15324 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
15325 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
15326 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
bc9f98a9 KY |
15327 | |
15328 | /* | |
15329 | * Set up output mixers (0x0c - 0x0f) | |
15330 | */ | |
15331 | /* set vol=0 to output mixers */ | |
15332 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
15333 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
15334 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
15335 | ||
15336 | /* set up input amps for analog loopback */ | |
15337 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
b60dd394 KY |
15338 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
15339 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15340 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
15341 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15342 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
15343 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
bc9f98a9 KY |
15344 | |
15345 | ||
15346 | /* FIXME: use matrix-type input source selection */ | |
15347 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
15348 | /* Input mixer */ | |
15349 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
d1a991a6 | 15350 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
bc9f98a9 KY |
15351 | { } |
15352 | }; | |
15353 | ||
24fb9173 TI |
15354 | /* additional verbs for ALC663 */ |
15355 | static struct hda_verb alc663_auto_init_verbs[] = { | |
15356 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
15357 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15358 | { } | |
15359 | }; | |
15360 | ||
6dda9f4a | 15361 | static struct hda_verb alc663_m51va_init_verbs[] = { |
f1d4e28b KY |
15362 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
15363 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
6dda9f4a KY |
15364 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
15365 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
f1d4e28b KY |
15366 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ |
15367 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
15368 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)}, | |
15369 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
15370 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
15371 | {} | |
15372 | }; | |
15373 | ||
15374 | static struct hda_verb alc663_21jd_amic_init_verbs[] = { | |
15375 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15376 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15377 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ | |
15378 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
15379 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15380 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
15381 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
15382 | {} | |
15383 | }; | |
15384 | ||
15385 | static struct hda_verb alc662_1bjd_amic_init_verbs[] = { | |
15386 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
15387 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15388 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15389 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */ | |
15390 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
15391 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15392 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
15393 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
15394 | {} | |
15395 | }; | |
6dda9f4a | 15396 | |
f1d4e28b KY |
15397 | static struct hda_verb alc663_15jd_amic_init_verbs[] = { |
15398 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15399 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15400 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ | |
15401 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
15402 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15403 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
15404 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
15405 | {} | |
15406 | }; | |
6dda9f4a | 15407 | |
f1d4e28b KY |
15408 | static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = { |
15409 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
15410 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15411 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15412 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */ | |
15413 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15414 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15415 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */ | |
15416 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
15417 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6dda9f4a KY |
15418 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, |
15419 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
f1d4e28b KY |
15420 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, |
15421 | {} | |
15422 | }; | |
15423 | ||
15424 | static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = { | |
15425 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
15426 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15427 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15428 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ | |
15429 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15430 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15431 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ | |
15432 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
15433 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15434 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
15435 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
15436 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
6dda9f4a KY |
15437 | {} |
15438 | }; | |
15439 | ||
15440 | static struct hda_verb alc663_g71v_init_verbs[] = { | |
15441 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15442 | /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */ | |
15443 | /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */ | |
15444 | ||
15445 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15446 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15447 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */ | |
15448 | ||
15449 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT}, | |
15450 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT}, | |
15451 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT}, | |
15452 | {} | |
15453 | }; | |
15454 | ||
15455 | static struct hda_verb alc663_g50v_init_verbs[] = { | |
15456 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15457 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15458 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */ | |
15459 | ||
15460 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
15461 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
15462 | {} | |
15463 | }; | |
15464 | ||
f1d4e28b KY |
15465 | static struct hda_verb alc662_ecs_init_verbs[] = { |
15466 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f}, | |
15467 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
15468 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
15469 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
15470 | {} | |
15471 | }; | |
15472 | ||
f1d4e28b KY |
15473 | static struct snd_kcontrol_new alc662_auto_capture_mixer[] = { |
15474 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
15475 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
15476 | { } /* end */ | |
15477 | }; | |
15478 | ||
bc9f98a9 KY |
15479 | static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec) |
15480 | { | |
15481 | unsigned int present; | |
f12ab1e0 | 15482 | unsigned char bits; |
bc9f98a9 KY |
15483 | |
15484 | present = snd_hda_codec_read(codec, 0x14, 0, | |
15485 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
15486 | bits = present ? HDA_AMP_MUTE : 0; |
15487 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
15488 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
15489 | } |
15490 | ||
15491 | static void alc662_lenovo_101e_all_automute(struct hda_codec *codec) | |
15492 | { | |
15493 | unsigned int present; | |
f12ab1e0 | 15494 | unsigned char bits; |
bc9f98a9 KY |
15495 | |
15496 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
15497 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
15498 | bits = present ? HDA_AMP_MUTE : 0; |
15499 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
15500 | HDA_AMP_MUTE, bits); | |
15501 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
15502 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
15503 | } |
15504 | ||
15505 | static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec, | |
15506 | unsigned int res) | |
15507 | { | |
15508 | if ((res >> 26) == ALC880_HP_EVENT) | |
15509 | alc662_lenovo_101e_all_automute(codec); | |
15510 | if ((res >> 26) == ALC880_FRONT_EVENT) | |
15511 | alc662_lenovo_101e_ispeaker_automute(codec); | |
15512 | } | |
15513 | ||
291702f0 KY |
15514 | static void alc662_eeepc_mic_automute(struct hda_codec *codec) |
15515 | { | |
15516 | unsigned int present; | |
15517 | ||
15518 | present = snd_hda_codec_read(codec, 0x18, 0, | |
15519 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
15520 | snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
15521 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | |
15522 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
15523 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | |
15524 | snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
15525 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); | |
15526 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
15527 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); | |
15528 | } | |
15529 | ||
15530 | /* unsolicited event for HP jack sensing */ | |
15531 | static void alc662_eeepc_unsol_event(struct hda_codec *codec, | |
15532 | unsigned int res) | |
15533 | { | |
15534 | if ((res >> 26) == ALC880_HP_EVENT) | |
15535 | alc262_hippo1_automute( codec ); | |
15536 | ||
15537 | if ((res >> 26) == ALC880_MIC_EVENT) | |
15538 | alc662_eeepc_mic_automute(codec); | |
15539 | } | |
15540 | ||
15541 | static void alc662_eeepc_inithook(struct hda_codec *codec) | |
15542 | { | |
15543 | alc262_hippo1_automute( codec ); | |
15544 | alc662_eeepc_mic_automute(codec); | |
15545 | } | |
15546 | ||
8c427226 KY |
15547 | static void alc662_eeepc_ep20_automute(struct hda_codec *codec) |
15548 | { | |
15549 | unsigned int mute; | |
15550 | unsigned int present; | |
15551 | ||
15552 | snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); | |
15553 | present = snd_hda_codec_read(codec, 0x14, 0, | |
15554 | AC_VERB_GET_PIN_SENSE, 0); | |
15555 | present = (present & 0x80000000) != 0; | |
15556 | if (present) { | |
15557 | /* mute internal speaker */ | |
15558 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
ea1fb29a | 15559 | HDA_AMP_MUTE, HDA_AMP_MUTE); |
8c427226 KY |
15560 | } else { |
15561 | /* unmute internal speaker if necessary */ | |
15562 | mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); | |
15563 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
ea1fb29a | 15564 | HDA_AMP_MUTE, mute); |
8c427226 KY |
15565 | } |
15566 | } | |
15567 | ||
15568 | /* unsolicited event for HP jack sensing */ | |
15569 | static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec, | |
15570 | unsigned int res) | |
15571 | { | |
15572 | if ((res >> 26) == ALC880_HP_EVENT) | |
15573 | alc662_eeepc_ep20_automute(codec); | |
15574 | } | |
15575 | ||
15576 | static void alc662_eeepc_ep20_inithook(struct hda_codec *codec) | |
15577 | { | |
15578 | alc662_eeepc_ep20_automute(codec); | |
15579 | } | |
15580 | ||
6dda9f4a KY |
15581 | static void alc663_m51va_speaker_automute(struct hda_codec *codec) |
15582 | { | |
15583 | unsigned int present; | |
15584 | unsigned char bits; | |
15585 | ||
15586 | present = snd_hda_codec_read(codec, 0x21, 0, | |
f1d4e28b KY |
15587 | AC_VERB_GET_PIN_SENSE, 0) |
15588 | & AC_PINSENSE_PRESENCE; | |
6dda9f4a | 15589 | bits = present ? HDA_AMP_MUTE : 0; |
f1d4e28b KY |
15590 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, |
15591 | AMP_IN_MUTE(0), bits); | |
15592 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
15593 | AMP_IN_MUTE(0), bits); | |
15594 | } | |
15595 | ||
15596 | static void alc663_21jd_two_speaker_automute(struct hda_codec *codec) | |
15597 | { | |
15598 | unsigned int present; | |
15599 | unsigned char bits; | |
15600 | ||
15601 | present = snd_hda_codec_read(codec, 0x21, 0, | |
15602 | AC_VERB_GET_PIN_SENSE, 0) | |
15603 | & AC_PINSENSE_PRESENCE; | |
15604 | bits = present ? HDA_AMP_MUTE : 0; | |
15605 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
15606 | AMP_IN_MUTE(0), bits); | |
15607 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
15608 | AMP_IN_MUTE(0), bits); | |
15609 | snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0, | |
15610 | AMP_IN_MUTE(0), bits); | |
15611 | snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1, | |
15612 | AMP_IN_MUTE(0), bits); | |
15613 | } | |
15614 | ||
15615 | static void alc663_15jd_two_speaker_automute(struct hda_codec *codec) | |
15616 | { | |
15617 | unsigned int present; | |
15618 | unsigned char bits; | |
15619 | ||
15620 | present = snd_hda_codec_read(codec, 0x15, 0, | |
15621 | AC_VERB_GET_PIN_SENSE, 0) | |
15622 | & AC_PINSENSE_PRESENCE; | |
15623 | bits = present ? HDA_AMP_MUTE : 0; | |
15624 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
15625 | AMP_IN_MUTE(0), bits); | |
15626 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
15627 | AMP_IN_MUTE(0), bits); | |
15628 | snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0, | |
15629 | AMP_IN_MUTE(0), bits); | |
15630 | snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1, | |
15631 | AMP_IN_MUTE(0), bits); | |
15632 | } | |
15633 | ||
15634 | static void alc662_f5z_speaker_automute(struct hda_codec *codec) | |
15635 | { | |
15636 | unsigned int present; | |
15637 | unsigned char bits; | |
15638 | ||
15639 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
15640 | AC_VERB_GET_PIN_SENSE, 0) | |
15641 | & AC_PINSENSE_PRESENCE; | |
15642 | bits = present ? 0 : PIN_OUT; | |
15643 | snd_hda_codec_write(codec, 0x14, 0, | |
15644 | AC_VERB_SET_PIN_WIDGET_CONTROL, bits); | |
15645 | } | |
15646 | ||
15647 | static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec) | |
15648 | { | |
15649 | unsigned int present1, present2; | |
15650 | ||
15651 | present1 = snd_hda_codec_read(codec, 0x21, 0, | |
15652 | AC_VERB_GET_PIN_SENSE, 0) | |
15653 | & AC_PINSENSE_PRESENCE; | |
15654 | present2 = snd_hda_codec_read(codec, 0x15, 0, | |
15655 | AC_VERB_GET_PIN_SENSE, 0) | |
15656 | & AC_PINSENSE_PRESENCE; | |
15657 | ||
15658 | if (present1 || present2) { | |
15659 | snd_hda_codec_write_cache(codec, 0x14, 0, | |
15660 | AC_VERB_SET_PIN_WIDGET_CONTROL, 0); | |
15661 | } else { | |
15662 | snd_hda_codec_write_cache(codec, 0x14, 0, | |
15663 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | |
15664 | } | |
15665 | } | |
15666 | ||
15667 | static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec) | |
15668 | { | |
15669 | unsigned int present1, present2; | |
15670 | ||
15671 | present1 = snd_hda_codec_read(codec, 0x1b, 0, | |
15672 | AC_VERB_GET_PIN_SENSE, 0) | |
15673 | & AC_PINSENSE_PRESENCE; | |
15674 | present2 = snd_hda_codec_read(codec, 0x15, 0, | |
15675 | AC_VERB_GET_PIN_SENSE, 0) | |
15676 | & AC_PINSENSE_PRESENCE; | |
15677 | ||
15678 | if (present1 || present2) { | |
15679 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
15680 | AMP_IN_MUTE(0), AMP_IN_MUTE(0)); | |
15681 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
15682 | AMP_IN_MUTE(0), AMP_IN_MUTE(0)); | |
15683 | } else { | |
15684 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
15685 | AMP_IN_MUTE(0), 0); | |
15686 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
15687 | AMP_IN_MUTE(0), 0); | |
15688 | } | |
6dda9f4a KY |
15689 | } |
15690 | ||
15691 | static void alc663_m51va_mic_automute(struct hda_codec *codec) | |
15692 | { | |
15693 | unsigned int present; | |
15694 | ||
15695 | present = snd_hda_codec_read(codec, 0x18, 0, | |
ea1fb29a KY |
15696 | AC_VERB_GET_PIN_SENSE, 0) |
15697 | & AC_PINSENSE_PRESENCE; | |
6dda9f4a | 15698 | snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
ea1fb29a | 15699 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); |
6dda9f4a | 15700 | snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
ea1fb29a | 15701 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); |
6dda9f4a | 15702 | snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
ea1fb29a | 15703 | 0x7000 | (0x09 << 8) | (present ? 0x80 : 0)); |
6dda9f4a | 15704 | snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
ea1fb29a | 15705 | 0x7000 | (0x09 << 8) | (present ? 0x80 : 0)); |
6dda9f4a KY |
15706 | } |
15707 | ||
15708 | static void alc663_m51va_unsol_event(struct hda_codec *codec, | |
15709 | unsigned int res) | |
15710 | { | |
15711 | switch (res >> 26) { | |
15712 | case ALC880_HP_EVENT: | |
15713 | alc663_m51va_speaker_automute(codec); | |
15714 | break; | |
15715 | case ALC880_MIC_EVENT: | |
15716 | alc663_m51va_mic_automute(codec); | |
15717 | break; | |
15718 | } | |
15719 | } | |
15720 | ||
15721 | static void alc663_m51va_inithook(struct hda_codec *codec) | |
15722 | { | |
15723 | alc663_m51va_speaker_automute(codec); | |
15724 | alc663_m51va_mic_automute(codec); | |
15725 | } | |
15726 | ||
f1d4e28b KY |
15727 | /* ***************** Mode1 ******************************/ |
15728 | static void alc663_mode1_unsol_event(struct hda_codec *codec, | |
15729 | unsigned int res) | |
15730 | { | |
15731 | switch (res >> 26) { | |
15732 | case ALC880_HP_EVENT: | |
15733 | alc663_m51va_speaker_automute(codec); | |
15734 | break; | |
15735 | case ALC880_MIC_EVENT: | |
15736 | alc662_eeepc_mic_automute(codec); | |
15737 | break; | |
15738 | } | |
15739 | } | |
15740 | ||
15741 | static void alc663_mode1_inithook(struct hda_codec *codec) | |
15742 | { | |
15743 | alc663_m51va_speaker_automute(codec); | |
15744 | alc662_eeepc_mic_automute(codec); | |
15745 | } | |
15746 | /* ***************** Mode2 ******************************/ | |
15747 | static void alc662_mode2_unsol_event(struct hda_codec *codec, | |
15748 | unsigned int res) | |
15749 | { | |
15750 | switch (res >> 26) { | |
15751 | case ALC880_HP_EVENT: | |
15752 | alc662_f5z_speaker_automute(codec); | |
15753 | break; | |
15754 | case ALC880_MIC_EVENT: | |
15755 | alc662_eeepc_mic_automute(codec); | |
15756 | break; | |
15757 | } | |
15758 | } | |
15759 | ||
15760 | static void alc662_mode2_inithook(struct hda_codec *codec) | |
15761 | { | |
15762 | alc662_f5z_speaker_automute(codec); | |
15763 | alc662_eeepc_mic_automute(codec); | |
15764 | } | |
15765 | /* ***************** Mode3 ******************************/ | |
15766 | static void alc663_mode3_unsol_event(struct hda_codec *codec, | |
15767 | unsigned int res) | |
15768 | { | |
15769 | switch (res >> 26) { | |
15770 | case ALC880_HP_EVENT: | |
15771 | alc663_two_hp_m1_speaker_automute(codec); | |
15772 | break; | |
15773 | case ALC880_MIC_EVENT: | |
15774 | alc662_eeepc_mic_automute(codec); | |
15775 | break; | |
15776 | } | |
15777 | } | |
15778 | ||
15779 | static void alc663_mode3_inithook(struct hda_codec *codec) | |
15780 | { | |
15781 | alc663_two_hp_m1_speaker_automute(codec); | |
15782 | alc662_eeepc_mic_automute(codec); | |
15783 | } | |
15784 | /* ***************** Mode4 ******************************/ | |
15785 | static void alc663_mode4_unsol_event(struct hda_codec *codec, | |
15786 | unsigned int res) | |
15787 | { | |
15788 | switch (res >> 26) { | |
15789 | case ALC880_HP_EVENT: | |
15790 | alc663_21jd_two_speaker_automute(codec); | |
15791 | break; | |
15792 | case ALC880_MIC_EVENT: | |
15793 | alc662_eeepc_mic_automute(codec); | |
15794 | break; | |
15795 | } | |
15796 | } | |
15797 | ||
15798 | static void alc663_mode4_inithook(struct hda_codec *codec) | |
15799 | { | |
15800 | alc663_21jd_two_speaker_automute(codec); | |
15801 | alc662_eeepc_mic_automute(codec); | |
15802 | } | |
15803 | /* ***************** Mode5 ******************************/ | |
15804 | static void alc663_mode5_unsol_event(struct hda_codec *codec, | |
15805 | unsigned int res) | |
15806 | { | |
15807 | switch (res >> 26) { | |
15808 | case ALC880_HP_EVENT: | |
15809 | alc663_15jd_two_speaker_automute(codec); | |
15810 | break; | |
15811 | case ALC880_MIC_EVENT: | |
15812 | alc662_eeepc_mic_automute(codec); | |
15813 | break; | |
15814 | } | |
15815 | } | |
15816 | ||
15817 | static void alc663_mode5_inithook(struct hda_codec *codec) | |
15818 | { | |
15819 | alc663_15jd_two_speaker_automute(codec); | |
15820 | alc662_eeepc_mic_automute(codec); | |
15821 | } | |
15822 | /* ***************** Mode6 ******************************/ | |
15823 | static void alc663_mode6_unsol_event(struct hda_codec *codec, | |
15824 | unsigned int res) | |
15825 | { | |
15826 | switch (res >> 26) { | |
15827 | case ALC880_HP_EVENT: | |
15828 | alc663_two_hp_m2_speaker_automute(codec); | |
15829 | break; | |
15830 | case ALC880_MIC_EVENT: | |
15831 | alc662_eeepc_mic_automute(codec); | |
15832 | break; | |
15833 | } | |
15834 | } | |
15835 | ||
15836 | static void alc663_mode6_inithook(struct hda_codec *codec) | |
15837 | { | |
15838 | alc663_two_hp_m2_speaker_automute(codec); | |
15839 | alc662_eeepc_mic_automute(codec); | |
15840 | } | |
15841 | ||
6dda9f4a KY |
15842 | static void alc663_g71v_hp_automute(struct hda_codec *codec) |
15843 | { | |
15844 | unsigned int present; | |
15845 | unsigned char bits; | |
15846 | ||
15847 | present = snd_hda_codec_read(codec, 0x21, 0, | |
15848 | AC_VERB_GET_PIN_SENSE, 0) | |
15849 | & AC_PINSENSE_PRESENCE; | |
15850 | bits = present ? HDA_AMP_MUTE : 0; | |
15851 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
15852 | HDA_AMP_MUTE, bits); | |
15853 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
15854 | HDA_AMP_MUTE, bits); | |
15855 | } | |
15856 | ||
15857 | static void alc663_g71v_front_automute(struct hda_codec *codec) | |
15858 | { | |
15859 | unsigned int present; | |
15860 | unsigned char bits; | |
15861 | ||
15862 | present = snd_hda_codec_read(codec, 0x15, 0, | |
15863 | AC_VERB_GET_PIN_SENSE, 0) | |
15864 | & AC_PINSENSE_PRESENCE; | |
15865 | bits = present ? HDA_AMP_MUTE : 0; | |
15866 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
15867 | HDA_AMP_MUTE, bits); | |
15868 | } | |
15869 | ||
15870 | static void alc663_g71v_unsol_event(struct hda_codec *codec, | |
15871 | unsigned int res) | |
15872 | { | |
15873 | switch (res >> 26) { | |
15874 | case ALC880_HP_EVENT: | |
15875 | alc663_g71v_hp_automute(codec); | |
15876 | break; | |
15877 | case ALC880_FRONT_EVENT: | |
15878 | alc663_g71v_front_automute(codec); | |
15879 | break; | |
15880 | case ALC880_MIC_EVENT: | |
15881 | alc662_eeepc_mic_automute(codec); | |
15882 | break; | |
15883 | } | |
15884 | } | |
15885 | ||
15886 | static void alc663_g71v_inithook(struct hda_codec *codec) | |
15887 | { | |
15888 | alc663_g71v_front_automute(codec); | |
15889 | alc663_g71v_hp_automute(codec); | |
15890 | alc662_eeepc_mic_automute(codec); | |
15891 | } | |
15892 | ||
15893 | static void alc663_g50v_unsol_event(struct hda_codec *codec, | |
15894 | unsigned int res) | |
15895 | { | |
15896 | switch (res >> 26) { | |
15897 | case ALC880_HP_EVENT: | |
15898 | alc663_m51va_speaker_automute(codec); | |
15899 | break; | |
15900 | case ALC880_MIC_EVENT: | |
15901 | alc662_eeepc_mic_automute(codec); | |
15902 | break; | |
15903 | } | |
15904 | } | |
15905 | ||
15906 | static void alc663_g50v_inithook(struct hda_codec *codec) | |
15907 | { | |
15908 | alc663_m51va_speaker_automute(codec); | |
15909 | alc662_eeepc_mic_automute(codec); | |
15910 | } | |
15911 | ||
f1d4e28b KY |
15912 | /* bind hp and internal speaker mute (with plug check) */ |
15913 | static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol, | |
15914 | struct snd_ctl_elem_value *ucontrol) | |
15915 | { | |
15916 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
15917 | long *valp = ucontrol->value.integer.value; | |
15918 | int change; | |
15919 | ||
15920 | change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0, | |
15921 | HDA_AMP_MUTE, | |
15922 | valp[0] ? 0 : HDA_AMP_MUTE); | |
15923 | change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0, | |
15924 | HDA_AMP_MUTE, | |
15925 | valp[1] ? 0 : HDA_AMP_MUTE); | |
15926 | if (change) | |
15927 | alc262_hippo1_automute(codec); | |
15928 | return change; | |
15929 | } | |
15930 | ||
15931 | static struct snd_kcontrol_new alc662_ecs_mixer[] = { | |
15932 | HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
15933 | { | |
15934 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
15935 | .name = "Master Playback Switch", | |
15936 | .info = snd_hda_mixer_amp_switch_info, | |
15937 | .get = snd_hda_mixer_amp_switch_get, | |
15938 | .put = alc662_ecs_master_sw_put, | |
15939 | .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), | |
15940 | }, | |
15941 | ||
15942 | HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT), | |
15943 | HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15944 | HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
15945 | ||
15946 | HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT), | |
15947 | HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
15948 | HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
15949 | { } /* end */ | |
15950 | }; | |
15951 | ||
cb53c626 TI |
15952 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
15953 | #define alc662_loopbacks alc880_loopbacks | |
15954 | #endif | |
15955 | ||
bc9f98a9 KY |
15956 | |
15957 | /* pcm configuration: identiacal with ALC880 */ | |
15958 | #define alc662_pcm_analog_playback alc880_pcm_analog_playback | |
15959 | #define alc662_pcm_analog_capture alc880_pcm_analog_capture | |
15960 | #define alc662_pcm_digital_playback alc880_pcm_digital_playback | |
15961 | #define alc662_pcm_digital_capture alc880_pcm_digital_capture | |
15962 | ||
15963 | /* | |
15964 | * configuration and preset | |
15965 | */ | |
15966 | static const char *alc662_models[ALC662_MODEL_LAST] = { | |
15967 | [ALC662_3ST_2ch_DIG] = "3stack-dig", | |
15968 | [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig", | |
15969 | [ALC662_3ST_6ch] = "3stack-6ch", | |
15970 | [ALC662_5ST_DIG] = "6stack-dig", | |
15971 | [ALC662_LENOVO_101E] = "lenovo-101e", | |
b995d76d | 15972 | [ALC662_ASUS_EEEPC_P701] = "eeepc-p701", |
8c427226 | 15973 | [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20", |
f1d4e28b | 15974 | [ALC662_ECS] = "ecs", |
6dda9f4a KY |
15975 | [ALC663_ASUS_M51VA] = "m51va", |
15976 | [ALC663_ASUS_G71V] = "g71v", | |
15977 | [ALC663_ASUS_H13] = "h13", | |
15978 | [ALC663_ASUS_G50V] = "g50v", | |
f1d4e28b KY |
15979 | [ALC663_ASUS_MODE1] = "asus-mode1", |
15980 | [ALC662_ASUS_MODE2] = "asus-mode2", | |
15981 | [ALC663_ASUS_MODE3] = "asus-mode3", | |
15982 | [ALC663_ASUS_MODE4] = "asus-mode4", | |
15983 | [ALC663_ASUS_MODE5] = "asus-mode5", | |
15984 | [ALC663_ASUS_MODE6] = "asus-mode6", | |
bc9f98a9 KY |
15985 | [ALC662_AUTO] = "auto", |
15986 | }; | |
15987 | ||
15988 | static struct snd_pci_quirk alc662_cfg_tbl[] = { | |
6dda9f4a | 15989 | SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA), |
80ffe869 | 15990 | SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V), |
3da23cac | 15991 | SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG), |
291702f0 | 15992 | SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701), |
8c427226 | 15993 | SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20), |
f1d4e28b KY |
15994 | SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1), |
15995 | SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1), | |
15996 | SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1), | |
15997 | SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1), | |
15998 | SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1), | |
15999 | SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1), | |
16000 | SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1), | |
16001 | SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1), | |
16002 | SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1), | |
80ffe869 | 16003 | SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1), |
f1d4e28b KY |
16004 | SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2), |
16005 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2), | |
16006 | SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2), | |
16007 | SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2), | |
16008 | SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2), | |
16009 | SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2), | |
16010 | SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2), | |
16011 | SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2), | |
16012 | SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2), | |
16013 | SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2), | |
16014 | SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2), | |
16015 | SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2), | |
16016 | SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3), | |
16017 | SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3), | |
16018 | SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3), | |
16019 | SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3), | |
16020 | SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3), | |
16021 | SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4), | |
16022 | SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5), | |
16023 | SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6), | |
16024 | SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6), | |
16025 | SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6), | |
95fe5f2c HRK |
16026 | SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K", |
16027 | ALC662_3ST_6ch_DIG), | |
ac3e3741 | 16028 | SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E), |
f1d4e28b KY |
16029 | SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS), |
16030 | SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS), | |
cb55974c HRK |
16031 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L", |
16032 | ALC662_3ST_6ch_DIG), | |
19c009aa | 16033 | SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG), |
238713d4 | 16034 | SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0", |
19c009aa | 16035 | ALC662_3ST_6ch_DIG), |
6dda9f4a KY |
16036 | SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13), |
16037 | SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13), | |
16038 | SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13), | |
bc9f98a9 KY |
16039 | {} |
16040 | }; | |
16041 | ||
16042 | static struct alc_config_preset alc662_presets[] = { | |
16043 | [ALC662_3ST_2ch_DIG] = { | |
f9e336f6 | 16044 | .mixers = { alc662_3ST_2ch_mixer }, |
bc9f98a9 KY |
16045 | .init_verbs = { alc662_init_verbs }, |
16046 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16047 | .dac_nids = alc662_dac_nids, | |
16048 | .dig_out_nid = ALC662_DIGOUT_NID, | |
bc9f98a9 KY |
16049 | .dig_in_nid = ALC662_DIGIN_NID, |
16050 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16051 | .channel_mode = alc662_3ST_2ch_modes, | |
16052 | .input_mux = &alc662_capture_source, | |
16053 | }, | |
16054 | [ALC662_3ST_6ch_DIG] = { | |
f9e336f6 | 16055 | .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer }, |
bc9f98a9 KY |
16056 | .init_verbs = { alc662_init_verbs }, |
16057 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16058 | .dac_nids = alc662_dac_nids, | |
16059 | .dig_out_nid = ALC662_DIGOUT_NID, | |
bc9f98a9 KY |
16060 | .dig_in_nid = ALC662_DIGIN_NID, |
16061 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), | |
16062 | .channel_mode = alc662_3ST_6ch_modes, | |
16063 | .need_dac_fix = 1, | |
16064 | .input_mux = &alc662_capture_source, | |
f12ab1e0 | 16065 | }, |
bc9f98a9 | 16066 | [ALC662_3ST_6ch] = { |
f9e336f6 | 16067 | .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer }, |
bc9f98a9 KY |
16068 | .init_verbs = { alc662_init_verbs }, |
16069 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16070 | .dac_nids = alc662_dac_nids, | |
bc9f98a9 KY |
16071 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), |
16072 | .channel_mode = alc662_3ST_6ch_modes, | |
16073 | .need_dac_fix = 1, | |
16074 | .input_mux = &alc662_capture_source, | |
f12ab1e0 | 16075 | }, |
bc9f98a9 | 16076 | [ALC662_5ST_DIG] = { |
f9e336f6 | 16077 | .mixers = { alc662_base_mixer, alc662_chmode_mixer }, |
bc9f98a9 KY |
16078 | .init_verbs = { alc662_init_verbs }, |
16079 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16080 | .dac_nids = alc662_dac_nids, | |
16081 | .dig_out_nid = ALC662_DIGOUT_NID, | |
bc9f98a9 KY |
16082 | .dig_in_nid = ALC662_DIGIN_NID, |
16083 | .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes), | |
16084 | .channel_mode = alc662_5stack_modes, | |
16085 | .input_mux = &alc662_capture_source, | |
16086 | }, | |
16087 | [ALC662_LENOVO_101E] = { | |
f9e336f6 | 16088 | .mixers = { alc662_lenovo_101e_mixer }, |
bc9f98a9 KY |
16089 | .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs }, |
16090 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16091 | .dac_nids = alc662_dac_nids, | |
bc9f98a9 KY |
16092 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
16093 | .channel_mode = alc662_3ST_2ch_modes, | |
16094 | .input_mux = &alc662_lenovo_101e_capture_source, | |
16095 | .unsol_event = alc662_lenovo_101e_unsol_event, | |
16096 | .init_hook = alc662_lenovo_101e_all_automute, | |
16097 | }, | |
291702f0 | 16098 | [ALC662_ASUS_EEEPC_P701] = { |
f9e336f6 | 16099 | .mixers = { alc662_eeepc_p701_mixer }, |
291702f0 KY |
16100 | .init_verbs = { alc662_init_verbs, |
16101 | alc662_eeepc_sue_init_verbs }, | |
16102 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16103 | .dac_nids = alc662_dac_nids, | |
291702f0 KY |
16104 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
16105 | .channel_mode = alc662_3ST_2ch_modes, | |
16106 | .input_mux = &alc662_eeepc_capture_source, | |
16107 | .unsol_event = alc662_eeepc_unsol_event, | |
16108 | .init_hook = alc662_eeepc_inithook, | |
16109 | }, | |
8c427226 | 16110 | [ALC662_ASUS_EEEPC_EP20] = { |
f9e336f6 | 16111 | .mixers = { alc662_eeepc_ep20_mixer, |
8c427226 KY |
16112 | alc662_chmode_mixer }, |
16113 | .init_verbs = { alc662_init_verbs, | |
16114 | alc662_eeepc_ep20_sue_init_verbs }, | |
16115 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16116 | .dac_nids = alc662_dac_nids, | |
8c427226 KY |
16117 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), |
16118 | .channel_mode = alc662_3ST_6ch_modes, | |
16119 | .input_mux = &alc662_lenovo_101e_capture_source, | |
16120 | .unsol_event = alc662_eeepc_ep20_unsol_event, | |
16121 | .init_hook = alc662_eeepc_ep20_inithook, | |
16122 | }, | |
f1d4e28b | 16123 | [ALC662_ECS] = { |
f9e336f6 | 16124 | .mixers = { alc662_ecs_mixer }, |
f1d4e28b KY |
16125 | .init_verbs = { alc662_init_verbs, |
16126 | alc662_ecs_init_verbs }, | |
16127 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16128 | .dac_nids = alc662_dac_nids, | |
16129 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16130 | .channel_mode = alc662_3ST_2ch_modes, | |
16131 | .input_mux = &alc662_eeepc_capture_source, | |
16132 | .unsol_event = alc662_eeepc_unsol_event, | |
16133 | .init_hook = alc662_eeepc_inithook, | |
16134 | }, | |
6dda9f4a | 16135 | [ALC663_ASUS_M51VA] = { |
f9e336f6 | 16136 | .mixers = { alc663_m51va_mixer }, |
6dda9f4a KY |
16137 | .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs }, |
16138 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16139 | .dac_nids = alc662_dac_nids, | |
16140 | .dig_out_nid = ALC662_DIGOUT_NID, | |
16141 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16142 | .channel_mode = alc662_3ST_2ch_modes, | |
16143 | .input_mux = &alc663_m51va_capture_source, | |
16144 | .unsol_event = alc663_m51va_unsol_event, | |
16145 | .init_hook = alc663_m51va_inithook, | |
16146 | }, | |
16147 | [ALC663_ASUS_G71V] = { | |
f9e336f6 | 16148 | .mixers = { alc663_g71v_mixer }, |
6dda9f4a KY |
16149 | .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs }, |
16150 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16151 | .dac_nids = alc662_dac_nids, | |
16152 | .dig_out_nid = ALC662_DIGOUT_NID, | |
16153 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16154 | .channel_mode = alc662_3ST_2ch_modes, | |
16155 | .input_mux = &alc662_eeepc_capture_source, | |
16156 | .unsol_event = alc663_g71v_unsol_event, | |
16157 | .init_hook = alc663_g71v_inithook, | |
16158 | }, | |
16159 | [ALC663_ASUS_H13] = { | |
f9e336f6 | 16160 | .mixers = { alc663_m51va_mixer }, |
6dda9f4a KY |
16161 | .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs }, |
16162 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16163 | .dac_nids = alc662_dac_nids, | |
16164 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16165 | .channel_mode = alc662_3ST_2ch_modes, | |
16166 | .input_mux = &alc663_m51va_capture_source, | |
16167 | .unsol_event = alc663_m51va_unsol_event, | |
16168 | .init_hook = alc663_m51va_inithook, | |
16169 | }, | |
16170 | [ALC663_ASUS_G50V] = { | |
f9e336f6 | 16171 | .mixers = { alc663_g50v_mixer }, |
6dda9f4a KY |
16172 | .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs }, |
16173 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16174 | .dac_nids = alc662_dac_nids, | |
16175 | .dig_out_nid = ALC662_DIGOUT_NID, | |
16176 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), | |
16177 | .channel_mode = alc662_3ST_6ch_modes, | |
16178 | .input_mux = &alc663_capture_source, | |
16179 | .unsol_event = alc663_g50v_unsol_event, | |
16180 | .init_hook = alc663_g50v_inithook, | |
16181 | }, | |
f1d4e28b | 16182 | [ALC663_ASUS_MODE1] = { |
f9e336f6 TI |
16183 | .mixers = { alc663_m51va_mixer }, |
16184 | .cap_mixer = alc662_auto_capture_mixer, | |
f1d4e28b KY |
16185 | .init_verbs = { alc662_init_verbs, |
16186 | alc663_21jd_amic_init_verbs }, | |
16187 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16188 | .hp_nid = 0x03, | |
16189 | .dac_nids = alc662_dac_nids, | |
16190 | .dig_out_nid = ALC662_DIGOUT_NID, | |
16191 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16192 | .channel_mode = alc662_3ST_2ch_modes, | |
16193 | .input_mux = &alc662_eeepc_capture_source, | |
16194 | .unsol_event = alc663_mode1_unsol_event, | |
16195 | .init_hook = alc663_mode1_inithook, | |
16196 | }, | |
16197 | [ALC662_ASUS_MODE2] = { | |
f9e336f6 TI |
16198 | .mixers = { alc662_1bjd_mixer }, |
16199 | .cap_mixer = alc662_auto_capture_mixer, | |
f1d4e28b KY |
16200 | .init_verbs = { alc662_init_verbs, |
16201 | alc662_1bjd_amic_init_verbs }, | |
16202 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16203 | .dac_nids = alc662_dac_nids, | |
16204 | .dig_out_nid = ALC662_DIGOUT_NID, | |
16205 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16206 | .channel_mode = alc662_3ST_2ch_modes, | |
16207 | .input_mux = &alc662_eeepc_capture_source, | |
16208 | .unsol_event = alc662_mode2_unsol_event, | |
16209 | .init_hook = alc662_mode2_inithook, | |
16210 | }, | |
16211 | [ALC663_ASUS_MODE3] = { | |
f9e336f6 TI |
16212 | .mixers = { alc663_two_hp_m1_mixer }, |
16213 | .cap_mixer = alc662_auto_capture_mixer, | |
f1d4e28b KY |
16214 | .init_verbs = { alc662_init_verbs, |
16215 | alc663_two_hp_amic_m1_init_verbs }, | |
16216 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16217 | .hp_nid = 0x03, | |
16218 | .dac_nids = alc662_dac_nids, | |
16219 | .dig_out_nid = ALC662_DIGOUT_NID, | |
16220 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16221 | .channel_mode = alc662_3ST_2ch_modes, | |
16222 | .input_mux = &alc662_eeepc_capture_source, | |
16223 | .unsol_event = alc663_mode3_unsol_event, | |
16224 | .init_hook = alc663_mode3_inithook, | |
16225 | }, | |
16226 | [ALC663_ASUS_MODE4] = { | |
f9e336f6 TI |
16227 | .mixers = { alc663_asus_21jd_clfe_mixer }, |
16228 | .cap_mixer = alc662_auto_capture_mixer, | |
f1d4e28b KY |
16229 | .init_verbs = { alc662_init_verbs, |
16230 | alc663_21jd_amic_init_verbs}, | |
16231 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16232 | .hp_nid = 0x03, | |
16233 | .dac_nids = alc662_dac_nids, | |
16234 | .dig_out_nid = ALC662_DIGOUT_NID, | |
16235 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16236 | .channel_mode = alc662_3ST_2ch_modes, | |
16237 | .input_mux = &alc662_eeepc_capture_source, | |
16238 | .unsol_event = alc663_mode4_unsol_event, | |
16239 | .init_hook = alc663_mode4_inithook, | |
16240 | }, | |
16241 | [ALC663_ASUS_MODE5] = { | |
f9e336f6 TI |
16242 | .mixers = { alc663_asus_15jd_clfe_mixer }, |
16243 | .cap_mixer = alc662_auto_capture_mixer, | |
f1d4e28b KY |
16244 | .init_verbs = { alc662_init_verbs, |
16245 | alc663_15jd_amic_init_verbs }, | |
16246 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16247 | .hp_nid = 0x03, | |
16248 | .dac_nids = alc662_dac_nids, | |
16249 | .dig_out_nid = ALC662_DIGOUT_NID, | |
16250 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16251 | .channel_mode = alc662_3ST_2ch_modes, | |
16252 | .input_mux = &alc662_eeepc_capture_source, | |
16253 | .unsol_event = alc663_mode5_unsol_event, | |
16254 | .init_hook = alc663_mode5_inithook, | |
16255 | }, | |
16256 | [ALC663_ASUS_MODE6] = { | |
f9e336f6 TI |
16257 | .mixers = { alc663_two_hp_m2_mixer }, |
16258 | .cap_mixer = alc662_auto_capture_mixer, | |
f1d4e28b KY |
16259 | .init_verbs = { alc662_init_verbs, |
16260 | alc663_two_hp_amic_m2_init_verbs }, | |
16261 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16262 | .hp_nid = 0x03, | |
16263 | .dac_nids = alc662_dac_nids, | |
16264 | .dig_out_nid = ALC662_DIGOUT_NID, | |
16265 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16266 | .channel_mode = alc662_3ST_2ch_modes, | |
16267 | .input_mux = &alc662_eeepc_capture_source, | |
16268 | .unsol_event = alc663_mode6_unsol_event, | |
16269 | .init_hook = alc663_mode6_inithook, | |
16270 | }, | |
bc9f98a9 KY |
16271 | }; |
16272 | ||
16273 | ||
16274 | /* | |
16275 | * BIOS auto configuration | |
16276 | */ | |
16277 | ||
16278 | /* add playback controls from the parsed DAC table */ | |
16279 | static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec, | |
16280 | const struct auto_pin_cfg *cfg) | |
16281 | { | |
16282 | char name[32]; | |
16283 | static const char *chname[4] = { | |
16284 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
16285 | }; | |
16286 | hda_nid_t nid; | |
16287 | int i, err; | |
16288 | ||
16289 | for (i = 0; i < cfg->line_outs; i++) { | |
16290 | if (!spec->multiout.dac_nids[i]) | |
16291 | continue; | |
b60dd394 | 16292 | nid = alc880_idx_to_dac(i); |
bc9f98a9 KY |
16293 | if (i == 2) { |
16294 | /* Center/LFE */ | |
16295 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
16296 | "Center Playback Volume", | |
f12ab1e0 TI |
16297 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, |
16298 | HDA_OUTPUT)); | |
bc9f98a9 KY |
16299 | if (err < 0) |
16300 | return err; | |
16301 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
16302 | "LFE Playback Volume", | |
f12ab1e0 TI |
16303 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, |
16304 | HDA_OUTPUT)); | |
bc9f98a9 KY |
16305 | if (err < 0) |
16306 | return err; | |
b69ce01a | 16307 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
bc9f98a9 | 16308 | "Center Playback Switch", |
b69ce01a | 16309 | HDA_COMPOSE_AMP_VAL(0x0e, 1, 0, |
f12ab1e0 | 16310 | HDA_INPUT)); |
bc9f98a9 KY |
16311 | if (err < 0) |
16312 | return err; | |
b69ce01a | 16313 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
bc9f98a9 | 16314 | "LFE Playback Switch", |
b69ce01a | 16315 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, |
f12ab1e0 | 16316 | HDA_INPUT)); |
bc9f98a9 KY |
16317 | if (err < 0) |
16318 | return err; | |
16319 | } else { | |
16320 | sprintf(name, "%s Playback Volume", chname[i]); | |
16321 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
f12ab1e0 TI |
16322 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, |
16323 | HDA_OUTPUT)); | |
bc9f98a9 KY |
16324 | if (err < 0) |
16325 | return err; | |
16326 | sprintf(name, "%s Playback Switch", chname[i]); | |
b69ce01a HRK |
16327 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
16328 | HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i), | |
16329 | 3, 0, HDA_INPUT)); | |
bc9f98a9 KY |
16330 | if (err < 0) |
16331 | return err; | |
16332 | } | |
16333 | } | |
16334 | return 0; | |
16335 | } | |
16336 | ||
16337 | /* add playback controls for speaker and HP outputs */ | |
16338 | static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, | |
16339 | const char *pfx) | |
16340 | { | |
16341 | hda_nid_t nid; | |
16342 | int err; | |
16343 | char name[32]; | |
16344 | ||
16345 | if (!pin) | |
16346 | return 0; | |
16347 | ||
24fb9173 TI |
16348 | if (pin == 0x17) { |
16349 | /* ALC663 has a mono output pin on 0x17 */ | |
16350 | sprintf(name, "%s Playback Switch", pfx); | |
16351 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | |
16352 | HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT)); | |
16353 | return err; | |
16354 | } | |
16355 | ||
bc9f98a9 KY |
16356 | if (alc880_is_fixed_pin(pin)) { |
16357 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
16358 | /* printk("DAC nid=%x\n",nid); */ | |
16359 | /* specify the DAC as the extra output */ | |
16360 | if (!spec->multiout.hp_nid) | |
16361 | spec->multiout.hp_nid = nid; | |
16362 | else | |
16363 | spec->multiout.extra_out_nid[0] = nid; | |
16364 | /* control HP volume/switch on the output mixer amp */ | |
16365 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
16366 | sprintf(name, "%s Playback Volume", pfx); | |
16367 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
16368 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
16369 | if (err < 0) | |
16370 | return err; | |
16371 | sprintf(name, "%s Playback Switch", pfx); | |
16372 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | |
16373 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); | |
16374 | if (err < 0) | |
16375 | return err; | |
16376 | } else if (alc880_is_multi_pin(pin)) { | |
16377 | /* set manual connection */ | |
16378 | /* we have only a switch on HP-out PIN */ | |
16379 | sprintf(name, "%s Playback Switch", pfx); | |
16380 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | |
16381 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
16382 | if (err < 0) | |
16383 | return err; | |
16384 | } | |
16385 | return 0; | |
16386 | } | |
16387 | ||
16388 | /* create playback/capture controls for input pins */ | |
16389 | static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec, | |
16390 | const struct auto_pin_cfg *cfg) | |
16391 | { | |
16392 | struct hda_input_mux *imux = &spec->private_imux; | |
16393 | int i, err, idx; | |
16394 | ||
16395 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
16396 | if (alc880_is_input_pin(cfg->input_pins[i])) { | |
16397 | idx = alc880_input_pin_idx(cfg->input_pins[i]); | |
16398 | err = new_analog_input(spec, cfg->input_pins[i], | |
16399 | auto_pin_cfg_labels[i], | |
16400 | idx, 0x0b); | |
16401 | if (err < 0) | |
16402 | return err; | |
16403 | imux->items[imux->num_items].label = | |
16404 | auto_pin_cfg_labels[i]; | |
16405 | imux->items[imux->num_items].index = | |
16406 | alc880_input_pin_idx(cfg->input_pins[i]); | |
16407 | imux->num_items++; | |
16408 | } | |
16409 | } | |
16410 | return 0; | |
16411 | } | |
16412 | ||
16413 | static void alc662_auto_set_output_and_unmute(struct hda_codec *codec, | |
16414 | hda_nid_t nid, int pin_type, | |
16415 | int dac_idx) | |
16416 | { | |
f6c7e546 | 16417 | alc_set_pin_output(codec, nid, pin_type); |
bc9f98a9 KY |
16418 | /* need the manual connection? */ |
16419 | if (alc880_is_multi_pin(nid)) { | |
16420 | struct alc_spec *spec = codec->spec; | |
16421 | int idx = alc880_multi_pin_idx(nid); | |
16422 | snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, | |
16423 | AC_VERB_SET_CONNECT_SEL, | |
16424 | alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); | |
16425 | } | |
16426 | } | |
16427 | ||
16428 | static void alc662_auto_init_multi_out(struct hda_codec *codec) | |
16429 | { | |
16430 | struct alc_spec *spec = codec->spec; | |
16431 | int i; | |
16432 | ||
8c427226 | 16433 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
bc9f98a9 KY |
16434 | for (i = 0; i <= HDA_SIDE; i++) { |
16435 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 16436 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
bc9f98a9 | 16437 | if (nid) |
baba8ee9 | 16438 | alc662_auto_set_output_and_unmute(codec, nid, pin_type, |
bc9f98a9 KY |
16439 | i); |
16440 | } | |
16441 | } | |
16442 | ||
16443 | static void alc662_auto_init_hp_out(struct hda_codec *codec) | |
16444 | { | |
16445 | struct alc_spec *spec = codec->spec; | |
16446 | hda_nid_t pin; | |
16447 | ||
16448 | pin = spec->autocfg.hp_pins[0]; | |
16449 | if (pin) /* connect to front */ | |
16450 | /* use dac 0 */ | |
16451 | alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
f6c7e546 TI |
16452 | pin = spec->autocfg.speaker_pins[0]; |
16453 | if (pin) | |
16454 | alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
bc9f98a9 KY |
16455 | } |
16456 | ||
16457 | #define alc662_is_input_pin(nid) alc880_is_input_pin(nid) | |
16458 | #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID | |
16459 | ||
16460 | static void alc662_auto_init_analog_input(struct hda_codec *codec) | |
16461 | { | |
16462 | struct alc_spec *spec = codec->spec; | |
16463 | int i; | |
16464 | ||
16465 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
16466 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
16467 | if (alc662_is_input_pin(nid)) { | |
16468 | snd_hda_codec_write(codec, nid, 0, | |
16469 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
16470 | (i <= AUTO_PIN_FRONT_MIC ? | |
16471 | PIN_VREF80 : PIN_IN)); | |
16472 | if (nid != ALC662_PIN_CD_NID) | |
16473 | snd_hda_codec_write(codec, nid, 0, | |
16474 | AC_VERB_SET_AMP_GAIN_MUTE, | |
16475 | AMP_OUT_MUTE); | |
16476 | } | |
16477 | } | |
16478 | } | |
16479 | ||
f511b01c TI |
16480 | #define alc662_auto_init_input_src alc882_auto_init_input_src |
16481 | ||
bc9f98a9 KY |
16482 | static int alc662_parse_auto_config(struct hda_codec *codec) |
16483 | { | |
16484 | struct alc_spec *spec = codec->spec; | |
16485 | int err; | |
16486 | static hda_nid_t alc662_ignore[] = { 0x1d, 0 }; | |
16487 | ||
16488 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | |
16489 | alc662_ignore); | |
16490 | if (err < 0) | |
16491 | return err; | |
16492 | if (!spec->autocfg.line_outs) | |
16493 | return 0; /* can't find valid BIOS pin config */ | |
16494 | ||
f12ab1e0 TI |
16495 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
16496 | if (err < 0) | |
16497 | return err; | |
16498 | err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
16499 | if (err < 0) | |
16500 | return err; | |
16501 | err = alc662_auto_create_extra_out(spec, | |
16502 | spec->autocfg.speaker_pins[0], | |
16503 | "Speaker"); | |
16504 | if (err < 0) | |
16505 | return err; | |
16506 | err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], | |
16507 | "Headphone"); | |
16508 | if (err < 0) | |
16509 | return err; | |
16510 | err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
16511 | if (err < 0) | |
bc9f98a9 KY |
16512 | return err; |
16513 | ||
16514 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
16515 | ||
16516 | if (spec->autocfg.dig_out_pin) | |
16517 | spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; | |
16518 | ||
603c4019 | 16519 | if (spec->kctls.list) |
d88897ea | 16520 | add_mixer(spec, spec->kctls.list); |
bc9f98a9 KY |
16521 | |
16522 | spec->num_mux_defs = 1; | |
16523 | spec->input_mux = &spec->private_imux; | |
ea1fb29a | 16524 | |
d88897ea | 16525 | add_verb(spec, alc662_auto_init_verbs); |
24fb9173 | 16526 | if (codec->vendor_id == 0x10ec0663) |
d88897ea | 16527 | add_verb(spec, alc663_auto_init_verbs); |
ee979a14 TI |
16528 | |
16529 | err = alc_auto_add_mic_boost(codec); | |
16530 | if (err < 0) | |
16531 | return err; | |
16532 | ||
e044c39a | 16533 | store_pin_configs(codec); |
8c87286f | 16534 | return 1; |
bc9f98a9 KY |
16535 | } |
16536 | ||
16537 | /* additional initialization for auto-configuration model */ | |
16538 | static void alc662_auto_init(struct hda_codec *codec) | |
16539 | { | |
f6c7e546 | 16540 | struct alc_spec *spec = codec->spec; |
bc9f98a9 KY |
16541 | alc662_auto_init_multi_out(codec); |
16542 | alc662_auto_init_hp_out(codec); | |
16543 | alc662_auto_init_analog_input(codec); | |
f511b01c | 16544 | alc662_auto_init_input_src(codec); |
f6c7e546 | 16545 | if (spec->unsol_event) |
7fb0d78f | 16546 | alc_inithook(codec); |
bc9f98a9 KY |
16547 | } |
16548 | ||
16549 | static int patch_alc662(struct hda_codec *codec) | |
16550 | { | |
16551 | struct alc_spec *spec; | |
16552 | int err, board_config; | |
16553 | ||
16554 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
16555 | if (!spec) | |
16556 | return -ENOMEM; | |
16557 | ||
16558 | codec->spec = spec; | |
16559 | ||
2c3bf9ab TI |
16560 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
16561 | ||
bc9f98a9 KY |
16562 | board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST, |
16563 | alc662_models, | |
16564 | alc662_cfg_tbl); | |
16565 | if (board_config < 0) { | |
16566 | printk(KERN_INFO "hda_codec: Unknown model for ALC662, " | |
16567 | "trying auto-probe from BIOS...\n"); | |
16568 | board_config = ALC662_AUTO; | |
16569 | } | |
16570 | ||
16571 | if (board_config == ALC662_AUTO) { | |
16572 | /* automatic parse from the BIOS config */ | |
16573 | err = alc662_parse_auto_config(codec); | |
16574 | if (err < 0) { | |
16575 | alc_free(codec); | |
16576 | return err; | |
8c87286f | 16577 | } else if (!err) { |
bc9f98a9 KY |
16578 | printk(KERN_INFO |
16579 | "hda_codec: Cannot set up configuration " | |
16580 | "from BIOS. Using base mode...\n"); | |
16581 | board_config = ALC662_3ST_2ch_DIG; | |
16582 | } | |
16583 | } | |
16584 | ||
16585 | if (board_config != ALC662_AUTO) | |
16586 | setup_preset(spec, &alc662_presets[board_config]); | |
16587 | ||
6dda9f4a KY |
16588 | if (codec->vendor_id == 0x10ec0663) { |
16589 | spec->stream_name_analog = "ALC663 Analog"; | |
16590 | spec->stream_name_digital = "ALC663 Digital"; | |
01afd41f KY |
16591 | } else if (codec->vendor_id == 0x10ec0272) { |
16592 | spec->stream_name_analog = "ALC272 Analog"; | |
16593 | spec->stream_name_digital = "ALC272 Digital"; | |
6dda9f4a KY |
16594 | } else { |
16595 | spec->stream_name_analog = "ALC662 Analog"; | |
16596 | spec->stream_name_digital = "ALC662 Digital"; | |
16597 | } | |
16598 | ||
bc9f98a9 KY |
16599 | spec->stream_analog_playback = &alc662_pcm_analog_playback; |
16600 | spec->stream_analog_capture = &alc662_pcm_analog_capture; | |
16601 | ||
bc9f98a9 KY |
16602 | spec->stream_digital_playback = &alc662_pcm_digital_playback; |
16603 | spec->stream_digital_capture = &alc662_pcm_digital_capture; | |
16604 | ||
e1406348 TI |
16605 | spec->adc_nids = alc662_adc_nids; |
16606 | spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids); | |
16607 | spec->capsrc_nids = alc662_capsrc_nids; | |
54cbc9ab | 16608 | spec->is_mix_capture = 1; |
bc9f98a9 | 16609 | |
f9e336f6 TI |
16610 | if (!spec->cap_mixer) |
16611 | set_capture_mixer(spec); | |
16612 | ||
2134ea4f TI |
16613 | spec->vmaster_nid = 0x02; |
16614 | ||
bc9f98a9 KY |
16615 | codec->patch_ops = alc_patch_ops; |
16616 | if (board_config == ALC662_AUTO) | |
16617 | spec->init_hook = alc662_auto_init; | |
cb53c626 TI |
16618 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
16619 | if (!spec->loopback.amplist) | |
16620 | spec->loopback.amplist = alc662_loopbacks; | |
16621 | #endif | |
daead538 | 16622 | codec->proc_widget_hook = print_realtek_coef; |
bc9f98a9 KY |
16623 | |
16624 | return 0; | |
16625 | } | |
16626 | ||
1da177e4 LT |
16627 | /* |
16628 | * patch entries | |
16629 | */ | |
1289e9e8 | 16630 | static struct hda_codec_preset snd_hda_preset_realtek[] = { |
1da177e4 | 16631 | { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, |
df694daa | 16632 | { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, |
f6a92248 | 16633 | { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, |
a361d84b | 16634 | { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, |
f6a92248 | 16635 | { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 }, |
01afd41f | 16636 | { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 }, |
f32610ed | 16637 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", |
bc9f98a9 | 16638 | .patch = patch_alc861 }, |
f32610ed JS |
16639 | { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, |
16640 | { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, | |
16641 | { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, | |
bc9f98a9 KY |
16642 | { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", |
16643 | .patch = patch_alc883 }, | |
16644 | { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", | |
16645 | .patch = patch_alc662 }, | |
6dda9f4a | 16646 | { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, |
f32610ed | 16647 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
1da177e4 | 16648 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, |
9c7f852e | 16649 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 }, |
669faba2 CM |
16650 | { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A", |
16651 | .patch = patch_alc882 }, /* should be patch_alc883() in future */ | |
cb308f97 | 16652 | { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", |
7943a8ab | 16653 | .patch = patch_alc882 }, /* should be patch_alc883() in future */ |
df694daa | 16654 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, |
a385a529 | 16655 | { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 }, |
4442608d KY |
16656 | { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", |
16657 | .patch = patch_alc883 }, | |
3fea2cb0 | 16658 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 }, |
f6a92248 | 16659 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 }, |
1da177e4 LT |
16660 | {} /* terminator */ |
16661 | }; | |
1289e9e8 TI |
16662 | |
16663 | MODULE_ALIAS("snd-hda-codec-id:10ec*"); | |
16664 | ||
16665 | MODULE_LICENSE("GPL"); | |
16666 | MODULE_DESCRIPTION("Realtek HD-audio codec"); | |
16667 | ||
16668 | static struct hda_codec_preset_list realtek_list = { | |
16669 | .preset = snd_hda_preset_realtek, | |
16670 | .owner = THIS_MODULE, | |
16671 | }; | |
16672 | ||
16673 | static int __init patch_realtek_init(void) | |
16674 | { | |
16675 | return snd_hda_add_codec_preset(&realtek_list); | |
16676 | } | |
16677 | ||
16678 | static void __exit patch_realtek_exit(void) | |
16679 | { | |
16680 | snd_hda_delete_codec_preset(&realtek_list); | |
16681 | } | |
16682 | ||
16683 | module_init(patch_realtek_init) | |
16684 | module_exit(patch_realtek_exit) |