]>
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 <[email protected]> |
7 | * PeiSen Hou <[email protected]> | |
1da177e4 | 8 | * Takashi Iwai <[email protected]> |
7cf51e48 | 9 | * Jonathan Woithe <[email protected]> |
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" | |
3c9a3203 | 33 | #include "hda_patch.h" |
1da177e4 | 34 | |
ccc656ce KY |
35 | #define ALC880_FRONT_EVENT 0x01 |
36 | #define ALC880_DCVOL_EVENT 0x02 | |
37 | #define ALC880_HP_EVENT 0x04 | |
38 | #define ALC880_MIC_EVENT 0x08 | |
1da177e4 LT |
39 | |
40 | /* ALC880 board config type */ | |
41 | enum { | |
1da177e4 LT |
42 | ALC880_3ST, |
43 | ALC880_3ST_DIG, | |
44 | ALC880_5ST, | |
45 | ALC880_5ST_DIG, | |
46 | ALC880_W810, | |
dfc0ff62 | 47 | ALC880_Z71V, |
b6482d48 | 48 | ALC880_6ST, |
16ded525 TI |
49 | ALC880_6ST_DIG, |
50 | ALC880_F1734, | |
51 | ALC880_ASUS, | |
52 | ALC880_ASUS_DIG, | |
53 | ALC880_ASUS_W1V, | |
df694daa | 54 | ALC880_ASUS_DIG2, |
2cf9f0fc | 55 | ALC880_FUJITSU, |
16ded525 | 56 | ALC880_UNIWILL_DIG, |
ccc656ce KY |
57 | ALC880_UNIWILL, |
58 | ALC880_UNIWILL_P53, | |
df694daa KY |
59 | ALC880_CLEVO, |
60 | ALC880_TCL_S700, | |
ae6b813a | 61 | ALC880_LG, |
d681518a | 62 | ALC880_LG_LW, |
df99cd33 | 63 | ALC880_MEDION_RIM, |
e9edcee0 TI |
64 | #ifdef CONFIG_SND_DEBUG |
65 | ALC880_TEST, | |
66 | #endif | |
df694daa | 67 | ALC880_AUTO, |
16ded525 TI |
68 | ALC880_MODEL_LAST /* last tag */ |
69 | }; | |
70 | ||
71 | /* ALC260 models */ | |
72 | enum { | |
73 | ALC260_BASIC, | |
74 | ALC260_HP, | |
3f878308 | 75 | ALC260_HP_DC7600, |
df694daa KY |
76 | ALC260_HP_3013, |
77 | ALC260_FUJITSU_S702X, | |
0bfc90e9 | 78 | ALC260_ACER, |
bc9f98a9 KY |
79 | ALC260_WILL, |
80 | ALC260_REPLACER_672V, | |
7cf51e48 JW |
81 | #ifdef CONFIG_SND_DEBUG |
82 | ALC260_TEST, | |
83 | #endif | |
df694daa | 84 | ALC260_AUTO, |
16ded525 | 85 | ALC260_MODEL_LAST /* last tag */ |
1da177e4 LT |
86 | }; |
87 | ||
df694daa KY |
88 | /* ALC262 models */ |
89 | enum { | |
90 | ALC262_BASIC, | |
ccc656ce KY |
91 | ALC262_HIPPO, |
92 | ALC262_HIPPO_1, | |
834be88d | 93 | ALC262_FUJITSU, |
9c7f852e | 94 | ALC262_HP_BPC, |
cd7509a4 KY |
95 | ALC262_HP_BPC_D7000_WL, |
96 | ALC262_HP_BPC_D7000_WF, | |
66d2a9d6 | 97 | ALC262_HP_TC_T5735, |
8c427226 | 98 | ALC262_HP_RP5700, |
304dcaac | 99 | ALC262_BENQ_ED8, |
272a527c | 100 | ALC262_SONY_ASSAMD, |
83c34218 | 101 | ALC262_BENQ_T31, |
f651b50b | 102 | ALC262_ULTRA, |
0e31daf7 | 103 | ALC262_LENOVO_3000, |
e8f9ae2a | 104 | ALC262_NEC, |
4e555fe5 | 105 | ALC262_TOSHIBA_S06, |
9f99a638 | 106 | ALC262_TOSHIBA_RX1, |
df694daa KY |
107 | ALC262_AUTO, |
108 | ALC262_MODEL_LAST /* last tag */ | |
109 | }; | |
110 | ||
a361d84b KY |
111 | /* ALC268 models */ |
112 | enum { | |
eb5a6621 | 113 | ALC267_QUANTA_IL1, |
a361d84b | 114 | ALC268_3ST, |
d1a991a6 | 115 | ALC268_TOSHIBA, |
d273809e | 116 | ALC268_ACER, |
c238b4f4 | 117 | ALC268_ACER_DMIC, |
8ef355da | 118 | ALC268_ACER_ASPIRE_ONE, |
3866f0b0 | 119 | ALC268_DELL, |
f12462c5 | 120 | ALC268_ZEPTO, |
86c53bd2 JW |
121 | #ifdef CONFIG_SND_DEBUG |
122 | ALC268_TEST, | |
123 | #endif | |
a361d84b KY |
124 | ALC268_AUTO, |
125 | ALC268_MODEL_LAST /* last tag */ | |
126 | }; | |
127 | ||
f6a92248 KY |
128 | /* ALC269 models */ |
129 | enum { | |
130 | ALC269_BASIC, | |
60db6b53 | 131 | ALC269_QUANTA_FL1, |
f53281e6 KY |
132 | ALC269_ASUS_EEEPC_P703, |
133 | ALC269_ASUS_EEEPC_P901, | |
26f5df26 | 134 | ALC269_FUJITSU, |
64154835 | 135 | ALC269_LIFEBOOK, |
f6a92248 KY |
136 | ALC269_AUTO, |
137 | ALC269_MODEL_LAST /* last tag */ | |
138 | }; | |
139 | ||
df694daa KY |
140 | /* ALC861 models */ |
141 | enum { | |
142 | ALC861_3ST, | |
9c7f852e | 143 | ALC660_3ST, |
df694daa KY |
144 | ALC861_3ST_DIG, |
145 | ALC861_6ST_DIG, | |
22309c3e | 146 | ALC861_UNIWILL_M31, |
a53d1aec | 147 | ALC861_TOSHIBA, |
7cdbff94 | 148 | ALC861_ASUS, |
56bb0cab | 149 | ALC861_ASUS_LAPTOP, |
df694daa KY |
150 | ALC861_AUTO, |
151 | ALC861_MODEL_LAST, | |
152 | }; | |
153 | ||
f32610ed JS |
154 | /* ALC861-VD models */ |
155 | enum { | |
156 | ALC660VD_3ST, | |
6963f84c | 157 | ALC660VD_3ST_DIG, |
13c94744 | 158 | ALC660VD_ASUS_V1S, |
f32610ed JS |
159 | ALC861VD_3ST, |
160 | ALC861VD_3ST_DIG, | |
161 | ALC861VD_6ST_DIG, | |
bdd148a3 | 162 | ALC861VD_LENOVO, |
272a527c | 163 | ALC861VD_DALLAS, |
d1a991a6 | 164 | ALC861VD_HP, |
f32610ed JS |
165 | ALC861VD_AUTO, |
166 | ALC861VD_MODEL_LAST, | |
167 | }; | |
168 | ||
bc9f98a9 KY |
169 | /* ALC662 models */ |
170 | enum { | |
171 | ALC662_3ST_2ch_DIG, | |
172 | ALC662_3ST_6ch_DIG, | |
173 | ALC662_3ST_6ch, | |
174 | ALC662_5ST_DIG, | |
175 | ALC662_LENOVO_101E, | |
291702f0 | 176 | ALC662_ASUS_EEEPC_P701, |
8c427226 | 177 | ALC662_ASUS_EEEPC_EP20, |
6dda9f4a KY |
178 | ALC663_ASUS_M51VA, |
179 | ALC663_ASUS_G71V, | |
180 | ALC663_ASUS_H13, | |
181 | ALC663_ASUS_G50V, | |
f1d4e28b KY |
182 | ALC662_ECS, |
183 | ALC663_ASUS_MODE1, | |
184 | ALC662_ASUS_MODE2, | |
185 | ALC663_ASUS_MODE3, | |
186 | ALC663_ASUS_MODE4, | |
187 | ALC663_ASUS_MODE5, | |
188 | ALC663_ASUS_MODE6, | |
bc9f98a9 KY |
189 | ALC662_AUTO, |
190 | ALC662_MODEL_LAST, | |
191 | }; | |
192 | ||
df694daa KY |
193 | /* ALC882 models */ |
194 | enum { | |
195 | ALC882_3ST_DIG, | |
196 | ALC882_6ST_DIG, | |
4b146cb0 | 197 | ALC882_ARIMA, |
bdd148a3 | 198 | ALC882_W2JC, |
272a527c KY |
199 | ALC882_TARGA, |
200 | ALC882_ASUS_A7J, | |
914759b7 | 201 | ALC882_ASUS_A7M, |
9102cd1c | 202 | ALC885_MACPRO, |
87350ad0 | 203 | ALC885_MBP3, |
c54728d8 | 204 | ALC885_IMAC24, |
272a527c | 205 | ALC882_AUTO, |
df694daa KY |
206 | ALC882_MODEL_LAST, |
207 | }; | |
208 | ||
9c7f852e TI |
209 | /* ALC883 models */ |
210 | enum { | |
211 | ALC883_3ST_2ch_DIG, | |
212 | ALC883_3ST_6ch_DIG, | |
213 | ALC883_3ST_6ch, | |
214 | ALC883_6ST_DIG, | |
ccc656ce KY |
215 | ALC883_TARGA_DIG, |
216 | ALC883_TARGA_2ch_DIG, | |
bab282b9 | 217 | ALC883_ACER, |
2880a867 | 218 | ALC883_ACER_ASPIRE, |
5b2d1eca | 219 | ALC888_ACER_ASPIRE_4930G, |
c07584c8 | 220 | ALC883_MEDION, |
ea1fb29a | 221 | ALC883_MEDION_MD2, |
b373bdeb | 222 | ALC883_LAPTOP_EAPD, |
bc9f98a9 | 223 | ALC883_LENOVO_101E_2ch, |
272a527c | 224 | ALC883_LENOVO_NB0763, |
189609ae | 225 | ALC888_LENOVO_MS7195_DIG, |
e2757d5e | 226 | ALC888_LENOVO_SKY, |
ea1fb29a | 227 | ALC883_HAIER_W66, |
4723c022 | 228 | ALC888_3ST_HP, |
5795b9e6 | 229 | ALC888_6ST_DELL, |
a8848bd6 | 230 | ALC883_MITAC, |
0c4cc443 | 231 | ALC883_CLEVO_M720, |
fb97dc67 | 232 | ALC883_FUJITSU_PI2515, |
ef8ef5fb | 233 | ALC888_FUJITSU_XA3530, |
17bba1b7 | 234 | ALC883_3ST_6ch_INTEL, |
e2757d5e KY |
235 | ALC888_ASUS_M90V, |
236 | ALC888_ASUS_EEE1601, | |
3ab90935 | 237 | ALC1200_ASUS_P5Q, |
9c7f852e TI |
238 | ALC883_AUTO, |
239 | ALC883_MODEL_LAST, | |
240 | }; | |
241 | ||
df694daa KY |
242 | /* for GPIO Poll */ |
243 | #define GPIO_MASK 0x03 | |
244 | ||
1da177e4 LT |
245 | struct alc_spec { |
246 | /* codec parameterization */ | |
df694daa | 247 | struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ |
1da177e4 | 248 | unsigned int num_mixers; |
f9e336f6 | 249 | struct snd_kcontrol_new *cap_mixer; /* capture mixer */ |
1da177e4 | 250 | |
df694daa | 251 | const struct hda_verb *init_verbs[5]; /* initialization verbs |
9c7f852e TI |
252 | * don't forget NULL |
253 | * termination! | |
e9edcee0 TI |
254 | */ |
255 | unsigned int num_init_verbs; | |
1da177e4 | 256 | |
16ded525 | 257 | char *stream_name_analog; /* analog PCM stream */ |
1da177e4 LT |
258 | struct hda_pcm_stream *stream_analog_playback; |
259 | struct hda_pcm_stream *stream_analog_capture; | |
6330079f TI |
260 | struct hda_pcm_stream *stream_analog_alt_playback; |
261 | struct hda_pcm_stream *stream_analog_alt_capture; | |
1da177e4 | 262 | |
f12ab1e0 | 263 | char *stream_name_digital; /* digital PCM stream */ |
1da177e4 LT |
264 | struct hda_pcm_stream *stream_digital_playback; |
265 | struct hda_pcm_stream *stream_digital_capture; | |
266 | ||
267 | /* playback */ | |
16ded525 TI |
268 | struct hda_multi_out multiout; /* playback set-up |
269 | * max_channels, dacs must be set | |
270 | * dig_out_nid and hp_nid are optional | |
271 | */ | |
6330079f | 272 | hda_nid_t alt_dac_nid; |
1da177e4 LT |
273 | |
274 | /* capture */ | |
275 | unsigned int num_adc_nids; | |
276 | hda_nid_t *adc_nids; | |
e1406348 | 277 | hda_nid_t *capsrc_nids; |
16ded525 | 278 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
54cbc9ab | 279 | unsigned char is_mix_capture; /* matrix-style capture (non-mux) */ |
1da177e4 LT |
280 | |
281 | /* capture source */ | |
a1e8d2da | 282 | unsigned int num_mux_defs; |
1da177e4 LT |
283 | const struct hda_input_mux *input_mux; |
284 | unsigned int cur_mux[3]; | |
285 | ||
286 | /* channel model */ | |
d2a6d7dc | 287 | const struct hda_channel_mode *channel_mode; |
1da177e4 | 288 | int num_channel_mode; |
4e195a7b | 289 | int need_dac_fix; |
1da177e4 LT |
290 | |
291 | /* PCM information */ | |
4c5186ed | 292 | struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ |
41e41f1f | 293 | |
e9edcee0 TI |
294 | /* dynamic controls, init_verbs and input_mux */ |
295 | struct auto_pin_cfg autocfg; | |
603c4019 | 296 | struct snd_array kctls; |
e9edcee0 | 297 | struct hda_input_mux private_imux; |
41923e44 | 298 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
834be88d | 299 | |
ae6b813a TI |
300 | /* hooks */ |
301 | void (*init_hook)(struct hda_codec *codec); | |
302 | void (*unsol_event)(struct hda_codec *codec, unsigned int res); | |
303 | ||
834be88d TI |
304 | /* for pin sensing */ |
305 | unsigned int sense_updated: 1; | |
306 | unsigned int jack_present: 1; | |
bec15c3a | 307 | unsigned int master_sw: 1; |
cb53c626 | 308 | |
2134ea4f TI |
309 | /* for virtual master */ |
310 | hda_nid_t vmaster_nid; | |
cb53c626 TI |
311 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
312 | struct hda_loopback_check loopback; | |
313 | #endif | |
2c3bf9ab TI |
314 | |
315 | /* for PLL fix */ | |
316 | hda_nid_t pll_nid; | |
317 | unsigned int pll_coef_idx, pll_coef_bit; | |
e044c39a TI |
318 | |
319 | #ifdef SND_HDA_NEEDS_RESUME | |
320 | #define ALC_MAX_PINS 16 | |
321 | unsigned int num_pins; | |
322 | hda_nid_t pin_nids[ALC_MAX_PINS]; | |
323 | unsigned int pin_cfgs[ALC_MAX_PINS]; | |
324 | #endif | |
df694daa KY |
325 | }; |
326 | ||
327 | /* | |
328 | * configuration template - to be copied to the spec instance | |
329 | */ | |
330 | struct alc_config_preset { | |
9c7f852e TI |
331 | struct snd_kcontrol_new *mixers[5]; /* should be identical size |
332 | * with spec | |
333 | */ | |
f9e336f6 | 334 | struct snd_kcontrol_new *cap_mixer; /* capture mixer */ |
df694daa KY |
335 | const struct hda_verb *init_verbs[5]; |
336 | unsigned int num_dacs; | |
337 | hda_nid_t *dac_nids; | |
338 | hda_nid_t dig_out_nid; /* optional */ | |
339 | hda_nid_t hp_nid; /* optional */ | |
340 | unsigned int num_adc_nids; | |
341 | hda_nid_t *adc_nids; | |
e1406348 | 342 | hda_nid_t *capsrc_nids; |
df694daa KY |
343 | hda_nid_t dig_in_nid; |
344 | unsigned int num_channel_mode; | |
345 | const struct hda_channel_mode *channel_mode; | |
4e195a7b | 346 | int need_dac_fix; |
a1e8d2da | 347 | unsigned int num_mux_defs; |
df694daa | 348 | const struct hda_input_mux *input_mux; |
ae6b813a TI |
349 | void (*unsol_event)(struct hda_codec *, unsigned int); |
350 | void (*init_hook)(struct hda_codec *); | |
cb53c626 TI |
351 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
352 | struct hda_amp_list *loopbacks; | |
353 | #endif | |
1da177e4 LT |
354 | }; |
355 | ||
1da177e4 LT |
356 | |
357 | /* | |
358 | * input MUX handling | |
359 | */ | |
9c7f852e TI |
360 | static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, |
361 | struct snd_ctl_elem_info *uinfo) | |
1da177e4 LT |
362 | { |
363 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
364 | struct alc_spec *spec = codec->spec; | |
a1e8d2da JW |
365 | unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id); |
366 | if (mux_idx >= spec->num_mux_defs) | |
367 | mux_idx = 0; | |
368 | return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo); | |
1da177e4 LT |
369 | } |
370 | ||
9c7f852e TI |
371 | static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, |
372 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
373 | { |
374 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
375 | struct alc_spec *spec = codec->spec; | |
376 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
377 | ||
378 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; | |
379 | return 0; | |
380 | } | |
381 | ||
9c7f852e TI |
382 | static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, |
383 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
384 | { |
385 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
386 | struct alc_spec *spec = codec->spec; | |
cd896c33 | 387 | const struct hda_input_mux *imux; |
1da177e4 | 388 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
cd896c33 | 389 | unsigned int mux_idx; |
e1406348 TI |
390 | hda_nid_t nid = spec->capsrc_nids ? |
391 | spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx]; | |
1da177e4 | 392 | |
cd896c33 TI |
393 | mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; |
394 | imux = &spec->input_mux[mux_idx]; | |
395 | ||
54cbc9ab TI |
396 | if (spec->is_mix_capture) { |
397 | /* Matrix-mixer style (e.g. ALC882) */ | |
398 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; | |
399 | unsigned int i, idx; | |
400 | ||
401 | idx = ucontrol->value.enumerated.item[0]; | |
402 | if (idx >= imux->num_items) | |
403 | idx = imux->num_items - 1; | |
404 | if (*cur_val == idx) | |
405 | return 0; | |
406 | for (i = 0; i < imux->num_items; i++) { | |
407 | unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE; | |
408 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, | |
409 | imux->items[i].index, | |
410 | HDA_AMP_MUTE, v); | |
411 | } | |
412 | *cur_val = idx; | |
413 | return 1; | |
414 | } else { | |
415 | /* MUX style (e.g. ALC880) */ | |
cd896c33 | 416 | return snd_hda_input_mux_put(codec, imux, ucontrol, nid, |
54cbc9ab TI |
417 | &spec->cur_mux[adc_idx]); |
418 | } | |
419 | } | |
e9edcee0 | 420 | |
1da177e4 LT |
421 | /* |
422 | * channel mode setting | |
423 | */ | |
9c7f852e TI |
424 | static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, |
425 | struct snd_ctl_elem_info *uinfo) | |
1da177e4 LT |
426 | { |
427 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
428 | struct alc_spec *spec = codec->spec; | |
d2a6d7dc TI |
429 | return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, |
430 | spec->num_channel_mode); | |
1da177e4 LT |
431 | } |
432 | ||
9c7f852e TI |
433 | static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, |
434 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
435 | { |
436 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
437 | struct alc_spec *spec = codec->spec; | |
d2a6d7dc | 438 | return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, |
9c7f852e TI |
439 | spec->num_channel_mode, |
440 | spec->multiout.max_channels); | |
1da177e4 LT |
441 | } |
442 | ||
9c7f852e TI |
443 | static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, |
444 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
445 | { |
446 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
447 | struct alc_spec *spec = codec->spec; | |
4e195a7b TI |
448 | int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, |
449 | spec->num_channel_mode, | |
450 | &spec->multiout.max_channels); | |
bd2033f2 | 451 | if (err >= 0 && spec->need_dac_fix) |
4e195a7b TI |
452 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; |
453 | return err; | |
1da177e4 LT |
454 | } |
455 | ||
a9430dd8 | 456 | /* |
4c5186ed | 457 | * Control the mode of pin widget settings via the mixer. "pc" is used |
ea1fb29a | 458 | * instead of "%" to avoid consequences of accidently treating the % as |
4c5186ed JW |
459 | * being part of a format specifier. Maximum allowed length of a value is |
460 | * 63 characters plus NULL terminator. | |
7cf51e48 JW |
461 | * |
462 | * Note: some retasking pin complexes seem to ignore requests for input | |
463 | * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these | |
464 | * are requested. Therefore order this list so that this behaviour will not | |
465 | * cause problems when mixer clients move through the enum sequentially. | |
a1e8d2da JW |
466 | * NIDs 0x0f and 0x10 have been observed to have this behaviour as of |
467 | * March 2006. | |
4c5186ed JW |
468 | */ |
469 | static char *alc_pin_mode_names[] = { | |
7cf51e48 JW |
470 | "Mic 50pc bias", "Mic 80pc bias", |
471 | "Line in", "Line out", "Headphone out", | |
4c5186ed JW |
472 | }; |
473 | static unsigned char alc_pin_mode_values[] = { | |
7cf51e48 | 474 | PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP, |
4c5186ed JW |
475 | }; |
476 | /* The control can present all 5 options, or it can limit the options based | |
a1e8d2da JW |
477 | * in the pin being assumed to be exclusively an input or an output pin. In |
478 | * addition, "input" pins may or may not process the mic bias option | |
479 | * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to | |
480 | * accept requests for bias as of chip versions up to March 2006) and/or | |
481 | * wiring in the computer. | |
a9430dd8 | 482 | */ |
a1e8d2da JW |
483 | #define ALC_PIN_DIR_IN 0x00 |
484 | #define ALC_PIN_DIR_OUT 0x01 | |
485 | #define ALC_PIN_DIR_INOUT 0x02 | |
486 | #define ALC_PIN_DIR_IN_NOMICBIAS 0x03 | |
487 | #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04 | |
4c5186ed | 488 | |
ea1fb29a | 489 | /* Info about the pin modes supported by the different pin direction modes. |
4c5186ed JW |
490 | * For each direction the minimum and maximum values are given. |
491 | */ | |
a1e8d2da | 492 | static signed char alc_pin_mode_dir_info[5][2] = { |
4c5186ed JW |
493 | { 0, 2 }, /* ALC_PIN_DIR_IN */ |
494 | { 3, 4 }, /* ALC_PIN_DIR_OUT */ | |
495 | { 0, 4 }, /* ALC_PIN_DIR_INOUT */ | |
a1e8d2da JW |
496 | { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */ |
497 | { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */ | |
4c5186ed JW |
498 | }; |
499 | #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0]) | |
500 | #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1]) | |
501 | #define alc_pin_mode_n_items(_dir) \ | |
502 | (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1) | |
503 | ||
9c7f852e TI |
504 | static int alc_pin_mode_info(struct snd_kcontrol *kcontrol, |
505 | struct snd_ctl_elem_info *uinfo) | |
a9430dd8 | 506 | { |
4c5186ed JW |
507 | unsigned int item_num = uinfo->value.enumerated.item; |
508 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; | |
509 | ||
510 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
a9430dd8 | 511 | uinfo->count = 1; |
4c5186ed JW |
512 | uinfo->value.enumerated.items = alc_pin_mode_n_items(dir); |
513 | ||
514 | if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir)) | |
515 | item_num = alc_pin_mode_min(dir); | |
516 | strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]); | |
a9430dd8 JW |
517 | return 0; |
518 | } | |
519 | ||
9c7f852e TI |
520 | static int alc_pin_mode_get(struct snd_kcontrol *kcontrol, |
521 | struct snd_ctl_elem_value *ucontrol) | |
a9430dd8 | 522 | { |
4c5186ed | 523 | unsigned int i; |
a9430dd8 JW |
524 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
525 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
4c5186ed | 526 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
a9430dd8 | 527 | long *valp = ucontrol->value.integer.value; |
9c7f852e TI |
528 | unsigned int pinctl = snd_hda_codec_read(codec, nid, 0, |
529 | AC_VERB_GET_PIN_WIDGET_CONTROL, | |
530 | 0x00); | |
a9430dd8 | 531 | |
4c5186ed JW |
532 | /* Find enumerated value for current pinctl setting */ |
533 | i = alc_pin_mode_min(dir); | |
9c7f852e | 534 | while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir)) |
4c5186ed | 535 | i++; |
9c7f852e | 536 | *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir); |
a9430dd8 JW |
537 | return 0; |
538 | } | |
539 | ||
9c7f852e TI |
540 | static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, |
541 | struct snd_ctl_elem_value *ucontrol) | |
a9430dd8 | 542 | { |
4c5186ed | 543 | signed int change; |
a9430dd8 JW |
544 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
545 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
4c5186ed JW |
546 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
547 | long val = *ucontrol->value.integer.value; | |
9c7f852e TI |
548 | unsigned int pinctl = snd_hda_codec_read(codec, nid, 0, |
549 | AC_VERB_GET_PIN_WIDGET_CONTROL, | |
550 | 0x00); | |
a9430dd8 | 551 | |
f12ab1e0 | 552 | if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir)) |
4c5186ed JW |
553 | val = alc_pin_mode_min(dir); |
554 | ||
555 | change = pinctl != alc_pin_mode_values[val]; | |
cdcd9268 JW |
556 | if (change) { |
557 | /* Set pin mode to that requested */ | |
82beb8fd TI |
558 | snd_hda_codec_write_cache(codec, nid, 0, |
559 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
560 | alc_pin_mode_values[val]); | |
cdcd9268 | 561 | |
ea1fb29a | 562 | /* Also enable the retasking pin's input/output as required |
cdcd9268 JW |
563 | * for the requested pin mode. Enum values of 2 or less are |
564 | * input modes. | |
565 | * | |
566 | * Dynamically switching the input/output buffers probably | |
a1e8d2da JW |
567 | * reduces noise slightly (particularly on input) so we'll |
568 | * do it. However, having both input and output buffers | |
569 | * enabled simultaneously doesn't seem to be problematic if | |
570 | * this turns out to be necessary in the future. | |
cdcd9268 JW |
571 | */ |
572 | if (val <= 2) { | |
47fd830a TI |
573 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
574 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
575 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0, | |
576 | HDA_AMP_MUTE, 0); | |
cdcd9268 | 577 | } else { |
47fd830a TI |
578 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0, |
579 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
580 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, | |
581 | HDA_AMP_MUTE, 0); | |
cdcd9268 JW |
582 | } |
583 | } | |
a9430dd8 JW |
584 | return change; |
585 | } | |
586 | ||
4c5186ed | 587 | #define ALC_PIN_MODE(xname, nid, dir) \ |
a9430dd8 | 588 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ |
4c5186ed JW |
589 | .info = alc_pin_mode_info, \ |
590 | .get = alc_pin_mode_get, \ | |
591 | .put = alc_pin_mode_put, \ | |
592 | .private_value = nid | (dir<<16) } | |
df694daa | 593 | |
5c8f858d JW |
594 | /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged |
595 | * together using a mask with more than one bit set. This control is | |
596 | * currently used only by the ALC260 test model. At this stage they are not | |
597 | * needed for any "production" models. | |
598 | */ | |
599 | #ifdef CONFIG_SND_DEBUG | |
a5ce8890 | 600 | #define alc_gpio_data_info snd_ctl_boolean_mono_info |
f12ab1e0 | 601 | |
9c7f852e TI |
602 | static int alc_gpio_data_get(struct snd_kcontrol *kcontrol, |
603 | struct snd_ctl_elem_value *ucontrol) | |
5c8f858d JW |
604 | { |
605 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
606 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
607 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
608 | long *valp = ucontrol->value.integer.value; | |
9c7f852e TI |
609 | unsigned int val = snd_hda_codec_read(codec, nid, 0, |
610 | AC_VERB_GET_GPIO_DATA, 0x00); | |
5c8f858d JW |
611 | |
612 | *valp = (val & mask) != 0; | |
613 | return 0; | |
614 | } | |
9c7f852e TI |
615 | static int alc_gpio_data_put(struct snd_kcontrol *kcontrol, |
616 | struct snd_ctl_elem_value *ucontrol) | |
5c8f858d JW |
617 | { |
618 | signed int change; | |
619 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
620 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
621 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
622 | long val = *ucontrol->value.integer.value; | |
9c7f852e TI |
623 | unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0, |
624 | AC_VERB_GET_GPIO_DATA, | |
625 | 0x00); | |
5c8f858d JW |
626 | |
627 | /* Set/unset the masked GPIO bit(s) as needed */ | |
9c7f852e TI |
628 | change = (val == 0 ? 0 : mask) != (gpio_data & mask); |
629 | if (val == 0) | |
5c8f858d JW |
630 | gpio_data &= ~mask; |
631 | else | |
632 | gpio_data |= mask; | |
82beb8fd TI |
633 | snd_hda_codec_write_cache(codec, nid, 0, |
634 | AC_VERB_SET_GPIO_DATA, gpio_data); | |
5c8f858d JW |
635 | |
636 | return change; | |
637 | } | |
638 | #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \ | |
639 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
640 | .info = alc_gpio_data_info, \ | |
641 | .get = alc_gpio_data_get, \ | |
642 | .put = alc_gpio_data_put, \ | |
643 | .private_value = nid | (mask<<16) } | |
644 | #endif /* CONFIG_SND_DEBUG */ | |
645 | ||
92621f13 JW |
646 | /* A switch control to allow the enabling of the digital IO pins on the |
647 | * ALC260. This is incredibly simplistic; the intention of this control is | |
648 | * to provide something in the test model allowing digital outputs to be | |
649 | * identified if present. If models are found which can utilise these | |
650 | * outputs a more complete mixer control can be devised for those models if | |
651 | * necessary. | |
652 | */ | |
653 | #ifdef CONFIG_SND_DEBUG | |
a5ce8890 | 654 | #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info |
f12ab1e0 | 655 | |
9c7f852e TI |
656 | static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol, |
657 | struct snd_ctl_elem_value *ucontrol) | |
92621f13 JW |
658 | { |
659 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
660 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
661 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
662 | long *valp = ucontrol->value.integer.value; | |
9c7f852e | 663 | unsigned int val = snd_hda_codec_read(codec, nid, 0, |
3982d17e | 664 | AC_VERB_GET_DIGI_CONVERT_1, 0x00); |
92621f13 JW |
665 | |
666 | *valp = (val & mask) != 0; | |
667 | return 0; | |
668 | } | |
9c7f852e TI |
669 | static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol, |
670 | struct snd_ctl_elem_value *ucontrol) | |
92621f13 JW |
671 | { |
672 | signed int change; | |
673 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
674 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
675 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
676 | long val = *ucontrol->value.integer.value; | |
9c7f852e | 677 | unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0, |
3982d17e | 678 | AC_VERB_GET_DIGI_CONVERT_1, |
9c7f852e | 679 | 0x00); |
92621f13 JW |
680 | |
681 | /* Set/unset the masked control bit(s) as needed */ | |
9c7f852e | 682 | change = (val == 0 ? 0 : mask) != (ctrl_data & mask); |
92621f13 JW |
683 | if (val==0) |
684 | ctrl_data &= ~mask; | |
685 | else | |
686 | ctrl_data |= mask; | |
82beb8fd TI |
687 | snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, |
688 | ctrl_data); | |
92621f13 JW |
689 | |
690 | return change; | |
691 | } | |
692 | #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \ | |
693 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
694 | .info = alc_spdif_ctrl_info, \ | |
695 | .get = alc_spdif_ctrl_get, \ | |
696 | .put = alc_spdif_ctrl_put, \ | |
697 | .private_value = nid | (mask<<16) } | |
698 | #endif /* CONFIG_SND_DEBUG */ | |
699 | ||
f8225f6d JW |
700 | /* A switch control to allow the enabling EAPD digital outputs on the ALC26x. |
701 | * Again, this is only used in the ALC26x test models to help identify when | |
702 | * the EAPD line must be asserted for features to work. | |
703 | */ | |
704 | #ifdef CONFIG_SND_DEBUG | |
705 | #define alc_eapd_ctrl_info snd_ctl_boolean_mono_info | |
706 | ||
707 | static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol, | |
708 | struct snd_ctl_elem_value *ucontrol) | |
709 | { | |
710 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
711 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
712 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
713 | long *valp = ucontrol->value.integer.value; | |
714 | unsigned int val = snd_hda_codec_read(codec, nid, 0, | |
715 | AC_VERB_GET_EAPD_BTLENABLE, 0x00); | |
716 | ||
717 | *valp = (val & mask) != 0; | |
718 | return 0; | |
719 | } | |
720 | ||
721 | static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol, | |
722 | struct snd_ctl_elem_value *ucontrol) | |
723 | { | |
724 | int change; | |
725 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
726 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
727 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
728 | long val = *ucontrol->value.integer.value; | |
729 | unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0, | |
730 | AC_VERB_GET_EAPD_BTLENABLE, | |
731 | 0x00); | |
732 | ||
733 | /* Set/unset the masked control bit(s) as needed */ | |
734 | change = (!val ? 0 : mask) != (ctrl_data & mask); | |
735 | if (!val) | |
736 | ctrl_data &= ~mask; | |
737 | else | |
738 | ctrl_data |= mask; | |
739 | snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, | |
740 | ctrl_data); | |
741 | ||
742 | return change; | |
743 | } | |
744 | ||
745 | #define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \ | |
746 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
747 | .info = alc_eapd_ctrl_info, \ | |
748 | .get = alc_eapd_ctrl_get, \ | |
749 | .put = alc_eapd_ctrl_put, \ | |
750 | .private_value = nid | (mask<<16) } | |
751 | #endif /* CONFIG_SND_DEBUG */ | |
752 | ||
d88897ea TI |
753 | /* |
754 | */ | |
755 | static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix) | |
756 | { | |
757 | if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers))) | |
758 | return; | |
759 | spec->mixers[spec->num_mixers++] = mix; | |
760 | } | |
761 | ||
762 | static void add_verb(struct alc_spec *spec, const struct hda_verb *verb) | |
763 | { | |
764 | if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs))) | |
765 | return; | |
766 | spec->init_verbs[spec->num_init_verbs++] = verb; | |
767 | } | |
768 | ||
df694daa KY |
769 | /* |
770 | * set up from the preset table | |
771 | */ | |
9c7f852e TI |
772 | static void setup_preset(struct alc_spec *spec, |
773 | const struct alc_config_preset *preset) | |
df694daa KY |
774 | { |
775 | int i; | |
776 | ||
777 | for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++) | |
d88897ea | 778 | add_mixer(spec, preset->mixers[i]); |
f9e336f6 | 779 | spec->cap_mixer = preset->cap_mixer; |
9c7f852e TI |
780 | for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; |
781 | i++) | |
d88897ea | 782 | add_verb(spec, preset->init_verbs[i]); |
ea1fb29a | 783 | |
df694daa KY |
784 | spec->channel_mode = preset->channel_mode; |
785 | spec->num_channel_mode = preset->num_channel_mode; | |
4e195a7b | 786 | spec->need_dac_fix = preset->need_dac_fix; |
df694daa KY |
787 | |
788 | spec->multiout.max_channels = spec->channel_mode[0].channels; | |
789 | ||
790 | spec->multiout.num_dacs = preset->num_dacs; | |
791 | spec->multiout.dac_nids = preset->dac_nids; | |
792 | spec->multiout.dig_out_nid = preset->dig_out_nid; | |
793 | spec->multiout.hp_nid = preset->hp_nid; | |
ea1fb29a | 794 | |
a1e8d2da | 795 | spec->num_mux_defs = preset->num_mux_defs; |
f12ab1e0 | 796 | if (!spec->num_mux_defs) |
a1e8d2da | 797 | spec->num_mux_defs = 1; |
df694daa KY |
798 | spec->input_mux = preset->input_mux; |
799 | ||
800 | spec->num_adc_nids = preset->num_adc_nids; | |
801 | spec->adc_nids = preset->adc_nids; | |
e1406348 | 802 | spec->capsrc_nids = preset->capsrc_nids; |
df694daa | 803 | spec->dig_in_nid = preset->dig_in_nid; |
ae6b813a TI |
804 | |
805 | spec->unsol_event = preset->unsol_event; | |
806 | spec->init_hook = preset->init_hook; | |
cb53c626 TI |
807 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
808 | spec->loopback.amplist = preset->loopbacks; | |
809 | #endif | |
df694daa KY |
810 | } |
811 | ||
bc9f98a9 KY |
812 | /* Enable GPIO mask and set output */ |
813 | static struct hda_verb alc_gpio1_init_verbs[] = { | |
814 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
815 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
816 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, | |
817 | { } | |
818 | }; | |
819 | ||
820 | static struct hda_verb alc_gpio2_init_verbs[] = { | |
821 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, | |
822 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, | |
823 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, | |
824 | { } | |
825 | }; | |
826 | ||
bdd148a3 KY |
827 | static struct hda_verb alc_gpio3_init_verbs[] = { |
828 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, | |
829 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | |
830 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | |
831 | { } | |
832 | }; | |
833 | ||
2c3bf9ab TI |
834 | /* |
835 | * Fix hardware PLL issue | |
836 | * On some codecs, the analog PLL gating control must be off while | |
837 | * the default value is 1. | |
838 | */ | |
839 | static void alc_fix_pll(struct hda_codec *codec) | |
840 | { | |
841 | struct alc_spec *spec = codec->spec; | |
842 | unsigned int val; | |
843 | ||
844 | if (!spec->pll_nid) | |
845 | return; | |
846 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, | |
847 | spec->pll_coef_idx); | |
848 | val = snd_hda_codec_read(codec, spec->pll_nid, 0, | |
849 | AC_VERB_GET_PROC_COEF, 0); | |
850 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, | |
851 | spec->pll_coef_idx); | |
852 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF, | |
853 | val & ~(1 << spec->pll_coef_bit)); | |
854 | } | |
855 | ||
856 | static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, | |
857 | unsigned int coef_idx, unsigned int coef_bit) | |
858 | { | |
859 | struct alc_spec *spec = codec->spec; | |
860 | spec->pll_nid = nid; | |
861 | spec->pll_coef_idx = coef_idx; | |
862 | spec->pll_coef_bit = coef_bit; | |
863 | alc_fix_pll(codec); | |
864 | } | |
865 | ||
c9b58006 KY |
866 | static void alc_sku_automute(struct hda_codec *codec) |
867 | { | |
868 | struct alc_spec *spec = codec->spec; | |
c9b58006 KY |
869 | unsigned int present; |
870 | unsigned int hp_nid = spec->autocfg.hp_pins[0]; | |
871 | unsigned int sp_nid = spec->autocfg.speaker_pins[0]; | |
872 | ||
873 | /* need to execute and sync at first */ | |
874 | snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0); | |
875 | present = snd_hda_codec_read(codec, hp_nid, 0, | |
876 | AC_VERB_GET_PIN_SENSE, 0); | |
877 | spec->jack_present = (present & 0x80000000) != 0; | |
f6c7e546 TI |
878 | snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
879 | spec->jack_present ? 0 : PIN_OUT); | |
c9b58006 KY |
880 | } |
881 | ||
4605b718 | 882 | #if 0 /* it's broken in some acses -- temporarily disabled */ |
7fb0d78f KY |
883 | static void alc_mic_automute(struct hda_codec *codec) |
884 | { | |
885 | struct alc_spec *spec = codec->spec; | |
886 | unsigned int present; | |
887 | unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC]; | |
888 | unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]; | |
889 | unsigned int mix_nid = spec->capsrc_nids[0]; | |
890 | unsigned int capsrc_idx_mic, capsrc_idx_fmic; | |
891 | ||
892 | capsrc_idx_mic = mic_nid - 0x18; | |
893 | capsrc_idx_fmic = fmic_nid - 0x18; | |
894 | present = snd_hda_codec_read(codec, mic_nid, 0, | |
895 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
896 | snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
897 | 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80)); | |
898 | snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
899 | 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0)); | |
900 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic, | |
901 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
902 | } | |
4605b718 TI |
903 | #else |
904 | #define alc_mic_automute(codec) /* NOP */ | |
905 | #endif /* disabled */ | |
7fb0d78f | 906 | |
c9b58006 KY |
907 | /* unsolicited event for HP jack sensing */ |
908 | static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) | |
909 | { | |
910 | if (codec->vendor_id == 0x10ec0880) | |
911 | res >>= 28; | |
912 | else | |
913 | res >>= 26; | |
7fb0d78f KY |
914 | if (res == ALC880_HP_EVENT) |
915 | alc_sku_automute(codec); | |
c9b58006 | 916 | |
7fb0d78f KY |
917 | if (res == ALC880_MIC_EVENT) |
918 | alc_mic_automute(codec); | |
919 | } | |
920 | ||
921 | static void alc_inithook(struct hda_codec *codec) | |
922 | { | |
c9b58006 | 923 | alc_sku_automute(codec); |
7fb0d78f | 924 | alc_mic_automute(codec); |
c9b58006 KY |
925 | } |
926 | ||
f9423e7a KY |
927 | /* additional initialization for ALC888 variants */ |
928 | static void alc888_coef_init(struct hda_codec *codec) | |
929 | { | |
930 | unsigned int tmp; | |
931 | ||
932 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0); | |
933 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); | |
934 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); | |
935 | if ((tmp & 0xf0) == 2) | |
936 | /* alc888S-VC */ | |
937 | snd_hda_codec_read(codec, 0x20, 0, | |
938 | AC_VERB_SET_PROC_COEF, 0x830); | |
939 | else | |
940 | /* alc888-VB */ | |
941 | snd_hda_codec_read(codec, 0x20, 0, | |
942 | AC_VERB_SET_PROC_COEF, 0x3030); | |
943 | } | |
944 | ||
bc9f98a9 KY |
945 | /* 32-bit subsystem ID for BIOS loading in HD Audio codec. |
946 | * 31 ~ 16 : Manufacture ID | |
947 | * 15 ~ 8 : SKU ID | |
948 | * 7 ~ 0 : Assembly ID | |
949 | * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36 | |
950 | */ | |
951 | static void alc_subsystem_id(struct hda_codec *codec, | |
952 | unsigned int porta, unsigned int porte, | |
953 | unsigned int portd) | |
954 | { | |
c9b58006 KY |
955 | unsigned int ass, tmp, i; |
956 | unsigned nid; | |
957 | struct alc_spec *spec = codec->spec; | |
bc9f98a9 | 958 | |
c9b58006 KY |
959 | ass = codec->subsystem_id & 0xffff; |
960 | if ((ass != codec->bus->pci->subsystem_device) && (ass & 1)) | |
961 | goto do_sku; | |
962 | ||
ea1fb29a | 963 | /* |
c9b58006 KY |
964 | * 31~30 : port conetcivity |
965 | * 29~21 : reserve | |
966 | * 20 : PCBEEP input | |
967 | * 19~16 : Check sum (15:1) | |
968 | * 15~1 : Custom | |
969 | * 0 : override | |
970 | */ | |
971 | nid = 0x1d; | |
972 | if (codec->vendor_id == 0x10ec0260) | |
973 | nid = 0x17; | |
974 | ass = snd_hda_codec_read(codec, nid, 0, | |
975 | AC_VERB_GET_CONFIG_DEFAULT, 0); | |
976 | if (!(ass & 1) && !(ass & 0x100000)) | |
977 | return; | |
978 | if ((ass >> 30) != 1) /* no physical connection */ | |
bc9f98a9 KY |
979 | return; |
980 | ||
c9b58006 KY |
981 | /* check sum */ |
982 | tmp = 0; | |
983 | for (i = 1; i < 16; i++) { | |
8c427226 | 984 | if ((ass >> i) & 1) |
c9b58006 KY |
985 | tmp++; |
986 | } | |
987 | if (((ass >> 16) & 0xf) != tmp) | |
988 | return; | |
989 | do_sku: | |
990 | /* | |
991 | * 0 : override | |
992 | * 1 : Swap Jack | |
993 | * 2 : 0 --> Desktop, 1 --> Laptop | |
994 | * 3~5 : External Amplifier control | |
995 | * 7~6 : Reserved | |
996 | */ | |
bc9f98a9 KY |
997 | tmp = (ass & 0x38) >> 3; /* external Amp control */ |
998 | switch (tmp) { | |
999 | case 1: | |
1000 | snd_hda_sequence_write(codec, alc_gpio1_init_verbs); | |
1001 | break; | |
1002 | case 3: | |
1003 | snd_hda_sequence_write(codec, alc_gpio2_init_verbs); | |
1004 | break; | |
bdd148a3 KY |
1005 | case 7: |
1006 | snd_hda_sequence_write(codec, alc_gpio3_init_verbs); | |
1007 | break; | |
c9b58006 | 1008 | case 5: /* set EAPD output high */ |
bdd148a3 | 1009 | switch (codec->vendor_id) { |
c9b58006 KY |
1010 | case 0x10ec0260: |
1011 | snd_hda_codec_write(codec, 0x0f, 0, | |
1012 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
1013 | snd_hda_codec_write(codec, 0x10, 0, | |
1014 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
1015 | break; | |
1016 | case 0x10ec0262: | |
bdd148a3 KY |
1017 | case 0x10ec0267: |
1018 | case 0x10ec0268: | |
c9b58006 | 1019 | case 0x10ec0269: |
f9423e7a KY |
1020 | case 0x10ec0660: |
1021 | case 0x10ec0662: | |
1022 | case 0x10ec0663: | |
c9b58006 | 1023 | case 0x10ec0862: |
20a3a05d | 1024 | case 0x10ec0889: |
bdd148a3 KY |
1025 | snd_hda_codec_write(codec, 0x14, 0, |
1026 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
1027 | snd_hda_codec_write(codec, 0x15, 0, | |
1028 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
c9b58006 | 1029 | break; |
bdd148a3 | 1030 | } |
c9b58006 KY |
1031 | switch (codec->vendor_id) { |
1032 | case 0x10ec0260: | |
1033 | snd_hda_codec_write(codec, 0x1a, 0, | |
1034 | AC_VERB_SET_COEF_INDEX, 7); | |
1035 | tmp = snd_hda_codec_read(codec, 0x1a, 0, | |
1036 | AC_VERB_GET_PROC_COEF, 0); | |
1037 | snd_hda_codec_write(codec, 0x1a, 0, | |
1038 | AC_VERB_SET_COEF_INDEX, 7); | |
1039 | snd_hda_codec_write(codec, 0x1a, 0, | |
1040 | AC_VERB_SET_PROC_COEF, | |
1041 | tmp | 0x2010); | |
1042 | break; | |
1043 | case 0x10ec0262: | |
1044 | case 0x10ec0880: | |
1045 | case 0x10ec0882: | |
1046 | case 0x10ec0883: | |
1047 | case 0x10ec0885: | |
20a3a05d | 1048 | case 0x10ec0889: |
c9b58006 KY |
1049 | snd_hda_codec_write(codec, 0x20, 0, |
1050 | AC_VERB_SET_COEF_INDEX, 7); | |
1051 | tmp = snd_hda_codec_read(codec, 0x20, 0, | |
1052 | AC_VERB_GET_PROC_COEF, 0); | |
1053 | snd_hda_codec_write(codec, 0x20, 0, | |
ea1fb29a | 1054 | AC_VERB_SET_COEF_INDEX, 7); |
c9b58006 KY |
1055 | snd_hda_codec_write(codec, 0x20, 0, |
1056 | AC_VERB_SET_PROC_COEF, | |
1057 | tmp | 0x2010); | |
1058 | break; | |
f9423e7a | 1059 | case 0x10ec0888: |
1082c748 | 1060 | /*alc888_coef_init(codec);*/ /* called in alc_init() */ |
f9423e7a | 1061 | break; |
c9b58006 KY |
1062 | case 0x10ec0267: |
1063 | case 0x10ec0268: | |
1064 | snd_hda_codec_write(codec, 0x20, 0, | |
1065 | AC_VERB_SET_COEF_INDEX, 7); | |
1066 | tmp = snd_hda_codec_read(codec, 0x20, 0, | |
1067 | AC_VERB_GET_PROC_COEF, 0); | |
1068 | snd_hda_codec_write(codec, 0x20, 0, | |
ea1fb29a | 1069 | AC_VERB_SET_COEF_INDEX, 7); |
c9b58006 KY |
1070 | snd_hda_codec_write(codec, 0x20, 0, |
1071 | AC_VERB_SET_PROC_COEF, | |
1072 | tmp | 0x3000); | |
1073 | break; | |
bc9f98a9 | 1074 | } |
c9b58006 | 1075 | default: |
bc9f98a9 KY |
1076 | break; |
1077 | } | |
ea1fb29a | 1078 | |
8c427226 | 1079 | /* is laptop or Desktop and enable the function "Mute internal speaker |
c9b58006 KY |
1080 | * when the external headphone out jack is plugged" |
1081 | */ | |
8c427226 | 1082 | if (!(ass & 0x8000)) |
c9b58006 KY |
1083 | return; |
1084 | /* | |
1085 | * 10~8 : Jack location | |
1086 | * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered | |
1087 | * 14~13: Resvered | |
1088 | * 15 : 1 --> enable the function "Mute internal speaker | |
1089 | * when the external headphone out jack is plugged" | |
1090 | */ | |
1091 | if (!spec->autocfg.speaker_pins[0]) { | |
8c427226 | 1092 | if (spec->autocfg.line_out_pins[0]) |
c9b58006 | 1093 | spec->autocfg.speaker_pins[0] = |
8c427226 | 1094 | spec->autocfg.line_out_pins[0]; |
c9b58006 KY |
1095 | else |
1096 | return; | |
1097 | } | |
1098 | ||
1099 | if (!spec->autocfg.hp_pins[0]) { | |
1100 | tmp = (ass >> 11) & 0x3; /* HP to chassis */ | |
1101 | if (tmp == 0) | |
1102 | spec->autocfg.hp_pins[0] = porta; | |
1103 | else if (tmp == 1) | |
1104 | spec->autocfg.hp_pins[0] = porte; | |
1105 | else if (tmp == 2) | |
1106 | spec->autocfg.hp_pins[0] = portd; | |
1107 | else | |
1108 | return; | |
1109 | } | |
7fb0d78f KY |
1110 | if (spec->autocfg.hp_pins[0]) |
1111 | snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0, | |
1112 | AC_VERB_SET_UNSOLICITED_ENABLE, | |
1113 | AC_USRSP_EN | ALC880_HP_EVENT); | |
c9b58006 | 1114 | |
4605b718 | 1115 | #if 0 /* it's broken in some acses -- temporarily disabled */ |
7fb0d78f KY |
1116 | if (spec->autocfg.input_pins[AUTO_PIN_MIC] && |
1117 | spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]) | |
1118 | snd_hda_codec_write(codec, | |
1119 | spec->autocfg.input_pins[AUTO_PIN_MIC], 0, | |
1120 | AC_VERB_SET_UNSOLICITED_ENABLE, | |
1121 | AC_USRSP_EN | ALC880_MIC_EVENT); | |
4605b718 | 1122 | #endif /* disabled */ |
ea1fb29a | 1123 | |
c9b58006 | 1124 | spec->unsol_event = alc_sku_unsol_event; |
bc9f98a9 KY |
1125 | } |
1126 | ||
f95474ec TI |
1127 | /* |
1128 | * Fix-up pin default configurations | |
1129 | */ | |
1130 | ||
1131 | struct alc_pincfg { | |
1132 | hda_nid_t nid; | |
1133 | u32 val; | |
1134 | }; | |
1135 | ||
1136 | static void alc_fix_pincfg(struct hda_codec *codec, | |
1137 | const struct snd_pci_quirk *quirk, | |
1138 | const struct alc_pincfg **pinfix) | |
1139 | { | |
1140 | const struct alc_pincfg *cfg; | |
1141 | ||
1142 | quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk); | |
1143 | if (!quirk) | |
1144 | return; | |
1145 | ||
1146 | cfg = pinfix[quirk->value]; | |
1147 | for (; cfg->nid; cfg++) { | |
1148 | int i; | |
1149 | u32 val = cfg->val; | |
1150 | for (i = 0; i < 4; i++) { | |
1151 | snd_hda_codec_write(codec, cfg->nid, 0, | |
1152 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i, | |
1153 | val & 0xff); | |
1154 | val >>= 8; | |
1155 | } | |
1156 | } | |
1157 | } | |
1158 | ||
ef8ef5fb VP |
1159 | /* |
1160 | * ALC888 | |
1161 | */ | |
1162 | ||
1163 | /* | |
1164 | * 2ch mode | |
1165 | */ | |
1166 | static struct hda_verb alc888_4ST_ch2_intel_init[] = { | |
1167 | /* Mic-in jack as mic in */ | |
1168 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
1169 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
1170 | /* Line-in jack as Line in */ | |
1171 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
1172 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
1173 | /* Line-Out as Front */ | |
1174 | { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1175 | { } /* end */ | |
1176 | }; | |
1177 | ||
1178 | /* | |
1179 | * 4ch mode | |
1180 | */ | |
1181 | static struct hda_verb alc888_4ST_ch4_intel_init[] = { | |
1182 | /* Mic-in jack as mic in */ | |
1183 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
1184 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
1185 | /* Line-in jack as Surround */ | |
1186 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1187 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1188 | /* Line-Out as Front */ | |
1189 | { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1190 | { } /* end */ | |
1191 | }; | |
1192 | ||
1193 | /* | |
1194 | * 6ch mode | |
1195 | */ | |
1196 | static struct hda_verb alc888_4ST_ch6_intel_init[] = { | |
1197 | /* Mic-in jack as CLFE */ | |
1198 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1199 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1200 | /* Line-in jack as Surround */ | |
1201 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1202 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1203 | /* Line-Out as CLFE (workaround because Mic-in is not loud enough) */ | |
1204 | { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
1205 | { } /* end */ | |
1206 | }; | |
1207 | ||
1208 | /* | |
1209 | * 8ch mode | |
1210 | */ | |
1211 | static struct hda_verb alc888_4ST_ch8_intel_init[] = { | |
1212 | /* Mic-in jack as CLFE */ | |
1213 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1214 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1215 | /* Line-in jack as Surround */ | |
1216 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1217 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1218 | /* Line-Out as Side */ | |
1219 | { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
1220 | { } /* end */ | |
1221 | }; | |
1222 | ||
1223 | static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = { | |
1224 | { 2, alc888_4ST_ch2_intel_init }, | |
1225 | { 4, alc888_4ST_ch4_intel_init }, | |
1226 | { 6, alc888_4ST_ch6_intel_init }, | |
1227 | { 8, alc888_4ST_ch8_intel_init }, | |
1228 | }; | |
1229 | ||
1230 | /* | |
1231 | * ALC888 Fujitsu Siemens Amillo xa3530 | |
1232 | */ | |
1233 | ||
1234 | static struct hda_verb alc888_fujitsu_xa3530_verbs[] = { | |
1235 | /* Front Mic: set to PIN_IN (empty by default) */ | |
1236 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1237 | /* Connect Internal HP to Front */ | |
1238 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1239 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1240 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1241 | /* Connect Bass HP to Front */ | |
1242 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1243 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1244 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1245 | /* Connect Line-Out side jack (SPDIF) to Side */ | |
1246 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1247 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1248 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
1249 | /* Connect Mic jack to CLFE */ | |
1250 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1251 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1252 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
1253 | /* Connect Line-in jack to Surround */ | |
1254 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1255 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1256 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
1257 | /* Connect HP out jack to Front */ | |
1258 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1259 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1260 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1261 | /* Enable unsolicited event for HP jack and Line-out jack */ | |
1262 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
1263 | {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
1264 | {} | |
1265 | }; | |
1266 | ||
1267 | static void alc888_fujitsu_xa3530_automute(struct hda_codec *codec) | |
1268 | { | |
1269 | unsigned int present; | |
1270 | unsigned int bits; | |
1271 | /* Line out presence */ | |
1272 | present = snd_hda_codec_read(codec, 0x17, 0, | |
1273 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
1274 | /* HP out presence */ | |
1275 | present = present || snd_hda_codec_read(codec, 0x1b, 0, | |
1276 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
1277 | bits = present ? HDA_AMP_MUTE : 0; | |
1278 | /* Toggle internal speakers muting */ | |
1279 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
1280 | HDA_AMP_MUTE, bits); | |
1281 | /* Toggle internal bass muting */ | |
1282 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
1283 | HDA_AMP_MUTE, bits); | |
1284 | } | |
1285 | ||
1286 | static void alc888_fujitsu_xa3530_unsol_event(struct hda_codec *codec, | |
1287 | unsigned int res) | |
1288 | { | |
1289 | if (res >> 26 == ALC880_HP_EVENT) | |
1290 | alc888_fujitsu_xa3530_automute(codec); | |
1291 | } | |
1292 | ||
1293 | ||
5b2d1eca VP |
1294 | /* |
1295 | * ALC888 Acer Aspire 4930G model | |
1296 | */ | |
1297 | ||
1298 | static struct hda_verb alc888_acer_aspire_4930g_verbs[] = { | |
1299 | /* Front Mic: set to PIN_IN (empty by default) */ | |
1300 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1301 | /* Unselect Front Mic by default in input mixer 3 */ | |
1302 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)}, | |
ef8ef5fb | 1303 | /* Enable unsolicited event for HP jack */ |
5b2d1eca VP |
1304 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
1305 | /* Connect Internal HP to front */ | |
1306 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1307 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1308 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1309 | /* Connect HP out to front */ | |
1310 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1311 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1312 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1313 | { } | |
1314 | }; | |
1315 | ||
ef8ef5fb | 1316 | static struct hda_input_mux alc888_2_capture_sources[2] = { |
5b2d1eca VP |
1317 | /* Front mic only available on one ADC */ |
1318 | { | |
1319 | .num_items = 4, | |
1320 | .items = { | |
1321 | { "Mic", 0x0 }, | |
1322 | { "Line", 0x2 }, | |
1323 | { "CD", 0x4 }, | |
1324 | { "Front Mic", 0xb }, | |
1325 | }, | |
1326 | }, | |
1327 | { | |
1328 | .num_items = 3, | |
1329 | .items = { | |
1330 | { "Mic", 0x0 }, | |
1331 | { "Line", 0x2 }, | |
1332 | { "CD", 0x4 }, | |
1333 | }, | |
1334 | } | |
1335 | }; | |
1336 | ||
ef8ef5fb | 1337 | static struct snd_kcontrol_new alc888_base_mixer[] = { |
5b2d1eca VP |
1338 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
1339 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
1340 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1341 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
1342 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, | |
1343 | HDA_OUTPUT), | |
1344 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
1345 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
1346 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
1347 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
1348 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
1349 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
1350 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1351 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1352 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
1353 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1354 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
1355 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1356 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
1357 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
1358 | { } /* end */ | |
1359 | }; | |
1360 | ||
1361 | static void alc888_acer_aspire_4930g_automute(struct hda_codec *codec) | |
1362 | { | |
1363 | unsigned int present; | |
ef8ef5fb | 1364 | unsigned int bits; |
5b2d1eca VP |
1365 | present = snd_hda_codec_read(codec, 0x15, 0, |
1366 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
ef8ef5fb VP |
1367 | bits = present ? HDA_AMP_MUTE : 0; |
1368 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
1369 | HDA_AMP_MUTE, bits); | |
5b2d1eca VP |
1370 | } |
1371 | ||
1372 | static void alc888_acer_aspire_4930g_unsol_event(struct hda_codec *codec, | |
1373 | unsigned int res) | |
1374 | { | |
1375 | if (res >> 26 == ALC880_HP_EVENT) | |
1376 | alc888_acer_aspire_4930g_automute(codec); | |
1377 | } | |
1378 | ||
1da177e4 | 1379 | /* |
e9edcee0 TI |
1380 | * ALC880 3-stack model |
1381 | * | |
1382 | * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e) | |
9c7f852e TI |
1383 | * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, |
1384 | * F-Mic = 0x1b, HP = 0x19 | |
1da177e4 LT |
1385 | */ |
1386 | ||
e9edcee0 TI |
1387 | static hda_nid_t alc880_dac_nids[4] = { |
1388 | /* front, rear, clfe, rear_surr */ | |
1389 | 0x02, 0x05, 0x04, 0x03 | |
1390 | }; | |
1391 | ||
1392 | static hda_nid_t alc880_adc_nids[3] = { | |
1393 | /* ADC0-2 */ | |
1394 | 0x07, 0x08, 0x09, | |
1395 | }; | |
1396 | ||
1397 | /* The datasheet says the node 0x07 is connected from inputs, | |
1398 | * but it shows zero connection in the real implementation on some devices. | |
df694daa | 1399 | * Note: this is a 915GAV bug, fixed on 915GLV |
1da177e4 | 1400 | */ |
e9edcee0 TI |
1401 | static hda_nid_t alc880_adc_nids_alt[2] = { |
1402 | /* ADC1-2 */ | |
1403 | 0x08, 0x09, | |
1404 | }; | |
1405 | ||
1406 | #define ALC880_DIGOUT_NID 0x06 | |
1407 | #define ALC880_DIGIN_NID 0x0a | |
1408 | ||
1409 | static struct hda_input_mux alc880_capture_source = { | |
1410 | .num_items = 4, | |
1411 | .items = { | |
1412 | { "Mic", 0x0 }, | |
1413 | { "Front Mic", 0x3 }, | |
1414 | { "Line", 0x2 }, | |
1415 | { "CD", 0x4 }, | |
1416 | }, | |
1417 | }; | |
1418 | ||
1419 | /* channel source setting (2/6 channel selection for 3-stack) */ | |
1420 | /* 2ch mode */ | |
1421 | static struct hda_verb alc880_threestack_ch2_init[] = { | |
1422 | /* set line-in to input, mute it */ | |
1423 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
1424 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
1425 | /* set mic-in to input vref 80%, mute it */ | |
1426 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
1427 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
1428 | { } /* end */ | |
1429 | }; | |
1430 | ||
1431 | /* 6ch mode */ | |
1432 | static struct hda_verb alc880_threestack_ch6_init[] = { | |
1433 | /* set line-in to output, unmute it */ | |
1434 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1435 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1436 | /* set mic-in to output, unmute it */ | |
1437 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1438 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1439 | { } /* end */ | |
1440 | }; | |
1441 | ||
d2a6d7dc | 1442 | static struct hda_channel_mode alc880_threestack_modes[2] = { |
e9edcee0 TI |
1443 | { 2, alc880_threestack_ch2_init }, |
1444 | { 6, alc880_threestack_ch6_init }, | |
1445 | }; | |
1446 | ||
c8b6bf9b | 1447 | static struct snd_kcontrol_new alc880_three_stack_mixer[] = { |
05acb863 | 1448 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1449 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
05acb863 | 1450 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 1451 | HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT), |
05acb863 TI |
1452 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1453 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1454 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1455 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
1da177e4 LT |
1456 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1457 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1458 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1459 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
1460 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1461 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1462 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT), | |
1463 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT), | |
1464 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
1465 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
e9edcee0 TI |
1466 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT), |
1467 | { | |
1468 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1469 | .name = "Channel Mode", | |
df694daa KY |
1470 | .info = alc_ch_mode_info, |
1471 | .get = alc_ch_mode_get, | |
1472 | .put = alc_ch_mode_put, | |
e9edcee0 TI |
1473 | }, |
1474 | { } /* end */ | |
1475 | }; | |
1476 | ||
1477 | /* capture mixer elements */ | |
f9e336f6 TI |
1478 | static int alc_cap_vol_info(struct snd_kcontrol *kcontrol, |
1479 | struct snd_ctl_elem_info *uinfo) | |
1480 | { | |
1481 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
1482 | struct alc_spec *spec = codec->spec; | |
1483 | int err; | |
1da177e4 | 1484 | |
f9e336f6 TI |
1485 | mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */ |
1486 | kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, | |
1487 | HDA_INPUT); | |
1488 | err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo); | |
1489 | mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */ | |
1490 | return err; | |
1491 | } | |
1492 | ||
1493 | static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag, | |
1494 | unsigned int size, unsigned int __user *tlv) | |
1495 | { | |
1496 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
1497 | struct alc_spec *spec = codec->spec; | |
1498 | int err; | |
1da177e4 | 1499 | |
f9e336f6 TI |
1500 | mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */ |
1501 | kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, | |
1502 | HDA_INPUT); | |
1503 | err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv); | |
1504 | mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */ | |
1505 | return err; | |
1506 | } | |
1507 | ||
1508 | typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol, | |
1509 | struct snd_ctl_elem_value *ucontrol); | |
1510 | ||
1511 | static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol, | |
1512 | struct snd_ctl_elem_value *ucontrol, | |
1513 | getput_call_t func) | |
1514 | { | |
1515 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
1516 | struct alc_spec *spec = codec->spec; | |
1517 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
1518 | int err; | |
1519 | ||
1520 | mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */ | |
1521 | kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx], | |
1522 | 3, 0, HDA_INPUT); | |
1523 | err = func(kcontrol, ucontrol); | |
1524 | mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */ | |
1525 | return err; | |
1526 | } | |
1527 | ||
1528 | static int alc_cap_vol_get(struct snd_kcontrol *kcontrol, | |
1529 | struct snd_ctl_elem_value *ucontrol) | |
1530 | { | |
1531 | return alc_cap_getput_caller(kcontrol, ucontrol, | |
1532 | snd_hda_mixer_amp_volume_get); | |
1533 | } | |
1534 | ||
1535 | static int alc_cap_vol_put(struct snd_kcontrol *kcontrol, | |
1536 | struct snd_ctl_elem_value *ucontrol) | |
1537 | { | |
1538 | return alc_cap_getput_caller(kcontrol, ucontrol, | |
1539 | snd_hda_mixer_amp_volume_put); | |
1540 | } | |
1541 | ||
1542 | /* capture mixer elements */ | |
1543 | #define alc_cap_sw_info snd_ctl_boolean_stereo_info | |
1544 | ||
1545 | static int alc_cap_sw_get(struct snd_kcontrol *kcontrol, | |
1546 | struct snd_ctl_elem_value *ucontrol) | |
1547 | { | |
1548 | return alc_cap_getput_caller(kcontrol, ucontrol, | |
1549 | snd_hda_mixer_amp_switch_get); | |
1550 | } | |
1551 | ||
1552 | static int alc_cap_sw_put(struct snd_kcontrol *kcontrol, | |
1553 | struct snd_ctl_elem_value *ucontrol) | |
1554 | { | |
1555 | return alc_cap_getput_caller(kcontrol, ucontrol, | |
1556 | snd_hda_mixer_amp_switch_put); | |
1557 | } | |
1558 | ||
1559 | #define DEFINE_CAPMIX(num) \ | |
1560 | static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \ | |
1561 | { \ | |
1562 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
1563 | .name = "Capture Switch", \ | |
1564 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ | |
1565 | .count = num, \ | |
1566 | .info = alc_cap_sw_info, \ | |
1567 | .get = alc_cap_sw_get, \ | |
1568 | .put = alc_cap_sw_put, \ | |
1569 | }, \ | |
1570 | { \ | |
1571 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
1572 | .name = "Capture Volume", \ | |
1573 | .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \ | |
1574 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ | |
1575 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \ | |
1576 | .count = num, \ | |
1577 | .info = alc_cap_vol_info, \ | |
1578 | .get = alc_cap_vol_get, \ | |
1579 | .put = alc_cap_vol_put, \ | |
1580 | .tlv = { .c = alc_cap_vol_tlv }, \ | |
1581 | }, \ | |
3c3e9892 TI |
1582 | { \ |
1583 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
1584 | /* .name = "Capture Source", */ \ | |
1585 | .name = "Input Source", \ | |
1586 | .count = num, \ | |
1587 | .info = alc_mux_enum_info, \ | |
1588 | .get = alc_mux_enum_get, \ | |
1589 | .put = alc_mux_enum_put, \ | |
1590 | }, \ | |
f9e336f6 TI |
1591 | { } /* end */ \ |
1592 | } | |
1593 | ||
1594 | /* up to three ADCs */ | |
1595 | DEFINE_CAPMIX(1); | |
1596 | DEFINE_CAPMIX(2); | |
1597 | DEFINE_CAPMIX(3); | |
e9edcee0 TI |
1598 | |
1599 | ||
1600 | /* | |
1601 | * ALC880 5-stack model | |
1602 | * | |
9c7f852e TI |
1603 | * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), |
1604 | * Side = 0x02 (0xd) | |
e9edcee0 TI |
1605 | * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16 |
1606 | * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19 | |
1607 | */ | |
1608 | ||
1609 | /* additional mixers to alc880_three_stack_mixer */ | |
c8b6bf9b | 1610 | static struct snd_kcontrol_new alc880_five_stack_mixer[] = { |
e9edcee0 | 1611 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1612 | HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT), |
1da177e4 LT |
1613 | { } /* end */ |
1614 | }; | |
1615 | ||
e9edcee0 TI |
1616 | /* channel source setting (6/8 channel selection for 5-stack) */ |
1617 | /* 6ch mode */ | |
1618 | static struct hda_verb alc880_fivestack_ch6_init[] = { | |
1619 | /* set line-in to input, mute it */ | |
1620 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
1621 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
dfc0ff62 TI |
1622 | { } /* end */ |
1623 | }; | |
1624 | ||
e9edcee0 TI |
1625 | /* 8ch mode */ |
1626 | static struct hda_verb alc880_fivestack_ch8_init[] = { | |
1627 | /* set line-in to output, unmute it */ | |
1628 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1629 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1630 | { } /* end */ | |
1631 | }; | |
1632 | ||
d2a6d7dc | 1633 | static struct hda_channel_mode alc880_fivestack_modes[2] = { |
e9edcee0 TI |
1634 | { 6, alc880_fivestack_ch6_init }, |
1635 | { 8, alc880_fivestack_ch8_init }, | |
1636 | }; | |
1637 | ||
1638 | ||
1639 | /* | |
1640 | * ALC880 6-stack model | |
1641 | * | |
9c7f852e TI |
1642 | * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), |
1643 | * Side = 0x05 (0x0f) | |
e9edcee0 TI |
1644 | * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17, |
1645 | * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b | |
1646 | */ | |
1647 | ||
1648 | static hda_nid_t alc880_6st_dac_nids[4] = { | |
1649 | /* front, rear, clfe, rear_surr */ | |
1650 | 0x02, 0x03, 0x04, 0x05 | |
f12ab1e0 | 1651 | }; |
e9edcee0 TI |
1652 | |
1653 | static struct hda_input_mux alc880_6stack_capture_source = { | |
1654 | .num_items = 4, | |
1655 | .items = { | |
1656 | { "Mic", 0x0 }, | |
1657 | { "Front Mic", 0x1 }, | |
1658 | { "Line", 0x2 }, | |
1659 | { "CD", 0x4 }, | |
1660 | }, | |
1661 | }; | |
1662 | ||
1663 | /* fixed 8-channels */ | |
d2a6d7dc | 1664 | static struct hda_channel_mode alc880_sixstack_modes[1] = { |
e9edcee0 TI |
1665 | { 8, NULL }, |
1666 | }; | |
1667 | ||
c8b6bf9b | 1668 | static struct snd_kcontrol_new alc880_six_stack_mixer[] = { |
16ded525 | 1669 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1670 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 1671 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1672 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1673 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1674 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1675 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1676 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
16ded525 | 1677 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 1678 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
16ded525 TI |
1679 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1680 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1681 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1682 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
1683 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1684 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1685 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1686 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1687 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
1688 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
16ded525 TI |
1689 | { |
1690 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1691 | .name = "Channel Mode", | |
df694daa KY |
1692 | .info = alc_ch_mode_info, |
1693 | .get = alc_ch_mode_get, | |
1694 | .put = alc_ch_mode_put, | |
16ded525 TI |
1695 | }, |
1696 | { } /* end */ | |
1697 | }; | |
1698 | ||
e9edcee0 TI |
1699 | |
1700 | /* | |
1701 | * ALC880 W810 model | |
1702 | * | |
1703 | * W810 has rear IO for: | |
1704 | * Front (DAC 02) | |
1705 | * Surround (DAC 03) | |
1706 | * Center/LFE (DAC 04) | |
1707 | * Digital out (06) | |
1708 | * | |
1709 | * The system also has a pair of internal speakers, and a headphone jack. | |
1710 | * These are both connected to Line2 on the codec, hence to DAC 02. | |
ea1fb29a | 1711 | * |
e9edcee0 TI |
1712 | * There is a variable resistor to control the speaker or headphone |
1713 | * volume. This is a hardware-only device without a software API. | |
1714 | * | |
1715 | * Plugging headphones in will disable the internal speakers. This is | |
1716 | * implemented in hardware, not via the driver using jack sense. In | |
1717 | * a similar fashion, plugging into the rear socket marked "front" will | |
1718 | * disable both the speakers and headphones. | |
1719 | * | |
1720 | * For input, there's a microphone jack, and an "audio in" jack. | |
1721 | * These may not do anything useful with this driver yet, because I | |
1722 | * haven't setup any initialization verbs for these yet... | |
1723 | */ | |
1724 | ||
1725 | static hda_nid_t alc880_w810_dac_nids[3] = { | |
1726 | /* front, rear/surround, clfe */ | |
1727 | 0x02, 0x03, 0x04 | |
16ded525 TI |
1728 | }; |
1729 | ||
e9edcee0 | 1730 | /* fixed 6 channels */ |
d2a6d7dc | 1731 | static struct hda_channel_mode alc880_w810_modes[1] = { |
e9edcee0 TI |
1732 | { 6, NULL } |
1733 | }; | |
1734 | ||
1735 | /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */ | |
c8b6bf9b | 1736 | static struct snd_kcontrol_new alc880_w810_base_mixer[] = { |
16ded525 | 1737 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1738 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 1739 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1740 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1741 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1742 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1743 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1744 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
e9edcee0 TI |
1745 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
1746 | { } /* end */ | |
1747 | }; | |
1748 | ||
1749 | ||
1750 | /* | |
1751 | * Z710V model | |
1752 | * | |
1753 | * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d) | |
9c7f852e TI |
1754 | * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), |
1755 | * Line = 0x1a | |
e9edcee0 TI |
1756 | */ |
1757 | ||
1758 | static hda_nid_t alc880_z71v_dac_nids[1] = { | |
1759 | 0x02 | |
1760 | }; | |
1761 | #define ALC880_Z71V_HP_DAC 0x03 | |
1762 | ||
1763 | /* fixed 2 channels */ | |
d2a6d7dc | 1764 | static struct hda_channel_mode alc880_2_jack_modes[1] = { |
e9edcee0 TI |
1765 | { 2, NULL } |
1766 | }; | |
1767 | ||
c8b6bf9b | 1768 | static struct snd_kcontrol_new alc880_z71v_mixer[] = { |
e9edcee0 | 1769 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1770 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
e9edcee0 | 1771 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1772 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1773 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1774 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
16ded525 TI |
1775 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
1776 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
16ded525 TI |
1777 | { } /* end */ |
1778 | }; | |
1779 | ||
e9edcee0 | 1780 | |
e9edcee0 TI |
1781 | /* |
1782 | * ALC880 F1734 model | |
1783 | * | |
1784 | * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d) | |
1785 | * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18 | |
1786 | */ | |
1787 | ||
1788 | static hda_nid_t alc880_f1734_dac_nids[1] = { | |
1789 | 0x03 | |
1790 | }; | |
1791 | #define ALC880_F1734_HP_DAC 0x02 | |
1792 | ||
c8b6bf9b | 1793 | static struct snd_kcontrol_new alc880_f1734_mixer[] = { |
e9edcee0 | 1794 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1795 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), |
2134ea4f TI |
1796 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
1797 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
e9edcee0 TI |
1798 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1799 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
937b4160 TI |
1800 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
1801 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
e9edcee0 TI |
1802 | { } /* end */ |
1803 | }; | |
1804 | ||
937b4160 TI |
1805 | static struct hda_input_mux alc880_f1734_capture_source = { |
1806 | .num_items = 2, | |
1807 | .items = { | |
1808 | { "Mic", 0x1 }, | |
1809 | { "CD", 0x4 }, | |
1810 | }, | |
1811 | }; | |
1812 | ||
e9edcee0 | 1813 | |
e9edcee0 TI |
1814 | /* |
1815 | * ALC880 ASUS model | |
1816 | * | |
1817 | * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) | |
1818 | * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, | |
1819 | * Mic = 0x18, Line = 0x1a | |
1820 | */ | |
1821 | ||
1822 | #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */ | |
1823 | #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */ | |
1824 | ||
c8b6bf9b | 1825 | static struct snd_kcontrol_new alc880_asus_mixer[] = { |
16ded525 | 1826 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1827 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 1828 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1829 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1830 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1831 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1832 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1833 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
16ded525 TI |
1834 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1835 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1836 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1837 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
16ded525 TI |
1838 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
1839 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
16ded525 TI |
1840 | { |
1841 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1842 | .name = "Channel Mode", | |
df694daa KY |
1843 | .info = alc_ch_mode_info, |
1844 | .get = alc_ch_mode_get, | |
1845 | .put = alc_ch_mode_put, | |
16ded525 TI |
1846 | }, |
1847 | { } /* end */ | |
1848 | }; | |
e9edcee0 | 1849 | |
e9edcee0 TI |
1850 | /* |
1851 | * ALC880 ASUS W1V model | |
1852 | * | |
1853 | * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) | |
1854 | * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, | |
1855 | * Mic = 0x18, Line = 0x1a, Line2 = 0x1b | |
1856 | */ | |
1857 | ||
1858 | /* additional mixers to alc880_asus_mixer */ | |
c8b6bf9b | 1859 | static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = { |
e9edcee0 TI |
1860 | HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT), |
1861 | HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT), | |
1862 | { } /* end */ | |
1863 | }; | |
1864 | ||
3c10a9d9 | 1865 | /* additional mixers to alc880_asus_mixer */ |
c8b6bf9b | 1866 | static struct snd_kcontrol_new alc880_pcbeep_mixer[] = { |
3c10a9d9 TI |
1867 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), |
1868 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
1869 | { } /* end */ | |
1870 | }; | |
e9edcee0 | 1871 | |
df694daa KY |
1872 | /* TCL S700 */ |
1873 | static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = { | |
1874 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1875 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
1876 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
1877 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT), | |
1878 | HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT), | |
1879 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT), | |
1880 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT), | |
1881 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
1882 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
df694daa KY |
1883 | { } /* end */ |
1884 | }; | |
1885 | ||
ccc656ce KY |
1886 | /* Uniwill */ |
1887 | static struct snd_kcontrol_new alc880_uniwill_mixer[] = { | |
2134ea4f TI |
1888 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
1889 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1890 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1891 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
ccc656ce KY |
1892 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1893 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
1894 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
1895 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
1896 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
1897 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1898 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1899 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, 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("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1903 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1904 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
1905 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
1906 | { | |
1907 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1908 | .name = "Channel Mode", | |
1909 | .info = alc_ch_mode_info, | |
1910 | .get = alc_ch_mode_get, | |
1911 | .put = alc_ch_mode_put, | |
1912 | }, | |
1913 | { } /* end */ | |
1914 | }; | |
1915 | ||
2cf9f0fc TD |
1916 | static struct snd_kcontrol_new alc880_fujitsu_mixer[] = { |
1917 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1918 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1919 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1920 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
1921 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
1922 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1923 | HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1924 | HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1925 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1926 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1927 | { } /* end */ | |
1928 | }; | |
1929 | ||
ccc656ce | 1930 | static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = { |
2134ea4f TI |
1931 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
1932 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1933 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1934 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
ccc656ce KY |
1935 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
1936 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1937 | { } /* end */ | |
1938 | }; | |
1939 | ||
2134ea4f TI |
1940 | /* |
1941 | * virtual master controls | |
1942 | */ | |
1943 | ||
1944 | /* | |
1945 | * slave controls for virtual master | |
1946 | */ | |
1947 | static const char *alc_slave_vols[] = { | |
1948 | "Front Playback Volume", | |
1949 | "Surround Playback Volume", | |
1950 | "Center Playback Volume", | |
1951 | "LFE Playback Volume", | |
1952 | "Side Playback Volume", | |
1953 | "Headphone Playback Volume", | |
1954 | "Speaker Playback Volume", | |
1955 | "Mono Playback Volume", | |
2134ea4f | 1956 | "Line-Out Playback Volume", |
26f5df26 | 1957 | "PCM Playback Volume", |
2134ea4f TI |
1958 | NULL, |
1959 | }; | |
1960 | ||
1961 | static const char *alc_slave_sws[] = { | |
1962 | "Front Playback Switch", | |
1963 | "Surround Playback Switch", | |
1964 | "Center Playback Switch", | |
1965 | "LFE Playback Switch", | |
1966 | "Side Playback Switch", | |
1967 | "Headphone Playback Switch", | |
1968 | "Speaker Playback Switch", | |
1969 | "Mono Playback Switch", | |
edb54a55 | 1970 | "IEC958 Playback Switch", |
2134ea4f TI |
1971 | NULL, |
1972 | }; | |
1973 | ||
1da177e4 | 1974 | /* |
e9edcee0 | 1975 | * build control elements |
1da177e4 | 1976 | */ |
603c4019 TI |
1977 | |
1978 | static void alc_free_kctls(struct hda_codec *codec); | |
1979 | ||
1da177e4 LT |
1980 | static int alc_build_controls(struct hda_codec *codec) |
1981 | { | |
1982 | struct alc_spec *spec = codec->spec; | |
1983 | int err; | |
1984 | int i; | |
1985 | ||
1986 | for (i = 0; i < spec->num_mixers; i++) { | |
1987 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); | |
1988 | if (err < 0) | |
1989 | return err; | |
1990 | } | |
f9e336f6 TI |
1991 | if (spec->cap_mixer) { |
1992 | err = snd_hda_add_new_ctls(codec, spec->cap_mixer); | |
1993 | if (err < 0) | |
1994 | return err; | |
1995 | } | |
1da177e4 | 1996 | if (spec->multiout.dig_out_nid) { |
9c7f852e TI |
1997 | err = snd_hda_create_spdif_out_ctls(codec, |
1998 | spec->multiout.dig_out_nid); | |
1da177e4 LT |
1999 | if (err < 0) |
2000 | return err; | |
9a08160b TI |
2001 | err = snd_hda_create_spdif_share_sw(codec, |
2002 | &spec->multiout); | |
2003 | if (err < 0) | |
2004 | return err; | |
2005 | spec->multiout.share_spdif = 1; | |
1da177e4 LT |
2006 | } |
2007 | if (spec->dig_in_nid) { | |
2008 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); | |
2009 | if (err < 0) | |
2010 | return err; | |
2011 | } | |
2134ea4f TI |
2012 | |
2013 | /* if we have no master control, let's create it */ | |
2014 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { | |
1c82ed1b | 2015 | unsigned int vmaster_tlv[4]; |
2134ea4f | 2016 | snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, |
1c82ed1b | 2017 | HDA_OUTPUT, vmaster_tlv); |
2134ea4f | 2018 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
1c82ed1b | 2019 | vmaster_tlv, alc_slave_vols); |
2134ea4f TI |
2020 | if (err < 0) |
2021 | return err; | |
2022 | } | |
2023 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { | |
2024 | err = snd_hda_add_vmaster(codec, "Master Playback Switch", | |
2025 | NULL, alc_slave_sws); | |
2026 | if (err < 0) | |
2027 | return err; | |
2028 | } | |
2029 | ||
603c4019 | 2030 | alc_free_kctls(codec); /* no longer needed */ |
1da177e4 LT |
2031 | return 0; |
2032 | } | |
2033 | ||
e9edcee0 | 2034 | |
1da177e4 LT |
2035 | /* |
2036 | * initialize the codec volumes, etc | |
2037 | */ | |
2038 | ||
e9edcee0 TI |
2039 | /* |
2040 | * generic initialization of ADC, input mixers and output mixers | |
2041 | */ | |
2042 | static struct hda_verb alc880_volume_init_verbs[] = { | |
2043 | /* | |
2044 | * Unmute ADC0-2 and set the default input to mic-in | |
2045 | */ | |
71fe7b82 | 2046 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 2047 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
71fe7b82 | 2048 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 2049 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
71fe7b82 | 2050 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 2051 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1da177e4 | 2052 | |
e9edcee0 TI |
2053 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
2054 | * mixer widget | |
9c7f852e TI |
2055 | * Note: PASD motherboards uses the Line In 2 as the input for front |
2056 | * panel mic (mic 2) | |
1da177e4 | 2057 | */ |
e9edcee0 | 2058 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ |
cb53c626 TI |
2059 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
2060 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2061 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
2062 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
2063 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
2064 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
2065 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
1da177e4 | 2066 | |
e9edcee0 TI |
2067 | /* |
2068 | * Set up output mixers (0x0c - 0x0f) | |
1da177e4 | 2069 | */ |
e9edcee0 TI |
2070 | /* set vol=0 to output mixers */ |
2071 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2072 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2073 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2074 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2075 | /* set up input amps for analog loopback */ | |
2076 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
05acb863 TI |
2077 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
2078 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
2079 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
2080 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
2081 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
2082 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
2083 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
2084 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 LT |
2085 | |
2086 | { } | |
2087 | }; | |
2088 | ||
e9edcee0 TI |
2089 | /* |
2090 | * 3-stack pin configuration: | |
2091 | * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b | |
2092 | */ | |
2093 | static struct hda_verb alc880_pin_3stack_init_verbs[] = { | |
2094 | /* | |
2095 | * preset connection lists of input pins | |
2096 | * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround | |
2097 | */ | |
2098 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
2099 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
2100 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */ | |
2101 | ||
2102 | /* | |
2103 | * Set pin mode and muting | |
2104 | */ | |
2105 | /* set front pin widgets 0x14 for output */ | |
05acb863 | 2106 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
2107 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
2108 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
2109 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2110 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2111 | /* Mic2 (as headphone out) for HP output */ | |
2112 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2113 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1da177e4 | 2114 | /* Line In pin widget for input */ |
05acb863 | 2115 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 TI |
2116 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
2117 | /* Line2 (as front mic) pin widget for input and vref at 80% */ | |
2118 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2119 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1da177e4 | 2120 | /* CD pin widget for input */ |
05acb863 | 2121 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 2122 | |
e9edcee0 TI |
2123 | { } |
2124 | }; | |
1da177e4 | 2125 | |
e9edcee0 TI |
2126 | /* |
2127 | * 5-stack pin configuration: | |
2128 | * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19, | |
2129 | * line-in/side = 0x1a, f-mic = 0x1b | |
2130 | */ | |
2131 | static struct hda_verb alc880_pin_5stack_init_verbs[] = { | |
2132 | /* | |
2133 | * preset connection lists of input pins | |
2134 | * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround | |
1da177e4 | 2135 | */ |
e9edcee0 TI |
2136 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
2137 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */ | |
1da177e4 | 2138 | |
e9edcee0 TI |
2139 | /* |
2140 | * Set pin mode and muting | |
1da177e4 | 2141 | */ |
e9edcee0 TI |
2142 | /* set pin widgets 0x14-0x17 for output */ |
2143 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2144 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2145 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2146 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2147 | /* unmute pins for output (no gain on this amp) */ | |
2148 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2149 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2150 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2151 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2152 | ||
2153 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
2154 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2155 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2156 | /* Mic2 (as headphone out) for HP output */ | |
2157 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2158 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2159 | /* Line In pin widget for input */ | |
2160 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2161 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2162 | /* Line2 (as front mic) pin widget for input and vref at 80% */ | |
2163 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2164 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2165 | /* CD pin widget for input */ | |
2166 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1da177e4 LT |
2167 | |
2168 | { } | |
2169 | }; | |
2170 | ||
e9edcee0 TI |
2171 | /* |
2172 | * W810 pin configuration: | |
2173 | * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b | |
2174 | */ | |
2175 | static struct hda_verb alc880_pin_w810_init_verbs[] = { | |
2176 | /* hphone/speaker input selector: front DAC */ | |
2177 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
1da177e4 | 2178 | |
05acb863 | 2179 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2180 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 2181 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2182 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 2183 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2184 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 2185 | |
e9edcee0 | 2186 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
05acb863 | 2187 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
1da177e4 | 2188 | |
1da177e4 LT |
2189 | { } |
2190 | }; | |
2191 | ||
e9edcee0 TI |
2192 | /* |
2193 | * Z71V pin configuration: | |
2194 | * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?) | |
2195 | */ | |
2196 | static struct hda_verb alc880_pin_z71v_init_verbs[] = { | |
05acb863 | 2197 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2198 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 2199 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
e9edcee0 | 2200 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
dfc0ff62 | 2201 | |
16ded525 | 2202 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 2203 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
16ded525 | 2204 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 2205 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
16ded525 TI |
2206 | |
2207 | { } | |
2208 | }; | |
2209 | ||
e9edcee0 TI |
2210 | /* |
2211 | * 6-stack pin configuration: | |
9c7f852e TI |
2212 | * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, |
2213 | * f-mic = 0x19, line = 0x1a, HP = 0x1b | |
e9edcee0 TI |
2214 | */ |
2215 | static struct hda_verb alc880_pin_6stack_init_verbs[] = { | |
2216 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
2217 | ||
16ded525 | 2218 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2219 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2220 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2221 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2222 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2223 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2224 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
2225 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
2226 | ||
16ded525 | 2227 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 2228 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 2229 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 2230 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 2231 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 | 2232 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 2233 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
e9edcee0 | 2234 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2235 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
ea1fb29a | 2236 | |
e9edcee0 TI |
2237 | { } |
2238 | }; | |
2239 | ||
ccc656ce KY |
2240 | /* |
2241 | * Uniwill pin configuration: | |
2242 | * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19, | |
2243 | * line = 0x1a | |
2244 | */ | |
2245 | static struct hda_verb alc880_uniwill_init_verbs[] = { | |
2246 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
2247 | ||
2248 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2249 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2250 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2251 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2252 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2253 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2254 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2255 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2256 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
2257 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
2258 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
2259 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
2260 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
2261 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
2262 | ||
2263 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2264 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2265 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2266 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2267 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2268 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2269 | /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */ | |
2270 | /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */ | |
2271 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2272 | ||
2273 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
2274 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
2275 | ||
2276 | { } | |
2277 | }; | |
2278 | ||
2279 | /* | |
2280 | * Uniwill P53 | |
ea1fb29a | 2281 | * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19, |
ccc656ce KY |
2282 | */ |
2283 | static struct hda_verb alc880_uniwill_p53_init_verbs[] = { | |
2284 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
2285 | ||
2286 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2287 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2288 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2289 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2290 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2291 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2292 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
2293 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
2294 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
2295 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
2296 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
2297 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
2298 | ||
2299 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2300 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2301 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2302 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2303 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2304 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2305 | ||
2306 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
2307 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT}, | |
2308 | ||
2309 | { } | |
2310 | }; | |
2311 | ||
2cf9f0fc TD |
2312 | static struct hda_verb alc880_beep_init_verbs[] = { |
2313 | { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) }, | |
2314 | { } | |
2315 | }; | |
2316 | ||
ccc656ce | 2317 | /* toggle speaker-output according to the hp-jack state */ |
458a4fab | 2318 | static void alc880_uniwill_hp_automute(struct hda_codec *codec) |
ccc656ce KY |
2319 | { |
2320 | unsigned int present; | |
f12ab1e0 | 2321 | unsigned char bits; |
ccc656ce KY |
2322 | |
2323 | present = snd_hda_codec_read(codec, 0x14, 0, | |
2324 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
2325 | bits = present ? HDA_AMP_MUTE : 0; |
2326 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
2327 | HDA_AMP_MUTE, bits); | |
2328 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
2329 | HDA_AMP_MUTE, bits); | |
458a4fab TI |
2330 | } |
2331 | ||
2332 | /* auto-toggle front mic */ | |
2333 | static void alc880_uniwill_mic_automute(struct hda_codec *codec) | |
2334 | { | |
2335 | unsigned int present; | |
2336 | unsigned char bits; | |
ccc656ce KY |
2337 | |
2338 | present = snd_hda_codec_read(codec, 0x18, 0, | |
2339 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
2340 | bits = present ? HDA_AMP_MUTE : 0; |
2341 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); | |
458a4fab TI |
2342 | } |
2343 | ||
2344 | static void alc880_uniwill_automute(struct hda_codec *codec) | |
2345 | { | |
2346 | alc880_uniwill_hp_automute(codec); | |
2347 | alc880_uniwill_mic_automute(codec); | |
ccc656ce KY |
2348 | } |
2349 | ||
2350 | static void alc880_uniwill_unsol_event(struct hda_codec *codec, | |
2351 | unsigned int res) | |
2352 | { | |
2353 | /* Looks like the unsol event is incompatible with the standard | |
2354 | * definition. 4bit tag is placed at 28 bit! | |
2355 | */ | |
458a4fab TI |
2356 | switch (res >> 28) { |
2357 | case ALC880_HP_EVENT: | |
2358 | alc880_uniwill_hp_automute(codec); | |
2359 | break; | |
2360 | case ALC880_MIC_EVENT: | |
2361 | alc880_uniwill_mic_automute(codec); | |
2362 | break; | |
2363 | } | |
ccc656ce KY |
2364 | } |
2365 | ||
2366 | static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec) | |
2367 | { | |
2368 | unsigned int present; | |
f12ab1e0 | 2369 | unsigned char bits; |
ccc656ce KY |
2370 | |
2371 | present = snd_hda_codec_read(codec, 0x14, 0, | |
2372 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a | 2373 | bits = present ? HDA_AMP_MUTE : 0; |
64654c2f | 2374 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits); |
ccc656ce KY |
2375 | } |
2376 | ||
2377 | static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) | |
2378 | { | |
2379 | unsigned int present; | |
ea1fb29a | 2380 | |
ccc656ce | 2381 | present = snd_hda_codec_read(codec, 0x21, 0, |
47fd830a TI |
2382 | AC_VERB_GET_VOLUME_KNOB_CONTROL, 0); |
2383 | present &= HDA_AMP_VOLMASK; | |
2384 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, | |
2385 | HDA_AMP_VOLMASK, present); | |
2386 | snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0, | |
2387 | HDA_AMP_VOLMASK, present); | |
ccc656ce | 2388 | } |
47fd830a | 2389 | |
ccc656ce KY |
2390 | static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec, |
2391 | unsigned int res) | |
2392 | { | |
2393 | /* Looks like the unsol event is incompatible with the standard | |
2394 | * definition. 4bit tag is placed at 28 bit! | |
2395 | */ | |
2396 | if ((res >> 28) == ALC880_HP_EVENT) | |
2397 | alc880_uniwill_p53_hp_automute(codec); | |
f12ab1e0 | 2398 | if ((res >> 28) == ALC880_DCVOL_EVENT) |
ccc656ce KY |
2399 | alc880_uniwill_p53_dcvol_automute(codec); |
2400 | } | |
2401 | ||
e9edcee0 TI |
2402 | /* |
2403 | * F1734 pin configuration: | |
2404 | * HP = 0x14, speaker-out = 0x15, mic = 0x18 | |
2405 | */ | |
2406 | static struct hda_verb alc880_pin_f1734_init_verbs[] = { | |
ee7a9c7c | 2407 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x01}, |
16ded525 TI |
2408 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, |
2409 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
2410 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
2411 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
2412 | ||
e9edcee0 | 2413 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
16ded525 | 2414 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
e9edcee0 | 2415 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
16ded525 | 2416 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2417 | |
e9edcee0 TI |
2418 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
2419 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
ee7a9c7c | 2420 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, |
e9edcee0 | 2421 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 2422 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2423 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2424 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2425 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2426 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
dfc0ff62 | 2427 | |
937b4160 TI |
2428 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT}, |
2429 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT}, | |
2430 | ||
dfc0ff62 TI |
2431 | { } |
2432 | }; | |
2433 | ||
e9edcee0 TI |
2434 | /* |
2435 | * ASUS pin configuration: | |
2436 | * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a | |
2437 | */ | |
2438 | static struct hda_verb alc880_pin_asus_init_verbs[] = { | |
16ded525 TI |
2439 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, |
2440 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
2441 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
2442 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
2443 | ||
2444 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
e9edcee0 | 2445 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2446 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2447 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2448 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2449 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2450 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
2451 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
2452 | ||
2453 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2454 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2455 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2456 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2457 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2458 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
16ded525 | 2459 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2460 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2461 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
ea1fb29a | 2462 | |
e9edcee0 TI |
2463 | { } |
2464 | }; | |
16ded525 | 2465 | |
e9edcee0 | 2466 | /* Enable GPIO mask and set output */ |
bc9f98a9 KY |
2467 | #define alc880_gpio1_init_verbs alc_gpio1_init_verbs |
2468 | #define alc880_gpio2_init_verbs alc_gpio2_init_verbs | |
df694daa KY |
2469 | |
2470 | /* Clevo m520g init */ | |
2471 | static struct hda_verb alc880_pin_clevo_init_verbs[] = { | |
2472 | /* headphone output */ | |
2473 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
2474 | /* line-out */ | |
2475 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2476 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2477 | /* Line-in */ | |
2478 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2479 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2480 | /* CD */ | |
2481 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2482 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2483 | /* Mic1 (rear panel) */ | |
2484 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2485 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2486 | /* Mic2 (front panel) */ | |
2487 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2488 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2489 | /* headphone */ | |
2490 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2491 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2492 | /* change to EAPD mode */ | |
2493 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
2494 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, | |
2495 | ||
2496 | { } | |
16ded525 TI |
2497 | }; |
2498 | ||
df694daa | 2499 | static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = { |
4b146cb0 TI |
2500 | /* change to EAPD mode */ |
2501 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
2502 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, | |
2503 | ||
df694daa KY |
2504 | /* Headphone output */ |
2505 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2506 | /* Front output*/ | |
2507 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2508 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
2509 | ||
2510 | /* Line In pin widget for input */ | |
2511 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2512 | /* CD pin widget for input */ | |
2513 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2514 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
2515 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2516 | ||
2517 | /* change to EAPD mode */ | |
2518 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
2519 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
2520 | ||
2521 | { } | |
2522 | }; | |
16ded525 | 2523 | |
e9edcee0 | 2524 | /* |
ae6b813a TI |
2525 | * LG m1 express dual |
2526 | * | |
2527 | * Pin assignment: | |
2528 | * Rear Line-In/Out (blue): 0x14 | |
2529 | * Build-in Mic-In: 0x15 | |
2530 | * Speaker-out: 0x17 | |
2531 | * HP-Out (green): 0x1b | |
2532 | * Mic-In/Out (red): 0x19 | |
2533 | * SPDIF-Out: 0x1e | |
2534 | */ | |
2535 | ||
2536 | /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */ | |
2537 | static hda_nid_t alc880_lg_dac_nids[3] = { | |
2538 | 0x05, 0x02, 0x03 | |
2539 | }; | |
2540 | ||
2541 | /* seems analog CD is not working */ | |
2542 | static struct hda_input_mux alc880_lg_capture_source = { | |
2543 | .num_items = 3, | |
2544 | .items = { | |
2545 | { "Mic", 0x1 }, | |
2546 | { "Line", 0x5 }, | |
2547 | { "Internal Mic", 0x6 }, | |
2548 | }, | |
2549 | }; | |
2550 | ||
2551 | /* 2,4,6 channel modes */ | |
2552 | static struct hda_verb alc880_lg_ch2_init[] = { | |
2553 | /* set line-in and mic-in to input */ | |
2554 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
2555 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
2556 | { } | |
2557 | }; | |
2558 | ||
2559 | static struct hda_verb alc880_lg_ch4_init[] = { | |
2560 | /* set line-in to out and mic-in to input */ | |
2561 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
2562 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
2563 | { } | |
2564 | }; | |
2565 | ||
2566 | static struct hda_verb alc880_lg_ch6_init[] = { | |
2567 | /* set line-in and mic-in to output */ | |
2568 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
2569 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
2570 | { } | |
2571 | }; | |
2572 | ||
2573 | static struct hda_channel_mode alc880_lg_ch_modes[3] = { | |
2574 | { 2, alc880_lg_ch2_init }, | |
2575 | { 4, alc880_lg_ch4_init }, | |
2576 | { 6, alc880_lg_ch6_init }, | |
2577 | }; | |
2578 | ||
2579 | static struct snd_kcontrol_new alc880_lg_mixer[] = { | |
2134ea4f TI |
2580 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
2581 | HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT), | |
ae6b813a TI |
2582 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
2583 | HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT), | |
2584 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), | |
2585 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT), | |
2586 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT), | |
2587 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), | |
2588 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
2589 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
2590 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT), | |
2591 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT), | |
2592 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT), | |
2593 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT), | |
2594 | { | |
2595 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2596 | .name = "Channel Mode", | |
2597 | .info = alc_ch_mode_info, | |
2598 | .get = alc_ch_mode_get, | |
2599 | .put = alc_ch_mode_put, | |
2600 | }, | |
2601 | { } /* end */ | |
2602 | }; | |
2603 | ||
2604 | static struct hda_verb alc880_lg_init_verbs[] = { | |
2605 | /* set capture source to mic-in */ | |
2606 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2607 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2608 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2609 | /* mute all amp mixer inputs */ | |
2610 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)}, | |
cb53c626 TI |
2611 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, |
2612 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
ae6b813a TI |
2613 | /* line-in to input */ |
2614 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2615 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2616 | /* built-in mic */ | |
2617 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2618 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2619 | /* speaker-out */ | |
2620 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2621 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2622 | /* mic-in to input */ | |
2623 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
2624 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2625 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2626 | /* HP-out */ | |
2627 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
2628 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2629 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2630 | /* jack sense */ | |
2631 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, | |
2632 | { } | |
2633 | }; | |
2634 | ||
2635 | /* toggle speaker-output according to the hp-jack state */ | |
2636 | static void alc880_lg_automute(struct hda_codec *codec) | |
2637 | { | |
2638 | unsigned int present; | |
f12ab1e0 | 2639 | unsigned char bits; |
ae6b813a TI |
2640 | |
2641 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
2642 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
2643 | bits = present ? HDA_AMP_MUTE : 0; |
2644 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
2645 | HDA_AMP_MUTE, bits); | |
ae6b813a TI |
2646 | } |
2647 | ||
2648 | static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res) | |
2649 | { | |
2650 | /* Looks like the unsol event is incompatible with the standard | |
2651 | * definition. 4bit tag is placed at 28 bit! | |
2652 | */ | |
2653 | if ((res >> 28) == 0x01) | |
2654 | alc880_lg_automute(codec); | |
2655 | } | |
2656 | ||
d681518a TI |
2657 | /* |
2658 | * LG LW20 | |
2659 | * | |
2660 | * Pin assignment: | |
2661 | * Speaker-out: 0x14 | |
2662 | * Mic-In: 0x18 | |
e4f41da9 CM |
2663 | * Built-in Mic-In: 0x19 |
2664 | * Line-In: 0x1b | |
2665 | * HP-Out: 0x1a | |
d681518a TI |
2666 | * SPDIF-Out: 0x1e |
2667 | */ | |
2668 | ||
d681518a | 2669 | static struct hda_input_mux alc880_lg_lw_capture_source = { |
e4f41da9 | 2670 | .num_items = 3, |
d681518a TI |
2671 | .items = { |
2672 | { "Mic", 0x0 }, | |
2673 | { "Internal Mic", 0x1 }, | |
e4f41da9 | 2674 | { "Line In", 0x2 }, |
d681518a TI |
2675 | }, |
2676 | }; | |
2677 | ||
0a8c5da3 CM |
2678 | #define alc880_lg_lw_modes alc880_threestack_modes |
2679 | ||
d681518a | 2680 | static struct snd_kcontrol_new alc880_lg_lw_mixer[] = { |
0a8c5da3 CM |
2681 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
2682 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
2683 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
2684 | HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT), | |
2685 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
2686 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
2687 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
2688 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
2689 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
2690 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
d681518a TI |
2691 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
2692 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2693 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
2694 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
0a8c5da3 CM |
2695 | { |
2696 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2697 | .name = "Channel Mode", | |
2698 | .info = alc_ch_mode_info, | |
2699 | .get = alc_ch_mode_get, | |
2700 | .put = alc_ch_mode_put, | |
2701 | }, | |
d681518a TI |
2702 | { } /* end */ |
2703 | }; | |
2704 | ||
2705 | static struct hda_verb alc880_lg_lw_init_verbs[] = { | |
0a8c5da3 CM |
2706 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
2707 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
2708 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */ | |
2709 | ||
d681518a TI |
2710 | /* set capture source to mic-in */ |
2711 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2712 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2713 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
cb53c626 | 2714 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, |
d681518a TI |
2715 | /* speaker-out */ |
2716 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2717 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2718 | /* HP-out */ | |
d681518a TI |
2719 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
2720 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2721 | /* mic-in to input */ | |
2722 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2723 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2724 | /* built-in mic */ | |
2725 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2726 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2727 | /* jack sense */ | |
2728 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, | |
2729 | { } | |
2730 | }; | |
2731 | ||
2732 | /* toggle speaker-output according to the hp-jack state */ | |
2733 | static void alc880_lg_lw_automute(struct hda_codec *codec) | |
2734 | { | |
2735 | unsigned int present; | |
f12ab1e0 | 2736 | unsigned char bits; |
d681518a TI |
2737 | |
2738 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
2739 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
2740 | bits = present ? HDA_AMP_MUTE : 0; |
2741 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
2742 | HDA_AMP_MUTE, bits); | |
d681518a TI |
2743 | } |
2744 | ||
2745 | static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res) | |
2746 | { | |
2747 | /* Looks like the unsol event is incompatible with the standard | |
2748 | * definition. 4bit tag is placed at 28 bit! | |
2749 | */ | |
2750 | if ((res >> 28) == 0x01) | |
2751 | alc880_lg_lw_automute(codec); | |
2752 | } | |
2753 | ||
df99cd33 TI |
2754 | static struct snd_kcontrol_new alc880_medion_rim_mixer[] = { |
2755 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
2756 | HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT), | |
2757 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
2758 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2759 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
2760 | HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
2761 | { } /* end */ | |
2762 | }; | |
2763 | ||
2764 | static struct hda_input_mux alc880_medion_rim_capture_source = { | |
2765 | .num_items = 2, | |
2766 | .items = { | |
2767 | { "Mic", 0x0 }, | |
2768 | { "Internal Mic", 0x1 }, | |
2769 | }, | |
2770 | }; | |
2771 | ||
2772 | static struct hda_verb alc880_medion_rim_init_verbs[] = { | |
2773 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
2774 | ||
2775 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2776 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2777 | ||
2778 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
2779 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2780 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2781 | /* Mic2 (as headphone out) for HP output */ | |
2782 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2783 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2784 | /* Internal Speaker */ | |
2785 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2786 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2787 | ||
2788 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
2789 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, | |
2790 | ||
2791 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
2792 | { } | |
2793 | }; | |
2794 | ||
2795 | /* toggle speaker-output according to the hp-jack state */ | |
2796 | static void alc880_medion_rim_automute(struct hda_codec *codec) | |
2797 | { | |
2798 | unsigned int present; | |
2799 | unsigned char bits; | |
2800 | ||
2801 | present = snd_hda_codec_read(codec, 0x14, 0, | |
2802 | AC_VERB_GET_PIN_SENSE, 0) | |
2803 | & AC_PINSENSE_PRESENCE; | |
2804 | bits = present ? HDA_AMP_MUTE : 0; | |
2805 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
2806 | HDA_AMP_MUTE, bits); | |
2807 | if (present) | |
2808 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0); | |
2809 | else | |
2810 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2); | |
2811 | } | |
2812 | ||
2813 | static void alc880_medion_rim_unsol_event(struct hda_codec *codec, | |
2814 | unsigned int res) | |
2815 | { | |
2816 | /* Looks like the unsol event is incompatible with the standard | |
2817 | * definition. 4bit tag is placed at 28 bit! | |
2818 | */ | |
2819 | if ((res >> 28) == ALC880_HP_EVENT) | |
2820 | alc880_medion_rim_automute(codec); | |
2821 | } | |
2822 | ||
cb53c626 TI |
2823 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
2824 | static struct hda_amp_list alc880_loopbacks[] = { | |
2825 | { 0x0b, HDA_INPUT, 0 }, | |
2826 | { 0x0b, HDA_INPUT, 1 }, | |
2827 | { 0x0b, HDA_INPUT, 2 }, | |
2828 | { 0x0b, HDA_INPUT, 3 }, | |
2829 | { 0x0b, HDA_INPUT, 4 }, | |
2830 | { } /* end */ | |
2831 | }; | |
2832 | ||
2833 | static struct hda_amp_list alc880_lg_loopbacks[] = { | |
2834 | { 0x0b, HDA_INPUT, 1 }, | |
2835 | { 0x0b, HDA_INPUT, 6 }, | |
2836 | { 0x0b, HDA_INPUT, 7 }, | |
2837 | { } /* end */ | |
2838 | }; | |
2839 | #endif | |
2840 | ||
ae6b813a TI |
2841 | /* |
2842 | * Common callbacks | |
e9edcee0 TI |
2843 | */ |
2844 | ||
1da177e4 LT |
2845 | static int alc_init(struct hda_codec *codec) |
2846 | { | |
2847 | struct alc_spec *spec = codec->spec; | |
e9edcee0 TI |
2848 | unsigned int i; |
2849 | ||
2c3bf9ab | 2850 | alc_fix_pll(codec); |
1082c748 TI |
2851 | if (codec->vendor_id == 0x10ec0888) |
2852 | alc888_coef_init(codec); | |
2c3bf9ab | 2853 | |
e9edcee0 TI |
2854 | for (i = 0; i < spec->num_init_verbs; i++) |
2855 | snd_hda_sequence_write(codec, spec->init_verbs[i]); | |
ae6b813a TI |
2856 | |
2857 | if (spec->init_hook) | |
2858 | spec->init_hook(codec); | |
2859 | ||
1da177e4 LT |
2860 | return 0; |
2861 | } | |
2862 | ||
ae6b813a TI |
2863 | static void alc_unsol_event(struct hda_codec *codec, unsigned int res) |
2864 | { | |
2865 | struct alc_spec *spec = codec->spec; | |
2866 | ||
2867 | if (spec->unsol_event) | |
2868 | spec->unsol_event(codec, res); | |
2869 | } | |
2870 | ||
cb53c626 TI |
2871 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
2872 | static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid) | |
2873 | { | |
2874 | struct alc_spec *spec = codec->spec; | |
2875 | return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); | |
2876 | } | |
2877 | #endif | |
2878 | ||
1da177e4 LT |
2879 | /* |
2880 | * Analog playback callbacks | |
2881 | */ | |
2882 | static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo, | |
2883 | struct hda_codec *codec, | |
c8b6bf9b | 2884 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2885 | { |
2886 | struct alc_spec *spec = codec->spec; | |
9a08160b TI |
2887 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
2888 | hinfo); | |
1da177e4 LT |
2889 | } |
2890 | ||
2891 | static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | |
2892 | struct hda_codec *codec, | |
2893 | unsigned int stream_tag, | |
2894 | unsigned int format, | |
c8b6bf9b | 2895 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2896 | { |
2897 | struct alc_spec *spec = codec->spec; | |
9c7f852e TI |
2898 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, |
2899 | stream_tag, format, substream); | |
1da177e4 LT |
2900 | } |
2901 | ||
2902 | static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, | |
2903 | struct hda_codec *codec, | |
c8b6bf9b | 2904 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2905 | { |
2906 | struct alc_spec *spec = codec->spec; | |
2907 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); | |
2908 | } | |
2909 | ||
2910 | /* | |
2911 | * Digital out | |
2912 | */ | |
2913 | static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, | |
2914 | struct hda_codec *codec, | |
c8b6bf9b | 2915 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2916 | { |
2917 | struct alc_spec *spec = codec->spec; | |
2918 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); | |
2919 | } | |
2920 | ||
6b97eb45 TI |
2921 | static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
2922 | struct hda_codec *codec, | |
2923 | unsigned int stream_tag, | |
2924 | unsigned int format, | |
2925 | struct snd_pcm_substream *substream) | |
2926 | { | |
2927 | struct alc_spec *spec = codec->spec; | |
2928 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, | |
2929 | stream_tag, format, substream); | |
2930 | } | |
2931 | ||
1da177e4 LT |
2932 | static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
2933 | struct hda_codec *codec, | |
c8b6bf9b | 2934 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2935 | { |
2936 | struct alc_spec *spec = codec->spec; | |
2937 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); | |
2938 | } | |
2939 | ||
2940 | /* | |
2941 | * Analog capture | |
2942 | */ | |
6330079f | 2943 | static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
1da177e4 LT |
2944 | struct hda_codec *codec, |
2945 | unsigned int stream_tag, | |
2946 | unsigned int format, | |
c8b6bf9b | 2947 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2948 | { |
2949 | struct alc_spec *spec = codec->spec; | |
2950 | ||
6330079f | 2951 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1], |
1da177e4 LT |
2952 | stream_tag, 0, format); |
2953 | return 0; | |
2954 | } | |
2955 | ||
6330079f | 2956 | static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
1da177e4 | 2957 | struct hda_codec *codec, |
c8b6bf9b | 2958 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2959 | { |
2960 | struct alc_spec *spec = codec->spec; | |
2961 | ||
888afa15 TI |
2962 | snd_hda_codec_cleanup_stream(codec, |
2963 | spec->adc_nids[substream->number + 1]); | |
1da177e4 LT |
2964 | return 0; |
2965 | } | |
2966 | ||
2967 | ||
2968 | /* | |
2969 | */ | |
2970 | static struct hda_pcm_stream alc880_pcm_analog_playback = { | |
2971 | .substreams = 1, | |
2972 | .channels_min = 2, | |
2973 | .channels_max = 8, | |
e9edcee0 | 2974 | /* NID is set in alc_build_pcms */ |
1da177e4 LT |
2975 | .ops = { |
2976 | .open = alc880_playback_pcm_open, | |
2977 | .prepare = alc880_playback_pcm_prepare, | |
2978 | .cleanup = alc880_playback_pcm_cleanup | |
2979 | }, | |
2980 | }; | |
2981 | ||
2982 | static struct hda_pcm_stream alc880_pcm_analog_capture = { | |
6330079f TI |
2983 | .substreams = 1, |
2984 | .channels_min = 2, | |
2985 | .channels_max = 2, | |
2986 | /* NID is set in alc_build_pcms */ | |
2987 | }; | |
2988 | ||
2989 | static struct hda_pcm_stream alc880_pcm_analog_alt_playback = { | |
2990 | .substreams = 1, | |
2991 | .channels_min = 2, | |
2992 | .channels_max = 2, | |
2993 | /* NID is set in alc_build_pcms */ | |
2994 | }; | |
2995 | ||
2996 | static struct hda_pcm_stream alc880_pcm_analog_alt_capture = { | |
2997 | .substreams = 2, /* can be overridden */ | |
1da177e4 LT |
2998 | .channels_min = 2, |
2999 | .channels_max = 2, | |
e9edcee0 | 3000 | /* NID is set in alc_build_pcms */ |
1da177e4 | 3001 | .ops = { |
6330079f TI |
3002 | .prepare = alc880_alt_capture_pcm_prepare, |
3003 | .cleanup = alc880_alt_capture_pcm_cleanup | |
1da177e4 LT |
3004 | }, |
3005 | }; | |
3006 | ||
3007 | static struct hda_pcm_stream alc880_pcm_digital_playback = { | |
3008 | .substreams = 1, | |
3009 | .channels_min = 2, | |
3010 | .channels_max = 2, | |
3011 | /* NID is set in alc_build_pcms */ | |
3012 | .ops = { | |
3013 | .open = alc880_dig_playback_pcm_open, | |
6b97eb45 TI |
3014 | .close = alc880_dig_playback_pcm_close, |
3015 | .prepare = alc880_dig_playback_pcm_prepare | |
1da177e4 LT |
3016 | }, |
3017 | }; | |
3018 | ||
3019 | static struct hda_pcm_stream alc880_pcm_digital_capture = { | |
3020 | .substreams = 1, | |
3021 | .channels_min = 2, | |
3022 | .channels_max = 2, | |
3023 | /* NID is set in alc_build_pcms */ | |
3024 | }; | |
3025 | ||
4c5186ed | 3026 | /* Used by alc_build_pcms to flag that a PCM has no playback stream */ |
6330079f | 3027 | static struct hda_pcm_stream alc_pcm_null_stream = { |
4c5186ed JW |
3028 | .substreams = 0, |
3029 | .channels_min = 0, | |
3030 | .channels_max = 0, | |
3031 | }; | |
3032 | ||
1da177e4 LT |
3033 | static int alc_build_pcms(struct hda_codec *codec) |
3034 | { | |
3035 | struct alc_spec *spec = codec->spec; | |
3036 | struct hda_pcm *info = spec->pcm_rec; | |
3037 | int i; | |
3038 | ||
3039 | codec->num_pcms = 1; | |
3040 | codec->pcm_info = info; | |
3041 | ||
3042 | info->name = spec->stream_name_analog; | |
4a471b7d | 3043 | if (spec->stream_analog_playback) { |
da3cec35 TI |
3044 | if (snd_BUG_ON(!spec->multiout.dac_nids)) |
3045 | return -EINVAL; | |
4a471b7d TI |
3046 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback); |
3047 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; | |
3048 | } | |
3049 | if (spec->stream_analog_capture) { | |
da3cec35 TI |
3050 | if (snd_BUG_ON(!spec->adc_nids)) |
3051 | return -EINVAL; | |
4a471b7d TI |
3052 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); |
3053 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; | |
3054 | } | |
3055 | ||
3056 | if (spec->channel_mode) { | |
3057 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; | |
3058 | for (i = 0; i < spec->num_channel_mode; i++) { | |
3059 | if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { | |
3060 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; | |
3061 | } | |
1da177e4 LT |
3062 | } |
3063 | } | |
3064 | ||
e08a007d | 3065 | /* SPDIF for stream index #1 */ |
1da177e4 | 3066 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
e08a007d | 3067 | codec->num_pcms = 2; |
c06134d7 | 3068 | info = spec->pcm_rec + 1; |
1da177e4 | 3069 | info->name = spec->stream_name_digital; |
7ba72ba1 | 3070 | info->pcm_type = HDA_PCM_TYPE_SPDIF; |
4a471b7d TI |
3071 | if (spec->multiout.dig_out_nid && |
3072 | spec->stream_digital_playback) { | |
1da177e4 LT |
3073 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback); |
3074 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; | |
3075 | } | |
4a471b7d TI |
3076 | if (spec->dig_in_nid && |
3077 | spec->stream_digital_capture) { | |
1da177e4 LT |
3078 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture); |
3079 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; | |
3080 | } | |
963f803f TI |
3081 | /* FIXME: do we need this for all Realtek codec models? */ |
3082 | codec->spdif_status_reset = 1; | |
1da177e4 LT |
3083 | } |
3084 | ||
e08a007d TI |
3085 | /* If the use of more than one ADC is requested for the current |
3086 | * model, configure a second analog capture-only PCM. | |
3087 | */ | |
3088 | /* Additional Analaog capture for index #2 */ | |
6330079f TI |
3089 | if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) || |
3090 | (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) { | |
e08a007d | 3091 | codec->num_pcms = 3; |
c06134d7 | 3092 | info = spec->pcm_rec + 2; |
e08a007d | 3093 | info->name = spec->stream_name_analog; |
6330079f TI |
3094 | if (spec->alt_dac_nid) { |
3095 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = | |
3096 | *spec->stream_analog_alt_playback; | |
3097 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = | |
3098 | spec->alt_dac_nid; | |
3099 | } else { | |
3100 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = | |
3101 | alc_pcm_null_stream; | |
3102 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; | |
3103 | } | |
3104 | if (spec->num_adc_nids > 1) { | |
3105 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = | |
3106 | *spec->stream_analog_alt_capture; | |
3107 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = | |
3108 | spec->adc_nids[1]; | |
3109 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = | |
3110 | spec->num_adc_nids - 1; | |
3111 | } else { | |
3112 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = | |
3113 | alc_pcm_null_stream; | |
3114 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0; | |
e08a007d TI |
3115 | } |
3116 | } | |
3117 | ||
1da177e4 LT |
3118 | return 0; |
3119 | } | |
3120 | ||
603c4019 TI |
3121 | static void alc_free_kctls(struct hda_codec *codec) |
3122 | { | |
3123 | struct alc_spec *spec = codec->spec; | |
3124 | ||
3125 | if (spec->kctls.list) { | |
3126 | struct snd_kcontrol_new *kctl = spec->kctls.list; | |
3127 | int i; | |
3128 | for (i = 0; i < spec->kctls.used; i++) | |
3129 | kfree(kctl[i].name); | |
3130 | } | |
3131 | snd_array_free(&spec->kctls); | |
3132 | } | |
3133 | ||
1da177e4 LT |
3134 | static void alc_free(struct hda_codec *codec) |
3135 | { | |
e9edcee0 | 3136 | struct alc_spec *spec = codec->spec; |
e9edcee0 | 3137 | |
f12ab1e0 | 3138 | if (!spec) |
e9edcee0 TI |
3139 | return; |
3140 | ||
603c4019 | 3141 | alc_free_kctls(codec); |
e9edcee0 | 3142 | kfree(spec); |
7943a8ab | 3143 | codec->spec = NULL; /* to be sure */ |
1da177e4 LT |
3144 | } |
3145 | ||
e044c39a TI |
3146 | #ifdef SND_HDA_NEEDS_RESUME |
3147 | static void store_pin_configs(struct hda_codec *codec) | |
3148 | { | |
3149 | struct alc_spec *spec = codec->spec; | |
3150 | hda_nid_t nid, end_nid; | |
3151 | ||
3152 | end_nid = codec->start_nid + codec->num_nodes; | |
3153 | for (nid = codec->start_nid; nid < end_nid; nid++) { | |
3154 | unsigned int wid_caps = get_wcaps(codec, nid); | |
3155 | unsigned int wid_type = | |
3156 | (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
3157 | if (wid_type != AC_WID_PIN) | |
3158 | continue; | |
3159 | if (spec->num_pins >= ARRAY_SIZE(spec->pin_nids)) | |
3160 | break; | |
3161 | spec->pin_nids[spec->num_pins] = nid; | |
3162 | spec->pin_cfgs[spec->num_pins] = | |
3163 | snd_hda_codec_read(codec, nid, 0, | |
3164 | AC_VERB_GET_CONFIG_DEFAULT, 0); | |
3165 | spec->num_pins++; | |
3166 | } | |
3167 | } | |
3168 | ||
3169 | static void resume_pin_configs(struct hda_codec *codec) | |
3170 | { | |
3171 | struct alc_spec *spec = codec->spec; | |
3172 | int i; | |
3173 | ||
3174 | for (i = 0; i < spec->num_pins; i++) { | |
3175 | hda_nid_t pin_nid = spec->pin_nids[i]; | |
3176 | unsigned int pin_config = spec->pin_cfgs[i]; | |
3177 | snd_hda_codec_write(codec, pin_nid, 0, | |
3178 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_0, | |
3179 | pin_config & 0x000000ff); | |
3180 | snd_hda_codec_write(codec, pin_nid, 0, | |
3181 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, | |
3182 | (pin_config & 0x0000ff00) >> 8); | |
3183 | snd_hda_codec_write(codec, pin_nid, 0, | |
3184 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, | |
3185 | (pin_config & 0x00ff0000) >> 16); | |
3186 | snd_hda_codec_write(codec, pin_nid, 0, | |
3187 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, | |
3188 | pin_config >> 24); | |
3189 | } | |
3190 | } | |
3191 | ||
3192 | static int alc_resume(struct hda_codec *codec) | |
3193 | { | |
3194 | resume_pin_configs(codec); | |
3195 | codec->patch_ops.init(codec); | |
3196 | snd_hda_codec_resume_amp(codec); | |
3197 | snd_hda_codec_resume_cache(codec); | |
3198 | return 0; | |
3199 | } | |
3200 | #else | |
3201 | #define store_pin_configs(codec) | |
3202 | #endif | |
3203 | ||
1da177e4 LT |
3204 | /* |
3205 | */ | |
3206 | static struct hda_codec_ops alc_patch_ops = { | |
3207 | .build_controls = alc_build_controls, | |
3208 | .build_pcms = alc_build_pcms, | |
3209 | .init = alc_init, | |
3210 | .free = alc_free, | |
ae6b813a | 3211 | .unsol_event = alc_unsol_event, |
e044c39a TI |
3212 | #ifdef SND_HDA_NEEDS_RESUME |
3213 | .resume = alc_resume, | |
3214 | #endif | |
cb53c626 TI |
3215 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
3216 | .check_power_status = alc_check_power_status, | |
3217 | #endif | |
1da177e4 LT |
3218 | }; |
3219 | ||
2fa522be TI |
3220 | |
3221 | /* | |
3222 | * Test configuration for debugging | |
3223 | * | |
3224 | * Almost all inputs/outputs are enabled. I/O pins can be configured via | |
3225 | * enum controls. | |
3226 | */ | |
3227 | #ifdef CONFIG_SND_DEBUG | |
3228 | static hda_nid_t alc880_test_dac_nids[4] = { | |
3229 | 0x02, 0x03, 0x04, 0x05 | |
3230 | }; | |
3231 | ||
3232 | static struct hda_input_mux alc880_test_capture_source = { | |
ae6b813a | 3233 | .num_items = 7, |
2fa522be TI |
3234 | .items = { |
3235 | { "In-1", 0x0 }, | |
3236 | { "In-2", 0x1 }, | |
3237 | { "In-3", 0x2 }, | |
3238 | { "In-4", 0x3 }, | |
3239 | { "CD", 0x4 }, | |
ae6b813a TI |
3240 | { "Front", 0x5 }, |
3241 | { "Surround", 0x6 }, | |
2fa522be TI |
3242 | }, |
3243 | }; | |
3244 | ||
d2a6d7dc | 3245 | static struct hda_channel_mode alc880_test_modes[4] = { |
2fa522be | 3246 | { 2, NULL }, |
fd2c326d | 3247 | { 4, NULL }, |
2fa522be | 3248 | { 6, NULL }, |
fd2c326d | 3249 | { 8, NULL }, |
2fa522be TI |
3250 | }; |
3251 | ||
9c7f852e TI |
3252 | static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, |
3253 | struct snd_ctl_elem_info *uinfo) | |
2fa522be TI |
3254 | { |
3255 | static char *texts[] = { | |
3256 | "N/A", "Line Out", "HP Out", | |
3257 | "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%" | |
3258 | }; | |
3259 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
3260 | uinfo->count = 1; | |
3261 | uinfo->value.enumerated.items = 8; | |
3262 | if (uinfo->value.enumerated.item >= 8) | |
3263 | uinfo->value.enumerated.item = 7; | |
3264 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | |
3265 | return 0; | |
3266 | } | |
3267 | ||
9c7f852e TI |
3268 | static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, |
3269 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
3270 | { |
3271 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
3272 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
3273 | unsigned int pin_ctl, item = 0; | |
3274 | ||
3275 | pin_ctl = snd_hda_codec_read(codec, nid, 0, | |
3276 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | |
3277 | if (pin_ctl & AC_PINCTL_OUT_EN) { | |
3278 | if (pin_ctl & AC_PINCTL_HP_EN) | |
3279 | item = 2; | |
3280 | else | |
3281 | item = 1; | |
3282 | } else if (pin_ctl & AC_PINCTL_IN_EN) { | |
3283 | switch (pin_ctl & AC_PINCTL_VREFEN) { | |
3284 | case AC_PINCTL_VREF_HIZ: item = 3; break; | |
3285 | case AC_PINCTL_VREF_50: item = 4; break; | |
3286 | case AC_PINCTL_VREF_GRD: item = 5; break; | |
3287 | case AC_PINCTL_VREF_80: item = 6; break; | |
3288 | case AC_PINCTL_VREF_100: item = 7; break; | |
3289 | } | |
3290 | } | |
3291 | ucontrol->value.enumerated.item[0] = item; | |
3292 | return 0; | |
3293 | } | |
3294 | ||
9c7f852e TI |
3295 | static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, |
3296 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
3297 | { |
3298 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
3299 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
3300 | static unsigned int ctls[] = { | |
3301 | 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN, | |
3302 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ, | |
3303 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_50, | |
3304 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD, | |
3305 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_80, | |
3306 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_100, | |
3307 | }; | |
3308 | unsigned int old_ctl, new_ctl; | |
3309 | ||
3310 | old_ctl = snd_hda_codec_read(codec, nid, 0, | |
3311 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | |
3312 | new_ctl = ctls[ucontrol->value.enumerated.item[0]]; | |
3313 | if (old_ctl != new_ctl) { | |
82beb8fd TI |
3314 | int val; |
3315 | snd_hda_codec_write_cache(codec, nid, 0, | |
3316 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
3317 | new_ctl); | |
47fd830a TI |
3318 | val = ucontrol->value.enumerated.item[0] >= 3 ? |
3319 | HDA_AMP_MUTE : 0; | |
3320 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, | |
3321 | HDA_AMP_MUTE, val); | |
2fa522be TI |
3322 | return 1; |
3323 | } | |
3324 | return 0; | |
3325 | } | |
3326 | ||
9c7f852e TI |
3327 | static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, |
3328 | struct snd_ctl_elem_info *uinfo) | |
2fa522be TI |
3329 | { |
3330 | static char *texts[] = { | |
3331 | "Front", "Surround", "CLFE", "Side" | |
3332 | }; | |
3333 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
3334 | uinfo->count = 1; | |
3335 | uinfo->value.enumerated.items = 4; | |
3336 | if (uinfo->value.enumerated.item >= 4) | |
3337 | uinfo->value.enumerated.item = 3; | |
3338 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | |
3339 | return 0; | |
3340 | } | |
3341 | ||
9c7f852e TI |
3342 | static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, |
3343 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
3344 | { |
3345 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
3346 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
3347 | unsigned int sel; | |
3348 | ||
3349 | sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0); | |
3350 | ucontrol->value.enumerated.item[0] = sel & 3; | |
3351 | return 0; | |
3352 | } | |
3353 | ||
9c7f852e TI |
3354 | static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, |
3355 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
3356 | { |
3357 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
3358 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
3359 | unsigned int sel; | |
3360 | ||
3361 | sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3; | |
3362 | if (ucontrol->value.enumerated.item[0] != sel) { | |
3363 | sel = ucontrol->value.enumerated.item[0] & 3; | |
82beb8fd TI |
3364 | snd_hda_codec_write_cache(codec, nid, 0, |
3365 | AC_VERB_SET_CONNECT_SEL, sel); | |
2fa522be TI |
3366 | return 1; |
3367 | } | |
3368 | return 0; | |
3369 | } | |
3370 | ||
3371 | #define PIN_CTL_TEST(xname,nid) { \ | |
3372 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
3373 | .name = xname, \ | |
3374 | .info = alc_test_pin_ctl_info, \ | |
3375 | .get = alc_test_pin_ctl_get, \ | |
3376 | .put = alc_test_pin_ctl_put, \ | |
3377 | .private_value = nid \ | |
3378 | } | |
3379 | ||
3380 | #define PIN_SRC_TEST(xname,nid) { \ | |
3381 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
3382 | .name = xname, \ | |
3383 | .info = alc_test_pin_src_info, \ | |
3384 | .get = alc_test_pin_src_get, \ | |
3385 | .put = alc_test_pin_src_put, \ | |
3386 | .private_value = nid \ | |
3387 | } | |
3388 | ||
c8b6bf9b | 3389 | static struct snd_kcontrol_new alc880_test_mixer[] = { |
05acb863 TI |
3390 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
3391 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
3392 | HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT), | |
3393 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
985be54b TI |
3394 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
3395 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
3396 | HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT), | |
3397 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
2fa522be TI |
3398 | PIN_CTL_TEST("Front Pin Mode", 0x14), |
3399 | PIN_CTL_TEST("Surround Pin Mode", 0x15), | |
3400 | PIN_CTL_TEST("CLFE Pin Mode", 0x16), | |
3401 | PIN_CTL_TEST("Side Pin Mode", 0x17), | |
3402 | PIN_CTL_TEST("In-1 Pin Mode", 0x18), | |
3403 | PIN_CTL_TEST("In-2 Pin Mode", 0x19), | |
3404 | PIN_CTL_TEST("In-3 Pin Mode", 0x1a), | |
3405 | PIN_CTL_TEST("In-4 Pin Mode", 0x1b), | |
3406 | PIN_SRC_TEST("In-1 Pin Source", 0x18), | |
3407 | PIN_SRC_TEST("In-2 Pin Source", 0x19), | |
3408 | PIN_SRC_TEST("In-3 Pin Source", 0x1a), | |
3409 | PIN_SRC_TEST("In-4 Pin Source", 0x1b), | |
3410 | HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
3411 | HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
3412 | HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
3413 | HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
3414 | HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT), | |
3415 | HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT), | |
3416 | HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT), | |
3417 | HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT), | |
3418 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT), | |
3419 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT), | |
2fa522be TI |
3420 | { |
3421 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
3422 | .name = "Channel Mode", | |
df694daa KY |
3423 | .info = alc_ch_mode_info, |
3424 | .get = alc_ch_mode_get, | |
3425 | .put = alc_ch_mode_put, | |
2fa522be TI |
3426 | }, |
3427 | { } /* end */ | |
3428 | }; | |
3429 | ||
3430 | static struct hda_verb alc880_test_init_verbs[] = { | |
3431 | /* Unmute inputs of 0x0c - 0x0f */ | |
05acb863 TI |
3432 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
3433 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
3434 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
3435 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
3436 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
3437 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
3438 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
3439 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2fa522be | 3440 | /* Vol output for 0x0c-0x0f */ |
05acb863 TI |
3441 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
3442 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3443 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3444 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2fa522be | 3445 | /* Set output pins 0x14-0x17 */ |
05acb863 TI |
3446 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
3447 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
3448 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
3449 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2fa522be | 3450 | /* Unmute output pins 0x14-0x17 */ |
05acb863 TI |
3451 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
3452 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3453 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3454 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2fa522be | 3455 | /* Set input pins 0x18-0x1c */ |
16ded525 TI |
3456 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
3457 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
05acb863 TI |
3458 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
3459 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
3460 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2fa522be | 3461 | /* Mute input pins 0x18-0x1b */ |
05acb863 TI |
3462 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
3463 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
3464 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
3465 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
71fe7b82 | 3466 | /* ADC set up */ |
05acb863 | 3467 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 3468 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 | 3469 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 3470 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 | 3471 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 3472 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
3473 | /* Analog input/passthru */ |
3474 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3475 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3476 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
3477 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
3478 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
2fa522be TI |
3479 | { } |
3480 | }; | |
3481 | #endif | |
3482 | ||
1da177e4 LT |
3483 | /* |
3484 | */ | |
3485 | ||
f5fcc13c TI |
3486 | static const char *alc880_models[ALC880_MODEL_LAST] = { |
3487 | [ALC880_3ST] = "3stack", | |
3488 | [ALC880_TCL_S700] = "tcl", | |
3489 | [ALC880_3ST_DIG] = "3stack-digout", | |
3490 | [ALC880_CLEVO] = "clevo", | |
3491 | [ALC880_5ST] = "5stack", | |
3492 | [ALC880_5ST_DIG] = "5stack-digout", | |
3493 | [ALC880_W810] = "w810", | |
3494 | [ALC880_Z71V] = "z71v", | |
3495 | [ALC880_6ST] = "6stack", | |
3496 | [ALC880_6ST_DIG] = "6stack-digout", | |
3497 | [ALC880_ASUS] = "asus", | |
3498 | [ALC880_ASUS_W1V] = "asus-w1v", | |
3499 | [ALC880_ASUS_DIG] = "asus-dig", | |
3500 | [ALC880_ASUS_DIG2] = "asus-dig2", | |
3501 | [ALC880_UNIWILL_DIG] = "uniwill", | |
2cf9f0fc TD |
3502 | [ALC880_UNIWILL_P53] = "uniwill-p53", |
3503 | [ALC880_FUJITSU] = "fujitsu", | |
f5fcc13c TI |
3504 | [ALC880_F1734] = "F1734", |
3505 | [ALC880_LG] = "lg", | |
3506 | [ALC880_LG_LW] = "lg-lw", | |
df99cd33 | 3507 | [ALC880_MEDION_RIM] = "medion", |
2fa522be | 3508 | #ifdef CONFIG_SND_DEBUG |
f5fcc13c | 3509 | [ALC880_TEST] = "test", |
2fa522be | 3510 | #endif |
f5fcc13c TI |
3511 | [ALC880_AUTO] = "auto", |
3512 | }; | |
3513 | ||
3514 | static struct snd_pci_quirk alc880_cfg_tbl[] = { | |
ac3e3741 | 3515 | SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810), |
f5fcc13c TI |
3516 | SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG), |
3517 | SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST), | |
3518 | SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG), | |
3519 | SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG), | |
3520 | SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG), | |
3521 | SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG), | |
3522 | SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG), | |
3523 | SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST), | |
f5fcc13c TI |
3524 | SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG), |
3525 | SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST), | |
f5fcc13c TI |
3526 | SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V), |
3527 | SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG), | |
3528 | SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG), | |
3529 | SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG), | |
3530 | SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG), | |
3531 | SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG), | |
3532 | SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V), | |
3533 | /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */ | |
3534 | SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG), | |
3535 | SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG), | |
186c3117 | 3536 | SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG), |
f5fcc13c TI |
3537 | SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG), |
3538 | SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST), | |
3539 | SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST), | |
ac3e3741 | 3540 | SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */ |
f5fcc13c | 3541 | SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST), |
ac3e3741 TI |
3542 | SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST), |
3543 | SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST), | |
f5fcc13c TI |
3544 | SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST), |
3545 | SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST), | |
f5fcc13c TI |
3546 | SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG), |
3547 | SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG), | |
3548 | SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG), | |
3549 | SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG), | |
ac3e3741 TI |
3550 | SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO), |
3551 | SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO), | |
f5fcc13c | 3552 | SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2), |
ac3e3741 | 3553 | SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG), |
f5fcc13c | 3554 | SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG), |
ac3e3741 | 3555 | SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734), |
f5fcc13c TI |
3556 | SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL), |
3557 | SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53), | |
ac3e3741 | 3558 | SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810), |
df99cd33 | 3559 | SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM), |
ac3e3741 | 3560 | SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG), |
f5fcc13c | 3561 | SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG), |
f5fcc13c | 3562 | SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734), |
1d11604e | 3563 | SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU), |
ac3e3741 | 3564 | SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL), |
2cf9f0fc | 3565 | SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU), |
ac3e3741 | 3566 | SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW), |
f5fcc13c TI |
3567 | SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG), |
3568 | SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG), | |
f5fcc13c | 3569 | SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW), |
ac3e3741 TI |
3570 | SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700), |
3571 | SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */ | |
3572 | SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG), | |
3573 | SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG), | |
f5fcc13c TI |
3574 | SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG), |
3575 | SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG), | |
ac3e3741 | 3576 | SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG), |
f5fcc13c | 3577 | SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG), |
ac3e3741 TI |
3578 | SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG), |
3579 | SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG), | |
f5fcc13c TI |
3580 | SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG), |
3581 | SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG), | |
3582 | SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG), | |
ac3e3741 TI |
3583 | SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */ |
3584 | SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG), | |
3585 | SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG), | |
1da177e4 LT |
3586 | {} |
3587 | }; | |
3588 | ||
16ded525 | 3589 | /* |
df694daa | 3590 | * ALC880 codec presets |
16ded525 | 3591 | */ |
16ded525 TI |
3592 | static struct alc_config_preset alc880_presets[] = { |
3593 | [ALC880_3ST] = { | |
e9edcee0 | 3594 | .mixers = { alc880_three_stack_mixer }, |
f12ab1e0 TI |
3595 | .init_verbs = { alc880_volume_init_verbs, |
3596 | alc880_pin_3stack_init_verbs }, | |
16ded525 | 3597 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
16ded525 | 3598 | .dac_nids = alc880_dac_nids, |
16ded525 TI |
3599 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
3600 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 3601 | .need_dac_fix = 1, |
16ded525 TI |
3602 | .input_mux = &alc880_capture_source, |
3603 | }, | |
3604 | [ALC880_3ST_DIG] = { | |
e9edcee0 | 3605 | .mixers = { alc880_three_stack_mixer }, |
f12ab1e0 TI |
3606 | .init_verbs = { alc880_volume_init_verbs, |
3607 | alc880_pin_3stack_init_verbs }, | |
16ded525 | 3608 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
16ded525 TI |
3609 | .dac_nids = alc880_dac_nids, |
3610 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3611 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
3612 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 3613 | .need_dac_fix = 1, |
16ded525 TI |
3614 | .input_mux = &alc880_capture_source, |
3615 | }, | |
df694daa KY |
3616 | [ALC880_TCL_S700] = { |
3617 | .mixers = { alc880_tcl_s700_mixer }, | |
3618 | .init_verbs = { alc880_volume_init_verbs, | |
3619 | alc880_pin_tcl_S700_init_verbs, | |
3620 | alc880_gpio2_init_verbs }, | |
3621 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
3622 | .dac_nids = alc880_dac_nids, | |
f9e336f6 TI |
3623 | .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */ |
3624 | .num_adc_nids = 1, /* single ADC */ | |
df694daa KY |
3625 | .hp_nid = 0x03, |
3626 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
3627 | .channel_mode = alc880_2_jack_modes, | |
3628 | .input_mux = &alc880_capture_source, | |
3629 | }, | |
16ded525 | 3630 | [ALC880_5ST] = { |
f12ab1e0 TI |
3631 | .mixers = { alc880_three_stack_mixer, |
3632 | alc880_five_stack_mixer}, | |
3633 | .init_verbs = { alc880_volume_init_verbs, | |
3634 | alc880_pin_5stack_init_verbs }, | |
16ded525 TI |
3635 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
3636 | .dac_nids = alc880_dac_nids, | |
16ded525 TI |
3637 | .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), |
3638 | .channel_mode = alc880_fivestack_modes, | |
3639 | .input_mux = &alc880_capture_source, | |
3640 | }, | |
3641 | [ALC880_5ST_DIG] = { | |
f12ab1e0 TI |
3642 | .mixers = { alc880_three_stack_mixer, |
3643 | alc880_five_stack_mixer }, | |
3644 | .init_verbs = { alc880_volume_init_verbs, | |
3645 | alc880_pin_5stack_init_verbs }, | |
16ded525 TI |
3646 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
3647 | .dac_nids = alc880_dac_nids, | |
3648 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3649 | .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), |
3650 | .channel_mode = alc880_fivestack_modes, | |
3651 | .input_mux = &alc880_capture_source, | |
3652 | }, | |
b6482d48 TI |
3653 | [ALC880_6ST] = { |
3654 | .mixers = { alc880_six_stack_mixer }, | |
f12ab1e0 TI |
3655 | .init_verbs = { alc880_volume_init_verbs, |
3656 | alc880_pin_6stack_init_verbs }, | |
b6482d48 TI |
3657 | .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), |
3658 | .dac_nids = alc880_6st_dac_nids, | |
3659 | .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), | |
3660 | .channel_mode = alc880_sixstack_modes, | |
3661 | .input_mux = &alc880_6stack_capture_source, | |
3662 | }, | |
16ded525 | 3663 | [ALC880_6ST_DIG] = { |
e9edcee0 | 3664 | .mixers = { alc880_six_stack_mixer }, |
f12ab1e0 TI |
3665 | .init_verbs = { alc880_volume_init_verbs, |
3666 | alc880_pin_6stack_init_verbs }, | |
16ded525 TI |
3667 | .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), |
3668 | .dac_nids = alc880_6st_dac_nids, | |
3669 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3670 | .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), |
3671 | .channel_mode = alc880_sixstack_modes, | |
3672 | .input_mux = &alc880_6stack_capture_source, | |
3673 | }, | |
3674 | [ALC880_W810] = { | |
e9edcee0 | 3675 | .mixers = { alc880_w810_base_mixer }, |
f12ab1e0 TI |
3676 | .init_verbs = { alc880_volume_init_verbs, |
3677 | alc880_pin_w810_init_verbs, | |
b0af0de5 | 3678 | alc880_gpio2_init_verbs }, |
16ded525 TI |
3679 | .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids), |
3680 | .dac_nids = alc880_w810_dac_nids, | |
3681 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3682 | .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), |
3683 | .channel_mode = alc880_w810_modes, | |
3684 | .input_mux = &alc880_capture_source, | |
3685 | }, | |
3686 | [ALC880_Z71V] = { | |
e9edcee0 | 3687 | .mixers = { alc880_z71v_mixer }, |
f12ab1e0 TI |
3688 | .init_verbs = { alc880_volume_init_verbs, |
3689 | alc880_pin_z71v_init_verbs }, | |
16ded525 TI |
3690 | .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids), |
3691 | .dac_nids = alc880_z71v_dac_nids, | |
3692 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3693 | .hp_nid = 0x03, | |
e9edcee0 TI |
3694 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), |
3695 | .channel_mode = alc880_2_jack_modes, | |
16ded525 TI |
3696 | .input_mux = &alc880_capture_source, |
3697 | }, | |
3698 | [ALC880_F1734] = { | |
e9edcee0 | 3699 | .mixers = { alc880_f1734_mixer }, |
f12ab1e0 TI |
3700 | .init_verbs = { alc880_volume_init_verbs, |
3701 | alc880_pin_f1734_init_verbs }, | |
e9edcee0 TI |
3702 | .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids), |
3703 | .dac_nids = alc880_f1734_dac_nids, | |
3704 | .hp_nid = 0x02, | |
3705 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
3706 | .channel_mode = alc880_2_jack_modes, | |
937b4160 TI |
3707 | .input_mux = &alc880_f1734_capture_source, |
3708 | .unsol_event = alc880_uniwill_p53_unsol_event, | |
3709 | .init_hook = alc880_uniwill_p53_hp_automute, | |
16ded525 TI |
3710 | }, |
3711 | [ALC880_ASUS] = { | |
e9edcee0 | 3712 | .mixers = { alc880_asus_mixer }, |
f12ab1e0 TI |
3713 | .init_verbs = { alc880_volume_init_verbs, |
3714 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
3715 | alc880_gpio1_init_verbs }, |
3716 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3717 | .dac_nids = alc880_asus_dac_nids, | |
3718 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), | |
3719 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3720 | .need_dac_fix = 1, |
16ded525 TI |
3721 | .input_mux = &alc880_capture_source, |
3722 | }, | |
3723 | [ALC880_ASUS_DIG] = { | |
e9edcee0 | 3724 | .mixers = { alc880_asus_mixer }, |
f12ab1e0 TI |
3725 | .init_verbs = { alc880_volume_init_verbs, |
3726 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
3727 | alc880_gpio1_init_verbs }, |
3728 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3729 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 3730 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
3731 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
3732 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3733 | .need_dac_fix = 1, |
16ded525 TI |
3734 | .input_mux = &alc880_capture_source, |
3735 | }, | |
df694daa KY |
3736 | [ALC880_ASUS_DIG2] = { |
3737 | .mixers = { alc880_asus_mixer }, | |
f12ab1e0 TI |
3738 | .init_verbs = { alc880_volume_init_verbs, |
3739 | alc880_pin_asus_init_verbs, | |
df694daa KY |
3740 | alc880_gpio2_init_verbs }, /* use GPIO2 */ |
3741 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3742 | .dac_nids = alc880_asus_dac_nids, | |
3743 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3744 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), | |
3745 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3746 | .need_dac_fix = 1, |
df694daa KY |
3747 | .input_mux = &alc880_capture_source, |
3748 | }, | |
16ded525 | 3749 | [ALC880_ASUS_W1V] = { |
e9edcee0 | 3750 | .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer }, |
f12ab1e0 TI |
3751 | .init_verbs = { alc880_volume_init_verbs, |
3752 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
3753 | alc880_gpio1_init_verbs }, |
3754 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3755 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 3756 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
3757 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
3758 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3759 | .need_dac_fix = 1, |
16ded525 TI |
3760 | .input_mux = &alc880_capture_source, |
3761 | }, | |
3762 | [ALC880_UNIWILL_DIG] = { | |
3c10a9d9 | 3763 | .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer }, |
ccc656ce KY |
3764 | .init_verbs = { alc880_volume_init_verbs, |
3765 | alc880_pin_asus_init_verbs }, | |
e9edcee0 TI |
3766 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), |
3767 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 3768 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
3769 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
3770 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3771 | .need_dac_fix = 1, |
16ded525 TI |
3772 | .input_mux = &alc880_capture_source, |
3773 | }, | |
ccc656ce KY |
3774 | [ALC880_UNIWILL] = { |
3775 | .mixers = { alc880_uniwill_mixer }, | |
3776 | .init_verbs = { alc880_volume_init_verbs, | |
3777 | alc880_uniwill_init_verbs }, | |
3778 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3779 | .dac_nids = alc880_asus_dac_nids, | |
3780 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3781 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
3782 | .channel_mode = alc880_threestack_modes, | |
3783 | .need_dac_fix = 1, | |
3784 | .input_mux = &alc880_capture_source, | |
3785 | .unsol_event = alc880_uniwill_unsol_event, | |
3786 | .init_hook = alc880_uniwill_automute, | |
3787 | }, | |
3788 | [ALC880_UNIWILL_P53] = { | |
3789 | .mixers = { alc880_uniwill_p53_mixer }, | |
3790 | .init_verbs = { alc880_volume_init_verbs, | |
3791 | alc880_uniwill_p53_init_verbs }, | |
3792 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3793 | .dac_nids = alc880_asus_dac_nids, | |
3794 | .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), | |
2cf9f0fc TD |
3795 | .channel_mode = alc880_threestack_modes, |
3796 | .input_mux = &alc880_capture_source, | |
3797 | .unsol_event = alc880_uniwill_p53_unsol_event, | |
3798 | .init_hook = alc880_uniwill_p53_hp_automute, | |
3799 | }, | |
3800 | [ALC880_FUJITSU] = { | |
f12ab1e0 | 3801 | .mixers = { alc880_fujitsu_mixer, |
2cf9f0fc TD |
3802 | alc880_pcbeep_mixer, }, |
3803 | .init_verbs = { alc880_volume_init_verbs, | |
3804 | alc880_uniwill_p53_init_verbs, | |
3805 | alc880_beep_init_verbs }, | |
3806 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
3807 | .dac_nids = alc880_dac_nids, | |
d53d7d9e | 3808 | .dig_out_nid = ALC880_DIGOUT_NID, |
2cf9f0fc TD |
3809 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), |
3810 | .channel_mode = alc880_2_jack_modes, | |
ccc656ce KY |
3811 | .input_mux = &alc880_capture_source, |
3812 | .unsol_event = alc880_uniwill_p53_unsol_event, | |
3813 | .init_hook = alc880_uniwill_p53_hp_automute, | |
3814 | }, | |
df694daa KY |
3815 | [ALC880_CLEVO] = { |
3816 | .mixers = { alc880_three_stack_mixer }, | |
3817 | .init_verbs = { alc880_volume_init_verbs, | |
3818 | alc880_pin_clevo_init_verbs }, | |
3819 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
3820 | .dac_nids = alc880_dac_nids, | |
3821 | .hp_nid = 0x03, | |
3822 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
3823 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 3824 | .need_dac_fix = 1, |
df694daa KY |
3825 | .input_mux = &alc880_capture_source, |
3826 | }, | |
ae6b813a TI |
3827 | [ALC880_LG] = { |
3828 | .mixers = { alc880_lg_mixer }, | |
3829 | .init_verbs = { alc880_volume_init_verbs, | |
3830 | alc880_lg_init_verbs }, | |
3831 | .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids), | |
3832 | .dac_nids = alc880_lg_dac_nids, | |
3833 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3834 | .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes), | |
3835 | .channel_mode = alc880_lg_ch_modes, | |
4e195a7b | 3836 | .need_dac_fix = 1, |
ae6b813a TI |
3837 | .input_mux = &alc880_lg_capture_source, |
3838 | .unsol_event = alc880_lg_unsol_event, | |
3839 | .init_hook = alc880_lg_automute, | |
cb53c626 TI |
3840 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
3841 | .loopbacks = alc880_lg_loopbacks, | |
3842 | #endif | |
ae6b813a | 3843 | }, |
d681518a TI |
3844 | [ALC880_LG_LW] = { |
3845 | .mixers = { alc880_lg_lw_mixer }, | |
3846 | .init_verbs = { alc880_volume_init_verbs, | |
3847 | alc880_lg_lw_init_verbs }, | |
0a8c5da3 | 3848 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
d681518a TI |
3849 | .dac_nids = alc880_dac_nids, |
3850 | .dig_out_nid = ALC880_DIGOUT_NID, | |
0a8c5da3 CM |
3851 | .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes), |
3852 | .channel_mode = alc880_lg_lw_modes, | |
d681518a TI |
3853 | .input_mux = &alc880_lg_lw_capture_source, |
3854 | .unsol_event = alc880_lg_lw_unsol_event, | |
3855 | .init_hook = alc880_lg_lw_automute, | |
3856 | }, | |
df99cd33 TI |
3857 | [ALC880_MEDION_RIM] = { |
3858 | .mixers = { alc880_medion_rim_mixer }, | |
3859 | .init_verbs = { alc880_volume_init_verbs, | |
3860 | alc880_medion_rim_init_verbs, | |
3861 | alc_gpio2_init_verbs }, | |
3862 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
3863 | .dac_nids = alc880_dac_nids, | |
3864 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3865 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
3866 | .channel_mode = alc880_2_jack_modes, | |
3867 | .input_mux = &alc880_medion_rim_capture_source, | |
3868 | .unsol_event = alc880_medion_rim_unsol_event, | |
3869 | .init_hook = alc880_medion_rim_automute, | |
3870 | }, | |
16ded525 TI |
3871 | #ifdef CONFIG_SND_DEBUG |
3872 | [ALC880_TEST] = { | |
e9edcee0 TI |
3873 | .mixers = { alc880_test_mixer }, |
3874 | .init_verbs = { alc880_test_init_verbs }, | |
16ded525 TI |
3875 | .num_dacs = ARRAY_SIZE(alc880_test_dac_nids), |
3876 | .dac_nids = alc880_test_dac_nids, | |
3877 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3878 | .num_channel_mode = ARRAY_SIZE(alc880_test_modes), |
3879 | .channel_mode = alc880_test_modes, | |
3880 | .input_mux = &alc880_test_capture_source, | |
3881 | }, | |
3882 | #endif | |
3883 | }; | |
3884 | ||
e9edcee0 TI |
3885 | /* |
3886 | * Automatic parse of I/O pins from the BIOS configuration | |
3887 | */ | |
3888 | ||
e9edcee0 TI |
3889 | enum { |
3890 | ALC_CTL_WIDGET_VOL, | |
3891 | ALC_CTL_WIDGET_MUTE, | |
3892 | ALC_CTL_BIND_MUTE, | |
3893 | }; | |
c8b6bf9b | 3894 | static struct snd_kcontrol_new alc880_control_templates[] = { |
e9edcee0 TI |
3895 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
3896 | HDA_CODEC_MUTE(NULL, 0, 0, 0), | |
985be54b | 3897 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
e9edcee0 TI |
3898 | }; |
3899 | ||
3900 | /* add dynamic controls */ | |
f12ab1e0 TI |
3901 | static int add_control(struct alc_spec *spec, int type, const char *name, |
3902 | unsigned long val) | |
e9edcee0 | 3903 | { |
c8b6bf9b | 3904 | struct snd_kcontrol_new *knew; |
e9edcee0 | 3905 | |
603c4019 TI |
3906 | snd_array_init(&spec->kctls, sizeof(*knew), 32); |
3907 | knew = snd_array_new(&spec->kctls); | |
3908 | if (!knew) | |
3909 | return -ENOMEM; | |
e9edcee0 | 3910 | *knew = alc880_control_templates[type]; |
543537bd | 3911 | knew->name = kstrdup(name, GFP_KERNEL); |
f12ab1e0 | 3912 | if (!knew->name) |
e9edcee0 TI |
3913 | return -ENOMEM; |
3914 | knew->private_value = val; | |
e9edcee0 TI |
3915 | return 0; |
3916 | } | |
3917 | ||
3918 | #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17) | |
3919 | #define alc880_fixed_pin_idx(nid) ((nid) - 0x14) | |
3920 | #define alc880_is_multi_pin(nid) ((nid) >= 0x18) | |
3921 | #define alc880_multi_pin_idx(nid) ((nid) - 0x18) | |
3922 | #define alc880_is_input_pin(nid) ((nid) >= 0x18) | |
3923 | #define alc880_input_pin_idx(nid) ((nid) - 0x18) | |
3924 | #define alc880_idx_to_dac(nid) ((nid) + 0x02) | |
3925 | #define alc880_dac_to_idx(nid) ((nid) - 0x02) | |
3926 | #define alc880_idx_to_mixer(nid) ((nid) + 0x0c) | |
3927 | #define alc880_idx_to_selector(nid) ((nid) + 0x10) | |
3928 | #define ALC880_PIN_CD_NID 0x1c | |
3929 | ||
3930 | /* fill in the dac_nids table from the parsed pin configuration */ | |
f12ab1e0 TI |
3931 | static int alc880_auto_fill_dac_nids(struct alc_spec *spec, |
3932 | const struct auto_pin_cfg *cfg) | |
e9edcee0 TI |
3933 | { |
3934 | hda_nid_t nid; | |
3935 | int assigned[4]; | |
3936 | int i, j; | |
3937 | ||
3938 | memset(assigned, 0, sizeof(assigned)); | |
b0af0de5 | 3939 | spec->multiout.dac_nids = spec->private_dac_nids; |
e9edcee0 TI |
3940 | |
3941 | /* check the pins hardwired to audio widget */ | |
3942 | for (i = 0; i < cfg->line_outs; i++) { | |
3943 | nid = cfg->line_out_pins[i]; | |
3944 | if (alc880_is_fixed_pin(nid)) { | |
3945 | int idx = alc880_fixed_pin_idx(nid); | |
5014f193 | 3946 | spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx); |
e9edcee0 TI |
3947 | assigned[idx] = 1; |
3948 | } | |
3949 | } | |
3950 | /* left pins can be connect to any audio widget */ | |
3951 | for (i = 0; i < cfg->line_outs; i++) { | |
3952 | nid = cfg->line_out_pins[i]; | |
3953 | if (alc880_is_fixed_pin(nid)) | |
3954 | continue; | |
3955 | /* search for an empty channel */ | |
3956 | for (j = 0; j < cfg->line_outs; j++) { | |
f12ab1e0 TI |
3957 | if (!assigned[j]) { |
3958 | spec->multiout.dac_nids[i] = | |
3959 | alc880_idx_to_dac(j); | |
e9edcee0 TI |
3960 | assigned[j] = 1; |
3961 | break; | |
3962 | } | |
3963 | } | |
3964 | } | |
3965 | spec->multiout.num_dacs = cfg->line_outs; | |
3966 | return 0; | |
3967 | } | |
3968 | ||
3969 | /* add playback controls from the parsed DAC table */ | |
df694daa KY |
3970 | static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, |
3971 | const struct auto_pin_cfg *cfg) | |
e9edcee0 TI |
3972 | { |
3973 | char name[32]; | |
f12ab1e0 TI |
3974 | static const char *chname[4] = { |
3975 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
3976 | }; | |
e9edcee0 TI |
3977 | hda_nid_t nid; |
3978 | int i, err; | |
3979 | ||
3980 | for (i = 0; i < cfg->line_outs; i++) { | |
f12ab1e0 | 3981 | if (!spec->multiout.dac_nids[i]) |
e9edcee0 TI |
3982 | continue; |
3983 | nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i])); | |
3984 | if (i == 2) { | |
3985 | /* Center/LFE */ | |
f12ab1e0 TI |
3986 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
3987 | "Center Playback Volume", | |
3988 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, | |
3989 | HDA_OUTPUT)); | |
3990 | if (err < 0) | |
e9edcee0 | 3991 | return err; |
f12ab1e0 TI |
3992 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
3993 | "LFE Playback Volume", | |
3994 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
3995 | HDA_OUTPUT)); | |
3996 | if (err < 0) | |
e9edcee0 | 3997 | return err; |
f12ab1e0 TI |
3998 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
3999 | "Center Playback Switch", | |
4000 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, | |
4001 | HDA_INPUT)); | |
4002 | if (err < 0) | |
e9edcee0 | 4003 | return err; |
f12ab1e0 TI |
4004 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
4005 | "LFE Playback Switch", | |
4006 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, | |
4007 | HDA_INPUT)); | |
4008 | if (err < 0) | |
e9edcee0 TI |
4009 | return err; |
4010 | } else { | |
4011 | sprintf(name, "%s Playback Volume", chname[i]); | |
f12ab1e0 TI |
4012 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
4013 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
4014 | HDA_OUTPUT)); | |
4015 | if (err < 0) | |
e9edcee0 TI |
4016 | return err; |
4017 | sprintf(name, "%s Playback Switch", chname[i]); | |
f12ab1e0 TI |
4018 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
4019 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, | |
4020 | HDA_INPUT)); | |
4021 | if (err < 0) | |
e9edcee0 TI |
4022 | return err; |
4023 | } | |
4024 | } | |
e9edcee0 TI |
4025 | return 0; |
4026 | } | |
4027 | ||
8d88bc3d TI |
4028 | /* add playback controls for speaker and HP outputs */ |
4029 | static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, | |
4030 | const char *pfx) | |
e9edcee0 TI |
4031 | { |
4032 | hda_nid_t nid; | |
4033 | int err; | |
8d88bc3d | 4034 | char name[32]; |
e9edcee0 | 4035 | |
f12ab1e0 | 4036 | if (!pin) |
e9edcee0 TI |
4037 | return 0; |
4038 | ||
4039 | if (alc880_is_fixed_pin(pin)) { | |
4040 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
82bc955f | 4041 | /* specify the DAC as the extra output */ |
f12ab1e0 | 4042 | if (!spec->multiout.hp_nid) |
e9edcee0 | 4043 | spec->multiout.hp_nid = nid; |
82bc955f TI |
4044 | else |
4045 | spec->multiout.extra_out_nid[0] = nid; | |
e9edcee0 TI |
4046 | /* control HP volume/switch on the output mixer amp */ |
4047 | nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin)); | |
8d88bc3d | 4048 | sprintf(name, "%s Playback Volume", pfx); |
f12ab1e0 TI |
4049 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
4050 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
4051 | if (err < 0) | |
e9edcee0 | 4052 | return err; |
8d88bc3d | 4053 | sprintf(name, "%s Playback Switch", pfx); |
f12ab1e0 TI |
4054 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
4055 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); | |
4056 | if (err < 0) | |
e9edcee0 TI |
4057 | return err; |
4058 | } else if (alc880_is_multi_pin(pin)) { | |
4059 | /* set manual connection */ | |
e9edcee0 | 4060 | /* we have only a switch on HP-out PIN */ |
8d88bc3d | 4061 | sprintf(name, "%s Playback Switch", pfx); |
f12ab1e0 TI |
4062 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
4063 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
4064 | if (err < 0) | |
e9edcee0 TI |
4065 | return err; |
4066 | } | |
4067 | return 0; | |
4068 | } | |
4069 | ||
4070 | /* create input playback/capture controls for the given pin */ | |
f12ab1e0 TI |
4071 | static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, |
4072 | const char *ctlname, | |
df694daa | 4073 | int idx, hda_nid_t mix_nid) |
e9edcee0 TI |
4074 | { |
4075 | char name[32]; | |
df694daa | 4076 | int err; |
e9edcee0 TI |
4077 | |
4078 | sprintf(name, "%s Playback Volume", ctlname); | |
f12ab1e0 TI |
4079 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
4080 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); | |
4081 | if (err < 0) | |
e9edcee0 TI |
4082 | return err; |
4083 | sprintf(name, "%s Playback Switch", ctlname); | |
f12ab1e0 TI |
4084 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
4085 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); | |
4086 | if (err < 0) | |
e9edcee0 TI |
4087 | return err; |
4088 | return 0; | |
4089 | } | |
4090 | ||
4091 | /* create playback/capture controls for input pins */ | |
df694daa KY |
4092 | static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, |
4093 | const struct auto_pin_cfg *cfg) | |
e9edcee0 | 4094 | { |
e9edcee0 | 4095 | struct hda_input_mux *imux = &spec->private_imux; |
df694daa | 4096 | int i, err, idx; |
e9edcee0 TI |
4097 | |
4098 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
4099 | if (alc880_is_input_pin(cfg->input_pins[i])) { | |
df694daa | 4100 | idx = alc880_input_pin_idx(cfg->input_pins[i]); |
4a471b7d TI |
4101 | err = new_analog_input(spec, cfg->input_pins[i], |
4102 | auto_pin_cfg_labels[i], | |
df694daa | 4103 | idx, 0x0b); |
e9edcee0 TI |
4104 | if (err < 0) |
4105 | return err; | |
f12ab1e0 TI |
4106 | imux->items[imux->num_items].label = |
4107 | auto_pin_cfg_labels[i]; | |
4108 | imux->items[imux->num_items].index = | |
4109 | alc880_input_pin_idx(cfg->input_pins[i]); | |
e9edcee0 TI |
4110 | imux->num_items++; |
4111 | } | |
4112 | } | |
4113 | return 0; | |
4114 | } | |
4115 | ||
f6c7e546 TI |
4116 | static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid, |
4117 | unsigned int pin_type) | |
4118 | { | |
4119 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4120 | pin_type); | |
4121 | /* unmute pin */ | |
d260cdf6 TI |
4122 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
4123 | AMP_OUT_UNMUTE); | |
f6c7e546 TI |
4124 | } |
4125 | ||
df694daa KY |
4126 | static void alc880_auto_set_output_and_unmute(struct hda_codec *codec, |
4127 | hda_nid_t nid, int pin_type, | |
e9edcee0 TI |
4128 | int dac_idx) |
4129 | { | |
f6c7e546 | 4130 | alc_set_pin_output(codec, nid, pin_type); |
e9edcee0 TI |
4131 | /* need the manual connection? */ |
4132 | if (alc880_is_multi_pin(nid)) { | |
4133 | struct alc_spec *spec = codec->spec; | |
4134 | int idx = alc880_multi_pin_idx(nid); | |
4135 | snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, | |
4136 | AC_VERB_SET_CONNECT_SEL, | |
4137 | alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); | |
4138 | } | |
4139 | } | |
4140 | ||
baba8ee9 TI |
4141 | static int get_pin_type(int line_out_type) |
4142 | { | |
4143 | if (line_out_type == AUTO_PIN_HP_OUT) | |
4144 | return PIN_HP; | |
4145 | else | |
4146 | return PIN_OUT; | |
4147 | } | |
4148 | ||
e9edcee0 TI |
4149 | static void alc880_auto_init_multi_out(struct hda_codec *codec) |
4150 | { | |
4151 | struct alc_spec *spec = codec->spec; | |
4152 | int i; | |
ea1fb29a | 4153 | |
bc9f98a9 | 4154 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
e9edcee0 TI |
4155 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
4156 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 TI |
4157 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
4158 | alc880_auto_set_output_and_unmute(codec, nid, pin_type, i); | |
e9edcee0 TI |
4159 | } |
4160 | } | |
4161 | ||
8d88bc3d | 4162 | static void alc880_auto_init_extra_out(struct hda_codec *codec) |
e9edcee0 TI |
4163 | { |
4164 | struct alc_spec *spec = codec->spec; | |
4165 | hda_nid_t pin; | |
4166 | ||
82bc955f | 4167 | pin = spec->autocfg.speaker_pins[0]; |
8d88bc3d TI |
4168 | if (pin) /* connect to front */ |
4169 | alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
eb06ed8f | 4170 | pin = spec->autocfg.hp_pins[0]; |
e9edcee0 TI |
4171 | if (pin) /* connect to front */ |
4172 | alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
4173 | } | |
4174 | ||
4175 | static void alc880_auto_init_analog_input(struct hda_codec *codec) | |
4176 | { | |
4177 | struct alc_spec *spec = codec->spec; | |
4178 | int i; | |
4179 | ||
4180 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
4181 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
4182 | if (alc880_is_input_pin(nid)) { | |
f12ab1e0 TI |
4183 | snd_hda_codec_write(codec, nid, 0, |
4184 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4185 | i <= AUTO_PIN_FRONT_MIC ? | |
4186 | PIN_VREF80 : PIN_IN); | |
e9edcee0 | 4187 | if (nid != ALC880_PIN_CD_NID) |
f12ab1e0 TI |
4188 | snd_hda_codec_write(codec, nid, 0, |
4189 | AC_VERB_SET_AMP_GAIN_MUTE, | |
e9edcee0 TI |
4190 | AMP_OUT_MUTE); |
4191 | } | |
4192 | } | |
4193 | } | |
4194 | ||
4195 | /* parse the BIOS configuration and set up the alc_spec */ | |
f12ab1e0 TI |
4196 | /* return 1 if successful, 0 if the proper config is not found, |
4197 | * or a negative error code | |
4198 | */ | |
e9edcee0 TI |
4199 | static int alc880_parse_auto_config(struct hda_codec *codec) |
4200 | { | |
4201 | struct alc_spec *spec = codec->spec; | |
4202 | int err; | |
df694daa | 4203 | static hda_nid_t alc880_ignore[] = { 0x1d, 0 }; |
e9edcee0 | 4204 | |
f12ab1e0 TI |
4205 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
4206 | alc880_ignore); | |
4207 | if (err < 0) | |
e9edcee0 | 4208 | return err; |
f12ab1e0 | 4209 | if (!spec->autocfg.line_outs) |
e9edcee0 | 4210 | return 0; /* can't find valid BIOS pin config */ |
df694daa | 4211 | |
f12ab1e0 TI |
4212 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
4213 | if (err < 0) | |
4214 | return err; | |
4215 | err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
4216 | if (err < 0) | |
4217 | return err; | |
4218 | err = alc880_auto_create_extra_out(spec, | |
4219 | spec->autocfg.speaker_pins[0], | |
4220 | "Speaker"); | |
4221 | if (err < 0) | |
4222 | return err; | |
4223 | err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], | |
4224 | "Headphone"); | |
4225 | if (err < 0) | |
4226 | return err; | |
4227 | err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
4228 | if (err < 0) | |
e9edcee0 TI |
4229 | return err; |
4230 | ||
4231 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
4232 | ||
4233 | if (spec->autocfg.dig_out_pin) | |
4234 | spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; | |
4235 | if (spec->autocfg.dig_in_pin) | |
4236 | spec->dig_in_nid = ALC880_DIGIN_NID; | |
4237 | ||
603c4019 | 4238 | if (spec->kctls.list) |
d88897ea | 4239 | add_mixer(spec, spec->kctls.list); |
e9edcee0 | 4240 | |
d88897ea | 4241 | add_verb(spec, alc880_volume_init_verbs); |
e9edcee0 | 4242 | |
a1e8d2da | 4243 | spec->num_mux_defs = 1; |
e9edcee0 TI |
4244 | spec->input_mux = &spec->private_imux; |
4245 | ||
e044c39a | 4246 | store_pin_configs(codec); |
e9edcee0 TI |
4247 | return 1; |
4248 | } | |
4249 | ||
ae6b813a TI |
4250 | /* additional initialization for auto-configuration model */ |
4251 | static void alc880_auto_init(struct hda_codec *codec) | |
e9edcee0 | 4252 | { |
f6c7e546 | 4253 | struct alc_spec *spec = codec->spec; |
e9edcee0 | 4254 | alc880_auto_init_multi_out(codec); |
8d88bc3d | 4255 | alc880_auto_init_extra_out(codec); |
e9edcee0 | 4256 | alc880_auto_init_analog_input(codec); |
f6c7e546 | 4257 | if (spec->unsol_event) |
7fb0d78f | 4258 | alc_inithook(codec); |
e9edcee0 TI |
4259 | } |
4260 | ||
4261 | /* | |
4262 | * OK, here we have finally the patch for ALC880 | |
4263 | */ | |
4264 | ||
f9e336f6 TI |
4265 | static void set_capture_mixer(struct alc_spec *spec) |
4266 | { | |
4267 | static struct snd_kcontrol_new *caps[3] = { | |
4268 | alc_capture_mixer1, | |
4269 | alc_capture_mixer2, | |
4270 | alc_capture_mixer3, | |
4271 | }; | |
4272 | if (spec->num_adc_nids > 0 && spec->num_adc_nids < 3) | |
4273 | spec->cap_mixer = caps[spec->num_adc_nids - 1]; | |
4274 | } | |
4275 | ||
1da177e4 LT |
4276 | static int patch_alc880(struct hda_codec *codec) |
4277 | { | |
4278 | struct alc_spec *spec; | |
4279 | int board_config; | |
df694daa | 4280 | int err; |
1da177e4 | 4281 | |
e560d8d8 | 4282 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
1da177e4 LT |
4283 | if (spec == NULL) |
4284 | return -ENOMEM; | |
4285 | ||
4286 | codec->spec = spec; | |
4287 | ||
f5fcc13c TI |
4288 | board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST, |
4289 | alc880_models, | |
4290 | alc880_cfg_tbl); | |
4291 | if (board_config < 0) { | |
9c7f852e TI |
4292 | printk(KERN_INFO "hda_codec: Unknown model for ALC880, " |
4293 | "trying auto-probe from BIOS...\n"); | |
e9edcee0 | 4294 | board_config = ALC880_AUTO; |
1da177e4 | 4295 | } |
1da177e4 | 4296 | |
e9edcee0 TI |
4297 | if (board_config == ALC880_AUTO) { |
4298 | /* automatic parse from the BIOS config */ | |
4299 | err = alc880_parse_auto_config(codec); | |
4300 | if (err < 0) { | |
4301 | alc_free(codec); | |
4302 | return err; | |
f12ab1e0 | 4303 | } else if (!err) { |
9c7f852e TI |
4304 | printk(KERN_INFO |
4305 | "hda_codec: Cannot set up configuration " | |
4306 | "from BIOS. Using 3-stack mode...\n"); | |
e9edcee0 TI |
4307 | board_config = ALC880_3ST; |
4308 | } | |
1da177e4 LT |
4309 | } |
4310 | ||
df694daa KY |
4311 | if (board_config != ALC880_AUTO) |
4312 | setup_preset(spec, &alc880_presets[board_config]); | |
1da177e4 LT |
4313 | |
4314 | spec->stream_name_analog = "ALC880 Analog"; | |
4315 | spec->stream_analog_playback = &alc880_pcm_analog_playback; | |
4316 | spec->stream_analog_capture = &alc880_pcm_analog_capture; | |
6330079f | 4317 | spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture; |
1da177e4 LT |
4318 | |
4319 | spec->stream_name_digital = "ALC880 Digital"; | |
4320 | spec->stream_digital_playback = &alc880_pcm_digital_playback; | |
4321 | spec->stream_digital_capture = &alc880_pcm_digital_capture; | |
4322 | ||
f12ab1e0 | 4323 | if (!spec->adc_nids && spec->input_mux) { |
e9edcee0 | 4324 | /* check whether NID 0x07 is valid */ |
54d17403 | 4325 | unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); |
f12ab1e0 TI |
4326 | /* get type */ |
4327 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
e9edcee0 TI |
4328 | if (wcap != AC_WID_AUD_IN) { |
4329 | spec->adc_nids = alc880_adc_nids_alt; | |
4330 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); | |
e9edcee0 TI |
4331 | } else { |
4332 | spec->adc_nids = alc880_adc_nids; | |
4333 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids); | |
e9edcee0 TI |
4334 | } |
4335 | } | |
f9e336f6 | 4336 | set_capture_mixer(spec); |
1da177e4 | 4337 | |
2134ea4f TI |
4338 | spec->vmaster_nid = 0x0c; |
4339 | ||
1da177e4 | 4340 | codec->patch_ops = alc_patch_ops; |
e9edcee0 | 4341 | if (board_config == ALC880_AUTO) |
ae6b813a | 4342 | spec->init_hook = alc880_auto_init; |
cb53c626 TI |
4343 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
4344 | if (!spec->loopback.amplist) | |
4345 | spec->loopback.amplist = alc880_loopbacks; | |
4346 | #endif | |
1da177e4 LT |
4347 | |
4348 | return 0; | |
4349 | } | |
4350 | ||
e9edcee0 | 4351 | |
1da177e4 LT |
4352 | /* |
4353 | * ALC260 support | |
4354 | */ | |
4355 | ||
e9edcee0 TI |
4356 | static hda_nid_t alc260_dac_nids[1] = { |
4357 | /* front */ | |
4358 | 0x02, | |
4359 | }; | |
4360 | ||
4361 | static hda_nid_t alc260_adc_nids[1] = { | |
4362 | /* ADC0 */ | |
4363 | 0x04, | |
4364 | }; | |
4365 | ||
df694daa | 4366 | static hda_nid_t alc260_adc_nids_alt[1] = { |
e9edcee0 TI |
4367 | /* ADC1 */ |
4368 | 0x05, | |
4369 | }; | |
4370 | ||
d57fdac0 JW |
4371 | /* NIDs used when simultaneous access to both ADCs makes sense. Note that |
4372 | * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC. | |
4373 | */ | |
4374 | static hda_nid_t alc260_dual_adc_nids[2] = { | |
4c5186ed JW |
4375 | /* ADC0, ADC1 */ |
4376 | 0x04, 0x05 | |
4377 | }; | |
4378 | ||
e9edcee0 TI |
4379 | #define ALC260_DIGOUT_NID 0x03 |
4380 | #define ALC260_DIGIN_NID 0x06 | |
4381 | ||
4382 | static struct hda_input_mux alc260_capture_source = { | |
4383 | .num_items = 4, | |
4384 | .items = { | |
4385 | { "Mic", 0x0 }, | |
4386 | { "Front Mic", 0x1 }, | |
4387 | { "Line", 0x2 }, | |
4388 | { "CD", 0x4 }, | |
4389 | }, | |
4390 | }; | |
4391 | ||
17e7aec6 | 4392 | /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack, |
a1e8d2da JW |
4393 | * headphone jack and the internal CD lines since these are the only pins at |
4394 | * which audio can appear. For flexibility, also allow the option of | |
4395 | * recording the mixer output on the second ADC (ADC0 doesn't have a | |
4396 | * connection to the mixer output). | |
a9430dd8 | 4397 | */ |
a1e8d2da JW |
4398 | static struct hda_input_mux alc260_fujitsu_capture_sources[2] = { |
4399 | { | |
4400 | .num_items = 3, | |
4401 | .items = { | |
4402 | { "Mic/Line", 0x0 }, | |
4403 | { "CD", 0x4 }, | |
4404 | { "Headphone", 0x2 }, | |
4405 | }, | |
a9430dd8 | 4406 | }, |
a1e8d2da JW |
4407 | { |
4408 | .num_items = 4, | |
4409 | .items = { | |
4410 | { "Mic/Line", 0x0 }, | |
4411 | { "CD", 0x4 }, | |
4412 | { "Headphone", 0x2 }, | |
4413 | { "Mixer", 0x5 }, | |
4414 | }, | |
4415 | }, | |
4416 | ||
a9430dd8 JW |
4417 | }; |
4418 | ||
a1e8d2da JW |
4419 | /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to |
4420 | * the Fujitsu S702x, but jacks are marked differently. | |
0bfc90e9 | 4421 | */ |
a1e8d2da JW |
4422 | static struct hda_input_mux alc260_acer_capture_sources[2] = { |
4423 | { | |
4424 | .num_items = 4, | |
4425 | .items = { | |
4426 | { "Mic", 0x0 }, | |
4427 | { "Line", 0x2 }, | |
4428 | { "CD", 0x4 }, | |
4429 | { "Headphone", 0x5 }, | |
4430 | }, | |
4431 | }, | |
4432 | { | |
4433 | .num_items = 5, | |
4434 | .items = { | |
4435 | { "Mic", 0x0 }, | |
4436 | { "Line", 0x2 }, | |
4437 | { "CD", 0x4 }, | |
4438 | { "Headphone", 0x6 }, | |
4439 | { "Mixer", 0x5 }, | |
4440 | }, | |
0bfc90e9 JW |
4441 | }, |
4442 | }; | |
1da177e4 LT |
4443 | /* |
4444 | * This is just place-holder, so there's something for alc_build_pcms to look | |
4445 | * at when it calculates the maximum number of channels. ALC260 has no mixer | |
4446 | * element which allows changing the channel mode, so the verb list is | |
4447 | * never used. | |
4448 | */ | |
d2a6d7dc | 4449 | static struct hda_channel_mode alc260_modes[1] = { |
1da177e4 LT |
4450 | { 2, NULL }, |
4451 | }; | |
4452 | ||
df694daa KY |
4453 | |
4454 | /* Mixer combinations | |
4455 | * | |
4456 | * basic: base_output + input + pc_beep + capture | |
4457 | * HP: base_output + input + capture_alt | |
4458 | * HP_3013: hp_3013 + input + capture | |
4459 | * fujitsu: fujitsu + capture | |
0bfc90e9 | 4460 | * acer: acer + capture |
df694daa KY |
4461 | */ |
4462 | ||
4463 | static struct snd_kcontrol_new alc260_base_output_mixer[] = { | |
05acb863 | 4464 | HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
985be54b | 4465 | HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), |
05acb863 | 4466 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
985be54b | 4467 | HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), |
05acb863 | 4468 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
985be54b | 4469 | HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), |
1da177e4 | 4470 | { } /* end */ |
f12ab1e0 | 4471 | }; |
1da177e4 | 4472 | |
df694daa | 4473 | static struct snd_kcontrol_new alc260_input_mixer[] = { |
16ded525 TI |
4474 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
4475 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
4476 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4477 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4478 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4479 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4480 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT), | |
4481 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT), | |
df694daa KY |
4482 | { } /* end */ |
4483 | }; | |
4484 | ||
4485 | static struct snd_kcontrol_new alc260_pc_beep_mixer[] = { | |
4486 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT), | |
4487 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT), | |
4488 | { } /* end */ | |
4489 | }; | |
4490 | ||
bec15c3a TI |
4491 | /* update HP, line and mono out pins according to the master switch */ |
4492 | static void alc260_hp_master_update(struct hda_codec *codec, | |
4493 | hda_nid_t hp, hda_nid_t line, | |
4494 | hda_nid_t mono) | |
4495 | { | |
4496 | struct alc_spec *spec = codec->spec; | |
4497 | unsigned int val = spec->master_sw ? PIN_HP : 0; | |
4498 | /* change HP and line-out pins */ | |
30cde0aa | 4499 | snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
bec15c3a | 4500 | val); |
30cde0aa | 4501 | snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
bec15c3a TI |
4502 | val); |
4503 | /* mono (speaker) depending on the HP jack sense */ | |
4504 | val = (val && !spec->jack_present) ? PIN_OUT : 0; | |
30cde0aa | 4505 | snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
bec15c3a TI |
4506 | val); |
4507 | } | |
4508 | ||
4509 | static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol, | |
4510 | struct snd_ctl_elem_value *ucontrol) | |
4511 | { | |
4512 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
4513 | struct alc_spec *spec = codec->spec; | |
4514 | *ucontrol->value.integer.value = spec->master_sw; | |
4515 | return 0; | |
4516 | } | |
4517 | ||
4518 | static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |
4519 | struct snd_ctl_elem_value *ucontrol) | |
4520 | { | |
4521 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
4522 | struct alc_spec *spec = codec->spec; | |
4523 | int val = !!*ucontrol->value.integer.value; | |
4524 | hda_nid_t hp, line, mono; | |
4525 | ||
4526 | if (val == spec->master_sw) | |
4527 | return 0; | |
4528 | spec->master_sw = val; | |
4529 | hp = (kcontrol->private_value >> 16) & 0xff; | |
4530 | line = (kcontrol->private_value >> 8) & 0xff; | |
4531 | mono = kcontrol->private_value & 0xff; | |
4532 | alc260_hp_master_update(codec, hp, line, mono); | |
4533 | return 1; | |
4534 | } | |
4535 | ||
4536 | static struct snd_kcontrol_new alc260_hp_output_mixer[] = { | |
4537 | { | |
4538 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
4539 | .name = "Master Playback Switch", | |
4540 | .info = snd_ctl_boolean_mono_info, | |
4541 | .get = alc260_hp_master_sw_get, | |
4542 | .put = alc260_hp_master_sw_put, | |
4543 | .private_value = (0x0f << 16) | (0x10 << 8) | 0x11 | |
4544 | }, | |
4545 | HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4546 | HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), | |
4547 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), | |
4548 | HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), | |
4549 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, | |
4550 | HDA_OUTPUT), | |
4551 | HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT), | |
4552 | { } /* end */ | |
4553 | }; | |
4554 | ||
4555 | static struct hda_verb alc260_hp_unsol_verbs[] = { | |
4556 | {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
4557 | {}, | |
4558 | }; | |
4559 | ||
4560 | static void alc260_hp_automute(struct hda_codec *codec) | |
4561 | { | |
4562 | struct alc_spec *spec = codec->spec; | |
4563 | unsigned int present; | |
4564 | ||
4565 | present = snd_hda_codec_read(codec, 0x10, 0, | |
4566 | AC_VERB_GET_PIN_SENSE, 0); | |
4567 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; | |
4568 | alc260_hp_master_update(codec, 0x0f, 0x10, 0x11); | |
4569 | } | |
4570 | ||
4571 | static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res) | |
4572 | { | |
4573 | if ((res >> 26) == ALC880_HP_EVENT) | |
4574 | alc260_hp_automute(codec); | |
4575 | } | |
4576 | ||
df694daa | 4577 | static struct snd_kcontrol_new alc260_hp_3013_mixer[] = { |
bec15c3a TI |
4578 | { |
4579 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
4580 | .name = "Master Playback Switch", | |
4581 | .info = snd_ctl_boolean_mono_info, | |
4582 | .get = alc260_hp_master_sw_get, | |
4583 | .put = alc260_hp_master_sw_put, | |
30cde0aa | 4584 | .private_value = (0x15 << 16) | (0x10 << 8) | 0x11 |
bec15c3a | 4585 | }, |
df694daa KY |
4586 | HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
4587 | HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT), | |
4588 | HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT), | |
4589 | HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT), | |
4590 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4591 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
86cd9298 TI |
4592 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
4593 | HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT), | |
16ded525 TI |
4594 | { } /* end */ |
4595 | }; | |
4596 | ||
3f878308 KY |
4597 | static struct hda_bind_ctls alc260_dc7600_bind_master_vol = { |
4598 | .ops = &snd_hda_bind_vol, | |
4599 | .values = { | |
4600 | HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT), | |
4601 | HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT), | |
4602 | HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT), | |
4603 | 0 | |
4604 | }, | |
4605 | }; | |
4606 | ||
4607 | static struct hda_bind_ctls alc260_dc7600_bind_switch = { | |
4608 | .ops = &snd_hda_bind_sw, | |
4609 | .values = { | |
4610 | HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT), | |
4611 | HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | |
4612 | 0 | |
4613 | }, | |
4614 | }; | |
4615 | ||
4616 | static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = { | |
4617 | HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol), | |
4618 | HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch), | |
4619 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT), | |
4620 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT), | |
4621 | { } /* end */ | |
4622 | }; | |
4623 | ||
bec15c3a TI |
4624 | static struct hda_verb alc260_hp_3013_unsol_verbs[] = { |
4625 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
4626 | {}, | |
4627 | }; | |
4628 | ||
4629 | static void alc260_hp_3013_automute(struct hda_codec *codec) | |
4630 | { | |
4631 | struct alc_spec *spec = codec->spec; | |
4632 | unsigned int present; | |
4633 | ||
4634 | present = snd_hda_codec_read(codec, 0x15, 0, | |
4635 | AC_VERB_GET_PIN_SENSE, 0); | |
4636 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; | |
30cde0aa | 4637 | alc260_hp_master_update(codec, 0x15, 0x10, 0x11); |
bec15c3a TI |
4638 | } |
4639 | ||
4640 | static void alc260_hp_3013_unsol_event(struct hda_codec *codec, | |
4641 | unsigned int res) | |
4642 | { | |
4643 | if ((res >> 26) == ALC880_HP_EVENT) | |
4644 | alc260_hp_3013_automute(codec); | |
4645 | } | |
4646 | ||
3f878308 KY |
4647 | static void alc260_hp_3012_automute(struct hda_codec *codec) |
4648 | { | |
4649 | unsigned int present, bits; | |
4650 | ||
4651 | present = snd_hda_codec_read(codec, 0x10, 0, | |
4652 | AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE; | |
4653 | ||
4654 | bits = present ? 0 : PIN_OUT; | |
4655 | snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4656 | bits); | |
4657 | snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4658 | bits); | |
4659 | snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4660 | bits); | |
4661 | } | |
4662 | ||
4663 | static void alc260_hp_3012_unsol_event(struct hda_codec *codec, | |
4664 | unsigned int res) | |
4665 | { | |
4666 | if ((res >> 26) == ALC880_HP_EVENT) | |
4667 | alc260_hp_3012_automute(codec); | |
4668 | } | |
4669 | ||
4670 | /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12, | |
a1e8d2da JW |
4671 | * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10. |
4672 | */ | |
c8b6bf9b | 4673 | static struct snd_kcontrol_new alc260_fujitsu_mixer[] = { |
a9430dd8 | 4674 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
985be54b | 4675 | HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT), |
4c5186ed | 4676 | ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT), |
a9430dd8 JW |
4677 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
4678 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
4679 | HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4680 | HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4c5186ed | 4681 | ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN), |
a9430dd8 JW |
4682 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), |
4683 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
31bffaa9 TI |
4684 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
4685 | HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT), | |
df694daa KY |
4686 | { } /* end */ |
4687 | }; | |
4688 | ||
a1e8d2da JW |
4689 | /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current |
4690 | * versions of the ALC260 don't act on requests to enable mic bias from NID | |
4691 | * 0x0f (used to drive the headphone jack in these laptops). The ALC260 | |
4692 | * datasheet doesn't mention this restriction. At this stage it's not clear | |
4693 | * whether this behaviour is intentional or is a hardware bug in chip | |
4694 | * revisions available in early 2006. Therefore for now allow the | |
4695 | * "Headphone Jack Mode" control to span all choices, but if it turns out | |
4696 | * that the lack of mic bias for this NID is intentional we could change the | |
4697 | * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
4698 | * | |
4699 | * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006 | |
4700 | * don't appear to make the mic bias available from the "line" jack, even | |
4701 | * though the NID used for this jack (0x14) can supply it. The theory is | |
4702 | * that perhaps Acer have included blocking capacitors between the ALC260 | |
4703 | * and the output jack. If this turns out to be the case for all such | |
4704 | * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT | |
4705 | * to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
bd869485 JW |
4706 | * |
4707 | * The C20x Tablet series have a mono internal speaker which is controlled | |
4708 | * via the chip's Mono sum widget and pin complex, so include the necessary | |
4709 | * controls for such models. On models without a "mono speaker" the control | |
4710 | * won't do anything. | |
a1e8d2da | 4711 | */ |
0bfc90e9 JW |
4712 | static struct snd_kcontrol_new alc260_acer_mixer[] = { |
4713 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4714 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT), | |
a1e8d2da | 4715 | ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT), |
31bffaa9 | 4716 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, |
bd869485 | 4717 | HDA_OUTPUT), |
31bffaa9 | 4718 | HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, |
bd869485 | 4719 | HDA_INPUT), |
0bfc90e9 JW |
4720 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
4721 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
4722 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4723 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4724 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
4725 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4726 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4727 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
4728 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), | |
4729 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
4730 | { } /* end */ | |
4731 | }; | |
4732 | ||
bc9f98a9 KY |
4733 | /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12, |
4734 | * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17. | |
4735 | */ | |
4736 | static struct snd_kcontrol_new alc260_will_mixer[] = { | |
4737 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4738 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT), | |
4739 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4740 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4741 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
4742 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4743 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4744 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
4745 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), | |
4746 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
4747 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), | |
4748 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
4749 | { } /* end */ | |
4750 | }; | |
4751 | ||
4752 | /* Replacer 672V ALC260 pin usage: Mic jack = 0x12, | |
4753 | * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f. | |
4754 | */ | |
4755 | static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = { | |
4756 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4757 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT), | |
4758 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4759 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4760 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
4761 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT), | |
4762 | HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT), | |
4763 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4764 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4765 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
4766 | { } /* end */ | |
4767 | }; | |
4768 | ||
df694daa KY |
4769 | /* |
4770 | * initialization verbs | |
4771 | */ | |
1da177e4 LT |
4772 | static struct hda_verb alc260_init_verbs[] = { |
4773 | /* Line In pin widget for input */ | |
05acb863 | 4774 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 4775 | /* CD pin widget for input */ |
05acb863 | 4776 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 4777 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
16ded525 | 4778 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1da177e4 | 4779 | /* Mic2 (front panel) pin widget for input and vref at 80% */ |
16ded525 | 4780 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1da177e4 | 4781 | /* LINE-2 is used for line-out in rear */ |
05acb863 | 4782 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1da177e4 | 4783 | /* select line-out */ |
fd56f2db | 4784 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00}, |
1da177e4 | 4785 | /* LINE-OUT pin */ |
05acb863 | 4786 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1da177e4 | 4787 | /* enable HP */ |
05acb863 | 4788 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
1da177e4 | 4789 | /* enable Mono */ |
05acb863 TI |
4790 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
4791 | /* mute capture amp left and right */ | |
16ded525 | 4792 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1da177e4 LT |
4793 | /* set connection select to line in (default select for this ADC) */ |
4794 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
16ded525 TI |
4795 | /* mute capture amp left and right */ |
4796 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4797 | /* set connection select to line in (default select for this ADC) */ | |
4798 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
05acb863 TI |
4799 | /* set vol=0 Line-Out mixer amp left and right */ |
4800 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4801 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
4802 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4803 | /* set vol=0 HP mixer amp left and right */ | |
4804 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4805 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
4806 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4807 | /* set vol=0 Mono mixer amp left and right */ | |
4808 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4809 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
4810 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4811 | /* unmute LINE-2 out pin */ | |
4812 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
f12ab1e0 TI |
4813 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
4814 | * Line In 2 = 0x03 | |
4815 | */ | |
cb53c626 TI |
4816 | /* mute analog inputs */ |
4817 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4818 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4819 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4820 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4821 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 4822 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
05acb863 TI |
4823 | /* mute Front out path */ |
4824 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4825 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4826 | /* mute Headphone out path */ | |
4827 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4828 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4829 | /* mute Mono out path */ | |
4830 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4831 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 LT |
4832 | { } |
4833 | }; | |
4834 | ||
474167d6 | 4835 | #if 0 /* should be identical with alc260_init_verbs? */ |
df694daa KY |
4836 | static struct hda_verb alc260_hp_init_verbs[] = { |
4837 | /* Headphone and output */ | |
4838 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
4839 | /* mono output */ | |
4840 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
4841 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
4842 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
4843 | /* Mic2 (front panel) pin widget for input and vref at 80% */ | |
4844 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
4845 | /* Line In pin widget for input */ | |
4846 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
4847 | /* Line-2 pin widget for output */ | |
4848 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
4849 | /* CD pin widget for input */ | |
4850 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
4851 | /* unmute amp left and right */ | |
4852 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | |
4853 | /* set connection select to line in (default select for this ADC) */ | |
4854 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
4855 | /* unmute Line-Out mixer amp left and right (volume = 0) */ | |
4856 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
4857 | /* mute pin widget amp left and right (no gain on this amp) */ | |
4858 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
4859 | /* unmute HP mixer amp left and right (volume = 0) */ | |
4860 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
4861 | /* mute pin widget amp left and right (no gain on this amp) */ | |
4862 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
f12ab1e0 TI |
4863 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
4864 | * Line In 2 = 0x03 | |
4865 | */ | |
cb53c626 TI |
4866 | /* mute analog inputs */ |
4867 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4868 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4869 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4870 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4871 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
4872 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
4873 | /* Unmute Front out path */ | |
4874 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4875 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4876 | /* Unmute Headphone out path */ | |
4877 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4878 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4879 | /* Unmute Mono out path */ | |
4880 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4881 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4882 | { } | |
4883 | }; | |
474167d6 | 4884 | #endif |
df694daa KY |
4885 | |
4886 | static struct hda_verb alc260_hp_3013_init_verbs[] = { | |
4887 | /* Line out and output */ | |
4888 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
4889 | /* mono output */ | |
4890 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
4891 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
4892 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
4893 | /* Mic2 (front panel) pin widget for input and vref at 80% */ | |
4894 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
4895 | /* Line In pin widget for input */ | |
4896 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
4897 | /* Headphone pin widget for output */ | |
4898 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
4899 | /* CD pin widget for input */ | |
4900 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
4901 | /* unmute amp left and right */ | |
4902 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | |
4903 | /* set connection select to line in (default select for this ADC) */ | |
4904 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
4905 | /* unmute Line-Out mixer amp left and right (volume = 0) */ | |
4906 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
4907 | /* mute pin widget amp left and right (no gain on this amp) */ | |
4908 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
4909 | /* unmute HP mixer amp left and right (volume = 0) */ | |
4910 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
4911 | /* mute pin widget amp left and right (no gain on this amp) */ | |
4912 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
f12ab1e0 TI |
4913 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
4914 | * Line In 2 = 0x03 | |
4915 | */ | |
cb53c626 TI |
4916 | /* mute analog inputs */ |
4917 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4918 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4919 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4920 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4921 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
4922 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
4923 | /* Unmute Front out path */ | |
4924 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4925 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4926 | /* Unmute Headphone out path */ | |
4927 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4928 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4929 | /* Unmute Mono out path */ | |
4930 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4931 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4932 | { } | |
4933 | }; | |
4934 | ||
a9430dd8 | 4935 | /* Initialisation sequence for ALC260 as configured in Fujitsu S702x |
a1e8d2da JW |
4936 | * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD |
4937 | * audio = 0x16, internal speaker = 0x10. | |
a9430dd8 JW |
4938 | */ |
4939 | static struct hda_verb alc260_fujitsu_init_verbs[] = { | |
4940 | /* Disable all GPIOs */ | |
4941 | {0x01, AC_VERB_SET_GPIO_MASK, 0}, | |
4942 | /* Internal speaker is connected to headphone pin */ | |
4943 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
4944 | /* Headphone/Line-out jack connects to Line1 pin; make it an output */ | |
4945 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
f7ace40d JW |
4946 | /* Mic/Line-in jack is connected to mic1 pin, so make it an input */ |
4947 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
4948 | /* Ensure all other unused pins are disabled and muted. */ | |
4949 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
4950 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
a9430dd8 | 4951 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
f7ace40d | 4952 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
a9430dd8 | 4953 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
f7ace40d JW |
4954 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
4955 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
4956 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4957 | ||
4958 | /* Disable digital (SPDIF) pins */ | |
4959 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
4960 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
a9430dd8 | 4961 | |
ea1fb29a | 4962 | /* Ensure Line1 pin widget takes its input from the OUT1 sum bus |
f7ace40d JW |
4963 | * when acting as an output. |
4964 | */ | |
4965 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
4c5186ed | 4966 | |
f7ace40d | 4967 | /* Start with output sum widgets muted and their output gains at min */ |
8b33a5aa TI |
4968 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
4969 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4970 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4971 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4972 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4973 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4974 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4975 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4976 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
a9430dd8 | 4977 | |
f7ace40d JW |
4978 | /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */ |
4979 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4980 | /* Unmute Line1 pin widget output buffer since it starts as an output. | |
4981 | * If the pin mode is changed by the user the pin mode control will | |
4982 | * take care of enabling the pin's input/output buffers as needed. | |
4983 | * Therefore there's no need to enable the input buffer at this | |
4984 | * stage. | |
cdcd9268 | 4985 | */ |
f7ace40d | 4986 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
ea1fb29a | 4987 | /* Unmute input buffer of pin widget used for Line-in (no equiv |
cdcd9268 JW |
4988 | * mixer ctrl) |
4989 | */ | |
f7ace40d JW |
4990 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
4991 | ||
4992 | /* Mute capture amp left and right */ | |
4993 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
ea1fb29a | 4994 | /* Set ADC connection select to match default mixer setting - line |
f7ace40d JW |
4995 | * in (on mic1 pin) |
4996 | */ | |
4997 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4998 | ||
4999 | /* Do the same for the second ADC: mute capture input amp and | |
5000 | * set ADC connection to line in (on mic1 pin) | |
5001 | */ | |
5002 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5003 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5004 | ||
5005 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
5006 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
5007 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
5008 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
5009 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
5010 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
5011 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
5012 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
5013 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
4a471b7d TI |
5014 | |
5015 | { } | |
a9430dd8 JW |
5016 | }; |
5017 | ||
0bfc90e9 JW |
5018 | /* Initialisation sequence for ALC260 as configured in Acer TravelMate and |
5019 | * similar laptops (adapted from Fujitsu init verbs). | |
5020 | */ | |
5021 | static struct hda_verb alc260_acer_init_verbs[] = { | |
5022 | /* On TravelMate laptops, GPIO 0 enables the internal speaker and | |
5023 | * the headphone jack. Turn this on and rely on the standard mute | |
5024 | * methods whenever the user wants to turn these outputs off. | |
5025 | */ | |
5026 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
5027 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
5028 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, | |
5029 | /* Internal speaker/Headphone jack is connected to Line-out pin */ | |
5030 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5031 | /* Internal microphone/Mic jack is connected to Mic1 pin */ | |
5032 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | |
5033 | /* Line In jack is connected to Line1 pin */ | |
5034 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
bd869485 JW |
5035 | /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */ |
5036 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
0bfc90e9 JW |
5037 | /* Ensure all other unused pins are disabled and muted. */ |
5038 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
5039 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
0bfc90e9 JW |
5040 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
5041 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5042 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
5043 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5044 | /* Disable digital (SPDIF) pins */ | |
5045 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
5046 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
5047 | ||
ea1fb29a | 5048 | /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum |
0bfc90e9 JW |
5049 | * bus when acting as outputs. |
5050 | */ | |
5051 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, | |
5052 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
5053 | ||
5054 | /* Start with output sum widgets muted and their output gains at min */ | |
5055 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5056 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5057 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5058 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5059 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5060 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5061 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5062 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5063 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5064 | ||
f12ab1e0 TI |
5065 | /* Unmute Line-out pin widget amp left and right |
5066 | * (no equiv mixer ctrl) | |
5067 | */ | |
0bfc90e9 | 5068 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
bd869485 JW |
5069 | /* Unmute mono pin widget amp output (no equiv mixer ctrl) */ |
5070 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
0bfc90e9 JW |
5071 | /* Unmute Mic1 and Line1 pin widget input buffers since they start as |
5072 | * inputs. If the pin mode is changed by the user the pin mode control | |
5073 | * will take care of enabling the pin's input/output buffers as needed. | |
5074 | * Therefore there's no need to enable the input buffer at this | |
5075 | * stage. | |
5076 | */ | |
5077 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5078 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5079 | ||
5080 | /* Mute capture amp left and right */ | |
5081 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5082 | /* Set ADC connection select to match default mixer setting - mic | |
5083 | * (on mic1 pin) | |
5084 | */ | |
5085 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5086 | ||
5087 | /* Do similar with the second ADC: mute capture input amp and | |
a1e8d2da | 5088 | * set ADC connection to mic to match ALSA's default state. |
0bfc90e9 JW |
5089 | */ |
5090 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
a1e8d2da | 5091 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, |
0bfc90e9 JW |
5092 | |
5093 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
5094 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
5095 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
5096 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
5097 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
5098 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
5099 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
5100 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
5101 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
5102 | ||
5103 | { } | |
5104 | }; | |
5105 | ||
bc9f98a9 KY |
5106 | static struct hda_verb alc260_will_verbs[] = { |
5107 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5108 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5109 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5110 | {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, | |
5111 | {0x1a, AC_VERB_SET_COEF_INDEX, 0x07}, | |
5112 | {0x1a, AC_VERB_SET_PROC_COEF, 0x3040}, | |
5113 | {} | |
5114 | }; | |
5115 | ||
5116 | static struct hda_verb alc260_replacer_672v_verbs[] = { | |
5117 | {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, | |
5118 | {0x1a, AC_VERB_SET_COEF_INDEX, 0x07}, | |
5119 | {0x1a, AC_VERB_SET_PROC_COEF, 0x3050}, | |
5120 | ||
5121 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
5122 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
5123 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, | |
5124 | ||
5125 | {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
5126 | {} | |
5127 | }; | |
5128 | ||
5129 | /* toggle speaker-output according to the hp-jack state */ | |
5130 | static void alc260_replacer_672v_automute(struct hda_codec *codec) | |
5131 | { | |
5132 | unsigned int present; | |
5133 | ||
5134 | /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */ | |
5135 | present = snd_hda_codec_read(codec, 0x0f, 0, | |
5136 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
5137 | if (present) { | |
82beb8fd TI |
5138 | snd_hda_codec_write_cache(codec, 0x01, 0, |
5139 | AC_VERB_SET_GPIO_DATA, 1); | |
5140 | snd_hda_codec_write_cache(codec, 0x0f, 0, | |
5141 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
5142 | PIN_HP); | |
bc9f98a9 | 5143 | } else { |
82beb8fd TI |
5144 | snd_hda_codec_write_cache(codec, 0x01, 0, |
5145 | AC_VERB_SET_GPIO_DATA, 0); | |
5146 | snd_hda_codec_write_cache(codec, 0x0f, 0, | |
5147 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
5148 | PIN_OUT); | |
bc9f98a9 KY |
5149 | } |
5150 | } | |
5151 | ||
5152 | static void alc260_replacer_672v_unsol_event(struct hda_codec *codec, | |
5153 | unsigned int res) | |
5154 | { | |
5155 | if ((res >> 26) == ALC880_HP_EVENT) | |
5156 | alc260_replacer_672v_automute(codec); | |
5157 | } | |
5158 | ||
3f878308 KY |
5159 | static struct hda_verb alc260_hp_dc7600_verbs[] = { |
5160 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
5161 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
5162 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5163 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5164 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5165 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5166 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
5167 | {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
5168 | {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
5169 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
5170 | {} | |
5171 | }; | |
5172 | ||
7cf51e48 JW |
5173 | /* Test configuration for debugging, modelled after the ALC880 test |
5174 | * configuration. | |
5175 | */ | |
5176 | #ifdef CONFIG_SND_DEBUG | |
5177 | static hda_nid_t alc260_test_dac_nids[1] = { | |
5178 | 0x02, | |
5179 | }; | |
5180 | static hda_nid_t alc260_test_adc_nids[2] = { | |
5181 | 0x04, 0x05, | |
5182 | }; | |
a1e8d2da | 5183 | /* For testing the ALC260, each input MUX needs its own definition since |
ea1fb29a | 5184 | * the signal assignments are different. This assumes that the first ADC |
a1e8d2da | 5185 | * is NID 0x04. |
17e7aec6 | 5186 | */ |
a1e8d2da JW |
5187 | static struct hda_input_mux alc260_test_capture_sources[2] = { |
5188 | { | |
5189 | .num_items = 7, | |
5190 | .items = { | |
5191 | { "MIC1 pin", 0x0 }, | |
5192 | { "MIC2 pin", 0x1 }, | |
5193 | { "LINE1 pin", 0x2 }, | |
5194 | { "LINE2 pin", 0x3 }, | |
5195 | { "CD pin", 0x4 }, | |
5196 | { "LINE-OUT pin", 0x5 }, | |
5197 | { "HP-OUT pin", 0x6 }, | |
5198 | }, | |
5199 | }, | |
5200 | { | |
5201 | .num_items = 8, | |
5202 | .items = { | |
5203 | { "MIC1 pin", 0x0 }, | |
5204 | { "MIC2 pin", 0x1 }, | |
5205 | { "LINE1 pin", 0x2 }, | |
5206 | { "LINE2 pin", 0x3 }, | |
5207 | { "CD pin", 0x4 }, | |
5208 | { "Mixer", 0x5 }, | |
5209 | { "LINE-OUT pin", 0x6 }, | |
5210 | { "HP-OUT pin", 0x7 }, | |
5211 | }, | |
7cf51e48 JW |
5212 | }, |
5213 | }; | |
5214 | static struct snd_kcontrol_new alc260_test_mixer[] = { | |
5215 | /* Output driver widgets */ | |
5216 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), | |
5217 | HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), | |
5218 | HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT), | |
5219 | HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT), | |
5220 | HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
5221 | HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT), | |
5222 | ||
a1e8d2da JW |
5223 | /* Modes for retasking pin widgets |
5224 | * Note: the ALC260 doesn't seem to act on requests to enable mic | |
5225 | * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't | |
5226 | * mention this restriction. At this stage it's not clear whether | |
5227 | * this behaviour is intentional or is a hardware bug in chip | |
5228 | * revisions available at least up until early 2006. Therefore for | |
5229 | * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all | |
5230 | * choices, but if it turns out that the lack of mic bias for these | |
5231 | * NIDs is intentional we could change their modes from | |
5232 | * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
5233 | */ | |
7cf51e48 JW |
5234 | ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT), |
5235 | ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT), | |
5236 | ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT), | |
5237 | ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT), | |
5238 | ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT), | |
5239 | ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT), | |
5240 | ||
5241 | /* Loopback mixer controls */ | |
5242 | HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT), | |
5243 | HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT), | |
5244 | HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT), | |
5245 | HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT), | |
5246 | HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT), | |
5247 | HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT), | |
5248 | HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT), | |
5249 | HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT), | |
5250 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), | |
5251 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
5252 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), | |
5253 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
5254 | HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT), | |
5255 | HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT), | |
5256 | HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT), | |
5257 | HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT), | |
5c8f858d JW |
5258 | |
5259 | /* Controls for GPIO pins, assuming they are configured as outputs */ | |
5260 | ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01), | |
5261 | ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02), | |
5262 | ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04), | |
5263 | ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08), | |
5264 | ||
92621f13 JW |
5265 | /* Switches to allow the digital IO pins to be enabled. The datasheet |
5266 | * is ambigious as to which NID is which; testing on laptops which | |
ea1fb29a | 5267 | * make this output available should provide clarification. |
92621f13 JW |
5268 | */ |
5269 | ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01), | |
5270 | ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01), | |
5271 | ||
f8225f6d JW |
5272 | /* A switch allowing EAPD to be enabled. Some laptops seem to use |
5273 | * this output to turn on an external amplifier. | |
5274 | */ | |
5275 | ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02), | |
5276 | ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02), | |
5277 | ||
7cf51e48 JW |
5278 | { } /* end */ |
5279 | }; | |
5280 | static struct hda_verb alc260_test_init_verbs[] = { | |
5c8f858d JW |
5281 | /* Enable all GPIOs as outputs with an initial value of 0 */ |
5282 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f}, | |
5283 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, | |
5284 | {0x01, AC_VERB_SET_GPIO_MASK, 0x0f}, | |
5285 | ||
7cf51e48 JW |
5286 | /* Enable retasking pins as output, initially without power amp */ |
5287 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5288 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5289 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5290 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5291 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5292 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5293 | ||
92621f13 JW |
5294 | /* Disable digital (SPDIF) pins initially, but users can enable |
5295 | * them via a mixer switch. In the case of SPDIF-out, this initverb | |
5296 | * payload also sets the generation to 0, output to be in "consumer" | |
5297 | * PCM format, copyright asserted, no pre-emphasis and no validity | |
5298 | * control. | |
5299 | */ | |
7cf51e48 JW |
5300 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, |
5301 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
5302 | ||
ea1fb29a | 5303 | /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the |
7cf51e48 JW |
5304 | * OUT1 sum bus when acting as an output. |
5305 | */ | |
5306 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, | |
5307 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0}, | |
5308 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
5309 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0}, | |
5310 | ||
5311 | /* Start with output sum widgets muted and their output gains at min */ | |
5312 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5313 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5314 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5315 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5316 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5317 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5318 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5319 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5320 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5321 | ||
cdcd9268 JW |
5322 | /* Unmute retasking pin widget output buffers since the default |
5323 | * state appears to be output. As the pin mode is changed by the | |
5324 | * user the pin mode control will take care of enabling the pin's | |
5325 | * input/output buffers as needed. | |
5326 | */ | |
7cf51e48 JW |
5327 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
5328 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5329 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5330 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5331 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5332 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5333 | /* Also unmute the mono-out pin widget */ | |
5334 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5335 | ||
7cf51e48 JW |
5336 | /* Mute capture amp left and right */ |
5337 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
f7ace40d JW |
5338 | /* Set ADC connection select to match default mixer setting (mic1 |
5339 | * pin) | |
7cf51e48 JW |
5340 | */ |
5341 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5342 | ||
5343 | /* Do the same for the second ADC: mute capture input amp and | |
f7ace40d | 5344 | * set ADC connection to mic1 pin |
7cf51e48 JW |
5345 | */ |
5346 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5347 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5348 | ||
5349 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
5350 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
5351 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
5352 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
5353 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
5354 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
5355 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
5356 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
5357 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
5358 | ||
5359 | { } | |
5360 | }; | |
5361 | #endif | |
5362 | ||
6330079f TI |
5363 | #define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback |
5364 | #define alc260_pcm_analog_capture alc880_pcm_analog_capture | |
1da177e4 | 5365 | |
a3bcba38 TI |
5366 | #define alc260_pcm_digital_playback alc880_pcm_digital_playback |
5367 | #define alc260_pcm_digital_capture alc880_pcm_digital_capture | |
5368 | ||
df694daa KY |
5369 | /* |
5370 | * for BIOS auto-configuration | |
5371 | */ | |
16ded525 | 5372 | |
df694daa | 5373 | static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid, |
863b4518 | 5374 | const char *pfx, int *vol_bits) |
df694daa KY |
5375 | { |
5376 | hda_nid_t nid_vol; | |
5377 | unsigned long vol_val, sw_val; | |
5378 | char name[32]; | |
5379 | int err; | |
5380 | ||
5381 | if (nid >= 0x0f && nid < 0x11) { | |
5382 | nid_vol = nid - 0x7; | |
5383 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); | |
5384 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); | |
5385 | } else if (nid == 0x11) { | |
5386 | nid_vol = nid - 0x7; | |
5387 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT); | |
5388 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT); | |
5389 | } else if (nid >= 0x12 && nid <= 0x15) { | |
5390 | nid_vol = 0x08; | |
5391 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); | |
5392 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); | |
5393 | } else | |
5394 | return 0; /* N/A */ | |
ea1fb29a | 5395 | |
863b4518 TI |
5396 | if (!(*vol_bits & (1 << nid_vol))) { |
5397 | /* first control for the volume widget */ | |
5398 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); | |
5399 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val); | |
5400 | if (err < 0) | |
5401 | return err; | |
5402 | *vol_bits |= (1 << nid_vol); | |
5403 | } | |
df694daa | 5404 | snprintf(name, sizeof(name), "%s Playback Switch", pfx); |
f12ab1e0 TI |
5405 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val); |
5406 | if (err < 0) | |
df694daa KY |
5407 | return err; |
5408 | return 1; | |
5409 | } | |
5410 | ||
5411 | /* add playback controls from the parsed DAC table */ | |
5412 | static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec, | |
5413 | const struct auto_pin_cfg *cfg) | |
5414 | { | |
5415 | hda_nid_t nid; | |
5416 | int err; | |
863b4518 | 5417 | int vols = 0; |
df694daa KY |
5418 | |
5419 | spec->multiout.num_dacs = 1; | |
5420 | spec->multiout.dac_nids = spec->private_dac_nids; | |
5421 | spec->multiout.dac_nids[0] = 0x02; | |
5422 | ||
5423 | nid = cfg->line_out_pins[0]; | |
5424 | if (nid) { | |
863b4518 | 5425 | err = alc260_add_playback_controls(spec, nid, "Front", &vols); |
df694daa KY |
5426 | if (err < 0) |
5427 | return err; | |
5428 | } | |
5429 | ||
82bc955f | 5430 | nid = cfg->speaker_pins[0]; |
df694daa | 5431 | if (nid) { |
863b4518 | 5432 | err = alc260_add_playback_controls(spec, nid, "Speaker", &vols); |
df694daa KY |
5433 | if (err < 0) |
5434 | return err; | |
5435 | } | |
5436 | ||
eb06ed8f | 5437 | nid = cfg->hp_pins[0]; |
df694daa | 5438 | if (nid) { |
863b4518 TI |
5439 | err = alc260_add_playback_controls(spec, nid, "Headphone", |
5440 | &vols); | |
df694daa KY |
5441 | if (err < 0) |
5442 | return err; | |
5443 | } | |
f12ab1e0 | 5444 | return 0; |
df694daa KY |
5445 | } |
5446 | ||
5447 | /* create playback/capture controls for input pins */ | |
5448 | static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec, | |
5449 | const struct auto_pin_cfg *cfg) | |
5450 | { | |
df694daa KY |
5451 | struct hda_input_mux *imux = &spec->private_imux; |
5452 | int i, err, idx; | |
5453 | ||
5454 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
5455 | if (cfg->input_pins[i] >= 0x12) { | |
5456 | idx = cfg->input_pins[i] - 0x12; | |
4a471b7d | 5457 | err = new_analog_input(spec, cfg->input_pins[i], |
f12ab1e0 TI |
5458 | auto_pin_cfg_labels[i], idx, |
5459 | 0x07); | |
df694daa KY |
5460 | if (err < 0) |
5461 | return err; | |
f12ab1e0 TI |
5462 | imux->items[imux->num_items].label = |
5463 | auto_pin_cfg_labels[i]; | |
df694daa KY |
5464 | imux->items[imux->num_items].index = idx; |
5465 | imux->num_items++; | |
5466 | } | |
f12ab1e0 | 5467 | if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){ |
df694daa | 5468 | idx = cfg->input_pins[i] - 0x09; |
4a471b7d | 5469 | err = new_analog_input(spec, cfg->input_pins[i], |
f12ab1e0 TI |
5470 | auto_pin_cfg_labels[i], idx, |
5471 | 0x07); | |
df694daa KY |
5472 | if (err < 0) |
5473 | return err; | |
f12ab1e0 TI |
5474 | imux->items[imux->num_items].label = |
5475 | auto_pin_cfg_labels[i]; | |
df694daa KY |
5476 | imux->items[imux->num_items].index = idx; |
5477 | imux->num_items++; | |
5478 | } | |
5479 | } | |
5480 | return 0; | |
5481 | } | |
5482 | ||
5483 | static void alc260_auto_set_output_and_unmute(struct hda_codec *codec, | |
5484 | hda_nid_t nid, int pin_type, | |
5485 | int sel_idx) | |
5486 | { | |
f6c7e546 | 5487 | alc_set_pin_output(codec, nid, pin_type); |
df694daa KY |
5488 | /* need the manual connection? */ |
5489 | if (nid >= 0x12) { | |
5490 | int idx = nid - 0x12; | |
5491 | snd_hda_codec_write(codec, idx + 0x0b, 0, | |
5492 | AC_VERB_SET_CONNECT_SEL, sel_idx); | |
df694daa KY |
5493 | } |
5494 | } | |
5495 | ||
5496 | static void alc260_auto_init_multi_out(struct hda_codec *codec) | |
5497 | { | |
5498 | struct alc_spec *spec = codec->spec; | |
5499 | hda_nid_t nid; | |
5500 | ||
bc9f98a9 | 5501 | alc_subsystem_id(codec, 0x10, 0x15, 0x0f); |
f12ab1e0 | 5502 | nid = spec->autocfg.line_out_pins[0]; |
baba8ee9 TI |
5503 | if (nid) { |
5504 | int pin_type = get_pin_type(spec->autocfg.line_out_type); | |
5505 | alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0); | |
5506 | } | |
ea1fb29a | 5507 | |
82bc955f | 5508 | nid = spec->autocfg.speaker_pins[0]; |
df694daa KY |
5509 | if (nid) |
5510 | alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); | |
5511 | ||
eb06ed8f | 5512 | nid = spec->autocfg.hp_pins[0]; |
df694daa | 5513 | if (nid) |
baba8ee9 | 5514 | alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0); |
f12ab1e0 | 5515 | } |
df694daa KY |
5516 | |
5517 | #define ALC260_PIN_CD_NID 0x16 | |
5518 | static void alc260_auto_init_analog_input(struct hda_codec *codec) | |
5519 | { | |
5520 | struct alc_spec *spec = codec->spec; | |
5521 | int i; | |
5522 | ||
5523 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
5524 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
5525 | if (nid >= 0x12) { | |
f12ab1e0 TI |
5526 | snd_hda_codec_write(codec, nid, 0, |
5527 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
5528 | i <= AUTO_PIN_FRONT_MIC ? | |
5529 | PIN_VREF80 : PIN_IN); | |
df694daa | 5530 | if (nid != ALC260_PIN_CD_NID) |
f12ab1e0 TI |
5531 | snd_hda_codec_write(codec, nid, 0, |
5532 | AC_VERB_SET_AMP_GAIN_MUTE, | |
df694daa KY |
5533 | AMP_OUT_MUTE); |
5534 | } | |
5535 | } | |
5536 | } | |
5537 | ||
5538 | /* | |
5539 | * generic initialization of ADC, input mixers and output mixers | |
5540 | */ | |
5541 | static struct hda_verb alc260_volume_init_verbs[] = { | |
5542 | /* | |
5543 | * Unmute ADC0-1 and set the default input to mic-in | |
5544 | */ | |
5545 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5546 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5547 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5548 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
ea1fb29a | 5549 | |
df694daa KY |
5550 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
5551 | * mixer widget | |
f12ab1e0 TI |
5552 | * Note: PASD motherboards uses the Line In 2 as the input for |
5553 | * front panel mic (mic 2) | |
df694daa KY |
5554 | */ |
5555 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
5556 | /* mute analog inputs */ |
5557 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5558 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5559 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5560 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5561 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
5562 | |
5563 | /* | |
5564 | * Set up output mixers (0x08 - 0x0a) | |
5565 | */ | |
5566 | /* set vol=0 to output mixers */ | |
5567 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5568 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5569 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5570 | /* set up input amps for analog loopback */ | |
5571 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
5572 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5573 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5574 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5575 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5576 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5577 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
ea1fb29a | 5578 | |
df694daa KY |
5579 | { } |
5580 | }; | |
5581 | ||
5582 | static int alc260_parse_auto_config(struct hda_codec *codec) | |
5583 | { | |
5584 | struct alc_spec *spec = codec->spec; | |
df694daa KY |
5585 | int err; |
5586 | static hda_nid_t alc260_ignore[] = { 0x17, 0 }; | |
5587 | ||
f12ab1e0 TI |
5588 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
5589 | alc260_ignore); | |
5590 | if (err < 0) | |
df694daa | 5591 | return err; |
f12ab1e0 TI |
5592 | err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg); |
5593 | if (err < 0) | |
4a471b7d | 5594 | return err; |
603c4019 | 5595 | if (!spec->kctls.list) |
df694daa | 5596 | return 0; /* can't find valid BIOS pin config */ |
f12ab1e0 TI |
5597 | err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg); |
5598 | if (err < 0) | |
df694daa KY |
5599 | return err; |
5600 | ||
5601 | spec->multiout.max_channels = 2; | |
5602 | ||
5603 | if (spec->autocfg.dig_out_pin) | |
5604 | spec->multiout.dig_out_nid = ALC260_DIGOUT_NID; | |
603c4019 | 5605 | if (spec->kctls.list) |
d88897ea | 5606 | add_mixer(spec, spec->kctls.list); |
df694daa | 5607 | |
d88897ea | 5608 | add_verb(spec, alc260_volume_init_verbs); |
df694daa | 5609 | |
a1e8d2da | 5610 | spec->num_mux_defs = 1; |
df694daa KY |
5611 | spec->input_mux = &spec->private_imux; |
5612 | ||
e044c39a | 5613 | store_pin_configs(codec); |
df694daa KY |
5614 | return 1; |
5615 | } | |
5616 | ||
ae6b813a TI |
5617 | /* additional initialization for auto-configuration model */ |
5618 | static void alc260_auto_init(struct hda_codec *codec) | |
df694daa | 5619 | { |
f6c7e546 | 5620 | struct alc_spec *spec = codec->spec; |
df694daa KY |
5621 | alc260_auto_init_multi_out(codec); |
5622 | alc260_auto_init_analog_input(codec); | |
f6c7e546 | 5623 | if (spec->unsol_event) |
7fb0d78f | 5624 | alc_inithook(codec); |
df694daa KY |
5625 | } |
5626 | ||
cb53c626 TI |
5627 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
5628 | static struct hda_amp_list alc260_loopbacks[] = { | |
5629 | { 0x07, HDA_INPUT, 0 }, | |
5630 | { 0x07, HDA_INPUT, 1 }, | |
5631 | { 0x07, HDA_INPUT, 2 }, | |
5632 | { 0x07, HDA_INPUT, 3 }, | |
5633 | { 0x07, HDA_INPUT, 4 }, | |
5634 | { } /* end */ | |
5635 | }; | |
5636 | #endif | |
5637 | ||
df694daa KY |
5638 | /* |
5639 | * ALC260 configurations | |
5640 | */ | |
f5fcc13c TI |
5641 | static const char *alc260_models[ALC260_MODEL_LAST] = { |
5642 | [ALC260_BASIC] = "basic", | |
5643 | [ALC260_HP] = "hp", | |
5644 | [ALC260_HP_3013] = "hp-3013", | |
2922c9af | 5645 | [ALC260_HP_DC7600] = "hp-dc7600", |
f5fcc13c TI |
5646 | [ALC260_FUJITSU_S702X] = "fujitsu", |
5647 | [ALC260_ACER] = "acer", | |
bc9f98a9 KY |
5648 | [ALC260_WILL] = "will", |
5649 | [ALC260_REPLACER_672V] = "replacer", | |
7cf51e48 | 5650 | #ifdef CONFIG_SND_DEBUG |
f5fcc13c | 5651 | [ALC260_TEST] = "test", |
7cf51e48 | 5652 | #endif |
f5fcc13c TI |
5653 | [ALC260_AUTO] = "auto", |
5654 | }; | |
5655 | ||
5656 | static struct snd_pci_quirk alc260_cfg_tbl[] = { | |
bd869485 | 5657 | SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER), |
f5fcc13c | 5658 | SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER), |
9720b718 | 5659 | SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013), |
a8a5d067 | 5660 | SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013), |
f5fcc13c | 5661 | SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013), |
34ec8a0a | 5662 | SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013), |
3f878308 | 5663 | SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600), |
f5fcc13c TI |
5664 | SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013), |
5665 | SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP), | |
5666 | SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP), | |
5667 | SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP), | |
5668 | SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC), | |
5669 | SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC), | |
5670 | SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC), | |
5671 | SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X), | |
5672 | SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC), | |
bc9f98a9 | 5673 | SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V), |
ac3e3741 | 5674 | SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL), |
df694daa KY |
5675 | {} |
5676 | }; | |
5677 | ||
5678 | static struct alc_config_preset alc260_presets[] = { | |
5679 | [ALC260_BASIC] = { | |
5680 | .mixers = { alc260_base_output_mixer, | |
5681 | alc260_input_mixer, | |
f9e336f6 | 5682 | alc260_pc_beep_mixer }, |
df694daa KY |
5683 | .init_verbs = { alc260_init_verbs }, |
5684 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5685 | .dac_nids = alc260_dac_nids, | |
f9e336f6 | 5686 | .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), |
df694daa KY |
5687 | .adc_nids = alc260_adc_nids, |
5688 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5689 | .channel_mode = alc260_modes, | |
5690 | .input_mux = &alc260_capture_source, | |
5691 | }, | |
5692 | [ALC260_HP] = { | |
bec15c3a | 5693 | .mixers = { alc260_hp_output_mixer, |
f9e336f6 | 5694 | alc260_input_mixer }, |
bec15c3a TI |
5695 | .init_verbs = { alc260_init_verbs, |
5696 | alc260_hp_unsol_verbs }, | |
df694daa KY |
5697 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), |
5698 | .dac_nids = alc260_dac_nids, | |
f9e336f6 TI |
5699 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt), |
5700 | .adc_nids = alc260_adc_nids_alt, | |
df694daa KY |
5701 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
5702 | .channel_mode = alc260_modes, | |
5703 | .input_mux = &alc260_capture_source, | |
bec15c3a TI |
5704 | .unsol_event = alc260_hp_unsol_event, |
5705 | .init_hook = alc260_hp_automute, | |
df694daa | 5706 | }, |
3f878308 KY |
5707 | [ALC260_HP_DC7600] = { |
5708 | .mixers = { alc260_hp_dc7600_mixer, | |
f9e336f6 | 5709 | alc260_input_mixer }, |
3f878308 KY |
5710 | .init_verbs = { alc260_init_verbs, |
5711 | alc260_hp_dc7600_verbs }, | |
5712 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5713 | .dac_nids = alc260_dac_nids, | |
f9e336f6 TI |
5714 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt), |
5715 | .adc_nids = alc260_adc_nids_alt, | |
3f878308 KY |
5716 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
5717 | .channel_mode = alc260_modes, | |
5718 | .input_mux = &alc260_capture_source, | |
5719 | .unsol_event = alc260_hp_3012_unsol_event, | |
5720 | .init_hook = alc260_hp_3012_automute, | |
5721 | }, | |
df694daa KY |
5722 | [ALC260_HP_3013] = { |
5723 | .mixers = { alc260_hp_3013_mixer, | |
f9e336f6 | 5724 | alc260_input_mixer }, |
bec15c3a TI |
5725 | .init_verbs = { alc260_hp_3013_init_verbs, |
5726 | alc260_hp_3013_unsol_verbs }, | |
df694daa KY |
5727 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), |
5728 | .dac_nids = alc260_dac_nids, | |
f9e336f6 TI |
5729 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt), |
5730 | .adc_nids = alc260_adc_nids_alt, | |
df694daa KY |
5731 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
5732 | .channel_mode = alc260_modes, | |
5733 | .input_mux = &alc260_capture_source, | |
bec15c3a TI |
5734 | .unsol_event = alc260_hp_3013_unsol_event, |
5735 | .init_hook = alc260_hp_3013_automute, | |
df694daa KY |
5736 | }, |
5737 | [ALC260_FUJITSU_S702X] = { | |
f9e336f6 | 5738 | .mixers = { alc260_fujitsu_mixer }, |
df694daa KY |
5739 | .init_verbs = { alc260_fujitsu_init_verbs }, |
5740 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5741 | .dac_nids = alc260_dac_nids, | |
d57fdac0 JW |
5742 | .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), |
5743 | .adc_nids = alc260_dual_adc_nids, | |
df694daa KY |
5744 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
5745 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
5746 | .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources), |
5747 | .input_mux = alc260_fujitsu_capture_sources, | |
df694daa | 5748 | }, |
0bfc90e9 | 5749 | [ALC260_ACER] = { |
f9e336f6 | 5750 | .mixers = { alc260_acer_mixer }, |
0bfc90e9 JW |
5751 | .init_verbs = { alc260_acer_init_verbs }, |
5752 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5753 | .dac_nids = alc260_dac_nids, | |
5754 | .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), | |
5755 | .adc_nids = alc260_dual_adc_nids, | |
5756 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5757 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
5758 | .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources), |
5759 | .input_mux = alc260_acer_capture_sources, | |
0bfc90e9 | 5760 | }, |
bc9f98a9 | 5761 | [ALC260_WILL] = { |
f9e336f6 | 5762 | .mixers = { alc260_will_mixer }, |
bc9f98a9 KY |
5763 | .init_verbs = { alc260_init_verbs, alc260_will_verbs }, |
5764 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5765 | .dac_nids = alc260_dac_nids, | |
5766 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), | |
5767 | .adc_nids = alc260_adc_nids, | |
5768 | .dig_out_nid = ALC260_DIGOUT_NID, | |
5769 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5770 | .channel_mode = alc260_modes, | |
5771 | .input_mux = &alc260_capture_source, | |
5772 | }, | |
5773 | [ALC260_REPLACER_672V] = { | |
f9e336f6 | 5774 | .mixers = { alc260_replacer_672v_mixer }, |
bc9f98a9 KY |
5775 | .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs }, |
5776 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5777 | .dac_nids = alc260_dac_nids, | |
5778 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), | |
5779 | .adc_nids = alc260_adc_nids, | |
5780 | .dig_out_nid = ALC260_DIGOUT_NID, | |
5781 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5782 | .channel_mode = alc260_modes, | |
5783 | .input_mux = &alc260_capture_source, | |
5784 | .unsol_event = alc260_replacer_672v_unsol_event, | |
5785 | .init_hook = alc260_replacer_672v_automute, | |
5786 | }, | |
7cf51e48 JW |
5787 | #ifdef CONFIG_SND_DEBUG |
5788 | [ALC260_TEST] = { | |
f9e336f6 | 5789 | .mixers = { alc260_test_mixer }, |
7cf51e48 JW |
5790 | .init_verbs = { alc260_test_init_verbs }, |
5791 | .num_dacs = ARRAY_SIZE(alc260_test_dac_nids), | |
5792 | .dac_nids = alc260_test_dac_nids, | |
5793 | .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids), | |
5794 | .adc_nids = alc260_test_adc_nids, | |
5795 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5796 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
5797 | .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources), |
5798 | .input_mux = alc260_test_capture_sources, | |
7cf51e48 JW |
5799 | }, |
5800 | #endif | |
df694daa KY |
5801 | }; |
5802 | ||
5803 | static int patch_alc260(struct hda_codec *codec) | |
1da177e4 LT |
5804 | { |
5805 | struct alc_spec *spec; | |
df694daa | 5806 | int err, board_config; |
1da177e4 | 5807 | |
e560d8d8 | 5808 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
1da177e4 LT |
5809 | if (spec == NULL) |
5810 | return -ENOMEM; | |
5811 | ||
5812 | codec->spec = spec; | |
5813 | ||
f5fcc13c TI |
5814 | board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST, |
5815 | alc260_models, | |
5816 | alc260_cfg_tbl); | |
5817 | if (board_config < 0) { | |
9c7f852e TI |
5818 | snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, " |
5819 | "trying auto-probe from BIOS...\n"); | |
df694daa | 5820 | board_config = ALC260_AUTO; |
16ded525 | 5821 | } |
1da177e4 | 5822 | |
df694daa KY |
5823 | if (board_config == ALC260_AUTO) { |
5824 | /* automatic parse from the BIOS config */ | |
5825 | err = alc260_parse_auto_config(codec); | |
5826 | if (err < 0) { | |
5827 | alc_free(codec); | |
5828 | return err; | |
f12ab1e0 | 5829 | } else if (!err) { |
9c7f852e TI |
5830 | printk(KERN_INFO |
5831 | "hda_codec: Cannot set up configuration " | |
5832 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
5833 | board_config = ALC260_BASIC; |
5834 | } | |
a9430dd8 | 5835 | } |
e9edcee0 | 5836 | |
df694daa KY |
5837 | if (board_config != ALC260_AUTO) |
5838 | setup_preset(spec, &alc260_presets[board_config]); | |
1da177e4 LT |
5839 | |
5840 | spec->stream_name_analog = "ALC260 Analog"; | |
5841 | spec->stream_analog_playback = &alc260_pcm_analog_playback; | |
5842 | spec->stream_analog_capture = &alc260_pcm_analog_capture; | |
5843 | ||
a3bcba38 TI |
5844 | spec->stream_name_digital = "ALC260 Digital"; |
5845 | spec->stream_digital_playback = &alc260_pcm_digital_playback; | |
5846 | spec->stream_digital_capture = &alc260_pcm_digital_capture; | |
5847 | ||
4ef0ef19 TI |
5848 | if (!spec->adc_nids && spec->input_mux) { |
5849 | /* check whether NID 0x04 is valid */ | |
5850 | unsigned int wcap = get_wcaps(codec, 0x04); | |
5851 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
5852 | /* get type */ | |
5853 | if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) { | |
5854 | spec->adc_nids = alc260_adc_nids_alt; | |
5855 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt); | |
5856 | } else { | |
5857 | spec->adc_nids = alc260_adc_nids; | |
5858 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); | |
5859 | } | |
5860 | } | |
f9e336f6 TI |
5861 | set_capture_mixer(spec); |
5862 | ||
2134ea4f TI |
5863 | spec->vmaster_nid = 0x08; |
5864 | ||
1da177e4 | 5865 | codec->patch_ops = alc_patch_ops; |
df694daa | 5866 | if (board_config == ALC260_AUTO) |
ae6b813a | 5867 | spec->init_hook = alc260_auto_init; |
cb53c626 TI |
5868 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
5869 | if (!spec->loopback.amplist) | |
5870 | spec->loopback.amplist = alc260_loopbacks; | |
5871 | #endif | |
1da177e4 LT |
5872 | |
5873 | return 0; | |
5874 | } | |
5875 | ||
e9edcee0 | 5876 | |
1da177e4 LT |
5877 | /* |
5878 | * ALC882 support | |
5879 | * | |
5880 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible | |
5881 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
5882 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
5883 | * 6-channel independent captures. | |
5884 | * | |
5885 | * In addition, an independent DAC for the multi-playback (not used in this | |
5886 | * driver yet). | |
5887 | */ | |
df694daa KY |
5888 | #define ALC882_DIGOUT_NID 0x06 |
5889 | #define ALC882_DIGIN_NID 0x0a | |
1da177e4 | 5890 | |
d2a6d7dc | 5891 | static struct hda_channel_mode alc882_ch_modes[1] = { |
1da177e4 LT |
5892 | { 8, NULL } |
5893 | }; | |
5894 | ||
5895 | static hda_nid_t alc882_dac_nids[4] = { | |
5896 | /* front, rear, clfe, rear_surr */ | |
5897 | 0x02, 0x03, 0x04, 0x05 | |
5898 | }; | |
5899 | ||
df694daa KY |
5900 | /* identical with ALC880 */ |
5901 | #define alc882_adc_nids alc880_adc_nids | |
5902 | #define alc882_adc_nids_alt alc880_adc_nids_alt | |
1da177e4 | 5903 | |
e1406348 TI |
5904 | static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 }; |
5905 | static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 }; | |
5906 | ||
1da177e4 LT |
5907 | /* input MUX */ |
5908 | /* FIXME: should be a matrix-type input source selection */ | |
5909 | ||
5910 | static struct hda_input_mux alc882_capture_source = { | |
5911 | .num_items = 4, | |
5912 | .items = { | |
5913 | { "Mic", 0x0 }, | |
5914 | { "Front Mic", 0x1 }, | |
5915 | { "Line", 0x2 }, | |
5916 | { "CD", 0x4 }, | |
5917 | }, | |
5918 | }; | |
272a527c KY |
5919 | /* |
5920 | * 2ch mode | |
5921 | */ | |
5922 | static struct hda_verb alc882_3ST_ch2_init[] = { | |
5923 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
5924 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
5925 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
5926 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
5927 | { } /* end */ | |
5928 | }; | |
5929 | ||
5930 | /* | |
5931 | * 6ch mode | |
5932 | */ | |
5933 | static struct hda_verb alc882_3ST_ch6_init[] = { | |
5934 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5935 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
5936 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
5937 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5938 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
5939 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
5940 | { } /* end */ | |
5941 | }; | |
5942 | ||
5943 | static struct hda_channel_mode alc882_3ST_6ch_modes[2] = { | |
5944 | { 2, alc882_3ST_ch2_init }, | |
5945 | { 6, alc882_3ST_ch6_init }, | |
5946 | }; | |
5947 | ||
df694daa KY |
5948 | /* |
5949 | * 6ch mode | |
5950 | */ | |
5951 | static struct hda_verb alc882_sixstack_ch6_init[] = { | |
5952 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
5953 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5954 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5955 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5956 | { } /* end */ | |
5957 | }; | |
5958 | ||
5959 | /* | |
5960 | * 8ch mode | |
5961 | */ | |
5962 | static struct hda_verb alc882_sixstack_ch8_init[] = { | |
5963 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5964 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5965 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5966 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5967 | { } /* end */ | |
5968 | }; | |
5969 | ||
5970 | static struct hda_channel_mode alc882_sixstack_modes[2] = { | |
5971 | { 6, alc882_sixstack_ch6_init }, | |
5972 | { 8, alc882_sixstack_ch8_init }, | |
5973 | }; | |
5974 | ||
87350ad0 TI |
5975 | /* |
5976 | * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic | |
5977 | */ | |
5978 | ||
5979 | /* | |
5980 | * 2ch mode | |
5981 | */ | |
5982 | static struct hda_verb alc885_mbp_ch2_init[] = { | |
5983 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
5984 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5985 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5986 | { } /* end */ | |
5987 | }; | |
5988 | ||
5989 | /* | |
5990 | * 6ch mode | |
5991 | */ | |
5992 | static struct hda_verb alc885_mbp_ch6_init[] = { | |
5993 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5994 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5995 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
5996 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5997 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5998 | { } /* end */ | |
5999 | }; | |
6000 | ||
6001 | static struct hda_channel_mode alc885_mbp_6ch_modes[2] = { | |
6002 | { 2, alc885_mbp_ch2_init }, | |
6003 | { 6, alc885_mbp_ch6_init }, | |
6004 | }; | |
6005 | ||
6006 | ||
1da177e4 LT |
6007 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
6008 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
6009 | */ | |
c8b6bf9b | 6010 | static struct snd_kcontrol_new alc882_base_mixer[] = { |
05acb863 | 6011 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 6012 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
05acb863 | 6013 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 6014 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
05acb863 TI |
6015 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
6016 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
6017 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
6018 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
05acb863 | 6019 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 6020 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
1da177e4 LT |
6021 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
6022 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6023 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6024 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6025 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6026 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 6027 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
1da177e4 LT |
6028 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
6029 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 6030 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
1da177e4 LT |
6031 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
6032 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
6033 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
1da177e4 LT |
6034 | { } /* end */ |
6035 | }; | |
6036 | ||
87350ad0 | 6037 | static struct snd_kcontrol_new alc885_mbp3_mixer[] = { |
2134ea4f TI |
6038 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT), |
6039 | HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT), | |
6040 | HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT), | |
6041 | HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT), | |
6042 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6043 | HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
87350ad0 TI |
6044 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT), |
6045 | HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT), | |
2134ea4f | 6046 | HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT), |
87350ad0 TI |
6047 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT), |
6048 | { } /* end */ | |
6049 | }; | |
bdd148a3 KY |
6050 | static struct snd_kcontrol_new alc882_w2jc_mixer[] = { |
6051 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6052 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
6053 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6054 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6055 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6056 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6057 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6058 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
6059 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
6060 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
6061 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
6062 | { } /* end */ | |
6063 | }; | |
6064 | ||
272a527c KY |
6065 | static struct snd_kcontrol_new alc882_targa_mixer[] = { |
6066 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6067 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
6068 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6069 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6070 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6071 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6072 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6073 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6074 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
96fe7cc8 | 6075 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
272a527c KY |
6076 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
6077 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
96fe7cc8 | 6078 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
272a527c KY |
6079 | { } /* end */ |
6080 | }; | |
6081 | ||
6082 | /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ??? | |
6083 | * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c | |
6084 | */ | |
6085 | static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = { | |
6086 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6087 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
6088 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
6089 | HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT), | |
6090 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6091 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6092 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6093 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6094 | HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT), | |
6095 | HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, 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 | { } /* end */ |
6100 | }; | |
6101 | ||
914759b7 TI |
6102 | static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = { |
6103 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6104 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
6105 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
6106 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6107 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6108 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6109 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6110 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6111 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
6112 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
6113 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
6114 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
6115 | { } /* end */ | |
6116 | }; | |
6117 | ||
df694daa KY |
6118 | static struct snd_kcontrol_new alc882_chmode_mixer[] = { |
6119 | { | |
6120 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6121 | .name = "Channel Mode", | |
6122 | .info = alc_ch_mode_info, | |
6123 | .get = alc_ch_mode_get, | |
6124 | .put = alc_ch_mode_put, | |
6125 | }, | |
6126 | { } /* end */ | |
6127 | }; | |
6128 | ||
1da177e4 LT |
6129 | static struct hda_verb alc882_init_verbs[] = { |
6130 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
05acb863 TI |
6131 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
6132 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6133 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 6134 | /* Rear mixer */ |
05acb863 TI |
6135 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
6136 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6137 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 6138 | /* CLFE mixer */ |
05acb863 TI |
6139 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
6140 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6141 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 6142 | /* Side mixer */ |
05acb863 TI |
6143 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
6144 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6145 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 6146 | |
e9edcee0 | 6147 | /* Front Pin: output 0 (0x0c) */ |
05acb863 | 6148 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 6149 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 6150 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 6151 | /* Rear Pin: output 1 (0x0d) */ |
05acb863 | 6152 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 6153 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 6154 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, |
e9edcee0 | 6155 | /* CLFE Pin: output 2 (0x0e) */ |
05acb863 | 6156 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 6157 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 6158 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, |
e9edcee0 | 6159 | /* Side Pin: output 3 (0x0f) */ |
05acb863 | 6160 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 6161 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 6162 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, |
e9edcee0 | 6163 | /* Mic (rear) pin: input vref at 80% */ |
16ded525 | 6164 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 TI |
6165 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
6166 | /* Front Mic pin: input vref at 80% */ | |
16ded525 | 6167 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 TI |
6168 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
6169 | /* Line In pin: input */ | |
05acb863 | 6170 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 TI |
6171 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
6172 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
6173 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6174 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6175 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1da177e4 | 6176 | /* CD pin widget for input */ |
05acb863 | 6177 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 LT |
6178 | |
6179 | /* FIXME: use matrix-type input source selection */ | |
6180 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
6181 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
05acb863 TI |
6182 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
6183 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6184 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6185 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 6186 | /* Input mixer2 */ |
05acb863 TI |
6187 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
6188 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6189 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6190 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 6191 | /* Input mixer3 */ |
05acb863 TI |
6192 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
6193 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6194 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6195 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
6196 | /* ADC1: mute amp left and right */ | |
6197 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 6198 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
6199 | /* ADC2: mute amp left and right */ |
6200 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 6201 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
6202 | /* ADC3: mute amp left and right */ |
6203 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 6204 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
1da177e4 LT |
6205 | |
6206 | { } | |
6207 | }; | |
6208 | ||
4b146cb0 TI |
6209 | static struct hda_verb alc882_eapd_verbs[] = { |
6210 | /* change to EAPD mode */ | |
6211 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
b373bdeb | 6212 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, |
f12ab1e0 | 6213 | { } |
4b146cb0 TI |
6214 | }; |
6215 | ||
9102cd1c TD |
6216 | /* Mac Pro test */ |
6217 | static struct snd_kcontrol_new alc882_macpro_mixer[] = { | |
6218 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6219 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
6220 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT), | |
6221 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
6222 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
6223 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6224 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6225 | { } /* end */ | |
6226 | }; | |
6227 | ||
6228 | static struct hda_verb alc882_macpro_init_verbs[] = { | |
6229 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
6230 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6231 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6232 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
6233 | /* Front Pin: output 0 (0x0c) */ | |
6234 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6235 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6236 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6237 | /* Front Mic pin: input vref at 80% */ | |
6238 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
6239 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
6240 | /* Speaker: output */ | |
6241 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6242 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6243 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04}, | |
6244 | /* Headphone output (output 0 - 0x0c) */ | |
6245 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6246 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6247 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6248 | ||
6249 | /* FIXME: use matrix-type input source selection */ | |
6250 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
6251 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
6252 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6253 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6254 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6255 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
6256 | /* Input mixer2 */ | |
6257 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6258 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6259 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6260 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
6261 | /* Input mixer3 */ | |
6262 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6263 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6264 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6265 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
6266 | /* ADC1: mute amp left and right */ | |
6267 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6268 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6269 | /* ADC2: mute amp left and right */ | |
6270 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6271 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6272 | /* ADC3: mute amp left and right */ | |
6273 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6274 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6275 | ||
6276 | { } | |
6277 | }; | |
f12ab1e0 | 6278 | |
87350ad0 TI |
6279 | /* Macbook Pro rev3 */ |
6280 | static struct hda_verb alc885_mbp3_init_verbs[] = { | |
6281 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
6282 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6283 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6284 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
6285 | /* Rear mixer */ | |
6286 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6287 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6288 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
6289 | /* Front Pin: output 0 (0x0c) */ | |
6290 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6291 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6292 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6293 | /* HP Pin: output 0 (0x0d) */ | |
6294 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, | |
6295 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
6296 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6297 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
6298 | /* Mic (rear) pin: input vref at 80% */ | |
6299 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
6300 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
6301 | /* Front Mic pin: input vref at 80% */ | |
6302 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
6303 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
6304 | /* Line In pin: use output 1 when in LineOut mode */ | |
6305 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
6306 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
6307 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
6308 | ||
6309 | /* FIXME: use matrix-type input source selection */ | |
6310 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
6311 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
6312 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6313 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6314 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6315 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
6316 | /* Input mixer2 */ | |
6317 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6318 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6319 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6320 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
6321 | /* Input mixer3 */ | |
6322 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6323 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6324 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6325 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
6326 | /* ADC1: mute amp left and right */ | |
6327 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6328 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6329 | /* ADC2: mute amp left and right */ | |
6330 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6331 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6332 | /* ADC3: mute amp left and right */ | |
6333 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6334 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6335 | ||
6336 | { } | |
6337 | }; | |
6338 | ||
c54728d8 NF |
6339 | /* iMac 24 mixer. */ |
6340 | static struct snd_kcontrol_new alc885_imac24_mixer[] = { | |
6341 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT), | |
6342 | HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT), | |
6343 | { } /* end */ | |
6344 | }; | |
6345 | ||
6346 | /* iMac 24 init verbs. */ | |
6347 | static struct hda_verb alc885_imac24_init_verbs[] = { | |
6348 | /* Internal speakers: output 0 (0x0c) */ | |
6349 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6350 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6351 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6352 | /* Internal speakers: output 0 (0x0c) */ | |
6353 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6354 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6355 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6356 | /* Headphone: output 0 (0x0c) */ | |
6357 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6358 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6359 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6360 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
6361 | /* Front Mic: input vref at 80% */ | |
6362 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
6363 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
6364 | { } | |
6365 | }; | |
6366 | ||
6367 | /* Toggle speaker-output according to the hp-jack state */ | |
6368 | static void alc885_imac24_automute(struct hda_codec *codec) | |
6369 | { | |
6370 | unsigned int present; | |
6371 | ||
6372 | present = snd_hda_codec_read(codec, 0x14, 0, | |
6373 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
6374 | snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0, |
6375 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
6376 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, | |
6377 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
c54728d8 NF |
6378 | } |
6379 | ||
6380 | /* Processes unsolicited events. */ | |
6381 | static void alc885_imac24_unsol_event(struct hda_codec *codec, | |
6382 | unsigned int res) | |
6383 | { | |
6384 | /* Headphone insertion or removal. */ | |
6385 | if ((res >> 26) == ALC880_HP_EVENT) | |
6386 | alc885_imac24_automute(codec); | |
6387 | } | |
6388 | ||
87350ad0 TI |
6389 | static void alc885_mbp3_automute(struct hda_codec *codec) |
6390 | { | |
6391 | unsigned int present; | |
6392 | ||
6393 | present = snd_hda_codec_read(codec, 0x15, 0, | |
6394 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
6395 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
6396 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
6397 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
6398 | HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE); | |
6399 | ||
6400 | } | |
6401 | static void alc885_mbp3_unsol_event(struct hda_codec *codec, | |
6402 | unsigned int res) | |
6403 | { | |
6404 | /* Headphone insertion or removal. */ | |
6405 | if ((res >> 26) == ALC880_HP_EVENT) | |
6406 | alc885_mbp3_automute(codec); | |
6407 | } | |
6408 | ||
6409 | ||
272a527c KY |
6410 | static struct hda_verb alc882_targa_verbs[] = { |
6411 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6412 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6413 | ||
6414 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6415 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
ea1fb29a | 6416 | |
272a527c KY |
6417 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ |
6418 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
6419 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
6420 | ||
6421 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
6422 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, | |
6423 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | |
6424 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | |
6425 | { } /* end */ | |
6426 | }; | |
6427 | ||
6428 | /* toggle speaker-output according to the hp-jack state */ | |
6429 | static void alc882_targa_automute(struct hda_codec *codec) | |
6430 | { | |
6431 | unsigned int present; | |
ea1fb29a | 6432 | |
272a527c KY |
6433 | present = snd_hda_codec_read(codec, 0x14, 0, |
6434 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
6435 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, |
6436 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
82beb8fd TI |
6437 | snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA, |
6438 | present ? 1 : 3); | |
272a527c KY |
6439 | } |
6440 | ||
6441 | static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res) | |
6442 | { | |
6443 | /* Looks like the unsol event is incompatible with the standard | |
6444 | * definition. 4bit tag is placed at 26 bit! | |
6445 | */ | |
6446 | if (((res >> 26) == ALC880_HP_EVENT)) { | |
6447 | alc882_targa_automute(codec); | |
6448 | } | |
6449 | } | |
6450 | ||
6451 | static struct hda_verb alc882_asus_a7j_verbs[] = { | |
6452 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6453 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6454 | ||
6455 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6456 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6457 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
ea1fb29a | 6458 | |
272a527c KY |
6459 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ |
6460 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
6461 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ | |
6462 | ||
6463 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
6464 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
6465 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
6466 | { } /* end */ | |
6467 | }; | |
6468 | ||
914759b7 TI |
6469 | static struct hda_verb alc882_asus_a7m_verbs[] = { |
6470 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6471 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6472 | ||
6473 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6474 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6475 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
ea1fb29a | 6476 | |
914759b7 TI |
6477 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ |
6478 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
6479 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ | |
6480 | ||
6481 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
6482 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
6483 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
6484 | { } /* end */ | |
6485 | }; | |
6486 | ||
9102cd1c TD |
6487 | static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) |
6488 | { | |
6489 | unsigned int gpiostate, gpiomask, gpiodir; | |
6490 | ||
6491 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, | |
6492 | AC_VERB_GET_GPIO_DATA, 0); | |
6493 | ||
6494 | if (!muted) | |
6495 | gpiostate |= (1 << pin); | |
6496 | else | |
6497 | gpiostate &= ~(1 << pin); | |
6498 | ||
6499 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, | |
6500 | AC_VERB_GET_GPIO_MASK, 0); | |
6501 | gpiomask |= (1 << pin); | |
6502 | ||
6503 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, | |
6504 | AC_VERB_GET_GPIO_DIRECTION, 0); | |
6505 | gpiodir |= (1 << pin); | |
6506 | ||
6507 | ||
6508 | snd_hda_codec_write(codec, codec->afg, 0, | |
6509 | AC_VERB_SET_GPIO_MASK, gpiomask); | |
6510 | snd_hda_codec_write(codec, codec->afg, 0, | |
6511 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); | |
6512 | ||
6513 | msleep(1); | |
6514 | ||
6515 | snd_hda_codec_write(codec, codec->afg, 0, | |
6516 | AC_VERB_SET_GPIO_DATA, gpiostate); | |
6517 | } | |
6518 | ||
7debbe51 TI |
6519 | /* set up GPIO at initialization */ |
6520 | static void alc885_macpro_init_hook(struct hda_codec *codec) | |
6521 | { | |
6522 | alc882_gpio_mute(codec, 0, 0); | |
6523 | alc882_gpio_mute(codec, 1, 0); | |
6524 | } | |
6525 | ||
6526 | /* set up GPIO and update auto-muting at initialization */ | |
6527 | static void alc885_imac24_init_hook(struct hda_codec *codec) | |
6528 | { | |
6529 | alc885_macpro_init_hook(codec); | |
6530 | alc885_imac24_automute(codec); | |
6531 | } | |
6532 | ||
df694daa KY |
6533 | /* |
6534 | * generic initialization of ADC, input mixers and output mixers | |
6535 | */ | |
6536 | static struct hda_verb alc882_auto_init_verbs[] = { | |
6537 | /* | |
6538 | * Unmute ADC0-2 and set the default input to mic-in | |
6539 | */ | |
6540 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6541 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6542 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6543 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6544 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6545 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
1da177e4 | 6546 | |
cb53c626 | 6547 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
df694daa | 6548 | * mixer widget |
f12ab1e0 TI |
6549 | * Note: PASD motherboards uses the Line In 2 as the input for |
6550 | * front panel mic (mic 2) | |
df694daa KY |
6551 | */ |
6552 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
6553 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
6554 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
6555 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6556 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6557 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
e9edcee0 | 6558 | |
df694daa KY |
6559 | /* |
6560 | * Set up output mixers (0x0c - 0x0f) | |
6561 | */ | |
6562 | /* set vol=0 to output mixers */ | |
6563 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6564 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6565 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6566 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6567 | /* set up input amps for analog loopback */ | |
6568 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
6569 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6570 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6571 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6572 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6573 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6574 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6575 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6576 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6577 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6578 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6579 | ||
6580 | /* FIXME: use matrix-type input source selection */ | |
6581 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
6582 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
6583 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
6584 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
6585 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
6586 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
6587 | /* Input mixer2 */ | |
6588 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
6589 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
6590 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
6591 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
6592 | /* Input mixer3 */ | |
6593 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
6594 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
6595 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
6596 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
6597 | ||
6598 | { } | |
6599 | }; | |
6600 | ||
cb53c626 TI |
6601 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
6602 | #define alc882_loopbacks alc880_loopbacks | |
6603 | #endif | |
6604 | ||
df694daa KY |
6605 | /* pcm configuration: identiacal with ALC880 */ |
6606 | #define alc882_pcm_analog_playback alc880_pcm_analog_playback | |
6607 | #define alc882_pcm_analog_capture alc880_pcm_analog_capture | |
6608 | #define alc882_pcm_digital_playback alc880_pcm_digital_playback | |
6609 | #define alc882_pcm_digital_capture alc880_pcm_digital_capture | |
6610 | ||
6611 | /* | |
6612 | * configuration and preset | |
6613 | */ | |
f5fcc13c TI |
6614 | static const char *alc882_models[ALC882_MODEL_LAST] = { |
6615 | [ALC882_3ST_DIG] = "3stack-dig", | |
6616 | [ALC882_6ST_DIG] = "6stack-dig", | |
6617 | [ALC882_ARIMA] = "arima", | |
bdd148a3 | 6618 | [ALC882_W2JC] = "w2jc", |
0438a00e TI |
6619 | [ALC882_TARGA] = "targa", |
6620 | [ALC882_ASUS_A7J] = "asus-a7j", | |
6621 | [ALC882_ASUS_A7M] = "asus-a7m", | |
9102cd1c | 6622 | [ALC885_MACPRO] = "macpro", |
87350ad0 | 6623 | [ALC885_MBP3] = "mbp3", |
c54728d8 | 6624 | [ALC885_IMAC24] = "imac24", |
f5fcc13c TI |
6625 | [ALC882_AUTO] = "auto", |
6626 | }; | |
6627 | ||
6628 | static struct snd_pci_quirk alc882_cfg_tbl[] = { | |
6629 | SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG), | |
272a527c | 6630 | SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J), |
ac8842a0 | 6631 | SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J), |
914759b7 | 6632 | SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M), |
ac3e3741 | 6633 | SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC), |
c5d9f1cd | 6634 | SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG), |
7b9470d8 | 6635 | SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG), |
ac3e3741 | 6636 | SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG), |
4444704c | 6637 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG), |
ac3e3741 TI |
6638 | SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */ |
6639 | SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG), | |
6640 | SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), | |
df694daa KY |
6641 | {} |
6642 | }; | |
6643 | ||
6644 | static struct alc_config_preset alc882_presets[] = { | |
6645 | [ALC882_3ST_DIG] = { | |
6646 | .mixers = { alc882_base_mixer }, | |
6647 | .init_verbs = { alc882_init_verbs }, | |
6648 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6649 | .dac_nids = alc882_dac_nids, | |
6650 | .dig_out_nid = ALC882_DIGOUT_NID, | |
df694daa KY |
6651 | .dig_in_nid = ALC882_DIGIN_NID, |
6652 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | |
6653 | .channel_mode = alc882_ch_modes, | |
4e195a7b | 6654 | .need_dac_fix = 1, |
df694daa KY |
6655 | .input_mux = &alc882_capture_source, |
6656 | }, | |
6657 | [ALC882_6ST_DIG] = { | |
6658 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, | |
6659 | .init_verbs = { alc882_init_verbs }, | |
6660 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6661 | .dac_nids = alc882_dac_nids, | |
6662 | .dig_out_nid = ALC882_DIGOUT_NID, | |
df694daa KY |
6663 | .dig_in_nid = ALC882_DIGIN_NID, |
6664 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), | |
6665 | .channel_mode = alc882_sixstack_modes, | |
6666 | .input_mux = &alc882_capture_source, | |
6667 | }, | |
4b146cb0 TI |
6668 | [ALC882_ARIMA] = { |
6669 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, | |
6670 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs }, | |
6671 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6672 | .dac_nids = alc882_dac_nids, | |
6673 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), | |
6674 | .channel_mode = alc882_sixstack_modes, | |
6675 | .input_mux = &alc882_capture_source, | |
6676 | }, | |
bdd148a3 KY |
6677 | [ALC882_W2JC] = { |
6678 | .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer }, | |
6679 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs, | |
6680 | alc880_gpio1_init_verbs }, | |
6681 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6682 | .dac_nids = alc882_dac_nids, | |
6683 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
6684 | .channel_mode = alc880_threestack_modes, | |
6685 | .need_dac_fix = 1, | |
6686 | .input_mux = &alc882_capture_source, | |
6687 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6688 | }, | |
87350ad0 TI |
6689 | [ALC885_MBP3] = { |
6690 | .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer }, | |
6691 | .init_verbs = { alc885_mbp3_init_verbs, | |
6692 | alc880_gpio1_init_verbs }, | |
6693 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6694 | .dac_nids = alc882_dac_nids, | |
6695 | .channel_mode = alc885_mbp_6ch_modes, | |
6696 | .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes), | |
6697 | .input_mux = &alc882_capture_source, | |
6698 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6699 | .dig_in_nid = ALC882_DIGIN_NID, | |
6700 | .unsol_event = alc885_mbp3_unsol_event, | |
6701 | .init_hook = alc885_mbp3_automute, | |
6702 | }, | |
9102cd1c TD |
6703 | [ALC885_MACPRO] = { |
6704 | .mixers = { alc882_macpro_mixer }, | |
6705 | .init_verbs = { alc882_macpro_init_verbs }, | |
6706 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6707 | .dac_nids = alc882_dac_nids, | |
6708 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6709 | .dig_in_nid = ALC882_DIGIN_NID, | |
6710 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | |
6711 | .channel_mode = alc882_ch_modes, | |
6712 | .input_mux = &alc882_capture_source, | |
7debbe51 | 6713 | .init_hook = alc885_macpro_init_hook, |
9102cd1c | 6714 | }, |
c54728d8 NF |
6715 | [ALC885_IMAC24] = { |
6716 | .mixers = { alc885_imac24_mixer }, | |
6717 | .init_verbs = { alc885_imac24_init_verbs }, | |
6718 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6719 | .dac_nids = alc882_dac_nids, | |
6720 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6721 | .dig_in_nid = ALC882_DIGIN_NID, | |
6722 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | |
6723 | .channel_mode = alc882_ch_modes, | |
6724 | .input_mux = &alc882_capture_source, | |
6725 | .unsol_event = alc885_imac24_unsol_event, | |
7debbe51 | 6726 | .init_hook = alc885_imac24_init_hook, |
c54728d8 | 6727 | }, |
272a527c | 6728 | [ALC882_TARGA] = { |
f9e336f6 | 6729 | .mixers = { alc882_targa_mixer, alc882_chmode_mixer }, |
272a527c KY |
6730 | .init_verbs = { alc882_init_verbs, alc882_targa_verbs}, |
6731 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6732 | .dac_nids = alc882_dac_nids, | |
6733 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6734 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), | |
6735 | .adc_nids = alc882_adc_nids, | |
e1406348 | 6736 | .capsrc_nids = alc882_capsrc_nids, |
272a527c KY |
6737 | .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), |
6738 | .channel_mode = alc882_3ST_6ch_modes, | |
6739 | .need_dac_fix = 1, | |
6740 | .input_mux = &alc882_capture_source, | |
6741 | .unsol_event = alc882_targa_unsol_event, | |
6742 | .init_hook = alc882_targa_automute, | |
6743 | }, | |
6744 | [ALC882_ASUS_A7J] = { | |
f9e336f6 | 6745 | .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer }, |
272a527c KY |
6746 | .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs}, |
6747 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6748 | .dac_nids = alc882_dac_nids, | |
6749 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6750 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), | |
6751 | .adc_nids = alc882_adc_nids, | |
e1406348 | 6752 | .capsrc_nids = alc882_capsrc_nids, |
272a527c KY |
6753 | .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), |
6754 | .channel_mode = alc882_3ST_6ch_modes, | |
6755 | .need_dac_fix = 1, | |
6756 | .input_mux = &alc882_capture_source, | |
ea1fb29a | 6757 | }, |
914759b7 TI |
6758 | [ALC882_ASUS_A7M] = { |
6759 | .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer }, | |
6760 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs, | |
6761 | alc880_gpio1_init_verbs, | |
6762 | alc882_asus_a7m_verbs }, | |
6763 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6764 | .dac_nids = alc882_dac_nids, | |
6765 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6766 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
6767 | .channel_mode = alc880_threestack_modes, | |
6768 | .need_dac_fix = 1, | |
6769 | .input_mux = &alc882_capture_source, | |
ea1fb29a | 6770 | }, |
df694daa KY |
6771 | }; |
6772 | ||
6773 | ||
f95474ec TI |
6774 | /* |
6775 | * Pin config fixes | |
6776 | */ | |
ea1fb29a | 6777 | enum { |
f95474ec TI |
6778 | PINFIX_ABIT_AW9D_MAX |
6779 | }; | |
6780 | ||
6781 | static struct alc_pincfg alc882_abit_aw9d_pinfix[] = { | |
6782 | { 0x15, 0x01080104 }, /* side */ | |
6783 | { 0x16, 0x01011012 }, /* rear */ | |
6784 | { 0x17, 0x01016011 }, /* clfe */ | |
6785 | { } | |
6786 | }; | |
6787 | ||
6788 | static const struct alc_pincfg *alc882_pin_fixes[] = { | |
6789 | [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix, | |
6790 | }; | |
6791 | ||
6792 | static struct snd_pci_quirk alc882_pinfix_tbl[] = { | |
6793 | SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX), | |
6794 | {} | |
6795 | }; | |
6796 | ||
df694daa KY |
6797 | /* |
6798 | * BIOS auto configuration | |
6799 | */ | |
6800 | static void alc882_auto_set_output_and_unmute(struct hda_codec *codec, | |
6801 | hda_nid_t nid, int pin_type, | |
6802 | int dac_idx) | |
6803 | { | |
6804 | /* set as output */ | |
6805 | struct alc_spec *spec = codec->spec; | |
f12ab1e0 TI |
6806 | int idx; |
6807 | ||
f6c7e546 | 6808 | alc_set_pin_output(codec, nid, pin_type); |
df694daa KY |
6809 | if (spec->multiout.dac_nids[dac_idx] == 0x25) |
6810 | idx = 4; | |
6811 | else | |
6812 | idx = spec->multiout.dac_nids[dac_idx] - 2; | |
df694daa KY |
6813 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); |
6814 | ||
6815 | } | |
6816 | ||
6817 | static void alc882_auto_init_multi_out(struct hda_codec *codec) | |
6818 | { | |
6819 | struct alc_spec *spec = codec->spec; | |
6820 | int i; | |
6821 | ||
bc9f98a9 | 6822 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
df694daa | 6823 | for (i = 0; i <= HDA_SIDE; i++) { |
f12ab1e0 | 6824 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
baba8ee9 | 6825 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
df694daa | 6826 | if (nid) |
baba8ee9 | 6827 | alc882_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 6828 | i); |
df694daa KY |
6829 | } |
6830 | } | |
6831 | ||
6832 | static void alc882_auto_init_hp_out(struct hda_codec *codec) | |
6833 | { | |
6834 | struct alc_spec *spec = codec->spec; | |
6835 | hda_nid_t pin; | |
6836 | ||
eb06ed8f | 6837 | pin = spec->autocfg.hp_pins[0]; |
df694daa | 6838 | if (pin) /* connect to front */ |
f12ab1e0 TI |
6839 | /* use dac 0 */ |
6840 | alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
f6c7e546 TI |
6841 | pin = spec->autocfg.speaker_pins[0]; |
6842 | if (pin) | |
6843 | alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
df694daa KY |
6844 | } |
6845 | ||
6846 | #define alc882_is_input_pin(nid) alc880_is_input_pin(nid) | |
6847 | #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID | |
6848 | ||
6849 | static void alc882_auto_init_analog_input(struct hda_codec *codec) | |
6850 | { | |
6851 | struct alc_spec *spec = codec->spec; | |
6852 | int i; | |
6853 | ||
6854 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
6855 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
7194cae6 TI |
6856 | unsigned int vref; |
6857 | if (!nid) | |
6858 | continue; | |
6859 | vref = PIN_IN; | |
6860 | if (1 /*i <= AUTO_PIN_FRONT_MIC*/) { | |
531240ff KY |
6861 | unsigned int pincap; |
6862 | pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); | |
6863 | if ((pincap >> AC_PINCAP_VREF_SHIFT) & | |
7194cae6 TI |
6864 | AC_PINCAP_VREF_80) |
6865 | vref = PIN_VREF80; | |
df694daa | 6866 | } |
7194cae6 TI |
6867 | snd_hda_codec_write(codec, nid, 0, |
6868 | AC_VERB_SET_PIN_WIDGET_CONTROL, vref); | |
6869 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) | |
6870 | snd_hda_codec_write(codec, nid, 0, | |
6871 | AC_VERB_SET_AMP_GAIN_MUTE, | |
6872 | AMP_OUT_MUTE); | |
df694daa KY |
6873 | } |
6874 | } | |
6875 | ||
f511b01c TI |
6876 | static void alc882_auto_init_input_src(struct hda_codec *codec) |
6877 | { | |
6878 | struct alc_spec *spec = codec->spec; | |
6879 | const struct hda_input_mux *imux = spec->input_mux; | |
6880 | int c; | |
6881 | ||
6882 | for (c = 0; c < spec->num_adc_nids; c++) { | |
6883 | hda_nid_t conn_list[HDA_MAX_NUM_INPUTS]; | |
6884 | hda_nid_t nid = spec->capsrc_nids[c]; | |
6885 | int conns, mute, idx, item; | |
6886 | ||
6887 | conns = snd_hda_get_connections(codec, nid, conn_list, | |
6888 | ARRAY_SIZE(conn_list)); | |
6889 | if (conns < 0) | |
6890 | continue; | |
6891 | for (idx = 0; idx < conns; idx++) { | |
6892 | /* if the current connection is the selected one, | |
6893 | * unmute it as default - otherwise mute it | |
6894 | */ | |
6895 | mute = AMP_IN_MUTE(idx); | |
6896 | for (item = 0; item < imux->num_items; item++) { | |
6897 | if (imux->items[item].index == idx) { | |
6898 | if (spec->cur_mux[c] == item) | |
6899 | mute = AMP_IN_UNMUTE(idx); | |
6900 | break; | |
6901 | } | |
6902 | } | |
6903 | snd_hda_codec_write(codec, nid, 0, | |
6904 | AC_VERB_SET_AMP_GAIN_MUTE, mute); | |
6905 | } | |
6906 | } | |
6907 | } | |
6908 | ||
776e184e TI |
6909 | /* add mic boosts if needed */ |
6910 | static int alc_auto_add_mic_boost(struct hda_codec *codec) | |
6911 | { | |
6912 | struct alc_spec *spec = codec->spec; | |
6913 | int err; | |
6914 | hda_nid_t nid; | |
6915 | ||
6916 | nid = spec->autocfg.input_pins[AUTO_PIN_MIC]; | |
ce22e03e | 6917 | if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) { |
776e184e TI |
6918 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
6919 | "Mic Boost", | |
6920 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | |
6921 | if (err < 0) | |
6922 | return err; | |
6923 | } | |
6924 | nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]; | |
ce22e03e | 6925 | if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) { |
776e184e TI |
6926 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
6927 | "Front Mic Boost", | |
6928 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | |
6929 | if (err < 0) | |
6930 | return err; | |
6931 | } | |
6932 | return 0; | |
6933 | } | |
6934 | ||
df694daa KY |
6935 | /* almost identical with ALC880 parser... */ |
6936 | static int alc882_parse_auto_config(struct hda_codec *codec) | |
6937 | { | |
6938 | struct alc_spec *spec = codec->spec; | |
6939 | int err = alc880_parse_auto_config(codec); | |
6940 | ||
6941 | if (err < 0) | |
6942 | return err; | |
776e184e TI |
6943 | else if (!err) |
6944 | return 0; /* no config found */ | |
6945 | ||
6946 | err = alc_auto_add_mic_boost(codec); | |
6947 | if (err < 0) | |
6948 | return err; | |
6949 | ||
6950 | /* hack - override the init verbs */ | |
6951 | spec->init_verbs[0] = alc882_auto_init_verbs; | |
6952 | ||
6953 | return 1; /* config found */ | |
df694daa KY |
6954 | } |
6955 | ||
ae6b813a TI |
6956 | /* additional initialization for auto-configuration model */ |
6957 | static void alc882_auto_init(struct hda_codec *codec) | |
df694daa | 6958 | { |
f6c7e546 | 6959 | struct alc_spec *spec = codec->spec; |
df694daa KY |
6960 | alc882_auto_init_multi_out(codec); |
6961 | alc882_auto_init_hp_out(codec); | |
6962 | alc882_auto_init_analog_input(codec); | |
f511b01c | 6963 | alc882_auto_init_input_src(codec); |
f6c7e546 | 6964 | if (spec->unsol_event) |
7fb0d78f | 6965 | alc_inithook(codec); |
df694daa KY |
6966 | } |
6967 | ||
7943a8ab TI |
6968 | static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */ |
6969 | ||
df694daa KY |
6970 | static int patch_alc882(struct hda_codec *codec) |
6971 | { | |
6972 | struct alc_spec *spec; | |
6973 | int err, board_config; | |
6974 | ||
6975 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
6976 | if (spec == NULL) | |
6977 | return -ENOMEM; | |
6978 | ||
6979 | codec->spec = spec; | |
6980 | ||
f5fcc13c TI |
6981 | board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST, |
6982 | alc882_models, | |
6983 | alc882_cfg_tbl); | |
df694daa KY |
6984 | |
6985 | if (board_config < 0 || board_config >= ALC882_MODEL_LAST) { | |
081d17c4 TD |
6986 | /* Pick up systems that don't supply PCI SSID */ |
6987 | switch (codec->subsystem_id) { | |
6988 | case 0x106b0c00: /* Mac Pro */ | |
6989 | board_config = ALC885_MACPRO; | |
6990 | break; | |
c54728d8 | 6991 | case 0x106b1000: /* iMac 24 */ |
f3911c5a | 6992 | case 0x106b2800: /* AppleTV */ |
c54728d8 NF |
6993 | board_config = ALC885_IMAC24; |
6994 | break; | |
c7e0757a | 6995 | case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */ |
9c95c43d | 6996 | case 0x106b00a4: /* MacbookPro4,1 */ |
87350ad0 | 6997 | case 0x106b2c00: /* Macbook Pro rev3 */ |
c7e0757a | 6998 | case 0x106b3600: /* Macbook 3.1 */ |
87350ad0 TI |
6999 | board_config = ALC885_MBP3; |
7000 | break; | |
081d17c4 | 7001 | default: |
7943a8ab | 7002 | /* ALC889A is handled better as ALC888-compatible */ |
669faba2 CM |
7003 | if (codec->revision_id == 0x100101 || |
7004 | codec->revision_id == 0x100103) { | |
7943a8ab TI |
7005 | alc_free(codec); |
7006 | return patch_alc883(codec); | |
7007 | } | |
081d17c4 TD |
7008 | printk(KERN_INFO "hda_codec: Unknown model for ALC882, " |
7009 | "trying auto-probe from BIOS...\n"); | |
7010 | board_config = ALC882_AUTO; | |
7011 | } | |
df694daa KY |
7012 | } |
7013 | ||
f95474ec TI |
7014 | alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes); |
7015 | ||
df694daa KY |
7016 | if (board_config == ALC882_AUTO) { |
7017 | /* automatic parse from the BIOS config */ | |
7018 | err = alc882_parse_auto_config(codec); | |
7019 | if (err < 0) { | |
7020 | alc_free(codec); | |
7021 | return err; | |
f12ab1e0 | 7022 | } else if (!err) { |
9c7f852e TI |
7023 | printk(KERN_INFO |
7024 | "hda_codec: Cannot set up configuration " | |
7025 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
7026 | board_config = ALC882_3ST_DIG; |
7027 | } | |
7028 | } | |
7029 | ||
7030 | if (board_config != ALC882_AUTO) | |
7031 | setup_preset(spec, &alc882_presets[board_config]); | |
1da177e4 | 7032 | |
2f893286 KY |
7033 | if (codec->vendor_id == 0x10ec0885) { |
7034 | spec->stream_name_analog = "ALC885 Analog"; | |
7035 | spec->stream_name_digital = "ALC885 Digital"; | |
7036 | } else { | |
7037 | spec->stream_name_analog = "ALC882 Analog"; | |
7038 | spec->stream_name_digital = "ALC882 Digital"; | |
7039 | } | |
7040 | ||
df694daa KY |
7041 | spec->stream_analog_playback = &alc882_pcm_analog_playback; |
7042 | spec->stream_analog_capture = &alc882_pcm_analog_capture; | |
6330079f TI |
7043 | /* FIXME: setup DAC5 */ |
7044 | /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/ | |
7045 | spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture; | |
1da177e4 | 7046 | |
df694daa KY |
7047 | spec->stream_digital_playback = &alc882_pcm_digital_playback; |
7048 | spec->stream_digital_capture = &alc882_pcm_digital_capture; | |
1da177e4 | 7049 | |
54cbc9ab | 7050 | spec->is_mix_capture = 1; /* matrix-style capture */ |
f12ab1e0 | 7051 | if (!spec->adc_nids && spec->input_mux) { |
df694daa | 7052 | /* check whether NID 0x07 is valid */ |
4a471b7d | 7053 | unsigned int wcap = get_wcaps(codec, 0x07); |
f12ab1e0 TI |
7054 | /* get type */ |
7055 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
df694daa KY |
7056 | if (wcap != AC_WID_AUD_IN) { |
7057 | spec->adc_nids = alc882_adc_nids_alt; | |
7058 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt); | |
e1406348 | 7059 | spec->capsrc_nids = alc882_capsrc_nids_alt; |
df694daa KY |
7060 | } else { |
7061 | spec->adc_nids = alc882_adc_nids; | |
7062 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids); | |
e1406348 | 7063 | spec->capsrc_nids = alc882_capsrc_nids; |
df694daa KY |
7064 | } |
7065 | } | |
f9e336f6 | 7066 | set_capture_mixer(spec); |
1da177e4 | 7067 | |
2134ea4f TI |
7068 | spec->vmaster_nid = 0x0c; |
7069 | ||
1da177e4 | 7070 | codec->patch_ops = alc_patch_ops; |
df694daa | 7071 | if (board_config == ALC882_AUTO) |
ae6b813a | 7072 | spec->init_hook = alc882_auto_init; |
cb53c626 TI |
7073 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
7074 | if (!spec->loopback.amplist) | |
7075 | spec->loopback.amplist = alc882_loopbacks; | |
7076 | #endif | |
df694daa KY |
7077 | |
7078 | return 0; | |
7079 | } | |
7080 | ||
7081 | /* | |
9c7f852e TI |
7082 | * ALC883 support |
7083 | * | |
7084 | * ALC883 is almost identical with ALC880 but has cleaner and more flexible | |
7085 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
7086 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
7087 | * 6-channel independent captures. | |
7088 | * | |
7089 | * In addition, an independent DAC for the multi-playback (not used in this | |
7090 | * driver yet). | |
df694daa | 7091 | */ |
9c7f852e TI |
7092 | #define ALC883_DIGOUT_NID 0x06 |
7093 | #define ALC883_DIGIN_NID 0x0a | |
df694daa | 7094 | |
3ab90935 WF |
7095 | #define ALC1200_DIGOUT_NID 0x10 |
7096 | ||
9c7f852e TI |
7097 | static hda_nid_t alc883_dac_nids[4] = { |
7098 | /* front, rear, clfe, rear_surr */ | |
f32a19e3 | 7099 | 0x02, 0x03, 0x04, 0x05 |
9c7f852e | 7100 | }; |
df694daa | 7101 | |
9c7f852e TI |
7102 | static hda_nid_t alc883_adc_nids[2] = { |
7103 | /* ADC1-2 */ | |
7104 | 0x08, 0x09, | |
7105 | }; | |
f12ab1e0 | 7106 | |
f9e336f6 TI |
7107 | static hda_nid_t alc883_adc_nids_alt[1] = { |
7108 | /* ADC1 */ | |
7109 | 0x08, | |
7110 | }; | |
7111 | ||
5b2d1eca VP |
7112 | static hda_nid_t alc883_adc_nids_rev[2] = { |
7113 | /* ADC2-1 */ | |
7114 | 0x09, 0x08 | |
7115 | }; | |
7116 | ||
e1406348 TI |
7117 | static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 }; |
7118 | ||
5b2d1eca VP |
7119 | static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 }; |
7120 | ||
9c7f852e TI |
7121 | /* input MUX */ |
7122 | /* FIXME: should be a matrix-type input source selection */ | |
df694daa | 7123 | |
9c7f852e TI |
7124 | static struct hda_input_mux alc883_capture_source = { |
7125 | .num_items = 4, | |
7126 | .items = { | |
7127 | { "Mic", 0x0 }, | |
7128 | { "Front Mic", 0x1 }, | |
7129 | { "Line", 0x2 }, | |
7130 | { "CD", 0x4 }, | |
7131 | }, | |
7132 | }; | |
bc9f98a9 | 7133 | |
17bba1b7 J |
7134 | static struct hda_input_mux alc883_3stack_6ch_intel = { |
7135 | .num_items = 4, | |
7136 | .items = { | |
7137 | { "Mic", 0x1 }, | |
7138 | { "Front Mic", 0x0 }, | |
7139 | { "Line", 0x2 }, | |
7140 | { "CD", 0x4 }, | |
7141 | }, | |
7142 | }; | |
7143 | ||
bc9f98a9 KY |
7144 | static struct hda_input_mux alc883_lenovo_101e_capture_source = { |
7145 | .num_items = 2, | |
7146 | .items = { | |
7147 | { "Mic", 0x1 }, | |
7148 | { "Line", 0x2 }, | |
7149 | }, | |
7150 | }; | |
7151 | ||
272a527c KY |
7152 | static struct hda_input_mux alc883_lenovo_nb0763_capture_source = { |
7153 | .num_items = 4, | |
7154 | .items = { | |
7155 | { "Mic", 0x0 }, | |
7156 | { "iMic", 0x1 }, | |
7157 | { "Line", 0x2 }, | |
7158 | { "CD", 0x4 }, | |
7159 | }, | |
7160 | }; | |
7161 | ||
fb97dc67 J |
7162 | static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = { |
7163 | .num_items = 2, | |
7164 | .items = { | |
7165 | { "Mic", 0x0 }, | |
7166 | { "Int Mic", 0x1 }, | |
7167 | }, | |
7168 | }; | |
7169 | ||
e2757d5e KY |
7170 | static struct hda_input_mux alc883_lenovo_sky_capture_source = { |
7171 | .num_items = 3, | |
7172 | .items = { | |
7173 | { "Mic", 0x0 }, | |
7174 | { "Front Mic", 0x1 }, | |
7175 | { "Line", 0x4 }, | |
7176 | }, | |
7177 | }; | |
7178 | ||
7179 | static struct hda_input_mux alc883_asus_eee1601_capture_source = { | |
7180 | .num_items = 2, | |
7181 | .items = { | |
7182 | { "Mic", 0x0 }, | |
7183 | { "Line", 0x2 }, | |
7184 | }, | |
7185 | }; | |
7186 | ||
9c7f852e TI |
7187 | /* |
7188 | * 2ch mode | |
7189 | */ | |
7190 | static struct hda_channel_mode alc883_3ST_2ch_modes[1] = { | |
7191 | { 2, NULL } | |
7192 | }; | |
7193 | ||
7194 | /* | |
7195 | * 2ch mode | |
7196 | */ | |
7197 | static struct hda_verb alc883_3ST_ch2_init[] = { | |
7198 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
7199 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7200 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
7201 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7202 | { } /* end */ | |
7203 | }; | |
7204 | ||
b201131c TD |
7205 | /* |
7206 | * 4ch mode | |
7207 | */ | |
7208 | static struct hda_verb alc883_3ST_ch4_init[] = { | |
7209 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
7210 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7211 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7212 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7213 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
7214 | { } /* end */ | |
7215 | }; | |
7216 | ||
9c7f852e TI |
7217 | /* |
7218 | * 6ch mode | |
7219 | */ | |
7220 | static struct hda_verb alc883_3ST_ch6_init[] = { | |
7221 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7222 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7223 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
7224 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7225 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7226 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
7227 | { } /* end */ | |
7228 | }; | |
7229 | ||
b201131c | 7230 | static struct hda_channel_mode alc883_3ST_6ch_modes[3] = { |
9c7f852e | 7231 | { 2, alc883_3ST_ch2_init }, |
b201131c | 7232 | { 4, alc883_3ST_ch4_init }, |
9c7f852e TI |
7233 | { 6, alc883_3ST_ch6_init }, |
7234 | }; | |
7235 | ||
17bba1b7 J |
7236 | /* |
7237 | * 2ch mode | |
7238 | */ | |
7239 | static struct hda_verb alc883_3ST_ch2_intel_init[] = { | |
7240 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
7241 | { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7242 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
7243 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7244 | { } /* end */ | |
7245 | }; | |
7246 | ||
7247 | /* | |
7248 | * 4ch mode | |
7249 | */ | |
7250 | static struct hda_verb alc883_3ST_ch4_intel_init[] = { | |
7251 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
7252 | { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7253 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7254 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7255 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
7256 | { } /* end */ | |
7257 | }; | |
7258 | ||
7259 | /* | |
7260 | * 6ch mode | |
7261 | */ | |
7262 | static struct hda_verb alc883_3ST_ch6_intel_init[] = { | |
7263 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7264 | { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7265 | { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
7266 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7267 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7268 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
7269 | { } /* end */ | |
7270 | }; | |
7271 | ||
7272 | static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = { | |
7273 | { 2, alc883_3ST_ch2_intel_init }, | |
7274 | { 4, alc883_3ST_ch4_intel_init }, | |
7275 | { 6, alc883_3ST_ch6_intel_init }, | |
7276 | }; | |
7277 | ||
9c7f852e TI |
7278 | /* |
7279 | * 6ch mode | |
7280 | */ | |
7281 | static struct hda_verb alc883_sixstack_ch6_init[] = { | |
7282 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
7283 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7284 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7285 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7286 | { } /* end */ | |
7287 | }; | |
7288 | ||
7289 | /* | |
7290 | * 8ch mode | |
7291 | */ | |
7292 | static struct hda_verb alc883_sixstack_ch8_init[] = { | |
7293 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7294 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7295 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7296 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7297 | { } /* end */ | |
7298 | }; | |
7299 | ||
7300 | static struct hda_channel_mode alc883_sixstack_modes[2] = { | |
7301 | { 6, alc883_sixstack_ch6_init }, | |
7302 | { 8, alc883_sixstack_ch8_init }, | |
7303 | }; | |
7304 | ||
b373bdeb AN |
7305 | static struct hda_verb alc883_medion_eapd_verbs[] = { |
7306 | /* eanable EAPD on medion laptop */ | |
7307 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
7308 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
7309 | { } | |
7310 | }; | |
7311 | ||
9c7f852e TI |
7312 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
7313 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
7314 | */ | |
7315 | ||
7316 | static struct snd_kcontrol_new alc883_base_mixer[] = { | |
df694daa | 7317 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9c7f852e TI |
7318 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
7319 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7320 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
7321 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
7322 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
7323 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
7324 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
7325 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
7326 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
7327 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
df694daa KY |
7328 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
7329 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7330 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7331 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7332 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 7333 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
df694daa | 7334 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
9c7f852e | 7335 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
32360416 | 7336 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
7337 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
7338 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
7339 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
df694daa | 7340 | { } /* end */ |
834be88d TI |
7341 | }; |
7342 | ||
a8848bd6 AS |
7343 | static struct snd_kcontrol_new alc883_mitac_mixer[] = { |
7344 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7345 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
7346 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
7347 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
7348 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
7349 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
7350 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
7351 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7352 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7353 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7354 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7355 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
7356 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
a8848bd6 AS |
7357 | { } /* end */ |
7358 | }; | |
7359 | ||
0c4cc443 | 7360 | static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = { |
368c7a95 J |
7361 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
7362 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
7363 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7364 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
7365 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7366 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7367 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7368 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7369 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
7370 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
368c7a95 J |
7371 | { } /* end */ |
7372 | }; | |
7373 | ||
fb97dc67 J |
7374 | static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = { |
7375 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7376 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
7377 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7378 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
7379 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7380 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7381 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7382 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7383 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
7384 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
fb97dc67 J |
7385 | { } /* end */ |
7386 | }; | |
7387 | ||
9c7f852e TI |
7388 | static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = { |
7389 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7390 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
7391 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7392 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7393 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7394 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7395 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7396 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 7397 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
7398 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
7399 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 7400 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
7401 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
7402 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
7403 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
9c7f852e TI |
7404 | { } /* end */ |
7405 | }; | |
df694daa | 7406 | |
9c7f852e TI |
7407 | static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = { |
7408 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7409 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
7410 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7411 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
7412 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
7413 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
7414 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
7415 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
7416 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7417 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7418 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7419 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7420 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7421 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 7422 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
7423 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
7424 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 7425 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
7426 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
7427 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
7428 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
9c7f852e TI |
7429 | { } /* end */ |
7430 | }; | |
7431 | ||
17bba1b7 J |
7432 | static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = { |
7433 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7434 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
7435 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7436 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
7437 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, | |
7438 | 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", 0x15, 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, 0x1, HDA_INPUT), | |
7448 | HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT), | |
7449 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
7450 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7451 | HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT), | |
7452 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, 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), | |
17bba1b7 J |
7455 | { } /* end */ |
7456 | }; | |
7457 | ||
d1d985f0 | 7458 | static struct snd_kcontrol_new alc883_fivestack_mixer[] = { |
c07584c8 | 7459 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
0701e064 | 7460 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
c07584c8 | 7461 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
0701e064 | 7462 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
c07584c8 TD |
7463 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
7464 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
0701e064 TI |
7465 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
7466 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
c07584c8 TD |
7467 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
7468 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7469 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7470 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7471 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7472 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 7473 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
c07584c8 TD |
7474 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
7475 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 7476 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
c07584c8 TD |
7477 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
7478 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
7479 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
c07584c8 TD |
7480 | { } /* end */ |
7481 | }; | |
7482 | ||
ccc656ce KY |
7483 | static struct snd_kcontrol_new alc883_tagra_mixer[] = { |
7484 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7485 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7486 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7487 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7488 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
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), | |
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), | |
7493 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7494 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7495 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7496 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7497 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 7498 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce | 7499 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
ccc656ce | 7500 | { } /* end */ |
f12ab1e0 | 7501 | }; |
ccc656ce KY |
7502 | |
7503 | static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = { | |
7504 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7505 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7506 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7507 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7508 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7509 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 7510 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce | 7511 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
4383fae0 J |
7512 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
7513 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
7514 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
ccc656ce | 7515 | { } /* end */ |
f12ab1e0 | 7516 | }; |
ccc656ce | 7517 | |
bc9f98a9 KY |
7518 | static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = { |
7519 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7520 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
86cd9298 TI |
7521 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
7522 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
bc9f98a9 KY |
7523 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
7524 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7525 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7526 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
bc9f98a9 | 7527 | { } /* end */ |
f12ab1e0 | 7528 | }; |
bc9f98a9 | 7529 | |
272a527c KY |
7530 | static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = { |
7531 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7532 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT), | |
7533 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7534 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7535 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7536 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7537 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7538 | HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7539 | HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
272a527c KY |
7540 | { } /* end */ |
7541 | }; | |
7542 | ||
7543 | static struct snd_kcontrol_new alc883_medion_md2_mixer[] = { | |
7544 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7545 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7546 | HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
7547 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7548 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7549 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7550 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7551 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7552 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
272a527c | 7553 | { } /* end */ |
ea1fb29a | 7554 | }; |
272a527c | 7555 | |
2880a867 | 7556 | static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = { |
d1a991a6 KY |
7557 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
7558 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
2880a867 | 7559 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), |
2880a867 TD |
7560 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
7561 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
d1a991a6 KY |
7562 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
7563 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7564 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2880a867 | 7565 | { } /* end */ |
d1a991a6 | 7566 | }; |
2880a867 | 7567 | |
e2757d5e KY |
7568 | static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = { |
7569 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7570 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
7571 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT), | |
7572 | HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT), | |
7573 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", | |
7574 | 0x0d, 1, 0x0, HDA_OUTPUT), | |
7575 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT), | |
7576 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT), | |
7577 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), | |
7578 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
7579 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
7580 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7581 | HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT), | |
7582 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7583 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7584 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7585 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7586 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7587 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7588 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7589 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7590 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
7591 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
e2757d5e KY |
7592 | { } /* end */ |
7593 | }; | |
7594 | ||
7595 | static struct hda_bind_ctls alc883_bind_cap_vol = { | |
7596 | .ops = &snd_hda_bind_vol, | |
7597 | .values = { | |
7598 | HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT), | |
7599 | HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT), | |
7600 | 0 | |
7601 | }, | |
7602 | }; | |
7603 | ||
7604 | static struct hda_bind_ctls alc883_bind_cap_switch = { | |
7605 | .ops = &snd_hda_bind_sw, | |
7606 | .values = { | |
7607 | HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT), | |
7608 | HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT), | |
7609 | 0 | |
7610 | }, | |
7611 | }; | |
7612 | ||
7613 | static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = { | |
7614 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7615 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
7616 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7617 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7618 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7619 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7620 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7621 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
f9e336f6 TI |
7622 | { } /* end */ |
7623 | }; | |
7624 | ||
7625 | static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = { | |
e2757d5e KY |
7626 | HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol), |
7627 | HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch), | |
7628 | { | |
7629 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7630 | /* .name = "Capture Source", */ | |
7631 | .name = "Input Source", | |
7632 | .count = 1, | |
54cbc9ab TI |
7633 | .info = alc_mux_enum_info, |
7634 | .get = alc_mux_enum_get, | |
7635 | .put = alc_mux_enum_put, | |
e2757d5e KY |
7636 | }, |
7637 | { } /* end */ | |
7638 | }; | |
7639 | ||
9c7f852e TI |
7640 | static struct snd_kcontrol_new alc883_chmode_mixer[] = { |
7641 | { | |
7642 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7643 | .name = "Channel Mode", | |
7644 | .info = alc_ch_mode_info, | |
7645 | .get = alc_ch_mode_get, | |
7646 | .put = alc_ch_mode_put, | |
7647 | }, | |
7648 | { } /* end */ | |
7649 | }; | |
7650 | ||
7651 | static struct hda_verb alc883_init_verbs[] = { | |
7652 | /* ADC1: mute amp left and right */ | |
e2757d5e | 7653 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
df694daa | 7654 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
9c7f852e TI |
7655 | /* ADC2: mute amp left and right */ |
7656 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
df694daa | 7657 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
9c7f852e TI |
7658 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ |
7659 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7660 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7661 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7662 | /* Rear mixer */ | |
7663 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7664 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7665 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7666 | /* CLFE mixer */ | |
7667 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7668 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7669 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7670 | /* Side mixer */ | |
7671 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7672 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7673 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
df694daa | 7674 | |
cb53c626 TI |
7675 | /* mute analog input loopbacks */ |
7676 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7677 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7678 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
7679 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
7680 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa | 7681 | |
9c7f852e TI |
7682 | /* Front Pin: output 0 (0x0c) */ |
7683 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7684 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7685 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7686 | /* Rear Pin: output 1 (0x0d) */ | |
7687 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7688 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7689 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
7690 | /* CLFE Pin: output 2 (0x0e) */ | |
7691 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7692 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7693 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
7694 | /* Side Pin: output 3 (0x0f) */ | |
7695 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7696 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7697 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
7698 | /* Mic (rear) pin: input vref at 80% */ | |
7699 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
7700 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
7701 | /* Front Mic pin: input vref at 80% */ | |
7702 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
7703 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
7704 | /* Line In pin: input */ | |
7705 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
7706 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
7707 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
7708 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7709 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7710 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7711 | /* CD pin widget for input */ | |
7712 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
7713 | ||
7714 | /* FIXME: use matrix-type input source selection */ | |
7715 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
7716 | /* Input mixer2 */ | |
7717 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
e2757d5e KY |
7718 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
7719 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
7720 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9c7f852e TI |
7721 | /* Input mixer3 */ |
7722 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
e2757d5e KY |
7723 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
7724 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
7725 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9c7f852e TI |
7726 | { } |
7727 | }; | |
7728 | ||
a8848bd6 AS |
7729 | /* toggle speaker-output according to the hp-jack state */ |
7730 | static void alc883_mitac_hp_automute(struct hda_codec *codec) | |
7731 | { | |
7732 | unsigned int present; | |
7733 | ||
7734 | present = snd_hda_codec_read(codec, 0x15, 0, | |
7735 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
7736 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
7737 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7738 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
7739 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7740 | } | |
7741 | ||
7742 | /* auto-toggle front mic */ | |
7743 | /* | |
7744 | static void alc883_mitac_mic_automute(struct hda_codec *codec) | |
7745 | { | |
7746 | unsigned int present; | |
7747 | unsigned char bits; | |
7748 | ||
7749 | present = snd_hda_codec_read(codec, 0x18, 0, | |
7750 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
7751 | bits = present ? HDA_AMP_MUTE : 0; | |
7752 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); | |
7753 | } | |
7754 | */ | |
7755 | ||
7756 | static void alc883_mitac_automute(struct hda_codec *codec) | |
7757 | { | |
7758 | alc883_mitac_hp_automute(codec); | |
7759 | /* alc883_mitac_mic_automute(codec); */ | |
7760 | } | |
7761 | ||
7762 | static void alc883_mitac_unsol_event(struct hda_codec *codec, | |
7763 | unsigned int res) | |
7764 | { | |
7765 | switch (res >> 26) { | |
7766 | case ALC880_HP_EVENT: | |
7767 | alc883_mitac_hp_automute(codec); | |
7768 | break; | |
7769 | case ALC880_MIC_EVENT: | |
7770 | /* alc883_mitac_mic_automute(codec); */ | |
7771 | break; | |
7772 | } | |
7773 | } | |
7774 | ||
7775 | static struct hda_verb alc883_mitac_verbs[] = { | |
7776 | /* HP */ | |
7777 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7778 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7779 | /* Subwoofer */ | |
7780 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
7781 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7782 | ||
7783 | /* enable unsolicited event */ | |
7784 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7785 | /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */ | |
7786 | ||
7787 | { } /* end */ | |
7788 | }; | |
7789 | ||
0c4cc443 | 7790 | static struct hda_verb alc883_clevo_m720_verbs[] = { |
368c7a95 J |
7791 | /* HP */ |
7792 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7793 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7794 | /* Int speaker */ | |
7795 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
7796 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7797 | ||
7798 | /* enable unsolicited event */ | |
7799 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
0c4cc443 | 7800 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, |
368c7a95 J |
7801 | |
7802 | { } /* end */ | |
7803 | }; | |
7804 | ||
fb97dc67 J |
7805 | static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = { |
7806 | /* HP */ | |
7807 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7808 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7809 | /* Subwoofer */ | |
7810 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
7811 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7812 | ||
7813 | /* enable unsolicited event */ | |
7814 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7815 | ||
7816 | { } /* end */ | |
7817 | }; | |
7818 | ||
ccc656ce KY |
7819 | static struct hda_verb alc883_tagra_verbs[] = { |
7820 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7821 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7822 | ||
7823 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7824 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
ea1fb29a | 7825 | |
ccc656ce KY |
7826 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ |
7827 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
7828 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
7829 | ||
7830 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
f12ab1e0 TI |
7831 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
7832 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | |
7833 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | |
ccc656ce KY |
7834 | |
7835 | { } /* end */ | |
7836 | }; | |
7837 | ||
bc9f98a9 KY |
7838 | static struct hda_verb alc883_lenovo_101e_verbs[] = { |
7839 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7840 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN}, | |
7841 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN}, | |
7842 | { } /* end */ | |
7843 | }; | |
7844 | ||
272a527c KY |
7845 | static struct hda_verb alc883_lenovo_nb0763_verbs[] = { |
7846 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7847 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7848 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7849 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7850 | { } /* end */ | |
7851 | }; | |
7852 | ||
7853 | static struct hda_verb alc888_lenovo_ms7195_verbs[] = { | |
7854 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7855 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7856 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7857 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN}, | |
7858 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7859 | { } /* end */ | |
7860 | }; | |
7861 | ||
189609ae KY |
7862 | static struct hda_verb alc883_haier_w66_verbs[] = { |
7863 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7864 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7865 | ||
7866 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7867 | ||
7868 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7869 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7870 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7871 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7872 | { } /* end */ | |
7873 | }; | |
7874 | ||
e2757d5e KY |
7875 | static struct hda_verb alc888_lenovo_sky_verbs[] = { |
7876 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7877 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7878 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7879 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7880 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7881 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7882 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7883 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7884 | { } /* end */ | |
7885 | }; | |
7886 | ||
4723c022 | 7887 | static struct hda_verb alc888_3st_hp_verbs[] = { |
8341de60 | 7888 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */ |
f32a19e3 HRK |
7889 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */ |
7890 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */ | |
8341de60 CM |
7891 | { } |
7892 | }; | |
7893 | ||
5795b9e6 | 7894 | static struct hda_verb alc888_6st_dell_verbs[] = { |
5795b9e6 CM |
7895 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
7896 | { } | |
7897 | }; | |
7898 | ||
4723c022 | 7899 | static struct hda_verb alc888_3st_hp_2ch_init[] = { |
8341de60 CM |
7900 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
7901 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7902 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
7903 | { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7904 | { } | |
7905 | }; | |
7906 | ||
4723c022 | 7907 | static struct hda_verb alc888_3st_hp_6ch_init[] = { |
8341de60 CM |
7908 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
7909 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7910 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7911 | { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7912 | { } | |
7913 | }; | |
7914 | ||
4723c022 CM |
7915 | static struct hda_channel_mode alc888_3st_hp_modes[2] = { |
7916 | { 2, alc888_3st_hp_2ch_init }, | |
7917 | { 6, alc888_3st_hp_6ch_init }, | |
8341de60 CM |
7918 | }; |
7919 | ||
272a527c KY |
7920 | /* toggle front-jack and RCA according to the hp-jack state */ |
7921 | static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec) | |
7922 | { | |
7923 | unsigned int present; | |
ea1fb29a | 7924 | |
272a527c KY |
7925 | present = snd_hda_codec_read(codec, 0x1b, 0, |
7926 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
7927 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
7928 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7929 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
7930 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c KY |
7931 | } |
7932 | ||
7933 | /* toggle RCA according to the front-jack state */ | |
7934 | static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec) | |
7935 | { | |
7936 | unsigned int present; | |
ea1fb29a | 7937 | |
272a527c KY |
7938 | present = snd_hda_codec_read(codec, 0x14, 0, |
7939 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
7940 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
7941 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c | 7942 | } |
47fd830a | 7943 | |
272a527c KY |
7944 | static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec, |
7945 | unsigned int res) | |
7946 | { | |
7947 | if ((res >> 26) == ALC880_HP_EVENT) | |
7948 | alc888_lenovo_ms7195_front_automute(codec); | |
7949 | if ((res >> 26) == ALC880_FRONT_EVENT) | |
7950 | alc888_lenovo_ms7195_rca_automute(codec); | |
7951 | } | |
7952 | ||
7953 | static struct hda_verb alc883_medion_md2_verbs[] = { | |
7954 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7955 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7956 | ||
7957 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7958 | ||
7959 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7960 | { } /* end */ | |
7961 | }; | |
7962 | ||
7963 | /* toggle speaker-output according to the hp-jack state */ | |
7964 | static void alc883_medion_md2_automute(struct hda_codec *codec) | |
7965 | { | |
7966 | unsigned int present; | |
ea1fb29a | 7967 | |
272a527c KY |
7968 | present = snd_hda_codec_read(codec, 0x14, 0, |
7969 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
7970 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
7971 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c KY |
7972 | } |
7973 | ||
7974 | static void alc883_medion_md2_unsol_event(struct hda_codec *codec, | |
7975 | unsigned int res) | |
7976 | { | |
7977 | if ((res >> 26) == ALC880_HP_EVENT) | |
7978 | alc883_medion_md2_automute(codec); | |
7979 | } | |
7980 | ||
ccc656ce KY |
7981 | /* toggle speaker-output according to the hp-jack state */ |
7982 | static void alc883_tagra_automute(struct hda_codec *codec) | |
7983 | { | |
7984 | unsigned int present; | |
f12ab1e0 | 7985 | unsigned char bits; |
ccc656ce KY |
7986 | |
7987 | present = snd_hda_codec_read(codec, 0x14, 0, | |
7988 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
7989 | bits = present ? HDA_AMP_MUTE : 0; |
7990 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
7991 | HDA_AMP_MUTE, bits); | |
82beb8fd TI |
7992 | snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA, |
7993 | present ? 1 : 3); | |
ccc656ce KY |
7994 | } |
7995 | ||
7996 | static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res) | |
7997 | { | |
7998 | if ((res >> 26) == ALC880_HP_EVENT) | |
7999 | alc883_tagra_automute(codec); | |
8000 | } | |
8001 | ||
368c7a95 | 8002 | /* toggle speaker-output according to the hp-jack state */ |
0c4cc443 | 8003 | static void alc883_clevo_m720_hp_automute(struct hda_codec *codec) |
368c7a95 J |
8004 | { |
8005 | unsigned int present; | |
8006 | unsigned char bits; | |
8007 | ||
8008 | present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0) | |
8009 | & AC_PINSENSE_PRESENCE; | |
8010 | bits = present ? HDA_AMP_MUTE : 0; | |
8011 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
8012 | HDA_AMP_MUTE, bits); | |
8013 | } | |
8014 | ||
0c4cc443 HRK |
8015 | static void alc883_clevo_m720_mic_automute(struct hda_codec *codec) |
8016 | { | |
8017 | unsigned int present; | |
8018 | ||
8019 | present = snd_hda_codec_read(codec, 0x18, 0, | |
8020 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
8021 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, | |
8022 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
8023 | } | |
8024 | ||
8025 | static void alc883_clevo_m720_automute(struct hda_codec *codec) | |
8026 | { | |
8027 | alc883_clevo_m720_hp_automute(codec); | |
8028 | alc883_clevo_m720_mic_automute(codec); | |
8029 | } | |
8030 | ||
8031 | static void alc883_clevo_m720_unsol_event(struct hda_codec *codec, | |
368c7a95 J |
8032 | unsigned int res) |
8033 | { | |
0c4cc443 HRK |
8034 | switch (res >> 26) { |
8035 | case ALC880_HP_EVENT: | |
8036 | alc883_clevo_m720_hp_automute(codec); | |
8037 | break; | |
8038 | case ALC880_MIC_EVENT: | |
8039 | alc883_clevo_m720_mic_automute(codec); | |
8040 | break; | |
8041 | } | |
368c7a95 J |
8042 | } |
8043 | ||
fb97dc67 J |
8044 | /* toggle speaker-output according to the hp-jack state */ |
8045 | static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec) | |
8046 | { | |
8047 | unsigned int present; | |
8048 | unsigned char bits; | |
8049 | ||
8050 | present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0) | |
8051 | & AC_PINSENSE_PRESENCE; | |
8052 | bits = present ? HDA_AMP_MUTE : 0; | |
8053 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
8054 | HDA_AMP_MUTE, bits); | |
8055 | } | |
8056 | ||
8057 | static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec, | |
8058 | unsigned int res) | |
8059 | { | |
8060 | if ((res >> 26) == ALC880_HP_EVENT) | |
8061 | alc883_2ch_fujitsu_pi2515_automute(codec); | |
8062 | } | |
8063 | ||
189609ae KY |
8064 | static void alc883_haier_w66_automute(struct hda_codec *codec) |
8065 | { | |
8066 | unsigned int present; | |
8067 | unsigned char bits; | |
8068 | ||
8069 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
8070 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
8071 | bits = present ? 0x80 : 0; | |
8072 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
8073 | 0x80, bits); | |
8074 | } | |
8075 | ||
8076 | static void alc883_haier_w66_unsol_event(struct hda_codec *codec, | |
8077 | unsigned int res) | |
8078 | { | |
8079 | if ((res >> 26) == ALC880_HP_EVENT) | |
8080 | alc883_haier_w66_automute(codec); | |
8081 | } | |
8082 | ||
bc9f98a9 KY |
8083 | static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec) |
8084 | { | |
8085 | unsigned int present; | |
f12ab1e0 | 8086 | unsigned char bits; |
bc9f98a9 KY |
8087 | |
8088 | present = snd_hda_codec_read(codec, 0x14, 0, | |
8089 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
8090 | bits = present ? HDA_AMP_MUTE : 0; |
8091 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
8092 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
8093 | } |
8094 | ||
8095 | static void alc883_lenovo_101e_all_automute(struct hda_codec *codec) | |
8096 | { | |
8097 | unsigned int present; | |
f12ab1e0 | 8098 | unsigned char bits; |
bc9f98a9 KY |
8099 | |
8100 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
8101 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
8102 | bits = present ? HDA_AMP_MUTE : 0; |
8103 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
8104 | HDA_AMP_MUTE, bits); | |
8105 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
8106 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
8107 | } |
8108 | ||
8109 | static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec, | |
8110 | unsigned int res) | |
8111 | { | |
8112 | if ((res >> 26) == ALC880_HP_EVENT) | |
8113 | alc883_lenovo_101e_all_automute(codec); | |
8114 | if ((res >> 26) == ALC880_FRONT_EVENT) | |
8115 | alc883_lenovo_101e_ispeaker_automute(codec); | |
8116 | } | |
8117 | ||
676a9b53 TI |
8118 | /* toggle speaker-output according to the hp-jack state */ |
8119 | static void alc883_acer_aspire_automute(struct hda_codec *codec) | |
8120 | { | |
8121 | unsigned int present; | |
ea1fb29a | 8122 | |
676a9b53 TI |
8123 | present = snd_hda_codec_read(codec, 0x14, 0, |
8124 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
8125 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
8126 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
8127 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
8128 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
8129 | } | |
8130 | ||
8131 | static void alc883_acer_aspire_unsol_event(struct hda_codec *codec, | |
8132 | unsigned int res) | |
8133 | { | |
8134 | if ((res >> 26) == ALC880_HP_EVENT) | |
8135 | alc883_acer_aspire_automute(codec); | |
8136 | } | |
8137 | ||
d1a991a6 KY |
8138 | static struct hda_verb alc883_acer_eapd_verbs[] = { |
8139 | /* HP Pin: output 0 (0x0c) */ | |
8140 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
8141 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8142 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8143 | /* Front Pin: output 0 (0x0c) */ | |
676a9b53 TI |
8144 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
8145 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
d1a991a6 | 8146 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
d1a991a6 KY |
8147 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, |
8148 | /* eanable EAPD on medion laptop */ | |
8149 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
8150 | {0x20, AC_VERB_SET_PROC_COEF, 0x3050}, | |
676a9b53 TI |
8151 | /* enable unsolicited event */ |
8152 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
d1a991a6 KY |
8153 | { } |
8154 | }; | |
8155 | ||
5795b9e6 CM |
8156 | static void alc888_6st_dell_front_automute(struct hda_codec *codec) |
8157 | { | |
8158 | unsigned int present; | |
ea1fb29a | 8159 | |
5795b9e6 CM |
8160 | present = snd_hda_codec_read(codec, 0x1b, 0, |
8161 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
8162 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
8163 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
8164 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
8165 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
8166 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
8167 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
8168 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
8169 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
8170 | } | |
8171 | ||
8172 | static void alc888_6st_dell_unsol_event(struct hda_codec *codec, | |
8173 | unsigned int res) | |
8174 | { | |
8175 | switch (res >> 26) { | |
8176 | case ALC880_HP_EVENT: | |
8177 | printk("hp_event\n"); | |
8178 | alc888_6st_dell_front_automute(codec); | |
8179 | break; | |
8180 | } | |
8181 | } | |
8182 | ||
e2757d5e KY |
8183 | static void alc888_lenovo_sky_front_automute(struct hda_codec *codec) |
8184 | { | |
8185 | unsigned int mute; | |
8186 | unsigned int present; | |
8187 | ||
8188 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); | |
8189 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
8190 | AC_VERB_GET_PIN_SENSE, 0); | |
8191 | present = (present & 0x80000000) != 0; | |
8192 | if (present) { | |
8193 | /* mute internal speaker */ | |
8194 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
8195 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
8196 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
8197 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
8198 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
8199 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
8200 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
8201 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
8202 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, | |
8203 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
8204 | } else { | |
8205 | /* unmute internal speaker if necessary */ | |
8206 | mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); | |
8207 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
8208 | HDA_AMP_MUTE, mute); | |
8209 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
8210 | HDA_AMP_MUTE, mute); | |
8211 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
8212 | HDA_AMP_MUTE, mute); | |
8213 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
8214 | HDA_AMP_MUTE, mute); | |
8215 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, | |
8216 | HDA_AMP_MUTE, mute); | |
8217 | } | |
8218 | } | |
8219 | ||
8220 | static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec, | |
8221 | unsigned int res) | |
8222 | { | |
8223 | if ((res >> 26) == ALC880_HP_EVENT) | |
8224 | alc888_lenovo_sky_front_automute(codec); | |
8225 | } | |
8226 | ||
9c7f852e TI |
8227 | /* |
8228 | * generic initialization of ADC, input mixers and output mixers | |
8229 | */ | |
8230 | static struct hda_verb alc883_auto_init_verbs[] = { | |
8231 | /* | |
8232 | * Unmute ADC0-2 and set the default input to mic-in | |
8233 | */ | |
8234 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8235 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8236 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8237 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8238 | ||
cb53c626 | 8239 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
9c7f852e | 8240 | * mixer widget |
f12ab1e0 TI |
8241 | * Note: PASD motherboards uses the Line In 2 as the input for |
8242 | * front panel mic (mic 2) | |
9c7f852e TI |
8243 | */ |
8244 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
8245 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
8246 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
8247 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
8248 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
8249 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9c7f852e TI |
8250 | |
8251 | /* | |
8252 | * Set up output mixers (0x0c - 0x0f) | |
8253 | */ | |
8254 | /* set vol=0 to output mixers */ | |
8255 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8256 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8257 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8258 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8259 | /* set up input amps for analog loopback */ | |
8260 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
8261 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8262 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8263 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8264 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8265 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8266 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8267 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8268 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8269 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8270 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8271 | ||
8272 | /* FIXME: use matrix-type input source selection */ | |
8273 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
8274 | /* Input mixer1 */ | |
8275 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8276 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8277 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 8278 | /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */ |
9c7f852e TI |
8279 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
8280 | /* Input mixer2 */ | |
8281 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8282 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8283 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 8284 | /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */ |
e3cde64a | 8285 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
9c7f852e TI |
8286 | |
8287 | { } | |
8288 | }; | |
8289 | ||
e2757d5e KY |
8290 | static struct hda_verb alc888_asus_m90v_verbs[] = { |
8291 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
8292 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
8293 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8294 | /* enable unsolicited event */ | |
8295 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
8296 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, | |
8297 | { } /* end */ | |
8298 | }; | |
8299 | ||
8300 | static void alc883_nb_mic_automute(struct hda_codec *codec) | |
8301 | { | |
8302 | unsigned int present; | |
8303 | ||
8304 | present = snd_hda_codec_read(codec, 0x18, 0, | |
8305 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
8306 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
8307 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | |
8308 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
8309 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); | |
8310 | } | |
8311 | ||
8312 | static void alc883_M90V_speaker_automute(struct hda_codec *codec) | |
8313 | { | |
8314 | unsigned int present; | |
8315 | unsigned char bits; | |
8316 | ||
8317 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
8318 | AC_VERB_GET_PIN_SENSE, 0) | |
8319 | & AC_PINSENSE_PRESENCE; | |
8320 | bits = present ? 0 : PIN_OUT; | |
8321 | snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8322 | bits); | |
8323 | snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8324 | bits); | |
8325 | snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8326 | bits); | |
8327 | } | |
8328 | ||
8329 | static void alc883_mode2_unsol_event(struct hda_codec *codec, | |
8330 | unsigned int res) | |
8331 | { | |
8332 | switch (res >> 26) { | |
8333 | case ALC880_HP_EVENT: | |
8334 | alc883_M90V_speaker_automute(codec); | |
8335 | break; | |
8336 | case ALC880_MIC_EVENT: | |
8337 | alc883_nb_mic_automute(codec); | |
8338 | break; | |
8339 | } | |
8340 | } | |
8341 | ||
8342 | static void alc883_mode2_inithook(struct hda_codec *codec) | |
8343 | { | |
8344 | alc883_M90V_speaker_automute(codec); | |
8345 | alc883_nb_mic_automute(codec); | |
8346 | } | |
8347 | ||
8348 | static struct hda_verb alc888_asus_eee1601_verbs[] = { | |
8349 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
8350 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
8351 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
8352 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8353 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
8354 | {0x20, AC_VERB_SET_COEF_INDEX, 0x0b}, | |
8355 | {0x20, AC_VERB_SET_PROC_COEF, 0x0838}, | |
8356 | /* enable unsolicited event */ | |
8357 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
8358 | { } /* end */ | |
8359 | }; | |
8360 | ||
8361 | static void alc883_eee1601_speaker_automute(struct hda_codec *codec) | |
8362 | { | |
8363 | unsigned int present; | |
8364 | unsigned char bits; | |
8365 | ||
8366 | present = snd_hda_codec_read(codec, 0x14, 0, | |
8367 | AC_VERB_GET_PIN_SENSE, 0) | |
8368 | & AC_PINSENSE_PRESENCE; | |
8369 | bits = present ? 0 : PIN_OUT; | |
8370 | snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8371 | bits); | |
8372 | } | |
8373 | ||
8374 | static void alc883_eee1601_unsol_event(struct hda_codec *codec, | |
8375 | unsigned int res) | |
8376 | { | |
8377 | switch (res >> 26) { | |
8378 | case ALC880_HP_EVENT: | |
8379 | alc883_eee1601_speaker_automute(codec); | |
8380 | break; | |
8381 | } | |
8382 | } | |
8383 | ||
8384 | static void alc883_eee1601_inithook(struct hda_codec *codec) | |
8385 | { | |
8386 | alc883_eee1601_speaker_automute(codec); | |
8387 | } | |
8388 | ||
cb53c626 TI |
8389 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
8390 | #define alc883_loopbacks alc880_loopbacks | |
8391 | #endif | |
8392 | ||
9c7f852e TI |
8393 | /* pcm configuration: identiacal with ALC880 */ |
8394 | #define alc883_pcm_analog_playback alc880_pcm_analog_playback | |
8395 | #define alc883_pcm_analog_capture alc880_pcm_analog_capture | |
6330079f | 8396 | #define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture |
9c7f852e TI |
8397 | #define alc883_pcm_digital_playback alc880_pcm_digital_playback |
8398 | #define alc883_pcm_digital_capture alc880_pcm_digital_capture | |
8399 | ||
8400 | /* | |
8401 | * configuration and preset | |
8402 | */ | |
f5fcc13c TI |
8403 | static const char *alc883_models[ALC883_MODEL_LAST] = { |
8404 | [ALC883_3ST_2ch_DIG] = "3stack-dig", | |
8405 | [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig", | |
8406 | [ALC883_3ST_6ch] = "3stack-6ch", | |
8407 | [ALC883_6ST_DIG] = "6stack-dig", | |
8408 | [ALC883_TARGA_DIG] = "targa-dig", | |
8409 | [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig", | |
f5fcc13c | 8410 | [ALC883_ACER] = "acer", |
2880a867 | 8411 | [ALC883_ACER_ASPIRE] = "acer-aspire", |
5b2d1eca | 8412 | [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g", |
f5fcc13c | 8413 | [ALC883_MEDION] = "medion", |
272a527c | 8414 | [ALC883_MEDION_MD2] = "medion-md2", |
f5fcc13c | 8415 | [ALC883_LAPTOP_EAPD] = "laptop-eapd", |
bc9f98a9 | 8416 | [ALC883_LENOVO_101E_2ch] = "lenovo-101e", |
272a527c KY |
8417 | [ALC883_LENOVO_NB0763] = "lenovo-nb0763", |
8418 | [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig", | |
e2757d5e | 8419 | [ALC888_LENOVO_SKY] = "lenovo-sky", |
189609ae | 8420 | [ALC883_HAIER_W66] = "haier-w66", |
4723c022 | 8421 | [ALC888_3ST_HP] = "3stack-hp", |
5795b9e6 | 8422 | [ALC888_6ST_DELL] = "6stack-dell", |
a8848bd6 | 8423 | [ALC883_MITAC] = "mitac", |
0c4cc443 | 8424 | [ALC883_CLEVO_M720] = "clevo-m720", |
fb97dc67 | 8425 | [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515", |
ef8ef5fb | 8426 | [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530", |
17bba1b7 | 8427 | [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel", |
3ab90935 | 8428 | [ALC1200_ASUS_P5Q] = "asus-p5q", |
f5fcc13c TI |
8429 | [ALC883_AUTO] = "auto", |
8430 | }; | |
8431 | ||
8432 | static struct snd_pci_quirk alc883_cfg_tbl[] = { | |
8433 | SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG), | |
ac3e3741 | 8434 | SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE), |
69e50282 | 8435 | SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE), |
ac3e3741 TI |
8436 | SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE), |
8437 | SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE), | |
0b18cb18 | 8438 | SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE), |
5b2d1eca VP |
8439 | SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G", |
8440 | ALC888_ACER_ASPIRE_4930G), | |
ac3e3741 | 8441 | SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */ |
5795b9e6 | 8442 | SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL), |
febe3375 | 8443 | SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG), |
ac3e3741 TI |
8444 | SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP), |
8445 | SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP), | |
5d85f8d0 | 8446 | SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG), |
a01c30cb | 8447 | SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V), |
ac3e3741 | 8448 | SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG), |
3ab90935 | 8449 | SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q), |
e2757d5e | 8450 | SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601), |
97ec710c | 8451 | SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG), |
f5fcc13c | 8452 | SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG), |
ac3e3741 TI |
8453 | SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC), |
8454 | SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD), | |
e2757d5e | 8455 | SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL), |
ac3e3741 | 8456 | SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch), |
57b14f24 | 8457 | SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG), |
6f3bf657 | 8458 | SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG), |
bba8dee7 | 8459 | SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG), |
ac3e3741 | 8460 | SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG), |
4383fae0 | 8461 | SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG), |
dd146a60 | 8462 | SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG), |
82808236 | 8463 | SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG), |
f5fcc13c | 8464 | SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG), |
ac3e3741 | 8465 | SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG), |
f5fcc13c TI |
8466 | SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG), |
8467 | SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG), | |
ac3e3741 | 8468 | SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG), |
64ca1c29 | 8469 | SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG), |
f5fcc13c TI |
8470 | SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG), |
8471 | SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG), | |
8472 | SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG), | |
ac3e3741 TI |
8473 | SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG), |
8474 | SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG), | |
8475 | SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG), | |
86d34b7e | 8476 | SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG), |
ac3e3741 TI |
8477 | SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG), |
8478 | SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG), | |
f5fcc13c | 8479 | SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG), |
ac3e3741 | 8480 | SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG), |
0c4cc443 HRK |
8481 | SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720), |
8482 | SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720), | |
ac3e3741 | 8483 | SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD), |
e60623b4 | 8484 | SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch), |
f5fcc13c | 8485 | SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), |
fb97dc67 | 8486 | SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515), |
ef8ef5fb VP |
8487 | SND_PCI_QUIRK(0x1734, 0x113d, "Fujitsu AMILO Xa3530", |
8488 | ALC888_FUJITSU_XA3530), | |
272a527c | 8489 | SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch), |
272a527c | 8490 | SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763), |
ac3e3741 TI |
8491 | SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763), |
8492 | SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763), | |
e2757d5e | 8493 | SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY), |
272a527c | 8494 | SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2), |
959973b9 | 8495 | SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG), |
0b167bf4 | 8496 | SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG), |
189609ae | 8497 | SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66), |
17bba1b7 J |
8498 | SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL), |
8499 | SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL), | |
ac3e3741 | 8500 | SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), |
9c7f852e TI |
8501 | {} |
8502 | }; | |
8503 | ||
8504 | static struct alc_config_preset alc883_presets[] = { | |
8505 | [ALC883_3ST_2ch_DIG] = { | |
8506 | .mixers = { alc883_3ST_2ch_mixer }, | |
8507 | .init_verbs = { alc883_init_verbs }, | |
8508 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8509 | .dac_nids = alc883_dac_nids, | |
8510 | .dig_out_nid = ALC883_DIGOUT_NID, | |
9c7f852e TI |
8511 | .dig_in_nid = ALC883_DIGIN_NID, |
8512 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
8513 | .channel_mode = alc883_3ST_2ch_modes, | |
8514 | .input_mux = &alc883_capture_source, | |
8515 | }, | |
8516 | [ALC883_3ST_6ch_DIG] = { | |
8517 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
8518 | .init_verbs = { alc883_init_verbs }, | |
8519 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8520 | .dac_nids = alc883_dac_nids, | |
8521 | .dig_out_nid = ALC883_DIGOUT_NID, | |
9c7f852e TI |
8522 | .dig_in_nid = ALC883_DIGIN_NID, |
8523 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
8524 | .channel_mode = alc883_3ST_6ch_modes, | |
4e195a7b | 8525 | .need_dac_fix = 1, |
9c7f852e | 8526 | .input_mux = &alc883_capture_source, |
f12ab1e0 | 8527 | }, |
9c7f852e TI |
8528 | [ALC883_3ST_6ch] = { |
8529 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
8530 | .init_verbs = { alc883_init_verbs }, | |
8531 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8532 | .dac_nids = alc883_dac_nids, | |
9c7f852e TI |
8533 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), |
8534 | .channel_mode = alc883_3ST_6ch_modes, | |
4e195a7b | 8535 | .need_dac_fix = 1, |
9c7f852e | 8536 | .input_mux = &alc883_capture_source, |
f12ab1e0 | 8537 | }, |
17bba1b7 J |
8538 | [ALC883_3ST_6ch_INTEL] = { |
8539 | .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer }, | |
8540 | .init_verbs = { alc883_init_verbs }, | |
8541 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8542 | .dac_nids = alc883_dac_nids, | |
8543 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8544 | .dig_in_nid = ALC883_DIGIN_NID, | |
8545 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes), | |
8546 | .channel_mode = alc883_3ST_6ch_intel_modes, | |
8547 | .need_dac_fix = 1, | |
8548 | .input_mux = &alc883_3stack_6ch_intel, | |
8549 | }, | |
9c7f852e TI |
8550 | [ALC883_6ST_DIG] = { |
8551 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, | |
8552 | .init_verbs = { alc883_init_verbs }, | |
8553 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8554 | .dac_nids = alc883_dac_nids, | |
8555 | .dig_out_nid = ALC883_DIGOUT_NID, | |
9c7f852e TI |
8556 | .dig_in_nid = ALC883_DIGIN_NID, |
8557 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | |
8558 | .channel_mode = alc883_sixstack_modes, | |
8559 | .input_mux = &alc883_capture_source, | |
8560 | }, | |
ccc656ce KY |
8561 | [ALC883_TARGA_DIG] = { |
8562 | .mixers = { alc883_tagra_mixer, alc883_chmode_mixer }, | |
8563 | .init_verbs = { alc883_init_verbs, alc883_tagra_verbs}, | |
8564 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8565 | .dac_nids = alc883_dac_nids, | |
8566 | .dig_out_nid = ALC883_DIGOUT_NID, | |
ccc656ce KY |
8567 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), |
8568 | .channel_mode = alc883_3ST_6ch_modes, | |
8569 | .need_dac_fix = 1, | |
8570 | .input_mux = &alc883_capture_source, | |
8571 | .unsol_event = alc883_tagra_unsol_event, | |
8572 | .init_hook = alc883_tagra_automute, | |
8573 | }, | |
8574 | [ALC883_TARGA_2ch_DIG] = { | |
8575 | .mixers = { alc883_tagra_2ch_mixer}, | |
8576 | .init_verbs = { alc883_init_verbs, alc883_tagra_verbs}, | |
8577 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8578 | .dac_nids = alc883_dac_nids, | |
f9e336f6 TI |
8579 | .adc_nids = alc883_adc_nids_alt, |
8580 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt), | |
ccc656ce | 8581 | .dig_out_nid = ALC883_DIGOUT_NID, |
ccc656ce KY |
8582 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8583 | .channel_mode = alc883_3ST_2ch_modes, | |
8584 | .input_mux = &alc883_capture_source, | |
8585 | .unsol_event = alc883_tagra_unsol_event, | |
8586 | .init_hook = alc883_tagra_automute, | |
8587 | }, | |
bab282b9 | 8588 | [ALC883_ACER] = { |
676a9b53 | 8589 | .mixers = { alc883_base_mixer }, |
bab282b9 VA |
8590 | /* On TravelMate laptops, GPIO 0 enables the internal speaker |
8591 | * and the headphone jack. Turn this on and rely on the | |
8592 | * standard mute methods whenever the user wants to turn | |
8593 | * these outputs off. | |
8594 | */ | |
8595 | .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs }, | |
8596 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8597 | .dac_nids = alc883_dac_nids, | |
bab282b9 VA |
8598 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8599 | .channel_mode = alc883_3ST_2ch_modes, | |
8600 | .input_mux = &alc883_capture_source, | |
8601 | }, | |
2880a867 | 8602 | [ALC883_ACER_ASPIRE] = { |
676a9b53 | 8603 | .mixers = { alc883_acer_aspire_mixer }, |
d1a991a6 | 8604 | .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs }, |
2880a867 TD |
8605 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
8606 | .dac_nids = alc883_dac_nids, | |
8607 | .dig_out_nid = ALC883_DIGOUT_NID, | |
2880a867 TD |
8608 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8609 | .channel_mode = alc883_3ST_2ch_modes, | |
8610 | .input_mux = &alc883_capture_source, | |
676a9b53 TI |
8611 | .unsol_event = alc883_acer_aspire_unsol_event, |
8612 | .init_hook = alc883_acer_aspire_automute, | |
d1a991a6 | 8613 | }, |
5b2d1eca | 8614 | [ALC888_ACER_ASPIRE_4930G] = { |
ef8ef5fb | 8615 | .mixers = { alc888_base_mixer, |
5b2d1eca VP |
8616 | alc883_chmode_mixer }, |
8617 | .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs, | |
8618 | alc888_acer_aspire_4930g_verbs }, | |
8619 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8620 | .dac_nids = alc883_dac_nids, | |
8621 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev), | |
8622 | .adc_nids = alc883_adc_nids_rev, | |
8623 | .capsrc_nids = alc883_capsrc_nids_rev, | |
8624 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8625 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
8626 | .channel_mode = alc883_3ST_6ch_modes, | |
8627 | .need_dac_fix = 1, | |
8628 | .num_mux_defs = | |
ef8ef5fb VP |
8629 | ARRAY_SIZE(alc888_2_capture_sources), |
8630 | .input_mux = alc888_2_capture_sources, | |
5b2d1eca VP |
8631 | .unsol_event = alc888_acer_aspire_4930g_unsol_event, |
8632 | .init_hook = alc888_acer_aspire_4930g_automute, | |
8633 | }, | |
c07584c8 TD |
8634 | [ALC883_MEDION] = { |
8635 | .mixers = { alc883_fivestack_mixer, | |
8636 | alc883_chmode_mixer }, | |
8637 | .init_verbs = { alc883_init_verbs, | |
b373bdeb | 8638 | alc883_medion_eapd_verbs }, |
c07584c8 TD |
8639 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
8640 | .dac_nids = alc883_dac_nids, | |
f9e336f6 TI |
8641 | .adc_nids = alc883_adc_nids_alt, |
8642 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt), | |
c07584c8 TD |
8643 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), |
8644 | .channel_mode = alc883_sixstack_modes, | |
8645 | .input_mux = &alc883_capture_source, | |
b373bdeb | 8646 | }, |
272a527c KY |
8647 | [ALC883_MEDION_MD2] = { |
8648 | .mixers = { alc883_medion_md2_mixer}, | |
8649 | .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs}, | |
8650 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8651 | .dac_nids = alc883_dac_nids, | |
8652 | .dig_out_nid = ALC883_DIGOUT_NID, | |
272a527c KY |
8653 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8654 | .channel_mode = alc883_3ST_2ch_modes, | |
8655 | .input_mux = &alc883_capture_source, | |
8656 | .unsol_event = alc883_medion_md2_unsol_event, | |
8657 | .init_hook = alc883_medion_md2_automute, | |
ea1fb29a | 8658 | }, |
b373bdeb | 8659 | [ALC883_LAPTOP_EAPD] = { |
676a9b53 | 8660 | .mixers = { alc883_base_mixer }, |
b373bdeb AN |
8661 | .init_verbs = { alc883_init_verbs, alc882_eapd_verbs }, |
8662 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8663 | .dac_nids = alc883_dac_nids, | |
b373bdeb AN |
8664 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8665 | .channel_mode = alc883_3ST_2ch_modes, | |
8666 | .input_mux = &alc883_capture_source, | |
8667 | }, | |
0c4cc443 HRK |
8668 | [ALC883_CLEVO_M720] = { |
8669 | .mixers = { alc883_clevo_m720_mixer }, | |
8670 | .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs }, | |
368c7a95 J |
8671 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
8672 | .dac_nids = alc883_dac_nids, | |
8673 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8674 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
8675 | .channel_mode = alc883_3ST_2ch_modes, | |
8676 | .input_mux = &alc883_capture_source, | |
0c4cc443 HRK |
8677 | .unsol_event = alc883_clevo_m720_unsol_event, |
8678 | .init_hook = alc883_clevo_m720_automute, | |
368c7a95 | 8679 | }, |
bc9f98a9 KY |
8680 | [ALC883_LENOVO_101E_2ch] = { |
8681 | .mixers = { alc883_lenovo_101e_2ch_mixer}, | |
8682 | .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs}, | |
8683 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8684 | .dac_nids = alc883_dac_nids, | |
f9e336f6 TI |
8685 | .adc_nids = alc883_adc_nids_alt, |
8686 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt), | |
bc9f98a9 KY |
8687 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8688 | .channel_mode = alc883_3ST_2ch_modes, | |
8689 | .input_mux = &alc883_lenovo_101e_capture_source, | |
8690 | .unsol_event = alc883_lenovo_101e_unsol_event, | |
8691 | .init_hook = alc883_lenovo_101e_all_automute, | |
8692 | }, | |
272a527c KY |
8693 | [ALC883_LENOVO_NB0763] = { |
8694 | .mixers = { alc883_lenovo_nb0763_mixer }, | |
8695 | .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs}, | |
8696 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8697 | .dac_nids = alc883_dac_nids, | |
272a527c KY |
8698 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8699 | .channel_mode = alc883_3ST_2ch_modes, | |
8700 | .need_dac_fix = 1, | |
8701 | .input_mux = &alc883_lenovo_nb0763_capture_source, | |
8702 | .unsol_event = alc883_medion_md2_unsol_event, | |
8703 | .init_hook = alc883_medion_md2_automute, | |
8704 | }, | |
8705 | [ALC888_LENOVO_MS7195_DIG] = { | |
8706 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
8707 | .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs}, | |
8708 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8709 | .dac_nids = alc883_dac_nids, | |
8710 | .dig_out_nid = ALC883_DIGOUT_NID, | |
272a527c KY |
8711 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), |
8712 | .channel_mode = alc883_3ST_6ch_modes, | |
8713 | .need_dac_fix = 1, | |
8714 | .input_mux = &alc883_capture_source, | |
8715 | .unsol_event = alc883_lenovo_ms7195_unsol_event, | |
8716 | .init_hook = alc888_lenovo_ms7195_front_automute, | |
189609ae KY |
8717 | }, |
8718 | [ALC883_HAIER_W66] = { | |
8719 | .mixers = { alc883_tagra_2ch_mixer}, | |
8720 | .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs}, | |
8721 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8722 | .dac_nids = alc883_dac_nids, | |
8723 | .dig_out_nid = ALC883_DIGOUT_NID, | |
189609ae KY |
8724 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8725 | .channel_mode = alc883_3ST_2ch_modes, | |
8726 | .input_mux = &alc883_capture_source, | |
8727 | .unsol_event = alc883_haier_w66_unsol_event, | |
8728 | .init_hook = alc883_haier_w66_automute, | |
eea6419e | 8729 | }, |
4723c022 | 8730 | [ALC888_3ST_HP] = { |
eea6419e | 8731 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, |
4723c022 | 8732 | .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs }, |
8341de60 CM |
8733 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
8734 | .dac_nids = alc883_dac_nids, | |
4723c022 CM |
8735 | .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes), |
8736 | .channel_mode = alc888_3st_hp_modes, | |
8341de60 CM |
8737 | .need_dac_fix = 1, |
8738 | .input_mux = &alc883_capture_source, | |
8739 | }, | |
5795b9e6 | 8740 | [ALC888_6ST_DELL] = { |
f24dbdc6 | 8741 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, |
5795b9e6 CM |
8742 | .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs }, |
8743 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8744 | .dac_nids = alc883_dac_nids, | |
8745 | .dig_out_nid = ALC883_DIGOUT_NID, | |
5795b9e6 CM |
8746 | .dig_in_nid = ALC883_DIGIN_NID, |
8747 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | |
8748 | .channel_mode = alc883_sixstack_modes, | |
8749 | .input_mux = &alc883_capture_source, | |
8750 | .unsol_event = alc888_6st_dell_unsol_event, | |
8751 | .init_hook = alc888_6st_dell_front_automute, | |
8752 | }, | |
a8848bd6 AS |
8753 | [ALC883_MITAC] = { |
8754 | .mixers = { alc883_mitac_mixer }, | |
8755 | .init_verbs = { alc883_init_verbs, alc883_mitac_verbs }, | |
8756 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8757 | .dac_nids = alc883_dac_nids, | |
a8848bd6 AS |
8758 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8759 | .channel_mode = alc883_3ST_2ch_modes, | |
8760 | .input_mux = &alc883_capture_source, | |
8761 | .unsol_event = alc883_mitac_unsol_event, | |
8762 | .init_hook = alc883_mitac_automute, | |
8763 | }, | |
fb97dc67 J |
8764 | [ALC883_FUJITSU_PI2515] = { |
8765 | .mixers = { alc883_2ch_fujitsu_pi2515_mixer }, | |
8766 | .init_verbs = { alc883_init_verbs, | |
8767 | alc883_2ch_fujitsu_pi2515_verbs}, | |
8768 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8769 | .dac_nids = alc883_dac_nids, | |
8770 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8771 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
8772 | .channel_mode = alc883_3ST_2ch_modes, | |
8773 | .input_mux = &alc883_fujitsu_pi2515_capture_source, | |
8774 | .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event, | |
8775 | .init_hook = alc883_2ch_fujitsu_pi2515_automute, | |
8776 | }, | |
ef8ef5fb VP |
8777 | [ALC888_FUJITSU_XA3530] = { |
8778 | .mixers = { alc888_base_mixer, alc883_chmode_mixer }, | |
8779 | .init_verbs = { alc883_init_verbs, | |
8780 | alc888_fujitsu_xa3530_verbs }, | |
8781 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8782 | .dac_nids = alc883_dac_nids, | |
8783 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev), | |
8784 | .adc_nids = alc883_adc_nids_rev, | |
8785 | .capsrc_nids = alc883_capsrc_nids_rev, | |
8786 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8787 | .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes), | |
8788 | .channel_mode = alc888_4ST_8ch_intel_modes, | |
8789 | .num_mux_defs = | |
8790 | ARRAY_SIZE(alc888_2_capture_sources), | |
8791 | .input_mux = alc888_2_capture_sources, | |
8792 | .unsol_event = alc888_fujitsu_xa3530_unsol_event, | |
8793 | .init_hook = alc888_fujitsu_xa3530_automute, | |
8794 | }, | |
e2757d5e KY |
8795 | [ALC888_LENOVO_SKY] = { |
8796 | .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer }, | |
8797 | .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs}, | |
8798 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8799 | .dac_nids = alc883_dac_nids, | |
8800 | .dig_out_nid = ALC883_DIGOUT_NID, | |
e2757d5e KY |
8801 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), |
8802 | .channel_mode = alc883_sixstack_modes, | |
8803 | .need_dac_fix = 1, | |
8804 | .input_mux = &alc883_lenovo_sky_capture_source, | |
8805 | .unsol_event = alc883_lenovo_sky_unsol_event, | |
8806 | .init_hook = alc888_lenovo_sky_front_automute, | |
8807 | }, | |
8808 | [ALC888_ASUS_M90V] = { | |
8809 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
8810 | .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs }, | |
8811 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8812 | .dac_nids = alc883_dac_nids, | |
8813 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8814 | .dig_in_nid = ALC883_DIGIN_NID, | |
8815 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
8816 | .channel_mode = alc883_3ST_6ch_modes, | |
8817 | .need_dac_fix = 1, | |
8818 | .input_mux = &alc883_fujitsu_pi2515_capture_source, | |
8819 | .unsol_event = alc883_mode2_unsol_event, | |
8820 | .init_hook = alc883_mode2_inithook, | |
8821 | }, | |
8822 | [ALC888_ASUS_EEE1601] = { | |
8823 | .mixers = { alc883_asus_eee1601_mixer }, | |
f9e336f6 | 8824 | .cap_mixer = alc883_asus_eee1601_cap_mixer, |
e2757d5e KY |
8825 | .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs }, |
8826 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8827 | .dac_nids = alc883_dac_nids, | |
8828 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8829 | .dig_in_nid = ALC883_DIGIN_NID, | |
8830 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
8831 | .channel_mode = alc883_3ST_2ch_modes, | |
8832 | .need_dac_fix = 1, | |
8833 | .input_mux = &alc883_asus_eee1601_capture_source, | |
8834 | .unsol_event = alc883_eee1601_unsol_event, | |
8835 | .init_hook = alc883_eee1601_inithook, | |
8836 | }, | |
3ab90935 WF |
8837 | [ALC1200_ASUS_P5Q] = { |
8838 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, | |
8839 | .init_verbs = { alc883_init_verbs }, | |
8840 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8841 | .dac_nids = alc883_dac_nids, | |
8842 | .dig_out_nid = ALC1200_DIGOUT_NID, | |
8843 | .dig_in_nid = ALC883_DIGIN_NID, | |
8844 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | |
8845 | .channel_mode = alc883_sixstack_modes, | |
8846 | .input_mux = &alc883_capture_source, | |
8847 | }, | |
9c7f852e TI |
8848 | }; |
8849 | ||
8850 | ||
8851 | /* | |
8852 | * BIOS auto configuration | |
8853 | */ | |
8854 | static void alc883_auto_set_output_and_unmute(struct hda_codec *codec, | |
8855 | hda_nid_t nid, int pin_type, | |
8856 | int dac_idx) | |
8857 | { | |
8858 | /* set as output */ | |
8859 | struct alc_spec *spec = codec->spec; | |
f12ab1e0 TI |
8860 | int idx; |
8861 | ||
f6c7e546 | 8862 | alc_set_pin_output(codec, nid, pin_type); |
9c7f852e TI |
8863 | if (spec->multiout.dac_nids[dac_idx] == 0x25) |
8864 | idx = 4; | |
8865 | else | |
8866 | idx = spec->multiout.dac_nids[dac_idx] - 2; | |
9c7f852e TI |
8867 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); |
8868 | ||
8869 | } | |
8870 | ||
8871 | static void alc883_auto_init_multi_out(struct hda_codec *codec) | |
8872 | { | |
8873 | struct alc_spec *spec = codec->spec; | |
8874 | int i; | |
8875 | ||
bc9f98a9 | 8876 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
9c7f852e | 8877 | for (i = 0; i <= HDA_SIDE; i++) { |
f12ab1e0 | 8878 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
baba8ee9 | 8879 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
9c7f852e | 8880 | if (nid) |
baba8ee9 | 8881 | alc883_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 8882 | i); |
9c7f852e TI |
8883 | } |
8884 | } | |
8885 | ||
8886 | static void alc883_auto_init_hp_out(struct hda_codec *codec) | |
8887 | { | |
8888 | struct alc_spec *spec = codec->spec; | |
8889 | hda_nid_t pin; | |
8890 | ||
eb06ed8f | 8891 | pin = spec->autocfg.hp_pins[0]; |
9c7f852e TI |
8892 | if (pin) /* connect to front */ |
8893 | /* use dac 0 */ | |
8894 | alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
f6c7e546 TI |
8895 | pin = spec->autocfg.speaker_pins[0]; |
8896 | if (pin) | |
8897 | alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
9c7f852e TI |
8898 | } |
8899 | ||
8900 | #define alc883_is_input_pin(nid) alc880_is_input_pin(nid) | |
8901 | #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID | |
8902 | ||
8903 | static void alc883_auto_init_analog_input(struct hda_codec *codec) | |
8904 | { | |
8905 | struct alc_spec *spec = codec->spec; | |
8906 | int i; | |
8907 | ||
8908 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
8909 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
8910 | if (alc883_is_input_pin(nid)) { | |
8911 | snd_hda_codec_write(codec, nid, 0, | |
8912 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8913 | (i <= AUTO_PIN_FRONT_MIC ? | |
8914 | PIN_VREF80 : PIN_IN)); | |
8915 | if (nid != ALC883_PIN_CD_NID) | |
8916 | snd_hda_codec_write(codec, nid, 0, | |
8917 | AC_VERB_SET_AMP_GAIN_MUTE, | |
8918 | AMP_OUT_MUTE); | |
8919 | } | |
8920 | } | |
8921 | } | |
8922 | ||
f511b01c TI |
8923 | #define alc883_auto_init_input_src alc882_auto_init_input_src |
8924 | ||
9c7f852e TI |
8925 | /* almost identical with ALC880 parser... */ |
8926 | static int alc883_parse_auto_config(struct hda_codec *codec) | |
8927 | { | |
8928 | struct alc_spec *spec = codec->spec; | |
8929 | int err = alc880_parse_auto_config(codec); | |
8930 | ||
8931 | if (err < 0) | |
8932 | return err; | |
776e184e TI |
8933 | else if (!err) |
8934 | return 0; /* no config found */ | |
8935 | ||
8936 | err = alc_auto_add_mic_boost(codec); | |
8937 | if (err < 0) | |
8938 | return err; | |
8939 | ||
8940 | /* hack - override the init verbs */ | |
8941 | spec->init_verbs[0] = alc883_auto_init_verbs; | |
776e184e TI |
8942 | |
8943 | return 1; /* config found */ | |
9c7f852e TI |
8944 | } |
8945 | ||
8946 | /* additional initialization for auto-configuration model */ | |
8947 | static void alc883_auto_init(struct hda_codec *codec) | |
8948 | { | |
f6c7e546 | 8949 | struct alc_spec *spec = codec->spec; |
9c7f852e TI |
8950 | alc883_auto_init_multi_out(codec); |
8951 | alc883_auto_init_hp_out(codec); | |
8952 | alc883_auto_init_analog_input(codec); | |
f511b01c | 8953 | alc883_auto_init_input_src(codec); |
f6c7e546 | 8954 | if (spec->unsol_event) |
7fb0d78f | 8955 | alc_inithook(codec); |
9c7f852e TI |
8956 | } |
8957 | ||
8958 | static int patch_alc883(struct hda_codec *codec) | |
8959 | { | |
8960 | struct alc_spec *spec; | |
8961 | int err, board_config; | |
8962 | ||
8963 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
8964 | if (spec == NULL) | |
8965 | return -ENOMEM; | |
8966 | ||
8967 | codec->spec = spec; | |
8968 | ||
2c3bf9ab TI |
8969 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
8970 | ||
f5fcc13c TI |
8971 | board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST, |
8972 | alc883_models, | |
8973 | alc883_cfg_tbl); | |
8974 | if (board_config < 0) { | |
9c7f852e TI |
8975 | printk(KERN_INFO "hda_codec: Unknown model for ALC883, " |
8976 | "trying auto-probe from BIOS...\n"); | |
8977 | board_config = ALC883_AUTO; | |
8978 | } | |
8979 | ||
8980 | if (board_config == ALC883_AUTO) { | |
8981 | /* automatic parse from the BIOS config */ | |
8982 | err = alc883_parse_auto_config(codec); | |
8983 | if (err < 0) { | |
8984 | alc_free(codec); | |
8985 | return err; | |
f12ab1e0 | 8986 | } else if (!err) { |
9c7f852e TI |
8987 | printk(KERN_INFO |
8988 | "hda_codec: Cannot set up configuration " | |
8989 | "from BIOS. Using base mode...\n"); | |
8990 | board_config = ALC883_3ST_2ch_DIG; | |
8991 | } | |
8992 | } | |
8993 | ||
8994 | if (board_config != ALC883_AUTO) | |
8995 | setup_preset(spec, &alc883_presets[board_config]); | |
8996 | ||
2f893286 KY |
8997 | switch (codec->vendor_id) { |
8998 | case 0x10ec0888: | |
4442608d KY |
8999 | if (codec->revision_id == 0x100101) { |
9000 | spec->stream_name_analog = "ALC1200 Analog"; | |
9001 | spec->stream_name_digital = "ALC1200 Digital"; | |
9002 | } else { | |
9003 | spec->stream_name_analog = "ALC888 Analog"; | |
9004 | spec->stream_name_digital = "ALC888 Digital"; | |
9005 | } | |
2f893286 KY |
9006 | break; |
9007 | case 0x10ec0889: | |
9008 | spec->stream_name_analog = "ALC889 Analog"; | |
9009 | spec->stream_name_digital = "ALC889 Digital"; | |
9010 | break; | |
9011 | default: | |
9012 | spec->stream_name_analog = "ALC883 Analog"; | |
9013 | spec->stream_name_digital = "ALC883 Digital"; | |
9014 | break; | |
9015 | } | |
9016 | ||
9c7f852e TI |
9017 | spec->stream_analog_playback = &alc883_pcm_analog_playback; |
9018 | spec->stream_analog_capture = &alc883_pcm_analog_capture; | |
6330079f | 9019 | spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture; |
9c7f852e | 9020 | |
9c7f852e TI |
9021 | spec->stream_digital_playback = &alc883_pcm_digital_playback; |
9022 | spec->stream_digital_capture = &alc883_pcm_digital_capture; | |
9023 | ||
f9e336f6 TI |
9024 | if (!spec->num_adc_nids) { |
9025 | spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); | |
9026 | spec->adc_nids = alc883_adc_nids; | |
9027 | } | |
9028 | if (!spec->capsrc_nids) | |
9029 | spec->capsrc_nids = alc883_capsrc_nids; | |
54cbc9ab | 9030 | spec->is_mix_capture = 1; /* matrix-style capture */ |
f9e336f6 TI |
9031 | if (!spec->cap_mixer) |
9032 | set_capture_mixer(spec); | |
9c7f852e | 9033 | |
2134ea4f TI |
9034 | spec->vmaster_nid = 0x0c; |
9035 | ||
9c7f852e TI |
9036 | codec->patch_ops = alc_patch_ops; |
9037 | if (board_config == ALC883_AUTO) | |
9038 | spec->init_hook = alc883_auto_init; | |
f9423e7a | 9039 | |
cb53c626 TI |
9040 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
9041 | if (!spec->loopback.amplist) | |
9042 | spec->loopback.amplist = alc883_loopbacks; | |
9043 | #endif | |
9c7f852e TI |
9044 | |
9045 | return 0; | |
9046 | } | |
9047 | ||
9048 | /* | |
9049 | * ALC262 support | |
9050 | */ | |
9051 | ||
9052 | #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID | |
9053 | #define ALC262_DIGIN_NID ALC880_DIGIN_NID | |
9054 | ||
9055 | #define alc262_dac_nids alc260_dac_nids | |
9056 | #define alc262_adc_nids alc882_adc_nids | |
9057 | #define alc262_adc_nids_alt alc882_adc_nids_alt | |
88c71a99 TI |
9058 | #define alc262_capsrc_nids alc882_capsrc_nids |
9059 | #define alc262_capsrc_nids_alt alc882_capsrc_nids_alt | |
9c7f852e TI |
9060 | |
9061 | #define alc262_modes alc260_modes | |
9062 | #define alc262_capture_source alc882_capture_source | |
9063 | ||
4e555fe5 KY |
9064 | static hda_nid_t alc262_dmic_adc_nids[1] = { |
9065 | /* ADC0 */ | |
9066 | 0x09 | |
9067 | }; | |
9068 | ||
9069 | static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 }; | |
9070 | ||
9c7f852e TI |
9071 | static struct snd_kcontrol_new alc262_base_mixer[] = { |
9072 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
9073 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
9074 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
9075 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
9076 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
9077 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
9078 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9079 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 9080 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
9081 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
9082 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 9083 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e | 9084 | /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), |
31bffaa9 | 9085 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */ |
9c7f852e TI |
9086 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT), |
9087 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
9088 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
9089 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | |
9090 | { } /* end */ | |
9091 | }; | |
9092 | ||
ccc656ce KY |
9093 | static struct snd_kcontrol_new alc262_hippo1_mixer[] = { |
9094 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
9095 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
9096 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
9097 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
9098 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
9099 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
9100 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9101 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 9102 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce KY |
9103 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
9104 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 9105 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
ccc656ce | 9106 | /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), |
31bffaa9 | 9107 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */ |
ccc656ce KY |
9108 | /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/ |
9109 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
9110 | { } /* end */ | |
9111 | }; | |
9112 | ||
ce875f07 TI |
9113 | /* update HP, line and mono-out pins according to the master switch */ |
9114 | static void alc262_hp_master_update(struct hda_codec *codec) | |
9115 | { | |
9116 | struct alc_spec *spec = codec->spec; | |
9117 | int val = spec->master_sw; | |
9118 | ||
9119 | /* HP & line-out */ | |
9120 | snd_hda_codec_write_cache(codec, 0x1b, 0, | |
9121 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
9122 | val ? PIN_HP : 0); | |
9123 | snd_hda_codec_write_cache(codec, 0x15, 0, | |
9124 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
9125 | val ? PIN_HP : 0); | |
9126 | /* mono (speaker) depending on the HP jack sense */ | |
9127 | val = val && !spec->jack_present; | |
9128 | snd_hda_codec_write_cache(codec, 0x16, 0, | |
9129 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
9130 | val ? PIN_OUT : 0); | |
9131 | } | |
9132 | ||
9133 | static void alc262_hp_bpc_automute(struct hda_codec *codec) | |
9134 | { | |
9135 | struct alc_spec *spec = codec->spec; | |
9136 | unsigned int presence; | |
9137 | presence = snd_hda_codec_read(codec, 0x1b, 0, | |
9138 | AC_VERB_GET_PIN_SENSE, 0); | |
9139 | spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE); | |
9140 | alc262_hp_master_update(codec); | |
9141 | } | |
9142 | ||
9143 | static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res) | |
9144 | { | |
9145 | if ((res >> 26) != ALC880_HP_EVENT) | |
9146 | return; | |
9147 | alc262_hp_bpc_automute(codec); | |
9148 | } | |
9149 | ||
9150 | static void alc262_hp_wildwest_automute(struct hda_codec *codec) | |
9151 | { | |
9152 | struct alc_spec *spec = codec->spec; | |
9153 | unsigned int presence; | |
9154 | presence = snd_hda_codec_read(codec, 0x15, 0, | |
9155 | AC_VERB_GET_PIN_SENSE, 0); | |
9156 | spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE); | |
9157 | alc262_hp_master_update(codec); | |
9158 | } | |
9159 | ||
9160 | static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec, | |
9161 | unsigned int res) | |
9162 | { | |
9163 | if ((res >> 26) != ALC880_HP_EVENT) | |
9164 | return; | |
9165 | alc262_hp_wildwest_automute(codec); | |
9166 | } | |
9167 | ||
9168 | static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol, | |
9169 | struct snd_ctl_elem_value *ucontrol) | |
9170 | { | |
9171 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
9172 | struct alc_spec *spec = codec->spec; | |
9173 | *ucontrol->value.integer.value = spec->master_sw; | |
9174 | return 0; | |
9175 | } | |
9176 | ||
9177 | static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |
9178 | struct snd_ctl_elem_value *ucontrol) | |
9179 | { | |
9180 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
9181 | struct alc_spec *spec = codec->spec; | |
9182 | int val = !!*ucontrol->value.integer.value; | |
9183 | ||
9184 | if (val == spec->master_sw) | |
9185 | return 0; | |
9186 | spec->master_sw = val; | |
9187 | alc262_hp_master_update(codec); | |
9188 | return 1; | |
9189 | } | |
9190 | ||
9c7f852e | 9191 | static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = { |
ce875f07 TI |
9192 | { |
9193 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9194 | .name = "Master Playback Switch", | |
9195 | .info = snd_ctl_boolean_mono_info, | |
9196 | .get = alc262_hp_master_sw_get, | |
9197 | .put = alc262_hp_master_sw_put, | |
9198 | }, | |
9c7f852e TI |
9199 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9200 | HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
9201 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
ce875f07 TI |
9202 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0, |
9203 | HDA_OUTPUT), | |
9204 | HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0, | |
9205 | HDA_OUTPUT), | |
9c7f852e TI |
9206 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
9207 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 9208 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
9209 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
9210 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 9211 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
9212 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
9213 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
9214 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
9215 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
9216 | HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
9217 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
9218 | HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT), | |
9219 | HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT), | |
9220 | { } /* end */ | |
9221 | }; | |
9222 | ||
cd7509a4 | 9223 | static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = { |
ce875f07 TI |
9224 | { |
9225 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9226 | .name = "Master Playback Switch", | |
9227 | .info = snd_ctl_boolean_mono_info, | |
9228 | .get = alc262_hp_master_sw_get, | |
9229 | .put = alc262_hp_master_sw_put, | |
9230 | }, | |
cd7509a4 KY |
9231 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9232 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
9233 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
9234 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
ce875f07 TI |
9235 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0, |
9236 | HDA_OUTPUT), | |
9237 | HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0, | |
9238 | HDA_OUTPUT), | |
cd7509a4 KY |
9239 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT), |
9240 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
cc69d12d | 9241 | HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT), |
cd7509a4 KY |
9242 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), |
9243 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
9244 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
9245 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
9246 | HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
9247 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
9248 | { } /* end */ | |
9249 | }; | |
9250 | ||
9251 | static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = { | |
9252 | HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9253 | HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 9254 | HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT), |
cd7509a4 KY |
9255 | { } /* end */ |
9256 | }; | |
9257 | ||
66d2a9d6 KY |
9258 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
9259 | static void alc262_hp_t5735_automute(struct hda_codec *codec, int force) | |
9260 | { | |
9261 | struct alc_spec *spec = codec->spec; | |
66d2a9d6 KY |
9262 | |
9263 | if (force || !spec->sense_updated) { | |
9264 | unsigned int present; | |
9265 | present = snd_hda_codec_read(codec, 0x15, 0, | |
9266 | AC_VERB_GET_PIN_SENSE, 0); | |
4bb26130 | 9267 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; |
66d2a9d6 KY |
9268 | spec->sense_updated = 1; |
9269 | } | |
4bb26130 TI |
9270 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE, |
9271 | spec->jack_present ? HDA_AMP_MUTE : 0); | |
66d2a9d6 KY |
9272 | } |
9273 | ||
9274 | static void alc262_hp_t5735_unsol_event(struct hda_codec *codec, | |
9275 | unsigned int res) | |
9276 | { | |
9277 | if ((res >> 26) != ALC880_HP_EVENT) | |
9278 | return; | |
9279 | alc262_hp_t5735_automute(codec, 1); | |
9280 | } | |
9281 | ||
9282 | static void alc262_hp_t5735_init_hook(struct hda_codec *codec) | |
9283 | { | |
9284 | alc262_hp_t5735_automute(codec, 1); | |
9285 | } | |
9286 | ||
9287 | static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = { | |
86cd9298 TI |
9288 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9289 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
66d2a9d6 KY |
9290 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
9291 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
9292 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9293 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9294 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
9295 | { } /* end */ | |
9296 | }; | |
9297 | ||
9298 | static struct hda_verb alc262_hp_t5735_verbs[] = { | |
9299 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9300 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
9301 | ||
9302 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
9303 | { } | |
9304 | }; | |
9305 | ||
8c427226 | 9306 | static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = { |
f2f48e18 TI |
9307 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9308 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
86cd9298 TI |
9309 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT), |
9310 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT), | |
8c427226 KY |
9311 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), |
9312 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
9313 | { } /* end */ | |
9314 | }; | |
9315 | ||
9316 | static struct hda_verb alc262_hp_rp5700_verbs[] = { | |
9317 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9318 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9319 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9320 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9321 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
9322 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9323 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
9324 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
9325 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))}, | |
9326 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))}, | |
9327 | {} | |
9328 | }; | |
9329 | ||
9330 | static struct hda_input_mux alc262_hp_rp5700_capture_source = { | |
9331 | .num_items = 1, | |
9332 | .items = { | |
9333 | { "Line", 0x1 }, | |
9334 | }, | |
9335 | }; | |
9336 | ||
0724ea2a TI |
9337 | /* bind hp and internal speaker mute (with plug check) */ |
9338 | static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol, | |
9339 | struct snd_ctl_elem_value *ucontrol) | |
9340 | { | |
9341 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
9342 | long *valp = ucontrol->value.integer.value; | |
9343 | int change; | |
9344 | ||
9345 | /* change hp mute */ | |
9346 | change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, | |
9347 | HDA_AMP_MUTE, | |
9348 | valp[0] ? 0 : HDA_AMP_MUTE); | |
9349 | change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, | |
9350 | HDA_AMP_MUTE, | |
9351 | valp[1] ? 0 : HDA_AMP_MUTE); | |
9352 | if (change) { | |
9353 | /* change speaker according to HP jack state */ | |
9354 | struct alc_spec *spec = codec->spec; | |
9355 | unsigned int mute; | |
9356 | if (spec->jack_present) | |
9357 | mute = HDA_AMP_MUTE; | |
9358 | else | |
9359 | mute = snd_hda_codec_amp_read(codec, 0x15, 0, | |
9360 | HDA_OUTPUT, 0); | |
9361 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
9362 | HDA_AMP_MUTE, mute); | |
9363 | } | |
9364 | return change; | |
9365 | } | |
5b31954e | 9366 | |
272a527c | 9367 | static struct snd_kcontrol_new alc262_sony_mixer[] = { |
0724ea2a TI |
9368 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9369 | { | |
9370 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9371 | .name = "Master Playback Switch", | |
9372 | .info = snd_hda_mixer_amp_switch_info, | |
9373 | .get = snd_hda_mixer_amp_switch_get, | |
9374 | .put = alc262_sony_master_sw_put, | |
9375 | .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | |
9376 | }, | |
272a527c KY |
9377 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
9378 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9379 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
9380 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
9381 | { } /* end */ | |
9382 | }; | |
9383 | ||
83c34218 KY |
9384 | static struct snd_kcontrol_new alc262_benq_t31_mixer[] = { |
9385 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
9386 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
9387 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
9388 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9389 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9390 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
9391 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
9392 | { } /* end */ | |
9393 | }; | |
272a527c | 9394 | |
9c7f852e TI |
9395 | #define alc262_capture_mixer alc882_capture_mixer |
9396 | #define alc262_capture_alt_mixer alc882_capture_alt_mixer | |
9397 | ||
9398 | /* | |
9399 | * generic initialization of ADC, input mixers and output mixers | |
9400 | */ | |
9401 | static struct hda_verb alc262_init_verbs[] = { | |
9402 | /* | |
9403 | * Unmute ADC0-2 and set the default input to mic-in | |
9404 | */ | |
9405 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9406 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9407 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9408 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9409 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9410 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9411 | ||
cb53c626 | 9412 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
9c7f852e | 9413 | * mixer widget |
f12ab1e0 TI |
9414 | * Note: PASD motherboards uses the Line In 2 as the input for |
9415 | * front panel mic (mic 2) | |
9c7f852e TI |
9416 | */ |
9417 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
9418 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
9419 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
9420 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
9421 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
9422 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9c7f852e TI |
9423 | |
9424 | /* | |
df694daa KY |
9425 | * Set up output mixers (0x0c - 0x0e) |
9426 | */ | |
9427 | /* set vol=0 to output mixers */ | |
9428 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9429 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9430 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9431 | /* set up input amps for analog loopback */ | |
9432 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
9433 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9434 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9435 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9436 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9437 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9438 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9439 | ||
9440 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
9441 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
9442 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
9443 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
9444 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
9445 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
9446 | ||
9447 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
9448 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
9449 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
9450 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
9451 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
ea1fb29a | 9452 | |
df694daa KY |
9453 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, |
9454 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
ea1fb29a | 9455 | |
df694daa KY |
9456 | /* FIXME: use matrix-type input source selection */ |
9457 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
9458 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
9459 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9460 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
9461 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
9462 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
9463 | /* Input mixer2 */ | |
9464 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9465 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
9466 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
9467 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
9468 | /* Input mixer3 */ | |
9469 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9470 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
9471 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
f12ab1e0 | 9472 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
df694daa KY |
9473 | |
9474 | { } | |
9475 | }; | |
1da177e4 | 9476 | |
4e555fe5 KY |
9477 | static struct hda_verb alc262_eapd_verbs[] = { |
9478 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
9479 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
9480 | { } | |
9481 | }; | |
9482 | ||
ccc656ce KY |
9483 | static struct hda_verb alc262_hippo_unsol_verbs[] = { |
9484 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
9485 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
9486 | {} | |
9487 | }; | |
9488 | ||
9489 | static struct hda_verb alc262_hippo1_unsol_verbs[] = { | |
9490 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
9491 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9492 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
9493 | ||
9494 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
9495 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
9496 | {} | |
9497 | }; | |
9498 | ||
272a527c KY |
9499 | static struct hda_verb alc262_sony_unsol_verbs[] = { |
9500 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
9501 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9502 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic | |
9503 | ||
9504 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
9505 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7b1e8795 | 9506 | {} |
272a527c KY |
9507 | }; |
9508 | ||
4e555fe5 KY |
9509 | static struct hda_input_mux alc262_dmic_capture_source = { |
9510 | .num_items = 2, | |
9511 | .items = { | |
9512 | { "Int DMic", 0x9 }, | |
9513 | { "Mic", 0x0 }, | |
9514 | }, | |
9515 | }; | |
9516 | ||
9517 | static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = { | |
9518 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
9519 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
9520 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
9521 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9522 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
4e555fe5 KY |
9523 | { } /* end */ |
9524 | }; | |
9525 | ||
9526 | static struct hda_verb alc262_toshiba_s06_verbs[] = { | |
9527 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
9528 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9529 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
9530 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9531 | {0x22, AC_VERB_SET_CONNECT_SEL, 0x09}, | |
9532 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
9533 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
9534 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
9535 | {} | |
9536 | }; | |
9537 | ||
9538 | static void alc262_dmic_automute(struct hda_codec *codec) | |
9539 | { | |
9540 | unsigned int present; | |
9541 | ||
9542 | present = snd_hda_codec_read(codec, 0x18, 0, | |
9543 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
9544 | snd_hda_codec_write(codec, 0x22, 0, | |
9545 | AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09); | |
9546 | } | |
9547 | ||
9548 | /* toggle speaker-output according to the hp-jack state */ | |
9549 | static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec) | |
9550 | { | |
9551 | unsigned int present; | |
9552 | unsigned char bits; | |
9553 | ||
9554 | present = snd_hda_codec_read(codec, 0x15, 0, | |
9555 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
9556 | bits = present ? 0 : PIN_OUT; | |
9557 | snd_hda_codec_write(codec, 0x14, 0, | |
9558 | AC_VERB_SET_PIN_WIDGET_CONTROL, bits); | |
9559 | } | |
9560 | ||
9561 | ||
9562 | ||
9563 | /* unsolicited event for HP jack sensing */ | |
9564 | static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec, | |
9565 | unsigned int res) | |
9566 | { | |
9567 | if ((res >> 26) == ALC880_HP_EVENT) | |
9568 | alc262_toshiba_s06_speaker_automute(codec); | |
9569 | if ((res >> 26) == ALC880_MIC_EVENT) | |
9570 | alc262_dmic_automute(codec); | |
9571 | ||
9572 | } | |
9573 | ||
9574 | static void alc262_toshiba_s06_init_hook(struct hda_codec *codec) | |
9575 | { | |
9576 | alc262_toshiba_s06_speaker_automute(codec); | |
9577 | alc262_dmic_automute(codec); | |
9578 | } | |
9579 | ||
ccc656ce | 9580 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
5b31954e | 9581 | static void alc262_hippo_automute(struct hda_codec *codec) |
ccc656ce KY |
9582 | { |
9583 | struct alc_spec *spec = codec->spec; | |
9584 | unsigned int mute; | |
5b31954e | 9585 | unsigned int present; |
ccc656ce | 9586 | |
5b31954e TI |
9587 | /* need to execute and sync at first */ |
9588 | snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); | |
9589 | present = snd_hda_codec_read(codec, 0x15, 0, | |
9590 | AC_VERB_GET_PIN_SENSE, 0); | |
9591 | spec->jack_present = (present & 0x80000000) != 0; | |
ccc656ce KY |
9592 | if (spec->jack_present) { |
9593 | /* mute internal speaker */ | |
47fd830a TI |
9594 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
9595 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
ccc656ce KY |
9596 | } else { |
9597 | /* unmute internal speaker if necessary */ | |
9598 | mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0); | |
47fd830a TI |
9599 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
9600 | HDA_AMP_MUTE, mute); | |
ccc656ce KY |
9601 | } |
9602 | } | |
9603 | ||
9604 | /* unsolicited event for HP jack sensing */ | |
9605 | static void alc262_hippo_unsol_event(struct hda_codec *codec, | |
9606 | unsigned int res) | |
9607 | { | |
9608 | if ((res >> 26) != ALC880_HP_EVENT) | |
9609 | return; | |
5b31954e | 9610 | alc262_hippo_automute(codec); |
ccc656ce KY |
9611 | } |
9612 | ||
5b31954e | 9613 | static void alc262_hippo1_automute(struct hda_codec *codec) |
ccc656ce | 9614 | { |
ccc656ce | 9615 | unsigned int mute; |
5b31954e | 9616 | unsigned int present; |
ccc656ce | 9617 | |
5b31954e TI |
9618 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); |
9619 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
9620 | AC_VERB_GET_PIN_SENSE, 0); | |
9621 | present = (present & 0x80000000) != 0; | |
9622 | if (present) { | |
ccc656ce | 9623 | /* mute internal speaker */ |
47fd830a TI |
9624 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
9625 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
ccc656ce KY |
9626 | } else { |
9627 | /* unmute internal speaker if necessary */ | |
9628 | mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); | |
47fd830a TI |
9629 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
9630 | HDA_AMP_MUTE, mute); | |
ccc656ce KY |
9631 | } |
9632 | } | |
9633 | ||
9634 | /* unsolicited event for HP jack sensing */ | |
9635 | static void alc262_hippo1_unsol_event(struct hda_codec *codec, | |
9636 | unsigned int res) | |
9637 | { | |
9638 | if ((res >> 26) != ALC880_HP_EVENT) | |
9639 | return; | |
5b31954e | 9640 | alc262_hippo1_automute(codec); |
ccc656ce KY |
9641 | } |
9642 | ||
e8f9ae2a PT |
9643 | /* |
9644 | * nec model | |
9645 | * 0x15 = headphone | |
9646 | * 0x16 = internal speaker | |
9647 | * 0x18 = external mic | |
9648 | */ | |
9649 | ||
9650 | static struct snd_kcontrol_new alc262_nec_mixer[] = { | |
9651 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
9652 | HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT), | |
9653 | ||
9654 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9655 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9656 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
9657 | ||
9658 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
9659 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
9660 | { } /* end */ | |
9661 | }; | |
9662 | ||
9663 | static struct hda_verb alc262_nec_verbs[] = { | |
9664 | /* Unmute Speaker */ | |
9665 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9666 | ||
9667 | /* Headphone */ | |
9668 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
9669 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9670 | ||
9671 | /* External mic to headphone */ | |
9672 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9673 | /* External mic to speaker */ | |
9674 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9675 | {} | |
9676 | }; | |
9677 | ||
834be88d TI |
9678 | /* |
9679 | * fujitsu model | |
5d9fab2d TV |
9680 | * 0x14 = headphone/spdif-out, 0x15 = internal speaker, |
9681 | * 0x1b = port replicator headphone out | |
834be88d TI |
9682 | */ |
9683 | ||
9684 | #define ALC_HP_EVENT 0x37 | |
9685 | ||
9686 | static struct hda_verb alc262_fujitsu_unsol_verbs[] = { | |
9687 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, | |
9688 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5d9fab2d TV |
9689 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, |
9690 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
834be88d TI |
9691 | {} |
9692 | }; | |
9693 | ||
0e31daf7 J |
9694 | static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = { |
9695 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, | |
9696 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
9697 | {} | |
9698 | }; | |
9699 | ||
834be88d | 9700 | static struct hda_input_mux alc262_fujitsu_capture_source = { |
39d3ed38 | 9701 | .num_items = 3, |
834be88d TI |
9702 | .items = { |
9703 | { "Mic", 0x0 }, | |
39d3ed38 | 9704 | { "Int Mic", 0x1 }, |
834be88d TI |
9705 | { "CD", 0x4 }, |
9706 | }, | |
9707 | }; | |
9708 | ||
9c7f852e TI |
9709 | static struct hda_input_mux alc262_HP_capture_source = { |
9710 | .num_items = 5, | |
9711 | .items = { | |
9712 | { "Mic", 0x0 }, | |
accbe498 | 9713 | { "Front Mic", 0x1 }, |
9c7f852e TI |
9714 | { "Line", 0x2 }, |
9715 | { "CD", 0x4 }, | |
9716 | { "AUX IN", 0x6 }, | |
9717 | }, | |
9718 | }; | |
9719 | ||
accbe498 | 9720 | static struct hda_input_mux alc262_HP_D7000_capture_source = { |
9721 | .num_items = 4, | |
9722 | .items = { | |
9723 | { "Mic", 0x0 }, | |
9724 | { "Front Mic", 0x2 }, | |
9725 | { "Line", 0x1 }, | |
9726 | { "CD", 0x4 }, | |
9727 | }, | |
9728 | }; | |
9729 | ||
ebc7a406 | 9730 | /* mute/unmute internal speaker according to the hp jacks and mute state */ |
834be88d TI |
9731 | static void alc262_fujitsu_automute(struct hda_codec *codec, int force) |
9732 | { | |
9733 | struct alc_spec *spec = codec->spec; | |
9734 | unsigned int mute; | |
9735 | ||
f12ab1e0 | 9736 | if (force || !spec->sense_updated) { |
ebc7a406 | 9737 | unsigned int present; |
834be88d TI |
9738 | /* need to execute and sync at first */ |
9739 | snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); | |
ebc7a406 TI |
9740 | /* check laptop HP jack */ |
9741 | present = snd_hda_codec_read(codec, 0x14, 0, | |
9742 | AC_VERB_GET_PIN_SENSE, 0); | |
9743 | /* need to execute and sync at first */ | |
9744 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); | |
9745 | /* check docking HP jack */ | |
9746 | present |= snd_hda_codec_read(codec, 0x1b, 0, | |
9747 | AC_VERB_GET_PIN_SENSE, 0); | |
9748 | if (present & AC_PINSENSE_PRESENCE) | |
9749 | spec->jack_present = 1; | |
9750 | else | |
9751 | spec->jack_present = 0; | |
834be88d TI |
9752 | spec->sense_updated = 1; |
9753 | } | |
ebc7a406 TI |
9754 | /* unmute internal speaker only if both HPs are unplugged and |
9755 | * master switch is on | |
9756 | */ | |
9757 | if (spec->jack_present) | |
9758 | mute = HDA_AMP_MUTE; | |
9759 | else | |
834be88d | 9760 | mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); |
ebc7a406 TI |
9761 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
9762 | HDA_AMP_MUTE, mute); | |
834be88d TI |
9763 | } |
9764 | ||
9765 | /* unsolicited event for HP jack sensing */ | |
9766 | static void alc262_fujitsu_unsol_event(struct hda_codec *codec, | |
9767 | unsigned int res) | |
9768 | { | |
9769 | if ((res >> 26) != ALC_HP_EVENT) | |
9770 | return; | |
9771 | alc262_fujitsu_automute(codec, 1); | |
9772 | } | |
9773 | ||
ebc7a406 TI |
9774 | static void alc262_fujitsu_init_hook(struct hda_codec *codec) |
9775 | { | |
9776 | alc262_fujitsu_automute(codec, 1); | |
9777 | } | |
9778 | ||
834be88d | 9779 | /* bind volumes of both NID 0x0c and 0x0d */ |
cca3b371 TI |
9780 | static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = { |
9781 | .ops = &snd_hda_bind_vol, | |
9782 | .values = { | |
9783 | HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT), | |
9784 | HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT), | |
9785 | 0 | |
9786 | }, | |
9787 | }; | |
834be88d | 9788 | |
0e31daf7 J |
9789 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
9790 | static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force) | |
9791 | { | |
9792 | struct alc_spec *spec = codec->spec; | |
9793 | unsigned int mute; | |
9794 | ||
9795 | if (force || !spec->sense_updated) { | |
9796 | unsigned int present_int_hp; | |
9797 | /* need to execute and sync at first */ | |
9798 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); | |
9799 | present_int_hp = snd_hda_codec_read(codec, 0x1b, 0, | |
9800 | AC_VERB_GET_PIN_SENSE, 0); | |
9801 | spec->jack_present = (present_int_hp & 0x80000000) != 0; | |
9802 | spec->sense_updated = 1; | |
9803 | } | |
9804 | if (spec->jack_present) { | |
9805 | /* mute internal speaker */ | |
9806 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
9807 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
9808 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
9809 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
9810 | } else { | |
9811 | /* unmute internal speaker if necessary */ | |
9812 | mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); | |
9813 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
9814 | HDA_AMP_MUTE, mute); | |
9815 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
9816 | HDA_AMP_MUTE, mute); | |
9817 | } | |
9818 | } | |
9819 | ||
9820 | /* unsolicited event for HP jack sensing */ | |
9821 | static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec, | |
9822 | unsigned int res) | |
9823 | { | |
9824 | if ((res >> 26) != ALC_HP_EVENT) | |
9825 | return; | |
9826 | alc262_lenovo_3000_automute(codec, 1); | |
9827 | } | |
9828 | ||
834be88d TI |
9829 | /* bind hp and internal speaker mute (with plug check) */ |
9830 | static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol, | |
9831 | struct snd_ctl_elem_value *ucontrol) | |
9832 | { | |
9833 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
9834 | long *valp = ucontrol->value.integer.value; | |
9835 | int change; | |
9836 | ||
5d9fab2d TV |
9837 | change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
9838 | HDA_AMP_MUTE, | |
9839 | valp ? 0 : HDA_AMP_MUTE); | |
9840 | change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
9841 | HDA_AMP_MUTE, | |
9842 | valp ? 0 : HDA_AMP_MUTE); | |
9843 | ||
82beb8fd TI |
9844 | if (change) |
9845 | alc262_fujitsu_automute(codec, 0); | |
834be88d TI |
9846 | return change; |
9847 | } | |
9848 | ||
9849 | static struct snd_kcontrol_new alc262_fujitsu_mixer[] = { | |
cca3b371 | 9850 | HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol), |
834be88d TI |
9851 | { |
9852 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9853 | .name = "Master Playback Switch", | |
9854 | .info = snd_hda_mixer_amp_switch_info, | |
9855 | .get = snd_hda_mixer_amp_switch_get, | |
9856 | .put = alc262_fujitsu_master_sw_put, | |
9857 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
9858 | }, | |
9859 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
9860 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
06a9c30c TV |
9861 | HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT), |
9862 | HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT), | |
834be88d TI |
9863 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9864 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9865 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
39d3ed38 TI |
9866 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), |
9867 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
9868 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
834be88d TI |
9869 | { } /* end */ |
9870 | }; | |
9871 | ||
0e31daf7 J |
9872 | /* bind hp and internal speaker mute (with plug check) */ |
9873 | static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol, | |
9874 | struct snd_ctl_elem_value *ucontrol) | |
9875 | { | |
9876 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
9877 | long *valp = ucontrol->value.integer.value; | |
9878 | int change; | |
9879 | ||
9880 | change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
9881 | HDA_AMP_MUTE, | |
9882 | valp ? 0 : HDA_AMP_MUTE); | |
9883 | ||
9884 | if (change) | |
9885 | alc262_lenovo_3000_automute(codec, 0); | |
9886 | return change; | |
9887 | } | |
9888 | ||
9889 | static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = { | |
9890 | HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol), | |
9891 | { | |
9892 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9893 | .name = "Master Playback Switch", | |
9894 | .info = snd_hda_mixer_amp_switch_info, | |
9895 | .get = snd_hda_mixer_amp_switch_get, | |
9896 | .put = alc262_lenovo_3000_master_sw_put, | |
9897 | .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), | |
9898 | }, | |
9899 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
9900 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
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), | |
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), | |
9907 | { } /* end */ | |
9908 | }; | |
9909 | ||
9f99a638 HM |
9910 | static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = { |
9911 | HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol), | |
9912 | { | |
9913 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9914 | .name = "Master Playback Switch", | |
9915 | .info = snd_hda_mixer_amp_switch_info, | |
9916 | .get = snd_hda_mixer_amp_switch_get, | |
9917 | .put = alc262_sony_master_sw_put, | |
9918 | .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | |
9919 | }, | |
9920 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9921 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9922 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
9923 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
9924 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
9925 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
9926 | { } /* end */ | |
9927 | }; | |
9928 | ||
304dcaac TI |
9929 | /* additional init verbs for Benq laptops */ |
9930 | static struct hda_verb alc262_EAPD_verbs[] = { | |
9931 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
9932 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
9933 | {} | |
9934 | }; | |
9935 | ||
83c34218 KY |
9936 | static struct hda_verb alc262_benq_t31_EAPD_verbs[] = { |
9937 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9938 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
9939 | ||
9940 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
9941 | {0x20, AC_VERB_SET_PROC_COEF, 0x3050}, | |
9942 | {} | |
9943 | }; | |
9944 | ||
f651b50b TD |
9945 | /* Samsung Q1 Ultra Vista model setup */ |
9946 | static struct snd_kcontrol_new alc262_ultra_mixer[] = { | |
bb9f76cd TI |
9947 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9948 | HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT), | |
f651b50b TD |
9949 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
9950 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
9951 | HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT), | |
bb9f76cd | 9952 | HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT), |
f651b50b TD |
9953 | { } /* end */ |
9954 | }; | |
9955 | ||
9956 | static struct hda_verb alc262_ultra_verbs[] = { | |
bb9f76cd TI |
9957 | /* output mixer */ |
9958 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
9959 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
9960 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9961 | /* speaker */ | |
9962 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9963 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9964 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9965 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9966 | /* HP */ | |
f651b50b | 9967 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
bb9f76cd TI |
9968 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
9969 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9970 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9971 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
9972 | /* internal mic */ | |
9973 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
9974 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
9975 | /* ADC, choose mic */ | |
9976 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
9977 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
9978 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9979 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
9980 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
9981 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9982 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
9983 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
9984 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
9985 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)}, | |
f651b50b TD |
9986 | {} |
9987 | }; | |
9988 | ||
f651b50b TD |
9989 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
9990 | static void alc262_ultra_automute(struct hda_codec *codec) | |
9991 | { | |
9992 | struct alc_spec *spec = codec->spec; | |
9993 | unsigned int mute; | |
f651b50b | 9994 | |
bb9f76cd TI |
9995 | mute = 0; |
9996 | /* auto-mute only when HP is used as HP */ | |
9997 | if (!spec->cur_mux[0]) { | |
9998 | unsigned int present; | |
9999 | /* need to execute and sync at first */ | |
10000 | snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); | |
10001 | present = snd_hda_codec_read(codec, 0x15, 0, | |
10002 | AC_VERB_GET_PIN_SENSE, 0); | |
10003 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; | |
10004 | if (spec->jack_present) | |
10005 | mute = HDA_AMP_MUTE; | |
f651b50b | 10006 | } |
bb9f76cd TI |
10007 | /* mute/unmute internal speaker */ |
10008 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
10009 | HDA_AMP_MUTE, mute); | |
10010 | /* mute/unmute HP */ | |
10011 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
10012 | HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE); | |
f651b50b TD |
10013 | } |
10014 | ||
10015 | /* unsolicited event for HP jack sensing */ | |
10016 | static void alc262_ultra_unsol_event(struct hda_codec *codec, | |
10017 | unsigned int res) | |
10018 | { | |
10019 | if ((res >> 26) != ALC880_HP_EVENT) | |
10020 | return; | |
10021 | alc262_ultra_automute(codec); | |
10022 | } | |
10023 | ||
bb9f76cd TI |
10024 | static struct hda_input_mux alc262_ultra_capture_source = { |
10025 | .num_items = 2, | |
10026 | .items = { | |
10027 | { "Mic", 0x1 }, | |
10028 | { "Headphone", 0x7 }, | |
10029 | }, | |
10030 | }; | |
10031 | ||
10032 | static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol, | |
10033 | struct snd_ctl_elem_value *ucontrol) | |
10034 | { | |
10035 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
10036 | struct alc_spec *spec = codec->spec; | |
10037 | int ret; | |
10038 | ||
54cbc9ab | 10039 | ret = alc_mux_enum_put(kcontrol, ucontrol); |
bb9f76cd TI |
10040 | if (!ret) |
10041 | return 0; | |
10042 | /* reprogram the HP pin as mic or HP according to the input source */ | |
10043 | snd_hda_codec_write_cache(codec, 0x15, 0, | |
10044 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
10045 | spec->cur_mux[0] ? PIN_VREF80 : PIN_HP); | |
10046 | alc262_ultra_automute(codec); /* mute/unmute HP */ | |
10047 | return ret; | |
10048 | } | |
10049 | ||
10050 | static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = { | |
10051 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), | |
10052 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), | |
10053 | { | |
10054 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10055 | .name = "Capture Source", | |
54cbc9ab TI |
10056 | .info = alc_mux_enum_info, |
10057 | .get = alc_mux_enum_get, | |
bb9f76cd TI |
10058 | .put = alc262_ultra_mux_enum_put, |
10059 | }, | |
10060 | { } /* end */ | |
10061 | }; | |
10062 | ||
df694daa | 10063 | /* add playback controls from the parsed DAC table */ |
f12ab1e0 TI |
10064 | static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, |
10065 | const struct auto_pin_cfg *cfg) | |
df694daa KY |
10066 | { |
10067 | hda_nid_t nid; | |
10068 | int err; | |
10069 | ||
10070 | spec->multiout.num_dacs = 1; /* only use one dac */ | |
10071 | spec->multiout.dac_nids = spec->private_dac_nids; | |
10072 | spec->multiout.dac_nids[0] = 2; | |
10073 | ||
10074 | nid = cfg->line_out_pins[0]; | |
10075 | if (nid) { | |
f12ab1e0 TI |
10076 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
10077 | "Front Playback Volume", | |
10078 | HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT)); | |
10079 | if (err < 0) | |
df694daa | 10080 | return err; |
f12ab1e0 TI |
10081 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
10082 | "Front Playback Switch", | |
10083 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
10084 | if (err < 0) | |
df694daa KY |
10085 | return err; |
10086 | } | |
10087 | ||
82bc955f | 10088 | nid = cfg->speaker_pins[0]; |
df694daa KY |
10089 | if (nid) { |
10090 | if (nid == 0x16) { | |
f12ab1e0 TI |
10091 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
10092 | "Speaker Playback Volume", | |
10093 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, | |
10094 | HDA_OUTPUT)); | |
10095 | if (err < 0) | |
df694daa | 10096 | return err; |
f12ab1e0 TI |
10097 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
10098 | "Speaker Playback Switch", | |
10099 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
10100 | HDA_OUTPUT)); | |
10101 | if (err < 0) | |
df694daa KY |
10102 | return err; |
10103 | } else { | |
f12ab1e0 TI |
10104 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
10105 | "Speaker Playback Switch", | |
10106 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
10107 | HDA_OUTPUT)); | |
10108 | if (err < 0) | |
df694daa KY |
10109 | return err; |
10110 | } | |
10111 | } | |
eb06ed8f | 10112 | nid = cfg->hp_pins[0]; |
df694daa KY |
10113 | if (nid) { |
10114 | /* spec->multiout.hp_nid = 2; */ | |
10115 | if (nid == 0x16) { | |
f12ab1e0 TI |
10116 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
10117 | "Headphone Playback Volume", | |
10118 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, | |
10119 | HDA_OUTPUT)); | |
10120 | if (err < 0) | |
df694daa | 10121 | return err; |
f12ab1e0 TI |
10122 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
10123 | "Headphone Playback Switch", | |
10124 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
10125 | HDA_OUTPUT)); | |
10126 | if (err < 0) | |
df694daa KY |
10127 | return err; |
10128 | } else { | |
f12ab1e0 TI |
10129 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
10130 | "Headphone Playback Switch", | |
10131 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
10132 | HDA_OUTPUT)); | |
10133 | if (err < 0) | |
df694daa KY |
10134 | return err; |
10135 | } | |
10136 | } | |
f12ab1e0 | 10137 | return 0; |
df694daa KY |
10138 | } |
10139 | ||
10140 | /* identical with ALC880 */ | |
f12ab1e0 TI |
10141 | #define alc262_auto_create_analog_input_ctls \ |
10142 | alc880_auto_create_analog_input_ctls | |
df694daa KY |
10143 | |
10144 | /* | |
10145 | * generic initialization of ADC, input mixers and output mixers | |
10146 | */ | |
10147 | static struct hda_verb alc262_volume_init_verbs[] = { | |
10148 | /* | |
10149 | * Unmute ADC0-2 and set the default input to mic-in | |
10150 | */ | |
10151 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10152 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10153 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10154 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10155 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10156 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10157 | ||
cb53c626 | 10158 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
df694daa | 10159 | * mixer widget |
f12ab1e0 TI |
10160 | * Note: PASD motherboards uses the Line In 2 as the input for |
10161 | * front panel mic (mic 2) | |
df694daa KY |
10162 | */ |
10163 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
10164 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
10165 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10166 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
10167 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
10168 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
10169 | |
10170 | /* | |
10171 | * Set up output mixers (0x0c - 0x0f) | |
10172 | */ | |
10173 | /* set vol=0 to output mixers */ | |
10174 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10175 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10176 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
ea1fb29a | 10177 | |
df694daa KY |
10178 | /* set up input amps for analog loopback */ |
10179 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
10180 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10181 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10182 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10183 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10184 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10185 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10186 | ||
10187 | /* FIXME: use matrix-type input source selection */ | |
10188 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
10189 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
10190 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
10191 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
10192 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
10193 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
10194 | /* Input mixer2 */ | |
10195 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
10196 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
10197 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
10198 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
10199 | /* Input mixer3 */ | |
10200 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
10201 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
10202 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
10203 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
10204 | ||
10205 | { } | |
10206 | }; | |
10207 | ||
9c7f852e TI |
10208 | static struct hda_verb alc262_HP_BPC_init_verbs[] = { |
10209 | /* | |
10210 | * Unmute ADC0-2 and set the default input to mic-in | |
10211 | */ | |
10212 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10213 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10214 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10215 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10216 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10217 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10218 | ||
cb53c626 | 10219 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
9c7f852e | 10220 | * mixer widget |
f12ab1e0 TI |
10221 | * Note: PASD motherboards uses the Line In 2 as the input for |
10222 | * front panel mic (mic 2) | |
9c7f852e TI |
10223 | */ |
10224 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
10225 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
10226 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10227 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
10228 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
10229 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
10230 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
10231 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
ea1fb29a | 10232 | |
9c7f852e TI |
10233 | /* |
10234 | * Set up output mixers (0x0c - 0x0e) | |
10235 | */ | |
10236 | /* set vol=0 to output mixers */ | |
10237 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10238 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10239 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10240 | ||
10241 | /* set up input amps for analog loopback */ | |
10242 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
10243 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10244 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10245 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10246 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10247 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10248 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10249 | ||
ce875f07 | 10250 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
9c7f852e TI |
10251 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
10252 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
10253 | ||
10254 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
10255 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
10256 | ||
10257 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10258 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10259 | ||
10260 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
10261 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
10262 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
10263 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
10264 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
10265 | ||
10266 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
10267 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10268 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10269 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
10270 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10271 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10272 | ||
10273 | ||
10274 | /* FIXME: use matrix-type input source selection */ | |
10275 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
10276 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
10277 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
10278 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
10279 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
10280 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
10281 | /* Input mixer2 */ | |
10282 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
10283 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
10284 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
10285 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
10286 | /* Input mixer3 */ | |
10287 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
10288 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
10289 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
10290 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
10291 | ||
ce875f07 TI |
10292 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
10293 | ||
9c7f852e TI |
10294 | { } |
10295 | }; | |
10296 | ||
cd7509a4 KY |
10297 | static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = { |
10298 | /* | |
10299 | * Unmute ADC0-2 and set the default input to mic-in | |
10300 | */ | |
10301 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10302 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10303 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10304 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10305 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10306 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10307 | ||
cb53c626 | 10308 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
cd7509a4 KY |
10309 | * mixer widget |
10310 | * Note: PASD motherboards uses the Line In 2 as the input for front | |
10311 | * panel mic (mic 2) | |
10312 | */ | |
10313 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
10314 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
10315 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10316 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
10317 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
10318 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
10319 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
10320 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
10321 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
cd7509a4 KY |
10322 | /* |
10323 | * Set up output mixers (0x0c - 0x0e) | |
10324 | */ | |
10325 | /* set vol=0 to output mixers */ | |
10326 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10327 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10328 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10329 | ||
10330 | /* set up input amps for analog loopback */ | |
10331 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
10332 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10333 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10334 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10335 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10336 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10337 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10338 | ||
10339 | ||
10340 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */ | |
10341 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */ | |
10342 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */ | |
10343 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */ | |
10344 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */ | |
10345 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */ | |
10346 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */ | |
10347 | ||
10348 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
10349 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
10350 | ||
10351 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10352 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
10353 | ||
10354 | /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */ | |
10355 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10356 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10357 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
10358 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10359 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10360 | ||
10361 | /* FIXME: use matrix-type input source selection */ | |
10362 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
10363 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
10364 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/ | |
10365 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/ | |
10366 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/ | |
10367 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/ | |
10368 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/ | |
10369 | /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
10370 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/ | |
10371 | /* Input mixer2 */ | |
10372 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
10373 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
10374 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
10375 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
10376 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
10377 | /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
10378 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, | |
10379 | /* Input mixer3 */ | |
10380 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
10381 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
10382 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
10383 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
10384 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
10385 | /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
10386 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, | |
10387 | ||
ce875f07 TI |
10388 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
10389 | ||
cd7509a4 KY |
10390 | { } |
10391 | }; | |
10392 | ||
9f99a638 HM |
10393 | static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = { |
10394 | ||
10395 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */ | |
10396 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
10397 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
10398 | ||
10399 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */ | |
10400 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */ | |
10401 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) }, | |
10402 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) }, | |
10403 | ||
10404 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */ | |
10405 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10406 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
10407 | {} | |
10408 | }; | |
10409 | ||
10410 | ||
cb53c626 TI |
10411 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
10412 | #define alc262_loopbacks alc880_loopbacks | |
10413 | #endif | |
10414 | ||
df694daa KY |
10415 | /* pcm configuration: identiacal with ALC880 */ |
10416 | #define alc262_pcm_analog_playback alc880_pcm_analog_playback | |
10417 | #define alc262_pcm_analog_capture alc880_pcm_analog_capture | |
10418 | #define alc262_pcm_digital_playback alc880_pcm_digital_playback | |
10419 | #define alc262_pcm_digital_capture alc880_pcm_digital_capture | |
10420 | ||
10421 | /* | |
10422 | * BIOS auto configuration | |
10423 | */ | |
10424 | static int alc262_parse_auto_config(struct hda_codec *codec) | |
10425 | { | |
10426 | struct alc_spec *spec = codec->spec; | |
10427 | int err; | |
10428 | static hda_nid_t alc262_ignore[] = { 0x1d, 0 }; | |
10429 | ||
f12ab1e0 TI |
10430 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
10431 | alc262_ignore); | |
10432 | if (err < 0) | |
df694daa | 10433 | return err; |
f12ab1e0 | 10434 | if (!spec->autocfg.line_outs) |
df694daa | 10435 | return 0; /* can't find valid BIOS pin config */ |
f12ab1e0 TI |
10436 | err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg); |
10437 | if (err < 0) | |
10438 | return err; | |
10439 | err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
10440 | if (err < 0) | |
df694daa KY |
10441 | return err; |
10442 | ||
10443 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
10444 | ||
10445 | if (spec->autocfg.dig_out_pin) | |
10446 | spec->multiout.dig_out_nid = ALC262_DIGOUT_NID; | |
10447 | if (spec->autocfg.dig_in_pin) | |
10448 | spec->dig_in_nid = ALC262_DIGIN_NID; | |
10449 | ||
603c4019 | 10450 | if (spec->kctls.list) |
d88897ea | 10451 | add_mixer(spec, spec->kctls.list); |
df694daa | 10452 | |
d88897ea | 10453 | add_verb(spec, alc262_volume_init_verbs); |
a1e8d2da | 10454 | spec->num_mux_defs = 1; |
df694daa KY |
10455 | spec->input_mux = &spec->private_imux; |
10456 | ||
776e184e TI |
10457 | err = alc_auto_add_mic_boost(codec); |
10458 | if (err < 0) | |
10459 | return err; | |
10460 | ||
e044c39a | 10461 | store_pin_configs(codec); |
df694daa KY |
10462 | return 1; |
10463 | } | |
10464 | ||
10465 | #define alc262_auto_init_multi_out alc882_auto_init_multi_out | |
10466 | #define alc262_auto_init_hp_out alc882_auto_init_hp_out | |
10467 | #define alc262_auto_init_analog_input alc882_auto_init_analog_input | |
f511b01c | 10468 | #define alc262_auto_init_input_src alc882_auto_init_input_src |
df694daa KY |
10469 | |
10470 | ||
10471 | /* init callback for auto-configuration model -- overriding the default init */ | |
ae6b813a | 10472 | static void alc262_auto_init(struct hda_codec *codec) |
df694daa | 10473 | { |
f6c7e546 | 10474 | struct alc_spec *spec = codec->spec; |
df694daa KY |
10475 | alc262_auto_init_multi_out(codec); |
10476 | alc262_auto_init_hp_out(codec); | |
10477 | alc262_auto_init_analog_input(codec); | |
f511b01c | 10478 | alc262_auto_init_input_src(codec); |
f6c7e546 | 10479 | if (spec->unsol_event) |
7fb0d78f | 10480 | alc_inithook(codec); |
df694daa KY |
10481 | } |
10482 | ||
10483 | /* | |
10484 | * configuration and preset | |
10485 | */ | |
f5fcc13c TI |
10486 | static const char *alc262_models[ALC262_MODEL_LAST] = { |
10487 | [ALC262_BASIC] = "basic", | |
10488 | [ALC262_HIPPO] = "hippo", | |
10489 | [ALC262_HIPPO_1] = "hippo_1", | |
10490 | [ALC262_FUJITSU] = "fujitsu", | |
10491 | [ALC262_HP_BPC] = "hp-bpc", | |
cd7509a4 | 10492 | [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000", |
61dc35de | 10493 | [ALC262_HP_TC_T5735] = "hp-tc-t5735", |
8c427226 | 10494 | [ALC262_HP_RP5700] = "hp-rp5700", |
f5fcc13c | 10495 | [ALC262_BENQ_ED8] = "benq", |
0f40502e TI |
10496 | [ALC262_BENQ_T31] = "benq-t31", |
10497 | [ALC262_SONY_ASSAMD] = "sony-assamd", | |
2922c9af | 10498 | [ALC262_TOSHIBA_S06] = "toshiba-s06", |
9f99a638 | 10499 | [ALC262_TOSHIBA_RX1] = "toshiba-rx1", |
f651b50b | 10500 | [ALC262_ULTRA] = "ultra", |
0e31daf7 | 10501 | [ALC262_LENOVO_3000] = "lenovo-3000", |
e8f9ae2a | 10502 | [ALC262_NEC] = "nec", |
f5fcc13c TI |
10503 | [ALC262_AUTO] = "auto", |
10504 | }; | |
10505 | ||
10506 | static struct snd_pci_quirk alc262_cfg_tbl[] = { | |
10507 | SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO), | |
e8f9ae2a | 10508 | SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC), |
f5fcc13c | 10509 | SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC), |
7d87de2d | 10510 | SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC), |
ac3e3741 TI |
10511 | SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC), |
10512 | SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC), | |
7d87de2d | 10513 | SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC), |
b98f9334 | 10514 | SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC), |
b98f9334 | 10515 | SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC), |
b98f9334 | 10516 | SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC), |
cd7509a4 | 10517 | SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL), |
cd7509a4 | 10518 | SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF), |
ac3e3741 | 10519 | SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL), |
cd7509a4 | 10520 | SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF), |
ac3e3741 | 10521 | SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL), |
cd7509a4 | 10522 | SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF), |
ac3e3741 | 10523 | SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL), |
cd7509a4 | 10524 | SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF), |
ac3e3741 TI |
10525 | SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC), |
10526 | SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC), | |
10527 | SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC), | |
66d2a9d6 KY |
10528 | SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735", |
10529 | ALC262_HP_TC_T5735), | |
8c427226 | 10530 | SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700), |
ac3e3741 | 10531 | SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD), |
f5fcc13c | 10532 | SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO), |
5b31954e | 10533 | SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD), |
272a527c | 10534 | SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD), |
ac3e3741 | 10535 | SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD), |
36ca6e13 | 10536 | SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1", |
9f99a638 | 10537 | ALC262_TOSHIBA_RX1), |
80ffe869 | 10538 | SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06), |
ac3e3741 | 10539 | SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU), |
3f1eeaed | 10540 | SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU), |
f651b50b | 10541 | SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA), |
bb9f76cd | 10542 | SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA), |
0e31daf7 | 10543 | SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000), |
ac3e3741 TI |
10544 | SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8), |
10545 | SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31), | |
10546 | SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1), | |
df694daa KY |
10547 | {} |
10548 | }; | |
10549 | ||
10550 | static struct alc_config_preset alc262_presets[] = { | |
10551 | [ALC262_BASIC] = { | |
10552 | .mixers = { alc262_base_mixer }, | |
10553 | .init_verbs = { alc262_init_verbs }, | |
10554 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10555 | .dac_nids = alc262_dac_nids, | |
10556 | .hp_nid = 0x03, | |
10557 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10558 | .channel_mode = alc262_modes, | |
a3bcba38 | 10559 | .input_mux = &alc262_capture_source, |
df694daa | 10560 | }, |
ccc656ce KY |
10561 | [ALC262_HIPPO] = { |
10562 | .mixers = { alc262_base_mixer }, | |
10563 | .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs}, | |
10564 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10565 | .dac_nids = alc262_dac_nids, | |
10566 | .hp_nid = 0x03, | |
10567 | .dig_out_nid = ALC262_DIGOUT_NID, | |
10568 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10569 | .channel_mode = alc262_modes, | |
10570 | .input_mux = &alc262_capture_source, | |
10571 | .unsol_event = alc262_hippo_unsol_event, | |
5b31954e | 10572 | .init_hook = alc262_hippo_automute, |
ccc656ce KY |
10573 | }, |
10574 | [ALC262_HIPPO_1] = { | |
10575 | .mixers = { alc262_hippo1_mixer }, | |
10576 | .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs}, | |
10577 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10578 | .dac_nids = alc262_dac_nids, | |
10579 | .hp_nid = 0x02, | |
10580 | .dig_out_nid = ALC262_DIGOUT_NID, | |
10581 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10582 | .channel_mode = alc262_modes, | |
10583 | .input_mux = &alc262_capture_source, | |
10584 | .unsol_event = alc262_hippo1_unsol_event, | |
5b31954e | 10585 | .init_hook = alc262_hippo1_automute, |
ccc656ce | 10586 | }, |
834be88d TI |
10587 | [ALC262_FUJITSU] = { |
10588 | .mixers = { alc262_fujitsu_mixer }, | |
39d3ed38 TI |
10589 | .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs, |
10590 | alc262_fujitsu_unsol_verbs }, | |
834be88d TI |
10591 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), |
10592 | .dac_nids = alc262_dac_nids, | |
10593 | .hp_nid = 0x03, | |
10594 | .dig_out_nid = ALC262_DIGOUT_NID, | |
10595 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10596 | .channel_mode = alc262_modes, | |
10597 | .input_mux = &alc262_fujitsu_capture_source, | |
ae6b813a | 10598 | .unsol_event = alc262_fujitsu_unsol_event, |
ebc7a406 | 10599 | .init_hook = alc262_fujitsu_init_hook, |
834be88d | 10600 | }, |
9c7f852e TI |
10601 | [ALC262_HP_BPC] = { |
10602 | .mixers = { alc262_HP_BPC_mixer }, | |
10603 | .init_verbs = { alc262_HP_BPC_init_verbs }, | |
10604 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10605 | .dac_nids = alc262_dac_nids, | |
10606 | .hp_nid = 0x03, | |
10607 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10608 | .channel_mode = alc262_modes, | |
10609 | .input_mux = &alc262_HP_capture_source, | |
ce875f07 TI |
10610 | .unsol_event = alc262_hp_bpc_unsol_event, |
10611 | .init_hook = alc262_hp_bpc_automute, | |
f12ab1e0 | 10612 | }, |
cd7509a4 KY |
10613 | [ALC262_HP_BPC_D7000_WF] = { |
10614 | .mixers = { alc262_HP_BPC_WildWest_mixer }, | |
10615 | .init_verbs = { alc262_HP_BPC_WildWest_init_verbs }, | |
10616 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10617 | .dac_nids = alc262_dac_nids, | |
10618 | .hp_nid = 0x03, | |
10619 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10620 | .channel_mode = alc262_modes, | |
accbe498 | 10621 | .input_mux = &alc262_HP_D7000_capture_source, |
ce875f07 TI |
10622 | .unsol_event = alc262_hp_wildwest_unsol_event, |
10623 | .init_hook = alc262_hp_wildwest_automute, | |
f12ab1e0 | 10624 | }, |
cd7509a4 KY |
10625 | [ALC262_HP_BPC_D7000_WL] = { |
10626 | .mixers = { alc262_HP_BPC_WildWest_mixer, | |
10627 | alc262_HP_BPC_WildWest_option_mixer }, | |
10628 | .init_verbs = { alc262_HP_BPC_WildWest_init_verbs }, | |
10629 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10630 | .dac_nids = alc262_dac_nids, | |
10631 | .hp_nid = 0x03, | |
10632 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10633 | .channel_mode = alc262_modes, | |
accbe498 | 10634 | .input_mux = &alc262_HP_D7000_capture_source, |
ce875f07 TI |
10635 | .unsol_event = alc262_hp_wildwest_unsol_event, |
10636 | .init_hook = alc262_hp_wildwest_automute, | |
f12ab1e0 | 10637 | }, |
66d2a9d6 KY |
10638 | [ALC262_HP_TC_T5735] = { |
10639 | .mixers = { alc262_hp_t5735_mixer }, | |
10640 | .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs }, | |
10641 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10642 | .dac_nids = alc262_dac_nids, | |
10643 | .hp_nid = 0x03, | |
10644 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10645 | .channel_mode = alc262_modes, | |
10646 | .input_mux = &alc262_capture_source, | |
10647 | .unsol_event = alc262_hp_t5735_unsol_event, | |
10648 | .init_hook = alc262_hp_t5735_init_hook, | |
8c427226 KY |
10649 | }, |
10650 | [ALC262_HP_RP5700] = { | |
10651 | .mixers = { alc262_hp_rp5700_mixer }, | |
10652 | .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs }, | |
10653 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10654 | .dac_nids = alc262_dac_nids, | |
10655 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10656 | .channel_mode = alc262_modes, | |
10657 | .input_mux = &alc262_hp_rp5700_capture_source, | |
66d2a9d6 | 10658 | }, |
304dcaac TI |
10659 | [ALC262_BENQ_ED8] = { |
10660 | .mixers = { alc262_base_mixer }, | |
10661 | .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs }, | |
10662 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10663 | .dac_nids = alc262_dac_nids, | |
10664 | .hp_nid = 0x03, | |
10665 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10666 | .channel_mode = alc262_modes, | |
10667 | .input_mux = &alc262_capture_source, | |
f12ab1e0 | 10668 | }, |
272a527c KY |
10669 | [ALC262_SONY_ASSAMD] = { |
10670 | .mixers = { alc262_sony_mixer }, | |
10671 | .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs}, | |
10672 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10673 | .dac_nids = alc262_dac_nids, | |
10674 | .hp_nid = 0x02, | |
10675 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10676 | .channel_mode = alc262_modes, | |
10677 | .input_mux = &alc262_capture_source, | |
10678 | .unsol_event = alc262_hippo_unsol_event, | |
5b31954e | 10679 | .init_hook = alc262_hippo_automute, |
83c34218 KY |
10680 | }, |
10681 | [ALC262_BENQ_T31] = { | |
10682 | .mixers = { alc262_benq_t31_mixer }, | |
10683 | .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs }, | |
10684 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10685 | .dac_nids = alc262_dac_nids, | |
10686 | .hp_nid = 0x03, | |
10687 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10688 | .channel_mode = alc262_modes, | |
10689 | .input_mux = &alc262_capture_source, | |
10690 | .unsol_event = alc262_hippo_unsol_event, | |
5b31954e | 10691 | .init_hook = alc262_hippo_automute, |
ea1fb29a | 10692 | }, |
f651b50b | 10693 | [ALC262_ULTRA] = { |
f9e336f6 TI |
10694 | .mixers = { alc262_ultra_mixer }, |
10695 | .cap_mixer = alc262_ultra_capture_mixer, | |
bb9f76cd | 10696 | .init_verbs = { alc262_ultra_verbs }, |
f651b50b TD |
10697 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), |
10698 | .dac_nids = alc262_dac_nids, | |
f651b50b TD |
10699 | .num_channel_mode = ARRAY_SIZE(alc262_modes), |
10700 | .channel_mode = alc262_modes, | |
10701 | .input_mux = &alc262_ultra_capture_source, | |
bb9f76cd TI |
10702 | .adc_nids = alc262_adc_nids, /* ADC0 */ |
10703 | .capsrc_nids = alc262_capsrc_nids, | |
10704 | .num_adc_nids = 1, /* single ADC */ | |
f651b50b TD |
10705 | .unsol_event = alc262_ultra_unsol_event, |
10706 | .init_hook = alc262_ultra_automute, | |
10707 | }, | |
0e31daf7 J |
10708 | [ALC262_LENOVO_3000] = { |
10709 | .mixers = { alc262_lenovo_3000_mixer }, | |
10710 | .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs, | |
10711 | alc262_lenovo_3000_unsol_verbs }, | |
10712 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10713 | .dac_nids = alc262_dac_nids, | |
10714 | .hp_nid = 0x03, | |
10715 | .dig_out_nid = ALC262_DIGOUT_NID, | |
10716 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10717 | .channel_mode = alc262_modes, | |
10718 | .input_mux = &alc262_fujitsu_capture_source, | |
10719 | .unsol_event = alc262_lenovo_3000_unsol_event, | |
10720 | }, | |
e8f9ae2a PT |
10721 | [ALC262_NEC] = { |
10722 | .mixers = { alc262_nec_mixer }, | |
10723 | .init_verbs = { alc262_nec_verbs }, | |
10724 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10725 | .dac_nids = alc262_dac_nids, | |
10726 | .hp_nid = 0x03, | |
10727 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10728 | .channel_mode = alc262_modes, | |
10729 | .input_mux = &alc262_capture_source, | |
10730 | }, | |
4e555fe5 KY |
10731 | [ALC262_TOSHIBA_S06] = { |
10732 | .mixers = { alc262_toshiba_s06_mixer }, | |
10733 | .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs, | |
10734 | alc262_eapd_verbs }, | |
10735 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10736 | .capsrc_nids = alc262_dmic_capsrc_nids, | |
10737 | .dac_nids = alc262_dac_nids, | |
10738 | .adc_nids = alc262_dmic_adc_nids, /* ADC0 */ | |
10739 | .dig_out_nid = ALC262_DIGOUT_NID, | |
10740 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10741 | .channel_mode = alc262_modes, | |
10742 | .input_mux = &alc262_dmic_capture_source, | |
10743 | .unsol_event = alc262_toshiba_s06_unsol_event, | |
10744 | .init_hook = alc262_toshiba_s06_init_hook, | |
10745 | }, | |
9f99a638 HM |
10746 | [ALC262_TOSHIBA_RX1] = { |
10747 | .mixers = { alc262_toshiba_rx1_mixer }, | |
10748 | .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs }, | |
10749 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10750 | .dac_nids = alc262_dac_nids, | |
10751 | .hp_nid = 0x03, | |
10752 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10753 | .channel_mode = alc262_modes, | |
10754 | .input_mux = &alc262_capture_source, | |
10755 | .unsol_event = alc262_hippo_unsol_event, | |
10756 | .init_hook = alc262_hippo_automute, | |
10757 | }, | |
df694daa KY |
10758 | }; |
10759 | ||
10760 | static int patch_alc262(struct hda_codec *codec) | |
10761 | { | |
10762 | struct alc_spec *spec; | |
10763 | int board_config; | |
10764 | int err; | |
10765 | ||
dc041e0b | 10766 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
df694daa KY |
10767 | if (spec == NULL) |
10768 | return -ENOMEM; | |
10769 | ||
10770 | codec->spec = spec; | |
10771 | #if 0 | |
f12ab1e0 TI |
10772 | /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is |
10773 | * under-run | |
10774 | */ | |
df694daa KY |
10775 | { |
10776 | int tmp; | |
10777 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); | |
10778 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); | |
10779 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); | |
10780 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); | |
10781 | } | |
10782 | #endif | |
10783 | ||
2c3bf9ab TI |
10784 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
10785 | ||
f5fcc13c TI |
10786 | board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST, |
10787 | alc262_models, | |
10788 | alc262_cfg_tbl); | |
cd7509a4 | 10789 | |
f5fcc13c | 10790 | if (board_config < 0) { |
9c7f852e TI |
10791 | printk(KERN_INFO "hda_codec: Unknown model for ALC262, " |
10792 | "trying auto-probe from BIOS...\n"); | |
df694daa KY |
10793 | board_config = ALC262_AUTO; |
10794 | } | |
10795 | ||
10796 | if (board_config == ALC262_AUTO) { | |
10797 | /* automatic parse from the BIOS config */ | |
10798 | err = alc262_parse_auto_config(codec); | |
10799 | if (err < 0) { | |
10800 | alc_free(codec); | |
10801 | return err; | |
f12ab1e0 | 10802 | } else if (!err) { |
9c7f852e TI |
10803 | printk(KERN_INFO |
10804 | "hda_codec: Cannot set up configuration " | |
10805 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
10806 | board_config = ALC262_BASIC; |
10807 | } | |
10808 | } | |
10809 | ||
10810 | if (board_config != ALC262_AUTO) | |
10811 | setup_preset(spec, &alc262_presets[board_config]); | |
10812 | ||
10813 | spec->stream_name_analog = "ALC262 Analog"; | |
10814 | spec->stream_analog_playback = &alc262_pcm_analog_playback; | |
10815 | spec->stream_analog_capture = &alc262_pcm_analog_capture; | |
ea1fb29a | 10816 | |
df694daa KY |
10817 | spec->stream_name_digital = "ALC262 Digital"; |
10818 | spec->stream_digital_playback = &alc262_pcm_digital_playback; | |
10819 | spec->stream_digital_capture = &alc262_pcm_digital_capture; | |
10820 | ||
54cbc9ab | 10821 | spec->is_mix_capture = 1; |
f12ab1e0 | 10822 | if (!spec->adc_nids && spec->input_mux) { |
df694daa | 10823 | /* check whether NID 0x07 is valid */ |
4a471b7d TI |
10824 | unsigned int wcap = get_wcaps(codec, 0x07); |
10825 | ||
f12ab1e0 TI |
10826 | /* get type */ |
10827 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
df694daa KY |
10828 | if (wcap != AC_WID_AUD_IN) { |
10829 | spec->adc_nids = alc262_adc_nids_alt; | |
10830 | spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt); | |
88c71a99 | 10831 | spec->capsrc_nids = alc262_capsrc_nids_alt; |
df694daa KY |
10832 | } else { |
10833 | spec->adc_nids = alc262_adc_nids; | |
10834 | spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids); | |
88c71a99 | 10835 | spec->capsrc_nids = alc262_capsrc_nids; |
df694daa KY |
10836 | } |
10837 | } | |
f9e336f6 TI |
10838 | if (!spec->cap_mixer) |
10839 | set_capture_mixer(spec); | |
df694daa | 10840 | |
2134ea4f TI |
10841 | spec->vmaster_nid = 0x0c; |
10842 | ||
df694daa KY |
10843 | codec->patch_ops = alc_patch_ops; |
10844 | if (board_config == ALC262_AUTO) | |
ae6b813a | 10845 | spec->init_hook = alc262_auto_init; |
cb53c626 TI |
10846 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
10847 | if (!spec->loopback.amplist) | |
10848 | spec->loopback.amplist = alc262_loopbacks; | |
10849 | #endif | |
ea1fb29a | 10850 | |
df694daa KY |
10851 | return 0; |
10852 | } | |
10853 | ||
a361d84b KY |
10854 | /* |
10855 | * ALC268 channel source setting (2 channel) | |
10856 | */ | |
10857 | #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID | |
10858 | #define alc268_modes alc260_modes | |
ea1fb29a | 10859 | |
a361d84b KY |
10860 | static hda_nid_t alc268_dac_nids[2] = { |
10861 | /* front, hp */ | |
10862 | 0x02, 0x03 | |
10863 | }; | |
10864 | ||
10865 | static hda_nid_t alc268_adc_nids[2] = { | |
10866 | /* ADC0-1 */ | |
10867 | 0x08, 0x07 | |
10868 | }; | |
10869 | ||
10870 | static hda_nid_t alc268_adc_nids_alt[1] = { | |
10871 | /* ADC0 */ | |
10872 | 0x08 | |
10873 | }; | |
10874 | ||
e1406348 TI |
10875 | static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 }; |
10876 | ||
a361d84b KY |
10877 | static struct snd_kcontrol_new alc268_base_mixer[] = { |
10878 | /* output mixer control */ | |
10879 | HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT), | |
10880 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
10881 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT), | |
10882 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
33bf17ab TI |
10883 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
10884 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
10885 | HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT), | |
a361d84b KY |
10886 | { } |
10887 | }; | |
10888 | ||
aef9d318 TI |
10889 | /* bind Beep switches of both NID 0x0f and 0x10 */ |
10890 | static struct hda_bind_ctls alc268_bind_beep_sw = { | |
10891 | .ops = &snd_hda_bind_sw, | |
10892 | .values = { | |
10893 | HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT), | |
10894 | HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT), | |
10895 | 0 | |
10896 | }, | |
10897 | }; | |
10898 | ||
10899 | static struct snd_kcontrol_new alc268_beep_mixer[] = { | |
10900 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT), | |
10901 | HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw), | |
10902 | { } | |
10903 | }; | |
10904 | ||
d1a991a6 KY |
10905 | static struct hda_verb alc268_eapd_verbs[] = { |
10906 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
10907 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
10908 | { } | |
10909 | }; | |
10910 | ||
d273809e TI |
10911 | /* Toshiba specific */ |
10912 | #define alc268_toshiba_automute alc262_hippo_automute | |
10913 | ||
10914 | static struct hda_verb alc268_toshiba_verbs[] = { | |
10915 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
10916 | { } /* end */ | |
10917 | }; | |
10918 | ||
8ef355da KY |
10919 | static struct hda_input_mux alc268_acer_lc_capture_source = { |
10920 | .num_items = 2, | |
10921 | .items = { | |
10922 | { "i-Mic", 0x6 }, | |
10923 | { "E-Mic", 0x0 }, | |
10924 | }, | |
10925 | }; | |
10926 | ||
d273809e | 10927 | /* Acer specific */ |
889c4395 | 10928 | /* bind volumes of both NID 0x02 and 0x03 */ |
6bc96857 TI |
10929 | static struct hda_bind_ctls alc268_acer_bind_master_vol = { |
10930 | .ops = &snd_hda_bind_vol, | |
10931 | .values = { | |
10932 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), | |
10933 | HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT), | |
10934 | 0 | |
10935 | }, | |
10936 | }; | |
10937 | ||
889c4395 TI |
10938 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
10939 | static void alc268_acer_automute(struct hda_codec *codec, int force) | |
10940 | { | |
10941 | struct alc_spec *spec = codec->spec; | |
10942 | unsigned int mute; | |
10943 | ||
10944 | if (force || !spec->sense_updated) { | |
10945 | unsigned int present; | |
10946 | present = snd_hda_codec_read(codec, 0x14, 0, | |
10947 | AC_VERB_GET_PIN_SENSE, 0); | |
10948 | spec->jack_present = (present & 0x80000000) != 0; | |
10949 | spec->sense_updated = 1; | |
10950 | } | |
10951 | if (spec->jack_present) | |
10952 | mute = HDA_AMP_MUTE; /* mute internal speaker */ | |
10953 | else /* unmute internal speaker if necessary */ | |
10954 | mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); | |
10955 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
10956 | HDA_AMP_MUTE, mute); | |
10957 | } | |
10958 | ||
10959 | ||
10960 | /* bind hp and internal speaker mute (with plug check) */ | |
10961 | static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol, | |
10962 | struct snd_ctl_elem_value *ucontrol) | |
10963 | { | |
10964 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
10965 | long *valp = ucontrol->value.integer.value; | |
10966 | int change; | |
10967 | ||
10968 | change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, | |
10969 | HDA_AMP_MUTE, | |
10970 | valp[0] ? 0 : HDA_AMP_MUTE); | |
10971 | change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, | |
10972 | HDA_AMP_MUTE, | |
10973 | valp[1] ? 0 : HDA_AMP_MUTE); | |
10974 | if (change) | |
10975 | alc268_acer_automute(codec, 0); | |
10976 | return change; | |
10977 | } | |
d273809e | 10978 | |
8ef355da KY |
10979 | static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = { |
10980 | /* output mixer control */ | |
10981 | HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol), | |
10982 | { | |
10983 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10984 | .name = "Master Playback Switch", | |
10985 | .info = snd_hda_mixer_amp_switch_info, | |
10986 | .get = snd_hda_mixer_amp_switch_get, | |
10987 | .put = alc268_acer_master_sw_put, | |
10988 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
10989 | }, | |
10990 | HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT), | |
10991 | { } | |
10992 | }; | |
10993 | ||
d273809e TI |
10994 | static struct snd_kcontrol_new alc268_acer_mixer[] = { |
10995 | /* output mixer control */ | |
10996 | HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol), | |
10997 | { | |
10998 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10999 | .name = "Master Playback Switch", | |
11000 | .info = snd_hda_mixer_amp_switch_info, | |
11001 | .get = snd_hda_mixer_amp_switch_get, | |
11002 | .put = alc268_acer_master_sw_put, | |
11003 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
11004 | }, | |
33bf17ab TI |
11005 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
11006 | HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT), | |
11007 | HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT), | |
d273809e TI |
11008 | { } |
11009 | }; | |
11010 | ||
c238b4f4 TI |
11011 | static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = { |
11012 | /* output mixer control */ | |
11013 | HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol), | |
11014 | { | |
11015 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11016 | .name = "Master Playback Switch", | |
11017 | .info = snd_hda_mixer_amp_switch_info, | |
11018 | .get = snd_hda_mixer_amp_switch_get, | |
11019 | .put = alc268_acer_master_sw_put, | |
11020 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
11021 | }, | |
11022 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
11023 | HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT), | |
11024 | { } | |
11025 | }; | |
11026 | ||
8ef355da KY |
11027 | static struct hda_verb alc268_acer_aspire_one_verbs[] = { |
11028 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
11029 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
11030 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
11031 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
11032 | {0x23, AC_VERB_SET_CONNECT_SEL, 0x06}, | |
11033 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017}, | |
11034 | { } | |
11035 | }; | |
11036 | ||
d273809e | 11037 | static struct hda_verb alc268_acer_verbs[] = { |
0ccb541c TI |
11038 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */ |
11039 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
d273809e TI |
11040 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
11041 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
0ccb541c TI |
11042 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
11043 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
d273809e TI |
11044 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
11045 | { } | |
11046 | }; | |
11047 | ||
11048 | /* unsolicited event for HP jack sensing */ | |
11049 | static void alc268_toshiba_unsol_event(struct hda_codec *codec, | |
11050 | unsigned int res) | |
11051 | { | |
889c4395 | 11052 | if ((res >> 26) != ALC880_HP_EVENT) |
d273809e TI |
11053 | return; |
11054 | alc268_toshiba_automute(codec); | |
11055 | } | |
11056 | ||
11057 | static void alc268_acer_unsol_event(struct hda_codec *codec, | |
11058 | unsigned int res) | |
11059 | { | |
889c4395 | 11060 | if ((res >> 26) != ALC880_HP_EVENT) |
d273809e TI |
11061 | return; |
11062 | alc268_acer_automute(codec, 1); | |
11063 | } | |
11064 | ||
889c4395 TI |
11065 | static void alc268_acer_init_hook(struct hda_codec *codec) |
11066 | { | |
11067 | alc268_acer_automute(codec, 1); | |
11068 | } | |
11069 | ||
8ef355da KY |
11070 | /* toggle speaker-output according to the hp-jack state */ |
11071 | static void alc268_aspire_one_speaker_automute(struct hda_codec *codec) | |
11072 | { | |
11073 | unsigned int present; | |
11074 | unsigned char bits; | |
11075 | ||
11076 | present = snd_hda_codec_read(codec, 0x15, 0, | |
11077 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
11078 | bits = present ? AMP_IN_MUTE(0) : 0; | |
11079 | snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0, | |
11080 | AMP_IN_MUTE(0), bits); | |
11081 | snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1, | |
11082 | AMP_IN_MUTE(0), bits); | |
11083 | } | |
11084 | ||
11085 | ||
11086 | static void alc268_acer_mic_automute(struct hda_codec *codec) | |
11087 | { | |
11088 | unsigned int present; | |
11089 | ||
11090 | present = snd_hda_codec_read(codec, 0x18, 0, | |
11091 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
11092 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL, | |
11093 | present ? 0x0 : 0x6); | |
11094 | } | |
11095 | ||
11096 | static void alc268_acer_lc_unsol_event(struct hda_codec *codec, | |
11097 | unsigned int res) | |
11098 | { | |
11099 | if ((res >> 26) == ALC880_HP_EVENT) | |
11100 | alc268_aspire_one_speaker_automute(codec); | |
11101 | if ((res >> 26) == ALC880_MIC_EVENT) | |
11102 | alc268_acer_mic_automute(codec); | |
11103 | } | |
11104 | ||
11105 | static void alc268_acer_lc_init_hook(struct hda_codec *codec) | |
11106 | { | |
11107 | alc268_aspire_one_speaker_automute(codec); | |
11108 | alc268_acer_mic_automute(codec); | |
11109 | } | |
11110 | ||
3866f0b0 TI |
11111 | static struct snd_kcontrol_new alc268_dell_mixer[] = { |
11112 | /* output mixer control */ | |
11113 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
11114 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
11115 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
11116 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
11117 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
11118 | HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT), | |
11119 | { } | |
11120 | }; | |
11121 | ||
11122 | static struct hda_verb alc268_dell_verbs[] = { | |
11123 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
11124 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
11125 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
11126 | { } | |
11127 | }; | |
11128 | ||
11129 | /* mute/unmute internal speaker according to the hp jack and mute state */ | |
11130 | static void alc268_dell_automute(struct hda_codec *codec) | |
11131 | { | |
11132 | unsigned int present; | |
11133 | unsigned int mute; | |
11134 | ||
11135 | present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0); | |
11136 | if (present & 0x80000000) | |
11137 | mute = HDA_AMP_MUTE; | |
11138 | else | |
11139 | mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0); | |
11140 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
11141 | HDA_AMP_MUTE, mute); | |
11142 | } | |
11143 | ||
11144 | static void alc268_dell_unsol_event(struct hda_codec *codec, | |
11145 | unsigned int res) | |
11146 | { | |
11147 | if ((res >> 26) != ALC880_HP_EVENT) | |
11148 | return; | |
11149 | alc268_dell_automute(codec); | |
11150 | } | |
11151 | ||
11152 | #define alc268_dell_init_hook alc268_dell_automute | |
11153 | ||
eb5a6621 HRK |
11154 | static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = { |
11155 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT), | |
11156 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
11157 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT), | |
11158 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
11159 | HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT), | |
11160 | HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT), | |
11161 | HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT), | |
11162 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
11163 | { } | |
11164 | }; | |
11165 | ||
11166 | static struct hda_verb alc267_quanta_il1_verbs[] = { | |
11167 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
11168 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, | |
11169 | { } | |
11170 | }; | |
11171 | ||
11172 | static void alc267_quanta_il1_hp_automute(struct hda_codec *codec) | |
11173 | { | |
11174 | unsigned int present; | |
11175 | ||
11176 | present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0) | |
11177 | & AC_PINSENSE_PRESENCE; | |
11178 | snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
11179 | present ? 0 : PIN_OUT); | |
11180 | } | |
11181 | ||
11182 | static void alc267_quanta_il1_mic_automute(struct hda_codec *codec) | |
11183 | { | |
11184 | unsigned int present; | |
11185 | ||
11186 | present = snd_hda_codec_read(codec, 0x18, 0, | |
11187 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
11188 | snd_hda_codec_write(codec, 0x23, 0, | |
11189 | AC_VERB_SET_CONNECT_SEL, | |
11190 | present ? 0x00 : 0x01); | |
11191 | } | |
11192 | ||
11193 | static void alc267_quanta_il1_automute(struct hda_codec *codec) | |
11194 | { | |
11195 | alc267_quanta_il1_hp_automute(codec); | |
11196 | alc267_quanta_il1_mic_automute(codec); | |
11197 | } | |
11198 | ||
11199 | static void alc267_quanta_il1_unsol_event(struct hda_codec *codec, | |
11200 | unsigned int res) | |
11201 | { | |
11202 | switch (res >> 26) { | |
11203 | case ALC880_HP_EVENT: | |
11204 | alc267_quanta_il1_hp_automute(codec); | |
11205 | break; | |
11206 | case ALC880_MIC_EVENT: | |
11207 | alc267_quanta_il1_mic_automute(codec); | |
11208 | break; | |
11209 | } | |
11210 | } | |
11211 | ||
a361d84b KY |
11212 | /* |
11213 | * generic initialization of ADC, input mixers and output mixers | |
11214 | */ | |
11215 | static struct hda_verb alc268_base_init_verbs[] = { | |
11216 | /* Unmute DAC0-1 and set vol = 0 */ | |
11217 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
11218 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11219 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11220 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
11221 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11222 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11223 | ||
11224 | /* | |
11225 | * Set up output mixers (0x0c - 0x0e) | |
11226 | */ | |
11227 | /* set vol=0 to output mixers */ | |
11228 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11229 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11230 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
11231 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
11232 | ||
11233 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11234 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11235 | ||
11236 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
11237 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
11238 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
11239 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
11240 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
11241 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
11242 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
11243 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
11244 | ||
11245 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11246 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11247 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11248 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11249 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11250 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11251 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
aef9d318 TI |
11252 | |
11253 | /* set PCBEEP vol = 0, mute connections */ | |
11254 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11255 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
11256 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
a361d84b | 11257 | |
a9b3aa8a | 11258 | /* Unmute Selector 23h,24h and set the default input to mic-in */ |
ea1fb29a | 11259 | |
a9b3aa8a JZ |
11260 | {0x23, AC_VERB_SET_CONNECT_SEL, 0x00}, |
11261 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11262 | {0x24, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
11263 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
a361d84b | 11264 | |
a361d84b KY |
11265 | { } |
11266 | }; | |
11267 | ||
11268 | /* | |
11269 | * generic initialization of ADC, input mixers and output mixers | |
11270 | */ | |
11271 | static struct hda_verb alc268_volume_init_verbs[] = { | |
11272 | /* set output DAC */ | |
11273 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11274 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11275 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11276 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11277 | ||
11278 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
11279 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
11280 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
11281 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
11282 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
11283 | ||
11284 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
11285 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11286 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11287 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11288 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11289 | ||
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}, | |
11294 | ||
aef9d318 TI |
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 KY |
11299 | |
11300 | { } | |
11301 | }; | |
11302 | ||
a361d84b KY |
11303 | static struct snd_kcontrol_new alc268_capture_alt_mixer[] = { |
11304 | HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), | |
11305 | HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), | |
11306 | { | |
11307 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11308 | /* The multiple "Capture Source" controls confuse alsamixer | |
11309 | * So call somewhat different.. | |
a361d84b KY |
11310 | */ |
11311 | /* .name = "Capture Source", */ | |
11312 | .name = "Input Source", | |
11313 | .count = 1, | |
54cbc9ab TI |
11314 | .info = alc_mux_enum_info, |
11315 | .get = alc_mux_enum_get, | |
11316 | .put = alc_mux_enum_put, | |
a361d84b KY |
11317 | }, |
11318 | { } /* end */ | |
11319 | }; | |
11320 | ||
11321 | static struct snd_kcontrol_new alc268_capture_mixer[] = { | |
11322 | HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), | |
11323 | HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), | |
11324 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT), | |
11325 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT), | |
11326 | { | |
11327 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11328 | /* The multiple "Capture Source" controls confuse alsamixer | |
11329 | * So call somewhat different.. | |
a361d84b KY |
11330 | */ |
11331 | /* .name = "Capture Source", */ | |
11332 | .name = "Input Source", | |
11333 | .count = 2, | |
54cbc9ab TI |
11334 | .info = alc_mux_enum_info, |
11335 | .get = alc_mux_enum_get, | |
11336 | .put = alc_mux_enum_put, | |
a361d84b KY |
11337 | }, |
11338 | { } /* end */ | |
11339 | }; | |
11340 | ||
11341 | static struct hda_input_mux alc268_capture_source = { | |
11342 | .num_items = 4, | |
11343 | .items = { | |
11344 | { "Mic", 0x0 }, | |
11345 | { "Front Mic", 0x1 }, | |
11346 | { "Line", 0x2 }, | |
11347 | { "CD", 0x3 }, | |
11348 | }, | |
11349 | }; | |
11350 | ||
0ccb541c | 11351 | static struct hda_input_mux alc268_acer_capture_source = { |
c238b4f4 TI |
11352 | .num_items = 3, |
11353 | .items = { | |
11354 | { "Mic", 0x0 }, | |
11355 | { "Internal Mic", 0x1 }, | |
11356 | { "Line", 0x2 }, | |
11357 | }, | |
11358 | }; | |
11359 | ||
11360 | static struct hda_input_mux alc268_acer_dmic_capture_source = { | |
0ccb541c TI |
11361 | .num_items = 3, |
11362 | .items = { | |
11363 | { "Mic", 0x0 }, | |
11364 | { "Internal Mic", 0x6 }, | |
11365 | { "Line", 0x2 }, | |
11366 | }, | |
11367 | }; | |
11368 | ||
86c53bd2 JW |
11369 | #ifdef CONFIG_SND_DEBUG |
11370 | static struct snd_kcontrol_new alc268_test_mixer[] = { | |
86c53bd2 JW |
11371 | /* Volume widgets */ |
11372 | HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
11373 | HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
11374 | HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
11375 | HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT), | |
11376 | HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT), | |
11377 | HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT), | |
11378 | HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT), | |
11379 | HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT), | |
11380 | HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT), | |
11381 | HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT), | |
11382 | HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT), | |
11383 | HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT), | |
11384 | HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT), | |
f0747ee6 TI |
11385 | /* The below appears problematic on some hardwares */ |
11386 | /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/ | |
86c53bd2 JW |
11387 | HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT), |
11388 | HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT), | |
11389 | HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT), | |
11390 | HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT), | |
11391 | ||
11392 | /* Modes for retasking pin widgets */ | |
11393 | ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT), | |
11394 | ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT), | |
11395 | ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT), | |
11396 | ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT), | |
11397 | ||
11398 | /* Controls for GPIO pins, assuming they are configured as outputs */ | |
11399 | ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01), | |
11400 | ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02), | |
11401 | ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04), | |
11402 | ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08), | |
11403 | ||
11404 | /* Switches to allow the digital SPDIF output pin to be enabled. | |
11405 | * The ALC268 does not have an SPDIF input. | |
11406 | */ | |
11407 | ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01), | |
11408 | ||
11409 | /* A switch allowing EAPD to be enabled. Some laptops seem to use | |
11410 | * this output to turn on an external amplifier. | |
11411 | */ | |
11412 | ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02), | |
11413 | ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02), | |
11414 | ||
11415 | { } /* end */ | |
11416 | }; | |
11417 | #endif | |
11418 | ||
a361d84b KY |
11419 | /* create input playback/capture controls for the given pin */ |
11420 | static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid, | |
11421 | const char *ctlname, int idx) | |
11422 | { | |
11423 | char name[32]; | |
11424 | int err; | |
11425 | ||
11426 | sprintf(name, "%s Playback Volume", ctlname); | |
11427 | if (nid == 0x14) { | |
11428 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
11429 | HDA_COMPOSE_AMP_VAL(0x02, 3, idx, | |
11430 | HDA_OUTPUT)); | |
11431 | if (err < 0) | |
11432 | return err; | |
11433 | } else if (nid == 0x15) { | |
11434 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
11435 | HDA_COMPOSE_AMP_VAL(0x03, 3, idx, | |
11436 | HDA_OUTPUT)); | |
11437 | if (err < 0) | |
11438 | return err; | |
11439 | } else | |
11440 | return -1; | |
11441 | sprintf(name, "%s Playback Switch", ctlname); | |
11442 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | |
11443 | HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT)); | |
11444 | if (err < 0) | |
11445 | return err; | |
11446 | return 0; | |
11447 | } | |
11448 | ||
11449 | /* add playback controls from the parsed DAC table */ | |
11450 | static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec, | |
11451 | const struct auto_pin_cfg *cfg) | |
11452 | { | |
11453 | hda_nid_t nid; | |
11454 | int err; | |
11455 | ||
11456 | spec->multiout.num_dacs = 2; /* only use one dac */ | |
11457 | spec->multiout.dac_nids = spec->private_dac_nids; | |
11458 | spec->multiout.dac_nids[0] = 2; | |
11459 | spec->multiout.dac_nids[1] = 3; | |
11460 | ||
11461 | nid = cfg->line_out_pins[0]; | |
11462 | if (nid) | |
ea1fb29a | 11463 | alc268_new_analog_output(spec, nid, "Front", 0); |
a361d84b KY |
11464 | |
11465 | nid = cfg->speaker_pins[0]; | |
11466 | if (nid == 0x1d) { | |
11467 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
11468 | "Speaker Playback Volume", | |
11469 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | |
11470 | if (err < 0) | |
11471 | return err; | |
11472 | } | |
11473 | nid = cfg->hp_pins[0]; | |
11474 | if (nid) | |
11475 | alc268_new_analog_output(spec, nid, "Headphone", 0); | |
11476 | ||
11477 | nid = cfg->line_out_pins[1] | cfg->line_out_pins[2]; | |
11478 | if (nid == 0x16) { | |
11479 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
11480 | "Mono Playback Switch", | |
11481 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT)); | |
11482 | if (err < 0) | |
11483 | return err; | |
11484 | } | |
ea1fb29a | 11485 | return 0; |
a361d84b KY |
11486 | } |
11487 | ||
11488 | /* create playback/capture controls for input pins */ | |
11489 | static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec, | |
11490 | const struct auto_pin_cfg *cfg) | |
11491 | { | |
11492 | struct hda_input_mux *imux = &spec->private_imux; | |
11493 | int i, idx1; | |
11494 | ||
11495 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
11496 | switch(cfg->input_pins[i]) { | |
11497 | case 0x18: | |
11498 | idx1 = 0; /* Mic 1 */ | |
11499 | break; | |
11500 | case 0x19: | |
11501 | idx1 = 1; /* Mic 2 */ | |
11502 | break; | |
11503 | case 0x1a: | |
11504 | idx1 = 2; /* Line In */ | |
11505 | break; | |
ea1fb29a | 11506 | case 0x1c: |
a361d84b KY |
11507 | idx1 = 3; /* CD */ |
11508 | break; | |
7194cae6 TI |
11509 | case 0x12: |
11510 | case 0x13: | |
11511 | idx1 = 6; /* digital mics */ | |
11512 | break; | |
a361d84b KY |
11513 | default: |
11514 | continue; | |
11515 | } | |
11516 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; | |
11517 | imux->items[imux->num_items].index = idx1; | |
ea1fb29a | 11518 | imux->num_items++; |
a361d84b KY |
11519 | } |
11520 | return 0; | |
11521 | } | |
11522 | ||
11523 | static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec) | |
11524 | { | |
11525 | struct alc_spec *spec = codec->spec; | |
11526 | hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0]; | |
11527 | hda_nid_t hp_nid = spec->autocfg.hp_pins[0]; | |
11528 | hda_nid_t line_nid = spec->autocfg.line_out_pins[0]; | |
11529 | unsigned int dac_vol1, dac_vol2; | |
11530 | ||
11531 | if (speaker_nid) { | |
11532 | snd_hda_codec_write(codec, speaker_nid, 0, | |
11533 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | |
11534 | snd_hda_codec_write(codec, 0x0f, 0, | |
11535 | AC_VERB_SET_AMP_GAIN_MUTE, | |
11536 | AMP_IN_UNMUTE(1)); | |
11537 | snd_hda_codec_write(codec, 0x10, 0, | |
11538 | AC_VERB_SET_AMP_GAIN_MUTE, | |
11539 | AMP_IN_UNMUTE(1)); | |
11540 | } else { | |
11541 | snd_hda_codec_write(codec, 0x0f, 0, | |
11542 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)); | |
11543 | snd_hda_codec_write(codec, 0x10, 0, | |
11544 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)); | |
11545 | } | |
11546 | ||
11547 | dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */ | |
ea1fb29a | 11548 | if (line_nid == 0x14) |
a361d84b KY |
11549 | dac_vol2 = AMP_OUT_ZERO; |
11550 | else if (line_nid == 0x15) | |
11551 | dac_vol1 = AMP_OUT_ZERO; | |
ea1fb29a | 11552 | if (hp_nid == 0x14) |
a361d84b KY |
11553 | dac_vol2 = AMP_OUT_ZERO; |
11554 | else if (hp_nid == 0x15) | |
11555 | dac_vol1 = AMP_OUT_ZERO; | |
11556 | if (line_nid != 0x16 || hp_nid != 0x16 || | |
11557 | spec->autocfg.line_out_pins[1] != 0x16 || | |
11558 | spec->autocfg.line_out_pins[2] != 0x16) | |
11559 | dac_vol1 = dac_vol2 = AMP_OUT_ZERO; | |
11560 | ||
11561 | snd_hda_codec_write(codec, 0x02, 0, | |
11562 | AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1); | |
11563 | snd_hda_codec_write(codec, 0x03, 0, | |
11564 | AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2); | |
11565 | } | |
11566 | ||
11567 | /* pcm configuration: identiacal with ALC880 */ | |
11568 | #define alc268_pcm_analog_playback alc880_pcm_analog_playback | |
11569 | #define alc268_pcm_analog_capture alc880_pcm_analog_capture | |
6330079f | 11570 | #define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture |
a361d84b KY |
11571 | #define alc268_pcm_digital_playback alc880_pcm_digital_playback |
11572 | ||
11573 | /* | |
11574 | * BIOS auto configuration | |
11575 | */ | |
11576 | static int alc268_parse_auto_config(struct hda_codec *codec) | |
11577 | { | |
11578 | struct alc_spec *spec = codec->spec; | |
11579 | int err; | |
11580 | static hda_nid_t alc268_ignore[] = { 0 }; | |
11581 | ||
11582 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | |
11583 | alc268_ignore); | |
11584 | if (err < 0) | |
11585 | return err; | |
11586 | if (!spec->autocfg.line_outs) | |
11587 | return 0; /* can't find valid BIOS pin config */ | |
11588 | ||
11589 | err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
11590 | if (err < 0) | |
11591 | return err; | |
11592 | err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
11593 | if (err < 0) | |
11594 | return err; | |
11595 | ||
11596 | spec->multiout.max_channels = 2; | |
11597 | ||
11598 | /* digital only support output */ | |
11599 | if (spec->autocfg.dig_out_pin) | |
11600 | spec->multiout.dig_out_nid = ALC268_DIGOUT_NID; | |
11601 | ||
603c4019 | 11602 | if (spec->kctls.list) |
d88897ea | 11603 | add_mixer(spec, spec->kctls.list); |
a361d84b | 11604 | |
aef9d318 | 11605 | if (spec->autocfg.speaker_pins[0] != 0x1d) |
d88897ea | 11606 | add_mixer(spec, alc268_beep_mixer); |
aef9d318 | 11607 | |
d88897ea | 11608 | add_verb(spec, alc268_volume_init_verbs); |
a361d84b KY |
11609 | spec->num_mux_defs = 1; |
11610 | spec->input_mux = &spec->private_imux; | |
11611 | ||
776e184e TI |
11612 | err = alc_auto_add_mic_boost(codec); |
11613 | if (err < 0) | |
11614 | return err; | |
11615 | ||
e044c39a | 11616 | store_pin_configs(codec); |
a361d84b KY |
11617 | return 1; |
11618 | } | |
11619 | ||
11620 | #define alc268_auto_init_multi_out alc882_auto_init_multi_out | |
11621 | #define alc268_auto_init_hp_out alc882_auto_init_hp_out | |
11622 | #define alc268_auto_init_analog_input alc882_auto_init_analog_input | |
11623 | ||
11624 | /* init callback for auto-configuration model -- overriding the default init */ | |
11625 | static void alc268_auto_init(struct hda_codec *codec) | |
11626 | { | |
f6c7e546 | 11627 | struct alc_spec *spec = codec->spec; |
a361d84b KY |
11628 | alc268_auto_init_multi_out(codec); |
11629 | alc268_auto_init_hp_out(codec); | |
11630 | alc268_auto_init_mono_speaker_out(codec); | |
11631 | alc268_auto_init_analog_input(codec); | |
f6c7e546 | 11632 | if (spec->unsol_event) |
7fb0d78f | 11633 | alc_inithook(codec); |
a361d84b KY |
11634 | } |
11635 | ||
11636 | /* | |
11637 | * configuration and preset | |
11638 | */ | |
11639 | static const char *alc268_models[ALC268_MODEL_LAST] = { | |
eb5a6621 | 11640 | [ALC267_QUANTA_IL1] = "quanta-il1", |
a361d84b | 11641 | [ALC268_3ST] = "3stack", |
983f8ae4 | 11642 | [ALC268_TOSHIBA] = "toshiba", |
d273809e | 11643 | [ALC268_ACER] = "acer", |
c238b4f4 | 11644 | [ALC268_ACER_DMIC] = "acer-dmic", |
8ef355da | 11645 | [ALC268_ACER_ASPIRE_ONE] = "acer-aspire", |
3866f0b0 | 11646 | [ALC268_DELL] = "dell", |
f12462c5 | 11647 | [ALC268_ZEPTO] = "zepto", |
86c53bd2 JW |
11648 | #ifdef CONFIG_SND_DEBUG |
11649 | [ALC268_TEST] = "test", | |
11650 | #endif | |
a361d84b KY |
11651 | [ALC268_AUTO] = "auto", |
11652 | }; | |
11653 | ||
11654 | static struct snd_pci_quirk alc268_cfg_tbl[] = { | |
a0b8f7d8 | 11655 | SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER), |
ac3e3741 | 11656 | SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER), |
dafc8357 | 11657 | SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER), |
ac3e3741 | 11658 | SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER), |
29a52c24 | 11659 | SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER), |
8ef355da KY |
11660 | SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One", |
11661 | ALC268_ACER_ASPIRE_ONE), | |
3866f0b0 | 11662 | SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL), |
ac3e3741 | 11663 | SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA), |
a361d84b | 11664 | SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST), |
d1a991a6 | 11665 | SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA), |
8e7f00f9 | 11666 | SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA), |
2346d0cd | 11667 | SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA), |
378bd6a5 | 11668 | SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA), |
b875bf3a | 11669 | SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER), |
eb5a6621 | 11670 | SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1), |
f12462c5 | 11671 | SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO), |
a361d84b KY |
11672 | {} |
11673 | }; | |
11674 | ||
11675 | static struct alc_config_preset alc268_presets[] = { | |
eb5a6621 HRK |
11676 | [ALC267_QUANTA_IL1] = { |
11677 | .mixers = { alc267_quanta_il1_mixer }, | |
11678 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, | |
11679 | alc267_quanta_il1_verbs }, | |
11680 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11681 | .dac_nids = alc268_dac_nids, | |
11682 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11683 | .adc_nids = alc268_adc_nids_alt, | |
11684 | .hp_nid = 0x03, | |
11685 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11686 | .channel_mode = alc268_modes, | |
11687 | .input_mux = &alc268_capture_source, | |
11688 | .unsol_event = alc267_quanta_il1_unsol_event, | |
11689 | .init_hook = alc267_quanta_il1_automute, | |
11690 | }, | |
a361d84b | 11691 | [ALC268_3ST] = { |
aef9d318 TI |
11692 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, |
11693 | alc268_beep_mixer }, | |
a361d84b KY |
11694 | .init_verbs = { alc268_base_init_verbs }, |
11695 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11696 | .dac_nids = alc268_dac_nids, | |
11697 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11698 | .adc_nids = alc268_adc_nids_alt, | |
e1406348 | 11699 | .capsrc_nids = alc268_capsrc_nids, |
a361d84b KY |
11700 | .hp_nid = 0x03, |
11701 | .dig_out_nid = ALC268_DIGOUT_NID, | |
11702 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11703 | .channel_mode = alc268_modes, | |
11704 | .input_mux = &alc268_capture_source, | |
11705 | }, | |
d1a991a6 | 11706 | [ALC268_TOSHIBA] = { |
aef9d318 TI |
11707 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, |
11708 | alc268_beep_mixer }, | |
d273809e TI |
11709 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
11710 | alc268_toshiba_verbs }, | |
d1a991a6 KY |
11711 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), |
11712 | .dac_nids = alc268_dac_nids, | |
11713 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11714 | .adc_nids = alc268_adc_nids_alt, | |
e1406348 | 11715 | .capsrc_nids = alc268_capsrc_nids, |
d1a991a6 KY |
11716 | .hp_nid = 0x03, |
11717 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11718 | .channel_mode = alc268_modes, | |
11719 | .input_mux = &alc268_capture_source, | |
d273809e TI |
11720 | .unsol_event = alc268_toshiba_unsol_event, |
11721 | .init_hook = alc268_toshiba_automute, | |
11722 | }, | |
11723 | [ALC268_ACER] = { | |
aef9d318 TI |
11724 | .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer, |
11725 | alc268_beep_mixer }, | |
d273809e TI |
11726 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
11727 | alc268_acer_verbs }, | |
11728 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11729 | .dac_nids = alc268_dac_nids, | |
11730 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11731 | .adc_nids = alc268_adc_nids_alt, | |
e1406348 | 11732 | .capsrc_nids = alc268_capsrc_nids, |
d273809e TI |
11733 | .hp_nid = 0x02, |
11734 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11735 | .channel_mode = alc268_modes, | |
0ccb541c | 11736 | .input_mux = &alc268_acer_capture_source, |
d273809e | 11737 | .unsol_event = alc268_acer_unsol_event, |
889c4395 | 11738 | .init_hook = alc268_acer_init_hook, |
d1a991a6 | 11739 | }, |
c238b4f4 TI |
11740 | [ALC268_ACER_DMIC] = { |
11741 | .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer, | |
11742 | alc268_beep_mixer }, | |
11743 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, | |
11744 | alc268_acer_verbs }, | |
11745 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11746 | .dac_nids = alc268_dac_nids, | |
11747 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11748 | .adc_nids = alc268_adc_nids_alt, | |
11749 | .capsrc_nids = alc268_capsrc_nids, | |
11750 | .hp_nid = 0x02, | |
11751 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11752 | .channel_mode = alc268_modes, | |
11753 | .input_mux = &alc268_acer_dmic_capture_source, | |
11754 | .unsol_event = alc268_acer_unsol_event, | |
11755 | .init_hook = alc268_acer_init_hook, | |
11756 | }, | |
8ef355da KY |
11757 | [ALC268_ACER_ASPIRE_ONE] = { |
11758 | .mixers = { alc268_acer_aspire_one_mixer, | |
11759 | alc268_capture_alt_mixer }, | |
11760 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, | |
11761 | alc268_acer_aspire_one_verbs }, | |
11762 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11763 | .dac_nids = alc268_dac_nids, | |
11764 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11765 | .adc_nids = alc268_adc_nids_alt, | |
11766 | .capsrc_nids = alc268_capsrc_nids, | |
11767 | .hp_nid = 0x03, | |
11768 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11769 | .channel_mode = alc268_modes, | |
11770 | .input_mux = &alc268_acer_lc_capture_source, | |
11771 | .unsol_event = alc268_acer_lc_unsol_event, | |
11772 | .init_hook = alc268_acer_lc_init_hook, | |
11773 | }, | |
3866f0b0 | 11774 | [ALC268_DELL] = { |
aef9d318 | 11775 | .mixers = { alc268_dell_mixer, alc268_beep_mixer }, |
3866f0b0 TI |
11776 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
11777 | alc268_dell_verbs }, | |
11778 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11779 | .dac_nids = alc268_dac_nids, | |
11780 | .hp_nid = 0x02, | |
11781 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11782 | .channel_mode = alc268_modes, | |
11783 | .unsol_event = alc268_dell_unsol_event, | |
11784 | .init_hook = alc268_dell_init_hook, | |
11785 | .input_mux = &alc268_capture_source, | |
11786 | }, | |
f12462c5 | 11787 | [ALC268_ZEPTO] = { |
aef9d318 TI |
11788 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, |
11789 | alc268_beep_mixer }, | |
f12462c5 MT |
11790 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
11791 | alc268_toshiba_verbs }, | |
11792 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11793 | .dac_nids = alc268_dac_nids, | |
11794 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11795 | .adc_nids = alc268_adc_nids_alt, | |
e1406348 | 11796 | .capsrc_nids = alc268_capsrc_nids, |
f12462c5 MT |
11797 | .hp_nid = 0x03, |
11798 | .dig_out_nid = ALC268_DIGOUT_NID, | |
11799 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11800 | .channel_mode = alc268_modes, | |
11801 | .input_mux = &alc268_capture_source, | |
11802 | .unsol_event = alc268_toshiba_unsol_event, | |
11803 | .init_hook = alc268_toshiba_automute | |
11804 | }, | |
86c53bd2 JW |
11805 | #ifdef CONFIG_SND_DEBUG |
11806 | [ALC268_TEST] = { | |
11807 | .mixers = { alc268_test_mixer, alc268_capture_mixer }, | |
11808 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, | |
11809 | alc268_volume_init_verbs }, | |
11810 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11811 | .dac_nids = alc268_dac_nids, | |
11812 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11813 | .adc_nids = alc268_adc_nids_alt, | |
e1406348 | 11814 | .capsrc_nids = alc268_capsrc_nids, |
86c53bd2 JW |
11815 | .hp_nid = 0x03, |
11816 | .dig_out_nid = ALC268_DIGOUT_NID, | |
11817 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11818 | .channel_mode = alc268_modes, | |
11819 | .input_mux = &alc268_capture_source, | |
11820 | }, | |
11821 | #endif | |
a361d84b KY |
11822 | }; |
11823 | ||
11824 | static int patch_alc268(struct hda_codec *codec) | |
11825 | { | |
11826 | struct alc_spec *spec; | |
11827 | int board_config; | |
11828 | int err; | |
11829 | ||
11830 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); | |
11831 | if (spec == NULL) | |
11832 | return -ENOMEM; | |
11833 | ||
11834 | codec->spec = spec; | |
11835 | ||
11836 | board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST, | |
11837 | alc268_models, | |
11838 | alc268_cfg_tbl); | |
11839 | ||
11840 | if (board_config < 0 || board_config >= ALC268_MODEL_LAST) { | |
11841 | printk(KERN_INFO "hda_codec: Unknown model for ALC268, " | |
11842 | "trying auto-probe from BIOS...\n"); | |
11843 | board_config = ALC268_AUTO; | |
11844 | } | |
11845 | ||
11846 | if (board_config == ALC268_AUTO) { | |
11847 | /* automatic parse from the BIOS config */ | |
11848 | err = alc268_parse_auto_config(codec); | |
11849 | if (err < 0) { | |
11850 | alc_free(codec); | |
11851 | return err; | |
11852 | } else if (!err) { | |
11853 | printk(KERN_INFO | |
11854 | "hda_codec: Cannot set up configuration " | |
11855 | "from BIOS. Using base mode...\n"); | |
11856 | board_config = ALC268_3ST; | |
11857 | } | |
11858 | } | |
11859 | ||
11860 | if (board_config != ALC268_AUTO) | |
11861 | setup_preset(spec, &alc268_presets[board_config]); | |
11862 | ||
2f893286 KY |
11863 | if (codec->vendor_id == 0x10ec0267) { |
11864 | spec->stream_name_analog = "ALC267 Analog"; | |
11865 | spec->stream_name_digital = "ALC267 Digital"; | |
11866 | } else { | |
11867 | spec->stream_name_analog = "ALC268 Analog"; | |
11868 | spec->stream_name_digital = "ALC268 Digital"; | |
11869 | } | |
11870 | ||
a361d84b KY |
11871 | spec->stream_analog_playback = &alc268_pcm_analog_playback; |
11872 | spec->stream_analog_capture = &alc268_pcm_analog_capture; | |
6330079f | 11873 | spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture; |
a361d84b | 11874 | |
a361d84b KY |
11875 | spec->stream_digital_playback = &alc268_pcm_digital_playback; |
11876 | ||
aef9d318 TI |
11877 | if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) |
11878 | /* override the amp caps for beep generator */ | |
11879 | snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, | |
11880 | (0x0c << AC_AMPCAP_OFFSET_SHIFT) | | |
11881 | (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) | | |
11882 | (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) | | |
11883 | (0 << AC_AMPCAP_MUTE_SHIFT)); | |
11884 | ||
3866f0b0 TI |
11885 | if (!spec->adc_nids && spec->input_mux) { |
11886 | /* check whether NID 0x07 is valid */ | |
11887 | unsigned int wcap = get_wcaps(codec, 0x07); | |
85860c06 | 11888 | int i; |
3866f0b0 TI |
11889 | |
11890 | /* get type */ | |
11891 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
67ebcb03 | 11892 | if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) { |
3866f0b0 TI |
11893 | spec->adc_nids = alc268_adc_nids_alt; |
11894 | spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt); | |
d88897ea | 11895 | add_mixer(spec, alc268_capture_alt_mixer); |
3866f0b0 TI |
11896 | } else { |
11897 | spec->adc_nids = alc268_adc_nids; | |
11898 | spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids); | |
d88897ea | 11899 | add_mixer(spec, alc268_capture_mixer); |
a361d84b | 11900 | } |
e1406348 | 11901 | spec->capsrc_nids = alc268_capsrc_nids; |
85860c06 TI |
11902 | /* set default input source */ |
11903 | for (i = 0; i < spec->num_adc_nids; i++) | |
11904 | snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i], | |
11905 | 0, AC_VERB_SET_CONNECT_SEL, | |
11906 | spec->input_mux->items[0].index); | |
a361d84b | 11907 | } |
2134ea4f TI |
11908 | |
11909 | spec->vmaster_nid = 0x02; | |
11910 | ||
a361d84b KY |
11911 | codec->patch_ops = alc_patch_ops; |
11912 | if (board_config == ALC268_AUTO) | |
11913 | spec->init_hook = alc268_auto_init; | |
ea1fb29a | 11914 | |
a361d84b KY |
11915 | return 0; |
11916 | } | |
11917 | ||
f6a92248 KY |
11918 | /* |
11919 | * ALC269 channel source setting (2 channel) | |
11920 | */ | |
11921 | #define ALC269_DIGOUT_NID ALC880_DIGOUT_NID | |
11922 | ||
11923 | #define alc269_dac_nids alc260_dac_nids | |
11924 | ||
11925 | static hda_nid_t alc269_adc_nids[1] = { | |
11926 | /* ADC1 */ | |
f53281e6 KY |
11927 | 0x08, |
11928 | }; | |
11929 | ||
e01bf509 TI |
11930 | static hda_nid_t alc269_capsrc_nids[1] = { |
11931 | 0x23, | |
11932 | }; | |
11933 | ||
11934 | /* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24), | |
11935 | * not a mux! | |
11936 | */ | |
11937 | ||
f53281e6 KY |
11938 | static struct hda_input_mux alc269_eeepc_dmic_capture_source = { |
11939 | .num_items = 2, | |
11940 | .items = { | |
11941 | { "i-Mic", 0x5 }, | |
11942 | { "e-Mic", 0x0 }, | |
11943 | }, | |
11944 | }; | |
11945 | ||
11946 | static struct hda_input_mux alc269_eeepc_amic_capture_source = { | |
11947 | .num_items = 2, | |
11948 | .items = { | |
11949 | { "i-Mic", 0x1 }, | |
11950 | { "e-Mic", 0x0 }, | |
11951 | }, | |
f6a92248 KY |
11952 | }; |
11953 | ||
11954 | #define alc269_modes alc260_modes | |
11955 | #define alc269_capture_source alc880_lg_lw_capture_source | |
11956 | ||
11957 | static struct snd_kcontrol_new alc269_base_mixer[] = { | |
11958 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
11959 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
11960 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
11961 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
11962 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
11963 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2005af24 TI |
11964 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT), |
11965 | HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT), | |
f6a92248 KY |
11966 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
11967 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
11968 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
11969 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
11970 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
11971 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | |
11972 | { } /* end */ | |
11973 | }; | |
11974 | ||
60db6b53 KY |
11975 | static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = { |
11976 | /* output mixer control */ | |
11977 | HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol), | |
11978 | { | |
11979 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11980 | .name = "Master Playback Switch", | |
11981 | .info = snd_hda_mixer_amp_switch_info, | |
11982 | .get = snd_hda_mixer_amp_switch_get, | |
11983 | .put = alc268_acer_master_sw_put, | |
11984 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
11985 | }, | |
11986 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
11987 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
11988 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
11989 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
11990 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
11991 | HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT), | |
11992 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
11993 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
11994 | { } | |
11995 | }; | |
11996 | ||
64154835 TV |
11997 | static struct snd_kcontrol_new alc269_lifebook_mixer[] = { |
11998 | /* output mixer control */ | |
11999 | HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol), | |
12000 | { | |
12001 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
12002 | .name = "Master Playback Switch", | |
12003 | .info = snd_hda_mixer_amp_switch_info, | |
12004 | .get = snd_hda_mixer_amp_switch_get, | |
12005 | .put = alc268_acer_master_sw_put, | |
12006 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
12007 | }, | |
12008 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
12009 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
12010 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
12011 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
12012 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
12013 | HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT), | |
12014 | HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT), | |
12015 | HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT), | |
12016 | HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT), | |
12017 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
12018 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
12019 | { } | |
12020 | }; | |
12021 | ||
f53281e6 KY |
12022 | /* bind volumes of both NID 0x0c and 0x0d */ |
12023 | static struct hda_bind_ctls alc269_epc_bind_vol = { | |
12024 | .ops = &snd_hda_bind_vol, | |
12025 | .values = { | |
12026 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), | |
12027 | HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT), | |
12028 | 0 | |
12029 | }, | |
12030 | }; | |
12031 | ||
12032 | static struct snd_kcontrol_new alc269_eeepc_mixer[] = { | |
12033 | HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
12034 | HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol), | |
12035 | HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
12036 | { } /* end */ | |
12037 | }; | |
12038 | ||
f53281e6 KY |
12039 | /* capture mixer elements */ |
12040 | static struct snd_kcontrol_new alc269_epc_capture_mixer[] = { | |
12041 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
12042 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
26f5df26 TI |
12043 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
12044 | { } /* end */ | |
12045 | }; | |
12046 | ||
12047 | /* FSC amilo */ | |
12048 | static struct snd_kcontrol_new alc269_fujitsu_mixer[] = { | |
12049 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
12050 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
12051 | HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol), | |
f53281e6 KY |
12052 | { } /* end */ |
12053 | }; | |
12054 | ||
2005af24 TI |
12055 | /* beep control */ |
12056 | static struct snd_kcontrol_new alc269_beep_mixer[] = { | |
12057 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT), | |
12058 | HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT), | |
12059 | { } /* end */ | |
12060 | }; | |
12061 | ||
60db6b53 KY |
12062 | static struct hda_verb alc269_quanta_fl1_verbs[] = { |
12063 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
12064 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12065 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
12066 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
12067 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
12068 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12069 | { } | |
12070 | }; | |
f6a92248 | 12071 | |
64154835 TV |
12072 | static struct hda_verb alc269_lifebook_verbs[] = { |
12073 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
12074 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
12075 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12076 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
12077 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
12078 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12079 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
12080 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
12081 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
12082 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12083 | { } | |
12084 | }; | |
12085 | ||
60db6b53 KY |
12086 | /* toggle speaker-output according to the hp-jack state */ |
12087 | static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec) | |
12088 | { | |
12089 | unsigned int present; | |
12090 | unsigned char bits; | |
f6a92248 | 12091 | |
60db6b53 KY |
12092 | present = snd_hda_codec_read(codec, 0x15, 0, |
12093 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
12094 | bits = present ? AMP_IN_MUTE(0) : 0; | |
12095 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
12096 | AMP_IN_MUTE(0), bits); | |
12097 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
12098 | AMP_IN_MUTE(0), bits); | |
f6a92248 | 12099 | |
60db6b53 KY |
12100 | snd_hda_codec_write(codec, 0x20, 0, |
12101 | AC_VERB_SET_COEF_INDEX, 0x0c); | |
12102 | snd_hda_codec_write(codec, 0x20, 0, | |
12103 | AC_VERB_SET_PROC_COEF, 0x680); | |
f6a92248 | 12104 | |
60db6b53 KY |
12105 | snd_hda_codec_write(codec, 0x20, 0, |
12106 | AC_VERB_SET_COEF_INDEX, 0x0c); | |
12107 | snd_hda_codec_write(codec, 0x20, 0, | |
12108 | AC_VERB_SET_PROC_COEF, 0x480); | |
12109 | } | |
f6a92248 | 12110 | |
64154835 TV |
12111 | /* toggle speaker-output according to the hp-jacks state */ |
12112 | static void alc269_lifebook_speaker_automute(struct hda_codec *codec) | |
12113 | { | |
12114 | unsigned int present; | |
12115 | unsigned char bits; | |
12116 | ||
12117 | /* Check laptop headphone socket */ | |
12118 | present = snd_hda_codec_read(codec, 0x15, 0, | |
12119 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
12120 | ||
12121 | /* Check port replicator headphone socket */ | |
12122 | present |= snd_hda_codec_read(codec, 0x1a, 0, | |
12123 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
12124 | ||
12125 | bits = present ? AMP_IN_MUTE(0) : 0; | |
12126 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
12127 | AMP_IN_MUTE(0), bits); | |
12128 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
12129 | AMP_IN_MUTE(0), bits); | |
12130 | ||
12131 | snd_hda_codec_write(codec, 0x20, 0, | |
12132 | AC_VERB_SET_COEF_INDEX, 0x0c); | |
12133 | snd_hda_codec_write(codec, 0x20, 0, | |
12134 | AC_VERB_SET_PROC_COEF, 0x680); | |
12135 | ||
12136 | snd_hda_codec_write(codec, 0x20, 0, | |
12137 | AC_VERB_SET_COEF_INDEX, 0x0c); | |
12138 | snd_hda_codec_write(codec, 0x20, 0, | |
12139 | AC_VERB_SET_PROC_COEF, 0x480); | |
12140 | } | |
12141 | ||
60db6b53 KY |
12142 | static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec) |
12143 | { | |
12144 | unsigned int present; | |
f6a92248 | 12145 | |
60db6b53 KY |
12146 | present = snd_hda_codec_read(codec, 0x18, 0, |
12147 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
12148 | snd_hda_codec_write(codec, 0x23, 0, | |
12149 | AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1); | |
12150 | } | |
f6a92248 | 12151 | |
64154835 TV |
12152 | static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec) |
12153 | { | |
12154 | unsigned int present_laptop; | |
12155 | unsigned int present_dock; | |
12156 | ||
12157 | present_laptop = snd_hda_codec_read(codec, 0x18, 0, | |
12158 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
12159 | ||
12160 | present_dock = snd_hda_codec_read(codec, 0x1b, 0, | |
12161 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
12162 | ||
12163 | /* Laptop mic port overrides dock mic port, design decision */ | |
12164 | if (present_dock) | |
12165 | snd_hda_codec_write(codec, 0x23, 0, | |
12166 | AC_VERB_SET_CONNECT_SEL, 0x3); | |
12167 | if (present_laptop) | |
12168 | snd_hda_codec_write(codec, 0x23, 0, | |
12169 | AC_VERB_SET_CONNECT_SEL, 0x0); | |
12170 | if (!present_dock && !present_laptop) | |
12171 | snd_hda_codec_write(codec, 0x23, 0, | |
12172 | AC_VERB_SET_CONNECT_SEL, 0x1); | |
12173 | } | |
12174 | ||
60db6b53 KY |
12175 | static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec, |
12176 | unsigned int res) | |
12177 | { | |
12178 | if ((res >> 26) == ALC880_HP_EVENT) | |
12179 | alc269_quanta_fl1_speaker_automute(codec); | |
12180 | if ((res >> 26) == ALC880_MIC_EVENT) | |
12181 | alc269_quanta_fl1_mic_automute(codec); | |
12182 | } | |
f6a92248 | 12183 | |
64154835 TV |
12184 | static void alc269_lifebook_unsol_event(struct hda_codec *codec, |
12185 | unsigned int res) | |
12186 | { | |
12187 | if ((res >> 26) == ALC880_HP_EVENT) | |
12188 | alc269_lifebook_speaker_automute(codec); | |
12189 | if ((res >> 26) == ALC880_MIC_EVENT) | |
12190 | alc269_lifebook_mic_autoswitch(codec); | |
12191 | } | |
12192 | ||
60db6b53 KY |
12193 | static void alc269_quanta_fl1_init_hook(struct hda_codec *codec) |
12194 | { | |
12195 | alc269_quanta_fl1_speaker_automute(codec); | |
12196 | alc269_quanta_fl1_mic_automute(codec); | |
12197 | } | |
f6a92248 | 12198 | |
64154835 TV |
12199 | static void alc269_lifebook_init_hook(struct hda_codec *codec) |
12200 | { | |
12201 | alc269_lifebook_speaker_automute(codec); | |
12202 | alc269_lifebook_mic_autoswitch(codec); | |
12203 | } | |
12204 | ||
f53281e6 KY |
12205 | static struct hda_verb alc269_eeepc_dmic_init_verbs[] = { |
12206 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
12207 | {0x23, AC_VERB_SET_CONNECT_SEL, 0x05}, | |
12208 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 }, | |
12209 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))}, | |
12210 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12211 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
12212 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
12213 | {} | |
12214 | }; | |
12215 | ||
12216 | static struct hda_verb alc269_eeepc_amic_init_verbs[] = { | |
12217 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
12218 | {0x23, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
12219 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 }, | |
12220 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))}, | |
12221 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
12222 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
12223 | {} | |
12224 | }; | |
12225 | ||
12226 | /* toggle speaker-output according to the hp-jack state */ | |
12227 | static void alc269_speaker_automute(struct hda_codec *codec) | |
12228 | { | |
12229 | unsigned int present; | |
60db6b53 | 12230 | unsigned char bits; |
f53281e6 KY |
12231 | |
12232 | present = snd_hda_codec_read(codec, 0x15, 0, | |
60db6b53 | 12233 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; |
f53281e6 KY |
12234 | bits = present ? AMP_IN_MUTE(0) : 0; |
12235 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
60db6b53 | 12236 | AMP_IN_MUTE(0), bits); |
f53281e6 | 12237 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, |
60db6b53 | 12238 | AMP_IN_MUTE(0), bits); |
f53281e6 KY |
12239 | } |
12240 | ||
12241 | static void alc269_eeepc_dmic_automute(struct hda_codec *codec) | |
12242 | { | |
12243 | unsigned int present; | |
12244 | ||
60db6b53 KY |
12245 | present = snd_hda_codec_read(codec, 0x18, 0, |
12246 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
12247 | snd_hda_codec_write(codec, 0x23, 0, | |
12248 | AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5)); | |
f53281e6 KY |
12249 | } |
12250 | ||
12251 | static void alc269_eeepc_amic_automute(struct hda_codec *codec) | |
12252 | { | |
12253 | unsigned int present; | |
12254 | ||
60db6b53 KY |
12255 | present = snd_hda_codec_read(codec, 0x18, 0, |
12256 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
f53281e6 | 12257 | snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
60db6b53 | 12258 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); |
f53281e6 | 12259 | snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
60db6b53 | 12260 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); |
f53281e6 KY |
12261 | } |
12262 | ||
12263 | /* unsolicited event for HP jack sensing */ | |
12264 | static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec, | |
60db6b53 | 12265 | unsigned int res) |
f53281e6 KY |
12266 | { |
12267 | if ((res >> 26) == ALC880_HP_EVENT) | |
12268 | alc269_speaker_automute(codec); | |
12269 | ||
12270 | if ((res >> 26) == ALC880_MIC_EVENT) | |
12271 | alc269_eeepc_dmic_automute(codec); | |
12272 | } | |
12273 | ||
12274 | static void alc269_eeepc_dmic_inithook(struct hda_codec *codec) | |
12275 | { | |
12276 | alc269_speaker_automute(codec); | |
12277 | alc269_eeepc_dmic_automute(codec); | |
12278 | } | |
12279 | ||
12280 | /* unsolicited event for HP jack sensing */ | |
12281 | static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec, | |
ea1fb29a | 12282 | unsigned int res) |
f53281e6 KY |
12283 | { |
12284 | if ((res >> 26) == ALC880_HP_EVENT) | |
12285 | alc269_speaker_automute(codec); | |
12286 | ||
12287 | if ((res >> 26) == ALC880_MIC_EVENT) | |
12288 | alc269_eeepc_amic_automute(codec); | |
12289 | } | |
12290 | ||
12291 | static void alc269_eeepc_amic_inithook(struct hda_codec *codec) | |
12292 | { | |
12293 | alc269_speaker_automute(codec); | |
12294 | alc269_eeepc_amic_automute(codec); | |
12295 | } | |
12296 | ||
60db6b53 KY |
12297 | /* |
12298 | * generic initialization of ADC, input mixers and output mixers | |
12299 | */ | |
12300 | static struct hda_verb alc269_init_verbs[] = { | |
12301 | /* | |
12302 | * Unmute ADC0 and set the default input to mic-in | |
12303 | */ | |
12304 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12305 | ||
12306 | /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the | |
12307 | * analog-loopback mixer widget | |
12308 | * Note: PASD motherboards uses the Line In 2 as the input for | |
12309 | * front panel mic (mic 2) | |
12310 | */ | |
12311 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
12312 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
12313 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
12314 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
12315 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
12316 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
12317 | ||
12318 | /* | |
12319 | * Set up output mixers (0x0c - 0x0e) | |
12320 | */ | |
12321 | /* set vol=0 to output mixers */ | |
12322 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
12323 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
12324 | ||
12325 | /* set up input amps for analog loopback */ | |
12326 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
12327 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12328 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12329 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12330 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12331 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12332 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12333 | ||
12334 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
12335 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
12336 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
12337 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
12338 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
12339 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12340 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12341 | ||
12342 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12343 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12344 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12345 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12346 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12347 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12348 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12349 | ||
12350 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
12351 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
12352 | ||
12353 | /* FIXME: use matrix-type input source selection */ | |
12354 | /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */ | |
12355 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
12356 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
12357 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12358 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
12359 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
12360 | ||
12361 | /* set EAPD */ | |
12362 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
12363 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
12364 | { } | |
12365 | }; | |
12366 | ||
f6a92248 KY |
12367 | /* add playback controls from the parsed DAC table */ |
12368 | static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec, | |
12369 | const struct auto_pin_cfg *cfg) | |
12370 | { | |
12371 | hda_nid_t nid; | |
12372 | int err; | |
12373 | ||
12374 | spec->multiout.num_dacs = 1; /* only use one dac */ | |
12375 | spec->multiout.dac_nids = spec->private_dac_nids; | |
12376 | spec->multiout.dac_nids[0] = 2; | |
12377 | ||
12378 | nid = cfg->line_out_pins[0]; | |
12379 | if (nid) { | |
12380 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
12381 | "Front Playback Volume", | |
12382 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT)); | |
12383 | if (err < 0) | |
12384 | return err; | |
12385 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
12386 | "Front Playback Switch", | |
12387 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
12388 | if (err < 0) | |
12389 | return err; | |
12390 | } | |
12391 | ||
12392 | nid = cfg->speaker_pins[0]; | |
12393 | if (nid) { | |
12394 | if (!cfg->line_out_pins[0]) { | |
12395 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
12396 | "Speaker Playback Volume", | |
12397 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, | |
12398 | HDA_OUTPUT)); | |
12399 | if (err < 0) | |
12400 | return err; | |
12401 | } | |
12402 | if (nid == 0x16) { | |
12403 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
12404 | "Speaker Playback Switch", | |
12405 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
12406 | HDA_OUTPUT)); | |
12407 | if (err < 0) | |
12408 | return err; | |
12409 | } else { | |
12410 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
12411 | "Speaker Playback Switch", | |
12412 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
12413 | HDA_OUTPUT)); | |
12414 | if (err < 0) | |
12415 | return err; | |
12416 | } | |
12417 | } | |
12418 | nid = cfg->hp_pins[0]; | |
12419 | if (nid) { | |
12420 | /* spec->multiout.hp_nid = 2; */ | |
12421 | if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) { | |
12422 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
12423 | "Headphone Playback Volume", | |
12424 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, | |
12425 | HDA_OUTPUT)); | |
12426 | if (err < 0) | |
12427 | return err; | |
12428 | } | |
12429 | if (nid == 0x16) { | |
12430 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
12431 | "Headphone Playback Switch", | |
12432 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
12433 | HDA_OUTPUT)); | |
12434 | if (err < 0) | |
12435 | return err; | |
12436 | } else { | |
12437 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
12438 | "Headphone Playback Switch", | |
12439 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
12440 | HDA_OUTPUT)); | |
12441 | if (err < 0) | |
12442 | return err; | |
12443 | } | |
12444 | } | |
12445 | return 0; | |
12446 | } | |
12447 | ||
ee956e09 TI |
12448 | static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec, |
12449 | const struct auto_pin_cfg *cfg) | |
12450 | { | |
12451 | int err; | |
12452 | ||
12453 | err = alc880_auto_create_analog_input_ctls(spec, cfg); | |
12454 | if (err < 0) | |
12455 | return err; | |
12456 | /* digital-mic input pin is excluded in alc880_auto_create..() | |
12457 | * because it's under 0x18 | |
12458 | */ | |
12459 | if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 || | |
12460 | cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) { | |
12461 | struct hda_input_mux *imux = &spec->private_imux; | |
12462 | imux->items[imux->num_items].label = "Int Mic"; | |
12463 | imux->items[imux->num_items].index = 0x05; | |
12464 | imux->num_items++; | |
12465 | } | |
12466 | return 0; | |
12467 | } | |
f6a92248 KY |
12468 | |
12469 | #ifdef CONFIG_SND_HDA_POWER_SAVE | |
12470 | #define alc269_loopbacks alc880_loopbacks | |
12471 | #endif | |
12472 | ||
12473 | /* pcm configuration: identiacal with ALC880 */ | |
12474 | #define alc269_pcm_analog_playback alc880_pcm_analog_playback | |
12475 | #define alc269_pcm_analog_capture alc880_pcm_analog_capture | |
12476 | #define alc269_pcm_digital_playback alc880_pcm_digital_playback | |
12477 | #define alc269_pcm_digital_capture alc880_pcm_digital_capture | |
12478 | ||
12479 | /* | |
12480 | * BIOS auto configuration | |
12481 | */ | |
12482 | static int alc269_parse_auto_config(struct hda_codec *codec) | |
12483 | { | |
12484 | struct alc_spec *spec = codec->spec; | |
2005af24 | 12485 | int i, err; |
f6a92248 KY |
12486 | static hda_nid_t alc269_ignore[] = { 0x1d, 0 }; |
12487 | ||
12488 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | |
12489 | alc269_ignore); | |
12490 | if (err < 0) | |
12491 | return err; | |
12492 | ||
12493 | err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
12494 | if (err < 0) | |
12495 | return err; | |
12496 | err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
12497 | if (err < 0) | |
12498 | return err; | |
12499 | ||
12500 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
12501 | ||
12502 | if (spec->autocfg.dig_out_pin) | |
12503 | spec->multiout.dig_out_nid = ALC269_DIGOUT_NID; | |
12504 | ||
603c4019 | 12505 | if (spec->kctls.list) |
d88897ea | 12506 | add_mixer(spec, spec->kctls.list); |
f6a92248 | 12507 | |
2005af24 TI |
12508 | /* create a beep mixer control if the pin 0x1d isn't assigned */ |
12509 | for (i = 0; i < ARRAY_SIZE(spec->autocfg.input_pins); i++) | |
12510 | if (spec->autocfg.input_pins[i] == 0x1d) | |
12511 | break; | |
12512 | if (i >= ARRAY_SIZE(spec->autocfg.input_pins)) | |
d88897ea | 12513 | add_mixer(spec, alc269_beep_mixer); |
2005af24 | 12514 | |
d88897ea | 12515 | add_verb(spec, alc269_init_verbs); |
f6a92248 KY |
12516 | spec->num_mux_defs = 1; |
12517 | spec->input_mux = &spec->private_imux; | |
e01bf509 TI |
12518 | /* set default input source */ |
12519 | snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0], | |
12520 | 0, AC_VERB_SET_CONNECT_SEL, | |
12521 | spec->input_mux->items[0].index); | |
f6a92248 KY |
12522 | |
12523 | err = alc_auto_add_mic_boost(codec); | |
12524 | if (err < 0) | |
12525 | return err; | |
12526 | ||
f9e336f6 TI |
12527 | if (!spec->cap_mixer) |
12528 | set_capture_mixer(spec); | |
f53281e6 | 12529 | |
e044c39a | 12530 | store_pin_configs(codec); |
f6a92248 KY |
12531 | return 1; |
12532 | } | |
12533 | ||
12534 | #define alc269_auto_init_multi_out alc882_auto_init_multi_out | |
12535 | #define alc269_auto_init_hp_out alc882_auto_init_hp_out | |
12536 | #define alc269_auto_init_analog_input alc882_auto_init_analog_input | |
12537 | ||
12538 | ||
12539 | /* init callback for auto-configuration model -- overriding the default init */ | |
12540 | static void alc269_auto_init(struct hda_codec *codec) | |
12541 | { | |
f6c7e546 | 12542 | struct alc_spec *spec = codec->spec; |
f6a92248 KY |
12543 | alc269_auto_init_multi_out(codec); |
12544 | alc269_auto_init_hp_out(codec); | |
12545 | alc269_auto_init_analog_input(codec); | |
f6c7e546 | 12546 | if (spec->unsol_event) |
7fb0d78f | 12547 | alc_inithook(codec); |
f6a92248 KY |
12548 | } |
12549 | ||
12550 | /* | |
12551 | * configuration and preset | |
12552 | */ | |
12553 | static const char *alc269_models[ALC269_MODEL_LAST] = { | |
60db6b53 | 12554 | [ALC269_BASIC] = "basic", |
2922c9af TI |
12555 | [ALC269_QUANTA_FL1] = "quanta", |
12556 | [ALC269_ASUS_EEEPC_P703] = "eeepc-p703", | |
26f5df26 | 12557 | [ALC269_ASUS_EEEPC_P901] = "eeepc-p901", |
64154835 TV |
12558 | [ALC269_FUJITSU] = "fujitsu", |
12559 | [ALC269_LIFEBOOK] = "lifebook" | |
f6a92248 KY |
12560 | }; |
12561 | ||
12562 | static struct snd_pci_quirk alc269_cfg_tbl[] = { | |
60db6b53 | 12563 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1), |
f53281e6 KY |
12564 | SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", |
12565 | ALC269_ASUS_EEEPC_P703), | |
12566 | SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901", | |
12567 | ALC269_ASUS_EEEPC_P901), | |
60db6b53 KY |
12568 | SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101", |
12569 | ALC269_ASUS_EEEPC_P901), | |
26f5df26 | 12570 | SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU), |
64154835 | 12571 | SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK), |
f6a92248 KY |
12572 | {} |
12573 | }; | |
12574 | ||
12575 | static struct alc_config_preset alc269_presets[] = { | |
12576 | [ALC269_BASIC] = { | |
f9e336f6 | 12577 | .mixers = { alc269_base_mixer }, |
f6a92248 KY |
12578 | .init_verbs = { alc269_init_verbs }, |
12579 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | |
12580 | .dac_nids = alc269_dac_nids, | |
12581 | .hp_nid = 0x03, | |
12582 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | |
12583 | .channel_mode = alc269_modes, | |
12584 | .input_mux = &alc269_capture_source, | |
12585 | }, | |
60db6b53 KY |
12586 | [ALC269_QUANTA_FL1] = { |
12587 | .mixers = { alc269_quanta_fl1_mixer }, | |
12588 | .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs }, | |
12589 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | |
12590 | .dac_nids = alc269_dac_nids, | |
12591 | .hp_nid = 0x03, | |
12592 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | |
12593 | .channel_mode = alc269_modes, | |
12594 | .input_mux = &alc269_capture_source, | |
12595 | .unsol_event = alc269_quanta_fl1_unsol_event, | |
12596 | .init_hook = alc269_quanta_fl1_init_hook, | |
12597 | }, | |
f53281e6 | 12598 | [ALC269_ASUS_EEEPC_P703] = { |
f9e336f6 TI |
12599 | .mixers = { alc269_eeepc_mixer }, |
12600 | .cap_mixer = alc269_epc_capture_mixer, | |
f53281e6 KY |
12601 | .init_verbs = { alc269_init_verbs, |
12602 | alc269_eeepc_amic_init_verbs }, | |
12603 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | |
12604 | .dac_nids = alc269_dac_nids, | |
12605 | .hp_nid = 0x03, | |
12606 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | |
12607 | .channel_mode = alc269_modes, | |
12608 | .input_mux = &alc269_eeepc_amic_capture_source, | |
12609 | .unsol_event = alc269_eeepc_amic_unsol_event, | |
12610 | .init_hook = alc269_eeepc_amic_inithook, | |
12611 | }, | |
12612 | [ALC269_ASUS_EEEPC_P901] = { | |
f9e336f6 TI |
12613 | .mixers = { alc269_eeepc_mixer }, |
12614 | .cap_mixer = alc269_epc_capture_mixer, | |
f53281e6 KY |
12615 | .init_verbs = { alc269_init_verbs, |
12616 | alc269_eeepc_dmic_init_verbs }, | |
12617 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | |
12618 | .dac_nids = alc269_dac_nids, | |
12619 | .hp_nid = 0x03, | |
12620 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | |
12621 | .channel_mode = alc269_modes, | |
12622 | .input_mux = &alc269_eeepc_dmic_capture_source, | |
12623 | .unsol_event = alc269_eeepc_dmic_unsol_event, | |
12624 | .init_hook = alc269_eeepc_dmic_inithook, | |
12625 | }, | |
26f5df26 TI |
12626 | [ALC269_FUJITSU] = { |
12627 | .mixers = { alc269_fujitsu_mixer, alc269_beep_mixer }, | |
12628 | .cap_mixer = alc269_epc_capture_mixer, | |
12629 | .init_verbs = { alc269_init_verbs, | |
12630 | alc269_eeepc_dmic_init_verbs }, | |
12631 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | |
12632 | .dac_nids = alc269_dac_nids, | |
12633 | .hp_nid = 0x03, | |
12634 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | |
12635 | .channel_mode = alc269_modes, | |
12636 | .input_mux = &alc269_eeepc_dmic_capture_source, | |
12637 | .unsol_event = alc269_eeepc_dmic_unsol_event, | |
12638 | .init_hook = alc269_eeepc_dmic_inithook, | |
12639 | }, | |
64154835 TV |
12640 | [ALC269_LIFEBOOK] = { |
12641 | .mixers = { alc269_lifebook_mixer }, | |
12642 | .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs }, | |
12643 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | |
12644 | .dac_nids = alc269_dac_nids, | |
12645 | .hp_nid = 0x03, | |
12646 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | |
12647 | .channel_mode = alc269_modes, | |
12648 | .input_mux = &alc269_capture_source, | |
12649 | .unsol_event = alc269_lifebook_unsol_event, | |
12650 | .init_hook = alc269_lifebook_init_hook, | |
12651 | }, | |
f6a92248 KY |
12652 | }; |
12653 | ||
12654 | static int patch_alc269(struct hda_codec *codec) | |
12655 | { | |
12656 | struct alc_spec *spec; | |
12657 | int board_config; | |
12658 | int err; | |
12659 | ||
12660 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
12661 | if (spec == NULL) | |
12662 | return -ENOMEM; | |
12663 | ||
12664 | codec->spec = spec; | |
12665 | ||
2c3bf9ab TI |
12666 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
12667 | ||
f6a92248 KY |
12668 | board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST, |
12669 | alc269_models, | |
12670 | alc269_cfg_tbl); | |
12671 | ||
12672 | if (board_config < 0) { | |
12673 | printk(KERN_INFO "hda_codec: Unknown model for ALC269, " | |
12674 | "trying auto-probe from BIOS...\n"); | |
12675 | board_config = ALC269_AUTO; | |
12676 | } | |
12677 | ||
12678 | if (board_config == ALC269_AUTO) { | |
12679 | /* automatic parse from the BIOS config */ | |
12680 | err = alc269_parse_auto_config(codec); | |
12681 | if (err < 0) { | |
12682 | alc_free(codec); | |
12683 | return err; | |
12684 | } else if (!err) { | |
12685 | printk(KERN_INFO | |
12686 | "hda_codec: Cannot set up configuration " | |
12687 | "from BIOS. Using base mode...\n"); | |
12688 | board_config = ALC269_BASIC; | |
12689 | } | |
12690 | } | |
12691 | ||
12692 | if (board_config != ALC269_AUTO) | |
12693 | setup_preset(spec, &alc269_presets[board_config]); | |
12694 | ||
12695 | spec->stream_name_analog = "ALC269 Analog"; | |
12696 | spec->stream_analog_playback = &alc269_pcm_analog_playback; | |
12697 | spec->stream_analog_capture = &alc269_pcm_analog_capture; | |
12698 | ||
12699 | spec->stream_name_digital = "ALC269 Digital"; | |
12700 | spec->stream_digital_playback = &alc269_pcm_digital_playback; | |
12701 | spec->stream_digital_capture = &alc269_pcm_digital_capture; | |
12702 | ||
12703 | spec->adc_nids = alc269_adc_nids; | |
12704 | spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids); | |
e01bf509 | 12705 | spec->capsrc_nids = alc269_capsrc_nids; |
f9e336f6 TI |
12706 | if (!spec->cap_mixer) |
12707 | set_capture_mixer(spec); | |
f6a92248 KY |
12708 | |
12709 | codec->patch_ops = alc_patch_ops; | |
12710 | if (board_config == ALC269_AUTO) | |
12711 | spec->init_hook = alc269_auto_init; | |
12712 | #ifdef CONFIG_SND_HDA_POWER_SAVE | |
12713 | if (!spec->loopback.amplist) | |
12714 | spec->loopback.amplist = alc269_loopbacks; | |
12715 | #endif | |
12716 | ||
12717 | return 0; | |
12718 | } | |
12719 | ||
df694daa KY |
12720 | /* |
12721 | * ALC861 channel source setting (2/6 channel selection for 3-stack) | |
12722 | */ | |
12723 | ||
12724 | /* | |
12725 | * set the path ways for 2 channel output | |
12726 | * need to set the codec line out and mic 1 pin widgets to inputs | |
12727 | */ | |
12728 | static struct hda_verb alc861_threestack_ch2_init[] = { | |
12729 | /* set pin widget 1Ah (line in) for input */ | |
12730 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
f12ab1e0 TI |
12731 | /* set pin widget 18h (mic1/2) for input, for mic also enable |
12732 | * the vref | |
12733 | */ | |
df694daa KY |
12734 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
12735 | ||
9c7f852e TI |
12736 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, |
12737 | #if 0 | |
12738 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
12739 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/ | |
12740 | #endif | |
df694daa KY |
12741 | { } /* end */ |
12742 | }; | |
12743 | /* | |
12744 | * 6ch mode | |
12745 | * need to set the codec line out and mic 1 pin widgets to outputs | |
12746 | */ | |
12747 | static struct hda_verb alc861_threestack_ch6_init[] = { | |
12748 | /* set pin widget 1Ah (line in) for output (Back Surround)*/ | |
12749 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12750 | /* set pin widget 18h (mic1) for output (CLFE)*/ | |
12751 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12752 | ||
12753 | { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
9c7f852e | 12754 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa | 12755 | |
9c7f852e TI |
12756 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, |
12757 | #if 0 | |
12758 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
12759 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/ | |
12760 | #endif | |
df694daa KY |
12761 | { } /* end */ |
12762 | }; | |
12763 | ||
12764 | static struct hda_channel_mode alc861_threestack_modes[2] = { | |
12765 | { 2, alc861_threestack_ch2_init }, | |
12766 | { 6, alc861_threestack_ch6_init }, | |
12767 | }; | |
22309c3e TI |
12768 | /* Set mic1 as input and unmute the mixer */ |
12769 | static struct hda_verb alc861_uniwill_m31_ch2_init[] = { | |
12770 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
12771 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
12772 | { } /* end */ | |
12773 | }; | |
12774 | /* Set mic1 as output and mute mixer */ | |
12775 | static struct hda_verb alc861_uniwill_m31_ch4_init[] = { | |
12776 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12777 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
12778 | { } /* end */ | |
12779 | }; | |
12780 | ||
12781 | static struct hda_channel_mode alc861_uniwill_m31_modes[2] = { | |
12782 | { 2, alc861_uniwill_m31_ch2_init }, | |
12783 | { 4, alc861_uniwill_m31_ch4_init }, | |
12784 | }; | |
df694daa | 12785 | |
7cdbff94 MD |
12786 | /* Set mic1 and line-in as input and unmute the mixer */ |
12787 | static struct hda_verb alc861_asus_ch2_init[] = { | |
12788 | /* set pin widget 1Ah (line in) for input */ | |
12789 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
f12ab1e0 TI |
12790 | /* set pin widget 18h (mic1/2) for input, for mic also enable |
12791 | * the vref | |
12792 | */ | |
7cdbff94 MD |
12793 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
12794 | ||
12795 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, | |
12796 | #if 0 | |
12797 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
12798 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/ | |
12799 | #endif | |
12800 | { } /* end */ | |
12801 | }; | |
12802 | /* Set mic1 nad line-in as output and mute mixer */ | |
12803 | static struct hda_verb alc861_asus_ch6_init[] = { | |
12804 | /* set pin widget 1Ah (line in) for output (Back Surround)*/ | |
12805 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12806 | /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */ | |
12807 | /* set pin widget 18h (mic1) for output (CLFE)*/ | |
12808 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12809 | /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */ | |
12810 | { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
12811 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
12812 | ||
12813 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, | |
12814 | #if 0 | |
12815 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
12816 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/ | |
12817 | #endif | |
12818 | { } /* end */ | |
12819 | }; | |
12820 | ||
12821 | static struct hda_channel_mode alc861_asus_modes[2] = { | |
12822 | { 2, alc861_asus_ch2_init }, | |
12823 | { 6, alc861_asus_ch6_init }, | |
12824 | }; | |
12825 | ||
df694daa KY |
12826 | /* patch-ALC861 */ |
12827 | ||
12828 | static struct snd_kcontrol_new alc861_base_mixer[] = { | |
12829 | /* output mixer control */ | |
12830 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
12831 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
12832 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
12833 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
12834 | HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), | |
12835 | ||
12836 | /*Input mixer control */ | |
12837 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
12838 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
12839 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
12840 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
12841 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
12842 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
12843 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
12844 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
12845 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
12846 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 12847 | |
df694daa KY |
12848 | { } /* end */ |
12849 | }; | |
12850 | ||
12851 | static struct snd_kcontrol_new alc861_3ST_mixer[] = { | |
12852 | /* output mixer control */ | |
12853 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
12854 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
12855 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
12856 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
12857 | /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ | |
12858 | ||
12859 | /* Input mixer control */ | |
12860 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
12861 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
12862 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
12863 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
12864 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
12865 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
12866 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
12867 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
12868 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
12869 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 12870 | |
df694daa KY |
12871 | { |
12872 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
12873 | .name = "Channel Mode", | |
12874 | .info = alc_ch_mode_info, | |
12875 | .get = alc_ch_mode_get, | |
12876 | .put = alc_ch_mode_put, | |
12877 | .private_value = ARRAY_SIZE(alc861_threestack_modes), | |
12878 | }, | |
12879 | { } /* end */ | |
a53d1aec TD |
12880 | }; |
12881 | ||
d1d985f0 | 12882 | static struct snd_kcontrol_new alc861_toshiba_mixer[] = { |
a53d1aec TD |
12883 | /* output mixer control */ |
12884 | HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
12885 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
12886 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
ea1fb29a | 12887 | |
a53d1aec | 12888 | { } /* end */ |
f12ab1e0 | 12889 | }; |
a53d1aec | 12890 | |
22309c3e TI |
12891 | static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = { |
12892 | /* output mixer control */ | |
12893 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
12894 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
12895 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
12896 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
12897 | /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ | |
12898 | ||
12899 | /* Input mixer control */ | |
12900 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
12901 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
12902 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
12903 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
12904 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
12905 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
12906 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
12907 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
12908 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
12909 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 12910 | |
22309c3e TI |
12911 | { |
12912 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
12913 | .name = "Channel Mode", | |
12914 | .info = alc_ch_mode_info, | |
12915 | .get = alc_ch_mode_get, | |
12916 | .put = alc_ch_mode_put, | |
12917 | .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes), | |
12918 | }, | |
12919 | { } /* end */ | |
f12ab1e0 | 12920 | }; |
7cdbff94 MD |
12921 | |
12922 | static struct snd_kcontrol_new alc861_asus_mixer[] = { | |
12923 | /* output mixer control */ | |
12924 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
12925 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
12926 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
12927 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
12928 | HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), | |
12929 | ||
12930 | /* Input mixer control */ | |
12931 | HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
12932 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
12933 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
12934 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
12935 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
12936 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
12937 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
12938 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
12939 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
f12ab1e0 TI |
12940 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), |
12941 | ||
7cdbff94 MD |
12942 | { |
12943 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
12944 | .name = "Channel Mode", | |
12945 | .info = alc_ch_mode_info, | |
12946 | .get = alc_ch_mode_get, | |
12947 | .put = alc_ch_mode_put, | |
12948 | .private_value = ARRAY_SIZE(alc861_asus_modes), | |
12949 | }, | |
12950 | { } | |
56bb0cab TI |
12951 | }; |
12952 | ||
12953 | /* additional mixer */ | |
d1d985f0 | 12954 | static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = { |
56bb0cab TI |
12955 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), |
12956 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
12957 | HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT), | |
12958 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT), | |
12959 | { } | |
12960 | }; | |
7cdbff94 | 12961 | |
df694daa KY |
12962 | /* |
12963 | * generic initialization of ADC, input mixers and output mixers | |
12964 | */ | |
12965 | static struct hda_verb alc861_base_init_verbs[] = { | |
12966 | /* | |
12967 | * Unmute ADC0 and set the default input to mic-in | |
12968 | */ | |
12969 | /* port-A for surround (rear panel) */ | |
12970 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12971 | { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
12972 | /* port-B for mic-in (rear panel) with vref */ | |
12973 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
12974 | /* port-C for line-in (rear panel) */ | |
12975 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
12976 | /* port-D for Front */ | |
12977 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12978 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
12979 | /* port-E for HP out (front panel) */ | |
12980 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | |
12981 | /* route front PCM to HP */ | |
9dece1d7 | 12982 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa KY |
12983 | /* port-F for mic-in (front panel) with vref */ |
12984 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
12985 | /* port-G for CLFE (rear panel) */ | |
12986 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12987 | { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
12988 | /* port-H for side (rear panel) */ | |
12989 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12990 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
12991 | /* CD-in */ | |
12992 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
12993 | /* route front mic to ADC1*/ | |
12994 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
12995 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
ea1fb29a | 12996 | |
df694daa KY |
12997 | /* Unmute DAC0~3 & spdif out*/ |
12998 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12999 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13000 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13001 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13002 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
ea1fb29a | 13003 | |
df694daa KY |
13004 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ |
13005 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13006 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13007 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13008 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
ea1fb29a | 13009 | |
df694daa KY |
13010 | /* Unmute Stereo Mixer 15 */ |
13011 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13012 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13013 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 13014 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
df694daa KY |
13015 | |
13016 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13017 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13018 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13019 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13020 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13021 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13022 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13023 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
13024 | /* hp used DAC 3 (Front) */ |
13025 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
13026 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
13027 | ||
13028 | { } | |
13029 | }; | |
13030 | ||
13031 | static struct hda_verb alc861_threestack_init_verbs[] = { | |
13032 | /* | |
13033 | * Unmute ADC0 and set the default input to mic-in | |
13034 | */ | |
13035 | /* port-A for surround (rear panel) */ | |
13036 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
13037 | /* port-B for mic-in (rear panel) with vref */ | |
13038 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
13039 | /* port-C for line-in (rear panel) */ | |
13040 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
13041 | /* port-D for Front */ | |
13042 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
13043 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
13044 | /* port-E for HP out (front panel) */ | |
13045 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | |
13046 | /* route front PCM to HP */ | |
9dece1d7 | 13047 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa KY |
13048 | /* port-F for mic-in (front panel) with vref */ |
13049 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
13050 | /* port-G for CLFE (rear panel) */ | |
13051 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
13052 | /* port-H for side (rear panel) */ | |
13053 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
13054 | /* CD-in */ | |
13055 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
13056 | /* route front mic to ADC1*/ | |
13057 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
13058 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13059 | /* Unmute DAC0~3 & spdif out*/ | |
13060 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13061 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13062 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13063 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13064 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
ea1fb29a | 13065 | |
df694daa KY |
13066 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ |
13067 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13068 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13069 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13070 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
ea1fb29a | 13071 | |
df694daa KY |
13072 | /* Unmute Stereo Mixer 15 */ |
13073 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13074 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13075 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 13076 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
df694daa KY |
13077 | |
13078 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13079 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13080 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13081 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13082 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13083 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13084 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13085 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
13086 | /* hp used DAC 3 (Front) */ |
13087 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
13088 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
13089 | { } | |
13090 | }; | |
22309c3e TI |
13091 | |
13092 | static struct hda_verb alc861_uniwill_m31_init_verbs[] = { | |
13093 | /* | |
13094 | * Unmute ADC0 and set the default input to mic-in | |
13095 | */ | |
13096 | /* port-A for surround (rear panel) */ | |
13097 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
13098 | /* port-B for mic-in (rear panel) with vref */ | |
13099 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
13100 | /* port-C for line-in (rear panel) */ | |
13101 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
13102 | /* port-D for Front */ | |
13103 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
13104 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
13105 | /* port-E for HP out (front panel) */ | |
f12ab1e0 TI |
13106 | /* this has to be set to VREF80 */ |
13107 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
22309c3e | 13108 | /* route front PCM to HP */ |
9dece1d7 | 13109 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
22309c3e TI |
13110 | /* port-F for mic-in (front panel) with vref */ |
13111 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
13112 | /* port-G for CLFE (rear panel) */ | |
13113 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
13114 | /* port-H for side (rear panel) */ | |
13115 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
13116 | /* CD-in */ | |
13117 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
13118 | /* route front mic to ADC1*/ | |
13119 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
13120 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13121 | /* Unmute DAC0~3 & spdif out*/ | |
13122 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13123 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13124 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13125 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13126 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
ea1fb29a | 13127 | |
22309c3e TI |
13128 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ |
13129 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13130 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13131 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13132 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
ea1fb29a | 13133 | |
22309c3e TI |
13134 | /* Unmute Stereo Mixer 15 */ |
13135 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13136 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13137 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 13138 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
22309c3e TI |
13139 | |
13140 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13141 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13142 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13143 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13144 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13145 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13146 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13147 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
13148 | /* hp used DAC 3 (Front) */ |
13149 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
22309c3e TI |
13150 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
13151 | { } | |
13152 | }; | |
13153 | ||
7cdbff94 MD |
13154 | static struct hda_verb alc861_asus_init_verbs[] = { |
13155 | /* | |
13156 | * Unmute ADC0 and set the default input to mic-in | |
13157 | */ | |
f12ab1e0 TI |
13158 | /* port-A for surround (rear panel) |
13159 | * according to codec#0 this is the HP jack | |
13160 | */ | |
7cdbff94 MD |
13161 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */ |
13162 | /* route front PCM to HP */ | |
13163 | { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
13164 | /* port-B for mic-in (rear panel) with vref */ | |
13165 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
13166 | /* port-C for line-in (rear panel) */ | |
13167 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
13168 | /* port-D for Front */ | |
13169 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
13170 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
13171 | /* port-E for HP out (front panel) */ | |
f12ab1e0 TI |
13172 | /* this has to be set to VREF80 */ |
13173 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
7cdbff94 | 13174 | /* route front PCM to HP */ |
9dece1d7 | 13175 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
7cdbff94 MD |
13176 | /* port-F for mic-in (front panel) with vref */ |
13177 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
13178 | /* port-G for CLFE (rear panel) */ | |
13179 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
13180 | /* port-H for side (rear panel) */ | |
13181 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
13182 | /* CD-in */ | |
13183 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
13184 | /* route front mic to ADC1*/ | |
13185 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
13186 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13187 | /* Unmute DAC0~3 & spdif out*/ | |
13188 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13189 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13190 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13191 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13192 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13193 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
13194 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13195 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13196 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13197 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
ea1fb29a | 13198 | |
7cdbff94 MD |
13199 | /* Unmute Stereo Mixer 15 */ |
13200 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13201 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13202 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 13203 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
7cdbff94 MD |
13204 | |
13205 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13206 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13207 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13208 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13209 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13210 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13211 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13212 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
13213 | /* hp used DAC 3 (Front) */ |
13214 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
7cdbff94 MD |
13215 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
13216 | { } | |
13217 | }; | |
13218 | ||
56bb0cab TI |
13219 | /* additional init verbs for ASUS laptops */ |
13220 | static struct hda_verb alc861_asus_laptop_init_verbs[] = { | |
13221 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */ | |
13222 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */ | |
13223 | { } | |
13224 | }; | |
7cdbff94 | 13225 | |
df694daa KY |
13226 | /* |
13227 | * generic initialization of ADC, input mixers and output mixers | |
13228 | */ | |
13229 | static struct hda_verb alc861_auto_init_verbs[] = { | |
13230 | /* | |
13231 | * Unmute ADC0 and set the default input to mic-in | |
13232 | */ | |
f12ab1e0 | 13233 | /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */ |
df694daa | 13234 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
ea1fb29a | 13235 | |
df694daa KY |
13236 | /* Unmute DAC0~3 & spdif out*/ |
13237 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13238 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13239 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13240 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13241 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
ea1fb29a | 13242 | |
df694daa KY |
13243 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ |
13244 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13245 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13246 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13247 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
ea1fb29a | 13248 | |
df694daa KY |
13249 | /* Unmute Stereo Mixer 15 */ |
13250 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13251 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13252 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
13253 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, | |
13254 | ||
13255 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13256 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13257 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13258 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13259 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13260 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13261 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13262 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13263 | ||
13264 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
13265 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
f12ab1e0 TI |
13266 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
13267 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
13268 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
13269 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
f12ab1e0 TI |
13270 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
13271 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa | 13272 | |
f12ab1e0 | 13273 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */ |
df694daa KY |
13274 | |
13275 | { } | |
13276 | }; | |
13277 | ||
a53d1aec TD |
13278 | static struct hda_verb alc861_toshiba_init_verbs[] = { |
13279 | {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
f12ab1e0 | 13280 | |
a53d1aec TD |
13281 | { } |
13282 | }; | |
13283 | ||
13284 | /* toggle speaker-output according to the hp-jack state */ | |
13285 | static void alc861_toshiba_automute(struct hda_codec *codec) | |
13286 | { | |
13287 | unsigned int present; | |
13288 | ||
13289 | present = snd_hda_codec_read(codec, 0x0f, 0, | |
13290 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
13291 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0, |
13292 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
13293 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3, | |
13294 | HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE); | |
a53d1aec TD |
13295 | } |
13296 | ||
13297 | static void alc861_toshiba_unsol_event(struct hda_codec *codec, | |
13298 | unsigned int res) | |
13299 | { | |
a53d1aec TD |
13300 | if ((res >> 26) == ALC880_HP_EVENT) |
13301 | alc861_toshiba_automute(codec); | |
13302 | } | |
13303 | ||
df694daa KY |
13304 | /* pcm configuration: identiacal with ALC880 */ |
13305 | #define alc861_pcm_analog_playback alc880_pcm_analog_playback | |
13306 | #define alc861_pcm_analog_capture alc880_pcm_analog_capture | |
13307 | #define alc861_pcm_digital_playback alc880_pcm_digital_playback | |
13308 | #define alc861_pcm_digital_capture alc880_pcm_digital_capture | |
13309 | ||
13310 | ||
13311 | #define ALC861_DIGOUT_NID 0x07 | |
13312 | ||
13313 | static struct hda_channel_mode alc861_8ch_modes[1] = { | |
13314 | { 8, NULL } | |
13315 | }; | |
13316 | ||
13317 | static hda_nid_t alc861_dac_nids[4] = { | |
13318 | /* front, surround, clfe, side */ | |
13319 | 0x03, 0x06, 0x05, 0x04 | |
13320 | }; | |
13321 | ||
9c7f852e TI |
13322 | static hda_nid_t alc660_dac_nids[3] = { |
13323 | /* front, clfe, surround */ | |
13324 | 0x03, 0x05, 0x06 | |
13325 | }; | |
13326 | ||
df694daa KY |
13327 | static hda_nid_t alc861_adc_nids[1] = { |
13328 | /* ADC0-2 */ | |
13329 | 0x08, | |
13330 | }; | |
13331 | ||
13332 | static struct hda_input_mux alc861_capture_source = { | |
13333 | .num_items = 5, | |
13334 | .items = { | |
13335 | { "Mic", 0x0 }, | |
13336 | { "Front Mic", 0x3 }, | |
13337 | { "Line", 0x1 }, | |
13338 | { "CD", 0x4 }, | |
13339 | { "Mixer", 0x5 }, | |
13340 | }, | |
13341 | }; | |
13342 | ||
13343 | /* fill in the dac_nids table from the parsed pin configuration */ | |
f12ab1e0 TI |
13344 | static int alc861_auto_fill_dac_nids(struct alc_spec *spec, |
13345 | const struct auto_pin_cfg *cfg) | |
df694daa KY |
13346 | { |
13347 | int i; | |
13348 | hda_nid_t nid; | |
13349 | ||
13350 | spec->multiout.dac_nids = spec->private_dac_nids; | |
13351 | for (i = 0; i < cfg->line_outs; i++) { | |
13352 | nid = cfg->line_out_pins[i]; | |
13353 | if (nid) { | |
13354 | if (i >= ARRAY_SIZE(alc861_dac_nids)) | |
13355 | continue; | |
13356 | spec->multiout.dac_nids[i] = alc861_dac_nids[i]; | |
13357 | } | |
13358 | } | |
13359 | spec->multiout.num_dacs = cfg->line_outs; | |
13360 | return 0; | |
13361 | } | |
13362 | ||
13363 | /* add playback controls from the parsed DAC table */ | |
13364 | static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec, | |
13365 | const struct auto_pin_cfg *cfg) | |
13366 | { | |
13367 | char name[32]; | |
f12ab1e0 TI |
13368 | static const char *chname[4] = { |
13369 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
13370 | }; | |
df694daa KY |
13371 | hda_nid_t nid; |
13372 | int i, idx, err; | |
13373 | ||
13374 | for (i = 0; i < cfg->line_outs; i++) { | |
13375 | nid = spec->multiout.dac_nids[i]; | |
f12ab1e0 | 13376 | if (!nid) |
df694daa KY |
13377 | continue; |
13378 | if (nid == 0x05) { | |
13379 | /* Center/LFE */ | |
f12ab1e0 TI |
13380 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
13381 | "Center Playback Switch", | |
13382 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, | |
13383 | HDA_OUTPUT)); | |
13384 | if (err < 0) | |
df694daa | 13385 | return err; |
f12ab1e0 TI |
13386 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
13387 | "LFE Playback Switch", | |
13388 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
13389 | HDA_OUTPUT)); | |
13390 | if (err < 0) | |
df694daa KY |
13391 | return err; |
13392 | } else { | |
f12ab1e0 TI |
13393 | for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; |
13394 | idx++) | |
df694daa KY |
13395 | if (nid == alc861_dac_nids[idx]) |
13396 | break; | |
13397 | sprintf(name, "%s Playback Switch", chname[idx]); | |
f12ab1e0 TI |
13398 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
13399 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
13400 | HDA_OUTPUT)); | |
13401 | if (err < 0) | |
df694daa KY |
13402 | return err; |
13403 | } | |
13404 | } | |
13405 | return 0; | |
13406 | } | |
13407 | ||
13408 | static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin) | |
13409 | { | |
13410 | int err; | |
13411 | hda_nid_t nid; | |
13412 | ||
f12ab1e0 | 13413 | if (!pin) |
df694daa KY |
13414 | return 0; |
13415 | ||
13416 | if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) { | |
13417 | nid = 0x03; | |
f12ab1e0 TI |
13418 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
13419 | "Headphone Playback Switch", | |
13420 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
13421 | if (err < 0) | |
df694daa KY |
13422 | return err; |
13423 | spec->multiout.hp_nid = nid; | |
13424 | } | |
13425 | return 0; | |
13426 | } | |
13427 | ||
13428 | /* create playback/capture controls for input pins */ | |
f12ab1e0 TI |
13429 | static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, |
13430 | const struct auto_pin_cfg *cfg) | |
df694daa | 13431 | { |
df694daa KY |
13432 | struct hda_input_mux *imux = &spec->private_imux; |
13433 | int i, err, idx, idx1; | |
13434 | ||
13435 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
f12ab1e0 | 13436 | switch (cfg->input_pins[i]) { |
df694daa KY |
13437 | case 0x0c: |
13438 | idx1 = 1; | |
f12ab1e0 | 13439 | idx = 2; /* Line In */ |
df694daa KY |
13440 | break; |
13441 | case 0x0f: | |
13442 | idx1 = 2; | |
f12ab1e0 | 13443 | idx = 2; /* Line In */ |
df694daa KY |
13444 | break; |
13445 | case 0x0d: | |
13446 | idx1 = 0; | |
f12ab1e0 | 13447 | idx = 1; /* Mic In */ |
df694daa | 13448 | break; |
f12ab1e0 | 13449 | case 0x10: |
df694daa | 13450 | idx1 = 3; |
f12ab1e0 | 13451 | idx = 1; /* Mic In */ |
df694daa KY |
13452 | break; |
13453 | case 0x11: | |
13454 | idx1 = 4; | |
f12ab1e0 | 13455 | idx = 0; /* CD */ |
df694daa KY |
13456 | break; |
13457 | default: | |
13458 | continue; | |
13459 | } | |
13460 | ||
4a471b7d TI |
13461 | err = new_analog_input(spec, cfg->input_pins[i], |
13462 | auto_pin_cfg_labels[i], idx, 0x15); | |
df694daa KY |
13463 | if (err < 0) |
13464 | return err; | |
13465 | ||
4a471b7d | 13466 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
df694daa | 13467 | imux->items[imux->num_items].index = idx1; |
f12ab1e0 | 13468 | imux->num_items++; |
df694daa KY |
13469 | } |
13470 | return 0; | |
13471 | } | |
13472 | ||
f12ab1e0 TI |
13473 | static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, |
13474 | hda_nid_t nid, | |
df694daa KY |
13475 | int pin_type, int dac_idx) |
13476 | { | |
564c5bea JL |
13477 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
13478 | pin_type); | |
13479 | snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
13480 | AMP_OUT_UNMUTE); | |
df694daa KY |
13481 | } |
13482 | ||
13483 | static void alc861_auto_init_multi_out(struct hda_codec *codec) | |
13484 | { | |
13485 | struct alc_spec *spec = codec->spec; | |
13486 | int i; | |
13487 | ||
bc9f98a9 | 13488 | alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b); |
df694daa KY |
13489 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
13490 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 13491 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
df694daa | 13492 | if (nid) |
baba8ee9 | 13493 | alc861_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 13494 | spec->multiout.dac_nids[i]); |
df694daa KY |
13495 | } |
13496 | } | |
13497 | ||
13498 | static void alc861_auto_init_hp_out(struct hda_codec *codec) | |
13499 | { | |
13500 | struct alc_spec *spec = codec->spec; | |
13501 | hda_nid_t pin; | |
13502 | ||
eb06ed8f | 13503 | pin = spec->autocfg.hp_pins[0]; |
df694daa | 13504 | if (pin) /* connect to front */ |
f12ab1e0 TI |
13505 | alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, |
13506 | spec->multiout.dac_nids[0]); | |
f6c7e546 TI |
13507 | pin = spec->autocfg.speaker_pins[0]; |
13508 | if (pin) | |
13509 | alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
df694daa KY |
13510 | } |
13511 | ||
13512 | static void alc861_auto_init_analog_input(struct hda_codec *codec) | |
13513 | { | |
13514 | struct alc_spec *spec = codec->spec; | |
13515 | int i; | |
13516 | ||
13517 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
13518 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
f12ab1e0 TI |
13519 | if (nid >= 0x0c && nid <= 0x11) { |
13520 | snd_hda_codec_write(codec, nid, 0, | |
13521 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
13522 | i <= AUTO_PIN_FRONT_MIC ? | |
13523 | PIN_VREF80 : PIN_IN); | |
df694daa KY |
13524 | } |
13525 | } | |
13526 | } | |
13527 | ||
13528 | /* parse the BIOS configuration and set up the alc_spec */ | |
f12ab1e0 TI |
13529 | /* return 1 if successful, 0 if the proper config is not found, |
13530 | * or a negative error code | |
13531 | */ | |
df694daa KY |
13532 | static int alc861_parse_auto_config(struct hda_codec *codec) |
13533 | { | |
13534 | struct alc_spec *spec = codec->spec; | |
13535 | int err; | |
13536 | static hda_nid_t alc861_ignore[] = { 0x1d, 0 }; | |
13537 | ||
f12ab1e0 TI |
13538 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
13539 | alc861_ignore); | |
13540 | if (err < 0) | |
df694daa | 13541 | return err; |
f12ab1e0 | 13542 | if (!spec->autocfg.line_outs) |
df694daa KY |
13543 | return 0; /* can't find valid BIOS pin config */ |
13544 | ||
f12ab1e0 TI |
13545 | err = alc861_auto_fill_dac_nids(spec, &spec->autocfg); |
13546 | if (err < 0) | |
13547 | return err; | |
13548 | err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
13549 | if (err < 0) | |
13550 | return err; | |
13551 | err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); | |
13552 | if (err < 0) | |
13553 | return err; | |
13554 | err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
13555 | if (err < 0) | |
df694daa KY |
13556 | return err; |
13557 | ||
13558 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
13559 | ||
13560 | if (spec->autocfg.dig_out_pin) | |
13561 | spec->multiout.dig_out_nid = ALC861_DIGOUT_NID; | |
13562 | ||
603c4019 | 13563 | if (spec->kctls.list) |
d88897ea | 13564 | add_mixer(spec, spec->kctls.list); |
df694daa | 13565 | |
d88897ea | 13566 | add_verb(spec, alc861_auto_init_verbs); |
df694daa | 13567 | |
a1e8d2da | 13568 | spec->num_mux_defs = 1; |
df694daa KY |
13569 | spec->input_mux = &spec->private_imux; |
13570 | ||
13571 | spec->adc_nids = alc861_adc_nids; | |
13572 | spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); | |
f9e336f6 | 13573 | set_capture_mixer(spec); |
df694daa | 13574 | |
e044c39a | 13575 | store_pin_configs(codec); |
df694daa KY |
13576 | return 1; |
13577 | } | |
13578 | ||
ae6b813a TI |
13579 | /* additional initialization for auto-configuration model */ |
13580 | static void alc861_auto_init(struct hda_codec *codec) | |
df694daa | 13581 | { |
f6c7e546 | 13582 | struct alc_spec *spec = codec->spec; |
df694daa KY |
13583 | alc861_auto_init_multi_out(codec); |
13584 | alc861_auto_init_hp_out(codec); | |
13585 | alc861_auto_init_analog_input(codec); | |
f6c7e546 | 13586 | if (spec->unsol_event) |
7fb0d78f | 13587 | alc_inithook(codec); |
df694daa KY |
13588 | } |
13589 | ||
cb53c626 TI |
13590 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
13591 | static struct hda_amp_list alc861_loopbacks[] = { | |
13592 | { 0x15, HDA_INPUT, 0 }, | |
13593 | { 0x15, HDA_INPUT, 1 }, | |
13594 | { 0x15, HDA_INPUT, 2 }, | |
13595 | { 0x15, HDA_INPUT, 3 }, | |
13596 | { } /* end */ | |
13597 | }; | |
13598 | #endif | |
13599 | ||
df694daa KY |
13600 | |
13601 | /* | |
13602 | * configuration and preset | |
13603 | */ | |
f5fcc13c TI |
13604 | static const char *alc861_models[ALC861_MODEL_LAST] = { |
13605 | [ALC861_3ST] = "3stack", | |
13606 | [ALC660_3ST] = "3stack-660", | |
13607 | [ALC861_3ST_DIG] = "3stack-dig", | |
13608 | [ALC861_6ST_DIG] = "6stack-dig", | |
13609 | [ALC861_UNIWILL_M31] = "uniwill-m31", | |
13610 | [ALC861_TOSHIBA] = "toshiba", | |
13611 | [ALC861_ASUS] = "asus", | |
13612 | [ALC861_ASUS_LAPTOP] = "asus-laptop", | |
13613 | [ALC861_AUTO] = "auto", | |
13614 | }; | |
13615 | ||
13616 | static struct snd_pci_quirk alc861_cfg_tbl[] = { | |
687a47bd | 13617 | SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST), |
f5fcc13c TI |
13618 | SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP), |
13619 | SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP), | |
13620 | SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS), | |
ac3e3741 | 13621 | SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP), |
83c34218 | 13622 | SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG), |
ad5e7737 | 13623 | SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA), |
341d4eb0 TI |
13624 | /* FIXME: the entry below breaks Toshiba A100 (model=auto works!) |
13625 | * Any other models that need this preset? | |
13626 | */ | |
13627 | /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */ | |
ac3e3741 TI |
13628 | SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST), |
13629 | SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST), | |
4147dab6 | 13630 | SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31), |
ac3e3741 TI |
13631 | SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31), |
13632 | SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP), | |
13633 | /* FIXME: the below seems conflict */ | |
13634 | /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */ | |
07e038b3 | 13635 | SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST), |
f5fcc13c | 13636 | SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST), |
df694daa KY |
13637 | {} |
13638 | }; | |
13639 | ||
13640 | static struct alc_config_preset alc861_presets[] = { | |
13641 | [ALC861_3ST] = { | |
13642 | .mixers = { alc861_3ST_mixer }, | |
13643 | .init_verbs = { alc861_threestack_init_verbs }, | |
13644 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
13645 | .dac_nids = alc861_dac_nids, | |
13646 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
13647 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 13648 | .need_dac_fix = 1, |
df694daa KY |
13649 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
13650 | .adc_nids = alc861_adc_nids, | |
13651 | .input_mux = &alc861_capture_source, | |
13652 | }, | |
13653 | [ALC861_3ST_DIG] = { | |
13654 | .mixers = { alc861_base_mixer }, | |
13655 | .init_verbs = { alc861_threestack_init_verbs }, | |
13656 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
13657 | .dac_nids = alc861_dac_nids, | |
13658 | .dig_out_nid = ALC861_DIGOUT_NID, | |
13659 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
13660 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 13661 | .need_dac_fix = 1, |
df694daa KY |
13662 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
13663 | .adc_nids = alc861_adc_nids, | |
13664 | .input_mux = &alc861_capture_source, | |
13665 | }, | |
13666 | [ALC861_6ST_DIG] = { | |
13667 | .mixers = { alc861_base_mixer }, | |
13668 | .init_verbs = { alc861_base_init_verbs }, | |
13669 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
13670 | .dac_nids = alc861_dac_nids, | |
13671 | .dig_out_nid = ALC861_DIGOUT_NID, | |
13672 | .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes), | |
13673 | .channel_mode = alc861_8ch_modes, | |
13674 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
13675 | .adc_nids = alc861_adc_nids, | |
13676 | .input_mux = &alc861_capture_source, | |
13677 | }, | |
9c7f852e TI |
13678 | [ALC660_3ST] = { |
13679 | .mixers = { alc861_3ST_mixer }, | |
13680 | .init_verbs = { alc861_threestack_init_verbs }, | |
13681 | .num_dacs = ARRAY_SIZE(alc660_dac_nids), | |
13682 | .dac_nids = alc660_dac_nids, | |
13683 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
13684 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 13685 | .need_dac_fix = 1, |
9c7f852e TI |
13686 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
13687 | .adc_nids = alc861_adc_nids, | |
13688 | .input_mux = &alc861_capture_source, | |
13689 | }, | |
22309c3e TI |
13690 | [ALC861_UNIWILL_M31] = { |
13691 | .mixers = { alc861_uniwill_m31_mixer }, | |
13692 | .init_verbs = { alc861_uniwill_m31_init_verbs }, | |
13693 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
13694 | .dac_nids = alc861_dac_nids, | |
13695 | .dig_out_nid = ALC861_DIGOUT_NID, | |
13696 | .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes), | |
13697 | .channel_mode = alc861_uniwill_m31_modes, | |
13698 | .need_dac_fix = 1, | |
13699 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
13700 | .adc_nids = alc861_adc_nids, | |
13701 | .input_mux = &alc861_capture_source, | |
13702 | }, | |
a53d1aec TD |
13703 | [ALC861_TOSHIBA] = { |
13704 | .mixers = { alc861_toshiba_mixer }, | |
f12ab1e0 TI |
13705 | .init_verbs = { alc861_base_init_verbs, |
13706 | alc861_toshiba_init_verbs }, | |
a53d1aec TD |
13707 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), |
13708 | .dac_nids = alc861_dac_nids, | |
13709 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
13710 | .channel_mode = alc883_3ST_2ch_modes, | |
13711 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
13712 | .adc_nids = alc861_adc_nids, | |
13713 | .input_mux = &alc861_capture_source, | |
13714 | .unsol_event = alc861_toshiba_unsol_event, | |
13715 | .init_hook = alc861_toshiba_automute, | |
13716 | }, | |
7cdbff94 MD |
13717 | [ALC861_ASUS] = { |
13718 | .mixers = { alc861_asus_mixer }, | |
13719 | .init_verbs = { alc861_asus_init_verbs }, | |
13720 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
13721 | .dac_nids = alc861_dac_nids, | |
13722 | .dig_out_nid = ALC861_DIGOUT_NID, | |
13723 | .num_channel_mode = ARRAY_SIZE(alc861_asus_modes), | |
13724 | .channel_mode = alc861_asus_modes, | |
13725 | .need_dac_fix = 1, | |
13726 | .hp_nid = 0x06, | |
13727 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
13728 | .adc_nids = alc861_adc_nids, | |
13729 | .input_mux = &alc861_capture_source, | |
13730 | }, | |
56bb0cab TI |
13731 | [ALC861_ASUS_LAPTOP] = { |
13732 | .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer }, | |
13733 | .init_verbs = { alc861_asus_init_verbs, | |
13734 | alc861_asus_laptop_init_verbs }, | |
13735 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
13736 | .dac_nids = alc861_dac_nids, | |
13737 | .dig_out_nid = ALC861_DIGOUT_NID, | |
13738 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
13739 | .channel_mode = alc883_3ST_2ch_modes, | |
13740 | .need_dac_fix = 1, | |
13741 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
13742 | .adc_nids = alc861_adc_nids, | |
13743 | .input_mux = &alc861_capture_source, | |
13744 | }, | |
13745 | }; | |
df694daa KY |
13746 | |
13747 | ||
13748 | static int patch_alc861(struct hda_codec *codec) | |
13749 | { | |
13750 | struct alc_spec *spec; | |
13751 | int board_config; | |
13752 | int err; | |
13753 | ||
dc041e0b | 13754 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
df694daa KY |
13755 | if (spec == NULL) |
13756 | return -ENOMEM; | |
13757 | ||
f12ab1e0 | 13758 | codec->spec = spec; |
df694daa | 13759 | |
f5fcc13c TI |
13760 | board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST, |
13761 | alc861_models, | |
13762 | alc861_cfg_tbl); | |
9c7f852e | 13763 | |
f5fcc13c | 13764 | if (board_config < 0) { |
9c7f852e TI |
13765 | printk(KERN_INFO "hda_codec: Unknown model for ALC861, " |
13766 | "trying auto-probe from BIOS...\n"); | |
df694daa KY |
13767 | board_config = ALC861_AUTO; |
13768 | } | |
13769 | ||
13770 | if (board_config == ALC861_AUTO) { | |
13771 | /* automatic parse from the BIOS config */ | |
13772 | err = alc861_parse_auto_config(codec); | |
13773 | if (err < 0) { | |
13774 | alc_free(codec); | |
13775 | return err; | |
f12ab1e0 | 13776 | } else if (!err) { |
9c7f852e TI |
13777 | printk(KERN_INFO |
13778 | "hda_codec: Cannot set up configuration " | |
13779 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
13780 | board_config = ALC861_3ST_DIG; |
13781 | } | |
13782 | } | |
13783 | ||
13784 | if (board_config != ALC861_AUTO) | |
13785 | setup_preset(spec, &alc861_presets[board_config]); | |
13786 | ||
13787 | spec->stream_name_analog = "ALC861 Analog"; | |
13788 | spec->stream_analog_playback = &alc861_pcm_analog_playback; | |
13789 | spec->stream_analog_capture = &alc861_pcm_analog_capture; | |
13790 | ||
13791 | spec->stream_name_digital = "ALC861 Digital"; | |
13792 | spec->stream_digital_playback = &alc861_pcm_digital_playback; | |
13793 | spec->stream_digital_capture = &alc861_pcm_digital_capture; | |
13794 | ||
2134ea4f TI |
13795 | spec->vmaster_nid = 0x03; |
13796 | ||
df694daa KY |
13797 | codec->patch_ops = alc_patch_ops; |
13798 | if (board_config == ALC861_AUTO) | |
ae6b813a | 13799 | spec->init_hook = alc861_auto_init; |
cb53c626 TI |
13800 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
13801 | if (!spec->loopback.amplist) | |
13802 | spec->loopback.amplist = alc861_loopbacks; | |
13803 | #endif | |
ea1fb29a | 13804 | |
1da177e4 LT |
13805 | return 0; |
13806 | } | |
13807 | ||
f32610ed JS |
13808 | /* |
13809 | * ALC861-VD support | |
13810 | * | |
13811 | * Based on ALC882 | |
13812 | * | |
13813 | * In addition, an independent DAC | |
13814 | */ | |
13815 | #define ALC861VD_DIGOUT_NID 0x06 | |
13816 | ||
13817 | static hda_nid_t alc861vd_dac_nids[4] = { | |
13818 | /* front, surr, clfe, side surr */ | |
13819 | 0x02, 0x03, 0x04, 0x05 | |
13820 | }; | |
13821 | ||
13822 | /* dac_nids for ALC660vd are in a different order - according to | |
13823 | * Realtek's driver. | |
13824 | * This should probably tesult in a different mixer for 6stack models | |
13825 | * of ALC660vd codecs, but for now there is only 3stack mixer | |
13826 | * - and it is the same as in 861vd. | |
13827 | * adc_nids in ALC660vd are (is) the same as in 861vd | |
13828 | */ | |
13829 | static hda_nid_t alc660vd_dac_nids[3] = { | |
13830 | /* front, rear, clfe, rear_surr */ | |
13831 | 0x02, 0x04, 0x03 | |
13832 | }; | |
13833 | ||
13834 | static hda_nid_t alc861vd_adc_nids[1] = { | |
13835 | /* ADC0 */ | |
13836 | 0x09, | |
13837 | }; | |
13838 | ||
e1406348 TI |
13839 | static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 }; |
13840 | ||
f32610ed JS |
13841 | /* input MUX */ |
13842 | /* FIXME: should be a matrix-type input source selection */ | |
13843 | static struct hda_input_mux alc861vd_capture_source = { | |
13844 | .num_items = 4, | |
13845 | .items = { | |
13846 | { "Mic", 0x0 }, | |
13847 | { "Front Mic", 0x1 }, | |
13848 | { "Line", 0x2 }, | |
13849 | { "CD", 0x4 }, | |
13850 | }, | |
13851 | }; | |
13852 | ||
272a527c | 13853 | static struct hda_input_mux alc861vd_dallas_capture_source = { |
b419f346 | 13854 | .num_items = 2, |
272a527c | 13855 | .items = { |
b419f346 TD |
13856 | { "Ext Mic", 0x0 }, |
13857 | { "Int Mic", 0x1 }, | |
272a527c KY |
13858 | }, |
13859 | }; | |
13860 | ||
d1a991a6 KY |
13861 | static struct hda_input_mux alc861vd_hp_capture_source = { |
13862 | .num_items = 2, | |
13863 | .items = { | |
13864 | { "Front Mic", 0x0 }, | |
13865 | { "ATAPI Mic", 0x1 }, | |
13866 | }, | |
13867 | }; | |
13868 | ||
f32610ed JS |
13869 | /* |
13870 | * 2ch mode | |
13871 | */ | |
13872 | static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = { | |
13873 | { 2, NULL } | |
13874 | }; | |
13875 | ||
13876 | /* | |
13877 | * 6ch mode | |
13878 | */ | |
13879 | static struct hda_verb alc861vd_6stack_ch6_init[] = { | |
13880 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
13881 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13882 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13883 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13884 | { } /* end */ | |
13885 | }; | |
13886 | ||
13887 | /* | |
13888 | * 8ch mode | |
13889 | */ | |
13890 | static struct hda_verb alc861vd_6stack_ch8_init[] = { | |
13891 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13892 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13893 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13894 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13895 | { } /* end */ | |
13896 | }; | |
13897 | ||
13898 | static struct hda_channel_mode alc861vd_6stack_modes[2] = { | |
13899 | { 6, alc861vd_6stack_ch6_init }, | |
13900 | { 8, alc861vd_6stack_ch8_init }, | |
13901 | }; | |
13902 | ||
13903 | static struct snd_kcontrol_new alc861vd_chmode_mixer[] = { | |
13904 | { | |
13905 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
13906 | .name = "Channel Mode", | |
13907 | .info = alc_ch_mode_info, | |
13908 | .get = alc_ch_mode_get, | |
13909 | .put = alc_ch_mode_put, | |
13910 | }, | |
13911 | { } /* end */ | |
13912 | }; | |
13913 | ||
f32610ed JS |
13914 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
13915 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
13916 | */ | |
13917 | static struct snd_kcontrol_new alc861vd_6st_mixer[] = { | |
13918 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
13919 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
13920 | ||
13921 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
13922 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
13923 | ||
13924 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, | |
13925 | HDA_OUTPUT), | |
13926 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, | |
13927 | HDA_OUTPUT), | |
13928 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
13929 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
13930 | ||
13931 | HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT), | |
13932 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
13933 | ||
13934 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
13935 | ||
13936 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
13937 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
13938 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
13939 | ||
13940 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
13941 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
13942 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
13943 | ||
13944 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
13945 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
13946 | ||
13947 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
13948 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
13949 | ||
13950 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
13951 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
13952 | ||
13953 | { } /* end */ | |
13954 | }; | |
13955 | ||
13956 | static struct snd_kcontrol_new alc861vd_3st_mixer[] = { | |
13957 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
13958 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
13959 | ||
13960 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
13961 | ||
13962 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
13963 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
13964 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
13965 | ||
13966 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
13967 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
13968 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
13969 | ||
13970 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
13971 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
13972 | ||
13973 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
13974 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
13975 | ||
13976 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
13977 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
13978 | ||
13979 | { } /* end */ | |
13980 | }; | |
13981 | ||
bdd148a3 KY |
13982 | static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = { |
13983 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
13984 | /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/ | |
13985 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
13986 | ||
13987 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
13988 | ||
13989 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
13990 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
13991 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
13992 | ||
13993 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
13994 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
13995 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
13996 | ||
13997 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
13998 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
13999 | ||
14000 | { } /* end */ | |
14001 | }; | |
14002 | ||
b419f346 TD |
14003 | /* Pin assignment: Speaker=0x14, HP = 0x15, |
14004 | * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d | |
272a527c KY |
14005 | */ |
14006 | static struct snd_kcontrol_new alc861vd_dallas_mixer[] = { | |
b419f346 TD |
14007 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), |
14008 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT), | |
272a527c KY |
14009 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
14010 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), | |
b419f346 TD |
14011 | HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT), |
14012 | HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14013 | HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14014 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
14015 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14016 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
14017 | HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT), | |
14018 | HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT), | |
272a527c KY |
14019 | { } /* end */ |
14020 | }; | |
14021 | ||
d1a991a6 KY |
14022 | /* Pin assignment: Speaker=0x14, Line-out = 0x15, |
14023 | * Front Mic=0x18, ATAPI Mic = 0x19, | |
14024 | */ | |
14025 | static struct snd_kcontrol_new alc861vd_hp_mixer[] = { | |
14026 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
14027 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
14028 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
14029 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), | |
14030 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14031 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14032 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14033 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
ea1fb29a | 14034 | |
d1a991a6 KY |
14035 | { } /* end */ |
14036 | }; | |
14037 | ||
f32610ed JS |
14038 | /* |
14039 | * generic initialization of ADC, input mixers and output mixers | |
14040 | */ | |
14041 | static struct hda_verb alc861vd_volume_init_verbs[] = { | |
14042 | /* | |
14043 | * Unmute ADC0 and set the default input to mic-in | |
14044 | */ | |
14045 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
14046 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
14047 | ||
14048 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of | |
14049 | * the analog-loopback mixer widget | |
14050 | */ | |
14051 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
14052 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
14053 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
14054 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
14055 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
14056 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
f32610ed JS |
14057 | |
14058 | /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */ | |
bdd148a3 KY |
14059 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
14060 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
14061 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f32610ed | 14062 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
f32610ed JS |
14063 | |
14064 | /* | |
14065 | * Set up output mixers (0x02 - 0x05) | |
14066 | */ | |
14067 | /* set vol=0 to output mixers */ | |
14068 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14069 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14070 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14071 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14072 | ||
14073 | /* set up input amps for analog loopback */ | |
14074 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
14075 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14076 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
14077 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14078 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
14079 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14080 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
14081 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14082 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
14083 | ||
14084 | { } | |
14085 | }; | |
14086 | ||
14087 | /* | |
14088 | * 3-stack pin configuration: | |
14089 | * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b | |
14090 | */ | |
14091 | static struct hda_verb alc861vd_3stack_init_verbs[] = { | |
14092 | /* | |
14093 | * Set pin mode and muting | |
14094 | */ | |
14095 | /* set front pin widgets 0x14 for output */ | |
14096 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
14097 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14098 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
14099 | ||
14100 | /* Mic (rear) pin: input vref at 80% */ | |
14101 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
14102 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
14103 | /* Front Mic pin: input vref at 80% */ | |
14104 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
14105 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
14106 | /* Line In pin: input */ | |
14107 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
14108 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
14109 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
14110 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
14111 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14112 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
14113 | /* CD pin widget for input */ | |
14114 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
14115 | ||
14116 | { } | |
14117 | }; | |
14118 | ||
14119 | /* | |
14120 | * 6-stack pin configuration: | |
14121 | */ | |
14122 | static struct hda_verb alc861vd_6stack_init_verbs[] = { | |
14123 | /* | |
14124 | * Set pin mode and muting | |
14125 | */ | |
14126 | /* set front pin widgets 0x14 for output */ | |
14127 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
14128 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14129 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
14130 | ||
14131 | /* Rear Pin: output 1 (0x0d) */ | |
14132 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
14133 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14134 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
14135 | /* CLFE Pin: output 2 (0x0e) */ | |
14136 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
14137 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14138 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
14139 | /* Side Pin: output 3 (0x0f) */ | |
14140 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
14141 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14142 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
14143 | ||
14144 | /* Mic (rear) pin: input vref at 80% */ | |
14145 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
14146 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
14147 | /* Front Mic pin: input vref at 80% */ | |
14148 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
14149 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
14150 | /* Line In pin: input */ | |
14151 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
14152 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
14153 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
14154 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
14155 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14156 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
14157 | /* CD pin widget for input */ | |
14158 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
14159 | ||
14160 | { } | |
14161 | }; | |
14162 | ||
bdd148a3 KY |
14163 | static struct hda_verb alc861vd_eapd_verbs[] = { |
14164 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
14165 | { } | |
14166 | }; | |
14167 | ||
f9423e7a KY |
14168 | static struct hda_verb alc660vd_eapd_verbs[] = { |
14169 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
14170 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
14171 | { } | |
14172 | }; | |
14173 | ||
bdd148a3 KY |
14174 | static struct hda_verb alc861vd_lenovo_unsol_verbs[] = { |
14175 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
14176 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
14177 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
14178 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
ea1fb29a | 14179 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, |
bdd148a3 KY |
14180 | {} |
14181 | }; | |
14182 | ||
14183 | /* toggle speaker-output according to the hp-jack state */ | |
14184 | static void alc861vd_lenovo_hp_automute(struct hda_codec *codec) | |
14185 | { | |
14186 | unsigned int present; | |
14187 | unsigned char bits; | |
14188 | ||
14189 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
14190 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
14191 | bits = present ? HDA_AMP_MUTE : 0; |
14192 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
14193 | HDA_AMP_MUTE, bits); | |
bdd148a3 KY |
14194 | } |
14195 | ||
14196 | static void alc861vd_lenovo_mic_automute(struct hda_codec *codec) | |
14197 | { | |
14198 | unsigned int present; | |
14199 | unsigned char bits; | |
14200 | ||
14201 | present = snd_hda_codec_read(codec, 0x18, 0, | |
14202 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
14203 | bits = present ? HDA_AMP_MUTE : 0; |
14204 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, | |
14205 | HDA_AMP_MUTE, bits); | |
bdd148a3 KY |
14206 | } |
14207 | ||
14208 | static void alc861vd_lenovo_automute(struct hda_codec *codec) | |
14209 | { | |
14210 | alc861vd_lenovo_hp_automute(codec); | |
14211 | alc861vd_lenovo_mic_automute(codec); | |
14212 | } | |
14213 | ||
14214 | static void alc861vd_lenovo_unsol_event(struct hda_codec *codec, | |
14215 | unsigned int res) | |
14216 | { | |
14217 | switch (res >> 26) { | |
14218 | case ALC880_HP_EVENT: | |
14219 | alc861vd_lenovo_hp_automute(codec); | |
14220 | break; | |
14221 | case ALC880_MIC_EVENT: | |
14222 | alc861vd_lenovo_mic_automute(codec); | |
14223 | break; | |
14224 | } | |
14225 | } | |
14226 | ||
272a527c KY |
14227 | static struct hda_verb alc861vd_dallas_verbs[] = { |
14228 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14229 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14230 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14231 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14232 | ||
14233 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
14234 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
14235 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14236 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
14237 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14238 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
14239 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14240 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
ea1fb29a | 14241 | |
272a527c KY |
14242 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
14243 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14244 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
14245 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14246 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
14247 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14248 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
14249 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14250 | ||
14251 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | |
14252 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
14253 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | |
14254 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
14255 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
14256 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
14257 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
14258 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
14259 | ||
14260 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
14261 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
14262 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
14263 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
14264 | ||
14265 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
ea1fb29a | 14266 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
272a527c KY |
14267 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, |
14268 | ||
14269 | { } /* end */ | |
14270 | }; | |
14271 | ||
14272 | /* toggle speaker-output according to the hp-jack state */ | |
14273 | static void alc861vd_dallas_automute(struct hda_codec *codec) | |
14274 | { | |
14275 | unsigned int present; | |
14276 | ||
14277 | present = snd_hda_codec_read(codec, 0x15, 0, | |
14278 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
14279 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
14280 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c KY |
14281 | } |
14282 | ||
14283 | static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res) | |
14284 | { | |
14285 | if ((res >> 26) == ALC880_HP_EVENT) | |
14286 | alc861vd_dallas_automute(codec); | |
14287 | } | |
14288 | ||
cb53c626 TI |
14289 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
14290 | #define alc861vd_loopbacks alc880_loopbacks | |
14291 | #endif | |
14292 | ||
f32610ed JS |
14293 | /* pcm configuration: identiacal with ALC880 */ |
14294 | #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback | |
14295 | #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture | |
14296 | #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback | |
14297 | #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture | |
14298 | ||
14299 | /* | |
14300 | * configuration and preset | |
14301 | */ | |
14302 | static const char *alc861vd_models[ALC861VD_MODEL_LAST] = { | |
14303 | [ALC660VD_3ST] = "3stack-660", | |
983f8ae4 | 14304 | [ALC660VD_3ST_DIG] = "3stack-660-digout", |
13c94744 | 14305 | [ALC660VD_ASUS_V1S] = "asus-v1s", |
f32610ed JS |
14306 | [ALC861VD_3ST] = "3stack", |
14307 | [ALC861VD_3ST_DIG] = "3stack-digout", | |
14308 | [ALC861VD_6ST_DIG] = "6stack-digout", | |
bdd148a3 | 14309 | [ALC861VD_LENOVO] = "lenovo", |
272a527c | 14310 | [ALC861VD_DALLAS] = "dallas", |
983f8ae4 | 14311 | [ALC861VD_HP] = "hp", |
f32610ed JS |
14312 | [ALC861VD_AUTO] = "auto", |
14313 | }; | |
14314 | ||
14315 | static struct snd_pci_quirk alc861vd_cfg_tbl[] = { | |
ac3e3741 TI |
14316 | SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST), |
14317 | SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP), | |
07e038b3 | 14318 | SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST), |
f32610ed | 14319 | SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST), |
13c94744 | 14320 | SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S), |
6963f84c | 14321 | SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG), |
f32610ed | 14322 | SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST), |
ac3e3741 | 14323 | SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO), |
38baf5ad | 14324 | /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/ |
272a527c | 14325 | SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS), |
542d7c66 | 14326 | SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO), |
b419f346 | 14327 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS), |
39c5d41f | 14328 | SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG), |
ac3e3741 TI |
14329 | SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO), |
14330 | SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO), | |
be321a89 | 14331 | SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 N200", ALC861VD_LENOVO), |
625dc0bf | 14332 | SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG), |
f32610ed JS |
14333 | {} |
14334 | }; | |
14335 | ||
14336 | static struct alc_config_preset alc861vd_presets[] = { | |
14337 | [ALC660VD_3ST] = { | |
14338 | .mixers = { alc861vd_3st_mixer }, | |
14339 | .init_verbs = { alc861vd_volume_init_verbs, | |
14340 | alc861vd_3stack_init_verbs }, | |
14341 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
14342 | .dac_nids = alc660vd_dac_nids, | |
f32610ed JS |
14343 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
14344 | .channel_mode = alc861vd_3stack_2ch_modes, | |
14345 | .input_mux = &alc861vd_capture_source, | |
14346 | }, | |
6963f84c MC |
14347 | [ALC660VD_3ST_DIG] = { |
14348 | .mixers = { alc861vd_3st_mixer }, | |
14349 | .init_verbs = { alc861vd_volume_init_verbs, | |
14350 | alc861vd_3stack_init_verbs }, | |
14351 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
14352 | .dac_nids = alc660vd_dac_nids, | |
14353 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
6963f84c MC |
14354 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
14355 | .channel_mode = alc861vd_3stack_2ch_modes, | |
14356 | .input_mux = &alc861vd_capture_source, | |
14357 | }, | |
f32610ed JS |
14358 | [ALC861VD_3ST] = { |
14359 | .mixers = { alc861vd_3st_mixer }, | |
14360 | .init_verbs = { alc861vd_volume_init_verbs, | |
14361 | alc861vd_3stack_init_verbs }, | |
14362 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
14363 | .dac_nids = alc861vd_dac_nids, | |
14364 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
14365 | .channel_mode = alc861vd_3stack_2ch_modes, | |
14366 | .input_mux = &alc861vd_capture_source, | |
14367 | }, | |
14368 | [ALC861VD_3ST_DIG] = { | |
14369 | .mixers = { alc861vd_3st_mixer }, | |
14370 | .init_verbs = { alc861vd_volume_init_verbs, | |
14371 | alc861vd_3stack_init_verbs }, | |
14372 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
14373 | .dac_nids = alc861vd_dac_nids, | |
14374 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
14375 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
14376 | .channel_mode = alc861vd_3stack_2ch_modes, | |
14377 | .input_mux = &alc861vd_capture_source, | |
14378 | }, | |
14379 | [ALC861VD_6ST_DIG] = { | |
14380 | .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer }, | |
14381 | .init_verbs = { alc861vd_volume_init_verbs, | |
14382 | alc861vd_6stack_init_verbs }, | |
14383 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
14384 | .dac_nids = alc861vd_dac_nids, | |
14385 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
14386 | .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes), | |
14387 | .channel_mode = alc861vd_6stack_modes, | |
14388 | .input_mux = &alc861vd_capture_source, | |
14389 | }, | |
bdd148a3 KY |
14390 | [ALC861VD_LENOVO] = { |
14391 | .mixers = { alc861vd_lenovo_mixer }, | |
14392 | .init_verbs = { alc861vd_volume_init_verbs, | |
14393 | alc861vd_3stack_init_verbs, | |
14394 | alc861vd_eapd_verbs, | |
14395 | alc861vd_lenovo_unsol_verbs }, | |
14396 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
14397 | .dac_nids = alc660vd_dac_nids, | |
bdd148a3 KY |
14398 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
14399 | .channel_mode = alc861vd_3stack_2ch_modes, | |
14400 | .input_mux = &alc861vd_capture_source, | |
14401 | .unsol_event = alc861vd_lenovo_unsol_event, | |
14402 | .init_hook = alc861vd_lenovo_automute, | |
14403 | }, | |
272a527c KY |
14404 | [ALC861VD_DALLAS] = { |
14405 | .mixers = { alc861vd_dallas_mixer }, | |
14406 | .init_verbs = { alc861vd_dallas_verbs }, | |
14407 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
14408 | .dac_nids = alc861vd_dac_nids, | |
272a527c KY |
14409 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
14410 | .channel_mode = alc861vd_3stack_2ch_modes, | |
14411 | .input_mux = &alc861vd_dallas_capture_source, | |
14412 | .unsol_event = alc861vd_dallas_unsol_event, | |
14413 | .init_hook = alc861vd_dallas_automute, | |
d1a991a6 KY |
14414 | }, |
14415 | [ALC861VD_HP] = { | |
14416 | .mixers = { alc861vd_hp_mixer }, | |
14417 | .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs }, | |
14418 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
14419 | .dac_nids = alc861vd_dac_nids, | |
d1a991a6 | 14420 | .dig_out_nid = ALC861VD_DIGOUT_NID, |
d1a991a6 KY |
14421 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
14422 | .channel_mode = alc861vd_3stack_2ch_modes, | |
14423 | .input_mux = &alc861vd_hp_capture_source, | |
14424 | .unsol_event = alc861vd_dallas_unsol_event, | |
14425 | .init_hook = alc861vd_dallas_automute, | |
ea1fb29a | 14426 | }, |
13c94744 TI |
14427 | [ALC660VD_ASUS_V1S] = { |
14428 | .mixers = { alc861vd_lenovo_mixer }, | |
14429 | .init_verbs = { alc861vd_volume_init_verbs, | |
14430 | alc861vd_3stack_init_verbs, | |
14431 | alc861vd_eapd_verbs, | |
14432 | alc861vd_lenovo_unsol_verbs }, | |
14433 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
14434 | .dac_nids = alc660vd_dac_nids, | |
14435 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
14436 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
14437 | .channel_mode = alc861vd_3stack_2ch_modes, | |
14438 | .input_mux = &alc861vd_capture_source, | |
14439 | .unsol_event = alc861vd_lenovo_unsol_event, | |
14440 | .init_hook = alc861vd_lenovo_automute, | |
14441 | }, | |
f32610ed JS |
14442 | }; |
14443 | ||
14444 | /* | |
14445 | * BIOS auto configuration | |
14446 | */ | |
14447 | static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec, | |
14448 | hda_nid_t nid, int pin_type, int dac_idx) | |
14449 | { | |
f6c7e546 | 14450 | alc_set_pin_output(codec, nid, pin_type); |
f32610ed JS |
14451 | } |
14452 | ||
14453 | static void alc861vd_auto_init_multi_out(struct hda_codec *codec) | |
14454 | { | |
14455 | struct alc_spec *spec = codec->spec; | |
14456 | int i; | |
14457 | ||
bc9f98a9 | 14458 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
f32610ed JS |
14459 | for (i = 0; i <= HDA_SIDE; i++) { |
14460 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 14461 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
f32610ed JS |
14462 | if (nid) |
14463 | alc861vd_auto_set_output_and_unmute(codec, nid, | |
baba8ee9 | 14464 | pin_type, i); |
f32610ed JS |
14465 | } |
14466 | } | |
14467 | ||
14468 | ||
14469 | static void alc861vd_auto_init_hp_out(struct hda_codec *codec) | |
14470 | { | |
14471 | struct alc_spec *spec = codec->spec; | |
14472 | hda_nid_t pin; | |
14473 | ||
14474 | pin = spec->autocfg.hp_pins[0]; | |
14475 | if (pin) /* connect to front and use dac 0 */ | |
14476 | alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
f6c7e546 TI |
14477 | pin = spec->autocfg.speaker_pins[0]; |
14478 | if (pin) | |
14479 | alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
f32610ed JS |
14480 | } |
14481 | ||
14482 | #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid) | |
14483 | #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID | |
14484 | ||
14485 | static void alc861vd_auto_init_analog_input(struct hda_codec *codec) | |
14486 | { | |
14487 | struct alc_spec *spec = codec->spec; | |
14488 | int i; | |
14489 | ||
14490 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
14491 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
14492 | if (alc861vd_is_input_pin(nid)) { | |
14493 | snd_hda_codec_write(codec, nid, 0, | |
14494 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
14495 | i <= AUTO_PIN_FRONT_MIC ? | |
14496 | PIN_VREF80 : PIN_IN); | |
14497 | if (nid != ALC861VD_PIN_CD_NID) | |
14498 | snd_hda_codec_write(codec, nid, 0, | |
14499 | AC_VERB_SET_AMP_GAIN_MUTE, | |
14500 | AMP_OUT_MUTE); | |
14501 | } | |
14502 | } | |
14503 | } | |
14504 | ||
f511b01c TI |
14505 | #define alc861vd_auto_init_input_src alc882_auto_init_input_src |
14506 | ||
f32610ed JS |
14507 | #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02) |
14508 | #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c) | |
14509 | ||
14510 | /* add playback controls from the parsed DAC table */ | |
14511 | /* Based on ALC880 version. But ALC861VD has separate, | |
14512 | * different NIDs for mute/unmute switch and volume control */ | |
14513 | static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec, | |
14514 | const struct auto_pin_cfg *cfg) | |
14515 | { | |
14516 | char name[32]; | |
14517 | static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"}; | |
14518 | hda_nid_t nid_v, nid_s; | |
14519 | int i, err; | |
14520 | ||
14521 | for (i = 0; i < cfg->line_outs; i++) { | |
f12ab1e0 | 14522 | if (!spec->multiout.dac_nids[i]) |
f32610ed JS |
14523 | continue; |
14524 | nid_v = alc861vd_idx_to_mixer_vol( | |
14525 | alc880_dac_to_idx( | |
14526 | spec->multiout.dac_nids[i])); | |
14527 | nid_s = alc861vd_idx_to_mixer_switch( | |
14528 | alc880_dac_to_idx( | |
14529 | spec->multiout.dac_nids[i])); | |
14530 | ||
14531 | if (i == 2) { | |
14532 | /* Center/LFE */ | |
f12ab1e0 TI |
14533 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
14534 | "Center Playback Volume", | |
14535 | HDA_COMPOSE_AMP_VAL(nid_v, 1, 0, | |
14536 | HDA_OUTPUT)); | |
14537 | if (err < 0) | |
f32610ed | 14538 | return err; |
f12ab1e0 TI |
14539 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
14540 | "LFE Playback Volume", | |
14541 | HDA_COMPOSE_AMP_VAL(nid_v, 2, 0, | |
14542 | HDA_OUTPUT)); | |
14543 | if (err < 0) | |
f32610ed | 14544 | return err; |
f12ab1e0 TI |
14545 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
14546 | "Center Playback Switch", | |
14547 | HDA_COMPOSE_AMP_VAL(nid_s, 1, 2, | |
14548 | HDA_INPUT)); | |
14549 | if (err < 0) | |
f32610ed | 14550 | return err; |
f12ab1e0 TI |
14551 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
14552 | "LFE Playback Switch", | |
14553 | HDA_COMPOSE_AMP_VAL(nid_s, 2, 2, | |
14554 | HDA_INPUT)); | |
14555 | if (err < 0) | |
f32610ed JS |
14556 | return err; |
14557 | } else { | |
14558 | sprintf(name, "%s Playback Volume", chname[i]); | |
f12ab1e0 TI |
14559 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
14560 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, | |
14561 | HDA_OUTPUT)); | |
14562 | if (err < 0) | |
f32610ed JS |
14563 | return err; |
14564 | sprintf(name, "%s Playback Switch", chname[i]); | |
f12ab1e0 | 14565 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
bdd148a3 | 14566 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, |
f12ab1e0 TI |
14567 | HDA_INPUT)); |
14568 | if (err < 0) | |
f32610ed JS |
14569 | return err; |
14570 | } | |
14571 | } | |
14572 | return 0; | |
14573 | } | |
14574 | ||
14575 | /* add playback controls for speaker and HP outputs */ | |
14576 | /* Based on ALC880 version. But ALC861VD has separate, | |
14577 | * different NIDs for mute/unmute switch and volume control */ | |
14578 | static int alc861vd_auto_create_extra_out(struct alc_spec *spec, | |
14579 | hda_nid_t pin, const char *pfx) | |
14580 | { | |
14581 | hda_nid_t nid_v, nid_s; | |
14582 | int err; | |
14583 | char name[32]; | |
14584 | ||
f12ab1e0 | 14585 | if (!pin) |
f32610ed JS |
14586 | return 0; |
14587 | ||
14588 | if (alc880_is_fixed_pin(pin)) { | |
14589 | nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
14590 | /* specify the DAC as the extra output */ | |
f12ab1e0 | 14591 | if (!spec->multiout.hp_nid) |
f32610ed JS |
14592 | spec->multiout.hp_nid = nid_v; |
14593 | else | |
14594 | spec->multiout.extra_out_nid[0] = nid_v; | |
14595 | /* control HP volume/switch on the output mixer amp */ | |
14596 | nid_v = alc861vd_idx_to_mixer_vol( | |
14597 | alc880_fixed_pin_idx(pin)); | |
14598 | nid_s = alc861vd_idx_to_mixer_switch( | |
14599 | alc880_fixed_pin_idx(pin)); | |
14600 | ||
14601 | sprintf(name, "%s Playback Volume", pfx); | |
f12ab1e0 TI |
14602 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
14603 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT)); | |
14604 | if (err < 0) | |
f32610ed JS |
14605 | return err; |
14606 | sprintf(name, "%s Playback Switch", pfx); | |
f12ab1e0 TI |
14607 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
14608 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT)); | |
14609 | if (err < 0) | |
f32610ed JS |
14610 | return err; |
14611 | } else if (alc880_is_multi_pin(pin)) { | |
14612 | /* set manual connection */ | |
14613 | /* we have only a switch on HP-out PIN */ | |
14614 | sprintf(name, "%s Playback Switch", pfx); | |
f12ab1e0 TI |
14615 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
14616 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
14617 | if (err < 0) | |
f32610ed JS |
14618 | return err; |
14619 | } | |
14620 | return 0; | |
14621 | } | |
14622 | ||
14623 | /* parse the BIOS configuration and set up the alc_spec | |
14624 | * return 1 if successful, 0 if the proper config is not found, | |
14625 | * or a negative error code | |
14626 | * Based on ALC880 version - had to change it to override | |
14627 | * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */ | |
14628 | static int alc861vd_parse_auto_config(struct hda_codec *codec) | |
14629 | { | |
14630 | struct alc_spec *spec = codec->spec; | |
14631 | int err; | |
14632 | static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; | |
14633 | ||
f12ab1e0 TI |
14634 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
14635 | alc861vd_ignore); | |
14636 | if (err < 0) | |
f32610ed | 14637 | return err; |
f12ab1e0 | 14638 | if (!spec->autocfg.line_outs) |
f32610ed JS |
14639 | return 0; /* can't find valid BIOS pin config */ |
14640 | ||
f12ab1e0 TI |
14641 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
14642 | if (err < 0) | |
14643 | return err; | |
14644 | err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
14645 | if (err < 0) | |
14646 | return err; | |
14647 | err = alc861vd_auto_create_extra_out(spec, | |
14648 | spec->autocfg.speaker_pins[0], | |
14649 | "Speaker"); | |
14650 | if (err < 0) | |
14651 | return err; | |
14652 | err = alc861vd_auto_create_extra_out(spec, | |
14653 | spec->autocfg.hp_pins[0], | |
14654 | "Headphone"); | |
14655 | if (err < 0) | |
14656 | return err; | |
14657 | err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
14658 | if (err < 0) | |
f32610ed JS |
14659 | return err; |
14660 | ||
14661 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
14662 | ||
14663 | if (spec->autocfg.dig_out_pin) | |
14664 | spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID; | |
14665 | ||
603c4019 | 14666 | if (spec->kctls.list) |
d88897ea | 14667 | add_mixer(spec, spec->kctls.list); |
f32610ed | 14668 | |
d88897ea | 14669 | add_verb(spec, alc861vd_volume_init_verbs); |
f32610ed JS |
14670 | |
14671 | spec->num_mux_defs = 1; | |
14672 | spec->input_mux = &spec->private_imux; | |
14673 | ||
776e184e TI |
14674 | err = alc_auto_add_mic_boost(codec); |
14675 | if (err < 0) | |
14676 | return err; | |
14677 | ||
e044c39a | 14678 | store_pin_configs(codec); |
f32610ed JS |
14679 | return 1; |
14680 | } | |
14681 | ||
14682 | /* additional initialization for auto-configuration model */ | |
14683 | static void alc861vd_auto_init(struct hda_codec *codec) | |
14684 | { | |
f6c7e546 | 14685 | struct alc_spec *spec = codec->spec; |
f32610ed JS |
14686 | alc861vd_auto_init_multi_out(codec); |
14687 | alc861vd_auto_init_hp_out(codec); | |
14688 | alc861vd_auto_init_analog_input(codec); | |
f511b01c | 14689 | alc861vd_auto_init_input_src(codec); |
f6c7e546 | 14690 | if (spec->unsol_event) |
7fb0d78f | 14691 | alc_inithook(codec); |
f32610ed JS |
14692 | } |
14693 | ||
14694 | static int patch_alc861vd(struct hda_codec *codec) | |
14695 | { | |
14696 | struct alc_spec *spec; | |
14697 | int err, board_config; | |
14698 | ||
14699 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
14700 | if (spec == NULL) | |
14701 | return -ENOMEM; | |
14702 | ||
14703 | codec->spec = spec; | |
14704 | ||
14705 | board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST, | |
14706 | alc861vd_models, | |
14707 | alc861vd_cfg_tbl); | |
14708 | ||
14709 | if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) { | |
14710 | printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/" | |
14711 | "ALC861VD, trying auto-probe from BIOS...\n"); | |
14712 | board_config = ALC861VD_AUTO; | |
14713 | } | |
14714 | ||
14715 | if (board_config == ALC861VD_AUTO) { | |
14716 | /* automatic parse from the BIOS config */ | |
14717 | err = alc861vd_parse_auto_config(codec); | |
14718 | if (err < 0) { | |
14719 | alc_free(codec); | |
14720 | return err; | |
f12ab1e0 | 14721 | } else if (!err) { |
f32610ed JS |
14722 | printk(KERN_INFO |
14723 | "hda_codec: Cannot set up configuration " | |
14724 | "from BIOS. Using base mode...\n"); | |
14725 | board_config = ALC861VD_3ST; | |
14726 | } | |
14727 | } | |
14728 | ||
14729 | if (board_config != ALC861VD_AUTO) | |
14730 | setup_preset(spec, &alc861vd_presets[board_config]); | |
14731 | ||
2f893286 KY |
14732 | if (codec->vendor_id == 0x10ec0660) { |
14733 | spec->stream_name_analog = "ALC660-VD Analog"; | |
14734 | spec->stream_name_digital = "ALC660-VD Digital"; | |
f9423e7a | 14735 | /* always turn on EAPD */ |
d88897ea | 14736 | add_verb(spec, alc660vd_eapd_verbs); |
2f893286 KY |
14737 | } else { |
14738 | spec->stream_name_analog = "ALC861VD Analog"; | |
14739 | spec->stream_name_digital = "ALC861VD Digital"; | |
14740 | } | |
14741 | ||
f32610ed JS |
14742 | spec->stream_analog_playback = &alc861vd_pcm_analog_playback; |
14743 | spec->stream_analog_capture = &alc861vd_pcm_analog_capture; | |
14744 | ||
f32610ed JS |
14745 | spec->stream_digital_playback = &alc861vd_pcm_digital_playback; |
14746 | spec->stream_digital_capture = &alc861vd_pcm_digital_capture; | |
14747 | ||
14748 | spec->adc_nids = alc861vd_adc_nids; | |
14749 | spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids); | |
e1406348 | 14750 | spec->capsrc_nids = alc861vd_capsrc_nids; |
54cbc9ab | 14751 | spec->is_mix_capture = 1; |
f32610ed | 14752 | |
f9e336f6 | 14753 | set_capture_mixer(spec); |
f32610ed | 14754 | |
2134ea4f TI |
14755 | spec->vmaster_nid = 0x02; |
14756 | ||
f32610ed JS |
14757 | codec->patch_ops = alc_patch_ops; |
14758 | ||
14759 | if (board_config == ALC861VD_AUTO) | |
14760 | spec->init_hook = alc861vd_auto_init; | |
cb53c626 TI |
14761 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
14762 | if (!spec->loopback.amplist) | |
14763 | spec->loopback.amplist = alc861vd_loopbacks; | |
14764 | #endif | |
f32610ed JS |
14765 | |
14766 | return 0; | |
14767 | } | |
14768 | ||
bc9f98a9 KY |
14769 | /* |
14770 | * ALC662 support | |
14771 | * | |
14772 | * ALC662 is almost identical with ALC880 but has cleaner and more flexible | |
14773 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
14774 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
14775 | * 6-channel independent captures. | |
14776 | * | |
14777 | * In addition, an independent DAC for the multi-playback (not used in this | |
14778 | * driver yet). | |
14779 | */ | |
14780 | #define ALC662_DIGOUT_NID 0x06 | |
14781 | #define ALC662_DIGIN_NID 0x0a | |
14782 | ||
14783 | static hda_nid_t alc662_dac_nids[4] = { | |
14784 | /* front, rear, clfe, rear_surr */ | |
14785 | 0x02, 0x03, 0x04 | |
14786 | }; | |
14787 | ||
14788 | static hda_nid_t alc662_adc_nids[1] = { | |
14789 | /* ADC1-2 */ | |
14790 | 0x09, | |
14791 | }; | |
e1406348 | 14792 | |
77a261b7 | 14793 | static hda_nid_t alc662_capsrc_nids[1] = { 0x22 }; |
e1406348 | 14794 | |
bc9f98a9 KY |
14795 | /* input MUX */ |
14796 | /* FIXME: should be a matrix-type input source selection */ | |
bc9f98a9 KY |
14797 | static struct hda_input_mux alc662_capture_source = { |
14798 | .num_items = 4, | |
14799 | .items = { | |
14800 | { "Mic", 0x0 }, | |
14801 | { "Front Mic", 0x1 }, | |
14802 | { "Line", 0x2 }, | |
14803 | { "CD", 0x4 }, | |
14804 | }, | |
14805 | }; | |
14806 | ||
14807 | static struct hda_input_mux alc662_lenovo_101e_capture_source = { | |
14808 | .num_items = 2, | |
14809 | .items = { | |
14810 | { "Mic", 0x1 }, | |
14811 | { "Line", 0x2 }, | |
14812 | }, | |
14813 | }; | |
291702f0 KY |
14814 | |
14815 | static struct hda_input_mux alc662_eeepc_capture_source = { | |
14816 | .num_items = 2, | |
14817 | .items = { | |
14818 | { "i-Mic", 0x1 }, | |
14819 | { "e-Mic", 0x0 }, | |
14820 | }, | |
14821 | }; | |
14822 | ||
6dda9f4a KY |
14823 | static struct hda_input_mux alc663_capture_source = { |
14824 | .num_items = 3, | |
14825 | .items = { | |
14826 | { "Mic", 0x0 }, | |
14827 | { "Front Mic", 0x1 }, | |
14828 | { "Line", 0x2 }, | |
14829 | }, | |
14830 | }; | |
14831 | ||
14832 | static struct hda_input_mux alc663_m51va_capture_source = { | |
14833 | .num_items = 2, | |
14834 | .items = { | |
14835 | { "Ext-Mic", 0x0 }, | |
14836 | { "D-Mic", 0x9 }, | |
14837 | }, | |
14838 | }; | |
14839 | ||
bc9f98a9 KY |
14840 | /* |
14841 | * 2ch mode | |
14842 | */ | |
14843 | static struct hda_channel_mode alc662_3ST_2ch_modes[1] = { | |
14844 | { 2, NULL } | |
14845 | }; | |
14846 | ||
14847 | /* | |
14848 | * 2ch mode | |
14849 | */ | |
14850 | static struct hda_verb alc662_3ST_ch2_init[] = { | |
14851 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
14852 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
14853 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
14854 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
14855 | { } /* end */ | |
14856 | }; | |
14857 | ||
14858 | /* | |
14859 | * 6ch mode | |
14860 | */ | |
14861 | static struct hda_verb alc662_3ST_ch6_init[] = { | |
14862 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
14863 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
14864 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
14865 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
14866 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
14867 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
14868 | { } /* end */ | |
14869 | }; | |
14870 | ||
14871 | static struct hda_channel_mode alc662_3ST_6ch_modes[2] = { | |
14872 | { 2, alc662_3ST_ch2_init }, | |
14873 | { 6, alc662_3ST_ch6_init }, | |
14874 | }; | |
14875 | ||
14876 | /* | |
14877 | * 2ch mode | |
14878 | */ | |
14879 | static struct hda_verb alc662_sixstack_ch6_init[] = { | |
14880 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
14881 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
14882 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
14883 | { } /* end */ | |
14884 | }; | |
14885 | ||
14886 | /* | |
14887 | * 6ch mode | |
14888 | */ | |
14889 | static struct hda_verb alc662_sixstack_ch8_init[] = { | |
14890 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
14891 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
14892 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
14893 | { } /* end */ | |
14894 | }; | |
14895 | ||
14896 | static struct hda_channel_mode alc662_5stack_modes[2] = { | |
14897 | { 2, alc662_sixstack_ch6_init }, | |
14898 | { 6, alc662_sixstack_ch8_init }, | |
14899 | }; | |
14900 | ||
14901 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 | |
14902 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
14903 | */ | |
14904 | ||
14905 | static struct snd_kcontrol_new alc662_base_mixer[] = { | |
14906 | /* output mixer control */ | |
14907 | HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT), | |
7055ad8a | 14908 | HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT), |
bc9f98a9 | 14909 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT), |
7055ad8a | 14910 | HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT), |
bc9f98a9 KY |
14911 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), |
14912 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), | |
7055ad8a HRK |
14913 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT), |
14914 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT), | |
bc9f98a9 KY |
14915 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
14916 | ||
14917 | /*Input mixer control */ | |
14918 | HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT), | |
14919 | HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT), | |
14920 | HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT), | |
14921 | HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT), | |
14922 | HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT), | |
14923 | HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT), | |
14924 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT), | |
14925 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT), | |
bc9f98a9 KY |
14926 | { } /* end */ |
14927 | }; | |
14928 | ||
14929 | static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = { | |
14930 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
7055ad8a | 14931 | HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT), |
bc9f98a9 KY |
14932 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
14933 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
14934 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
14935 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
14936 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
14937 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14938 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14939 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14940 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
14941 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
14942 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
bc9f98a9 KY |
14943 | { } /* end */ |
14944 | }; | |
14945 | ||
14946 | static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = { | |
14947 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
7055ad8a | 14948 | HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT), |
bc9f98a9 | 14949 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
7055ad8a | 14950 | HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT), |
bc9f98a9 KY |
14951 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), |
14952 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), | |
7055ad8a HRK |
14953 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT), |
14954 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT), | |
bc9f98a9 KY |
14955 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
14956 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
14957 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
14958 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
14959 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
14960 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14961 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14962 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14963 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
14964 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
14965 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
bc9f98a9 KY |
14966 | { } /* end */ |
14967 | }; | |
14968 | ||
14969 | static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = { | |
14970 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
14971 | HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT), | |
86cd9298 TI |
14972 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
14973 | HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT), | |
bc9f98a9 KY |
14974 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
14975 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
14976 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
14977 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14978 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
bc9f98a9 KY |
14979 | { } /* end */ |
14980 | }; | |
14981 | ||
291702f0 | 14982 | static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = { |
86cd9298 | 14983 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), |
291702f0 | 14984 | |
b4818494 HRK |
14985 | HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT), |
14986 | HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
291702f0 KY |
14987 | |
14988 | HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT), | |
14989 | HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14990 | HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14991 | ||
14992 | HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT), | |
14993 | HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14994 | HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
14995 | { } /* end */ | |
14996 | }; | |
14997 | ||
8c427226 | 14998 | static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = { |
31bffaa9 TI |
14999 | HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT), |
15000 | HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
8c427226 KY |
15001 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
15002 | HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT), | |
15003 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), | |
15004 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), | |
15005 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT), | |
15006 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT), | |
86cd9298 | 15007 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
8c427226 KY |
15008 | HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT), |
15009 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
15010 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
15011 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15012 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
15013 | { } /* end */ | |
15014 | }; | |
15015 | ||
f1d4e28b KY |
15016 | static struct hda_bind_ctls alc663_asus_bind_master_vol = { |
15017 | .ops = &snd_hda_bind_vol, | |
15018 | .values = { | |
15019 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), | |
15020 | HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT), | |
15021 | 0 | |
15022 | }, | |
15023 | }; | |
15024 | ||
15025 | static struct hda_bind_ctls alc663_asus_one_bind_switch = { | |
15026 | .ops = &snd_hda_bind_sw, | |
15027 | .values = { | |
15028 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
15029 | HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT), | |
15030 | 0 | |
15031 | }, | |
15032 | }; | |
15033 | ||
6dda9f4a | 15034 | static struct snd_kcontrol_new alc663_m51va_mixer[] = { |
f1d4e28b KY |
15035 | HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol), |
15036 | HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch), | |
15037 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15038 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
15039 | { } /* end */ | |
15040 | }; | |
15041 | ||
15042 | static struct hda_bind_ctls alc663_asus_tree_bind_switch = { | |
15043 | .ops = &snd_hda_bind_sw, | |
15044 | .values = { | |
15045 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
15046 | HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | |
15047 | HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT), | |
15048 | 0 | |
15049 | }, | |
15050 | }; | |
15051 | ||
15052 | static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = { | |
15053 | HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol), | |
15054 | HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch), | |
15055 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15056 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
15057 | HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
15058 | HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
15059 | ||
15060 | { } /* end */ | |
15061 | }; | |
15062 | ||
15063 | static struct hda_bind_ctls alc663_asus_four_bind_switch = { | |
15064 | .ops = &snd_hda_bind_sw, | |
15065 | .values = { | |
15066 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
15067 | HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | |
15068 | HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), | |
15069 | 0 | |
15070 | }, | |
15071 | }; | |
15072 | ||
15073 | static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = { | |
15074 | HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol), | |
15075 | HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch), | |
15076 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15077 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
15078 | HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
15079 | HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
15080 | { } /* end */ | |
15081 | }; | |
15082 | ||
15083 | static struct snd_kcontrol_new alc662_1bjd_mixer[] = { | |
6dda9f4a KY |
15084 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), |
15085 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
f1d4e28b KY |
15086 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
15087 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15088 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
15089 | HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
15090 | HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
15091 | { } /* end */ | |
15092 | }; | |
15093 | ||
15094 | static struct hda_bind_ctls alc663_asus_two_bind_master_vol = { | |
15095 | .ops = &snd_hda_bind_vol, | |
15096 | .values = { | |
15097 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), | |
15098 | HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT), | |
15099 | 0 | |
15100 | }, | |
15101 | }; | |
15102 | ||
15103 | static struct hda_bind_ctls alc663_asus_two_bind_switch = { | |
15104 | .ops = &snd_hda_bind_sw, | |
15105 | .values = { | |
15106 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
15107 | HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT), | |
15108 | 0 | |
15109 | }, | |
15110 | }; | |
15111 | ||
15112 | static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = { | |
15113 | HDA_BIND_VOL("Master Playback Volume", | |
15114 | &alc663_asus_two_bind_master_vol), | |
15115 | HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch), | |
15116 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
6dda9f4a KY |
15117 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT), |
15118 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15119 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
f1d4e28b KY |
15120 | { } /* end */ |
15121 | }; | |
15122 | ||
15123 | static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = { | |
15124 | HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol), | |
15125 | HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch), | |
15126 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
15127 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
15128 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15129 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
6dda9f4a KY |
15130 | { } /* end */ |
15131 | }; | |
15132 | ||
15133 | static struct snd_kcontrol_new alc663_g71v_mixer[] = { | |
15134 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
15135 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
15136 | HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
15137 | HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
15138 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT), | |
15139 | ||
15140 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15141 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
15142 | HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
15143 | HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
15144 | { } /* end */ | |
15145 | }; | |
15146 | ||
15147 | static struct snd_kcontrol_new alc663_g50v_mixer[] = { | |
15148 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
15149 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
15150 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT), | |
15151 | ||
15152 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15153 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
15154 | HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
15155 | HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
15156 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
15157 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
15158 | { } /* end */ | |
15159 | }; | |
15160 | ||
bc9f98a9 KY |
15161 | static struct snd_kcontrol_new alc662_chmode_mixer[] = { |
15162 | { | |
15163 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
15164 | .name = "Channel Mode", | |
15165 | .info = alc_ch_mode_info, | |
15166 | .get = alc_ch_mode_get, | |
15167 | .put = alc_ch_mode_put, | |
15168 | }, | |
15169 | { } /* end */ | |
15170 | }; | |
15171 | ||
15172 | static struct hda_verb alc662_init_verbs[] = { | |
15173 | /* ADC: mute amp left and right */ | |
15174 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
15175 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
15176 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
15177 | ||
cb53c626 TI |
15178 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
15179 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
15180 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
15181 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
15182 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
bc9f98a9 | 15183 | |
b60dd394 KY |
15184 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
15185 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15186 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
15187 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15188 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
15189 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
bc9f98a9 KY |
15190 | |
15191 | /* Front Pin: output 0 (0x0c) */ | |
15192 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
15193 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15194 | ||
15195 | /* Rear Pin: output 1 (0x0d) */ | |
15196 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
15197 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15198 | ||
15199 | /* CLFE Pin: output 2 (0x0e) */ | |
15200 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
15201 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15202 | ||
15203 | /* Mic (rear) pin: input vref at 80% */ | |
15204 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
15205 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
15206 | /* Front Mic pin: input vref at 80% */ | |
15207 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
15208 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
15209 | /* Line In pin: input */ | |
15210 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
15211 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
15212 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
15213 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15214 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15215 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
15216 | /* CD pin widget for input */ | |
15217 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
15218 | ||
15219 | /* FIXME: use matrix-type input source selection */ | |
15220 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
15221 | /* Input mixer */ | |
15222 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
15223 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15224 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
15225 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
291702f0 KY |
15226 | |
15227 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
15228 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15229 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
15230 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
6dda9f4a KY |
15231 | |
15232 | /* always trun on EAPD */ | |
15233 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
15234 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
15235 | ||
bc9f98a9 KY |
15236 | { } |
15237 | }; | |
15238 | ||
15239 | static struct hda_verb alc662_sue_init_verbs[] = { | |
15240 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT}, | |
15241 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT}, | |
291702f0 KY |
15242 | {} |
15243 | }; | |
15244 | ||
15245 | static struct hda_verb alc662_eeepc_sue_init_verbs[] = { | |
15246 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
15247 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
15248 | {} | |
bc9f98a9 KY |
15249 | }; |
15250 | ||
8c427226 KY |
15251 | /* Set Unsolicited Event*/ |
15252 | static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = { | |
15253 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
15254 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
15255 | {} | |
15256 | }; | |
15257 | ||
bc9f98a9 KY |
15258 | /* |
15259 | * generic initialization of ADC, input mixers and output mixers | |
15260 | */ | |
15261 | static struct hda_verb alc662_auto_init_verbs[] = { | |
15262 | /* | |
15263 | * Unmute ADC and set the default input to mic-in | |
15264 | */ | |
15265 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
15266 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
15267 | ||
15268 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | |
15269 | * mixer widget | |
15270 | * Note: PASD motherboards uses the Line In 2 as the input for front | |
15271 | * panel mic (mic 2) | |
15272 | */ | |
15273 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
15274 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
15275 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
15276 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
15277 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
15278 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
bc9f98a9 KY |
15279 | |
15280 | /* | |
15281 | * Set up output mixers (0x0c - 0x0f) | |
15282 | */ | |
15283 | /* set vol=0 to output mixers */ | |
15284 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
15285 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
15286 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
15287 | ||
15288 | /* set up input amps for analog loopback */ | |
15289 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
b60dd394 KY |
15290 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
15291 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15292 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
15293 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15294 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
15295 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
bc9f98a9 KY |
15296 | |
15297 | ||
15298 | /* FIXME: use matrix-type input source selection */ | |
15299 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
15300 | /* Input mixer */ | |
15301 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
d1a991a6 | 15302 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
bc9f98a9 KY |
15303 | { } |
15304 | }; | |
15305 | ||
24fb9173 TI |
15306 | /* additional verbs for ALC663 */ |
15307 | static struct hda_verb alc663_auto_init_verbs[] = { | |
15308 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
15309 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15310 | { } | |
15311 | }; | |
15312 | ||
6dda9f4a | 15313 | static struct hda_verb alc663_m51va_init_verbs[] = { |
f1d4e28b KY |
15314 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
15315 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
6dda9f4a KY |
15316 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
15317 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
f1d4e28b KY |
15318 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ |
15319 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
15320 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)}, | |
15321 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
15322 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
15323 | {} | |
15324 | }; | |
15325 | ||
15326 | static struct hda_verb alc663_21jd_amic_init_verbs[] = { | |
15327 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15328 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15329 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ | |
15330 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
15331 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15332 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
15333 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
15334 | {} | |
15335 | }; | |
15336 | ||
15337 | static struct hda_verb alc662_1bjd_amic_init_verbs[] = { | |
15338 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
15339 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15340 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15341 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */ | |
15342 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
15343 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15344 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
15345 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
15346 | {} | |
15347 | }; | |
6dda9f4a | 15348 | |
f1d4e28b KY |
15349 | static struct hda_verb alc663_15jd_amic_init_verbs[] = { |
15350 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15351 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15352 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ | |
15353 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
15354 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15355 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
15356 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
15357 | {} | |
15358 | }; | |
6dda9f4a | 15359 | |
f1d4e28b KY |
15360 | static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = { |
15361 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
15362 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15363 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15364 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */ | |
15365 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15366 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15367 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */ | |
15368 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
15369 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6dda9f4a KY |
15370 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, |
15371 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
f1d4e28b KY |
15372 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, |
15373 | {} | |
15374 | }; | |
15375 | ||
15376 | static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = { | |
15377 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
15378 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15379 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15380 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ | |
15381 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15382 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15383 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ | |
15384 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
15385 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15386 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
15387 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
15388 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
6dda9f4a KY |
15389 | {} |
15390 | }; | |
15391 | ||
15392 | static struct hda_verb alc663_g71v_init_verbs[] = { | |
15393 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15394 | /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */ | |
15395 | /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */ | |
15396 | ||
15397 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15398 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15399 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */ | |
15400 | ||
15401 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT}, | |
15402 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT}, | |
15403 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT}, | |
15404 | {} | |
15405 | }; | |
15406 | ||
15407 | static struct hda_verb alc663_g50v_init_verbs[] = { | |
15408 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15409 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15410 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */ | |
15411 | ||
15412 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
15413 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
15414 | {} | |
15415 | }; | |
15416 | ||
f1d4e28b KY |
15417 | static struct hda_verb alc662_ecs_init_verbs[] = { |
15418 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f}, | |
15419 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
15420 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
15421 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
15422 | {} | |
15423 | }; | |
15424 | ||
f1d4e28b KY |
15425 | static struct snd_kcontrol_new alc662_auto_capture_mixer[] = { |
15426 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
15427 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
15428 | { } /* end */ | |
15429 | }; | |
15430 | ||
bc9f98a9 KY |
15431 | static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec) |
15432 | { | |
15433 | unsigned int present; | |
f12ab1e0 | 15434 | unsigned char bits; |
bc9f98a9 KY |
15435 | |
15436 | present = snd_hda_codec_read(codec, 0x14, 0, | |
15437 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
15438 | bits = present ? HDA_AMP_MUTE : 0; |
15439 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
15440 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
15441 | } |
15442 | ||
15443 | static void alc662_lenovo_101e_all_automute(struct hda_codec *codec) | |
15444 | { | |
15445 | unsigned int present; | |
f12ab1e0 | 15446 | unsigned char bits; |
bc9f98a9 KY |
15447 | |
15448 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
15449 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
15450 | bits = present ? HDA_AMP_MUTE : 0; |
15451 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
15452 | HDA_AMP_MUTE, bits); | |
15453 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
15454 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
15455 | } |
15456 | ||
15457 | static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec, | |
15458 | unsigned int res) | |
15459 | { | |
15460 | if ((res >> 26) == ALC880_HP_EVENT) | |
15461 | alc662_lenovo_101e_all_automute(codec); | |
15462 | if ((res >> 26) == ALC880_FRONT_EVENT) | |
15463 | alc662_lenovo_101e_ispeaker_automute(codec); | |
15464 | } | |
15465 | ||
291702f0 KY |
15466 | static void alc662_eeepc_mic_automute(struct hda_codec *codec) |
15467 | { | |
15468 | unsigned int present; | |
15469 | ||
15470 | present = snd_hda_codec_read(codec, 0x18, 0, | |
15471 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
15472 | snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
15473 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | |
15474 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
15475 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | |
15476 | snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
15477 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); | |
15478 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
15479 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); | |
15480 | } | |
15481 | ||
15482 | /* unsolicited event for HP jack sensing */ | |
15483 | static void alc662_eeepc_unsol_event(struct hda_codec *codec, | |
15484 | unsigned int res) | |
15485 | { | |
15486 | if ((res >> 26) == ALC880_HP_EVENT) | |
15487 | alc262_hippo1_automute( codec ); | |
15488 | ||
15489 | if ((res >> 26) == ALC880_MIC_EVENT) | |
15490 | alc662_eeepc_mic_automute(codec); | |
15491 | } | |
15492 | ||
15493 | static void alc662_eeepc_inithook(struct hda_codec *codec) | |
15494 | { | |
15495 | alc262_hippo1_automute( codec ); | |
15496 | alc662_eeepc_mic_automute(codec); | |
15497 | } | |
15498 | ||
8c427226 KY |
15499 | static void alc662_eeepc_ep20_automute(struct hda_codec *codec) |
15500 | { | |
15501 | unsigned int mute; | |
15502 | unsigned int present; | |
15503 | ||
15504 | snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); | |
15505 | present = snd_hda_codec_read(codec, 0x14, 0, | |
15506 | AC_VERB_GET_PIN_SENSE, 0); | |
15507 | present = (present & 0x80000000) != 0; | |
15508 | if (present) { | |
15509 | /* mute internal speaker */ | |
15510 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
ea1fb29a | 15511 | HDA_AMP_MUTE, HDA_AMP_MUTE); |
8c427226 KY |
15512 | } else { |
15513 | /* unmute internal speaker if necessary */ | |
15514 | mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); | |
15515 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
ea1fb29a | 15516 | HDA_AMP_MUTE, mute); |
8c427226 KY |
15517 | } |
15518 | } | |
15519 | ||
15520 | /* unsolicited event for HP jack sensing */ | |
15521 | static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec, | |
15522 | unsigned int res) | |
15523 | { | |
15524 | if ((res >> 26) == ALC880_HP_EVENT) | |
15525 | alc662_eeepc_ep20_automute(codec); | |
15526 | } | |
15527 | ||
15528 | static void alc662_eeepc_ep20_inithook(struct hda_codec *codec) | |
15529 | { | |
15530 | alc662_eeepc_ep20_automute(codec); | |
15531 | } | |
15532 | ||
6dda9f4a KY |
15533 | static void alc663_m51va_speaker_automute(struct hda_codec *codec) |
15534 | { | |
15535 | unsigned int present; | |
15536 | unsigned char bits; | |
15537 | ||
15538 | present = snd_hda_codec_read(codec, 0x21, 0, | |
f1d4e28b KY |
15539 | AC_VERB_GET_PIN_SENSE, 0) |
15540 | & AC_PINSENSE_PRESENCE; | |
6dda9f4a | 15541 | bits = present ? HDA_AMP_MUTE : 0; |
f1d4e28b KY |
15542 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, |
15543 | AMP_IN_MUTE(0), bits); | |
15544 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
15545 | AMP_IN_MUTE(0), bits); | |
15546 | } | |
15547 | ||
15548 | static void alc663_21jd_two_speaker_automute(struct hda_codec *codec) | |
15549 | { | |
15550 | unsigned int present; | |
15551 | unsigned char bits; | |
15552 | ||
15553 | present = snd_hda_codec_read(codec, 0x21, 0, | |
15554 | AC_VERB_GET_PIN_SENSE, 0) | |
15555 | & AC_PINSENSE_PRESENCE; | |
15556 | bits = present ? HDA_AMP_MUTE : 0; | |
15557 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
15558 | AMP_IN_MUTE(0), bits); | |
15559 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
15560 | AMP_IN_MUTE(0), bits); | |
15561 | snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0, | |
15562 | AMP_IN_MUTE(0), bits); | |
15563 | snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1, | |
15564 | AMP_IN_MUTE(0), bits); | |
15565 | } | |
15566 | ||
15567 | static void alc663_15jd_two_speaker_automute(struct hda_codec *codec) | |
15568 | { | |
15569 | unsigned int present; | |
15570 | unsigned char bits; | |
15571 | ||
15572 | present = snd_hda_codec_read(codec, 0x15, 0, | |
15573 | AC_VERB_GET_PIN_SENSE, 0) | |
15574 | & AC_PINSENSE_PRESENCE; | |
15575 | bits = present ? HDA_AMP_MUTE : 0; | |
15576 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
15577 | AMP_IN_MUTE(0), bits); | |
15578 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
15579 | AMP_IN_MUTE(0), bits); | |
15580 | snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0, | |
15581 | AMP_IN_MUTE(0), bits); | |
15582 | snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1, | |
15583 | AMP_IN_MUTE(0), bits); | |
15584 | } | |
15585 | ||
15586 | static void alc662_f5z_speaker_automute(struct hda_codec *codec) | |
15587 | { | |
15588 | unsigned int present; | |
15589 | unsigned char bits; | |
15590 | ||
15591 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
15592 | AC_VERB_GET_PIN_SENSE, 0) | |
15593 | & AC_PINSENSE_PRESENCE; | |
15594 | bits = present ? 0 : PIN_OUT; | |
15595 | snd_hda_codec_write(codec, 0x14, 0, | |
15596 | AC_VERB_SET_PIN_WIDGET_CONTROL, bits); | |
15597 | } | |
15598 | ||
15599 | static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec) | |
15600 | { | |
15601 | unsigned int present1, present2; | |
15602 | ||
15603 | present1 = snd_hda_codec_read(codec, 0x21, 0, | |
15604 | AC_VERB_GET_PIN_SENSE, 0) | |
15605 | & AC_PINSENSE_PRESENCE; | |
15606 | present2 = snd_hda_codec_read(codec, 0x15, 0, | |
15607 | AC_VERB_GET_PIN_SENSE, 0) | |
15608 | & AC_PINSENSE_PRESENCE; | |
15609 | ||
15610 | if (present1 || present2) { | |
15611 | snd_hda_codec_write_cache(codec, 0x14, 0, | |
15612 | AC_VERB_SET_PIN_WIDGET_CONTROL, 0); | |
15613 | } else { | |
15614 | snd_hda_codec_write_cache(codec, 0x14, 0, | |
15615 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | |
15616 | } | |
15617 | } | |
15618 | ||
15619 | static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec) | |
15620 | { | |
15621 | unsigned int present1, present2; | |
15622 | ||
15623 | present1 = snd_hda_codec_read(codec, 0x1b, 0, | |
15624 | AC_VERB_GET_PIN_SENSE, 0) | |
15625 | & AC_PINSENSE_PRESENCE; | |
15626 | present2 = snd_hda_codec_read(codec, 0x15, 0, | |
15627 | AC_VERB_GET_PIN_SENSE, 0) | |
15628 | & AC_PINSENSE_PRESENCE; | |
15629 | ||
15630 | if (present1 || present2) { | |
15631 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
15632 | AMP_IN_MUTE(0), AMP_IN_MUTE(0)); | |
15633 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
15634 | AMP_IN_MUTE(0), AMP_IN_MUTE(0)); | |
15635 | } else { | |
15636 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
15637 | AMP_IN_MUTE(0), 0); | |
15638 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
15639 | AMP_IN_MUTE(0), 0); | |
15640 | } | |
6dda9f4a KY |
15641 | } |
15642 | ||
15643 | static void alc663_m51va_mic_automute(struct hda_codec *codec) | |
15644 | { | |
15645 | unsigned int present; | |
15646 | ||
15647 | present = snd_hda_codec_read(codec, 0x18, 0, | |
ea1fb29a KY |
15648 | AC_VERB_GET_PIN_SENSE, 0) |
15649 | & AC_PINSENSE_PRESENCE; | |
6dda9f4a | 15650 | snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
ea1fb29a | 15651 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); |
6dda9f4a | 15652 | snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
ea1fb29a | 15653 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); |
6dda9f4a | 15654 | snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
ea1fb29a | 15655 | 0x7000 | (0x09 << 8) | (present ? 0x80 : 0)); |
6dda9f4a | 15656 | snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
ea1fb29a | 15657 | 0x7000 | (0x09 << 8) | (present ? 0x80 : 0)); |
6dda9f4a KY |
15658 | } |
15659 | ||
15660 | static void alc663_m51va_unsol_event(struct hda_codec *codec, | |
15661 | unsigned int res) | |
15662 | { | |
15663 | switch (res >> 26) { | |
15664 | case ALC880_HP_EVENT: | |
15665 | alc663_m51va_speaker_automute(codec); | |
15666 | break; | |
15667 | case ALC880_MIC_EVENT: | |
15668 | alc663_m51va_mic_automute(codec); | |
15669 | break; | |
15670 | } | |
15671 | } | |
15672 | ||
15673 | static void alc663_m51va_inithook(struct hda_codec *codec) | |
15674 | { | |
15675 | alc663_m51va_speaker_automute(codec); | |
15676 | alc663_m51va_mic_automute(codec); | |
15677 | } | |
15678 | ||
f1d4e28b KY |
15679 | /* ***************** Mode1 ******************************/ |
15680 | static void alc663_mode1_unsol_event(struct hda_codec *codec, | |
15681 | unsigned int res) | |
15682 | { | |
15683 | switch (res >> 26) { | |
15684 | case ALC880_HP_EVENT: | |
15685 | alc663_m51va_speaker_automute(codec); | |
15686 | break; | |
15687 | case ALC880_MIC_EVENT: | |
15688 | alc662_eeepc_mic_automute(codec); | |
15689 | break; | |
15690 | } | |
15691 | } | |
15692 | ||
15693 | static void alc663_mode1_inithook(struct hda_codec *codec) | |
15694 | { | |
15695 | alc663_m51va_speaker_automute(codec); | |
15696 | alc662_eeepc_mic_automute(codec); | |
15697 | } | |
15698 | /* ***************** Mode2 ******************************/ | |
15699 | static void alc662_mode2_unsol_event(struct hda_codec *codec, | |
15700 | unsigned int res) | |
15701 | { | |
15702 | switch (res >> 26) { | |
15703 | case ALC880_HP_EVENT: | |
15704 | alc662_f5z_speaker_automute(codec); | |
15705 | break; | |
15706 | case ALC880_MIC_EVENT: | |
15707 | alc662_eeepc_mic_automute(codec); | |
15708 | break; | |
15709 | } | |
15710 | } | |
15711 | ||
15712 | static void alc662_mode2_inithook(struct hda_codec *codec) | |
15713 | { | |
15714 | alc662_f5z_speaker_automute(codec); | |
15715 | alc662_eeepc_mic_automute(codec); | |
15716 | } | |
15717 | /* ***************** Mode3 ******************************/ | |
15718 | static void alc663_mode3_unsol_event(struct hda_codec *codec, | |
15719 | unsigned int res) | |
15720 | { | |
15721 | switch (res >> 26) { | |
15722 | case ALC880_HP_EVENT: | |
15723 | alc663_two_hp_m1_speaker_automute(codec); | |
15724 | break; | |
15725 | case ALC880_MIC_EVENT: | |
15726 | alc662_eeepc_mic_automute(codec); | |
15727 | break; | |
15728 | } | |
15729 | } | |
15730 | ||
15731 | static void alc663_mode3_inithook(struct hda_codec *codec) | |
15732 | { | |
15733 | alc663_two_hp_m1_speaker_automute(codec); | |
15734 | alc662_eeepc_mic_automute(codec); | |
15735 | } | |
15736 | /* ***************** Mode4 ******************************/ | |
15737 | static void alc663_mode4_unsol_event(struct hda_codec *codec, | |
15738 | unsigned int res) | |
15739 | { | |
15740 | switch (res >> 26) { | |
15741 | case ALC880_HP_EVENT: | |
15742 | alc663_21jd_two_speaker_automute(codec); | |
15743 | break; | |
15744 | case ALC880_MIC_EVENT: | |
15745 | alc662_eeepc_mic_automute(codec); | |
15746 | break; | |
15747 | } | |
15748 | } | |
15749 | ||
15750 | static void alc663_mode4_inithook(struct hda_codec *codec) | |
15751 | { | |
15752 | alc663_21jd_two_speaker_automute(codec); | |
15753 | alc662_eeepc_mic_automute(codec); | |
15754 | } | |
15755 | /* ***************** Mode5 ******************************/ | |
15756 | static void alc663_mode5_unsol_event(struct hda_codec *codec, | |
15757 | unsigned int res) | |
15758 | { | |
15759 | switch (res >> 26) { | |
15760 | case ALC880_HP_EVENT: | |
15761 | alc663_15jd_two_speaker_automute(codec); | |
15762 | break; | |
15763 | case ALC880_MIC_EVENT: | |
15764 | alc662_eeepc_mic_automute(codec); | |
15765 | break; | |
15766 | } | |
15767 | } | |
15768 | ||
15769 | static void alc663_mode5_inithook(struct hda_codec *codec) | |
15770 | { | |
15771 | alc663_15jd_two_speaker_automute(codec); | |
15772 | alc662_eeepc_mic_automute(codec); | |
15773 | } | |
15774 | /* ***************** Mode6 ******************************/ | |
15775 | static void alc663_mode6_unsol_event(struct hda_codec *codec, | |
15776 | unsigned int res) | |
15777 | { | |
15778 | switch (res >> 26) { | |
15779 | case ALC880_HP_EVENT: | |
15780 | alc663_two_hp_m2_speaker_automute(codec); | |
15781 | break; | |
15782 | case ALC880_MIC_EVENT: | |
15783 | alc662_eeepc_mic_automute(codec); | |
15784 | break; | |
15785 | } | |
15786 | } | |
15787 | ||
15788 | static void alc663_mode6_inithook(struct hda_codec *codec) | |
15789 | { | |
15790 | alc663_two_hp_m2_speaker_automute(codec); | |
15791 | alc662_eeepc_mic_automute(codec); | |
15792 | } | |
15793 | ||
6dda9f4a KY |
15794 | static void alc663_g71v_hp_automute(struct hda_codec *codec) |
15795 | { | |
15796 | unsigned int present; | |
15797 | unsigned char bits; | |
15798 | ||
15799 | present = snd_hda_codec_read(codec, 0x21, 0, | |
15800 | AC_VERB_GET_PIN_SENSE, 0) | |
15801 | & AC_PINSENSE_PRESENCE; | |
15802 | bits = present ? HDA_AMP_MUTE : 0; | |
15803 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
15804 | HDA_AMP_MUTE, bits); | |
15805 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
15806 | HDA_AMP_MUTE, bits); | |
15807 | } | |
15808 | ||
15809 | static void alc663_g71v_front_automute(struct hda_codec *codec) | |
15810 | { | |
15811 | unsigned int present; | |
15812 | unsigned char bits; | |
15813 | ||
15814 | present = snd_hda_codec_read(codec, 0x15, 0, | |
15815 | AC_VERB_GET_PIN_SENSE, 0) | |
15816 | & AC_PINSENSE_PRESENCE; | |
15817 | bits = present ? HDA_AMP_MUTE : 0; | |
15818 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
15819 | HDA_AMP_MUTE, bits); | |
15820 | } | |
15821 | ||
15822 | static void alc663_g71v_unsol_event(struct hda_codec *codec, | |
15823 | unsigned int res) | |
15824 | { | |
15825 | switch (res >> 26) { | |
15826 | case ALC880_HP_EVENT: | |
15827 | alc663_g71v_hp_automute(codec); | |
15828 | break; | |
15829 | case ALC880_FRONT_EVENT: | |
15830 | alc663_g71v_front_automute(codec); | |
15831 | break; | |
15832 | case ALC880_MIC_EVENT: | |
15833 | alc662_eeepc_mic_automute(codec); | |
15834 | break; | |
15835 | } | |
15836 | } | |
15837 | ||
15838 | static void alc663_g71v_inithook(struct hda_codec *codec) | |
15839 | { | |
15840 | alc663_g71v_front_automute(codec); | |
15841 | alc663_g71v_hp_automute(codec); | |
15842 | alc662_eeepc_mic_automute(codec); | |
15843 | } | |
15844 | ||
15845 | static void alc663_g50v_unsol_event(struct hda_codec *codec, | |
15846 | unsigned int res) | |
15847 | { | |
15848 | switch (res >> 26) { | |
15849 | case ALC880_HP_EVENT: | |
15850 | alc663_m51va_speaker_automute(codec); | |
15851 | break; | |
15852 | case ALC880_MIC_EVENT: | |
15853 | alc662_eeepc_mic_automute(codec); | |
15854 | break; | |
15855 | } | |
15856 | } | |
15857 | ||
15858 | static void alc663_g50v_inithook(struct hda_codec *codec) | |
15859 | { | |
15860 | alc663_m51va_speaker_automute(codec); | |
15861 | alc662_eeepc_mic_automute(codec); | |
15862 | } | |
15863 | ||
f1d4e28b KY |
15864 | /* bind hp and internal speaker mute (with plug check) */ |
15865 | static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol, | |
15866 | struct snd_ctl_elem_value *ucontrol) | |
15867 | { | |
15868 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
15869 | long *valp = ucontrol->value.integer.value; | |
15870 | int change; | |
15871 | ||
15872 | change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0, | |
15873 | HDA_AMP_MUTE, | |
15874 | valp[0] ? 0 : HDA_AMP_MUTE); | |
15875 | change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0, | |
15876 | HDA_AMP_MUTE, | |
15877 | valp[1] ? 0 : HDA_AMP_MUTE); | |
15878 | if (change) | |
15879 | alc262_hippo1_automute(codec); | |
15880 | return change; | |
15881 | } | |
15882 | ||
15883 | static struct snd_kcontrol_new alc662_ecs_mixer[] = { | |
15884 | HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
15885 | { | |
15886 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
15887 | .name = "Master Playback Switch", | |
15888 | .info = snd_hda_mixer_amp_switch_info, | |
15889 | .get = snd_hda_mixer_amp_switch_get, | |
15890 | .put = alc662_ecs_master_sw_put, | |
15891 | .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), | |
15892 | }, | |
15893 | ||
15894 | HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT), | |
15895 | HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15896 | HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
15897 | ||
15898 | HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT), | |
15899 | HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
15900 | HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
15901 | { } /* end */ | |
15902 | }; | |
15903 | ||
cb53c626 TI |
15904 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
15905 | #define alc662_loopbacks alc880_loopbacks | |
15906 | #endif | |
15907 | ||
bc9f98a9 KY |
15908 | |
15909 | /* pcm configuration: identiacal with ALC880 */ | |
15910 | #define alc662_pcm_analog_playback alc880_pcm_analog_playback | |
15911 | #define alc662_pcm_analog_capture alc880_pcm_analog_capture | |
15912 | #define alc662_pcm_digital_playback alc880_pcm_digital_playback | |
15913 | #define alc662_pcm_digital_capture alc880_pcm_digital_capture | |
15914 | ||
15915 | /* | |
15916 | * configuration and preset | |
15917 | */ | |
15918 | static const char *alc662_models[ALC662_MODEL_LAST] = { | |
15919 | [ALC662_3ST_2ch_DIG] = "3stack-dig", | |
15920 | [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig", | |
15921 | [ALC662_3ST_6ch] = "3stack-6ch", | |
15922 | [ALC662_5ST_DIG] = "6stack-dig", | |
15923 | [ALC662_LENOVO_101E] = "lenovo-101e", | |
b995d76d | 15924 | [ALC662_ASUS_EEEPC_P701] = "eeepc-p701", |
8c427226 | 15925 | [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20", |
f1d4e28b | 15926 | [ALC662_ECS] = "ecs", |
6dda9f4a KY |
15927 | [ALC663_ASUS_M51VA] = "m51va", |
15928 | [ALC663_ASUS_G71V] = "g71v", | |
15929 | [ALC663_ASUS_H13] = "h13", | |
15930 | [ALC663_ASUS_G50V] = "g50v", | |
f1d4e28b KY |
15931 | [ALC663_ASUS_MODE1] = "asus-mode1", |
15932 | [ALC662_ASUS_MODE2] = "asus-mode2", | |
15933 | [ALC663_ASUS_MODE3] = "asus-mode3", | |
15934 | [ALC663_ASUS_MODE4] = "asus-mode4", | |
15935 | [ALC663_ASUS_MODE5] = "asus-mode5", | |
15936 | [ALC663_ASUS_MODE6] = "asus-mode6", | |
bc9f98a9 KY |
15937 | [ALC662_AUTO] = "auto", |
15938 | }; | |
15939 | ||
15940 | static struct snd_pci_quirk alc662_cfg_tbl[] = { | |
6dda9f4a | 15941 | SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA), |
80ffe869 | 15942 | SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V), |
3da23cac | 15943 | SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG), |
291702f0 | 15944 | SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701), |
8c427226 | 15945 | SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20), |
f1d4e28b KY |
15946 | SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1), |
15947 | SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1), | |
15948 | SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1), | |
15949 | SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1), | |
15950 | SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1), | |
15951 | SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1), | |
15952 | SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1), | |
15953 | SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1), | |
15954 | SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1), | |
80ffe869 | 15955 | SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1), |
f1d4e28b KY |
15956 | SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2), |
15957 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2), | |
15958 | SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2), | |
15959 | SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2), | |
15960 | SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2), | |
15961 | SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2), | |
15962 | SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2), | |
15963 | SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2), | |
15964 | SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2), | |
15965 | SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2), | |
15966 | SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2), | |
15967 | SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2), | |
15968 | SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3), | |
15969 | SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3), | |
15970 | SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3), | |
15971 | SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3), | |
15972 | SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3), | |
15973 | SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4), | |
15974 | SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5), | |
15975 | SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6), | |
15976 | SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6), | |
15977 | SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6), | |
95fe5f2c HRK |
15978 | SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K", |
15979 | ALC662_3ST_6ch_DIG), | |
ac3e3741 | 15980 | SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E), |
f1d4e28b KY |
15981 | SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS), |
15982 | SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS), | |
cb55974c HRK |
15983 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L", |
15984 | ALC662_3ST_6ch_DIG), | |
19c009aa | 15985 | SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG), |
238713d4 | 15986 | SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0", |
19c009aa | 15987 | ALC662_3ST_6ch_DIG), |
6dda9f4a KY |
15988 | SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13), |
15989 | SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13), | |
15990 | SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13), | |
bc9f98a9 KY |
15991 | {} |
15992 | }; | |
15993 | ||
15994 | static struct alc_config_preset alc662_presets[] = { | |
15995 | [ALC662_3ST_2ch_DIG] = { | |
f9e336f6 | 15996 | .mixers = { alc662_3ST_2ch_mixer }, |
bc9f98a9 KY |
15997 | .init_verbs = { alc662_init_verbs }, |
15998 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15999 | .dac_nids = alc662_dac_nids, | |
16000 | .dig_out_nid = ALC662_DIGOUT_NID, | |
bc9f98a9 KY |
16001 | .dig_in_nid = ALC662_DIGIN_NID, |
16002 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16003 | .channel_mode = alc662_3ST_2ch_modes, | |
16004 | .input_mux = &alc662_capture_source, | |
16005 | }, | |
16006 | [ALC662_3ST_6ch_DIG] = { | |
f9e336f6 | 16007 | .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer }, |
bc9f98a9 KY |
16008 | .init_verbs = { alc662_init_verbs }, |
16009 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16010 | .dac_nids = alc662_dac_nids, | |
16011 | .dig_out_nid = ALC662_DIGOUT_NID, | |
bc9f98a9 KY |
16012 | .dig_in_nid = ALC662_DIGIN_NID, |
16013 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), | |
16014 | .channel_mode = alc662_3ST_6ch_modes, | |
16015 | .need_dac_fix = 1, | |
16016 | .input_mux = &alc662_capture_source, | |
f12ab1e0 | 16017 | }, |
bc9f98a9 | 16018 | [ALC662_3ST_6ch] = { |
f9e336f6 | 16019 | .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer }, |
bc9f98a9 KY |
16020 | .init_verbs = { alc662_init_verbs }, |
16021 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16022 | .dac_nids = alc662_dac_nids, | |
bc9f98a9 KY |
16023 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), |
16024 | .channel_mode = alc662_3ST_6ch_modes, | |
16025 | .need_dac_fix = 1, | |
16026 | .input_mux = &alc662_capture_source, | |
f12ab1e0 | 16027 | }, |
bc9f98a9 | 16028 | [ALC662_5ST_DIG] = { |
f9e336f6 | 16029 | .mixers = { alc662_base_mixer, alc662_chmode_mixer }, |
bc9f98a9 KY |
16030 | .init_verbs = { alc662_init_verbs }, |
16031 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16032 | .dac_nids = alc662_dac_nids, | |
16033 | .dig_out_nid = ALC662_DIGOUT_NID, | |
bc9f98a9 KY |
16034 | .dig_in_nid = ALC662_DIGIN_NID, |
16035 | .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes), | |
16036 | .channel_mode = alc662_5stack_modes, | |
16037 | .input_mux = &alc662_capture_source, | |
16038 | }, | |
16039 | [ALC662_LENOVO_101E] = { | |
f9e336f6 | 16040 | .mixers = { alc662_lenovo_101e_mixer }, |
bc9f98a9 KY |
16041 | .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs }, |
16042 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16043 | .dac_nids = alc662_dac_nids, | |
bc9f98a9 KY |
16044 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
16045 | .channel_mode = alc662_3ST_2ch_modes, | |
16046 | .input_mux = &alc662_lenovo_101e_capture_source, | |
16047 | .unsol_event = alc662_lenovo_101e_unsol_event, | |
16048 | .init_hook = alc662_lenovo_101e_all_automute, | |
16049 | }, | |
291702f0 | 16050 | [ALC662_ASUS_EEEPC_P701] = { |
f9e336f6 | 16051 | .mixers = { alc662_eeepc_p701_mixer }, |
291702f0 KY |
16052 | .init_verbs = { alc662_init_verbs, |
16053 | alc662_eeepc_sue_init_verbs }, | |
16054 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16055 | .dac_nids = alc662_dac_nids, | |
291702f0 KY |
16056 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
16057 | .channel_mode = alc662_3ST_2ch_modes, | |
16058 | .input_mux = &alc662_eeepc_capture_source, | |
16059 | .unsol_event = alc662_eeepc_unsol_event, | |
16060 | .init_hook = alc662_eeepc_inithook, | |
16061 | }, | |
8c427226 | 16062 | [ALC662_ASUS_EEEPC_EP20] = { |
f9e336f6 | 16063 | .mixers = { alc662_eeepc_ep20_mixer, |
8c427226 KY |
16064 | alc662_chmode_mixer }, |
16065 | .init_verbs = { alc662_init_verbs, | |
16066 | alc662_eeepc_ep20_sue_init_verbs }, | |
16067 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16068 | .dac_nids = alc662_dac_nids, | |
8c427226 KY |
16069 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), |
16070 | .channel_mode = alc662_3ST_6ch_modes, | |
16071 | .input_mux = &alc662_lenovo_101e_capture_source, | |
16072 | .unsol_event = alc662_eeepc_ep20_unsol_event, | |
16073 | .init_hook = alc662_eeepc_ep20_inithook, | |
16074 | }, | |
f1d4e28b | 16075 | [ALC662_ECS] = { |
f9e336f6 | 16076 | .mixers = { alc662_ecs_mixer }, |
f1d4e28b KY |
16077 | .init_verbs = { alc662_init_verbs, |
16078 | alc662_ecs_init_verbs }, | |
16079 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16080 | .dac_nids = alc662_dac_nids, | |
16081 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16082 | .channel_mode = alc662_3ST_2ch_modes, | |
16083 | .input_mux = &alc662_eeepc_capture_source, | |
16084 | .unsol_event = alc662_eeepc_unsol_event, | |
16085 | .init_hook = alc662_eeepc_inithook, | |
16086 | }, | |
6dda9f4a | 16087 | [ALC663_ASUS_M51VA] = { |
f9e336f6 | 16088 | .mixers = { alc663_m51va_mixer }, |
6dda9f4a KY |
16089 | .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs }, |
16090 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16091 | .dac_nids = alc662_dac_nids, | |
16092 | .dig_out_nid = ALC662_DIGOUT_NID, | |
16093 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16094 | .channel_mode = alc662_3ST_2ch_modes, | |
16095 | .input_mux = &alc663_m51va_capture_source, | |
16096 | .unsol_event = alc663_m51va_unsol_event, | |
16097 | .init_hook = alc663_m51va_inithook, | |
16098 | }, | |
16099 | [ALC663_ASUS_G71V] = { | |
f9e336f6 | 16100 | .mixers = { alc663_g71v_mixer }, |
6dda9f4a KY |
16101 | .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs }, |
16102 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16103 | .dac_nids = alc662_dac_nids, | |
16104 | .dig_out_nid = ALC662_DIGOUT_NID, | |
16105 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16106 | .channel_mode = alc662_3ST_2ch_modes, | |
16107 | .input_mux = &alc662_eeepc_capture_source, | |
16108 | .unsol_event = alc663_g71v_unsol_event, | |
16109 | .init_hook = alc663_g71v_inithook, | |
16110 | }, | |
16111 | [ALC663_ASUS_H13] = { | |
f9e336f6 | 16112 | .mixers = { alc663_m51va_mixer }, |
6dda9f4a KY |
16113 | .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs }, |
16114 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16115 | .dac_nids = alc662_dac_nids, | |
16116 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16117 | .channel_mode = alc662_3ST_2ch_modes, | |
16118 | .input_mux = &alc663_m51va_capture_source, | |
16119 | .unsol_event = alc663_m51va_unsol_event, | |
16120 | .init_hook = alc663_m51va_inithook, | |
16121 | }, | |
16122 | [ALC663_ASUS_G50V] = { | |
f9e336f6 | 16123 | .mixers = { alc663_g50v_mixer }, |
6dda9f4a KY |
16124 | .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs }, |
16125 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16126 | .dac_nids = alc662_dac_nids, | |
16127 | .dig_out_nid = ALC662_DIGOUT_NID, | |
16128 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), | |
16129 | .channel_mode = alc662_3ST_6ch_modes, | |
16130 | .input_mux = &alc663_capture_source, | |
16131 | .unsol_event = alc663_g50v_unsol_event, | |
16132 | .init_hook = alc663_g50v_inithook, | |
16133 | }, | |
f1d4e28b | 16134 | [ALC663_ASUS_MODE1] = { |
f9e336f6 TI |
16135 | .mixers = { alc663_m51va_mixer }, |
16136 | .cap_mixer = alc662_auto_capture_mixer, | |
f1d4e28b KY |
16137 | .init_verbs = { alc662_init_verbs, |
16138 | alc663_21jd_amic_init_verbs }, | |
16139 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16140 | .hp_nid = 0x03, | |
16141 | .dac_nids = alc662_dac_nids, | |
16142 | .dig_out_nid = ALC662_DIGOUT_NID, | |
16143 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16144 | .channel_mode = alc662_3ST_2ch_modes, | |
16145 | .input_mux = &alc662_eeepc_capture_source, | |
16146 | .unsol_event = alc663_mode1_unsol_event, | |
16147 | .init_hook = alc663_mode1_inithook, | |
16148 | }, | |
16149 | [ALC662_ASUS_MODE2] = { | |
f9e336f6 TI |
16150 | .mixers = { alc662_1bjd_mixer }, |
16151 | .cap_mixer = alc662_auto_capture_mixer, | |
f1d4e28b KY |
16152 | .init_verbs = { alc662_init_verbs, |
16153 | alc662_1bjd_amic_init_verbs }, | |
16154 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16155 | .dac_nids = alc662_dac_nids, | |
16156 | .dig_out_nid = ALC662_DIGOUT_NID, | |
16157 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16158 | .channel_mode = alc662_3ST_2ch_modes, | |
16159 | .input_mux = &alc662_eeepc_capture_source, | |
16160 | .unsol_event = alc662_mode2_unsol_event, | |
16161 | .init_hook = alc662_mode2_inithook, | |
16162 | }, | |
16163 | [ALC663_ASUS_MODE3] = { | |
f9e336f6 TI |
16164 | .mixers = { alc663_two_hp_m1_mixer }, |
16165 | .cap_mixer = alc662_auto_capture_mixer, | |
f1d4e28b KY |
16166 | .init_verbs = { alc662_init_verbs, |
16167 | alc663_two_hp_amic_m1_init_verbs }, | |
16168 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16169 | .hp_nid = 0x03, | |
16170 | .dac_nids = alc662_dac_nids, | |
16171 | .dig_out_nid = ALC662_DIGOUT_NID, | |
16172 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16173 | .channel_mode = alc662_3ST_2ch_modes, | |
16174 | .input_mux = &alc662_eeepc_capture_source, | |
16175 | .unsol_event = alc663_mode3_unsol_event, | |
16176 | .init_hook = alc663_mode3_inithook, | |
16177 | }, | |
16178 | [ALC663_ASUS_MODE4] = { | |
f9e336f6 TI |
16179 | .mixers = { alc663_asus_21jd_clfe_mixer }, |
16180 | .cap_mixer = alc662_auto_capture_mixer, | |
f1d4e28b KY |
16181 | .init_verbs = { alc662_init_verbs, |
16182 | alc663_21jd_amic_init_verbs}, | |
16183 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16184 | .hp_nid = 0x03, | |
16185 | .dac_nids = alc662_dac_nids, | |
16186 | .dig_out_nid = ALC662_DIGOUT_NID, | |
16187 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16188 | .channel_mode = alc662_3ST_2ch_modes, | |
16189 | .input_mux = &alc662_eeepc_capture_source, | |
16190 | .unsol_event = alc663_mode4_unsol_event, | |
16191 | .init_hook = alc663_mode4_inithook, | |
16192 | }, | |
16193 | [ALC663_ASUS_MODE5] = { | |
f9e336f6 TI |
16194 | .mixers = { alc663_asus_15jd_clfe_mixer }, |
16195 | .cap_mixer = alc662_auto_capture_mixer, | |
f1d4e28b KY |
16196 | .init_verbs = { alc662_init_verbs, |
16197 | alc663_15jd_amic_init_verbs }, | |
16198 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16199 | .hp_nid = 0x03, | |
16200 | .dac_nids = alc662_dac_nids, | |
16201 | .dig_out_nid = ALC662_DIGOUT_NID, | |
16202 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16203 | .channel_mode = alc662_3ST_2ch_modes, | |
16204 | .input_mux = &alc662_eeepc_capture_source, | |
16205 | .unsol_event = alc663_mode5_unsol_event, | |
16206 | .init_hook = alc663_mode5_inithook, | |
16207 | }, | |
16208 | [ALC663_ASUS_MODE6] = { | |
f9e336f6 TI |
16209 | .mixers = { alc663_two_hp_m2_mixer }, |
16210 | .cap_mixer = alc662_auto_capture_mixer, | |
f1d4e28b KY |
16211 | .init_verbs = { alc662_init_verbs, |
16212 | alc663_two_hp_amic_m2_init_verbs }, | |
16213 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
16214 | .hp_nid = 0x03, | |
16215 | .dac_nids = alc662_dac_nids, | |
16216 | .dig_out_nid = ALC662_DIGOUT_NID, | |
16217 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
16218 | .channel_mode = alc662_3ST_2ch_modes, | |
16219 | .input_mux = &alc662_eeepc_capture_source, | |
16220 | .unsol_event = alc663_mode6_unsol_event, | |
16221 | .init_hook = alc663_mode6_inithook, | |
16222 | }, | |
bc9f98a9 KY |
16223 | }; |
16224 | ||
16225 | ||
16226 | /* | |
16227 | * BIOS auto configuration | |
16228 | */ | |
16229 | ||
16230 | /* add playback controls from the parsed DAC table */ | |
16231 | static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec, | |
16232 | const struct auto_pin_cfg *cfg) | |
16233 | { | |
16234 | char name[32]; | |
16235 | static const char *chname[4] = { | |
16236 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
16237 | }; | |
16238 | hda_nid_t nid; | |
16239 | int i, err; | |
16240 | ||
16241 | for (i = 0; i < cfg->line_outs; i++) { | |
16242 | if (!spec->multiout.dac_nids[i]) | |
16243 | continue; | |
b60dd394 | 16244 | nid = alc880_idx_to_dac(i); |
bc9f98a9 KY |
16245 | if (i == 2) { |
16246 | /* Center/LFE */ | |
16247 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
16248 | "Center Playback Volume", | |
f12ab1e0 TI |
16249 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, |
16250 | HDA_OUTPUT)); | |
bc9f98a9 KY |
16251 | if (err < 0) |
16252 | return err; | |
16253 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
16254 | "LFE Playback Volume", | |
f12ab1e0 TI |
16255 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, |
16256 | HDA_OUTPUT)); | |
bc9f98a9 KY |
16257 | if (err < 0) |
16258 | return err; | |
b69ce01a | 16259 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
bc9f98a9 | 16260 | "Center Playback Switch", |
b69ce01a | 16261 | HDA_COMPOSE_AMP_VAL(0x0e, 1, 0, |
f12ab1e0 | 16262 | HDA_INPUT)); |
bc9f98a9 KY |
16263 | if (err < 0) |
16264 | return err; | |
b69ce01a | 16265 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
bc9f98a9 | 16266 | "LFE Playback Switch", |
b69ce01a | 16267 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, |
f12ab1e0 | 16268 | HDA_INPUT)); |
bc9f98a9 KY |
16269 | if (err < 0) |
16270 | return err; | |
16271 | } else { | |
16272 | sprintf(name, "%s Playback Volume", chname[i]); | |
16273 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
f12ab1e0 TI |
16274 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, |
16275 | HDA_OUTPUT)); | |
bc9f98a9 KY |
16276 | if (err < 0) |
16277 | return err; | |
16278 | sprintf(name, "%s Playback Switch", chname[i]); | |
b69ce01a HRK |
16279 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
16280 | HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i), | |
16281 | 3, 0, HDA_INPUT)); | |
bc9f98a9 KY |
16282 | if (err < 0) |
16283 | return err; | |
16284 | } | |
16285 | } | |
16286 | return 0; | |
16287 | } | |
16288 | ||
16289 | /* add playback controls for speaker and HP outputs */ | |
16290 | static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, | |
16291 | const char *pfx) | |
16292 | { | |
16293 | hda_nid_t nid; | |
16294 | int err; | |
16295 | char name[32]; | |
16296 | ||
16297 | if (!pin) | |
16298 | return 0; | |
16299 | ||
24fb9173 TI |
16300 | if (pin == 0x17) { |
16301 | /* ALC663 has a mono output pin on 0x17 */ | |
16302 | sprintf(name, "%s Playback Switch", pfx); | |
16303 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | |
16304 | HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT)); | |
16305 | return err; | |
16306 | } | |
16307 | ||
bc9f98a9 KY |
16308 | if (alc880_is_fixed_pin(pin)) { |
16309 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
16310 | /* printk("DAC nid=%x\n",nid); */ | |
16311 | /* specify the DAC as the extra output */ | |
16312 | if (!spec->multiout.hp_nid) | |
16313 | spec->multiout.hp_nid = nid; | |
16314 | else | |
16315 | spec->multiout.extra_out_nid[0] = nid; | |
16316 | /* control HP volume/switch on the output mixer amp */ | |
16317 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
16318 | sprintf(name, "%s Playback Volume", pfx); | |
16319 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
16320 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
16321 | if (err < 0) | |
16322 | return err; | |
16323 | sprintf(name, "%s Playback Switch", pfx); | |
16324 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | |
16325 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); | |
16326 | if (err < 0) | |
16327 | return err; | |
16328 | } else if (alc880_is_multi_pin(pin)) { | |
16329 | /* set manual connection */ | |
16330 | /* we have only a switch on HP-out PIN */ | |
16331 | sprintf(name, "%s Playback Switch", pfx); | |
16332 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | |
16333 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
16334 | if (err < 0) | |
16335 | return err; | |
16336 | } | |
16337 | return 0; | |
16338 | } | |
16339 | ||
16340 | /* create playback/capture controls for input pins */ | |
16341 | static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec, | |
16342 | const struct auto_pin_cfg *cfg) | |
16343 | { | |
16344 | struct hda_input_mux *imux = &spec->private_imux; | |
16345 | int i, err, idx; | |
16346 | ||
16347 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
16348 | if (alc880_is_input_pin(cfg->input_pins[i])) { | |
16349 | idx = alc880_input_pin_idx(cfg->input_pins[i]); | |
16350 | err = new_analog_input(spec, cfg->input_pins[i], | |
16351 | auto_pin_cfg_labels[i], | |
16352 | idx, 0x0b); | |
16353 | if (err < 0) | |
16354 | return err; | |
16355 | imux->items[imux->num_items].label = | |
16356 | auto_pin_cfg_labels[i]; | |
16357 | imux->items[imux->num_items].index = | |
16358 | alc880_input_pin_idx(cfg->input_pins[i]); | |
16359 | imux->num_items++; | |
16360 | } | |
16361 | } | |
16362 | return 0; | |
16363 | } | |
16364 | ||
16365 | static void alc662_auto_set_output_and_unmute(struct hda_codec *codec, | |
16366 | hda_nid_t nid, int pin_type, | |
16367 | int dac_idx) | |
16368 | { | |
f6c7e546 | 16369 | alc_set_pin_output(codec, nid, pin_type); |
bc9f98a9 KY |
16370 | /* need the manual connection? */ |
16371 | if (alc880_is_multi_pin(nid)) { | |
16372 | struct alc_spec *spec = codec->spec; | |
16373 | int idx = alc880_multi_pin_idx(nid); | |
16374 | snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, | |
16375 | AC_VERB_SET_CONNECT_SEL, | |
16376 | alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); | |
16377 | } | |
16378 | } | |
16379 | ||
16380 | static void alc662_auto_init_multi_out(struct hda_codec *codec) | |
16381 | { | |
16382 | struct alc_spec *spec = codec->spec; | |
16383 | int i; | |
16384 | ||
8c427226 | 16385 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
bc9f98a9 KY |
16386 | for (i = 0; i <= HDA_SIDE; i++) { |
16387 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 16388 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
bc9f98a9 | 16389 | if (nid) |
baba8ee9 | 16390 | alc662_auto_set_output_and_unmute(codec, nid, pin_type, |
bc9f98a9 KY |
16391 | i); |
16392 | } | |
16393 | } | |
16394 | ||
16395 | static void alc662_auto_init_hp_out(struct hda_codec *codec) | |
16396 | { | |
16397 | struct alc_spec *spec = codec->spec; | |
16398 | hda_nid_t pin; | |
16399 | ||
16400 | pin = spec->autocfg.hp_pins[0]; | |
16401 | if (pin) /* connect to front */ | |
16402 | /* use dac 0 */ | |
16403 | alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
f6c7e546 TI |
16404 | pin = spec->autocfg.speaker_pins[0]; |
16405 | if (pin) | |
16406 | alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
bc9f98a9 KY |
16407 | } |
16408 | ||
16409 | #define alc662_is_input_pin(nid) alc880_is_input_pin(nid) | |
16410 | #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID | |
16411 | ||
16412 | static void alc662_auto_init_analog_input(struct hda_codec *codec) | |
16413 | { | |
16414 | struct alc_spec *spec = codec->spec; | |
16415 | int i; | |
16416 | ||
16417 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
16418 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
16419 | if (alc662_is_input_pin(nid)) { | |
16420 | snd_hda_codec_write(codec, nid, 0, | |
16421 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
16422 | (i <= AUTO_PIN_FRONT_MIC ? | |
16423 | PIN_VREF80 : PIN_IN)); | |
16424 | if (nid != ALC662_PIN_CD_NID) | |
16425 | snd_hda_codec_write(codec, nid, 0, | |
16426 | AC_VERB_SET_AMP_GAIN_MUTE, | |
16427 | AMP_OUT_MUTE); | |
16428 | } | |
16429 | } | |
16430 | } | |
16431 | ||
f511b01c TI |
16432 | #define alc662_auto_init_input_src alc882_auto_init_input_src |
16433 | ||
bc9f98a9 KY |
16434 | static int alc662_parse_auto_config(struct hda_codec *codec) |
16435 | { | |
16436 | struct alc_spec *spec = codec->spec; | |
16437 | int err; | |
16438 | static hda_nid_t alc662_ignore[] = { 0x1d, 0 }; | |
16439 | ||
16440 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | |
16441 | alc662_ignore); | |
16442 | if (err < 0) | |
16443 | return err; | |
16444 | if (!spec->autocfg.line_outs) | |
16445 | return 0; /* can't find valid BIOS pin config */ | |
16446 | ||
f12ab1e0 TI |
16447 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
16448 | if (err < 0) | |
16449 | return err; | |
16450 | err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
16451 | if (err < 0) | |
16452 | return err; | |
16453 | err = alc662_auto_create_extra_out(spec, | |
16454 | spec->autocfg.speaker_pins[0], | |
16455 | "Speaker"); | |
16456 | if (err < 0) | |
16457 | return err; | |
16458 | err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], | |
16459 | "Headphone"); | |
16460 | if (err < 0) | |
16461 | return err; | |
16462 | err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
16463 | if (err < 0) | |
bc9f98a9 KY |
16464 | return err; |
16465 | ||
16466 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
16467 | ||
16468 | if (spec->autocfg.dig_out_pin) | |
16469 | spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; | |
16470 | ||
603c4019 | 16471 | if (spec->kctls.list) |
d88897ea | 16472 | add_mixer(spec, spec->kctls.list); |
bc9f98a9 KY |
16473 | |
16474 | spec->num_mux_defs = 1; | |
16475 | spec->input_mux = &spec->private_imux; | |
ea1fb29a | 16476 | |
d88897ea | 16477 | add_verb(spec, alc662_auto_init_verbs); |
24fb9173 | 16478 | if (codec->vendor_id == 0x10ec0663) |
d88897ea | 16479 | add_verb(spec, alc663_auto_init_verbs); |
ee979a14 TI |
16480 | |
16481 | err = alc_auto_add_mic_boost(codec); | |
16482 | if (err < 0) | |
16483 | return err; | |
16484 | ||
e044c39a | 16485 | store_pin_configs(codec); |
8c87286f | 16486 | return 1; |
bc9f98a9 KY |
16487 | } |
16488 | ||
16489 | /* additional initialization for auto-configuration model */ | |
16490 | static void alc662_auto_init(struct hda_codec *codec) | |
16491 | { | |
f6c7e546 | 16492 | struct alc_spec *spec = codec->spec; |
bc9f98a9 KY |
16493 | alc662_auto_init_multi_out(codec); |
16494 | alc662_auto_init_hp_out(codec); | |
16495 | alc662_auto_init_analog_input(codec); | |
f511b01c | 16496 | alc662_auto_init_input_src(codec); |
f6c7e546 | 16497 | if (spec->unsol_event) |
7fb0d78f | 16498 | alc_inithook(codec); |
bc9f98a9 KY |
16499 | } |
16500 | ||
16501 | static int patch_alc662(struct hda_codec *codec) | |
16502 | { | |
16503 | struct alc_spec *spec; | |
16504 | int err, board_config; | |
16505 | ||
16506 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
16507 | if (!spec) | |
16508 | return -ENOMEM; | |
16509 | ||
16510 | codec->spec = spec; | |
16511 | ||
2c3bf9ab TI |
16512 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
16513 | ||
bc9f98a9 KY |
16514 | board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST, |
16515 | alc662_models, | |
16516 | alc662_cfg_tbl); | |
16517 | if (board_config < 0) { | |
16518 | printk(KERN_INFO "hda_codec: Unknown model for ALC662, " | |
16519 | "trying auto-probe from BIOS...\n"); | |
16520 | board_config = ALC662_AUTO; | |
16521 | } | |
16522 | ||
16523 | if (board_config == ALC662_AUTO) { | |
16524 | /* automatic parse from the BIOS config */ | |
16525 | err = alc662_parse_auto_config(codec); | |
16526 | if (err < 0) { | |
16527 | alc_free(codec); | |
16528 | return err; | |
8c87286f | 16529 | } else if (!err) { |
bc9f98a9 KY |
16530 | printk(KERN_INFO |
16531 | "hda_codec: Cannot set up configuration " | |
16532 | "from BIOS. Using base mode...\n"); | |
16533 | board_config = ALC662_3ST_2ch_DIG; | |
16534 | } | |
16535 | } | |
16536 | ||
16537 | if (board_config != ALC662_AUTO) | |
16538 | setup_preset(spec, &alc662_presets[board_config]); | |
16539 | ||
6dda9f4a KY |
16540 | if (codec->vendor_id == 0x10ec0663) { |
16541 | spec->stream_name_analog = "ALC663 Analog"; | |
16542 | spec->stream_name_digital = "ALC663 Digital"; | |
01afd41f KY |
16543 | } else if (codec->vendor_id == 0x10ec0272) { |
16544 | spec->stream_name_analog = "ALC272 Analog"; | |
16545 | spec->stream_name_digital = "ALC272 Digital"; | |
6dda9f4a KY |
16546 | } else { |
16547 | spec->stream_name_analog = "ALC662 Analog"; | |
16548 | spec->stream_name_digital = "ALC662 Digital"; | |
16549 | } | |
16550 | ||
bc9f98a9 KY |
16551 | spec->stream_analog_playback = &alc662_pcm_analog_playback; |
16552 | spec->stream_analog_capture = &alc662_pcm_analog_capture; | |
16553 | ||
bc9f98a9 KY |
16554 | spec->stream_digital_playback = &alc662_pcm_digital_playback; |
16555 | spec->stream_digital_capture = &alc662_pcm_digital_capture; | |
16556 | ||
e1406348 TI |
16557 | spec->adc_nids = alc662_adc_nids; |
16558 | spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids); | |
16559 | spec->capsrc_nids = alc662_capsrc_nids; | |
54cbc9ab | 16560 | spec->is_mix_capture = 1; |
bc9f98a9 | 16561 | |
f9e336f6 TI |
16562 | if (!spec->cap_mixer) |
16563 | set_capture_mixer(spec); | |
16564 | ||
2134ea4f TI |
16565 | spec->vmaster_nid = 0x02; |
16566 | ||
bc9f98a9 KY |
16567 | codec->patch_ops = alc_patch_ops; |
16568 | if (board_config == ALC662_AUTO) | |
16569 | spec->init_hook = alc662_auto_init; | |
cb53c626 TI |
16570 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
16571 | if (!spec->loopback.amplist) | |
16572 | spec->loopback.amplist = alc662_loopbacks; | |
16573 | #endif | |
bc9f98a9 KY |
16574 | |
16575 | return 0; | |
16576 | } | |
16577 | ||
1da177e4 LT |
16578 | /* |
16579 | * patch entries | |
16580 | */ | |
16581 | struct hda_codec_preset snd_hda_preset_realtek[] = { | |
16582 | { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, | |
df694daa | 16583 | { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, |
f6a92248 | 16584 | { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, |
a361d84b | 16585 | { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, |
f6a92248 | 16586 | { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 }, |
01afd41f | 16587 | { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 }, |
f32610ed | 16588 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", |
bc9f98a9 | 16589 | .patch = patch_alc861 }, |
f32610ed JS |
16590 | { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, |
16591 | { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, | |
16592 | { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, | |
bc9f98a9 KY |
16593 | { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", |
16594 | .patch = patch_alc883 }, | |
16595 | { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", | |
16596 | .patch = patch_alc662 }, | |
6dda9f4a | 16597 | { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, |
f32610ed | 16598 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
1da177e4 | 16599 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, |
9c7f852e | 16600 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 }, |
669faba2 CM |
16601 | { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A", |
16602 | .patch = patch_alc882 }, /* should be patch_alc883() in future */ | |
cb308f97 | 16603 | { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", |
7943a8ab | 16604 | .patch = patch_alc882 }, /* should be patch_alc883() in future */ |
df694daa | 16605 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, |
a385a529 | 16606 | { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 }, |
9c7f852e | 16607 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 }, |
4442608d KY |
16608 | { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", |
16609 | .patch = patch_alc883 }, | |
f6a92248 | 16610 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 }, |
1da177e4 LT |
16611 | {} /* terminator */ |
16612 | }; |