]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * Universal Interface for Intel High Definition Audio Codec | |
3 | * | |
4 | * HD audio interface patch for ALC 260/880/882 codecs | |
5 | * | |
df694daa KY |
6 | * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw> |
7 | * PeiSen Hou <pshou@realtek.com.tw> | |
1da177e4 | 8 | * Takashi Iwai <tiwai@suse.de> |
7cf51e48 | 9 | * Jonathan Woithe <jwoithe@physics.adelaide.edu.au> |
1da177e4 LT |
10 | * |
11 | * This driver is free software; you can redistribute it and/or modify | |
12 | * it under the terms of the GNU General Public License as published by | |
13 | * the Free Software Foundation; either version 2 of the License, or | |
14 | * (at your option) any later version. | |
15 | * | |
16 | * This driver is distributed in the hope that it will be useful, | |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | * GNU General Public License for more details. | |
20 | * | |
21 | * You should have received a copy of the GNU General Public License | |
22 | * along with this program; if not, write to the Free Software | |
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 | */ | |
25 | ||
1da177e4 LT |
26 | #include <linux/init.h> |
27 | #include <linux/delay.h> | |
28 | #include <linux/slab.h> | |
29 | #include <linux/pci.h> | |
30 | #include <sound/core.h> | |
31 | #include "hda_codec.h" | |
32 | #include "hda_local.h" | |
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, |
df694daa KY |
106 | ALC262_AUTO, |
107 | ALC262_MODEL_LAST /* last tag */ | |
108 | }; | |
109 | ||
a361d84b KY |
110 | /* ALC268 models */ |
111 | enum { | |
eb5a6621 | 112 | ALC267_QUANTA_IL1, |
a361d84b | 113 | ALC268_3ST, |
d1a991a6 | 114 | ALC268_TOSHIBA, |
d273809e | 115 | ALC268_ACER, |
8ef355da | 116 | ALC268_ACER_ASPIRE_ONE, |
3866f0b0 | 117 | ALC268_DELL, |
f12462c5 | 118 | ALC268_ZEPTO, |
86c53bd2 JW |
119 | #ifdef CONFIG_SND_DEBUG |
120 | ALC268_TEST, | |
121 | #endif | |
a361d84b KY |
122 | ALC268_AUTO, |
123 | ALC268_MODEL_LAST /* last tag */ | |
124 | }; | |
125 | ||
f6a92248 KY |
126 | /* ALC269 models */ |
127 | enum { | |
128 | ALC269_BASIC, | |
60db6b53 | 129 | ALC269_QUANTA_FL1, |
f53281e6 KY |
130 | ALC269_ASUS_EEEPC_P703, |
131 | ALC269_ASUS_EEEPC_P901, | |
f6a92248 KY |
132 | ALC269_AUTO, |
133 | ALC269_MODEL_LAST /* last tag */ | |
134 | }; | |
135 | ||
df694daa KY |
136 | /* ALC861 models */ |
137 | enum { | |
138 | ALC861_3ST, | |
9c7f852e | 139 | ALC660_3ST, |
df694daa KY |
140 | ALC861_3ST_DIG, |
141 | ALC861_6ST_DIG, | |
22309c3e | 142 | ALC861_UNIWILL_M31, |
a53d1aec | 143 | ALC861_TOSHIBA, |
7cdbff94 | 144 | ALC861_ASUS, |
56bb0cab | 145 | ALC861_ASUS_LAPTOP, |
df694daa KY |
146 | ALC861_AUTO, |
147 | ALC861_MODEL_LAST, | |
148 | }; | |
149 | ||
f32610ed JS |
150 | /* ALC861-VD models */ |
151 | enum { | |
152 | ALC660VD_3ST, | |
6963f84c | 153 | ALC660VD_3ST_DIG, |
f32610ed JS |
154 | ALC861VD_3ST, |
155 | ALC861VD_3ST_DIG, | |
156 | ALC861VD_6ST_DIG, | |
bdd148a3 | 157 | ALC861VD_LENOVO, |
272a527c | 158 | ALC861VD_DALLAS, |
d1a991a6 | 159 | ALC861VD_HP, |
f32610ed JS |
160 | ALC861VD_AUTO, |
161 | ALC861VD_MODEL_LAST, | |
162 | }; | |
163 | ||
bc9f98a9 KY |
164 | /* ALC662 models */ |
165 | enum { | |
166 | ALC662_3ST_2ch_DIG, | |
167 | ALC662_3ST_6ch_DIG, | |
168 | ALC662_3ST_6ch, | |
169 | ALC662_5ST_DIG, | |
170 | ALC662_LENOVO_101E, | |
291702f0 | 171 | ALC662_ASUS_EEEPC_P701, |
8c427226 | 172 | ALC662_ASUS_EEEPC_EP20, |
6dda9f4a KY |
173 | ALC663_ASUS_M51VA, |
174 | ALC663_ASUS_G71V, | |
175 | ALC663_ASUS_H13, | |
176 | ALC663_ASUS_G50V, | |
f1d4e28b KY |
177 | ALC662_ECS, |
178 | ALC663_ASUS_MODE1, | |
179 | ALC662_ASUS_MODE2, | |
180 | ALC663_ASUS_MODE3, | |
181 | ALC663_ASUS_MODE4, | |
182 | ALC663_ASUS_MODE5, | |
183 | ALC663_ASUS_MODE6, | |
bc9f98a9 KY |
184 | ALC662_AUTO, |
185 | ALC662_MODEL_LAST, | |
186 | }; | |
187 | ||
df694daa KY |
188 | /* ALC882 models */ |
189 | enum { | |
190 | ALC882_3ST_DIG, | |
191 | ALC882_6ST_DIG, | |
4b146cb0 | 192 | ALC882_ARIMA, |
bdd148a3 | 193 | ALC882_W2JC, |
272a527c KY |
194 | ALC882_TARGA, |
195 | ALC882_ASUS_A7J, | |
914759b7 | 196 | ALC882_ASUS_A7M, |
9102cd1c | 197 | ALC885_MACPRO, |
87350ad0 | 198 | ALC885_MBP3, |
c54728d8 | 199 | ALC885_IMAC24, |
272a527c | 200 | ALC882_AUTO, |
df694daa KY |
201 | ALC882_MODEL_LAST, |
202 | }; | |
203 | ||
9c7f852e TI |
204 | /* ALC883 models */ |
205 | enum { | |
206 | ALC883_3ST_2ch_DIG, | |
207 | ALC883_3ST_6ch_DIG, | |
208 | ALC883_3ST_6ch, | |
209 | ALC883_6ST_DIG, | |
ccc656ce KY |
210 | ALC883_TARGA_DIG, |
211 | ALC883_TARGA_2ch_DIG, | |
bab282b9 | 212 | ALC883_ACER, |
2880a867 | 213 | ALC883_ACER_ASPIRE, |
c07584c8 | 214 | ALC883_MEDION, |
ea1fb29a | 215 | ALC883_MEDION_MD2, |
b373bdeb | 216 | ALC883_LAPTOP_EAPD, |
bc9f98a9 | 217 | ALC883_LENOVO_101E_2ch, |
272a527c | 218 | ALC883_LENOVO_NB0763, |
189609ae | 219 | ALC888_LENOVO_MS7195_DIG, |
e2757d5e | 220 | ALC888_LENOVO_SKY, |
ea1fb29a | 221 | ALC883_HAIER_W66, |
4723c022 | 222 | ALC888_3ST_HP, |
5795b9e6 | 223 | ALC888_6ST_DELL, |
a8848bd6 | 224 | ALC883_MITAC, |
0c4cc443 | 225 | ALC883_CLEVO_M720, |
fb97dc67 | 226 | ALC883_FUJITSU_PI2515, |
17bba1b7 | 227 | ALC883_3ST_6ch_INTEL, |
e2757d5e KY |
228 | ALC888_ASUS_M90V, |
229 | ALC888_ASUS_EEE1601, | |
9c7f852e TI |
230 | ALC883_AUTO, |
231 | ALC883_MODEL_LAST, | |
232 | }; | |
233 | ||
df694daa KY |
234 | /* for GPIO Poll */ |
235 | #define GPIO_MASK 0x03 | |
236 | ||
1da177e4 LT |
237 | struct alc_spec { |
238 | /* codec parameterization */ | |
df694daa | 239 | struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ |
1da177e4 LT |
240 | unsigned int num_mixers; |
241 | ||
df694daa | 242 | const struct hda_verb *init_verbs[5]; /* initialization verbs |
9c7f852e TI |
243 | * don't forget NULL |
244 | * termination! | |
e9edcee0 TI |
245 | */ |
246 | unsigned int num_init_verbs; | |
1da177e4 | 247 | |
16ded525 | 248 | char *stream_name_analog; /* analog PCM stream */ |
1da177e4 LT |
249 | struct hda_pcm_stream *stream_analog_playback; |
250 | struct hda_pcm_stream *stream_analog_capture; | |
6330079f TI |
251 | struct hda_pcm_stream *stream_analog_alt_playback; |
252 | struct hda_pcm_stream *stream_analog_alt_capture; | |
1da177e4 | 253 | |
f12ab1e0 | 254 | char *stream_name_digital; /* digital PCM stream */ |
1da177e4 LT |
255 | struct hda_pcm_stream *stream_digital_playback; |
256 | struct hda_pcm_stream *stream_digital_capture; | |
257 | ||
258 | /* playback */ | |
16ded525 TI |
259 | struct hda_multi_out multiout; /* playback set-up |
260 | * max_channels, dacs must be set | |
261 | * dig_out_nid and hp_nid are optional | |
262 | */ | |
6330079f | 263 | hda_nid_t alt_dac_nid; |
1da177e4 LT |
264 | |
265 | /* capture */ | |
266 | unsigned int num_adc_nids; | |
267 | hda_nid_t *adc_nids; | |
e1406348 | 268 | hda_nid_t *capsrc_nids; |
16ded525 | 269 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
1da177e4 LT |
270 | |
271 | /* capture source */ | |
a1e8d2da | 272 | unsigned int num_mux_defs; |
1da177e4 LT |
273 | const struct hda_input_mux *input_mux; |
274 | unsigned int cur_mux[3]; | |
275 | ||
276 | /* channel model */ | |
d2a6d7dc | 277 | const struct hda_channel_mode *channel_mode; |
1da177e4 | 278 | int num_channel_mode; |
4e195a7b | 279 | int need_dac_fix; |
1da177e4 LT |
280 | |
281 | /* PCM information */ | |
4c5186ed | 282 | struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ |
41e41f1f | 283 | |
e9edcee0 TI |
284 | /* dynamic controls, init_verbs and input_mux */ |
285 | struct auto_pin_cfg autocfg; | |
286 | unsigned int num_kctl_alloc, num_kctl_used; | |
c8b6bf9b | 287 | struct snd_kcontrol_new *kctl_alloc; |
e9edcee0 | 288 | struct hda_input_mux private_imux; |
41923e44 | 289 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
834be88d | 290 | |
ae6b813a TI |
291 | /* hooks */ |
292 | void (*init_hook)(struct hda_codec *codec); | |
293 | void (*unsol_event)(struct hda_codec *codec, unsigned int res); | |
294 | ||
834be88d TI |
295 | /* for pin sensing */ |
296 | unsigned int sense_updated: 1; | |
297 | unsigned int jack_present: 1; | |
bec15c3a | 298 | unsigned int master_sw: 1; |
cb53c626 | 299 | |
2134ea4f TI |
300 | /* for virtual master */ |
301 | hda_nid_t vmaster_nid; | |
cb53c626 TI |
302 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
303 | struct hda_loopback_check loopback; | |
304 | #endif | |
2c3bf9ab TI |
305 | |
306 | /* for PLL fix */ | |
307 | hda_nid_t pll_nid; | |
308 | unsigned int pll_coef_idx, pll_coef_bit; | |
df694daa KY |
309 | }; |
310 | ||
311 | /* | |
312 | * configuration template - to be copied to the spec instance | |
313 | */ | |
314 | struct alc_config_preset { | |
9c7f852e TI |
315 | struct snd_kcontrol_new *mixers[5]; /* should be identical size |
316 | * with spec | |
317 | */ | |
df694daa KY |
318 | const struct hda_verb *init_verbs[5]; |
319 | unsigned int num_dacs; | |
320 | hda_nid_t *dac_nids; | |
321 | hda_nid_t dig_out_nid; /* optional */ | |
322 | hda_nid_t hp_nid; /* optional */ | |
323 | unsigned int num_adc_nids; | |
324 | hda_nid_t *adc_nids; | |
e1406348 | 325 | hda_nid_t *capsrc_nids; |
df694daa KY |
326 | hda_nid_t dig_in_nid; |
327 | unsigned int num_channel_mode; | |
328 | const struct hda_channel_mode *channel_mode; | |
4e195a7b | 329 | int need_dac_fix; |
a1e8d2da | 330 | unsigned int num_mux_defs; |
df694daa | 331 | const struct hda_input_mux *input_mux; |
ae6b813a TI |
332 | void (*unsol_event)(struct hda_codec *, unsigned int); |
333 | void (*init_hook)(struct hda_codec *); | |
cb53c626 TI |
334 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
335 | struct hda_amp_list *loopbacks; | |
336 | #endif | |
1da177e4 LT |
337 | }; |
338 | ||
1da177e4 LT |
339 | |
340 | /* | |
341 | * input MUX handling | |
342 | */ | |
9c7f852e TI |
343 | static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, |
344 | struct snd_ctl_elem_info *uinfo) | |
1da177e4 LT |
345 | { |
346 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
347 | struct alc_spec *spec = codec->spec; | |
a1e8d2da JW |
348 | unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id); |
349 | if (mux_idx >= spec->num_mux_defs) | |
350 | mux_idx = 0; | |
351 | return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo); | |
1da177e4 LT |
352 | } |
353 | ||
9c7f852e TI |
354 | static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, |
355 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
356 | { |
357 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
358 | struct alc_spec *spec = codec->spec; | |
359 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
360 | ||
361 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; | |
362 | return 0; | |
363 | } | |
364 | ||
9c7f852e TI |
365 | static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, |
366 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
367 | { |
368 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
369 | struct alc_spec *spec = codec->spec; | |
370 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
a1e8d2da | 371 | unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; |
e1406348 TI |
372 | hda_nid_t nid = spec->capsrc_nids ? |
373 | spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx]; | |
a1e8d2da | 374 | return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol, |
e1406348 | 375 | nid, &spec->cur_mux[adc_idx]); |
1da177e4 LT |
376 | } |
377 | ||
e9edcee0 | 378 | |
1da177e4 LT |
379 | /* |
380 | * channel mode setting | |
381 | */ | |
9c7f852e TI |
382 | static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, |
383 | struct snd_ctl_elem_info *uinfo) | |
1da177e4 LT |
384 | { |
385 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
386 | struct alc_spec *spec = codec->spec; | |
d2a6d7dc TI |
387 | return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, |
388 | spec->num_channel_mode); | |
1da177e4 LT |
389 | } |
390 | ||
9c7f852e TI |
391 | static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, |
392 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
393 | { |
394 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
395 | struct alc_spec *spec = codec->spec; | |
d2a6d7dc | 396 | return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, |
9c7f852e TI |
397 | spec->num_channel_mode, |
398 | spec->multiout.max_channels); | |
1da177e4 LT |
399 | } |
400 | ||
9c7f852e TI |
401 | static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, |
402 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
403 | { |
404 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
405 | struct alc_spec *spec = codec->spec; | |
4e195a7b TI |
406 | int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, |
407 | spec->num_channel_mode, | |
408 | &spec->multiout.max_channels); | |
bd2033f2 | 409 | if (err >= 0 && spec->need_dac_fix) |
4e195a7b TI |
410 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; |
411 | return err; | |
1da177e4 LT |
412 | } |
413 | ||
a9430dd8 | 414 | /* |
4c5186ed | 415 | * Control the mode of pin widget settings via the mixer. "pc" is used |
ea1fb29a | 416 | * instead of "%" to avoid consequences of accidently treating the % as |
4c5186ed JW |
417 | * being part of a format specifier. Maximum allowed length of a value is |
418 | * 63 characters plus NULL terminator. | |
7cf51e48 JW |
419 | * |
420 | * Note: some retasking pin complexes seem to ignore requests for input | |
421 | * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these | |
422 | * are requested. Therefore order this list so that this behaviour will not | |
423 | * cause problems when mixer clients move through the enum sequentially. | |
a1e8d2da JW |
424 | * NIDs 0x0f and 0x10 have been observed to have this behaviour as of |
425 | * March 2006. | |
4c5186ed JW |
426 | */ |
427 | static char *alc_pin_mode_names[] = { | |
7cf51e48 JW |
428 | "Mic 50pc bias", "Mic 80pc bias", |
429 | "Line in", "Line out", "Headphone out", | |
4c5186ed JW |
430 | }; |
431 | static unsigned char alc_pin_mode_values[] = { | |
7cf51e48 | 432 | PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP, |
4c5186ed JW |
433 | }; |
434 | /* The control can present all 5 options, or it can limit the options based | |
a1e8d2da JW |
435 | * in the pin being assumed to be exclusively an input or an output pin. In |
436 | * addition, "input" pins may or may not process the mic bias option | |
437 | * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to | |
438 | * accept requests for bias as of chip versions up to March 2006) and/or | |
439 | * wiring in the computer. | |
a9430dd8 | 440 | */ |
a1e8d2da JW |
441 | #define ALC_PIN_DIR_IN 0x00 |
442 | #define ALC_PIN_DIR_OUT 0x01 | |
443 | #define ALC_PIN_DIR_INOUT 0x02 | |
444 | #define ALC_PIN_DIR_IN_NOMICBIAS 0x03 | |
445 | #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04 | |
4c5186ed | 446 | |
ea1fb29a | 447 | /* Info about the pin modes supported by the different pin direction modes. |
4c5186ed JW |
448 | * For each direction the minimum and maximum values are given. |
449 | */ | |
a1e8d2da | 450 | static signed char alc_pin_mode_dir_info[5][2] = { |
4c5186ed JW |
451 | { 0, 2 }, /* ALC_PIN_DIR_IN */ |
452 | { 3, 4 }, /* ALC_PIN_DIR_OUT */ | |
453 | { 0, 4 }, /* ALC_PIN_DIR_INOUT */ | |
a1e8d2da JW |
454 | { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */ |
455 | { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */ | |
4c5186ed JW |
456 | }; |
457 | #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0]) | |
458 | #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1]) | |
459 | #define alc_pin_mode_n_items(_dir) \ | |
460 | (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1) | |
461 | ||
9c7f852e TI |
462 | static int alc_pin_mode_info(struct snd_kcontrol *kcontrol, |
463 | struct snd_ctl_elem_info *uinfo) | |
a9430dd8 | 464 | { |
4c5186ed JW |
465 | unsigned int item_num = uinfo->value.enumerated.item; |
466 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; | |
467 | ||
468 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
a9430dd8 | 469 | uinfo->count = 1; |
4c5186ed JW |
470 | uinfo->value.enumerated.items = alc_pin_mode_n_items(dir); |
471 | ||
472 | if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir)) | |
473 | item_num = alc_pin_mode_min(dir); | |
474 | strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]); | |
a9430dd8 JW |
475 | return 0; |
476 | } | |
477 | ||
9c7f852e TI |
478 | static int alc_pin_mode_get(struct snd_kcontrol *kcontrol, |
479 | struct snd_ctl_elem_value *ucontrol) | |
a9430dd8 | 480 | { |
4c5186ed | 481 | unsigned int i; |
a9430dd8 JW |
482 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
483 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
4c5186ed | 484 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
a9430dd8 | 485 | long *valp = ucontrol->value.integer.value; |
9c7f852e TI |
486 | unsigned int pinctl = snd_hda_codec_read(codec, nid, 0, |
487 | AC_VERB_GET_PIN_WIDGET_CONTROL, | |
488 | 0x00); | |
a9430dd8 | 489 | |
4c5186ed JW |
490 | /* Find enumerated value for current pinctl setting */ |
491 | i = alc_pin_mode_min(dir); | |
9c7f852e | 492 | while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir)) |
4c5186ed | 493 | i++; |
9c7f852e | 494 | *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir); |
a9430dd8 JW |
495 | return 0; |
496 | } | |
497 | ||
9c7f852e TI |
498 | static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, |
499 | struct snd_ctl_elem_value *ucontrol) | |
a9430dd8 | 500 | { |
4c5186ed | 501 | signed int change; |
a9430dd8 JW |
502 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
503 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
4c5186ed JW |
504 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
505 | long val = *ucontrol->value.integer.value; | |
9c7f852e TI |
506 | unsigned int pinctl = snd_hda_codec_read(codec, nid, 0, |
507 | AC_VERB_GET_PIN_WIDGET_CONTROL, | |
508 | 0x00); | |
a9430dd8 | 509 | |
f12ab1e0 | 510 | if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir)) |
4c5186ed JW |
511 | val = alc_pin_mode_min(dir); |
512 | ||
513 | change = pinctl != alc_pin_mode_values[val]; | |
cdcd9268 JW |
514 | if (change) { |
515 | /* Set pin mode to that requested */ | |
82beb8fd TI |
516 | snd_hda_codec_write_cache(codec, nid, 0, |
517 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
518 | alc_pin_mode_values[val]); | |
cdcd9268 | 519 | |
ea1fb29a | 520 | /* Also enable the retasking pin's input/output as required |
cdcd9268 JW |
521 | * for the requested pin mode. Enum values of 2 or less are |
522 | * input modes. | |
523 | * | |
524 | * Dynamically switching the input/output buffers probably | |
a1e8d2da JW |
525 | * reduces noise slightly (particularly on input) so we'll |
526 | * do it. However, having both input and output buffers | |
527 | * enabled simultaneously doesn't seem to be problematic if | |
528 | * this turns out to be necessary in the future. | |
cdcd9268 JW |
529 | */ |
530 | if (val <= 2) { | |
47fd830a TI |
531 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
532 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
533 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0, | |
534 | HDA_AMP_MUTE, 0); | |
cdcd9268 | 535 | } else { |
47fd830a TI |
536 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0, |
537 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
538 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, | |
539 | HDA_AMP_MUTE, 0); | |
cdcd9268 JW |
540 | } |
541 | } | |
a9430dd8 JW |
542 | return change; |
543 | } | |
544 | ||
4c5186ed | 545 | #define ALC_PIN_MODE(xname, nid, dir) \ |
a9430dd8 | 546 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ |
4c5186ed JW |
547 | .info = alc_pin_mode_info, \ |
548 | .get = alc_pin_mode_get, \ | |
549 | .put = alc_pin_mode_put, \ | |
550 | .private_value = nid | (dir<<16) } | |
df694daa | 551 | |
5c8f858d JW |
552 | /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged |
553 | * together using a mask with more than one bit set. This control is | |
554 | * currently used only by the ALC260 test model. At this stage they are not | |
555 | * needed for any "production" models. | |
556 | */ | |
557 | #ifdef CONFIG_SND_DEBUG | |
a5ce8890 | 558 | #define alc_gpio_data_info snd_ctl_boolean_mono_info |
f12ab1e0 | 559 | |
9c7f852e TI |
560 | static int alc_gpio_data_get(struct snd_kcontrol *kcontrol, |
561 | struct snd_ctl_elem_value *ucontrol) | |
5c8f858d JW |
562 | { |
563 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
564 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
565 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
566 | long *valp = ucontrol->value.integer.value; | |
9c7f852e TI |
567 | unsigned int val = snd_hda_codec_read(codec, nid, 0, |
568 | AC_VERB_GET_GPIO_DATA, 0x00); | |
5c8f858d JW |
569 | |
570 | *valp = (val & mask) != 0; | |
571 | return 0; | |
572 | } | |
9c7f852e TI |
573 | static int alc_gpio_data_put(struct snd_kcontrol *kcontrol, |
574 | struct snd_ctl_elem_value *ucontrol) | |
5c8f858d JW |
575 | { |
576 | signed int change; | |
577 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
578 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
579 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
580 | long val = *ucontrol->value.integer.value; | |
9c7f852e TI |
581 | unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0, |
582 | AC_VERB_GET_GPIO_DATA, | |
583 | 0x00); | |
5c8f858d JW |
584 | |
585 | /* Set/unset the masked GPIO bit(s) as needed */ | |
9c7f852e TI |
586 | change = (val == 0 ? 0 : mask) != (gpio_data & mask); |
587 | if (val == 0) | |
5c8f858d JW |
588 | gpio_data &= ~mask; |
589 | else | |
590 | gpio_data |= mask; | |
82beb8fd TI |
591 | snd_hda_codec_write_cache(codec, nid, 0, |
592 | AC_VERB_SET_GPIO_DATA, gpio_data); | |
5c8f858d JW |
593 | |
594 | return change; | |
595 | } | |
596 | #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \ | |
597 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
598 | .info = alc_gpio_data_info, \ | |
599 | .get = alc_gpio_data_get, \ | |
600 | .put = alc_gpio_data_put, \ | |
601 | .private_value = nid | (mask<<16) } | |
602 | #endif /* CONFIG_SND_DEBUG */ | |
603 | ||
92621f13 JW |
604 | /* A switch control to allow the enabling of the digital IO pins on the |
605 | * ALC260. This is incredibly simplistic; the intention of this control is | |
606 | * to provide something in the test model allowing digital outputs to be | |
607 | * identified if present. If models are found which can utilise these | |
608 | * outputs a more complete mixer control can be devised for those models if | |
609 | * necessary. | |
610 | */ | |
611 | #ifdef CONFIG_SND_DEBUG | |
a5ce8890 | 612 | #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info |
f12ab1e0 | 613 | |
9c7f852e TI |
614 | static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol, |
615 | struct snd_ctl_elem_value *ucontrol) | |
92621f13 JW |
616 | { |
617 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
618 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
619 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
620 | long *valp = ucontrol->value.integer.value; | |
9c7f852e | 621 | unsigned int val = snd_hda_codec_read(codec, nid, 0, |
3982d17e | 622 | AC_VERB_GET_DIGI_CONVERT_1, 0x00); |
92621f13 JW |
623 | |
624 | *valp = (val & mask) != 0; | |
625 | return 0; | |
626 | } | |
9c7f852e TI |
627 | static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol, |
628 | struct snd_ctl_elem_value *ucontrol) | |
92621f13 JW |
629 | { |
630 | signed int change; | |
631 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
632 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
633 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
634 | long val = *ucontrol->value.integer.value; | |
9c7f852e | 635 | unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0, |
3982d17e | 636 | AC_VERB_GET_DIGI_CONVERT_1, |
9c7f852e | 637 | 0x00); |
92621f13 JW |
638 | |
639 | /* Set/unset the masked control bit(s) as needed */ | |
9c7f852e | 640 | change = (val == 0 ? 0 : mask) != (ctrl_data & mask); |
92621f13 JW |
641 | if (val==0) |
642 | ctrl_data &= ~mask; | |
643 | else | |
644 | ctrl_data |= mask; | |
82beb8fd TI |
645 | snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, |
646 | ctrl_data); | |
92621f13 JW |
647 | |
648 | return change; | |
649 | } | |
650 | #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \ | |
651 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
652 | .info = alc_spdif_ctrl_info, \ | |
653 | .get = alc_spdif_ctrl_get, \ | |
654 | .put = alc_spdif_ctrl_put, \ | |
655 | .private_value = nid | (mask<<16) } | |
656 | #endif /* CONFIG_SND_DEBUG */ | |
657 | ||
f8225f6d JW |
658 | /* A switch control to allow the enabling EAPD digital outputs on the ALC26x. |
659 | * Again, this is only used in the ALC26x test models to help identify when | |
660 | * the EAPD line must be asserted for features to work. | |
661 | */ | |
662 | #ifdef CONFIG_SND_DEBUG | |
663 | #define alc_eapd_ctrl_info snd_ctl_boolean_mono_info | |
664 | ||
665 | static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol, | |
666 | struct snd_ctl_elem_value *ucontrol) | |
667 | { | |
668 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
669 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
670 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
671 | long *valp = ucontrol->value.integer.value; | |
672 | unsigned int val = snd_hda_codec_read(codec, nid, 0, | |
673 | AC_VERB_GET_EAPD_BTLENABLE, 0x00); | |
674 | ||
675 | *valp = (val & mask) != 0; | |
676 | return 0; | |
677 | } | |
678 | ||
679 | static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol, | |
680 | struct snd_ctl_elem_value *ucontrol) | |
681 | { | |
682 | int change; | |
683 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
684 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
685 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
686 | long val = *ucontrol->value.integer.value; | |
687 | unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0, | |
688 | AC_VERB_GET_EAPD_BTLENABLE, | |
689 | 0x00); | |
690 | ||
691 | /* Set/unset the masked control bit(s) as needed */ | |
692 | change = (!val ? 0 : mask) != (ctrl_data & mask); | |
693 | if (!val) | |
694 | ctrl_data &= ~mask; | |
695 | else | |
696 | ctrl_data |= mask; | |
697 | snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, | |
698 | ctrl_data); | |
699 | ||
700 | return change; | |
701 | } | |
702 | ||
703 | #define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \ | |
704 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
705 | .info = alc_eapd_ctrl_info, \ | |
706 | .get = alc_eapd_ctrl_get, \ | |
707 | .put = alc_eapd_ctrl_put, \ | |
708 | .private_value = nid | (mask<<16) } | |
709 | #endif /* CONFIG_SND_DEBUG */ | |
710 | ||
df694daa KY |
711 | /* |
712 | * set up from the preset table | |
713 | */ | |
9c7f852e TI |
714 | static void setup_preset(struct alc_spec *spec, |
715 | const struct alc_config_preset *preset) | |
df694daa KY |
716 | { |
717 | int i; | |
718 | ||
719 | for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++) | |
720 | spec->mixers[spec->num_mixers++] = preset->mixers[i]; | |
9c7f852e TI |
721 | for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; |
722 | i++) | |
723 | spec->init_verbs[spec->num_init_verbs++] = | |
724 | preset->init_verbs[i]; | |
ea1fb29a | 725 | |
df694daa KY |
726 | spec->channel_mode = preset->channel_mode; |
727 | spec->num_channel_mode = preset->num_channel_mode; | |
4e195a7b | 728 | spec->need_dac_fix = preset->need_dac_fix; |
df694daa KY |
729 | |
730 | spec->multiout.max_channels = spec->channel_mode[0].channels; | |
731 | ||
732 | spec->multiout.num_dacs = preset->num_dacs; | |
733 | spec->multiout.dac_nids = preset->dac_nids; | |
734 | spec->multiout.dig_out_nid = preset->dig_out_nid; | |
735 | spec->multiout.hp_nid = preset->hp_nid; | |
ea1fb29a | 736 | |
a1e8d2da | 737 | spec->num_mux_defs = preset->num_mux_defs; |
f12ab1e0 | 738 | if (!spec->num_mux_defs) |
a1e8d2da | 739 | spec->num_mux_defs = 1; |
df694daa KY |
740 | spec->input_mux = preset->input_mux; |
741 | ||
742 | spec->num_adc_nids = preset->num_adc_nids; | |
743 | spec->adc_nids = preset->adc_nids; | |
e1406348 | 744 | spec->capsrc_nids = preset->capsrc_nids; |
df694daa | 745 | spec->dig_in_nid = preset->dig_in_nid; |
ae6b813a TI |
746 | |
747 | spec->unsol_event = preset->unsol_event; | |
748 | spec->init_hook = preset->init_hook; | |
cb53c626 TI |
749 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
750 | spec->loopback.amplist = preset->loopbacks; | |
751 | #endif | |
df694daa KY |
752 | } |
753 | ||
bc9f98a9 KY |
754 | /* Enable GPIO mask and set output */ |
755 | static struct hda_verb alc_gpio1_init_verbs[] = { | |
756 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
757 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
758 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, | |
759 | { } | |
760 | }; | |
761 | ||
762 | static struct hda_verb alc_gpio2_init_verbs[] = { | |
763 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, | |
764 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, | |
765 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, | |
766 | { } | |
767 | }; | |
768 | ||
bdd148a3 KY |
769 | static struct hda_verb alc_gpio3_init_verbs[] = { |
770 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, | |
771 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | |
772 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | |
773 | { } | |
774 | }; | |
775 | ||
2c3bf9ab TI |
776 | /* |
777 | * Fix hardware PLL issue | |
778 | * On some codecs, the analog PLL gating control must be off while | |
779 | * the default value is 1. | |
780 | */ | |
781 | static void alc_fix_pll(struct hda_codec *codec) | |
782 | { | |
783 | struct alc_spec *spec = codec->spec; | |
784 | unsigned int val; | |
785 | ||
786 | if (!spec->pll_nid) | |
787 | return; | |
788 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, | |
789 | spec->pll_coef_idx); | |
790 | val = snd_hda_codec_read(codec, spec->pll_nid, 0, | |
791 | AC_VERB_GET_PROC_COEF, 0); | |
792 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, | |
793 | spec->pll_coef_idx); | |
794 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF, | |
795 | val & ~(1 << spec->pll_coef_bit)); | |
796 | } | |
797 | ||
798 | static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, | |
799 | unsigned int coef_idx, unsigned int coef_bit) | |
800 | { | |
801 | struct alc_spec *spec = codec->spec; | |
802 | spec->pll_nid = nid; | |
803 | spec->pll_coef_idx = coef_idx; | |
804 | spec->pll_coef_bit = coef_bit; | |
805 | alc_fix_pll(codec); | |
806 | } | |
807 | ||
c9b58006 KY |
808 | static void alc_sku_automute(struct hda_codec *codec) |
809 | { | |
810 | struct alc_spec *spec = codec->spec; | |
c9b58006 KY |
811 | unsigned int present; |
812 | unsigned int hp_nid = spec->autocfg.hp_pins[0]; | |
813 | unsigned int sp_nid = spec->autocfg.speaker_pins[0]; | |
814 | ||
815 | /* need to execute and sync at first */ | |
816 | snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0); | |
817 | present = snd_hda_codec_read(codec, hp_nid, 0, | |
818 | AC_VERB_GET_PIN_SENSE, 0); | |
819 | spec->jack_present = (present & 0x80000000) != 0; | |
f6c7e546 TI |
820 | snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
821 | spec->jack_present ? 0 : PIN_OUT); | |
c9b58006 KY |
822 | } |
823 | ||
824 | /* unsolicited event for HP jack sensing */ | |
825 | static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) | |
826 | { | |
827 | if (codec->vendor_id == 0x10ec0880) | |
828 | res >>= 28; | |
829 | else | |
830 | res >>= 26; | |
831 | if (res != ALC880_HP_EVENT) | |
832 | return; | |
833 | ||
834 | alc_sku_automute(codec); | |
835 | } | |
836 | ||
f9423e7a KY |
837 | /* additional initialization for ALC888 variants */ |
838 | static void alc888_coef_init(struct hda_codec *codec) | |
839 | { | |
840 | unsigned int tmp; | |
841 | ||
842 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0); | |
843 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); | |
844 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); | |
845 | if ((tmp & 0xf0) == 2) | |
846 | /* alc888S-VC */ | |
847 | snd_hda_codec_read(codec, 0x20, 0, | |
848 | AC_VERB_SET_PROC_COEF, 0x830); | |
849 | else | |
850 | /* alc888-VB */ | |
851 | snd_hda_codec_read(codec, 0x20, 0, | |
852 | AC_VERB_SET_PROC_COEF, 0x3030); | |
853 | } | |
854 | ||
bc9f98a9 KY |
855 | /* 32-bit subsystem ID for BIOS loading in HD Audio codec. |
856 | * 31 ~ 16 : Manufacture ID | |
857 | * 15 ~ 8 : SKU ID | |
858 | * 7 ~ 0 : Assembly ID | |
859 | * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36 | |
860 | */ | |
861 | static void alc_subsystem_id(struct hda_codec *codec, | |
862 | unsigned int porta, unsigned int porte, | |
863 | unsigned int portd) | |
864 | { | |
c9b58006 KY |
865 | unsigned int ass, tmp, i; |
866 | unsigned nid; | |
867 | struct alc_spec *spec = codec->spec; | |
bc9f98a9 | 868 | |
c9b58006 KY |
869 | ass = codec->subsystem_id & 0xffff; |
870 | if ((ass != codec->bus->pci->subsystem_device) && (ass & 1)) | |
871 | goto do_sku; | |
872 | ||
ea1fb29a | 873 | /* |
c9b58006 KY |
874 | * 31~30 : port conetcivity |
875 | * 29~21 : reserve | |
876 | * 20 : PCBEEP input | |
877 | * 19~16 : Check sum (15:1) | |
878 | * 15~1 : Custom | |
879 | * 0 : override | |
880 | */ | |
881 | nid = 0x1d; | |
882 | if (codec->vendor_id == 0x10ec0260) | |
883 | nid = 0x17; | |
884 | ass = snd_hda_codec_read(codec, nid, 0, | |
885 | AC_VERB_GET_CONFIG_DEFAULT, 0); | |
886 | if (!(ass & 1) && !(ass & 0x100000)) | |
887 | return; | |
888 | if ((ass >> 30) != 1) /* no physical connection */ | |
bc9f98a9 KY |
889 | return; |
890 | ||
c9b58006 KY |
891 | /* check sum */ |
892 | tmp = 0; | |
893 | for (i = 1; i < 16; i++) { | |
8c427226 | 894 | if ((ass >> i) & 1) |
c9b58006 KY |
895 | tmp++; |
896 | } | |
897 | if (((ass >> 16) & 0xf) != tmp) | |
898 | return; | |
899 | do_sku: | |
900 | /* | |
901 | * 0 : override | |
902 | * 1 : Swap Jack | |
903 | * 2 : 0 --> Desktop, 1 --> Laptop | |
904 | * 3~5 : External Amplifier control | |
905 | * 7~6 : Reserved | |
906 | */ | |
bc9f98a9 KY |
907 | tmp = (ass & 0x38) >> 3; /* external Amp control */ |
908 | switch (tmp) { | |
909 | case 1: | |
910 | snd_hda_sequence_write(codec, alc_gpio1_init_verbs); | |
911 | break; | |
912 | case 3: | |
913 | snd_hda_sequence_write(codec, alc_gpio2_init_verbs); | |
914 | break; | |
bdd148a3 KY |
915 | case 7: |
916 | snd_hda_sequence_write(codec, alc_gpio3_init_verbs); | |
917 | break; | |
c9b58006 | 918 | case 5: /* set EAPD output high */ |
bdd148a3 | 919 | switch (codec->vendor_id) { |
c9b58006 KY |
920 | case 0x10ec0260: |
921 | snd_hda_codec_write(codec, 0x0f, 0, | |
922 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
923 | snd_hda_codec_write(codec, 0x10, 0, | |
924 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
925 | break; | |
926 | case 0x10ec0262: | |
bdd148a3 KY |
927 | case 0x10ec0267: |
928 | case 0x10ec0268: | |
c9b58006 | 929 | case 0x10ec0269: |
f9423e7a KY |
930 | case 0x10ec0660: |
931 | case 0x10ec0662: | |
932 | case 0x10ec0663: | |
c9b58006 | 933 | case 0x10ec0862: |
20a3a05d | 934 | case 0x10ec0889: |
bdd148a3 KY |
935 | snd_hda_codec_write(codec, 0x14, 0, |
936 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
937 | snd_hda_codec_write(codec, 0x15, 0, | |
938 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
c9b58006 | 939 | break; |
bdd148a3 | 940 | } |
c9b58006 KY |
941 | switch (codec->vendor_id) { |
942 | case 0x10ec0260: | |
943 | snd_hda_codec_write(codec, 0x1a, 0, | |
944 | AC_VERB_SET_COEF_INDEX, 7); | |
945 | tmp = snd_hda_codec_read(codec, 0x1a, 0, | |
946 | AC_VERB_GET_PROC_COEF, 0); | |
947 | snd_hda_codec_write(codec, 0x1a, 0, | |
948 | AC_VERB_SET_COEF_INDEX, 7); | |
949 | snd_hda_codec_write(codec, 0x1a, 0, | |
950 | AC_VERB_SET_PROC_COEF, | |
951 | tmp | 0x2010); | |
952 | break; | |
953 | case 0x10ec0262: | |
954 | case 0x10ec0880: | |
955 | case 0x10ec0882: | |
956 | case 0x10ec0883: | |
957 | case 0x10ec0885: | |
20a3a05d | 958 | case 0x10ec0889: |
c9b58006 KY |
959 | snd_hda_codec_write(codec, 0x20, 0, |
960 | AC_VERB_SET_COEF_INDEX, 7); | |
961 | tmp = snd_hda_codec_read(codec, 0x20, 0, | |
962 | AC_VERB_GET_PROC_COEF, 0); | |
963 | snd_hda_codec_write(codec, 0x20, 0, | |
ea1fb29a | 964 | AC_VERB_SET_COEF_INDEX, 7); |
c9b58006 KY |
965 | snd_hda_codec_write(codec, 0x20, 0, |
966 | AC_VERB_SET_PROC_COEF, | |
967 | tmp | 0x2010); | |
968 | break; | |
f9423e7a | 969 | case 0x10ec0888: |
1082c748 | 970 | /*alc888_coef_init(codec);*/ /* called in alc_init() */ |
f9423e7a | 971 | break; |
c9b58006 KY |
972 | case 0x10ec0267: |
973 | case 0x10ec0268: | |
974 | snd_hda_codec_write(codec, 0x20, 0, | |
975 | AC_VERB_SET_COEF_INDEX, 7); | |
976 | tmp = snd_hda_codec_read(codec, 0x20, 0, | |
977 | AC_VERB_GET_PROC_COEF, 0); | |
978 | snd_hda_codec_write(codec, 0x20, 0, | |
ea1fb29a | 979 | AC_VERB_SET_COEF_INDEX, 7); |
c9b58006 KY |
980 | snd_hda_codec_write(codec, 0x20, 0, |
981 | AC_VERB_SET_PROC_COEF, | |
982 | tmp | 0x3000); | |
983 | break; | |
bc9f98a9 | 984 | } |
c9b58006 | 985 | default: |
bc9f98a9 KY |
986 | break; |
987 | } | |
ea1fb29a | 988 | |
8c427226 | 989 | /* is laptop or Desktop and enable the function "Mute internal speaker |
c9b58006 KY |
990 | * when the external headphone out jack is plugged" |
991 | */ | |
8c427226 | 992 | if (!(ass & 0x8000)) |
c9b58006 KY |
993 | return; |
994 | /* | |
995 | * 10~8 : Jack location | |
996 | * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered | |
997 | * 14~13: Resvered | |
998 | * 15 : 1 --> enable the function "Mute internal speaker | |
999 | * when the external headphone out jack is plugged" | |
1000 | */ | |
1001 | if (!spec->autocfg.speaker_pins[0]) { | |
8c427226 | 1002 | if (spec->autocfg.line_out_pins[0]) |
c9b58006 | 1003 | spec->autocfg.speaker_pins[0] = |
8c427226 | 1004 | spec->autocfg.line_out_pins[0]; |
c9b58006 KY |
1005 | else |
1006 | return; | |
1007 | } | |
1008 | ||
1009 | if (!spec->autocfg.hp_pins[0]) { | |
1010 | tmp = (ass >> 11) & 0x3; /* HP to chassis */ | |
1011 | if (tmp == 0) | |
1012 | spec->autocfg.hp_pins[0] = porta; | |
1013 | else if (tmp == 1) | |
1014 | spec->autocfg.hp_pins[0] = porte; | |
1015 | else if (tmp == 2) | |
1016 | spec->autocfg.hp_pins[0] = portd; | |
1017 | else | |
1018 | return; | |
1019 | } | |
1020 | ||
1021 | snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0, | |
1022 | AC_VERB_SET_UNSOLICITED_ENABLE, | |
1023 | AC_USRSP_EN | ALC880_HP_EVENT); | |
ea1fb29a | 1024 | |
c9b58006 | 1025 | spec->unsol_event = alc_sku_unsol_event; |
bc9f98a9 KY |
1026 | } |
1027 | ||
f95474ec TI |
1028 | /* |
1029 | * Fix-up pin default configurations | |
1030 | */ | |
1031 | ||
1032 | struct alc_pincfg { | |
1033 | hda_nid_t nid; | |
1034 | u32 val; | |
1035 | }; | |
1036 | ||
1037 | static void alc_fix_pincfg(struct hda_codec *codec, | |
1038 | const struct snd_pci_quirk *quirk, | |
1039 | const struct alc_pincfg **pinfix) | |
1040 | { | |
1041 | const struct alc_pincfg *cfg; | |
1042 | ||
1043 | quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk); | |
1044 | if (!quirk) | |
1045 | return; | |
1046 | ||
1047 | cfg = pinfix[quirk->value]; | |
1048 | for (; cfg->nid; cfg++) { | |
1049 | int i; | |
1050 | u32 val = cfg->val; | |
1051 | for (i = 0; i < 4; i++) { | |
1052 | snd_hda_codec_write(codec, cfg->nid, 0, | |
1053 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i, | |
1054 | val & 0xff); | |
1055 | val >>= 8; | |
1056 | } | |
1057 | } | |
1058 | } | |
1059 | ||
1da177e4 | 1060 | /* |
e9edcee0 TI |
1061 | * ALC880 3-stack model |
1062 | * | |
1063 | * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e) | |
9c7f852e TI |
1064 | * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, |
1065 | * F-Mic = 0x1b, HP = 0x19 | |
1da177e4 LT |
1066 | */ |
1067 | ||
e9edcee0 TI |
1068 | static hda_nid_t alc880_dac_nids[4] = { |
1069 | /* front, rear, clfe, rear_surr */ | |
1070 | 0x02, 0x05, 0x04, 0x03 | |
1071 | }; | |
1072 | ||
1073 | static hda_nid_t alc880_adc_nids[3] = { | |
1074 | /* ADC0-2 */ | |
1075 | 0x07, 0x08, 0x09, | |
1076 | }; | |
1077 | ||
1078 | /* The datasheet says the node 0x07 is connected from inputs, | |
1079 | * but it shows zero connection in the real implementation on some devices. | |
df694daa | 1080 | * Note: this is a 915GAV bug, fixed on 915GLV |
1da177e4 | 1081 | */ |
e9edcee0 TI |
1082 | static hda_nid_t alc880_adc_nids_alt[2] = { |
1083 | /* ADC1-2 */ | |
1084 | 0x08, 0x09, | |
1085 | }; | |
1086 | ||
1087 | #define ALC880_DIGOUT_NID 0x06 | |
1088 | #define ALC880_DIGIN_NID 0x0a | |
1089 | ||
1090 | static struct hda_input_mux alc880_capture_source = { | |
1091 | .num_items = 4, | |
1092 | .items = { | |
1093 | { "Mic", 0x0 }, | |
1094 | { "Front Mic", 0x3 }, | |
1095 | { "Line", 0x2 }, | |
1096 | { "CD", 0x4 }, | |
1097 | }, | |
1098 | }; | |
1099 | ||
1100 | /* channel source setting (2/6 channel selection for 3-stack) */ | |
1101 | /* 2ch mode */ | |
1102 | static struct hda_verb alc880_threestack_ch2_init[] = { | |
1103 | /* set line-in to input, mute it */ | |
1104 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
1105 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
1106 | /* set mic-in to input vref 80%, mute it */ | |
1107 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
1108 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
1109 | { } /* end */ | |
1110 | }; | |
1111 | ||
1112 | /* 6ch mode */ | |
1113 | static struct hda_verb alc880_threestack_ch6_init[] = { | |
1114 | /* set line-in to output, unmute it */ | |
1115 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1116 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1117 | /* set mic-in to output, unmute it */ | |
1118 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1119 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1120 | { } /* end */ | |
1121 | }; | |
1122 | ||
d2a6d7dc | 1123 | static struct hda_channel_mode alc880_threestack_modes[2] = { |
e9edcee0 TI |
1124 | { 2, alc880_threestack_ch2_init }, |
1125 | { 6, alc880_threestack_ch6_init }, | |
1126 | }; | |
1127 | ||
c8b6bf9b | 1128 | static struct snd_kcontrol_new alc880_three_stack_mixer[] = { |
05acb863 | 1129 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1130 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
05acb863 | 1131 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 1132 | HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT), |
05acb863 TI |
1133 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1134 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1135 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1136 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
1da177e4 LT |
1137 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1138 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1139 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1140 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
1141 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1142 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1143 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT), | |
1144 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT), | |
1145 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
1146 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
e9edcee0 TI |
1147 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT), |
1148 | { | |
1149 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1150 | .name = "Channel Mode", | |
df694daa KY |
1151 | .info = alc_ch_mode_info, |
1152 | .get = alc_ch_mode_get, | |
1153 | .put = alc_ch_mode_put, | |
e9edcee0 TI |
1154 | }, |
1155 | { } /* end */ | |
1156 | }; | |
1157 | ||
1158 | /* capture mixer elements */ | |
c8b6bf9b | 1159 | static struct snd_kcontrol_new alc880_capture_mixer[] = { |
e9edcee0 TI |
1160 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), |
1161 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), | |
1162 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), | |
1163 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), | |
1164 | HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), | |
1165 | HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), | |
1da177e4 LT |
1166 | { |
1167 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1168 | /* The multiple "Capture Source" controls confuse alsamixer | |
1169 | * So call somewhat different.. | |
1da177e4 LT |
1170 | */ |
1171 | /* .name = "Capture Source", */ | |
1172 | .name = "Input Source", | |
e9edcee0 | 1173 | .count = 3, |
1da177e4 LT |
1174 | .info = alc_mux_enum_info, |
1175 | .get = alc_mux_enum_get, | |
1176 | .put = alc_mux_enum_put, | |
1177 | }, | |
1da177e4 LT |
1178 | { } /* end */ |
1179 | }; | |
1180 | ||
e9edcee0 | 1181 | /* capture mixer elements (in case NID 0x07 not available) */ |
c8b6bf9b | 1182 | static struct snd_kcontrol_new alc880_capture_alt_mixer[] = { |
71fe7b82 TI |
1183 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
1184 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
1185 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
1186 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
1da177e4 LT |
1187 | { |
1188 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1189 | /* The multiple "Capture Source" controls confuse alsamixer | |
1190 | * So call somewhat different.. | |
1da177e4 LT |
1191 | */ |
1192 | /* .name = "Capture Source", */ | |
1193 | .name = "Input Source", | |
1194 | .count = 2, | |
1195 | .info = alc_mux_enum_info, | |
1196 | .get = alc_mux_enum_get, | |
1197 | .put = alc_mux_enum_put, | |
1198 | }, | |
1da177e4 LT |
1199 | { } /* end */ |
1200 | }; | |
1201 | ||
e9edcee0 TI |
1202 | |
1203 | ||
1204 | /* | |
1205 | * ALC880 5-stack model | |
1206 | * | |
9c7f852e TI |
1207 | * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), |
1208 | * Side = 0x02 (0xd) | |
e9edcee0 TI |
1209 | * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16 |
1210 | * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19 | |
1211 | */ | |
1212 | ||
1213 | /* additional mixers to alc880_three_stack_mixer */ | |
c8b6bf9b | 1214 | static struct snd_kcontrol_new alc880_five_stack_mixer[] = { |
e9edcee0 | 1215 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1216 | HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT), |
1da177e4 LT |
1217 | { } /* end */ |
1218 | }; | |
1219 | ||
e9edcee0 TI |
1220 | /* channel source setting (6/8 channel selection for 5-stack) */ |
1221 | /* 6ch mode */ | |
1222 | static struct hda_verb alc880_fivestack_ch6_init[] = { | |
1223 | /* set line-in to input, mute it */ | |
1224 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
1225 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
dfc0ff62 TI |
1226 | { } /* end */ |
1227 | }; | |
1228 | ||
e9edcee0 TI |
1229 | /* 8ch mode */ |
1230 | static struct hda_verb alc880_fivestack_ch8_init[] = { | |
1231 | /* set line-in to output, unmute it */ | |
1232 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1233 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1234 | { } /* end */ | |
1235 | }; | |
1236 | ||
d2a6d7dc | 1237 | static struct hda_channel_mode alc880_fivestack_modes[2] = { |
e9edcee0 TI |
1238 | { 6, alc880_fivestack_ch6_init }, |
1239 | { 8, alc880_fivestack_ch8_init }, | |
1240 | }; | |
1241 | ||
1242 | ||
1243 | /* | |
1244 | * ALC880 6-stack model | |
1245 | * | |
9c7f852e TI |
1246 | * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), |
1247 | * Side = 0x05 (0x0f) | |
e9edcee0 TI |
1248 | * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17, |
1249 | * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b | |
1250 | */ | |
1251 | ||
1252 | static hda_nid_t alc880_6st_dac_nids[4] = { | |
1253 | /* front, rear, clfe, rear_surr */ | |
1254 | 0x02, 0x03, 0x04, 0x05 | |
f12ab1e0 | 1255 | }; |
e9edcee0 TI |
1256 | |
1257 | static struct hda_input_mux alc880_6stack_capture_source = { | |
1258 | .num_items = 4, | |
1259 | .items = { | |
1260 | { "Mic", 0x0 }, | |
1261 | { "Front Mic", 0x1 }, | |
1262 | { "Line", 0x2 }, | |
1263 | { "CD", 0x4 }, | |
1264 | }, | |
1265 | }; | |
1266 | ||
1267 | /* fixed 8-channels */ | |
d2a6d7dc | 1268 | static struct hda_channel_mode alc880_sixstack_modes[1] = { |
e9edcee0 TI |
1269 | { 8, NULL }, |
1270 | }; | |
1271 | ||
c8b6bf9b | 1272 | static struct snd_kcontrol_new alc880_six_stack_mixer[] = { |
16ded525 | 1273 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1274 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 1275 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1276 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1277 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1278 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1279 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1280 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
16ded525 | 1281 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 1282 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
16ded525 TI |
1283 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1284 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1285 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1286 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
1287 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1288 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1289 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1290 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1291 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
1292 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
16ded525 TI |
1293 | { |
1294 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1295 | .name = "Channel Mode", | |
df694daa KY |
1296 | .info = alc_ch_mode_info, |
1297 | .get = alc_ch_mode_get, | |
1298 | .put = alc_ch_mode_put, | |
16ded525 TI |
1299 | }, |
1300 | { } /* end */ | |
1301 | }; | |
1302 | ||
e9edcee0 TI |
1303 | |
1304 | /* | |
1305 | * ALC880 W810 model | |
1306 | * | |
1307 | * W810 has rear IO for: | |
1308 | * Front (DAC 02) | |
1309 | * Surround (DAC 03) | |
1310 | * Center/LFE (DAC 04) | |
1311 | * Digital out (06) | |
1312 | * | |
1313 | * The system also has a pair of internal speakers, and a headphone jack. | |
1314 | * These are both connected to Line2 on the codec, hence to DAC 02. | |
ea1fb29a | 1315 | * |
e9edcee0 TI |
1316 | * There is a variable resistor to control the speaker or headphone |
1317 | * volume. This is a hardware-only device without a software API. | |
1318 | * | |
1319 | * Plugging headphones in will disable the internal speakers. This is | |
1320 | * implemented in hardware, not via the driver using jack sense. In | |
1321 | * a similar fashion, plugging into the rear socket marked "front" will | |
1322 | * disable both the speakers and headphones. | |
1323 | * | |
1324 | * For input, there's a microphone jack, and an "audio in" jack. | |
1325 | * These may not do anything useful with this driver yet, because I | |
1326 | * haven't setup any initialization verbs for these yet... | |
1327 | */ | |
1328 | ||
1329 | static hda_nid_t alc880_w810_dac_nids[3] = { | |
1330 | /* front, rear/surround, clfe */ | |
1331 | 0x02, 0x03, 0x04 | |
16ded525 TI |
1332 | }; |
1333 | ||
e9edcee0 | 1334 | /* fixed 6 channels */ |
d2a6d7dc | 1335 | static struct hda_channel_mode alc880_w810_modes[1] = { |
e9edcee0 TI |
1336 | { 6, NULL } |
1337 | }; | |
1338 | ||
1339 | /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */ | |
c8b6bf9b | 1340 | static struct snd_kcontrol_new alc880_w810_base_mixer[] = { |
16ded525 | 1341 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1342 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 1343 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1344 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1345 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1346 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1347 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1348 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
e9edcee0 TI |
1349 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
1350 | { } /* end */ | |
1351 | }; | |
1352 | ||
1353 | ||
1354 | /* | |
1355 | * Z710V model | |
1356 | * | |
1357 | * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d) | |
9c7f852e TI |
1358 | * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), |
1359 | * Line = 0x1a | |
e9edcee0 TI |
1360 | */ |
1361 | ||
1362 | static hda_nid_t alc880_z71v_dac_nids[1] = { | |
1363 | 0x02 | |
1364 | }; | |
1365 | #define ALC880_Z71V_HP_DAC 0x03 | |
1366 | ||
1367 | /* fixed 2 channels */ | |
d2a6d7dc | 1368 | static struct hda_channel_mode alc880_2_jack_modes[1] = { |
e9edcee0 TI |
1369 | { 2, NULL } |
1370 | }; | |
1371 | ||
c8b6bf9b | 1372 | static struct snd_kcontrol_new alc880_z71v_mixer[] = { |
e9edcee0 | 1373 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1374 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
e9edcee0 | 1375 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1376 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1377 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1378 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
16ded525 TI |
1379 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
1380 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
16ded525 TI |
1381 | { } /* end */ |
1382 | }; | |
1383 | ||
e9edcee0 | 1384 | |
e9edcee0 TI |
1385 | /* |
1386 | * ALC880 F1734 model | |
1387 | * | |
1388 | * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d) | |
1389 | * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18 | |
1390 | */ | |
1391 | ||
1392 | static hda_nid_t alc880_f1734_dac_nids[1] = { | |
1393 | 0x03 | |
1394 | }; | |
1395 | #define ALC880_F1734_HP_DAC 0x02 | |
1396 | ||
c8b6bf9b | 1397 | static struct snd_kcontrol_new alc880_f1734_mixer[] = { |
e9edcee0 | 1398 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1399 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), |
2134ea4f TI |
1400 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
1401 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
e9edcee0 TI |
1402 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1403 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
937b4160 TI |
1404 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
1405 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
e9edcee0 TI |
1406 | { } /* end */ |
1407 | }; | |
1408 | ||
937b4160 TI |
1409 | static struct hda_input_mux alc880_f1734_capture_source = { |
1410 | .num_items = 2, | |
1411 | .items = { | |
1412 | { "Mic", 0x1 }, | |
1413 | { "CD", 0x4 }, | |
1414 | }, | |
1415 | }; | |
1416 | ||
e9edcee0 | 1417 | |
e9edcee0 TI |
1418 | /* |
1419 | * ALC880 ASUS model | |
1420 | * | |
1421 | * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) | |
1422 | * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, | |
1423 | * Mic = 0x18, Line = 0x1a | |
1424 | */ | |
1425 | ||
1426 | #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */ | |
1427 | #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */ | |
1428 | ||
c8b6bf9b | 1429 | static struct snd_kcontrol_new alc880_asus_mixer[] = { |
16ded525 | 1430 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1431 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 1432 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1433 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1434 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1435 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1436 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1437 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
16ded525 TI |
1438 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1439 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1440 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1441 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
16ded525 TI |
1442 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
1443 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
16ded525 TI |
1444 | { |
1445 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1446 | .name = "Channel Mode", | |
df694daa KY |
1447 | .info = alc_ch_mode_info, |
1448 | .get = alc_ch_mode_get, | |
1449 | .put = alc_ch_mode_put, | |
16ded525 TI |
1450 | }, |
1451 | { } /* end */ | |
1452 | }; | |
e9edcee0 | 1453 | |
e9edcee0 TI |
1454 | /* |
1455 | * ALC880 ASUS W1V model | |
1456 | * | |
1457 | * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) | |
1458 | * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, | |
1459 | * Mic = 0x18, Line = 0x1a, Line2 = 0x1b | |
1460 | */ | |
1461 | ||
1462 | /* additional mixers to alc880_asus_mixer */ | |
c8b6bf9b | 1463 | static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = { |
e9edcee0 TI |
1464 | HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT), |
1465 | HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT), | |
1466 | { } /* end */ | |
1467 | }; | |
1468 | ||
3c10a9d9 | 1469 | /* additional mixers to alc880_asus_mixer */ |
c8b6bf9b | 1470 | static struct snd_kcontrol_new alc880_pcbeep_mixer[] = { |
3c10a9d9 TI |
1471 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), |
1472 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
1473 | { } /* end */ | |
1474 | }; | |
e9edcee0 | 1475 | |
df694daa KY |
1476 | /* TCL S700 */ |
1477 | static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = { | |
1478 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1479 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
1480 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
1481 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT), | |
1482 | HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT), | |
1483 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT), | |
1484 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT), | |
1485 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
1486 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
1487 | { | |
1488 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1489 | /* The multiple "Capture Source" controls confuse alsamixer | |
1490 | * So call somewhat different.. | |
df694daa KY |
1491 | */ |
1492 | /* .name = "Capture Source", */ | |
1493 | .name = "Input Source", | |
1494 | .count = 1, | |
1495 | .info = alc_mux_enum_info, | |
1496 | .get = alc_mux_enum_get, | |
1497 | .put = alc_mux_enum_put, | |
1498 | }, | |
1499 | { } /* end */ | |
1500 | }; | |
1501 | ||
ccc656ce KY |
1502 | /* Uniwill */ |
1503 | static struct snd_kcontrol_new alc880_uniwill_mixer[] = { | |
2134ea4f TI |
1504 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
1505 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1506 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1507 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
ccc656ce KY |
1508 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1509 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
1510 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
1511 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
1512 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
1513 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1514 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1515 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
1516 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1517 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1518 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1519 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1520 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
1521 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
1522 | { | |
1523 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1524 | .name = "Channel Mode", | |
1525 | .info = alc_ch_mode_info, | |
1526 | .get = alc_ch_mode_get, | |
1527 | .put = alc_ch_mode_put, | |
1528 | }, | |
1529 | { } /* end */ | |
1530 | }; | |
1531 | ||
2cf9f0fc TD |
1532 | static struct snd_kcontrol_new alc880_fujitsu_mixer[] = { |
1533 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1534 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1535 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1536 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
1537 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
1538 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1539 | HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1540 | HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1541 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1542 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1543 | { } /* end */ | |
1544 | }; | |
1545 | ||
ccc656ce | 1546 | static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = { |
2134ea4f TI |
1547 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
1548 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1549 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1550 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
ccc656ce KY |
1551 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
1552 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1553 | { } /* end */ | |
1554 | }; | |
1555 | ||
2134ea4f TI |
1556 | /* |
1557 | * virtual master controls | |
1558 | */ | |
1559 | ||
1560 | /* | |
1561 | * slave controls for virtual master | |
1562 | */ | |
1563 | static const char *alc_slave_vols[] = { | |
1564 | "Front Playback Volume", | |
1565 | "Surround Playback Volume", | |
1566 | "Center Playback Volume", | |
1567 | "LFE Playback Volume", | |
1568 | "Side Playback Volume", | |
1569 | "Headphone Playback Volume", | |
1570 | "Speaker Playback Volume", | |
1571 | "Mono Playback Volume", | |
2134ea4f TI |
1572 | "Line-Out Playback Volume", |
1573 | NULL, | |
1574 | }; | |
1575 | ||
1576 | static const char *alc_slave_sws[] = { | |
1577 | "Front Playback Switch", | |
1578 | "Surround Playback Switch", | |
1579 | "Center Playback Switch", | |
1580 | "LFE Playback Switch", | |
1581 | "Side Playback Switch", | |
1582 | "Headphone Playback Switch", | |
1583 | "Speaker Playback Switch", | |
1584 | "Mono Playback Switch", | |
edb54a55 | 1585 | "IEC958 Playback Switch", |
2134ea4f TI |
1586 | NULL, |
1587 | }; | |
1588 | ||
1da177e4 | 1589 | /* |
e9edcee0 | 1590 | * build control elements |
1da177e4 LT |
1591 | */ |
1592 | static int alc_build_controls(struct hda_codec *codec) | |
1593 | { | |
1594 | struct alc_spec *spec = codec->spec; | |
1595 | int err; | |
1596 | int i; | |
1597 | ||
1598 | for (i = 0; i < spec->num_mixers; i++) { | |
1599 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); | |
1600 | if (err < 0) | |
1601 | return err; | |
1602 | } | |
1603 | ||
1604 | if (spec->multiout.dig_out_nid) { | |
9c7f852e TI |
1605 | err = snd_hda_create_spdif_out_ctls(codec, |
1606 | spec->multiout.dig_out_nid); | |
1da177e4 LT |
1607 | if (err < 0) |
1608 | return err; | |
9a08160b TI |
1609 | err = snd_hda_create_spdif_share_sw(codec, |
1610 | &spec->multiout); | |
1611 | if (err < 0) | |
1612 | return err; | |
1613 | spec->multiout.share_spdif = 1; | |
1da177e4 LT |
1614 | } |
1615 | if (spec->dig_in_nid) { | |
1616 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); | |
1617 | if (err < 0) | |
1618 | return err; | |
1619 | } | |
2134ea4f TI |
1620 | |
1621 | /* if we have no master control, let's create it */ | |
1622 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { | |
1c82ed1b | 1623 | unsigned int vmaster_tlv[4]; |
2134ea4f | 1624 | snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, |
1c82ed1b | 1625 | HDA_OUTPUT, vmaster_tlv); |
2134ea4f | 1626 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
1c82ed1b | 1627 | vmaster_tlv, alc_slave_vols); |
2134ea4f TI |
1628 | if (err < 0) |
1629 | return err; | |
1630 | } | |
1631 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { | |
1632 | err = snd_hda_add_vmaster(codec, "Master Playback Switch", | |
1633 | NULL, alc_slave_sws); | |
1634 | if (err < 0) | |
1635 | return err; | |
1636 | } | |
1637 | ||
1da177e4 LT |
1638 | return 0; |
1639 | } | |
1640 | ||
e9edcee0 | 1641 | |
1da177e4 LT |
1642 | /* |
1643 | * initialize the codec volumes, etc | |
1644 | */ | |
1645 | ||
e9edcee0 TI |
1646 | /* |
1647 | * generic initialization of ADC, input mixers and output mixers | |
1648 | */ | |
1649 | static struct hda_verb alc880_volume_init_verbs[] = { | |
1650 | /* | |
1651 | * Unmute ADC0-2 and set the default input to mic-in | |
1652 | */ | |
71fe7b82 | 1653 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 1654 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
71fe7b82 | 1655 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 1656 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
71fe7b82 | 1657 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 1658 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1da177e4 | 1659 | |
e9edcee0 TI |
1660 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
1661 | * mixer widget | |
9c7f852e TI |
1662 | * Note: PASD motherboards uses the Line In 2 as the input for front |
1663 | * panel mic (mic 2) | |
1da177e4 | 1664 | */ |
e9edcee0 | 1665 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ |
cb53c626 TI |
1666 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1667 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1668 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
1669 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
1670 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1671 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
1672 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
1da177e4 | 1673 | |
e9edcee0 TI |
1674 | /* |
1675 | * Set up output mixers (0x0c - 0x0f) | |
1da177e4 | 1676 | */ |
e9edcee0 TI |
1677 | /* set vol=0 to output mixers */ |
1678 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1679 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1680 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1681 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1682 | /* set up input amps for analog loopback */ | |
1683 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
05acb863 TI |
1684 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1685 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
1686 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1687 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
1688 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1689 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
1690 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1691 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 LT |
1692 | |
1693 | { } | |
1694 | }; | |
1695 | ||
e9edcee0 TI |
1696 | /* |
1697 | * 3-stack pin configuration: | |
1698 | * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b | |
1699 | */ | |
1700 | static struct hda_verb alc880_pin_3stack_init_verbs[] = { | |
1701 | /* | |
1702 | * preset connection lists of input pins | |
1703 | * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround | |
1704 | */ | |
1705 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
1706 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
1707 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */ | |
1708 | ||
1709 | /* | |
1710 | * Set pin mode and muting | |
1711 | */ | |
1712 | /* set front pin widgets 0x14 for output */ | |
05acb863 | 1713 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
1714 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1715 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
1716 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1717 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1718 | /* Mic2 (as headphone out) for HP output */ | |
1719 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1720 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1da177e4 | 1721 | /* Line In pin widget for input */ |
05acb863 | 1722 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 TI |
1723 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
1724 | /* Line2 (as front mic) pin widget for input and vref at 80% */ | |
1725 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1726 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1da177e4 | 1727 | /* CD pin widget for input */ |
05acb863 | 1728 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 1729 | |
e9edcee0 TI |
1730 | { } |
1731 | }; | |
1da177e4 | 1732 | |
e9edcee0 TI |
1733 | /* |
1734 | * 5-stack pin configuration: | |
1735 | * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19, | |
1736 | * line-in/side = 0x1a, f-mic = 0x1b | |
1737 | */ | |
1738 | static struct hda_verb alc880_pin_5stack_init_verbs[] = { | |
1739 | /* | |
1740 | * preset connection lists of input pins | |
1741 | * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround | |
1da177e4 | 1742 | */ |
e9edcee0 TI |
1743 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
1744 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */ | |
1da177e4 | 1745 | |
e9edcee0 TI |
1746 | /* |
1747 | * Set pin mode and muting | |
1da177e4 | 1748 | */ |
e9edcee0 TI |
1749 | /* set pin widgets 0x14-0x17 for output */ |
1750 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1751 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1752 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1753 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1754 | /* unmute pins for output (no gain on this amp) */ | |
1755 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1756 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1757 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1758 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1759 | ||
1760 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
1761 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1762 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1763 | /* Mic2 (as headphone out) for HP output */ | |
1764 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1765 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1766 | /* Line In pin widget for input */ | |
1767 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1768 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1769 | /* Line2 (as front mic) pin widget for input and vref at 80% */ | |
1770 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1771 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1772 | /* CD pin widget for input */ | |
1773 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1da177e4 LT |
1774 | |
1775 | { } | |
1776 | }; | |
1777 | ||
e9edcee0 TI |
1778 | /* |
1779 | * W810 pin configuration: | |
1780 | * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b | |
1781 | */ | |
1782 | static struct hda_verb alc880_pin_w810_init_verbs[] = { | |
1783 | /* hphone/speaker input selector: front DAC */ | |
1784 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
1da177e4 | 1785 | |
05acb863 | 1786 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1787 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 1788 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1789 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 1790 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1791 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 1792 | |
e9edcee0 | 1793 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
05acb863 | 1794 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
1da177e4 | 1795 | |
1da177e4 LT |
1796 | { } |
1797 | }; | |
1798 | ||
e9edcee0 TI |
1799 | /* |
1800 | * Z71V pin configuration: | |
1801 | * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?) | |
1802 | */ | |
1803 | static struct hda_verb alc880_pin_z71v_init_verbs[] = { | |
05acb863 | 1804 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1805 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 1806 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
e9edcee0 | 1807 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
dfc0ff62 | 1808 | |
16ded525 | 1809 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1810 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
16ded525 | 1811 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1812 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
16ded525 TI |
1813 | |
1814 | { } | |
1815 | }; | |
1816 | ||
e9edcee0 TI |
1817 | /* |
1818 | * 6-stack pin configuration: | |
9c7f852e TI |
1819 | * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, |
1820 | * f-mic = 0x19, line = 0x1a, HP = 0x1b | |
e9edcee0 TI |
1821 | */ |
1822 | static struct hda_verb alc880_pin_6stack_init_verbs[] = { | |
1823 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
1824 | ||
16ded525 | 1825 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1826 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1827 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1828 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1829 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1830 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1831 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
1832 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1833 | ||
16ded525 | 1834 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1835 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 1836 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1837 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 1838 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 | 1839 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 1840 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
e9edcee0 | 1841 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1842 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
ea1fb29a | 1843 | |
e9edcee0 TI |
1844 | { } |
1845 | }; | |
1846 | ||
ccc656ce KY |
1847 | /* |
1848 | * Uniwill pin configuration: | |
1849 | * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19, | |
1850 | * line = 0x1a | |
1851 | */ | |
1852 | static struct hda_verb alc880_uniwill_init_verbs[] = { | |
1853 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
1854 | ||
1855 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1856 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1857 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1858 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1859 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1860 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1861 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1862 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1863 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1864 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1865 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1866 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1867 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1868 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1869 | ||
1870 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1871 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1872 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1873 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1874 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1875 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1876 | /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */ | |
1877 | /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */ | |
1878 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1879 | ||
1880 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
1881 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
1882 | ||
1883 | { } | |
1884 | }; | |
1885 | ||
1886 | /* | |
1887 | * Uniwill P53 | |
ea1fb29a | 1888 | * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19, |
ccc656ce KY |
1889 | */ |
1890 | static struct hda_verb alc880_uniwill_p53_init_verbs[] = { | |
1891 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
1892 | ||
1893 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1894 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1895 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1896 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1897 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1898 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1899 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1900 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1901 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1902 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1903 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1904 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1905 | ||
1906 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1907 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1908 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1909 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1910 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1911 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1912 | ||
1913 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
1914 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT}, | |
1915 | ||
1916 | { } | |
1917 | }; | |
1918 | ||
2cf9f0fc TD |
1919 | static struct hda_verb alc880_beep_init_verbs[] = { |
1920 | { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) }, | |
1921 | { } | |
1922 | }; | |
1923 | ||
ccc656ce | 1924 | /* toggle speaker-output according to the hp-jack state */ |
458a4fab | 1925 | static void alc880_uniwill_hp_automute(struct hda_codec *codec) |
ccc656ce KY |
1926 | { |
1927 | unsigned int present; | |
f12ab1e0 | 1928 | unsigned char bits; |
ccc656ce KY |
1929 | |
1930 | present = snd_hda_codec_read(codec, 0x14, 0, | |
1931 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
1932 | bits = present ? HDA_AMP_MUTE : 0; |
1933 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
1934 | HDA_AMP_MUTE, bits); | |
1935 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
1936 | HDA_AMP_MUTE, bits); | |
458a4fab TI |
1937 | } |
1938 | ||
1939 | /* auto-toggle front mic */ | |
1940 | static void alc880_uniwill_mic_automute(struct hda_codec *codec) | |
1941 | { | |
1942 | unsigned int present; | |
1943 | unsigned char bits; | |
ccc656ce KY |
1944 | |
1945 | present = snd_hda_codec_read(codec, 0x18, 0, | |
1946 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
1947 | bits = present ? HDA_AMP_MUTE : 0; |
1948 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); | |
458a4fab TI |
1949 | } |
1950 | ||
1951 | static void alc880_uniwill_automute(struct hda_codec *codec) | |
1952 | { | |
1953 | alc880_uniwill_hp_automute(codec); | |
1954 | alc880_uniwill_mic_automute(codec); | |
ccc656ce KY |
1955 | } |
1956 | ||
1957 | static void alc880_uniwill_unsol_event(struct hda_codec *codec, | |
1958 | unsigned int res) | |
1959 | { | |
1960 | /* Looks like the unsol event is incompatible with the standard | |
1961 | * definition. 4bit tag is placed at 28 bit! | |
1962 | */ | |
458a4fab TI |
1963 | switch (res >> 28) { |
1964 | case ALC880_HP_EVENT: | |
1965 | alc880_uniwill_hp_automute(codec); | |
1966 | break; | |
1967 | case ALC880_MIC_EVENT: | |
1968 | alc880_uniwill_mic_automute(codec); | |
1969 | break; | |
1970 | } | |
ccc656ce KY |
1971 | } |
1972 | ||
1973 | static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec) | |
1974 | { | |
1975 | unsigned int present; | |
f12ab1e0 | 1976 | unsigned char bits; |
ccc656ce KY |
1977 | |
1978 | present = snd_hda_codec_read(codec, 0x14, 0, | |
1979 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a | 1980 | bits = present ? HDA_AMP_MUTE : 0; |
64654c2f | 1981 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits); |
ccc656ce KY |
1982 | } |
1983 | ||
1984 | static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) | |
1985 | { | |
1986 | unsigned int present; | |
ea1fb29a | 1987 | |
ccc656ce | 1988 | present = snd_hda_codec_read(codec, 0x21, 0, |
47fd830a TI |
1989 | AC_VERB_GET_VOLUME_KNOB_CONTROL, 0); |
1990 | present &= HDA_AMP_VOLMASK; | |
1991 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, | |
1992 | HDA_AMP_VOLMASK, present); | |
1993 | snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0, | |
1994 | HDA_AMP_VOLMASK, present); | |
ccc656ce | 1995 | } |
47fd830a | 1996 | |
ccc656ce KY |
1997 | static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec, |
1998 | unsigned int res) | |
1999 | { | |
2000 | /* Looks like the unsol event is incompatible with the standard | |
2001 | * definition. 4bit tag is placed at 28 bit! | |
2002 | */ | |
2003 | if ((res >> 28) == ALC880_HP_EVENT) | |
2004 | alc880_uniwill_p53_hp_automute(codec); | |
f12ab1e0 | 2005 | if ((res >> 28) == ALC880_DCVOL_EVENT) |
ccc656ce KY |
2006 | alc880_uniwill_p53_dcvol_automute(codec); |
2007 | } | |
2008 | ||
e9edcee0 TI |
2009 | /* |
2010 | * F1734 pin configuration: | |
2011 | * HP = 0x14, speaker-out = 0x15, mic = 0x18 | |
2012 | */ | |
2013 | static struct hda_verb alc880_pin_f1734_init_verbs[] = { | |
ee7a9c7c | 2014 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x01}, |
16ded525 TI |
2015 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, |
2016 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
2017 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
2018 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
2019 | ||
e9edcee0 | 2020 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
16ded525 | 2021 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
e9edcee0 | 2022 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
16ded525 | 2023 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2024 | |
e9edcee0 TI |
2025 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
2026 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
ee7a9c7c | 2027 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, |
e9edcee0 | 2028 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 2029 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2030 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2031 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2032 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2033 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
dfc0ff62 | 2034 | |
937b4160 TI |
2035 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT}, |
2036 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT}, | |
2037 | ||
dfc0ff62 TI |
2038 | { } |
2039 | }; | |
2040 | ||
e9edcee0 TI |
2041 | /* |
2042 | * ASUS pin configuration: | |
2043 | * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a | |
2044 | */ | |
2045 | static struct hda_verb alc880_pin_asus_init_verbs[] = { | |
16ded525 TI |
2046 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, |
2047 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
2048 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
2049 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
2050 | ||
2051 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
e9edcee0 | 2052 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2053 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2054 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2055 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2056 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2057 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
2058 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
2059 | ||
2060 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2061 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2062 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2063 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2064 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2065 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
16ded525 | 2066 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2067 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2068 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
ea1fb29a | 2069 | |
e9edcee0 TI |
2070 | { } |
2071 | }; | |
16ded525 | 2072 | |
e9edcee0 | 2073 | /* Enable GPIO mask and set output */ |
bc9f98a9 KY |
2074 | #define alc880_gpio1_init_verbs alc_gpio1_init_verbs |
2075 | #define alc880_gpio2_init_verbs alc_gpio2_init_verbs | |
df694daa KY |
2076 | |
2077 | /* Clevo m520g init */ | |
2078 | static struct hda_verb alc880_pin_clevo_init_verbs[] = { | |
2079 | /* headphone output */ | |
2080 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
2081 | /* line-out */ | |
2082 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2083 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2084 | /* Line-in */ | |
2085 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2086 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2087 | /* CD */ | |
2088 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2089 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2090 | /* Mic1 (rear panel) */ | |
2091 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2092 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2093 | /* Mic2 (front panel) */ | |
2094 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2095 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2096 | /* headphone */ | |
2097 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2098 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2099 | /* change to EAPD mode */ | |
2100 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
2101 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, | |
2102 | ||
2103 | { } | |
16ded525 TI |
2104 | }; |
2105 | ||
df694daa | 2106 | static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = { |
4b146cb0 TI |
2107 | /* change to EAPD mode */ |
2108 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
2109 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, | |
2110 | ||
df694daa KY |
2111 | /* Headphone output */ |
2112 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2113 | /* Front output*/ | |
2114 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2115 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
2116 | ||
2117 | /* Line In pin widget for input */ | |
2118 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2119 | /* CD pin widget for input */ | |
2120 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2121 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
2122 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2123 | ||
2124 | /* change to EAPD mode */ | |
2125 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
2126 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
2127 | ||
2128 | { } | |
2129 | }; | |
16ded525 | 2130 | |
e9edcee0 | 2131 | /* |
ae6b813a TI |
2132 | * LG m1 express dual |
2133 | * | |
2134 | * Pin assignment: | |
2135 | * Rear Line-In/Out (blue): 0x14 | |
2136 | * Build-in Mic-In: 0x15 | |
2137 | * Speaker-out: 0x17 | |
2138 | * HP-Out (green): 0x1b | |
2139 | * Mic-In/Out (red): 0x19 | |
2140 | * SPDIF-Out: 0x1e | |
2141 | */ | |
2142 | ||
2143 | /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */ | |
2144 | static hda_nid_t alc880_lg_dac_nids[3] = { | |
2145 | 0x05, 0x02, 0x03 | |
2146 | }; | |
2147 | ||
2148 | /* seems analog CD is not working */ | |
2149 | static struct hda_input_mux alc880_lg_capture_source = { | |
2150 | .num_items = 3, | |
2151 | .items = { | |
2152 | { "Mic", 0x1 }, | |
2153 | { "Line", 0x5 }, | |
2154 | { "Internal Mic", 0x6 }, | |
2155 | }, | |
2156 | }; | |
2157 | ||
2158 | /* 2,4,6 channel modes */ | |
2159 | static struct hda_verb alc880_lg_ch2_init[] = { | |
2160 | /* set line-in and mic-in to input */ | |
2161 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
2162 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
2163 | { } | |
2164 | }; | |
2165 | ||
2166 | static struct hda_verb alc880_lg_ch4_init[] = { | |
2167 | /* set line-in to out and mic-in to input */ | |
2168 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
2169 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
2170 | { } | |
2171 | }; | |
2172 | ||
2173 | static struct hda_verb alc880_lg_ch6_init[] = { | |
2174 | /* set line-in and mic-in to output */ | |
2175 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
2176 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
2177 | { } | |
2178 | }; | |
2179 | ||
2180 | static struct hda_channel_mode alc880_lg_ch_modes[3] = { | |
2181 | { 2, alc880_lg_ch2_init }, | |
2182 | { 4, alc880_lg_ch4_init }, | |
2183 | { 6, alc880_lg_ch6_init }, | |
2184 | }; | |
2185 | ||
2186 | static struct snd_kcontrol_new alc880_lg_mixer[] = { | |
2134ea4f TI |
2187 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
2188 | HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT), | |
ae6b813a TI |
2189 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
2190 | HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT), | |
2191 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), | |
2192 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT), | |
2193 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT), | |
2194 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), | |
2195 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
2196 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
2197 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT), | |
2198 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT), | |
2199 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT), | |
2200 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT), | |
2201 | { | |
2202 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2203 | .name = "Channel Mode", | |
2204 | .info = alc_ch_mode_info, | |
2205 | .get = alc_ch_mode_get, | |
2206 | .put = alc_ch_mode_put, | |
2207 | }, | |
2208 | { } /* end */ | |
2209 | }; | |
2210 | ||
2211 | static struct hda_verb alc880_lg_init_verbs[] = { | |
2212 | /* set capture source to mic-in */ | |
2213 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2214 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2215 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2216 | /* mute all amp mixer inputs */ | |
2217 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)}, | |
cb53c626 TI |
2218 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, |
2219 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
ae6b813a TI |
2220 | /* line-in to input */ |
2221 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2222 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2223 | /* built-in mic */ | |
2224 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2225 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2226 | /* speaker-out */ | |
2227 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2228 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2229 | /* mic-in to input */ | |
2230 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
2231 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2232 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2233 | /* HP-out */ | |
2234 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
2235 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2236 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2237 | /* jack sense */ | |
2238 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, | |
2239 | { } | |
2240 | }; | |
2241 | ||
2242 | /* toggle speaker-output according to the hp-jack state */ | |
2243 | static void alc880_lg_automute(struct hda_codec *codec) | |
2244 | { | |
2245 | unsigned int present; | |
f12ab1e0 | 2246 | unsigned char bits; |
ae6b813a TI |
2247 | |
2248 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
2249 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
2250 | bits = present ? HDA_AMP_MUTE : 0; |
2251 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
2252 | HDA_AMP_MUTE, bits); | |
ae6b813a TI |
2253 | } |
2254 | ||
2255 | static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res) | |
2256 | { | |
2257 | /* Looks like the unsol event is incompatible with the standard | |
2258 | * definition. 4bit tag is placed at 28 bit! | |
2259 | */ | |
2260 | if ((res >> 28) == 0x01) | |
2261 | alc880_lg_automute(codec); | |
2262 | } | |
2263 | ||
d681518a TI |
2264 | /* |
2265 | * LG LW20 | |
2266 | * | |
2267 | * Pin assignment: | |
2268 | * Speaker-out: 0x14 | |
2269 | * Mic-In: 0x18 | |
e4f41da9 CM |
2270 | * Built-in Mic-In: 0x19 |
2271 | * Line-In: 0x1b | |
2272 | * HP-Out: 0x1a | |
d681518a TI |
2273 | * SPDIF-Out: 0x1e |
2274 | */ | |
2275 | ||
d681518a | 2276 | static struct hda_input_mux alc880_lg_lw_capture_source = { |
e4f41da9 | 2277 | .num_items = 3, |
d681518a TI |
2278 | .items = { |
2279 | { "Mic", 0x0 }, | |
2280 | { "Internal Mic", 0x1 }, | |
e4f41da9 | 2281 | { "Line In", 0x2 }, |
d681518a TI |
2282 | }, |
2283 | }; | |
2284 | ||
0a8c5da3 CM |
2285 | #define alc880_lg_lw_modes alc880_threestack_modes |
2286 | ||
d681518a | 2287 | static struct snd_kcontrol_new alc880_lg_lw_mixer[] = { |
0a8c5da3 CM |
2288 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
2289 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
2290 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
2291 | HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT), | |
2292 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
2293 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
2294 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
2295 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
2296 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
2297 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
d681518a TI |
2298 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
2299 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2300 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
2301 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
0a8c5da3 CM |
2302 | { |
2303 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2304 | .name = "Channel Mode", | |
2305 | .info = alc_ch_mode_info, | |
2306 | .get = alc_ch_mode_get, | |
2307 | .put = alc_ch_mode_put, | |
2308 | }, | |
d681518a TI |
2309 | { } /* end */ |
2310 | }; | |
2311 | ||
2312 | static struct hda_verb alc880_lg_lw_init_verbs[] = { | |
0a8c5da3 CM |
2313 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
2314 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
2315 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */ | |
2316 | ||
d681518a TI |
2317 | /* set capture source to mic-in */ |
2318 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2319 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2320 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
cb53c626 | 2321 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, |
d681518a TI |
2322 | /* speaker-out */ |
2323 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2324 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2325 | /* HP-out */ | |
d681518a TI |
2326 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
2327 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2328 | /* mic-in to input */ | |
2329 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2330 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2331 | /* built-in mic */ | |
2332 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2333 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2334 | /* jack sense */ | |
2335 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, | |
2336 | { } | |
2337 | }; | |
2338 | ||
2339 | /* toggle speaker-output according to the hp-jack state */ | |
2340 | static void alc880_lg_lw_automute(struct hda_codec *codec) | |
2341 | { | |
2342 | unsigned int present; | |
f12ab1e0 | 2343 | unsigned char bits; |
d681518a TI |
2344 | |
2345 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
2346 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
2347 | bits = present ? HDA_AMP_MUTE : 0; |
2348 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
2349 | HDA_AMP_MUTE, bits); | |
d681518a TI |
2350 | } |
2351 | ||
2352 | static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res) | |
2353 | { | |
2354 | /* Looks like the unsol event is incompatible with the standard | |
2355 | * definition. 4bit tag is placed at 28 bit! | |
2356 | */ | |
2357 | if ((res >> 28) == 0x01) | |
2358 | alc880_lg_lw_automute(codec); | |
2359 | } | |
2360 | ||
df99cd33 TI |
2361 | static struct snd_kcontrol_new alc880_medion_rim_mixer[] = { |
2362 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
2363 | HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT), | |
2364 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
2365 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2366 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
2367 | HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
2368 | { } /* end */ | |
2369 | }; | |
2370 | ||
2371 | static struct hda_input_mux alc880_medion_rim_capture_source = { | |
2372 | .num_items = 2, | |
2373 | .items = { | |
2374 | { "Mic", 0x0 }, | |
2375 | { "Internal Mic", 0x1 }, | |
2376 | }, | |
2377 | }; | |
2378 | ||
2379 | static struct hda_verb alc880_medion_rim_init_verbs[] = { | |
2380 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
2381 | ||
2382 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2383 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2384 | ||
2385 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
2386 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2387 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2388 | /* Mic2 (as headphone out) for HP output */ | |
2389 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2390 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2391 | /* Internal Speaker */ | |
2392 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2393 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2394 | ||
2395 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
2396 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, | |
2397 | ||
2398 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
2399 | { } | |
2400 | }; | |
2401 | ||
2402 | /* toggle speaker-output according to the hp-jack state */ | |
2403 | static void alc880_medion_rim_automute(struct hda_codec *codec) | |
2404 | { | |
2405 | unsigned int present; | |
2406 | unsigned char bits; | |
2407 | ||
2408 | present = snd_hda_codec_read(codec, 0x14, 0, | |
2409 | AC_VERB_GET_PIN_SENSE, 0) | |
2410 | & AC_PINSENSE_PRESENCE; | |
2411 | bits = present ? HDA_AMP_MUTE : 0; | |
2412 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
2413 | HDA_AMP_MUTE, bits); | |
2414 | if (present) | |
2415 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0); | |
2416 | else | |
2417 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2); | |
2418 | } | |
2419 | ||
2420 | static void alc880_medion_rim_unsol_event(struct hda_codec *codec, | |
2421 | unsigned int res) | |
2422 | { | |
2423 | /* Looks like the unsol event is incompatible with the standard | |
2424 | * definition. 4bit tag is placed at 28 bit! | |
2425 | */ | |
2426 | if ((res >> 28) == ALC880_HP_EVENT) | |
2427 | alc880_medion_rim_automute(codec); | |
2428 | } | |
2429 | ||
cb53c626 TI |
2430 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
2431 | static struct hda_amp_list alc880_loopbacks[] = { | |
2432 | { 0x0b, HDA_INPUT, 0 }, | |
2433 | { 0x0b, HDA_INPUT, 1 }, | |
2434 | { 0x0b, HDA_INPUT, 2 }, | |
2435 | { 0x0b, HDA_INPUT, 3 }, | |
2436 | { 0x0b, HDA_INPUT, 4 }, | |
2437 | { } /* end */ | |
2438 | }; | |
2439 | ||
2440 | static struct hda_amp_list alc880_lg_loopbacks[] = { | |
2441 | { 0x0b, HDA_INPUT, 1 }, | |
2442 | { 0x0b, HDA_INPUT, 6 }, | |
2443 | { 0x0b, HDA_INPUT, 7 }, | |
2444 | { } /* end */ | |
2445 | }; | |
2446 | #endif | |
2447 | ||
ae6b813a TI |
2448 | /* |
2449 | * Common callbacks | |
e9edcee0 TI |
2450 | */ |
2451 | ||
1da177e4 LT |
2452 | static int alc_init(struct hda_codec *codec) |
2453 | { | |
2454 | struct alc_spec *spec = codec->spec; | |
e9edcee0 TI |
2455 | unsigned int i; |
2456 | ||
2c3bf9ab | 2457 | alc_fix_pll(codec); |
1082c748 TI |
2458 | if (codec->vendor_id == 0x10ec0888) |
2459 | alc888_coef_init(codec); | |
2c3bf9ab | 2460 | |
e9edcee0 TI |
2461 | for (i = 0; i < spec->num_init_verbs; i++) |
2462 | snd_hda_sequence_write(codec, spec->init_verbs[i]); | |
ae6b813a TI |
2463 | |
2464 | if (spec->init_hook) | |
2465 | spec->init_hook(codec); | |
2466 | ||
1da177e4 LT |
2467 | return 0; |
2468 | } | |
2469 | ||
ae6b813a TI |
2470 | static void alc_unsol_event(struct hda_codec *codec, unsigned int res) |
2471 | { | |
2472 | struct alc_spec *spec = codec->spec; | |
2473 | ||
2474 | if (spec->unsol_event) | |
2475 | spec->unsol_event(codec, res); | |
2476 | } | |
2477 | ||
cb53c626 TI |
2478 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
2479 | static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid) | |
2480 | { | |
2481 | struct alc_spec *spec = codec->spec; | |
2482 | return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); | |
2483 | } | |
2484 | #endif | |
2485 | ||
1da177e4 LT |
2486 | /* |
2487 | * Analog playback callbacks | |
2488 | */ | |
2489 | static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo, | |
2490 | struct hda_codec *codec, | |
c8b6bf9b | 2491 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2492 | { |
2493 | struct alc_spec *spec = codec->spec; | |
9a08160b TI |
2494 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
2495 | hinfo); | |
1da177e4 LT |
2496 | } |
2497 | ||
2498 | static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | |
2499 | struct hda_codec *codec, | |
2500 | unsigned int stream_tag, | |
2501 | unsigned int format, | |
c8b6bf9b | 2502 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2503 | { |
2504 | struct alc_spec *spec = codec->spec; | |
9c7f852e TI |
2505 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, |
2506 | stream_tag, format, substream); | |
1da177e4 LT |
2507 | } |
2508 | ||
2509 | static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, | |
2510 | struct hda_codec *codec, | |
c8b6bf9b | 2511 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2512 | { |
2513 | struct alc_spec *spec = codec->spec; | |
2514 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); | |
2515 | } | |
2516 | ||
2517 | /* | |
2518 | * Digital out | |
2519 | */ | |
2520 | static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, | |
2521 | struct hda_codec *codec, | |
c8b6bf9b | 2522 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2523 | { |
2524 | struct alc_spec *spec = codec->spec; | |
2525 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); | |
2526 | } | |
2527 | ||
6b97eb45 TI |
2528 | static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
2529 | struct hda_codec *codec, | |
2530 | unsigned int stream_tag, | |
2531 | unsigned int format, | |
2532 | struct snd_pcm_substream *substream) | |
2533 | { | |
2534 | struct alc_spec *spec = codec->spec; | |
2535 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, | |
2536 | stream_tag, format, substream); | |
2537 | } | |
2538 | ||
1da177e4 LT |
2539 | static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
2540 | struct hda_codec *codec, | |
c8b6bf9b | 2541 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2542 | { |
2543 | struct alc_spec *spec = codec->spec; | |
2544 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); | |
2545 | } | |
2546 | ||
2547 | /* | |
2548 | * Analog capture | |
2549 | */ | |
6330079f | 2550 | static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
1da177e4 LT |
2551 | struct hda_codec *codec, |
2552 | unsigned int stream_tag, | |
2553 | unsigned int format, | |
c8b6bf9b | 2554 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2555 | { |
2556 | struct alc_spec *spec = codec->spec; | |
2557 | ||
6330079f | 2558 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1], |
1da177e4 LT |
2559 | stream_tag, 0, format); |
2560 | return 0; | |
2561 | } | |
2562 | ||
6330079f | 2563 | static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
1da177e4 | 2564 | struct hda_codec *codec, |
c8b6bf9b | 2565 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2566 | { |
2567 | struct alc_spec *spec = codec->spec; | |
2568 | ||
888afa15 TI |
2569 | snd_hda_codec_cleanup_stream(codec, |
2570 | spec->adc_nids[substream->number + 1]); | |
1da177e4 LT |
2571 | return 0; |
2572 | } | |
2573 | ||
2574 | ||
2575 | /* | |
2576 | */ | |
2577 | static struct hda_pcm_stream alc880_pcm_analog_playback = { | |
2578 | .substreams = 1, | |
2579 | .channels_min = 2, | |
2580 | .channels_max = 8, | |
e9edcee0 | 2581 | /* NID is set in alc_build_pcms */ |
1da177e4 LT |
2582 | .ops = { |
2583 | .open = alc880_playback_pcm_open, | |
2584 | .prepare = alc880_playback_pcm_prepare, | |
2585 | .cleanup = alc880_playback_pcm_cleanup | |
2586 | }, | |
2587 | }; | |
2588 | ||
2589 | static struct hda_pcm_stream alc880_pcm_analog_capture = { | |
6330079f TI |
2590 | .substreams = 1, |
2591 | .channels_min = 2, | |
2592 | .channels_max = 2, | |
2593 | /* NID is set in alc_build_pcms */ | |
2594 | }; | |
2595 | ||
2596 | static struct hda_pcm_stream alc880_pcm_analog_alt_playback = { | |
2597 | .substreams = 1, | |
2598 | .channels_min = 2, | |
2599 | .channels_max = 2, | |
2600 | /* NID is set in alc_build_pcms */ | |
2601 | }; | |
2602 | ||
2603 | static struct hda_pcm_stream alc880_pcm_analog_alt_capture = { | |
2604 | .substreams = 2, /* can be overridden */ | |
1da177e4 LT |
2605 | .channels_min = 2, |
2606 | .channels_max = 2, | |
e9edcee0 | 2607 | /* NID is set in alc_build_pcms */ |
1da177e4 | 2608 | .ops = { |
6330079f TI |
2609 | .prepare = alc880_alt_capture_pcm_prepare, |
2610 | .cleanup = alc880_alt_capture_pcm_cleanup | |
1da177e4 LT |
2611 | }, |
2612 | }; | |
2613 | ||
2614 | static struct hda_pcm_stream alc880_pcm_digital_playback = { | |
2615 | .substreams = 1, | |
2616 | .channels_min = 2, | |
2617 | .channels_max = 2, | |
2618 | /* NID is set in alc_build_pcms */ | |
2619 | .ops = { | |
2620 | .open = alc880_dig_playback_pcm_open, | |
6b97eb45 TI |
2621 | .close = alc880_dig_playback_pcm_close, |
2622 | .prepare = alc880_dig_playback_pcm_prepare | |
1da177e4 LT |
2623 | }, |
2624 | }; | |
2625 | ||
2626 | static struct hda_pcm_stream alc880_pcm_digital_capture = { | |
2627 | .substreams = 1, | |
2628 | .channels_min = 2, | |
2629 | .channels_max = 2, | |
2630 | /* NID is set in alc_build_pcms */ | |
2631 | }; | |
2632 | ||
4c5186ed | 2633 | /* Used by alc_build_pcms to flag that a PCM has no playback stream */ |
6330079f | 2634 | static struct hda_pcm_stream alc_pcm_null_stream = { |
4c5186ed JW |
2635 | .substreams = 0, |
2636 | .channels_min = 0, | |
2637 | .channels_max = 0, | |
2638 | }; | |
2639 | ||
1da177e4 LT |
2640 | static int alc_build_pcms(struct hda_codec *codec) |
2641 | { | |
2642 | struct alc_spec *spec = codec->spec; | |
2643 | struct hda_pcm *info = spec->pcm_rec; | |
2644 | int i; | |
2645 | ||
2646 | codec->num_pcms = 1; | |
2647 | codec->pcm_info = info; | |
2648 | ||
2649 | info->name = spec->stream_name_analog; | |
4a471b7d | 2650 | if (spec->stream_analog_playback) { |
da3cec35 TI |
2651 | if (snd_BUG_ON(!spec->multiout.dac_nids)) |
2652 | return -EINVAL; | |
4a471b7d TI |
2653 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback); |
2654 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; | |
2655 | } | |
2656 | if (spec->stream_analog_capture) { | |
da3cec35 TI |
2657 | if (snd_BUG_ON(!spec->adc_nids)) |
2658 | return -EINVAL; | |
4a471b7d TI |
2659 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); |
2660 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; | |
2661 | } | |
2662 | ||
2663 | if (spec->channel_mode) { | |
2664 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; | |
2665 | for (i = 0; i < spec->num_channel_mode; i++) { | |
2666 | if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { | |
2667 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; | |
2668 | } | |
1da177e4 LT |
2669 | } |
2670 | } | |
2671 | ||
e08a007d | 2672 | /* SPDIF for stream index #1 */ |
1da177e4 | 2673 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
e08a007d | 2674 | codec->num_pcms = 2; |
c06134d7 | 2675 | info = spec->pcm_rec + 1; |
1da177e4 | 2676 | info->name = spec->stream_name_digital; |
7ba72ba1 | 2677 | info->pcm_type = HDA_PCM_TYPE_SPDIF; |
4a471b7d TI |
2678 | if (spec->multiout.dig_out_nid && |
2679 | spec->stream_digital_playback) { | |
1da177e4 LT |
2680 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback); |
2681 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; | |
2682 | } | |
4a471b7d TI |
2683 | if (spec->dig_in_nid && |
2684 | spec->stream_digital_capture) { | |
1da177e4 LT |
2685 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture); |
2686 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; | |
2687 | } | |
963f803f TI |
2688 | /* FIXME: do we need this for all Realtek codec models? */ |
2689 | codec->spdif_status_reset = 1; | |
1da177e4 LT |
2690 | } |
2691 | ||
e08a007d TI |
2692 | /* If the use of more than one ADC is requested for the current |
2693 | * model, configure a second analog capture-only PCM. | |
2694 | */ | |
2695 | /* Additional Analaog capture for index #2 */ | |
6330079f TI |
2696 | if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) || |
2697 | (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) { | |
e08a007d | 2698 | codec->num_pcms = 3; |
c06134d7 | 2699 | info = spec->pcm_rec + 2; |
e08a007d | 2700 | info->name = spec->stream_name_analog; |
6330079f TI |
2701 | if (spec->alt_dac_nid) { |
2702 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = | |
2703 | *spec->stream_analog_alt_playback; | |
2704 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = | |
2705 | spec->alt_dac_nid; | |
2706 | } else { | |
2707 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = | |
2708 | alc_pcm_null_stream; | |
2709 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; | |
2710 | } | |
2711 | if (spec->num_adc_nids > 1) { | |
2712 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = | |
2713 | *spec->stream_analog_alt_capture; | |
2714 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = | |
2715 | spec->adc_nids[1]; | |
2716 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = | |
2717 | spec->num_adc_nids - 1; | |
2718 | } else { | |
2719 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = | |
2720 | alc_pcm_null_stream; | |
2721 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0; | |
e08a007d TI |
2722 | } |
2723 | } | |
2724 | ||
1da177e4 LT |
2725 | return 0; |
2726 | } | |
2727 | ||
2728 | static void alc_free(struct hda_codec *codec) | |
2729 | { | |
e9edcee0 TI |
2730 | struct alc_spec *spec = codec->spec; |
2731 | unsigned int i; | |
2732 | ||
f12ab1e0 | 2733 | if (!spec) |
e9edcee0 TI |
2734 | return; |
2735 | ||
2736 | if (spec->kctl_alloc) { | |
2737 | for (i = 0; i < spec->num_kctl_used; i++) | |
2738 | kfree(spec->kctl_alloc[i].name); | |
2739 | kfree(spec->kctl_alloc); | |
2740 | } | |
2741 | kfree(spec); | |
7943a8ab | 2742 | codec->spec = NULL; /* to be sure */ |
1da177e4 LT |
2743 | } |
2744 | ||
2745 | /* | |
2746 | */ | |
2747 | static struct hda_codec_ops alc_patch_ops = { | |
2748 | .build_controls = alc_build_controls, | |
2749 | .build_pcms = alc_build_pcms, | |
2750 | .init = alc_init, | |
2751 | .free = alc_free, | |
ae6b813a | 2752 | .unsol_event = alc_unsol_event, |
cb53c626 TI |
2753 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
2754 | .check_power_status = alc_check_power_status, | |
2755 | #endif | |
1da177e4 LT |
2756 | }; |
2757 | ||
2fa522be TI |
2758 | |
2759 | /* | |
2760 | * Test configuration for debugging | |
2761 | * | |
2762 | * Almost all inputs/outputs are enabled. I/O pins can be configured via | |
2763 | * enum controls. | |
2764 | */ | |
2765 | #ifdef CONFIG_SND_DEBUG | |
2766 | static hda_nid_t alc880_test_dac_nids[4] = { | |
2767 | 0x02, 0x03, 0x04, 0x05 | |
2768 | }; | |
2769 | ||
2770 | static struct hda_input_mux alc880_test_capture_source = { | |
ae6b813a | 2771 | .num_items = 7, |
2fa522be TI |
2772 | .items = { |
2773 | { "In-1", 0x0 }, | |
2774 | { "In-2", 0x1 }, | |
2775 | { "In-3", 0x2 }, | |
2776 | { "In-4", 0x3 }, | |
2777 | { "CD", 0x4 }, | |
ae6b813a TI |
2778 | { "Front", 0x5 }, |
2779 | { "Surround", 0x6 }, | |
2fa522be TI |
2780 | }, |
2781 | }; | |
2782 | ||
d2a6d7dc | 2783 | static struct hda_channel_mode alc880_test_modes[4] = { |
2fa522be | 2784 | { 2, NULL }, |
fd2c326d | 2785 | { 4, NULL }, |
2fa522be | 2786 | { 6, NULL }, |
fd2c326d | 2787 | { 8, NULL }, |
2fa522be TI |
2788 | }; |
2789 | ||
9c7f852e TI |
2790 | static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, |
2791 | struct snd_ctl_elem_info *uinfo) | |
2fa522be TI |
2792 | { |
2793 | static char *texts[] = { | |
2794 | "N/A", "Line Out", "HP Out", | |
2795 | "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%" | |
2796 | }; | |
2797 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
2798 | uinfo->count = 1; | |
2799 | uinfo->value.enumerated.items = 8; | |
2800 | if (uinfo->value.enumerated.item >= 8) | |
2801 | uinfo->value.enumerated.item = 7; | |
2802 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | |
2803 | return 0; | |
2804 | } | |
2805 | ||
9c7f852e TI |
2806 | static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, |
2807 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
2808 | { |
2809 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2810 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
2811 | unsigned int pin_ctl, item = 0; | |
2812 | ||
2813 | pin_ctl = snd_hda_codec_read(codec, nid, 0, | |
2814 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | |
2815 | if (pin_ctl & AC_PINCTL_OUT_EN) { | |
2816 | if (pin_ctl & AC_PINCTL_HP_EN) | |
2817 | item = 2; | |
2818 | else | |
2819 | item = 1; | |
2820 | } else if (pin_ctl & AC_PINCTL_IN_EN) { | |
2821 | switch (pin_ctl & AC_PINCTL_VREFEN) { | |
2822 | case AC_PINCTL_VREF_HIZ: item = 3; break; | |
2823 | case AC_PINCTL_VREF_50: item = 4; break; | |
2824 | case AC_PINCTL_VREF_GRD: item = 5; break; | |
2825 | case AC_PINCTL_VREF_80: item = 6; break; | |
2826 | case AC_PINCTL_VREF_100: item = 7; break; | |
2827 | } | |
2828 | } | |
2829 | ucontrol->value.enumerated.item[0] = item; | |
2830 | return 0; | |
2831 | } | |
2832 | ||
9c7f852e TI |
2833 | static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, |
2834 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
2835 | { |
2836 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2837 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
2838 | static unsigned int ctls[] = { | |
2839 | 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN, | |
2840 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ, | |
2841 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_50, | |
2842 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD, | |
2843 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_80, | |
2844 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_100, | |
2845 | }; | |
2846 | unsigned int old_ctl, new_ctl; | |
2847 | ||
2848 | old_ctl = snd_hda_codec_read(codec, nid, 0, | |
2849 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | |
2850 | new_ctl = ctls[ucontrol->value.enumerated.item[0]]; | |
2851 | if (old_ctl != new_ctl) { | |
82beb8fd TI |
2852 | int val; |
2853 | snd_hda_codec_write_cache(codec, nid, 0, | |
2854 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
2855 | new_ctl); | |
47fd830a TI |
2856 | val = ucontrol->value.enumerated.item[0] >= 3 ? |
2857 | HDA_AMP_MUTE : 0; | |
2858 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, | |
2859 | HDA_AMP_MUTE, val); | |
2fa522be TI |
2860 | return 1; |
2861 | } | |
2862 | return 0; | |
2863 | } | |
2864 | ||
9c7f852e TI |
2865 | static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, |
2866 | struct snd_ctl_elem_info *uinfo) | |
2fa522be TI |
2867 | { |
2868 | static char *texts[] = { | |
2869 | "Front", "Surround", "CLFE", "Side" | |
2870 | }; | |
2871 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
2872 | uinfo->count = 1; | |
2873 | uinfo->value.enumerated.items = 4; | |
2874 | if (uinfo->value.enumerated.item >= 4) | |
2875 | uinfo->value.enumerated.item = 3; | |
2876 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | |
2877 | return 0; | |
2878 | } | |
2879 | ||
9c7f852e TI |
2880 | static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, |
2881 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
2882 | { |
2883 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2884 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
2885 | unsigned int sel; | |
2886 | ||
2887 | sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0); | |
2888 | ucontrol->value.enumerated.item[0] = sel & 3; | |
2889 | return 0; | |
2890 | } | |
2891 | ||
9c7f852e TI |
2892 | static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, |
2893 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
2894 | { |
2895 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2896 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
2897 | unsigned int sel; | |
2898 | ||
2899 | sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3; | |
2900 | if (ucontrol->value.enumerated.item[0] != sel) { | |
2901 | sel = ucontrol->value.enumerated.item[0] & 3; | |
82beb8fd TI |
2902 | snd_hda_codec_write_cache(codec, nid, 0, |
2903 | AC_VERB_SET_CONNECT_SEL, sel); | |
2fa522be TI |
2904 | return 1; |
2905 | } | |
2906 | return 0; | |
2907 | } | |
2908 | ||
2909 | #define PIN_CTL_TEST(xname,nid) { \ | |
2910 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
2911 | .name = xname, \ | |
2912 | .info = alc_test_pin_ctl_info, \ | |
2913 | .get = alc_test_pin_ctl_get, \ | |
2914 | .put = alc_test_pin_ctl_put, \ | |
2915 | .private_value = nid \ | |
2916 | } | |
2917 | ||
2918 | #define PIN_SRC_TEST(xname,nid) { \ | |
2919 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
2920 | .name = xname, \ | |
2921 | .info = alc_test_pin_src_info, \ | |
2922 | .get = alc_test_pin_src_get, \ | |
2923 | .put = alc_test_pin_src_put, \ | |
2924 | .private_value = nid \ | |
2925 | } | |
2926 | ||
c8b6bf9b | 2927 | static struct snd_kcontrol_new alc880_test_mixer[] = { |
05acb863 TI |
2928 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
2929 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
2930 | HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT), | |
2931 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
985be54b TI |
2932 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
2933 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
2934 | HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT), | |
2935 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
2fa522be TI |
2936 | PIN_CTL_TEST("Front Pin Mode", 0x14), |
2937 | PIN_CTL_TEST("Surround Pin Mode", 0x15), | |
2938 | PIN_CTL_TEST("CLFE Pin Mode", 0x16), | |
2939 | PIN_CTL_TEST("Side Pin Mode", 0x17), | |
2940 | PIN_CTL_TEST("In-1 Pin Mode", 0x18), | |
2941 | PIN_CTL_TEST("In-2 Pin Mode", 0x19), | |
2942 | PIN_CTL_TEST("In-3 Pin Mode", 0x1a), | |
2943 | PIN_CTL_TEST("In-4 Pin Mode", 0x1b), | |
2944 | PIN_SRC_TEST("In-1 Pin Source", 0x18), | |
2945 | PIN_SRC_TEST("In-2 Pin Source", 0x19), | |
2946 | PIN_SRC_TEST("In-3 Pin Source", 0x1a), | |
2947 | PIN_SRC_TEST("In-4 Pin Source", 0x1b), | |
2948 | HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
2949 | HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2950 | HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
2951 | HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
2952 | HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT), | |
2953 | HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT), | |
2954 | HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT), | |
2955 | HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT), | |
2956 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT), | |
2957 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT), | |
2fa522be TI |
2958 | { |
2959 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2960 | .name = "Channel Mode", | |
df694daa KY |
2961 | .info = alc_ch_mode_info, |
2962 | .get = alc_ch_mode_get, | |
2963 | .put = alc_ch_mode_put, | |
2fa522be TI |
2964 | }, |
2965 | { } /* end */ | |
2966 | }; | |
2967 | ||
2968 | static struct hda_verb alc880_test_init_verbs[] = { | |
2969 | /* Unmute inputs of 0x0c - 0x0f */ | |
05acb863 TI |
2970 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
2971 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2972 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2973 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2974 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2975 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2976 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2977 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2fa522be | 2978 | /* Vol output for 0x0c-0x0f */ |
05acb863 TI |
2979 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
2980 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2981 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2982 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2fa522be | 2983 | /* Set output pins 0x14-0x17 */ |
05acb863 TI |
2984 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
2985 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2986 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2987 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2fa522be | 2988 | /* Unmute output pins 0x14-0x17 */ |
05acb863 TI |
2989 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
2990 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2991 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2992 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2fa522be | 2993 | /* Set input pins 0x18-0x1c */ |
16ded525 TI |
2994 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
2995 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
05acb863 TI |
2996 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
2997 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2998 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2fa522be | 2999 | /* Mute input pins 0x18-0x1b */ |
05acb863 TI |
3000 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
3001 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
3002 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
3003 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
71fe7b82 | 3004 | /* ADC set up */ |
05acb863 | 3005 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 3006 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 | 3007 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 3008 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 | 3009 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 3010 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
3011 | /* Analog input/passthru */ |
3012 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3013 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3014 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
3015 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
3016 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
2fa522be TI |
3017 | { } |
3018 | }; | |
3019 | #endif | |
3020 | ||
1da177e4 LT |
3021 | /* |
3022 | */ | |
3023 | ||
f5fcc13c TI |
3024 | static const char *alc880_models[ALC880_MODEL_LAST] = { |
3025 | [ALC880_3ST] = "3stack", | |
3026 | [ALC880_TCL_S700] = "tcl", | |
3027 | [ALC880_3ST_DIG] = "3stack-digout", | |
3028 | [ALC880_CLEVO] = "clevo", | |
3029 | [ALC880_5ST] = "5stack", | |
3030 | [ALC880_5ST_DIG] = "5stack-digout", | |
3031 | [ALC880_W810] = "w810", | |
3032 | [ALC880_Z71V] = "z71v", | |
3033 | [ALC880_6ST] = "6stack", | |
3034 | [ALC880_6ST_DIG] = "6stack-digout", | |
3035 | [ALC880_ASUS] = "asus", | |
3036 | [ALC880_ASUS_W1V] = "asus-w1v", | |
3037 | [ALC880_ASUS_DIG] = "asus-dig", | |
3038 | [ALC880_ASUS_DIG2] = "asus-dig2", | |
3039 | [ALC880_UNIWILL_DIG] = "uniwill", | |
2cf9f0fc TD |
3040 | [ALC880_UNIWILL_P53] = "uniwill-p53", |
3041 | [ALC880_FUJITSU] = "fujitsu", | |
f5fcc13c TI |
3042 | [ALC880_F1734] = "F1734", |
3043 | [ALC880_LG] = "lg", | |
3044 | [ALC880_LG_LW] = "lg-lw", | |
df99cd33 | 3045 | [ALC880_MEDION_RIM] = "medion", |
2fa522be | 3046 | #ifdef CONFIG_SND_DEBUG |
f5fcc13c | 3047 | [ALC880_TEST] = "test", |
2fa522be | 3048 | #endif |
f5fcc13c TI |
3049 | [ALC880_AUTO] = "auto", |
3050 | }; | |
3051 | ||
3052 | static struct snd_pci_quirk alc880_cfg_tbl[] = { | |
ac3e3741 | 3053 | SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810), |
f5fcc13c TI |
3054 | SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG), |
3055 | SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST), | |
3056 | SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG), | |
3057 | SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG), | |
3058 | SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG), | |
3059 | SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG), | |
3060 | SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG), | |
3061 | SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST), | |
f5fcc13c TI |
3062 | SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG), |
3063 | SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST), | |
f5fcc13c TI |
3064 | SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V), |
3065 | SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG), | |
3066 | SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG), | |
3067 | SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG), | |
3068 | SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG), | |
3069 | SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG), | |
3070 | SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V), | |
3071 | /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */ | |
3072 | SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG), | |
3073 | SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG), | |
186c3117 | 3074 | SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG), |
f5fcc13c TI |
3075 | SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG), |
3076 | SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST), | |
3077 | SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST), | |
ac3e3741 | 3078 | SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */ |
f5fcc13c | 3079 | SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST), |
ac3e3741 TI |
3080 | SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST), |
3081 | SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST), | |
f5fcc13c TI |
3082 | SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST), |
3083 | SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST), | |
f5fcc13c TI |
3084 | SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG), |
3085 | SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG), | |
3086 | SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG), | |
3087 | SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG), | |
ac3e3741 TI |
3088 | SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO), |
3089 | SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO), | |
f5fcc13c | 3090 | SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2), |
ac3e3741 | 3091 | SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG), |
f5fcc13c | 3092 | SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG), |
ac3e3741 | 3093 | SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734), |
f5fcc13c TI |
3094 | SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL), |
3095 | SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53), | |
ac3e3741 | 3096 | SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810), |
df99cd33 | 3097 | SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM), |
ac3e3741 | 3098 | SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG), |
f5fcc13c | 3099 | SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG), |
f5fcc13c | 3100 | SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734), |
1d11604e | 3101 | SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU), |
ac3e3741 | 3102 | SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL), |
2cf9f0fc | 3103 | SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU), |
ac3e3741 | 3104 | SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW), |
f5fcc13c TI |
3105 | SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG), |
3106 | SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG), | |
f5fcc13c | 3107 | SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW), |
ac3e3741 TI |
3108 | SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700), |
3109 | SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */ | |
3110 | SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG), | |
3111 | SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG), | |
f5fcc13c TI |
3112 | SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG), |
3113 | SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG), | |
ac3e3741 | 3114 | SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG), |
f5fcc13c | 3115 | SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG), |
ac3e3741 TI |
3116 | SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG), |
3117 | SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG), | |
f5fcc13c TI |
3118 | SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG), |
3119 | SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG), | |
3120 | SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG), | |
ac3e3741 TI |
3121 | SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */ |
3122 | SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG), | |
3123 | SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG), | |
1da177e4 LT |
3124 | {} |
3125 | }; | |
3126 | ||
16ded525 | 3127 | /* |
df694daa | 3128 | * ALC880 codec presets |
16ded525 | 3129 | */ |
16ded525 TI |
3130 | static struct alc_config_preset alc880_presets[] = { |
3131 | [ALC880_3ST] = { | |
e9edcee0 | 3132 | .mixers = { alc880_three_stack_mixer }, |
f12ab1e0 TI |
3133 | .init_verbs = { alc880_volume_init_verbs, |
3134 | alc880_pin_3stack_init_verbs }, | |
16ded525 | 3135 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
16ded525 | 3136 | .dac_nids = alc880_dac_nids, |
16ded525 TI |
3137 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
3138 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 3139 | .need_dac_fix = 1, |
16ded525 TI |
3140 | .input_mux = &alc880_capture_source, |
3141 | }, | |
3142 | [ALC880_3ST_DIG] = { | |
e9edcee0 | 3143 | .mixers = { alc880_three_stack_mixer }, |
f12ab1e0 TI |
3144 | .init_verbs = { alc880_volume_init_verbs, |
3145 | alc880_pin_3stack_init_verbs }, | |
16ded525 | 3146 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
16ded525 TI |
3147 | .dac_nids = alc880_dac_nids, |
3148 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3149 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
3150 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 3151 | .need_dac_fix = 1, |
16ded525 TI |
3152 | .input_mux = &alc880_capture_source, |
3153 | }, | |
df694daa KY |
3154 | [ALC880_TCL_S700] = { |
3155 | .mixers = { alc880_tcl_s700_mixer }, | |
3156 | .init_verbs = { alc880_volume_init_verbs, | |
3157 | alc880_pin_tcl_S700_init_verbs, | |
3158 | alc880_gpio2_init_verbs }, | |
3159 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
3160 | .dac_nids = alc880_dac_nids, | |
3161 | .hp_nid = 0x03, | |
3162 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
3163 | .channel_mode = alc880_2_jack_modes, | |
3164 | .input_mux = &alc880_capture_source, | |
3165 | }, | |
16ded525 | 3166 | [ALC880_5ST] = { |
f12ab1e0 TI |
3167 | .mixers = { alc880_three_stack_mixer, |
3168 | alc880_five_stack_mixer}, | |
3169 | .init_verbs = { alc880_volume_init_verbs, | |
3170 | alc880_pin_5stack_init_verbs }, | |
16ded525 TI |
3171 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
3172 | .dac_nids = alc880_dac_nids, | |
16ded525 TI |
3173 | .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), |
3174 | .channel_mode = alc880_fivestack_modes, | |
3175 | .input_mux = &alc880_capture_source, | |
3176 | }, | |
3177 | [ALC880_5ST_DIG] = { | |
f12ab1e0 TI |
3178 | .mixers = { alc880_three_stack_mixer, |
3179 | alc880_five_stack_mixer }, | |
3180 | .init_verbs = { alc880_volume_init_verbs, | |
3181 | alc880_pin_5stack_init_verbs }, | |
16ded525 TI |
3182 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
3183 | .dac_nids = alc880_dac_nids, | |
3184 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3185 | .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), |
3186 | .channel_mode = alc880_fivestack_modes, | |
3187 | .input_mux = &alc880_capture_source, | |
3188 | }, | |
b6482d48 TI |
3189 | [ALC880_6ST] = { |
3190 | .mixers = { alc880_six_stack_mixer }, | |
f12ab1e0 TI |
3191 | .init_verbs = { alc880_volume_init_verbs, |
3192 | alc880_pin_6stack_init_verbs }, | |
b6482d48 TI |
3193 | .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), |
3194 | .dac_nids = alc880_6st_dac_nids, | |
3195 | .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), | |
3196 | .channel_mode = alc880_sixstack_modes, | |
3197 | .input_mux = &alc880_6stack_capture_source, | |
3198 | }, | |
16ded525 | 3199 | [ALC880_6ST_DIG] = { |
e9edcee0 | 3200 | .mixers = { alc880_six_stack_mixer }, |
f12ab1e0 TI |
3201 | .init_verbs = { alc880_volume_init_verbs, |
3202 | alc880_pin_6stack_init_verbs }, | |
16ded525 TI |
3203 | .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), |
3204 | .dac_nids = alc880_6st_dac_nids, | |
3205 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3206 | .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), |
3207 | .channel_mode = alc880_sixstack_modes, | |
3208 | .input_mux = &alc880_6stack_capture_source, | |
3209 | }, | |
3210 | [ALC880_W810] = { | |
e9edcee0 | 3211 | .mixers = { alc880_w810_base_mixer }, |
f12ab1e0 TI |
3212 | .init_verbs = { alc880_volume_init_verbs, |
3213 | alc880_pin_w810_init_verbs, | |
b0af0de5 | 3214 | alc880_gpio2_init_verbs }, |
16ded525 TI |
3215 | .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids), |
3216 | .dac_nids = alc880_w810_dac_nids, | |
3217 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3218 | .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), |
3219 | .channel_mode = alc880_w810_modes, | |
3220 | .input_mux = &alc880_capture_source, | |
3221 | }, | |
3222 | [ALC880_Z71V] = { | |
e9edcee0 | 3223 | .mixers = { alc880_z71v_mixer }, |
f12ab1e0 TI |
3224 | .init_verbs = { alc880_volume_init_verbs, |
3225 | alc880_pin_z71v_init_verbs }, | |
16ded525 TI |
3226 | .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids), |
3227 | .dac_nids = alc880_z71v_dac_nids, | |
3228 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3229 | .hp_nid = 0x03, | |
e9edcee0 TI |
3230 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), |
3231 | .channel_mode = alc880_2_jack_modes, | |
16ded525 TI |
3232 | .input_mux = &alc880_capture_source, |
3233 | }, | |
3234 | [ALC880_F1734] = { | |
e9edcee0 | 3235 | .mixers = { alc880_f1734_mixer }, |
f12ab1e0 TI |
3236 | .init_verbs = { alc880_volume_init_verbs, |
3237 | alc880_pin_f1734_init_verbs }, | |
e9edcee0 TI |
3238 | .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids), |
3239 | .dac_nids = alc880_f1734_dac_nids, | |
3240 | .hp_nid = 0x02, | |
3241 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
3242 | .channel_mode = alc880_2_jack_modes, | |
937b4160 TI |
3243 | .input_mux = &alc880_f1734_capture_source, |
3244 | .unsol_event = alc880_uniwill_p53_unsol_event, | |
3245 | .init_hook = alc880_uniwill_p53_hp_automute, | |
16ded525 TI |
3246 | }, |
3247 | [ALC880_ASUS] = { | |
e9edcee0 | 3248 | .mixers = { alc880_asus_mixer }, |
f12ab1e0 TI |
3249 | .init_verbs = { alc880_volume_init_verbs, |
3250 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
3251 | alc880_gpio1_init_verbs }, |
3252 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3253 | .dac_nids = alc880_asus_dac_nids, | |
3254 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), | |
3255 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3256 | .need_dac_fix = 1, |
16ded525 TI |
3257 | .input_mux = &alc880_capture_source, |
3258 | }, | |
3259 | [ALC880_ASUS_DIG] = { | |
e9edcee0 | 3260 | .mixers = { alc880_asus_mixer }, |
f12ab1e0 TI |
3261 | .init_verbs = { alc880_volume_init_verbs, |
3262 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
3263 | alc880_gpio1_init_verbs }, |
3264 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3265 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 3266 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
3267 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
3268 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3269 | .need_dac_fix = 1, |
16ded525 TI |
3270 | .input_mux = &alc880_capture_source, |
3271 | }, | |
df694daa KY |
3272 | [ALC880_ASUS_DIG2] = { |
3273 | .mixers = { alc880_asus_mixer }, | |
f12ab1e0 TI |
3274 | .init_verbs = { alc880_volume_init_verbs, |
3275 | alc880_pin_asus_init_verbs, | |
df694daa KY |
3276 | alc880_gpio2_init_verbs }, /* use GPIO2 */ |
3277 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3278 | .dac_nids = alc880_asus_dac_nids, | |
3279 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3280 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), | |
3281 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3282 | .need_dac_fix = 1, |
df694daa KY |
3283 | .input_mux = &alc880_capture_source, |
3284 | }, | |
16ded525 | 3285 | [ALC880_ASUS_W1V] = { |
e9edcee0 | 3286 | .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer }, |
f12ab1e0 TI |
3287 | .init_verbs = { alc880_volume_init_verbs, |
3288 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
3289 | alc880_gpio1_init_verbs }, |
3290 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3291 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 3292 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
3293 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
3294 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3295 | .need_dac_fix = 1, |
16ded525 TI |
3296 | .input_mux = &alc880_capture_source, |
3297 | }, | |
3298 | [ALC880_UNIWILL_DIG] = { | |
3c10a9d9 | 3299 | .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer }, |
ccc656ce KY |
3300 | .init_verbs = { alc880_volume_init_verbs, |
3301 | alc880_pin_asus_init_verbs }, | |
e9edcee0 TI |
3302 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), |
3303 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 3304 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
3305 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
3306 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3307 | .need_dac_fix = 1, |
16ded525 TI |
3308 | .input_mux = &alc880_capture_source, |
3309 | }, | |
ccc656ce KY |
3310 | [ALC880_UNIWILL] = { |
3311 | .mixers = { alc880_uniwill_mixer }, | |
3312 | .init_verbs = { alc880_volume_init_verbs, | |
3313 | alc880_uniwill_init_verbs }, | |
3314 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3315 | .dac_nids = alc880_asus_dac_nids, | |
3316 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3317 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
3318 | .channel_mode = alc880_threestack_modes, | |
3319 | .need_dac_fix = 1, | |
3320 | .input_mux = &alc880_capture_source, | |
3321 | .unsol_event = alc880_uniwill_unsol_event, | |
3322 | .init_hook = alc880_uniwill_automute, | |
3323 | }, | |
3324 | [ALC880_UNIWILL_P53] = { | |
3325 | .mixers = { alc880_uniwill_p53_mixer }, | |
3326 | .init_verbs = { alc880_volume_init_verbs, | |
3327 | alc880_uniwill_p53_init_verbs }, | |
3328 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3329 | .dac_nids = alc880_asus_dac_nids, | |
3330 | .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), | |
2cf9f0fc TD |
3331 | .channel_mode = alc880_threestack_modes, |
3332 | .input_mux = &alc880_capture_source, | |
3333 | .unsol_event = alc880_uniwill_p53_unsol_event, | |
3334 | .init_hook = alc880_uniwill_p53_hp_automute, | |
3335 | }, | |
3336 | [ALC880_FUJITSU] = { | |
f12ab1e0 | 3337 | .mixers = { alc880_fujitsu_mixer, |
2cf9f0fc TD |
3338 | alc880_pcbeep_mixer, }, |
3339 | .init_verbs = { alc880_volume_init_verbs, | |
3340 | alc880_uniwill_p53_init_verbs, | |
3341 | alc880_beep_init_verbs }, | |
3342 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
3343 | .dac_nids = alc880_dac_nids, | |
d53d7d9e | 3344 | .dig_out_nid = ALC880_DIGOUT_NID, |
2cf9f0fc TD |
3345 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), |
3346 | .channel_mode = alc880_2_jack_modes, | |
ccc656ce KY |
3347 | .input_mux = &alc880_capture_source, |
3348 | .unsol_event = alc880_uniwill_p53_unsol_event, | |
3349 | .init_hook = alc880_uniwill_p53_hp_automute, | |
3350 | }, | |
df694daa KY |
3351 | [ALC880_CLEVO] = { |
3352 | .mixers = { alc880_three_stack_mixer }, | |
3353 | .init_verbs = { alc880_volume_init_verbs, | |
3354 | alc880_pin_clevo_init_verbs }, | |
3355 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
3356 | .dac_nids = alc880_dac_nids, | |
3357 | .hp_nid = 0x03, | |
3358 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
3359 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 3360 | .need_dac_fix = 1, |
df694daa KY |
3361 | .input_mux = &alc880_capture_source, |
3362 | }, | |
ae6b813a TI |
3363 | [ALC880_LG] = { |
3364 | .mixers = { alc880_lg_mixer }, | |
3365 | .init_verbs = { alc880_volume_init_verbs, | |
3366 | alc880_lg_init_verbs }, | |
3367 | .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids), | |
3368 | .dac_nids = alc880_lg_dac_nids, | |
3369 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3370 | .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes), | |
3371 | .channel_mode = alc880_lg_ch_modes, | |
4e195a7b | 3372 | .need_dac_fix = 1, |
ae6b813a TI |
3373 | .input_mux = &alc880_lg_capture_source, |
3374 | .unsol_event = alc880_lg_unsol_event, | |
3375 | .init_hook = alc880_lg_automute, | |
cb53c626 TI |
3376 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
3377 | .loopbacks = alc880_lg_loopbacks, | |
3378 | #endif | |
ae6b813a | 3379 | }, |
d681518a TI |
3380 | [ALC880_LG_LW] = { |
3381 | .mixers = { alc880_lg_lw_mixer }, | |
3382 | .init_verbs = { alc880_volume_init_verbs, | |
3383 | alc880_lg_lw_init_verbs }, | |
0a8c5da3 | 3384 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
d681518a TI |
3385 | .dac_nids = alc880_dac_nids, |
3386 | .dig_out_nid = ALC880_DIGOUT_NID, | |
0a8c5da3 CM |
3387 | .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes), |
3388 | .channel_mode = alc880_lg_lw_modes, | |
d681518a TI |
3389 | .input_mux = &alc880_lg_lw_capture_source, |
3390 | .unsol_event = alc880_lg_lw_unsol_event, | |
3391 | .init_hook = alc880_lg_lw_automute, | |
3392 | }, | |
df99cd33 TI |
3393 | [ALC880_MEDION_RIM] = { |
3394 | .mixers = { alc880_medion_rim_mixer }, | |
3395 | .init_verbs = { alc880_volume_init_verbs, | |
3396 | alc880_medion_rim_init_verbs, | |
3397 | alc_gpio2_init_verbs }, | |
3398 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
3399 | .dac_nids = alc880_dac_nids, | |
3400 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3401 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
3402 | .channel_mode = alc880_2_jack_modes, | |
3403 | .input_mux = &alc880_medion_rim_capture_source, | |
3404 | .unsol_event = alc880_medion_rim_unsol_event, | |
3405 | .init_hook = alc880_medion_rim_automute, | |
3406 | }, | |
16ded525 TI |
3407 | #ifdef CONFIG_SND_DEBUG |
3408 | [ALC880_TEST] = { | |
e9edcee0 TI |
3409 | .mixers = { alc880_test_mixer }, |
3410 | .init_verbs = { alc880_test_init_verbs }, | |
16ded525 TI |
3411 | .num_dacs = ARRAY_SIZE(alc880_test_dac_nids), |
3412 | .dac_nids = alc880_test_dac_nids, | |
3413 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3414 | .num_channel_mode = ARRAY_SIZE(alc880_test_modes), |
3415 | .channel_mode = alc880_test_modes, | |
3416 | .input_mux = &alc880_test_capture_source, | |
3417 | }, | |
3418 | #endif | |
3419 | }; | |
3420 | ||
e9edcee0 TI |
3421 | /* |
3422 | * Automatic parse of I/O pins from the BIOS configuration | |
3423 | */ | |
3424 | ||
3425 | #define NUM_CONTROL_ALLOC 32 | |
3426 | #define NUM_VERB_ALLOC 32 | |
3427 | ||
3428 | enum { | |
3429 | ALC_CTL_WIDGET_VOL, | |
3430 | ALC_CTL_WIDGET_MUTE, | |
3431 | ALC_CTL_BIND_MUTE, | |
3432 | }; | |
c8b6bf9b | 3433 | static struct snd_kcontrol_new alc880_control_templates[] = { |
e9edcee0 TI |
3434 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
3435 | HDA_CODEC_MUTE(NULL, 0, 0, 0), | |
985be54b | 3436 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
e9edcee0 TI |
3437 | }; |
3438 | ||
3439 | /* add dynamic controls */ | |
f12ab1e0 TI |
3440 | static int add_control(struct alc_spec *spec, int type, const char *name, |
3441 | unsigned long val) | |
e9edcee0 | 3442 | { |
c8b6bf9b | 3443 | struct snd_kcontrol_new *knew; |
e9edcee0 TI |
3444 | |
3445 | if (spec->num_kctl_used >= spec->num_kctl_alloc) { | |
3446 | int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; | |
3447 | ||
f12ab1e0 TI |
3448 | /* array + terminator */ |
3449 | knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); | |
3450 | if (!knew) | |
e9edcee0 TI |
3451 | return -ENOMEM; |
3452 | if (spec->kctl_alloc) { | |
f12ab1e0 TI |
3453 | memcpy(knew, spec->kctl_alloc, |
3454 | sizeof(*knew) * spec->num_kctl_alloc); | |
e9edcee0 TI |
3455 | kfree(spec->kctl_alloc); |
3456 | } | |
3457 | spec->kctl_alloc = knew; | |
3458 | spec->num_kctl_alloc = num; | |
3459 | } | |
3460 | ||
3461 | knew = &spec->kctl_alloc[spec->num_kctl_used]; | |
3462 | *knew = alc880_control_templates[type]; | |
543537bd | 3463 | knew->name = kstrdup(name, GFP_KERNEL); |
f12ab1e0 | 3464 | if (!knew->name) |
e9edcee0 TI |
3465 | return -ENOMEM; |
3466 | knew->private_value = val; | |
3467 | spec->num_kctl_used++; | |
3468 | return 0; | |
3469 | } | |
3470 | ||
3471 | #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17) | |
3472 | #define alc880_fixed_pin_idx(nid) ((nid) - 0x14) | |
3473 | #define alc880_is_multi_pin(nid) ((nid) >= 0x18) | |
3474 | #define alc880_multi_pin_idx(nid) ((nid) - 0x18) | |
3475 | #define alc880_is_input_pin(nid) ((nid) >= 0x18) | |
3476 | #define alc880_input_pin_idx(nid) ((nid) - 0x18) | |
3477 | #define alc880_idx_to_dac(nid) ((nid) + 0x02) | |
3478 | #define alc880_dac_to_idx(nid) ((nid) - 0x02) | |
3479 | #define alc880_idx_to_mixer(nid) ((nid) + 0x0c) | |
3480 | #define alc880_idx_to_selector(nid) ((nid) + 0x10) | |
3481 | #define ALC880_PIN_CD_NID 0x1c | |
3482 | ||
3483 | /* fill in the dac_nids table from the parsed pin configuration */ | |
f12ab1e0 TI |
3484 | static int alc880_auto_fill_dac_nids(struct alc_spec *spec, |
3485 | const struct auto_pin_cfg *cfg) | |
e9edcee0 TI |
3486 | { |
3487 | hda_nid_t nid; | |
3488 | int assigned[4]; | |
3489 | int i, j; | |
3490 | ||
3491 | memset(assigned, 0, sizeof(assigned)); | |
b0af0de5 | 3492 | spec->multiout.dac_nids = spec->private_dac_nids; |
e9edcee0 TI |
3493 | |
3494 | /* check the pins hardwired to audio widget */ | |
3495 | for (i = 0; i < cfg->line_outs; i++) { | |
3496 | nid = cfg->line_out_pins[i]; | |
3497 | if (alc880_is_fixed_pin(nid)) { | |
3498 | int idx = alc880_fixed_pin_idx(nid); | |
5014f193 | 3499 | spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx); |
e9edcee0 TI |
3500 | assigned[idx] = 1; |
3501 | } | |
3502 | } | |
3503 | /* left pins can be connect to any audio widget */ | |
3504 | for (i = 0; i < cfg->line_outs; i++) { | |
3505 | nid = cfg->line_out_pins[i]; | |
3506 | if (alc880_is_fixed_pin(nid)) | |
3507 | continue; | |
3508 | /* search for an empty channel */ | |
3509 | for (j = 0; j < cfg->line_outs; j++) { | |
f12ab1e0 TI |
3510 | if (!assigned[j]) { |
3511 | spec->multiout.dac_nids[i] = | |
3512 | alc880_idx_to_dac(j); | |
e9edcee0 TI |
3513 | assigned[j] = 1; |
3514 | break; | |
3515 | } | |
3516 | } | |
3517 | } | |
3518 | spec->multiout.num_dacs = cfg->line_outs; | |
3519 | return 0; | |
3520 | } | |
3521 | ||
3522 | /* add playback controls from the parsed DAC table */ | |
df694daa KY |
3523 | static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, |
3524 | const struct auto_pin_cfg *cfg) | |
e9edcee0 TI |
3525 | { |
3526 | char name[32]; | |
f12ab1e0 TI |
3527 | static const char *chname[4] = { |
3528 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
3529 | }; | |
e9edcee0 TI |
3530 | hda_nid_t nid; |
3531 | int i, err; | |
3532 | ||
3533 | for (i = 0; i < cfg->line_outs; i++) { | |
f12ab1e0 | 3534 | if (!spec->multiout.dac_nids[i]) |
e9edcee0 TI |
3535 | continue; |
3536 | nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i])); | |
3537 | if (i == 2) { | |
3538 | /* Center/LFE */ | |
f12ab1e0 TI |
3539 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
3540 | "Center Playback Volume", | |
3541 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, | |
3542 | HDA_OUTPUT)); | |
3543 | if (err < 0) | |
e9edcee0 | 3544 | return err; |
f12ab1e0 TI |
3545 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
3546 | "LFE Playback Volume", | |
3547 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
3548 | HDA_OUTPUT)); | |
3549 | if (err < 0) | |
e9edcee0 | 3550 | return err; |
f12ab1e0 TI |
3551 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
3552 | "Center Playback Switch", | |
3553 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, | |
3554 | HDA_INPUT)); | |
3555 | if (err < 0) | |
e9edcee0 | 3556 | return err; |
f12ab1e0 TI |
3557 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
3558 | "LFE Playback Switch", | |
3559 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, | |
3560 | HDA_INPUT)); | |
3561 | if (err < 0) | |
e9edcee0 TI |
3562 | return err; |
3563 | } else { | |
3564 | sprintf(name, "%s Playback Volume", chname[i]); | |
f12ab1e0 TI |
3565 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
3566 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
3567 | HDA_OUTPUT)); | |
3568 | if (err < 0) | |
e9edcee0 TI |
3569 | return err; |
3570 | sprintf(name, "%s Playback Switch", chname[i]); | |
f12ab1e0 TI |
3571 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
3572 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, | |
3573 | HDA_INPUT)); | |
3574 | if (err < 0) | |
e9edcee0 TI |
3575 | return err; |
3576 | } | |
3577 | } | |
e9edcee0 TI |
3578 | return 0; |
3579 | } | |
3580 | ||
8d88bc3d TI |
3581 | /* add playback controls for speaker and HP outputs */ |
3582 | static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, | |
3583 | const char *pfx) | |
e9edcee0 TI |
3584 | { |
3585 | hda_nid_t nid; | |
3586 | int err; | |
8d88bc3d | 3587 | char name[32]; |
e9edcee0 | 3588 | |
f12ab1e0 | 3589 | if (!pin) |
e9edcee0 TI |
3590 | return 0; |
3591 | ||
3592 | if (alc880_is_fixed_pin(pin)) { | |
3593 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
82bc955f | 3594 | /* specify the DAC as the extra output */ |
f12ab1e0 | 3595 | if (!spec->multiout.hp_nid) |
e9edcee0 | 3596 | spec->multiout.hp_nid = nid; |
82bc955f TI |
3597 | else |
3598 | spec->multiout.extra_out_nid[0] = nid; | |
e9edcee0 TI |
3599 | /* control HP volume/switch on the output mixer amp */ |
3600 | nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin)); | |
8d88bc3d | 3601 | sprintf(name, "%s Playback Volume", pfx); |
f12ab1e0 TI |
3602 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
3603 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
3604 | if (err < 0) | |
e9edcee0 | 3605 | return err; |
8d88bc3d | 3606 | sprintf(name, "%s Playback Switch", pfx); |
f12ab1e0 TI |
3607 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
3608 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); | |
3609 | if (err < 0) | |
e9edcee0 TI |
3610 | return err; |
3611 | } else if (alc880_is_multi_pin(pin)) { | |
3612 | /* set manual connection */ | |
e9edcee0 | 3613 | /* we have only a switch on HP-out PIN */ |
8d88bc3d | 3614 | sprintf(name, "%s Playback Switch", pfx); |
f12ab1e0 TI |
3615 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
3616 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
3617 | if (err < 0) | |
e9edcee0 TI |
3618 | return err; |
3619 | } | |
3620 | return 0; | |
3621 | } | |
3622 | ||
3623 | /* create input playback/capture controls for the given pin */ | |
f12ab1e0 TI |
3624 | static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, |
3625 | const char *ctlname, | |
df694daa | 3626 | int idx, hda_nid_t mix_nid) |
e9edcee0 TI |
3627 | { |
3628 | char name[32]; | |
df694daa | 3629 | int err; |
e9edcee0 TI |
3630 | |
3631 | sprintf(name, "%s Playback Volume", ctlname); | |
f12ab1e0 TI |
3632 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
3633 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); | |
3634 | if (err < 0) | |
e9edcee0 TI |
3635 | return err; |
3636 | sprintf(name, "%s Playback Switch", ctlname); | |
f12ab1e0 TI |
3637 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
3638 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); | |
3639 | if (err < 0) | |
e9edcee0 TI |
3640 | return err; |
3641 | return 0; | |
3642 | } | |
3643 | ||
3644 | /* create playback/capture controls for input pins */ | |
df694daa KY |
3645 | static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, |
3646 | const struct auto_pin_cfg *cfg) | |
e9edcee0 | 3647 | { |
e9edcee0 | 3648 | struct hda_input_mux *imux = &spec->private_imux; |
df694daa | 3649 | int i, err, idx; |
e9edcee0 TI |
3650 | |
3651 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
3652 | if (alc880_is_input_pin(cfg->input_pins[i])) { | |
df694daa | 3653 | idx = alc880_input_pin_idx(cfg->input_pins[i]); |
4a471b7d TI |
3654 | err = new_analog_input(spec, cfg->input_pins[i], |
3655 | auto_pin_cfg_labels[i], | |
df694daa | 3656 | idx, 0x0b); |
e9edcee0 TI |
3657 | if (err < 0) |
3658 | return err; | |
f12ab1e0 TI |
3659 | imux->items[imux->num_items].label = |
3660 | auto_pin_cfg_labels[i]; | |
3661 | imux->items[imux->num_items].index = | |
3662 | alc880_input_pin_idx(cfg->input_pins[i]); | |
e9edcee0 TI |
3663 | imux->num_items++; |
3664 | } | |
3665 | } | |
3666 | return 0; | |
3667 | } | |
3668 | ||
f6c7e546 TI |
3669 | static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid, |
3670 | unsigned int pin_type) | |
3671 | { | |
3672 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
3673 | pin_type); | |
3674 | /* unmute pin */ | |
d260cdf6 TI |
3675 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
3676 | AMP_OUT_UNMUTE); | |
f6c7e546 TI |
3677 | } |
3678 | ||
df694daa KY |
3679 | static void alc880_auto_set_output_and_unmute(struct hda_codec *codec, |
3680 | hda_nid_t nid, int pin_type, | |
e9edcee0 TI |
3681 | int dac_idx) |
3682 | { | |
f6c7e546 | 3683 | alc_set_pin_output(codec, nid, pin_type); |
e9edcee0 TI |
3684 | /* need the manual connection? */ |
3685 | if (alc880_is_multi_pin(nid)) { | |
3686 | struct alc_spec *spec = codec->spec; | |
3687 | int idx = alc880_multi_pin_idx(nid); | |
3688 | snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, | |
3689 | AC_VERB_SET_CONNECT_SEL, | |
3690 | alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); | |
3691 | } | |
3692 | } | |
3693 | ||
baba8ee9 TI |
3694 | static int get_pin_type(int line_out_type) |
3695 | { | |
3696 | if (line_out_type == AUTO_PIN_HP_OUT) | |
3697 | return PIN_HP; | |
3698 | else | |
3699 | return PIN_OUT; | |
3700 | } | |
3701 | ||
e9edcee0 TI |
3702 | static void alc880_auto_init_multi_out(struct hda_codec *codec) |
3703 | { | |
3704 | struct alc_spec *spec = codec->spec; | |
3705 | int i; | |
ea1fb29a | 3706 | |
bc9f98a9 | 3707 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
e9edcee0 TI |
3708 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
3709 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 TI |
3710 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
3711 | alc880_auto_set_output_and_unmute(codec, nid, pin_type, i); | |
e9edcee0 TI |
3712 | } |
3713 | } | |
3714 | ||
8d88bc3d | 3715 | static void alc880_auto_init_extra_out(struct hda_codec *codec) |
e9edcee0 TI |
3716 | { |
3717 | struct alc_spec *spec = codec->spec; | |
3718 | hda_nid_t pin; | |
3719 | ||
82bc955f | 3720 | pin = spec->autocfg.speaker_pins[0]; |
8d88bc3d TI |
3721 | if (pin) /* connect to front */ |
3722 | alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
eb06ed8f | 3723 | pin = spec->autocfg.hp_pins[0]; |
e9edcee0 TI |
3724 | if (pin) /* connect to front */ |
3725 | alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
3726 | } | |
3727 | ||
3728 | static void alc880_auto_init_analog_input(struct hda_codec *codec) | |
3729 | { | |
3730 | struct alc_spec *spec = codec->spec; | |
3731 | int i; | |
3732 | ||
3733 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
3734 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
3735 | if (alc880_is_input_pin(nid)) { | |
f12ab1e0 TI |
3736 | snd_hda_codec_write(codec, nid, 0, |
3737 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
3738 | i <= AUTO_PIN_FRONT_MIC ? | |
3739 | PIN_VREF80 : PIN_IN); | |
e9edcee0 | 3740 | if (nid != ALC880_PIN_CD_NID) |
f12ab1e0 TI |
3741 | snd_hda_codec_write(codec, nid, 0, |
3742 | AC_VERB_SET_AMP_GAIN_MUTE, | |
e9edcee0 TI |
3743 | AMP_OUT_MUTE); |
3744 | } | |
3745 | } | |
3746 | } | |
3747 | ||
3748 | /* parse the BIOS configuration and set up the alc_spec */ | |
f12ab1e0 TI |
3749 | /* return 1 if successful, 0 if the proper config is not found, |
3750 | * or a negative error code | |
3751 | */ | |
e9edcee0 TI |
3752 | static int alc880_parse_auto_config(struct hda_codec *codec) |
3753 | { | |
3754 | struct alc_spec *spec = codec->spec; | |
3755 | int err; | |
df694daa | 3756 | static hda_nid_t alc880_ignore[] = { 0x1d, 0 }; |
e9edcee0 | 3757 | |
f12ab1e0 TI |
3758 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
3759 | alc880_ignore); | |
3760 | if (err < 0) | |
e9edcee0 | 3761 | return err; |
f12ab1e0 | 3762 | if (!spec->autocfg.line_outs) |
e9edcee0 | 3763 | return 0; /* can't find valid BIOS pin config */ |
df694daa | 3764 | |
f12ab1e0 TI |
3765 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
3766 | if (err < 0) | |
3767 | return err; | |
3768 | err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
3769 | if (err < 0) | |
3770 | return err; | |
3771 | err = alc880_auto_create_extra_out(spec, | |
3772 | spec->autocfg.speaker_pins[0], | |
3773 | "Speaker"); | |
3774 | if (err < 0) | |
3775 | return err; | |
3776 | err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], | |
3777 | "Headphone"); | |
3778 | if (err < 0) | |
3779 | return err; | |
3780 | err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
3781 | if (err < 0) | |
e9edcee0 TI |
3782 | return err; |
3783 | ||
3784 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
3785 | ||
3786 | if (spec->autocfg.dig_out_pin) | |
3787 | spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; | |
3788 | if (spec->autocfg.dig_in_pin) | |
3789 | spec->dig_in_nid = ALC880_DIGIN_NID; | |
3790 | ||
3791 | if (spec->kctl_alloc) | |
3792 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
3793 | ||
3794 | spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs; | |
3795 | ||
a1e8d2da | 3796 | spec->num_mux_defs = 1; |
e9edcee0 TI |
3797 | spec->input_mux = &spec->private_imux; |
3798 | ||
3799 | return 1; | |
3800 | } | |
3801 | ||
ae6b813a TI |
3802 | /* additional initialization for auto-configuration model */ |
3803 | static void alc880_auto_init(struct hda_codec *codec) | |
e9edcee0 | 3804 | { |
f6c7e546 | 3805 | struct alc_spec *spec = codec->spec; |
e9edcee0 | 3806 | alc880_auto_init_multi_out(codec); |
8d88bc3d | 3807 | alc880_auto_init_extra_out(codec); |
e9edcee0 | 3808 | alc880_auto_init_analog_input(codec); |
f6c7e546 TI |
3809 | if (spec->unsol_event) |
3810 | alc_sku_automute(codec); | |
e9edcee0 TI |
3811 | } |
3812 | ||
3813 | /* | |
3814 | * OK, here we have finally the patch for ALC880 | |
3815 | */ | |
3816 | ||
1da177e4 LT |
3817 | static int patch_alc880(struct hda_codec *codec) |
3818 | { | |
3819 | struct alc_spec *spec; | |
3820 | int board_config; | |
df694daa | 3821 | int err; |
1da177e4 | 3822 | |
e560d8d8 | 3823 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
1da177e4 LT |
3824 | if (spec == NULL) |
3825 | return -ENOMEM; | |
3826 | ||
3827 | codec->spec = spec; | |
3828 | ||
f5fcc13c TI |
3829 | board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST, |
3830 | alc880_models, | |
3831 | alc880_cfg_tbl); | |
3832 | if (board_config < 0) { | |
9c7f852e TI |
3833 | printk(KERN_INFO "hda_codec: Unknown model for ALC880, " |
3834 | "trying auto-probe from BIOS...\n"); | |
e9edcee0 | 3835 | board_config = ALC880_AUTO; |
1da177e4 | 3836 | } |
1da177e4 | 3837 | |
e9edcee0 TI |
3838 | if (board_config == ALC880_AUTO) { |
3839 | /* automatic parse from the BIOS config */ | |
3840 | err = alc880_parse_auto_config(codec); | |
3841 | if (err < 0) { | |
3842 | alc_free(codec); | |
3843 | return err; | |
f12ab1e0 | 3844 | } else if (!err) { |
9c7f852e TI |
3845 | printk(KERN_INFO |
3846 | "hda_codec: Cannot set up configuration " | |
3847 | "from BIOS. Using 3-stack mode...\n"); | |
e9edcee0 TI |
3848 | board_config = ALC880_3ST; |
3849 | } | |
1da177e4 LT |
3850 | } |
3851 | ||
df694daa KY |
3852 | if (board_config != ALC880_AUTO) |
3853 | setup_preset(spec, &alc880_presets[board_config]); | |
1da177e4 LT |
3854 | |
3855 | spec->stream_name_analog = "ALC880 Analog"; | |
3856 | spec->stream_analog_playback = &alc880_pcm_analog_playback; | |
3857 | spec->stream_analog_capture = &alc880_pcm_analog_capture; | |
6330079f | 3858 | spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture; |
1da177e4 LT |
3859 | |
3860 | spec->stream_name_digital = "ALC880 Digital"; | |
3861 | spec->stream_digital_playback = &alc880_pcm_digital_playback; | |
3862 | spec->stream_digital_capture = &alc880_pcm_digital_capture; | |
3863 | ||
f12ab1e0 | 3864 | if (!spec->adc_nids && spec->input_mux) { |
e9edcee0 | 3865 | /* check whether NID 0x07 is valid */ |
54d17403 | 3866 | unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); |
f12ab1e0 TI |
3867 | /* get type */ |
3868 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
e9edcee0 TI |
3869 | if (wcap != AC_WID_AUD_IN) { |
3870 | spec->adc_nids = alc880_adc_nids_alt; | |
3871 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); | |
f12ab1e0 TI |
3872 | spec->mixers[spec->num_mixers] = |
3873 | alc880_capture_alt_mixer; | |
e9edcee0 TI |
3874 | spec->num_mixers++; |
3875 | } else { | |
3876 | spec->adc_nids = alc880_adc_nids; | |
3877 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids); | |
3878 | spec->mixers[spec->num_mixers] = alc880_capture_mixer; | |
3879 | spec->num_mixers++; | |
3880 | } | |
3881 | } | |
1da177e4 | 3882 | |
2134ea4f TI |
3883 | spec->vmaster_nid = 0x0c; |
3884 | ||
1da177e4 | 3885 | codec->patch_ops = alc_patch_ops; |
e9edcee0 | 3886 | if (board_config == ALC880_AUTO) |
ae6b813a | 3887 | spec->init_hook = alc880_auto_init; |
cb53c626 TI |
3888 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
3889 | if (!spec->loopback.amplist) | |
3890 | spec->loopback.amplist = alc880_loopbacks; | |
3891 | #endif | |
1da177e4 LT |
3892 | |
3893 | return 0; | |
3894 | } | |
3895 | ||
e9edcee0 | 3896 | |
1da177e4 LT |
3897 | /* |
3898 | * ALC260 support | |
3899 | */ | |
3900 | ||
e9edcee0 TI |
3901 | static hda_nid_t alc260_dac_nids[1] = { |
3902 | /* front */ | |
3903 | 0x02, | |
3904 | }; | |
3905 | ||
3906 | static hda_nid_t alc260_adc_nids[1] = { | |
3907 | /* ADC0 */ | |
3908 | 0x04, | |
3909 | }; | |
3910 | ||
df694daa | 3911 | static hda_nid_t alc260_adc_nids_alt[1] = { |
e9edcee0 TI |
3912 | /* ADC1 */ |
3913 | 0x05, | |
3914 | }; | |
3915 | ||
df694daa KY |
3916 | static hda_nid_t alc260_hp_adc_nids[2] = { |
3917 | /* ADC1, 0 */ | |
3918 | 0x05, 0x04 | |
3919 | }; | |
3920 | ||
d57fdac0 JW |
3921 | /* NIDs used when simultaneous access to both ADCs makes sense. Note that |
3922 | * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC. | |
3923 | */ | |
3924 | static hda_nid_t alc260_dual_adc_nids[2] = { | |
4c5186ed JW |
3925 | /* ADC0, ADC1 */ |
3926 | 0x04, 0x05 | |
3927 | }; | |
3928 | ||
e9edcee0 TI |
3929 | #define ALC260_DIGOUT_NID 0x03 |
3930 | #define ALC260_DIGIN_NID 0x06 | |
3931 | ||
3932 | static struct hda_input_mux alc260_capture_source = { | |
3933 | .num_items = 4, | |
3934 | .items = { | |
3935 | { "Mic", 0x0 }, | |
3936 | { "Front Mic", 0x1 }, | |
3937 | { "Line", 0x2 }, | |
3938 | { "CD", 0x4 }, | |
3939 | }, | |
3940 | }; | |
3941 | ||
17e7aec6 | 3942 | /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack, |
a1e8d2da JW |
3943 | * headphone jack and the internal CD lines since these are the only pins at |
3944 | * which audio can appear. For flexibility, also allow the option of | |
3945 | * recording the mixer output on the second ADC (ADC0 doesn't have a | |
3946 | * connection to the mixer output). | |
a9430dd8 | 3947 | */ |
a1e8d2da JW |
3948 | static struct hda_input_mux alc260_fujitsu_capture_sources[2] = { |
3949 | { | |
3950 | .num_items = 3, | |
3951 | .items = { | |
3952 | { "Mic/Line", 0x0 }, | |
3953 | { "CD", 0x4 }, | |
3954 | { "Headphone", 0x2 }, | |
3955 | }, | |
a9430dd8 | 3956 | }, |
a1e8d2da JW |
3957 | { |
3958 | .num_items = 4, | |
3959 | .items = { | |
3960 | { "Mic/Line", 0x0 }, | |
3961 | { "CD", 0x4 }, | |
3962 | { "Headphone", 0x2 }, | |
3963 | { "Mixer", 0x5 }, | |
3964 | }, | |
3965 | }, | |
3966 | ||
a9430dd8 JW |
3967 | }; |
3968 | ||
a1e8d2da JW |
3969 | /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to |
3970 | * the Fujitsu S702x, but jacks are marked differently. | |
0bfc90e9 | 3971 | */ |
a1e8d2da JW |
3972 | static struct hda_input_mux alc260_acer_capture_sources[2] = { |
3973 | { | |
3974 | .num_items = 4, | |
3975 | .items = { | |
3976 | { "Mic", 0x0 }, | |
3977 | { "Line", 0x2 }, | |
3978 | { "CD", 0x4 }, | |
3979 | { "Headphone", 0x5 }, | |
3980 | }, | |
3981 | }, | |
3982 | { | |
3983 | .num_items = 5, | |
3984 | .items = { | |
3985 | { "Mic", 0x0 }, | |
3986 | { "Line", 0x2 }, | |
3987 | { "CD", 0x4 }, | |
3988 | { "Headphone", 0x6 }, | |
3989 | { "Mixer", 0x5 }, | |
3990 | }, | |
0bfc90e9 JW |
3991 | }, |
3992 | }; | |
1da177e4 LT |
3993 | /* |
3994 | * This is just place-holder, so there's something for alc_build_pcms to look | |
3995 | * at when it calculates the maximum number of channels. ALC260 has no mixer | |
3996 | * element which allows changing the channel mode, so the verb list is | |
3997 | * never used. | |
3998 | */ | |
d2a6d7dc | 3999 | static struct hda_channel_mode alc260_modes[1] = { |
1da177e4 LT |
4000 | { 2, NULL }, |
4001 | }; | |
4002 | ||
df694daa KY |
4003 | |
4004 | /* Mixer combinations | |
4005 | * | |
4006 | * basic: base_output + input + pc_beep + capture | |
4007 | * HP: base_output + input + capture_alt | |
4008 | * HP_3013: hp_3013 + input + capture | |
4009 | * fujitsu: fujitsu + capture | |
0bfc90e9 | 4010 | * acer: acer + capture |
df694daa KY |
4011 | */ |
4012 | ||
4013 | static struct snd_kcontrol_new alc260_base_output_mixer[] = { | |
05acb863 | 4014 | HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
985be54b | 4015 | HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), |
05acb863 | 4016 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
985be54b | 4017 | HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), |
05acb863 | 4018 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
985be54b | 4019 | HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), |
1da177e4 | 4020 | { } /* end */ |
f12ab1e0 | 4021 | }; |
1da177e4 | 4022 | |
df694daa | 4023 | static struct snd_kcontrol_new alc260_input_mixer[] = { |
16ded525 TI |
4024 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
4025 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
4026 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4027 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4028 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4029 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4030 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT), | |
4031 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT), | |
df694daa KY |
4032 | { } /* end */ |
4033 | }; | |
4034 | ||
4035 | static struct snd_kcontrol_new alc260_pc_beep_mixer[] = { | |
4036 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT), | |
4037 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT), | |
4038 | { } /* end */ | |
4039 | }; | |
4040 | ||
bec15c3a TI |
4041 | /* update HP, line and mono out pins according to the master switch */ |
4042 | static void alc260_hp_master_update(struct hda_codec *codec, | |
4043 | hda_nid_t hp, hda_nid_t line, | |
4044 | hda_nid_t mono) | |
4045 | { | |
4046 | struct alc_spec *spec = codec->spec; | |
4047 | unsigned int val = spec->master_sw ? PIN_HP : 0; | |
4048 | /* change HP and line-out pins */ | |
4049 | snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4050 | val); | |
4051 | snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4052 | val); | |
4053 | /* mono (speaker) depending on the HP jack sense */ | |
4054 | val = (val && !spec->jack_present) ? PIN_OUT : 0; | |
4055 | snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4056 | val); | |
4057 | } | |
4058 | ||
4059 | static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol, | |
4060 | struct snd_ctl_elem_value *ucontrol) | |
4061 | { | |
4062 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
4063 | struct alc_spec *spec = codec->spec; | |
4064 | *ucontrol->value.integer.value = spec->master_sw; | |
4065 | return 0; | |
4066 | } | |
4067 | ||
4068 | static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |
4069 | struct snd_ctl_elem_value *ucontrol) | |
4070 | { | |
4071 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
4072 | struct alc_spec *spec = codec->spec; | |
4073 | int val = !!*ucontrol->value.integer.value; | |
4074 | hda_nid_t hp, line, mono; | |
4075 | ||
4076 | if (val == spec->master_sw) | |
4077 | return 0; | |
4078 | spec->master_sw = val; | |
4079 | hp = (kcontrol->private_value >> 16) & 0xff; | |
4080 | line = (kcontrol->private_value >> 8) & 0xff; | |
4081 | mono = kcontrol->private_value & 0xff; | |
4082 | alc260_hp_master_update(codec, hp, line, mono); | |
4083 | return 1; | |
4084 | } | |
4085 | ||
4086 | static struct snd_kcontrol_new alc260_hp_output_mixer[] = { | |
4087 | { | |
4088 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
4089 | .name = "Master Playback Switch", | |
4090 | .info = snd_ctl_boolean_mono_info, | |
4091 | .get = alc260_hp_master_sw_get, | |
4092 | .put = alc260_hp_master_sw_put, | |
4093 | .private_value = (0x0f << 16) | (0x10 << 8) | 0x11 | |
4094 | }, | |
4095 | HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4096 | HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), | |
4097 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), | |
4098 | HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), | |
4099 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, | |
4100 | HDA_OUTPUT), | |
4101 | HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT), | |
4102 | { } /* end */ | |
4103 | }; | |
4104 | ||
4105 | static struct hda_verb alc260_hp_unsol_verbs[] = { | |
4106 | {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
4107 | {}, | |
4108 | }; | |
4109 | ||
4110 | static void alc260_hp_automute(struct hda_codec *codec) | |
4111 | { | |
4112 | struct alc_spec *spec = codec->spec; | |
4113 | unsigned int present; | |
4114 | ||
4115 | present = snd_hda_codec_read(codec, 0x10, 0, | |
4116 | AC_VERB_GET_PIN_SENSE, 0); | |
4117 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; | |
4118 | alc260_hp_master_update(codec, 0x0f, 0x10, 0x11); | |
4119 | } | |
4120 | ||
4121 | static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res) | |
4122 | { | |
4123 | if ((res >> 26) == ALC880_HP_EVENT) | |
4124 | alc260_hp_automute(codec); | |
4125 | } | |
4126 | ||
df694daa | 4127 | static struct snd_kcontrol_new alc260_hp_3013_mixer[] = { |
bec15c3a TI |
4128 | { |
4129 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
4130 | .name = "Master Playback Switch", | |
4131 | .info = snd_ctl_boolean_mono_info, | |
4132 | .get = alc260_hp_master_sw_get, | |
4133 | .put = alc260_hp_master_sw_put, | |
4134 | .private_value = (0x10 << 16) | (0x15 << 8) | 0x11 | |
4135 | }, | |
df694daa KY |
4136 | HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
4137 | HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT), | |
4138 | HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT), | |
4139 | HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT), | |
4140 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4141 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
86cd9298 TI |
4142 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
4143 | HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT), | |
16ded525 TI |
4144 | { } /* end */ |
4145 | }; | |
4146 | ||
3f878308 KY |
4147 | static struct hda_bind_ctls alc260_dc7600_bind_master_vol = { |
4148 | .ops = &snd_hda_bind_vol, | |
4149 | .values = { | |
4150 | HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT), | |
4151 | HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT), | |
4152 | HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT), | |
4153 | 0 | |
4154 | }, | |
4155 | }; | |
4156 | ||
4157 | static struct hda_bind_ctls alc260_dc7600_bind_switch = { | |
4158 | .ops = &snd_hda_bind_sw, | |
4159 | .values = { | |
4160 | HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT), | |
4161 | HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | |
4162 | 0 | |
4163 | }, | |
4164 | }; | |
4165 | ||
4166 | static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = { | |
4167 | HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol), | |
4168 | HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch), | |
4169 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT), | |
4170 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT), | |
4171 | { } /* end */ | |
4172 | }; | |
4173 | ||
bec15c3a TI |
4174 | static struct hda_verb alc260_hp_3013_unsol_verbs[] = { |
4175 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
4176 | {}, | |
4177 | }; | |
4178 | ||
4179 | static void alc260_hp_3013_automute(struct hda_codec *codec) | |
4180 | { | |
4181 | struct alc_spec *spec = codec->spec; | |
4182 | unsigned int present; | |
4183 | ||
4184 | present = snd_hda_codec_read(codec, 0x15, 0, | |
4185 | AC_VERB_GET_PIN_SENSE, 0); | |
4186 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; | |
4187 | alc260_hp_master_update(codec, 0x10, 0x15, 0x11); | |
4188 | } | |
4189 | ||
4190 | static void alc260_hp_3013_unsol_event(struct hda_codec *codec, | |
4191 | unsigned int res) | |
4192 | { | |
4193 | if ((res >> 26) == ALC880_HP_EVENT) | |
4194 | alc260_hp_3013_automute(codec); | |
4195 | } | |
4196 | ||
3f878308 KY |
4197 | static void alc260_hp_3012_automute(struct hda_codec *codec) |
4198 | { | |
4199 | unsigned int present, bits; | |
4200 | ||
4201 | present = snd_hda_codec_read(codec, 0x10, 0, | |
4202 | AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE; | |
4203 | ||
4204 | bits = present ? 0 : PIN_OUT; | |
4205 | snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4206 | bits); | |
4207 | snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4208 | bits); | |
4209 | snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4210 | bits); | |
4211 | } | |
4212 | ||
4213 | static void alc260_hp_3012_unsol_event(struct hda_codec *codec, | |
4214 | unsigned int res) | |
4215 | { | |
4216 | if ((res >> 26) == ALC880_HP_EVENT) | |
4217 | alc260_hp_3012_automute(codec); | |
4218 | } | |
4219 | ||
4220 | /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12, | |
a1e8d2da JW |
4221 | * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10. |
4222 | */ | |
c8b6bf9b | 4223 | static struct snd_kcontrol_new alc260_fujitsu_mixer[] = { |
a9430dd8 | 4224 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
985be54b | 4225 | HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT), |
4c5186ed | 4226 | ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT), |
a9430dd8 JW |
4227 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
4228 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
4229 | HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4230 | HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4c5186ed | 4231 | ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN), |
a9430dd8 JW |
4232 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), |
4233 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
31bffaa9 TI |
4234 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
4235 | HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT), | |
df694daa KY |
4236 | { } /* end */ |
4237 | }; | |
4238 | ||
a1e8d2da JW |
4239 | /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current |
4240 | * versions of the ALC260 don't act on requests to enable mic bias from NID | |
4241 | * 0x0f (used to drive the headphone jack in these laptops). The ALC260 | |
4242 | * datasheet doesn't mention this restriction. At this stage it's not clear | |
4243 | * whether this behaviour is intentional or is a hardware bug in chip | |
4244 | * revisions available in early 2006. Therefore for now allow the | |
4245 | * "Headphone Jack Mode" control to span all choices, but if it turns out | |
4246 | * that the lack of mic bias for this NID is intentional we could change the | |
4247 | * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
4248 | * | |
4249 | * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006 | |
4250 | * don't appear to make the mic bias available from the "line" jack, even | |
4251 | * though the NID used for this jack (0x14) can supply it. The theory is | |
4252 | * that perhaps Acer have included blocking capacitors between the ALC260 | |
4253 | * and the output jack. If this turns out to be the case for all such | |
4254 | * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT | |
4255 | * to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
bd869485 JW |
4256 | * |
4257 | * The C20x Tablet series have a mono internal speaker which is controlled | |
4258 | * via the chip's Mono sum widget and pin complex, so include the necessary | |
4259 | * controls for such models. On models without a "mono speaker" the control | |
4260 | * won't do anything. | |
a1e8d2da | 4261 | */ |
0bfc90e9 JW |
4262 | static struct snd_kcontrol_new alc260_acer_mixer[] = { |
4263 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4264 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT), | |
a1e8d2da | 4265 | ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT), |
31bffaa9 | 4266 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, |
bd869485 | 4267 | HDA_OUTPUT), |
31bffaa9 | 4268 | HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, |
bd869485 | 4269 | HDA_INPUT), |
0bfc90e9 JW |
4270 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
4271 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
4272 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4273 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4274 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
4275 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4276 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4277 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
4278 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), | |
4279 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
4280 | { } /* end */ | |
4281 | }; | |
4282 | ||
bc9f98a9 KY |
4283 | /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12, |
4284 | * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17. | |
4285 | */ | |
4286 | static struct snd_kcontrol_new alc260_will_mixer[] = { | |
4287 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4288 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT), | |
4289 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4290 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4291 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
4292 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4293 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4294 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
4295 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), | |
4296 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
4297 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), | |
4298 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
4299 | { } /* end */ | |
4300 | }; | |
4301 | ||
4302 | /* Replacer 672V ALC260 pin usage: Mic jack = 0x12, | |
4303 | * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f. | |
4304 | */ | |
4305 | static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = { | |
4306 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4307 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT), | |
4308 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4309 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4310 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
4311 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT), | |
4312 | HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT), | |
4313 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4314 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4315 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
4316 | { } /* end */ | |
4317 | }; | |
4318 | ||
df694daa KY |
4319 | /* capture mixer elements */ |
4320 | static struct snd_kcontrol_new alc260_capture_mixer[] = { | |
a9430dd8 JW |
4321 | HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT), |
4322 | HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT), | |
df694daa KY |
4323 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT), |
4324 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT), | |
a9430dd8 JW |
4325 | { |
4326 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
df694daa KY |
4327 | /* The multiple "Capture Source" controls confuse alsamixer |
4328 | * So call somewhat different.. | |
df694daa KY |
4329 | */ |
4330 | /* .name = "Capture Source", */ | |
4331 | .name = "Input Source", | |
4332 | .count = 2, | |
4333 | .info = alc_mux_enum_info, | |
4334 | .get = alc_mux_enum_get, | |
4335 | .put = alc_mux_enum_put, | |
4336 | }, | |
4337 | { } /* end */ | |
4338 | }; | |
4339 | ||
4340 | static struct snd_kcontrol_new alc260_capture_alt_mixer[] = { | |
4341 | HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT), | |
4342 | HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT), | |
4343 | { | |
4344 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
4345 | /* The multiple "Capture Source" controls confuse alsamixer | |
4346 | * So call somewhat different.. | |
df694daa KY |
4347 | */ |
4348 | /* .name = "Capture Source", */ | |
4349 | .name = "Input Source", | |
4350 | .count = 1, | |
a9430dd8 JW |
4351 | .info = alc_mux_enum_info, |
4352 | .get = alc_mux_enum_get, | |
4353 | .put = alc_mux_enum_put, | |
4354 | }, | |
4355 | { } /* end */ | |
4356 | }; | |
4357 | ||
df694daa KY |
4358 | /* |
4359 | * initialization verbs | |
4360 | */ | |
1da177e4 LT |
4361 | static struct hda_verb alc260_init_verbs[] = { |
4362 | /* Line In pin widget for input */ | |
05acb863 | 4363 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 4364 | /* CD pin widget for input */ |
05acb863 | 4365 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 4366 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
16ded525 | 4367 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1da177e4 | 4368 | /* Mic2 (front panel) pin widget for input and vref at 80% */ |
16ded525 | 4369 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1da177e4 | 4370 | /* LINE-2 is used for line-out in rear */ |
05acb863 | 4371 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1da177e4 | 4372 | /* select line-out */ |
fd56f2db | 4373 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00}, |
1da177e4 | 4374 | /* LINE-OUT pin */ |
05acb863 | 4375 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1da177e4 | 4376 | /* enable HP */ |
05acb863 | 4377 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
1da177e4 | 4378 | /* enable Mono */ |
05acb863 TI |
4379 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
4380 | /* mute capture amp left and right */ | |
16ded525 | 4381 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1da177e4 LT |
4382 | /* set connection select to line in (default select for this ADC) */ |
4383 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
16ded525 TI |
4384 | /* mute capture amp left and right */ |
4385 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4386 | /* set connection select to line in (default select for this ADC) */ | |
4387 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
05acb863 TI |
4388 | /* set vol=0 Line-Out mixer amp left and right */ |
4389 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4390 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
4391 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4392 | /* set vol=0 HP mixer amp left and right */ | |
4393 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4394 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
4395 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4396 | /* set vol=0 Mono mixer amp left and right */ | |
4397 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4398 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
4399 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4400 | /* unmute LINE-2 out pin */ | |
4401 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
f12ab1e0 TI |
4402 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
4403 | * Line In 2 = 0x03 | |
4404 | */ | |
cb53c626 TI |
4405 | /* mute analog inputs */ |
4406 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4407 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4408 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4409 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4410 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 4411 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
05acb863 TI |
4412 | /* mute Front out path */ |
4413 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4414 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4415 | /* mute Headphone out path */ | |
4416 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4417 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4418 | /* mute Mono out path */ | |
4419 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4420 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 LT |
4421 | { } |
4422 | }; | |
4423 | ||
474167d6 | 4424 | #if 0 /* should be identical with alc260_init_verbs? */ |
df694daa KY |
4425 | static struct hda_verb alc260_hp_init_verbs[] = { |
4426 | /* Headphone and output */ | |
4427 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
4428 | /* mono output */ | |
4429 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
4430 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
4431 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
4432 | /* Mic2 (front panel) pin widget for input and vref at 80% */ | |
4433 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
4434 | /* Line In pin widget for input */ | |
4435 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
4436 | /* Line-2 pin widget for output */ | |
4437 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
4438 | /* CD pin widget for input */ | |
4439 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
4440 | /* unmute amp left and right */ | |
4441 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | |
4442 | /* set connection select to line in (default select for this ADC) */ | |
4443 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
4444 | /* unmute Line-Out mixer amp left and right (volume = 0) */ | |
4445 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
4446 | /* mute pin widget amp left and right (no gain on this amp) */ | |
4447 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
4448 | /* unmute HP mixer amp left and right (volume = 0) */ | |
4449 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
4450 | /* mute pin widget amp left and right (no gain on this amp) */ | |
4451 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
f12ab1e0 TI |
4452 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
4453 | * Line In 2 = 0x03 | |
4454 | */ | |
cb53c626 TI |
4455 | /* mute analog inputs */ |
4456 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4457 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4458 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4459 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4460 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
4461 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
4462 | /* Unmute Front out path */ | |
4463 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4464 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4465 | /* Unmute Headphone out path */ | |
4466 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4467 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4468 | /* Unmute Mono out path */ | |
4469 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4470 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4471 | { } | |
4472 | }; | |
474167d6 | 4473 | #endif |
df694daa KY |
4474 | |
4475 | static struct hda_verb alc260_hp_3013_init_verbs[] = { | |
4476 | /* Line out and output */ | |
4477 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
4478 | /* mono output */ | |
4479 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
4480 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
4481 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
4482 | /* Mic2 (front panel) pin widget for input and vref at 80% */ | |
4483 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
4484 | /* Line In pin widget for input */ | |
4485 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
4486 | /* Headphone pin widget for output */ | |
4487 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
4488 | /* CD pin widget for input */ | |
4489 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
4490 | /* unmute amp left and right */ | |
4491 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | |
4492 | /* set connection select to line in (default select for this ADC) */ | |
4493 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
4494 | /* unmute Line-Out mixer amp left and right (volume = 0) */ | |
4495 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
4496 | /* mute pin widget amp left and right (no gain on this amp) */ | |
4497 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
4498 | /* unmute HP mixer amp left and right (volume = 0) */ | |
4499 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
4500 | /* mute pin widget amp left and right (no gain on this amp) */ | |
4501 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
f12ab1e0 TI |
4502 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
4503 | * Line In 2 = 0x03 | |
4504 | */ | |
cb53c626 TI |
4505 | /* mute analog inputs */ |
4506 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4507 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4508 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4509 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4510 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
4511 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
4512 | /* Unmute Front out path */ | |
4513 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4514 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4515 | /* Unmute Headphone out path */ | |
4516 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4517 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4518 | /* Unmute Mono out path */ | |
4519 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4520 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4521 | { } | |
4522 | }; | |
4523 | ||
a9430dd8 | 4524 | /* Initialisation sequence for ALC260 as configured in Fujitsu S702x |
a1e8d2da JW |
4525 | * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD |
4526 | * audio = 0x16, internal speaker = 0x10. | |
a9430dd8 JW |
4527 | */ |
4528 | static struct hda_verb alc260_fujitsu_init_verbs[] = { | |
4529 | /* Disable all GPIOs */ | |
4530 | {0x01, AC_VERB_SET_GPIO_MASK, 0}, | |
4531 | /* Internal speaker is connected to headphone pin */ | |
4532 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
4533 | /* Headphone/Line-out jack connects to Line1 pin; make it an output */ | |
4534 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
f7ace40d JW |
4535 | /* Mic/Line-in jack is connected to mic1 pin, so make it an input */ |
4536 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
4537 | /* Ensure all other unused pins are disabled and muted. */ | |
4538 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
4539 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
a9430dd8 | 4540 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
f7ace40d | 4541 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
a9430dd8 | 4542 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
f7ace40d JW |
4543 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
4544 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
4545 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4546 | ||
4547 | /* Disable digital (SPDIF) pins */ | |
4548 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
4549 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
a9430dd8 | 4550 | |
ea1fb29a | 4551 | /* Ensure Line1 pin widget takes its input from the OUT1 sum bus |
f7ace40d JW |
4552 | * when acting as an output. |
4553 | */ | |
4554 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
4c5186ed | 4555 | |
f7ace40d | 4556 | /* Start with output sum widgets muted and their output gains at min */ |
8b33a5aa TI |
4557 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
4558 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4559 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4560 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4561 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4562 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4563 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4564 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4565 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
a9430dd8 | 4566 | |
f7ace40d JW |
4567 | /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */ |
4568 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4569 | /* Unmute Line1 pin widget output buffer since it starts as an output. | |
4570 | * If the pin mode is changed by the user the pin mode control will | |
4571 | * take care of enabling the pin's input/output buffers as needed. | |
4572 | * Therefore there's no need to enable the input buffer at this | |
4573 | * stage. | |
cdcd9268 | 4574 | */ |
f7ace40d | 4575 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
ea1fb29a | 4576 | /* Unmute input buffer of pin widget used for Line-in (no equiv |
cdcd9268 JW |
4577 | * mixer ctrl) |
4578 | */ | |
f7ace40d JW |
4579 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
4580 | ||
4581 | /* Mute capture amp left and right */ | |
4582 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
ea1fb29a | 4583 | /* Set ADC connection select to match default mixer setting - line |
f7ace40d JW |
4584 | * in (on mic1 pin) |
4585 | */ | |
4586 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4587 | ||
4588 | /* Do the same for the second ADC: mute capture input amp and | |
4589 | * set ADC connection to line in (on mic1 pin) | |
4590 | */ | |
4591 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4592 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4593 | ||
4594 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
4595 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
4596 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
4597 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
4598 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
4599 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
4600 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
4601 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
4602 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
4a471b7d TI |
4603 | |
4604 | { } | |
a9430dd8 JW |
4605 | }; |
4606 | ||
0bfc90e9 JW |
4607 | /* Initialisation sequence for ALC260 as configured in Acer TravelMate and |
4608 | * similar laptops (adapted from Fujitsu init verbs). | |
4609 | */ | |
4610 | static struct hda_verb alc260_acer_init_verbs[] = { | |
4611 | /* On TravelMate laptops, GPIO 0 enables the internal speaker and | |
4612 | * the headphone jack. Turn this on and rely on the standard mute | |
4613 | * methods whenever the user wants to turn these outputs off. | |
4614 | */ | |
4615 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
4616 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
4617 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, | |
4618 | /* Internal speaker/Headphone jack is connected to Line-out pin */ | |
4619 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
4620 | /* Internal microphone/Mic jack is connected to Mic1 pin */ | |
4621 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | |
4622 | /* Line In jack is connected to Line1 pin */ | |
4623 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
bd869485 JW |
4624 | /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */ |
4625 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
0bfc90e9 JW |
4626 | /* Ensure all other unused pins are disabled and muted. */ |
4627 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
4628 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
0bfc90e9 JW |
4629 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
4630 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4631 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
4632 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4633 | /* Disable digital (SPDIF) pins */ | |
4634 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
4635 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
4636 | ||
ea1fb29a | 4637 | /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum |
0bfc90e9 JW |
4638 | * bus when acting as outputs. |
4639 | */ | |
4640 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, | |
4641 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
4642 | ||
4643 | /* Start with output sum widgets muted and their output gains at min */ | |
4644 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4645 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4646 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4647 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4648 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4649 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4650 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4651 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4652 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4653 | ||
f12ab1e0 TI |
4654 | /* Unmute Line-out pin widget amp left and right |
4655 | * (no equiv mixer ctrl) | |
4656 | */ | |
0bfc90e9 | 4657 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
bd869485 JW |
4658 | /* Unmute mono pin widget amp output (no equiv mixer ctrl) */ |
4659 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
0bfc90e9 JW |
4660 | /* Unmute Mic1 and Line1 pin widget input buffers since they start as |
4661 | * inputs. If the pin mode is changed by the user the pin mode control | |
4662 | * will take care of enabling the pin's input/output buffers as needed. | |
4663 | * Therefore there's no need to enable the input buffer at this | |
4664 | * stage. | |
4665 | */ | |
4666 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4667 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4668 | ||
4669 | /* Mute capture amp left and right */ | |
4670 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4671 | /* Set ADC connection select to match default mixer setting - mic | |
4672 | * (on mic1 pin) | |
4673 | */ | |
4674 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4675 | ||
4676 | /* Do similar with the second ADC: mute capture input amp and | |
a1e8d2da | 4677 | * set ADC connection to mic to match ALSA's default state. |
0bfc90e9 JW |
4678 | */ |
4679 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
a1e8d2da | 4680 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, |
0bfc90e9 JW |
4681 | |
4682 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
4683 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
4684 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
4685 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
4686 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
4687 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
4688 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
4689 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
4690 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
4691 | ||
4692 | { } | |
4693 | }; | |
4694 | ||
bc9f98a9 KY |
4695 | static struct hda_verb alc260_will_verbs[] = { |
4696 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
4697 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4698 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4699 | {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, | |
4700 | {0x1a, AC_VERB_SET_COEF_INDEX, 0x07}, | |
4701 | {0x1a, AC_VERB_SET_PROC_COEF, 0x3040}, | |
4702 | {} | |
4703 | }; | |
4704 | ||
4705 | static struct hda_verb alc260_replacer_672v_verbs[] = { | |
4706 | {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, | |
4707 | {0x1a, AC_VERB_SET_COEF_INDEX, 0x07}, | |
4708 | {0x1a, AC_VERB_SET_PROC_COEF, 0x3050}, | |
4709 | ||
4710 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
4711 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
4712 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, | |
4713 | ||
4714 | {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
4715 | {} | |
4716 | }; | |
4717 | ||
4718 | /* toggle speaker-output according to the hp-jack state */ | |
4719 | static void alc260_replacer_672v_automute(struct hda_codec *codec) | |
4720 | { | |
4721 | unsigned int present; | |
4722 | ||
4723 | /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */ | |
4724 | present = snd_hda_codec_read(codec, 0x0f, 0, | |
4725 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
4726 | if (present) { | |
82beb8fd TI |
4727 | snd_hda_codec_write_cache(codec, 0x01, 0, |
4728 | AC_VERB_SET_GPIO_DATA, 1); | |
4729 | snd_hda_codec_write_cache(codec, 0x0f, 0, | |
4730 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4731 | PIN_HP); | |
bc9f98a9 | 4732 | } else { |
82beb8fd TI |
4733 | snd_hda_codec_write_cache(codec, 0x01, 0, |
4734 | AC_VERB_SET_GPIO_DATA, 0); | |
4735 | snd_hda_codec_write_cache(codec, 0x0f, 0, | |
4736 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4737 | PIN_OUT); | |
bc9f98a9 KY |
4738 | } |
4739 | } | |
4740 | ||
4741 | static void alc260_replacer_672v_unsol_event(struct hda_codec *codec, | |
4742 | unsigned int res) | |
4743 | { | |
4744 | if ((res >> 26) == ALC880_HP_EVENT) | |
4745 | alc260_replacer_672v_automute(codec); | |
4746 | } | |
4747 | ||
3f878308 KY |
4748 | static struct hda_verb alc260_hp_dc7600_verbs[] = { |
4749 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
4750 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
4751 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4752 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
4753 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4754 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4755 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
4756 | {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
4757 | {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
4758 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
4759 | {} | |
4760 | }; | |
4761 | ||
7cf51e48 JW |
4762 | /* Test configuration for debugging, modelled after the ALC880 test |
4763 | * configuration. | |
4764 | */ | |
4765 | #ifdef CONFIG_SND_DEBUG | |
4766 | static hda_nid_t alc260_test_dac_nids[1] = { | |
4767 | 0x02, | |
4768 | }; | |
4769 | static hda_nid_t alc260_test_adc_nids[2] = { | |
4770 | 0x04, 0x05, | |
4771 | }; | |
a1e8d2da | 4772 | /* For testing the ALC260, each input MUX needs its own definition since |
ea1fb29a | 4773 | * the signal assignments are different. This assumes that the first ADC |
a1e8d2da | 4774 | * is NID 0x04. |
17e7aec6 | 4775 | */ |
a1e8d2da JW |
4776 | static struct hda_input_mux alc260_test_capture_sources[2] = { |
4777 | { | |
4778 | .num_items = 7, | |
4779 | .items = { | |
4780 | { "MIC1 pin", 0x0 }, | |
4781 | { "MIC2 pin", 0x1 }, | |
4782 | { "LINE1 pin", 0x2 }, | |
4783 | { "LINE2 pin", 0x3 }, | |
4784 | { "CD pin", 0x4 }, | |
4785 | { "LINE-OUT pin", 0x5 }, | |
4786 | { "HP-OUT pin", 0x6 }, | |
4787 | }, | |
4788 | }, | |
4789 | { | |
4790 | .num_items = 8, | |
4791 | .items = { | |
4792 | { "MIC1 pin", 0x0 }, | |
4793 | { "MIC2 pin", 0x1 }, | |
4794 | { "LINE1 pin", 0x2 }, | |
4795 | { "LINE2 pin", 0x3 }, | |
4796 | { "CD pin", 0x4 }, | |
4797 | { "Mixer", 0x5 }, | |
4798 | { "LINE-OUT pin", 0x6 }, | |
4799 | { "HP-OUT pin", 0x7 }, | |
4800 | }, | |
7cf51e48 JW |
4801 | }, |
4802 | }; | |
4803 | static struct snd_kcontrol_new alc260_test_mixer[] = { | |
4804 | /* Output driver widgets */ | |
4805 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), | |
4806 | HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), | |
4807 | HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT), | |
4808 | HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT), | |
4809 | HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4810 | HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT), | |
4811 | ||
a1e8d2da JW |
4812 | /* Modes for retasking pin widgets |
4813 | * Note: the ALC260 doesn't seem to act on requests to enable mic | |
4814 | * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't | |
4815 | * mention this restriction. At this stage it's not clear whether | |
4816 | * this behaviour is intentional or is a hardware bug in chip | |
4817 | * revisions available at least up until early 2006. Therefore for | |
4818 | * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all | |
4819 | * choices, but if it turns out that the lack of mic bias for these | |
4820 | * NIDs is intentional we could change their modes from | |
4821 | * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
4822 | */ | |
7cf51e48 JW |
4823 | ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT), |
4824 | ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT), | |
4825 | ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT), | |
4826 | ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT), | |
4827 | ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT), | |
4828 | ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT), | |
4829 | ||
4830 | /* Loopback mixer controls */ | |
4831 | HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT), | |
4832 | HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT), | |
4833 | HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT), | |
4834 | HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT), | |
4835 | HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4836 | HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4837 | HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT), | |
4838 | HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT), | |
4839 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), | |
4840 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
4841 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), | |
4842 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
4843 | HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT), | |
4844 | HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT), | |
4845 | HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT), | |
4846 | HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT), | |
5c8f858d JW |
4847 | |
4848 | /* Controls for GPIO pins, assuming they are configured as outputs */ | |
4849 | ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01), | |
4850 | ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02), | |
4851 | ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04), | |
4852 | ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08), | |
4853 | ||
92621f13 JW |
4854 | /* Switches to allow the digital IO pins to be enabled. The datasheet |
4855 | * is ambigious as to which NID is which; testing on laptops which | |
ea1fb29a | 4856 | * make this output available should provide clarification. |
92621f13 JW |
4857 | */ |
4858 | ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01), | |
4859 | ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01), | |
4860 | ||
f8225f6d JW |
4861 | /* A switch allowing EAPD to be enabled. Some laptops seem to use |
4862 | * this output to turn on an external amplifier. | |
4863 | */ | |
4864 | ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02), | |
4865 | ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02), | |
4866 | ||
7cf51e48 JW |
4867 | { } /* end */ |
4868 | }; | |
4869 | static struct hda_verb alc260_test_init_verbs[] = { | |
5c8f858d JW |
4870 | /* Enable all GPIOs as outputs with an initial value of 0 */ |
4871 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f}, | |
4872 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, | |
4873 | {0x01, AC_VERB_SET_GPIO_MASK, 0x0f}, | |
4874 | ||
7cf51e48 JW |
4875 | /* Enable retasking pins as output, initially without power amp */ |
4876 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4877 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4878 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4879 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4880 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4881 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4882 | ||
92621f13 JW |
4883 | /* Disable digital (SPDIF) pins initially, but users can enable |
4884 | * them via a mixer switch. In the case of SPDIF-out, this initverb | |
4885 | * payload also sets the generation to 0, output to be in "consumer" | |
4886 | * PCM format, copyright asserted, no pre-emphasis and no validity | |
4887 | * control. | |
4888 | */ | |
7cf51e48 JW |
4889 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, |
4890 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
4891 | ||
ea1fb29a | 4892 | /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the |
7cf51e48 JW |
4893 | * OUT1 sum bus when acting as an output. |
4894 | */ | |
4895 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, | |
4896 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0}, | |
4897 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
4898 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0}, | |
4899 | ||
4900 | /* Start with output sum widgets muted and their output gains at min */ | |
4901 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4902 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4903 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4904 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4905 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4906 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4907 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4908 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4909 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4910 | ||
cdcd9268 JW |
4911 | /* Unmute retasking pin widget output buffers since the default |
4912 | * state appears to be output. As the pin mode is changed by the | |
4913 | * user the pin mode control will take care of enabling the pin's | |
4914 | * input/output buffers as needed. | |
4915 | */ | |
7cf51e48 JW |
4916 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
4917 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4918 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4919 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4920 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4921 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4922 | /* Also unmute the mono-out pin widget */ | |
4923 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4924 | ||
7cf51e48 JW |
4925 | /* Mute capture amp left and right */ |
4926 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
f7ace40d JW |
4927 | /* Set ADC connection select to match default mixer setting (mic1 |
4928 | * pin) | |
7cf51e48 JW |
4929 | */ |
4930 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4931 | ||
4932 | /* Do the same for the second ADC: mute capture input amp and | |
f7ace40d | 4933 | * set ADC connection to mic1 pin |
7cf51e48 JW |
4934 | */ |
4935 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4936 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4937 | ||
4938 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
4939 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
4940 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
4941 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
4942 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
4943 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
4944 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
4945 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
4946 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
4947 | ||
4948 | { } | |
4949 | }; | |
4950 | #endif | |
4951 | ||
6330079f TI |
4952 | #define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback |
4953 | #define alc260_pcm_analog_capture alc880_pcm_analog_capture | |
1da177e4 | 4954 | |
a3bcba38 TI |
4955 | #define alc260_pcm_digital_playback alc880_pcm_digital_playback |
4956 | #define alc260_pcm_digital_capture alc880_pcm_digital_capture | |
4957 | ||
df694daa KY |
4958 | /* |
4959 | * for BIOS auto-configuration | |
4960 | */ | |
16ded525 | 4961 | |
df694daa KY |
4962 | static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid, |
4963 | const char *pfx) | |
4964 | { | |
4965 | hda_nid_t nid_vol; | |
4966 | unsigned long vol_val, sw_val; | |
4967 | char name[32]; | |
4968 | int err; | |
4969 | ||
4970 | if (nid >= 0x0f && nid < 0x11) { | |
4971 | nid_vol = nid - 0x7; | |
4972 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); | |
4973 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); | |
4974 | } else if (nid == 0x11) { | |
4975 | nid_vol = nid - 0x7; | |
4976 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT); | |
4977 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT); | |
4978 | } else if (nid >= 0x12 && nid <= 0x15) { | |
4979 | nid_vol = 0x08; | |
4980 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); | |
4981 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); | |
4982 | } else | |
4983 | return 0; /* N/A */ | |
ea1fb29a | 4984 | |
df694daa | 4985 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); |
f12ab1e0 TI |
4986 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val); |
4987 | if (err < 0) | |
df694daa KY |
4988 | return err; |
4989 | snprintf(name, sizeof(name), "%s Playback Switch", pfx); | |
f12ab1e0 TI |
4990 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val); |
4991 | if (err < 0) | |
df694daa KY |
4992 | return err; |
4993 | return 1; | |
4994 | } | |
4995 | ||
4996 | /* add playback controls from the parsed DAC table */ | |
4997 | static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec, | |
4998 | const struct auto_pin_cfg *cfg) | |
4999 | { | |
5000 | hda_nid_t nid; | |
5001 | int err; | |
5002 | ||
5003 | spec->multiout.num_dacs = 1; | |
5004 | spec->multiout.dac_nids = spec->private_dac_nids; | |
5005 | spec->multiout.dac_nids[0] = 0x02; | |
5006 | ||
5007 | nid = cfg->line_out_pins[0]; | |
5008 | if (nid) { | |
5009 | err = alc260_add_playback_controls(spec, nid, "Front"); | |
5010 | if (err < 0) | |
5011 | return err; | |
5012 | } | |
5013 | ||
82bc955f | 5014 | nid = cfg->speaker_pins[0]; |
df694daa KY |
5015 | if (nid) { |
5016 | err = alc260_add_playback_controls(spec, nid, "Speaker"); | |
5017 | if (err < 0) | |
5018 | return err; | |
5019 | } | |
5020 | ||
eb06ed8f | 5021 | nid = cfg->hp_pins[0]; |
df694daa KY |
5022 | if (nid) { |
5023 | err = alc260_add_playback_controls(spec, nid, "Headphone"); | |
5024 | if (err < 0) | |
5025 | return err; | |
5026 | } | |
f12ab1e0 | 5027 | return 0; |
df694daa KY |
5028 | } |
5029 | ||
5030 | /* create playback/capture controls for input pins */ | |
5031 | static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec, | |
5032 | const struct auto_pin_cfg *cfg) | |
5033 | { | |
df694daa KY |
5034 | struct hda_input_mux *imux = &spec->private_imux; |
5035 | int i, err, idx; | |
5036 | ||
5037 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
5038 | if (cfg->input_pins[i] >= 0x12) { | |
5039 | idx = cfg->input_pins[i] - 0x12; | |
4a471b7d | 5040 | err = new_analog_input(spec, cfg->input_pins[i], |
f12ab1e0 TI |
5041 | auto_pin_cfg_labels[i], idx, |
5042 | 0x07); | |
df694daa KY |
5043 | if (err < 0) |
5044 | return err; | |
f12ab1e0 TI |
5045 | imux->items[imux->num_items].label = |
5046 | auto_pin_cfg_labels[i]; | |
df694daa KY |
5047 | imux->items[imux->num_items].index = idx; |
5048 | imux->num_items++; | |
5049 | } | |
f12ab1e0 | 5050 | if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){ |
df694daa | 5051 | idx = cfg->input_pins[i] - 0x09; |
4a471b7d | 5052 | err = new_analog_input(spec, cfg->input_pins[i], |
f12ab1e0 TI |
5053 | auto_pin_cfg_labels[i], idx, |
5054 | 0x07); | |
df694daa KY |
5055 | if (err < 0) |
5056 | return err; | |
f12ab1e0 TI |
5057 | imux->items[imux->num_items].label = |
5058 | auto_pin_cfg_labels[i]; | |
df694daa KY |
5059 | imux->items[imux->num_items].index = idx; |
5060 | imux->num_items++; | |
5061 | } | |
5062 | } | |
5063 | return 0; | |
5064 | } | |
5065 | ||
5066 | static void alc260_auto_set_output_and_unmute(struct hda_codec *codec, | |
5067 | hda_nid_t nid, int pin_type, | |
5068 | int sel_idx) | |
5069 | { | |
f6c7e546 | 5070 | alc_set_pin_output(codec, nid, pin_type); |
df694daa KY |
5071 | /* need the manual connection? */ |
5072 | if (nid >= 0x12) { | |
5073 | int idx = nid - 0x12; | |
5074 | snd_hda_codec_write(codec, idx + 0x0b, 0, | |
5075 | AC_VERB_SET_CONNECT_SEL, sel_idx); | |
df694daa KY |
5076 | } |
5077 | } | |
5078 | ||
5079 | static void alc260_auto_init_multi_out(struct hda_codec *codec) | |
5080 | { | |
5081 | struct alc_spec *spec = codec->spec; | |
5082 | hda_nid_t nid; | |
5083 | ||
bc9f98a9 | 5084 | alc_subsystem_id(codec, 0x10, 0x15, 0x0f); |
f12ab1e0 | 5085 | nid = spec->autocfg.line_out_pins[0]; |
baba8ee9 TI |
5086 | if (nid) { |
5087 | int pin_type = get_pin_type(spec->autocfg.line_out_type); | |
5088 | alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0); | |
5089 | } | |
ea1fb29a | 5090 | |
82bc955f | 5091 | nid = spec->autocfg.speaker_pins[0]; |
df694daa KY |
5092 | if (nid) |
5093 | alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); | |
5094 | ||
eb06ed8f | 5095 | nid = spec->autocfg.hp_pins[0]; |
df694daa | 5096 | if (nid) |
baba8ee9 | 5097 | alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0); |
f12ab1e0 | 5098 | } |
df694daa KY |
5099 | |
5100 | #define ALC260_PIN_CD_NID 0x16 | |
5101 | static void alc260_auto_init_analog_input(struct hda_codec *codec) | |
5102 | { | |
5103 | struct alc_spec *spec = codec->spec; | |
5104 | int i; | |
5105 | ||
5106 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
5107 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
5108 | if (nid >= 0x12) { | |
f12ab1e0 TI |
5109 | snd_hda_codec_write(codec, nid, 0, |
5110 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
5111 | i <= AUTO_PIN_FRONT_MIC ? | |
5112 | PIN_VREF80 : PIN_IN); | |
df694daa | 5113 | if (nid != ALC260_PIN_CD_NID) |
f12ab1e0 TI |
5114 | snd_hda_codec_write(codec, nid, 0, |
5115 | AC_VERB_SET_AMP_GAIN_MUTE, | |
df694daa KY |
5116 | AMP_OUT_MUTE); |
5117 | } | |
5118 | } | |
5119 | } | |
5120 | ||
5121 | /* | |
5122 | * generic initialization of ADC, input mixers and output mixers | |
5123 | */ | |
5124 | static struct hda_verb alc260_volume_init_verbs[] = { | |
5125 | /* | |
5126 | * Unmute ADC0-1 and set the default input to mic-in | |
5127 | */ | |
5128 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5129 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5130 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5131 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
ea1fb29a | 5132 | |
df694daa KY |
5133 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
5134 | * mixer widget | |
f12ab1e0 TI |
5135 | * Note: PASD motherboards uses the Line In 2 as the input for |
5136 | * front panel mic (mic 2) | |
df694daa KY |
5137 | */ |
5138 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
5139 | /* mute analog inputs */ |
5140 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5141 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5142 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5143 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5144 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
5145 | |
5146 | /* | |
5147 | * Set up output mixers (0x08 - 0x0a) | |
5148 | */ | |
5149 | /* set vol=0 to output mixers */ | |
5150 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5151 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5152 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5153 | /* set up input amps for analog loopback */ | |
5154 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
5155 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5156 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5157 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5158 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5159 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5160 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
ea1fb29a | 5161 | |
df694daa KY |
5162 | { } |
5163 | }; | |
5164 | ||
5165 | static int alc260_parse_auto_config(struct hda_codec *codec) | |
5166 | { | |
5167 | struct alc_spec *spec = codec->spec; | |
5168 | unsigned int wcap; | |
5169 | int err; | |
5170 | static hda_nid_t alc260_ignore[] = { 0x17, 0 }; | |
5171 | ||
f12ab1e0 TI |
5172 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
5173 | alc260_ignore); | |
5174 | if (err < 0) | |
df694daa | 5175 | return err; |
f12ab1e0 TI |
5176 | err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg); |
5177 | if (err < 0) | |
4a471b7d | 5178 | return err; |
f12ab1e0 | 5179 | if (!spec->kctl_alloc) |
df694daa | 5180 | return 0; /* can't find valid BIOS pin config */ |
f12ab1e0 TI |
5181 | err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg); |
5182 | if (err < 0) | |
df694daa KY |
5183 | return err; |
5184 | ||
5185 | spec->multiout.max_channels = 2; | |
5186 | ||
5187 | if (spec->autocfg.dig_out_pin) | |
5188 | spec->multiout.dig_out_nid = ALC260_DIGOUT_NID; | |
5189 | if (spec->kctl_alloc) | |
5190 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
5191 | ||
5192 | spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs; | |
5193 | ||
a1e8d2da | 5194 | spec->num_mux_defs = 1; |
df694daa KY |
5195 | spec->input_mux = &spec->private_imux; |
5196 | ||
5197 | /* check whether NID 0x04 is valid */ | |
4a471b7d | 5198 | wcap = get_wcaps(codec, 0x04); |
df694daa | 5199 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ |
67ebcb03 | 5200 | if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) { |
df694daa KY |
5201 | spec->adc_nids = alc260_adc_nids_alt; |
5202 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt); | |
5203 | spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer; | |
df694daa KY |
5204 | } else { |
5205 | spec->adc_nids = alc260_adc_nids; | |
5206 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); | |
5207 | spec->mixers[spec->num_mixers] = alc260_capture_mixer; | |
df694daa | 5208 | } |
4a471b7d | 5209 | spec->num_mixers++; |
df694daa KY |
5210 | |
5211 | return 1; | |
5212 | } | |
5213 | ||
ae6b813a TI |
5214 | /* additional initialization for auto-configuration model */ |
5215 | static void alc260_auto_init(struct hda_codec *codec) | |
df694daa | 5216 | { |
f6c7e546 | 5217 | struct alc_spec *spec = codec->spec; |
df694daa KY |
5218 | alc260_auto_init_multi_out(codec); |
5219 | alc260_auto_init_analog_input(codec); | |
f6c7e546 TI |
5220 | if (spec->unsol_event) |
5221 | alc_sku_automute(codec); | |
df694daa KY |
5222 | } |
5223 | ||
cb53c626 TI |
5224 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
5225 | static struct hda_amp_list alc260_loopbacks[] = { | |
5226 | { 0x07, HDA_INPUT, 0 }, | |
5227 | { 0x07, HDA_INPUT, 1 }, | |
5228 | { 0x07, HDA_INPUT, 2 }, | |
5229 | { 0x07, HDA_INPUT, 3 }, | |
5230 | { 0x07, HDA_INPUT, 4 }, | |
5231 | { } /* end */ | |
5232 | }; | |
5233 | #endif | |
5234 | ||
df694daa KY |
5235 | /* |
5236 | * ALC260 configurations | |
5237 | */ | |
f5fcc13c TI |
5238 | static const char *alc260_models[ALC260_MODEL_LAST] = { |
5239 | [ALC260_BASIC] = "basic", | |
5240 | [ALC260_HP] = "hp", | |
5241 | [ALC260_HP_3013] = "hp-3013", | |
2922c9af | 5242 | [ALC260_HP_DC7600] = "hp-dc7600", |
f5fcc13c TI |
5243 | [ALC260_FUJITSU_S702X] = "fujitsu", |
5244 | [ALC260_ACER] = "acer", | |
bc9f98a9 KY |
5245 | [ALC260_WILL] = "will", |
5246 | [ALC260_REPLACER_672V] = "replacer", | |
7cf51e48 | 5247 | #ifdef CONFIG_SND_DEBUG |
f5fcc13c | 5248 | [ALC260_TEST] = "test", |
7cf51e48 | 5249 | #endif |
f5fcc13c TI |
5250 | [ALC260_AUTO] = "auto", |
5251 | }; | |
5252 | ||
5253 | static struct snd_pci_quirk alc260_cfg_tbl[] = { | |
bd869485 | 5254 | SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER), |
f5fcc13c | 5255 | SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER), |
9720b718 | 5256 | SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013), |
a8a5d067 | 5257 | SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013), |
f5fcc13c | 5258 | SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013), |
34ec8a0a | 5259 | SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013), |
3f878308 | 5260 | SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600), |
f5fcc13c TI |
5261 | SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013), |
5262 | SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP), | |
5263 | SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP), | |
5264 | SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP), | |
5265 | SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC), | |
5266 | SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC), | |
5267 | SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC), | |
5268 | SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X), | |
5269 | SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC), | |
bc9f98a9 | 5270 | SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V), |
ac3e3741 | 5271 | SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL), |
df694daa KY |
5272 | {} |
5273 | }; | |
5274 | ||
5275 | static struct alc_config_preset alc260_presets[] = { | |
5276 | [ALC260_BASIC] = { | |
5277 | .mixers = { alc260_base_output_mixer, | |
5278 | alc260_input_mixer, | |
5279 | alc260_pc_beep_mixer, | |
5280 | alc260_capture_mixer }, | |
5281 | .init_verbs = { alc260_init_verbs }, | |
5282 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5283 | .dac_nids = alc260_dac_nids, | |
5284 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), | |
5285 | .adc_nids = alc260_adc_nids, | |
5286 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5287 | .channel_mode = alc260_modes, | |
5288 | .input_mux = &alc260_capture_source, | |
5289 | }, | |
5290 | [ALC260_HP] = { | |
bec15c3a | 5291 | .mixers = { alc260_hp_output_mixer, |
df694daa KY |
5292 | alc260_input_mixer, |
5293 | alc260_capture_alt_mixer }, | |
bec15c3a TI |
5294 | .init_verbs = { alc260_init_verbs, |
5295 | alc260_hp_unsol_verbs }, | |
df694daa KY |
5296 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), |
5297 | .dac_nids = alc260_dac_nids, | |
5298 | .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), | |
5299 | .adc_nids = alc260_hp_adc_nids, | |
5300 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5301 | .channel_mode = alc260_modes, | |
5302 | .input_mux = &alc260_capture_source, | |
bec15c3a TI |
5303 | .unsol_event = alc260_hp_unsol_event, |
5304 | .init_hook = alc260_hp_automute, | |
df694daa | 5305 | }, |
3f878308 KY |
5306 | [ALC260_HP_DC7600] = { |
5307 | .mixers = { alc260_hp_dc7600_mixer, | |
5308 | alc260_input_mixer, | |
5309 | alc260_capture_alt_mixer }, | |
5310 | .init_verbs = { alc260_init_verbs, | |
5311 | alc260_hp_dc7600_verbs }, | |
5312 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5313 | .dac_nids = alc260_dac_nids, | |
5314 | .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), | |
5315 | .adc_nids = alc260_hp_adc_nids, | |
5316 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5317 | .channel_mode = alc260_modes, | |
5318 | .input_mux = &alc260_capture_source, | |
5319 | .unsol_event = alc260_hp_3012_unsol_event, | |
5320 | .init_hook = alc260_hp_3012_automute, | |
5321 | }, | |
df694daa KY |
5322 | [ALC260_HP_3013] = { |
5323 | .mixers = { alc260_hp_3013_mixer, | |
5324 | alc260_input_mixer, | |
5325 | alc260_capture_alt_mixer }, | |
bec15c3a TI |
5326 | .init_verbs = { alc260_hp_3013_init_verbs, |
5327 | alc260_hp_3013_unsol_verbs }, | |
df694daa KY |
5328 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), |
5329 | .dac_nids = alc260_dac_nids, | |
5330 | .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), | |
5331 | .adc_nids = alc260_hp_adc_nids, | |
5332 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5333 | .channel_mode = alc260_modes, | |
5334 | .input_mux = &alc260_capture_source, | |
bec15c3a TI |
5335 | .unsol_event = alc260_hp_3013_unsol_event, |
5336 | .init_hook = alc260_hp_3013_automute, | |
df694daa KY |
5337 | }, |
5338 | [ALC260_FUJITSU_S702X] = { | |
5339 | .mixers = { alc260_fujitsu_mixer, | |
5340 | alc260_capture_mixer }, | |
5341 | .init_verbs = { alc260_fujitsu_init_verbs }, | |
5342 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5343 | .dac_nids = alc260_dac_nids, | |
d57fdac0 JW |
5344 | .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), |
5345 | .adc_nids = alc260_dual_adc_nids, | |
df694daa KY |
5346 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
5347 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
5348 | .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources), |
5349 | .input_mux = alc260_fujitsu_capture_sources, | |
df694daa | 5350 | }, |
0bfc90e9 JW |
5351 | [ALC260_ACER] = { |
5352 | .mixers = { alc260_acer_mixer, | |
5353 | alc260_capture_mixer }, | |
5354 | .init_verbs = { alc260_acer_init_verbs }, | |
5355 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5356 | .dac_nids = alc260_dac_nids, | |
5357 | .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), | |
5358 | .adc_nids = alc260_dual_adc_nids, | |
5359 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5360 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
5361 | .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources), |
5362 | .input_mux = alc260_acer_capture_sources, | |
0bfc90e9 | 5363 | }, |
bc9f98a9 KY |
5364 | [ALC260_WILL] = { |
5365 | .mixers = { alc260_will_mixer, | |
5366 | alc260_capture_mixer }, | |
5367 | .init_verbs = { alc260_init_verbs, alc260_will_verbs }, | |
5368 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5369 | .dac_nids = alc260_dac_nids, | |
5370 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), | |
5371 | .adc_nids = alc260_adc_nids, | |
5372 | .dig_out_nid = ALC260_DIGOUT_NID, | |
5373 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5374 | .channel_mode = alc260_modes, | |
5375 | .input_mux = &alc260_capture_source, | |
5376 | }, | |
5377 | [ALC260_REPLACER_672V] = { | |
5378 | .mixers = { alc260_replacer_672v_mixer, | |
5379 | alc260_capture_mixer }, | |
5380 | .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs }, | |
5381 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5382 | .dac_nids = alc260_dac_nids, | |
5383 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), | |
5384 | .adc_nids = alc260_adc_nids, | |
5385 | .dig_out_nid = ALC260_DIGOUT_NID, | |
5386 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5387 | .channel_mode = alc260_modes, | |
5388 | .input_mux = &alc260_capture_source, | |
5389 | .unsol_event = alc260_replacer_672v_unsol_event, | |
5390 | .init_hook = alc260_replacer_672v_automute, | |
5391 | }, | |
7cf51e48 JW |
5392 | #ifdef CONFIG_SND_DEBUG |
5393 | [ALC260_TEST] = { | |
5394 | .mixers = { alc260_test_mixer, | |
5395 | alc260_capture_mixer }, | |
5396 | .init_verbs = { alc260_test_init_verbs }, | |
5397 | .num_dacs = ARRAY_SIZE(alc260_test_dac_nids), | |
5398 | .dac_nids = alc260_test_dac_nids, | |
5399 | .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids), | |
5400 | .adc_nids = alc260_test_adc_nids, | |
5401 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5402 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
5403 | .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources), |
5404 | .input_mux = alc260_test_capture_sources, | |
7cf51e48 JW |
5405 | }, |
5406 | #endif | |
df694daa KY |
5407 | }; |
5408 | ||
5409 | static int patch_alc260(struct hda_codec *codec) | |
1da177e4 LT |
5410 | { |
5411 | struct alc_spec *spec; | |
df694daa | 5412 | int err, board_config; |
1da177e4 | 5413 | |
e560d8d8 | 5414 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
1da177e4 LT |
5415 | if (spec == NULL) |
5416 | return -ENOMEM; | |
5417 | ||
5418 | codec->spec = spec; | |
5419 | ||
f5fcc13c TI |
5420 | board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST, |
5421 | alc260_models, | |
5422 | alc260_cfg_tbl); | |
5423 | if (board_config < 0) { | |
9c7f852e TI |
5424 | snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, " |
5425 | "trying auto-probe from BIOS...\n"); | |
df694daa | 5426 | board_config = ALC260_AUTO; |
16ded525 | 5427 | } |
1da177e4 | 5428 | |
df694daa KY |
5429 | if (board_config == ALC260_AUTO) { |
5430 | /* automatic parse from the BIOS config */ | |
5431 | err = alc260_parse_auto_config(codec); | |
5432 | if (err < 0) { | |
5433 | alc_free(codec); | |
5434 | return err; | |
f12ab1e0 | 5435 | } else if (!err) { |
9c7f852e TI |
5436 | printk(KERN_INFO |
5437 | "hda_codec: Cannot set up configuration " | |
5438 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
5439 | board_config = ALC260_BASIC; |
5440 | } | |
a9430dd8 | 5441 | } |
e9edcee0 | 5442 | |
df694daa KY |
5443 | if (board_config != ALC260_AUTO) |
5444 | setup_preset(spec, &alc260_presets[board_config]); | |
1da177e4 LT |
5445 | |
5446 | spec->stream_name_analog = "ALC260 Analog"; | |
5447 | spec->stream_analog_playback = &alc260_pcm_analog_playback; | |
5448 | spec->stream_analog_capture = &alc260_pcm_analog_capture; | |
5449 | ||
a3bcba38 TI |
5450 | spec->stream_name_digital = "ALC260 Digital"; |
5451 | spec->stream_digital_playback = &alc260_pcm_digital_playback; | |
5452 | spec->stream_digital_capture = &alc260_pcm_digital_capture; | |
5453 | ||
2134ea4f TI |
5454 | spec->vmaster_nid = 0x08; |
5455 | ||
1da177e4 | 5456 | codec->patch_ops = alc_patch_ops; |
df694daa | 5457 | if (board_config == ALC260_AUTO) |
ae6b813a | 5458 | spec->init_hook = alc260_auto_init; |
cb53c626 TI |
5459 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
5460 | if (!spec->loopback.amplist) | |
5461 | spec->loopback.amplist = alc260_loopbacks; | |
5462 | #endif | |
1da177e4 LT |
5463 | |
5464 | return 0; | |
5465 | } | |
5466 | ||
e9edcee0 | 5467 | |
1da177e4 LT |
5468 | /* |
5469 | * ALC882 support | |
5470 | * | |
5471 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible | |
5472 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
5473 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
5474 | * 6-channel independent captures. | |
5475 | * | |
5476 | * In addition, an independent DAC for the multi-playback (not used in this | |
5477 | * driver yet). | |
5478 | */ | |
df694daa KY |
5479 | #define ALC882_DIGOUT_NID 0x06 |
5480 | #define ALC882_DIGIN_NID 0x0a | |
1da177e4 | 5481 | |
d2a6d7dc | 5482 | static struct hda_channel_mode alc882_ch_modes[1] = { |
1da177e4 LT |
5483 | { 8, NULL } |
5484 | }; | |
5485 | ||
5486 | static hda_nid_t alc882_dac_nids[4] = { | |
5487 | /* front, rear, clfe, rear_surr */ | |
5488 | 0x02, 0x03, 0x04, 0x05 | |
5489 | }; | |
5490 | ||
df694daa KY |
5491 | /* identical with ALC880 */ |
5492 | #define alc882_adc_nids alc880_adc_nids | |
5493 | #define alc882_adc_nids_alt alc880_adc_nids_alt | |
1da177e4 | 5494 | |
e1406348 TI |
5495 | static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 }; |
5496 | static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 }; | |
5497 | ||
1da177e4 LT |
5498 | /* input MUX */ |
5499 | /* FIXME: should be a matrix-type input source selection */ | |
5500 | ||
5501 | static struct hda_input_mux alc882_capture_source = { | |
5502 | .num_items = 4, | |
5503 | .items = { | |
5504 | { "Mic", 0x0 }, | |
5505 | { "Front Mic", 0x1 }, | |
5506 | { "Line", 0x2 }, | |
5507 | { "CD", 0x4 }, | |
5508 | }, | |
5509 | }; | |
1da177e4 LT |
5510 | #define alc882_mux_enum_info alc_mux_enum_info |
5511 | #define alc882_mux_enum_get alc_mux_enum_get | |
5512 | ||
f12ab1e0 TI |
5513 | static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, |
5514 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
5515 | { |
5516 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
5517 | struct alc_spec *spec = codec->spec; | |
5518 | const struct hda_input_mux *imux = spec->input_mux; | |
5519 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
88c71a99 TI |
5520 | hda_nid_t nid = spec->capsrc_nids ? |
5521 | spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx]; | |
1da177e4 LT |
5522 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; |
5523 | unsigned int i, idx; | |
5524 | ||
5525 | idx = ucontrol->value.enumerated.item[0]; | |
5526 | if (idx >= imux->num_items) | |
5527 | idx = imux->num_items - 1; | |
82beb8fd | 5528 | if (*cur_val == idx) |
1da177e4 LT |
5529 | return 0; |
5530 | for (i = 0; i < imux->num_items; i++) { | |
47fd830a TI |
5531 | unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE; |
5532 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, | |
82beb8fd | 5533 | imux->items[i].index, |
47fd830a | 5534 | HDA_AMP_MUTE, v); |
1da177e4 LT |
5535 | } |
5536 | *cur_val = idx; | |
5537 | return 1; | |
5538 | } | |
5539 | ||
272a527c KY |
5540 | /* |
5541 | * 2ch mode | |
5542 | */ | |
5543 | static struct hda_verb alc882_3ST_ch2_init[] = { | |
5544 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
5545 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
5546 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
5547 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
5548 | { } /* end */ | |
5549 | }; | |
5550 | ||
5551 | /* | |
5552 | * 6ch mode | |
5553 | */ | |
5554 | static struct hda_verb alc882_3ST_ch6_init[] = { | |
5555 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5556 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
5557 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
5558 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5559 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
5560 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
5561 | { } /* end */ | |
5562 | }; | |
5563 | ||
5564 | static struct hda_channel_mode alc882_3ST_6ch_modes[2] = { | |
5565 | { 2, alc882_3ST_ch2_init }, | |
5566 | { 6, alc882_3ST_ch6_init }, | |
5567 | }; | |
5568 | ||
df694daa KY |
5569 | /* |
5570 | * 6ch mode | |
5571 | */ | |
5572 | static struct hda_verb alc882_sixstack_ch6_init[] = { | |
5573 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
5574 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5575 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5576 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5577 | { } /* end */ | |
5578 | }; | |
5579 | ||
5580 | /* | |
5581 | * 8ch mode | |
5582 | */ | |
5583 | static struct hda_verb alc882_sixstack_ch8_init[] = { | |
5584 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5585 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5586 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5587 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5588 | { } /* end */ | |
5589 | }; | |
5590 | ||
5591 | static struct hda_channel_mode alc882_sixstack_modes[2] = { | |
5592 | { 6, alc882_sixstack_ch6_init }, | |
5593 | { 8, alc882_sixstack_ch8_init }, | |
5594 | }; | |
5595 | ||
87350ad0 TI |
5596 | /* |
5597 | * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic | |
5598 | */ | |
5599 | ||
5600 | /* | |
5601 | * 2ch mode | |
5602 | */ | |
5603 | static struct hda_verb alc885_mbp_ch2_init[] = { | |
5604 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
5605 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5606 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5607 | { } /* end */ | |
5608 | }; | |
5609 | ||
5610 | /* | |
5611 | * 6ch mode | |
5612 | */ | |
5613 | static struct hda_verb alc885_mbp_ch6_init[] = { | |
5614 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5615 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5616 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
5617 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5618 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5619 | { } /* end */ | |
5620 | }; | |
5621 | ||
5622 | static struct hda_channel_mode alc885_mbp_6ch_modes[2] = { | |
5623 | { 2, alc885_mbp_ch2_init }, | |
5624 | { 6, alc885_mbp_ch6_init }, | |
5625 | }; | |
5626 | ||
5627 | ||
1da177e4 LT |
5628 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
5629 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
5630 | */ | |
c8b6bf9b | 5631 | static struct snd_kcontrol_new alc882_base_mixer[] = { |
05acb863 | 5632 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 5633 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
05acb863 | 5634 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 5635 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
05acb863 TI |
5636 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
5637 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
5638 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
5639 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
05acb863 | 5640 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 5641 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
1da177e4 LT |
5642 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
5643 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5644 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5645 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5646 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5647 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 5648 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
1da177e4 LT |
5649 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
5650 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 5651 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
1da177e4 LT |
5652 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
5653 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
5654 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
1da177e4 LT |
5655 | { } /* end */ |
5656 | }; | |
5657 | ||
87350ad0 | 5658 | static struct snd_kcontrol_new alc885_mbp3_mixer[] = { |
2134ea4f TI |
5659 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT), |
5660 | HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT), | |
5661 | HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT), | |
5662 | HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT), | |
5663 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5664 | HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
87350ad0 TI |
5665 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT), |
5666 | HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT), | |
2134ea4f | 5667 | HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT), |
87350ad0 TI |
5668 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT), |
5669 | { } /* end */ | |
5670 | }; | |
bdd148a3 KY |
5671 | static struct snd_kcontrol_new alc882_w2jc_mixer[] = { |
5672 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5673 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
5674 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5675 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5676 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5677 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5678 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
5679 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
5680 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
5681 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
5682 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
5683 | { } /* end */ | |
5684 | }; | |
5685 | ||
272a527c KY |
5686 | static struct snd_kcontrol_new alc882_targa_mixer[] = { |
5687 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5688 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
5689 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
5690 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5691 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5692 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5693 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5694 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
5695 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
96fe7cc8 | 5696 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
272a527c KY |
5697 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
5698 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
96fe7cc8 | 5699 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
272a527c KY |
5700 | { } /* end */ |
5701 | }; | |
5702 | ||
5703 | /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ??? | |
5704 | * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c | |
5705 | */ | |
5706 | static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = { | |
5707 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5708 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
5709 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
5710 | HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT), | |
5711 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5712 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5713 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5714 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5715 | HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT), | |
5716 | HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT), | |
5717 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
5718 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
96fe7cc8 | 5719 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
272a527c KY |
5720 | { } /* end */ |
5721 | }; | |
5722 | ||
914759b7 TI |
5723 | static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = { |
5724 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5725 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
5726 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
5727 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5728 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5729 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5730 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5731 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
5732 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
5733 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
5734 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
5735 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
5736 | { } /* end */ | |
5737 | }; | |
5738 | ||
df694daa KY |
5739 | static struct snd_kcontrol_new alc882_chmode_mixer[] = { |
5740 | { | |
5741 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5742 | .name = "Channel Mode", | |
5743 | .info = alc_ch_mode_info, | |
5744 | .get = alc_ch_mode_get, | |
5745 | .put = alc_ch_mode_put, | |
5746 | }, | |
5747 | { } /* end */ | |
5748 | }; | |
5749 | ||
1da177e4 LT |
5750 | static struct hda_verb alc882_init_verbs[] = { |
5751 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
05acb863 TI |
5752 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
5753 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5754 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 5755 | /* Rear mixer */ |
05acb863 TI |
5756 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
5757 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5758 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 5759 | /* CLFE mixer */ |
05acb863 TI |
5760 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
5761 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5762 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 5763 | /* Side mixer */ |
05acb863 TI |
5764 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
5765 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5766 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 5767 | |
e9edcee0 | 5768 | /* Front Pin: output 0 (0x0c) */ |
05acb863 | 5769 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 5770 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 5771 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 5772 | /* Rear Pin: output 1 (0x0d) */ |
05acb863 | 5773 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 5774 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 5775 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, |
e9edcee0 | 5776 | /* CLFE Pin: output 2 (0x0e) */ |
05acb863 | 5777 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 5778 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 5779 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, |
e9edcee0 | 5780 | /* Side Pin: output 3 (0x0f) */ |
05acb863 | 5781 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 5782 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 5783 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, |
e9edcee0 | 5784 | /* Mic (rear) pin: input vref at 80% */ |
16ded525 | 5785 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 TI |
5786 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
5787 | /* Front Mic pin: input vref at 80% */ | |
16ded525 | 5788 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 TI |
5789 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
5790 | /* Line In pin: input */ | |
05acb863 | 5791 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 TI |
5792 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
5793 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
5794 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5795 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5796 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1da177e4 | 5797 | /* CD pin widget for input */ |
05acb863 | 5798 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 LT |
5799 | |
5800 | /* FIXME: use matrix-type input source selection */ | |
5801 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
5802 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
05acb863 TI |
5803 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
5804 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5805 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5806 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 5807 | /* Input mixer2 */ |
05acb863 TI |
5808 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
5809 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5810 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5811 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 5812 | /* Input mixer3 */ |
05acb863 TI |
5813 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
5814 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5815 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5816 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5817 | /* ADC1: mute amp left and right */ | |
5818 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 5819 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
5820 | /* ADC2: mute amp left and right */ |
5821 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 5822 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
5823 | /* ADC3: mute amp left and right */ |
5824 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 5825 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
1da177e4 LT |
5826 | |
5827 | { } | |
5828 | }; | |
5829 | ||
4b146cb0 TI |
5830 | static struct hda_verb alc882_eapd_verbs[] = { |
5831 | /* change to EAPD mode */ | |
5832 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
b373bdeb | 5833 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, |
f12ab1e0 | 5834 | { } |
4b146cb0 TI |
5835 | }; |
5836 | ||
9102cd1c TD |
5837 | /* Mac Pro test */ |
5838 | static struct snd_kcontrol_new alc882_macpro_mixer[] = { | |
5839 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5840 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
5841 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT), | |
5842 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
5843 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
5844 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5845 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5846 | { } /* end */ | |
5847 | }; | |
5848 | ||
5849 | static struct hda_verb alc882_macpro_init_verbs[] = { | |
5850 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
5851 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5852 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5853 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5854 | /* Front Pin: output 0 (0x0c) */ | |
5855 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5856 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5857 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5858 | /* Front Mic pin: input vref at 80% */ | |
5859 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
5860 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5861 | /* Speaker: output */ | |
5862 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5863 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5864 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04}, | |
5865 | /* Headphone output (output 0 - 0x0c) */ | |
5866 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5867 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5868 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5869 | ||
5870 | /* FIXME: use matrix-type input source selection */ | |
5871 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
5872 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
5873 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5874 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5875 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5876 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5877 | /* Input mixer2 */ | |
5878 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5879 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5880 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5881 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5882 | /* Input mixer3 */ | |
5883 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5884 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5885 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5886 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5887 | /* ADC1: mute amp left and right */ | |
5888 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5889 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5890 | /* ADC2: mute amp left and right */ | |
5891 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5892 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5893 | /* ADC3: mute amp left and right */ | |
5894 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5895 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5896 | ||
5897 | { } | |
5898 | }; | |
f12ab1e0 | 5899 | |
87350ad0 TI |
5900 | /* Macbook Pro rev3 */ |
5901 | static struct hda_verb alc885_mbp3_init_verbs[] = { | |
5902 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
5903 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5904 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5905 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5906 | /* Rear mixer */ | |
5907 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5908 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5909 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5910 | /* Front Pin: output 0 (0x0c) */ | |
5911 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5912 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5913 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5914 | /* HP Pin: output 0 (0x0d) */ | |
5915 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, | |
5916 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5917 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5918 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
5919 | /* Mic (rear) pin: input vref at 80% */ | |
5920 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
5921 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5922 | /* Front Mic pin: input vref at 80% */ | |
5923 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
5924 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5925 | /* Line In pin: use output 1 when in LineOut mode */ | |
5926 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
5927 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5928 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
5929 | ||
5930 | /* FIXME: use matrix-type input source selection */ | |
5931 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
5932 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
5933 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5934 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5935 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5936 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5937 | /* Input mixer2 */ | |
5938 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5939 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5940 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5941 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5942 | /* Input mixer3 */ | |
5943 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5944 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5945 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5946 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5947 | /* ADC1: mute amp left and right */ | |
5948 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5949 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5950 | /* ADC2: mute amp left and right */ | |
5951 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5952 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5953 | /* ADC3: mute amp left and right */ | |
5954 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5955 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5956 | ||
5957 | { } | |
5958 | }; | |
5959 | ||
c54728d8 NF |
5960 | /* iMac 24 mixer. */ |
5961 | static struct snd_kcontrol_new alc885_imac24_mixer[] = { | |
5962 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT), | |
5963 | HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT), | |
5964 | { } /* end */ | |
5965 | }; | |
5966 | ||
5967 | /* iMac 24 init verbs. */ | |
5968 | static struct hda_verb alc885_imac24_init_verbs[] = { | |
5969 | /* Internal speakers: output 0 (0x0c) */ | |
5970 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5971 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5972 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5973 | /* Internal speakers: output 0 (0x0c) */ | |
5974 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5975 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5976 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5977 | /* Headphone: output 0 (0x0c) */ | |
5978 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5979 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5980 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5981 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
5982 | /* Front Mic: input vref at 80% */ | |
5983 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
5984 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5985 | { } | |
5986 | }; | |
5987 | ||
5988 | /* Toggle speaker-output according to the hp-jack state */ | |
5989 | static void alc885_imac24_automute(struct hda_codec *codec) | |
5990 | { | |
5991 | unsigned int present; | |
5992 | ||
5993 | present = snd_hda_codec_read(codec, 0x14, 0, | |
5994 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
5995 | snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0, |
5996 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
5997 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, | |
5998 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
c54728d8 NF |
5999 | } |
6000 | ||
6001 | /* Processes unsolicited events. */ | |
6002 | static void alc885_imac24_unsol_event(struct hda_codec *codec, | |
6003 | unsigned int res) | |
6004 | { | |
6005 | /* Headphone insertion or removal. */ | |
6006 | if ((res >> 26) == ALC880_HP_EVENT) | |
6007 | alc885_imac24_automute(codec); | |
6008 | } | |
6009 | ||
87350ad0 TI |
6010 | static void alc885_mbp3_automute(struct hda_codec *codec) |
6011 | { | |
6012 | unsigned int present; | |
6013 | ||
6014 | present = snd_hda_codec_read(codec, 0x15, 0, | |
6015 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
6016 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
6017 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
6018 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
6019 | HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE); | |
6020 | ||
6021 | } | |
6022 | static void alc885_mbp3_unsol_event(struct hda_codec *codec, | |
6023 | unsigned int res) | |
6024 | { | |
6025 | /* Headphone insertion or removal. */ | |
6026 | if ((res >> 26) == ALC880_HP_EVENT) | |
6027 | alc885_mbp3_automute(codec); | |
6028 | } | |
6029 | ||
6030 | ||
272a527c KY |
6031 | static struct hda_verb alc882_targa_verbs[] = { |
6032 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6033 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6034 | ||
6035 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6036 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
ea1fb29a | 6037 | |
272a527c KY |
6038 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ |
6039 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
6040 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
6041 | ||
6042 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
6043 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, | |
6044 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | |
6045 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | |
6046 | { } /* end */ | |
6047 | }; | |
6048 | ||
6049 | /* toggle speaker-output according to the hp-jack state */ | |
6050 | static void alc882_targa_automute(struct hda_codec *codec) | |
6051 | { | |
6052 | unsigned int present; | |
ea1fb29a | 6053 | |
272a527c KY |
6054 | present = snd_hda_codec_read(codec, 0x14, 0, |
6055 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
6056 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, |
6057 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
82beb8fd TI |
6058 | snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA, |
6059 | present ? 1 : 3); | |
272a527c KY |
6060 | } |
6061 | ||
6062 | static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res) | |
6063 | { | |
6064 | /* Looks like the unsol event is incompatible with the standard | |
6065 | * definition. 4bit tag is placed at 26 bit! | |
6066 | */ | |
6067 | if (((res >> 26) == ALC880_HP_EVENT)) { | |
6068 | alc882_targa_automute(codec); | |
6069 | } | |
6070 | } | |
6071 | ||
6072 | static struct hda_verb alc882_asus_a7j_verbs[] = { | |
6073 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6074 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6075 | ||
6076 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6077 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6078 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
ea1fb29a | 6079 | |
272a527c KY |
6080 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ |
6081 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
6082 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ | |
6083 | ||
6084 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
6085 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
6086 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
6087 | { } /* end */ | |
6088 | }; | |
6089 | ||
914759b7 TI |
6090 | static struct hda_verb alc882_asus_a7m_verbs[] = { |
6091 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6092 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6093 | ||
6094 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6095 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6096 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
ea1fb29a | 6097 | |
914759b7 TI |
6098 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ |
6099 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
6100 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ | |
6101 | ||
6102 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
6103 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
6104 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
6105 | { } /* end */ | |
6106 | }; | |
6107 | ||
9102cd1c TD |
6108 | static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) |
6109 | { | |
6110 | unsigned int gpiostate, gpiomask, gpiodir; | |
6111 | ||
6112 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, | |
6113 | AC_VERB_GET_GPIO_DATA, 0); | |
6114 | ||
6115 | if (!muted) | |
6116 | gpiostate |= (1 << pin); | |
6117 | else | |
6118 | gpiostate &= ~(1 << pin); | |
6119 | ||
6120 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, | |
6121 | AC_VERB_GET_GPIO_MASK, 0); | |
6122 | gpiomask |= (1 << pin); | |
6123 | ||
6124 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, | |
6125 | AC_VERB_GET_GPIO_DIRECTION, 0); | |
6126 | gpiodir |= (1 << pin); | |
6127 | ||
6128 | ||
6129 | snd_hda_codec_write(codec, codec->afg, 0, | |
6130 | AC_VERB_SET_GPIO_MASK, gpiomask); | |
6131 | snd_hda_codec_write(codec, codec->afg, 0, | |
6132 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); | |
6133 | ||
6134 | msleep(1); | |
6135 | ||
6136 | snd_hda_codec_write(codec, codec->afg, 0, | |
6137 | AC_VERB_SET_GPIO_DATA, gpiostate); | |
6138 | } | |
6139 | ||
7debbe51 TI |
6140 | /* set up GPIO at initialization */ |
6141 | static void alc885_macpro_init_hook(struct hda_codec *codec) | |
6142 | { | |
6143 | alc882_gpio_mute(codec, 0, 0); | |
6144 | alc882_gpio_mute(codec, 1, 0); | |
6145 | } | |
6146 | ||
6147 | /* set up GPIO and update auto-muting at initialization */ | |
6148 | static void alc885_imac24_init_hook(struct hda_codec *codec) | |
6149 | { | |
6150 | alc885_macpro_init_hook(codec); | |
6151 | alc885_imac24_automute(codec); | |
6152 | } | |
6153 | ||
df694daa KY |
6154 | /* |
6155 | * generic initialization of ADC, input mixers and output mixers | |
6156 | */ | |
6157 | static struct hda_verb alc882_auto_init_verbs[] = { | |
6158 | /* | |
6159 | * Unmute ADC0-2 and set the default input to mic-in | |
6160 | */ | |
6161 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6162 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6163 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6164 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6165 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6166 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
1da177e4 | 6167 | |
cb53c626 | 6168 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
df694daa | 6169 | * mixer widget |
f12ab1e0 TI |
6170 | * Note: PASD motherboards uses the Line In 2 as the input for |
6171 | * front panel mic (mic 2) | |
df694daa KY |
6172 | */ |
6173 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
6174 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
6175 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
6176 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6177 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6178 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
e9edcee0 | 6179 | |
df694daa KY |
6180 | /* |
6181 | * Set up output mixers (0x0c - 0x0f) | |
6182 | */ | |
6183 | /* set vol=0 to output mixers */ | |
6184 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6185 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6186 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6187 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6188 | /* set up input amps for analog loopback */ | |
6189 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
6190 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6191 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6192 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6193 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6194 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6195 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6196 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6197 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6198 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6199 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6200 | ||
6201 | /* FIXME: use matrix-type input source selection */ | |
6202 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
6203 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
6204 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
6205 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
6206 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
6207 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
6208 | /* Input mixer2 */ | |
6209 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
6210 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
6211 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
6212 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
6213 | /* Input mixer3 */ | |
6214 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
6215 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
6216 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
6217 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
6218 | ||
6219 | { } | |
6220 | }; | |
6221 | ||
6222 | /* capture mixer elements */ | |
6223 | static struct snd_kcontrol_new alc882_capture_alt_mixer[] = { | |
6224 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6225 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6226 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6227 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6228 | { | |
6229 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6230 | /* The multiple "Capture Source" controls confuse alsamixer | |
6231 | * So call somewhat different.. | |
df694daa KY |
6232 | */ |
6233 | /* .name = "Capture Source", */ | |
6234 | .name = "Input Source", | |
6235 | .count = 2, | |
6236 | .info = alc882_mux_enum_info, | |
6237 | .get = alc882_mux_enum_get, | |
6238 | .put = alc882_mux_enum_put, | |
6239 | }, | |
6240 | { } /* end */ | |
6241 | }; | |
6242 | ||
6243 | static struct snd_kcontrol_new alc882_capture_mixer[] = { | |
6244 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), | |
6245 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), | |
6246 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), | |
6247 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), | |
6248 | HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), | |
6249 | HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), | |
6250 | { | |
6251 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6252 | /* The multiple "Capture Source" controls confuse alsamixer | |
6253 | * So call somewhat different.. | |
df694daa KY |
6254 | */ |
6255 | /* .name = "Capture Source", */ | |
6256 | .name = "Input Source", | |
6257 | .count = 3, | |
6258 | .info = alc882_mux_enum_info, | |
6259 | .get = alc882_mux_enum_get, | |
6260 | .put = alc882_mux_enum_put, | |
6261 | }, | |
6262 | { } /* end */ | |
6263 | }; | |
6264 | ||
cb53c626 TI |
6265 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
6266 | #define alc882_loopbacks alc880_loopbacks | |
6267 | #endif | |
6268 | ||
df694daa KY |
6269 | /* pcm configuration: identiacal with ALC880 */ |
6270 | #define alc882_pcm_analog_playback alc880_pcm_analog_playback | |
6271 | #define alc882_pcm_analog_capture alc880_pcm_analog_capture | |
6272 | #define alc882_pcm_digital_playback alc880_pcm_digital_playback | |
6273 | #define alc882_pcm_digital_capture alc880_pcm_digital_capture | |
6274 | ||
6275 | /* | |
6276 | * configuration and preset | |
6277 | */ | |
f5fcc13c TI |
6278 | static const char *alc882_models[ALC882_MODEL_LAST] = { |
6279 | [ALC882_3ST_DIG] = "3stack-dig", | |
6280 | [ALC882_6ST_DIG] = "6stack-dig", | |
6281 | [ALC882_ARIMA] = "arima", | |
bdd148a3 | 6282 | [ALC882_W2JC] = "w2jc", |
0438a00e TI |
6283 | [ALC882_TARGA] = "targa", |
6284 | [ALC882_ASUS_A7J] = "asus-a7j", | |
6285 | [ALC882_ASUS_A7M] = "asus-a7m", | |
9102cd1c | 6286 | [ALC885_MACPRO] = "macpro", |
87350ad0 | 6287 | [ALC885_MBP3] = "mbp3", |
c54728d8 | 6288 | [ALC885_IMAC24] = "imac24", |
f5fcc13c TI |
6289 | [ALC882_AUTO] = "auto", |
6290 | }; | |
6291 | ||
6292 | static struct snd_pci_quirk alc882_cfg_tbl[] = { | |
6293 | SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG), | |
272a527c | 6294 | SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J), |
ac8842a0 | 6295 | SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J), |
914759b7 | 6296 | SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M), |
ac3e3741 | 6297 | SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC), |
c5d9f1cd | 6298 | SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG), |
7b9470d8 | 6299 | SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG), |
ac3e3741 | 6300 | SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG), |
4444704c | 6301 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG), |
ac3e3741 TI |
6302 | SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */ |
6303 | SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG), | |
6304 | SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), | |
df694daa KY |
6305 | {} |
6306 | }; | |
6307 | ||
6308 | static struct alc_config_preset alc882_presets[] = { | |
6309 | [ALC882_3ST_DIG] = { | |
6310 | .mixers = { alc882_base_mixer }, | |
6311 | .init_verbs = { alc882_init_verbs }, | |
6312 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6313 | .dac_nids = alc882_dac_nids, | |
6314 | .dig_out_nid = ALC882_DIGOUT_NID, | |
df694daa KY |
6315 | .dig_in_nid = ALC882_DIGIN_NID, |
6316 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | |
6317 | .channel_mode = alc882_ch_modes, | |
4e195a7b | 6318 | .need_dac_fix = 1, |
df694daa KY |
6319 | .input_mux = &alc882_capture_source, |
6320 | }, | |
6321 | [ALC882_6ST_DIG] = { | |
6322 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, | |
6323 | .init_verbs = { alc882_init_verbs }, | |
6324 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6325 | .dac_nids = alc882_dac_nids, | |
6326 | .dig_out_nid = ALC882_DIGOUT_NID, | |
df694daa KY |
6327 | .dig_in_nid = ALC882_DIGIN_NID, |
6328 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), | |
6329 | .channel_mode = alc882_sixstack_modes, | |
6330 | .input_mux = &alc882_capture_source, | |
6331 | }, | |
4b146cb0 TI |
6332 | [ALC882_ARIMA] = { |
6333 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, | |
6334 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs }, | |
6335 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6336 | .dac_nids = alc882_dac_nids, | |
6337 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), | |
6338 | .channel_mode = alc882_sixstack_modes, | |
6339 | .input_mux = &alc882_capture_source, | |
6340 | }, | |
bdd148a3 KY |
6341 | [ALC882_W2JC] = { |
6342 | .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer }, | |
6343 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs, | |
6344 | alc880_gpio1_init_verbs }, | |
6345 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6346 | .dac_nids = alc882_dac_nids, | |
6347 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
6348 | .channel_mode = alc880_threestack_modes, | |
6349 | .need_dac_fix = 1, | |
6350 | .input_mux = &alc882_capture_source, | |
6351 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6352 | }, | |
87350ad0 TI |
6353 | [ALC885_MBP3] = { |
6354 | .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer }, | |
6355 | .init_verbs = { alc885_mbp3_init_verbs, | |
6356 | alc880_gpio1_init_verbs }, | |
6357 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6358 | .dac_nids = alc882_dac_nids, | |
6359 | .channel_mode = alc885_mbp_6ch_modes, | |
6360 | .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes), | |
6361 | .input_mux = &alc882_capture_source, | |
6362 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6363 | .dig_in_nid = ALC882_DIGIN_NID, | |
6364 | .unsol_event = alc885_mbp3_unsol_event, | |
6365 | .init_hook = alc885_mbp3_automute, | |
6366 | }, | |
9102cd1c TD |
6367 | [ALC885_MACPRO] = { |
6368 | .mixers = { alc882_macpro_mixer }, | |
6369 | .init_verbs = { alc882_macpro_init_verbs }, | |
6370 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6371 | .dac_nids = alc882_dac_nids, | |
6372 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6373 | .dig_in_nid = ALC882_DIGIN_NID, | |
6374 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | |
6375 | .channel_mode = alc882_ch_modes, | |
6376 | .input_mux = &alc882_capture_source, | |
7debbe51 | 6377 | .init_hook = alc885_macpro_init_hook, |
9102cd1c | 6378 | }, |
c54728d8 NF |
6379 | [ALC885_IMAC24] = { |
6380 | .mixers = { alc885_imac24_mixer }, | |
6381 | .init_verbs = { alc885_imac24_init_verbs }, | |
6382 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6383 | .dac_nids = alc882_dac_nids, | |
6384 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6385 | .dig_in_nid = ALC882_DIGIN_NID, | |
6386 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | |
6387 | .channel_mode = alc882_ch_modes, | |
6388 | .input_mux = &alc882_capture_source, | |
6389 | .unsol_event = alc885_imac24_unsol_event, | |
7debbe51 | 6390 | .init_hook = alc885_imac24_init_hook, |
c54728d8 | 6391 | }, |
272a527c KY |
6392 | [ALC882_TARGA] = { |
6393 | .mixers = { alc882_targa_mixer, alc882_chmode_mixer, | |
6394 | alc882_capture_mixer }, | |
6395 | .init_verbs = { alc882_init_verbs, alc882_targa_verbs}, | |
6396 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6397 | .dac_nids = alc882_dac_nids, | |
6398 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6399 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), | |
6400 | .adc_nids = alc882_adc_nids, | |
e1406348 | 6401 | .capsrc_nids = alc882_capsrc_nids, |
272a527c KY |
6402 | .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), |
6403 | .channel_mode = alc882_3ST_6ch_modes, | |
6404 | .need_dac_fix = 1, | |
6405 | .input_mux = &alc882_capture_source, | |
6406 | .unsol_event = alc882_targa_unsol_event, | |
6407 | .init_hook = alc882_targa_automute, | |
6408 | }, | |
6409 | [ALC882_ASUS_A7J] = { | |
6410 | .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer, | |
6411 | alc882_capture_mixer }, | |
6412 | .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs}, | |
6413 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6414 | .dac_nids = alc882_dac_nids, | |
6415 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6416 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), | |
6417 | .adc_nids = alc882_adc_nids, | |
e1406348 | 6418 | .capsrc_nids = alc882_capsrc_nids, |
272a527c KY |
6419 | .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), |
6420 | .channel_mode = alc882_3ST_6ch_modes, | |
6421 | .need_dac_fix = 1, | |
6422 | .input_mux = &alc882_capture_source, | |
ea1fb29a | 6423 | }, |
914759b7 TI |
6424 | [ALC882_ASUS_A7M] = { |
6425 | .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer }, | |
6426 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs, | |
6427 | alc880_gpio1_init_verbs, | |
6428 | alc882_asus_a7m_verbs }, | |
6429 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6430 | .dac_nids = alc882_dac_nids, | |
6431 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6432 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
6433 | .channel_mode = alc880_threestack_modes, | |
6434 | .need_dac_fix = 1, | |
6435 | .input_mux = &alc882_capture_source, | |
ea1fb29a | 6436 | }, |
df694daa KY |
6437 | }; |
6438 | ||
6439 | ||
f95474ec TI |
6440 | /* |
6441 | * Pin config fixes | |
6442 | */ | |
ea1fb29a | 6443 | enum { |
f95474ec TI |
6444 | PINFIX_ABIT_AW9D_MAX |
6445 | }; | |
6446 | ||
6447 | static struct alc_pincfg alc882_abit_aw9d_pinfix[] = { | |
6448 | { 0x15, 0x01080104 }, /* side */ | |
6449 | { 0x16, 0x01011012 }, /* rear */ | |
6450 | { 0x17, 0x01016011 }, /* clfe */ | |
6451 | { } | |
6452 | }; | |
6453 | ||
6454 | static const struct alc_pincfg *alc882_pin_fixes[] = { | |
6455 | [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix, | |
6456 | }; | |
6457 | ||
6458 | static struct snd_pci_quirk alc882_pinfix_tbl[] = { | |
6459 | SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX), | |
6460 | {} | |
6461 | }; | |
6462 | ||
df694daa KY |
6463 | /* |
6464 | * BIOS auto configuration | |
6465 | */ | |
6466 | static void alc882_auto_set_output_and_unmute(struct hda_codec *codec, | |
6467 | hda_nid_t nid, int pin_type, | |
6468 | int dac_idx) | |
6469 | { | |
6470 | /* set as output */ | |
6471 | struct alc_spec *spec = codec->spec; | |
f12ab1e0 TI |
6472 | int idx; |
6473 | ||
f6c7e546 | 6474 | alc_set_pin_output(codec, nid, pin_type); |
df694daa KY |
6475 | if (spec->multiout.dac_nids[dac_idx] == 0x25) |
6476 | idx = 4; | |
6477 | else | |
6478 | idx = spec->multiout.dac_nids[dac_idx] - 2; | |
df694daa KY |
6479 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); |
6480 | ||
6481 | } | |
6482 | ||
6483 | static void alc882_auto_init_multi_out(struct hda_codec *codec) | |
6484 | { | |
6485 | struct alc_spec *spec = codec->spec; | |
6486 | int i; | |
6487 | ||
bc9f98a9 | 6488 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
df694daa | 6489 | for (i = 0; i <= HDA_SIDE; i++) { |
f12ab1e0 | 6490 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
baba8ee9 | 6491 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
df694daa | 6492 | if (nid) |
baba8ee9 | 6493 | alc882_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 6494 | i); |
df694daa KY |
6495 | } |
6496 | } | |
6497 | ||
6498 | static void alc882_auto_init_hp_out(struct hda_codec *codec) | |
6499 | { | |
6500 | struct alc_spec *spec = codec->spec; | |
6501 | hda_nid_t pin; | |
6502 | ||
eb06ed8f | 6503 | pin = spec->autocfg.hp_pins[0]; |
df694daa | 6504 | if (pin) /* connect to front */ |
f12ab1e0 TI |
6505 | /* use dac 0 */ |
6506 | alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
f6c7e546 TI |
6507 | pin = spec->autocfg.speaker_pins[0]; |
6508 | if (pin) | |
6509 | alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
df694daa KY |
6510 | } |
6511 | ||
6512 | #define alc882_is_input_pin(nid) alc880_is_input_pin(nid) | |
6513 | #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID | |
6514 | ||
6515 | static void alc882_auto_init_analog_input(struct hda_codec *codec) | |
6516 | { | |
6517 | struct alc_spec *spec = codec->spec; | |
6518 | int i; | |
6519 | ||
6520 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
6521 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
7194cae6 TI |
6522 | unsigned int vref; |
6523 | if (!nid) | |
6524 | continue; | |
6525 | vref = PIN_IN; | |
6526 | if (1 /*i <= AUTO_PIN_FRONT_MIC*/) { | |
531240ff KY |
6527 | unsigned int pincap; |
6528 | pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); | |
6529 | if ((pincap >> AC_PINCAP_VREF_SHIFT) & | |
7194cae6 TI |
6530 | AC_PINCAP_VREF_80) |
6531 | vref = PIN_VREF80; | |
df694daa | 6532 | } |
7194cae6 TI |
6533 | snd_hda_codec_write(codec, nid, 0, |
6534 | AC_VERB_SET_PIN_WIDGET_CONTROL, vref); | |
6535 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) | |
6536 | snd_hda_codec_write(codec, nid, 0, | |
6537 | AC_VERB_SET_AMP_GAIN_MUTE, | |
6538 | AMP_OUT_MUTE); | |
df694daa KY |
6539 | } |
6540 | } | |
6541 | ||
f511b01c TI |
6542 | static void alc882_auto_init_input_src(struct hda_codec *codec) |
6543 | { | |
6544 | struct alc_spec *spec = codec->spec; | |
6545 | const struct hda_input_mux *imux = spec->input_mux; | |
6546 | int c; | |
6547 | ||
6548 | for (c = 0; c < spec->num_adc_nids; c++) { | |
6549 | hda_nid_t conn_list[HDA_MAX_NUM_INPUTS]; | |
6550 | hda_nid_t nid = spec->capsrc_nids[c]; | |
6551 | int conns, mute, idx, item; | |
6552 | ||
6553 | conns = snd_hda_get_connections(codec, nid, conn_list, | |
6554 | ARRAY_SIZE(conn_list)); | |
6555 | if (conns < 0) | |
6556 | continue; | |
6557 | for (idx = 0; idx < conns; idx++) { | |
6558 | /* if the current connection is the selected one, | |
6559 | * unmute it as default - otherwise mute it | |
6560 | */ | |
6561 | mute = AMP_IN_MUTE(idx); | |
6562 | for (item = 0; item < imux->num_items; item++) { | |
6563 | if (imux->items[item].index == idx) { | |
6564 | if (spec->cur_mux[c] == item) | |
6565 | mute = AMP_IN_UNMUTE(idx); | |
6566 | break; | |
6567 | } | |
6568 | } | |
6569 | snd_hda_codec_write(codec, nid, 0, | |
6570 | AC_VERB_SET_AMP_GAIN_MUTE, mute); | |
6571 | } | |
6572 | } | |
6573 | } | |
6574 | ||
776e184e TI |
6575 | /* add mic boosts if needed */ |
6576 | static int alc_auto_add_mic_boost(struct hda_codec *codec) | |
6577 | { | |
6578 | struct alc_spec *spec = codec->spec; | |
6579 | int err; | |
6580 | hda_nid_t nid; | |
6581 | ||
6582 | nid = spec->autocfg.input_pins[AUTO_PIN_MIC]; | |
ce22e03e | 6583 | if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) { |
776e184e TI |
6584 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
6585 | "Mic Boost", | |
6586 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | |
6587 | if (err < 0) | |
6588 | return err; | |
6589 | } | |
6590 | nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]; | |
ce22e03e | 6591 | if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) { |
776e184e TI |
6592 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
6593 | "Front Mic Boost", | |
6594 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | |
6595 | if (err < 0) | |
6596 | return err; | |
6597 | } | |
6598 | return 0; | |
6599 | } | |
6600 | ||
df694daa KY |
6601 | /* almost identical with ALC880 parser... */ |
6602 | static int alc882_parse_auto_config(struct hda_codec *codec) | |
6603 | { | |
6604 | struct alc_spec *spec = codec->spec; | |
6605 | int err = alc880_parse_auto_config(codec); | |
6606 | ||
6607 | if (err < 0) | |
6608 | return err; | |
776e184e TI |
6609 | else if (!err) |
6610 | return 0; /* no config found */ | |
6611 | ||
6612 | err = alc_auto_add_mic_boost(codec); | |
6613 | if (err < 0) | |
6614 | return err; | |
6615 | ||
6616 | /* hack - override the init verbs */ | |
6617 | spec->init_verbs[0] = alc882_auto_init_verbs; | |
6618 | ||
6619 | return 1; /* config found */ | |
df694daa KY |
6620 | } |
6621 | ||
ae6b813a TI |
6622 | /* additional initialization for auto-configuration model */ |
6623 | static void alc882_auto_init(struct hda_codec *codec) | |
df694daa | 6624 | { |
f6c7e546 | 6625 | struct alc_spec *spec = codec->spec; |
df694daa KY |
6626 | alc882_auto_init_multi_out(codec); |
6627 | alc882_auto_init_hp_out(codec); | |
6628 | alc882_auto_init_analog_input(codec); | |
f511b01c | 6629 | alc882_auto_init_input_src(codec); |
f6c7e546 TI |
6630 | if (spec->unsol_event) |
6631 | alc_sku_automute(codec); | |
df694daa KY |
6632 | } |
6633 | ||
7943a8ab TI |
6634 | static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */ |
6635 | ||
df694daa KY |
6636 | static int patch_alc882(struct hda_codec *codec) |
6637 | { | |
6638 | struct alc_spec *spec; | |
6639 | int err, board_config; | |
6640 | ||
6641 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
6642 | if (spec == NULL) | |
6643 | return -ENOMEM; | |
6644 | ||
6645 | codec->spec = spec; | |
6646 | ||
f5fcc13c TI |
6647 | board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST, |
6648 | alc882_models, | |
6649 | alc882_cfg_tbl); | |
df694daa KY |
6650 | |
6651 | if (board_config < 0 || board_config >= ALC882_MODEL_LAST) { | |
081d17c4 TD |
6652 | /* Pick up systems that don't supply PCI SSID */ |
6653 | switch (codec->subsystem_id) { | |
6654 | case 0x106b0c00: /* Mac Pro */ | |
6655 | board_config = ALC885_MACPRO; | |
6656 | break; | |
c54728d8 NF |
6657 | case 0x106b1000: /* iMac 24 */ |
6658 | board_config = ALC885_IMAC24; | |
6659 | break; | |
c7e0757a | 6660 | case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */ |
87350ad0 | 6661 | case 0x106b2c00: /* Macbook Pro rev3 */ |
c7e0757a | 6662 | case 0x106b3600: /* Macbook 3.1 */ |
87350ad0 TI |
6663 | board_config = ALC885_MBP3; |
6664 | break; | |
081d17c4 | 6665 | default: |
7943a8ab TI |
6666 | /* ALC889A is handled better as ALC888-compatible */ |
6667 | if (codec->revision_id == 0x100103) { | |
6668 | alc_free(codec); | |
6669 | return patch_alc883(codec); | |
6670 | } | |
081d17c4 TD |
6671 | printk(KERN_INFO "hda_codec: Unknown model for ALC882, " |
6672 | "trying auto-probe from BIOS...\n"); | |
6673 | board_config = ALC882_AUTO; | |
6674 | } | |
df694daa KY |
6675 | } |
6676 | ||
f95474ec TI |
6677 | alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes); |
6678 | ||
df694daa KY |
6679 | if (board_config == ALC882_AUTO) { |
6680 | /* automatic parse from the BIOS config */ | |
6681 | err = alc882_parse_auto_config(codec); | |
6682 | if (err < 0) { | |
6683 | alc_free(codec); | |
6684 | return err; | |
f12ab1e0 | 6685 | } else if (!err) { |
9c7f852e TI |
6686 | printk(KERN_INFO |
6687 | "hda_codec: Cannot set up configuration " | |
6688 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
6689 | board_config = ALC882_3ST_DIG; |
6690 | } | |
6691 | } | |
6692 | ||
6693 | if (board_config != ALC882_AUTO) | |
6694 | setup_preset(spec, &alc882_presets[board_config]); | |
1da177e4 | 6695 | |
2f893286 KY |
6696 | if (codec->vendor_id == 0x10ec0885) { |
6697 | spec->stream_name_analog = "ALC885 Analog"; | |
6698 | spec->stream_name_digital = "ALC885 Digital"; | |
6699 | } else { | |
6700 | spec->stream_name_analog = "ALC882 Analog"; | |
6701 | spec->stream_name_digital = "ALC882 Digital"; | |
6702 | } | |
6703 | ||
df694daa KY |
6704 | spec->stream_analog_playback = &alc882_pcm_analog_playback; |
6705 | spec->stream_analog_capture = &alc882_pcm_analog_capture; | |
6330079f TI |
6706 | /* FIXME: setup DAC5 */ |
6707 | /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/ | |
6708 | spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture; | |
1da177e4 | 6709 | |
df694daa KY |
6710 | spec->stream_digital_playback = &alc882_pcm_digital_playback; |
6711 | spec->stream_digital_capture = &alc882_pcm_digital_capture; | |
1da177e4 | 6712 | |
f12ab1e0 | 6713 | if (!spec->adc_nids && spec->input_mux) { |
df694daa | 6714 | /* check whether NID 0x07 is valid */ |
4a471b7d | 6715 | unsigned int wcap = get_wcaps(codec, 0x07); |
f12ab1e0 TI |
6716 | /* get type */ |
6717 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
df694daa KY |
6718 | if (wcap != AC_WID_AUD_IN) { |
6719 | spec->adc_nids = alc882_adc_nids_alt; | |
6720 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt); | |
e1406348 | 6721 | spec->capsrc_nids = alc882_capsrc_nids_alt; |
f12ab1e0 TI |
6722 | spec->mixers[spec->num_mixers] = |
6723 | alc882_capture_alt_mixer; | |
df694daa KY |
6724 | spec->num_mixers++; |
6725 | } else { | |
6726 | spec->adc_nids = alc882_adc_nids; | |
6727 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids); | |
e1406348 | 6728 | spec->capsrc_nids = alc882_capsrc_nids; |
df694daa KY |
6729 | spec->mixers[spec->num_mixers] = alc882_capture_mixer; |
6730 | spec->num_mixers++; | |
6731 | } | |
6732 | } | |
1da177e4 | 6733 | |
2134ea4f TI |
6734 | spec->vmaster_nid = 0x0c; |
6735 | ||
1da177e4 | 6736 | codec->patch_ops = alc_patch_ops; |
df694daa | 6737 | if (board_config == ALC882_AUTO) |
ae6b813a | 6738 | spec->init_hook = alc882_auto_init; |
cb53c626 TI |
6739 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
6740 | if (!spec->loopback.amplist) | |
6741 | spec->loopback.amplist = alc882_loopbacks; | |
6742 | #endif | |
df694daa KY |
6743 | |
6744 | return 0; | |
6745 | } | |
6746 | ||
6747 | /* | |
9c7f852e TI |
6748 | * ALC883 support |
6749 | * | |
6750 | * ALC883 is almost identical with ALC880 but has cleaner and more flexible | |
6751 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
6752 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
6753 | * 6-channel independent captures. | |
6754 | * | |
6755 | * In addition, an independent DAC for the multi-playback (not used in this | |
6756 | * driver yet). | |
df694daa | 6757 | */ |
9c7f852e TI |
6758 | #define ALC883_DIGOUT_NID 0x06 |
6759 | #define ALC883_DIGIN_NID 0x0a | |
df694daa | 6760 | |
9c7f852e TI |
6761 | static hda_nid_t alc883_dac_nids[4] = { |
6762 | /* front, rear, clfe, rear_surr */ | |
f32a19e3 | 6763 | 0x02, 0x03, 0x04, 0x05 |
9c7f852e | 6764 | }; |
df694daa | 6765 | |
9c7f852e TI |
6766 | static hda_nid_t alc883_adc_nids[2] = { |
6767 | /* ADC1-2 */ | |
6768 | 0x08, 0x09, | |
6769 | }; | |
f12ab1e0 | 6770 | |
e1406348 TI |
6771 | static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 }; |
6772 | ||
9c7f852e TI |
6773 | /* input MUX */ |
6774 | /* FIXME: should be a matrix-type input source selection */ | |
df694daa | 6775 | |
9c7f852e TI |
6776 | static struct hda_input_mux alc883_capture_source = { |
6777 | .num_items = 4, | |
6778 | .items = { | |
6779 | { "Mic", 0x0 }, | |
6780 | { "Front Mic", 0x1 }, | |
6781 | { "Line", 0x2 }, | |
6782 | { "CD", 0x4 }, | |
6783 | }, | |
6784 | }; | |
bc9f98a9 | 6785 | |
17bba1b7 J |
6786 | static struct hda_input_mux alc883_3stack_6ch_intel = { |
6787 | .num_items = 4, | |
6788 | .items = { | |
6789 | { "Mic", 0x1 }, | |
6790 | { "Front Mic", 0x0 }, | |
6791 | { "Line", 0x2 }, | |
6792 | { "CD", 0x4 }, | |
6793 | }, | |
6794 | }; | |
6795 | ||
bc9f98a9 KY |
6796 | static struct hda_input_mux alc883_lenovo_101e_capture_source = { |
6797 | .num_items = 2, | |
6798 | .items = { | |
6799 | { "Mic", 0x1 }, | |
6800 | { "Line", 0x2 }, | |
6801 | }, | |
6802 | }; | |
6803 | ||
272a527c KY |
6804 | static struct hda_input_mux alc883_lenovo_nb0763_capture_source = { |
6805 | .num_items = 4, | |
6806 | .items = { | |
6807 | { "Mic", 0x0 }, | |
6808 | { "iMic", 0x1 }, | |
6809 | { "Line", 0x2 }, | |
6810 | { "CD", 0x4 }, | |
6811 | }, | |
6812 | }; | |
6813 | ||
fb97dc67 J |
6814 | static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = { |
6815 | .num_items = 2, | |
6816 | .items = { | |
6817 | { "Mic", 0x0 }, | |
6818 | { "Int Mic", 0x1 }, | |
6819 | }, | |
6820 | }; | |
6821 | ||
e2757d5e KY |
6822 | static struct hda_input_mux alc883_lenovo_sky_capture_source = { |
6823 | .num_items = 3, | |
6824 | .items = { | |
6825 | { "Mic", 0x0 }, | |
6826 | { "Front Mic", 0x1 }, | |
6827 | { "Line", 0x4 }, | |
6828 | }, | |
6829 | }; | |
6830 | ||
6831 | static struct hda_input_mux alc883_asus_eee1601_capture_source = { | |
6832 | .num_items = 2, | |
6833 | .items = { | |
6834 | { "Mic", 0x0 }, | |
6835 | { "Line", 0x2 }, | |
6836 | }, | |
6837 | }; | |
6838 | ||
9c7f852e TI |
6839 | #define alc883_mux_enum_info alc_mux_enum_info |
6840 | #define alc883_mux_enum_get alc_mux_enum_get | |
e1406348 TI |
6841 | /* ALC883 has the ALC882-type input selection */ |
6842 | #define alc883_mux_enum_put alc882_mux_enum_put | |
f12ab1e0 | 6843 | |
9c7f852e TI |
6844 | /* |
6845 | * 2ch mode | |
6846 | */ | |
6847 | static struct hda_channel_mode alc883_3ST_2ch_modes[1] = { | |
6848 | { 2, NULL } | |
6849 | }; | |
6850 | ||
6851 | /* | |
6852 | * 2ch mode | |
6853 | */ | |
6854 | static struct hda_verb alc883_3ST_ch2_init[] = { | |
6855 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
6856 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
6857 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
6858 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
6859 | { } /* end */ | |
6860 | }; | |
6861 | ||
b201131c TD |
6862 | /* |
6863 | * 4ch mode | |
6864 | */ | |
6865 | static struct hda_verb alc883_3ST_ch4_init[] = { | |
6866 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
6867 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
6868 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6869 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
6870 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
6871 | { } /* end */ | |
6872 | }; | |
6873 | ||
9c7f852e TI |
6874 | /* |
6875 | * 6ch mode | |
6876 | */ | |
6877 | static struct hda_verb alc883_3ST_ch6_init[] = { | |
6878 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6879 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
6880 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
6881 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6882 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
6883 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
6884 | { } /* end */ | |
6885 | }; | |
6886 | ||
b201131c | 6887 | static struct hda_channel_mode alc883_3ST_6ch_modes[3] = { |
9c7f852e | 6888 | { 2, alc883_3ST_ch2_init }, |
b201131c | 6889 | { 4, alc883_3ST_ch4_init }, |
9c7f852e TI |
6890 | { 6, alc883_3ST_ch6_init }, |
6891 | }; | |
6892 | ||
17bba1b7 J |
6893 | /* |
6894 | * 2ch mode | |
6895 | */ | |
6896 | static struct hda_verb alc883_3ST_ch2_intel_init[] = { | |
6897 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
6898 | { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
6899 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
6900 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
6901 | { } /* end */ | |
6902 | }; | |
6903 | ||
6904 | /* | |
6905 | * 4ch mode | |
6906 | */ | |
6907 | static struct hda_verb alc883_3ST_ch4_intel_init[] = { | |
6908 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
6909 | { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
6910 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6911 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
6912 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
6913 | { } /* end */ | |
6914 | }; | |
6915 | ||
6916 | /* | |
6917 | * 6ch mode | |
6918 | */ | |
6919 | static struct hda_verb alc883_3ST_ch6_intel_init[] = { | |
6920 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6921 | { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
6922 | { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
6923 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6924 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
6925 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
6926 | { } /* end */ | |
6927 | }; | |
6928 | ||
6929 | static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = { | |
6930 | { 2, alc883_3ST_ch2_intel_init }, | |
6931 | { 4, alc883_3ST_ch4_intel_init }, | |
6932 | { 6, alc883_3ST_ch6_intel_init }, | |
6933 | }; | |
6934 | ||
9c7f852e TI |
6935 | /* |
6936 | * 6ch mode | |
6937 | */ | |
6938 | static struct hda_verb alc883_sixstack_ch6_init[] = { | |
6939 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
6940 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6941 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6942 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6943 | { } /* end */ | |
6944 | }; | |
6945 | ||
6946 | /* | |
6947 | * 8ch mode | |
6948 | */ | |
6949 | static struct hda_verb alc883_sixstack_ch8_init[] = { | |
6950 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6951 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6952 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6953 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6954 | { } /* end */ | |
6955 | }; | |
6956 | ||
6957 | static struct hda_channel_mode alc883_sixstack_modes[2] = { | |
6958 | { 6, alc883_sixstack_ch6_init }, | |
6959 | { 8, alc883_sixstack_ch8_init }, | |
6960 | }; | |
6961 | ||
b373bdeb AN |
6962 | static struct hda_verb alc883_medion_eapd_verbs[] = { |
6963 | /* eanable EAPD on medion laptop */ | |
6964 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
6965 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
6966 | { } | |
6967 | }; | |
6968 | ||
9c7f852e TI |
6969 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
6970 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
6971 | */ | |
6972 | ||
6973 | static struct snd_kcontrol_new alc883_base_mixer[] = { | |
df694daa | 6974 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9c7f852e TI |
6975 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
6976 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
6977 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
6978 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
6979 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
6980 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
6981 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
6982 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
6983 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
6984 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
df694daa KY |
6985 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
6986 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6987 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6988 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6989 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 6990 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
df694daa | 6991 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
9c7f852e | 6992 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
32360416 | 6993 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
6994 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
6995 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
6996 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
6997 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6998 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6999 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
7000 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
7001 | { | |
7002 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7003 | /* .name = "Capture Source", */ | |
7004 | .name = "Input Source", | |
7005 | .count = 2, | |
7006 | .info = alc883_mux_enum_info, | |
7007 | .get = alc883_mux_enum_get, | |
7008 | .put = alc883_mux_enum_put, | |
7009 | }, | |
df694daa | 7010 | { } /* end */ |
834be88d TI |
7011 | }; |
7012 | ||
a8848bd6 AS |
7013 | static struct snd_kcontrol_new alc883_mitac_mixer[] = { |
7014 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7015 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
7016 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
7017 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
7018 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
7019 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
7020 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
7021 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7022 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7023 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7024 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7025 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
7026 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
7027 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
7028 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
7029 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
7030 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
7031 | { | |
7032 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7033 | /* .name = "Capture Source", */ | |
7034 | .name = "Input Source", | |
7035 | .count = 2, | |
7036 | .info = alc883_mux_enum_info, | |
7037 | .get = alc883_mux_enum_get, | |
7038 | .put = alc883_mux_enum_put, | |
7039 | }, | |
7040 | { } /* end */ | |
7041 | }; | |
7042 | ||
0c4cc443 | 7043 | static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = { |
368c7a95 J |
7044 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
7045 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
7046 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7047 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
7048 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7049 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7050 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7051 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7052 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
7053 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
7054 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
7055 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
7056 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
7057 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
7058 | { | |
7059 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7060 | /* .name = "Capture Source", */ | |
7061 | .name = "Input Source", | |
7062 | .count = 2, | |
7063 | .info = alc883_mux_enum_info, | |
7064 | .get = alc883_mux_enum_get, | |
7065 | .put = alc883_mux_enum_put, | |
7066 | }, | |
7067 | { } /* end */ | |
7068 | }; | |
7069 | ||
fb97dc67 J |
7070 | static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = { |
7071 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7072 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
7073 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7074 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
7075 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7076 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7077 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7078 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7079 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
7080 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
7081 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
7082 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
7083 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
7084 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
7085 | { | |
7086 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7087 | /* .name = "Capture Source", */ | |
7088 | .name = "Input Source", | |
7089 | .count = 2, | |
7090 | .info = alc883_mux_enum_info, | |
7091 | .get = alc883_mux_enum_get, | |
7092 | .put = alc883_mux_enum_put, | |
7093 | }, | |
7094 | { } /* end */ | |
7095 | }; | |
7096 | ||
9c7f852e TI |
7097 | static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = { |
7098 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7099 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
7100 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7101 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7102 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7103 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7104 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7105 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 7106 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
7107 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
7108 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 7109 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
7110 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
7111 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
7112 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
7113 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
7114 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
7115 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
7116 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
7117 | { | |
7118 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7119 | /* .name = "Capture Source", */ | |
7120 | .name = "Input Source", | |
7121 | .count = 2, | |
7122 | .info = alc883_mux_enum_info, | |
7123 | .get = alc883_mux_enum_get, | |
7124 | .put = alc883_mux_enum_put, | |
7125 | }, | |
7126 | { } /* end */ | |
7127 | }; | |
df694daa | 7128 | |
9c7f852e TI |
7129 | static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = { |
7130 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7131 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
7132 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7133 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
7134 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
7135 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
7136 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
7137 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
7138 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7139 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7140 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7141 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7142 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7143 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 7144 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
7145 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
7146 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 7147 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
7148 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
7149 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
7150 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
7151 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
7152 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
9c7f852e TI |
7153 | { |
7154 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7155 | /* .name = "Capture Source", */ | |
7156 | .name = "Input Source", | |
e2757d5e | 7157 | .count = 1, |
9c7f852e TI |
7158 | .info = alc883_mux_enum_info, |
7159 | .get = alc883_mux_enum_get, | |
7160 | .put = alc883_mux_enum_put, | |
7161 | }, | |
7162 | { } /* end */ | |
7163 | }; | |
7164 | ||
17bba1b7 J |
7165 | static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = { |
7166 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7167 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
7168 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7169 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
7170 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, | |
7171 | HDA_OUTPUT), | |
7172 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
7173 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
7174 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
7175 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
7176 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7177 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7178 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7179 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7180 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7181 | HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT), | |
7182 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
7183 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7184 | HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT), | |
7185 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7186 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
7187 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
7188 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
7189 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
7190 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
7191 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
7192 | { | |
7193 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7194 | /* .name = "Capture Source", */ | |
7195 | .name = "Input Source", | |
7196 | .count = 2, | |
7197 | .info = alc883_mux_enum_info, | |
7198 | .get = alc883_mux_enum_get, | |
7199 | .put = alc883_mux_enum_put, | |
7200 | }, | |
7201 | { } /* end */ | |
7202 | }; | |
7203 | ||
d1d985f0 | 7204 | static struct snd_kcontrol_new alc883_fivestack_mixer[] = { |
c07584c8 | 7205 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
0701e064 | 7206 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
c07584c8 | 7207 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
0701e064 | 7208 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
c07584c8 TD |
7209 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
7210 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
0701e064 TI |
7211 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
7212 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
c07584c8 TD |
7213 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
7214 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7215 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7216 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7217 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7218 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 7219 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
c07584c8 TD |
7220 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
7221 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 7222 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
c07584c8 TD |
7223 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
7224 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
7225 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
7226 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
7227 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
7228 | ||
7229 | { | |
7230 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7231 | /* .name = "Capture Source", */ | |
7232 | .name = "Input Source", | |
7233 | .count = 1, | |
7234 | .info = alc883_mux_enum_info, | |
7235 | .get = alc883_mux_enum_get, | |
7236 | .put = alc883_mux_enum_put, | |
7237 | }, | |
7238 | { } /* end */ | |
7239 | }; | |
7240 | ||
ccc656ce KY |
7241 | static struct snd_kcontrol_new alc883_tagra_mixer[] = { |
7242 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7243 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7244 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7245 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7246 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
7247 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
7248 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
7249 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
7250 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
7251 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7252 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7253 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7254 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7255 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 7256 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce KY |
7257 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
7258 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
7259 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
7260 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
7261 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
7262 | { | |
7263 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7264 | /* .name = "Capture Source", */ | |
7265 | .name = "Input Source", | |
7266 | .count = 2, | |
7267 | .info = alc883_mux_enum_info, | |
7268 | .get = alc883_mux_enum_get, | |
7269 | .put = alc883_mux_enum_put, | |
7270 | }, | |
7271 | { } /* end */ | |
f12ab1e0 | 7272 | }; |
ccc656ce KY |
7273 | |
7274 | static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = { | |
7275 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7276 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7277 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7278 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7279 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7280 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 7281 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce | 7282 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
4383fae0 J |
7283 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
7284 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
7285 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
ccc656ce KY |
7286 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
7287 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
7288 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
7289 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
7290 | { | |
7291 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7292 | /* .name = "Capture Source", */ | |
7293 | .name = "Input Source", | |
7294 | .count = 2, | |
7295 | .info = alc883_mux_enum_info, | |
7296 | .get = alc883_mux_enum_get, | |
7297 | .put = alc883_mux_enum_put, | |
7298 | }, | |
7299 | { } /* end */ | |
f12ab1e0 | 7300 | }; |
ccc656ce | 7301 | |
bc9f98a9 KY |
7302 | static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = { |
7303 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7304 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
86cd9298 TI |
7305 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
7306 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
bc9f98a9 KY |
7307 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
7308 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7309 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7310 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
7311 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
7312 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
7313 | { | |
7314 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7315 | /* .name = "Capture Source", */ | |
7316 | .name = "Input Source", | |
7317 | .count = 1, | |
7318 | .info = alc883_mux_enum_info, | |
7319 | .get = alc883_mux_enum_get, | |
7320 | .put = alc883_mux_enum_put, | |
7321 | }, | |
7322 | { } /* end */ | |
f12ab1e0 | 7323 | }; |
bc9f98a9 | 7324 | |
272a527c KY |
7325 | static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = { |
7326 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7327 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT), | |
7328 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7329 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7330 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7331 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7332 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7333 | HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7334 | HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
7335 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
7336 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
7337 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
7338 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
7339 | { | |
7340 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7341 | /* .name = "Capture Source", */ | |
7342 | .name = "Input Source", | |
7343 | .count = 2, | |
7344 | .info = alc883_mux_enum_info, | |
7345 | .get = alc883_mux_enum_get, | |
7346 | .put = alc883_mux_enum_put, | |
7347 | }, | |
7348 | { } /* end */ | |
7349 | }; | |
7350 | ||
7351 | static struct snd_kcontrol_new alc883_medion_md2_mixer[] = { | |
7352 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7353 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7354 | HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
7355 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7356 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7357 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7358 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7359 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7360 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7361 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
7362 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
7363 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
7364 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
7365 | { | |
7366 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7367 | /* .name = "Capture Source", */ | |
7368 | .name = "Input Source", | |
7369 | .count = 2, | |
7370 | .info = alc883_mux_enum_info, | |
7371 | .get = alc883_mux_enum_get, | |
7372 | .put = alc883_mux_enum_put, | |
7373 | }, | |
7374 | { } /* end */ | |
ea1fb29a | 7375 | }; |
272a527c | 7376 | |
2880a867 | 7377 | static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = { |
d1a991a6 KY |
7378 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
7379 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
2880a867 | 7380 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), |
2880a867 TD |
7381 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
7382 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
d1a991a6 KY |
7383 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
7384 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7385 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2880a867 TD |
7386 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
7387 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
7388 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
7389 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
7390 | { | |
7391 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7392 | /* .name = "Capture Source", */ | |
7393 | .name = "Input Source", | |
7394 | .count = 2, | |
7395 | .info = alc883_mux_enum_info, | |
7396 | .get = alc883_mux_enum_get, | |
7397 | .put = alc883_mux_enum_put, | |
7398 | }, | |
7399 | { } /* end */ | |
d1a991a6 | 7400 | }; |
2880a867 | 7401 | |
e2757d5e KY |
7402 | static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = { |
7403 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7404 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
7405 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT), | |
7406 | HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT), | |
7407 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", | |
7408 | 0x0d, 1, 0x0, HDA_OUTPUT), | |
7409 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT), | |
7410 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT), | |
7411 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), | |
7412 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
7413 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
7414 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7415 | HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT), | |
7416 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7417 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7418 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7419 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7420 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7421 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7422 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7423 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7424 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
7425 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
7426 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
7427 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
7428 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
7429 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
7430 | { | |
7431 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7432 | /* .name = "Capture Source", */ | |
7433 | .name = "Input Source", | |
7434 | .count = 2, | |
7435 | .info = alc883_mux_enum_info, | |
7436 | .get = alc883_mux_enum_get, | |
7437 | .put = alc883_mux_enum_put, | |
7438 | }, | |
7439 | { } /* end */ | |
7440 | }; | |
7441 | ||
7442 | static struct hda_bind_ctls alc883_bind_cap_vol = { | |
7443 | .ops = &snd_hda_bind_vol, | |
7444 | .values = { | |
7445 | HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT), | |
7446 | HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT), | |
7447 | 0 | |
7448 | }, | |
7449 | }; | |
7450 | ||
7451 | static struct hda_bind_ctls alc883_bind_cap_switch = { | |
7452 | .ops = &snd_hda_bind_sw, | |
7453 | .values = { | |
7454 | HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT), | |
7455 | HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT), | |
7456 | 0 | |
7457 | }, | |
7458 | }; | |
7459 | ||
7460 | static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = { | |
7461 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7462 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
7463 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7464 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7465 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7466 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7467 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7468 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7469 | HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol), | |
7470 | HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch), | |
7471 | { | |
7472 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7473 | /* .name = "Capture Source", */ | |
7474 | .name = "Input Source", | |
7475 | .count = 1, | |
7476 | .info = alc883_mux_enum_info, | |
7477 | .get = alc883_mux_enum_get, | |
7478 | .put = alc883_mux_enum_put, | |
7479 | }, | |
7480 | { } /* end */ | |
7481 | }; | |
7482 | ||
9c7f852e TI |
7483 | static struct snd_kcontrol_new alc883_chmode_mixer[] = { |
7484 | { | |
7485 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7486 | .name = "Channel Mode", | |
7487 | .info = alc_ch_mode_info, | |
7488 | .get = alc_ch_mode_get, | |
7489 | .put = alc_ch_mode_put, | |
7490 | }, | |
7491 | { } /* end */ | |
7492 | }; | |
7493 | ||
7494 | static struct hda_verb alc883_init_verbs[] = { | |
7495 | /* ADC1: mute amp left and right */ | |
e2757d5e | 7496 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
df694daa | 7497 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
9c7f852e TI |
7498 | /* ADC2: mute amp left and right */ |
7499 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
df694daa | 7500 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
9c7f852e TI |
7501 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ |
7502 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7503 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7504 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7505 | /* Rear mixer */ | |
7506 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7507 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7508 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7509 | /* CLFE mixer */ | |
7510 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7511 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7512 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7513 | /* Side mixer */ | |
7514 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7515 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7516 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
df694daa | 7517 | |
cb53c626 TI |
7518 | /* mute analog input loopbacks */ |
7519 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7520 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7521 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
7522 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
7523 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa | 7524 | |
9c7f852e TI |
7525 | /* Front Pin: output 0 (0x0c) */ |
7526 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7527 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7528 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7529 | /* Rear Pin: output 1 (0x0d) */ | |
7530 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7531 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7532 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
7533 | /* CLFE Pin: output 2 (0x0e) */ | |
7534 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7535 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7536 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
7537 | /* Side Pin: output 3 (0x0f) */ | |
7538 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7539 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7540 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
7541 | /* Mic (rear) pin: input vref at 80% */ | |
7542 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
7543 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
7544 | /* Front Mic pin: input vref at 80% */ | |
7545 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
7546 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
7547 | /* Line In pin: input */ | |
7548 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
7549 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
7550 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
7551 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7552 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7553 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7554 | /* CD pin widget for input */ | |
7555 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
7556 | ||
7557 | /* FIXME: use matrix-type input source selection */ | |
7558 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
7559 | /* Input mixer2 */ | |
7560 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
e2757d5e KY |
7561 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
7562 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
7563 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9c7f852e TI |
7564 | /* Input mixer3 */ |
7565 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
e2757d5e KY |
7566 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
7567 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
7568 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9c7f852e TI |
7569 | { } |
7570 | }; | |
7571 | ||
a8848bd6 AS |
7572 | /* toggle speaker-output according to the hp-jack state */ |
7573 | static void alc883_mitac_hp_automute(struct hda_codec *codec) | |
7574 | { | |
7575 | unsigned int present; | |
7576 | ||
7577 | present = snd_hda_codec_read(codec, 0x15, 0, | |
7578 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
7579 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
7580 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7581 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
7582 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7583 | } | |
7584 | ||
7585 | /* auto-toggle front mic */ | |
7586 | /* | |
7587 | static void alc883_mitac_mic_automute(struct hda_codec *codec) | |
7588 | { | |
7589 | unsigned int present; | |
7590 | unsigned char bits; | |
7591 | ||
7592 | present = snd_hda_codec_read(codec, 0x18, 0, | |
7593 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
7594 | bits = present ? HDA_AMP_MUTE : 0; | |
7595 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); | |
7596 | } | |
7597 | */ | |
7598 | ||
7599 | static void alc883_mitac_automute(struct hda_codec *codec) | |
7600 | { | |
7601 | alc883_mitac_hp_automute(codec); | |
7602 | /* alc883_mitac_mic_automute(codec); */ | |
7603 | } | |
7604 | ||
7605 | static void alc883_mitac_unsol_event(struct hda_codec *codec, | |
7606 | unsigned int res) | |
7607 | { | |
7608 | switch (res >> 26) { | |
7609 | case ALC880_HP_EVENT: | |
7610 | alc883_mitac_hp_automute(codec); | |
7611 | break; | |
7612 | case ALC880_MIC_EVENT: | |
7613 | /* alc883_mitac_mic_automute(codec); */ | |
7614 | break; | |
7615 | } | |
7616 | } | |
7617 | ||
7618 | static struct hda_verb alc883_mitac_verbs[] = { | |
7619 | /* HP */ | |
7620 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7621 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7622 | /* Subwoofer */ | |
7623 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
7624 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7625 | ||
7626 | /* enable unsolicited event */ | |
7627 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7628 | /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */ | |
7629 | ||
7630 | { } /* end */ | |
7631 | }; | |
7632 | ||
0c4cc443 | 7633 | static struct hda_verb alc883_clevo_m720_verbs[] = { |
368c7a95 J |
7634 | /* HP */ |
7635 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7636 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7637 | /* Int speaker */ | |
7638 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
7639 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7640 | ||
7641 | /* enable unsolicited event */ | |
7642 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
0c4cc443 | 7643 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, |
368c7a95 J |
7644 | |
7645 | { } /* end */ | |
7646 | }; | |
7647 | ||
fb97dc67 J |
7648 | static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = { |
7649 | /* HP */ | |
7650 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7651 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7652 | /* Subwoofer */ | |
7653 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
7654 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7655 | ||
7656 | /* enable unsolicited event */ | |
7657 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7658 | ||
7659 | { } /* end */ | |
7660 | }; | |
7661 | ||
ccc656ce KY |
7662 | static struct hda_verb alc883_tagra_verbs[] = { |
7663 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7664 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7665 | ||
7666 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7667 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
ea1fb29a | 7668 | |
ccc656ce KY |
7669 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ |
7670 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
7671 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
7672 | ||
7673 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
f12ab1e0 TI |
7674 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
7675 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | |
7676 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | |
ccc656ce KY |
7677 | |
7678 | { } /* end */ | |
7679 | }; | |
7680 | ||
bc9f98a9 KY |
7681 | static struct hda_verb alc883_lenovo_101e_verbs[] = { |
7682 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7683 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN}, | |
7684 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN}, | |
7685 | { } /* end */ | |
7686 | }; | |
7687 | ||
272a527c KY |
7688 | static struct hda_verb alc883_lenovo_nb0763_verbs[] = { |
7689 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7690 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7691 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7692 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7693 | { } /* end */ | |
7694 | }; | |
7695 | ||
7696 | static struct hda_verb alc888_lenovo_ms7195_verbs[] = { | |
7697 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7698 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7699 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7700 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN}, | |
7701 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7702 | { } /* end */ | |
7703 | }; | |
7704 | ||
189609ae KY |
7705 | static struct hda_verb alc883_haier_w66_verbs[] = { |
7706 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7707 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7708 | ||
7709 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7710 | ||
7711 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7712 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7713 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7714 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7715 | { } /* end */ | |
7716 | }; | |
7717 | ||
e2757d5e KY |
7718 | static struct hda_verb alc888_lenovo_sky_verbs[] = { |
7719 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7720 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7721 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7722 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7723 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7724 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7725 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7726 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7727 | { } /* end */ | |
7728 | }; | |
7729 | ||
4723c022 | 7730 | static struct hda_verb alc888_3st_hp_verbs[] = { |
8341de60 | 7731 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */ |
f32a19e3 HRK |
7732 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */ |
7733 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */ | |
8341de60 CM |
7734 | { } |
7735 | }; | |
7736 | ||
5795b9e6 | 7737 | static struct hda_verb alc888_6st_dell_verbs[] = { |
5795b9e6 CM |
7738 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
7739 | { } | |
7740 | }; | |
7741 | ||
4723c022 | 7742 | static struct hda_verb alc888_3st_hp_2ch_init[] = { |
8341de60 CM |
7743 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
7744 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7745 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
7746 | { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7747 | { } | |
7748 | }; | |
7749 | ||
4723c022 | 7750 | static struct hda_verb alc888_3st_hp_6ch_init[] = { |
8341de60 CM |
7751 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
7752 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7753 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7754 | { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7755 | { } | |
7756 | }; | |
7757 | ||
4723c022 CM |
7758 | static struct hda_channel_mode alc888_3st_hp_modes[2] = { |
7759 | { 2, alc888_3st_hp_2ch_init }, | |
7760 | { 6, alc888_3st_hp_6ch_init }, | |
8341de60 CM |
7761 | }; |
7762 | ||
272a527c KY |
7763 | /* toggle front-jack and RCA according to the hp-jack state */ |
7764 | static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec) | |
7765 | { | |
7766 | unsigned int present; | |
ea1fb29a | 7767 | |
272a527c KY |
7768 | present = snd_hda_codec_read(codec, 0x1b, 0, |
7769 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
7770 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
7771 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7772 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
7773 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c KY |
7774 | } |
7775 | ||
7776 | /* toggle RCA according to the front-jack state */ | |
7777 | static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec) | |
7778 | { | |
7779 | unsigned int present; | |
ea1fb29a | 7780 | |
272a527c KY |
7781 | present = snd_hda_codec_read(codec, 0x14, 0, |
7782 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
7783 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
7784 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c | 7785 | } |
47fd830a | 7786 | |
272a527c KY |
7787 | static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec, |
7788 | unsigned int res) | |
7789 | { | |
7790 | if ((res >> 26) == ALC880_HP_EVENT) | |
7791 | alc888_lenovo_ms7195_front_automute(codec); | |
7792 | if ((res >> 26) == ALC880_FRONT_EVENT) | |
7793 | alc888_lenovo_ms7195_rca_automute(codec); | |
7794 | } | |
7795 | ||
7796 | static struct hda_verb alc883_medion_md2_verbs[] = { | |
7797 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7798 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7799 | ||
7800 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7801 | ||
7802 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7803 | { } /* end */ | |
7804 | }; | |
7805 | ||
7806 | /* toggle speaker-output according to the hp-jack state */ | |
7807 | static void alc883_medion_md2_automute(struct hda_codec *codec) | |
7808 | { | |
7809 | unsigned int present; | |
ea1fb29a | 7810 | |
272a527c KY |
7811 | present = snd_hda_codec_read(codec, 0x14, 0, |
7812 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
7813 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
7814 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c KY |
7815 | } |
7816 | ||
7817 | static void alc883_medion_md2_unsol_event(struct hda_codec *codec, | |
7818 | unsigned int res) | |
7819 | { | |
7820 | if ((res >> 26) == ALC880_HP_EVENT) | |
7821 | alc883_medion_md2_automute(codec); | |
7822 | } | |
7823 | ||
ccc656ce KY |
7824 | /* toggle speaker-output according to the hp-jack state */ |
7825 | static void alc883_tagra_automute(struct hda_codec *codec) | |
7826 | { | |
7827 | unsigned int present; | |
f12ab1e0 | 7828 | unsigned char bits; |
ccc656ce KY |
7829 | |
7830 | present = snd_hda_codec_read(codec, 0x14, 0, | |
7831 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
7832 | bits = present ? HDA_AMP_MUTE : 0; |
7833 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
7834 | HDA_AMP_MUTE, bits); | |
82beb8fd TI |
7835 | snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA, |
7836 | present ? 1 : 3); | |
ccc656ce KY |
7837 | } |
7838 | ||
7839 | static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res) | |
7840 | { | |
7841 | if ((res >> 26) == ALC880_HP_EVENT) | |
7842 | alc883_tagra_automute(codec); | |
7843 | } | |
7844 | ||
368c7a95 | 7845 | /* toggle speaker-output according to the hp-jack state */ |
0c4cc443 | 7846 | static void alc883_clevo_m720_hp_automute(struct hda_codec *codec) |
368c7a95 J |
7847 | { |
7848 | unsigned int present; | |
7849 | unsigned char bits; | |
7850 | ||
7851 | present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0) | |
7852 | & AC_PINSENSE_PRESENCE; | |
7853 | bits = present ? HDA_AMP_MUTE : 0; | |
7854 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
7855 | HDA_AMP_MUTE, bits); | |
7856 | } | |
7857 | ||
0c4cc443 HRK |
7858 | static void alc883_clevo_m720_mic_automute(struct hda_codec *codec) |
7859 | { | |
7860 | unsigned int present; | |
7861 | ||
7862 | present = snd_hda_codec_read(codec, 0x18, 0, | |
7863 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
7864 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, | |
7865 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7866 | } | |
7867 | ||
7868 | static void alc883_clevo_m720_automute(struct hda_codec *codec) | |
7869 | { | |
7870 | alc883_clevo_m720_hp_automute(codec); | |
7871 | alc883_clevo_m720_mic_automute(codec); | |
7872 | } | |
7873 | ||
7874 | static void alc883_clevo_m720_unsol_event(struct hda_codec *codec, | |
368c7a95 J |
7875 | unsigned int res) |
7876 | { | |
0c4cc443 HRK |
7877 | switch (res >> 26) { |
7878 | case ALC880_HP_EVENT: | |
7879 | alc883_clevo_m720_hp_automute(codec); | |
7880 | break; | |
7881 | case ALC880_MIC_EVENT: | |
7882 | alc883_clevo_m720_mic_automute(codec); | |
7883 | break; | |
7884 | } | |
368c7a95 J |
7885 | } |
7886 | ||
fb97dc67 J |
7887 | /* toggle speaker-output according to the hp-jack state */ |
7888 | static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec) | |
7889 | { | |
7890 | unsigned int present; | |
7891 | unsigned char bits; | |
7892 | ||
7893 | present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0) | |
7894 | & AC_PINSENSE_PRESENCE; | |
7895 | bits = present ? HDA_AMP_MUTE : 0; | |
7896 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
7897 | HDA_AMP_MUTE, bits); | |
7898 | } | |
7899 | ||
7900 | static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec, | |
7901 | unsigned int res) | |
7902 | { | |
7903 | if ((res >> 26) == ALC880_HP_EVENT) | |
7904 | alc883_2ch_fujitsu_pi2515_automute(codec); | |
7905 | } | |
7906 | ||
189609ae KY |
7907 | static void alc883_haier_w66_automute(struct hda_codec *codec) |
7908 | { | |
7909 | unsigned int present; | |
7910 | unsigned char bits; | |
7911 | ||
7912 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
7913 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
7914 | bits = present ? 0x80 : 0; | |
7915 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
7916 | 0x80, bits); | |
7917 | } | |
7918 | ||
7919 | static void alc883_haier_w66_unsol_event(struct hda_codec *codec, | |
7920 | unsigned int res) | |
7921 | { | |
7922 | if ((res >> 26) == ALC880_HP_EVENT) | |
7923 | alc883_haier_w66_automute(codec); | |
7924 | } | |
7925 | ||
bc9f98a9 KY |
7926 | static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec) |
7927 | { | |
7928 | unsigned int present; | |
f12ab1e0 | 7929 | unsigned char bits; |
bc9f98a9 KY |
7930 | |
7931 | present = snd_hda_codec_read(codec, 0x14, 0, | |
7932 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
7933 | bits = present ? HDA_AMP_MUTE : 0; |
7934 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
7935 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
7936 | } |
7937 | ||
7938 | static void alc883_lenovo_101e_all_automute(struct hda_codec *codec) | |
7939 | { | |
7940 | unsigned int present; | |
f12ab1e0 | 7941 | unsigned char bits; |
bc9f98a9 KY |
7942 | |
7943 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
7944 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
7945 | bits = present ? HDA_AMP_MUTE : 0; |
7946 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
7947 | HDA_AMP_MUTE, bits); | |
7948 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
7949 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
7950 | } |
7951 | ||
7952 | static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec, | |
7953 | unsigned int res) | |
7954 | { | |
7955 | if ((res >> 26) == ALC880_HP_EVENT) | |
7956 | alc883_lenovo_101e_all_automute(codec); | |
7957 | if ((res >> 26) == ALC880_FRONT_EVENT) | |
7958 | alc883_lenovo_101e_ispeaker_automute(codec); | |
7959 | } | |
7960 | ||
676a9b53 TI |
7961 | /* toggle speaker-output according to the hp-jack state */ |
7962 | static void alc883_acer_aspire_automute(struct hda_codec *codec) | |
7963 | { | |
7964 | unsigned int present; | |
ea1fb29a | 7965 | |
676a9b53 TI |
7966 | present = snd_hda_codec_read(codec, 0x14, 0, |
7967 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
7968 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
7969 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7970 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
7971 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7972 | } | |
7973 | ||
7974 | static void alc883_acer_aspire_unsol_event(struct hda_codec *codec, | |
7975 | unsigned int res) | |
7976 | { | |
7977 | if ((res >> 26) == ALC880_HP_EVENT) | |
7978 | alc883_acer_aspire_automute(codec); | |
7979 | } | |
7980 | ||
d1a991a6 KY |
7981 | static struct hda_verb alc883_acer_eapd_verbs[] = { |
7982 | /* HP Pin: output 0 (0x0c) */ | |
7983 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7984 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7985 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7986 | /* Front Pin: output 0 (0x0c) */ | |
676a9b53 TI |
7987 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
7988 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
d1a991a6 | 7989 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
d1a991a6 KY |
7990 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, |
7991 | /* eanable EAPD on medion laptop */ | |
7992 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
7993 | {0x20, AC_VERB_SET_PROC_COEF, 0x3050}, | |
676a9b53 TI |
7994 | /* enable unsolicited event */ |
7995 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
d1a991a6 KY |
7996 | { } |
7997 | }; | |
7998 | ||
5795b9e6 CM |
7999 | static void alc888_6st_dell_front_automute(struct hda_codec *codec) |
8000 | { | |
8001 | unsigned int present; | |
ea1fb29a | 8002 | |
5795b9e6 CM |
8003 | present = snd_hda_codec_read(codec, 0x1b, 0, |
8004 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
8005 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
8006 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
8007 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
8008 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
8009 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
8010 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
8011 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
8012 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
8013 | } | |
8014 | ||
8015 | static void alc888_6st_dell_unsol_event(struct hda_codec *codec, | |
8016 | unsigned int res) | |
8017 | { | |
8018 | switch (res >> 26) { | |
8019 | case ALC880_HP_EVENT: | |
8020 | printk("hp_event\n"); | |
8021 | alc888_6st_dell_front_automute(codec); | |
8022 | break; | |
8023 | } | |
8024 | } | |
8025 | ||
e2757d5e KY |
8026 | static void alc888_lenovo_sky_front_automute(struct hda_codec *codec) |
8027 | { | |
8028 | unsigned int mute; | |
8029 | unsigned int present; | |
8030 | ||
8031 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); | |
8032 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
8033 | AC_VERB_GET_PIN_SENSE, 0); | |
8034 | present = (present & 0x80000000) != 0; | |
8035 | if (present) { | |
8036 | /* mute internal speaker */ | |
8037 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
8038 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
8039 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
8040 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
8041 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
8042 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
8043 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
8044 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
8045 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, | |
8046 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
8047 | } else { | |
8048 | /* unmute internal speaker if necessary */ | |
8049 | mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); | |
8050 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
8051 | HDA_AMP_MUTE, mute); | |
8052 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
8053 | HDA_AMP_MUTE, mute); | |
8054 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
8055 | HDA_AMP_MUTE, mute); | |
8056 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
8057 | HDA_AMP_MUTE, mute); | |
8058 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, | |
8059 | HDA_AMP_MUTE, mute); | |
8060 | } | |
8061 | } | |
8062 | ||
8063 | static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec, | |
8064 | unsigned int res) | |
8065 | { | |
8066 | if ((res >> 26) == ALC880_HP_EVENT) | |
8067 | alc888_lenovo_sky_front_automute(codec); | |
8068 | } | |
8069 | ||
9c7f852e TI |
8070 | /* |
8071 | * generic initialization of ADC, input mixers and output mixers | |
8072 | */ | |
8073 | static struct hda_verb alc883_auto_init_verbs[] = { | |
8074 | /* | |
8075 | * Unmute ADC0-2 and set the default input to mic-in | |
8076 | */ | |
8077 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8078 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8079 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8080 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8081 | ||
cb53c626 | 8082 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
9c7f852e | 8083 | * mixer widget |
f12ab1e0 TI |
8084 | * Note: PASD motherboards uses the Line In 2 as the input for |
8085 | * front panel mic (mic 2) | |
9c7f852e TI |
8086 | */ |
8087 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
8088 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
8089 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
8090 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
8091 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
8092 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9c7f852e TI |
8093 | |
8094 | /* | |
8095 | * Set up output mixers (0x0c - 0x0f) | |
8096 | */ | |
8097 | /* set vol=0 to output mixers */ | |
8098 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8099 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8100 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8101 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8102 | /* set up input amps for analog loopback */ | |
8103 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
8104 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8105 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8106 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8107 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8108 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8109 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8110 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8111 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8112 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8113 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8114 | ||
8115 | /* FIXME: use matrix-type input source selection */ | |
8116 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
8117 | /* Input mixer1 */ | |
8118 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8119 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8120 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 8121 | /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */ |
9c7f852e TI |
8122 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
8123 | /* Input mixer2 */ | |
8124 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8125 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8126 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 8127 | /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */ |
e3cde64a | 8128 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
9c7f852e TI |
8129 | |
8130 | { } | |
8131 | }; | |
8132 | ||
8133 | /* capture mixer elements */ | |
8134 | static struct snd_kcontrol_new alc883_capture_mixer[] = { | |
8135 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
8136 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
8137 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
8138 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
8139 | { | |
8140 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
8141 | /* The multiple "Capture Source" controls confuse alsamixer | |
8142 | * So call somewhat different.. | |
9c7f852e TI |
8143 | */ |
8144 | /* .name = "Capture Source", */ | |
8145 | .name = "Input Source", | |
8146 | .count = 2, | |
8147 | .info = alc882_mux_enum_info, | |
8148 | .get = alc882_mux_enum_get, | |
8149 | .put = alc882_mux_enum_put, | |
8150 | }, | |
8151 | { } /* end */ | |
8152 | }; | |
8153 | ||
e2757d5e KY |
8154 | static struct hda_verb alc888_asus_m90v_verbs[] = { |
8155 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
8156 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
8157 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8158 | /* enable unsolicited event */ | |
8159 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
8160 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, | |
8161 | { } /* end */ | |
8162 | }; | |
8163 | ||
8164 | static void alc883_nb_mic_automute(struct hda_codec *codec) | |
8165 | { | |
8166 | unsigned int present; | |
8167 | ||
8168 | present = snd_hda_codec_read(codec, 0x18, 0, | |
8169 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
8170 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
8171 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | |
8172 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
8173 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); | |
8174 | } | |
8175 | ||
8176 | static void alc883_M90V_speaker_automute(struct hda_codec *codec) | |
8177 | { | |
8178 | unsigned int present; | |
8179 | unsigned char bits; | |
8180 | ||
8181 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
8182 | AC_VERB_GET_PIN_SENSE, 0) | |
8183 | & AC_PINSENSE_PRESENCE; | |
8184 | bits = present ? 0 : PIN_OUT; | |
8185 | snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8186 | bits); | |
8187 | snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8188 | bits); | |
8189 | snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8190 | bits); | |
8191 | } | |
8192 | ||
8193 | static void alc883_mode2_unsol_event(struct hda_codec *codec, | |
8194 | unsigned int res) | |
8195 | { | |
8196 | switch (res >> 26) { | |
8197 | case ALC880_HP_EVENT: | |
8198 | alc883_M90V_speaker_automute(codec); | |
8199 | break; | |
8200 | case ALC880_MIC_EVENT: | |
8201 | alc883_nb_mic_automute(codec); | |
8202 | break; | |
8203 | } | |
8204 | } | |
8205 | ||
8206 | static void alc883_mode2_inithook(struct hda_codec *codec) | |
8207 | { | |
8208 | alc883_M90V_speaker_automute(codec); | |
8209 | alc883_nb_mic_automute(codec); | |
8210 | } | |
8211 | ||
8212 | static struct hda_verb alc888_asus_eee1601_verbs[] = { | |
8213 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
8214 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
8215 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
8216 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8217 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
8218 | {0x20, AC_VERB_SET_COEF_INDEX, 0x0b}, | |
8219 | {0x20, AC_VERB_SET_PROC_COEF, 0x0838}, | |
8220 | /* enable unsolicited event */ | |
8221 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
8222 | { } /* end */ | |
8223 | }; | |
8224 | ||
8225 | static void alc883_eee1601_speaker_automute(struct hda_codec *codec) | |
8226 | { | |
8227 | unsigned int present; | |
8228 | unsigned char bits; | |
8229 | ||
8230 | present = snd_hda_codec_read(codec, 0x14, 0, | |
8231 | AC_VERB_GET_PIN_SENSE, 0) | |
8232 | & AC_PINSENSE_PRESENCE; | |
8233 | bits = present ? 0 : PIN_OUT; | |
8234 | snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8235 | bits); | |
8236 | } | |
8237 | ||
8238 | static void alc883_eee1601_unsol_event(struct hda_codec *codec, | |
8239 | unsigned int res) | |
8240 | { | |
8241 | switch (res >> 26) { | |
8242 | case ALC880_HP_EVENT: | |
8243 | alc883_eee1601_speaker_automute(codec); | |
8244 | break; | |
8245 | } | |
8246 | } | |
8247 | ||
8248 | static void alc883_eee1601_inithook(struct hda_codec *codec) | |
8249 | { | |
8250 | alc883_eee1601_speaker_automute(codec); | |
8251 | } | |
8252 | ||
cb53c626 TI |
8253 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
8254 | #define alc883_loopbacks alc880_loopbacks | |
8255 | #endif | |
8256 | ||
9c7f852e TI |
8257 | /* pcm configuration: identiacal with ALC880 */ |
8258 | #define alc883_pcm_analog_playback alc880_pcm_analog_playback | |
8259 | #define alc883_pcm_analog_capture alc880_pcm_analog_capture | |
6330079f | 8260 | #define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture |
9c7f852e TI |
8261 | #define alc883_pcm_digital_playback alc880_pcm_digital_playback |
8262 | #define alc883_pcm_digital_capture alc880_pcm_digital_capture | |
8263 | ||
8264 | /* | |
8265 | * configuration and preset | |
8266 | */ | |
f5fcc13c TI |
8267 | static const char *alc883_models[ALC883_MODEL_LAST] = { |
8268 | [ALC883_3ST_2ch_DIG] = "3stack-dig", | |
8269 | [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig", | |
8270 | [ALC883_3ST_6ch] = "3stack-6ch", | |
8271 | [ALC883_6ST_DIG] = "6stack-dig", | |
8272 | [ALC883_TARGA_DIG] = "targa-dig", | |
8273 | [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig", | |
f5fcc13c | 8274 | [ALC883_ACER] = "acer", |
2880a867 | 8275 | [ALC883_ACER_ASPIRE] = "acer-aspire", |
f5fcc13c | 8276 | [ALC883_MEDION] = "medion", |
272a527c | 8277 | [ALC883_MEDION_MD2] = "medion-md2", |
f5fcc13c | 8278 | [ALC883_LAPTOP_EAPD] = "laptop-eapd", |
bc9f98a9 | 8279 | [ALC883_LENOVO_101E_2ch] = "lenovo-101e", |
272a527c KY |
8280 | [ALC883_LENOVO_NB0763] = "lenovo-nb0763", |
8281 | [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig", | |
e2757d5e | 8282 | [ALC888_LENOVO_SKY] = "lenovo-sky", |
189609ae | 8283 | [ALC883_HAIER_W66] = "haier-w66", |
4723c022 | 8284 | [ALC888_3ST_HP] = "3stack-hp", |
5795b9e6 | 8285 | [ALC888_6ST_DELL] = "6stack-dell", |
a8848bd6 | 8286 | [ALC883_MITAC] = "mitac", |
0c4cc443 | 8287 | [ALC883_CLEVO_M720] = "clevo-m720", |
fb97dc67 | 8288 | [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515", |
17bba1b7 | 8289 | [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel", |
f5fcc13c TI |
8290 | [ALC883_AUTO] = "auto", |
8291 | }; | |
8292 | ||
8293 | static struct snd_pci_quirk alc883_cfg_tbl[] = { | |
8294 | SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG), | |
ac3e3741 TI |
8295 | SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE), |
8296 | SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE), | |
8297 | SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE), | |
0b18cb18 | 8298 | SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE), |
ac3e3741 | 8299 | SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */ |
5795b9e6 | 8300 | SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL), |
febe3375 | 8301 | SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG), |
ac3e3741 TI |
8302 | SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP), |
8303 | SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP), | |
5d85f8d0 | 8304 | SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG), |
ac3e3741 | 8305 | SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG), |
e2757d5e KY |
8306 | SND_PCI_QUIRK(0x1043, 0x8317, "Asus M90V", ALC888_ASUS_M90V), |
8307 | SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601), | |
97ec710c | 8308 | SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG), |
f5fcc13c | 8309 | SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG), |
ac3e3741 TI |
8310 | SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC), |
8311 | SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD), | |
e2757d5e | 8312 | SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL), |
ac3e3741 | 8313 | SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch), |
57b14f24 | 8314 | SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG), |
6f3bf657 | 8315 | SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG), |
bba8dee7 | 8316 | SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG), |
ac3e3741 | 8317 | SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG), |
4383fae0 | 8318 | SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG), |
dd146a60 | 8319 | SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG), |
82808236 | 8320 | SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG), |
f5fcc13c | 8321 | SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG), |
ac3e3741 | 8322 | SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG), |
f5fcc13c TI |
8323 | SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG), |
8324 | SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG), | |
ac3e3741 | 8325 | SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG), |
64ca1c29 | 8326 | SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG), |
f5fcc13c TI |
8327 | SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG), |
8328 | SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG), | |
8329 | SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG), | |
ac3e3741 TI |
8330 | SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG), |
8331 | SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG), | |
8332 | SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG), | |
86d34b7e | 8333 | SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG), |
ac3e3741 TI |
8334 | SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG), |
8335 | SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG), | |
f5fcc13c | 8336 | SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG), |
ac3e3741 | 8337 | SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG), |
0c4cc443 HRK |
8338 | SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720), |
8339 | SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720), | |
ac3e3741 | 8340 | SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD), |
e60623b4 | 8341 | SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch), |
f5fcc13c | 8342 | SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), |
fb97dc67 | 8343 | SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515), |
272a527c | 8344 | SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch), |
272a527c | 8345 | SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763), |
ac3e3741 TI |
8346 | SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763), |
8347 | SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763), | |
e2757d5e | 8348 | SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY), |
272a527c | 8349 | SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2), |
0b167bf4 | 8350 | SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG), |
189609ae | 8351 | SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66), |
17bba1b7 J |
8352 | SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL), |
8353 | SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL), | |
ac3e3741 | 8354 | SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), |
9c7f852e TI |
8355 | {} |
8356 | }; | |
8357 | ||
8358 | static struct alc_config_preset alc883_presets[] = { | |
8359 | [ALC883_3ST_2ch_DIG] = { | |
8360 | .mixers = { alc883_3ST_2ch_mixer }, | |
8361 | .init_verbs = { alc883_init_verbs }, | |
8362 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8363 | .dac_nids = alc883_dac_nids, | |
8364 | .dig_out_nid = ALC883_DIGOUT_NID, | |
9c7f852e TI |
8365 | .dig_in_nid = ALC883_DIGIN_NID, |
8366 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
8367 | .channel_mode = alc883_3ST_2ch_modes, | |
8368 | .input_mux = &alc883_capture_source, | |
8369 | }, | |
8370 | [ALC883_3ST_6ch_DIG] = { | |
8371 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
8372 | .init_verbs = { alc883_init_verbs }, | |
8373 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8374 | .dac_nids = alc883_dac_nids, | |
8375 | .dig_out_nid = ALC883_DIGOUT_NID, | |
9c7f852e TI |
8376 | .dig_in_nid = ALC883_DIGIN_NID, |
8377 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
8378 | .channel_mode = alc883_3ST_6ch_modes, | |
4e195a7b | 8379 | .need_dac_fix = 1, |
9c7f852e | 8380 | .input_mux = &alc883_capture_source, |
f12ab1e0 | 8381 | }, |
9c7f852e TI |
8382 | [ALC883_3ST_6ch] = { |
8383 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
8384 | .init_verbs = { alc883_init_verbs }, | |
8385 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8386 | .dac_nids = alc883_dac_nids, | |
9c7f852e TI |
8387 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), |
8388 | .channel_mode = alc883_3ST_6ch_modes, | |
4e195a7b | 8389 | .need_dac_fix = 1, |
9c7f852e | 8390 | .input_mux = &alc883_capture_source, |
f12ab1e0 | 8391 | }, |
17bba1b7 J |
8392 | [ALC883_3ST_6ch_INTEL] = { |
8393 | .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer }, | |
8394 | .init_verbs = { alc883_init_verbs }, | |
8395 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8396 | .dac_nids = alc883_dac_nids, | |
8397 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8398 | .dig_in_nid = ALC883_DIGIN_NID, | |
8399 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes), | |
8400 | .channel_mode = alc883_3ST_6ch_intel_modes, | |
8401 | .need_dac_fix = 1, | |
8402 | .input_mux = &alc883_3stack_6ch_intel, | |
8403 | }, | |
9c7f852e TI |
8404 | [ALC883_6ST_DIG] = { |
8405 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, | |
8406 | .init_verbs = { alc883_init_verbs }, | |
8407 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8408 | .dac_nids = alc883_dac_nids, | |
8409 | .dig_out_nid = ALC883_DIGOUT_NID, | |
9c7f852e TI |
8410 | .dig_in_nid = ALC883_DIGIN_NID, |
8411 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | |
8412 | .channel_mode = alc883_sixstack_modes, | |
8413 | .input_mux = &alc883_capture_source, | |
8414 | }, | |
ccc656ce KY |
8415 | [ALC883_TARGA_DIG] = { |
8416 | .mixers = { alc883_tagra_mixer, alc883_chmode_mixer }, | |
8417 | .init_verbs = { alc883_init_verbs, alc883_tagra_verbs}, | |
8418 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8419 | .dac_nids = alc883_dac_nids, | |
8420 | .dig_out_nid = ALC883_DIGOUT_NID, | |
ccc656ce KY |
8421 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), |
8422 | .channel_mode = alc883_3ST_6ch_modes, | |
8423 | .need_dac_fix = 1, | |
8424 | .input_mux = &alc883_capture_source, | |
8425 | .unsol_event = alc883_tagra_unsol_event, | |
8426 | .init_hook = alc883_tagra_automute, | |
8427 | }, | |
8428 | [ALC883_TARGA_2ch_DIG] = { | |
8429 | .mixers = { alc883_tagra_2ch_mixer}, | |
8430 | .init_verbs = { alc883_init_verbs, alc883_tagra_verbs}, | |
8431 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8432 | .dac_nids = alc883_dac_nids, | |
8433 | .dig_out_nid = ALC883_DIGOUT_NID, | |
ccc656ce KY |
8434 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8435 | .channel_mode = alc883_3ST_2ch_modes, | |
8436 | .input_mux = &alc883_capture_source, | |
8437 | .unsol_event = alc883_tagra_unsol_event, | |
8438 | .init_hook = alc883_tagra_automute, | |
8439 | }, | |
bab282b9 | 8440 | [ALC883_ACER] = { |
676a9b53 | 8441 | .mixers = { alc883_base_mixer }, |
bab282b9 VA |
8442 | /* On TravelMate laptops, GPIO 0 enables the internal speaker |
8443 | * and the headphone jack. Turn this on and rely on the | |
8444 | * standard mute methods whenever the user wants to turn | |
8445 | * these outputs off. | |
8446 | */ | |
8447 | .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs }, | |
8448 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8449 | .dac_nids = alc883_dac_nids, | |
bab282b9 VA |
8450 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8451 | .channel_mode = alc883_3ST_2ch_modes, | |
8452 | .input_mux = &alc883_capture_source, | |
8453 | }, | |
2880a867 | 8454 | [ALC883_ACER_ASPIRE] = { |
676a9b53 | 8455 | .mixers = { alc883_acer_aspire_mixer }, |
d1a991a6 | 8456 | .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs }, |
2880a867 TD |
8457 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
8458 | .dac_nids = alc883_dac_nids, | |
8459 | .dig_out_nid = ALC883_DIGOUT_NID, | |
2880a867 TD |
8460 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8461 | .channel_mode = alc883_3ST_2ch_modes, | |
8462 | .input_mux = &alc883_capture_source, | |
676a9b53 TI |
8463 | .unsol_event = alc883_acer_aspire_unsol_event, |
8464 | .init_hook = alc883_acer_aspire_automute, | |
d1a991a6 | 8465 | }, |
c07584c8 TD |
8466 | [ALC883_MEDION] = { |
8467 | .mixers = { alc883_fivestack_mixer, | |
8468 | alc883_chmode_mixer }, | |
8469 | .init_verbs = { alc883_init_verbs, | |
b373bdeb | 8470 | alc883_medion_eapd_verbs }, |
c07584c8 TD |
8471 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
8472 | .dac_nids = alc883_dac_nids, | |
c07584c8 TD |
8473 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), |
8474 | .channel_mode = alc883_sixstack_modes, | |
8475 | .input_mux = &alc883_capture_source, | |
b373bdeb | 8476 | }, |
272a527c KY |
8477 | [ALC883_MEDION_MD2] = { |
8478 | .mixers = { alc883_medion_md2_mixer}, | |
8479 | .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs}, | |
8480 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8481 | .dac_nids = alc883_dac_nids, | |
8482 | .dig_out_nid = ALC883_DIGOUT_NID, | |
272a527c KY |
8483 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8484 | .channel_mode = alc883_3ST_2ch_modes, | |
8485 | .input_mux = &alc883_capture_source, | |
8486 | .unsol_event = alc883_medion_md2_unsol_event, | |
8487 | .init_hook = alc883_medion_md2_automute, | |
ea1fb29a | 8488 | }, |
b373bdeb | 8489 | [ALC883_LAPTOP_EAPD] = { |
676a9b53 | 8490 | .mixers = { alc883_base_mixer }, |
b373bdeb AN |
8491 | .init_verbs = { alc883_init_verbs, alc882_eapd_verbs }, |
8492 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8493 | .dac_nids = alc883_dac_nids, | |
b373bdeb AN |
8494 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8495 | .channel_mode = alc883_3ST_2ch_modes, | |
8496 | .input_mux = &alc883_capture_source, | |
8497 | }, | |
0c4cc443 HRK |
8498 | [ALC883_CLEVO_M720] = { |
8499 | .mixers = { alc883_clevo_m720_mixer }, | |
8500 | .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs }, | |
368c7a95 J |
8501 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
8502 | .dac_nids = alc883_dac_nids, | |
8503 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8504 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
8505 | .channel_mode = alc883_3ST_2ch_modes, | |
8506 | .input_mux = &alc883_capture_source, | |
0c4cc443 HRK |
8507 | .unsol_event = alc883_clevo_m720_unsol_event, |
8508 | .init_hook = alc883_clevo_m720_automute, | |
368c7a95 | 8509 | }, |
bc9f98a9 KY |
8510 | [ALC883_LENOVO_101E_2ch] = { |
8511 | .mixers = { alc883_lenovo_101e_2ch_mixer}, | |
8512 | .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs}, | |
8513 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8514 | .dac_nids = alc883_dac_nids, | |
bc9f98a9 KY |
8515 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8516 | .channel_mode = alc883_3ST_2ch_modes, | |
8517 | .input_mux = &alc883_lenovo_101e_capture_source, | |
8518 | .unsol_event = alc883_lenovo_101e_unsol_event, | |
8519 | .init_hook = alc883_lenovo_101e_all_automute, | |
8520 | }, | |
272a527c KY |
8521 | [ALC883_LENOVO_NB0763] = { |
8522 | .mixers = { alc883_lenovo_nb0763_mixer }, | |
8523 | .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs}, | |
8524 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8525 | .dac_nids = alc883_dac_nids, | |
272a527c KY |
8526 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8527 | .channel_mode = alc883_3ST_2ch_modes, | |
8528 | .need_dac_fix = 1, | |
8529 | .input_mux = &alc883_lenovo_nb0763_capture_source, | |
8530 | .unsol_event = alc883_medion_md2_unsol_event, | |
8531 | .init_hook = alc883_medion_md2_automute, | |
8532 | }, | |
8533 | [ALC888_LENOVO_MS7195_DIG] = { | |
8534 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
8535 | .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs}, | |
8536 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8537 | .dac_nids = alc883_dac_nids, | |
8538 | .dig_out_nid = ALC883_DIGOUT_NID, | |
272a527c KY |
8539 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), |
8540 | .channel_mode = alc883_3ST_6ch_modes, | |
8541 | .need_dac_fix = 1, | |
8542 | .input_mux = &alc883_capture_source, | |
8543 | .unsol_event = alc883_lenovo_ms7195_unsol_event, | |
8544 | .init_hook = alc888_lenovo_ms7195_front_automute, | |
189609ae KY |
8545 | }, |
8546 | [ALC883_HAIER_W66] = { | |
8547 | .mixers = { alc883_tagra_2ch_mixer}, | |
8548 | .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs}, | |
8549 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8550 | .dac_nids = alc883_dac_nids, | |
8551 | .dig_out_nid = ALC883_DIGOUT_NID, | |
189609ae KY |
8552 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8553 | .channel_mode = alc883_3ST_2ch_modes, | |
8554 | .input_mux = &alc883_capture_source, | |
8555 | .unsol_event = alc883_haier_w66_unsol_event, | |
8556 | .init_hook = alc883_haier_w66_automute, | |
eea6419e | 8557 | }, |
4723c022 | 8558 | [ALC888_3ST_HP] = { |
eea6419e | 8559 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, |
4723c022 | 8560 | .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs }, |
8341de60 CM |
8561 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
8562 | .dac_nids = alc883_dac_nids, | |
4723c022 CM |
8563 | .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes), |
8564 | .channel_mode = alc888_3st_hp_modes, | |
8341de60 CM |
8565 | .need_dac_fix = 1, |
8566 | .input_mux = &alc883_capture_source, | |
8567 | }, | |
5795b9e6 | 8568 | [ALC888_6ST_DELL] = { |
f24dbdc6 | 8569 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, |
5795b9e6 CM |
8570 | .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs }, |
8571 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8572 | .dac_nids = alc883_dac_nids, | |
8573 | .dig_out_nid = ALC883_DIGOUT_NID, | |
5795b9e6 CM |
8574 | .dig_in_nid = ALC883_DIGIN_NID, |
8575 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | |
8576 | .channel_mode = alc883_sixstack_modes, | |
8577 | .input_mux = &alc883_capture_source, | |
8578 | .unsol_event = alc888_6st_dell_unsol_event, | |
8579 | .init_hook = alc888_6st_dell_front_automute, | |
8580 | }, | |
a8848bd6 AS |
8581 | [ALC883_MITAC] = { |
8582 | .mixers = { alc883_mitac_mixer }, | |
8583 | .init_verbs = { alc883_init_verbs, alc883_mitac_verbs }, | |
8584 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8585 | .dac_nids = alc883_dac_nids, | |
a8848bd6 AS |
8586 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8587 | .channel_mode = alc883_3ST_2ch_modes, | |
8588 | .input_mux = &alc883_capture_source, | |
8589 | .unsol_event = alc883_mitac_unsol_event, | |
8590 | .init_hook = alc883_mitac_automute, | |
8591 | }, | |
fb97dc67 J |
8592 | [ALC883_FUJITSU_PI2515] = { |
8593 | .mixers = { alc883_2ch_fujitsu_pi2515_mixer }, | |
8594 | .init_verbs = { alc883_init_verbs, | |
8595 | alc883_2ch_fujitsu_pi2515_verbs}, | |
8596 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8597 | .dac_nids = alc883_dac_nids, | |
8598 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8599 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
8600 | .channel_mode = alc883_3ST_2ch_modes, | |
8601 | .input_mux = &alc883_fujitsu_pi2515_capture_source, | |
8602 | .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event, | |
8603 | .init_hook = alc883_2ch_fujitsu_pi2515_automute, | |
8604 | }, | |
e2757d5e KY |
8605 | [ALC888_LENOVO_SKY] = { |
8606 | .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer }, | |
8607 | .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs}, | |
8608 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8609 | .dac_nids = alc883_dac_nids, | |
8610 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8611 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
8612 | .adc_nids = alc883_adc_nids, | |
8613 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | |
8614 | .channel_mode = alc883_sixstack_modes, | |
8615 | .need_dac_fix = 1, | |
8616 | .input_mux = &alc883_lenovo_sky_capture_source, | |
8617 | .unsol_event = alc883_lenovo_sky_unsol_event, | |
8618 | .init_hook = alc888_lenovo_sky_front_automute, | |
8619 | }, | |
8620 | [ALC888_ASUS_M90V] = { | |
8621 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
8622 | .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs }, | |
8623 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8624 | .dac_nids = alc883_dac_nids, | |
8625 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8626 | .dig_in_nid = ALC883_DIGIN_NID, | |
8627 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
8628 | .channel_mode = alc883_3ST_6ch_modes, | |
8629 | .need_dac_fix = 1, | |
8630 | .input_mux = &alc883_fujitsu_pi2515_capture_source, | |
8631 | .unsol_event = alc883_mode2_unsol_event, | |
8632 | .init_hook = alc883_mode2_inithook, | |
8633 | }, | |
8634 | [ALC888_ASUS_EEE1601] = { | |
8635 | .mixers = { alc883_asus_eee1601_mixer }, | |
8636 | .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs }, | |
8637 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8638 | .dac_nids = alc883_dac_nids, | |
8639 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8640 | .dig_in_nid = ALC883_DIGIN_NID, | |
8641 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
8642 | .channel_mode = alc883_3ST_2ch_modes, | |
8643 | .need_dac_fix = 1, | |
8644 | .input_mux = &alc883_asus_eee1601_capture_source, | |
8645 | .unsol_event = alc883_eee1601_unsol_event, | |
8646 | .init_hook = alc883_eee1601_inithook, | |
8647 | }, | |
9c7f852e TI |
8648 | }; |
8649 | ||
8650 | ||
8651 | /* | |
8652 | * BIOS auto configuration | |
8653 | */ | |
8654 | static void alc883_auto_set_output_and_unmute(struct hda_codec *codec, | |
8655 | hda_nid_t nid, int pin_type, | |
8656 | int dac_idx) | |
8657 | { | |
8658 | /* set as output */ | |
8659 | struct alc_spec *spec = codec->spec; | |
f12ab1e0 TI |
8660 | int idx; |
8661 | ||
f6c7e546 | 8662 | alc_set_pin_output(codec, nid, pin_type); |
9c7f852e TI |
8663 | if (spec->multiout.dac_nids[dac_idx] == 0x25) |
8664 | idx = 4; | |
8665 | else | |
8666 | idx = spec->multiout.dac_nids[dac_idx] - 2; | |
9c7f852e TI |
8667 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); |
8668 | ||
8669 | } | |
8670 | ||
8671 | static void alc883_auto_init_multi_out(struct hda_codec *codec) | |
8672 | { | |
8673 | struct alc_spec *spec = codec->spec; | |
8674 | int i; | |
8675 | ||
bc9f98a9 | 8676 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
9c7f852e | 8677 | for (i = 0; i <= HDA_SIDE; i++) { |
f12ab1e0 | 8678 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
baba8ee9 | 8679 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
9c7f852e | 8680 | if (nid) |
baba8ee9 | 8681 | alc883_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 8682 | i); |
9c7f852e TI |
8683 | } |
8684 | } | |
8685 | ||
8686 | static void alc883_auto_init_hp_out(struct hda_codec *codec) | |
8687 | { | |
8688 | struct alc_spec *spec = codec->spec; | |
8689 | hda_nid_t pin; | |
8690 | ||
eb06ed8f | 8691 | pin = spec->autocfg.hp_pins[0]; |
9c7f852e TI |
8692 | if (pin) /* connect to front */ |
8693 | /* use dac 0 */ | |
8694 | alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
f6c7e546 TI |
8695 | pin = spec->autocfg.speaker_pins[0]; |
8696 | if (pin) | |
8697 | alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
9c7f852e TI |
8698 | } |
8699 | ||
8700 | #define alc883_is_input_pin(nid) alc880_is_input_pin(nid) | |
8701 | #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID | |
8702 | ||
8703 | static void alc883_auto_init_analog_input(struct hda_codec *codec) | |
8704 | { | |
8705 | struct alc_spec *spec = codec->spec; | |
8706 | int i; | |
8707 | ||
8708 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
8709 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
8710 | if (alc883_is_input_pin(nid)) { | |
8711 | snd_hda_codec_write(codec, nid, 0, | |
8712 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8713 | (i <= AUTO_PIN_FRONT_MIC ? | |
8714 | PIN_VREF80 : PIN_IN)); | |
8715 | if (nid != ALC883_PIN_CD_NID) | |
8716 | snd_hda_codec_write(codec, nid, 0, | |
8717 | AC_VERB_SET_AMP_GAIN_MUTE, | |
8718 | AMP_OUT_MUTE); | |
8719 | } | |
8720 | } | |
8721 | } | |
8722 | ||
f511b01c TI |
8723 | #define alc883_auto_init_input_src alc882_auto_init_input_src |
8724 | ||
9c7f852e TI |
8725 | /* almost identical with ALC880 parser... */ |
8726 | static int alc883_parse_auto_config(struct hda_codec *codec) | |
8727 | { | |
8728 | struct alc_spec *spec = codec->spec; | |
8729 | int err = alc880_parse_auto_config(codec); | |
8730 | ||
8731 | if (err < 0) | |
8732 | return err; | |
776e184e TI |
8733 | else if (!err) |
8734 | return 0; /* no config found */ | |
8735 | ||
8736 | err = alc_auto_add_mic_boost(codec); | |
8737 | if (err < 0) | |
8738 | return err; | |
8739 | ||
8740 | /* hack - override the init verbs */ | |
8741 | spec->init_verbs[0] = alc883_auto_init_verbs; | |
bc9f98a9 KY |
8742 | spec->mixers[spec->num_mixers] = alc883_capture_mixer; |
8743 | spec->num_mixers++; | |
776e184e TI |
8744 | |
8745 | return 1; /* config found */ | |
9c7f852e TI |
8746 | } |
8747 | ||
8748 | /* additional initialization for auto-configuration model */ | |
8749 | static void alc883_auto_init(struct hda_codec *codec) | |
8750 | { | |
f6c7e546 | 8751 | struct alc_spec *spec = codec->spec; |
9c7f852e TI |
8752 | alc883_auto_init_multi_out(codec); |
8753 | alc883_auto_init_hp_out(codec); | |
8754 | alc883_auto_init_analog_input(codec); | |
f511b01c | 8755 | alc883_auto_init_input_src(codec); |
f6c7e546 TI |
8756 | if (spec->unsol_event) |
8757 | alc_sku_automute(codec); | |
9c7f852e TI |
8758 | } |
8759 | ||
8760 | static int patch_alc883(struct hda_codec *codec) | |
8761 | { | |
8762 | struct alc_spec *spec; | |
8763 | int err, board_config; | |
8764 | ||
8765 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
8766 | if (spec == NULL) | |
8767 | return -ENOMEM; | |
8768 | ||
8769 | codec->spec = spec; | |
8770 | ||
2c3bf9ab TI |
8771 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
8772 | ||
f5fcc13c TI |
8773 | board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST, |
8774 | alc883_models, | |
8775 | alc883_cfg_tbl); | |
8776 | if (board_config < 0) { | |
9c7f852e TI |
8777 | printk(KERN_INFO "hda_codec: Unknown model for ALC883, " |
8778 | "trying auto-probe from BIOS...\n"); | |
8779 | board_config = ALC883_AUTO; | |
8780 | } | |
8781 | ||
8782 | if (board_config == ALC883_AUTO) { | |
8783 | /* automatic parse from the BIOS config */ | |
8784 | err = alc883_parse_auto_config(codec); | |
8785 | if (err < 0) { | |
8786 | alc_free(codec); | |
8787 | return err; | |
f12ab1e0 | 8788 | } else if (!err) { |
9c7f852e TI |
8789 | printk(KERN_INFO |
8790 | "hda_codec: Cannot set up configuration " | |
8791 | "from BIOS. Using base mode...\n"); | |
8792 | board_config = ALC883_3ST_2ch_DIG; | |
8793 | } | |
8794 | } | |
8795 | ||
8796 | if (board_config != ALC883_AUTO) | |
8797 | setup_preset(spec, &alc883_presets[board_config]); | |
8798 | ||
2f893286 KY |
8799 | switch (codec->vendor_id) { |
8800 | case 0x10ec0888: | |
8801 | spec->stream_name_analog = "ALC888 Analog"; | |
8802 | spec->stream_name_digital = "ALC888 Digital"; | |
8803 | break; | |
8804 | case 0x10ec0889: | |
8805 | spec->stream_name_analog = "ALC889 Analog"; | |
8806 | spec->stream_name_digital = "ALC889 Digital"; | |
8807 | break; | |
8808 | default: | |
8809 | spec->stream_name_analog = "ALC883 Analog"; | |
8810 | spec->stream_name_digital = "ALC883 Digital"; | |
8811 | break; | |
8812 | } | |
8813 | ||
9c7f852e TI |
8814 | spec->stream_analog_playback = &alc883_pcm_analog_playback; |
8815 | spec->stream_analog_capture = &alc883_pcm_analog_capture; | |
6330079f | 8816 | spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture; |
9c7f852e | 8817 | |
9c7f852e TI |
8818 | spec->stream_digital_playback = &alc883_pcm_digital_playback; |
8819 | spec->stream_digital_capture = &alc883_pcm_digital_capture; | |
8820 | ||
e1406348 TI |
8821 | spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); |
8822 | spec->adc_nids = alc883_adc_nids; | |
8823 | spec->capsrc_nids = alc883_capsrc_nids; | |
9c7f852e | 8824 | |
2134ea4f TI |
8825 | spec->vmaster_nid = 0x0c; |
8826 | ||
9c7f852e TI |
8827 | codec->patch_ops = alc_patch_ops; |
8828 | if (board_config == ALC883_AUTO) | |
8829 | spec->init_hook = alc883_auto_init; | |
f9423e7a | 8830 | |
cb53c626 TI |
8831 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
8832 | if (!spec->loopback.amplist) | |
8833 | spec->loopback.amplist = alc883_loopbacks; | |
8834 | #endif | |
9c7f852e TI |
8835 | |
8836 | return 0; | |
8837 | } | |
8838 | ||
8839 | /* | |
8840 | * ALC262 support | |
8841 | */ | |
8842 | ||
8843 | #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID | |
8844 | #define ALC262_DIGIN_NID ALC880_DIGIN_NID | |
8845 | ||
8846 | #define alc262_dac_nids alc260_dac_nids | |
8847 | #define alc262_adc_nids alc882_adc_nids | |
8848 | #define alc262_adc_nids_alt alc882_adc_nids_alt | |
88c71a99 TI |
8849 | #define alc262_capsrc_nids alc882_capsrc_nids |
8850 | #define alc262_capsrc_nids_alt alc882_capsrc_nids_alt | |
9c7f852e TI |
8851 | |
8852 | #define alc262_modes alc260_modes | |
8853 | #define alc262_capture_source alc882_capture_source | |
8854 | ||
4e555fe5 KY |
8855 | static hda_nid_t alc262_dmic_adc_nids[1] = { |
8856 | /* ADC0 */ | |
8857 | 0x09 | |
8858 | }; | |
8859 | ||
8860 | static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 }; | |
8861 | ||
9c7f852e TI |
8862 | static struct snd_kcontrol_new alc262_base_mixer[] = { |
8863 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
8864 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
8865 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
8866 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
8867 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
8868 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
8869 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
8870 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 8871 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
8872 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
8873 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 8874 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e | 8875 | /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), |
31bffaa9 | 8876 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */ |
9c7f852e TI |
8877 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT), |
8878 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
8879 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
8880 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | |
8881 | { } /* end */ | |
8882 | }; | |
8883 | ||
ccc656ce KY |
8884 | static struct snd_kcontrol_new alc262_hippo1_mixer[] = { |
8885 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
8886 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
8887 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
8888 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
8889 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
8890 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
8891 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
8892 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 8893 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce KY |
8894 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
8895 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 8896 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
ccc656ce | 8897 | /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), |
31bffaa9 | 8898 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */ |
ccc656ce KY |
8899 | /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/ |
8900 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
8901 | { } /* end */ | |
8902 | }; | |
8903 | ||
ce875f07 TI |
8904 | /* update HP, line and mono-out pins according to the master switch */ |
8905 | static void alc262_hp_master_update(struct hda_codec *codec) | |
8906 | { | |
8907 | struct alc_spec *spec = codec->spec; | |
8908 | int val = spec->master_sw; | |
8909 | ||
8910 | /* HP & line-out */ | |
8911 | snd_hda_codec_write_cache(codec, 0x1b, 0, | |
8912 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8913 | val ? PIN_HP : 0); | |
8914 | snd_hda_codec_write_cache(codec, 0x15, 0, | |
8915 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8916 | val ? PIN_HP : 0); | |
8917 | /* mono (speaker) depending on the HP jack sense */ | |
8918 | val = val && !spec->jack_present; | |
8919 | snd_hda_codec_write_cache(codec, 0x16, 0, | |
8920 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8921 | val ? PIN_OUT : 0); | |
8922 | } | |
8923 | ||
8924 | static void alc262_hp_bpc_automute(struct hda_codec *codec) | |
8925 | { | |
8926 | struct alc_spec *spec = codec->spec; | |
8927 | unsigned int presence; | |
8928 | presence = snd_hda_codec_read(codec, 0x1b, 0, | |
8929 | AC_VERB_GET_PIN_SENSE, 0); | |
8930 | spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE); | |
8931 | alc262_hp_master_update(codec); | |
8932 | } | |
8933 | ||
8934 | static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res) | |
8935 | { | |
8936 | if ((res >> 26) != ALC880_HP_EVENT) | |
8937 | return; | |
8938 | alc262_hp_bpc_automute(codec); | |
8939 | } | |
8940 | ||
8941 | static void alc262_hp_wildwest_automute(struct hda_codec *codec) | |
8942 | { | |
8943 | struct alc_spec *spec = codec->spec; | |
8944 | unsigned int presence; | |
8945 | presence = snd_hda_codec_read(codec, 0x15, 0, | |
8946 | AC_VERB_GET_PIN_SENSE, 0); | |
8947 | spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE); | |
8948 | alc262_hp_master_update(codec); | |
8949 | } | |
8950 | ||
8951 | static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec, | |
8952 | unsigned int res) | |
8953 | { | |
8954 | if ((res >> 26) != ALC880_HP_EVENT) | |
8955 | return; | |
8956 | alc262_hp_wildwest_automute(codec); | |
8957 | } | |
8958 | ||
8959 | static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol, | |
8960 | struct snd_ctl_elem_value *ucontrol) | |
8961 | { | |
8962 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
8963 | struct alc_spec *spec = codec->spec; | |
8964 | *ucontrol->value.integer.value = spec->master_sw; | |
8965 | return 0; | |
8966 | } | |
8967 | ||
8968 | static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |
8969 | struct snd_ctl_elem_value *ucontrol) | |
8970 | { | |
8971 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
8972 | struct alc_spec *spec = codec->spec; | |
8973 | int val = !!*ucontrol->value.integer.value; | |
8974 | ||
8975 | if (val == spec->master_sw) | |
8976 | return 0; | |
8977 | spec->master_sw = val; | |
8978 | alc262_hp_master_update(codec); | |
8979 | return 1; | |
8980 | } | |
8981 | ||
9c7f852e | 8982 | static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = { |
ce875f07 TI |
8983 | { |
8984 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
8985 | .name = "Master Playback Switch", | |
8986 | .info = snd_ctl_boolean_mono_info, | |
8987 | .get = alc262_hp_master_sw_get, | |
8988 | .put = alc262_hp_master_sw_put, | |
8989 | }, | |
9c7f852e TI |
8990 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
8991 | HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
8992 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
ce875f07 TI |
8993 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0, |
8994 | HDA_OUTPUT), | |
8995 | HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0, | |
8996 | HDA_OUTPUT), | |
9c7f852e TI |
8997 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
8998 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 8999 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
9000 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
9001 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 9002 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
9003 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
9004 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
9005 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
9006 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
9007 | HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
9008 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
9009 | HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT), | |
9010 | HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT), | |
9011 | { } /* end */ | |
9012 | }; | |
9013 | ||
cd7509a4 | 9014 | static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = { |
ce875f07 TI |
9015 | { |
9016 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9017 | .name = "Master Playback Switch", | |
9018 | .info = snd_ctl_boolean_mono_info, | |
9019 | .get = alc262_hp_master_sw_get, | |
9020 | .put = alc262_hp_master_sw_put, | |
9021 | }, | |
cd7509a4 KY |
9022 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9023 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
9024 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
9025 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
ce875f07 TI |
9026 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0, |
9027 | HDA_OUTPUT), | |
9028 | HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0, | |
9029 | HDA_OUTPUT), | |
cd7509a4 KY |
9030 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT), |
9031 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
cc69d12d | 9032 | HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT), |
cd7509a4 KY |
9033 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), |
9034 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
9035 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
9036 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
9037 | HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
9038 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
9039 | { } /* end */ | |
9040 | }; | |
9041 | ||
9042 | static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = { | |
9043 | HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9044 | HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 9045 | HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT), |
cd7509a4 KY |
9046 | { } /* end */ |
9047 | }; | |
9048 | ||
66d2a9d6 KY |
9049 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
9050 | static void alc262_hp_t5735_automute(struct hda_codec *codec, int force) | |
9051 | { | |
9052 | struct alc_spec *spec = codec->spec; | |
66d2a9d6 KY |
9053 | |
9054 | if (force || !spec->sense_updated) { | |
9055 | unsigned int present; | |
9056 | present = snd_hda_codec_read(codec, 0x15, 0, | |
9057 | AC_VERB_GET_PIN_SENSE, 0); | |
4bb26130 | 9058 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; |
66d2a9d6 KY |
9059 | spec->sense_updated = 1; |
9060 | } | |
4bb26130 TI |
9061 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE, |
9062 | spec->jack_present ? HDA_AMP_MUTE : 0); | |
66d2a9d6 KY |
9063 | } |
9064 | ||
9065 | static void alc262_hp_t5735_unsol_event(struct hda_codec *codec, | |
9066 | unsigned int res) | |
9067 | { | |
9068 | if ((res >> 26) != ALC880_HP_EVENT) | |
9069 | return; | |
9070 | alc262_hp_t5735_automute(codec, 1); | |
9071 | } | |
9072 | ||
9073 | static void alc262_hp_t5735_init_hook(struct hda_codec *codec) | |
9074 | { | |
9075 | alc262_hp_t5735_automute(codec, 1); | |
9076 | } | |
9077 | ||
9078 | static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = { | |
86cd9298 TI |
9079 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9080 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
66d2a9d6 KY |
9081 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
9082 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
9083 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9084 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9085 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
9086 | { } /* end */ | |
9087 | }; | |
9088 | ||
9089 | static struct hda_verb alc262_hp_t5735_verbs[] = { | |
9090 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9091 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
9092 | ||
9093 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
9094 | { } | |
9095 | }; | |
9096 | ||
8c427226 | 9097 | static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = { |
f2f48e18 TI |
9098 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9099 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
86cd9298 TI |
9100 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT), |
9101 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT), | |
8c427226 KY |
9102 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), |
9103 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
9104 | { } /* end */ | |
9105 | }; | |
9106 | ||
9107 | static struct hda_verb alc262_hp_rp5700_verbs[] = { | |
9108 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9109 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9110 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9111 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9112 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
9113 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9114 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
9115 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
9116 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))}, | |
9117 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))}, | |
9118 | {} | |
9119 | }; | |
9120 | ||
9121 | static struct hda_input_mux alc262_hp_rp5700_capture_source = { | |
9122 | .num_items = 1, | |
9123 | .items = { | |
9124 | { "Line", 0x1 }, | |
9125 | }, | |
9126 | }; | |
9127 | ||
0724ea2a TI |
9128 | /* bind hp and internal speaker mute (with plug check) */ |
9129 | static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol, | |
9130 | struct snd_ctl_elem_value *ucontrol) | |
9131 | { | |
9132 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
9133 | long *valp = ucontrol->value.integer.value; | |
9134 | int change; | |
9135 | ||
9136 | /* change hp mute */ | |
9137 | change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, | |
9138 | HDA_AMP_MUTE, | |
9139 | valp[0] ? 0 : HDA_AMP_MUTE); | |
9140 | change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, | |
9141 | HDA_AMP_MUTE, | |
9142 | valp[1] ? 0 : HDA_AMP_MUTE); | |
9143 | if (change) { | |
9144 | /* change speaker according to HP jack state */ | |
9145 | struct alc_spec *spec = codec->spec; | |
9146 | unsigned int mute; | |
9147 | if (spec->jack_present) | |
9148 | mute = HDA_AMP_MUTE; | |
9149 | else | |
9150 | mute = snd_hda_codec_amp_read(codec, 0x15, 0, | |
9151 | HDA_OUTPUT, 0); | |
9152 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
9153 | HDA_AMP_MUTE, mute); | |
9154 | } | |
9155 | return change; | |
9156 | } | |
5b31954e | 9157 | |
272a527c | 9158 | static struct snd_kcontrol_new alc262_sony_mixer[] = { |
0724ea2a TI |
9159 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9160 | { | |
9161 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9162 | .name = "Master Playback Switch", | |
9163 | .info = snd_hda_mixer_amp_switch_info, | |
9164 | .get = snd_hda_mixer_amp_switch_get, | |
9165 | .put = alc262_sony_master_sw_put, | |
9166 | .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | |
9167 | }, | |
272a527c KY |
9168 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
9169 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9170 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
9171 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
9172 | { } /* end */ | |
9173 | }; | |
9174 | ||
83c34218 KY |
9175 | static struct snd_kcontrol_new alc262_benq_t31_mixer[] = { |
9176 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
9177 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
9178 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
9179 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9180 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9181 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
9182 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
9183 | { } /* end */ | |
9184 | }; | |
272a527c | 9185 | |
9c7f852e TI |
9186 | #define alc262_capture_mixer alc882_capture_mixer |
9187 | #define alc262_capture_alt_mixer alc882_capture_alt_mixer | |
9188 | ||
9189 | /* | |
9190 | * generic initialization of ADC, input mixers and output mixers | |
9191 | */ | |
9192 | static struct hda_verb alc262_init_verbs[] = { | |
9193 | /* | |
9194 | * Unmute ADC0-2 and set the default input to mic-in | |
9195 | */ | |
9196 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9197 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9198 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9199 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9200 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9201 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9202 | ||
cb53c626 | 9203 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
9c7f852e | 9204 | * mixer widget |
f12ab1e0 TI |
9205 | * Note: PASD motherboards uses the Line In 2 as the input for |
9206 | * front panel mic (mic 2) | |
9c7f852e TI |
9207 | */ |
9208 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
9209 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
9210 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
9211 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
9212 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
9213 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9c7f852e TI |
9214 | |
9215 | /* | |
df694daa KY |
9216 | * Set up output mixers (0x0c - 0x0e) |
9217 | */ | |
9218 | /* set vol=0 to output mixers */ | |
9219 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9220 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9221 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9222 | /* set up input amps for analog loopback */ | |
9223 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
9224 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9225 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9226 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9227 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9228 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9229 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9230 | ||
9231 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
9232 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
9233 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
9234 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
9235 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
9236 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
9237 | ||
9238 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
9239 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
9240 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
9241 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
9242 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
ea1fb29a | 9243 | |
df694daa KY |
9244 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, |
9245 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
ea1fb29a | 9246 | |
df694daa KY |
9247 | /* FIXME: use matrix-type input source selection */ |
9248 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
9249 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
9250 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9251 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
9252 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
9253 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
9254 | /* Input mixer2 */ | |
9255 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9256 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
9257 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
9258 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
9259 | /* Input mixer3 */ | |
9260 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9261 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
9262 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
f12ab1e0 | 9263 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
df694daa KY |
9264 | |
9265 | { } | |
9266 | }; | |
1da177e4 | 9267 | |
4e555fe5 KY |
9268 | static struct hda_verb alc262_eapd_verbs[] = { |
9269 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
9270 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
9271 | { } | |
9272 | }; | |
9273 | ||
ccc656ce KY |
9274 | static struct hda_verb alc262_hippo_unsol_verbs[] = { |
9275 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
9276 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
9277 | {} | |
9278 | }; | |
9279 | ||
9280 | static struct hda_verb alc262_hippo1_unsol_verbs[] = { | |
9281 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
9282 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9283 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
9284 | ||
9285 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
9286 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
9287 | {} | |
9288 | }; | |
9289 | ||
272a527c KY |
9290 | static struct hda_verb alc262_sony_unsol_verbs[] = { |
9291 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
9292 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9293 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic | |
9294 | ||
9295 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
9296 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7b1e8795 | 9297 | {} |
272a527c KY |
9298 | }; |
9299 | ||
4e555fe5 KY |
9300 | static struct hda_input_mux alc262_dmic_capture_source = { |
9301 | .num_items = 2, | |
9302 | .items = { | |
9303 | { "Int DMic", 0x9 }, | |
9304 | { "Mic", 0x0 }, | |
9305 | }, | |
9306 | }; | |
9307 | ||
9308 | static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = { | |
9309 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
9310 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
9311 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
9312 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9313 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9314 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
9315 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
9316 | { | |
9317 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9318 | /* The multiple "Capture Source" controls confuse alsamixer | |
9319 | * So call somewhat different.. | |
9320 | */ | |
9321 | /* .name = "Capture Source", */ | |
9322 | .name = "Input Source", | |
9323 | .count = 1, | |
9324 | .info = alc_mux_enum_info, | |
9325 | .get = alc_mux_enum_get, | |
9326 | .put = alc_mux_enum_put, | |
9327 | }, | |
9328 | { } /* end */ | |
9329 | }; | |
9330 | ||
9331 | static struct hda_verb alc262_toshiba_s06_verbs[] = { | |
9332 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
9333 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9334 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
9335 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9336 | {0x22, AC_VERB_SET_CONNECT_SEL, 0x09}, | |
9337 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
9338 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
9339 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
9340 | {} | |
9341 | }; | |
9342 | ||
9343 | static void alc262_dmic_automute(struct hda_codec *codec) | |
9344 | { | |
9345 | unsigned int present; | |
9346 | ||
9347 | present = snd_hda_codec_read(codec, 0x18, 0, | |
9348 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
9349 | snd_hda_codec_write(codec, 0x22, 0, | |
9350 | AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09); | |
9351 | } | |
9352 | ||
9353 | /* toggle speaker-output according to the hp-jack state */ | |
9354 | static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec) | |
9355 | { | |
9356 | unsigned int present; | |
9357 | unsigned char bits; | |
9358 | ||
9359 | present = snd_hda_codec_read(codec, 0x15, 0, | |
9360 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
9361 | bits = present ? 0 : PIN_OUT; | |
9362 | snd_hda_codec_write(codec, 0x14, 0, | |
9363 | AC_VERB_SET_PIN_WIDGET_CONTROL, bits); | |
9364 | } | |
9365 | ||
9366 | ||
9367 | ||
9368 | /* unsolicited event for HP jack sensing */ | |
9369 | static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec, | |
9370 | unsigned int res) | |
9371 | { | |
9372 | if ((res >> 26) == ALC880_HP_EVENT) | |
9373 | alc262_toshiba_s06_speaker_automute(codec); | |
9374 | if ((res >> 26) == ALC880_MIC_EVENT) | |
9375 | alc262_dmic_automute(codec); | |
9376 | ||
9377 | } | |
9378 | ||
9379 | static void alc262_toshiba_s06_init_hook(struct hda_codec *codec) | |
9380 | { | |
9381 | alc262_toshiba_s06_speaker_automute(codec); | |
9382 | alc262_dmic_automute(codec); | |
9383 | } | |
9384 | ||
ccc656ce | 9385 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
5b31954e | 9386 | static void alc262_hippo_automute(struct hda_codec *codec) |
ccc656ce KY |
9387 | { |
9388 | struct alc_spec *spec = codec->spec; | |
9389 | unsigned int mute; | |
5b31954e | 9390 | unsigned int present; |
ccc656ce | 9391 | |
5b31954e TI |
9392 | /* need to execute and sync at first */ |
9393 | snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); | |
9394 | present = snd_hda_codec_read(codec, 0x15, 0, | |
9395 | AC_VERB_GET_PIN_SENSE, 0); | |
9396 | spec->jack_present = (present & 0x80000000) != 0; | |
ccc656ce KY |
9397 | if (spec->jack_present) { |
9398 | /* mute internal speaker */ | |
47fd830a TI |
9399 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
9400 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
ccc656ce KY |
9401 | } else { |
9402 | /* unmute internal speaker if necessary */ | |
9403 | mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0); | |
47fd830a TI |
9404 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
9405 | HDA_AMP_MUTE, mute); | |
ccc656ce KY |
9406 | } |
9407 | } | |
9408 | ||
9409 | /* unsolicited event for HP jack sensing */ | |
9410 | static void alc262_hippo_unsol_event(struct hda_codec *codec, | |
9411 | unsigned int res) | |
9412 | { | |
9413 | if ((res >> 26) != ALC880_HP_EVENT) | |
9414 | return; | |
5b31954e | 9415 | alc262_hippo_automute(codec); |
ccc656ce KY |
9416 | } |
9417 | ||
5b31954e | 9418 | static void alc262_hippo1_automute(struct hda_codec *codec) |
ccc656ce | 9419 | { |
ccc656ce | 9420 | unsigned int mute; |
5b31954e | 9421 | unsigned int present; |
ccc656ce | 9422 | |
5b31954e TI |
9423 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); |
9424 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
9425 | AC_VERB_GET_PIN_SENSE, 0); | |
9426 | present = (present & 0x80000000) != 0; | |
9427 | if (present) { | |
ccc656ce | 9428 | /* mute internal speaker */ |
47fd830a TI |
9429 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
9430 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
ccc656ce KY |
9431 | } else { |
9432 | /* unmute internal speaker if necessary */ | |
9433 | mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); | |
47fd830a TI |
9434 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
9435 | HDA_AMP_MUTE, mute); | |
ccc656ce KY |
9436 | } |
9437 | } | |
9438 | ||
9439 | /* unsolicited event for HP jack sensing */ | |
9440 | static void alc262_hippo1_unsol_event(struct hda_codec *codec, | |
9441 | unsigned int res) | |
9442 | { | |
9443 | if ((res >> 26) != ALC880_HP_EVENT) | |
9444 | return; | |
5b31954e | 9445 | alc262_hippo1_automute(codec); |
ccc656ce KY |
9446 | } |
9447 | ||
e8f9ae2a PT |
9448 | /* |
9449 | * nec model | |
9450 | * 0x15 = headphone | |
9451 | * 0x16 = internal speaker | |
9452 | * 0x18 = external mic | |
9453 | */ | |
9454 | ||
9455 | static struct snd_kcontrol_new alc262_nec_mixer[] = { | |
9456 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
9457 | HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT), | |
9458 | ||
9459 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9460 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9461 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
9462 | ||
9463 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
9464 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
9465 | { } /* end */ | |
9466 | }; | |
9467 | ||
9468 | static struct hda_verb alc262_nec_verbs[] = { | |
9469 | /* Unmute Speaker */ | |
9470 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9471 | ||
9472 | /* Headphone */ | |
9473 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
9474 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9475 | ||
9476 | /* External mic to headphone */ | |
9477 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9478 | /* External mic to speaker */ | |
9479 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9480 | {} | |
9481 | }; | |
9482 | ||
834be88d TI |
9483 | /* |
9484 | * fujitsu model | |
5d9fab2d TV |
9485 | * 0x14 = headphone/spdif-out, 0x15 = internal speaker, |
9486 | * 0x1b = port replicator headphone out | |
834be88d TI |
9487 | */ |
9488 | ||
9489 | #define ALC_HP_EVENT 0x37 | |
9490 | ||
9491 | static struct hda_verb alc262_fujitsu_unsol_verbs[] = { | |
9492 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, | |
9493 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5d9fab2d TV |
9494 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, |
9495 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
834be88d TI |
9496 | {} |
9497 | }; | |
9498 | ||
0e31daf7 J |
9499 | static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = { |
9500 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, | |
9501 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
9502 | {} | |
9503 | }; | |
9504 | ||
834be88d | 9505 | static struct hda_input_mux alc262_fujitsu_capture_source = { |
39d3ed38 | 9506 | .num_items = 3, |
834be88d TI |
9507 | .items = { |
9508 | { "Mic", 0x0 }, | |
39d3ed38 | 9509 | { "Int Mic", 0x1 }, |
834be88d TI |
9510 | { "CD", 0x4 }, |
9511 | }, | |
9512 | }; | |
9513 | ||
9c7f852e TI |
9514 | static struct hda_input_mux alc262_HP_capture_source = { |
9515 | .num_items = 5, | |
9516 | .items = { | |
9517 | { "Mic", 0x0 }, | |
accbe498 | 9518 | { "Front Mic", 0x1 }, |
9c7f852e TI |
9519 | { "Line", 0x2 }, |
9520 | { "CD", 0x4 }, | |
9521 | { "AUX IN", 0x6 }, | |
9522 | }, | |
9523 | }; | |
9524 | ||
accbe498 | 9525 | static struct hda_input_mux alc262_HP_D7000_capture_source = { |
9526 | .num_items = 4, | |
9527 | .items = { | |
9528 | { "Mic", 0x0 }, | |
9529 | { "Front Mic", 0x2 }, | |
9530 | { "Line", 0x1 }, | |
9531 | { "CD", 0x4 }, | |
9532 | }, | |
9533 | }; | |
9534 | ||
ebc7a406 | 9535 | /* mute/unmute internal speaker according to the hp jacks and mute state */ |
834be88d TI |
9536 | static void alc262_fujitsu_automute(struct hda_codec *codec, int force) |
9537 | { | |
9538 | struct alc_spec *spec = codec->spec; | |
9539 | unsigned int mute; | |
9540 | ||
f12ab1e0 | 9541 | if (force || !spec->sense_updated) { |
ebc7a406 | 9542 | unsigned int present; |
834be88d TI |
9543 | /* need to execute and sync at first */ |
9544 | snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); | |
ebc7a406 TI |
9545 | /* check laptop HP jack */ |
9546 | present = snd_hda_codec_read(codec, 0x14, 0, | |
9547 | AC_VERB_GET_PIN_SENSE, 0); | |
9548 | /* need to execute and sync at first */ | |
9549 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); | |
9550 | /* check docking HP jack */ | |
9551 | present |= snd_hda_codec_read(codec, 0x1b, 0, | |
9552 | AC_VERB_GET_PIN_SENSE, 0); | |
9553 | if (present & AC_PINSENSE_PRESENCE) | |
9554 | spec->jack_present = 1; | |
9555 | else | |
9556 | spec->jack_present = 0; | |
834be88d TI |
9557 | spec->sense_updated = 1; |
9558 | } | |
ebc7a406 TI |
9559 | /* unmute internal speaker only if both HPs are unplugged and |
9560 | * master switch is on | |
9561 | */ | |
9562 | if (spec->jack_present) | |
9563 | mute = HDA_AMP_MUTE; | |
9564 | else | |
834be88d | 9565 | mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); |
ebc7a406 TI |
9566 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
9567 | HDA_AMP_MUTE, mute); | |
834be88d TI |
9568 | } |
9569 | ||
9570 | /* unsolicited event for HP jack sensing */ | |
9571 | static void alc262_fujitsu_unsol_event(struct hda_codec *codec, | |
9572 | unsigned int res) | |
9573 | { | |
9574 | if ((res >> 26) != ALC_HP_EVENT) | |
9575 | return; | |
9576 | alc262_fujitsu_automute(codec, 1); | |
9577 | } | |
9578 | ||
ebc7a406 TI |
9579 | static void alc262_fujitsu_init_hook(struct hda_codec *codec) |
9580 | { | |
9581 | alc262_fujitsu_automute(codec, 1); | |
9582 | } | |
9583 | ||
834be88d | 9584 | /* bind volumes of both NID 0x0c and 0x0d */ |
cca3b371 TI |
9585 | static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = { |
9586 | .ops = &snd_hda_bind_vol, | |
9587 | .values = { | |
9588 | HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT), | |
9589 | HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT), | |
9590 | 0 | |
9591 | }, | |
9592 | }; | |
834be88d | 9593 | |
0e31daf7 J |
9594 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
9595 | static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force) | |
9596 | { | |
9597 | struct alc_spec *spec = codec->spec; | |
9598 | unsigned int mute; | |
9599 | ||
9600 | if (force || !spec->sense_updated) { | |
9601 | unsigned int present_int_hp; | |
9602 | /* need to execute and sync at first */ | |
9603 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); | |
9604 | present_int_hp = snd_hda_codec_read(codec, 0x1b, 0, | |
9605 | AC_VERB_GET_PIN_SENSE, 0); | |
9606 | spec->jack_present = (present_int_hp & 0x80000000) != 0; | |
9607 | spec->sense_updated = 1; | |
9608 | } | |
9609 | if (spec->jack_present) { | |
9610 | /* mute internal speaker */ | |
9611 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
9612 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
9613 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
9614 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
9615 | } else { | |
9616 | /* unmute internal speaker if necessary */ | |
9617 | mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); | |
9618 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
9619 | HDA_AMP_MUTE, mute); | |
9620 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
9621 | HDA_AMP_MUTE, mute); | |
9622 | } | |
9623 | } | |
9624 | ||
9625 | /* unsolicited event for HP jack sensing */ | |
9626 | static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec, | |
9627 | unsigned int res) | |
9628 | { | |
9629 | if ((res >> 26) != ALC_HP_EVENT) | |
9630 | return; | |
9631 | alc262_lenovo_3000_automute(codec, 1); | |
9632 | } | |
9633 | ||
834be88d TI |
9634 | /* bind hp and internal speaker mute (with plug check) */ |
9635 | static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol, | |
9636 | struct snd_ctl_elem_value *ucontrol) | |
9637 | { | |
9638 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
9639 | long *valp = ucontrol->value.integer.value; | |
9640 | int change; | |
9641 | ||
5d9fab2d TV |
9642 | change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
9643 | HDA_AMP_MUTE, | |
9644 | valp ? 0 : HDA_AMP_MUTE); | |
9645 | change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
9646 | HDA_AMP_MUTE, | |
9647 | valp ? 0 : HDA_AMP_MUTE); | |
9648 | ||
82beb8fd TI |
9649 | if (change) |
9650 | alc262_fujitsu_automute(codec, 0); | |
834be88d TI |
9651 | return change; |
9652 | } | |
9653 | ||
9654 | static struct snd_kcontrol_new alc262_fujitsu_mixer[] = { | |
cca3b371 | 9655 | HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol), |
834be88d TI |
9656 | { |
9657 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9658 | .name = "Master Playback Switch", | |
9659 | .info = snd_hda_mixer_amp_switch_info, | |
9660 | .get = snd_hda_mixer_amp_switch_get, | |
9661 | .put = alc262_fujitsu_master_sw_put, | |
9662 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
9663 | }, | |
9664 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
9665 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
06a9c30c TV |
9666 | HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT), |
9667 | HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT), | |
834be88d TI |
9668 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9669 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9670 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
39d3ed38 TI |
9671 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), |
9672 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
9673 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
834be88d TI |
9674 | { } /* end */ |
9675 | }; | |
9676 | ||
0e31daf7 J |
9677 | /* bind hp and internal speaker mute (with plug check) */ |
9678 | static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol, | |
9679 | struct snd_ctl_elem_value *ucontrol) | |
9680 | { | |
9681 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
9682 | long *valp = ucontrol->value.integer.value; | |
9683 | int change; | |
9684 | ||
9685 | change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
9686 | HDA_AMP_MUTE, | |
9687 | valp ? 0 : HDA_AMP_MUTE); | |
9688 | ||
9689 | if (change) | |
9690 | alc262_lenovo_3000_automute(codec, 0); | |
9691 | return change; | |
9692 | } | |
9693 | ||
9694 | static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = { | |
9695 | HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol), | |
9696 | { | |
9697 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9698 | .name = "Master Playback Switch", | |
9699 | .info = snd_hda_mixer_amp_switch_info, | |
9700 | .get = snd_hda_mixer_amp_switch_get, | |
9701 | .put = alc262_lenovo_3000_master_sw_put, | |
9702 | .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), | |
9703 | }, | |
9704 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
9705 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
9706 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
9707 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9708 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9709 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
9710 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
9711 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
9712 | { } /* end */ | |
9713 | }; | |
9714 | ||
304dcaac TI |
9715 | /* additional init verbs for Benq laptops */ |
9716 | static struct hda_verb alc262_EAPD_verbs[] = { | |
9717 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
9718 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
9719 | {} | |
9720 | }; | |
9721 | ||
83c34218 KY |
9722 | static struct hda_verb alc262_benq_t31_EAPD_verbs[] = { |
9723 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9724 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
9725 | ||
9726 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
9727 | {0x20, AC_VERB_SET_PROC_COEF, 0x3050}, | |
9728 | {} | |
9729 | }; | |
9730 | ||
f651b50b TD |
9731 | /* Samsung Q1 Ultra Vista model setup */ |
9732 | static struct snd_kcontrol_new alc262_ultra_mixer[] = { | |
bb9f76cd TI |
9733 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9734 | HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT), | |
f651b50b TD |
9735 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
9736 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
9737 | HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT), | |
bb9f76cd | 9738 | HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT), |
f651b50b TD |
9739 | { } /* end */ |
9740 | }; | |
9741 | ||
9742 | static struct hda_verb alc262_ultra_verbs[] = { | |
bb9f76cd TI |
9743 | /* output mixer */ |
9744 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
9745 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
9746 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9747 | /* speaker */ | |
9748 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9749 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9750 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9751 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9752 | /* HP */ | |
f651b50b | 9753 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
bb9f76cd TI |
9754 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
9755 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9756 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9757 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
9758 | /* internal mic */ | |
9759 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
9760 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
9761 | /* ADC, choose mic */ | |
9762 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
9763 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
9764 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9765 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
9766 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
9767 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9768 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
9769 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
9770 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
9771 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)}, | |
f651b50b TD |
9772 | {} |
9773 | }; | |
9774 | ||
f651b50b TD |
9775 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
9776 | static void alc262_ultra_automute(struct hda_codec *codec) | |
9777 | { | |
9778 | struct alc_spec *spec = codec->spec; | |
9779 | unsigned int mute; | |
f651b50b | 9780 | |
bb9f76cd TI |
9781 | mute = 0; |
9782 | /* auto-mute only when HP is used as HP */ | |
9783 | if (!spec->cur_mux[0]) { | |
9784 | unsigned int present; | |
9785 | /* need to execute and sync at first */ | |
9786 | snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); | |
9787 | present = snd_hda_codec_read(codec, 0x15, 0, | |
9788 | AC_VERB_GET_PIN_SENSE, 0); | |
9789 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; | |
9790 | if (spec->jack_present) | |
9791 | mute = HDA_AMP_MUTE; | |
f651b50b | 9792 | } |
bb9f76cd TI |
9793 | /* mute/unmute internal speaker */ |
9794 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
9795 | HDA_AMP_MUTE, mute); | |
9796 | /* mute/unmute HP */ | |
9797 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
9798 | HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE); | |
f651b50b TD |
9799 | } |
9800 | ||
9801 | /* unsolicited event for HP jack sensing */ | |
9802 | static void alc262_ultra_unsol_event(struct hda_codec *codec, | |
9803 | unsigned int res) | |
9804 | { | |
9805 | if ((res >> 26) != ALC880_HP_EVENT) | |
9806 | return; | |
9807 | alc262_ultra_automute(codec); | |
9808 | } | |
9809 | ||
bb9f76cd TI |
9810 | static struct hda_input_mux alc262_ultra_capture_source = { |
9811 | .num_items = 2, | |
9812 | .items = { | |
9813 | { "Mic", 0x1 }, | |
9814 | { "Headphone", 0x7 }, | |
9815 | }, | |
9816 | }; | |
9817 | ||
9818 | static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol, | |
9819 | struct snd_ctl_elem_value *ucontrol) | |
9820 | { | |
9821 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
9822 | struct alc_spec *spec = codec->spec; | |
9823 | int ret; | |
9824 | ||
9825 | ret = alc882_mux_enum_put(kcontrol, ucontrol); | |
9826 | if (!ret) | |
9827 | return 0; | |
9828 | /* reprogram the HP pin as mic or HP according to the input source */ | |
9829 | snd_hda_codec_write_cache(codec, 0x15, 0, | |
9830 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
9831 | spec->cur_mux[0] ? PIN_VREF80 : PIN_HP); | |
9832 | alc262_ultra_automute(codec); /* mute/unmute HP */ | |
9833 | return ret; | |
9834 | } | |
9835 | ||
9836 | static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = { | |
9837 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), | |
9838 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), | |
9839 | { | |
9840 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9841 | .name = "Capture Source", | |
9842 | .info = alc882_mux_enum_info, | |
9843 | .get = alc882_mux_enum_get, | |
9844 | .put = alc262_ultra_mux_enum_put, | |
9845 | }, | |
9846 | { } /* end */ | |
9847 | }; | |
9848 | ||
df694daa | 9849 | /* add playback controls from the parsed DAC table */ |
f12ab1e0 TI |
9850 | static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, |
9851 | const struct auto_pin_cfg *cfg) | |
df694daa KY |
9852 | { |
9853 | hda_nid_t nid; | |
9854 | int err; | |
9855 | ||
9856 | spec->multiout.num_dacs = 1; /* only use one dac */ | |
9857 | spec->multiout.dac_nids = spec->private_dac_nids; | |
9858 | spec->multiout.dac_nids[0] = 2; | |
9859 | ||
9860 | nid = cfg->line_out_pins[0]; | |
9861 | if (nid) { | |
f12ab1e0 TI |
9862 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
9863 | "Front Playback Volume", | |
9864 | HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT)); | |
9865 | if (err < 0) | |
df694daa | 9866 | return err; |
f12ab1e0 TI |
9867 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
9868 | "Front Playback Switch", | |
9869 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
9870 | if (err < 0) | |
df694daa KY |
9871 | return err; |
9872 | } | |
9873 | ||
82bc955f | 9874 | nid = cfg->speaker_pins[0]; |
df694daa KY |
9875 | if (nid) { |
9876 | if (nid == 0x16) { | |
f12ab1e0 TI |
9877 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
9878 | "Speaker Playback Volume", | |
9879 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, | |
9880 | HDA_OUTPUT)); | |
9881 | if (err < 0) | |
df694daa | 9882 | return err; |
f12ab1e0 TI |
9883 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
9884 | "Speaker Playback Switch", | |
9885 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
9886 | HDA_OUTPUT)); | |
9887 | if (err < 0) | |
df694daa KY |
9888 | return err; |
9889 | } else { | |
f12ab1e0 TI |
9890 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
9891 | "Speaker Playback Switch", | |
9892 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
9893 | HDA_OUTPUT)); | |
9894 | if (err < 0) | |
df694daa KY |
9895 | return err; |
9896 | } | |
9897 | } | |
eb06ed8f | 9898 | nid = cfg->hp_pins[0]; |
df694daa KY |
9899 | if (nid) { |
9900 | /* spec->multiout.hp_nid = 2; */ | |
9901 | if (nid == 0x16) { | |
f12ab1e0 TI |
9902 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
9903 | "Headphone Playback Volume", | |
9904 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, | |
9905 | HDA_OUTPUT)); | |
9906 | if (err < 0) | |
df694daa | 9907 | return err; |
f12ab1e0 TI |
9908 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
9909 | "Headphone Playback Switch", | |
9910 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
9911 | HDA_OUTPUT)); | |
9912 | if (err < 0) | |
df694daa KY |
9913 | return err; |
9914 | } else { | |
f12ab1e0 TI |
9915 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
9916 | "Headphone Playback Switch", | |
9917 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
9918 | HDA_OUTPUT)); | |
9919 | if (err < 0) | |
df694daa KY |
9920 | return err; |
9921 | } | |
9922 | } | |
f12ab1e0 | 9923 | return 0; |
df694daa KY |
9924 | } |
9925 | ||
9926 | /* identical with ALC880 */ | |
f12ab1e0 TI |
9927 | #define alc262_auto_create_analog_input_ctls \ |
9928 | alc880_auto_create_analog_input_ctls | |
df694daa KY |
9929 | |
9930 | /* | |
9931 | * generic initialization of ADC, input mixers and output mixers | |
9932 | */ | |
9933 | static struct hda_verb alc262_volume_init_verbs[] = { | |
9934 | /* | |
9935 | * Unmute ADC0-2 and set the default input to mic-in | |
9936 | */ | |
9937 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9938 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9939 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9940 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9941 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9942 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9943 | ||
cb53c626 | 9944 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
df694daa | 9945 | * mixer widget |
f12ab1e0 TI |
9946 | * Note: PASD motherboards uses the Line In 2 as the input for |
9947 | * front panel mic (mic 2) | |
df694daa KY |
9948 | */ |
9949 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
9950 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
9951 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
9952 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
9953 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
9954 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
9955 | |
9956 | /* | |
9957 | * Set up output mixers (0x0c - 0x0f) | |
9958 | */ | |
9959 | /* set vol=0 to output mixers */ | |
9960 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9961 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9962 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
ea1fb29a | 9963 | |
df694daa KY |
9964 | /* set up input amps for analog loopback */ |
9965 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
9966 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9967 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9968 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9969 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9970 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9971 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9972 | ||
9973 | /* FIXME: use matrix-type input source selection */ | |
9974 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
9975 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
9976 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9977 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
9978 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
9979 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
9980 | /* Input mixer2 */ | |
9981 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9982 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
9983 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
9984 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
9985 | /* Input mixer3 */ | |
9986 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9987 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
9988 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
9989 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
9990 | ||
9991 | { } | |
9992 | }; | |
9993 | ||
9c7f852e TI |
9994 | static struct hda_verb alc262_HP_BPC_init_verbs[] = { |
9995 | /* | |
9996 | * Unmute ADC0-2 and set the default input to mic-in | |
9997 | */ | |
9998 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9999 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10000 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10001 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10002 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10003 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10004 | ||
cb53c626 | 10005 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
9c7f852e | 10006 | * mixer widget |
f12ab1e0 TI |
10007 | * Note: PASD motherboards uses the Line In 2 as the input for |
10008 | * front panel mic (mic 2) | |
9c7f852e TI |
10009 | */ |
10010 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
10011 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
10012 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10013 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
10014 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
10015 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
10016 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
10017 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
ea1fb29a | 10018 | |
9c7f852e TI |
10019 | /* |
10020 | * Set up output mixers (0x0c - 0x0e) | |
10021 | */ | |
10022 | /* set vol=0 to output mixers */ | |
10023 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10024 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10025 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10026 | ||
10027 | /* set up input amps for analog loopback */ | |
10028 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
10029 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10030 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10031 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10032 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10033 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10034 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10035 | ||
ce875f07 | 10036 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
9c7f852e TI |
10037 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
10038 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
10039 | ||
10040 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
10041 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
10042 | ||
10043 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10044 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10045 | ||
10046 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
10047 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
10048 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
10049 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
10050 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
10051 | ||
10052 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
10053 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10054 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10055 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
10056 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10057 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10058 | ||
10059 | ||
10060 | /* FIXME: use matrix-type input source selection */ | |
10061 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
10062 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
10063 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
10064 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
10065 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
10066 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
10067 | /* Input mixer2 */ | |
10068 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
10069 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
10070 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
10071 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
10072 | /* Input mixer3 */ | |
10073 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
10074 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
10075 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
10076 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
10077 | ||
ce875f07 TI |
10078 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
10079 | ||
9c7f852e TI |
10080 | { } |
10081 | }; | |
10082 | ||
cd7509a4 KY |
10083 | static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = { |
10084 | /* | |
10085 | * Unmute ADC0-2 and set the default input to mic-in | |
10086 | */ | |
10087 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10088 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10089 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10090 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10091 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10092 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10093 | ||
cb53c626 | 10094 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
cd7509a4 KY |
10095 | * mixer widget |
10096 | * Note: PASD motherboards uses the Line In 2 as the input for front | |
10097 | * panel mic (mic 2) | |
10098 | */ | |
10099 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
10100 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
10101 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10102 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
10103 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
10104 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
10105 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
10106 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
10107 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
cd7509a4 KY |
10108 | /* |
10109 | * Set up output mixers (0x0c - 0x0e) | |
10110 | */ | |
10111 | /* set vol=0 to output mixers */ | |
10112 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10113 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10114 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10115 | ||
10116 | /* set up input amps for analog loopback */ | |
10117 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
10118 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10119 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10120 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10121 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10122 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10123 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10124 | ||
10125 | ||
10126 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */ | |
10127 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */ | |
10128 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */ | |
10129 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */ | |
10130 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */ | |
10131 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */ | |
10132 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */ | |
10133 | ||
10134 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
10135 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
10136 | ||
10137 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10138 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
10139 | ||
10140 | /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */ | |
10141 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10142 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10143 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
10144 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10145 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10146 | ||
10147 | /* FIXME: use matrix-type input source selection */ | |
10148 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
10149 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
10150 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/ | |
10151 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/ | |
10152 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/ | |
10153 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/ | |
10154 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/ | |
10155 | /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
10156 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/ | |
10157 | /* Input mixer2 */ | |
10158 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
10159 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
10160 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
10161 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
10162 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
10163 | /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
10164 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, | |
10165 | /* Input mixer3 */ | |
10166 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
10167 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
10168 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
10169 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
10170 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
10171 | /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
10172 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, | |
10173 | ||
ce875f07 TI |
10174 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
10175 | ||
cd7509a4 KY |
10176 | { } |
10177 | }; | |
10178 | ||
cb53c626 TI |
10179 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
10180 | #define alc262_loopbacks alc880_loopbacks | |
10181 | #endif | |
10182 | ||
df694daa KY |
10183 | /* pcm configuration: identiacal with ALC880 */ |
10184 | #define alc262_pcm_analog_playback alc880_pcm_analog_playback | |
10185 | #define alc262_pcm_analog_capture alc880_pcm_analog_capture | |
10186 | #define alc262_pcm_digital_playback alc880_pcm_digital_playback | |
10187 | #define alc262_pcm_digital_capture alc880_pcm_digital_capture | |
10188 | ||
10189 | /* | |
10190 | * BIOS auto configuration | |
10191 | */ | |
10192 | static int alc262_parse_auto_config(struct hda_codec *codec) | |
10193 | { | |
10194 | struct alc_spec *spec = codec->spec; | |
10195 | int err; | |
10196 | static hda_nid_t alc262_ignore[] = { 0x1d, 0 }; | |
10197 | ||
f12ab1e0 TI |
10198 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
10199 | alc262_ignore); | |
10200 | if (err < 0) | |
df694daa | 10201 | return err; |
f12ab1e0 | 10202 | if (!spec->autocfg.line_outs) |
df694daa | 10203 | return 0; /* can't find valid BIOS pin config */ |
f12ab1e0 TI |
10204 | err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg); |
10205 | if (err < 0) | |
10206 | return err; | |
10207 | err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
10208 | if (err < 0) | |
df694daa KY |
10209 | return err; |
10210 | ||
10211 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
10212 | ||
10213 | if (spec->autocfg.dig_out_pin) | |
10214 | spec->multiout.dig_out_nid = ALC262_DIGOUT_NID; | |
10215 | if (spec->autocfg.dig_in_pin) | |
10216 | spec->dig_in_nid = ALC262_DIGIN_NID; | |
10217 | ||
10218 | if (spec->kctl_alloc) | |
10219 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
10220 | ||
10221 | spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs; | |
a1e8d2da | 10222 | spec->num_mux_defs = 1; |
df694daa KY |
10223 | spec->input_mux = &spec->private_imux; |
10224 | ||
776e184e TI |
10225 | err = alc_auto_add_mic_boost(codec); |
10226 | if (err < 0) | |
10227 | return err; | |
10228 | ||
df694daa KY |
10229 | return 1; |
10230 | } | |
10231 | ||
10232 | #define alc262_auto_init_multi_out alc882_auto_init_multi_out | |
10233 | #define alc262_auto_init_hp_out alc882_auto_init_hp_out | |
10234 | #define alc262_auto_init_analog_input alc882_auto_init_analog_input | |
f511b01c | 10235 | #define alc262_auto_init_input_src alc882_auto_init_input_src |
df694daa KY |
10236 | |
10237 | ||
10238 | /* init callback for auto-configuration model -- overriding the default init */ | |
ae6b813a | 10239 | static void alc262_auto_init(struct hda_codec *codec) |
df694daa | 10240 | { |
f6c7e546 | 10241 | struct alc_spec *spec = codec->spec; |
df694daa KY |
10242 | alc262_auto_init_multi_out(codec); |
10243 | alc262_auto_init_hp_out(codec); | |
10244 | alc262_auto_init_analog_input(codec); | |
f511b01c | 10245 | alc262_auto_init_input_src(codec); |
f6c7e546 TI |
10246 | if (spec->unsol_event) |
10247 | alc_sku_automute(codec); | |
df694daa KY |
10248 | } |
10249 | ||
10250 | /* | |
10251 | * configuration and preset | |
10252 | */ | |
f5fcc13c TI |
10253 | static const char *alc262_models[ALC262_MODEL_LAST] = { |
10254 | [ALC262_BASIC] = "basic", | |
10255 | [ALC262_HIPPO] = "hippo", | |
10256 | [ALC262_HIPPO_1] = "hippo_1", | |
10257 | [ALC262_FUJITSU] = "fujitsu", | |
10258 | [ALC262_HP_BPC] = "hp-bpc", | |
cd7509a4 | 10259 | [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000", |
61dc35de | 10260 | [ALC262_HP_TC_T5735] = "hp-tc-t5735", |
8c427226 | 10261 | [ALC262_HP_RP5700] = "hp-rp5700", |
f5fcc13c | 10262 | [ALC262_BENQ_ED8] = "benq", |
0f40502e TI |
10263 | [ALC262_BENQ_T31] = "benq-t31", |
10264 | [ALC262_SONY_ASSAMD] = "sony-assamd", | |
2922c9af | 10265 | [ALC262_TOSHIBA_S06] = "toshiba-s06", |
f651b50b | 10266 | [ALC262_ULTRA] = "ultra", |
0e31daf7 | 10267 | [ALC262_LENOVO_3000] = "lenovo-3000", |
e8f9ae2a | 10268 | [ALC262_NEC] = "nec", |
f5fcc13c TI |
10269 | [ALC262_AUTO] = "auto", |
10270 | }; | |
10271 | ||
10272 | static struct snd_pci_quirk alc262_cfg_tbl[] = { | |
10273 | SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO), | |
e8f9ae2a | 10274 | SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC), |
f5fcc13c | 10275 | SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC), |
7d87de2d | 10276 | SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC), |
ac3e3741 TI |
10277 | SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC), |
10278 | SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC), | |
7d87de2d | 10279 | SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC), |
b98f9334 | 10280 | SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC), |
b98f9334 | 10281 | SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC), |
b98f9334 | 10282 | SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC), |
cd7509a4 | 10283 | SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL), |
cd7509a4 | 10284 | SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF), |
ac3e3741 | 10285 | SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL), |
cd7509a4 | 10286 | SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF), |
ac3e3741 | 10287 | SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL), |
cd7509a4 | 10288 | SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF), |
ac3e3741 | 10289 | SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL), |
cd7509a4 | 10290 | SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF), |
ac3e3741 TI |
10291 | SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC), |
10292 | SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC), | |
10293 | SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC), | |
66d2a9d6 KY |
10294 | SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735", |
10295 | ALC262_HP_TC_T5735), | |
8c427226 | 10296 | SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700), |
ac3e3741 | 10297 | SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD), |
f5fcc13c | 10298 | SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO), |
5b31954e | 10299 | SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD), |
272a527c | 10300 | SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD), |
ac3e3741 | 10301 | SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD), |
36ca6e13 AI |
10302 | SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1", |
10303 | ALC262_SONY_ASSAMD), | |
4e555fe5 | 10304 | SND_PCI_QUIRK(0x1179, 0x0268, "Toshiba S06", ALC262_TOSHIBA_S06), |
ac3e3741 | 10305 | SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU), |
3f1eeaed | 10306 | SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU), |
f651b50b | 10307 | SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA), |
bb9f76cd | 10308 | SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA), |
0e31daf7 | 10309 | SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000), |
ac3e3741 TI |
10310 | SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8), |
10311 | SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31), | |
10312 | SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1), | |
df694daa KY |
10313 | {} |
10314 | }; | |
10315 | ||
10316 | static struct alc_config_preset alc262_presets[] = { | |
10317 | [ALC262_BASIC] = { | |
10318 | .mixers = { alc262_base_mixer }, | |
10319 | .init_verbs = { alc262_init_verbs }, | |
10320 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10321 | .dac_nids = alc262_dac_nids, | |
10322 | .hp_nid = 0x03, | |
10323 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10324 | .channel_mode = alc262_modes, | |
a3bcba38 | 10325 | .input_mux = &alc262_capture_source, |
df694daa | 10326 | }, |
ccc656ce KY |
10327 | [ALC262_HIPPO] = { |
10328 | .mixers = { alc262_base_mixer }, | |
10329 | .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs}, | |
10330 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10331 | .dac_nids = alc262_dac_nids, | |
10332 | .hp_nid = 0x03, | |
10333 | .dig_out_nid = ALC262_DIGOUT_NID, | |
10334 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10335 | .channel_mode = alc262_modes, | |
10336 | .input_mux = &alc262_capture_source, | |
10337 | .unsol_event = alc262_hippo_unsol_event, | |
5b31954e | 10338 | .init_hook = alc262_hippo_automute, |
ccc656ce KY |
10339 | }, |
10340 | [ALC262_HIPPO_1] = { | |
10341 | .mixers = { alc262_hippo1_mixer }, | |
10342 | .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs}, | |
10343 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10344 | .dac_nids = alc262_dac_nids, | |
10345 | .hp_nid = 0x02, | |
10346 | .dig_out_nid = ALC262_DIGOUT_NID, | |
10347 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10348 | .channel_mode = alc262_modes, | |
10349 | .input_mux = &alc262_capture_source, | |
10350 | .unsol_event = alc262_hippo1_unsol_event, | |
5b31954e | 10351 | .init_hook = alc262_hippo1_automute, |
ccc656ce | 10352 | }, |
834be88d TI |
10353 | [ALC262_FUJITSU] = { |
10354 | .mixers = { alc262_fujitsu_mixer }, | |
39d3ed38 TI |
10355 | .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs, |
10356 | alc262_fujitsu_unsol_verbs }, | |
834be88d TI |
10357 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), |
10358 | .dac_nids = alc262_dac_nids, | |
10359 | .hp_nid = 0x03, | |
10360 | .dig_out_nid = ALC262_DIGOUT_NID, | |
10361 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10362 | .channel_mode = alc262_modes, | |
10363 | .input_mux = &alc262_fujitsu_capture_source, | |
ae6b813a | 10364 | .unsol_event = alc262_fujitsu_unsol_event, |
ebc7a406 | 10365 | .init_hook = alc262_fujitsu_init_hook, |
834be88d | 10366 | }, |
9c7f852e TI |
10367 | [ALC262_HP_BPC] = { |
10368 | .mixers = { alc262_HP_BPC_mixer }, | |
10369 | .init_verbs = { alc262_HP_BPC_init_verbs }, | |
10370 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10371 | .dac_nids = alc262_dac_nids, | |
10372 | .hp_nid = 0x03, | |
10373 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10374 | .channel_mode = alc262_modes, | |
10375 | .input_mux = &alc262_HP_capture_source, | |
ce875f07 TI |
10376 | .unsol_event = alc262_hp_bpc_unsol_event, |
10377 | .init_hook = alc262_hp_bpc_automute, | |
f12ab1e0 | 10378 | }, |
cd7509a4 KY |
10379 | [ALC262_HP_BPC_D7000_WF] = { |
10380 | .mixers = { alc262_HP_BPC_WildWest_mixer }, | |
10381 | .init_verbs = { alc262_HP_BPC_WildWest_init_verbs }, | |
10382 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10383 | .dac_nids = alc262_dac_nids, | |
10384 | .hp_nid = 0x03, | |
10385 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10386 | .channel_mode = alc262_modes, | |
accbe498 | 10387 | .input_mux = &alc262_HP_D7000_capture_source, |
ce875f07 TI |
10388 | .unsol_event = alc262_hp_wildwest_unsol_event, |
10389 | .init_hook = alc262_hp_wildwest_automute, | |
f12ab1e0 | 10390 | }, |
cd7509a4 KY |
10391 | [ALC262_HP_BPC_D7000_WL] = { |
10392 | .mixers = { alc262_HP_BPC_WildWest_mixer, | |
10393 | alc262_HP_BPC_WildWest_option_mixer }, | |
10394 | .init_verbs = { alc262_HP_BPC_WildWest_init_verbs }, | |
10395 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10396 | .dac_nids = alc262_dac_nids, | |
10397 | .hp_nid = 0x03, | |
10398 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10399 | .channel_mode = alc262_modes, | |
accbe498 | 10400 | .input_mux = &alc262_HP_D7000_capture_source, |
ce875f07 TI |
10401 | .unsol_event = alc262_hp_wildwest_unsol_event, |
10402 | .init_hook = alc262_hp_wildwest_automute, | |
f12ab1e0 | 10403 | }, |
66d2a9d6 KY |
10404 | [ALC262_HP_TC_T5735] = { |
10405 | .mixers = { alc262_hp_t5735_mixer }, | |
10406 | .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs }, | |
10407 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10408 | .dac_nids = alc262_dac_nids, | |
10409 | .hp_nid = 0x03, | |
10410 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10411 | .channel_mode = alc262_modes, | |
10412 | .input_mux = &alc262_capture_source, | |
10413 | .unsol_event = alc262_hp_t5735_unsol_event, | |
10414 | .init_hook = alc262_hp_t5735_init_hook, | |
8c427226 KY |
10415 | }, |
10416 | [ALC262_HP_RP5700] = { | |
10417 | .mixers = { alc262_hp_rp5700_mixer }, | |
10418 | .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs }, | |
10419 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10420 | .dac_nids = alc262_dac_nids, | |
10421 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10422 | .channel_mode = alc262_modes, | |
10423 | .input_mux = &alc262_hp_rp5700_capture_source, | |
66d2a9d6 | 10424 | }, |
304dcaac TI |
10425 | [ALC262_BENQ_ED8] = { |
10426 | .mixers = { alc262_base_mixer }, | |
10427 | .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs }, | |
10428 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10429 | .dac_nids = alc262_dac_nids, | |
10430 | .hp_nid = 0x03, | |
10431 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10432 | .channel_mode = alc262_modes, | |
10433 | .input_mux = &alc262_capture_source, | |
f12ab1e0 | 10434 | }, |
272a527c KY |
10435 | [ALC262_SONY_ASSAMD] = { |
10436 | .mixers = { alc262_sony_mixer }, | |
10437 | .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs}, | |
10438 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10439 | .dac_nids = alc262_dac_nids, | |
10440 | .hp_nid = 0x02, | |
10441 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10442 | .channel_mode = alc262_modes, | |
10443 | .input_mux = &alc262_capture_source, | |
10444 | .unsol_event = alc262_hippo_unsol_event, | |
5b31954e | 10445 | .init_hook = alc262_hippo_automute, |
83c34218 KY |
10446 | }, |
10447 | [ALC262_BENQ_T31] = { | |
10448 | .mixers = { alc262_benq_t31_mixer }, | |
10449 | .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs }, | |
10450 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10451 | .dac_nids = alc262_dac_nids, | |
10452 | .hp_nid = 0x03, | |
10453 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10454 | .channel_mode = alc262_modes, | |
10455 | .input_mux = &alc262_capture_source, | |
10456 | .unsol_event = alc262_hippo_unsol_event, | |
5b31954e | 10457 | .init_hook = alc262_hippo_automute, |
ea1fb29a | 10458 | }, |
f651b50b | 10459 | [ALC262_ULTRA] = { |
bb9f76cd TI |
10460 | .mixers = { alc262_ultra_mixer, alc262_ultra_capture_mixer }, |
10461 | .init_verbs = { alc262_ultra_verbs }, | |
f651b50b TD |
10462 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), |
10463 | .dac_nids = alc262_dac_nids, | |
f651b50b TD |
10464 | .num_channel_mode = ARRAY_SIZE(alc262_modes), |
10465 | .channel_mode = alc262_modes, | |
10466 | .input_mux = &alc262_ultra_capture_source, | |
bb9f76cd TI |
10467 | .adc_nids = alc262_adc_nids, /* ADC0 */ |
10468 | .capsrc_nids = alc262_capsrc_nids, | |
10469 | .num_adc_nids = 1, /* single ADC */ | |
f651b50b TD |
10470 | .unsol_event = alc262_ultra_unsol_event, |
10471 | .init_hook = alc262_ultra_automute, | |
10472 | }, | |
0e31daf7 J |
10473 | [ALC262_LENOVO_3000] = { |
10474 | .mixers = { alc262_lenovo_3000_mixer }, | |
10475 | .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs, | |
10476 | alc262_lenovo_3000_unsol_verbs }, | |
10477 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10478 | .dac_nids = alc262_dac_nids, | |
10479 | .hp_nid = 0x03, | |
10480 | .dig_out_nid = ALC262_DIGOUT_NID, | |
10481 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10482 | .channel_mode = alc262_modes, | |
10483 | .input_mux = &alc262_fujitsu_capture_source, | |
10484 | .unsol_event = alc262_lenovo_3000_unsol_event, | |
10485 | }, | |
e8f9ae2a PT |
10486 | [ALC262_NEC] = { |
10487 | .mixers = { alc262_nec_mixer }, | |
10488 | .init_verbs = { alc262_nec_verbs }, | |
10489 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10490 | .dac_nids = alc262_dac_nids, | |
10491 | .hp_nid = 0x03, | |
10492 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10493 | .channel_mode = alc262_modes, | |
10494 | .input_mux = &alc262_capture_source, | |
10495 | }, | |
4e555fe5 KY |
10496 | [ALC262_TOSHIBA_S06] = { |
10497 | .mixers = { alc262_toshiba_s06_mixer }, | |
10498 | .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs, | |
10499 | alc262_eapd_verbs }, | |
10500 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10501 | .capsrc_nids = alc262_dmic_capsrc_nids, | |
10502 | .dac_nids = alc262_dac_nids, | |
10503 | .adc_nids = alc262_dmic_adc_nids, /* ADC0 */ | |
10504 | .dig_out_nid = ALC262_DIGOUT_NID, | |
10505 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10506 | .channel_mode = alc262_modes, | |
10507 | .input_mux = &alc262_dmic_capture_source, | |
10508 | .unsol_event = alc262_toshiba_s06_unsol_event, | |
10509 | .init_hook = alc262_toshiba_s06_init_hook, | |
10510 | }, | |
df694daa KY |
10511 | }; |
10512 | ||
10513 | static int patch_alc262(struct hda_codec *codec) | |
10514 | { | |
10515 | struct alc_spec *spec; | |
10516 | int board_config; | |
10517 | int err; | |
10518 | ||
dc041e0b | 10519 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
df694daa KY |
10520 | if (spec == NULL) |
10521 | return -ENOMEM; | |
10522 | ||
10523 | codec->spec = spec; | |
10524 | #if 0 | |
f12ab1e0 TI |
10525 | /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is |
10526 | * under-run | |
10527 | */ | |
df694daa KY |
10528 | { |
10529 | int tmp; | |
10530 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); | |
10531 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); | |
10532 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); | |
10533 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); | |
10534 | } | |
10535 | #endif | |
10536 | ||
2c3bf9ab TI |
10537 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
10538 | ||
f5fcc13c TI |
10539 | board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST, |
10540 | alc262_models, | |
10541 | alc262_cfg_tbl); | |
cd7509a4 | 10542 | |
f5fcc13c | 10543 | if (board_config < 0) { |
9c7f852e TI |
10544 | printk(KERN_INFO "hda_codec: Unknown model for ALC262, " |
10545 | "trying auto-probe from BIOS...\n"); | |
df694daa KY |
10546 | board_config = ALC262_AUTO; |
10547 | } | |
10548 | ||
10549 | if (board_config == ALC262_AUTO) { | |
10550 | /* automatic parse from the BIOS config */ | |
10551 | err = alc262_parse_auto_config(codec); | |
10552 | if (err < 0) { | |
10553 | alc_free(codec); | |
10554 | return err; | |
f12ab1e0 | 10555 | } else if (!err) { |
9c7f852e TI |
10556 | printk(KERN_INFO |
10557 | "hda_codec: Cannot set up configuration " | |
10558 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
10559 | board_config = ALC262_BASIC; |
10560 | } | |
10561 | } | |
10562 | ||
10563 | if (board_config != ALC262_AUTO) | |
10564 | setup_preset(spec, &alc262_presets[board_config]); | |
10565 | ||
10566 | spec->stream_name_analog = "ALC262 Analog"; | |
10567 | spec->stream_analog_playback = &alc262_pcm_analog_playback; | |
10568 | spec->stream_analog_capture = &alc262_pcm_analog_capture; | |
ea1fb29a | 10569 | |
df694daa KY |
10570 | spec->stream_name_digital = "ALC262 Digital"; |
10571 | spec->stream_digital_playback = &alc262_pcm_digital_playback; | |
10572 | spec->stream_digital_capture = &alc262_pcm_digital_capture; | |
10573 | ||
f12ab1e0 | 10574 | if (!spec->adc_nids && spec->input_mux) { |
df694daa | 10575 | /* check whether NID 0x07 is valid */ |
4a471b7d TI |
10576 | unsigned int wcap = get_wcaps(codec, 0x07); |
10577 | ||
f12ab1e0 TI |
10578 | /* get type */ |
10579 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
df694daa KY |
10580 | if (wcap != AC_WID_AUD_IN) { |
10581 | spec->adc_nids = alc262_adc_nids_alt; | |
10582 | spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt); | |
88c71a99 | 10583 | spec->capsrc_nids = alc262_capsrc_nids_alt; |
f12ab1e0 TI |
10584 | spec->mixers[spec->num_mixers] = |
10585 | alc262_capture_alt_mixer; | |
df694daa KY |
10586 | spec->num_mixers++; |
10587 | } else { | |
10588 | spec->adc_nids = alc262_adc_nids; | |
10589 | spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids); | |
88c71a99 | 10590 | spec->capsrc_nids = alc262_capsrc_nids; |
df694daa KY |
10591 | spec->mixers[spec->num_mixers] = alc262_capture_mixer; |
10592 | spec->num_mixers++; | |
10593 | } | |
10594 | } | |
10595 | ||
2134ea4f TI |
10596 | spec->vmaster_nid = 0x0c; |
10597 | ||
df694daa KY |
10598 | codec->patch_ops = alc_patch_ops; |
10599 | if (board_config == ALC262_AUTO) | |
ae6b813a | 10600 | spec->init_hook = alc262_auto_init; |
cb53c626 TI |
10601 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
10602 | if (!spec->loopback.amplist) | |
10603 | spec->loopback.amplist = alc262_loopbacks; | |
10604 | #endif | |
ea1fb29a | 10605 | |
df694daa KY |
10606 | return 0; |
10607 | } | |
10608 | ||
a361d84b KY |
10609 | /* |
10610 | * ALC268 channel source setting (2 channel) | |
10611 | */ | |
10612 | #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID | |
10613 | #define alc268_modes alc260_modes | |
ea1fb29a | 10614 | |
a361d84b KY |
10615 | static hda_nid_t alc268_dac_nids[2] = { |
10616 | /* front, hp */ | |
10617 | 0x02, 0x03 | |
10618 | }; | |
10619 | ||
10620 | static hda_nid_t alc268_adc_nids[2] = { | |
10621 | /* ADC0-1 */ | |
10622 | 0x08, 0x07 | |
10623 | }; | |
10624 | ||
10625 | static hda_nid_t alc268_adc_nids_alt[1] = { | |
10626 | /* ADC0 */ | |
10627 | 0x08 | |
10628 | }; | |
10629 | ||
e1406348 TI |
10630 | static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 }; |
10631 | ||
a361d84b KY |
10632 | static struct snd_kcontrol_new alc268_base_mixer[] = { |
10633 | /* output mixer control */ | |
10634 | HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT), | |
10635 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
10636 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT), | |
10637 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
33bf17ab TI |
10638 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
10639 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
10640 | HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT), | |
a361d84b KY |
10641 | { } |
10642 | }; | |
10643 | ||
aef9d318 TI |
10644 | /* bind Beep switches of both NID 0x0f and 0x10 */ |
10645 | static struct hda_bind_ctls alc268_bind_beep_sw = { | |
10646 | .ops = &snd_hda_bind_sw, | |
10647 | .values = { | |
10648 | HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT), | |
10649 | HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT), | |
10650 | 0 | |
10651 | }, | |
10652 | }; | |
10653 | ||
10654 | static struct snd_kcontrol_new alc268_beep_mixer[] = { | |
10655 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT), | |
10656 | HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw), | |
10657 | { } | |
10658 | }; | |
10659 | ||
d1a991a6 KY |
10660 | static struct hda_verb alc268_eapd_verbs[] = { |
10661 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
10662 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
10663 | { } | |
10664 | }; | |
10665 | ||
d273809e TI |
10666 | /* Toshiba specific */ |
10667 | #define alc268_toshiba_automute alc262_hippo_automute | |
10668 | ||
10669 | static struct hda_verb alc268_toshiba_verbs[] = { | |
10670 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
10671 | { } /* end */ | |
10672 | }; | |
10673 | ||
8ef355da KY |
10674 | static struct hda_input_mux alc268_acer_lc_capture_source = { |
10675 | .num_items = 2, | |
10676 | .items = { | |
10677 | { "i-Mic", 0x6 }, | |
10678 | { "E-Mic", 0x0 }, | |
10679 | }, | |
10680 | }; | |
10681 | ||
d273809e | 10682 | /* Acer specific */ |
889c4395 | 10683 | /* bind volumes of both NID 0x02 and 0x03 */ |
6bc96857 TI |
10684 | static struct hda_bind_ctls alc268_acer_bind_master_vol = { |
10685 | .ops = &snd_hda_bind_vol, | |
10686 | .values = { | |
10687 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), | |
10688 | HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT), | |
10689 | 0 | |
10690 | }, | |
10691 | }; | |
10692 | ||
889c4395 TI |
10693 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
10694 | static void alc268_acer_automute(struct hda_codec *codec, int force) | |
10695 | { | |
10696 | struct alc_spec *spec = codec->spec; | |
10697 | unsigned int mute; | |
10698 | ||
10699 | if (force || !spec->sense_updated) { | |
10700 | unsigned int present; | |
10701 | present = snd_hda_codec_read(codec, 0x14, 0, | |
10702 | AC_VERB_GET_PIN_SENSE, 0); | |
10703 | spec->jack_present = (present & 0x80000000) != 0; | |
10704 | spec->sense_updated = 1; | |
10705 | } | |
10706 | if (spec->jack_present) | |
10707 | mute = HDA_AMP_MUTE; /* mute internal speaker */ | |
10708 | else /* unmute internal speaker if necessary */ | |
10709 | mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); | |
10710 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
10711 | HDA_AMP_MUTE, mute); | |
10712 | } | |
10713 | ||
10714 | ||
10715 | /* bind hp and internal speaker mute (with plug check) */ | |
10716 | static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol, | |
10717 | struct snd_ctl_elem_value *ucontrol) | |
10718 | { | |
10719 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
10720 | long *valp = ucontrol->value.integer.value; | |
10721 | int change; | |
10722 | ||
10723 | change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, | |
10724 | HDA_AMP_MUTE, | |
10725 | valp[0] ? 0 : HDA_AMP_MUTE); | |
10726 | change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, | |
10727 | HDA_AMP_MUTE, | |
10728 | valp[1] ? 0 : HDA_AMP_MUTE); | |
10729 | if (change) | |
10730 | alc268_acer_automute(codec, 0); | |
10731 | return change; | |
10732 | } | |
d273809e | 10733 | |
8ef355da KY |
10734 | static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = { |
10735 | /* output mixer control */ | |
10736 | HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol), | |
10737 | { | |
10738 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10739 | .name = "Master Playback Switch", | |
10740 | .info = snd_hda_mixer_amp_switch_info, | |
10741 | .get = snd_hda_mixer_amp_switch_get, | |
10742 | .put = alc268_acer_master_sw_put, | |
10743 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
10744 | }, | |
10745 | HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT), | |
10746 | { } | |
10747 | }; | |
10748 | ||
d273809e TI |
10749 | static struct snd_kcontrol_new alc268_acer_mixer[] = { |
10750 | /* output mixer control */ | |
10751 | HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol), | |
10752 | { | |
10753 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10754 | .name = "Master Playback Switch", | |
10755 | .info = snd_hda_mixer_amp_switch_info, | |
10756 | .get = snd_hda_mixer_amp_switch_get, | |
10757 | .put = alc268_acer_master_sw_put, | |
10758 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
10759 | }, | |
33bf17ab TI |
10760 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
10761 | HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT), | |
10762 | HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT), | |
d273809e TI |
10763 | { } |
10764 | }; | |
10765 | ||
8ef355da KY |
10766 | static struct hda_verb alc268_acer_aspire_one_verbs[] = { |
10767 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
10768 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
10769 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
10770 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
10771 | {0x23, AC_VERB_SET_CONNECT_SEL, 0x06}, | |
10772 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017}, | |
10773 | { } | |
10774 | }; | |
10775 | ||
d273809e | 10776 | static struct hda_verb alc268_acer_verbs[] = { |
0ccb541c TI |
10777 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */ |
10778 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
d273809e TI |
10779 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
10780 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
0ccb541c TI |
10781 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
10782 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
d273809e TI |
10783 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
10784 | { } | |
10785 | }; | |
10786 | ||
10787 | /* unsolicited event for HP jack sensing */ | |
10788 | static void alc268_toshiba_unsol_event(struct hda_codec *codec, | |
10789 | unsigned int res) | |
10790 | { | |
889c4395 | 10791 | if ((res >> 26) != ALC880_HP_EVENT) |
d273809e TI |
10792 | return; |
10793 | alc268_toshiba_automute(codec); | |
10794 | } | |
10795 | ||
10796 | static void alc268_acer_unsol_event(struct hda_codec *codec, | |
10797 | unsigned int res) | |
10798 | { | |
889c4395 | 10799 | if ((res >> 26) != ALC880_HP_EVENT) |
d273809e TI |
10800 | return; |
10801 | alc268_acer_automute(codec, 1); | |
10802 | } | |
10803 | ||
889c4395 TI |
10804 | static void alc268_acer_init_hook(struct hda_codec *codec) |
10805 | { | |
10806 | alc268_acer_automute(codec, 1); | |
10807 | } | |
10808 | ||
8ef355da KY |
10809 | /* toggle speaker-output according to the hp-jack state */ |
10810 | static void alc268_aspire_one_speaker_automute(struct hda_codec *codec) | |
10811 | { | |
10812 | unsigned int present; | |
10813 | unsigned char bits; | |
10814 | ||
10815 | present = snd_hda_codec_read(codec, 0x15, 0, | |
10816 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
10817 | bits = present ? AMP_IN_MUTE(0) : 0; | |
10818 | snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0, | |
10819 | AMP_IN_MUTE(0), bits); | |
10820 | snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1, | |
10821 | AMP_IN_MUTE(0), bits); | |
10822 | } | |
10823 | ||
10824 | ||
10825 | static void alc268_acer_mic_automute(struct hda_codec *codec) | |
10826 | { | |
10827 | unsigned int present; | |
10828 | ||
10829 | present = snd_hda_codec_read(codec, 0x18, 0, | |
10830 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
10831 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL, | |
10832 | present ? 0x0 : 0x6); | |
10833 | } | |
10834 | ||
10835 | static void alc268_acer_lc_unsol_event(struct hda_codec *codec, | |
10836 | unsigned int res) | |
10837 | { | |
10838 | if ((res >> 26) == ALC880_HP_EVENT) | |
10839 | alc268_aspire_one_speaker_automute(codec); | |
10840 | if ((res >> 26) == ALC880_MIC_EVENT) | |
10841 | alc268_acer_mic_automute(codec); | |
10842 | } | |
10843 | ||
10844 | static void alc268_acer_lc_init_hook(struct hda_codec *codec) | |
10845 | { | |
10846 | alc268_aspire_one_speaker_automute(codec); | |
10847 | alc268_acer_mic_automute(codec); | |
10848 | } | |
10849 | ||
3866f0b0 TI |
10850 | static struct snd_kcontrol_new alc268_dell_mixer[] = { |
10851 | /* output mixer control */ | |
10852 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
10853 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
10854 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
10855 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
10856 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
10857 | HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT), | |
10858 | { } | |
10859 | }; | |
10860 | ||
10861 | static struct hda_verb alc268_dell_verbs[] = { | |
10862 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
10863 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
10864 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
10865 | { } | |
10866 | }; | |
10867 | ||
10868 | /* mute/unmute internal speaker according to the hp jack and mute state */ | |
10869 | static void alc268_dell_automute(struct hda_codec *codec) | |
10870 | { | |
10871 | unsigned int present; | |
10872 | unsigned int mute; | |
10873 | ||
10874 | present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0); | |
10875 | if (present & 0x80000000) | |
10876 | mute = HDA_AMP_MUTE; | |
10877 | else | |
10878 | mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0); | |
10879 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
10880 | HDA_AMP_MUTE, mute); | |
10881 | } | |
10882 | ||
10883 | static void alc268_dell_unsol_event(struct hda_codec *codec, | |
10884 | unsigned int res) | |
10885 | { | |
10886 | if ((res >> 26) != ALC880_HP_EVENT) | |
10887 | return; | |
10888 | alc268_dell_automute(codec); | |
10889 | } | |
10890 | ||
10891 | #define alc268_dell_init_hook alc268_dell_automute | |
10892 | ||
eb5a6621 HRK |
10893 | static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = { |
10894 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT), | |
10895 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
10896 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT), | |
10897 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
10898 | HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT), | |
10899 | HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT), | |
10900 | HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT), | |
10901 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
10902 | { } | |
10903 | }; | |
10904 | ||
10905 | static struct hda_verb alc267_quanta_il1_verbs[] = { | |
10906 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
10907 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, | |
10908 | { } | |
10909 | }; | |
10910 | ||
10911 | static void alc267_quanta_il1_hp_automute(struct hda_codec *codec) | |
10912 | { | |
10913 | unsigned int present; | |
10914 | ||
10915 | present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0) | |
10916 | & AC_PINSENSE_PRESENCE; | |
10917 | snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
10918 | present ? 0 : PIN_OUT); | |
10919 | } | |
10920 | ||
10921 | static void alc267_quanta_il1_mic_automute(struct hda_codec *codec) | |
10922 | { | |
10923 | unsigned int present; | |
10924 | ||
10925 | present = snd_hda_codec_read(codec, 0x18, 0, | |
10926 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
10927 | snd_hda_codec_write(codec, 0x23, 0, | |
10928 | AC_VERB_SET_CONNECT_SEL, | |
10929 | present ? 0x00 : 0x01); | |
10930 | } | |
10931 | ||
10932 | static void alc267_quanta_il1_automute(struct hda_codec *codec) | |
10933 | { | |
10934 | alc267_quanta_il1_hp_automute(codec); | |
10935 | alc267_quanta_il1_mic_automute(codec); | |
10936 | } | |
10937 | ||
10938 | static void alc267_quanta_il1_unsol_event(struct hda_codec *codec, | |
10939 | unsigned int res) | |
10940 | { | |
10941 | switch (res >> 26) { | |
10942 | case ALC880_HP_EVENT: | |
10943 | alc267_quanta_il1_hp_automute(codec); | |
10944 | break; | |
10945 | case ALC880_MIC_EVENT: | |
10946 | alc267_quanta_il1_mic_automute(codec); | |
10947 | break; | |
10948 | } | |
10949 | } | |
10950 | ||
a361d84b KY |
10951 | /* |
10952 | * generic initialization of ADC, input mixers and output mixers | |
10953 | */ | |
10954 | static struct hda_verb alc268_base_init_verbs[] = { | |
10955 | /* Unmute DAC0-1 and set vol = 0 */ | |
10956 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10957 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10958 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10959 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10960 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10961 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10962 | ||
10963 | /* | |
10964 | * Set up output mixers (0x0c - 0x0e) | |
10965 | */ | |
10966 | /* set vol=0 to output mixers */ | |
10967 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10968 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10969 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10970 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10971 | ||
10972 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10973 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10974 | ||
10975 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
10976 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
10977 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
10978 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
10979 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
10980 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
10981 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
10982 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
10983 | ||
10984 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10985 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10986 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10987 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10988 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10989 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10990 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
aef9d318 TI |
10991 | |
10992 | /* set PCBEEP vol = 0, mute connections */ | |
10993 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10994 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10995 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
a361d84b | 10996 | |
a9b3aa8a | 10997 | /* Unmute Selector 23h,24h and set the default input to mic-in */ |
ea1fb29a | 10998 | |
a9b3aa8a JZ |
10999 | {0x23, AC_VERB_SET_CONNECT_SEL, 0x00}, |
11000 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11001 | {0x24, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
11002 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
a361d84b | 11003 | |
a361d84b KY |
11004 | { } |
11005 | }; | |
11006 | ||
11007 | /* | |
11008 | * generic initialization of ADC, input mixers and output mixers | |
11009 | */ | |
11010 | static struct hda_verb alc268_volume_init_verbs[] = { | |
11011 | /* set output DAC */ | |
11012 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11013 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11014 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11015 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11016 | ||
11017 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
11018 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
11019 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
11020 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
11021 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
11022 | ||
11023 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
11024 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11025 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11026 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11027 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11028 | ||
11029 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11030 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11031 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11032 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11033 | ||
aef9d318 TI |
11034 | /* set PCBEEP vol = 0, mute connections */ |
11035 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11036 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
11037 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
a361d84b KY |
11038 | |
11039 | { } | |
11040 | }; | |
11041 | ||
11042 | #define alc268_mux_enum_info alc_mux_enum_info | |
11043 | #define alc268_mux_enum_get alc_mux_enum_get | |
e1406348 | 11044 | #define alc268_mux_enum_put alc_mux_enum_put |
a361d84b KY |
11045 | |
11046 | static struct snd_kcontrol_new alc268_capture_alt_mixer[] = { | |
11047 | HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), | |
11048 | HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), | |
11049 | { | |
11050 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11051 | /* The multiple "Capture Source" controls confuse alsamixer | |
11052 | * So call somewhat different.. | |
a361d84b KY |
11053 | */ |
11054 | /* .name = "Capture Source", */ | |
11055 | .name = "Input Source", | |
11056 | .count = 1, | |
11057 | .info = alc268_mux_enum_info, | |
11058 | .get = alc268_mux_enum_get, | |
11059 | .put = alc268_mux_enum_put, | |
11060 | }, | |
11061 | { } /* end */ | |
11062 | }; | |
11063 | ||
11064 | static struct snd_kcontrol_new alc268_capture_mixer[] = { | |
11065 | HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), | |
11066 | HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), | |
11067 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT), | |
11068 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT), | |
11069 | { | |
11070 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11071 | /* The multiple "Capture Source" controls confuse alsamixer | |
11072 | * So call somewhat different.. | |
a361d84b KY |
11073 | */ |
11074 | /* .name = "Capture Source", */ | |
11075 | .name = "Input Source", | |
11076 | .count = 2, | |
11077 | .info = alc268_mux_enum_info, | |
11078 | .get = alc268_mux_enum_get, | |
11079 | .put = alc268_mux_enum_put, | |
11080 | }, | |
11081 | { } /* end */ | |
11082 | }; | |
11083 | ||
11084 | static struct hda_input_mux alc268_capture_source = { | |
11085 | .num_items = 4, | |
11086 | .items = { | |
11087 | { "Mic", 0x0 }, | |
11088 | { "Front Mic", 0x1 }, | |
11089 | { "Line", 0x2 }, | |
11090 | { "CD", 0x3 }, | |
11091 | }, | |
11092 | }; | |
11093 | ||
0ccb541c TI |
11094 | static struct hda_input_mux alc268_acer_capture_source = { |
11095 | .num_items = 3, | |
11096 | .items = { | |
11097 | { "Mic", 0x0 }, | |
11098 | { "Internal Mic", 0x6 }, | |
11099 | { "Line", 0x2 }, | |
11100 | }, | |
11101 | }; | |
11102 | ||
86c53bd2 JW |
11103 | #ifdef CONFIG_SND_DEBUG |
11104 | static struct snd_kcontrol_new alc268_test_mixer[] = { | |
86c53bd2 JW |
11105 | /* Volume widgets */ |
11106 | HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
11107 | HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
11108 | HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
11109 | HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT), | |
11110 | HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT), | |
11111 | HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT), | |
11112 | HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT), | |
11113 | HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT), | |
11114 | HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT), | |
11115 | HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT), | |
11116 | HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT), | |
11117 | HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT), | |
11118 | HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT), | |
f0747ee6 TI |
11119 | /* The below appears problematic on some hardwares */ |
11120 | /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/ | |
86c53bd2 JW |
11121 | HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT), |
11122 | HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT), | |
11123 | HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT), | |
11124 | HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT), | |
11125 | ||
11126 | /* Modes for retasking pin widgets */ | |
11127 | ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT), | |
11128 | ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT), | |
11129 | ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT), | |
11130 | ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT), | |
11131 | ||
11132 | /* Controls for GPIO pins, assuming they are configured as outputs */ | |
11133 | ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01), | |
11134 | ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02), | |
11135 | ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04), | |
11136 | ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08), | |
11137 | ||
11138 | /* Switches to allow the digital SPDIF output pin to be enabled. | |
11139 | * The ALC268 does not have an SPDIF input. | |
11140 | */ | |
11141 | ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01), | |
11142 | ||
11143 | /* A switch allowing EAPD to be enabled. Some laptops seem to use | |
11144 | * this output to turn on an external amplifier. | |
11145 | */ | |
11146 | ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02), | |
11147 | ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02), | |
11148 | ||
11149 | { } /* end */ | |
11150 | }; | |
11151 | #endif | |
11152 | ||
a361d84b KY |
11153 | /* create input playback/capture controls for the given pin */ |
11154 | static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid, | |
11155 | const char *ctlname, int idx) | |
11156 | { | |
11157 | char name[32]; | |
11158 | int err; | |
11159 | ||
11160 | sprintf(name, "%s Playback Volume", ctlname); | |
11161 | if (nid == 0x14) { | |
11162 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
11163 | HDA_COMPOSE_AMP_VAL(0x02, 3, idx, | |
11164 | HDA_OUTPUT)); | |
11165 | if (err < 0) | |
11166 | return err; | |
11167 | } else if (nid == 0x15) { | |
11168 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
11169 | HDA_COMPOSE_AMP_VAL(0x03, 3, idx, | |
11170 | HDA_OUTPUT)); | |
11171 | if (err < 0) | |
11172 | return err; | |
11173 | } else | |
11174 | return -1; | |
11175 | sprintf(name, "%s Playback Switch", ctlname); | |
11176 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | |
11177 | HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT)); | |
11178 | if (err < 0) | |
11179 | return err; | |
11180 | return 0; | |
11181 | } | |
11182 | ||
11183 | /* add playback controls from the parsed DAC table */ | |
11184 | static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec, | |
11185 | const struct auto_pin_cfg *cfg) | |
11186 | { | |
11187 | hda_nid_t nid; | |
11188 | int err; | |
11189 | ||
11190 | spec->multiout.num_dacs = 2; /* only use one dac */ | |
11191 | spec->multiout.dac_nids = spec->private_dac_nids; | |
11192 | spec->multiout.dac_nids[0] = 2; | |
11193 | spec->multiout.dac_nids[1] = 3; | |
11194 | ||
11195 | nid = cfg->line_out_pins[0]; | |
11196 | if (nid) | |
ea1fb29a | 11197 | alc268_new_analog_output(spec, nid, "Front", 0); |
a361d84b KY |
11198 | |
11199 | nid = cfg->speaker_pins[0]; | |
11200 | if (nid == 0x1d) { | |
11201 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
11202 | "Speaker Playback Volume", | |
11203 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | |
11204 | if (err < 0) | |
11205 | return err; | |
11206 | } | |
11207 | nid = cfg->hp_pins[0]; | |
11208 | if (nid) | |
11209 | alc268_new_analog_output(spec, nid, "Headphone", 0); | |
11210 | ||
11211 | nid = cfg->line_out_pins[1] | cfg->line_out_pins[2]; | |
11212 | if (nid == 0x16) { | |
11213 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
11214 | "Mono Playback Switch", | |
11215 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT)); | |
11216 | if (err < 0) | |
11217 | return err; | |
11218 | } | |
ea1fb29a | 11219 | return 0; |
a361d84b KY |
11220 | } |
11221 | ||
11222 | /* create playback/capture controls for input pins */ | |
11223 | static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec, | |
11224 | const struct auto_pin_cfg *cfg) | |
11225 | { | |
11226 | struct hda_input_mux *imux = &spec->private_imux; | |
11227 | int i, idx1; | |
11228 | ||
11229 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
11230 | switch(cfg->input_pins[i]) { | |
11231 | case 0x18: | |
11232 | idx1 = 0; /* Mic 1 */ | |
11233 | break; | |
11234 | case 0x19: | |
11235 | idx1 = 1; /* Mic 2 */ | |
11236 | break; | |
11237 | case 0x1a: | |
11238 | idx1 = 2; /* Line In */ | |
11239 | break; | |
ea1fb29a | 11240 | case 0x1c: |
a361d84b KY |
11241 | idx1 = 3; /* CD */ |
11242 | break; | |
7194cae6 TI |
11243 | case 0x12: |
11244 | case 0x13: | |
11245 | idx1 = 6; /* digital mics */ | |
11246 | break; | |
a361d84b KY |
11247 | default: |
11248 | continue; | |
11249 | } | |
11250 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; | |
11251 | imux->items[imux->num_items].index = idx1; | |
ea1fb29a | 11252 | imux->num_items++; |
a361d84b KY |
11253 | } |
11254 | return 0; | |
11255 | } | |
11256 | ||
11257 | static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec) | |
11258 | { | |
11259 | struct alc_spec *spec = codec->spec; | |
11260 | hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0]; | |
11261 | hda_nid_t hp_nid = spec->autocfg.hp_pins[0]; | |
11262 | hda_nid_t line_nid = spec->autocfg.line_out_pins[0]; | |
11263 | unsigned int dac_vol1, dac_vol2; | |
11264 | ||
11265 | if (speaker_nid) { | |
11266 | snd_hda_codec_write(codec, speaker_nid, 0, | |
11267 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | |
11268 | snd_hda_codec_write(codec, 0x0f, 0, | |
11269 | AC_VERB_SET_AMP_GAIN_MUTE, | |
11270 | AMP_IN_UNMUTE(1)); | |
11271 | snd_hda_codec_write(codec, 0x10, 0, | |
11272 | AC_VERB_SET_AMP_GAIN_MUTE, | |
11273 | AMP_IN_UNMUTE(1)); | |
11274 | } else { | |
11275 | snd_hda_codec_write(codec, 0x0f, 0, | |
11276 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)); | |
11277 | snd_hda_codec_write(codec, 0x10, 0, | |
11278 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)); | |
11279 | } | |
11280 | ||
11281 | dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */ | |
ea1fb29a | 11282 | if (line_nid == 0x14) |
a361d84b KY |
11283 | dac_vol2 = AMP_OUT_ZERO; |
11284 | else if (line_nid == 0x15) | |
11285 | dac_vol1 = AMP_OUT_ZERO; | |
ea1fb29a | 11286 | if (hp_nid == 0x14) |
a361d84b KY |
11287 | dac_vol2 = AMP_OUT_ZERO; |
11288 | else if (hp_nid == 0x15) | |
11289 | dac_vol1 = AMP_OUT_ZERO; | |
11290 | if (line_nid != 0x16 || hp_nid != 0x16 || | |
11291 | spec->autocfg.line_out_pins[1] != 0x16 || | |
11292 | spec->autocfg.line_out_pins[2] != 0x16) | |
11293 | dac_vol1 = dac_vol2 = AMP_OUT_ZERO; | |
11294 | ||
11295 | snd_hda_codec_write(codec, 0x02, 0, | |
11296 | AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1); | |
11297 | snd_hda_codec_write(codec, 0x03, 0, | |
11298 | AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2); | |
11299 | } | |
11300 | ||
11301 | /* pcm configuration: identiacal with ALC880 */ | |
11302 | #define alc268_pcm_analog_playback alc880_pcm_analog_playback | |
11303 | #define alc268_pcm_analog_capture alc880_pcm_analog_capture | |
6330079f | 11304 | #define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture |
a361d84b KY |
11305 | #define alc268_pcm_digital_playback alc880_pcm_digital_playback |
11306 | ||
11307 | /* | |
11308 | * BIOS auto configuration | |
11309 | */ | |
11310 | static int alc268_parse_auto_config(struct hda_codec *codec) | |
11311 | { | |
11312 | struct alc_spec *spec = codec->spec; | |
11313 | int err; | |
11314 | static hda_nid_t alc268_ignore[] = { 0 }; | |
11315 | ||
11316 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | |
11317 | alc268_ignore); | |
11318 | if (err < 0) | |
11319 | return err; | |
11320 | if (!spec->autocfg.line_outs) | |
11321 | return 0; /* can't find valid BIOS pin config */ | |
11322 | ||
11323 | err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
11324 | if (err < 0) | |
11325 | return err; | |
11326 | err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
11327 | if (err < 0) | |
11328 | return err; | |
11329 | ||
11330 | spec->multiout.max_channels = 2; | |
11331 | ||
11332 | /* digital only support output */ | |
11333 | if (spec->autocfg.dig_out_pin) | |
11334 | spec->multiout.dig_out_nid = ALC268_DIGOUT_NID; | |
11335 | ||
11336 | if (spec->kctl_alloc) | |
11337 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
11338 | ||
aef9d318 TI |
11339 | if (spec->autocfg.speaker_pins[0] != 0x1d) |
11340 | spec->mixers[spec->num_mixers++] = alc268_beep_mixer; | |
11341 | ||
a361d84b KY |
11342 | spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs; |
11343 | spec->num_mux_defs = 1; | |
11344 | spec->input_mux = &spec->private_imux; | |
11345 | ||
776e184e TI |
11346 | err = alc_auto_add_mic_boost(codec); |
11347 | if (err < 0) | |
11348 | return err; | |
11349 | ||
a361d84b KY |
11350 | return 1; |
11351 | } | |
11352 | ||
11353 | #define alc268_auto_init_multi_out alc882_auto_init_multi_out | |
11354 | #define alc268_auto_init_hp_out alc882_auto_init_hp_out | |
11355 | #define alc268_auto_init_analog_input alc882_auto_init_analog_input | |
11356 | ||
11357 | /* init callback for auto-configuration model -- overriding the default init */ | |
11358 | static void alc268_auto_init(struct hda_codec *codec) | |
11359 | { | |
f6c7e546 | 11360 | struct alc_spec *spec = codec->spec; |
a361d84b KY |
11361 | alc268_auto_init_multi_out(codec); |
11362 | alc268_auto_init_hp_out(codec); | |
11363 | alc268_auto_init_mono_speaker_out(codec); | |
11364 | alc268_auto_init_analog_input(codec); | |
f6c7e546 TI |
11365 | if (spec->unsol_event) |
11366 | alc_sku_automute(codec); | |
a361d84b KY |
11367 | } |
11368 | ||
11369 | /* | |
11370 | * configuration and preset | |
11371 | */ | |
11372 | static const char *alc268_models[ALC268_MODEL_LAST] = { | |
eb5a6621 | 11373 | [ALC267_QUANTA_IL1] = "quanta-il1", |
a361d84b | 11374 | [ALC268_3ST] = "3stack", |
983f8ae4 | 11375 | [ALC268_TOSHIBA] = "toshiba", |
d273809e | 11376 | [ALC268_ACER] = "acer", |
8ef355da | 11377 | [ALC268_ACER_ASPIRE_ONE] = "acer-aspire", |
3866f0b0 | 11378 | [ALC268_DELL] = "dell", |
f12462c5 | 11379 | [ALC268_ZEPTO] = "zepto", |
86c53bd2 JW |
11380 | #ifdef CONFIG_SND_DEBUG |
11381 | [ALC268_TEST] = "test", | |
11382 | #endif | |
a361d84b KY |
11383 | [ALC268_AUTO] = "auto", |
11384 | }; | |
11385 | ||
11386 | static struct snd_pci_quirk alc268_cfg_tbl[] = { | |
a0b8f7d8 | 11387 | SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER), |
ac3e3741 | 11388 | SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER), |
dafc8357 | 11389 | SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER), |
ac3e3741 | 11390 | SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER), |
29a52c24 | 11391 | SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER), |
8ef355da KY |
11392 | SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One", |
11393 | ALC268_ACER_ASPIRE_ONE), | |
3866f0b0 | 11394 | SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL), |
ac3e3741 | 11395 | SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA), |
a361d84b | 11396 | SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST), |
d1a991a6 | 11397 | SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA), |
8e7f00f9 | 11398 | SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA), |
378bd6a5 | 11399 | SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA), |
b875bf3a | 11400 | SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER), |
eb5a6621 | 11401 | SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1), |
f12462c5 | 11402 | SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO), |
a361d84b KY |
11403 | {} |
11404 | }; | |
11405 | ||
11406 | static struct alc_config_preset alc268_presets[] = { | |
eb5a6621 HRK |
11407 | [ALC267_QUANTA_IL1] = { |
11408 | .mixers = { alc267_quanta_il1_mixer }, | |
11409 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, | |
11410 | alc267_quanta_il1_verbs }, | |
11411 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11412 | .dac_nids = alc268_dac_nids, | |
11413 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11414 | .adc_nids = alc268_adc_nids_alt, | |
11415 | .hp_nid = 0x03, | |
11416 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11417 | .channel_mode = alc268_modes, | |
11418 | .input_mux = &alc268_capture_source, | |
11419 | .unsol_event = alc267_quanta_il1_unsol_event, | |
11420 | .init_hook = alc267_quanta_il1_automute, | |
11421 | }, | |
a361d84b | 11422 | [ALC268_3ST] = { |
aef9d318 TI |
11423 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, |
11424 | alc268_beep_mixer }, | |
a361d84b KY |
11425 | .init_verbs = { alc268_base_init_verbs }, |
11426 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11427 | .dac_nids = alc268_dac_nids, | |
11428 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11429 | .adc_nids = alc268_adc_nids_alt, | |
e1406348 | 11430 | .capsrc_nids = alc268_capsrc_nids, |
a361d84b KY |
11431 | .hp_nid = 0x03, |
11432 | .dig_out_nid = ALC268_DIGOUT_NID, | |
11433 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11434 | .channel_mode = alc268_modes, | |
11435 | .input_mux = &alc268_capture_source, | |
11436 | }, | |
d1a991a6 | 11437 | [ALC268_TOSHIBA] = { |
aef9d318 TI |
11438 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, |
11439 | alc268_beep_mixer }, | |
d273809e TI |
11440 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
11441 | alc268_toshiba_verbs }, | |
d1a991a6 KY |
11442 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), |
11443 | .dac_nids = alc268_dac_nids, | |
11444 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11445 | .adc_nids = alc268_adc_nids_alt, | |
e1406348 | 11446 | .capsrc_nids = alc268_capsrc_nids, |
d1a991a6 KY |
11447 | .hp_nid = 0x03, |
11448 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11449 | .channel_mode = alc268_modes, | |
11450 | .input_mux = &alc268_capture_source, | |
d273809e TI |
11451 | .unsol_event = alc268_toshiba_unsol_event, |
11452 | .init_hook = alc268_toshiba_automute, | |
11453 | }, | |
11454 | [ALC268_ACER] = { | |
aef9d318 TI |
11455 | .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer, |
11456 | alc268_beep_mixer }, | |
d273809e TI |
11457 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
11458 | alc268_acer_verbs }, | |
11459 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11460 | .dac_nids = alc268_dac_nids, | |
11461 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11462 | .adc_nids = alc268_adc_nids_alt, | |
e1406348 | 11463 | .capsrc_nids = alc268_capsrc_nids, |
d273809e TI |
11464 | .hp_nid = 0x02, |
11465 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11466 | .channel_mode = alc268_modes, | |
0ccb541c | 11467 | .input_mux = &alc268_acer_capture_source, |
d273809e | 11468 | .unsol_event = alc268_acer_unsol_event, |
889c4395 | 11469 | .init_hook = alc268_acer_init_hook, |
d1a991a6 | 11470 | }, |
8ef355da KY |
11471 | [ALC268_ACER_ASPIRE_ONE] = { |
11472 | .mixers = { alc268_acer_aspire_one_mixer, | |
11473 | alc268_capture_alt_mixer }, | |
11474 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, | |
11475 | alc268_acer_aspire_one_verbs }, | |
11476 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11477 | .dac_nids = alc268_dac_nids, | |
11478 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11479 | .adc_nids = alc268_adc_nids_alt, | |
11480 | .capsrc_nids = alc268_capsrc_nids, | |
11481 | .hp_nid = 0x03, | |
11482 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11483 | .channel_mode = alc268_modes, | |
11484 | .input_mux = &alc268_acer_lc_capture_source, | |
11485 | .unsol_event = alc268_acer_lc_unsol_event, | |
11486 | .init_hook = alc268_acer_lc_init_hook, | |
11487 | }, | |
3866f0b0 | 11488 | [ALC268_DELL] = { |
aef9d318 | 11489 | .mixers = { alc268_dell_mixer, alc268_beep_mixer }, |
3866f0b0 TI |
11490 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
11491 | alc268_dell_verbs }, | |
11492 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11493 | .dac_nids = alc268_dac_nids, | |
11494 | .hp_nid = 0x02, | |
11495 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11496 | .channel_mode = alc268_modes, | |
11497 | .unsol_event = alc268_dell_unsol_event, | |
11498 | .init_hook = alc268_dell_init_hook, | |
11499 | .input_mux = &alc268_capture_source, | |
11500 | }, | |
f12462c5 | 11501 | [ALC268_ZEPTO] = { |
aef9d318 TI |
11502 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, |
11503 | alc268_beep_mixer }, | |
f12462c5 MT |
11504 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
11505 | alc268_toshiba_verbs }, | |
11506 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11507 | .dac_nids = alc268_dac_nids, | |
11508 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11509 | .adc_nids = alc268_adc_nids_alt, | |
e1406348 | 11510 | .capsrc_nids = alc268_capsrc_nids, |
f12462c5 MT |
11511 | .hp_nid = 0x03, |
11512 | .dig_out_nid = ALC268_DIGOUT_NID, | |
11513 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11514 | .channel_mode = alc268_modes, | |
11515 | .input_mux = &alc268_capture_source, | |
11516 | .unsol_event = alc268_toshiba_unsol_event, | |
11517 | .init_hook = alc268_toshiba_automute | |
11518 | }, | |
86c53bd2 JW |
11519 | #ifdef CONFIG_SND_DEBUG |
11520 | [ALC268_TEST] = { | |
11521 | .mixers = { alc268_test_mixer, alc268_capture_mixer }, | |
11522 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, | |
11523 | alc268_volume_init_verbs }, | |
11524 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11525 | .dac_nids = alc268_dac_nids, | |
11526 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11527 | .adc_nids = alc268_adc_nids_alt, | |
e1406348 | 11528 | .capsrc_nids = alc268_capsrc_nids, |
86c53bd2 JW |
11529 | .hp_nid = 0x03, |
11530 | .dig_out_nid = ALC268_DIGOUT_NID, | |
11531 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11532 | .channel_mode = alc268_modes, | |
11533 | .input_mux = &alc268_capture_source, | |
11534 | }, | |
11535 | #endif | |
a361d84b KY |
11536 | }; |
11537 | ||
11538 | static int patch_alc268(struct hda_codec *codec) | |
11539 | { | |
11540 | struct alc_spec *spec; | |
11541 | int board_config; | |
11542 | int err; | |
11543 | ||
11544 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); | |
11545 | if (spec == NULL) | |
11546 | return -ENOMEM; | |
11547 | ||
11548 | codec->spec = spec; | |
11549 | ||
11550 | board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST, | |
11551 | alc268_models, | |
11552 | alc268_cfg_tbl); | |
11553 | ||
11554 | if (board_config < 0 || board_config >= ALC268_MODEL_LAST) { | |
11555 | printk(KERN_INFO "hda_codec: Unknown model for ALC268, " | |
11556 | "trying auto-probe from BIOS...\n"); | |
11557 | board_config = ALC268_AUTO; | |
11558 | } | |
11559 | ||
11560 | if (board_config == ALC268_AUTO) { | |
11561 | /* automatic parse from the BIOS config */ | |
11562 | err = alc268_parse_auto_config(codec); | |
11563 | if (err < 0) { | |
11564 | alc_free(codec); | |
11565 | return err; | |
11566 | } else if (!err) { | |
11567 | printk(KERN_INFO | |
11568 | "hda_codec: Cannot set up configuration " | |
11569 | "from BIOS. Using base mode...\n"); | |
11570 | board_config = ALC268_3ST; | |
11571 | } | |
11572 | } | |
11573 | ||
11574 | if (board_config != ALC268_AUTO) | |
11575 | setup_preset(spec, &alc268_presets[board_config]); | |
11576 | ||
2f893286 KY |
11577 | if (codec->vendor_id == 0x10ec0267) { |
11578 | spec->stream_name_analog = "ALC267 Analog"; | |
11579 | spec->stream_name_digital = "ALC267 Digital"; | |
11580 | } else { | |
11581 | spec->stream_name_analog = "ALC268 Analog"; | |
11582 | spec->stream_name_digital = "ALC268 Digital"; | |
11583 | } | |
11584 | ||
a361d84b KY |
11585 | spec->stream_analog_playback = &alc268_pcm_analog_playback; |
11586 | spec->stream_analog_capture = &alc268_pcm_analog_capture; | |
6330079f | 11587 | spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture; |
a361d84b | 11588 | |
a361d84b KY |
11589 | spec->stream_digital_playback = &alc268_pcm_digital_playback; |
11590 | ||
aef9d318 TI |
11591 | if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) |
11592 | /* override the amp caps for beep generator */ | |
11593 | snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, | |
11594 | (0x0c << AC_AMPCAP_OFFSET_SHIFT) | | |
11595 | (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) | | |
11596 | (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) | | |
11597 | (0 << AC_AMPCAP_MUTE_SHIFT)); | |
11598 | ||
3866f0b0 TI |
11599 | if (!spec->adc_nids && spec->input_mux) { |
11600 | /* check whether NID 0x07 is valid */ | |
11601 | unsigned int wcap = get_wcaps(codec, 0x07); | |
85860c06 | 11602 | int i; |
3866f0b0 TI |
11603 | |
11604 | /* get type */ | |
11605 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
67ebcb03 | 11606 | if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) { |
3866f0b0 TI |
11607 | spec->adc_nids = alc268_adc_nids_alt; |
11608 | spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt); | |
11609 | spec->mixers[spec->num_mixers] = | |
a361d84b | 11610 | alc268_capture_alt_mixer; |
3866f0b0 TI |
11611 | spec->num_mixers++; |
11612 | } else { | |
11613 | spec->adc_nids = alc268_adc_nids; | |
11614 | spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids); | |
11615 | spec->mixers[spec->num_mixers] = | |
11616 | alc268_capture_mixer; | |
11617 | spec->num_mixers++; | |
a361d84b | 11618 | } |
e1406348 | 11619 | spec->capsrc_nids = alc268_capsrc_nids; |
85860c06 TI |
11620 | /* set default input source */ |
11621 | for (i = 0; i < spec->num_adc_nids; i++) | |
11622 | snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i], | |
11623 | 0, AC_VERB_SET_CONNECT_SEL, | |
11624 | spec->input_mux->items[0].index); | |
a361d84b | 11625 | } |
2134ea4f TI |
11626 | |
11627 | spec->vmaster_nid = 0x02; | |
11628 | ||
a361d84b KY |
11629 | codec->patch_ops = alc_patch_ops; |
11630 | if (board_config == ALC268_AUTO) | |
11631 | spec->init_hook = alc268_auto_init; | |
ea1fb29a | 11632 | |
a361d84b KY |
11633 | return 0; |
11634 | } | |
11635 | ||
f6a92248 KY |
11636 | /* |
11637 | * ALC269 channel source setting (2 channel) | |
11638 | */ | |
11639 | #define ALC269_DIGOUT_NID ALC880_DIGOUT_NID | |
11640 | ||
11641 | #define alc269_dac_nids alc260_dac_nids | |
11642 | ||
11643 | static hda_nid_t alc269_adc_nids[1] = { | |
11644 | /* ADC1 */ | |
f53281e6 KY |
11645 | 0x08, |
11646 | }; | |
11647 | ||
e01bf509 TI |
11648 | static hda_nid_t alc269_capsrc_nids[1] = { |
11649 | 0x23, | |
11650 | }; | |
11651 | ||
11652 | /* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24), | |
11653 | * not a mux! | |
11654 | */ | |
11655 | ||
f53281e6 KY |
11656 | static struct hda_input_mux alc269_eeepc_dmic_capture_source = { |
11657 | .num_items = 2, | |
11658 | .items = { | |
11659 | { "i-Mic", 0x5 }, | |
11660 | { "e-Mic", 0x0 }, | |
11661 | }, | |
11662 | }; | |
11663 | ||
11664 | static struct hda_input_mux alc269_eeepc_amic_capture_source = { | |
11665 | .num_items = 2, | |
11666 | .items = { | |
11667 | { "i-Mic", 0x1 }, | |
11668 | { "e-Mic", 0x0 }, | |
11669 | }, | |
f6a92248 KY |
11670 | }; |
11671 | ||
11672 | #define alc269_modes alc260_modes | |
11673 | #define alc269_capture_source alc880_lg_lw_capture_source | |
11674 | ||
11675 | static struct snd_kcontrol_new alc269_base_mixer[] = { | |
11676 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
11677 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
11678 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
11679 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
11680 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
11681 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2005af24 TI |
11682 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT), |
11683 | HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT), | |
f6a92248 KY |
11684 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
11685 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
11686 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
11687 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
11688 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
11689 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | |
11690 | { } /* end */ | |
11691 | }; | |
11692 | ||
60db6b53 KY |
11693 | static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = { |
11694 | /* output mixer control */ | |
11695 | HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol), | |
11696 | { | |
11697 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11698 | .name = "Master Playback Switch", | |
11699 | .info = snd_hda_mixer_amp_switch_info, | |
11700 | .get = snd_hda_mixer_amp_switch_get, | |
11701 | .put = alc268_acer_master_sw_put, | |
11702 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
11703 | }, | |
11704 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
11705 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
11706 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
11707 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
11708 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
11709 | HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT), | |
11710 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
11711 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
11712 | { } | |
11713 | }; | |
11714 | ||
f53281e6 KY |
11715 | /* bind volumes of both NID 0x0c and 0x0d */ |
11716 | static struct hda_bind_ctls alc269_epc_bind_vol = { | |
11717 | .ops = &snd_hda_bind_vol, | |
11718 | .values = { | |
11719 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), | |
11720 | HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT), | |
11721 | 0 | |
11722 | }, | |
11723 | }; | |
11724 | ||
11725 | static struct snd_kcontrol_new alc269_eeepc_mixer[] = { | |
11726 | HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
11727 | HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol), | |
11728 | HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
11729 | { } /* end */ | |
11730 | }; | |
11731 | ||
f6a92248 KY |
11732 | /* capture mixer elements */ |
11733 | static struct snd_kcontrol_new alc269_capture_mixer[] = { | |
f53281e6 KY |
11734 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
11735 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
f6a92248 KY |
11736 | { |
11737 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11738 | /* The multiple "Capture Source" controls confuse alsamixer | |
11739 | * So call somewhat different.. | |
f6a92248 KY |
11740 | */ |
11741 | /* .name = "Capture Source", */ | |
11742 | .name = "Input Source", | |
11743 | .count = 1, | |
11744 | .info = alc_mux_enum_info, | |
11745 | .get = alc_mux_enum_get, | |
11746 | .put = alc_mux_enum_put, | |
11747 | }, | |
11748 | { } /* end */ | |
11749 | }; | |
11750 | ||
f53281e6 KY |
11751 | /* capture mixer elements */ |
11752 | static struct snd_kcontrol_new alc269_epc_capture_mixer[] = { | |
11753 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
11754 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
11755 | { } /* end */ | |
11756 | }; | |
11757 | ||
2005af24 TI |
11758 | /* beep control */ |
11759 | static struct snd_kcontrol_new alc269_beep_mixer[] = { | |
11760 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT), | |
11761 | HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT), | |
11762 | { } /* end */ | |
11763 | }; | |
11764 | ||
60db6b53 KY |
11765 | static struct hda_verb alc269_quanta_fl1_verbs[] = { |
11766 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
11767 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
11768 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
11769 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
11770 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
11771 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
11772 | { } | |
11773 | }; | |
f6a92248 | 11774 | |
60db6b53 KY |
11775 | /* toggle speaker-output according to the hp-jack state */ |
11776 | static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec) | |
11777 | { | |
11778 | unsigned int present; | |
11779 | unsigned char bits; | |
f6a92248 | 11780 | |
60db6b53 KY |
11781 | present = snd_hda_codec_read(codec, 0x15, 0, |
11782 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
11783 | bits = present ? AMP_IN_MUTE(0) : 0; | |
11784 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
11785 | AMP_IN_MUTE(0), bits); | |
11786 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
11787 | AMP_IN_MUTE(0), bits); | |
f6a92248 | 11788 | |
60db6b53 KY |
11789 | snd_hda_codec_write(codec, 0x20, 0, |
11790 | AC_VERB_SET_COEF_INDEX, 0x0c); | |
11791 | snd_hda_codec_write(codec, 0x20, 0, | |
11792 | AC_VERB_SET_PROC_COEF, 0x680); | |
f6a92248 | 11793 | |
60db6b53 KY |
11794 | snd_hda_codec_write(codec, 0x20, 0, |
11795 | AC_VERB_SET_COEF_INDEX, 0x0c); | |
11796 | snd_hda_codec_write(codec, 0x20, 0, | |
11797 | AC_VERB_SET_PROC_COEF, 0x480); | |
11798 | } | |
f6a92248 | 11799 | |
60db6b53 KY |
11800 | static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec) |
11801 | { | |
11802 | unsigned int present; | |
f6a92248 | 11803 | |
60db6b53 KY |
11804 | present = snd_hda_codec_read(codec, 0x18, 0, |
11805 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
11806 | snd_hda_codec_write(codec, 0x23, 0, | |
11807 | AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1); | |
11808 | } | |
f6a92248 | 11809 | |
60db6b53 KY |
11810 | static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec, |
11811 | unsigned int res) | |
11812 | { | |
11813 | if ((res >> 26) == ALC880_HP_EVENT) | |
11814 | alc269_quanta_fl1_speaker_automute(codec); | |
11815 | if ((res >> 26) == ALC880_MIC_EVENT) | |
11816 | alc269_quanta_fl1_mic_automute(codec); | |
11817 | } | |
f6a92248 | 11818 | |
60db6b53 KY |
11819 | static void alc269_quanta_fl1_init_hook(struct hda_codec *codec) |
11820 | { | |
11821 | alc269_quanta_fl1_speaker_automute(codec); | |
11822 | alc269_quanta_fl1_mic_automute(codec); | |
11823 | } | |
f6a92248 | 11824 | |
f53281e6 KY |
11825 | static struct hda_verb alc269_eeepc_dmic_init_verbs[] = { |
11826 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
11827 | {0x23, AC_VERB_SET_CONNECT_SEL, 0x05}, | |
11828 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 }, | |
11829 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))}, | |
11830 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
11831 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
11832 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
11833 | {} | |
11834 | }; | |
11835 | ||
11836 | static struct hda_verb alc269_eeepc_amic_init_verbs[] = { | |
11837 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
11838 | {0x23, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
11839 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 }, | |
11840 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))}, | |
11841 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
11842 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
11843 | {} | |
11844 | }; | |
11845 | ||
11846 | /* toggle speaker-output according to the hp-jack state */ | |
11847 | static void alc269_speaker_automute(struct hda_codec *codec) | |
11848 | { | |
11849 | unsigned int present; | |
60db6b53 | 11850 | unsigned char bits; |
f53281e6 KY |
11851 | |
11852 | present = snd_hda_codec_read(codec, 0x15, 0, | |
60db6b53 | 11853 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; |
f53281e6 KY |
11854 | bits = present ? AMP_IN_MUTE(0) : 0; |
11855 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
60db6b53 | 11856 | AMP_IN_MUTE(0), bits); |
f53281e6 | 11857 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, |
60db6b53 | 11858 | AMP_IN_MUTE(0), bits); |
f53281e6 KY |
11859 | } |
11860 | ||
11861 | static void alc269_eeepc_dmic_automute(struct hda_codec *codec) | |
11862 | { | |
11863 | unsigned int present; | |
11864 | ||
60db6b53 KY |
11865 | present = snd_hda_codec_read(codec, 0x18, 0, |
11866 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
11867 | snd_hda_codec_write(codec, 0x23, 0, | |
11868 | AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5)); | |
f53281e6 KY |
11869 | } |
11870 | ||
11871 | static void alc269_eeepc_amic_automute(struct hda_codec *codec) | |
11872 | { | |
11873 | unsigned int present; | |
11874 | ||
60db6b53 KY |
11875 | present = snd_hda_codec_read(codec, 0x18, 0, |
11876 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
f53281e6 | 11877 | snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
60db6b53 | 11878 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); |
f53281e6 | 11879 | snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
60db6b53 | 11880 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); |
f53281e6 KY |
11881 | } |
11882 | ||
11883 | /* unsolicited event for HP jack sensing */ | |
11884 | static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec, | |
60db6b53 | 11885 | unsigned int res) |
f53281e6 KY |
11886 | { |
11887 | if ((res >> 26) == ALC880_HP_EVENT) | |
11888 | alc269_speaker_automute(codec); | |
11889 | ||
11890 | if ((res >> 26) == ALC880_MIC_EVENT) | |
11891 | alc269_eeepc_dmic_automute(codec); | |
11892 | } | |
11893 | ||
11894 | static void alc269_eeepc_dmic_inithook(struct hda_codec *codec) | |
11895 | { | |
11896 | alc269_speaker_automute(codec); | |
11897 | alc269_eeepc_dmic_automute(codec); | |
11898 | } | |
11899 | ||
11900 | /* unsolicited event for HP jack sensing */ | |
11901 | static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec, | |
ea1fb29a | 11902 | unsigned int res) |
f53281e6 KY |
11903 | { |
11904 | if ((res >> 26) == ALC880_HP_EVENT) | |
11905 | alc269_speaker_automute(codec); | |
11906 | ||
11907 | if ((res >> 26) == ALC880_MIC_EVENT) | |
11908 | alc269_eeepc_amic_automute(codec); | |
11909 | } | |
11910 | ||
11911 | static void alc269_eeepc_amic_inithook(struct hda_codec *codec) | |
11912 | { | |
11913 | alc269_speaker_automute(codec); | |
11914 | alc269_eeepc_amic_automute(codec); | |
11915 | } | |
11916 | ||
60db6b53 KY |
11917 | /* |
11918 | * generic initialization of ADC, input mixers and output mixers | |
11919 | */ | |
11920 | static struct hda_verb alc269_init_verbs[] = { | |
11921 | /* | |
11922 | * Unmute ADC0 and set the default input to mic-in | |
11923 | */ | |
11924 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11925 | ||
11926 | /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the | |
11927 | * analog-loopback mixer widget | |
11928 | * Note: PASD motherboards uses the Line In 2 as the input for | |
11929 | * front panel mic (mic 2) | |
11930 | */ | |
11931 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
11932 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
11933 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
11934 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
11935 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
11936 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
11937 | ||
11938 | /* | |
11939 | * Set up output mixers (0x0c - 0x0e) | |
11940 | */ | |
11941 | /* set vol=0 to output mixers */ | |
11942 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
11943 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
11944 | ||
11945 | /* set up input amps for analog loopback */ | |
11946 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
11947 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11948 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11949 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11950 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11951 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11952 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11953 | ||
11954 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
11955 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
11956 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
11957 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
11958 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
11959 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
11960 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
11961 | ||
11962 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11963 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11964 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11965 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11966 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11967 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11968 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11969 | ||
11970 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
11971 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
11972 | ||
11973 | /* FIXME: use matrix-type input source selection */ | |
11974 | /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */ | |
11975 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
11976 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
11977 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11978 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
11979 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
11980 | ||
11981 | /* set EAPD */ | |
11982 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
11983 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
11984 | { } | |
11985 | }; | |
11986 | ||
f6a92248 KY |
11987 | /* add playback controls from the parsed DAC table */ |
11988 | static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec, | |
11989 | const struct auto_pin_cfg *cfg) | |
11990 | { | |
11991 | hda_nid_t nid; | |
11992 | int err; | |
11993 | ||
11994 | spec->multiout.num_dacs = 1; /* only use one dac */ | |
11995 | spec->multiout.dac_nids = spec->private_dac_nids; | |
11996 | spec->multiout.dac_nids[0] = 2; | |
11997 | ||
11998 | nid = cfg->line_out_pins[0]; | |
11999 | if (nid) { | |
12000 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
12001 | "Front Playback Volume", | |
12002 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT)); | |
12003 | if (err < 0) | |
12004 | return err; | |
12005 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
12006 | "Front Playback Switch", | |
12007 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
12008 | if (err < 0) | |
12009 | return err; | |
12010 | } | |
12011 | ||
12012 | nid = cfg->speaker_pins[0]; | |
12013 | if (nid) { | |
12014 | if (!cfg->line_out_pins[0]) { | |
12015 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
12016 | "Speaker Playback Volume", | |
12017 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, | |
12018 | HDA_OUTPUT)); | |
12019 | if (err < 0) | |
12020 | return err; | |
12021 | } | |
12022 | if (nid == 0x16) { | |
12023 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
12024 | "Speaker Playback Switch", | |
12025 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
12026 | HDA_OUTPUT)); | |
12027 | if (err < 0) | |
12028 | return err; | |
12029 | } else { | |
12030 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
12031 | "Speaker Playback Switch", | |
12032 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
12033 | HDA_OUTPUT)); | |
12034 | if (err < 0) | |
12035 | return err; | |
12036 | } | |
12037 | } | |
12038 | nid = cfg->hp_pins[0]; | |
12039 | if (nid) { | |
12040 | /* spec->multiout.hp_nid = 2; */ | |
12041 | if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) { | |
12042 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
12043 | "Headphone Playback Volume", | |
12044 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, | |
12045 | HDA_OUTPUT)); | |
12046 | if (err < 0) | |
12047 | return err; | |
12048 | } | |
12049 | if (nid == 0x16) { | |
12050 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
12051 | "Headphone Playback Switch", | |
12052 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
12053 | HDA_OUTPUT)); | |
12054 | if (err < 0) | |
12055 | return err; | |
12056 | } else { | |
12057 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
12058 | "Headphone Playback Switch", | |
12059 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
12060 | HDA_OUTPUT)); | |
12061 | if (err < 0) | |
12062 | return err; | |
12063 | } | |
12064 | } | |
12065 | return 0; | |
12066 | } | |
12067 | ||
12068 | #define alc269_auto_create_analog_input_ctls \ | |
12069 | alc880_auto_create_analog_input_ctls | |
12070 | ||
12071 | #ifdef CONFIG_SND_HDA_POWER_SAVE | |
12072 | #define alc269_loopbacks alc880_loopbacks | |
12073 | #endif | |
12074 | ||
12075 | /* pcm configuration: identiacal with ALC880 */ | |
12076 | #define alc269_pcm_analog_playback alc880_pcm_analog_playback | |
12077 | #define alc269_pcm_analog_capture alc880_pcm_analog_capture | |
12078 | #define alc269_pcm_digital_playback alc880_pcm_digital_playback | |
12079 | #define alc269_pcm_digital_capture alc880_pcm_digital_capture | |
12080 | ||
12081 | /* | |
12082 | * BIOS auto configuration | |
12083 | */ | |
12084 | static int alc269_parse_auto_config(struct hda_codec *codec) | |
12085 | { | |
12086 | struct alc_spec *spec = codec->spec; | |
2005af24 | 12087 | int i, err; |
f6a92248 KY |
12088 | static hda_nid_t alc269_ignore[] = { 0x1d, 0 }; |
12089 | ||
12090 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | |
12091 | alc269_ignore); | |
12092 | if (err < 0) | |
12093 | return err; | |
12094 | ||
12095 | err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
12096 | if (err < 0) | |
12097 | return err; | |
12098 | err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
12099 | if (err < 0) | |
12100 | return err; | |
12101 | ||
12102 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
12103 | ||
12104 | if (spec->autocfg.dig_out_pin) | |
12105 | spec->multiout.dig_out_nid = ALC269_DIGOUT_NID; | |
12106 | ||
12107 | if (spec->kctl_alloc) | |
12108 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
12109 | ||
2005af24 TI |
12110 | /* create a beep mixer control if the pin 0x1d isn't assigned */ |
12111 | for (i = 0; i < ARRAY_SIZE(spec->autocfg.input_pins); i++) | |
12112 | if (spec->autocfg.input_pins[i] == 0x1d) | |
12113 | break; | |
12114 | if (i >= ARRAY_SIZE(spec->autocfg.input_pins)) | |
12115 | spec->mixers[spec->num_mixers++] = alc269_beep_mixer; | |
12116 | ||
f6a92248 KY |
12117 | spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs; |
12118 | spec->num_mux_defs = 1; | |
12119 | spec->input_mux = &spec->private_imux; | |
e01bf509 TI |
12120 | /* set default input source */ |
12121 | snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0], | |
12122 | 0, AC_VERB_SET_CONNECT_SEL, | |
12123 | spec->input_mux->items[0].index); | |
f6a92248 KY |
12124 | |
12125 | err = alc_auto_add_mic_boost(codec); | |
12126 | if (err < 0) | |
12127 | return err; | |
12128 | ||
f53281e6 KY |
12129 | spec->mixers[spec->num_mixers] = alc269_capture_mixer; |
12130 | spec->num_mixers++; | |
12131 | ||
f6a92248 KY |
12132 | return 1; |
12133 | } | |
12134 | ||
12135 | #define alc269_auto_init_multi_out alc882_auto_init_multi_out | |
12136 | #define alc269_auto_init_hp_out alc882_auto_init_hp_out | |
12137 | #define alc269_auto_init_analog_input alc882_auto_init_analog_input | |
12138 | ||
12139 | ||
12140 | /* init callback for auto-configuration model -- overriding the default init */ | |
12141 | static void alc269_auto_init(struct hda_codec *codec) | |
12142 | { | |
f6c7e546 | 12143 | struct alc_spec *spec = codec->spec; |
f6a92248 KY |
12144 | alc269_auto_init_multi_out(codec); |
12145 | alc269_auto_init_hp_out(codec); | |
12146 | alc269_auto_init_analog_input(codec); | |
f6c7e546 TI |
12147 | if (spec->unsol_event) |
12148 | alc_sku_automute(codec); | |
f6a92248 KY |
12149 | } |
12150 | ||
12151 | /* | |
12152 | * configuration and preset | |
12153 | */ | |
12154 | static const char *alc269_models[ALC269_MODEL_LAST] = { | |
60db6b53 | 12155 | [ALC269_BASIC] = "basic", |
2922c9af TI |
12156 | [ALC269_QUANTA_FL1] = "quanta", |
12157 | [ALC269_ASUS_EEEPC_P703] = "eeepc-p703", | |
12158 | [ALC269_ASUS_EEEPC_P901] = "eeepc-p901" | |
f6a92248 KY |
12159 | }; |
12160 | ||
12161 | static struct snd_pci_quirk alc269_cfg_tbl[] = { | |
60db6b53 | 12162 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1), |
f53281e6 KY |
12163 | SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", |
12164 | ALC269_ASUS_EEEPC_P703), | |
12165 | SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901", | |
12166 | ALC269_ASUS_EEEPC_P901), | |
60db6b53 KY |
12167 | SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101", |
12168 | ALC269_ASUS_EEEPC_P901), | |
f6a92248 KY |
12169 | {} |
12170 | }; | |
12171 | ||
12172 | static struct alc_config_preset alc269_presets[] = { | |
12173 | [ALC269_BASIC] = { | |
f53281e6 | 12174 | .mixers = { alc269_base_mixer, alc269_capture_mixer }, |
f6a92248 KY |
12175 | .init_verbs = { alc269_init_verbs }, |
12176 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | |
12177 | .dac_nids = alc269_dac_nids, | |
12178 | .hp_nid = 0x03, | |
12179 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | |
12180 | .channel_mode = alc269_modes, | |
12181 | .input_mux = &alc269_capture_source, | |
12182 | }, | |
60db6b53 KY |
12183 | [ALC269_QUANTA_FL1] = { |
12184 | .mixers = { alc269_quanta_fl1_mixer }, | |
12185 | .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs }, | |
12186 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | |
12187 | .dac_nids = alc269_dac_nids, | |
12188 | .hp_nid = 0x03, | |
12189 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | |
12190 | .channel_mode = alc269_modes, | |
12191 | .input_mux = &alc269_capture_source, | |
12192 | .unsol_event = alc269_quanta_fl1_unsol_event, | |
12193 | .init_hook = alc269_quanta_fl1_init_hook, | |
12194 | }, | |
f53281e6 KY |
12195 | [ALC269_ASUS_EEEPC_P703] = { |
12196 | .mixers = { alc269_eeepc_mixer, alc269_epc_capture_mixer }, | |
12197 | .init_verbs = { alc269_init_verbs, | |
12198 | alc269_eeepc_amic_init_verbs }, | |
12199 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | |
12200 | .dac_nids = alc269_dac_nids, | |
12201 | .hp_nid = 0x03, | |
12202 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | |
12203 | .channel_mode = alc269_modes, | |
12204 | .input_mux = &alc269_eeepc_amic_capture_source, | |
12205 | .unsol_event = alc269_eeepc_amic_unsol_event, | |
12206 | .init_hook = alc269_eeepc_amic_inithook, | |
12207 | }, | |
12208 | [ALC269_ASUS_EEEPC_P901] = { | |
12209 | .mixers = { alc269_eeepc_mixer, alc269_epc_capture_mixer}, | |
12210 | .init_verbs = { alc269_init_verbs, | |
12211 | alc269_eeepc_dmic_init_verbs }, | |
12212 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | |
12213 | .dac_nids = alc269_dac_nids, | |
12214 | .hp_nid = 0x03, | |
12215 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | |
12216 | .channel_mode = alc269_modes, | |
12217 | .input_mux = &alc269_eeepc_dmic_capture_source, | |
12218 | .unsol_event = alc269_eeepc_dmic_unsol_event, | |
12219 | .init_hook = alc269_eeepc_dmic_inithook, | |
12220 | }, | |
f6a92248 KY |
12221 | }; |
12222 | ||
12223 | static int patch_alc269(struct hda_codec *codec) | |
12224 | { | |
12225 | struct alc_spec *spec; | |
12226 | int board_config; | |
12227 | int err; | |
12228 | ||
12229 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
12230 | if (spec == NULL) | |
12231 | return -ENOMEM; | |
12232 | ||
12233 | codec->spec = spec; | |
12234 | ||
2c3bf9ab TI |
12235 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
12236 | ||
f6a92248 KY |
12237 | board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST, |
12238 | alc269_models, | |
12239 | alc269_cfg_tbl); | |
12240 | ||
12241 | if (board_config < 0) { | |
12242 | printk(KERN_INFO "hda_codec: Unknown model for ALC269, " | |
12243 | "trying auto-probe from BIOS...\n"); | |
12244 | board_config = ALC269_AUTO; | |
12245 | } | |
12246 | ||
12247 | if (board_config == ALC269_AUTO) { | |
12248 | /* automatic parse from the BIOS config */ | |
12249 | err = alc269_parse_auto_config(codec); | |
12250 | if (err < 0) { | |
12251 | alc_free(codec); | |
12252 | return err; | |
12253 | } else if (!err) { | |
12254 | printk(KERN_INFO | |
12255 | "hda_codec: Cannot set up configuration " | |
12256 | "from BIOS. Using base mode...\n"); | |
12257 | board_config = ALC269_BASIC; | |
12258 | } | |
12259 | } | |
12260 | ||
12261 | if (board_config != ALC269_AUTO) | |
12262 | setup_preset(spec, &alc269_presets[board_config]); | |
12263 | ||
12264 | spec->stream_name_analog = "ALC269 Analog"; | |
12265 | spec->stream_analog_playback = &alc269_pcm_analog_playback; | |
12266 | spec->stream_analog_capture = &alc269_pcm_analog_capture; | |
12267 | ||
12268 | spec->stream_name_digital = "ALC269 Digital"; | |
12269 | spec->stream_digital_playback = &alc269_pcm_digital_playback; | |
12270 | spec->stream_digital_capture = &alc269_pcm_digital_capture; | |
12271 | ||
12272 | spec->adc_nids = alc269_adc_nids; | |
12273 | spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids); | |
e01bf509 | 12274 | spec->capsrc_nids = alc269_capsrc_nids; |
f6a92248 KY |
12275 | |
12276 | codec->patch_ops = alc_patch_ops; | |
12277 | if (board_config == ALC269_AUTO) | |
12278 | spec->init_hook = alc269_auto_init; | |
12279 | #ifdef CONFIG_SND_HDA_POWER_SAVE | |
12280 | if (!spec->loopback.amplist) | |
12281 | spec->loopback.amplist = alc269_loopbacks; | |
12282 | #endif | |
12283 | ||
12284 | return 0; | |
12285 | } | |
12286 | ||
df694daa KY |
12287 | /* |
12288 | * ALC861 channel source setting (2/6 channel selection for 3-stack) | |
12289 | */ | |
12290 | ||
12291 | /* | |
12292 | * set the path ways for 2 channel output | |
12293 | * need to set the codec line out and mic 1 pin widgets to inputs | |
12294 | */ | |
12295 | static struct hda_verb alc861_threestack_ch2_init[] = { | |
12296 | /* set pin widget 1Ah (line in) for input */ | |
12297 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
f12ab1e0 TI |
12298 | /* set pin widget 18h (mic1/2) for input, for mic also enable |
12299 | * the vref | |
12300 | */ | |
df694daa KY |
12301 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
12302 | ||
9c7f852e TI |
12303 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, |
12304 | #if 0 | |
12305 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
12306 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/ | |
12307 | #endif | |
df694daa KY |
12308 | { } /* end */ |
12309 | }; | |
12310 | /* | |
12311 | * 6ch mode | |
12312 | * need to set the codec line out and mic 1 pin widgets to outputs | |
12313 | */ | |
12314 | static struct hda_verb alc861_threestack_ch6_init[] = { | |
12315 | /* set pin widget 1Ah (line in) for output (Back Surround)*/ | |
12316 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12317 | /* set pin widget 18h (mic1) for output (CLFE)*/ | |
12318 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12319 | ||
12320 | { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
9c7f852e | 12321 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa | 12322 | |
9c7f852e TI |
12323 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, |
12324 | #if 0 | |
12325 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
12326 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/ | |
12327 | #endif | |
df694daa KY |
12328 | { } /* end */ |
12329 | }; | |
12330 | ||
12331 | static struct hda_channel_mode alc861_threestack_modes[2] = { | |
12332 | { 2, alc861_threestack_ch2_init }, | |
12333 | { 6, alc861_threestack_ch6_init }, | |
12334 | }; | |
22309c3e TI |
12335 | /* Set mic1 as input and unmute the mixer */ |
12336 | static struct hda_verb alc861_uniwill_m31_ch2_init[] = { | |
12337 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
12338 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
12339 | { } /* end */ | |
12340 | }; | |
12341 | /* Set mic1 as output and mute mixer */ | |
12342 | static struct hda_verb alc861_uniwill_m31_ch4_init[] = { | |
12343 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12344 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
12345 | { } /* end */ | |
12346 | }; | |
12347 | ||
12348 | static struct hda_channel_mode alc861_uniwill_m31_modes[2] = { | |
12349 | { 2, alc861_uniwill_m31_ch2_init }, | |
12350 | { 4, alc861_uniwill_m31_ch4_init }, | |
12351 | }; | |
df694daa | 12352 | |
7cdbff94 MD |
12353 | /* Set mic1 and line-in as input and unmute the mixer */ |
12354 | static struct hda_verb alc861_asus_ch2_init[] = { | |
12355 | /* set pin widget 1Ah (line in) for input */ | |
12356 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
f12ab1e0 TI |
12357 | /* set pin widget 18h (mic1/2) for input, for mic also enable |
12358 | * the vref | |
12359 | */ | |
7cdbff94 MD |
12360 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
12361 | ||
12362 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, | |
12363 | #if 0 | |
12364 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
12365 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/ | |
12366 | #endif | |
12367 | { } /* end */ | |
12368 | }; | |
12369 | /* Set mic1 nad line-in as output and mute mixer */ | |
12370 | static struct hda_verb alc861_asus_ch6_init[] = { | |
12371 | /* set pin widget 1Ah (line in) for output (Back Surround)*/ | |
12372 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12373 | /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */ | |
12374 | /* set pin widget 18h (mic1) for output (CLFE)*/ | |
12375 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12376 | /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */ | |
12377 | { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
12378 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
12379 | ||
12380 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, | |
12381 | #if 0 | |
12382 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
12383 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/ | |
12384 | #endif | |
12385 | { } /* end */ | |
12386 | }; | |
12387 | ||
12388 | static struct hda_channel_mode alc861_asus_modes[2] = { | |
12389 | { 2, alc861_asus_ch2_init }, | |
12390 | { 6, alc861_asus_ch6_init }, | |
12391 | }; | |
12392 | ||
df694daa KY |
12393 | /* patch-ALC861 */ |
12394 | ||
12395 | static struct snd_kcontrol_new alc861_base_mixer[] = { | |
12396 | /* output mixer control */ | |
12397 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
12398 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
12399 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
12400 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
12401 | HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), | |
12402 | ||
12403 | /*Input mixer control */ | |
12404 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
12405 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
12406 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
12407 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
12408 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
12409 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
12410 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
12411 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
12412 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
12413 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 12414 | |
df694daa KY |
12415 | /* Capture mixer control */ |
12416 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
12417 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
12418 | { | |
12419 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
12420 | .name = "Capture Source", | |
12421 | .count = 1, | |
12422 | .info = alc_mux_enum_info, | |
12423 | .get = alc_mux_enum_get, | |
12424 | .put = alc_mux_enum_put, | |
12425 | }, | |
12426 | { } /* end */ | |
12427 | }; | |
12428 | ||
12429 | static struct snd_kcontrol_new alc861_3ST_mixer[] = { | |
12430 | /* output mixer control */ | |
12431 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
12432 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
12433 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
12434 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
12435 | /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ | |
12436 | ||
12437 | /* Input mixer control */ | |
12438 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
12439 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
12440 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
12441 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
12442 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
12443 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
12444 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
12445 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
12446 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
12447 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 12448 | |
df694daa KY |
12449 | /* Capture mixer control */ |
12450 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
12451 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
12452 | { | |
12453 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
12454 | .name = "Capture Source", | |
12455 | .count = 1, | |
12456 | .info = alc_mux_enum_info, | |
12457 | .get = alc_mux_enum_get, | |
12458 | .put = alc_mux_enum_put, | |
12459 | }, | |
12460 | { | |
12461 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
12462 | .name = "Channel Mode", | |
12463 | .info = alc_ch_mode_info, | |
12464 | .get = alc_ch_mode_get, | |
12465 | .put = alc_ch_mode_put, | |
12466 | .private_value = ARRAY_SIZE(alc861_threestack_modes), | |
12467 | }, | |
12468 | { } /* end */ | |
a53d1aec TD |
12469 | }; |
12470 | ||
d1d985f0 | 12471 | static struct snd_kcontrol_new alc861_toshiba_mixer[] = { |
a53d1aec TD |
12472 | /* output mixer control */ |
12473 | HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
12474 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
12475 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
ea1fb29a | 12476 | |
a53d1aec TD |
12477 | /*Capture mixer control */ |
12478 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
12479 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
12480 | { | |
12481 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
12482 | .name = "Capture Source", | |
12483 | .count = 1, | |
12484 | .info = alc_mux_enum_info, | |
12485 | .get = alc_mux_enum_get, | |
12486 | .put = alc_mux_enum_put, | |
12487 | }, | |
12488 | ||
12489 | { } /* end */ | |
f12ab1e0 | 12490 | }; |
a53d1aec | 12491 | |
22309c3e TI |
12492 | static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = { |
12493 | /* output mixer control */ | |
12494 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
12495 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
12496 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
12497 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
12498 | /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ | |
12499 | ||
12500 | /* Input mixer control */ | |
12501 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
12502 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
12503 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
12504 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
12505 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
12506 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
12507 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
12508 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
12509 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
12510 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 12511 | |
22309c3e TI |
12512 | /* Capture mixer control */ |
12513 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
12514 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
12515 | { | |
12516 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
12517 | .name = "Capture Source", | |
12518 | .count = 1, | |
12519 | .info = alc_mux_enum_info, | |
12520 | .get = alc_mux_enum_get, | |
12521 | .put = alc_mux_enum_put, | |
12522 | }, | |
12523 | { | |
12524 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
12525 | .name = "Channel Mode", | |
12526 | .info = alc_ch_mode_info, | |
12527 | .get = alc_ch_mode_get, | |
12528 | .put = alc_ch_mode_put, | |
12529 | .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes), | |
12530 | }, | |
12531 | { } /* end */ | |
f12ab1e0 | 12532 | }; |
7cdbff94 MD |
12533 | |
12534 | static struct snd_kcontrol_new alc861_asus_mixer[] = { | |
12535 | /* output mixer control */ | |
12536 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
12537 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
12538 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
12539 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
12540 | HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), | |
12541 | ||
12542 | /* Input mixer control */ | |
12543 | HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
12544 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
12545 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
12546 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
12547 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
12548 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
12549 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
12550 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
12551 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
f12ab1e0 TI |
12552 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), |
12553 | ||
7cdbff94 MD |
12554 | /* Capture mixer control */ |
12555 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
12556 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
12557 | { | |
12558 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
12559 | .name = "Capture Source", | |
12560 | .count = 1, | |
12561 | .info = alc_mux_enum_info, | |
12562 | .get = alc_mux_enum_get, | |
12563 | .put = alc_mux_enum_put, | |
12564 | }, | |
12565 | { | |
12566 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
12567 | .name = "Channel Mode", | |
12568 | .info = alc_ch_mode_info, | |
12569 | .get = alc_ch_mode_get, | |
12570 | .put = alc_ch_mode_put, | |
12571 | .private_value = ARRAY_SIZE(alc861_asus_modes), | |
12572 | }, | |
12573 | { } | |
56bb0cab TI |
12574 | }; |
12575 | ||
12576 | /* additional mixer */ | |
d1d985f0 | 12577 | static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = { |
56bb0cab TI |
12578 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), |
12579 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
12580 | HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT), | |
12581 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT), | |
12582 | { } | |
12583 | }; | |
7cdbff94 | 12584 | |
df694daa KY |
12585 | /* |
12586 | * generic initialization of ADC, input mixers and output mixers | |
12587 | */ | |
12588 | static struct hda_verb alc861_base_init_verbs[] = { | |
12589 | /* | |
12590 | * Unmute ADC0 and set the default input to mic-in | |
12591 | */ | |
12592 | /* port-A for surround (rear panel) */ | |
12593 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12594 | { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
12595 | /* port-B for mic-in (rear panel) with vref */ | |
12596 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
12597 | /* port-C for line-in (rear panel) */ | |
12598 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
12599 | /* port-D for Front */ | |
12600 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12601 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
12602 | /* port-E for HP out (front panel) */ | |
12603 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | |
12604 | /* route front PCM to HP */ | |
9dece1d7 | 12605 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa KY |
12606 | /* port-F for mic-in (front panel) with vref */ |
12607 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
12608 | /* port-G for CLFE (rear panel) */ | |
12609 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12610 | { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
12611 | /* port-H for side (rear panel) */ | |
12612 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12613 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
12614 | /* CD-in */ | |
12615 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
12616 | /* route front mic to ADC1*/ | |
12617 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
12618 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
ea1fb29a | 12619 | |
df694daa KY |
12620 | /* Unmute DAC0~3 & spdif out*/ |
12621 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12622 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12623 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12624 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12625 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
ea1fb29a | 12626 | |
df694daa KY |
12627 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ |
12628 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12629 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12630 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12631 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
ea1fb29a | 12632 | |
df694daa KY |
12633 | /* Unmute Stereo Mixer 15 */ |
12634 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12635 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12636 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 12637 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
df694daa KY |
12638 | |
12639 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12640 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12641 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12642 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12643 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12644 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12645 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12646 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
12647 | /* hp used DAC 3 (Front) */ |
12648 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
12649 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
12650 | ||
12651 | { } | |
12652 | }; | |
12653 | ||
12654 | static struct hda_verb alc861_threestack_init_verbs[] = { | |
12655 | /* | |
12656 | * Unmute ADC0 and set the default input to mic-in | |
12657 | */ | |
12658 | /* port-A for surround (rear panel) */ | |
12659 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
12660 | /* port-B for mic-in (rear panel) with vref */ | |
12661 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
12662 | /* port-C for line-in (rear panel) */ | |
12663 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
12664 | /* port-D for Front */ | |
12665 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12666 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
12667 | /* port-E for HP out (front panel) */ | |
12668 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | |
12669 | /* route front PCM to HP */ | |
9dece1d7 | 12670 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa KY |
12671 | /* port-F for mic-in (front panel) with vref */ |
12672 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
12673 | /* port-G for CLFE (rear panel) */ | |
12674 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
12675 | /* port-H for side (rear panel) */ | |
12676 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
12677 | /* CD-in */ | |
12678 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
12679 | /* route front mic to ADC1*/ | |
12680 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
12681 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12682 | /* Unmute DAC0~3 & spdif out*/ | |
12683 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12684 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12685 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12686 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12687 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
ea1fb29a | 12688 | |
df694daa KY |
12689 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ |
12690 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12691 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12692 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12693 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
ea1fb29a | 12694 | |
df694daa KY |
12695 | /* Unmute Stereo Mixer 15 */ |
12696 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12697 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12698 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 12699 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
df694daa KY |
12700 | |
12701 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12702 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12703 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12704 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12705 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12706 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12707 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12708 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
12709 | /* hp used DAC 3 (Front) */ |
12710 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
12711 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
12712 | { } | |
12713 | }; | |
22309c3e TI |
12714 | |
12715 | static struct hda_verb alc861_uniwill_m31_init_verbs[] = { | |
12716 | /* | |
12717 | * Unmute ADC0 and set the default input to mic-in | |
12718 | */ | |
12719 | /* port-A for surround (rear panel) */ | |
12720 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
12721 | /* port-B for mic-in (rear panel) with vref */ | |
12722 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
12723 | /* port-C for line-in (rear panel) */ | |
12724 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
12725 | /* port-D for Front */ | |
12726 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12727 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
12728 | /* port-E for HP out (front panel) */ | |
f12ab1e0 TI |
12729 | /* this has to be set to VREF80 */ |
12730 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
22309c3e | 12731 | /* route front PCM to HP */ |
9dece1d7 | 12732 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
22309c3e TI |
12733 | /* port-F for mic-in (front panel) with vref */ |
12734 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
12735 | /* port-G for CLFE (rear panel) */ | |
12736 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
12737 | /* port-H for side (rear panel) */ | |
12738 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
12739 | /* CD-in */ | |
12740 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
12741 | /* route front mic to ADC1*/ | |
12742 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
12743 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12744 | /* Unmute DAC0~3 & spdif out*/ | |
12745 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12746 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12747 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12748 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12749 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
ea1fb29a | 12750 | |
22309c3e TI |
12751 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ |
12752 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12753 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12754 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12755 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
ea1fb29a | 12756 | |
22309c3e TI |
12757 | /* Unmute Stereo Mixer 15 */ |
12758 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12759 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12760 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 12761 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
22309c3e TI |
12762 | |
12763 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12764 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12765 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12766 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12767 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12768 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12769 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12770 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
12771 | /* hp used DAC 3 (Front) */ |
12772 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
22309c3e TI |
12773 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
12774 | { } | |
12775 | }; | |
12776 | ||
7cdbff94 MD |
12777 | static struct hda_verb alc861_asus_init_verbs[] = { |
12778 | /* | |
12779 | * Unmute ADC0 and set the default input to mic-in | |
12780 | */ | |
f12ab1e0 TI |
12781 | /* port-A for surround (rear panel) |
12782 | * according to codec#0 this is the HP jack | |
12783 | */ | |
7cdbff94 MD |
12784 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */ |
12785 | /* route front PCM to HP */ | |
12786 | { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
12787 | /* port-B for mic-in (rear panel) with vref */ | |
12788 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
12789 | /* port-C for line-in (rear panel) */ | |
12790 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
12791 | /* port-D for Front */ | |
12792 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12793 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
12794 | /* port-E for HP out (front panel) */ | |
f12ab1e0 TI |
12795 | /* this has to be set to VREF80 */ |
12796 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
7cdbff94 | 12797 | /* route front PCM to HP */ |
9dece1d7 | 12798 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
7cdbff94 MD |
12799 | /* port-F for mic-in (front panel) with vref */ |
12800 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
12801 | /* port-G for CLFE (rear panel) */ | |
12802 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12803 | /* port-H for side (rear panel) */ | |
12804 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12805 | /* CD-in */ | |
12806 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
12807 | /* route front mic to ADC1*/ | |
12808 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
12809 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12810 | /* Unmute DAC0~3 & spdif out*/ | |
12811 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12812 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12813 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12814 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12815 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12816 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
12817 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12818 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12819 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12820 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
ea1fb29a | 12821 | |
7cdbff94 MD |
12822 | /* Unmute Stereo Mixer 15 */ |
12823 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12824 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12825 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 12826 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
7cdbff94 MD |
12827 | |
12828 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12829 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12830 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12831 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12832 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12833 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12834 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12835 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
12836 | /* hp used DAC 3 (Front) */ |
12837 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
7cdbff94 MD |
12838 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
12839 | { } | |
12840 | }; | |
12841 | ||
56bb0cab TI |
12842 | /* additional init verbs for ASUS laptops */ |
12843 | static struct hda_verb alc861_asus_laptop_init_verbs[] = { | |
12844 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */ | |
12845 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */ | |
12846 | { } | |
12847 | }; | |
7cdbff94 | 12848 | |
df694daa KY |
12849 | /* |
12850 | * generic initialization of ADC, input mixers and output mixers | |
12851 | */ | |
12852 | static struct hda_verb alc861_auto_init_verbs[] = { | |
12853 | /* | |
12854 | * Unmute ADC0 and set the default input to mic-in | |
12855 | */ | |
f12ab1e0 | 12856 | /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */ |
df694daa | 12857 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
ea1fb29a | 12858 | |
df694daa KY |
12859 | /* Unmute DAC0~3 & spdif out*/ |
12860 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12861 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12862 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12863 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12864 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
ea1fb29a | 12865 | |
df694daa KY |
12866 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ |
12867 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12868 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12869 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12870 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
ea1fb29a | 12871 | |
df694daa KY |
12872 | /* Unmute Stereo Mixer 15 */ |
12873 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12874 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12875 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
12876 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, | |
12877 | ||
12878 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12879 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12880 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12881 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12882 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12883 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12884 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12885 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12886 | ||
12887 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
12888 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
f12ab1e0 TI |
12889 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
12890 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
12891 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
12892 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
f12ab1e0 TI |
12893 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
12894 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa | 12895 | |
f12ab1e0 | 12896 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */ |
df694daa KY |
12897 | |
12898 | { } | |
12899 | }; | |
12900 | ||
a53d1aec TD |
12901 | static struct hda_verb alc861_toshiba_init_verbs[] = { |
12902 | {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
f12ab1e0 | 12903 | |
a53d1aec TD |
12904 | { } |
12905 | }; | |
12906 | ||
12907 | /* toggle speaker-output according to the hp-jack state */ | |
12908 | static void alc861_toshiba_automute(struct hda_codec *codec) | |
12909 | { | |
12910 | unsigned int present; | |
12911 | ||
12912 | present = snd_hda_codec_read(codec, 0x0f, 0, | |
12913 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
12914 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0, |
12915 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
12916 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3, | |
12917 | HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE); | |
a53d1aec TD |
12918 | } |
12919 | ||
12920 | static void alc861_toshiba_unsol_event(struct hda_codec *codec, | |
12921 | unsigned int res) | |
12922 | { | |
a53d1aec TD |
12923 | if ((res >> 26) == ALC880_HP_EVENT) |
12924 | alc861_toshiba_automute(codec); | |
12925 | } | |
12926 | ||
df694daa KY |
12927 | /* pcm configuration: identiacal with ALC880 */ |
12928 | #define alc861_pcm_analog_playback alc880_pcm_analog_playback | |
12929 | #define alc861_pcm_analog_capture alc880_pcm_analog_capture | |
12930 | #define alc861_pcm_digital_playback alc880_pcm_digital_playback | |
12931 | #define alc861_pcm_digital_capture alc880_pcm_digital_capture | |
12932 | ||
12933 | ||
12934 | #define ALC861_DIGOUT_NID 0x07 | |
12935 | ||
12936 | static struct hda_channel_mode alc861_8ch_modes[1] = { | |
12937 | { 8, NULL } | |
12938 | }; | |
12939 | ||
12940 | static hda_nid_t alc861_dac_nids[4] = { | |
12941 | /* front, surround, clfe, side */ | |
12942 | 0x03, 0x06, 0x05, 0x04 | |
12943 | }; | |
12944 | ||
9c7f852e TI |
12945 | static hda_nid_t alc660_dac_nids[3] = { |
12946 | /* front, clfe, surround */ | |
12947 | 0x03, 0x05, 0x06 | |
12948 | }; | |
12949 | ||
df694daa KY |
12950 | static hda_nid_t alc861_adc_nids[1] = { |
12951 | /* ADC0-2 */ | |
12952 | 0x08, | |
12953 | }; | |
12954 | ||
12955 | static struct hda_input_mux alc861_capture_source = { | |
12956 | .num_items = 5, | |
12957 | .items = { | |
12958 | { "Mic", 0x0 }, | |
12959 | { "Front Mic", 0x3 }, | |
12960 | { "Line", 0x1 }, | |
12961 | { "CD", 0x4 }, | |
12962 | { "Mixer", 0x5 }, | |
12963 | }, | |
12964 | }; | |
12965 | ||
12966 | /* fill in the dac_nids table from the parsed pin configuration */ | |
f12ab1e0 TI |
12967 | static int alc861_auto_fill_dac_nids(struct alc_spec *spec, |
12968 | const struct auto_pin_cfg *cfg) | |
df694daa KY |
12969 | { |
12970 | int i; | |
12971 | hda_nid_t nid; | |
12972 | ||
12973 | spec->multiout.dac_nids = spec->private_dac_nids; | |
12974 | for (i = 0; i < cfg->line_outs; i++) { | |
12975 | nid = cfg->line_out_pins[i]; | |
12976 | if (nid) { | |
12977 | if (i >= ARRAY_SIZE(alc861_dac_nids)) | |
12978 | continue; | |
12979 | spec->multiout.dac_nids[i] = alc861_dac_nids[i]; | |
12980 | } | |
12981 | } | |
12982 | spec->multiout.num_dacs = cfg->line_outs; | |
12983 | return 0; | |
12984 | } | |
12985 | ||
12986 | /* add playback controls from the parsed DAC table */ | |
12987 | static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec, | |
12988 | const struct auto_pin_cfg *cfg) | |
12989 | { | |
12990 | char name[32]; | |
f12ab1e0 TI |
12991 | static const char *chname[4] = { |
12992 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
12993 | }; | |
df694daa KY |
12994 | hda_nid_t nid; |
12995 | int i, idx, err; | |
12996 | ||
12997 | for (i = 0; i < cfg->line_outs; i++) { | |
12998 | nid = spec->multiout.dac_nids[i]; | |
f12ab1e0 | 12999 | if (!nid) |
df694daa KY |
13000 | continue; |
13001 | if (nid == 0x05) { | |
13002 | /* Center/LFE */ | |
f12ab1e0 TI |
13003 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
13004 | "Center Playback Switch", | |
13005 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, | |
13006 | HDA_OUTPUT)); | |
13007 | if (err < 0) | |
df694daa | 13008 | return err; |
f12ab1e0 TI |
13009 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
13010 | "LFE Playback Switch", | |
13011 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
13012 | HDA_OUTPUT)); | |
13013 | if (err < 0) | |
df694daa KY |
13014 | return err; |
13015 | } else { | |
f12ab1e0 TI |
13016 | for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; |
13017 | idx++) | |
df694daa KY |
13018 | if (nid == alc861_dac_nids[idx]) |
13019 | break; | |
13020 | sprintf(name, "%s Playback Switch", chname[idx]); | |
f12ab1e0 TI |
13021 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
13022 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
13023 | HDA_OUTPUT)); | |
13024 | if (err < 0) | |
df694daa KY |
13025 | return err; |
13026 | } | |
13027 | } | |
13028 | return 0; | |
13029 | } | |
13030 | ||
13031 | static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin) | |
13032 | { | |
13033 | int err; | |
13034 | hda_nid_t nid; | |
13035 | ||
f12ab1e0 | 13036 | if (!pin) |
df694daa KY |
13037 | return 0; |
13038 | ||
13039 | if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) { | |
13040 | nid = 0x03; | |
f12ab1e0 TI |
13041 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
13042 | "Headphone Playback Switch", | |
13043 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
13044 | if (err < 0) | |
df694daa KY |
13045 | return err; |
13046 | spec->multiout.hp_nid = nid; | |
13047 | } | |
13048 | return 0; | |
13049 | } | |
13050 | ||
13051 | /* create playback/capture controls for input pins */ | |
f12ab1e0 TI |
13052 | static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, |
13053 | const struct auto_pin_cfg *cfg) | |
df694daa | 13054 | { |
df694daa KY |
13055 | struct hda_input_mux *imux = &spec->private_imux; |
13056 | int i, err, idx, idx1; | |
13057 | ||
13058 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
f12ab1e0 | 13059 | switch (cfg->input_pins[i]) { |
df694daa KY |
13060 | case 0x0c: |
13061 | idx1 = 1; | |
f12ab1e0 | 13062 | idx = 2; /* Line In */ |
df694daa KY |
13063 | break; |
13064 | case 0x0f: | |
13065 | idx1 = 2; | |
f12ab1e0 | 13066 | idx = 2; /* Line In */ |
df694daa KY |
13067 | break; |
13068 | case 0x0d: | |
13069 | idx1 = 0; | |
f12ab1e0 | 13070 | idx = 1; /* Mic In */ |
df694daa | 13071 | break; |
f12ab1e0 | 13072 | case 0x10: |
df694daa | 13073 | idx1 = 3; |
f12ab1e0 | 13074 | idx = 1; /* Mic In */ |
df694daa KY |
13075 | break; |
13076 | case 0x11: | |
13077 | idx1 = 4; | |
f12ab1e0 | 13078 | idx = 0; /* CD */ |
df694daa KY |
13079 | break; |
13080 | default: | |
13081 | continue; | |
13082 | } | |
13083 | ||
4a471b7d TI |
13084 | err = new_analog_input(spec, cfg->input_pins[i], |
13085 | auto_pin_cfg_labels[i], idx, 0x15); | |
df694daa KY |
13086 | if (err < 0) |
13087 | return err; | |
13088 | ||
4a471b7d | 13089 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
df694daa | 13090 | imux->items[imux->num_items].index = idx1; |
f12ab1e0 | 13091 | imux->num_items++; |
df694daa KY |
13092 | } |
13093 | return 0; | |
13094 | } | |
13095 | ||
13096 | static struct snd_kcontrol_new alc861_capture_mixer[] = { | |
13097 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
13098 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
13099 | ||
13100 | { | |
13101 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
13102 | /* The multiple "Capture Source" controls confuse alsamixer | |
13103 | * So call somewhat different.. | |
df694daa KY |
13104 | */ |
13105 | /* .name = "Capture Source", */ | |
13106 | .name = "Input Source", | |
13107 | .count = 1, | |
13108 | .info = alc_mux_enum_info, | |
13109 | .get = alc_mux_enum_get, | |
13110 | .put = alc_mux_enum_put, | |
13111 | }, | |
13112 | { } /* end */ | |
13113 | }; | |
13114 | ||
f12ab1e0 TI |
13115 | static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, |
13116 | hda_nid_t nid, | |
df694daa KY |
13117 | int pin_type, int dac_idx) |
13118 | { | |
564c5bea JL |
13119 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
13120 | pin_type); | |
13121 | snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
13122 | AMP_OUT_UNMUTE); | |
df694daa KY |
13123 | } |
13124 | ||
13125 | static void alc861_auto_init_multi_out(struct hda_codec *codec) | |
13126 | { | |
13127 | struct alc_spec *spec = codec->spec; | |
13128 | int i; | |
13129 | ||
bc9f98a9 | 13130 | alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b); |
df694daa KY |
13131 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
13132 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 13133 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
df694daa | 13134 | if (nid) |
baba8ee9 | 13135 | alc861_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 13136 | spec->multiout.dac_nids[i]); |
df694daa KY |
13137 | } |
13138 | } | |
13139 | ||
13140 | static void alc861_auto_init_hp_out(struct hda_codec *codec) | |
13141 | { | |
13142 | struct alc_spec *spec = codec->spec; | |
13143 | hda_nid_t pin; | |
13144 | ||
eb06ed8f | 13145 | pin = spec->autocfg.hp_pins[0]; |
df694daa | 13146 | if (pin) /* connect to front */ |
f12ab1e0 TI |
13147 | alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, |
13148 | spec->multiout.dac_nids[0]); | |
f6c7e546 TI |
13149 | pin = spec->autocfg.speaker_pins[0]; |
13150 | if (pin) | |
13151 | alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
df694daa KY |
13152 | } |
13153 | ||
13154 | static void alc861_auto_init_analog_input(struct hda_codec *codec) | |
13155 | { | |
13156 | struct alc_spec *spec = codec->spec; | |
13157 | int i; | |
13158 | ||
13159 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
13160 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
f12ab1e0 TI |
13161 | if (nid >= 0x0c && nid <= 0x11) { |
13162 | snd_hda_codec_write(codec, nid, 0, | |
13163 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
13164 | i <= AUTO_PIN_FRONT_MIC ? | |
13165 | PIN_VREF80 : PIN_IN); | |
df694daa KY |
13166 | } |
13167 | } | |
13168 | } | |
13169 | ||
13170 | /* parse the BIOS configuration and set up the alc_spec */ | |
f12ab1e0 TI |
13171 | /* return 1 if successful, 0 if the proper config is not found, |
13172 | * or a negative error code | |
13173 | */ | |
df694daa KY |
13174 | static int alc861_parse_auto_config(struct hda_codec *codec) |
13175 | { | |
13176 | struct alc_spec *spec = codec->spec; | |
13177 | int err; | |
13178 | static hda_nid_t alc861_ignore[] = { 0x1d, 0 }; | |
13179 | ||
f12ab1e0 TI |
13180 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
13181 | alc861_ignore); | |
13182 | if (err < 0) | |
df694daa | 13183 | return err; |
f12ab1e0 | 13184 | if (!spec->autocfg.line_outs) |
df694daa KY |
13185 | return 0; /* can't find valid BIOS pin config */ |
13186 | ||
f12ab1e0 TI |
13187 | err = alc861_auto_fill_dac_nids(spec, &spec->autocfg); |
13188 | if (err < 0) | |
13189 | return err; | |
13190 | err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
13191 | if (err < 0) | |
13192 | return err; | |
13193 | err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); | |
13194 | if (err < 0) | |
13195 | return err; | |
13196 | err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
13197 | if (err < 0) | |
df694daa KY |
13198 | return err; |
13199 | ||
13200 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
13201 | ||
13202 | if (spec->autocfg.dig_out_pin) | |
13203 | spec->multiout.dig_out_nid = ALC861_DIGOUT_NID; | |
13204 | ||
13205 | if (spec->kctl_alloc) | |
13206 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
13207 | ||
13208 | spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs; | |
13209 | ||
a1e8d2da | 13210 | spec->num_mux_defs = 1; |
df694daa KY |
13211 | spec->input_mux = &spec->private_imux; |
13212 | ||
13213 | spec->adc_nids = alc861_adc_nids; | |
13214 | spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); | |
13215 | spec->mixers[spec->num_mixers] = alc861_capture_mixer; | |
13216 | spec->num_mixers++; | |
13217 | ||
13218 | return 1; | |
13219 | } | |
13220 | ||
ae6b813a TI |
13221 | /* additional initialization for auto-configuration model */ |
13222 | static void alc861_auto_init(struct hda_codec *codec) | |
df694daa | 13223 | { |
f6c7e546 | 13224 | struct alc_spec *spec = codec->spec; |
df694daa KY |
13225 | alc861_auto_init_multi_out(codec); |
13226 | alc861_auto_init_hp_out(codec); | |
13227 | alc861_auto_init_analog_input(codec); | |
f6c7e546 TI |
13228 | if (spec->unsol_event) |
13229 | alc_sku_automute(codec); | |
df694daa KY |
13230 | } |
13231 | ||
cb53c626 TI |
13232 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
13233 | static struct hda_amp_list alc861_loopbacks[] = { | |
13234 | { 0x15, HDA_INPUT, 0 }, | |
13235 | { 0x15, HDA_INPUT, 1 }, | |
13236 | { 0x15, HDA_INPUT, 2 }, | |
13237 | { 0x15, HDA_INPUT, 3 }, | |
13238 | { } /* end */ | |
13239 | }; | |
13240 | #endif | |
13241 | ||
df694daa KY |
13242 | |
13243 | /* | |
13244 | * configuration and preset | |
13245 | */ | |
f5fcc13c TI |
13246 | static const char *alc861_models[ALC861_MODEL_LAST] = { |
13247 | [ALC861_3ST] = "3stack", | |
13248 | [ALC660_3ST] = "3stack-660", | |
13249 | [ALC861_3ST_DIG] = "3stack-dig", | |
13250 | [ALC861_6ST_DIG] = "6stack-dig", | |
13251 | [ALC861_UNIWILL_M31] = "uniwill-m31", | |
13252 | [ALC861_TOSHIBA] = "toshiba", | |
13253 | [ALC861_ASUS] = "asus", | |
13254 | [ALC861_ASUS_LAPTOP] = "asus-laptop", | |
13255 | [ALC861_AUTO] = "auto", | |
13256 | }; | |
13257 | ||
13258 | static struct snd_pci_quirk alc861_cfg_tbl[] = { | |
687a47bd | 13259 | SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST), |
f5fcc13c TI |
13260 | SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP), |
13261 | SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP), | |
13262 | SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS), | |
ac3e3741 | 13263 | SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP), |
83c34218 | 13264 | SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG), |
ad5e7737 | 13265 | SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA), |
341d4eb0 TI |
13266 | /* FIXME: the entry below breaks Toshiba A100 (model=auto works!) |
13267 | * Any other models that need this preset? | |
13268 | */ | |
13269 | /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */ | |
ac3e3741 TI |
13270 | SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST), |
13271 | SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST), | |
4147dab6 | 13272 | SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31), |
ac3e3741 TI |
13273 | SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31), |
13274 | SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP), | |
13275 | /* FIXME: the below seems conflict */ | |
13276 | /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */ | |
07e038b3 | 13277 | SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST), |
f5fcc13c | 13278 | SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST), |
df694daa KY |
13279 | {} |
13280 | }; | |
13281 | ||
13282 | static struct alc_config_preset alc861_presets[] = { | |
13283 | [ALC861_3ST] = { | |
13284 | .mixers = { alc861_3ST_mixer }, | |
13285 | .init_verbs = { alc861_threestack_init_verbs }, | |
13286 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
13287 | .dac_nids = alc861_dac_nids, | |
13288 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
13289 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 13290 | .need_dac_fix = 1, |
df694daa KY |
13291 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
13292 | .adc_nids = alc861_adc_nids, | |
13293 | .input_mux = &alc861_capture_source, | |
13294 | }, | |
13295 | [ALC861_3ST_DIG] = { | |
13296 | .mixers = { alc861_base_mixer }, | |
13297 | .init_verbs = { alc861_threestack_init_verbs }, | |
13298 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
13299 | .dac_nids = alc861_dac_nids, | |
13300 | .dig_out_nid = ALC861_DIGOUT_NID, | |
13301 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
13302 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 13303 | .need_dac_fix = 1, |
df694daa KY |
13304 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
13305 | .adc_nids = alc861_adc_nids, | |
13306 | .input_mux = &alc861_capture_source, | |
13307 | }, | |
13308 | [ALC861_6ST_DIG] = { | |
13309 | .mixers = { alc861_base_mixer }, | |
13310 | .init_verbs = { alc861_base_init_verbs }, | |
13311 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
13312 | .dac_nids = alc861_dac_nids, | |
13313 | .dig_out_nid = ALC861_DIGOUT_NID, | |
13314 | .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes), | |
13315 | .channel_mode = alc861_8ch_modes, | |
13316 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
13317 | .adc_nids = alc861_adc_nids, | |
13318 | .input_mux = &alc861_capture_source, | |
13319 | }, | |
9c7f852e TI |
13320 | [ALC660_3ST] = { |
13321 | .mixers = { alc861_3ST_mixer }, | |
13322 | .init_verbs = { alc861_threestack_init_verbs }, | |
13323 | .num_dacs = ARRAY_SIZE(alc660_dac_nids), | |
13324 | .dac_nids = alc660_dac_nids, | |
13325 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
13326 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 13327 | .need_dac_fix = 1, |
9c7f852e TI |
13328 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
13329 | .adc_nids = alc861_adc_nids, | |
13330 | .input_mux = &alc861_capture_source, | |
13331 | }, | |
22309c3e TI |
13332 | [ALC861_UNIWILL_M31] = { |
13333 | .mixers = { alc861_uniwill_m31_mixer }, | |
13334 | .init_verbs = { alc861_uniwill_m31_init_verbs }, | |
13335 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
13336 | .dac_nids = alc861_dac_nids, | |
13337 | .dig_out_nid = ALC861_DIGOUT_NID, | |
13338 | .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes), | |
13339 | .channel_mode = alc861_uniwill_m31_modes, | |
13340 | .need_dac_fix = 1, | |
13341 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
13342 | .adc_nids = alc861_adc_nids, | |
13343 | .input_mux = &alc861_capture_source, | |
13344 | }, | |
a53d1aec TD |
13345 | [ALC861_TOSHIBA] = { |
13346 | .mixers = { alc861_toshiba_mixer }, | |
f12ab1e0 TI |
13347 | .init_verbs = { alc861_base_init_verbs, |
13348 | alc861_toshiba_init_verbs }, | |
a53d1aec TD |
13349 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), |
13350 | .dac_nids = alc861_dac_nids, | |
13351 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
13352 | .channel_mode = alc883_3ST_2ch_modes, | |
13353 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
13354 | .adc_nids = alc861_adc_nids, | |
13355 | .input_mux = &alc861_capture_source, | |
13356 | .unsol_event = alc861_toshiba_unsol_event, | |
13357 | .init_hook = alc861_toshiba_automute, | |
13358 | }, | |
7cdbff94 MD |
13359 | [ALC861_ASUS] = { |
13360 | .mixers = { alc861_asus_mixer }, | |
13361 | .init_verbs = { alc861_asus_init_verbs }, | |
13362 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
13363 | .dac_nids = alc861_dac_nids, | |
13364 | .dig_out_nid = ALC861_DIGOUT_NID, | |
13365 | .num_channel_mode = ARRAY_SIZE(alc861_asus_modes), | |
13366 | .channel_mode = alc861_asus_modes, | |
13367 | .need_dac_fix = 1, | |
13368 | .hp_nid = 0x06, | |
13369 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
13370 | .adc_nids = alc861_adc_nids, | |
13371 | .input_mux = &alc861_capture_source, | |
13372 | }, | |
56bb0cab TI |
13373 | [ALC861_ASUS_LAPTOP] = { |
13374 | .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer }, | |
13375 | .init_verbs = { alc861_asus_init_verbs, | |
13376 | alc861_asus_laptop_init_verbs }, | |
13377 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
13378 | .dac_nids = alc861_dac_nids, | |
13379 | .dig_out_nid = ALC861_DIGOUT_NID, | |
13380 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
13381 | .channel_mode = alc883_3ST_2ch_modes, | |
13382 | .need_dac_fix = 1, | |
13383 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
13384 | .adc_nids = alc861_adc_nids, | |
13385 | .input_mux = &alc861_capture_source, | |
13386 | }, | |
13387 | }; | |
df694daa KY |
13388 | |
13389 | ||
13390 | static int patch_alc861(struct hda_codec *codec) | |
13391 | { | |
13392 | struct alc_spec *spec; | |
13393 | int board_config; | |
13394 | int err; | |
13395 | ||
dc041e0b | 13396 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
df694daa KY |
13397 | if (spec == NULL) |
13398 | return -ENOMEM; | |
13399 | ||
f12ab1e0 | 13400 | codec->spec = spec; |
df694daa | 13401 | |
f5fcc13c TI |
13402 | board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST, |
13403 | alc861_models, | |
13404 | alc861_cfg_tbl); | |
9c7f852e | 13405 | |
f5fcc13c | 13406 | if (board_config < 0) { |
9c7f852e TI |
13407 | printk(KERN_INFO "hda_codec: Unknown model for ALC861, " |
13408 | "trying auto-probe from BIOS...\n"); | |
df694daa KY |
13409 | board_config = ALC861_AUTO; |
13410 | } | |
13411 | ||
13412 | if (board_config == ALC861_AUTO) { | |
13413 | /* automatic parse from the BIOS config */ | |
13414 | err = alc861_parse_auto_config(codec); | |
13415 | if (err < 0) { | |
13416 | alc_free(codec); | |
13417 | return err; | |
f12ab1e0 | 13418 | } else if (!err) { |
9c7f852e TI |
13419 | printk(KERN_INFO |
13420 | "hda_codec: Cannot set up configuration " | |
13421 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
13422 | board_config = ALC861_3ST_DIG; |
13423 | } | |
13424 | } | |
13425 | ||
13426 | if (board_config != ALC861_AUTO) | |
13427 | setup_preset(spec, &alc861_presets[board_config]); | |
13428 | ||
13429 | spec->stream_name_analog = "ALC861 Analog"; | |
13430 | spec->stream_analog_playback = &alc861_pcm_analog_playback; | |
13431 | spec->stream_analog_capture = &alc861_pcm_analog_capture; | |
13432 | ||
13433 | spec->stream_name_digital = "ALC861 Digital"; | |
13434 | spec->stream_digital_playback = &alc861_pcm_digital_playback; | |
13435 | spec->stream_digital_capture = &alc861_pcm_digital_capture; | |
13436 | ||
2134ea4f TI |
13437 | spec->vmaster_nid = 0x03; |
13438 | ||
df694daa KY |
13439 | codec->patch_ops = alc_patch_ops; |
13440 | if (board_config == ALC861_AUTO) | |
ae6b813a | 13441 | spec->init_hook = alc861_auto_init; |
cb53c626 TI |
13442 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
13443 | if (!spec->loopback.amplist) | |
13444 | spec->loopback.amplist = alc861_loopbacks; | |
13445 | #endif | |
ea1fb29a | 13446 | |
1da177e4 LT |
13447 | return 0; |
13448 | } | |
13449 | ||
f32610ed JS |
13450 | /* |
13451 | * ALC861-VD support | |
13452 | * | |
13453 | * Based on ALC882 | |
13454 | * | |
13455 | * In addition, an independent DAC | |
13456 | */ | |
13457 | #define ALC861VD_DIGOUT_NID 0x06 | |
13458 | ||
13459 | static hda_nid_t alc861vd_dac_nids[4] = { | |
13460 | /* front, surr, clfe, side surr */ | |
13461 | 0x02, 0x03, 0x04, 0x05 | |
13462 | }; | |
13463 | ||
13464 | /* dac_nids for ALC660vd are in a different order - according to | |
13465 | * Realtek's driver. | |
13466 | * This should probably tesult in a different mixer for 6stack models | |
13467 | * of ALC660vd codecs, but for now there is only 3stack mixer | |
13468 | * - and it is the same as in 861vd. | |
13469 | * adc_nids in ALC660vd are (is) the same as in 861vd | |
13470 | */ | |
13471 | static hda_nid_t alc660vd_dac_nids[3] = { | |
13472 | /* front, rear, clfe, rear_surr */ | |
13473 | 0x02, 0x04, 0x03 | |
13474 | }; | |
13475 | ||
13476 | static hda_nid_t alc861vd_adc_nids[1] = { | |
13477 | /* ADC0 */ | |
13478 | 0x09, | |
13479 | }; | |
13480 | ||
e1406348 TI |
13481 | static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 }; |
13482 | ||
f32610ed JS |
13483 | /* input MUX */ |
13484 | /* FIXME: should be a matrix-type input source selection */ | |
13485 | static struct hda_input_mux alc861vd_capture_source = { | |
13486 | .num_items = 4, | |
13487 | .items = { | |
13488 | { "Mic", 0x0 }, | |
13489 | { "Front Mic", 0x1 }, | |
13490 | { "Line", 0x2 }, | |
13491 | { "CD", 0x4 }, | |
13492 | }, | |
13493 | }; | |
13494 | ||
272a527c | 13495 | static struct hda_input_mux alc861vd_dallas_capture_source = { |
b419f346 | 13496 | .num_items = 2, |
272a527c | 13497 | .items = { |
b419f346 TD |
13498 | { "Ext Mic", 0x0 }, |
13499 | { "Int Mic", 0x1 }, | |
272a527c KY |
13500 | }, |
13501 | }; | |
13502 | ||
d1a991a6 KY |
13503 | static struct hda_input_mux alc861vd_hp_capture_source = { |
13504 | .num_items = 2, | |
13505 | .items = { | |
13506 | { "Front Mic", 0x0 }, | |
13507 | { "ATAPI Mic", 0x1 }, | |
13508 | }, | |
13509 | }; | |
13510 | ||
f32610ed JS |
13511 | #define alc861vd_mux_enum_info alc_mux_enum_info |
13512 | #define alc861vd_mux_enum_get alc_mux_enum_get | |
e1406348 TI |
13513 | /* ALC861VD has the ALC882-type input selection (but has only one ADC) */ |
13514 | #define alc861vd_mux_enum_put alc882_mux_enum_put | |
f32610ed JS |
13515 | |
13516 | /* | |
13517 | * 2ch mode | |
13518 | */ | |
13519 | static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = { | |
13520 | { 2, NULL } | |
13521 | }; | |
13522 | ||
13523 | /* | |
13524 | * 6ch mode | |
13525 | */ | |
13526 | static struct hda_verb alc861vd_6stack_ch6_init[] = { | |
13527 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
13528 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13529 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13530 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13531 | { } /* end */ | |
13532 | }; | |
13533 | ||
13534 | /* | |
13535 | * 8ch mode | |
13536 | */ | |
13537 | static struct hda_verb alc861vd_6stack_ch8_init[] = { | |
13538 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13539 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13540 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13541 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13542 | { } /* end */ | |
13543 | }; | |
13544 | ||
13545 | static struct hda_channel_mode alc861vd_6stack_modes[2] = { | |
13546 | { 6, alc861vd_6stack_ch6_init }, | |
13547 | { 8, alc861vd_6stack_ch8_init }, | |
13548 | }; | |
13549 | ||
13550 | static struct snd_kcontrol_new alc861vd_chmode_mixer[] = { | |
13551 | { | |
13552 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
13553 | .name = "Channel Mode", | |
13554 | .info = alc_ch_mode_info, | |
13555 | .get = alc_ch_mode_get, | |
13556 | .put = alc_ch_mode_put, | |
13557 | }, | |
13558 | { } /* end */ | |
13559 | }; | |
13560 | ||
13561 | static struct snd_kcontrol_new alc861vd_capture_mixer[] = { | |
13562 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
13563 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
13564 | ||
13565 | { | |
13566 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
13567 | /* The multiple "Capture Source" controls confuse alsamixer | |
13568 | * So call somewhat different.. | |
f32610ed JS |
13569 | */ |
13570 | /* .name = "Capture Source", */ | |
13571 | .name = "Input Source", | |
13572 | .count = 1, | |
13573 | .info = alc861vd_mux_enum_info, | |
13574 | .get = alc861vd_mux_enum_get, | |
13575 | .put = alc861vd_mux_enum_put, | |
13576 | }, | |
13577 | { } /* end */ | |
13578 | }; | |
13579 | ||
13580 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 | |
13581 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
13582 | */ | |
13583 | static struct snd_kcontrol_new alc861vd_6st_mixer[] = { | |
13584 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
13585 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
13586 | ||
13587 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
13588 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
13589 | ||
13590 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, | |
13591 | HDA_OUTPUT), | |
13592 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, | |
13593 | HDA_OUTPUT), | |
13594 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
13595 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
13596 | ||
13597 | HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT), | |
13598 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
13599 | ||
13600 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
13601 | ||
13602 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
13603 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
13604 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
13605 | ||
13606 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
13607 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
13608 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
13609 | ||
13610 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
13611 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
13612 | ||
13613 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
13614 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
13615 | ||
13616 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
13617 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
13618 | ||
13619 | { } /* end */ | |
13620 | }; | |
13621 | ||
13622 | static struct snd_kcontrol_new alc861vd_3st_mixer[] = { | |
13623 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
13624 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
13625 | ||
13626 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
13627 | ||
13628 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
13629 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
13630 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
13631 | ||
13632 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
13633 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
13634 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
13635 | ||
13636 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
13637 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
13638 | ||
13639 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
13640 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
13641 | ||
13642 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
13643 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
13644 | ||
13645 | { } /* end */ | |
13646 | }; | |
13647 | ||
bdd148a3 KY |
13648 | static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = { |
13649 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
13650 | /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/ | |
13651 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
13652 | ||
13653 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
13654 | ||
13655 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
13656 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
13657 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
13658 | ||
13659 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
13660 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
13661 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
13662 | ||
13663 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
13664 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
13665 | ||
13666 | { } /* end */ | |
13667 | }; | |
13668 | ||
b419f346 TD |
13669 | /* Pin assignment: Speaker=0x14, HP = 0x15, |
13670 | * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d | |
272a527c KY |
13671 | */ |
13672 | static struct snd_kcontrol_new alc861vd_dallas_mixer[] = { | |
b419f346 TD |
13673 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), |
13674 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT), | |
272a527c KY |
13675 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
13676 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), | |
b419f346 TD |
13677 | HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT), |
13678 | HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
13679 | HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
13680 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
13681 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
13682 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
13683 | HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT), | |
13684 | HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT), | |
272a527c KY |
13685 | { } /* end */ |
13686 | }; | |
13687 | ||
d1a991a6 KY |
13688 | /* Pin assignment: Speaker=0x14, Line-out = 0x15, |
13689 | * Front Mic=0x18, ATAPI Mic = 0x19, | |
13690 | */ | |
13691 | static struct snd_kcontrol_new alc861vd_hp_mixer[] = { | |
13692 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
13693 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
13694 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
13695 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), | |
13696 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
13697 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
13698 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
13699 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
ea1fb29a | 13700 | |
d1a991a6 KY |
13701 | { } /* end */ |
13702 | }; | |
13703 | ||
f32610ed JS |
13704 | /* |
13705 | * generic initialization of ADC, input mixers and output mixers | |
13706 | */ | |
13707 | static struct hda_verb alc861vd_volume_init_verbs[] = { | |
13708 | /* | |
13709 | * Unmute ADC0 and set the default input to mic-in | |
13710 | */ | |
13711 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
13712 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13713 | ||
13714 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of | |
13715 | * the analog-loopback mixer widget | |
13716 | */ | |
13717 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
13718 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
13719 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
13720 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
13721 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
13722 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
f32610ed JS |
13723 | |
13724 | /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */ | |
bdd148a3 KY |
13725 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
13726 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13727 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f32610ed | 13728 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
f32610ed JS |
13729 | |
13730 | /* | |
13731 | * Set up output mixers (0x02 - 0x05) | |
13732 | */ | |
13733 | /* set vol=0 to output mixers */ | |
13734 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
13735 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
13736 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
13737 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
13738 | ||
13739 | /* set up input amps for analog loopback */ | |
13740 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
13741 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
13742 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
13743 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
13744 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
13745 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
13746 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
13747 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
13748 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
13749 | ||
13750 | { } | |
13751 | }; | |
13752 | ||
13753 | /* | |
13754 | * 3-stack pin configuration: | |
13755 | * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b | |
13756 | */ | |
13757 | static struct hda_verb alc861vd_3stack_init_verbs[] = { | |
13758 | /* | |
13759 | * Set pin mode and muting | |
13760 | */ | |
13761 | /* set front pin widgets 0x14 for output */ | |
13762 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
13763 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13764 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
13765 | ||
13766 | /* Mic (rear) pin: input vref at 80% */ | |
13767 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
13768 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13769 | /* Front Mic pin: input vref at 80% */ | |
13770 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
13771 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13772 | /* Line In pin: input */ | |
13773 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
13774 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13775 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
13776 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
13777 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13778 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
13779 | /* CD pin widget for input */ | |
13780 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
13781 | ||
13782 | { } | |
13783 | }; | |
13784 | ||
13785 | /* | |
13786 | * 6-stack pin configuration: | |
13787 | */ | |
13788 | static struct hda_verb alc861vd_6stack_init_verbs[] = { | |
13789 | /* | |
13790 | * Set pin mode and muting | |
13791 | */ | |
13792 | /* set front pin widgets 0x14 for output */ | |
13793 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
13794 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13795 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
13796 | ||
13797 | /* Rear Pin: output 1 (0x0d) */ | |
13798 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
13799 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13800 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
13801 | /* CLFE Pin: output 2 (0x0e) */ | |
13802 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
13803 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13804 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
13805 | /* Side Pin: output 3 (0x0f) */ | |
13806 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
13807 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13808 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
13809 | ||
13810 | /* Mic (rear) pin: input vref at 80% */ | |
13811 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
13812 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13813 | /* Front Mic pin: input vref at 80% */ | |
13814 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
13815 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13816 | /* Line In pin: input */ | |
13817 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
13818 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13819 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
13820 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
13821 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13822 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
13823 | /* CD pin widget for input */ | |
13824 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
13825 | ||
13826 | { } | |
13827 | }; | |
13828 | ||
bdd148a3 KY |
13829 | static struct hda_verb alc861vd_eapd_verbs[] = { |
13830 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
13831 | { } | |
13832 | }; | |
13833 | ||
f9423e7a KY |
13834 | static struct hda_verb alc660vd_eapd_verbs[] = { |
13835 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
13836 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
13837 | { } | |
13838 | }; | |
13839 | ||
bdd148a3 KY |
13840 | static struct hda_verb alc861vd_lenovo_unsol_verbs[] = { |
13841 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13842 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13843 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
13844 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
ea1fb29a | 13845 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, |
bdd148a3 KY |
13846 | {} |
13847 | }; | |
13848 | ||
13849 | /* toggle speaker-output according to the hp-jack state */ | |
13850 | static void alc861vd_lenovo_hp_automute(struct hda_codec *codec) | |
13851 | { | |
13852 | unsigned int present; | |
13853 | unsigned char bits; | |
13854 | ||
13855 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
13856 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
13857 | bits = present ? HDA_AMP_MUTE : 0; |
13858 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
13859 | HDA_AMP_MUTE, bits); | |
bdd148a3 KY |
13860 | } |
13861 | ||
13862 | static void alc861vd_lenovo_mic_automute(struct hda_codec *codec) | |
13863 | { | |
13864 | unsigned int present; | |
13865 | unsigned char bits; | |
13866 | ||
13867 | present = snd_hda_codec_read(codec, 0x18, 0, | |
13868 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
13869 | bits = present ? HDA_AMP_MUTE : 0; |
13870 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, | |
13871 | HDA_AMP_MUTE, bits); | |
bdd148a3 KY |
13872 | } |
13873 | ||
13874 | static void alc861vd_lenovo_automute(struct hda_codec *codec) | |
13875 | { | |
13876 | alc861vd_lenovo_hp_automute(codec); | |
13877 | alc861vd_lenovo_mic_automute(codec); | |
13878 | } | |
13879 | ||
13880 | static void alc861vd_lenovo_unsol_event(struct hda_codec *codec, | |
13881 | unsigned int res) | |
13882 | { | |
13883 | switch (res >> 26) { | |
13884 | case ALC880_HP_EVENT: | |
13885 | alc861vd_lenovo_hp_automute(codec); | |
13886 | break; | |
13887 | case ALC880_MIC_EVENT: | |
13888 | alc861vd_lenovo_mic_automute(codec); | |
13889 | break; | |
13890 | } | |
13891 | } | |
13892 | ||
272a527c KY |
13893 | static struct hda_verb alc861vd_dallas_verbs[] = { |
13894 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
13895 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
13896 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
13897 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
13898 | ||
13899 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13900 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13901 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
13902 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
13903 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
13904 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
13905 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
13906 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
ea1fb29a | 13907 | |
272a527c KY |
13908 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
13909 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13910 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
13911 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13912 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
13913 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13914 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
13915 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13916 | ||
13917 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | |
13918 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13919 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | |
13920 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13921 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
13922 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
13923 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
13924 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
13925 | ||
13926 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13927 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
13928 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
13929 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
13930 | ||
13931 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
ea1fb29a | 13932 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
272a527c KY |
13933 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, |
13934 | ||
13935 | { } /* end */ | |
13936 | }; | |
13937 | ||
13938 | /* toggle speaker-output according to the hp-jack state */ | |
13939 | static void alc861vd_dallas_automute(struct hda_codec *codec) | |
13940 | { | |
13941 | unsigned int present; | |
13942 | ||
13943 | present = snd_hda_codec_read(codec, 0x15, 0, | |
13944 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
13945 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
13946 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c KY |
13947 | } |
13948 | ||
13949 | static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res) | |
13950 | { | |
13951 | if ((res >> 26) == ALC880_HP_EVENT) | |
13952 | alc861vd_dallas_automute(codec); | |
13953 | } | |
13954 | ||
cb53c626 TI |
13955 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
13956 | #define alc861vd_loopbacks alc880_loopbacks | |
13957 | #endif | |
13958 | ||
f32610ed JS |
13959 | /* pcm configuration: identiacal with ALC880 */ |
13960 | #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback | |
13961 | #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture | |
13962 | #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback | |
13963 | #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture | |
13964 | ||
13965 | /* | |
13966 | * configuration and preset | |
13967 | */ | |
13968 | static const char *alc861vd_models[ALC861VD_MODEL_LAST] = { | |
13969 | [ALC660VD_3ST] = "3stack-660", | |
983f8ae4 | 13970 | [ALC660VD_3ST_DIG] = "3stack-660-digout", |
f32610ed JS |
13971 | [ALC861VD_3ST] = "3stack", |
13972 | [ALC861VD_3ST_DIG] = "3stack-digout", | |
13973 | [ALC861VD_6ST_DIG] = "6stack-digout", | |
bdd148a3 | 13974 | [ALC861VD_LENOVO] = "lenovo", |
272a527c | 13975 | [ALC861VD_DALLAS] = "dallas", |
983f8ae4 | 13976 | [ALC861VD_HP] = "hp", |
f32610ed JS |
13977 | [ALC861VD_AUTO] = "auto", |
13978 | }; | |
13979 | ||
13980 | static struct snd_pci_quirk alc861vd_cfg_tbl[] = { | |
ac3e3741 TI |
13981 | SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST), |
13982 | SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP), | |
07e038b3 | 13983 | SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST), |
f32610ed | 13984 | SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST), |
2522d735 | 13985 | SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC861VD_LENOVO), |
6963f84c | 13986 | SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG), |
f32610ed | 13987 | SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST), |
ac3e3741 | 13988 | SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO), |
38baf5ad | 13989 | /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/ |
272a527c | 13990 | SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS), |
542d7c66 | 13991 | SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO), |
b419f346 | 13992 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS), |
39c5d41f | 13993 | SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG), |
ac3e3741 TI |
13994 | SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO), |
13995 | SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO), | |
be321a89 | 13996 | SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 N200", ALC861VD_LENOVO), |
625dc0bf | 13997 | SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG), |
f32610ed JS |
13998 | {} |
13999 | }; | |
14000 | ||
14001 | static struct alc_config_preset alc861vd_presets[] = { | |
14002 | [ALC660VD_3ST] = { | |
14003 | .mixers = { alc861vd_3st_mixer }, | |
14004 | .init_verbs = { alc861vd_volume_init_verbs, | |
14005 | alc861vd_3stack_init_verbs }, | |
14006 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
14007 | .dac_nids = alc660vd_dac_nids, | |
f32610ed JS |
14008 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
14009 | .channel_mode = alc861vd_3stack_2ch_modes, | |
14010 | .input_mux = &alc861vd_capture_source, | |
14011 | }, | |
6963f84c MC |
14012 | [ALC660VD_3ST_DIG] = { |
14013 | .mixers = { alc861vd_3st_mixer }, | |
14014 | .init_verbs = { alc861vd_volume_init_verbs, | |
14015 | alc861vd_3stack_init_verbs }, | |
14016 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
14017 | .dac_nids = alc660vd_dac_nids, | |
14018 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
6963f84c MC |
14019 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
14020 | .channel_mode = alc861vd_3stack_2ch_modes, | |
14021 | .input_mux = &alc861vd_capture_source, | |
14022 | }, | |
f32610ed JS |
14023 | [ALC861VD_3ST] = { |
14024 | .mixers = { alc861vd_3st_mixer }, | |
14025 | .init_verbs = { alc861vd_volume_init_verbs, | |
14026 | alc861vd_3stack_init_verbs }, | |
14027 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
14028 | .dac_nids = alc861vd_dac_nids, | |
14029 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
14030 | .channel_mode = alc861vd_3stack_2ch_modes, | |
14031 | .input_mux = &alc861vd_capture_source, | |
14032 | }, | |
14033 | [ALC861VD_3ST_DIG] = { | |
14034 | .mixers = { alc861vd_3st_mixer }, | |
14035 | .init_verbs = { alc861vd_volume_init_verbs, | |
14036 | alc861vd_3stack_init_verbs }, | |
14037 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
14038 | .dac_nids = alc861vd_dac_nids, | |
14039 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
14040 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
14041 | .channel_mode = alc861vd_3stack_2ch_modes, | |
14042 | .input_mux = &alc861vd_capture_source, | |
14043 | }, | |
14044 | [ALC861VD_6ST_DIG] = { | |
14045 | .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer }, | |
14046 | .init_verbs = { alc861vd_volume_init_verbs, | |
14047 | alc861vd_6stack_init_verbs }, | |
14048 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
14049 | .dac_nids = alc861vd_dac_nids, | |
14050 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
14051 | .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes), | |
14052 | .channel_mode = alc861vd_6stack_modes, | |
14053 | .input_mux = &alc861vd_capture_source, | |
14054 | }, | |
bdd148a3 KY |
14055 | [ALC861VD_LENOVO] = { |
14056 | .mixers = { alc861vd_lenovo_mixer }, | |
14057 | .init_verbs = { alc861vd_volume_init_verbs, | |
14058 | alc861vd_3stack_init_verbs, | |
14059 | alc861vd_eapd_verbs, | |
14060 | alc861vd_lenovo_unsol_verbs }, | |
14061 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
14062 | .dac_nids = alc660vd_dac_nids, | |
bdd148a3 KY |
14063 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
14064 | .channel_mode = alc861vd_3stack_2ch_modes, | |
14065 | .input_mux = &alc861vd_capture_source, | |
14066 | .unsol_event = alc861vd_lenovo_unsol_event, | |
14067 | .init_hook = alc861vd_lenovo_automute, | |
14068 | }, | |
272a527c KY |
14069 | [ALC861VD_DALLAS] = { |
14070 | .mixers = { alc861vd_dallas_mixer }, | |
14071 | .init_verbs = { alc861vd_dallas_verbs }, | |
14072 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
14073 | .dac_nids = alc861vd_dac_nids, | |
272a527c KY |
14074 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
14075 | .channel_mode = alc861vd_3stack_2ch_modes, | |
14076 | .input_mux = &alc861vd_dallas_capture_source, | |
14077 | .unsol_event = alc861vd_dallas_unsol_event, | |
14078 | .init_hook = alc861vd_dallas_automute, | |
d1a991a6 KY |
14079 | }, |
14080 | [ALC861VD_HP] = { | |
14081 | .mixers = { alc861vd_hp_mixer }, | |
14082 | .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs }, | |
14083 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
14084 | .dac_nids = alc861vd_dac_nids, | |
d1a991a6 | 14085 | .dig_out_nid = ALC861VD_DIGOUT_NID, |
d1a991a6 KY |
14086 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
14087 | .channel_mode = alc861vd_3stack_2ch_modes, | |
14088 | .input_mux = &alc861vd_hp_capture_source, | |
14089 | .unsol_event = alc861vd_dallas_unsol_event, | |
14090 | .init_hook = alc861vd_dallas_automute, | |
ea1fb29a | 14091 | }, |
f32610ed JS |
14092 | }; |
14093 | ||
14094 | /* | |
14095 | * BIOS auto configuration | |
14096 | */ | |
14097 | static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec, | |
14098 | hda_nid_t nid, int pin_type, int dac_idx) | |
14099 | { | |
f6c7e546 | 14100 | alc_set_pin_output(codec, nid, pin_type); |
f32610ed JS |
14101 | } |
14102 | ||
14103 | static void alc861vd_auto_init_multi_out(struct hda_codec *codec) | |
14104 | { | |
14105 | struct alc_spec *spec = codec->spec; | |
14106 | int i; | |
14107 | ||
bc9f98a9 | 14108 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
f32610ed JS |
14109 | for (i = 0; i <= HDA_SIDE; i++) { |
14110 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 14111 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
f32610ed JS |
14112 | if (nid) |
14113 | alc861vd_auto_set_output_and_unmute(codec, nid, | |
baba8ee9 | 14114 | pin_type, i); |
f32610ed JS |
14115 | } |
14116 | } | |
14117 | ||
14118 | ||
14119 | static void alc861vd_auto_init_hp_out(struct hda_codec *codec) | |
14120 | { | |
14121 | struct alc_spec *spec = codec->spec; | |
14122 | hda_nid_t pin; | |
14123 | ||
14124 | pin = spec->autocfg.hp_pins[0]; | |
14125 | if (pin) /* connect to front and use dac 0 */ | |
14126 | alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
f6c7e546 TI |
14127 | pin = spec->autocfg.speaker_pins[0]; |
14128 | if (pin) | |
14129 | alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
f32610ed JS |
14130 | } |
14131 | ||
14132 | #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid) | |
14133 | #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID | |
14134 | ||
14135 | static void alc861vd_auto_init_analog_input(struct hda_codec *codec) | |
14136 | { | |
14137 | struct alc_spec *spec = codec->spec; | |
14138 | int i; | |
14139 | ||
14140 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
14141 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
14142 | if (alc861vd_is_input_pin(nid)) { | |
14143 | snd_hda_codec_write(codec, nid, 0, | |
14144 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
14145 | i <= AUTO_PIN_FRONT_MIC ? | |
14146 | PIN_VREF80 : PIN_IN); | |
14147 | if (nid != ALC861VD_PIN_CD_NID) | |
14148 | snd_hda_codec_write(codec, nid, 0, | |
14149 | AC_VERB_SET_AMP_GAIN_MUTE, | |
14150 | AMP_OUT_MUTE); | |
14151 | } | |
14152 | } | |
14153 | } | |
14154 | ||
f511b01c TI |
14155 | #define alc861vd_auto_init_input_src alc882_auto_init_input_src |
14156 | ||
f32610ed JS |
14157 | #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02) |
14158 | #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c) | |
14159 | ||
14160 | /* add playback controls from the parsed DAC table */ | |
14161 | /* Based on ALC880 version. But ALC861VD has separate, | |
14162 | * different NIDs for mute/unmute switch and volume control */ | |
14163 | static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec, | |
14164 | const struct auto_pin_cfg *cfg) | |
14165 | { | |
14166 | char name[32]; | |
14167 | static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"}; | |
14168 | hda_nid_t nid_v, nid_s; | |
14169 | int i, err; | |
14170 | ||
14171 | for (i = 0; i < cfg->line_outs; i++) { | |
f12ab1e0 | 14172 | if (!spec->multiout.dac_nids[i]) |
f32610ed JS |
14173 | continue; |
14174 | nid_v = alc861vd_idx_to_mixer_vol( | |
14175 | alc880_dac_to_idx( | |
14176 | spec->multiout.dac_nids[i])); | |
14177 | nid_s = alc861vd_idx_to_mixer_switch( | |
14178 | alc880_dac_to_idx( | |
14179 | spec->multiout.dac_nids[i])); | |
14180 | ||
14181 | if (i == 2) { | |
14182 | /* Center/LFE */ | |
f12ab1e0 TI |
14183 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
14184 | "Center Playback Volume", | |
14185 | HDA_COMPOSE_AMP_VAL(nid_v, 1, 0, | |
14186 | HDA_OUTPUT)); | |
14187 | if (err < 0) | |
f32610ed | 14188 | return err; |
f12ab1e0 TI |
14189 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
14190 | "LFE Playback Volume", | |
14191 | HDA_COMPOSE_AMP_VAL(nid_v, 2, 0, | |
14192 | HDA_OUTPUT)); | |
14193 | if (err < 0) | |
f32610ed | 14194 | return err; |
f12ab1e0 TI |
14195 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
14196 | "Center Playback Switch", | |
14197 | HDA_COMPOSE_AMP_VAL(nid_s, 1, 2, | |
14198 | HDA_INPUT)); | |
14199 | if (err < 0) | |
f32610ed | 14200 | return err; |
f12ab1e0 TI |
14201 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
14202 | "LFE Playback Switch", | |
14203 | HDA_COMPOSE_AMP_VAL(nid_s, 2, 2, | |
14204 | HDA_INPUT)); | |
14205 | if (err < 0) | |
f32610ed JS |
14206 | return err; |
14207 | } else { | |
14208 | sprintf(name, "%s Playback Volume", chname[i]); | |
f12ab1e0 TI |
14209 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
14210 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, | |
14211 | HDA_OUTPUT)); | |
14212 | if (err < 0) | |
f32610ed JS |
14213 | return err; |
14214 | sprintf(name, "%s Playback Switch", chname[i]); | |
f12ab1e0 | 14215 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
bdd148a3 | 14216 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, |
f12ab1e0 TI |
14217 | HDA_INPUT)); |
14218 | if (err < 0) | |
f32610ed JS |
14219 | return err; |
14220 | } | |
14221 | } | |
14222 | return 0; | |
14223 | } | |
14224 | ||
14225 | /* add playback controls for speaker and HP outputs */ | |
14226 | /* Based on ALC880 version. But ALC861VD has separate, | |
14227 | * different NIDs for mute/unmute switch and volume control */ | |
14228 | static int alc861vd_auto_create_extra_out(struct alc_spec *spec, | |
14229 | hda_nid_t pin, const char *pfx) | |
14230 | { | |
14231 | hda_nid_t nid_v, nid_s; | |
14232 | int err; | |
14233 | char name[32]; | |
14234 | ||
f12ab1e0 | 14235 | if (!pin) |
f32610ed JS |
14236 | return 0; |
14237 | ||
14238 | if (alc880_is_fixed_pin(pin)) { | |
14239 | nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
14240 | /* specify the DAC as the extra output */ | |
f12ab1e0 | 14241 | if (!spec->multiout.hp_nid) |
f32610ed JS |
14242 | spec->multiout.hp_nid = nid_v; |
14243 | else | |
14244 | spec->multiout.extra_out_nid[0] = nid_v; | |
14245 | /* control HP volume/switch on the output mixer amp */ | |
14246 | nid_v = alc861vd_idx_to_mixer_vol( | |
14247 | alc880_fixed_pin_idx(pin)); | |
14248 | nid_s = alc861vd_idx_to_mixer_switch( | |
14249 | alc880_fixed_pin_idx(pin)); | |
14250 | ||
14251 | sprintf(name, "%s Playback Volume", pfx); | |
f12ab1e0 TI |
14252 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
14253 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT)); | |
14254 | if (err < 0) | |
f32610ed JS |
14255 | return err; |
14256 | sprintf(name, "%s Playback Switch", pfx); | |
f12ab1e0 TI |
14257 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
14258 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT)); | |
14259 | if (err < 0) | |
f32610ed JS |
14260 | return err; |
14261 | } else if (alc880_is_multi_pin(pin)) { | |
14262 | /* set manual connection */ | |
14263 | /* we have only a switch on HP-out PIN */ | |
14264 | sprintf(name, "%s Playback Switch", pfx); | |
f12ab1e0 TI |
14265 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
14266 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
14267 | if (err < 0) | |
f32610ed JS |
14268 | return err; |
14269 | } | |
14270 | return 0; | |
14271 | } | |
14272 | ||
14273 | /* parse the BIOS configuration and set up the alc_spec | |
14274 | * return 1 if successful, 0 if the proper config is not found, | |
14275 | * or a negative error code | |
14276 | * Based on ALC880 version - had to change it to override | |
14277 | * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */ | |
14278 | static int alc861vd_parse_auto_config(struct hda_codec *codec) | |
14279 | { | |
14280 | struct alc_spec *spec = codec->spec; | |
14281 | int err; | |
14282 | static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; | |
14283 | ||
f12ab1e0 TI |
14284 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
14285 | alc861vd_ignore); | |
14286 | if (err < 0) | |
f32610ed | 14287 | return err; |
f12ab1e0 | 14288 | if (!spec->autocfg.line_outs) |
f32610ed JS |
14289 | return 0; /* can't find valid BIOS pin config */ |
14290 | ||
f12ab1e0 TI |
14291 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
14292 | if (err < 0) | |
14293 | return err; | |
14294 | err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
14295 | if (err < 0) | |
14296 | return err; | |
14297 | err = alc861vd_auto_create_extra_out(spec, | |
14298 | spec->autocfg.speaker_pins[0], | |
14299 | "Speaker"); | |
14300 | if (err < 0) | |
14301 | return err; | |
14302 | err = alc861vd_auto_create_extra_out(spec, | |
14303 | spec->autocfg.hp_pins[0], | |
14304 | "Headphone"); | |
14305 | if (err < 0) | |
14306 | return err; | |
14307 | err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
14308 | if (err < 0) | |
f32610ed JS |
14309 | return err; |
14310 | ||
14311 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
14312 | ||
14313 | if (spec->autocfg.dig_out_pin) | |
14314 | spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID; | |
14315 | ||
14316 | if (spec->kctl_alloc) | |
14317 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
14318 | ||
14319 | spec->init_verbs[spec->num_init_verbs++] | |
14320 | = alc861vd_volume_init_verbs; | |
14321 | ||
14322 | spec->num_mux_defs = 1; | |
14323 | spec->input_mux = &spec->private_imux; | |
14324 | ||
776e184e TI |
14325 | err = alc_auto_add_mic_boost(codec); |
14326 | if (err < 0) | |
14327 | return err; | |
14328 | ||
f32610ed JS |
14329 | return 1; |
14330 | } | |
14331 | ||
14332 | /* additional initialization for auto-configuration model */ | |
14333 | static void alc861vd_auto_init(struct hda_codec *codec) | |
14334 | { | |
f6c7e546 | 14335 | struct alc_spec *spec = codec->spec; |
f32610ed JS |
14336 | alc861vd_auto_init_multi_out(codec); |
14337 | alc861vd_auto_init_hp_out(codec); | |
14338 | alc861vd_auto_init_analog_input(codec); | |
f511b01c | 14339 | alc861vd_auto_init_input_src(codec); |
f6c7e546 TI |
14340 | if (spec->unsol_event) |
14341 | alc_sku_automute(codec); | |
f32610ed JS |
14342 | } |
14343 | ||
14344 | static int patch_alc861vd(struct hda_codec *codec) | |
14345 | { | |
14346 | struct alc_spec *spec; | |
14347 | int err, board_config; | |
14348 | ||
14349 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
14350 | if (spec == NULL) | |
14351 | return -ENOMEM; | |
14352 | ||
14353 | codec->spec = spec; | |
14354 | ||
14355 | board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST, | |
14356 | alc861vd_models, | |
14357 | alc861vd_cfg_tbl); | |
14358 | ||
14359 | if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) { | |
14360 | printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/" | |
14361 | "ALC861VD, trying auto-probe from BIOS...\n"); | |
14362 | board_config = ALC861VD_AUTO; | |
14363 | } | |
14364 | ||
14365 | if (board_config == ALC861VD_AUTO) { | |
14366 | /* automatic parse from the BIOS config */ | |
14367 | err = alc861vd_parse_auto_config(codec); | |
14368 | if (err < 0) { | |
14369 | alc_free(codec); | |
14370 | return err; | |
f12ab1e0 | 14371 | } else if (!err) { |
f32610ed JS |
14372 | printk(KERN_INFO |
14373 | "hda_codec: Cannot set up configuration " | |
14374 | "from BIOS. Using base mode...\n"); | |
14375 | board_config = ALC861VD_3ST; | |
14376 | } | |
14377 | } | |
14378 | ||
14379 | if (board_config != ALC861VD_AUTO) | |
14380 | setup_preset(spec, &alc861vd_presets[board_config]); | |
14381 | ||
2f893286 KY |
14382 | if (codec->vendor_id == 0x10ec0660) { |
14383 | spec->stream_name_analog = "ALC660-VD Analog"; | |
14384 | spec->stream_name_digital = "ALC660-VD Digital"; | |
f9423e7a KY |
14385 | /* always turn on EAPD */ |
14386 | spec->init_verbs[spec->num_init_verbs++] = alc660vd_eapd_verbs; | |
2f893286 KY |
14387 | } else { |
14388 | spec->stream_name_analog = "ALC861VD Analog"; | |
14389 | spec->stream_name_digital = "ALC861VD Digital"; | |
14390 | } | |
14391 | ||
f32610ed JS |
14392 | spec->stream_analog_playback = &alc861vd_pcm_analog_playback; |
14393 | spec->stream_analog_capture = &alc861vd_pcm_analog_capture; | |
14394 | ||
f32610ed JS |
14395 | spec->stream_digital_playback = &alc861vd_pcm_digital_playback; |
14396 | spec->stream_digital_capture = &alc861vd_pcm_digital_capture; | |
14397 | ||
14398 | spec->adc_nids = alc861vd_adc_nids; | |
14399 | spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids); | |
e1406348 | 14400 | spec->capsrc_nids = alc861vd_capsrc_nids; |
f32610ed JS |
14401 | |
14402 | spec->mixers[spec->num_mixers] = alc861vd_capture_mixer; | |
14403 | spec->num_mixers++; | |
14404 | ||
2134ea4f TI |
14405 | spec->vmaster_nid = 0x02; |
14406 | ||
f32610ed JS |
14407 | codec->patch_ops = alc_patch_ops; |
14408 | ||
14409 | if (board_config == ALC861VD_AUTO) | |
14410 | spec->init_hook = alc861vd_auto_init; | |
cb53c626 TI |
14411 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
14412 | if (!spec->loopback.amplist) | |
14413 | spec->loopback.amplist = alc861vd_loopbacks; | |
14414 | #endif | |
f32610ed JS |
14415 | |
14416 | return 0; | |
14417 | } | |
14418 | ||
bc9f98a9 KY |
14419 | /* |
14420 | * ALC662 support | |
14421 | * | |
14422 | * ALC662 is almost identical with ALC880 but has cleaner and more flexible | |
14423 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
14424 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
14425 | * 6-channel independent captures. | |
14426 | * | |
14427 | * In addition, an independent DAC for the multi-playback (not used in this | |
14428 | * driver yet). | |
14429 | */ | |
14430 | #define ALC662_DIGOUT_NID 0x06 | |
14431 | #define ALC662_DIGIN_NID 0x0a | |
14432 | ||
14433 | static hda_nid_t alc662_dac_nids[4] = { | |
14434 | /* front, rear, clfe, rear_surr */ | |
14435 | 0x02, 0x03, 0x04 | |
14436 | }; | |
14437 | ||
14438 | static hda_nid_t alc662_adc_nids[1] = { | |
14439 | /* ADC1-2 */ | |
14440 | 0x09, | |
14441 | }; | |
e1406348 | 14442 | |
77a261b7 | 14443 | static hda_nid_t alc662_capsrc_nids[1] = { 0x22 }; |
e1406348 | 14444 | |
bc9f98a9 KY |
14445 | /* input MUX */ |
14446 | /* FIXME: should be a matrix-type input source selection */ | |
bc9f98a9 KY |
14447 | static struct hda_input_mux alc662_capture_source = { |
14448 | .num_items = 4, | |
14449 | .items = { | |
14450 | { "Mic", 0x0 }, | |
14451 | { "Front Mic", 0x1 }, | |
14452 | { "Line", 0x2 }, | |
14453 | { "CD", 0x4 }, | |
14454 | }, | |
14455 | }; | |
14456 | ||
14457 | static struct hda_input_mux alc662_lenovo_101e_capture_source = { | |
14458 | .num_items = 2, | |
14459 | .items = { | |
14460 | { "Mic", 0x1 }, | |
14461 | { "Line", 0x2 }, | |
14462 | }, | |
14463 | }; | |
291702f0 KY |
14464 | |
14465 | static struct hda_input_mux alc662_eeepc_capture_source = { | |
14466 | .num_items = 2, | |
14467 | .items = { | |
14468 | { "i-Mic", 0x1 }, | |
14469 | { "e-Mic", 0x0 }, | |
14470 | }, | |
14471 | }; | |
14472 | ||
6dda9f4a KY |
14473 | static struct hda_input_mux alc663_capture_source = { |
14474 | .num_items = 3, | |
14475 | .items = { | |
14476 | { "Mic", 0x0 }, | |
14477 | { "Front Mic", 0x1 }, | |
14478 | { "Line", 0x2 }, | |
14479 | }, | |
14480 | }; | |
14481 | ||
14482 | static struct hda_input_mux alc663_m51va_capture_source = { | |
14483 | .num_items = 2, | |
14484 | .items = { | |
14485 | { "Ext-Mic", 0x0 }, | |
14486 | { "D-Mic", 0x9 }, | |
14487 | }, | |
14488 | }; | |
14489 | ||
bc9f98a9 KY |
14490 | #define alc662_mux_enum_info alc_mux_enum_info |
14491 | #define alc662_mux_enum_get alc_mux_enum_get | |
e1406348 | 14492 | #define alc662_mux_enum_put alc882_mux_enum_put |
bc9f98a9 | 14493 | |
bc9f98a9 KY |
14494 | /* |
14495 | * 2ch mode | |
14496 | */ | |
14497 | static struct hda_channel_mode alc662_3ST_2ch_modes[1] = { | |
14498 | { 2, NULL } | |
14499 | }; | |
14500 | ||
14501 | /* | |
14502 | * 2ch mode | |
14503 | */ | |
14504 | static struct hda_verb alc662_3ST_ch2_init[] = { | |
14505 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
14506 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
14507 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
14508 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
14509 | { } /* end */ | |
14510 | }; | |
14511 | ||
14512 | /* | |
14513 | * 6ch mode | |
14514 | */ | |
14515 | static struct hda_verb alc662_3ST_ch6_init[] = { | |
14516 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
14517 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
14518 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
14519 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
14520 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
14521 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
14522 | { } /* end */ | |
14523 | }; | |
14524 | ||
14525 | static struct hda_channel_mode alc662_3ST_6ch_modes[2] = { | |
14526 | { 2, alc662_3ST_ch2_init }, | |
14527 | { 6, alc662_3ST_ch6_init }, | |
14528 | }; | |
14529 | ||
14530 | /* | |
14531 | * 2ch mode | |
14532 | */ | |
14533 | static struct hda_verb alc662_sixstack_ch6_init[] = { | |
14534 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
14535 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
14536 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
14537 | { } /* end */ | |
14538 | }; | |
14539 | ||
14540 | /* | |
14541 | * 6ch mode | |
14542 | */ | |
14543 | static struct hda_verb alc662_sixstack_ch8_init[] = { | |
14544 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
14545 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
14546 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
14547 | { } /* end */ | |
14548 | }; | |
14549 | ||
14550 | static struct hda_channel_mode alc662_5stack_modes[2] = { | |
14551 | { 2, alc662_sixstack_ch6_init }, | |
14552 | { 6, alc662_sixstack_ch8_init }, | |
14553 | }; | |
14554 | ||
14555 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 | |
14556 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
14557 | */ | |
14558 | ||
14559 | static struct snd_kcontrol_new alc662_base_mixer[] = { | |
14560 | /* output mixer control */ | |
14561 | HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT), | |
7055ad8a | 14562 | HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT), |
bc9f98a9 | 14563 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT), |
7055ad8a | 14564 | HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT), |
bc9f98a9 KY |
14565 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), |
14566 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), | |
7055ad8a HRK |
14567 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT), |
14568 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT), | |
bc9f98a9 KY |
14569 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
14570 | ||
14571 | /*Input mixer control */ | |
14572 | HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT), | |
14573 | HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT), | |
14574 | HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT), | |
14575 | HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT), | |
14576 | HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT), | |
14577 | HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT), | |
14578 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT), | |
14579 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT), | |
bc9f98a9 KY |
14580 | { } /* end */ |
14581 | }; | |
14582 | ||
14583 | static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = { | |
14584 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
7055ad8a | 14585 | HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT), |
bc9f98a9 KY |
14586 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
14587 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
14588 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
14589 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
14590 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
14591 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14592 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14593 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14594 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
14595 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
14596 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
bc9f98a9 KY |
14597 | { } /* end */ |
14598 | }; | |
14599 | ||
14600 | static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = { | |
14601 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
7055ad8a | 14602 | HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT), |
bc9f98a9 | 14603 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
7055ad8a | 14604 | HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT), |
bc9f98a9 KY |
14605 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), |
14606 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), | |
7055ad8a HRK |
14607 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT), |
14608 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT), | |
bc9f98a9 KY |
14609 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
14610 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
14611 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
14612 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
14613 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
14614 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14615 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14616 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14617 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
14618 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
14619 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
bc9f98a9 KY |
14620 | { } /* end */ |
14621 | }; | |
14622 | ||
14623 | static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = { | |
14624 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
14625 | HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT), | |
86cd9298 TI |
14626 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
14627 | HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT), | |
bc9f98a9 KY |
14628 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
14629 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
14630 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
14631 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14632 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
bc9f98a9 KY |
14633 | { } /* end */ |
14634 | }; | |
14635 | ||
291702f0 | 14636 | static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = { |
86cd9298 | 14637 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), |
291702f0 | 14638 | |
b4818494 HRK |
14639 | HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT), |
14640 | HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
291702f0 KY |
14641 | |
14642 | HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT), | |
14643 | HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14644 | HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14645 | ||
14646 | HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT), | |
14647 | HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14648 | HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
14649 | { } /* end */ | |
14650 | }; | |
14651 | ||
8c427226 | 14652 | static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = { |
31bffaa9 TI |
14653 | HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT), |
14654 | HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
8c427226 KY |
14655 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
14656 | HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT), | |
14657 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), | |
14658 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), | |
14659 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT), | |
14660 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT), | |
86cd9298 | 14661 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
8c427226 KY |
14662 | HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT), |
14663 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
14664 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
14665 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14666 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14667 | { } /* end */ | |
14668 | }; | |
14669 | ||
f1d4e28b KY |
14670 | static struct hda_bind_ctls alc663_asus_bind_master_vol = { |
14671 | .ops = &snd_hda_bind_vol, | |
14672 | .values = { | |
14673 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), | |
14674 | HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT), | |
14675 | 0 | |
14676 | }, | |
14677 | }; | |
14678 | ||
14679 | static struct hda_bind_ctls alc663_asus_one_bind_switch = { | |
14680 | .ops = &snd_hda_bind_sw, | |
14681 | .values = { | |
14682 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
14683 | HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT), | |
14684 | 0 | |
14685 | }, | |
14686 | }; | |
14687 | ||
6dda9f4a | 14688 | static struct snd_kcontrol_new alc663_m51va_mixer[] = { |
f1d4e28b KY |
14689 | HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol), |
14690 | HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch), | |
14691 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14692 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14693 | { } /* end */ | |
14694 | }; | |
14695 | ||
14696 | static struct hda_bind_ctls alc663_asus_tree_bind_switch = { | |
14697 | .ops = &snd_hda_bind_sw, | |
14698 | .values = { | |
14699 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
14700 | HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | |
14701 | HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT), | |
14702 | 0 | |
14703 | }, | |
14704 | }; | |
14705 | ||
14706 | static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = { | |
14707 | HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol), | |
14708 | HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch), | |
14709 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14710 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14711 | HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14712 | HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
14713 | ||
14714 | { } /* end */ | |
14715 | }; | |
14716 | ||
14717 | static struct hda_bind_ctls alc663_asus_four_bind_switch = { | |
14718 | .ops = &snd_hda_bind_sw, | |
14719 | .values = { | |
14720 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
14721 | HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | |
14722 | HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), | |
14723 | 0 | |
14724 | }, | |
14725 | }; | |
14726 | ||
14727 | static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = { | |
14728 | HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol), | |
14729 | HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch), | |
14730 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14731 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14732 | HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14733 | HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
14734 | { } /* end */ | |
14735 | }; | |
14736 | ||
14737 | static struct snd_kcontrol_new alc662_1bjd_mixer[] = { | |
6dda9f4a KY |
14738 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), |
14739 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
f1d4e28b KY |
14740 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
14741 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14742 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14743 | HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14744 | HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
14745 | { } /* end */ | |
14746 | }; | |
14747 | ||
14748 | static struct hda_bind_ctls alc663_asus_two_bind_master_vol = { | |
14749 | .ops = &snd_hda_bind_vol, | |
14750 | .values = { | |
14751 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), | |
14752 | HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT), | |
14753 | 0 | |
14754 | }, | |
14755 | }; | |
14756 | ||
14757 | static struct hda_bind_ctls alc663_asus_two_bind_switch = { | |
14758 | .ops = &snd_hda_bind_sw, | |
14759 | .values = { | |
14760 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
14761 | HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT), | |
14762 | 0 | |
14763 | }, | |
14764 | }; | |
14765 | ||
14766 | static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = { | |
14767 | HDA_BIND_VOL("Master Playback Volume", | |
14768 | &alc663_asus_two_bind_master_vol), | |
14769 | HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch), | |
14770 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
6dda9f4a KY |
14771 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT), |
14772 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14773 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
f1d4e28b KY |
14774 | { } /* end */ |
14775 | }; | |
14776 | ||
14777 | static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = { | |
14778 | HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol), | |
14779 | HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch), | |
14780 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
14781 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
14782 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14783 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
6dda9f4a KY |
14784 | { } /* end */ |
14785 | }; | |
14786 | ||
14787 | static struct snd_kcontrol_new alc663_g71v_mixer[] = { | |
14788 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
14789 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
14790 | HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
14791 | HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
14792 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT), | |
14793 | ||
14794 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14795 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14796 | HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14797 | HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
14798 | { } /* end */ | |
14799 | }; | |
14800 | ||
14801 | static struct snd_kcontrol_new alc663_g50v_mixer[] = { | |
14802 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
14803 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
14804 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT), | |
14805 | ||
14806 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14807 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14808 | HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14809 | HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
14810 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
14811 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
14812 | { } /* end */ | |
14813 | }; | |
14814 | ||
bc9f98a9 KY |
14815 | static struct snd_kcontrol_new alc662_chmode_mixer[] = { |
14816 | { | |
14817 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
14818 | .name = "Channel Mode", | |
14819 | .info = alc_ch_mode_info, | |
14820 | .get = alc_ch_mode_get, | |
14821 | .put = alc_ch_mode_put, | |
14822 | }, | |
14823 | { } /* end */ | |
14824 | }; | |
14825 | ||
14826 | static struct hda_verb alc662_init_verbs[] = { | |
14827 | /* ADC: mute amp left and right */ | |
14828 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14829 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
14830 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
14831 | ||
cb53c626 TI |
14832 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
14833 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
14834 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
14835 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
14836 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
bc9f98a9 | 14837 | |
b60dd394 KY |
14838 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
14839 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
14840 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
14841 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
14842 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
14843 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
bc9f98a9 KY |
14844 | |
14845 | /* Front Pin: output 0 (0x0c) */ | |
14846 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
14847 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14848 | ||
14849 | /* Rear Pin: output 1 (0x0d) */ | |
14850 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
14851 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14852 | ||
14853 | /* CLFE Pin: output 2 (0x0e) */ | |
14854 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
14855 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14856 | ||
14857 | /* Mic (rear) pin: input vref at 80% */ | |
14858 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
14859 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
14860 | /* Front Mic pin: input vref at 80% */ | |
14861 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
14862 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
14863 | /* Line In pin: input */ | |
14864 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
14865 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
14866 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
14867 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
14868 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14869 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
14870 | /* CD pin widget for input */ | |
14871 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
14872 | ||
14873 | /* FIXME: use matrix-type input source selection */ | |
14874 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
14875 | /* Input mixer */ | |
14876 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
14877 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
14878 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
14879 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
291702f0 KY |
14880 | |
14881 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
14882 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
14883 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
14884 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
6dda9f4a KY |
14885 | |
14886 | /* always trun on EAPD */ | |
14887 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
14888 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
14889 | ||
bc9f98a9 KY |
14890 | { } |
14891 | }; | |
14892 | ||
14893 | static struct hda_verb alc662_sue_init_verbs[] = { | |
14894 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT}, | |
14895 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT}, | |
291702f0 KY |
14896 | {} |
14897 | }; | |
14898 | ||
14899 | static struct hda_verb alc662_eeepc_sue_init_verbs[] = { | |
14900 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
14901 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
14902 | {} | |
bc9f98a9 KY |
14903 | }; |
14904 | ||
8c427226 KY |
14905 | /* Set Unsolicited Event*/ |
14906 | static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = { | |
14907 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
14908 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
14909 | {} | |
14910 | }; | |
14911 | ||
bc9f98a9 KY |
14912 | /* |
14913 | * generic initialization of ADC, input mixers and output mixers | |
14914 | */ | |
14915 | static struct hda_verb alc662_auto_init_verbs[] = { | |
14916 | /* | |
14917 | * Unmute ADC and set the default input to mic-in | |
14918 | */ | |
14919 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
14920 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
14921 | ||
14922 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | |
14923 | * mixer widget | |
14924 | * Note: PASD motherboards uses the Line In 2 as the input for front | |
14925 | * panel mic (mic 2) | |
14926 | */ | |
14927 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
14928 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
14929 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
14930 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
14931 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
14932 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
bc9f98a9 KY |
14933 | |
14934 | /* | |
14935 | * Set up output mixers (0x0c - 0x0f) | |
14936 | */ | |
14937 | /* set vol=0 to output mixers */ | |
14938 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14939 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14940 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14941 | ||
14942 | /* set up input amps for analog loopback */ | |
14943 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
b60dd394 KY |
14944 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
14945 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
14946 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
14947 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
14948 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
14949 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
bc9f98a9 KY |
14950 | |
14951 | ||
14952 | /* FIXME: use matrix-type input source selection */ | |
14953 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
14954 | /* Input mixer */ | |
14955 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
d1a991a6 | 14956 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
bc9f98a9 KY |
14957 | { } |
14958 | }; | |
14959 | ||
24fb9173 TI |
14960 | /* additional verbs for ALC663 */ |
14961 | static struct hda_verb alc663_auto_init_verbs[] = { | |
14962 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
14963 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
14964 | { } | |
14965 | }; | |
14966 | ||
6dda9f4a | 14967 | static struct hda_verb alc663_m51va_init_verbs[] = { |
f1d4e28b KY |
14968 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
14969 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
6dda9f4a KY |
14970 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
14971 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
f1d4e28b KY |
14972 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ |
14973 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14974 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)}, | |
14975 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
14976 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
14977 | {} | |
14978 | }; | |
14979 | ||
14980 | static struct hda_verb alc663_21jd_amic_init_verbs[] = { | |
14981 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
14982 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14983 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ | |
14984 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14985 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
14986 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
14987 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
14988 | {} | |
14989 | }; | |
14990 | ||
14991 | static struct hda_verb alc662_1bjd_amic_init_verbs[] = { | |
14992 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
14993 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
14994 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14995 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */ | |
14996 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14997 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
14998 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
14999 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
15000 | {} | |
15001 | }; | |
6dda9f4a | 15002 | |
f1d4e28b KY |
15003 | static struct hda_verb alc663_15jd_amic_init_verbs[] = { |
15004 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15005 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15006 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ | |
15007 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
15008 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15009 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
15010 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
15011 | {} | |
15012 | }; | |
6dda9f4a | 15013 | |
f1d4e28b KY |
15014 | static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = { |
15015 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
15016 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15017 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15018 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */ | |
15019 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15020 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15021 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */ | |
15022 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
15023 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6dda9f4a KY |
15024 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, |
15025 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
f1d4e28b KY |
15026 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, |
15027 | {} | |
15028 | }; | |
15029 | ||
15030 | static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = { | |
15031 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
15032 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15033 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15034 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ | |
15035 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15036 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15037 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ | |
15038 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
15039 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
15040 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
15041 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
15042 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
6dda9f4a KY |
15043 | {} |
15044 | }; | |
15045 | ||
15046 | static struct hda_verb alc663_g71v_init_verbs[] = { | |
15047 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15048 | /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */ | |
15049 | /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */ | |
15050 | ||
15051 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15052 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15053 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */ | |
15054 | ||
15055 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT}, | |
15056 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT}, | |
15057 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT}, | |
15058 | {} | |
15059 | }; | |
15060 | ||
15061 | static struct hda_verb alc663_g50v_init_verbs[] = { | |
15062 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
15063 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
15064 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */ | |
15065 | ||
15066 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
15067 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
15068 | {} | |
15069 | }; | |
15070 | ||
f1d4e28b KY |
15071 | static struct hda_verb alc662_ecs_init_verbs[] = { |
15072 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f}, | |
15073 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
15074 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
15075 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
15076 | {} | |
15077 | }; | |
15078 | ||
bc9f98a9 KY |
15079 | /* capture mixer elements */ |
15080 | static struct snd_kcontrol_new alc662_capture_mixer[] = { | |
15081 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
15082 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
15083 | { | |
15084 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
15085 | /* The multiple "Capture Source" controls confuse alsamixer | |
15086 | * So call somewhat different.. | |
bc9f98a9 KY |
15087 | */ |
15088 | /* .name = "Capture Source", */ | |
15089 | .name = "Input Source", | |
15090 | .count = 1, | |
6e7939bb HRK |
15091 | .info = alc662_mux_enum_info, |
15092 | .get = alc662_mux_enum_get, | |
15093 | .put = alc662_mux_enum_put, | |
bc9f98a9 KY |
15094 | }, |
15095 | { } /* end */ | |
15096 | }; | |
15097 | ||
f1d4e28b KY |
15098 | static struct snd_kcontrol_new alc662_auto_capture_mixer[] = { |
15099 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
15100 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
15101 | { } /* end */ | |
15102 | }; | |
15103 | ||
bc9f98a9 KY |
15104 | static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec) |
15105 | { | |
15106 | unsigned int present; | |
f12ab1e0 | 15107 | unsigned char bits; |
bc9f98a9 KY |
15108 | |
15109 | present = snd_hda_codec_read(codec, 0x14, 0, | |
15110 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
15111 | bits = present ? HDA_AMP_MUTE : 0; |
15112 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
15113 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
15114 | } |
15115 | ||
15116 | static void alc662_lenovo_101e_all_automute(struct hda_codec *codec) | |
15117 | { | |
15118 | unsigned int present; | |
f12ab1e0 | 15119 | unsigned char bits; |
bc9f98a9 KY |
15120 | |
15121 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
15122 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
15123 | bits = present ? HDA_AMP_MUTE : 0; |
15124 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
15125 | HDA_AMP_MUTE, bits); | |
15126 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
15127 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
15128 | } |
15129 | ||
15130 | static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec, | |
15131 | unsigned int res) | |
15132 | { | |
15133 | if ((res >> 26) == ALC880_HP_EVENT) | |
15134 | alc662_lenovo_101e_all_automute(codec); | |
15135 | if ((res >> 26) == ALC880_FRONT_EVENT) | |
15136 | alc662_lenovo_101e_ispeaker_automute(codec); | |
15137 | } | |
15138 | ||
291702f0 KY |
15139 | static void alc662_eeepc_mic_automute(struct hda_codec *codec) |
15140 | { | |
15141 | unsigned int present; | |
15142 | ||
15143 | present = snd_hda_codec_read(codec, 0x18, 0, | |
15144 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
15145 | snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
15146 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | |
15147 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
15148 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | |
15149 | snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
15150 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); | |
15151 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
15152 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); | |
15153 | } | |
15154 | ||
15155 | /* unsolicited event for HP jack sensing */ | |
15156 | static void alc662_eeepc_unsol_event(struct hda_codec *codec, | |
15157 | unsigned int res) | |
15158 | { | |
15159 | if ((res >> 26) == ALC880_HP_EVENT) | |
15160 | alc262_hippo1_automute( codec ); | |
15161 | ||
15162 | if ((res >> 26) == ALC880_MIC_EVENT) | |
15163 | alc662_eeepc_mic_automute(codec); | |
15164 | } | |
15165 | ||
15166 | static void alc662_eeepc_inithook(struct hda_codec *codec) | |
15167 | { | |
15168 | alc262_hippo1_automute( codec ); | |
15169 | alc662_eeepc_mic_automute(codec); | |
15170 | } | |
15171 | ||
8c427226 KY |
15172 | static void alc662_eeepc_ep20_automute(struct hda_codec *codec) |
15173 | { | |
15174 | unsigned int mute; | |
15175 | unsigned int present; | |
15176 | ||
15177 | snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); | |
15178 | present = snd_hda_codec_read(codec, 0x14, 0, | |
15179 | AC_VERB_GET_PIN_SENSE, 0); | |
15180 | present = (present & 0x80000000) != 0; | |
15181 | if (present) { | |
15182 | /* mute internal speaker */ | |
15183 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
ea1fb29a | 15184 | HDA_AMP_MUTE, HDA_AMP_MUTE); |
8c427226 KY |
15185 | } else { |
15186 | /* unmute internal speaker if necessary */ | |
15187 | mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); | |
15188 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
ea1fb29a | 15189 | HDA_AMP_MUTE, mute); |
8c427226 KY |
15190 | } |
15191 | } | |
15192 | ||
15193 | /* unsolicited event for HP jack sensing */ | |
15194 | static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec, | |
15195 | unsigned int res) | |
15196 | { | |
15197 | if ((res >> 26) == ALC880_HP_EVENT) | |
15198 | alc662_eeepc_ep20_automute(codec); | |
15199 | } | |
15200 | ||
15201 | static void alc662_eeepc_ep20_inithook(struct hda_codec *codec) | |
15202 | { | |
15203 | alc662_eeepc_ep20_automute(codec); | |
15204 | } | |
15205 | ||
6dda9f4a KY |
15206 | static void alc663_m51va_speaker_automute(struct hda_codec *codec) |
15207 | { | |
15208 | unsigned int present; | |
15209 | unsigned char bits; | |
15210 | ||
15211 | present = snd_hda_codec_read(codec, 0x21, 0, | |
f1d4e28b KY |
15212 | AC_VERB_GET_PIN_SENSE, 0) |
15213 | & AC_PINSENSE_PRESENCE; | |
6dda9f4a | 15214 | bits = present ? HDA_AMP_MUTE : 0; |
f1d4e28b KY |
15215 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, |
15216 | AMP_IN_MUTE(0), bits); | |
15217 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
15218 | AMP_IN_MUTE(0), bits); | |
15219 | } | |
15220 | ||
15221 | static void alc663_21jd_two_speaker_automute(struct hda_codec *codec) | |
15222 | { | |
15223 | unsigned int present; | |
15224 | unsigned char bits; | |
15225 | ||
15226 | present = snd_hda_codec_read(codec, 0x21, 0, | |
15227 | AC_VERB_GET_PIN_SENSE, 0) | |
15228 | & AC_PINSENSE_PRESENCE; | |
15229 | bits = present ? HDA_AMP_MUTE : 0; | |
15230 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
15231 | AMP_IN_MUTE(0), bits); | |
15232 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
15233 | AMP_IN_MUTE(0), bits); | |
15234 | snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0, | |
15235 | AMP_IN_MUTE(0), bits); | |
15236 | snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1, | |
15237 | AMP_IN_MUTE(0), bits); | |
15238 | } | |
15239 | ||
15240 | static void alc663_15jd_two_speaker_automute(struct hda_codec *codec) | |
15241 | { | |
15242 | unsigned int present; | |
15243 | unsigned char bits; | |
15244 | ||
15245 | present = snd_hda_codec_read(codec, 0x15, 0, | |
15246 | AC_VERB_GET_PIN_SENSE, 0) | |
15247 | & AC_PINSENSE_PRESENCE; | |
15248 | bits = present ? HDA_AMP_MUTE : 0; | |
15249 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
15250 | AMP_IN_MUTE(0), bits); | |
15251 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
15252 | AMP_IN_MUTE(0), bits); | |
15253 | snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0, | |
15254 | AMP_IN_MUTE(0), bits); | |
15255 | snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1, | |
15256 | AMP_IN_MUTE(0), bits); | |
15257 | } | |
15258 | ||
15259 | static void alc662_f5z_speaker_automute(struct hda_codec *codec) | |
15260 | { | |
15261 | unsigned int present; | |
15262 | unsigned char bits; | |
15263 | ||
15264 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
15265 | AC_VERB_GET_PIN_SENSE, 0) | |
15266 | & AC_PINSENSE_PRESENCE; | |
15267 | bits = present ? 0 : PIN_OUT; | |
15268 | snd_hda_codec_write(codec, 0x14, 0, | |
15269 | AC_VERB_SET_PIN_WIDGET_CONTROL, bits); | |
15270 | } | |
15271 | ||
15272 | static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec) | |
15273 | { | |
15274 | unsigned int present1, present2; | |
15275 | ||
15276 | present1 = snd_hda_codec_read(codec, 0x21, 0, | |
15277 | AC_VERB_GET_PIN_SENSE, 0) | |
15278 | & AC_PINSENSE_PRESENCE; | |
15279 | present2 = snd_hda_codec_read(codec, 0x15, 0, | |
15280 | AC_VERB_GET_PIN_SENSE, 0) | |
15281 | & AC_PINSENSE_PRESENCE; | |
15282 | ||
15283 | if (present1 || present2) { | |
15284 | snd_hda_codec_write_cache(codec, 0x14, 0, | |
15285 | AC_VERB_SET_PIN_WIDGET_CONTROL, 0); | |
15286 | } else { | |
15287 | snd_hda_codec_write_cache(codec, 0x14, 0, | |
15288 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | |
15289 | } | |
15290 | } | |
15291 | ||
15292 | static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec) | |
15293 | { | |
15294 | unsigned int present1, present2; | |
15295 | ||
15296 | present1 = snd_hda_codec_read(codec, 0x1b, 0, | |
15297 | AC_VERB_GET_PIN_SENSE, 0) | |
15298 | & AC_PINSENSE_PRESENCE; | |
15299 | present2 = snd_hda_codec_read(codec, 0x15, 0, | |
15300 | AC_VERB_GET_PIN_SENSE, 0) | |
15301 | & AC_PINSENSE_PRESENCE; | |
15302 | ||
15303 | if (present1 || present2) { | |
15304 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
15305 | AMP_IN_MUTE(0), AMP_IN_MUTE(0)); | |
15306 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
15307 | AMP_IN_MUTE(0), AMP_IN_MUTE(0)); | |
15308 | } else { | |
15309 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
15310 | AMP_IN_MUTE(0), 0); | |
15311 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
15312 | AMP_IN_MUTE(0), 0); | |
15313 | } | |
6dda9f4a KY |
15314 | } |
15315 | ||
15316 | static void alc663_m51va_mic_automute(struct hda_codec *codec) | |
15317 | { | |
15318 | unsigned int present; | |
15319 | ||
15320 | present = snd_hda_codec_read(codec, 0x18, 0, | |
ea1fb29a KY |
15321 | AC_VERB_GET_PIN_SENSE, 0) |
15322 | & AC_PINSENSE_PRESENCE; | |
6dda9f4a | 15323 | snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
ea1fb29a | 15324 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); |
6dda9f4a | 15325 | snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
ea1fb29a | 15326 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); |
6dda9f4a | 15327 | snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
ea1fb29a | 15328 | 0x7000 | (0x09 << 8) | (present ? 0x80 : 0)); |
6dda9f4a | 15329 | snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
ea1fb29a | 15330 | 0x7000 | (0x09 << 8) | (present ? 0x80 : 0)); |
6dda9f4a KY |
15331 | } |
15332 | ||
15333 | static void alc663_m51va_unsol_event(struct hda_codec *codec, | |
15334 | unsigned int res) | |
15335 | { | |
15336 | switch (res >> 26) { | |
15337 | case ALC880_HP_EVENT: | |
15338 | alc663_m51va_speaker_automute(codec); | |
15339 | break; | |
15340 | case ALC880_MIC_EVENT: | |
15341 | alc663_m51va_mic_automute(codec); | |
15342 | break; | |
15343 | } | |
15344 | } | |
15345 | ||
15346 | static void alc663_m51va_inithook(struct hda_codec *codec) | |
15347 | { | |
15348 | alc663_m51va_speaker_automute(codec); | |
15349 | alc663_m51va_mic_automute(codec); | |
15350 | } | |
15351 | ||
f1d4e28b KY |
15352 | /* ***************** Mode1 ******************************/ |
15353 | static void alc663_mode1_unsol_event(struct hda_codec *codec, | |
15354 | unsigned int res) | |
15355 | { | |
15356 | switch (res >> 26) { | |
15357 | case ALC880_HP_EVENT: | |
15358 | alc663_m51va_speaker_automute(codec); | |
15359 | break; | |
15360 | case ALC880_MIC_EVENT: | |
15361 | alc662_eeepc_mic_automute(codec); | |
15362 | break; | |
15363 | } | |
15364 | } | |
15365 | ||
15366 | static void alc663_mode1_inithook(struct hda_codec *codec) | |
15367 | { | |
15368 | alc663_m51va_speaker_automute(codec); | |
15369 | alc662_eeepc_mic_automute(codec); | |
15370 | } | |
15371 | /* ***************** Mode2 ******************************/ | |
15372 | static void alc662_mode2_unsol_event(struct hda_codec *codec, | |
15373 | unsigned int res) | |
15374 | { | |
15375 | switch (res >> 26) { | |
15376 | case ALC880_HP_EVENT: | |
15377 | alc662_f5z_speaker_automute(codec); | |
15378 | break; | |
15379 | case ALC880_MIC_EVENT: | |
15380 | alc662_eeepc_mic_automute(codec); | |
15381 | break; | |
15382 | } | |
15383 | } | |
15384 | ||
15385 | static void alc662_mode2_inithook(struct hda_codec *codec) | |
15386 | { | |
15387 | alc662_f5z_speaker_automute(codec); | |
15388 | alc662_eeepc_mic_automute(codec); | |
15389 | } | |
15390 | /* ***************** Mode3 ******************************/ | |
15391 | static void alc663_mode3_unsol_event(struct hda_codec *codec, | |
15392 | unsigned int res) | |
15393 | { | |
15394 | switch (res >> 26) { | |
15395 | case ALC880_HP_EVENT: | |
15396 | alc663_two_hp_m1_speaker_automute(codec); | |
15397 | break; | |
15398 | case ALC880_MIC_EVENT: | |
15399 | alc662_eeepc_mic_automute(codec); | |
15400 | break; | |
15401 | } | |
15402 | } | |
15403 | ||
15404 | static void alc663_mode3_inithook(struct hda_codec *codec) | |
15405 | { | |
15406 | alc663_two_hp_m1_speaker_automute(codec); | |
15407 | alc662_eeepc_mic_automute(codec); | |
15408 | } | |
15409 | /* ***************** Mode4 ******************************/ | |
15410 | static void alc663_mode4_unsol_event(struct hda_codec *codec, | |
15411 | unsigned int res) | |
15412 | { | |
15413 | switch (res >> 26) { | |
15414 | case ALC880_HP_EVENT: | |
15415 | alc663_21jd_two_speaker_automute(codec); | |
15416 | break; | |
15417 | case ALC880_MIC_EVENT: | |
15418 | alc662_eeepc_mic_automute(codec); | |
15419 | break; | |
15420 | } | |
15421 | } | |
15422 | ||
15423 | static void alc663_mode4_inithook(struct hda_codec *codec) | |
15424 | { | |
15425 | alc663_21jd_two_speaker_automute(codec); | |
15426 | alc662_eeepc_mic_automute(codec); | |
15427 | } | |
15428 | /* ***************** Mode5 ******************************/ | |
15429 | static void alc663_mode5_unsol_event(struct hda_codec *codec, | |
15430 | unsigned int res) | |
15431 | { | |
15432 | switch (res >> 26) { | |
15433 | case ALC880_HP_EVENT: | |
15434 | alc663_15jd_two_speaker_automute(codec); | |
15435 | break; | |
15436 | case ALC880_MIC_EVENT: | |
15437 | alc662_eeepc_mic_automute(codec); | |
15438 | break; | |
15439 | } | |
15440 | } | |
15441 | ||
15442 | static void alc663_mode5_inithook(struct hda_codec *codec) | |
15443 | { | |
15444 | alc663_15jd_two_speaker_automute(codec); | |
15445 | alc662_eeepc_mic_automute(codec); | |
15446 | } | |
15447 | /* ***************** Mode6 ******************************/ | |
15448 | static void alc663_mode6_unsol_event(struct hda_codec *codec, | |
15449 | unsigned int res) | |
15450 | { | |
15451 | switch (res >> 26) { | |
15452 | case ALC880_HP_EVENT: | |
15453 | alc663_two_hp_m2_speaker_automute(codec); | |
15454 | break; | |
15455 | case ALC880_MIC_EVENT: | |
15456 | alc662_eeepc_mic_automute(codec); | |
15457 | break; | |
15458 | } | |
15459 | } | |
15460 | ||
15461 | static void alc663_mode6_inithook(struct hda_codec *codec) | |
15462 | { | |
15463 | alc663_two_hp_m2_speaker_automute(codec); | |
15464 | alc662_eeepc_mic_automute(codec); | |
15465 | } | |
15466 | ||
6dda9f4a KY |
15467 | static void alc663_g71v_hp_automute(struct hda_codec *codec) |
15468 | { | |
15469 | unsigned int present; | |
15470 | unsigned char bits; | |
15471 | ||
15472 | present = snd_hda_codec_read(codec, 0x21, 0, | |
15473 | AC_VERB_GET_PIN_SENSE, 0) | |
15474 | & AC_PINSENSE_PRESENCE; | |
15475 | bits = present ? HDA_AMP_MUTE : 0; | |
15476 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
15477 | HDA_AMP_MUTE, bits); | |
15478 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
15479 | HDA_AMP_MUTE, bits); | |
15480 | } | |
15481 | ||
15482 | static void alc663_g71v_front_automute(struct hda_codec *codec) | |
15483 | { | |
15484 | unsigned int present; | |
15485 | unsigned char bits; | |
15486 | ||
15487 | present = snd_hda_codec_read(codec, 0x15, 0, | |
15488 | AC_VERB_GET_PIN_SENSE, 0) | |
15489 | & AC_PINSENSE_PRESENCE; | |
15490 | bits = present ? HDA_AMP_MUTE : 0; | |
15491 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
15492 | HDA_AMP_MUTE, bits); | |
15493 | } | |
15494 | ||
15495 | static void alc663_g71v_unsol_event(struct hda_codec *codec, | |
15496 | unsigned int res) | |
15497 | { | |
15498 | switch (res >> 26) { | |
15499 | case ALC880_HP_EVENT: | |
15500 | alc663_g71v_hp_automute(codec); | |
15501 | break; | |
15502 | case ALC880_FRONT_EVENT: | |
15503 | alc663_g71v_front_automute(codec); | |
15504 | break; | |
15505 | case ALC880_MIC_EVENT: | |
15506 | alc662_eeepc_mic_automute(codec); | |
15507 | break; | |
15508 | } | |
15509 | } | |
15510 | ||
15511 | static void alc663_g71v_inithook(struct hda_codec *codec) | |
15512 | { | |
15513 | alc663_g71v_front_automute(codec); | |
15514 | alc663_g71v_hp_automute(codec); | |
15515 | alc662_eeepc_mic_automute(codec); | |
15516 | } | |
15517 | ||
15518 | static void alc663_g50v_unsol_event(struct hda_codec *codec, | |
15519 | unsigned int res) | |
15520 | { | |
15521 | switch (res >> 26) { | |
15522 | case ALC880_HP_EVENT: | |
15523 | alc663_m51va_speaker_automute(codec); | |
15524 | break; | |
15525 | case ALC880_MIC_EVENT: | |
15526 | alc662_eeepc_mic_automute(codec); | |
15527 | break; | |
15528 | } | |
15529 | } | |
15530 | ||
15531 | static void alc663_g50v_inithook(struct hda_codec *codec) | |
15532 | { | |
15533 | alc663_m51va_speaker_automute(codec); | |
15534 | alc662_eeepc_mic_automute(codec); | |
15535 | } | |
15536 | ||
f1d4e28b KY |
15537 | /* bind hp and internal speaker mute (with plug check) */ |
15538 | static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol, | |
15539 | struct snd_ctl_elem_value *ucontrol) | |
15540 | { | |
15541 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
15542 | long *valp = ucontrol->value.integer.value; | |
15543 | int change; | |
15544 | ||
15545 | change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0, | |
15546 | HDA_AMP_MUTE, | |
15547 | valp[0] ? 0 : HDA_AMP_MUTE); | |
15548 | change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0, | |
15549 | HDA_AMP_MUTE, | |
15550 | valp[1] ? 0 : HDA_AMP_MUTE); | |
15551 | if (change) | |
15552 | alc262_hippo1_automute(codec); | |
15553 | return change; | |
15554 | } | |
15555 | ||
15556 | static struct snd_kcontrol_new alc662_ecs_mixer[] = { | |
15557 | HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
15558 | { | |
15559 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
15560 | .name = "Master Playback Switch", | |
15561 | .info = snd_hda_mixer_amp_switch_info, | |
15562 | .get = snd_hda_mixer_amp_switch_get, | |
15563 | .put = alc662_ecs_master_sw_put, | |
15564 | .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), | |
15565 | }, | |
15566 | ||
15567 | HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT), | |
15568 | HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15569 | HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
15570 | ||
15571 | HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT), | |
15572 | HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
15573 | HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
15574 | { } /* end */ | |
15575 | }; | |
15576 | ||
cb53c626 TI |
15577 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
15578 | #define alc662_loopbacks alc880_loopbacks | |
15579 | #endif | |
15580 | ||
bc9f98a9 KY |
15581 | |
15582 | /* pcm configuration: identiacal with ALC880 */ | |
15583 | #define alc662_pcm_analog_playback alc880_pcm_analog_playback | |
15584 | #define alc662_pcm_analog_capture alc880_pcm_analog_capture | |
15585 | #define alc662_pcm_digital_playback alc880_pcm_digital_playback | |
15586 | #define alc662_pcm_digital_capture alc880_pcm_digital_capture | |
15587 | ||
15588 | /* | |
15589 | * configuration and preset | |
15590 | */ | |
15591 | static const char *alc662_models[ALC662_MODEL_LAST] = { | |
15592 | [ALC662_3ST_2ch_DIG] = "3stack-dig", | |
15593 | [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig", | |
15594 | [ALC662_3ST_6ch] = "3stack-6ch", | |
15595 | [ALC662_5ST_DIG] = "6stack-dig", | |
15596 | [ALC662_LENOVO_101E] = "lenovo-101e", | |
b995d76d | 15597 | [ALC662_ASUS_EEEPC_P701] = "eeepc-p701", |
8c427226 | 15598 | [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20", |
f1d4e28b | 15599 | [ALC662_ECS] = "ecs", |
6dda9f4a KY |
15600 | [ALC663_ASUS_M51VA] = "m51va", |
15601 | [ALC663_ASUS_G71V] = "g71v", | |
15602 | [ALC663_ASUS_H13] = "h13", | |
15603 | [ALC663_ASUS_G50V] = "g50v", | |
f1d4e28b KY |
15604 | [ALC663_ASUS_MODE1] = "asus-mode1", |
15605 | [ALC662_ASUS_MODE2] = "asus-mode2", | |
15606 | [ALC663_ASUS_MODE3] = "asus-mode3", | |
15607 | [ALC663_ASUS_MODE4] = "asus-mode4", | |
15608 | [ALC663_ASUS_MODE5] = "asus-mode5", | |
15609 | [ALC663_ASUS_MODE6] = "asus-mode6", | |
bc9f98a9 KY |
15610 | [ALC662_AUTO] = "auto", |
15611 | }; | |
15612 | ||
15613 | static struct snd_pci_quirk alc662_cfg_tbl[] = { | |
6dda9f4a KY |
15614 | SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA), |
15615 | SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS M51VA", ALC663_ASUS_G50V), | |
3da23cac | 15616 | SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG), |
291702f0 | 15617 | SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701), |
8c427226 | 15618 | SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20), |
f1d4e28b KY |
15619 | SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1), |
15620 | SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1), | |
15621 | SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1), | |
15622 | SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1), | |
15623 | SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1), | |
15624 | SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1), | |
15625 | SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1), | |
15626 | SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1), | |
15627 | SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1), | |
15628 | SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2), | |
15629 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2), | |
15630 | SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2), | |
15631 | SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2), | |
15632 | SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2), | |
15633 | SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2), | |
15634 | SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2), | |
15635 | SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2), | |
15636 | SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2), | |
15637 | SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2), | |
15638 | SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2), | |
15639 | SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2), | |
15640 | SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3), | |
15641 | SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3), | |
15642 | SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3), | |
15643 | SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3), | |
15644 | SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3), | |
15645 | SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4), | |
15646 | SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5), | |
15647 | SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6), | |
15648 | SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6), | |
15649 | SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6), | |
ac3e3741 | 15650 | SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E), |
f1d4e28b KY |
15651 | SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS), |
15652 | SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS), | |
6dda9f4a KY |
15653 | SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13), |
15654 | SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13), | |
15655 | SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13), | |
bc9f98a9 KY |
15656 | {} |
15657 | }; | |
15658 | ||
15659 | static struct alc_config_preset alc662_presets[] = { | |
15660 | [ALC662_3ST_2ch_DIG] = { | |
291702f0 | 15661 | .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer }, |
bc9f98a9 KY |
15662 | .init_verbs = { alc662_init_verbs }, |
15663 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15664 | .dac_nids = alc662_dac_nids, | |
15665 | .dig_out_nid = ALC662_DIGOUT_NID, | |
bc9f98a9 KY |
15666 | .dig_in_nid = ALC662_DIGIN_NID, |
15667 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
15668 | .channel_mode = alc662_3ST_2ch_modes, | |
15669 | .input_mux = &alc662_capture_source, | |
15670 | }, | |
15671 | [ALC662_3ST_6ch_DIG] = { | |
291702f0 KY |
15672 | .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer, |
15673 | alc662_capture_mixer }, | |
bc9f98a9 KY |
15674 | .init_verbs = { alc662_init_verbs }, |
15675 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15676 | .dac_nids = alc662_dac_nids, | |
15677 | .dig_out_nid = ALC662_DIGOUT_NID, | |
bc9f98a9 KY |
15678 | .dig_in_nid = ALC662_DIGIN_NID, |
15679 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), | |
15680 | .channel_mode = alc662_3ST_6ch_modes, | |
15681 | .need_dac_fix = 1, | |
15682 | .input_mux = &alc662_capture_source, | |
f12ab1e0 | 15683 | }, |
bc9f98a9 | 15684 | [ALC662_3ST_6ch] = { |
291702f0 KY |
15685 | .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer, |
15686 | alc662_capture_mixer }, | |
bc9f98a9 KY |
15687 | .init_verbs = { alc662_init_verbs }, |
15688 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15689 | .dac_nids = alc662_dac_nids, | |
bc9f98a9 KY |
15690 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), |
15691 | .channel_mode = alc662_3ST_6ch_modes, | |
15692 | .need_dac_fix = 1, | |
15693 | .input_mux = &alc662_capture_source, | |
f12ab1e0 | 15694 | }, |
bc9f98a9 | 15695 | [ALC662_5ST_DIG] = { |
291702f0 KY |
15696 | .mixers = { alc662_base_mixer, alc662_chmode_mixer, |
15697 | alc662_capture_mixer }, | |
bc9f98a9 KY |
15698 | .init_verbs = { alc662_init_verbs }, |
15699 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15700 | .dac_nids = alc662_dac_nids, | |
15701 | .dig_out_nid = ALC662_DIGOUT_NID, | |
bc9f98a9 KY |
15702 | .dig_in_nid = ALC662_DIGIN_NID, |
15703 | .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes), | |
15704 | .channel_mode = alc662_5stack_modes, | |
15705 | .input_mux = &alc662_capture_source, | |
15706 | }, | |
15707 | [ALC662_LENOVO_101E] = { | |
291702f0 | 15708 | .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer }, |
bc9f98a9 KY |
15709 | .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs }, |
15710 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15711 | .dac_nids = alc662_dac_nids, | |
bc9f98a9 KY |
15712 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
15713 | .channel_mode = alc662_3ST_2ch_modes, | |
15714 | .input_mux = &alc662_lenovo_101e_capture_source, | |
15715 | .unsol_event = alc662_lenovo_101e_unsol_event, | |
15716 | .init_hook = alc662_lenovo_101e_all_automute, | |
15717 | }, | |
291702f0 KY |
15718 | [ALC662_ASUS_EEEPC_P701] = { |
15719 | .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer }, | |
15720 | .init_verbs = { alc662_init_verbs, | |
15721 | alc662_eeepc_sue_init_verbs }, | |
15722 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15723 | .dac_nids = alc662_dac_nids, | |
291702f0 KY |
15724 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
15725 | .channel_mode = alc662_3ST_2ch_modes, | |
15726 | .input_mux = &alc662_eeepc_capture_source, | |
15727 | .unsol_event = alc662_eeepc_unsol_event, | |
15728 | .init_hook = alc662_eeepc_inithook, | |
15729 | }, | |
8c427226 KY |
15730 | [ALC662_ASUS_EEEPC_EP20] = { |
15731 | .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer, | |
15732 | alc662_chmode_mixer }, | |
15733 | .init_verbs = { alc662_init_verbs, | |
15734 | alc662_eeepc_ep20_sue_init_verbs }, | |
15735 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15736 | .dac_nids = alc662_dac_nids, | |
8c427226 KY |
15737 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), |
15738 | .channel_mode = alc662_3ST_6ch_modes, | |
15739 | .input_mux = &alc662_lenovo_101e_capture_source, | |
15740 | .unsol_event = alc662_eeepc_ep20_unsol_event, | |
15741 | .init_hook = alc662_eeepc_ep20_inithook, | |
15742 | }, | |
f1d4e28b KY |
15743 | [ALC662_ECS] = { |
15744 | .mixers = { alc662_ecs_mixer, alc662_capture_mixer }, | |
15745 | .init_verbs = { alc662_init_verbs, | |
15746 | alc662_ecs_init_verbs }, | |
15747 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15748 | .dac_nids = alc662_dac_nids, | |
15749 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
15750 | .channel_mode = alc662_3ST_2ch_modes, | |
15751 | .input_mux = &alc662_eeepc_capture_source, | |
15752 | .unsol_event = alc662_eeepc_unsol_event, | |
15753 | .init_hook = alc662_eeepc_inithook, | |
15754 | }, | |
6dda9f4a KY |
15755 | [ALC663_ASUS_M51VA] = { |
15756 | .mixers = { alc663_m51va_mixer, alc662_capture_mixer}, | |
15757 | .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs }, | |
15758 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15759 | .dac_nids = alc662_dac_nids, | |
15760 | .dig_out_nid = ALC662_DIGOUT_NID, | |
15761 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
15762 | .channel_mode = alc662_3ST_2ch_modes, | |
15763 | .input_mux = &alc663_m51va_capture_source, | |
15764 | .unsol_event = alc663_m51va_unsol_event, | |
15765 | .init_hook = alc663_m51va_inithook, | |
15766 | }, | |
15767 | [ALC663_ASUS_G71V] = { | |
15768 | .mixers = { alc663_g71v_mixer, alc662_capture_mixer}, | |
15769 | .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs }, | |
15770 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15771 | .dac_nids = alc662_dac_nids, | |
15772 | .dig_out_nid = ALC662_DIGOUT_NID, | |
15773 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
15774 | .channel_mode = alc662_3ST_2ch_modes, | |
15775 | .input_mux = &alc662_eeepc_capture_source, | |
15776 | .unsol_event = alc663_g71v_unsol_event, | |
15777 | .init_hook = alc663_g71v_inithook, | |
15778 | }, | |
15779 | [ALC663_ASUS_H13] = { | |
15780 | .mixers = { alc663_m51va_mixer, alc662_capture_mixer}, | |
15781 | .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs }, | |
15782 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15783 | .dac_nids = alc662_dac_nids, | |
15784 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
15785 | .channel_mode = alc662_3ST_2ch_modes, | |
15786 | .input_mux = &alc663_m51va_capture_source, | |
15787 | .unsol_event = alc663_m51va_unsol_event, | |
15788 | .init_hook = alc663_m51va_inithook, | |
15789 | }, | |
15790 | [ALC663_ASUS_G50V] = { | |
15791 | .mixers = { alc663_g50v_mixer, alc662_capture_mixer}, | |
15792 | .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs }, | |
15793 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15794 | .dac_nids = alc662_dac_nids, | |
15795 | .dig_out_nid = ALC662_DIGOUT_NID, | |
15796 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), | |
15797 | .channel_mode = alc662_3ST_6ch_modes, | |
15798 | .input_mux = &alc663_capture_source, | |
15799 | .unsol_event = alc663_g50v_unsol_event, | |
15800 | .init_hook = alc663_g50v_inithook, | |
15801 | }, | |
f1d4e28b KY |
15802 | [ALC663_ASUS_MODE1] = { |
15803 | .mixers = { alc663_m51va_mixer, alc662_auto_capture_mixer }, | |
15804 | .init_verbs = { alc662_init_verbs, | |
15805 | alc663_21jd_amic_init_verbs }, | |
15806 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15807 | .hp_nid = 0x03, | |
15808 | .dac_nids = alc662_dac_nids, | |
15809 | .dig_out_nid = ALC662_DIGOUT_NID, | |
15810 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
15811 | .channel_mode = alc662_3ST_2ch_modes, | |
15812 | .input_mux = &alc662_eeepc_capture_source, | |
15813 | .unsol_event = alc663_mode1_unsol_event, | |
15814 | .init_hook = alc663_mode1_inithook, | |
15815 | }, | |
15816 | [ALC662_ASUS_MODE2] = { | |
15817 | .mixers = { alc662_1bjd_mixer, alc662_auto_capture_mixer }, | |
15818 | .init_verbs = { alc662_init_verbs, | |
15819 | alc662_1bjd_amic_init_verbs }, | |
15820 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15821 | .dac_nids = alc662_dac_nids, | |
15822 | .dig_out_nid = ALC662_DIGOUT_NID, | |
15823 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
15824 | .channel_mode = alc662_3ST_2ch_modes, | |
15825 | .input_mux = &alc662_eeepc_capture_source, | |
15826 | .unsol_event = alc662_mode2_unsol_event, | |
15827 | .init_hook = alc662_mode2_inithook, | |
15828 | }, | |
15829 | [ALC663_ASUS_MODE3] = { | |
15830 | .mixers = { alc663_two_hp_m1_mixer, alc662_auto_capture_mixer }, | |
15831 | .init_verbs = { alc662_init_verbs, | |
15832 | alc663_two_hp_amic_m1_init_verbs }, | |
15833 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15834 | .hp_nid = 0x03, | |
15835 | .dac_nids = alc662_dac_nids, | |
15836 | .dig_out_nid = ALC662_DIGOUT_NID, | |
15837 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
15838 | .channel_mode = alc662_3ST_2ch_modes, | |
15839 | .input_mux = &alc662_eeepc_capture_source, | |
15840 | .unsol_event = alc663_mode3_unsol_event, | |
15841 | .init_hook = alc663_mode3_inithook, | |
15842 | }, | |
15843 | [ALC663_ASUS_MODE4] = { | |
15844 | .mixers = { alc663_asus_21jd_clfe_mixer, | |
15845 | alc662_auto_capture_mixer}, | |
15846 | .init_verbs = { alc662_init_verbs, | |
15847 | alc663_21jd_amic_init_verbs}, | |
15848 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15849 | .hp_nid = 0x03, | |
15850 | .dac_nids = alc662_dac_nids, | |
15851 | .dig_out_nid = ALC662_DIGOUT_NID, | |
15852 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
15853 | .channel_mode = alc662_3ST_2ch_modes, | |
15854 | .input_mux = &alc662_eeepc_capture_source, | |
15855 | .unsol_event = alc663_mode4_unsol_event, | |
15856 | .init_hook = alc663_mode4_inithook, | |
15857 | }, | |
15858 | [ALC663_ASUS_MODE5] = { | |
15859 | .mixers = { alc663_asus_15jd_clfe_mixer, | |
15860 | alc662_auto_capture_mixer }, | |
15861 | .init_verbs = { alc662_init_verbs, | |
15862 | alc663_15jd_amic_init_verbs }, | |
15863 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15864 | .hp_nid = 0x03, | |
15865 | .dac_nids = alc662_dac_nids, | |
15866 | .dig_out_nid = ALC662_DIGOUT_NID, | |
15867 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
15868 | .channel_mode = alc662_3ST_2ch_modes, | |
15869 | .input_mux = &alc662_eeepc_capture_source, | |
15870 | .unsol_event = alc663_mode5_unsol_event, | |
15871 | .init_hook = alc663_mode5_inithook, | |
15872 | }, | |
15873 | [ALC663_ASUS_MODE6] = { | |
15874 | .mixers = { alc663_two_hp_m2_mixer, alc662_auto_capture_mixer }, | |
15875 | .init_verbs = { alc662_init_verbs, | |
15876 | alc663_two_hp_amic_m2_init_verbs }, | |
15877 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15878 | .hp_nid = 0x03, | |
15879 | .dac_nids = alc662_dac_nids, | |
15880 | .dig_out_nid = ALC662_DIGOUT_NID, | |
15881 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
15882 | .channel_mode = alc662_3ST_2ch_modes, | |
15883 | .input_mux = &alc662_eeepc_capture_source, | |
15884 | .unsol_event = alc663_mode6_unsol_event, | |
15885 | .init_hook = alc663_mode6_inithook, | |
15886 | }, | |
bc9f98a9 KY |
15887 | }; |
15888 | ||
15889 | ||
15890 | /* | |
15891 | * BIOS auto configuration | |
15892 | */ | |
15893 | ||
15894 | /* add playback controls from the parsed DAC table */ | |
15895 | static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec, | |
15896 | const struct auto_pin_cfg *cfg) | |
15897 | { | |
15898 | char name[32]; | |
15899 | static const char *chname[4] = { | |
15900 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
15901 | }; | |
15902 | hda_nid_t nid; | |
15903 | int i, err; | |
15904 | ||
15905 | for (i = 0; i < cfg->line_outs; i++) { | |
15906 | if (!spec->multiout.dac_nids[i]) | |
15907 | continue; | |
b60dd394 | 15908 | nid = alc880_idx_to_dac(i); |
bc9f98a9 KY |
15909 | if (i == 2) { |
15910 | /* Center/LFE */ | |
15911 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
15912 | "Center Playback Volume", | |
f12ab1e0 TI |
15913 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, |
15914 | HDA_OUTPUT)); | |
bc9f98a9 KY |
15915 | if (err < 0) |
15916 | return err; | |
15917 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
15918 | "LFE Playback Volume", | |
f12ab1e0 TI |
15919 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, |
15920 | HDA_OUTPUT)); | |
bc9f98a9 KY |
15921 | if (err < 0) |
15922 | return err; | |
15923 | err = add_control(spec, ALC_CTL_BIND_MUTE, | |
15924 | "Center Playback Switch", | |
f12ab1e0 TI |
15925 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, |
15926 | HDA_INPUT)); | |
bc9f98a9 KY |
15927 | if (err < 0) |
15928 | return err; | |
15929 | err = add_control(spec, ALC_CTL_BIND_MUTE, | |
15930 | "LFE Playback Switch", | |
f12ab1e0 TI |
15931 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, |
15932 | HDA_INPUT)); | |
bc9f98a9 KY |
15933 | if (err < 0) |
15934 | return err; | |
15935 | } else { | |
15936 | sprintf(name, "%s Playback Volume", chname[i]); | |
15937 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
f12ab1e0 TI |
15938 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, |
15939 | HDA_OUTPUT)); | |
bc9f98a9 KY |
15940 | if (err < 0) |
15941 | return err; | |
15942 | sprintf(name, "%s Playback Switch", chname[i]); | |
15943 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | |
f12ab1e0 TI |
15944 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, |
15945 | HDA_INPUT)); | |
bc9f98a9 KY |
15946 | if (err < 0) |
15947 | return err; | |
15948 | } | |
15949 | } | |
15950 | return 0; | |
15951 | } | |
15952 | ||
15953 | /* add playback controls for speaker and HP outputs */ | |
15954 | static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, | |
15955 | const char *pfx) | |
15956 | { | |
15957 | hda_nid_t nid; | |
15958 | int err; | |
15959 | char name[32]; | |
15960 | ||
15961 | if (!pin) | |
15962 | return 0; | |
15963 | ||
24fb9173 TI |
15964 | if (pin == 0x17) { |
15965 | /* ALC663 has a mono output pin on 0x17 */ | |
15966 | sprintf(name, "%s Playback Switch", pfx); | |
15967 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | |
15968 | HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT)); | |
15969 | return err; | |
15970 | } | |
15971 | ||
bc9f98a9 KY |
15972 | if (alc880_is_fixed_pin(pin)) { |
15973 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
15974 | /* printk("DAC nid=%x\n",nid); */ | |
15975 | /* specify the DAC as the extra output */ | |
15976 | if (!spec->multiout.hp_nid) | |
15977 | spec->multiout.hp_nid = nid; | |
15978 | else | |
15979 | spec->multiout.extra_out_nid[0] = nid; | |
15980 | /* control HP volume/switch on the output mixer amp */ | |
15981 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
15982 | sprintf(name, "%s Playback Volume", pfx); | |
15983 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
15984 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
15985 | if (err < 0) | |
15986 | return err; | |
15987 | sprintf(name, "%s Playback Switch", pfx); | |
15988 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | |
15989 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); | |
15990 | if (err < 0) | |
15991 | return err; | |
15992 | } else if (alc880_is_multi_pin(pin)) { | |
15993 | /* set manual connection */ | |
15994 | /* we have only a switch on HP-out PIN */ | |
15995 | sprintf(name, "%s Playback Switch", pfx); | |
15996 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | |
15997 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
15998 | if (err < 0) | |
15999 | return err; | |
16000 | } | |
16001 | return 0; | |
16002 | } | |
16003 | ||
16004 | /* create playback/capture controls for input pins */ | |
16005 | static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec, | |
16006 | const struct auto_pin_cfg *cfg) | |
16007 | { | |
16008 | struct hda_input_mux *imux = &spec->private_imux; | |
16009 | int i, err, idx; | |
16010 | ||
16011 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
16012 | if (alc880_is_input_pin(cfg->input_pins[i])) { | |
16013 | idx = alc880_input_pin_idx(cfg->input_pins[i]); | |
16014 | err = new_analog_input(spec, cfg->input_pins[i], | |
16015 | auto_pin_cfg_labels[i], | |
16016 | idx, 0x0b); | |
16017 | if (err < 0) | |
16018 | return err; | |
16019 | imux->items[imux->num_items].label = | |
16020 | auto_pin_cfg_labels[i]; | |
16021 | imux->items[imux->num_items].index = | |
16022 | alc880_input_pin_idx(cfg->input_pins[i]); | |
16023 | imux->num_items++; | |
16024 | } | |
16025 | } | |
16026 | return 0; | |
16027 | } | |
16028 | ||
16029 | static void alc662_auto_set_output_and_unmute(struct hda_codec *codec, | |
16030 | hda_nid_t nid, int pin_type, | |
16031 | int dac_idx) | |
16032 | { | |
f6c7e546 | 16033 | alc_set_pin_output(codec, nid, pin_type); |
bc9f98a9 KY |
16034 | /* need the manual connection? */ |
16035 | if (alc880_is_multi_pin(nid)) { | |
16036 | struct alc_spec *spec = codec->spec; | |
16037 | int idx = alc880_multi_pin_idx(nid); | |
16038 | snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, | |
16039 | AC_VERB_SET_CONNECT_SEL, | |
16040 | alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); | |
16041 | } | |
16042 | } | |
16043 | ||
16044 | static void alc662_auto_init_multi_out(struct hda_codec *codec) | |
16045 | { | |
16046 | struct alc_spec *spec = codec->spec; | |
16047 | int i; | |
16048 | ||
8c427226 | 16049 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
bc9f98a9 KY |
16050 | for (i = 0; i <= HDA_SIDE; i++) { |
16051 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 16052 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
bc9f98a9 | 16053 | if (nid) |
baba8ee9 | 16054 | alc662_auto_set_output_and_unmute(codec, nid, pin_type, |
bc9f98a9 KY |
16055 | i); |
16056 | } | |
16057 | } | |
16058 | ||
16059 | static void alc662_auto_init_hp_out(struct hda_codec *codec) | |
16060 | { | |
16061 | struct alc_spec *spec = codec->spec; | |
16062 | hda_nid_t pin; | |
16063 | ||
16064 | pin = spec->autocfg.hp_pins[0]; | |
16065 | if (pin) /* connect to front */ | |
16066 | /* use dac 0 */ | |
16067 | alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
f6c7e546 TI |
16068 | pin = spec->autocfg.speaker_pins[0]; |
16069 | if (pin) | |
16070 | alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
bc9f98a9 KY |
16071 | } |
16072 | ||
16073 | #define alc662_is_input_pin(nid) alc880_is_input_pin(nid) | |
16074 | #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID | |
16075 | ||
16076 | static void alc662_auto_init_analog_input(struct hda_codec *codec) | |
16077 | { | |
16078 | struct alc_spec *spec = codec->spec; | |
16079 | int i; | |
16080 | ||
16081 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
16082 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
16083 | if (alc662_is_input_pin(nid)) { | |
16084 | snd_hda_codec_write(codec, nid, 0, | |
16085 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
16086 | (i <= AUTO_PIN_FRONT_MIC ? | |
16087 | PIN_VREF80 : PIN_IN)); | |
16088 | if (nid != ALC662_PIN_CD_NID) | |
16089 | snd_hda_codec_write(codec, nid, 0, | |
16090 | AC_VERB_SET_AMP_GAIN_MUTE, | |
16091 | AMP_OUT_MUTE); | |
16092 | } | |
16093 | } | |
16094 | } | |
16095 | ||
f511b01c TI |
16096 | #define alc662_auto_init_input_src alc882_auto_init_input_src |
16097 | ||
bc9f98a9 KY |
16098 | static int alc662_parse_auto_config(struct hda_codec *codec) |
16099 | { | |
16100 | struct alc_spec *spec = codec->spec; | |
16101 | int err; | |
16102 | static hda_nid_t alc662_ignore[] = { 0x1d, 0 }; | |
16103 | ||
16104 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | |
16105 | alc662_ignore); | |
16106 | if (err < 0) | |
16107 | return err; | |
16108 | if (!spec->autocfg.line_outs) | |
16109 | return 0; /* can't find valid BIOS pin config */ | |
16110 | ||
f12ab1e0 TI |
16111 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
16112 | if (err < 0) | |
16113 | return err; | |
16114 | err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
16115 | if (err < 0) | |
16116 | return err; | |
16117 | err = alc662_auto_create_extra_out(spec, | |
16118 | spec->autocfg.speaker_pins[0], | |
16119 | "Speaker"); | |
16120 | if (err < 0) | |
16121 | return err; | |
16122 | err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], | |
16123 | "Headphone"); | |
16124 | if (err < 0) | |
16125 | return err; | |
16126 | err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
16127 | if (err < 0) | |
bc9f98a9 KY |
16128 | return err; |
16129 | ||
16130 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
16131 | ||
16132 | if (spec->autocfg.dig_out_pin) | |
16133 | spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; | |
16134 | ||
16135 | if (spec->kctl_alloc) | |
16136 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
16137 | ||
16138 | spec->num_mux_defs = 1; | |
16139 | spec->input_mux = &spec->private_imux; | |
ea1fb29a | 16140 | |
8c87286f | 16141 | spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs; |
24fb9173 TI |
16142 | if (codec->vendor_id == 0x10ec0663) |
16143 | spec->init_verbs[spec->num_init_verbs++] = | |
16144 | alc663_auto_init_verbs; | |
ee979a14 TI |
16145 | |
16146 | err = alc_auto_add_mic_boost(codec); | |
16147 | if (err < 0) | |
16148 | return err; | |
16149 | ||
bc9f98a9 KY |
16150 | spec->mixers[spec->num_mixers] = alc662_capture_mixer; |
16151 | spec->num_mixers++; | |
8c87286f | 16152 | return 1; |
bc9f98a9 KY |
16153 | } |
16154 | ||
16155 | /* additional initialization for auto-configuration model */ | |
16156 | static void alc662_auto_init(struct hda_codec *codec) | |
16157 | { | |
f6c7e546 | 16158 | struct alc_spec *spec = codec->spec; |
bc9f98a9 KY |
16159 | alc662_auto_init_multi_out(codec); |
16160 | alc662_auto_init_hp_out(codec); | |
16161 | alc662_auto_init_analog_input(codec); | |
f511b01c | 16162 | alc662_auto_init_input_src(codec); |
f6c7e546 TI |
16163 | if (spec->unsol_event) |
16164 | alc_sku_automute(codec); | |
bc9f98a9 KY |
16165 | } |
16166 | ||
16167 | static int patch_alc662(struct hda_codec *codec) | |
16168 | { | |
16169 | struct alc_spec *spec; | |
16170 | int err, board_config; | |
16171 | ||
16172 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
16173 | if (!spec) | |
16174 | return -ENOMEM; | |
16175 | ||
16176 | codec->spec = spec; | |
16177 | ||
2c3bf9ab TI |
16178 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
16179 | ||
bc9f98a9 KY |
16180 | board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST, |
16181 | alc662_models, | |
16182 | alc662_cfg_tbl); | |
16183 | if (board_config < 0) { | |
16184 | printk(KERN_INFO "hda_codec: Unknown model for ALC662, " | |
16185 | "trying auto-probe from BIOS...\n"); | |
16186 | board_config = ALC662_AUTO; | |
16187 | } | |
16188 | ||
16189 | if (board_config == ALC662_AUTO) { | |
16190 | /* automatic parse from the BIOS config */ | |
16191 | err = alc662_parse_auto_config(codec); | |
16192 | if (err < 0) { | |
16193 | alc_free(codec); | |
16194 | return err; | |
8c87286f | 16195 | } else if (!err) { |
bc9f98a9 KY |
16196 | printk(KERN_INFO |
16197 | "hda_codec: Cannot set up configuration " | |
16198 | "from BIOS. Using base mode...\n"); | |
16199 | board_config = ALC662_3ST_2ch_DIG; | |
16200 | } | |
16201 | } | |
16202 | ||
16203 | if (board_config != ALC662_AUTO) | |
16204 | setup_preset(spec, &alc662_presets[board_config]); | |
16205 | ||
6dda9f4a KY |
16206 | if (codec->vendor_id == 0x10ec0663) { |
16207 | spec->stream_name_analog = "ALC663 Analog"; | |
16208 | spec->stream_name_digital = "ALC663 Digital"; | |
16209 | } else { | |
16210 | spec->stream_name_analog = "ALC662 Analog"; | |
16211 | spec->stream_name_digital = "ALC662 Digital"; | |
16212 | } | |
16213 | ||
bc9f98a9 KY |
16214 | spec->stream_analog_playback = &alc662_pcm_analog_playback; |
16215 | spec->stream_analog_capture = &alc662_pcm_analog_capture; | |
16216 | ||
bc9f98a9 KY |
16217 | spec->stream_digital_playback = &alc662_pcm_digital_playback; |
16218 | spec->stream_digital_capture = &alc662_pcm_digital_capture; | |
16219 | ||
e1406348 TI |
16220 | spec->adc_nids = alc662_adc_nids; |
16221 | spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids); | |
16222 | spec->capsrc_nids = alc662_capsrc_nids; | |
bc9f98a9 | 16223 | |
2134ea4f TI |
16224 | spec->vmaster_nid = 0x02; |
16225 | ||
bc9f98a9 KY |
16226 | codec->patch_ops = alc_patch_ops; |
16227 | if (board_config == ALC662_AUTO) | |
16228 | spec->init_hook = alc662_auto_init; | |
cb53c626 TI |
16229 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
16230 | if (!spec->loopback.amplist) | |
16231 | spec->loopback.amplist = alc662_loopbacks; | |
16232 | #endif | |
bc9f98a9 KY |
16233 | |
16234 | return 0; | |
16235 | } | |
16236 | ||
1da177e4 LT |
16237 | /* |
16238 | * patch entries | |
16239 | */ | |
16240 | struct hda_codec_preset snd_hda_preset_realtek[] = { | |
16241 | { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, | |
df694daa | 16242 | { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, |
f6a92248 | 16243 | { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, |
a361d84b | 16244 | { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, |
f6a92248 | 16245 | { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 }, |
f32610ed | 16246 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", |
bc9f98a9 | 16247 | .patch = patch_alc861 }, |
f32610ed JS |
16248 | { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, |
16249 | { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, | |
16250 | { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, | |
bc9f98a9 KY |
16251 | { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", |
16252 | .patch = patch_alc883 }, | |
16253 | { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", | |
16254 | .patch = patch_alc662 }, | |
6dda9f4a | 16255 | { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, |
f32610ed | 16256 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
1da177e4 | 16257 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, |
9c7f852e | 16258 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 }, |
cb308f97 | 16259 | { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", |
7943a8ab | 16260 | .patch = patch_alc882 }, /* should be patch_alc883() in future */ |
df694daa | 16261 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, |
9c7f852e | 16262 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 }, |
f6a92248 | 16263 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 }, |
1da177e4 LT |
16264 | {} /* terminator */ |
16265 | }; |