]>
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, | |
df694daa KY |
75 | ALC260_HP_3013, |
76 | ALC260_FUJITSU_S702X, | |
0bfc90e9 | 77 | ALC260_ACER, |
bc9f98a9 KY |
78 | ALC260_WILL, |
79 | ALC260_REPLACER_672V, | |
7cf51e48 JW |
80 | #ifdef CONFIG_SND_DEBUG |
81 | ALC260_TEST, | |
82 | #endif | |
df694daa | 83 | ALC260_AUTO, |
16ded525 | 84 | ALC260_MODEL_LAST /* last tag */ |
1da177e4 LT |
85 | }; |
86 | ||
df694daa KY |
87 | /* ALC262 models */ |
88 | enum { | |
89 | ALC262_BASIC, | |
ccc656ce KY |
90 | ALC262_HIPPO, |
91 | ALC262_HIPPO_1, | |
834be88d | 92 | ALC262_FUJITSU, |
9c7f852e | 93 | ALC262_HP_BPC, |
cd7509a4 KY |
94 | ALC262_HP_BPC_D7000_WL, |
95 | ALC262_HP_BPC_D7000_WF, | |
66d2a9d6 | 96 | ALC262_HP_TC_T5735, |
8c427226 | 97 | ALC262_HP_RP5700, |
304dcaac | 98 | ALC262_BENQ_ED8, |
272a527c | 99 | ALC262_SONY_ASSAMD, |
83c34218 | 100 | ALC262_BENQ_T31, |
f651b50b | 101 | ALC262_ULTRA, |
0e31daf7 | 102 | ALC262_LENOVO_3000, |
df694daa KY |
103 | ALC262_AUTO, |
104 | ALC262_MODEL_LAST /* last tag */ | |
105 | }; | |
106 | ||
a361d84b KY |
107 | /* ALC268 models */ |
108 | enum { | |
eb5a6621 | 109 | ALC267_QUANTA_IL1, |
a361d84b | 110 | ALC268_3ST, |
d1a991a6 | 111 | ALC268_TOSHIBA, |
d273809e | 112 | ALC268_ACER, |
3866f0b0 | 113 | ALC268_DELL, |
f12462c5 | 114 | ALC268_ZEPTO, |
86c53bd2 JW |
115 | #ifdef CONFIG_SND_DEBUG |
116 | ALC268_TEST, | |
117 | #endif | |
a361d84b KY |
118 | ALC268_AUTO, |
119 | ALC268_MODEL_LAST /* last tag */ | |
120 | }; | |
121 | ||
f6a92248 KY |
122 | /* ALC269 models */ |
123 | enum { | |
124 | ALC269_BASIC, | |
f53281e6 KY |
125 | ALC269_ASUS_EEEPC_P703, |
126 | ALC269_ASUS_EEEPC_P901, | |
f6a92248 KY |
127 | ALC269_AUTO, |
128 | ALC269_MODEL_LAST /* last tag */ | |
129 | }; | |
130 | ||
df694daa KY |
131 | /* ALC861 models */ |
132 | enum { | |
133 | ALC861_3ST, | |
9c7f852e | 134 | ALC660_3ST, |
df694daa KY |
135 | ALC861_3ST_DIG, |
136 | ALC861_6ST_DIG, | |
22309c3e | 137 | ALC861_UNIWILL_M31, |
a53d1aec | 138 | ALC861_TOSHIBA, |
7cdbff94 | 139 | ALC861_ASUS, |
56bb0cab | 140 | ALC861_ASUS_LAPTOP, |
df694daa KY |
141 | ALC861_AUTO, |
142 | ALC861_MODEL_LAST, | |
143 | }; | |
144 | ||
f32610ed JS |
145 | /* ALC861-VD models */ |
146 | enum { | |
147 | ALC660VD_3ST, | |
6963f84c | 148 | ALC660VD_3ST_DIG, |
f32610ed JS |
149 | ALC861VD_3ST, |
150 | ALC861VD_3ST_DIG, | |
151 | ALC861VD_6ST_DIG, | |
bdd148a3 | 152 | ALC861VD_LENOVO, |
272a527c | 153 | ALC861VD_DALLAS, |
d1a991a6 | 154 | ALC861VD_HP, |
f32610ed JS |
155 | ALC861VD_AUTO, |
156 | ALC861VD_MODEL_LAST, | |
157 | }; | |
158 | ||
bc9f98a9 KY |
159 | /* ALC662 models */ |
160 | enum { | |
161 | ALC662_3ST_2ch_DIG, | |
162 | ALC662_3ST_6ch_DIG, | |
163 | ALC662_3ST_6ch, | |
164 | ALC662_5ST_DIG, | |
165 | ALC662_LENOVO_101E, | |
291702f0 | 166 | ALC662_ASUS_EEEPC_P701, |
8c427226 | 167 | ALC662_ASUS_EEEPC_EP20, |
6dda9f4a KY |
168 | ALC663_ASUS_M51VA, |
169 | ALC663_ASUS_G71V, | |
170 | ALC663_ASUS_H13, | |
171 | ALC663_ASUS_G50V, | |
bc9f98a9 KY |
172 | ALC662_AUTO, |
173 | ALC662_MODEL_LAST, | |
174 | }; | |
175 | ||
df694daa KY |
176 | /* ALC882 models */ |
177 | enum { | |
178 | ALC882_3ST_DIG, | |
179 | ALC882_6ST_DIG, | |
4b146cb0 | 180 | ALC882_ARIMA, |
bdd148a3 | 181 | ALC882_W2JC, |
272a527c KY |
182 | ALC882_TARGA, |
183 | ALC882_ASUS_A7J, | |
914759b7 | 184 | ALC882_ASUS_A7M, |
9102cd1c | 185 | ALC885_MACPRO, |
87350ad0 | 186 | ALC885_MBP3, |
c54728d8 | 187 | ALC885_IMAC24, |
272a527c | 188 | ALC882_AUTO, |
df694daa KY |
189 | ALC882_MODEL_LAST, |
190 | }; | |
191 | ||
9c7f852e TI |
192 | /* ALC883 models */ |
193 | enum { | |
194 | ALC883_3ST_2ch_DIG, | |
195 | ALC883_3ST_6ch_DIG, | |
196 | ALC883_3ST_6ch, | |
197 | ALC883_6ST_DIG, | |
ccc656ce KY |
198 | ALC883_TARGA_DIG, |
199 | ALC883_TARGA_2ch_DIG, | |
bab282b9 | 200 | ALC883_ACER, |
2880a867 | 201 | ALC883_ACER_ASPIRE, |
c07584c8 | 202 | ALC883_MEDION, |
272a527c | 203 | ALC883_MEDION_MD2, |
b373bdeb | 204 | ALC883_LAPTOP_EAPD, |
bc9f98a9 | 205 | ALC883_LENOVO_101E_2ch, |
272a527c | 206 | ALC883_LENOVO_NB0763, |
189609ae KY |
207 | ALC888_LENOVO_MS7195_DIG, |
208 | ALC883_HAIER_W66, | |
4723c022 | 209 | ALC888_3ST_HP, |
5795b9e6 | 210 | ALC888_6ST_DELL, |
a8848bd6 | 211 | ALC883_MITAC, |
0c4cc443 | 212 | ALC883_CLEVO_M720, |
fb97dc67 | 213 | ALC883_FUJITSU_PI2515, |
17bba1b7 | 214 | ALC883_3ST_6ch_INTEL, |
9c7f852e TI |
215 | ALC883_AUTO, |
216 | ALC883_MODEL_LAST, | |
217 | }; | |
218 | ||
df694daa KY |
219 | /* for GPIO Poll */ |
220 | #define GPIO_MASK 0x03 | |
221 | ||
1da177e4 LT |
222 | struct alc_spec { |
223 | /* codec parameterization */ | |
df694daa | 224 | struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ |
1da177e4 LT |
225 | unsigned int num_mixers; |
226 | ||
df694daa | 227 | const struct hda_verb *init_verbs[5]; /* initialization verbs |
9c7f852e TI |
228 | * don't forget NULL |
229 | * termination! | |
e9edcee0 TI |
230 | */ |
231 | unsigned int num_init_verbs; | |
1da177e4 | 232 | |
16ded525 | 233 | char *stream_name_analog; /* analog PCM stream */ |
1da177e4 LT |
234 | struct hda_pcm_stream *stream_analog_playback; |
235 | struct hda_pcm_stream *stream_analog_capture; | |
6330079f TI |
236 | struct hda_pcm_stream *stream_analog_alt_playback; |
237 | struct hda_pcm_stream *stream_analog_alt_capture; | |
1da177e4 | 238 | |
f12ab1e0 | 239 | char *stream_name_digital; /* digital PCM stream */ |
1da177e4 LT |
240 | struct hda_pcm_stream *stream_digital_playback; |
241 | struct hda_pcm_stream *stream_digital_capture; | |
242 | ||
243 | /* playback */ | |
16ded525 TI |
244 | struct hda_multi_out multiout; /* playback set-up |
245 | * max_channels, dacs must be set | |
246 | * dig_out_nid and hp_nid are optional | |
247 | */ | |
6330079f | 248 | hda_nid_t alt_dac_nid; |
1da177e4 LT |
249 | |
250 | /* capture */ | |
251 | unsigned int num_adc_nids; | |
252 | hda_nid_t *adc_nids; | |
e1406348 | 253 | hda_nid_t *capsrc_nids; |
16ded525 | 254 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
1da177e4 LT |
255 | |
256 | /* capture source */ | |
a1e8d2da | 257 | unsigned int num_mux_defs; |
1da177e4 LT |
258 | const struct hda_input_mux *input_mux; |
259 | unsigned int cur_mux[3]; | |
260 | ||
261 | /* channel model */ | |
d2a6d7dc | 262 | const struct hda_channel_mode *channel_mode; |
1da177e4 | 263 | int num_channel_mode; |
4e195a7b | 264 | int need_dac_fix; |
1da177e4 LT |
265 | |
266 | /* PCM information */ | |
4c5186ed | 267 | struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ |
41e41f1f | 268 | |
e9edcee0 TI |
269 | /* dynamic controls, init_verbs and input_mux */ |
270 | struct auto_pin_cfg autocfg; | |
271 | unsigned int num_kctl_alloc, num_kctl_used; | |
c8b6bf9b | 272 | struct snd_kcontrol_new *kctl_alloc; |
e9edcee0 | 273 | struct hda_input_mux private_imux; |
41923e44 | 274 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
834be88d | 275 | |
ae6b813a TI |
276 | /* hooks */ |
277 | void (*init_hook)(struct hda_codec *codec); | |
278 | void (*unsol_event)(struct hda_codec *codec, unsigned int res); | |
279 | ||
834be88d TI |
280 | /* for pin sensing */ |
281 | unsigned int sense_updated: 1; | |
282 | unsigned int jack_present: 1; | |
bec15c3a | 283 | unsigned int master_sw: 1; |
cb53c626 | 284 | |
2134ea4f TI |
285 | /* for virtual master */ |
286 | hda_nid_t vmaster_nid; | |
cb53c626 TI |
287 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
288 | struct hda_loopback_check loopback; | |
289 | #endif | |
2c3bf9ab TI |
290 | |
291 | /* for PLL fix */ | |
292 | hda_nid_t pll_nid; | |
293 | unsigned int pll_coef_idx, pll_coef_bit; | |
df694daa KY |
294 | }; |
295 | ||
296 | /* | |
297 | * configuration template - to be copied to the spec instance | |
298 | */ | |
299 | struct alc_config_preset { | |
9c7f852e TI |
300 | struct snd_kcontrol_new *mixers[5]; /* should be identical size |
301 | * with spec | |
302 | */ | |
df694daa KY |
303 | const struct hda_verb *init_verbs[5]; |
304 | unsigned int num_dacs; | |
305 | hda_nid_t *dac_nids; | |
306 | hda_nid_t dig_out_nid; /* optional */ | |
307 | hda_nid_t hp_nid; /* optional */ | |
308 | unsigned int num_adc_nids; | |
309 | hda_nid_t *adc_nids; | |
e1406348 | 310 | hda_nid_t *capsrc_nids; |
df694daa KY |
311 | hda_nid_t dig_in_nid; |
312 | unsigned int num_channel_mode; | |
313 | const struct hda_channel_mode *channel_mode; | |
4e195a7b | 314 | int need_dac_fix; |
a1e8d2da | 315 | unsigned int num_mux_defs; |
df694daa | 316 | const struct hda_input_mux *input_mux; |
ae6b813a TI |
317 | void (*unsol_event)(struct hda_codec *, unsigned int); |
318 | void (*init_hook)(struct hda_codec *); | |
cb53c626 TI |
319 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
320 | struct hda_amp_list *loopbacks; | |
321 | #endif | |
1da177e4 LT |
322 | }; |
323 | ||
1da177e4 LT |
324 | |
325 | /* | |
326 | * input MUX handling | |
327 | */ | |
9c7f852e TI |
328 | static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, |
329 | struct snd_ctl_elem_info *uinfo) | |
1da177e4 LT |
330 | { |
331 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
332 | struct alc_spec *spec = codec->spec; | |
a1e8d2da JW |
333 | unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id); |
334 | if (mux_idx >= spec->num_mux_defs) | |
335 | mux_idx = 0; | |
336 | return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo); | |
1da177e4 LT |
337 | } |
338 | ||
9c7f852e TI |
339 | static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, |
340 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
341 | { |
342 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
343 | struct alc_spec *spec = codec->spec; | |
344 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
345 | ||
346 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; | |
347 | return 0; | |
348 | } | |
349 | ||
9c7f852e TI |
350 | static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, |
351 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
352 | { |
353 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
354 | struct alc_spec *spec = codec->spec; | |
355 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
a1e8d2da | 356 | unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; |
e1406348 TI |
357 | hda_nid_t nid = spec->capsrc_nids ? |
358 | spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx]; | |
a1e8d2da | 359 | return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol, |
e1406348 | 360 | nid, &spec->cur_mux[adc_idx]); |
1da177e4 LT |
361 | } |
362 | ||
e9edcee0 | 363 | |
1da177e4 LT |
364 | /* |
365 | * channel mode setting | |
366 | */ | |
9c7f852e TI |
367 | static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, |
368 | struct snd_ctl_elem_info *uinfo) | |
1da177e4 LT |
369 | { |
370 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
371 | struct alc_spec *spec = codec->spec; | |
d2a6d7dc TI |
372 | return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, |
373 | spec->num_channel_mode); | |
1da177e4 LT |
374 | } |
375 | ||
9c7f852e TI |
376 | static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, |
377 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
378 | { |
379 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
380 | struct alc_spec *spec = codec->spec; | |
d2a6d7dc | 381 | return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, |
9c7f852e TI |
382 | spec->num_channel_mode, |
383 | spec->multiout.max_channels); | |
1da177e4 LT |
384 | } |
385 | ||
9c7f852e TI |
386 | static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, |
387 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
388 | { |
389 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
390 | struct alc_spec *spec = codec->spec; | |
4e195a7b TI |
391 | int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, |
392 | spec->num_channel_mode, | |
393 | &spec->multiout.max_channels); | |
bd2033f2 | 394 | if (err >= 0 && spec->need_dac_fix) |
4e195a7b TI |
395 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; |
396 | return err; | |
1da177e4 LT |
397 | } |
398 | ||
a9430dd8 | 399 | /* |
4c5186ed JW |
400 | * Control the mode of pin widget settings via the mixer. "pc" is used |
401 | * instead of "%" to avoid consequences of accidently treating the % as | |
402 | * being part of a format specifier. Maximum allowed length of a value is | |
403 | * 63 characters plus NULL terminator. | |
7cf51e48 JW |
404 | * |
405 | * Note: some retasking pin complexes seem to ignore requests for input | |
406 | * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these | |
407 | * are requested. Therefore order this list so that this behaviour will not | |
408 | * cause problems when mixer clients move through the enum sequentially. | |
a1e8d2da JW |
409 | * NIDs 0x0f and 0x10 have been observed to have this behaviour as of |
410 | * March 2006. | |
4c5186ed JW |
411 | */ |
412 | static char *alc_pin_mode_names[] = { | |
7cf51e48 JW |
413 | "Mic 50pc bias", "Mic 80pc bias", |
414 | "Line in", "Line out", "Headphone out", | |
4c5186ed JW |
415 | }; |
416 | static unsigned char alc_pin_mode_values[] = { | |
7cf51e48 | 417 | PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP, |
4c5186ed JW |
418 | }; |
419 | /* The control can present all 5 options, or it can limit the options based | |
a1e8d2da JW |
420 | * in the pin being assumed to be exclusively an input or an output pin. In |
421 | * addition, "input" pins may or may not process the mic bias option | |
422 | * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to | |
423 | * accept requests for bias as of chip versions up to March 2006) and/or | |
424 | * wiring in the computer. | |
a9430dd8 | 425 | */ |
a1e8d2da JW |
426 | #define ALC_PIN_DIR_IN 0x00 |
427 | #define ALC_PIN_DIR_OUT 0x01 | |
428 | #define ALC_PIN_DIR_INOUT 0x02 | |
429 | #define ALC_PIN_DIR_IN_NOMICBIAS 0x03 | |
430 | #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04 | |
4c5186ed | 431 | |
a1e8d2da | 432 | /* Info about the pin modes supported by the different pin direction modes. |
4c5186ed JW |
433 | * For each direction the minimum and maximum values are given. |
434 | */ | |
a1e8d2da | 435 | static signed char alc_pin_mode_dir_info[5][2] = { |
4c5186ed JW |
436 | { 0, 2 }, /* ALC_PIN_DIR_IN */ |
437 | { 3, 4 }, /* ALC_PIN_DIR_OUT */ | |
438 | { 0, 4 }, /* ALC_PIN_DIR_INOUT */ | |
a1e8d2da JW |
439 | { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */ |
440 | { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */ | |
4c5186ed JW |
441 | }; |
442 | #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0]) | |
443 | #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1]) | |
444 | #define alc_pin_mode_n_items(_dir) \ | |
445 | (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1) | |
446 | ||
9c7f852e TI |
447 | static int alc_pin_mode_info(struct snd_kcontrol *kcontrol, |
448 | struct snd_ctl_elem_info *uinfo) | |
a9430dd8 | 449 | { |
4c5186ed JW |
450 | unsigned int item_num = uinfo->value.enumerated.item; |
451 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; | |
452 | ||
453 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
a9430dd8 | 454 | uinfo->count = 1; |
4c5186ed JW |
455 | uinfo->value.enumerated.items = alc_pin_mode_n_items(dir); |
456 | ||
457 | if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir)) | |
458 | item_num = alc_pin_mode_min(dir); | |
459 | strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]); | |
a9430dd8 JW |
460 | return 0; |
461 | } | |
462 | ||
9c7f852e TI |
463 | static int alc_pin_mode_get(struct snd_kcontrol *kcontrol, |
464 | struct snd_ctl_elem_value *ucontrol) | |
a9430dd8 | 465 | { |
4c5186ed | 466 | unsigned int i; |
a9430dd8 JW |
467 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
468 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
4c5186ed | 469 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
a9430dd8 | 470 | long *valp = ucontrol->value.integer.value; |
9c7f852e TI |
471 | unsigned int pinctl = snd_hda_codec_read(codec, nid, 0, |
472 | AC_VERB_GET_PIN_WIDGET_CONTROL, | |
473 | 0x00); | |
a9430dd8 | 474 | |
4c5186ed JW |
475 | /* Find enumerated value for current pinctl setting */ |
476 | i = alc_pin_mode_min(dir); | |
9c7f852e | 477 | while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir)) |
4c5186ed | 478 | i++; |
9c7f852e | 479 | *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir); |
a9430dd8 JW |
480 | return 0; |
481 | } | |
482 | ||
9c7f852e TI |
483 | static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, |
484 | struct snd_ctl_elem_value *ucontrol) | |
a9430dd8 | 485 | { |
4c5186ed | 486 | signed int change; |
a9430dd8 JW |
487 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
488 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
4c5186ed JW |
489 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
490 | long val = *ucontrol->value.integer.value; | |
9c7f852e TI |
491 | unsigned int pinctl = snd_hda_codec_read(codec, nid, 0, |
492 | AC_VERB_GET_PIN_WIDGET_CONTROL, | |
493 | 0x00); | |
a9430dd8 | 494 | |
f12ab1e0 | 495 | if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir)) |
4c5186ed JW |
496 | val = alc_pin_mode_min(dir); |
497 | ||
498 | change = pinctl != alc_pin_mode_values[val]; | |
cdcd9268 JW |
499 | if (change) { |
500 | /* Set pin mode to that requested */ | |
82beb8fd TI |
501 | snd_hda_codec_write_cache(codec, nid, 0, |
502 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
503 | alc_pin_mode_values[val]); | |
cdcd9268 JW |
504 | |
505 | /* Also enable the retasking pin's input/output as required | |
506 | * for the requested pin mode. Enum values of 2 or less are | |
507 | * input modes. | |
508 | * | |
509 | * Dynamically switching the input/output buffers probably | |
a1e8d2da JW |
510 | * reduces noise slightly (particularly on input) so we'll |
511 | * do it. However, having both input and output buffers | |
512 | * enabled simultaneously doesn't seem to be problematic if | |
513 | * this turns out to be necessary in the future. | |
cdcd9268 JW |
514 | */ |
515 | if (val <= 2) { | |
47fd830a TI |
516 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
517 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
518 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0, | |
519 | HDA_AMP_MUTE, 0); | |
cdcd9268 | 520 | } else { |
47fd830a TI |
521 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0, |
522 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
523 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, | |
524 | HDA_AMP_MUTE, 0); | |
cdcd9268 JW |
525 | } |
526 | } | |
a9430dd8 JW |
527 | return change; |
528 | } | |
529 | ||
4c5186ed | 530 | #define ALC_PIN_MODE(xname, nid, dir) \ |
a9430dd8 | 531 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ |
4c5186ed JW |
532 | .info = alc_pin_mode_info, \ |
533 | .get = alc_pin_mode_get, \ | |
534 | .put = alc_pin_mode_put, \ | |
535 | .private_value = nid | (dir<<16) } | |
df694daa | 536 | |
5c8f858d JW |
537 | /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged |
538 | * together using a mask with more than one bit set. This control is | |
539 | * currently used only by the ALC260 test model. At this stage they are not | |
540 | * needed for any "production" models. | |
541 | */ | |
542 | #ifdef CONFIG_SND_DEBUG | |
a5ce8890 | 543 | #define alc_gpio_data_info snd_ctl_boolean_mono_info |
f12ab1e0 | 544 | |
9c7f852e TI |
545 | static int alc_gpio_data_get(struct snd_kcontrol *kcontrol, |
546 | struct snd_ctl_elem_value *ucontrol) | |
5c8f858d JW |
547 | { |
548 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
549 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
550 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
551 | long *valp = ucontrol->value.integer.value; | |
9c7f852e TI |
552 | unsigned int val = snd_hda_codec_read(codec, nid, 0, |
553 | AC_VERB_GET_GPIO_DATA, 0x00); | |
5c8f858d JW |
554 | |
555 | *valp = (val & mask) != 0; | |
556 | return 0; | |
557 | } | |
9c7f852e TI |
558 | static int alc_gpio_data_put(struct snd_kcontrol *kcontrol, |
559 | struct snd_ctl_elem_value *ucontrol) | |
5c8f858d JW |
560 | { |
561 | signed int change; | |
562 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
563 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
564 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
565 | long val = *ucontrol->value.integer.value; | |
9c7f852e TI |
566 | unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0, |
567 | AC_VERB_GET_GPIO_DATA, | |
568 | 0x00); | |
5c8f858d JW |
569 | |
570 | /* Set/unset the masked GPIO bit(s) as needed */ | |
9c7f852e TI |
571 | change = (val == 0 ? 0 : mask) != (gpio_data & mask); |
572 | if (val == 0) | |
5c8f858d JW |
573 | gpio_data &= ~mask; |
574 | else | |
575 | gpio_data |= mask; | |
82beb8fd TI |
576 | snd_hda_codec_write_cache(codec, nid, 0, |
577 | AC_VERB_SET_GPIO_DATA, gpio_data); | |
5c8f858d JW |
578 | |
579 | return change; | |
580 | } | |
581 | #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \ | |
582 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
583 | .info = alc_gpio_data_info, \ | |
584 | .get = alc_gpio_data_get, \ | |
585 | .put = alc_gpio_data_put, \ | |
586 | .private_value = nid | (mask<<16) } | |
587 | #endif /* CONFIG_SND_DEBUG */ | |
588 | ||
92621f13 JW |
589 | /* A switch control to allow the enabling of the digital IO pins on the |
590 | * ALC260. This is incredibly simplistic; the intention of this control is | |
591 | * to provide something in the test model allowing digital outputs to be | |
592 | * identified if present. If models are found which can utilise these | |
593 | * outputs a more complete mixer control can be devised for those models if | |
594 | * necessary. | |
595 | */ | |
596 | #ifdef CONFIG_SND_DEBUG | |
a5ce8890 | 597 | #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info |
f12ab1e0 | 598 | |
9c7f852e TI |
599 | static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol, |
600 | struct snd_ctl_elem_value *ucontrol) | |
92621f13 JW |
601 | { |
602 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
603 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
604 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
605 | long *valp = ucontrol->value.integer.value; | |
9c7f852e | 606 | unsigned int val = snd_hda_codec_read(codec, nid, 0, |
3982d17e | 607 | AC_VERB_GET_DIGI_CONVERT_1, 0x00); |
92621f13 JW |
608 | |
609 | *valp = (val & mask) != 0; | |
610 | return 0; | |
611 | } | |
9c7f852e TI |
612 | static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol, |
613 | struct snd_ctl_elem_value *ucontrol) | |
92621f13 JW |
614 | { |
615 | signed int change; | |
616 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
617 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
618 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
619 | long val = *ucontrol->value.integer.value; | |
9c7f852e | 620 | unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0, |
3982d17e | 621 | AC_VERB_GET_DIGI_CONVERT_1, |
9c7f852e | 622 | 0x00); |
92621f13 JW |
623 | |
624 | /* Set/unset the masked control bit(s) as needed */ | |
9c7f852e | 625 | change = (val == 0 ? 0 : mask) != (ctrl_data & mask); |
92621f13 JW |
626 | if (val==0) |
627 | ctrl_data &= ~mask; | |
628 | else | |
629 | ctrl_data |= mask; | |
82beb8fd TI |
630 | snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, |
631 | ctrl_data); | |
92621f13 JW |
632 | |
633 | return change; | |
634 | } | |
635 | #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \ | |
636 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
637 | .info = alc_spdif_ctrl_info, \ | |
638 | .get = alc_spdif_ctrl_get, \ | |
639 | .put = alc_spdif_ctrl_put, \ | |
640 | .private_value = nid | (mask<<16) } | |
641 | #endif /* CONFIG_SND_DEBUG */ | |
642 | ||
f8225f6d JW |
643 | /* A switch control to allow the enabling EAPD digital outputs on the ALC26x. |
644 | * Again, this is only used in the ALC26x test models to help identify when | |
645 | * the EAPD line must be asserted for features to work. | |
646 | */ | |
647 | #ifdef CONFIG_SND_DEBUG | |
648 | #define alc_eapd_ctrl_info snd_ctl_boolean_mono_info | |
649 | ||
650 | static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol, | |
651 | struct snd_ctl_elem_value *ucontrol) | |
652 | { | |
653 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
654 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
655 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
656 | long *valp = ucontrol->value.integer.value; | |
657 | unsigned int val = snd_hda_codec_read(codec, nid, 0, | |
658 | AC_VERB_GET_EAPD_BTLENABLE, 0x00); | |
659 | ||
660 | *valp = (val & mask) != 0; | |
661 | return 0; | |
662 | } | |
663 | ||
664 | static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol, | |
665 | struct snd_ctl_elem_value *ucontrol) | |
666 | { | |
667 | int change; | |
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 val = *ucontrol->value.integer.value; | |
672 | unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0, | |
673 | AC_VERB_GET_EAPD_BTLENABLE, | |
674 | 0x00); | |
675 | ||
676 | /* Set/unset the masked control bit(s) as needed */ | |
677 | change = (!val ? 0 : mask) != (ctrl_data & mask); | |
678 | if (!val) | |
679 | ctrl_data &= ~mask; | |
680 | else | |
681 | ctrl_data |= mask; | |
682 | snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, | |
683 | ctrl_data); | |
684 | ||
685 | return change; | |
686 | } | |
687 | ||
688 | #define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \ | |
689 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
690 | .info = alc_eapd_ctrl_info, \ | |
691 | .get = alc_eapd_ctrl_get, \ | |
692 | .put = alc_eapd_ctrl_put, \ | |
693 | .private_value = nid | (mask<<16) } | |
694 | #endif /* CONFIG_SND_DEBUG */ | |
695 | ||
df694daa KY |
696 | /* |
697 | * set up from the preset table | |
698 | */ | |
9c7f852e TI |
699 | static void setup_preset(struct alc_spec *spec, |
700 | const struct alc_config_preset *preset) | |
df694daa KY |
701 | { |
702 | int i; | |
703 | ||
704 | for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++) | |
705 | spec->mixers[spec->num_mixers++] = preset->mixers[i]; | |
9c7f852e TI |
706 | for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; |
707 | i++) | |
708 | spec->init_verbs[spec->num_init_verbs++] = | |
709 | preset->init_verbs[i]; | |
df694daa KY |
710 | |
711 | spec->channel_mode = preset->channel_mode; | |
712 | spec->num_channel_mode = preset->num_channel_mode; | |
4e195a7b | 713 | spec->need_dac_fix = preset->need_dac_fix; |
df694daa KY |
714 | |
715 | spec->multiout.max_channels = spec->channel_mode[0].channels; | |
716 | ||
717 | spec->multiout.num_dacs = preset->num_dacs; | |
718 | spec->multiout.dac_nids = preset->dac_nids; | |
719 | spec->multiout.dig_out_nid = preset->dig_out_nid; | |
720 | spec->multiout.hp_nid = preset->hp_nid; | |
721 | ||
a1e8d2da | 722 | spec->num_mux_defs = preset->num_mux_defs; |
f12ab1e0 | 723 | if (!spec->num_mux_defs) |
a1e8d2da | 724 | spec->num_mux_defs = 1; |
df694daa KY |
725 | spec->input_mux = preset->input_mux; |
726 | ||
727 | spec->num_adc_nids = preset->num_adc_nids; | |
728 | spec->adc_nids = preset->adc_nids; | |
e1406348 | 729 | spec->capsrc_nids = preset->capsrc_nids; |
df694daa | 730 | spec->dig_in_nid = preset->dig_in_nid; |
ae6b813a TI |
731 | |
732 | spec->unsol_event = preset->unsol_event; | |
733 | spec->init_hook = preset->init_hook; | |
cb53c626 TI |
734 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
735 | spec->loopback.amplist = preset->loopbacks; | |
736 | #endif | |
df694daa KY |
737 | } |
738 | ||
bc9f98a9 KY |
739 | /* Enable GPIO mask and set output */ |
740 | static struct hda_verb alc_gpio1_init_verbs[] = { | |
741 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
742 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
743 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, | |
744 | { } | |
745 | }; | |
746 | ||
747 | static struct hda_verb alc_gpio2_init_verbs[] = { | |
748 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, | |
749 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, | |
750 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, | |
751 | { } | |
752 | }; | |
753 | ||
bdd148a3 KY |
754 | static struct hda_verb alc_gpio3_init_verbs[] = { |
755 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, | |
756 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | |
757 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | |
758 | { } | |
759 | }; | |
760 | ||
2c3bf9ab TI |
761 | /* |
762 | * Fix hardware PLL issue | |
763 | * On some codecs, the analog PLL gating control must be off while | |
764 | * the default value is 1. | |
765 | */ | |
766 | static void alc_fix_pll(struct hda_codec *codec) | |
767 | { | |
768 | struct alc_spec *spec = codec->spec; | |
769 | unsigned int val; | |
770 | ||
771 | if (!spec->pll_nid) | |
772 | return; | |
773 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, | |
774 | spec->pll_coef_idx); | |
775 | val = snd_hda_codec_read(codec, spec->pll_nid, 0, | |
776 | AC_VERB_GET_PROC_COEF, 0); | |
777 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, | |
778 | spec->pll_coef_idx); | |
779 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF, | |
780 | val & ~(1 << spec->pll_coef_bit)); | |
781 | } | |
782 | ||
783 | static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, | |
784 | unsigned int coef_idx, unsigned int coef_bit) | |
785 | { | |
786 | struct alc_spec *spec = codec->spec; | |
787 | spec->pll_nid = nid; | |
788 | spec->pll_coef_idx = coef_idx; | |
789 | spec->pll_coef_bit = coef_bit; | |
790 | alc_fix_pll(codec); | |
791 | } | |
792 | ||
c9b58006 KY |
793 | static void alc_sku_automute(struct hda_codec *codec) |
794 | { | |
795 | struct alc_spec *spec = codec->spec; | |
c9b58006 KY |
796 | unsigned int present; |
797 | unsigned int hp_nid = spec->autocfg.hp_pins[0]; | |
798 | unsigned int sp_nid = spec->autocfg.speaker_pins[0]; | |
799 | ||
800 | /* need to execute and sync at first */ | |
801 | snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0); | |
802 | present = snd_hda_codec_read(codec, hp_nid, 0, | |
803 | AC_VERB_GET_PIN_SENSE, 0); | |
804 | spec->jack_present = (present & 0x80000000) != 0; | |
f6c7e546 TI |
805 | snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
806 | spec->jack_present ? 0 : PIN_OUT); | |
c9b58006 KY |
807 | } |
808 | ||
809 | /* unsolicited event for HP jack sensing */ | |
810 | static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) | |
811 | { | |
812 | if (codec->vendor_id == 0x10ec0880) | |
813 | res >>= 28; | |
814 | else | |
815 | res >>= 26; | |
816 | if (res != ALC880_HP_EVENT) | |
817 | return; | |
818 | ||
819 | alc_sku_automute(codec); | |
820 | } | |
821 | ||
f9423e7a KY |
822 | /* additional initialization for ALC888 variants */ |
823 | static void alc888_coef_init(struct hda_codec *codec) | |
824 | { | |
825 | unsigned int tmp; | |
826 | ||
827 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0); | |
828 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); | |
829 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); | |
830 | if ((tmp & 0xf0) == 2) | |
831 | /* alc888S-VC */ | |
832 | snd_hda_codec_read(codec, 0x20, 0, | |
833 | AC_VERB_SET_PROC_COEF, 0x830); | |
834 | else | |
835 | /* alc888-VB */ | |
836 | snd_hda_codec_read(codec, 0x20, 0, | |
837 | AC_VERB_SET_PROC_COEF, 0x3030); | |
838 | } | |
839 | ||
bc9f98a9 KY |
840 | /* 32-bit subsystem ID for BIOS loading in HD Audio codec. |
841 | * 31 ~ 16 : Manufacture ID | |
842 | * 15 ~ 8 : SKU ID | |
843 | * 7 ~ 0 : Assembly ID | |
844 | * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36 | |
845 | */ | |
846 | static void alc_subsystem_id(struct hda_codec *codec, | |
847 | unsigned int porta, unsigned int porte, | |
848 | unsigned int portd) | |
849 | { | |
c9b58006 KY |
850 | unsigned int ass, tmp, i; |
851 | unsigned nid; | |
852 | struct alc_spec *spec = codec->spec; | |
bc9f98a9 | 853 | |
c9b58006 KY |
854 | ass = codec->subsystem_id & 0xffff; |
855 | if ((ass != codec->bus->pci->subsystem_device) && (ass & 1)) | |
856 | goto do_sku; | |
857 | ||
858 | /* | |
859 | * 31~30 : port conetcivity | |
860 | * 29~21 : reserve | |
861 | * 20 : PCBEEP input | |
862 | * 19~16 : Check sum (15:1) | |
863 | * 15~1 : Custom | |
864 | * 0 : override | |
865 | */ | |
866 | nid = 0x1d; | |
867 | if (codec->vendor_id == 0x10ec0260) | |
868 | nid = 0x17; | |
869 | ass = snd_hda_codec_read(codec, nid, 0, | |
870 | AC_VERB_GET_CONFIG_DEFAULT, 0); | |
871 | if (!(ass & 1) && !(ass & 0x100000)) | |
872 | return; | |
873 | if ((ass >> 30) != 1) /* no physical connection */ | |
bc9f98a9 KY |
874 | return; |
875 | ||
c9b58006 KY |
876 | /* check sum */ |
877 | tmp = 0; | |
878 | for (i = 1; i < 16; i++) { | |
8c427226 | 879 | if ((ass >> i) & 1) |
c9b58006 KY |
880 | tmp++; |
881 | } | |
882 | if (((ass >> 16) & 0xf) != tmp) | |
883 | return; | |
884 | do_sku: | |
885 | /* | |
886 | * 0 : override | |
887 | * 1 : Swap Jack | |
888 | * 2 : 0 --> Desktop, 1 --> Laptop | |
889 | * 3~5 : External Amplifier control | |
890 | * 7~6 : Reserved | |
891 | */ | |
bc9f98a9 KY |
892 | tmp = (ass & 0x38) >> 3; /* external Amp control */ |
893 | switch (tmp) { | |
894 | case 1: | |
895 | snd_hda_sequence_write(codec, alc_gpio1_init_verbs); | |
896 | break; | |
897 | case 3: | |
898 | snd_hda_sequence_write(codec, alc_gpio2_init_verbs); | |
899 | break; | |
bdd148a3 KY |
900 | case 7: |
901 | snd_hda_sequence_write(codec, alc_gpio3_init_verbs); | |
902 | break; | |
c9b58006 | 903 | case 5: /* set EAPD output high */ |
bdd148a3 | 904 | switch (codec->vendor_id) { |
c9b58006 KY |
905 | case 0x10ec0260: |
906 | snd_hda_codec_write(codec, 0x0f, 0, | |
907 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
908 | snd_hda_codec_write(codec, 0x10, 0, | |
909 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
910 | break; | |
911 | case 0x10ec0262: | |
bdd148a3 KY |
912 | case 0x10ec0267: |
913 | case 0x10ec0268: | |
c9b58006 | 914 | case 0x10ec0269: |
f9423e7a KY |
915 | case 0x10ec0660: |
916 | case 0x10ec0662: | |
917 | case 0x10ec0663: | |
c9b58006 | 918 | case 0x10ec0862: |
20a3a05d | 919 | case 0x10ec0889: |
bdd148a3 KY |
920 | snd_hda_codec_write(codec, 0x14, 0, |
921 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
922 | snd_hda_codec_write(codec, 0x15, 0, | |
923 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
c9b58006 | 924 | break; |
bdd148a3 | 925 | } |
c9b58006 KY |
926 | switch (codec->vendor_id) { |
927 | case 0x10ec0260: | |
928 | snd_hda_codec_write(codec, 0x1a, 0, | |
929 | AC_VERB_SET_COEF_INDEX, 7); | |
930 | tmp = snd_hda_codec_read(codec, 0x1a, 0, | |
931 | AC_VERB_GET_PROC_COEF, 0); | |
932 | snd_hda_codec_write(codec, 0x1a, 0, | |
933 | AC_VERB_SET_COEF_INDEX, 7); | |
934 | snd_hda_codec_write(codec, 0x1a, 0, | |
935 | AC_VERB_SET_PROC_COEF, | |
936 | tmp | 0x2010); | |
937 | break; | |
938 | case 0x10ec0262: | |
939 | case 0x10ec0880: | |
940 | case 0x10ec0882: | |
941 | case 0x10ec0883: | |
942 | case 0x10ec0885: | |
20a3a05d | 943 | case 0x10ec0889: |
c9b58006 KY |
944 | snd_hda_codec_write(codec, 0x20, 0, |
945 | AC_VERB_SET_COEF_INDEX, 7); | |
946 | tmp = snd_hda_codec_read(codec, 0x20, 0, | |
947 | AC_VERB_GET_PROC_COEF, 0); | |
948 | snd_hda_codec_write(codec, 0x20, 0, | |
949 | AC_VERB_SET_COEF_INDEX, 7); | |
950 | snd_hda_codec_write(codec, 0x20, 0, | |
951 | AC_VERB_SET_PROC_COEF, | |
952 | tmp | 0x2010); | |
953 | break; | |
f9423e7a KY |
954 | case 0x10ec0888: |
955 | alc888_coef_init(codec); | |
956 | break; | |
c9b58006 KY |
957 | case 0x10ec0267: |
958 | case 0x10ec0268: | |
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, | |
964 | AC_VERB_SET_COEF_INDEX, 7); | |
965 | snd_hda_codec_write(codec, 0x20, 0, | |
966 | AC_VERB_SET_PROC_COEF, | |
967 | tmp | 0x3000); | |
968 | break; | |
bc9f98a9 | 969 | } |
c9b58006 | 970 | default: |
bc9f98a9 KY |
971 | break; |
972 | } | |
c9b58006 | 973 | |
8c427226 | 974 | /* is laptop or Desktop and enable the function "Mute internal speaker |
c9b58006 KY |
975 | * when the external headphone out jack is plugged" |
976 | */ | |
8c427226 | 977 | if (!(ass & 0x8000)) |
c9b58006 KY |
978 | return; |
979 | /* | |
980 | * 10~8 : Jack location | |
981 | * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered | |
982 | * 14~13: Resvered | |
983 | * 15 : 1 --> enable the function "Mute internal speaker | |
984 | * when the external headphone out jack is plugged" | |
985 | */ | |
986 | if (!spec->autocfg.speaker_pins[0]) { | |
8c427226 | 987 | if (spec->autocfg.line_out_pins[0]) |
c9b58006 | 988 | spec->autocfg.speaker_pins[0] = |
8c427226 | 989 | spec->autocfg.line_out_pins[0]; |
c9b58006 KY |
990 | else |
991 | return; | |
992 | } | |
993 | ||
994 | if (!spec->autocfg.hp_pins[0]) { | |
995 | tmp = (ass >> 11) & 0x3; /* HP to chassis */ | |
996 | if (tmp == 0) | |
997 | spec->autocfg.hp_pins[0] = porta; | |
998 | else if (tmp == 1) | |
999 | spec->autocfg.hp_pins[0] = porte; | |
1000 | else if (tmp == 2) | |
1001 | spec->autocfg.hp_pins[0] = portd; | |
1002 | else | |
1003 | return; | |
1004 | } | |
1005 | ||
1006 | snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0, | |
1007 | AC_VERB_SET_UNSOLICITED_ENABLE, | |
1008 | AC_USRSP_EN | ALC880_HP_EVENT); | |
1009 | spec->unsol_event = alc_sku_unsol_event; | |
bc9f98a9 KY |
1010 | } |
1011 | ||
f95474ec TI |
1012 | /* |
1013 | * Fix-up pin default configurations | |
1014 | */ | |
1015 | ||
1016 | struct alc_pincfg { | |
1017 | hda_nid_t nid; | |
1018 | u32 val; | |
1019 | }; | |
1020 | ||
1021 | static void alc_fix_pincfg(struct hda_codec *codec, | |
1022 | const struct snd_pci_quirk *quirk, | |
1023 | const struct alc_pincfg **pinfix) | |
1024 | { | |
1025 | const struct alc_pincfg *cfg; | |
1026 | ||
1027 | quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk); | |
1028 | if (!quirk) | |
1029 | return; | |
1030 | ||
1031 | cfg = pinfix[quirk->value]; | |
1032 | for (; cfg->nid; cfg++) { | |
1033 | int i; | |
1034 | u32 val = cfg->val; | |
1035 | for (i = 0; i < 4; i++) { | |
1036 | snd_hda_codec_write(codec, cfg->nid, 0, | |
1037 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i, | |
1038 | val & 0xff); | |
1039 | val >>= 8; | |
1040 | } | |
1041 | } | |
1042 | } | |
1043 | ||
1da177e4 | 1044 | /* |
e9edcee0 TI |
1045 | * ALC880 3-stack model |
1046 | * | |
1047 | * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e) | |
9c7f852e TI |
1048 | * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, |
1049 | * F-Mic = 0x1b, HP = 0x19 | |
1da177e4 LT |
1050 | */ |
1051 | ||
e9edcee0 TI |
1052 | static hda_nid_t alc880_dac_nids[4] = { |
1053 | /* front, rear, clfe, rear_surr */ | |
1054 | 0x02, 0x05, 0x04, 0x03 | |
1055 | }; | |
1056 | ||
1057 | static hda_nid_t alc880_adc_nids[3] = { | |
1058 | /* ADC0-2 */ | |
1059 | 0x07, 0x08, 0x09, | |
1060 | }; | |
1061 | ||
1062 | /* The datasheet says the node 0x07 is connected from inputs, | |
1063 | * but it shows zero connection in the real implementation on some devices. | |
df694daa | 1064 | * Note: this is a 915GAV bug, fixed on 915GLV |
1da177e4 | 1065 | */ |
e9edcee0 TI |
1066 | static hda_nid_t alc880_adc_nids_alt[2] = { |
1067 | /* ADC1-2 */ | |
1068 | 0x08, 0x09, | |
1069 | }; | |
1070 | ||
1071 | #define ALC880_DIGOUT_NID 0x06 | |
1072 | #define ALC880_DIGIN_NID 0x0a | |
1073 | ||
1074 | static struct hda_input_mux alc880_capture_source = { | |
1075 | .num_items = 4, | |
1076 | .items = { | |
1077 | { "Mic", 0x0 }, | |
1078 | { "Front Mic", 0x3 }, | |
1079 | { "Line", 0x2 }, | |
1080 | { "CD", 0x4 }, | |
1081 | }, | |
1082 | }; | |
1083 | ||
1084 | /* channel source setting (2/6 channel selection for 3-stack) */ | |
1085 | /* 2ch mode */ | |
1086 | static struct hda_verb alc880_threestack_ch2_init[] = { | |
1087 | /* set line-in to input, mute it */ | |
1088 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
1089 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
1090 | /* set mic-in to input vref 80%, mute it */ | |
1091 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
1092 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
1093 | { } /* end */ | |
1094 | }; | |
1095 | ||
1096 | /* 6ch mode */ | |
1097 | static struct hda_verb alc880_threestack_ch6_init[] = { | |
1098 | /* set line-in to output, unmute it */ | |
1099 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1100 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1101 | /* set mic-in to output, unmute it */ | |
1102 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1103 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1104 | { } /* end */ | |
1105 | }; | |
1106 | ||
d2a6d7dc | 1107 | static struct hda_channel_mode alc880_threestack_modes[2] = { |
e9edcee0 TI |
1108 | { 2, alc880_threestack_ch2_init }, |
1109 | { 6, alc880_threestack_ch6_init }, | |
1110 | }; | |
1111 | ||
c8b6bf9b | 1112 | static struct snd_kcontrol_new alc880_three_stack_mixer[] = { |
05acb863 | 1113 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1114 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
05acb863 | 1115 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 1116 | HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT), |
05acb863 TI |
1117 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1118 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1119 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1120 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
1da177e4 LT |
1121 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1122 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1123 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1124 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
1125 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1126 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1127 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT), | |
1128 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT), | |
1129 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
1130 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
e9edcee0 TI |
1131 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT), |
1132 | { | |
1133 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1134 | .name = "Channel Mode", | |
df694daa KY |
1135 | .info = alc_ch_mode_info, |
1136 | .get = alc_ch_mode_get, | |
1137 | .put = alc_ch_mode_put, | |
e9edcee0 TI |
1138 | }, |
1139 | { } /* end */ | |
1140 | }; | |
1141 | ||
1142 | /* capture mixer elements */ | |
c8b6bf9b | 1143 | static struct snd_kcontrol_new alc880_capture_mixer[] = { |
e9edcee0 TI |
1144 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), |
1145 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), | |
1146 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), | |
1147 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), | |
1148 | HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), | |
1149 | HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), | |
1da177e4 LT |
1150 | { |
1151 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1152 | /* The multiple "Capture Source" controls confuse alsamixer | |
1153 | * So call somewhat different.. | |
1da177e4 LT |
1154 | */ |
1155 | /* .name = "Capture Source", */ | |
1156 | .name = "Input Source", | |
e9edcee0 | 1157 | .count = 3, |
1da177e4 LT |
1158 | .info = alc_mux_enum_info, |
1159 | .get = alc_mux_enum_get, | |
1160 | .put = alc_mux_enum_put, | |
1161 | }, | |
1da177e4 LT |
1162 | { } /* end */ |
1163 | }; | |
1164 | ||
e9edcee0 | 1165 | /* capture mixer elements (in case NID 0x07 not available) */ |
c8b6bf9b | 1166 | static struct snd_kcontrol_new alc880_capture_alt_mixer[] = { |
71fe7b82 TI |
1167 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
1168 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
1169 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
1170 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
1da177e4 LT |
1171 | { |
1172 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1173 | /* The multiple "Capture Source" controls confuse alsamixer | |
1174 | * So call somewhat different.. | |
1da177e4 LT |
1175 | */ |
1176 | /* .name = "Capture Source", */ | |
1177 | .name = "Input Source", | |
1178 | .count = 2, | |
1179 | .info = alc_mux_enum_info, | |
1180 | .get = alc_mux_enum_get, | |
1181 | .put = alc_mux_enum_put, | |
1182 | }, | |
1da177e4 LT |
1183 | { } /* end */ |
1184 | }; | |
1185 | ||
e9edcee0 TI |
1186 | |
1187 | ||
1188 | /* | |
1189 | * ALC880 5-stack model | |
1190 | * | |
9c7f852e TI |
1191 | * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), |
1192 | * Side = 0x02 (0xd) | |
e9edcee0 TI |
1193 | * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16 |
1194 | * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19 | |
1195 | */ | |
1196 | ||
1197 | /* additional mixers to alc880_three_stack_mixer */ | |
c8b6bf9b | 1198 | static struct snd_kcontrol_new alc880_five_stack_mixer[] = { |
e9edcee0 | 1199 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1200 | HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT), |
1da177e4 LT |
1201 | { } /* end */ |
1202 | }; | |
1203 | ||
e9edcee0 TI |
1204 | /* channel source setting (6/8 channel selection for 5-stack) */ |
1205 | /* 6ch mode */ | |
1206 | static struct hda_verb alc880_fivestack_ch6_init[] = { | |
1207 | /* set line-in to input, mute it */ | |
1208 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
1209 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
dfc0ff62 TI |
1210 | { } /* end */ |
1211 | }; | |
1212 | ||
e9edcee0 TI |
1213 | /* 8ch mode */ |
1214 | static struct hda_verb alc880_fivestack_ch8_init[] = { | |
1215 | /* set line-in to output, unmute it */ | |
1216 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1217 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1218 | { } /* end */ | |
1219 | }; | |
1220 | ||
d2a6d7dc | 1221 | static struct hda_channel_mode alc880_fivestack_modes[2] = { |
e9edcee0 TI |
1222 | { 6, alc880_fivestack_ch6_init }, |
1223 | { 8, alc880_fivestack_ch8_init }, | |
1224 | }; | |
1225 | ||
1226 | ||
1227 | /* | |
1228 | * ALC880 6-stack model | |
1229 | * | |
9c7f852e TI |
1230 | * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), |
1231 | * Side = 0x05 (0x0f) | |
e9edcee0 TI |
1232 | * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17, |
1233 | * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b | |
1234 | */ | |
1235 | ||
1236 | static hda_nid_t alc880_6st_dac_nids[4] = { | |
1237 | /* front, rear, clfe, rear_surr */ | |
1238 | 0x02, 0x03, 0x04, 0x05 | |
f12ab1e0 | 1239 | }; |
e9edcee0 TI |
1240 | |
1241 | static struct hda_input_mux alc880_6stack_capture_source = { | |
1242 | .num_items = 4, | |
1243 | .items = { | |
1244 | { "Mic", 0x0 }, | |
1245 | { "Front Mic", 0x1 }, | |
1246 | { "Line", 0x2 }, | |
1247 | { "CD", 0x4 }, | |
1248 | }, | |
1249 | }; | |
1250 | ||
1251 | /* fixed 8-channels */ | |
d2a6d7dc | 1252 | static struct hda_channel_mode alc880_sixstack_modes[1] = { |
e9edcee0 TI |
1253 | { 8, NULL }, |
1254 | }; | |
1255 | ||
c8b6bf9b | 1256 | static struct snd_kcontrol_new alc880_six_stack_mixer[] = { |
16ded525 | 1257 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1258 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 1259 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1260 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1261 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1262 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1263 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1264 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
16ded525 | 1265 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 1266 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
16ded525 TI |
1267 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1268 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1269 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1270 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
1271 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1272 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1273 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1274 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1275 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
1276 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
16ded525 TI |
1277 | { |
1278 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1279 | .name = "Channel Mode", | |
df694daa KY |
1280 | .info = alc_ch_mode_info, |
1281 | .get = alc_ch_mode_get, | |
1282 | .put = alc_ch_mode_put, | |
16ded525 TI |
1283 | }, |
1284 | { } /* end */ | |
1285 | }; | |
1286 | ||
e9edcee0 TI |
1287 | |
1288 | /* | |
1289 | * ALC880 W810 model | |
1290 | * | |
1291 | * W810 has rear IO for: | |
1292 | * Front (DAC 02) | |
1293 | * Surround (DAC 03) | |
1294 | * Center/LFE (DAC 04) | |
1295 | * Digital out (06) | |
1296 | * | |
1297 | * The system also has a pair of internal speakers, and a headphone jack. | |
1298 | * These are both connected to Line2 on the codec, hence to DAC 02. | |
1299 | * | |
1300 | * There is a variable resistor to control the speaker or headphone | |
1301 | * volume. This is a hardware-only device without a software API. | |
1302 | * | |
1303 | * Plugging headphones in will disable the internal speakers. This is | |
1304 | * implemented in hardware, not via the driver using jack sense. In | |
1305 | * a similar fashion, plugging into the rear socket marked "front" will | |
1306 | * disable both the speakers and headphones. | |
1307 | * | |
1308 | * For input, there's a microphone jack, and an "audio in" jack. | |
1309 | * These may not do anything useful with this driver yet, because I | |
1310 | * haven't setup any initialization verbs for these yet... | |
1311 | */ | |
1312 | ||
1313 | static hda_nid_t alc880_w810_dac_nids[3] = { | |
1314 | /* front, rear/surround, clfe */ | |
1315 | 0x02, 0x03, 0x04 | |
16ded525 TI |
1316 | }; |
1317 | ||
e9edcee0 | 1318 | /* fixed 6 channels */ |
d2a6d7dc | 1319 | static struct hda_channel_mode alc880_w810_modes[1] = { |
e9edcee0 TI |
1320 | { 6, NULL } |
1321 | }; | |
1322 | ||
1323 | /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */ | |
c8b6bf9b | 1324 | static struct snd_kcontrol_new alc880_w810_base_mixer[] = { |
16ded525 | 1325 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1326 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 1327 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1328 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1329 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1330 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1331 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1332 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
e9edcee0 TI |
1333 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
1334 | { } /* end */ | |
1335 | }; | |
1336 | ||
1337 | ||
1338 | /* | |
1339 | * Z710V model | |
1340 | * | |
1341 | * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d) | |
9c7f852e TI |
1342 | * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), |
1343 | * Line = 0x1a | |
e9edcee0 TI |
1344 | */ |
1345 | ||
1346 | static hda_nid_t alc880_z71v_dac_nids[1] = { | |
1347 | 0x02 | |
1348 | }; | |
1349 | #define ALC880_Z71V_HP_DAC 0x03 | |
1350 | ||
1351 | /* fixed 2 channels */ | |
d2a6d7dc | 1352 | static struct hda_channel_mode alc880_2_jack_modes[1] = { |
e9edcee0 TI |
1353 | { 2, NULL } |
1354 | }; | |
1355 | ||
c8b6bf9b | 1356 | static struct snd_kcontrol_new alc880_z71v_mixer[] = { |
e9edcee0 | 1357 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1358 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
e9edcee0 | 1359 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1360 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1361 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1362 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
16ded525 TI |
1363 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
1364 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
16ded525 TI |
1365 | { } /* end */ |
1366 | }; | |
1367 | ||
e9edcee0 | 1368 | |
e9edcee0 TI |
1369 | /* |
1370 | * ALC880 F1734 model | |
1371 | * | |
1372 | * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d) | |
1373 | * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18 | |
1374 | */ | |
1375 | ||
1376 | static hda_nid_t alc880_f1734_dac_nids[1] = { | |
1377 | 0x03 | |
1378 | }; | |
1379 | #define ALC880_F1734_HP_DAC 0x02 | |
1380 | ||
c8b6bf9b | 1381 | static struct snd_kcontrol_new alc880_f1734_mixer[] = { |
e9edcee0 | 1382 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1383 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), |
2134ea4f TI |
1384 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
1385 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
e9edcee0 TI |
1386 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1387 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
937b4160 TI |
1388 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
1389 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
e9edcee0 TI |
1390 | { } /* end */ |
1391 | }; | |
1392 | ||
937b4160 TI |
1393 | static struct hda_input_mux alc880_f1734_capture_source = { |
1394 | .num_items = 2, | |
1395 | .items = { | |
1396 | { "Mic", 0x1 }, | |
1397 | { "CD", 0x4 }, | |
1398 | }, | |
1399 | }; | |
1400 | ||
e9edcee0 | 1401 | |
e9edcee0 TI |
1402 | /* |
1403 | * ALC880 ASUS model | |
1404 | * | |
1405 | * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) | |
1406 | * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, | |
1407 | * Mic = 0x18, Line = 0x1a | |
1408 | */ | |
1409 | ||
1410 | #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */ | |
1411 | #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */ | |
1412 | ||
c8b6bf9b | 1413 | static struct snd_kcontrol_new alc880_asus_mixer[] = { |
16ded525 | 1414 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1415 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 1416 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1417 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1418 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1419 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1420 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1421 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
16ded525 TI |
1422 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1423 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1424 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1425 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
16ded525 TI |
1426 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
1427 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
16ded525 TI |
1428 | { |
1429 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1430 | .name = "Channel Mode", | |
df694daa KY |
1431 | .info = alc_ch_mode_info, |
1432 | .get = alc_ch_mode_get, | |
1433 | .put = alc_ch_mode_put, | |
16ded525 TI |
1434 | }, |
1435 | { } /* end */ | |
1436 | }; | |
e9edcee0 | 1437 | |
e9edcee0 TI |
1438 | /* |
1439 | * ALC880 ASUS W1V model | |
1440 | * | |
1441 | * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) | |
1442 | * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, | |
1443 | * Mic = 0x18, Line = 0x1a, Line2 = 0x1b | |
1444 | */ | |
1445 | ||
1446 | /* additional mixers to alc880_asus_mixer */ | |
c8b6bf9b | 1447 | static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = { |
e9edcee0 TI |
1448 | HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT), |
1449 | HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT), | |
1450 | { } /* end */ | |
1451 | }; | |
1452 | ||
3c10a9d9 | 1453 | /* additional mixers to alc880_asus_mixer */ |
c8b6bf9b | 1454 | static struct snd_kcontrol_new alc880_pcbeep_mixer[] = { |
3c10a9d9 TI |
1455 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), |
1456 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
1457 | { } /* end */ | |
1458 | }; | |
e9edcee0 | 1459 | |
df694daa KY |
1460 | /* TCL S700 */ |
1461 | static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = { | |
1462 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1463 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
1464 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
1465 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT), | |
1466 | HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT), | |
1467 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT), | |
1468 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT), | |
1469 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
1470 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
1471 | { | |
1472 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1473 | /* The multiple "Capture Source" controls confuse alsamixer | |
1474 | * So call somewhat different.. | |
df694daa KY |
1475 | */ |
1476 | /* .name = "Capture Source", */ | |
1477 | .name = "Input Source", | |
1478 | .count = 1, | |
1479 | .info = alc_mux_enum_info, | |
1480 | .get = alc_mux_enum_get, | |
1481 | .put = alc_mux_enum_put, | |
1482 | }, | |
1483 | { } /* end */ | |
1484 | }; | |
1485 | ||
ccc656ce KY |
1486 | /* Uniwill */ |
1487 | static struct snd_kcontrol_new alc880_uniwill_mixer[] = { | |
2134ea4f TI |
1488 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
1489 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1490 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1491 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
ccc656ce KY |
1492 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1493 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
1494 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
1495 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
1496 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
1497 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1498 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1499 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
1500 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1501 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1502 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1503 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1504 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
1505 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
1506 | { | |
1507 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1508 | .name = "Channel Mode", | |
1509 | .info = alc_ch_mode_info, | |
1510 | .get = alc_ch_mode_get, | |
1511 | .put = alc_ch_mode_put, | |
1512 | }, | |
1513 | { } /* end */ | |
1514 | }; | |
1515 | ||
2cf9f0fc TD |
1516 | static struct snd_kcontrol_new alc880_fujitsu_mixer[] = { |
1517 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1518 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1519 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1520 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
1521 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
1522 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1523 | HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1524 | HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1525 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1526 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1527 | { } /* end */ | |
1528 | }; | |
1529 | ||
ccc656ce | 1530 | static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = { |
2134ea4f TI |
1531 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
1532 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1533 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1534 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
ccc656ce KY |
1535 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
1536 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1537 | { } /* end */ | |
1538 | }; | |
1539 | ||
2134ea4f TI |
1540 | /* |
1541 | * virtual master controls | |
1542 | */ | |
1543 | ||
1544 | /* | |
1545 | * slave controls for virtual master | |
1546 | */ | |
1547 | static const char *alc_slave_vols[] = { | |
1548 | "Front Playback Volume", | |
1549 | "Surround Playback Volume", | |
1550 | "Center Playback Volume", | |
1551 | "LFE Playback Volume", | |
1552 | "Side Playback Volume", | |
1553 | "Headphone Playback Volume", | |
1554 | "Speaker Playback Volume", | |
1555 | "Mono Playback Volume", | |
2134ea4f TI |
1556 | "Line-Out Playback Volume", |
1557 | NULL, | |
1558 | }; | |
1559 | ||
1560 | static const char *alc_slave_sws[] = { | |
1561 | "Front Playback Switch", | |
1562 | "Surround Playback Switch", | |
1563 | "Center Playback Switch", | |
1564 | "LFE Playback Switch", | |
1565 | "Side Playback Switch", | |
1566 | "Headphone Playback Switch", | |
1567 | "Speaker Playback Switch", | |
1568 | "Mono Playback Switch", | |
edb54a55 | 1569 | "IEC958 Playback Switch", |
2134ea4f TI |
1570 | NULL, |
1571 | }; | |
1572 | ||
1da177e4 | 1573 | /* |
e9edcee0 | 1574 | * build control elements |
1da177e4 LT |
1575 | */ |
1576 | static int alc_build_controls(struct hda_codec *codec) | |
1577 | { | |
1578 | struct alc_spec *spec = codec->spec; | |
1579 | int err; | |
1580 | int i; | |
1581 | ||
1582 | for (i = 0; i < spec->num_mixers; i++) { | |
1583 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); | |
1584 | if (err < 0) | |
1585 | return err; | |
1586 | } | |
1587 | ||
1588 | if (spec->multiout.dig_out_nid) { | |
9c7f852e TI |
1589 | err = snd_hda_create_spdif_out_ctls(codec, |
1590 | spec->multiout.dig_out_nid); | |
1da177e4 LT |
1591 | if (err < 0) |
1592 | return err; | |
9a08160b TI |
1593 | err = snd_hda_create_spdif_share_sw(codec, |
1594 | &spec->multiout); | |
1595 | if (err < 0) | |
1596 | return err; | |
1597 | spec->multiout.share_spdif = 1; | |
1da177e4 LT |
1598 | } |
1599 | if (spec->dig_in_nid) { | |
1600 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); | |
1601 | if (err < 0) | |
1602 | return err; | |
1603 | } | |
2134ea4f TI |
1604 | |
1605 | /* if we have no master control, let's create it */ | |
1606 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { | |
1c82ed1b | 1607 | unsigned int vmaster_tlv[4]; |
2134ea4f | 1608 | snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, |
1c82ed1b | 1609 | HDA_OUTPUT, vmaster_tlv); |
2134ea4f | 1610 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
1c82ed1b | 1611 | vmaster_tlv, alc_slave_vols); |
2134ea4f TI |
1612 | if (err < 0) |
1613 | return err; | |
1614 | } | |
1615 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { | |
1616 | err = snd_hda_add_vmaster(codec, "Master Playback Switch", | |
1617 | NULL, alc_slave_sws); | |
1618 | if (err < 0) | |
1619 | return err; | |
1620 | } | |
1621 | ||
1da177e4 LT |
1622 | return 0; |
1623 | } | |
1624 | ||
e9edcee0 | 1625 | |
1da177e4 LT |
1626 | /* |
1627 | * initialize the codec volumes, etc | |
1628 | */ | |
1629 | ||
e9edcee0 TI |
1630 | /* |
1631 | * generic initialization of ADC, input mixers and output mixers | |
1632 | */ | |
1633 | static struct hda_verb alc880_volume_init_verbs[] = { | |
1634 | /* | |
1635 | * Unmute ADC0-2 and set the default input to mic-in | |
1636 | */ | |
71fe7b82 | 1637 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 1638 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
71fe7b82 | 1639 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 1640 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
71fe7b82 | 1641 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 1642 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1da177e4 | 1643 | |
e9edcee0 TI |
1644 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
1645 | * mixer widget | |
9c7f852e TI |
1646 | * Note: PASD motherboards uses the Line In 2 as the input for front |
1647 | * panel mic (mic 2) | |
1da177e4 | 1648 | */ |
e9edcee0 | 1649 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ |
cb53c626 TI |
1650 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1651 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1652 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
1653 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
1654 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1655 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
1656 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
1da177e4 | 1657 | |
e9edcee0 TI |
1658 | /* |
1659 | * Set up output mixers (0x0c - 0x0f) | |
1da177e4 | 1660 | */ |
e9edcee0 TI |
1661 | /* set vol=0 to output mixers */ |
1662 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1663 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1664 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1665 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1666 | /* set up input amps for analog loopback */ | |
1667 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
05acb863 TI |
1668 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1669 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
1670 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1671 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
1672 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1673 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
1674 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1675 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 LT |
1676 | |
1677 | { } | |
1678 | }; | |
1679 | ||
e9edcee0 TI |
1680 | /* |
1681 | * 3-stack pin configuration: | |
1682 | * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b | |
1683 | */ | |
1684 | static struct hda_verb alc880_pin_3stack_init_verbs[] = { | |
1685 | /* | |
1686 | * preset connection lists of input pins | |
1687 | * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround | |
1688 | */ | |
1689 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
1690 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
1691 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */ | |
1692 | ||
1693 | /* | |
1694 | * Set pin mode and muting | |
1695 | */ | |
1696 | /* set front pin widgets 0x14 for output */ | |
05acb863 | 1697 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
1698 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1699 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
1700 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1701 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1702 | /* Mic2 (as headphone out) for HP output */ | |
1703 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1704 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1da177e4 | 1705 | /* Line In pin widget for input */ |
05acb863 | 1706 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 TI |
1707 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
1708 | /* Line2 (as front mic) pin widget for input and vref at 80% */ | |
1709 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1710 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1da177e4 | 1711 | /* CD pin widget for input */ |
05acb863 | 1712 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 1713 | |
e9edcee0 TI |
1714 | { } |
1715 | }; | |
1da177e4 | 1716 | |
e9edcee0 TI |
1717 | /* |
1718 | * 5-stack pin configuration: | |
1719 | * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19, | |
1720 | * line-in/side = 0x1a, f-mic = 0x1b | |
1721 | */ | |
1722 | static struct hda_verb alc880_pin_5stack_init_verbs[] = { | |
1723 | /* | |
1724 | * preset connection lists of input pins | |
1725 | * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround | |
1da177e4 | 1726 | */ |
e9edcee0 TI |
1727 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
1728 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */ | |
1da177e4 | 1729 | |
e9edcee0 TI |
1730 | /* |
1731 | * Set pin mode and muting | |
1da177e4 | 1732 | */ |
e9edcee0 TI |
1733 | /* set pin widgets 0x14-0x17 for output */ |
1734 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1735 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1736 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1737 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1738 | /* unmute pins for output (no gain on this amp) */ | |
1739 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1740 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1741 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1742 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1743 | ||
1744 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
1745 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1746 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1747 | /* Mic2 (as headphone out) for HP output */ | |
1748 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1749 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1750 | /* Line In pin widget for input */ | |
1751 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1752 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1753 | /* Line2 (as front mic) pin widget for input and vref at 80% */ | |
1754 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1755 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1756 | /* CD pin widget for input */ | |
1757 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1da177e4 LT |
1758 | |
1759 | { } | |
1760 | }; | |
1761 | ||
e9edcee0 TI |
1762 | /* |
1763 | * W810 pin configuration: | |
1764 | * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b | |
1765 | */ | |
1766 | static struct hda_verb alc880_pin_w810_init_verbs[] = { | |
1767 | /* hphone/speaker input selector: front DAC */ | |
1768 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
1da177e4 | 1769 | |
05acb863 | 1770 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1771 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 1772 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1773 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 1774 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1775 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 1776 | |
e9edcee0 | 1777 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
05acb863 | 1778 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
1da177e4 | 1779 | |
1da177e4 LT |
1780 | { } |
1781 | }; | |
1782 | ||
e9edcee0 TI |
1783 | /* |
1784 | * Z71V pin configuration: | |
1785 | * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?) | |
1786 | */ | |
1787 | static struct hda_verb alc880_pin_z71v_init_verbs[] = { | |
05acb863 | 1788 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1789 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 1790 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
e9edcee0 | 1791 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
dfc0ff62 | 1792 | |
16ded525 | 1793 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1794 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
16ded525 | 1795 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1796 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
16ded525 TI |
1797 | |
1798 | { } | |
1799 | }; | |
1800 | ||
e9edcee0 TI |
1801 | /* |
1802 | * 6-stack pin configuration: | |
9c7f852e TI |
1803 | * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, |
1804 | * f-mic = 0x19, line = 0x1a, HP = 0x1b | |
e9edcee0 TI |
1805 | */ |
1806 | static struct hda_verb alc880_pin_6stack_init_verbs[] = { | |
1807 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
1808 | ||
16ded525 | 1809 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1810 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1811 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1812 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1813 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1814 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1815 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
1816 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1817 | ||
16ded525 | 1818 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1819 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 1820 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1821 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 1822 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 | 1823 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 1824 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
e9edcee0 | 1825 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 TI |
1826 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1827 | ||
e9edcee0 TI |
1828 | { } |
1829 | }; | |
1830 | ||
ccc656ce KY |
1831 | /* |
1832 | * Uniwill pin configuration: | |
1833 | * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19, | |
1834 | * line = 0x1a | |
1835 | */ | |
1836 | static struct hda_verb alc880_uniwill_init_verbs[] = { | |
1837 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
1838 | ||
1839 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1840 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1841 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1842 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1843 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1844 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1845 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1846 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1847 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1848 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1849 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1850 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1851 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1852 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1853 | ||
1854 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1855 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1856 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1857 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1858 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1859 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1860 | /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */ | |
1861 | /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */ | |
1862 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1863 | ||
1864 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
1865 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
1866 | ||
1867 | { } | |
1868 | }; | |
1869 | ||
1870 | /* | |
1871 | * Uniwill P53 | |
1872 | * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19, | |
1873 | */ | |
1874 | static struct hda_verb alc880_uniwill_p53_init_verbs[] = { | |
1875 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
1876 | ||
1877 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1878 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1879 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1880 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1881 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1882 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1883 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1884 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1885 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1886 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1887 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1888 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1889 | ||
1890 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1891 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1892 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1893 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1894 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1895 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1896 | ||
1897 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
1898 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT}, | |
1899 | ||
1900 | { } | |
1901 | }; | |
1902 | ||
2cf9f0fc TD |
1903 | static struct hda_verb alc880_beep_init_verbs[] = { |
1904 | { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) }, | |
1905 | { } | |
1906 | }; | |
1907 | ||
ccc656ce | 1908 | /* toggle speaker-output according to the hp-jack state */ |
458a4fab | 1909 | static void alc880_uniwill_hp_automute(struct hda_codec *codec) |
ccc656ce KY |
1910 | { |
1911 | unsigned int present; | |
f12ab1e0 | 1912 | unsigned char bits; |
ccc656ce KY |
1913 | |
1914 | present = snd_hda_codec_read(codec, 0x14, 0, | |
1915 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
1916 | bits = present ? HDA_AMP_MUTE : 0; |
1917 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
1918 | HDA_AMP_MUTE, bits); | |
1919 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
1920 | HDA_AMP_MUTE, bits); | |
458a4fab TI |
1921 | } |
1922 | ||
1923 | /* auto-toggle front mic */ | |
1924 | static void alc880_uniwill_mic_automute(struct hda_codec *codec) | |
1925 | { | |
1926 | unsigned int present; | |
1927 | unsigned char bits; | |
ccc656ce KY |
1928 | |
1929 | present = snd_hda_codec_read(codec, 0x18, 0, | |
1930 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
1931 | bits = present ? HDA_AMP_MUTE : 0; |
1932 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); | |
458a4fab TI |
1933 | } |
1934 | ||
1935 | static void alc880_uniwill_automute(struct hda_codec *codec) | |
1936 | { | |
1937 | alc880_uniwill_hp_automute(codec); | |
1938 | alc880_uniwill_mic_automute(codec); | |
ccc656ce KY |
1939 | } |
1940 | ||
1941 | static void alc880_uniwill_unsol_event(struct hda_codec *codec, | |
1942 | unsigned int res) | |
1943 | { | |
1944 | /* Looks like the unsol event is incompatible with the standard | |
1945 | * definition. 4bit tag is placed at 28 bit! | |
1946 | */ | |
458a4fab TI |
1947 | switch (res >> 28) { |
1948 | case ALC880_HP_EVENT: | |
1949 | alc880_uniwill_hp_automute(codec); | |
1950 | break; | |
1951 | case ALC880_MIC_EVENT: | |
1952 | alc880_uniwill_mic_automute(codec); | |
1953 | break; | |
1954 | } | |
ccc656ce KY |
1955 | } |
1956 | ||
1957 | static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec) | |
1958 | { | |
1959 | unsigned int present; | |
f12ab1e0 | 1960 | unsigned char bits; |
ccc656ce KY |
1961 | |
1962 | present = snd_hda_codec_read(codec, 0x14, 0, | |
1963 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a | 1964 | bits = present ? HDA_AMP_MUTE : 0; |
64654c2f | 1965 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits); |
ccc656ce KY |
1966 | } |
1967 | ||
1968 | static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) | |
1969 | { | |
1970 | unsigned int present; | |
1971 | ||
1972 | present = snd_hda_codec_read(codec, 0x21, 0, | |
47fd830a TI |
1973 | AC_VERB_GET_VOLUME_KNOB_CONTROL, 0); |
1974 | present &= HDA_AMP_VOLMASK; | |
1975 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, | |
1976 | HDA_AMP_VOLMASK, present); | |
1977 | snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0, | |
1978 | HDA_AMP_VOLMASK, present); | |
ccc656ce | 1979 | } |
47fd830a | 1980 | |
ccc656ce KY |
1981 | static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec, |
1982 | unsigned int res) | |
1983 | { | |
1984 | /* Looks like the unsol event is incompatible with the standard | |
1985 | * definition. 4bit tag is placed at 28 bit! | |
1986 | */ | |
1987 | if ((res >> 28) == ALC880_HP_EVENT) | |
1988 | alc880_uniwill_p53_hp_automute(codec); | |
f12ab1e0 | 1989 | if ((res >> 28) == ALC880_DCVOL_EVENT) |
ccc656ce KY |
1990 | alc880_uniwill_p53_dcvol_automute(codec); |
1991 | } | |
1992 | ||
e9edcee0 TI |
1993 | /* |
1994 | * F1734 pin configuration: | |
1995 | * HP = 0x14, speaker-out = 0x15, mic = 0x18 | |
1996 | */ | |
1997 | static struct hda_verb alc880_pin_f1734_init_verbs[] = { | |
ee7a9c7c | 1998 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x01}, |
16ded525 TI |
1999 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, |
2000 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
2001 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
2002 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
2003 | ||
e9edcee0 | 2004 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
16ded525 | 2005 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
e9edcee0 | 2006 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
16ded525 | 2007 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2008 | |
e9edcee0 TI |
2009 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
2010 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
ee7a9c7c | 2011 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, |
e9edcee0 | 2012 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 2013 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2014 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2015 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2016 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2017 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
dfc0ff62 | 2018 | |
937b4160 TI |
2019 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT}, |
2020 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT}, | |
2021 | ||
dfc0ff62 TI |
2022 | { } |
2023 | }; | |
2024 | ||
e9edcee0 TI |
2025 | /* |
2026 | * ASUS pin configuration: | |
2027 | * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a | |
2028 | */ | |
2029 | static struct hda_verb alc880_pin_asus_init_verbs[] = { | |
16ded525 TI |
2030 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, |
2031 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
2032 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
2033 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
2034 | ||
2035 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
e9edcee0 | 2036 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2037 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2038 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2039 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2040 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2041 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
2042 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
2043 | ||
2044 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2045 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2046 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2047 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2048 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2049 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
16ded525 | 2050 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2051 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 TI |
2052 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
2053 | ||
e9edcee0 TI |
2054 | { } |
2055 | }; | |
16ded525 | 2056 | |
e9edcee0 | 2057 | /* Enable GPIO mask and set output */ |
bc9f98a9 KY |
2058 | #define alc880_gpio1_init_verbs alc_gpio1_init_verbs |
2059 | #define alc880_gpio2_init_verbs alc_gpio2_init_verbs | |
df694daa KY |
2060 | |
2061 | /* Clevo m520g init */ | |
2062 | static struct hda_verb alc880_pin_clevo_init_verbs[] = { | |
2063 | /* headphone output */ | |
2064 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
2065 | /* line-out */ | |
2066 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2067 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2068 | /* Line-in */ | |
2069 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2070 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2071 | /* CD */ | |
2072 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2073 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2074 | /* Mic1 (rear panel) */ | |
2075 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2076 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2077 | /* Mic2 (front panel) */ | |
2078 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2079 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2080 | /* headphone */ | |
2081 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2082 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2083 | /* change to EAPD mode */ | |
2084 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
2085 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, | |
2086 | ||
2087 | { } | |
16ded525 TI |
2088 | }; |
2089 | ||
df694daa | 2090 | static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = { |
4b146cb0 TI |
2091 | /* change to EAPD mode */ |
2092 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
2093 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, | |
2094 | ||
df694daa KY |
2095 | /* Headphone output */ |
2096 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2097 | /* Front output*/ | |
2098 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2099 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
2100 | ||
2101 | /* Line In pin widget for input */ | |
2102 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2103 | /* CD pin widget for input */ | |
2104 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2105 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
2106 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2107 | ||
2108 | /* change to EAPD mode */ | |
2109 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
2110 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
2111 | ||
2112 | { } | |
2113 | }; | |
16ded525 | 2114 | |
e9edcee0 | 2115 | /* |
ae6b813a TI |
2116 | * LG m1 express dual |
2117 | * | |
2118 | * Pin assignment: | |
2119 | * Rear Line-In/Out (blue): 0x14 | |
2120 | * Build-in Mic-In: 0x15 | |
2121 | * Speaker-out: 0x17 | |
2122 | * HP-Out (green): 0x1b | |
2123 | * Mic-In/Out (red): 0x19 | |
2124 | * SPDIF-Out: 0x1e | |
2125 | */ | |
2126 | ||
2127 | /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */ | |
2128 | static hda_nid_t alc880_lg_dac_nids[3] = { | |
2129 | 0x05, 0x02, 0x03 | |
2130 | }; | |
2131 | ||
2132 | /* seems analog CD is not working */ | |
2133 | static struct hda_input_mux alc880_lg_capture_source = { | |
2134 | .num_items = 3, | |
2135 | .items = { | |
2136 | { "Mic", 0x1 }, | |
2137 | { "Line", 0x5 }, | |
2138 | { "Internal Mic", 0x6 }, | |
2139 | }, | |
2140 | }; | |
2141 | ||
2142 | /* 2,4,6 channel modes */ | |
2143 | static struct hda_verb alc880_lg_ch2_init[] = { | |
2144 | /* set line-in and mic-in to input */ | |
2145 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
2146 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
2147 | { } | |
2148 | }; | |
2149 | ||
2150 | static struct hda_verb alc880_lg_ch4_init[] = { | |
2151 | /* set line-in to out and mic-in to input */ | |
2152 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
2153 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
2154 | { } | |
2155 | }; | |
2156 | ||
2157 | static struct hda_verb alc880_lg_ch6_init[] = { | |
2158 | /* set line-in and mic-in to output */ | |
2159 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
2160 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
2161 | { } | |
2162 | }; | |
2163 | ||
2164 | static struct hda_channel_mode alc880_lg_ch_modes[3] = { | |
2165 | { 2, alc880_lg_ch2_init }, | |
2166 | { 4, alc880_lg_ch4_init }, | |
2167 | { 6, alc880_lg_ch6_init }, | |
2168 | }; | |
2169 | ||
2170 | static struct snd_kcontrol_new alc880_lg_mixer[] = { | |
2134ea4f TI |
2171 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
2172 | HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT), | |
ae6b813a TI |
2173 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
2174 | HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT), | |
2175 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), | |
2176 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT), | |
2177 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT), | |
2178 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), | |
2179 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
2180 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
2181 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT), | |
2182 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT), | |
2183 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT), | |
2184 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT), | |
2185 | { | |
2186 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2187 | .name = "Channel Mode", | |
2188 | .info = alc_ch_mode_info, | |
2189 | .get = alc_ch_mode_get, | |
2190 | .put = alc_ch_mode_put, | |
2191 | }, | |
2192 | { } /* end */ | |
2193 | }; | |
2194 | ||
2195 | static struct hda_verb alc880_lg_init_verbs[] = { | |
2196 | /* set capture source to mic-in */ | |
2197 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2198 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2199 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2200 | /* mute all amp mixer inputs */ | |
2201 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)}, | |
cb53c626 TI |
2202 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, |
2203 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
ae6b813a TI |
2204 | /* line-in to input */ |
2205 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2206 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2207 | /* built-in mic */ | |
2208 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2209 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2210 | /* speaker-out */ | |
2211 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2212 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2213 | /* mic-in to input */ | |
2214 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
2215 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2216 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2217 | /* HP-out */ | |
2218 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
2219 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2220 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2221 | /* jack sense */ | |
2222 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, | |
2223 | { } | |
2224 | }; | |
2225 | ||
2226 | /* toggle speaker-output according to the hp-jack state */ | |
2227 | static void alc880_lg_automute(struct hda_codec *codec) | |
2228 | { | |
2229 | unsigned int present; | |
f12ab1e0 | 2230 | unsigned char bits; |
ae6b813a TI |
2231 | |
2232 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
2233 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
2234 | bits = present ? HDA_AMP_MUTE : 0; |
2235 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
2236 | HDA_AMP_MUTE, bits); | |
ae6b813a TI |
2237 | } |
2238 | ||
2239 | static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res) | |
2240 | { | |
2241 | /* Looks like the unsol event is incompatible with the standard | |
2242 | * definition. 4bit tag is placed at 28 bit! | |
2243 | */ | |
2244 | if ((res >> 28) == 0x01) | |
2245 | alc880_lg_automute(codec); | |
2246 | } | |
2247 | ||
d681518a TI |
2248 | /* |
2249 | * LG LW20 | |
2250 | * | |
2251 | * Pin assignment: | |
2252 | * Speaker-out: 0x14 | |
2253 | * Mic-In: 0x18 | |
e4f41da9 CM |
2254 | * Built-in Mic-In: 0x19 |
2255 | * Line-In: 0x1b | |
2256 | * HP-Out: 0x1a | |
d681518a TI |
2257 | * SPDIF-Out: 0x1e |
2258 | */ | |
2259 | ||
d681518a | 2260 | static struct hda_input_mux alc880_lg_lw_capture_source = { |
e4f41da9 | 2261 | .num_items = 3, |
d681518a TI |
2262 | .items = { |
2263 | { "Mic", 0x0 }, | |
2264 | { "Internal Mic", 0x1 }, | |
e4f41da9 | 2265 | { "Line In", 0x2 }, |
d681518a TI |
2266 | }, |
2267 | }; | |
2268 | ||
0a8c5da3 CM |
2269 | #define alc880_lg_lw_modes alc880_threestack_modes |
2270 | ||
d681518a | 2271 | static struct snd_kcontrol_new alc880_lg_lw_mixer[] = { |
0a8c5da3 CM |
2272 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
2273 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
2274 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
2275 | HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT), | |
2276 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
2277 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
2278 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
2279 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
2280 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
2281 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
d681518a TI |
2282 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
2283 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2284 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
2285 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
0a8c5da3 CM |
2286 | { |
2287 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2288 | .name = "Channel Mode", | |
2289 | .info = alc_ch_mode_info, | |
2290 | .get = alc_ch_mode_get, | |
2291 | .put = alc_ch_mode_put, | |
2292 | }, | |
d681518a TI |
2293 | { } /* end */ |
2294 | }; | |
2295 | ||
2296 | static struct hda_verb alc880_lg_lw_init_verbs[] = { | |
0a8c5da3 CM |
2297 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
2298 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
2299 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */ | |
2300 | ||
d681518a TI |
2301 | /* set capture source to mic-in */ |
2302 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2303 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2304 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
cb53c626 | 2305 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, |
d681518a TI |
2306 | /* speaker-out */ |
2307 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2308 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2309 | /* HP-out */ | |
d681518a TI |
2310 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
2311 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2312 | /* mic-in to input */ | |
2313 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2314 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2315 | /* built-in mic */ | |
2316 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2317 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2318 | /* jack sense */ | |
2319 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, | |
2320 | { } | |
2321 | }; | |
2322 | ||
2323 | /* toggle speaker-output according to the hp-jack state */ | |
2324 | static void alc880_lg_lw_automute(struct hda_codec *codec) | |
2325 | { | |
2326 | unsigned int present; | |
f12ab1e0 | 2327 | unsigned char bits; |
d681518a TI |
2328 | |
2329 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
2330 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
2331 | bits = present ? HDA_AMP_MUTE : 0; |
2332 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
2333 | HDA_AMP_MUTE, bits); | |
d681518a TI |
2334 | } |
2335 | ||
2336 | static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res) | |
2337 | { | |
2338 | /* Looks like the unsol event is incompatible with the standard | |
2339 | * definition. 4bit tag is placed at 28 bit! | |
2340 | */ | |
2341 | if ((res >> 28) == 0x01) | |
2342 | alc880_lg_lw_automute(codec); | |
2343 | } | |
2344 | ||
df99cd33 TI |
2345 | static struct snd_kcontrol_new alc880_medion_rim_mixer[] = { |
2346 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
2347 | HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT), | |
2348 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
2349 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2350 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
2351 | HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
2352 | { } /* end */ | |
2353 | }; | |
2354 | ||
2355 | static struct hda_input_mux alc880_medion_rim_capture_source = { | |
2356 | .num_items = 2, | |
2357 | .items = { | |
2358 | { "Mic", 0x0 }, | |
2359 | { "Internal Mic", 0x1 }, | |
2360 | }, | |
2361 | }; | |
2362 | ||
2363 | static struct hda_verb alc880_medion_rim_init_verbs[] = { | |
2364 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
2365 | ||
2366 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2367 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2368 | ||
2369 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
2370 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2371 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2372 | /* Mic2 (as headphone out) for HP output */ | |
2373 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2374 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2375 | /* Internal Speaker */ | |
2376 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2377 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2378 | ||
2379 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
2380 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, | |
2381 | ||
2382 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
2383 | { } | |
2384 | }; | |
2385 | ||
2386 | /* toggle speaker-output according to the hp-jack state */ | |
2387 | static void alc880_medion_rim_automute(struct hda_codec *codec) | |
2388 | { | |
2389 | unsigned int present; | |
2390 | unsigned char bits; | |
2391 | ||
2392 | present = snd_hda_codec_read(codec, 0x14, 0, | |
2393 | AC_VERB_GET_PIN_SENSE, 0) | |
2394 | & AC_PINSENSE_PRESENCE; | |
2395 | bits = present ? HDA_AMP_MUTE : 0; | |
2396 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
2397 | HDA_AMP_MUTE, bits); | |
2398 | if (present) | |
2399 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0); | |
2400 | else | |
2401 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2); | |
2402 | } | |
2403 | ||
2404 | static void alc880_medion_rim_unsol_event(struct hda_codec *codec, | |
2405 | unsigned int res) | |
2406 | { | |
2407 | /* Looks like the unsol event is incompatible with the standard | |
2408 | * definition. 4bit tag is placed at 28 bit! | |
2409 | */ | |
2410 | if ((res >> 28) == ALC880_HP_EVENT) | |
2411 | alc880_medion_rim_automute(codec); | |
2412 | } | |
2413 | ||
cb53c626 TI |
2414 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
2415 | static struct hda_amp_list alc880_loopbacks[] = { | |
2416 | { 0x0b, HDA_INPUT, 0 }, | |
2417 | { 0x0b, HDA_INPUT, 1 }, | |
2418 | { 0x0b, HDA_INPUT, 2 }, | |
2419 | { 0x0b, HDA_INPUT, 3 }, | |
2420 | { 0x0b, HDA_INPUT, 4 }, | |
2421 | { } /* end */ | |
2422 | }; | |
2423 | ||
2424 | static struct hda_amp_list alc880_lg_loopbacks[] = { | |
2425 | { 0x0b, HDA_INPUT, 1 }, | |
2426 | { 0x0b, HDA_INPUT, 6 }, | |
2427 | { 0x0b, HDA_INPUT, 7 }, | |
2428 | { } /* end */ | |
2429 | }; | |
2430 | #endif | |
2431 | ||
ae6b813a TI |
2432 | /* |
2433 | * Common callbacks | |
e9edcee0 TI |
2434 | */ |
2435 | ||
1da177e4 LT |
2436 | static int alc_init(struct hda_codec *codec) |
2437 | { | |
2438 | struct alc_spec *spec = codec->spec; | |
e9edcee0 TI |
2439 | unsigned int i; |
2440 | ||
2c3bf9ab TI |
2441 | alc_fix_pll(codec); |
2442 | ||
e9edcee0 TI |
2443 | for (i = 0; i < spec->num_init_verbs; i++) |
2444 | snd_hda_sequence_write(codec, spec->init_verbs[i]); | |
ae6b813a TI |
2445 | |
2446 | if (spec->init_hook) | |
2447 | spec->init_hook(codec); | |
2448 | ||
1da177e4 LT |
2449 | return 0; |
2450 | } | |
2451 | ||
ae6b813a TI |
2452 | static void alc_unsol_event(struct hda_codec *codec, unsigned int res) |
2453 | { | |
2454 | struct alc_spec *spec = codec->spec; | |
2455 | ||
2456 | if (spec->unsol_event) | |
2457 | spec->unsol_event(codec, res); | |
2458 | } | |
2459 | ||
cb53c626 TI |
2460 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
2461 | static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid) | |
2462 | { | |
2463 | struct alc_spec *spec = codec->spec; | |
2464 | return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); | |
2465 | } | |
2466 | #endif | |
2467 | ||
1da177e4 LT |
2468 | /* |
2469 | * Analog playback callbacks | |
2470 | */ | |
2471 | static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo, | |
2472 | struct hda_codec *codec, | |
c8b6bf9b | 2473 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2474 | { |
2475 | struct alc_spec *spec = codec->spec; | |
9a08160b TI |
2476 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
2477 | hinfo); | |
1da177e4 LT |
2478 | } |
2479 | ||
2480 | static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | |
2481 | struct hda_codec *codec, | |
2482 | unsigned int stream_tag, | |
2483 | unsigned int format, | |
c8b6bf9b | 2484 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2485 | { |
2486 | struct alc_spec *spec = codec->spec; | |
9c7f852e TI |
2487 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, |
2488 | stream_tag, format, substream); | |
1da177e4 LT |
2489 | } |
2490 | ||
2491 | static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, | |
2492 | struct hda_codec *codec, | |
c8b6bf9b | 2493 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2494 | { |
2495 | struct alc_spec *spec = codec->spec; | |
2496 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); | |
2497 | } | |
2498 | ||
2499 | /* | |
2500 | * Digital out | |
2501 | */ | |
2502 | static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, | |
2503 | struct hda_codec *codec, | |
c8b6bf9b | 2504 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2505 | { |
2506 | struct alc_spec *spec = codec->spec; | |
2507 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); | |
2508 | } | |
2509 | ||
6b97eb45 TI |
2510 | static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
2511 | struct hda_codec *codec, | |
2512 | unsigned int stream_tag, | |
2513 | unsigned int format, | |
2514 | struct snd_pcm_substream *substream) | |
2515 | { | |
2516 | struct alc_spec *spec = codec->spec; | |
2517 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, | |
2518 | stream_tag, format, substream); | |
2519 | } | |
2520 | ||
1da177e4 LT |
2521 | static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
2522 | struct hda_codec *codec, | |
c8b6bf9b | 2523 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2524 | { |
2525 | struct alc_spec *spec = codec->spec; | |
2526 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); | |
2527 | } | |
2528 | ||
2529 | /* | |
2530 | * Analog capture | |
2531 | */ | |
6330079f | 2532 | static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
1da177e4 LT |
2533 | struct hda_codec *codec, |
2534 | unsigned int stream_tag, | |
2535 | unsigned int format, | |
c8b6bf9b | 2536 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2537 | { |
2538 | struct alc_spec *spec = codec->spec; | |
2539 | ||
6330079f | 2540 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1], |
1da177e4 LT |
2541 | stream_tag, 0, format); |
2542 | return 0; | |
2543 | } | |
2544 | ||
6330079f | 2545 | static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
1da177e4 | 2546 | struct hda_codec *codec, |
c8b6bf9b | 2547 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2548 | { |
2549 | struct alc_spec *spec = codec->spec; | |
2550 | ||
888afa15 TI |
2551 | snd_hda_codec_cleanup_stream(codec, |
2552 | spec->adc_nids[substream->number + 1]); | |
1da177e4 LT |
2553 | return 0; |
2554 | } | |
2555 | ||
2556 | ||
2557 | /* | |
2558 | */ | |
2559 | static struct hda_pcm_stream alc880_pcm_analog_playback = { | |
2560 | .substreams = 1, | |
2561 | .channels_min = 2, | |
2562 | .channels_max = 8, | |
e9edcee0 | 2563 | /* NID is set in alc_build_pcms */ |
1da177e4 LT |
2564 | .ops = { |
2565 | .open = alc880_playback_pcm_open, | |
2566 | .prepare = alc880_playback_pcm_prepare, | |
2567 | .cleanup = alc880_playback_pcm_cleanup | |
2568 | }, | |
2569 | }; | |
2570 | ||
2571 | static struct hda_pcm_stream alc880_pcm_analog_capture = { | |
6330079f TI |
2572 | .substreams = 1, |
2573 | .channels_min = 2, | |
2574 | .channels_max = 2, | |
2575 | /* NID is set in alc_build_pcms */ | |
2576 | }; | |
2577 | ||
2578 | static struct hda_pcm_stream alc880_pcm_analog_alt_playback = { | |
2579 | .substreams = 1, | |
2580 | .channels_min = 2, | |
2581 | .channels_max = 2, | |
2582 | /* NID is set in alc_build_pcms */ | |
2583 | }; | |
2584 | ||
2585 | static struct hda_pcm_stream alc880_pcm_analog_alt_capture = { | |
2586 | .substreams = 2, /* can be overridden */ | |
1da177e4 LT |
2587 | .channels_min = 2, |
2588 | .channels_max = 2, | |
e9edcee0 | 2589 | /* NID is set in alc_build_pcms */ |
1da177e4 | 2590 | .ops = { |
6330079f TI |
2591 | .prepare = alc880_alt_capture_pcm_prepare, |
2592 | .cleanup = alc880_alt_capture_pcm_cleanup | |
1da177e4 LT |
2593 | }, |
2594 | }; | |
2595 | ||
2596 | static struct hda_pcm_stream alc880_pcm_digital_playback = { | |
2597 | .substreams = 1, | |
2598 | .channels_min = 2, | |
2599 | .channels_max = 2, | |
2600 | /* NID is set in alc_build_pcms */ | |
2601 | .ops = { | |
2602 | .open = alc880_dig_playback_pcm_open, | |
6b97eb45 TI |
2603 | .close = alc880_dig_playback_pcm_close, |
2604 | .prepare = alc880_dig_playback_pcm_prepare | |
1da177e4 LT |
2605 | }, |
2606 | }; | |
2607 | ||
2608 | static struct hda_pcm_stream alc880_pcm_digital_capture = { | |
2609 | .substreams = 1, | |
2610 | .channels_min = 2, | |
2611 | .channels_max = 2, | |
2612 | /* NID is set in alc_build_pcms */ | |
2613 | }; | |
2614 | ||
4c5186ed | 2615 | /* Used by alc_build_pcms to flag that a PCM has no playback stream */ |
6330079f | 2616 | static struct hda_pcm_stream alc_pcm_null_stream = { |
4c5186ed JW |
2617 | .substreams = 0, |
2618 | .channels_min = 0, | |
2619 | .channels_max = 0, | |
2620 | }; | |
2621 | ||
1da177e4 LT |
2622 | static int alc_build_pcms(struct hda_codec *codec) |
2623 | { | |
2624 | struct alc_spec *spec = codec->spec; | |
2625 | struct hda_pcm *info = spec->pcm_rec; | |
2626 | int i; | |
2627 | ||
2628 | codec->num_pcms = 1; | |
2629 | codec->pcm_info = info; | |
2630 | ||
2631 | info->name = spec->stream_name_analog; | |
4a471b7d TI |
2632 | if (spec->stream_analog_playback) { |
2633 | snd_assert(spec->multiout.dac_nids, return -EINVAL); | |
2634 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback); | |
2635 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; | |
2636 | } | |
2637 | if (spec->stream_analog_capture) { | |
2638 | snd_assert(spec->adc_nids, return -EINVAL); | |
2639 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); | |
2640 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; | |
2641 | } | |
2642 | ||
2643 | if (spec->channel_mode) { | |
2644 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; | |
2645 | for (i = 0; i < spec->num_channel_mode; i++) { | |
2646 | if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { | |
2647 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; | |
2648 | } | |
1da177e4 LT |
2649 | } |
2650 | } | |
2651 | ||
e08a007d | 2652 | /* SPDIF for stream index #1 */ |
1da177e4 | 2653 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
e08a007d | 2654 | codec->num_pcms = 2; |
c06134d7 | 2655 | info = spec->pcm_rec + 1; |
1da177e4 | 2656 | info->name = spec->stream_name_digital; |
7ba72ba1 | 2657 | info->pcm_type = HDA_PCM_TYPE_SPDIF; |
4a471b7d TI |
2658 | if (spec->multiout.dig_out_nid && |
2659 | spec->stream_digital_playback) { | |
1da177e4 LT |
2660 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback); |
2661 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; | |
2662 | } | |
4a471b7d TI |
2663 | if (spec->dig_in_nid && |
2664 | spec->stream_digital_capture) { | |
1da177e4 LT |
2665 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture); |
2666 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; | |
2667 | } | |
2668 | } | |
2669 | ||
e08a007d TI |
2670 | /* If the use of more than one ADC is requested for the current |
2671 | * model, configure a second analog capture-only PCM. | |
2672 | */ | |
2673 | /* Additional Analaog capture for index #2 */ | |
6330079f TI |
2674 | if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) || |
2675 | (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) { | |
e08a007d | 2676 | codec->num_pcms = 3; |
c06134d7 | 2677 | info = spec->pcm_rec + 2; |
e08a007d | 2678 | info->name = spec->stream_name_analog; |
6330079f TI |
2679 | if (spec->alt_dac_nid) { |
2680 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = | |
2681 | *spec->stream_analog_alt_playback; | |
2682 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = | |
2683 | spec->alt_dac_nid; | |
2684 | } else { | |
2685 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = | |
2686 | alc_pcm_null_stream; | |
2687 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; | |
2688 | } | |
2689 | if (spec->num_adc_nids > 1) { | |
2690 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = | |
2691 | *spec->stream_analog_alt_capture; | |
2692 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = | |
2693 | spec->adc_nids[1]; | |
2694 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = | |
2695 | spec->num_adc_nids - 1; | |
2696 | } else { | |
2697 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = | |
2698 | alc_pcm_null_stream; | |
2699 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0; | |
e08a007d TI |
2700 | } |
2701 | } | |
2702 | ||
1da177e4 LT |
2703 | return 0; |
2704 | } | |
2705 | ||
2706 | static void alc_free(struct hda_codec *codec) | |
2707 | { | |
e9edcee0 TI |
2708 | struct alc_spec *spec = codec->spec; |
2709 | unsigned int i; | |
2710 | ||
f12ab1e0 | 2711 | if (!spec) |
e9edcee0 TI |
2712 | return; |
2713 | ||
2714 | if (spec->kctl_alloc) { | |
2715 | for (i = 0; i < spec->num_kctl_used; i++) | |
2716 | kfree(spec->kctl_alloc[i].name); | |
2717 | kfree(spec->kctl_alloc); | |
2718 | } | |
2719 | kfree(spec); | |
7943a8ab | 2720 | codec->spec = NULL; /* to be sure */ |
1da177e4 LT |
2721 | } |
2722 | ||
2723 | /* | |
2724 | */ | |
2725 | static struct hda_codec_ops alc_patch_ops = { | |
2726 | .build_controls = alc_build_controls, | |
2727 | .build_pcms = alc_build_pcms, | |
2728 | .init = alc_init, | |
2729 | .free = alc_free, | |
ae6b813a | 2730 | .unsol_event = alc_unsol_event, |
cb53c626 TI |
2731 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
2732 | .check_power_status = alc_check_power_status, | |
2733 | #endif | |
1da177e4 LT |
2734 | }; |
2735 | ||
2fa522be TI |
2736 | |
2737 | /* | |
2738 | * Test configuration for debugging | |
2739 | * | |
2740 | * Almost all inputs/outputs are enabled. I/O pins can be configured via | |
2741 | * enum controls. | |
2742 | */ | |
2743 | #ifdef CONFIG_SND_DEBUG | |
2744 | static hda_nid_t alc880_test_dac_nids[4] = { | |
2745 | 0x02, 0x03, 0x04, 0x05 | |
2746 | }; | |
2747 | ||
2748 | static struct hda_input_mux alc880_test_capture_source = { | |
ae6b813a | 2749 | .num_items = 7, |
2fa522be TI |
2750 | .items = { |
2751 | { "In-1", 0x0 }, | |
2752 | { "In-2", 0x1 }, | |
2753 | { "In-3", 0x2 }, | |
2754 | { "In-4", 0x3 }, | |
2755 | { "CD", 0x4 }, | |
ae6b813a TI |
2756 | { "Front", 0x5 }, |
2757 | { "Surround", 0x6 }, | |
2fa522be TI |
2758 | }, |
2759 | }; | |
2760 | ||
d2a6d7dc | 2761 | static struct hda_channel_mode alc880_test_modes[4] = { |
2fa522be | 2762 | { 2, NULL }, |
fd2c326d | 2763 | { 4, NULL }, |
2fa522be | 2764 | { 6, NULL }, |
fd2c326d | 2765 | { 8, NULL }, |
2fa522be TI |
2766 | }; |
2767 | ||
9c7f852e TI |
2768 | static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, |
2769 | struct snd_ctl_elem_info *uinfo) | |
2fa522be TI |
2770 | { |
2771 | static char *texts[] = { | |
2772 | "N/A", "Line Out", "HP Out", | |
2773 | "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%" | |
2774 | }; | |
2775 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
2776 | uinfo->count = 1; | |
2777 | uinfo->value.enumerated.items = 8; | |
2778 | if (uinfo->value.enumerated.item >= 8) | |
2779 | uinfo->value.enumerated.item = 7; | |
2780 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | |
2781 | return 0; | |
2782 | } | |
2783 | ||
9c7f852e TI |
2784 | static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, |
2785 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
2786 | { |
2787 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2788 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
2789 | unsigned int pin_ctl, item = 0; | |
2790 | ||
2791 | pin_ctl = snd_hda_codec_read(codec, nid, 0, | |
2792 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | |
2793 | if (pin_ctl & AC_PINCTL_OUT_EN) { | |
2794 | if (pin_ctl & AC_PINCTL_HP_EN) | |
2795 | item = 2; | |
2796 | else | |
2797 | item = 1; | |
2798 | } else if (pin_ctl & AC_PINCTL_IN_EN) { | |
2799 | switch (pin_ctl & AC_PINCTL_VREFEN) { | |
2800 | case AC_PINCTL_VREF_HIZ: item = 3; break; | |
2801 | case AC_PINCTL_VREF_50: item = 4; break; | |
2802 | case AC_PINCTL_VREF_GRD: item = 5; break; | |
2803 | case AC_PINCTL_VREF_80: item = 6; break; | |
2804 | case AC_PINCTL_VREF_100: item = 7; break; | |
2805 | } | |
2806 | } | |
2807 | ucontrol->value.enumerated.item[0] = item; | |
2808 | return 0; | |
2809 | } | |
2810 | ||
9c7f852e TI |
2811 | static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, |
2812 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
2813 | { |
2814 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2815 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
2816 | static unsigned int ctls[] = { | |
2817 | 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN, | |
2818 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ, | |
2819 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_50, | |
2820 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD, | |
2821 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_80, | |
2822 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_100, | |
2823 | }; | |
2824 | unsigned int old_ctl, new_ctl; | |
2825 | ||
2826 | old_ctl = snd_hda_codec_read(codec, nid, 0, | |
2827 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | |
2828 | new_ctl = ctls[ucontrol->value.enumerated.item[0]]; | |
2829 | if (old_ctl != new_ctl) { | |
82beb8fd TI |
2830 | int val; |
2831 | snd_hda_codec_write_cache(codec, nid, 0, | |
2832 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
2833 | new_ctl); | |
47fd830a TI |
2834 | val = ucontrol->value.enumerated.item[0] >= 3 ? |
2835 | HDA_AMP_MUTE : 0; | |
2836 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, | |
2837 | HDA_AMP_MUTE, val); | |
2fa522be TI |
2838 | return 1; |
2839 | } | |
2840 | return 0; | |
2841 | } | |
2842 | ||
9c7f852e TI |
2843 | static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, |
2844 | struct snd_ctl_elem_info *uinfo) | |
2fa522be TI |
2845 | { |
2846 | static char *texts[] = { | |
2847 | "Front", "Surround", "CLFE", "Side" | |
2848 | }; | |
2849 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
2850 | uinfo->count = 1; | |
2851 | uinfo->value.enumerated.items = 4; | |
2852 | if (uinfo->value.enumerated.item >= 4) | |
2853 | uinfo->value.enumerated.item = 3; | |
2854 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | |
2855 | return 0; | |
2856 | } | |
2857 | ||
9c7f852e TI |
2858 | static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, |
2859 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
2860 | { |
2861 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2862 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
2863 | unsigned int sel; | |
2864 | ||
2865 | sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0); | |
2866 | ucontrol->value.enumerated.item[0] = sel & 3; | |
2867 | return 0; | |
2868 | } | |
2869 | ||
9c7f852e TI |
2870 | static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, |
2871 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
2872 | { |
2873 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2874 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
2875 | unsigned int sel; | |
2876 | ||
2877 | sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3; | |
2878 | if (ucontrol->value.enumerated.item[0] != sel) { | |
2879 | sel = ucontrol->value.enumerated.item[0] & 3; | |
82beb8fd TI |
2880 | snd_hda_codec_write_cache(codec, nid, 0, |
2881 | AC_VERB_SET_CONNECT_SEL, sel); | |
2fa522be TI |
2882 | return 1; |
2883 | } | |
2884 | return 0; | |
2885 | } | |
2886 | ||
2887 | #define PIN_CTL_TEST(xname,nid) { \ | |
2888 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
2889 | .name = xname, \ | |
2890 | .info = alc_test_pin_ctl_info, \ | |
2891 | .get = alc_test_pin_ctl_get, \ | |
2892 | .put = alc_test_pin_ctl_put, \ | |
2893 | .private_value = nid \ | |
2894 | } | |
2895 | ||
2896 | #define PIN_SRC_TEST(xname,nid) { \ | |
2897 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
2898 | .name = xname, \ | |
2899 | .info = alc_test_pin_src_info, \ | |
2900 | .get = alc_test_pin_src_get, \ | |
2901 | .put = alc_test_pin_src_put, \ | |
2902 | .private_value = nid \ | |
2903 | } | |
2904 | ||
c8b6bf9b | 2905 | static struct snd_kcontrol_new alc880_test_mixer[] = { |
05acb863 TI |
2906 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
2907 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
2908 | HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT), | |
2909 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
985be54b TI |
2910 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
2911 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
2912 | HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT), | |
2913 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
2fa522be TI |
2914 | PIN_CTL_TEST("Front Pin Mode", 0x14), |
2915 | PIN_CTL_TEST("Surround Pin Mode", 0x15), | |
2916 | PIN_CTL_TEST("CLFE Pin Mode", 0x16), | |
2917 | PIN_CTL_TEST("Side Pin Mode", 0x17), | |
2918 | PIN_CTL_TEST("In-1 Pin Mode", 0x18), | |
2919 | PIN_CTL_TEST("In-2 Pin Mode", 0x19), | |
2920 | PIN_CTL_TEST("In-3 Pin Mode", 0x1a), | |
2921 | PIN_CTL_TEST("In-4 Pin Mode", 0x1b), | |
2922 | PIN_SRC_TEST("In-1 Pin Source", 0x18), | |
2923 | PIN_SRC_TEST("In-2 Pin Source", 0x19), | |
2924 | PIN_SRC_TEST("In-3 Pin Source", 0x1a), | |
2925 | PIN_SRC_TEST("In-4 Pin Source", 0x1b), | |
2926 | HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
2927 | HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2928 | HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
2929 | HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
2930 | HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT), | |
2931 | HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT), | |
2932 | HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT), | |
2933 | HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT), | |
2934 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT), | |
2935 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT), | |
2fa522be TI |
2936 | { |
2937 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2938 | .name = "Channel Mode", | |
df694daa KY |
2939 | .info = alc_ch_mode_info, |
2940 | .get = alc_ch_mode_get, | |
2941 | .put = alc_ch_mode_put, | |
2fa522be TI |
2942 | }, |
2943 | { } /* end */ | |
2944 | }; | |
2945 | ||
2946 | static struct hda_verb alc880_test_init_verbs[] = { | |
2947 | /* Unmute inputs of 0x0c - 0x0f */ | |
05acb863 TI |
2948 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
2949 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2950 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2951 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2952 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2953 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2954 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2955 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2fa522be | 2956 | /* Vol output for 0x0c-0x0f */ |
05acb863 TI |
2957 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
2958 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2959 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2960 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2fa522be | 2961 | /* Set output pins 0x14-0x17 */ |
05acb863 TI |
2962 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
2963 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2964 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2965 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2fa522be | 2966 | /* Unmute output pins 0x14-0x17 */ |
05acb863 TI |
2967 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
2968 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2969 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2970 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2fa522be | 2971 | /* Set input pins 0x18-0x1c */ |
16ded525 TI |
2972 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
2973 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
05acb863 TI |
2974 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
2975 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2976 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2fa522be | 2977 | /* Mute input pins 0x18-0x1b */ |
05acb863 TI |
2978 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
2979 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2980 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2981 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
71fe7b82 | 2982 | /* ADC set up */ |
05acb863 | 2983 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 2984 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 | 2985 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 2986 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 | 2987 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 2988 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
2989 | /* Analog input/passthru */ |
2990 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
2991 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2992 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
2993 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
2994 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
2fa522be TI |
2995 | { } |
2996 | }; | |
2997 | #endif | |
2998 | ||
1da177e4 LT |
2999 | /* |
3000 | */ | |
3001 | ||
f5fcc13c TI |
3002 | static const char *alc880_models[ALC880_MODEL_LAST] = { |
3003 | [ALC880_3ST] = "3stack", | |
3004 | [ALC880_TCL_S700] = "tcl", | |
3005 | [ALC880_3ST_DIG] = "3stack-digout", | |
3006 | [ALC880_CLEVO] = "clevo", | |
3007 | [ALC880_5ST] = "5stack", | |
3008 | [ALC880_5ST_DIG] = "5stack-digout", | |
3009 | [ALC880_W810] = "w810", | |
3010 | [ALC880_Z71V] = "z71v", | |
3011 | [ALC880_6ST] = "6stack", | |
3012 | [ALC880_6ST_DIG] = "6stack-digout", | |
3013 | [ALC880_ASUS] = "asus", | |
3014 | [ALC880_ASUS_W1V] = "asus-w1v", | |
3015 | [ALC880_ASUS_DIG] = "asus-dig", | |
3016 | [ALC880_ASUS_DIG2] = "asus-dig2", | |
3017 | [ALC880_UNIWILL_DIG] = "uniwill", | |
2cf9f0fc TD |
3018 | [ALC880_UNIWILL_P53] = "uniwill-p53", |
3019 | [ALC880_FUJITSU] = "fujitsu", | |
f5fcc13c TI |
3020 | [ALC880_F1734] = "F1734", |
3021 | [ALC880_LG] = "lg", | |
3022 | [ALC880_LG_LW] = "lg-lw", | |
df99cd33 | 3023 | [ALC880_MEDION_RIM] = "medion", |
2fa522be | 3024 | #ifdef CONFIG_SND_DEBUG |
f5fcc13c | 3025 | [ALC880_TEST] = "test", |
2fa522be | 3026 | #endif |
f5fcc13c TI |
3027 | [ALC880_AUTO] = "auto", |
3028 | }; | |
3029 | ||
3030 | static struct snd_pci_quirk alc880_cfg_tbl[] = { | |
ac3e3741 | 3031 | SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810), |
f5fcc13c TI |
3032 | SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG), |
3033 | SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST), | |
3034 | SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG), | |
3035 | SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG), | |
3036 | SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG), | |
3037 | SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG), | |
3038 | SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG), | |
3039 | SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST), | |
f5fcc13c TI |
3040 | SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG), |
3041 | SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST), | |
f5fcc13c TI |
3042 | SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V), |
3043 | SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG), | |
3044 | SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG), | |
3045 | SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG), | |
3046 | SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG), | |
3047 | SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG), | |
3048 | SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V), | |
3049 | /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */ | |
3050 | SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG), | |
3051 | SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG), | |
186c3117 | 3052 | SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG), |
f5fcc13c TI |
3053 | SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG), |
3054 | SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST), | |
3055 | SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST), | |
ac3e3741 | 3056 | SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */ |
f5fcc13c | 3057 | SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST), |
ac3e3741 TI |
3058 | SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST), |
3059 | SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST), | |
f5fcc13c TI |
3060 | SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST), |
3061 | SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST), | |
f5fcc13c TI |
3062 | SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG), |
3063 | SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG), | |
3064 | SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG), | |
3065 | SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG), | |
ac3e3741 TI |
3066 | SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO), |
3067 | SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO), | |
f5fcc13c | 3068 | SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2), |
ac3e3741 | 3069 | SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG), |
f5fcc13c | 3070 | SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG), |
ac3e3741 | 3071 | SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734), |
f5fcc13c TI |
3072 | SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL), |
3073 | SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53), | |
ac3e3741 | 3074 | SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810), |
df99cd33 | 3075 | SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM), |
ac3e3741 | 3076 | SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG), |
f5fcc13c | 3077 | SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG), |
f5fcc13c | 3078 | SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734), |
1d11604e | 3079 | SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU), |
ac3e3741 | 3080 | SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL), |
2cf9f0fc | 3081 | SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU), |
ac3e3741 | 3082 | SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW), |
f5fcc13c TI |
3083 | SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG), |
3084 | SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG), | |
f5fcc13c | 3085 | SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW), |
ac3e3741 TI |
3086 | SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700), |
3087 | SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */ | |
3088 | SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG), | |
3089 | SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG), | |
f5fcc13c TI |
3090 | SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG), |
3091 | SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG), | |
ac3e3741 | 3092 | SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG), |
f5fcc13c | 3093 | SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG), |
ac3e3741 TI |
3094 | SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG), |
3095 | SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG), | |
f5fcc13c TI |
3096 | SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG), |
3097 | SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG), | |
3098 | SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG), | |
ac3e3741 TI |
3099 | SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */ |
3100 | SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG), | |
3101 | SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG), | |
1da177e4 LT |
3102 | {} |
3103 | }; | |
3104 | ||
16ded525 | 3105 | /* |
df694daa | 3106 | * ALC880 codec presets |
16ded525 | 3107 | */ |
16ded525 TI |
3108 | static struct alc_config_preset alc880_presets[] = { |
3109 | [ALC880_3ST] = { | |
e9edcee0 | 3110 | .mixers = { alc880_three_stack_mixer }, |
f12ab1e0 TI |
3111 | .init_verbs = { alc880_volume_init_verbs, |
3112 | alc880_pin_3stack_init_verbs }, | |
16ded525 | 3113 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
16ded525 | 3114 | .dac_nids = alc880_dac_nids, |
16ded525 TI |
3115 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
3116 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 3117 | .need_dac_fix = 1, |
16ded525 TI |
3118 | .input_mux = &alc880_capture_source, |
3119 | }, | |
3120 | [ALC880_3ST_DIG] = { | |
e9edcee0 | 3121 | .mixers = { alc880_three_stack_mixer }, |
f12ab1e0 TI |
3122 | .init_verbs = { alc880_volume_init_verbs, |
3123 | alc880_pin_3stack_init_verbs }, | |
16ded525 | 3124 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
16ded525 TI |
3125 | .dac_nids = alc880_dac_nids, |
3126 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3127 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
3128 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 3129 | .need_dac_fix = 1, |
16ded525 TI |
3130 | .input_mux = &alc880_capture_source, |
3131 | }, | |
df694daa KY |
3132 | [ALC880_TCL_S700] = { |
3133 | .mixers = { alc880_tcl_s700_mixer }, | |
3134 | .init_verbs = { alc880_volume_init_verbs, | |
3135 | alc880_pin_tcl_S700_init_verbs, | |
3136 | alc880_gpio2_init_verbs }, | |
3137 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
3138 | .dac_nids = alc880_dac_nids, | |
3139 | .hp_nid = 0x03, | |
3140 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
3141 | .channel_mode = alc880_2_jack_modes, | |
3142 | .input_mux = &alc880_capture_source, | |
3143 | }, | |
16ded525 | 3144 | [ALC880_5ST] = { |
f12ab1e0 TI |
3145 | .mixers = { alc880_three_stack_mixer, |
3146 | alc880_five_stack_mixer}, | |
3147 | .init_verbs = { alc880_volume_init_verbs, | |
3148 | alc880_pin_5stack_init_verbs }, | |
16ded525 TI |
3149 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
3150 | .dac_nids = alc880_dac_nids, | |
16ded525 TI |
3151 | .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), |
3152 | .channel_mode = alc880_fivestack_modes, | |
3153 | .input_mux = &alc880_capture_source, | |
3154 | }, | |
3155 | [ALC880_5ST_DIG] = { | |
f12ab1e0 TI |
3156 | .mixers = { alc880_three_stack_mixer, |
3157 | alc880_five_stack_mixer }, | |
3158 | .init_verbs = { alc880_volume_init_verbs, | |
3159 | alc880_pin_5stack_init_verbs }, | |
16ded525 TI |
3160 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
3161 | .dac_nids = alc880_dac_nids, | |
3162 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3163 | .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), |
3164 | .channel_mode = alc880_fivestack_modes, | |
3165 | .input_mux = &alc880_capture_source, | |
3166 | }, | |
b6482d48 TI |
3167 | [ALC880_6ST] = { |
3168 | .mixers = { alc880_six_stack_mixer }, | |
f12ab1e0 TI |
3169 | .init_verbs = { alc880_volume_init_verbs, |
3170 | alc880_pin_6stack_init_verbs }, | |
b6482d48 TI |
3171 | .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), |
3172 | .dac_nids = alc880_6st_dac_nids, | |
3173 | .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), | |
3174 | .channel_mode = alc880_sixstack_modes, | |
3175 | .input_mux = &alc880_6stack_capture_source, | |
3176 | }, | |
16ded525 | 3177 | [ALC880_6ST_DIG] = { |
e9edcee0 | 3178 | .mixers = { alc880_six_stack_mixer }, |
f12ab1e0 TI |
3179 | .init_verbs = { alc880_volume_init_verbs, |
3180 | alc880_pin_6stack_init_verbs }, | |
16ded525 TI |
3181 | .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), |
3182 | .dac_nids = alc880_6st_dac_nids, | |
3183 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3184 | .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), |
3185 | .channel_mode = alc880_sixstack_modes, | |
3186 | .input_mux = &alc880_6stack_capture_source, | |
3187 | }, | |
3188 | [ALC880_W810] = { | |
e9edcee0 | 3189 | .mixers = { alc880_w810_base_mixer }, |
f12ab1e0 TI |
3190 | .init_verbs = { alc880_volume_init_verbs, |
3191 | alc880_pin_w810_init_verbs, | |
b0af0de5 | 3192 | alc880_gpio2_init_verbs }, |
16ded525 TI |
3193 | .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids), |
3194 | .dac_nids = alc880_w810_dac_nids, | |
3195 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3196 | .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), |
3197 | .channel_mode = alc880_w810_modes, | |
3198 | .input_mux = &alc880_capture_source, | |
3199 | }, | |
3200 | [ALC880_Z71V] = { | |
e9edcee0 | 3201 | .mixers = { alc880_z71v_mixer }, |
f12ab1e0 TI |
3202 | .init_verbs = { alc880_volume_init_verbs, |
3203 | alc880_pin_z71v_init_verbs }, | |
16ded525 TI |
3204 | .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids), |
3205 | .dac_nids = alc880_z71v_dac_nids, | |
3206 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3207 | .hp_nid = 0x03, | |
e9edcee0 TI |
3208 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), |
3209 | .channel_mode = alc880_2_jack_modes, | |
16ded525 TI |
3210 | .input_mux = &alc880_capture_source, |
3211 | }, | |
3212 | [ALC880_F1734] = { | |
e9edcee0 | 3213 | .mixers = { alc880_f1734_mixer }, |
f12ab1e0 TI |
3214 | .init_verbs = { alc880_volume_init_verbs, |
3215 | alc880_pin_f1734_init_verbs }, | |
e9edcee0 TI |
3216 | .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids), |
3217 | .dac_nids = alc880_f1734_dac_nids, | |
3218 | .hp_nid = 0x02, | |
3219 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
3220 | .channel_mode = alc880_2_jack_modes, | |
937b4160 TI |
3221 | .input_mux = &alc880_f1734_capture_source, |
3222 | .unsol_event = alc880_uniwill_p53_unsol_event, | |
3223 | .init_hook = alc880_uniwill_p53_hp_automute, | |
16ded525 TI |
3224 | }, |
3225 | [ALC880_ASUS] = { | |
e9edcee0 | 3226 | .mixers = { alc880_asus_mixer }, |
f12ab1e0 TI |
3227 | .init_verbs = { alc880_volume_init_verbs, |
3228 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
3229 | alc880_gpio1_init_verbs }, |
3230 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3231 | .dac_nids = alc880_asus_dac_nids, | |
3232 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), | |
3233 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3234 | .need_dac_fix = 1, |
16ded525 TI |
3235 | .input_mux = &alc880_capture_source, |
3236 | }, | |
3237 | [ALC880_ASUS_DIG] = { | |
e9edcee0 | 3238 | .mixers = { alc880_asus_mixer }, |
f12ab1e0 TI |
3239 | .init_verbs = { alc880_volume_init_verbs, |
3240 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
3241 | alc880_gpio1_init_verbs }, |
3242 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3243 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 3244 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
3245 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
3246 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3247 | .need_dac_fix = 1, |
16ded525 TI |
3248 | .input_mux = &alc880_capture_source, |
3249 | }, | |
df694daa KY |
3250 | [ALC880_ASUS_DIG2] = { |
3251 | .mixers = { alc880_asus_mixer }, | |
f12ab1e0 TI |
3252 | .init_verbs = { alc880_volume_init_verbs, |
3253 | alc880_pin_asus_init_verbs, | |
df694daa KY |
3254 | alc880_gpio2_init_verbs }, /* use GPIO2 */ |
3255 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3256 | .dac_nids = alc880_asus_dac_nids, | |
3257 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3258 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), | |
3259 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3260 | .need_dac_fix = 1, |
df694daa KY |
3261 | .input_mux = &alc880_capture_source, |
3262 | }, | |
16ded525 | 3263 | [ALC880_ASUS_W1V] = { |
e9edcee0 | 3264 | .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer }, |
f12ab1e0 TI |
3265 | .init_verbs = { alc880_volume_init_verbs, |
3266 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
3267 | alc880_gpio1_init_verbs }, |
3268 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3269 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 3270 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
3271 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
3272 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3273 | .need_dac_fix = 1, |
16ded525 TI |
3274 | .input_mux = &alc880_capture_source, |
3275 | }, | |
3276 | [ALC880_UNIWILL_DIG] = { | |
3c10a9d9 | 3277 | .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer }, |
ccc656ce KY |
3278 | .init_verbs = { alc880_volume_init_verbs, |
3279 | alc880_pin_asus_init_verbs }, | |
e9edcee0 TI |
3280 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), |
3281 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 3282 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
3283 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
3284 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3285 | .need_dac_fix = 1, |
16ded525 TI |
3286 | .input_mux = &alc880_capture_source, |
3287 | }, | |
ccc656ce KY |
3288 | [ALC880_UNIWILL] = { |
3289 | .mixers = { alc880_uniwill_mixer }, | |
3290 | .init_verbs = { alc880_volume_init_verbs, | |
3291 | alc880_uniwill_init_verbs }, | |
3292 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3293 | .dac_nids = alc880_asus_dac_nids, | |
3294 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3295 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
3296 | .channel_mode = alc880_threestack_modes, | |
3297 | .need_dac_fix = 1, | |
3298 | .input_mux = &alc880_capture_source, | |
3299 | .unsol_event = alc880_uniwill_unsol_event, | |
3300 | .init_hook = alc880_uniwill_automute, | |
3301 | }, | |
3302 | [ALC880_UNIWILL_P53] = { | |
3303 | .mixers = { alc880_uniwill_p53_mixer }, | |
3304 | .init_verbs = { alc880_volume_init_verbs, | |
3305 | alc880_uniwill_p53_init_verbs }, | |
3306 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3307 | .dac_nids = alc880_asus_dac_nids, | |
3308 | .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), | |
2cf9f0fc TD |
3309 | .channel_mode = alc880_threestack_modes, |
3310 | .input_mux = &alc880_capture_source, | |
3311 | .unsol_event = alc880_uniwill_p53_unsol_event, | |
3312 | .init_hook = alc880_uniwill_p53_hp_automute, | |
3313 | }, | |
3314 | [ALC880_FUJITSU] = { | |
f12ab1e0 | 3315 | .mixers = { alc880_fujitsu_mixer, |
2cf9f0fc TD |
3316 | alc880_pcbeep_mixer, }, |
3317 | .init_verbs = { alc880_volume_init_verbs, | |
3318 | alc880_uniwill_p53_init_verbs, | |
3319 | alc880_beep_init_verbs }, | |
3320 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
3321 | .dac_nids = alc880_dac_nids, | |
d53d7d9e | 3322 | .dig_out_nid = ALC880_DIGOUT_NID, |
2cf9f0fc TD |
3323 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), |
3324 | .channel_mode = alc880_2_jack_modes, | |
ccc656ce KY |
3325 | .input_mux = &alc880_capture_source, |
3326 | .unsol_event = alc880_uniwill_p53_unsol_event, | |
3327 | .init_hook = alc880_uniwill_p53_hp_automute, | |
3328 | }, | |
df694daa KY |
3329 | [ALC880_CLEVO] = { |
3330 | .mixers = { alc880_three_stack_mixer }, | |
3331 | .init_verbs = { alc880_volume_init_verbs, | |
3332 | alc880_pin_clevo_init_verbs }, | |
3333 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
3334 | .dac_nids = alc880_dac_nids, | |
3335 | .hp_nid = 0x03, | |
3336 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
3337 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 3338 | .need_dac_fix = 1, |
df694daa KY |
3339 | .input_mux = &alc880_capture_source, |
3340 | }, | |
ae6b813a TI |
3341 | [ALC880_LG] = { |
3342 | .mixers = { alc880_lg_mixer }, | |
3343 | .init_verbs = { alc880_volume_init_verbs, | |
3344 | alc880_lg_init_verbs }, | |
3345 | .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids), | |
3346 | .dac_nids = alc880_lg_dac_nids, | |
3347 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3348 | .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes), | |
3349 | .channel_mode = alc880_lg_ch_modes, | |
4e195a7b | 3350 | .need_dac_fix = 1, |
ae6b813a TI |
3351 | .input_mux = &alc880_lg_capture_source, |
3352 | .unsol_event = alc880_lg_unsol_event, | |
3353 | .init_hook = alc880_lg_automute, | |
cb53c626 TI |
3354 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
3355 | .loopbacks = alc880_lg_loopbacks, | |
3356 | #endif | |
ae6b813a | 3357 | }, |
d681518a TI |
3358 | [ALC880_LG_LW] = { |
3359 | .mixers = { alc880_lg_lw_mixer }, | |
3360 | .init_verbs = { alc880_volume_init_verbs, | |
3361 | alc880_lg_lw_init_verbs }, | |
0a8c5da3 | 3362 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
d681518a TI |
3363 | .dac_nids = alc880_dac_nids, |
3364 | .dig_out_nid = ALC880_DIGOUT_NID, | |
0a8c5da3 CM |
3365 | .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes), |
3366 | .channel_mode = alc880_lg_lw_modes, | |
d681518a TI |
3367 | .input_mux = &alc880_lg_lw_capture_source, |
3368 | .unsol_event = alc880_lg_lw_unsol_event, | |
3369 | .init_hook = alc880_lg_lw_automute, | |
3370 | }, | |
df99cd33 TI |
3371 | [ALC880_MEDION_RIM] = { |
3372 | .mixers = { alc880_medion_rim_mixer }, | |
3373 | .init_verbs = { alc880_volume_init_verbs, | |
3374 | alc880_medion_rim_init_verbs, | |
3375 | alc_gpio2_init_verbs }, | |
3376 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
3377 | .dac_nids = alc880_dac_nids, | |
3378 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3379 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
3380 | .channel_mode = alc880_2_jack_modes, | |
3381 | .input_mux = &alc880_medion_rim_capture_source, | |
3382 | .unsol_event = alc880_medion_rim_unsol_event, | |
3383 | .init_hook = alc880_medion_rim_automute, | |
3384 | }, | |
16ded525 TI |
3385 | #ifdef CONFIG_SND_DEBUG |
3386 | [ALC880_TEST] = { | |
e9edcee0 TI |
3387 | .mixers = { alc880_test_mixer }, |
3388 | .init_verbs = { alc880_test_init_verbs }, | |
16ded525 TI |
3389 | .num_dacs = ARRAY_SIZE(alc880_test_dac_nids), |
3390 | .dac_nids = alc880_test_dac_nids, | |
3391 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3392 | .num_channel_mode = ARRAY_SIZE(alc880_test_modes), |
3393 | .channel_mode = alc880_test_modes, | |
3394 | .input_mux = &alc880_test_capture_source, | |
3395 | }, | |
3396 | #endif | |
3397 | }; | |
3398 | ||
e9edcee0 TI |
3399 | /* |
3400 | * Automatic parse of I/O pins from the BIOS configuration | |
3401 | */ | |
3402 | ||
3403 | #define NUM_CONTROL_ALLOC 32 | |
3404 | #define NUM_VERB_ALLOC 32 | |
3405 | ||
3406 | enum { | |
3407 | ALC_CTL_WIDGET_VOL, | |
3408 | ALC_CTL_WIDGET_MUTE, | |
3409 | ALC_CTL_BIND_MUTE, | |
3410 | }; | |
c8b6bf9b | 3411 | static struct snd_kcontrol_new alc880_control_templates[] = { |
e9edcee0 TI |
3412 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
3413 | HDA_CODEC_MUTE(NULL, 0, 0, 0), | |
985be54b | 3414 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
e9edcee0 TI |
3415 | }; |
3416 | ||
3417 | /* add dynamic controls */ | |
f12ab1e0 TI |
3418 | static int add_control(struct alc_spec *spec, int type, const char *name, |
3419 | unsigned long val) | |
e9edcee0 | 3420 | { |
c8b6bf9b | 3421 | struct snd_kcontrol_new *knew; |
e9edcee0 TI |
3422 | |
3423 | if (spec->num_kctl_used >= spec->num_kctl_alloc) { | |
3424 | int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; | |
3425 | ||
f12ab1e0 TI |
3426 | /* array + terminator */ |
3427 | knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); | |
3428 | if (!knew) | |
e9edcee0 TI |
3429 | return -ENOMEM; |
3430 | if (spec->kctl_alloc) { | |
f12ab1e0 TI |
3431 | memcpy(knew, spec->kctl_alloc, |
3432 | sizeof(*knew) * spec->num_kctl_alloc); | |
e9edcee0 TI |
3433 | kfree(spec->kctl_alloc); |
3434 | } | |
3435 | spec->kctl_alloc = knew; | |
3436 | spec->num_kctl_alloc = num; | |
3437 | } | |
3438 | ||
3439 | knew = &spec->kctl_alloc[spec->num_kctl_used]; | |
3440 | *knew = alc880_control_templates[type]; | |
543537bd | 3441 | knew->name = kstrdup(name, GFP_KERNEL); |
f12ab1e0 | 3442 | if (!knew->name) |
e9edcee0 TI |
3443 | return -ENOMEM; |
3444 | knew->private_value = val; | |
3445 | spec->num_kctl_used++; | |
3446 | return 0; | |
3447 | } | |
3448 | ||
3449 | #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17) | |
3450 | #define alc880_fixed_pin_idx(nid) ((nid) - 0x14) | |
3451 | #define alc880_is_multi_pin(nid) ((nid) >= 0x18) | |
3452 | #define alc880_multi_pin_idx(nid) ((nid) - 0x18) | |
3453 | #define alc880_is_input_pin(nid) ((nid) >= 0x18) | |
3454 | #define alc880_input_pin_idx(nid) ((nid) - 0x18) | |
3455 | #define alc880_idx_to_dac(nid) ((nid) + 0x02) | |
3456 | #define alc880_dac_to_idx(nid) ((nid) - 0x02) | |
3457 | #define alc880_idx_to_mixer(nid) ((nid) + 0x0c) | |
3458 | #define alc880_idx_to_selector(nid) ((nid) + 0x10) | |
3459 | #define ALC880_PIN_CD_NID 0x1c | |
3460 | ||
3461 | /* fill in the dac_nids table from the parsed pin configuration */ | |
f12ab1e0 TI |
3462 | static int alc880_auto_fill_dac_nids(struct alc_spec *spec, |
3463 | const struct auto_pin_cfg *cfg) | |
e9edcee0 TI |
3464 | { |
3465 | hda_nid_t nid; | |
3466 | int assigned[4]; | |
3467 | int i, j; | |
3468 | ||
3469 | memset(assigned, 0, sizeof(assigned)); | |
b0af0de5 | 3470 | spec->multiout.dac_nids = spec->private_dac_nids; |
e9edcee0 TI |
3471 | |
3472 | /* check the pins hardwired to audio widget */ | |
3473 | for (i = 0; i < cfg->line_outs; i++) { | |
3474 | nid = cfg->line_out_pins[i]; | |
3475 | if (alc880_is_fixed_pin(nid)) { | |
3476 | int idx = alc880_fixed_pin_idx(nid); | |
5014f193 | 3477 | spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx); |
e9edcee0 TI |
3478 | assigned[idx] = 1; |
3479 | } | |
3480 | } | |
3481 | /* left pins can be connect to any audio widget */ | |
3482 | for (i = 0; i < cfg->line_outs; i++) { | |
3483 | nid = cfg->line_out_pins[i]; | |
3484 | if (alc880_is_fixed_pin(nid)) | |
3485 | continue; | |
3486 | /* search for an empty channel */ | |
3487 | for (j = 0; j < cfg->line_outs; j++) { | |
f12ab1e0 TI |
3488 | if (!assigned[j]) { |
3489 | spec->multiout.dac_nids[i] = | |
3490 | alc880_idx_to_dac(j); | |
e9edcee0 TI |
3491 | assigned[j] = 1; |
3492 | break; | |
3493 | } | |
3494 | } | |
3495 | } | |
3496 | spec->multiout.num_dacs = cfg->line_outs; | |
3497 | return 0; | |
3498 | } | |
3499 | ||
3500 | /* add playback controls from the parsed DAC table */ | |
df694daa KY |
3501 | static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, |
3502 | const struct auto_pin_cfg *cfg) | |
e9edcee0 TI |
3503 | { |
3504 | char name[32]; | |
f12ab1e0 TI |
3505 | static const char *chname[4] = { |
3506 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
3507 | }; | |
e9edcee0 TI |
3508 | hda_nid_t nid; |
3509 | int i, err; | |
3510 | ||
3511 | for (i = 0; i < cfg->line_outs; i++) { | |
f12ab1e0 | 3512 | if (!spec->multiout.dac_nids[i]) |
e9edcee0 TI |
3513 | continue; |
3514 | nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i])); | |
3515 | if (i == 2) { | |
3516 | /* Center/LFE */ | |
f12ab1e0 TI |
3517 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
3518 | "Center Playback Volume", | |
3519 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, | |
3520 | HDA_OUTPUT)); | |
3521 | if (err < 0) | |
e9edcee0 | 3522 | return err; |
f12ab1e0 TI |
3523 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
3524 | "LFE Playback Volume", | |
3525 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
3526 | HDA_OUTPUT)); | |
3527 | if (err < 0) | |
e9edcee0 | 3528 | return err; |
f12ab1e0 TI |
3529 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
3530 | "Center Playback Switch", | |
3531 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, | |
3532 | HDA_INPUT)); | |
3533 | if (err < 0) | |
e9edcee0 | 3534 | return err; |
f12ab1e0 TI |
3535 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
3536 | "LFE Playback Switch", | |
3537 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, | |
3538 | HDA_INPUT)); | |
3539 | if (err < 0) | |
e9edcee0 TI |
3540 | return err; |
3541 | } else { | |
3542 | sprintf(name, "%s Playback Volume", chname[i]); | |
f12ab1e0 TI |
3543 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
3544 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
3545 | HDA_OUTPUT)); | |
3546 | if (err < 0) | |
e9edcee0 TI |
3547 | return err; |
3548 | sprintf(name, "%s Playback Switch", chname[i]); | |
f12ab1e0 TI |
3549 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
3550 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, | |
3551 | HDA_INPUT)); | |
3552 | if (err < 0) | |
e9edcee0 TI |
3553 | return err; |
3554 | } | |
3555 | } | |
e9edcee0 TI |
3556 | return 0; |
3557 | } | |
3558 | ||
8d88bc3d TI |
3559 | /* add playback controls for speaker and HP outputs */ |
3560 | static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, | |
3561 | const char *pfx) | |
e9edcee0 TI |
3562 | { |
3563 | hda_nid_t nid; | |
3564 | int err; | |
8d88bc3d | 3565 | char name[32]; |
e9edcee0 | 3566 | |
f12ab1e0 | 3567 | if (!pin) |
e9edcee0 TI |
3568 | return 0; |
3569 | ||
3570 | if (alc880_is_fixed_pin(pin)) { | |
3571 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
82bc955f | 3572 | /* specify the DAC as the extra output */ |
f12ab1e0 | 3573 | if (!spec->multiout.hp_nid) |
e9edcee0 | 3574 | spec->multiout.hp_nid = nid; |
82bc955f TI |
3575 | else |
3576 | spec->multiout.extra_out_nid[0] = nid; | |
e9edcee0 TI |
3577 | /* control HP volume/switch on the output mixer amp */ |
3578 | nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin)); | |
8d88bc3d | 3579 | sprintf(name, "%s Playback Volume", pfx); |
f12ab1e0 TI |
3580 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
3581 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
3582 | if (err < 0) | |
e9edcee0 | 3583 | return err; |
8d88bc3d | 3584 | sprintf(name, "%s Playback Switch", pfx); |
f12ab1e0 TI |
3585 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
3586 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); | |
3587 | if (err < 0) | |
e9edcee0 TI |
3588 | return err; |
3589 | } else if (alc880_is_multi_pin(pin)) { | |
3590 | /* set manual connection */ | |
e9edcee0 | 3591 | /* we have only a switch on HP-out PIN */ |
8d88bc3d | 3592 | sprintf(name, "%s Playback Switch", pfx); |
f12ab1e0 TI |
3593 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
3594 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
3595 | if (err < 0) | |
e9edcee0 TI |
3596 | return err; |
3597 | } | |
3598 | return 0; | |
3599 | } | |
3600 | ||
3601 | /* create input playback/capture controls for the given pin */ | |
f12ab1e0 TI |
3602 | static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, |
3603 | const char *ctlname, | |
df694daa | 3604 | int idx, hda_nid_t mix_nid) |
e9edcee0 TI |
3605 | { |
3606 | char name[32]; | |
df694daa | 3607 | int err; |
e9edcee0 TI |
3608 | |
3609 | sprintf(name, "%s Playback Volume", ctlname); | |
f12ab1e0 TI |
3610 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
3611 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); | |
3612 | if (err < 0) | |
e9edcee0 TI |
3613 | return err; |
3614 | sprintf(name, "%s Playback Switch", ctlname); | |
f12ab1e0 TI |
3615 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
3616 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); | |
3617 | if (err < 0) | |
e9edcee0 TI |
3618 | return err; |
3619 | return 0; | |
3620 | } | |
3621 | ||
3622 | /* create playback/capture controls for input pins */ | |
df694daa KY |
3623 | static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, |
3624 | const struct auto_pin_cfg *cfg) | |
e9edcee0 | 3625 | { |
e9edcee0 | 3626 | struct hda_input_mux *imux = &spec->private_imux; |
df694daa | 3627 | int i, err, idx; |
e9edcee0 TI |
3628 | |
3629 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
3630 | if (alc880_is_input_pin(cfg->input_pins[i])) { | |
df694daa | 3631 | idx = alc880_input_pin_idx(cfg->input_pins[i]); |
4a471b7d TI |
3632 | err = new_analog_input(spec, cfg->input_pins[i], |
3633 | auto_pin_cfg_labels[i], | |
df694daa | 3634 | idx, 0x0b); |
e9edcee0 TI |
3635 | if (err < 0) |
3636 | return err; | |
f12ab1e0 TI |
3637 | imux->items[imux->num_items].label = |
3638 | auto_pin_cfg_labels[i]; | |
3639 | imux->items[imux->num_items].index = | |
3640 | alc880_input_pin_idx(cfg->input_pins[i]); | |
e9edcee0 TI |
3641 | imux->num_items++; |
3642 | } | |
3643 | } | |
3644 | return 0; | |
3645 | } | |
3646 | ||
f6c7e546 TI |
3647 | static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid, |
3648 | unsigned int pin_type) | |
3649 | { | |
3650 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
3651 | pin_type); | |
3652 | /* unmute pin */ | |
d260cdf6 TI |
3653 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
3654 | AMP_OUT_UNMUTE); | |
f6c7e546 TI |
3655 | } |
3656 | ||
df694daa KY |
3657 | static void alc880_auto_set_output_and_unmute(struct hda_codec *codec, |
3658 | hda_nid_t nid, int pin_type, | |
e9edcee0 TI |
3659 | int dac_idx) |
3660 | { | |
f6c7e546 | 3661 | alc_set_pin_output(codec, nid, pin_type); |
e9edcee0 TI |
3662 | /* need the manual connection? */ |
3663 | if (alc880_is_multi_pin(nid)) { | |
3664 | struct alc_spec *spec = codec->spec; | |
3665 | int idx = alc880_multi_pin_idx(nid); | |
3666 | snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, | |
3667 | AC_VERB_SET_CONNECT_SEL, | |
3668 | alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); | |
3669 | } | |
3670 | } | |
3671 | ||
baba8ee9 TI |
3672 | static int get_pin_type(int line_out_type) |
3673 | { | |
3674 | if (line_out_type == AUTO_PIN_HP_OUT) | |
3675 | return PIN_HP; | |
3676 | else | |
3677 | return PIN_OUT; | |
3678 | } | |
3679 | ||
e9edcee0 TI |
3680 | static void alc880_auto_init_multi_out(struct hda_codec *codec) |
3681 | { | |
3682 | struct alc_spec *spec = codec->spec; | |
3683 | int i; | |
bc9f98a9 KY |
3684 | |
3685 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); | |
e9edcee0 TI |
3686 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
3687 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 TI |
3688 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
3689 | alc880_auto_set_output_and_unmute(codec, nid, pin_type, i); | |
e9edcee0 TI |
3690 | } |
3691 | } | |
3692 | ||
8d88bc3d | 3693 | static void alc880_auto_init_extra_out(struct hda_codec *codec) |
e9edcee0 TI |
3694 | { |
3695 | struct alc_spec *spec = codec->spec; | |
3696 | hda_nid_t pin; | |
3697 | ||
82bc955f | 3698 | pin = spec->autocfg.speaker_pins[0]; |
8d88bc3d TI |
3699 | if (pin) /* connect to front */ |
3700 | alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
eb06ed8f | 3701 | pin = spec->autocfg.hp_pins[0]; |
e9edcee0 TI |
3702 | if (pin) /* connect to front */ |
3703 | alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
3704 | } | |
3705 | ||
3706 | static void alc880_auto_init_analog_input(struct hda_codec *codec) | |
3707 | { | |
3708 | struct alc_spec *spec = codec->spec; | |
3709 | int i; | |
3710 | ||
3711 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
3712 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
3713 | if (alc880_is_input_pin(nid)) { | |
f12ab1e0 TI |
3714 | snd_hda_codec_write(codec, nid, 0, |
3715 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
3716 | i <= AUTO_PIN_FRONT_MIC ? | |
3717 | PIN_VREF80 : PIN_IN); | |
e9edcee0 | 3718 | if (nid != ALC880_PIN_CD_NID) |
f12ab1e0 TI |
3719 | snd_hda_codec_write(codec, nid, 0, |
3720 | AC_VERB_SET_AMP_GAIN_MUTE, | |
e9edcee0 TI |
3721 | AMP_OUT_MUTE); |
3722 | } | |
3723 | } | |
3724 | } | |
3725 | ||
3726 | /* parse the BIOS configuration and set up the alc_spec */ | |
f12ab1e0 TI |
3727 | /* return 1 if successful, 0 if the proper config is not found, |
3728 | * or a negative error code | |
3729 | */ | |
e9edcee0 TI |
3730 | static int alc880_parse_auto_config(struct hda_codec *codec) |
3731 | { | |
3732 | struct alc_spec *spec = codec->spec; | |
3733 | int err; | |
df694daa | 3734 | static hda_nid_t alc880_ignore[] = { 0x1d, 0 }; |
e9edcee0 | 3735 | |
f12ab1e0 TI |
3736 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
3737 | alc880_ignore); | |
3738 | if (err < 0) | |
e9edcee0 | 3739 | return err; |
f12ab1e0 | 3740 | if (!spec->autocfg.line_outs) |
e9edcee0 | 3741 | return 0; /* can't find valid BIOS pin config */ |
df694daa | 3742 | |
f12ab1e0 TI |
3743 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
3744 | if (err < 0) | |
3745 | return err; | |
3746 | err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
3747 | if (err < 0) | |
3748 | return err; | |
3749 | err = alc880_auto_create_extra_out(spec, | |
3750 | spec->autocfg.speaker_pins[0], | |
3751 | "Speaker"); | |
3752 | if (err < 0) | |
3753 | return err; | |
3754 | err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], | |
3755 | "Headphone"); | |
3756 | if (err < 0) | |
3757 | return err; | |
3758 | err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
3759 | if (err < 0) | |
e9edcee0 TI |
3760 | return err; |
3761 | ||
3762 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
3763 | ||
3764 | if (spec->autocfg.dig_out_pin) | |
3765 | spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; | |
3766 | if (spec->autocfg.dig_in_pin) | |
3767 | spec->dig_in_nid = ALC880_DIGIN_NID; | |
3768 | ||
3769 | if (spec->kctl_alloc) | |
3770 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
3771 | ||
3772 | spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs; | |
3773 | ||
a1e8d2da | 3774 | spec->num_mux_defs = 1; |
e9edcee0 TI |
3775 | spec->input_mux = &spec->private_imux; |
3776 | ||
3777 | return 1; | |
3778 | } | |
3779 | ||
ae6b813a TI |
3780 | /* additional initialization for auto-configuration model */ |
3781 | static void alc880_auto_init(struct hda_codec *codec) | |
e9edcee0 | 3782 | { |
f6c7e546 | 3783 | struct alc_spec *spec = codec->spec; |
e9edcee0 | 3784 | alc880_auto_init_multi_out(codec); |
8d88bc3d | 3785 | alc880_auto_init_extra_out(codec); |
e9edcee0 | 3786 | alc880_auto_init_analog_input(codec); |
f6c7e546 TI |
3787 | if (spec->unsol_event) |
3788 | alc_sku_automute(codec); | |
e9edcee0 TI |
3789 | } |
3790 | ||
3791 | /* | |
3792 | * OK, here we have finally the patch for ALC880 | |
3793 | */ | |
3794 | ||
1da177e4 LT |
3795 | static int patch_alc880(struct hda_codec *codec) |
3796 | { | |
3797 | struct alc_spec *spec; | |
3798 | int board_config; | |
df694daa | 3799 | int err; |
1da177e4 | 3800 | |
e560d8d8 | 3801 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
1da177e4 LT |
3802 | if (spec == NULL) |
3803 | return -ENOMEM; | |
3804 | ||
3805 | codec->spec = spec; | |
3806 | ||
f5fcc13c TI |
3807 | board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST, |
3808 | alc880_models, | |
3809 | alc880_cfg_tbl); | |
3810 | if (board_config < 0) { | |
9c7f852e TI |
3811 | printk(KERN_INFO "hda_codec: Unknown model for ALC880, " |
3812 | "trying auto-probe from BIOS...\n"); | |
e9edcee0 | 3813 | board_config = ALC880_AUTO; |
1da177e4 | 3814 | } |
1da177e4 | 3815 | |
e9edcee0 TI |
3816 | if (board_config == ALC880_AUTO) { |
3817 | /* automatic parse from the BIOS config */ | |
3818 | err = alc880_parse_auto_config(codec); | |
3819 | if (err < 0) { | |
3820 | alc_free(codec); | |
3821 | return err; | |
f12ab1e0 | 3822 | } else if (!err) { |
9c7f852e TI |
3823 | printk(KERN_INFO |
3824 | "hda_codec: Cannot set up configuration " | |
3825 | "from BIOS. Using 3-stack mode...\n"); | |
e9edcee0 TI |
3826 | board_config = ALC880_3ST; |
3827 | } | |
1da177e4 LT |
3828 | } |
3829 | ||
df694daa KY |
3830 | if (board_config != ALC880_AUTO) |
3831 | setup_preset(spec, &alc880_presets[board_config]); | |
1da177e4 LT |
3832 | |
3833 | spec->stream_name_analog = "ALC880 Analog"; | |
3834 | spec->stream_analog_playback = &alc880_pcm_analog_playback; | |
3835 | spec->stream_analog_capture = &alc880_pcm_analog_capture; | |
6330079f | 3836 | spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture; |
1da177e4 LT |
3837 | |
3838 | spec->stream_name_digital = "ALC880 Digital"; | |
3839 | spec->stream_digital_playback = &alc880_pcm_digital_playback; | |
3840 | spec->stream_digital_capture = &alc880_pcm_digital_capture; | |
3841 | ||
f12ab1e0 | 3842 | if (!spec->adc_nids && spec->input_mux) { |
e9edcee0 | 3843 | /* check whether NID 0x07 is valid */ |
54d17403 | 3844 | unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); |
f12ab1e0 TI |
3845 | /* get type */ |
3846 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
e9edcee0 TI |
3847 | if (wcap != AC_WID_AUD_IN) { |
3848 | spec->adc_nids = alc880_adc_nids_alt; | |
3849 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); | |
f12ab1e0 TI |
3850 | spec->mixers[spec->num_mixers] = |
3851 | alc880_capture_alt_mixer; | |
e9edcee0 TI |
3852 | spec->num_mixers++; |
3853 | } else { | |
3854 | spec->adc_nids = alc880_adc_nids; | |
3855 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids); | |
3856 | spec->mixers[spec->num_mixers] = alc880_capture_mixer; | |
3857 | spec->num_mixers++; | |
3858 | } | |
3859 | } | |
1da177e4 | 3860 | |
2134ea4f TI |
3861 | spec->vmaster_nid = 0x0c; |
3862 | ||
1da177e4 | 3863 | codec->patch_ops = alc_patch_ops; |
e9edcee0 | 3864 | if (board_config == ALC880_AUTO) |
ae6b813a | 3865 | spec->init_hook = alc880_auto_init; |
cb53c626 TI |
3866 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
3867 | if (!spec->loopback.amplist) | |
3868 | spec->loopback.amplist = alc880_loopbacks; | |
3869 | #endif | |
1da177e4 LT |
3870 | |
3871 | return 0; | |
3872 | } | |
3873 | ||
e9edcee0 | 3874 | |
1da177e4 LT |
3875 | /* |
3876 | * ALC260 support | |
3877 | */ | |
3878 | ||
e9edcee0 TI |
3879 | static hda_nid_t alc260_dac_nids[1] = { |
3880 | /* front */ | |
3881 | 0x02, | |
3882 | }; | |
3883 | ||
3884 | static hda_nid_t alc260_adc_nids[1] = { | |
3885 | /* ADC0 */ | |
3886 | 0x04, | |
3887 | }; | |
3888 | ||
df694daa | 3889 | static hda_nid_t alc260_adc_nids_alt[1] = { |
e9edcee0 TI |
3890 | /* ADC1 */ |
3891 | 0x05, | |
3892 | }; | |
3893 | ||
df694daa KY |
3894 | static hda_nid_t alc260_hp_adc_nids[2] = { |
3895 | /* ADC1, 0 */ | |
3896 | 0x05, 0x04 | |
3897 | }; | |
3898 | ||
d57fdac0 JW |
3899 | /* NIDs used when simultaneous access to both ADCs makes sense. Note that |
3900 | * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC. | |
3901 | */ | |
3902 | static hda_nid_t alc260_dual_adc_nids[2] = { | |
4c5186ed JW |
3903 | /* ADC0, ADC1 */ |
3904 | 0x04, 0x05 | |
3905 | }; | |
3906 | ||
e9edcee0 TI |
3907 | #define ALC260_DIGOUT_NID 0x03 |
3908 | #define ALC260_DIGIN_NID 0x06 | |
3909 | ||
3910 | static struct hda_input_mux alc260_capture_source = { | |
3911 | .num_items = 4, | |
3912 | .items = { | |
3913 | { "Mic", 0x0 }, | |
3914 | { "Front Mic", 0x1 }, | |
3915 | { "Line", 0x2 }, | |
3916 | { "CD", 0x4 }, | |
3917 | }, | |
3918 | }; | |
3919 | ||
17e7aec6 | 3920 | /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack, |
a1e8d2da JW |
3921 | * headphone jack and the internal CD lines since these are the only pins at |
3922 | * which audio can appear. For flexibility, also allow the option of | |
3923 | * recording the mixer output on the second ADC (ADC0 doesn't have a | |
3924 | * connection to the mixer output). | |
a9430dd8 | 3925 | */ |
a1e8d2da JW |
3926 | static struct hda_input_mux alc260_fujitsu_capture_sources[2] = { |
3927 | { | |
3928 | .num_items = 3, | |
3929 | .items = { | |
3930 | { "Mic/Line", 0x0 }, | |
3931 | { "CD", 0x4 }, | |
3932 | { "Headphone", 0x2 }, | |
3933 | }, | |
a9430dd8 | 3934 | }, |
a1e8d2da JW |
3935 | { |
3936 | .num_items = 4, | |
3937 | .items = { | |
3938 | { "Mic/Line", 0x0 }, | |
3939 | { "CD", 0x4 }, | |
3940 | { "Headphone", 0x2 }, | |
3941 | { "Mixer", 0x5 }, | |
3942 | }, | |
3943 | }, | |
3944 | ||
a9430dd8 JW |
3945 | }; |
3946 | ||
a1e8d2da JW |
3947 | /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to |
3948 | * the Fujitsu S702x, but jacks are marked differently. | |
0bfc90e9 | 3949 | */ |
a1e8d2da JW |
3950 | static struct hda_input_mux alc260_acer_capture_sources[2] = { |
3951 | { | |
3952 | .num_items = 4, | |
3953 | .items = { | |
3954 | { "Mic", 0x0 }, | |
3955 | { "Line", 0x2 }, | |
3956 | { "CD", 0x4 }, | |
3957 | { "Headphone", 0x5 }, | |
3958 | }, | |
3959 | }, | |
3960 | { | |
3961 | .num_items = 5, | |
3962 | .items = { | |
3963 | { "Mic", 0x0 }, | |
3964 | { "Line", 0x2 }, | |
3965 | { "CD", 0x4 }, | |
3966 | { "Headphone", 0x6 }, | |
3967 | { "Mixer", 0x5 }, | |
3968 | }, | |
0bfc90e9 JW |
3969 | }, |
3970 | }; | |
1da177e4 LT |
3971 | /* |
3972 | * This is just place-holder, so there's something for alc_build_pcms to look | |
3973 | * at when it calculates the maximum number of channels. ALC260 has no mixer | |
3974 | * element which allows changing the channel mode, so the verb list is | |
3975 | * never used. | |
3976 | */ | |
d2a6d7dc | 3977 | static struct hda_channel_mode alc260_modes[1] = { |
1da177e4 LT |
3978 | { 2, NULL }, |
3979 | }; | |
3980 | ||
df694daa KY |
3981 | |
3982 | /* Mixer combinations | |
3983 | * | |
3984 | * basic: base_output + input + pc_beep + capture | |
3985 | * HP: base_output + input + capture_alt | |
3986 | * HP_3013: hp_3013 + input + capture | |
3987 | * fujitsu: fujitsu + capture | |
0bfc90e9 | 3988 | * acer: acer + capture |
df694daa KY |
3989 | */ |
3990 | ||
3991 | static struct snd_kcontrol_new alc260_base_output_mixer[] = { | |
05acb863 | 3992 | HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
985be54b | 3993 | HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), |
05acb863 | 3994 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
985be54b | 3995 | HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), |
05acb863 | 3996 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
985be54b | 3997 | HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), |
1da177e4 | 3998 | { } /* end */ |
f12ab1e0 | 3999 | }; |
1da177e4 | 4000 | |
df694daa | 4001 | static struct snd_kcontrol_new alc260_input_mixer[] = { |
16ded525 TI |
4002 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
4003 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
4004 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4005 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4006 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4007 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4008 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT), | |
4009 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT), | |
df694daa KY |
4010 | { } /* end */ |
4011 | }; | |
4012 | ||
4013 | static struct snd_kcontrol_new alc260_pc_beep_mixer[] = { | |
4014 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT), | |
4015 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT), | |
4016 | { } /* end */ | |
4017 | }; | |
4018 | ||
bec15c3a TI |
4019 | /* update HP, line and mono out pins according to the master switch */ |
4020 | static void alc260_hp_master_update(struct hda_codec *codec, | |
4021 | hda_nid_t hp, hda_nid_t line, | |
4022 | hda_nid_t mono) | |
4023 | { | |
4024 | struct alc_spec *spec = codec->spec; | |
4025 | unsigned int val = spec->master_sw ? PIN_HP : 0; | |
4026 | /* change HP and line-out pins */ | |
4027 | snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4028 | val); | |
4029 | snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4030 | val); | |
4031 | /* mono (speaker) depending on the HP jack sense */ | |
4032 | val = (val && !spec->jack_present) ? PIN_OUT : 0; | |
4033 | snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4034 | val); | |
4035 | } | |
4036 | ||
4037 | static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol, | |
4038 | struct snd_ctl_elem_value *ucontrol) | |
4039 | { | |
4040 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
4041 | struct alc_spec *spec = codec->spec; | |
4042 | *ucontrol->value.integer.value = spec->master_sw; | |
4043 | return 0; | |
4044 | } | |
4045 | ||
4046 | static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |
4047 | struct snd_ctl_elem_value *ucontrol) | |
4048 | { | |
4049 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
4050 | struct alc_spec *spec = codec->spec; | |
4051 | int val = !!*ucontrol->value.integer.value; | |
4052 | hda_nid_t hp, line, mono; | |
4053 | ||
4054 | if (val == spec->master_sw) | |
4055 | return 0; | |
4056 | spec->master_sw = val; | |
4057 | hp = (kcontrol->private_value >> 16) & 0xff; | |
4058 | line = (kcontrol->private_value >> 8) & 0xff; | |
4059 | mono = kcontrol->private_value & 0xff; | |
4060 | alc260_hp_master_update(codec, hp, line, mono); | |
4061 | return 1; | |
4062 | } | |
4063 | ||
4064 | static struct snd_kcontrol_new alc260_hp_output_mixer[] = { | |
4065 | { | |
4066 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
4067 | .name = "Master Playback Switch", | |
4068 | .info = snd_ctl_boolean_mono_info, | |
4069 | .get = alc260_hp_master_sw_get, | |
4070 | .put = alc260_hp_master_sw_put, | |
4071 | .private_value = (0x0f << 16) | (0x10 << 8) | 0x11 | |
4072 | }, | |
4073 | HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4074 | HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), | |
4075 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), | |
4076 | HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), | |
4077 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, | |
4078 | HDA_OUTPUT), | |
4079 | HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT), | |
4080 | { } /* end */ | |
4081 | }; | |
4082 | ||
4083 | static struct hda_verb alc260_hp_unsol_verbs[] = { | |
4084 | {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
4085 | {}, | |
4086 | }; | |
4087 | ||
4088 | static void alc260_hp_automute(struct hda_codec *codec) | |
4089 | { | |
4090 | struct alc_spec *spec = codec->spec; | |
4091 | unsigned int present; | |
4092 | ||
4093 | present = snd_hda_codec_read(codec, 0x10, 0, | |
4094 | AC_VERB_GET_PIN_SENSE, 0); | |
4095 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; | |
4096 | alc260_hp_master_update(codec, 0x0f, 0x10, 0x11); | |
4097 | } | |
4098 | ||
4099 | static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res) | |
4100 | { | |
4101 | if ((res >> 26) == ALC880_HP_EVENT) | |
4102 | alc260_hp_automute(codec); | |
4103 | } | |
4104 | ||
df694daa | 4105 | static struct snd_kcontrol_new alc260_hp_3013_mixer[] = { |
bec15c3a TI |
4106 | { |
4107 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
4108 | .name = "Master Playback Switch", | |
4109 | .info = snd_ctl_boolean_mono_info, | |
4110 | .get = alc260_hp_master_sw_get, | |
4111 | .put = alc260_hp_master_sw_put, | |
4112 | .private_value = (0x10 << 16) | (0x15 << 8) | 0x11 | |
4113 | }, | |
df694daa KY |
4114 | HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
4115 | HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT), | |
4116 | HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT), | |
4117 | HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT), | |
4118 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4119 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
86cd9298 TI |
4120 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
4121 | HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT), | |
16ded525 TI |
4122 | { } /* end */ |
4123 | }; | |
4124 | ||
bec15c3a TI |
4125 | static struct hda_verb alc260_hp_3013_unsol_verbs[] = { |
4126 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
4127 | {}, | |
4128 | }; | |
4129 | ||
4130 | static void alc260_hp_3013_automute(struct hda_codec *codec) | |
4131 | { | |
4132 | struct alc_spec *spec = codec->spec; | |
4133 | unsigned int present; | |
4134 | ||
4135 | present = snd_hda_codec_read(codec, 0x15, 0, | |
4136 | AC_VERB_GET_PIN_SENSE, 0); | |
4137 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; | |
4138 | alc260_hp_master_update(codec, 0x10, 0x15, 0x11); | |
4139 | } | |
4140 | ||
4141 | static void alc260_hp_3013_unsol_event(struct hda_codec *codec, | |
4142 | unsigned int res) | |
4143 | { | |
4144 | if ((res >> 26) == ALC880_HP_EVENT) | |
4145 | alc260_hp_3013_automute(codec); | |
4146 | } | |
4147 | ||
a1e8d2da JW |
4148 | /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12, |
4149 | * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10. | |
4150 | */ | |
c8b6bf9b | 4151 | static struct snd_kcontrol_new alc260_fujitsu_mixer[] = { |
a9430dd8 | 4152 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
985be54b | 4153 | HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT), |
4c5186ed | 4154 | ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT), |
a9430dd8 JW |
4155 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
4156 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
4157 | HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4158 | HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4c5186ed | 4159 | ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN), |
a9430dd8 JW |
4160 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), |
4161 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
31bffaa9 TI |
4162 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
4163 | HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT), | |
df694daa KY |
4164 | { } /* end */ |
4165 | }; | |
4166 | ||
a1e8d2da JW |
4167 | /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current |
4168 | * versions of the ALC260 don't act on requests to enable mic bias from NID | |
4169 | * 0x0f (used to drive the headphone jack in these laptops). The ALC260 | |
4170 | * datasheet doesn't mention this restriction. At this stage it's not clear | |
4171 | * whether this behaviour is intentional or is a hardware bug in chip | |
4172 | * revisions available in early 2006. Therefore for now allow the | |
4173 | * "Headphone Jack Mode" control to span all choices, but if it turns out | |
4174 | * that the lack of mic bias for this NID is intentional we could change the | |
4175 | * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
4176 | * | |
4177 | * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006 | |
4178 | * don't appear to make the mic bias available from the "line" jack, even | |
4179 | * though the NID used for this jack (0x14) can supply it. The theory is | |
4180 | * that perhaps Acer have included blocking capacitors between the ALC260 | |
4181 | * and the output jack. If this turns out to be the case for all such | |
4182 | * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT | |
4183 | * to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
bd869485 JW |
4184 | * |
4185 | * The C20x Tablet series have a mono internal speaker which is controlled | |
4186 | * via the chip's Mono sum widget and pin complex, so include the necessary | |
4187 | * controls for such models. On models without a "mono speaker" the control | |
4188 | * won't do anything. | |
a1e8d2da | 4189 | */ |
0bfc90e9 JW |
4190 | static struct snd_kcontrol_new alc260_acer_mixer[] = { |
4191 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4192 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT), | |
a1e8d2da | 4193 | ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT), |
31bffaa9 | 4194 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, |
bd869485 | 4195 | HDA_OUTPUT), |
31bffaa9 | 4196 | HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, |
bd869485 | 4197 | HDA_INPUT), |
0bfc90e9 JW |
4198 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
4199 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
4200 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4201 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4202 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
4203 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4204 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4205 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
4206 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), | |
4207 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
4208 | { } /* end */ | |
4209 | }; | |
4210 | ||
bc9f98a9 KY |
4211 | /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12, |
4212 | * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17. | |
4213 | */ | |
4214 | static struct snd_kcontrol_new alc260_will_mixer[] = { | |
4215 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4216 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT), | |
4217 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4218 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4219 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
4220 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4221 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4222 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
4223 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), | |
4224 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
4225 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), | |
4226 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
4227 | { } /* end */ | |
4228 | }; | |
4229 | ||
4230 | /* Replacer 672V ALC260 pin usage: Mic jack = 0x12, | |
4231 | * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f. | |
4232 | */ | |
4233 | static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = { | |
4234 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4235 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT), | |
4236 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4237 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4238 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
4239 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT), | |
4240 | HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT), | |
4241 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4242 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4243 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
4244 | { } /* end */ | |
4245 | }; | |
4246 | ||
df694daa KY |
4247 | /* capture mixer elements */ |
4248 | static struct snd_kcontrol_new alc260_capture_mixer[] = { | |
a9430dd8 JW |
4249 | HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT), |
4250 | HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT), | |
df694daa KY |
4251 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT), |
4252 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT), | |
a9430dd8 JW |
4253 | { |
4254 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
df694daa KY |
4255 | /* The multiple "Capture Source" controls confuse alsamixer |
4256 | * So call somewhat different.. | |
df694daa KY |
4257 | */ |
4258 | /* .name = "Capture Source", */ | |
4259 | .name = "Input Source", | |
4260 | .count = 2, | |
4261 | .info = alc_mux_enum_info, | |
4262 | .get = alc_mux_enum_get, | |
4263 | .put = alc_mux_enum_put, | |
4264 | }, | |
4265 | { } /* end */ | |
4266 | }; | |
4267 | ||
4268 | static struct snd_kcontrol_new alc260_capture_alt_mixer[] = { | |
4269 | HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT), | |
4270 | HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT), | |
4271 | { | |
4272 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
4273 | /* The multiple "Capture Source" controls confuse alsamixer | |
4274 | * So call somewhat different.. | |
df694daa KY |
4275 | */ |
4276 | /* .name = "Capture Source", */ | |
4277 | .name = "Input Source", | |
4278 | .count = 1, | |
a9430dd8 JW |
4279 | .info = alc_mux_enum_info, |
4280 | .get = alc_mux_enum_get, | |
4281 | .put = alc_mux_enum_put, | |
4282 | }, | |
4283 | { } /* end */ | |
4284 | }; | |
4285 | ||
df694daa KY |
4286 | /* |
4287 | * initialization verbs | |
4288 | */ | |
1da177e4 LT |
4289 | static struct hda_verb alc260_init_verbs[] = { |
4290 | /* Line In pin widget for input */ | |
05acb863 | 4291 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 4292 | /* CD pin widget for input */ |
05acb863 | 4293 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 4294 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
16ded525 | 4295 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1da177e4 | 4296 | /* Mic2 (front panel) pin widget for input and vref at 80% */ |
16ded525 | 4297 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1da177e4 | 4298 | /* LINE-2 is used for line-out in rear */ |
05acb863 | 4299 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1da177e4 | 4300 | /* select line-out */ |
fd56f2db | 4301 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00}, |
1da177e4 | 4302 | /* LINE-OUT pin */ |
05acb863 | 4303 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1da177e4 | 4304 | /* enable HP */ |
05acb863 | 4305 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
1da177e4 | 4306 | /* enable Mono */ |
05acb863 TI |
4307 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
4308 | /* mute capture amp left and right */ | |
16ded525 | 4309 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1da177e4 LT |
4310 | /* set connection select to line in (default select for this ADC) */ |
4311 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
16ded525 TI |
4312 | /* mute capture amp left and right */ |
4313 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4314 | /* set connection select to line in (default select for this ADC) */ | |
4315 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
05acb863 TI |
4316 | /* set vol=0 Line-Out mixer amp left and right */ |
4317 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4318 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
4319 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4320 | /* set vol=0 HP mixer amp left and right */ | |
4321 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4322 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
4323 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4324 | /* set vol=0 Mono mixer amp left and right */ | |
4325 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4326 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
4327 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4328 | /* unmute LINE-2 out pin */ | |
4329 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
f12ab1e0 TI |
4330 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
4331 | * Line In 2 = 0x03 | |
4332 | */ | |
cb53c626 TI |
4333 | /* mute analog inputs */ |
4334 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4335 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4336 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4337 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4338 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 4339 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
05acb863 TI |
4340 | /* mute Front out path */ |
4341 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4342 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4343 | /* mute Headphone out path */ | |
4344 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4345 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4346 | /* mute Mono out path */ | |
4347 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4348 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 LT |
4349 | { } |
4350 | }; | |
4351 | ||
474167d6 | 4352 | #if 0 /* should be identical with alc260_init_verbs? */ |
df694daa KY |
4353 | static struct hda_verb alc260_hp_init_verbs[] = { |
4354 | /* Headphone and output */ | |
4355 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
4356 | /* mono output */ | |
4357 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
4358 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
4359 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
4360 | /* Mic2 (front panel) pin widget for input and vref at 80% */ | |
4361 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
4362 | /* Line In pin widget for input */ | |
4363 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
4364 | /* Line-2 pin widget for output */ | |
4365 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
4366 | /* CD pin widget for input */ | |
4367 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
4368 | /* unmute amp left and right */ | |
4369 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | |
4370 | /* set connection select to line in (default select for this ADC) */ | |
4371 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
4372 | /* unmute Line-Out mixer amp left and right (volume = 0) */ | |
4373 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
4374 | /* mute pin widget amp left and right (no gain on this amp) */ | |
4375 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
4376 | /* unmute HP mixer amp left and right (volume = 0) */ | |
4377 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
4378 | /* mute pin widget amp left and right (no gain on this amp) */ | |
4379 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
f12ab1e0 TI |
4380 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
4381 | * Line In 2 = 0x03 | |
4382 | */ | |
cb53c626 TI |
4383 | /* mute analog inputs */ |
4384 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4385 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4386 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4387 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4388 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
4389 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
4390 | /* Unmute Front out path */ | |
4391 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4392 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4393 | /* Unmute Headphone out path */ | |
4394 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4395 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4396 | /* Unmute Mono out path */ | |
4397 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4398 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4399 | { } | |
4400 | }; | |
474167d6 | 4401 | #endif |
df694daa KY |
4402 | |
4403 | static struct hda_verb alc260_hp_3013_init_verbs[] = { | |
4404 | /* Line out and output */ | |
4405 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
4406 | /* mono output */ | |
4407 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
4408 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
4409 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
4410 | /* Mic2 (front panel) pin widget for input and vref at 80% */ | |
4411 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
4412 | /* Line In pin widget for input */ | |
4413 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
4414 | /* Headphone pin widget for output */ | |
4415 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
4416 | /* CD pin widget for input */ | |
4417 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
4418 | /* unmute amp left and right */ | |
4419 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | |
4420 | /* set connection select to line in (default select for this ADC) */ | |
4421 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
4422 | /* unmute Line-Out mixer amp left and right (volume = 0) */ | |
4423 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
4424 | /* mute pin widget amp left and right (no gain on this amp) */ | |
4425 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
4426 | /* unmute HP mixer amp left and right (volume = 0) */ | |
4427 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
4428 | /* mute pin widget amp left and right (no gain on this amp) */ | |
4429 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
f12ab1e0 TI |
4430 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
4431 | * Line In 2 = 0x03 | |
4432 | */ | |
cb53c626 TI |
4433 | /* mute analog inputs */ |
4434 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4435 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4436 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4437 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4438 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
4439 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
4440 | /* Unmute Front out path */ | |
4441 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4442 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4443 | /* Unmute Headphone out path */ | |
4444 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4445 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4446 | /* Unmute Mono out path */ | |
4447 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4448 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4449 | { } | |
4450 | }; | |
4451 | ||
a9430dd8 | 4452 | /* Initialisation sequence for ALC260 as configured in Fujitsu S702x |
a1e8d2da JW |
4453 | * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD |
4454 | * audio = 0x16, internal speaker = 0x10. | |
a9430dd8 JW |
4455 | */ |
4456 | static struct hda_verb alc260_fujitsu_init_verbs[] = { | |
4457 | /* Disable all GPIOs */ | |
4458 | {0x01, AC_VERB_SET_GPIO_MASK, 0}, | |
4459 | /* Internal speaker is connected to headphone pin */ | |
4460 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
4461 | /* Headphone/Line-out jack connects to Line1 pin; make it an output */ | |
4462 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
f7ace40d JW |
4463 | /* Mic/Line-in jack is connected to mic1 pin, so make it an input */ |
4464 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
4465 | /* Ensure all other unused pins are disabled and muted. */ | |
4466 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
4467 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
a9430dd8 | 4468 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
f7ace40d | 4469 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
a9430dd8 | 4470 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
f7ace40d JW |
4471 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
4472 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
4473 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4474 | ||
4475 | /* Disable digital (SPDIF) pins */ | |
4476 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
4477 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
a9430dd8 | 4478 | |
f7ace40d JW |
4479 | /* Ensure Line1 pin widget takes its input from the OUT1 sum bus |
4480 | * when acting as an output. | |
4481 | */ | |
4482 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
4c5186ed | 4483 | |
f7ace40d | 4484 | /* Start with output sum widgets muted and their output gains at min */ |
8b33a5aa TI |
4485 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
4486 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4487 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4488 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4489 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4490 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4491 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4492 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4493 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
a9430dd8 | 4494 | |
f7ace40d JW |
4495 | /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */ |
4496 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4497 | /* Unmute Line1 pin widget output buffer since it starts as an output. | |
4498 | * If the pin mode is changed by the user the pin mode control will | |
4499 | * take care of enabling the pin's input/output buffers as needed. | |
4500 | * Therefore there's no need to enable the input buffer at this | |
4501 | * stage. | |
cdcd9268 | 4502 | */ |
f7ace40d | 4503 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
cdcd9268 JW |
4504 | /* Unmute input buffer of pin widget used for Line-in (no equiv |
4505 | * mixer ctrl) | |
4506 | */ | |
f7ace40d JW |
4507 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
4508 | ||
4509 | /* Mute capture amp left and right */ | |
4510 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4511 | /* Set ADC connection select to match default mixer setting - line | |
4512 | * in (on mic1 pin) | |
4513 | */ | |
4514 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4515 | ||
4516 | /* Do the same for the second ADC: mute capture input amp and | |
4517 | * set ADC connection to line in (on mic1 pin) | |
4518 | */ | |
4519 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4520 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4521 | ||
4522 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
4523 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
4524 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
4525 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
4526 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
4527 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
4528 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
4529 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
4530 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
4a471b7d TI |
4531 | |
4532 | { } | |
a9430dd8 JW |
4533 | }; |
4534 | ||
0bfc90e9 JW |
4535 | /* Initialisation sequence for ALC260 as configured in Acer TravelMate and |
4536 | * similar laptops (adapted from Fujitsu init verbs). | |
4537 | */ | |
4538 | static struct hda_verb alc260_acer_init_verbs[] = { | |
4539 | /* On TravelMate laptops, GPIO 0 enables the internal speaker and | |
4540 | * the headphone jack. Turn this on and rely on the standard mute | |
4541 | * methods whenever the user wants to turn these outputs off. | |
4542 | */ | |
4543 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
4544 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
4545 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, | |
4546 | /* Internal speaker/Headphone jack is connected to Line-out pin */ | |
4547 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
4548 | /* Internal microphone/Mic jack is connected to Mic1 pin */ | |
4549 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | |
4550 | /* Line In jack is connected to Line1 pin */ | |
4551 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
bd869485 JW |
4552 | /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */ |
4553 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
0bfc90e9 JW |
4554 | /* Ensure all other unused pins are disabled and muted. */ |
4555 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
4556 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
0bfc90e9 JW |
4557 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
4558 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4559 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
4560 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4561 | /* Disable digital (SPDIF) pins */ | |
4562 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
4563 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
4564 | ||
4565 | /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum | |
4566 | * bus when acting as outputs. | |
4567 | */ | |
4568 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, | |
4569 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
4570 | ||
4571 | /* Start with output sum widgets muted and their output gains at min */ | |
4572 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4573 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4574 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4575 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4576 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4577 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4578 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4579 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4580 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4581 | ||
f12ab1e0 TI |
4582 | /* Unmute Line-out pin widget amp left and right |
4583 | * (no equiv mixer ctrl) | |
4584 | */ | |
0bfc90e9 | 4585 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
bd869485 JW |
4586 | /* Unmute mono pin widget amp output (no equiv mixer ctrl) */ |
4587 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
0bfc90e9 JW |
4588 | /* Unmute Mic1 and Line1 pin widget input buffers since they start as |
4589 | * inputs. If the pin mode is changed by the user the pin mode control | |
4590 | * will take care of enabling the pin's input/output buffers as needed. | |
4591 | * Therefore there's no need to enable the input buffer at this | |
4592 | * stage. | |
4593 | */ | |
4594 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4595 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4596 | ||
4597 | /* Mute capture amp left and right */ | |
4598 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4599 | /* Set ADC connection select to match default mixer setting - mic | |
4600 | * (on mic1 pin) | |
4601 | */ | |
4602 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4603 | ||
4604 | /* Do similar with the second ADC: mute capture input amp and | |
a1e8d2da | 4605 | * set ADC connection to mic to match ALSA's default state. |
0bfc90e9 JW |
4606 | */ |
4607 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
a1e8d2da | 4608 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, |
0bfc90e9 JW |
4609 | |
4610 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
4611 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
4612 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
4613 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
4614 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
4615 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
4616 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
4617 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
4618 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
4619 | ||
4620 | { } | |
4621 | }; | |
4622 | ||
bc9f98a9 KY |
4623 | static struct hda_verb alc260_will_verbs[] = { |
4624 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
4625 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4626 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4627 | {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, | |
4628 | {0x1a, AC_VERB_SET_COEF_INDEX, 0x07}, | |
4629 | {0x1a, AC_VERB_SET_PROC_COEF, 0x3040}, | |
4630 | {} | |
4631 | }; | |
4632 | ||
4633 | static struct hda_verb alc260_replacer_672v_verbs[] = { | |
4634 | {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, | |
4635 | {0x1a, AC_VERB_SET_COEF_INDEX, 0x07}, | |
4636 | {0x1a, AC_VERB_SET_PROC_COEF, 0x3050}, | |
4637 | ||
4638 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
4639 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
4640 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, | |
4641 | ||
4642 | {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
4643 | {} | |
4644 | }; | |
4645 | ||
4646 | /* toggle speaker-output according to the hp-jack state */ | |
4647 | static void alc260_replacer_672v_automute(struct hda_codec *codec) | |
4648 | { | |
4649 | unsigned int present; | |
4650 | ||
4651 | /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */ | |
4652 | present = snd_hda_codec_read(codec, 0x0f, 0, | |
4653 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
4654 | if (present) { | |
82beb8fd TI |
4655 | snd_hda_codec_write_cache(codec, 0x01, 0, |
4656 | AC_VERB_SET_GPIO_DATA, 1); | |
4657 | snd_hda_codec_write_cache(codec, 0x0f, 0, | |
4658 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4659 | PIN_HP); | |
bc9f98a9 | 4660 | } else { |
82beb8fd TI |
4661 | snd_hda_codec_write_cache(codec, 0x01, 0, |
4662 | AC_VERB_SET_GPIO_DATA, 0); | |
4663 | snd_hda_codec_write_cache(codec, 0x0f, 0, | |
4664 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4665 | PIN_OUT); | |
bc9f98a9 KY |
4666 | } |
4667 | } | |
4668 | ||
4669 | static void alc260_replacer_672v_unsol_event(struct hda_codec *codec, | |
4670 | unsigned int res) | |
4671 | { | |
4672 | if ((res >> 26) == ALC880_HP_EVENT) | |
4673 | alc260_replacer_672v_automute(codec); | |
4674 | } | |
4675 | ||
7cf51e48 JW |
4676 | /* Test configuration for debugging, modelled after the ALC880 test |
4677 | * configuration. | |
4678 | */ | |
4679 | #ifdef CONFIG_SND_DEBUG | |
4680 | static hda_nid_t alc260_test_dac_nids[1] = { | |
4681 | 0x02, | |
4682 | }; | |
4683 | static hda_nid_t alc260_test_adc_nids[2] = { | |
4684 | 0x04, 0x05, | |
4685 | }; | |
a1e8d2da JW |
4686 | /* For testing the ALC260, each input MUX needs its own definition since |
4687 | * the signal assignments are different. This assumes that the first ADC | |
4688 | * is NID 0x04. | |
17e7aec6 | 4689 | */ |
a1e8d2da JW |
4690 | static struct hda_input_mux alc260_test_capture_sources[2] = { |
4691 | { | |
4692 | .num_items = 7, | |
4693 | .items = { | |
4694 | { "MIC1 pin", 0x0 }, | |
4695 | { "MIC2 pin", 0x1 }, | |
4696 | { "LINE1 pin", 0x2 }, | |
4697 | { "LINE2 pin", 0x3 }, | |
4698 | { "CD pin", 0x4 }, | |
4699 | { "LINE-OUT pin", 0x5 }, | |
4700 | { "HP-OUT pin", 0x6 }, | |
4701 | }, | |
4702 | }, | |
4703 | { | |
4704 | .num_items = 8, | |
4705 | .items = { | |
4706 | { "MIC1 pin", 0x0 }, | |
4707 | { "MIC2 pin", 0x1 }, | |
4708 | { "LINE1 pin", 0x2 }, | |
4709 | { "LINE2 pin", 0x3 }, | |
4710 | { "CD pin", 0x4 }, | |
4711 | { "Mixer", 0x5 }, | |
4712 | { "LINE-OUT pin", 0x6 }, | |
4713 | { "HP-OUT pin", 0x7 }, | |
4714 | }, | |
7cf51e48 JW |
4715 | }, |
4716 | }; | |
4717 | static struct snd_kcontrol_new alc260_test_mixer[] = { | |
4718 | /* Output driver widgets */ | |
4719 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), | |
4720 | HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), | |
4721 | HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT), | |
4722 | HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT), | |
4723 | HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4724 | HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT), | |
4725 | ||
a1e8d2da JW |
4726 | /* Modes for retasking pin widgets |
4727 | * Note: the ALC260 doesn't seem to act on requests to enable mic | |
4728 | * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't | |
4729 | * mention this restriction. At this stage it's not clear whether | |
4730 | * this behaviour is intentional or is a hardware bug in chip | |
4731 | * revisions available at least up until early 2006. Therefore for | |
4732 | * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all | |
4733 | * choices, but if it turns out that the lack of mic bias for these | |
4734 | * NIDs is intentional we could change their modes from | |
4735 | * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
4736 | */ | |
7cf51e48 JW |
4737 | ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT), |
4738 | ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT), | |
4739 | ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT), | |
4740 | ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT), | |
4741 | ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT), | |
4742 | ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT), | |
4743 | ||
4744 | /* Loopback mixer controls */ | |
4745 | HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT), | |
4746 | HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT), | |
4747 | HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT), | |
4748 | HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT), | |
4749 | HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4750 | HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4751 | HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT), | |
4752 | HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT), | |
4753 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), | |
4754 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
4755 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), | |
4756 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
4757 | HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT), | |
4758 | HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT), | |
4759 | HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT), | |
4760 | HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT), | |
5c8f858d JW |
4761 | |
4762 | /* Controls for GPIO pins, assuming they are configured as outputs */ | |
4763 | ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01), | |
4764 | ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02), | |
4765 | ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04), | |
4766 | ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08), | |
4767 | ||
92621f13 JW |
4768 | /* Switches to allow the digital IO pins to be enabled. The datasheet |
4769 | * is ambigious as to which NID is which; testing on laptops which | |
4770 | * make this output available should provide clarification. | |
4771 | */ | |
4772 | ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01), | |
4773 | ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01), | |
4774 | ||
f8225f6d JW |
4775 | /* A switch allowing EAPD to be enabled. Some laptops seem to use |
4776 | * this output to turn on an external amplifier. | |
4777 | */ | |
4778 | ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02), | |
4779 | ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02), | |
4780 | ||
7cf51e48 JW |
4781 | { } /* end */ |
4782 | }; | |
4783 | static struct hda_verb alc260_test_init_verbs[] = { | |
5c8f858d JW |
4784 | /* Enable all GPIOs as outputs with an initial value of 0 */ |
4785 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f}, | |
4786 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, | |
4787 | {0x01, AC_VERB_SET_GPIO_MASK, 0x0f}, | |
4788 | ||
7cf51e48 JW |
4789 | /* Enable retasking pins as output, initially without power amp */ |
4790 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4791 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4792 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4793 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4794 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4795 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4796 | ||
92621f13 JW |
4797 | /* Disable digital (SPDIF) pins initially, but users can enable |
4798 | * them via a mixer switch. In the case of SPDIF-out, this initverb | |
4799 | * payload also sets the generation to 0, output to be in "consumer" | |
4800 | * PCM format, copyright asserted, no pre-emphasis and no validity | |
4801 | * control. | |
4802 | */ | |
7cf51e48 JW |
4803 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, |
4804 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
4805 | ||
f7ace40d | 4806 | /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the |
7cf51e48 JW |
4807 | * OUT1 sum bus when acting as an output. |
4808 | */ | |
4809 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, | |
4810 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0}, | |
4811 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
4812 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0}, | |
4813 | ||
4814 | /* Start with output sum widgets muted and their output gains at min */ | |
4815 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4816 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4817 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4818 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4819 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4820 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4821 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4822 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4823 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4824 | ||
cdcd9268 JW |
4825 | /* Unmute retasking pin widget output buffers since the default |
4826 | * state appears to be output. As the pin mode is changed by the | |
4827 | * user the pin mode control will take care of enabling the pin's | |
4828 | * input/output buffers as needed. | |
4829 | */ | |
7cf51e48 JW |
4830 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
4831 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4832 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4833 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4834 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4835 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4836 | /* Also unmute the mono-out pin widget */ | |
4837 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4838 | ||
7cf51e48 JW |
4839 | /* Mute capture amp left and right */ |
4840 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
f7ace40d JW |
4841 | /* Set ADC connection select to match default mixer setting (mic1 |
4842 | * pin) | |
7cf51e48 JW |
4843 | */ |
4844 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4845 | ||
4846 | /* Do the same for the second ADC: mute capture input amp and | |
f7ace40d | 4847 | * set ADC connection to mic1 pin |
7cf51e48 JW |
4848 | */ |
4849 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4850 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4851 | ||
4852 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
4853 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
4854 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
4855 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
4856 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
4857 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
4858 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
4859 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
4860 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
4861 | ||
4862 | { } | |
4863 | }; | |
4864 | #endif | |
4865 | ||
6330079f TI |
4866 | #define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback |
4867 | #define alc260_pcm_analog_capture alc880_pcm_analog_capture | |
1da177e4 | 4868 | |
a3bcba38 TI |
4869 | #define alc260_pcm_digital_playback alc880_pcm_digital_playback |
4870 | #define alc260_pcm_digital_capture alc880_pcm_digital_capture | |
4871 | ||
df694daa KY |
4872 | /* |
4873 | * for BIOS auto-configuration | |
4874 | */ | |
16ded525 | 4875 | |
df694daa KY |
4876 | static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid, |
4877 | const char *pfx) | |
4878 | { | |
4879 | hda_nid_t nid_vol; | |
4880 | unsigned long vol_val, sw_val; | |
4881 | char name[32]; | |
4882 | int err; | |
4883 | ||
4884 | if (nid >= 0x0f && nid < 0x11) { | |
4885 | nid_vol = nid - 0x7; | |
4886 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); | |
4887 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); | |
4888 | } else if (nid == 0x11) { | |
4889 | nid_vol = nid - 0x7; | |
4890 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT); | |
4891 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT); | |
4892 | } else if (nid >= 0x12 && nid <= 0x15) { | |
4893 | nid_vol = 0x08; | |
4894 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); | |
4895 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); | |
4896 | } else | |
4897 | return 0; /* N/A */ | |
4898 | ||
4899 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); | |
f12ab1e0 TI |
4900 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val); |
4901 | if (err < 0) | |
df694daa KY |
4902 | return err; |
4903 | snprintf(name, sizeof(name), "%s Playback Switch", pfx); | |
f12ab1e0 TI |
4904 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val); |
4905 | if (err < 0) | |
df694daa KY |
4906 | return err; |
4907 | return 1; | |
4908 | } | |
4909 | ||
4910 | /* add playback controls from the parsed DAC table */ | |
4911 | static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec, | |
4912 | const struct auto_pin_cfg *cfg) | |
4913 | { | |
4914 | hda_nid_t nid; | |
4915 | int err; | |
4916 | ||
4917 | spec->multiout.num_dacs = 1; | |
4918 | spec->multiout.dac_nids = spec->private_dac_nids; | |
4919 | spec->multiout.dac_nids[0] = 0x02; | |
4920 | ||
4921 | nid = cfg->line_out_pins[0]; | |
4922 | if (nid) { | |
4923 | err = alc260_add_playback_controls(spec, nid, "Front"); | |
4924 | if (err < 0) | |
4925 | return err; | |
4926 | } | |
4927 | ||
82bc955f | 4928 | nid = cfg->speaker_pins[0]; |
df694daa KY |
4929 | if (nid) { |
4930 | err = alc260_add_playback_controls(spec, nid, "Speaker"); | |
4931 | if (err < 0) | |
4932 | return err; | |
4933 | } | |
4934 | ||
eb06ed8f | 4935 | nid = cfg->hp_pins[0]; |
df694daa KY |
4936 | if (nid) { |
4937 | err = alc260_add_playback_controls(spec, nid, "Headphone"); | |
4938 | if (err < 0) | |
4939 | return err; | |
4940 | } | |
f12ab1e0 | 4941 | return 0; |
df694daa KY |
4942 | } |
4943 | ||
4944 | /* create playback/capture controls for input pins */ | |
4945 | static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec, | |
4946 | const struct auto_pin_cfg *cfg) | |
4947 | { | |
df694daa KY |
4948 | struct hda_input_mux *imux = &spec->private_imux; |
4949 | int i, err, idx; | |
4950 | ||
4951 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
4952 | if (cfg->input_pins[i] >= 0x12) { | |
4953 | idx = cfg->input_pins[i] - 0x12; | |
4a471b7d | 4954 | err = new_analog_input(spec, cfg->input_pins[i], |
f12ab1e0 TI |
4955 | auto_pin_cfg_labels[i], idx, |
4956 | 0x07); | |
df694daa KY |
4957 | if (err < 0) |
4958 | return err; | |
f12ab1e0 TI |
4959 | imux->items[imux->num_items].label = |
4960 | auto_pin_cfg_labels[i]; | |
df694daa KY |
4961 | imux->items[imux->num_items].index = idx; |
4962 | imux->num_items++; | |
4963 | } | |
f12ab1e0 | 4964 | if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){ |
df694daa | 4965 | idx = cfg->input_pins[i] - 0x09; |
4a471b7d | 4966 | err = new_analog_input(spec, cfg->input_pins[i], |
f12ab1e0 TI |
4967 | auto_pin_cfg_labels[i], idx, |
4968 | 0x07); | |
df694daa KY |
4969 | if (err < 0) |
4970 | return err; | |
f12ab1e0 TI |
4971 | imux->items[imux->num_items].label = |
4972 | auto_pin_cfg_labels[i]; | |
df694daa KY |
4973 | imux->items[imux->num_items].index = idx; |
4974 | imux->num_items++; | |
4975 | } | |
4976 | } | |
4977 | return 0; | |
4978 | } | |
4979 | ||
4980 | static void alc260_auto_set_output_and_unmute(struct hda_codec *codec, | |
4981 | hda_nid_t nid, int pin_type, | |
4982 | int sel_idx) | |
4983 | { | |
f6c7e546 | 4984 | alc_set_pin_output(codec, nid, pin_type); |
df694daa KY |
4985 | /* need the manual connection? */ |
4986 | if (nid >= 0x12) { | |
4987 | int idx = nid - 0x12; | |
4988 | snd_hda_codec_write(codec, idx + 0x0b, 0, | |
4989 | AC_VERB_SET_CONNECT_SEL, sel_idx); | |
df694daa KY |
4990 | } |
4991 | } | |
4992 | ||
4993 | static void alc260_auto_init_multi_out(struct hda_codec *codec) | |
4994 | { | |
4995 | struct alc_spec *spec = codec->spec; | |
4996 | hda_nid_t nid; | |
4997 | ||
bc9f98a9 | 4998 | alc_subsystem_id(codec, 0x10, 0x15, 0x0f); |
f12ab1e0 | 4999 | nid = spec->autocfg.line_out_pins[0]; |
baba8ee9 TI |
5000 | if (nid) { |
5001 | int pin_type = get_pin_type(spec->autocfg.line_out_type); | |
5002 | alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0); | |
5003 | } | |
df694daa | 5004 | |
82bc955f | 5005 | nid = spec->autocfg.speaker_pins[0]; |
df694daa KY |
5006 | if (nid) |
5007 | alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); | |
5008 | ||
eb06ed8f | 5009 | nid = spec->autocfg.hp_pins[0]; |
df694daa | 5010 | if (nid) |
baba8ee9 | 5011 | alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0); |
f12ab1e0 | 5012 | } |
df694daa KY |
5013 | |
5014 | #define ALC260_PIN_CD_NID 0x16 | |
5015 | static void alc260_auto_init_analog_input(struct hda_codec *codec) | |
5016 | { | |
5017 | struct alc_spec *spec = codec->spec; | |
5018 | int i; | |
5019 | ||
5020 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
5021 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
5022 | if (nid >= 0x12) { | |
f12ab1e0 TI |
5023 | snd_hda_codec_write(codec, nid, 0, |
5024 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
5025 | i <= AUTO_PIN_FRONT_MIC ? | |
5026 | PIN_VREF80 : PIN_IN); | |
df694daa | 5027 | if (nid != ALC260_PIN_CD_NID) |
f12ab1e0 TI |
5028 | snd_hda_codec_write(codec, nid, 0, |
5029 | AC_VERB_SET_AMP_GAIN_MUTE, | |
df694daa KY |
5030 | AMP_OUT_MUTE); |
5031 | } | |
5032 | } | |
5033 | } | |
5034 | ||
5035 | /* | |
5036 | * generic initialization of ADC, input mixers and output mixers | |
5037 | */ | |
5038 | static struct hda_verb alc260_volume_init_verbs[] = { | |
5039 | /* | |
5040 | * Unmute ADC0-1 and set the default input to mic-in | |
5041 | */ | |
5042 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5043 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5044 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5045 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5046 | ||
5047 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | |
5048 | * mixer widget | |
f12ab1e0 TI |
5049 | * Note: PASD motherboards uses the Line In 2 as the input for |
5050 | * front panel mic (mic 2) | |
df694daa KY |
5051 | */ |
5052 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
5053 | /* mute analog inputs */ |
5054 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5055 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5056 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5057 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5058 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
5059 | |
5060 | /* | |
5061 | * Set up output mixers (0x08 - 0x0a) | |
5062 | */ | |
5063 | /* set vol=0 to output mixers */ | |
5064 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5065 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5066 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5067 | /* set up input amps for analog loopback */ | |
5068 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
5069 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5070 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5071 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5072 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5073 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5074 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5075 | ||
5076 | { } | |
5077 | }; | |
5078 | ||
5079 | static int alc260_parse_auto_config(struct hda_codec *codec) | |
5080 | { | |
5081 | struct alc_spec *spec = codec->spec; | |
5082 | unsigned int wcap; | |
5083 | int err; | |
5084 | static hda_nid_t alc260_ignore[] = { 0x17, 0 }; | |
5085 | ||
f12ab1e0 TI |
5086 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
5087 | alc260_ignore); | |
5088 | if (err < 0) | |
df694daa | 5089 | return err; |
f12ab1e0 TI |
5090 | err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg); |
5091 | if (err < 0) | |
4a471b7d | 5092 | return err; |
f12ab1e0 | 5093 | if (!spec->kctl_alloc) |
df694daa | 5094 | return 0; /* can't find valid BIOS pin config */ |
f12ab1e0 TI |
5095 | err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg); |
5096 | if (err < 0) | |
df694daa KY |
5097 | return err; |
5098 | ||
5099 | spec->multiout.max_channels = 2; | |
5100 | ||
5101 | if (spec->autocfg.dig_out_pin) | |
5102 | spec->multiout.dig_out_nid = ALC260_DIGOUT_NID; | |
5103 | if (spec->kctl_alloc) | |
5104 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
5105 | ||
5106 | spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs; | |
5107 | ||
a1e8d2da | 5108 | spec->num_mux_defs = 1; |
df694daa KY |
5109 | spec->input_mux = &spec->private_imux; |
5110 | ||
5111 | /* check whether NID 0x04 is valid */ | |
4a471b7d | 5112 | wcap = get_wcaps(codec, 0x04); |
df694daa | 5113 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ |
67ebcb03 | 5114 | if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) { |
df694daa KY |
5115 | spec->adc_nids = alc260_adc_nids_alt; |
5116 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt); | |
5117 | spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer; | |
df694daa KY |
5118 | } else { |
5119 | spec->adc_nids = alc260_adc_nids; | |
5120 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); | |
5121 | spec->mixers[spec->num_mixers] = alc260_capture_mixer; | |
df694daa | 5122 | } |
4a471b7d | 5123 | spec->num_mixers++; |
df694daa KY |
5124 | |
5125 | return 1; | |
5126 | } | |
5127 | ||
ae6b813a TI |
5128 | /* additional initialization for auto-configuration model */ |
5129 | static void alc260_auto_init(struct hda_codec *codec) | |
df694daa | 5130 | { |
f6c7e546 | 5131 | struct alc_spec *spec = codec->spec; |
df694daa KY |
5132 | alc260_auto_init_multi_out(codec); |
5133 | alc260_auto_init_analog_input(codec); | |
f6c7e546 TI |
5134 | if (spec->unsol_event) |
5135 | alc_sku_automute(codec); | |
df694daa KY |
5136 | } |
5137 | ||
cb53c626 TI |
5138 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
5139 | static struct hda_amp_list alc260_loopbacks[] = { | |
5140 | { 0x07, HDA_INPUT, 0 }, | |
5141 | { 0x07, HDA_INPUT, 1 }, | |
5142 | { 0x07, HDA_INPUT, 2 }, | |
5143 | { 0x07, HDA_INPUT, 3 }, | |
5144 | { 0x07, HDA_INPUT, 4 }, | |
5145 | { } /* end */ | |
5146 | }; | |
5147 | #endif | |
5148 | ||
df694daa KY |
5149 | /* |
5150 | * ALC260 configurations | |
5151 | */ | |
f5fcc13c TI |
5152 | static const char *alc260_models[ALC260_MODEL_LAST] = { |
5153 | [ALC260_BASIC] = "basic", | |
5154 | [ALC260_HP] = "hp", | |
5155 | [ALC260_HP_3013] = "hp-3013", | |
5156 | [ALC260_FUJITSU_S702X] = "fujitsu", | |
5157 | [ALC260_ACER] = "acer", | |
bc9f98a9 KY |
5158 | [ALC260_WILL] = "will", |
5159 | [ALC260_REPLACER_672V] = "replacer", | |
7cf51e48 | 5160 | #ifdef CONFIG_SND_DEBUG |
f5fcc13c | 5161 | [ALC260_TEST] = "test", |
7cf51e48 | 5162 | #endif |
f5fcc13c TI |
5163 | [ALC260_AUTO] = "auto", |
5164 | }; | |
5165 | ||
5166 | static struct snd_pci_quirk alc260_cfg_tbl[] = { | |
bd869485 | 5167 | SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER), |
f5fcc13c | 5168 | SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER), |
9720b718 | 5169 | SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013), |
a8a5d067 | 5170 | SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013), |
f5fcc13c | 5171 | SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013), |
34ec8a0a | 5172 | SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013), |
f5fcc13c TI |
5173 | SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013), |
5174 | SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013), | |
5175 | SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP), | |
5176 | SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP), | |
5177 | SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP), | |
5178 | SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC), | |
5179 | SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC), | |
5180 | SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC), | |
5181 | SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X), | |
5182 | SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC), | |
bc9f98a9 | 5183 | SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V), |
ac3e3741 | 5184 | SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL), |
df694daa KY |
5185 | {} |
5186 | }; | |
5187 | ||
5188 | static struct alc_config_preset alc260_presets[] = { | |
5189 | [ALC260_BASIC] = { | |
5190 | .mixers = { alc260_base_output_mixer, | |
5191 | alc260_input_mixer, | |
5192 | alc260_pc_beep_mixer, | |
5193 | alc260_capture_mixer }, | |
5194 | .init_verbs = { alc260_init_verbs }, | |
5195 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5196 | .dac_nids = alc260_dac_nids, | |
5197 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), | |
5198 | .adc_nids = alc260_adc_nids, | |
5199 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5200 | .channel_mode = alc260_modes, | |
5201 | .input_mux = &alc260_capture_source, | |
5202 | }, | |
5203 | [ALC260_HP] = { | |
bec15c3a | 5204 | .mixers = { alc260_hp_output_mixer, |
df694daa KY |
5205 | alc260_input_mixer, |
5206 | alc260_capture_alt_mixer }, | |
bec15c3a TI |
5207 | .init_verbs = { alc260_init_verbs, |
5208 | alc260_hp_unsol_verbs }, | |
df694daa KY |
5209 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), |
5210 | .dac_nids = alc260_dac_nids, | |
5211 | .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), | |
5212 | .adc_nids = alc260_hp_adc_nids, | |
5213 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5214 | .channel_mode = alc260_modes, | |
5215 | .input_mux = &alc260_capture_source, | |
bec15c3a TI |
5216 | .unsol_event = alc260_hp_unsol_event, |
5217 | .init_hook = alc260_hp_automute, | |
df694daa KY |
5218 | }, |
5219 | [ALC260_HP_3013] = { | |
5220 | .mixers = { alc260_hp_3013_mixer, | |
5221 | alc260_input_mixer, | |
5222 | alc260_capture_alt_mixer }, | |
bec15c3a TI |
5223 | .init_verbs = { alc260_hp_3013_init_verbs, |
5224 | alc260_hp_3013_unsol_verbs }, | |
df694daa KY |
5225 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), |
5226 | .dac_nids = alc260_dac_nids, | |
5227 | .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), | |
5228 | .adc_nids = alc260_hp_adc_nids, | |
5229 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5230 | .channel_mode = alc260_modes, | |
5231 | .input_mux = &alc260_capture_source, | |
bec15c3a TI |
5232 | .unsol_event = alc260_hp_3013_unsol_event, |
5233 | .init_hook = alc260_hp_3013_automute, | |
df694daa KY |
5234 | }, |
5235 | [ALC260_FUJITSU_S702X] = { | |
5236 | .mixers = { alc260_fujitsu_mixer, | |
5237 | alc260_capture_mixer }, | |
5238 | .init_verbs = { alc260_fujitsu_init_verbs }, | |
5239 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5240 | .dac_nids = alc260_dac_nids, | |
d57fdac0 JW |
5241 | .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), |
5242 | .adc_nids = alc260_dual_adc_nids, | |
df694daa KY |
5243 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
5244 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
5245 | .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources), |
5246 | .input_mux = alc260_fujitsu_capture_sources, | |
df694daa | 5247 | }, |
0bfc90e9 JW |
5248 | [ALC260_ACER] = { |
5249 | .mixers = { alc260_acer_mixer, | |
5250 | alc260_capture_mixer }, | |
5251 | .init_verbs = { alc260_acer_init_verbs }, | |
5252 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5253 | .dac_nids = alc260_dac_nids, | |
5254 | .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), | |
5255 | .adc_nids = alc260_dual_adc_nids, | |
5256 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5257 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
5258 | .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources), |
5259 | .input_mux = alc260_acer_capture_sources, | |
0bfc90e9 | 5260 | }, |
bc9f98a9 KY |
5261 | [ALC260_WILL] = { |
5262 | .mixers = { alc260_will_mixer, | |
5263 | alc260_capture_mixer }, | |
5264 | .init_verbs = { alc260_init_verbs, alc260_will_verbs }, | |
5265 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5266 | .dac_nids = alc260_dac_nids, | |
5267 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), | |
5268 | .adc_nids = alc260_adc_nids, | |
5269 | .dig_out_nid = ALC260_DIGOUT_NID, | |
5270 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5271 | .channel_mode = alc260_modes, | |
5272 | .input_mux = &alc260_capture_source, | |
5273 | }, | |
5274 | [ALC260_REPLACER_672V] = { | |
5275 | .mixers = { alc260_replacer_672v_mixer, | |
5276 | alc260_capture_mixer }, | |
5277 | .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs }, | |
5278 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5279 | .dac_nids = alc260_dac_nids, | |
5280 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), | |
5281 | .adc_nids = alc260_adc_nids, | |
5282 | .dig_out_nid = ALC260_DIGOUT_NID, | |
5283 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5284 | .channel_mode = alc260_modes, | |
5285 | .input_mux = &alc260_capture_source, | |
5286 | .unsol_event = alc260_replacer_672v_unsol_event, | |
5287 | .init_hook = alc260_replacer_672v_automute, | |
5288 | }, | |
7cf51e48 JW |
5289 | #ifdef CONFIG_SND_DEBUG |
5290 | [ALC260_TEST] = { | |
5291 | .mixers = { alc260_test_mixer, | |
5292 | alc260_capture_mixer }, | |
5293 | .init_verbs = { alc260_test_init_verbs }, | |
5294 | .num_dacs = ARRAY_SIZE(alc260_test_dac_nids), | |
5295 | .dac_nids = alc260_test_dac_nids, | |
5296 | .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids), | |
5297 | .adc_nids = alc260_test_adc_nids, | |
5298 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5299 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
5300 | .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources), |
5301 | .input_mux = alc260_test_capture_sources, | |
7cf51e48 JW |
5302 | }, |
5303 | #endif | |
df694daa KY |
5304 | }; |
5305 | ||
5306 | static int patch_alc260(struct hda_codec *codec) | |
1da177e4 LT |
5307 | { |
5308 | struct alc_spec *spec; | |
df694daa | 5309 | int err, board_config; |
1da177e4 | 5310 | |
e560d8d8 | 5311 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
1da177e4 LT |
5312 | if (spec == NULL) |
5313 | return -ENOMEM; | |
5314 | ||
5315 | codec->spec = spec; | |
5316 | ||
f5fcc13c TI |
5317 | board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST, |
5318 | alc260_models, | |
5319 | alc260_cfg_tbl); | |
5320 | if (board_config < 0) { | |
9c7f852e TI |
5321 | snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, " |
5322 | "trying auto-probe from BIOS...\n"); | |
df694daa | 5323 | board_config = ALC260_AUTO; |
16ded525 | 5324 | } |
1da177e4 | 5325 | |
df694daa KY |
5326 | if (board_config == ALC260_AUTO) { |
5327 | /* automatic parse from the BIOS config */ | |
5328 | err = alc260_parse_auto_config(codec); | |
5329 | if (err < 0) { | |
5330 | alc_free(codec); | |
5331 | return err; | |
f12ab1e0 | 5332 | } else if (!err) { |
9c7f852e TI |
5333 | printk(KERN_INFO |
5334 | "hda_codec: Cannot set up configuration " | |
5335 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
5336 | board_config = ALC260_BASIC; |
5337 | } | |
a9430dd8 | 5338 | } |
e9edcee0 | 5339 | |
df694daa KY |
5340 | if (board_config != ALC260_AUTO) |
5341 | setup_preset(spec, &alc260_presets[board_config]); | |
1da177e4 LT |
5342 | |
5343 | spec->stream_name_analog = "ALC260 Analog"; | |
5344 | spec->stream_analog_playback = &alc260_pcm_analog_playback; | |
5345 | spec->stream_analog_capture = &alc260_pcm_analog_capture; | |
5346 | ||
a3bcba38 TI |
5347 | spec->stream_name_digital = "ALC260 Digital"; |
5348 | spec->stream_digital_playback = &alc260_pcm_digital_playback; | |
5349 | spec->stream_digital_capture = &alc260_pcm_digital_capture; | |
5350 | ||
2134ea4f TI |
5351 | spec->vmaster_nid = 0x08; |
5352 | ||
1da177e4 | 5353 | codec->patch_ops = alc_patch_ops; |
df694daa | 5354 | if (board_config == ALC260_AUTO) |
ae6b813a | 5355 | spec->init_hook = alc260_auto_init; |
cb53c626 TI |
5356 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
5357 | if (!spec->loopback.amplist) | |
5358 | spec->loopback.amplist = alc260_loopbacks; | |
5359 | #endif | |
1da177e4 LT |
5360 | |
5361 | return 0; | |
5362 | } | |
5363 | ||
e9edcee0 | 5364 | |
1da177e4 LT |
5365 | /* |
5366 | * ALC882 support | |
5367 | * | |
5368 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible | |
5369 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
5370 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
5371 | * 6-channel independent captures. | |
5372 | * | |
5373 | * In addition, an independent DAC for the multi-playback (not used in this | |
5374 | * driver yet). | |
5375 | */ | |
df694daa KY |
5376 | #define ALC882_DIGOUT_NID 0x06 |
5377 | #define ALC882_DIGIN_NID 0x0a | |
1da177e4 | 5378 | |
d2a6d7dc | 5379 | static struct hda_channel_mode alc882_ch_modes[1] = { |
1da177e4 LT |
5380 | { 8, NULL } |
5381 | }; | |
5382 | ||
5383 | static hda_nid_t alc882_dac_nids[4] = { | |
5384 | /* front, rear, clfe, rear_surr */ | |
5385 | 0x02, 0x03, 0x04, 0x05 | |
5386 | }; | |
5387 | ||
df694daa KY |
5388 | /* identical with ALC880 */ |
5389 | #define alc882_adc_nids alc880_adc_nids | |
5390 | #define alc882_adc_nids_alt alc880_adc_nids_alt | |
1da177e4 | 5391 | |
e1406348 TI |
5392 | static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 }; |
5393 | static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 }; | |
5394 | ||
1da177e4 LT |
5395 | /* input MUX */ |
5396 | /* FIXME: should be a matrix-type input source selection */ | |
5397 | ||
5398 | static struct hda_input_mux alc882_capture_source = { | |
5399 | .num_items = 4, | |
5400 | .items = { | |
5401 | { "Mic", 0x0 }, | |
5402 | { "Front Mic", 0x1 }, | |
5403 | { "Line", 0x2 }, | |
5404 | { "CD", 0x4 }, | |
5405 | }, | |
5406 | }; | |
1da177e4 LT |
5407 | #define alc882_mux_enum_info alc_mux_enum_info |
5408 | #define alc882_mux_enum_get alc_mux_enum_get | |
5409 | ||
f12ab1e0 TI |
5410 | static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, |
5411 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
5412 | { |
5413 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
5414 | struct alc_spec *spec = codec->spec; | |
5415 | const struct hda_input_mux *imux = spec->input_mux; | |
5416 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
88c71a99 TI |
5417 | hda_nid_t nid = spec->capsrc_nids ? |
5418 | spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx]; | |
1da177e4 LT |
5419 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; |
5420 | unsigned int i, idx; | |
5421 | ||
5422 | idx = ucontrol->value.enumerated.item[0]; | |
5423 | if (idx >= imux->num_items) | |
5424 | idx = imux->num_items - 1; | |
82beb8fd | 5425 | if (*cur_val == idx) |
1da177e4 LT |
5426 | return 0; |
5427 | for (i = 0; i < imux->num_items; i++) { | |
47fd830a TI |
5428 | unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE; |
5429 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, | |
82beb8fd | 5430 | imux->items[i].index, |
47fd830a | 5431 | HDA_AMP_MUTE, v); |
1da177e4 LT |
5432 | } |
5433 | *cur_val = idx; | |
5434 | return 1; | |
5435 | } | |
5436 | ||
272a527c KY |
5437 | /* |
5438 | * 2ch mode | |
5439 | */ | |
5440 | static struct hda_verb alc882_3ST_ch2_init[] = { | |
5441 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
5442 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
5443 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
5444 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
5445 | { } /* end */ | |
5446 | }; | |
5447 | ||
5448 | /* | |
5449 | * 6ch mode | |
5450 | */ | |
5451 | static struct hda_verb alc882_3ST_ch6_init[] = { | |
5452 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5453 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
5454 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
5455 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5456 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
5457 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
5458 | { } /* end */ | |
5459 | }; | |
5460 | ||
5461 | static struct hda_channel_mode alc882_3ST_6ch_modes[2] = { | |
5462 | { 2, alc882_3ST_ch2_init }, | |
5463 | { 6, alc882_3ST_ch6_init }, | |
5464 | }; | |
5465 | ||
df694daa KY |
5466 | /* |
5467 | * 6ch mode | |
5468 | */ | |
5469 | static struct hda_verb alc882_sixstack_ch6_init[] = { | |
5470 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
5471 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5472 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5473 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5474 | { } /* end */ | |
5475 | }; | |
5476 | ||
5477 | /* | |
5478 | * 8ch mode | |
5479 | */ | |
5480 | static struct hda_verb alc882_sixstack_ch8_init[] = { | |
5481 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5482 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5483 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5484 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5485 | { } /* end */ | |
5486 | }; | |
5487 | ||
5488 | static struct hda_channel_mode alc882_sixstack_modes[2] = { | |
5489 | { 6, alc882_sixstack_ch6_init }, | |
5490 | { 8, alc882_sixstack_ch8_init }, | |
5491 | }; | |
5492 | ||
87350ad0 TI |
5493 | /* |
5494 | * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic | |
5495 | */ | |
5496 | ||
5497 | /* | |
5498 | * 2ch mode | |
5499 | */ | |
5500 | static struct hda_verb alc885_mbp_ch2_init[] = { | |
5501 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
5502 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5503 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5504 | { } /* end */ | |
5505 | }; | |
5506 | ||
5507 | /* | |
5508 | * 6ch mode | |
5509 | */ | |
5510 | static struct hda_verb alc885_mbp_ch6_init[] = { | |
5511 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5512 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5513 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
5514 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5515 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5516 | { } /* end */ | |
5517 | }; | |
5518 | ||
5519 | static struct hda_channel_mode alc885_mbp_6ch_modes[2] = { | |
5520 | { 2, alc885_mbp_ch2_init }, | |
5521 | { 6, alc885_mbp_ch6_init }, | |
5522 | }; | |
5523 | ||
5524 | ||
1da177e4 LT |
5525 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
5526 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
5527 | */ | |
c8b6bf9b | 5528 | static struct snd_kcontrol_new alc882_base_mixer[] = { |
05acb863 | 5529 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 5530 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
05acb863 | 5531 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 5532 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
05acb863 TI |
5533 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
5534 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
5535 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
5536 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
05acb863 | 5537 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 5538 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
1da177e4 LT |
5539 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
5540 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5541 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5542 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5543 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5544 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 5545 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
1da177e4 LT |
5546 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
5547 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 5548 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
1da177e4 LT |
5549 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
5550 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
5551 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
1da177e4 LT |
5552 | { } /* end */ |
5553 | }; | |
5554 | ||
87350ad0 | 5555 | static struct snd_kcontrol_new alc885_mbp3_mixer[] = { |
2134ea4f TI |
5556 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT), |
5557 | HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT), | |
5558 | HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT), | |
5559 | HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT), | |
5560 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5561 | HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
87350ad0 TI |
5562 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT), |
5563 | HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT), | |
2134ea4f | 5564 | HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT), |
87350ad0 TI |
5565 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT), |
5566 | { } /* end */ | |
5567 | }; | |
bdd148a3 KY |
5568 | static struct snd_kcontrol_new alc882_w2jc_mixer[] = { |
5569 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5570 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
5571 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5572 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5573 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5574 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5575 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
5576 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
5577 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
5578 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
5579 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
5580 | { } /* end */ | |
5581 | }; | |
5582 | ||
272a527c KY |
5583 | static struct snd_kcontrol_new alc882_targa_mixer[] = { |
5584 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5585 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
5586 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
5587 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5588 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5589 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5590 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5591 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
5592 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
96fe7cc8 | 5593 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
272a527c KY |
5594 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
5595 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
96fe7cc8 | 5596 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
272a527c KY |
5597 | { } /* end */ |
5598 | }; | |
5599 | ||
5600 | /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ??? | |
5601 | * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c | |
5602 | */ | |
5603 | static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = { | |
5604 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5605 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
5606 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
5607 | HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT), | |
5608 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5609 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5610 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5611 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5612 | HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT), | |
5613 | HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT), | |
5614 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
5615 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
96fe7cc8 | 5616 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
272a527c KY |
5617 | { } /* end */ |
5618 | }; | |
5619 | ||
914759b7 TI |
5620 | static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = { |
5621 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5622 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
5623 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
5624 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5625 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5626 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5627 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5628 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
5629 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
5630 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
5631 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
5632 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
5633 | { } /* end */ | |
5634 | }; | |
5635 | ||
df694daa KY |
5636 | static struct snd_kcontrol_new alc882_chmode_mixer[] = { |
5637 | { | |
5638 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5639 | .name = "Channel Mode", | |
5640 | .info = alc_ch_mode_info, | |
5641 | .get = alc_ch_mode_get, | |
5642 | .put = alc_ch_mode_put, | |
5643 | }, | |
5644 | { } /* end */ | |
5645 | }; | |
5646 | ||
1da177e4 LT |
5647 | static struct hda_verb alc882_init_verbs[] = { |
5648 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
05acb863 TI |
5649 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
5650 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5651 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 5652 | /* Rear mixer */ |
05acb863 TI |
5653 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
5654 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5655 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 5656 | /* CLFE mixer */ |
05acb863 TI |
5657 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
5658 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5659 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 5660 | /* Side mixer */ |
05acb863 TI |
5661 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
5662 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5663 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 5664 | |
e9edcee0 | 5665 | /* Front Pin: output 0 (0x0c) */ |
05acb863 | 5666 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 5667 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 5668 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 5669 | /* Rear Pin: output 1 (0x0d) */ |
05acb863 | 5670 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 5671 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 5672 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, |
e9edcee0 | 5673 | /* CLFE Pin: output 2 (0x0e) */ |
05acb863 | 5674 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 5675 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 5676 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, |
e9edcee0 | 5677 | /* Side Pin: output 3 (0x0f) */ |
05acb863 | 5678 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 5679 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 5680 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, |
e9edcee0 | 5681 | /* Mic (rear) pin: input vref at 80% */ |
16ded525 | 5682 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 TI |
5683 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
5684 | /* Front Mic pin: input vref at 80% */ | |
16ded525 | 5685 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 TI |
5686 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
5687 | /* Line In pin: input */ | |
05acb863 | 5688 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 TI |
5689 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
5690 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
5691 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5692 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5693 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1da177e4 | 5694 | /* CD pin widget for input */ |
05acb863 | 5695 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 LT |
5696 | |
5697 | /* FIXME: use matrix-type input source selection */ | |
5698 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
5699 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
05acb863 TI |
5700 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
5701 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5702 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5703 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 5704 | /* Input mixer2 */ |
05acb863 TI |
5705 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
5706 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5707 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5708 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 5709 | /* Input mixer3 */ |
05acb863 TI |
5710 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
5711 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5712 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5713 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5714 | /* ADC1: mute amp left and right */ | |
5715 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 5716 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
5717 | /* ADC2: mute amp left and right */ |
5718 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 5719 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
5720 | /* ADC3: mute amp left and right */ |
5721 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 5722 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
1da177e4 LT |
5723 | |
5724 | { } | |
5725 | }; | |
5726 | ||
4b146cb0 TI |
5727 | static struct hda_verb alc882_eapd_verbs[] = { |
5728 | /* change to EAPD mode */ | |
5729 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
b373bdeb | 5730 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, |
f12ab1e0 | 5731 | { } |
4b146cb0 TI |
5732 | }; |
5733 | ||
9102cd1c TD |
5734 | /* Mac Pro test */ |
5735 | static struct snd_kcontrol_new alc882_macpro_mixer[] = { | |
5736 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5737 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
5738 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT), | |
5739 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
5740 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
5741 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5742 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5743 | { } /* end */ | |
5744 | }; | |
5745 | ||
5746 | static struct hda_verb alc882_macpro_init_verbs[] = { | |
5747 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
5748 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5749 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5750 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5751 | /* Front Pin: output 0 (0x0c) */ | |
5752 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5753 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5754 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5755 | /* Front Mic pin: input vref at 80% */ | |
5756 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
5757 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5758 | /* Speaker: output */ | |
5759 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5760 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5761 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04}, | |
5762 | /* Headphone output (output 0 - 0x0c) */ | |
5763 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5764 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5765 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5766 | ||
5767 | /* FIXME: use matrix-type input source selection */ | |
5768 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
5769 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
5770 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5771 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5772 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5773 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5774 | /* Input mixer2 */ | |
5775 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5776 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5777 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5778 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5779 | /* Input mixer3 */ | |
5780 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5781 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5782 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5783 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5784 | /* ADC1: mute amp left and right */ | |
5785 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5786 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5787 | /* ADC2: mute amp left and right */ | |
5788 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5789 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5790 | /* ADC3: mute amp left and right */ | |
5791 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5792 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5793 | ||
5794 | { } | |
5795 | }; | |
f12ab1e0 | 5796 | |
87350ad0 TI |
5797 | /* Macbook Pro rev3 */ |
5798 | static struct hda_verb alc885_mbp3_init_verbs[] = { | |
5799 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
5800 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5801 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5802 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5803 | /* Rear mixer */ | |
5804 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5805 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5806 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5807 | /* Front Pin: output 0 (0x0c) */ | |
5808 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5809 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5810 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5811 | /* HP Pin: output 0 (0x0d) */ | |
5812 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, | |
5813 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5814 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5815 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
5816 | /* Mic (rear) pin: input vref at 80% */ | |
5817 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
5818 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5819 | /* Front Mic pin: input vref at 80% */ | |
5820 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
5821 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5822 | /* Line In pin: use output 1 when in LineOut mode */ | |
5823 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
5824 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5825 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
5826 | ||
5827 | /* FIXME: use matrix-type input source selection */ | |
5828 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
5829 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
5830 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5831 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5832 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5833 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5834 | /* Input mixer2 */ | |
5835 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5836 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5837 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5838 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5839 | /* Input mixer3 */ | |
5840 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5841 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5842 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5843 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5844 | /* ADC1: mute amp left and right */ | |
5845 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5846 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5847 | /* ADC2: mute amp left and right */ | |
5848 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5849 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5850 | /* ADC3: mute amp left and right */ | |
5851 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5852 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5853 | ||
5854 | { } | |
5855 | }; | |
5856 | ||
c54728d8 NF |
5857 | /* iMac 24 mixer. */ |
5858 | static struct snd_kcontrol_new alc885_imac24_mixer[] = { | |
5859 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT), | |
5860 | HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT), | |
5861 | { } /* end */ | |
5862 | }; | |
5863 | ||
5864 | /* iMac 24 init verbs. */ | |
5865 | static struct hda_verb alc885_imac24_init_verbs[] = { | |
5866 | /* Internal speakers: output 0 (0x0c) */ | |
5867 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5868 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5869 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5870 | /* Internal speakers: output 0 (0x0c) */ | |
5871 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5872 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5873 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5874 | /* Headphone: output 0 (0x0c) */ | |
5875 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5876 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5877 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5878 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
5879 | /* Front Mic: input vref at 80% */ | |
5880 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
5881 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5882 | { } | |
5883 | }; | |
5884 | ||
5885 | /* Toggle speaker-output according to the hp-jack state */ | |
5886 | static void alc885_imac24_automute(struct hda_codec *codec) | |
5887 | { | |
5888 | unsigned int present; | |
5889 | ||
5890 | present = snd_hda_codec_read(codec, 0x14, 0, | |
5891 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
5892 | snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0, |
5893 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
5894 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, | |
5895 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
c54728d8 NF |
5896 | } |
5897 | ||
5898 | /* Processes unsolicited events. */ | |
5899 | static void alc885_imac24_unsol_event(struct hda_codec *codec, | |
5900 | unsigned int res) | |
5901 | { | |
5902 | /* Headphone insertion or removal. */ | |
5903 | if ((res >> 26) == ALC880_HP_EVENT) | |
5904 | alc885_imac24_automute(codec); | |
5905 | } | |
5906 | ||
87350ad0 TI |
5907 | static void alc885_mbp3_automute(struct hda_codec *codec) |
5908 | { | |
5909 | unsigned int present; | |
5910 | ||
5911 | present = snd_hda_codec_read(codec, 0x15, 0, | |
5912 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
5913 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
5914 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
5915 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
5916 | HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE); | |
5917 | ||
5918 | } | |
5919 | static void alc885_mbp3_unsol_event(struct hda_codec *codec, | |
5920 | unsigned int res) | |
5921 | { | |
5922 | /* Headphone insertion or removal. */ | |
5923 | if ((res >> 26) == ALC880_HP_EVENT) | |
5924 | alc885_mbp3_automute(codec); | |
5925 | } | |
5926 | ||
5927 | ||
272a527c KY |
5928 | static struct hda_verb alc882_targa_verbs[] = { |
5929 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5930 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5931 | ||
5932 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5933 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5934 | ||
5935 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
5936 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
5937 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
5938 | ||
5939 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
5940 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, | |
5941 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | |
5942 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | |
5943 | { } /* end */ | |
5944 | }; | |
5945 | ||
5946 | /* toggle speaker-output according to the hp-jack state */ | |
5947 | static void alc882_targa_automute(struct hda_codec *codec) | |
5948 | { | |
5949 | unsigned int present; | |
5950 | ||
5951 | present = snd_hda_codec_read(codec, 0x14, 0, | |
5952 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
5953 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, |
5954 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
82beb8fd TI |
5955 | snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA, |
5956 | present ? 1 : 3); | |
272a527c KY |
5957 | } |
5958 | ||
5959 | static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res) | |
5960 | { | |
5961 | /* Looks like the unsol event is incompatible with the standard | |
5962 | * definition. 4bit tag is placed at 26 bit! | |
5963 | */ | |
5964 | if (((res >> 26) == ALC880_HP_EVENT)) { | |
5965 | alc882_targa_automute(codec); | |
5966 | } | |
5967 | } | |
5968 | ||
5969 | static struct hda_verb alc882_asus_a7j_verbs[] = { | |
5970 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5971 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5972 | ||
5973 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5974 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5975 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5976 | ||
5977 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ | |
5978 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
5979 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ | |
5980 | ||
5981 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
5982 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
5983 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
5984 | { } /* end */ | |
5985 | }; | |
5986 | ||
914759b7 TI |
5987 | static struct hda_verb alc882_asus_a7m_verbs[] = { |
5988 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5989 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5990 | ||
5991 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5992 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5993 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5994 | ||
5995 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ | |
5996 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
5997 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ | |
5998 | ||
5999 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
6000 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
6001 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
6002 | { } /* end */ | |
6003 | }; | |
6004 | ||
9102cd1c TD |
6005 | static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) |
6006 | { | |
6007 | unsigned int gpiostate, gpiomask, gpiodir; | |
6008 | ||
6009 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, | |
6010 | AC_VERB_GET_GPIO_DATA, 0); | |
6011 | ||
6012 | if (!muted) | |
6013 | gpiostate |= (1 << pin); | |
6014 | else | |
6015 | gpiostate &= ~(1 << pin); | |
6016 | ||
6017 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, | |
6018 | AC_VERB_GET_GPIO_MASK, 0); | |
6019 | gpiomask |= (1 << pin); | |
6020 | ||
6021 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, | |
6022 | AC_VERB_GET_GPIO_DIRECTION, 0); | |
6023 | gpiodir |= (1 << pin); | |
6024 | ||
6025 | ||
6026 | snd_hda_codec_write(codec, codec->afg, 0, | |
6027 | AC_VERB_SET_GPIO_MASK, gpiomask); | |
6028 | snd_hda_codec_write(codec, codec->afg, 0, | |
6029 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); | |
6030 | ||
6031 | msleep(1); | |
6032 | ||
6033 | snd_hda_codec_write(codec, codec->afg, 0, | |
6034 | AC_VERB_SET_GPIO_DATA, gpiostate); | |
6035 | } | |
6036 | ||
7debbe51 TI |
6037 | /* set up GPIO at initialization */ |
6038 | static void alc885_macpro_init_hook(struct hda_codec *codec) | |
6039 | { | |
6040 | alc882_gpio_mute(codec, 0, 0); | |
6041 | alc882_gpio_mute(codec, 1, 0); | |
6042 | } | |
6043 | ||
6044 | /* set up GPIO and update auto-muting at initialization */ | |
6045 | static void alc885_imac24_init_hook(struct hda_codec *codec) | |
6046 | { | |
6047 | alc885_macpro_init_hook(codec); | |
6048 | alc885_imac24_automute(codec); | |
6049 | } | |
6050 | ||
df694daa KY |
6051 | /* |
6052 | * generic initialization of ADC, input mixers and output mixers | |
6053 | */ | |
6054 | static struct hda_verb alc882_auto_init_verbs[] = { | |
6055 | /* | |
6056 | * Unmute ADC0-2 and set the default input to mic-in | |
6057 | */ | |
6058 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6059 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6060 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6061 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6062 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6063 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
1da177e4 | 6064 | |
cb53c626 | 6065 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
df694daa | 6066 | * mixer widget |
f12ab1e0 TI |
6067 | * Note: PASD motherboards uses the Line In 2 as the input for |
6068 | * front panel mic (mic 2) | |
df694daa KY |
6069 | */ |
6070 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
6071 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
6072 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
6073 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6074 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6075 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
e9edcee0 | 6076 | |
df694daa KY |
6077 | /* |
6078 | * Set up output mixers (0x0c - 0x0f) | |
6079 | */ | |
6080 | /* set vol=0 to output mixers */ | |
6081 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6082 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6083 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6084 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6085 | /* set up input amps for analog loopback */ | |
6086 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
6087 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6088 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6089 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6090 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6091 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6092 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6093 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6094 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6095 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6096 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6097 | ||
6098 | /* FIXME: use matrix-type input source selection */ | |
6099 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
6100 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
6101 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
6102 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
6103 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
6104 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
6105 | /* Input mixer2 */ | |
6106 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
6107 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
6108 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
6109 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
6110 | /* Input mixer3 */ | |
6111 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
6112 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
6113 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
6114 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
6115 | ||
6116 | { } | |
6117 | }; | |
6118 | ||
6119 | /* capture mixer elements */ | |
6120 | static struct snd_kcontrol_new alc882_capture_alt_mixer[] = { | |
6121 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6122 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6123 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6124 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6125 | { | |
6126 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6127 | /* The multiple "Capture Source" controls confuse alsamixer | |
6128 | * So call somewhat different.. | |
df694daa KY |
6129 | */ |
6130 | /* .name = "Capture Source", */ | |
6131 | .name = "Input Source", | |
6132 | .count = 2, | |
6133 | .info = alc882_mux_enum_info, | |
6134 | .get = alc882_mux_enum_get, | |
6135 | .put = alc882_mux_enum_put, | |
6136 | }, | |
6137 | { } /* end */ | |
6138 | }; | |
6139 | ||
6140 | static struct snd_kcontrol_new alc882_capture_mixer[] = { | |
6141 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), | |
6142 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), | |
6143 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), | |
6144 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), | |
6145 | HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), | |
6146 | HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), | |
6147 | { | |
6148 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6149 | /* The multiple "Capture Source" controls confuse alsamixer | |
6150 | * So call somewhat different.. | |
df694daa KY |
6151 | */ |
6152 | /* .name = "Capture Source", */ | |
6153 | .name = "Input Source", | |
6154 | .count = 3, | |
6155 | .info = alc882_mux_enum_info, | |
6156 | .get = alc882_mux_enum_get, | |
6157 | .put = alc882_mux_enum_put, | |
6158 | }, | |
6159 | { } /* end */ | |
6160 | }; | |
6161 | ||
cb53c626 TI |
6162 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
6163 | #define alc882_loopbacks alc880_loopbacks | |
6164 | #endif | |
6165 | ||
df694daa KY |
6166 | /* pcm configuration: identiacal with ALC880 */ |
6167 | #define alc882_pcm_analog_playback alc880_pcm_analog_playback | |
6168 | #define alc882_pcm_analog_capture alc880_pcm_analog_capture | |
6169 | #define alc882_pcm_digital_playback alc880_pcm_digital_playback | |
6170 | #define alc882_pcm_digital_capture alc880_pcm_digital_capture | |
6171 | ||
6172 | /* | |
6173 | * configuration and preset | |
6174 | */ | |
f5fcc13c TI |
6175 | static const char *alc882_models[ALC882_MODEL_LAST] = { |
6176 | [ALC882_3ST_DIG] = "3stack-dig", | |
6177 | [ALC882_6ST_DIG] = "6stack-dig", | |
6178 | [ALC882_ARIMA] = "arima", | |
bdd148a3 | 6179 | [ALC882_W2JC] = "w2jc", |
0438a00e TI |
6180 | [ALC882_TARGA] = "targa", |
6181 | [ALC882_ASUS_A7J] = "asus-a7j", | |
6182 | [ALC882_ASUS_A7M] = "asus-a7m", | |
9102cd1c | 6183 | [ALC885_MACPRO] = "macpro", |
87350ad0 | 6184 | [ALC885_MBP3] = "mbp3", |
c54728d8 | 6185 | [ALC885_IMAC24] = "imac24", |
f5fcc13c TI |
6186 | [ALC882_AUTO] = "auto", |
6187 | }; | |
6188 | ||
6189 | static struct snd_pci_quirk alc882_cfg_tbl[] = { | |
6190 | SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG), | |
272a527c | 6191 | SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J), |
ac8842a0 | 6192 | SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J), |
914759b7 | 6193 | SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M), |
ac3e3741 | 6194 | SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC), |
c5d9f1cd | 6195 | SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG), |
7b9470d8 | 6196 | SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG), |
ac3e3741 | 6197 | SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG), |
3e0e469f | 6198 | SND_PCI_QUIRK(0x106b, 0x00a0, "Apple iMac 24''", ALC885_IMAC24), |
4444704c | 6199 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG), |
ac3e3741 TI |
6200 | SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */ |
6201 | SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG), | |
6202 | SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), | |
df694daa KY |
6203 | {} |
6204 | }; | |
6205 | ||
6206 | static struct alc_config_preset alc882_presets[] = { | |
6207 | [ALC882_3ST_DIG] = { | |
6208 | .mixers = { alc882_base_mixer }, | |
6209 | .init_verbs = { alc882_init_verbs }, | |
6210 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6211 | .dac_nids = alc882_dac_nids, | |
6212 | .dig_out_nid = ALC882_DIGOUT_NID, | |
df694daa KY |
6213 | .dig_in_nid = ALC882_DIGIN_NID, |
6214 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | |
6215 | .channel_mode = alc882_ch_modes, | |
4e195a7b | 6216 | .need_dac_fix = 1, |
df694daa KY |
6217 | .input_mux = &alc882_capture_source, |
6218 | }, | |
6219 | [ALC882_6ST_DIG] = { | |
6220 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, | |
6221 | .init_verbs = { alc882_init_verbs }, | |
6222 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6223 | .dac_nids = alc882_dac_nids, | |
6224 | .dig_out_nid = ALC882_DIGOUT_NID, | |
df694daa KY |
6225 | .dig_in_nid = ALC882_DIGIN_NID, |
6226 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), | |
6227 | .channel_mode = alc882_sixstack_modes, | |
6228 | .input_mux = &alc882_capture_source, | |
6229 | }, | |
4b146cb0 TI |
6230 | [ALC882_ARIMA] = { |
6231 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, | |
6232 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs }, | |
6233 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6234 | .dac_nids = alc882_dac_nids, | |
6235 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), | |
6236 | .channel_mode = alc882_sixstack_modes, | |
6237 | .input_mux = &alc882_capture_source, | |
6238 | }, | |
bdd148a3 KY |
6239 | [ALC882_W2JC] = { |
6240 | .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer }, | |
6241 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs, | |
6242 | alc880_gpio1_init_verbs }, | |
6243 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6244 | .dac_nids = alc882_dac_nids, | |
6245 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
6246 | .channel_mode = alc880_threestack_modes, | |
6247 | .need_dac_fix = 1, | |
6248 | .input_mux = &alc882_capture_source, | |
6249 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6250 | }, | |
87350ad0 TI |
6251 | [ALC885_MBP3] = { |
6252 | .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer }, | |
6253 | .init_verbs = { alc885_mbp3_init_verbs, | |
6254 | alc880_gpio1_init_verbs }, | |
6255 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6256 | .dac_nids = alc882_dac_nids, | |
6257 | .channel_mode = alc885_mbp_6ch_modes, | |
6258 | .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes), | |
6259 | .input_mux = &alc882_capture_source, | |
6260 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6261 | .dig_in_nid = ALC882_DIGIN_NID, | |
6262 | .unsol_event = alc885_mbp3_unsol_event, | |
6263 | .init_hook = alc885_mbp3_automute, | |
6264 | }, | |
9102cd1c TD |
6265 | [ALC885_MACPRO] = { |
6266 | .mixers = { alc882_macpro_mixer }, | |
6267 | .init_verbs = { alc882_macpro_init_verbs }, | |
6268 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6269 | .dac_nids = alc882_dac_nids, | |
6270 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6271 | .dig_in_nid = ALC882_DIGIN_NID, | |
6272 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | |
6273 | .channel_mode = alc882_ch_modes, | |
6274 | .input_mux = &alc882_capture_source, | |
7debbe51 | 6275 | .init_hook = alc885_macpro_init_hook, |
9102cd1c | 6276 | }, |
c54728d8 NF |
6277 | [ALC885_IMAC24] = { |
6278 | .mixers = { alc885_imac24_mixer }, | |
6279 | .init_verbs = { alc885_imac24_init_verbs }, | |
6280 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6281 | .dac_nids = alc882_dac_nids, | |
6282 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6283 | .dig_in_nid = ALC882_DIGIN_NID, | |
6284 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | |
6285 | .channel_mode = alc882_ch_modes, | |
6286 | .input_mux = &alc882_capture_source, | |
6287 | .unsol_event = alc885_imac24_unsol_event, | |
7debbe51 | 6288 | .init_hook = alc885_imac24_init_hook, |
c54728d8 | 6289 | }, |
272a527c KY |
6290 | [ALC882_TARGA] = { |
6291 | .mixers = { alc882_targa_mixer, alc882_chmode_mixer, | |
6292 | alc882_capture_mixer }, | |
6293 | .init_verbs = { alc882_init_verbs, alc882_targa_verbs}, | |
6294 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6295 | .dac_nids = alc882_dac_nids, | |
6296 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6297 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), | |
6298 | .adc_nids = alc882_adc_nids, | |
e1406348 | 6299 | .capsrc_nids = alc882_capsrc_nids, |
272a527c KY |
6300 | .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), |
6301 | .channel_mode = alc882_3ST_6ch_modes, | |
6302 | .need_dac_fix = 1, | |
6303 | .input_mux = &alc882_capture_source, | |
6304 | .unsol_event = alc882_targa_unsol_event, | |
6305 | .init_hook = alc882_targa_automute, | |
6306 | }, | |
6307 | [ALC882_ASUS_A7J] = { | |
6308 | .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer, | |
6309 | alc882_capture_mixer }, | |
6310 | .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs}, | |
6311 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6312 | .dac_nids = alc882_dac_nids, | |
6313 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6314 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), | |
6315 | .adc_nids = alc882_adc_nids, | |
e1406348 | 6316 | .capsrc_nids = alc882_capsrc_nids, |
272a527c KY |
6317 | .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), |
6318 | .channel_mode = alc882_3ST_6ch_modes, | |
6319 | .need_dac_fix = 1, | |
6320 | .input_mux = &alc882_capture_source, | |
6321 | }, | |
914759b7 TI |
6322 | [ALC882_ASUS_A7M] = { |
6323 | .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer }, | |
6324 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs, | |
6325 | alc880_gpio1_init_verbs, | |
6326 | alc882_asus_a7m_verbs }, | |
6327 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6328 | .dac_nids = alc882_dac_nids, | |
6329 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6330 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
6331 | .channel_mode = alc880_threestack_modes, | |
6332 | .need_dac_fix = 1, | |
6333 | .input_mux = &alc882_capture_source, | |
6334 | }, | |
df694daa KY |
6335 | }; |
6336 | ||
6337 | ||
f95474ec TI |
6338 | /* |
6339 | * Pin config fixes | |
6340 | */ | |
6341 | enum { | |
6342 | PINFIX_ABIT_AW9D_MAX | |
6343 | }; | |
6344 | ||
6345 | static struct alc_pincfg alc882_abit_aw9d_pinfix[] = { | |
6346 | { 0x15, 0x01080104 }, /* side */ | |
6347 | { 0x16, 0x01011012 }, /* rear */ | |
6348 | { 0x17, 0x01016011 }, /* clfe */ | |
6349 | { } | |
6350 | }; | |
6351 | ||
6352 | static const struct alc_pincfg *alc882_pin_fixes[] = { | |
6353 | [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix, | |
6354 | }; | |
6355 | ||
6356 | static struct snd_pci_quirk alc882_pinfix_tbl[] = { | |
6357 | SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX), | |
6358 | {} | |
6359 | }; | |
6360 | ||
df694daa KY |
6361 | /* |
6362 | * BIOS auto configuration | |
6363 | */ | |
6364 | static void alc882_auto_set_output_and_unmute(struct hda_codec *codec, | |
6365 | hda_nid_t nid, int pin_type, | |
6366 | int dac_idx) | |
6367 | { | |
6368 | /* set as output */ | |
6369 | struct alc_spec *spec = codec->spec; | |
f12ab1e0 TI |
6370 | int idx; |
6371 | ||
f6c7e546 | 6372 | alc_set_pin_output(codec, nid, pin_type); |
df694daa KY |
6373 | if (spec->multiout.dac_nids[dac_idx] == 0x25) |
6374 | idx = 4; | |
6375 | else | |
6376 | idx = spec->multiout.dac_nids[dac_idx] - 2; | |
df694daa KY |
6377 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); |
6378 | ||
6379 | } | |
6380 | ||
6381 | static void alc882_auto_init_multi_out(struct hda_codec *codec) | |
6382 | { | |
6383 | struct alc_spec *spec = codec->spec; | |
6384 | int i; | |
6385 | ||
bc9f98a9 | 6386 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
df694daa | 6387 | for (i = 0; i <= HDA_SIDE; i++) { |
f12ab1e0 | 6388 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
baba8ee9 | 6389 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
df694daa | 6390 | if (nid) |
baba8ee9 | 6391 | alc882_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 6392 | i); |
df694daa KY |
6393 | } |
6394 | } | |
6395 | ||
6396 | static void alc882_auto_init_hp_out(struct hda_codec *codec) | |
6397 | { | |
6398 | struct alc_spec *spec = codec->spec; | |
6399 | hda_nid_t pin; | |
6400 | ||
eb06ed8f | 6401 | pin = spec->autocfg.hp_pins[0]; |
df694daa | 6402 | if (pin) /* connect to front */ |
f12ab1e0 TI |
6403 | /* use dac 0 */ |
6404 | alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
f6c7e546 TI |
6405 | pin = spec->autocfg.speaker_pins[0]; |
6406 | if (pin) | |
6407 | alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
df694daa KY |
6408 | } |
6409 | ||
6410 | #define alc882_is_input_pin(nid) alc880_is_input_pin(nid) | |
6411 | #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID | |
6412 | ||
6413 | static void alc882_auto_init_analog_input(struct hda_codec *codec) | |
6414 | { | |
6415 | struct alc_spec *spec = codec->spec; | |
6416 | int i; | |
6417 | ||
6418 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
6419 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
7194cae6 TI |
6420 | unsigned int vref; |
6421 | if (!nid) | |
6422 | continue; | |
6423 | vref = PIN_IN; | |
6424 | if (1 /*i <= AUTO_PIN_FRONT_MIC*/) { | |
531240ff KY |
6425 | unsigned int pincap; |
6426 | pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); | |
6427 | if ((pincap >> AC_PINCAP_VREF_SHIFT) & | |
7194cae6 TI |
6428 | AC_PINCAP_VREF_80) |
6429 | vref = PIN_VREF80; | |
df694daa | 6430 | } |
7194cae6 TI |
6431 | snd_hda_codec_write(codec, nid, 0, |
6432 | AC_VERB_SET_PIN_WIDGET_CONTROL, vref); | |
6433 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) | |
6434 | snd_hda_codec_write(codec, nid, 0, | |
6435 | AC_VERB_SET_AMP_GAIN_MUTE, | |
6436 | AMP_OUT_MUTE); | |
df694daa KY |
6437 | } |
6438 | } | |
6439 | ||
776e184e TI |
6440 | /* add mic boosts if needed */ |
6441 | static int alc_auto_add_mic_boost(struct hda_codec *codec) | |
6442 | { | |
6443 | struct alc_spec *spec = codec->spec; | |
6444 | int err; | |
6445 | hda_nid_t nid; | |
6446 | ||
6447 | nid = spec->autocfg.input_pins[AUTO_PIN_MIC]; | |
ce22e03e | 6448 | if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) { |
776e184e TI |
6449 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
6450 | "Mic Boost", | |
6451 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | |
6452 | if (err < 0) | |
6453 | return err; | |
6454 | } | |
6455 | nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]; | |
ce22e03e | 6456 | if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) { |
776e184e TI |
6457 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
6458 | "Front Mic Boost", | |
6459 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | |
6460 | if (err < 0) | |
6461 | return err; | |
6462 | } | |
6463 | return 0; | |
6464 | } | |
6465 | ||
df694daa KY |
6466 | /* almost identical with ALC880 parser... */ |
6467 | static int alc882_parse_auto_config(struct hda_codec *codec) | |
6468 | { | |
6469 | struct alc_spec *spec = codec->spec; | |
6470 | int err = alc880_parse_auto_config(codec); | |
6471 | ||
6472 | if (err < 0) | |
6473 | return err; | |
776e184e TI |
6474 | else if (!err) |
6475 | return 0; /* no config found */ | |
6476 | ||
6477 | err = alc_auto_add_mic_boost(codec); | |
6478 | if (err < 0) | |
6479 | return err; | |
6480 | ||
6481 | /* hack - override the init verbs */ | |
6482 | spec->init_verbs[0] = alc882_auto_init_verbs; | |
6483 | ||
6484 | return 1; /* config found */ | |
df694daa KY |
6485 | } |
6486 | ||
ae6b813a TI |
6487 | /* additional initialization for auto-configuration model */ |
6488 | static void alc882_auto_init(struct hda_codec *codec) | |
df694daa | 6489 | { |
f6c7e546 | 6490 | struct alc_spec *spec = codec->spec; |
df694daa KY |
6491 | alc882_auto_init_multi_out(codec); |
6492 | alc882_auto_init_hp_out(codec); | |
6493 | alc882_auto_init_analog_input(codec); | |
f6c7e546 TI |
6494 | if (spec->unsol_event) |
6495 | alc_sku_automute(codec); | |
df694daa KY |
6496 | } |
6497 | ||
7943a8ab TI |
6498 | static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */ |
6499 | ||
df694daa KY |
6500 | static int patch_alc882(struct hda_codec *codec) |
6501 | { | |
6502 | struct alc_spec *spec; | |
6503 | int err, board_config; | |
6504 | ||
6505 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
6506 | if (spec == NULL) | |
6507 | return -ENOMEM; | |
6508 | ||
6509 | codec->spec = spec; | |
6510 | ||
f5fcc13c TI |
6511 | board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST, |
6512 | alc882_models, | |
6513 | alc882_cfg_tbl); | |
df694daa KY |
6514 | |
6515 | if (board_config < 0 || board_config >= ALC882_MODEL_LAST) { | |
081d17c4 TD |
6516 | /* Pick up systems that don't supply PCI SSID */ |
6517 | switch (codec->subsystem_id) { | |
6518 | case 0x106b0c00: /* Mac Pro */ | |
6519 | board_config = ALC885_MACPRO; | |
6520 | break; | |
c54728d8 NF |
6521 | case 0x106b1000: /* iMac 24 */ |
6522 | board_config = ALC885_IMAC24; | |
6523 | break; | |
c7e0757a | 6524 | case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */ |
87350ad0 | 6525 | case 0x106b2c00: /* Macbook Pro rev3 */ |
c7e0757a | 6526 | case 0x106b3600: /* Macbook 3.1 */ |
87350ad0 TI |
6527 | board_config = ALC885_MBP3; |
6528 | break; | |
081d17c4 | 6529 | default: |
7943a8ab TI |
6530 | /* ALC889A is handled better as ALC888-compatible */ |
6531 | if (codec->revision_id == 0x100103) { | |
6532 | alc_free(codec); | |
6533 | return patch_alc883(codec); | |
6534 | } | |
081d17c4 TD |
6535 | printk(KERN_INFO "hda_codec: Unknown model for ALC882, " |
6536 | "trying auto-probe from BIOS...\n"); | |
6537 | board_config = ALC882_AUTO; | |
6538 | } | |
df694daa KY |
6539 | } |
6540 | ||
f95474ec TI |
6541 | alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes); |
6542 | ||
df694daa KY |
6543 | if (board_config == ALC882_AUTO) { |
6544 | /* automatic parse from the BIOS config */ | |
6545 | err = alc882_parse_auto_config(codec); | |
6546 | if (err < 0) { | |
6547 | alc_free(codec); | |
6548 | return err; | |
f12ab1e0 | 6549 | } else if (!err) { |
9c7f852e TI |
6550 | printk(KERN_INFO |
6551 | "hda_codec: Cannot set up configuration " | |
6552 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
6553 | board_config = ALC882_3ST_DIG; |
6554 | } | |
6555 | } | |
6556 | ||
6557 | if (board_config != ALC882_AUTO) | |
6558 | setup_preset(spec, &alc882_presets[board_config]); | |
1da177e4 | 6559 | |
2f893286 KY |
6560 | if (codec->vendor_id == 0x10ec0885) { |
6561 | spec->stream_name_analog = "ALC885 Analog"; | |
6562 | spec->stream_name_digital = "ALC885 Digital"; | |
6563 | } else { | |
6564 | spec->stream_name_analog = "ALC882 Analog"; | |
6565 | spec->stream_name_digital = "ALC882 Digital"; | |
6566 | } | |
6567 | ||
df694daa KY |
6568 | spec->stream_analog_playback = &alc882_pcm_analog_playback; |
6569 | spec->stream_analog_capture = &alc882_pcm_analog_capture; | |
6330079f TI |
6570 | /* FIXME: setup DAC5 */ |
6571 | /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/ | |
6572 | spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture; | |
1da177e4 | 6573 | |
df694daa KY |
6574 | spec->stream_digital_playback = &alc882_pcm_digital_playback; |
6575 | spec->stream_digital_capture = &alc882_pcm_digital_capture; | |
1da177e4 | 6576 | |
f12ab1e0 | 6577 | if (!spec->adc_nids && spec->input_mux) { |
df694daa | 6578 | /* check whether NID 0x07 is valid */ |
4a471b7d | 6579 | unsigned int wcap = get_wcaps(codec, 0x07); |
f12ab1e0 TI |
6580 | /* get type */ |
6581 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
df694daa KY |
6582 | if (wcap != AC_WID_AUD_IN) { |
6583 | spec->adc_nids = alc882_adc_nids_alt; | |
6584 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt); | |
e1406348 | 6585 | spec->capsrc_nids = alc882_capsrc_nids_alt; |
f12ab1e0 TI |
6586 | spec->mixers[spec->num_mixers] = |
6587 | alc882_capture_alt_mixer; | |
df694daa KY |
6588 | spec->num_mixers++; |
6589 | } else { | |
6590 | spec->adc_nids = alc882_adc_nids; | |
6591 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids); | |
e1406348 | 6592 | spec->capsrc_nids = alc882_capsrc_nids; |
df694daa KY |
6593 | spec->mixers[spec->num_mixers] = alc882_capture_mixer; |
6594 | spec->num_mixers++; | |
6595 | } | |
6596 | } | |
1da177e4 | 6597 | |
2134ea4f TI |
6598 | spec->vmaster_nid = 0x0c; |
6599 | ||
1da177e4 | 6600 | codec->patch_ops = alc_patch_ops; |
df694daa | 6601 | if (board_config == ALC882_AUTO) |
ae6b813a | 6602 | spec->init_hook = alc882_auto_init; |
cb53c626 TI |
6603 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
6604 | if (!spec->loopback.amplist) | |
6605 | spec->loopback.amplist = alc882_loopbacks; | |
6606 | #endif | |
df694daa KY |
6607 | |
6608 | return 0; | |
6609 | } | |
6610 | ||
6611 | /* | |
9c7f852e TI |
6612 | * ALC883 support |
6613 | * | |
6614 | * ALC883 is almost identical with ALC880 but has cleaner and more flexible | |
6615 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
6616 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
6617 | * 6-channel independent captures. | |
6618 | * | |
6619 | * In addition, an independent DAC for the multi-playback (not used in this | |
6620 | * driver yet). | |
df694daa | 6621 | */ |
9c7f852e TI |
6622 | #define ALC883_DIGOUT_NID 0x06 |
6623 | #define ALC883_DIGIN_NID 0x0a | |
df694daa | 6624 | |
9c7f852e TI |
6625 | static hda_nid_t alc883_dac_nids[4] = { |
6626 | /* front, rear, clfe, rear_surr */ | |
f32a19e3 | 6627 | 0x02, 0x03, 0x04, 0x05 |
9c7f852e | 6628 | }; |
df694daa | 6629 | |
9c7f852e TI |
6630 | static hda_nid_t alc883_adc_nids[2] = { |
6631 | /* ADC1-2 */ | |
6632 | 0x08, 0x09, | |
6633 | }; | |
f12ab1e0 | 6634 | |
e1406348 TI |
6635 | static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 }; |
6636 | ||
9c7f852e TI |
6637 | /* input MUX */ |
6638 | /* FIXME: should be a matrix-type input source selection */ | |
df694daa | 6639 | |
9c7f852e TI |
6640 | static struct hda_input_mux alc883_capture_source = { |
6641 | .num_items = 4, | |
6642 | .items = { | |
6643 | { "Mic", 0x0 }, | |
6644 | { "Front Mic", 0x1 }, | |
6645 | { "Line", 0x2 }, | |
6646 | { "CD", 0x4 }, | |
6647 | }, | |
6648 | }; | |
bc9f98a9 | 6649 | |
17bba1b7 J |
6650 | static struct hda_input_mux alc883_3stack_6ch_intel = { |
6651 | .num_items = 4, | |
6652 | .items = { | |
6653 | { "Mic", 0x1 }, | |
6654 | { "Front Mic", 0x0 }, | |
6655 | { "Line", 0x2 }, | |
6656 | { "CD", 0x4 }, | |
6657 | }, | |
6658 | }; | |
6659 | ||
bc9f98a9 KY |
6660 | static struct hda_input_mux alc883_lenovo_101e_capture_source = { |
6661 | .num_items = 2, | |
6662 | .items = { | |
6663 | { "Mic", 0x1 }, | |
6664 | { "Line", 0x2 }, | |
6665 | }, | |
6666 | }; | |
6667 | ||
272a527c KY |
6668 | static struct hda_input_mux alc883_lenovo_nb0763_capture_source = { |
6669 | .num_items = 4, | |
6670 | .items = { | |
6671 | { "Mic", 0x0 }, | |
6672 | { "iMic", 0x1 }, | |
6673 | { "Line", 0x2 }, | |
6674 | { "CD", 0x4 }, | |
6675 | }, | |
6676 | }; | |
6677 | ||
fb97dc67 J |
6678 | static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = { |
6679 | .num_items = 2, | |
6680 | .items = { | |
6681 | { "Mic", 0x0 }, | |
6682 | { "Int Mic", 0x1 }, | |
6683 | }, | |
6684 | }; | |
6685 | ||
9c7f852e TI |
6686 | #define alc883_mux_enum_info alc_mux_enum_info |
6687 | #define alc883_mux_enum_get alc_mux_enum_get | |
e1406348 TI |
6688 | /* ALC883 has the ALC882-type input selection */ |
6689 | #define alc883_mux_enum_put alc882_mux_enum_put | |
f12ab1e0 | 6690 | |
9c7f852e TI |
6691 | /* |
6692 | * 2ch mode | |
6693 | */ | |
6694 | static struct hda_channel_mode alc883_3ST_2ch_modes[1] = { | |
6695 | { 2, NULL } | |
6696 | }; | |
6697 | ||
6698 | /* | |
6699 | * 2ch mode | |
6700 | */ | |
6701 | static struct hda_verb alc883_3ST_ch2_init[] = { | |
6702 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
6703 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
6704 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
6705 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
6706 | { } /* end */ | |
6707 | }; | |
6708 | ||
b201131c TD |
6709 | /* |
6710 | * 4ch mode | |
6711 | */ | |
6712 | static struct hda_verb alc883_3ST_ch4_init[] = { | |
6713 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
6714 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
6715 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6716 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
6717 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
6718 | { } /* end */ | |
6719 | }; | |
6720 | ||
9c7f852e TI |
6721 | /* |
6722 | * 6ch mode | |
6723 | */ | |
6724 | static struct hda_verb alc883_3ST_ch6_init[] = { | |
6725 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6726 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
6727 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
6728 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6729 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
6730 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
6731 | { } /* end */ | |
6732 | }; | |
6733 | ||
b201131c | 6734 | static struct hda_channel_mode alc883_3ST_6ch_modes[3] = { |
9c7f852e | 6735 | { 2, alc883_3ST_ch2_init }, |
b201131c | 6736 | { 4, alc883_3ST_ch4_init }, |
9c7f852e TI |
6737 | { 6, alc883_3ST_ch6_init }, |
6738 | }; | |
6739 | ||
17bba1b7 J |
6740 | /* |
6741 | * 2ch mode | |
6742 | */ | |
6743 | static struct hda_verb alc883_3ST_ch2_intel_init[] = { | |
6744 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
6745 | { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
6746 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
6747 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
6748 | { } /* end */ | |
6749 | }; | |
6750 | ||
6751 | /* | |
6752 | * 4ch mode | |
6753 | */ | |
6754 | static struct hda_verb alc883_3ST_ch4_intel_init[] = { | |
6755 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
6756 | { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
6757 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6758 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
6759 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
6760 | { } /* end */ | |
6761 | }; | |
6762 | ||
6763 | /* | |
6764 | * 6ch mode | |
6765 | */ | |
6766 | static struct hda_verb alc883_3ST_ch6_intel_init[] = { | |
6767 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6768 | { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
6769 | { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
6770 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6771 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
6772 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
6773 | { } /* end */ | |
6774 | }; | |
6775 | ||
6776 | static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = { | |
6777 | { 2, alc883_3ST_ch2_intel_init }, | |
6778 | { 4, alc883_3ST_ch4_intel_init }, | |
6779 | { 6, alc883_3ST_ch6_intel_init }, | |
6780 | }; | |
6781 | ||
9c7f852e TI |
6782 | /* |
6783 | * 6ch mode | |
6784 | */ | |
6785 | static struct hda_verb alc883_sixstack_ch6_init[] = { | |
6786 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
6787 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6788 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6789 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6790 | { } /* end */ | |
6791 | }; | |
6792 | ||
6793 | /* | |
6794 | * 8ch mode | |
6795 | */ | |
6796 | static struct hda_verb alc883_sixstack_ch8_init[] = { | |
6797 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6798 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6799 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6800 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6801 | { } /* end */ | |
6802 | }; | |
6803 | ||
6804 | static struct hda_channel_mode alc883_sixstack_modes[2] = { | |
6805 | { 6, alc883_sixstack_ch6_init }, | |
6806 | { 8, alc883_sixstack_ch8_init }, | |
6807 | }; | |
6808 | ||
b373bdeb AN |
6809 | static struct hda_verb alc883_medion_eapd_verbs[] = { |
6810 | /* eanable EAPD on medion laptop */ | |
6811 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
6812 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
6813 | { } | |
6814 | }; | |
6815 | ||
9c7f852e TI |
6816 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
6817 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
6818 | */ | |
6819 | ||
6820 | static struct snd_kcontrol_new alc883_base_mixer[] = { | |
df694daa | 6821 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9c7f852e TI |
6822 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
6823 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
6824 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
6825 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
6826 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
6827 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
6828 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
6829 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
6830 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
6831 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
df694daa KY |
6832 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
6833 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6834 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6835 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6836 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 6837 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
df694daa | 6838 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
9c7f852e | 6839 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
32360416 | 6840 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
6841 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
6842 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
6843 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
6844 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6845 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6846 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6847 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6848 | { | |
6849 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6850 | /* .name = "Capture Source", */ | |
6851 | .name = "Input Source", | |
6852 | .count = 2, | |
6853 | .info = alc883_mux_enum_info, | |
6854 | .get = alc883_mux_enum_get, | |
6855 | .put = alc883_mux_enum_put, | |
6856 | }, | |
df694daa | 6857 | { } /* end */ |
834be88d TI |
6858 | }; |
6859 | ||
a8848bd6 AS |
6860 | static struct snd_kcontrol_new alc883_mitac_mixer[] = { |
6861 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6862 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
6863 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
6864 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
6865 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
6866 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
6867 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
6868 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6869 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
6870 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
6871 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
6872 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
6873 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
6874 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6875 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6876 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6877 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6878 | { | |
6879 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6880 | /* .name = "Capture Source", */ | |
6881 | .name = "Input Source", | |
6882 | .count = 2, | |
6883 | .info = alc883_mux_enum_info, | |
6884 | .get = alc883_mux_enum_get, | |
6885 | .put = alc883_mux_enum_put, | |
6886 | }, | |
6887 | { } /* end */ | |
6888 | }; | |
6889 | ||
0c4cc443 | 6890 | static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = { |
368c7a95 J |
6891 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
6892 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
6893 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
6894 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
6895 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6896 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
6897 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
6898 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
6899 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
6900 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
6901 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6902 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6903 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6904 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6905 | { | |
6906 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6907 | /* .name = "Capture Source", */ | |
6908 | .name = "Input Source", | |
6909 | .count = 2, | |
6910 | .info = alc883_mux_enum_info, | |
6911 | .get = alc883_mux_enum_get, | |
6912 | .put = alc883_mux_enum_put, | |
6913 | }, | |
6914 | { } /* end */ | |
6915 | }; | |
6916 | ||
fb97dc67 J |
6917 | static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = { |
6918 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6919 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
6920 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
6921 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
6922 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6923 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
6924 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
6925 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
6926 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
6927 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
6928 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6929 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6930 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6931 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6932 | { | |
6933 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6934 | /* .name = "Capture Source", */ | |
6935 | .name = "Input Source", | |
6936 | .count = 2, | |
6937 | .info = alc883_mux_enum_info, | |
6938 | .get = alc883_mux_enum_get, | |
6939 | .put = alc883_mux_enum_put, | |
6940 | }, | |
6941 | { } /* end */ | |
6942 | }; | |
6943 | ||
9c7f852e TI |
6944 | static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = { |
6945 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6946 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
6947 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6948 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6949 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6950 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6951 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6952 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 6953 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
6954 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
6955 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 6956 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
6957 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
6958 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
6959 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
6960 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6961 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6962 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6963 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6964 | { | |
6965 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6966 | /* .name = "Capture Source", */ | |
6967 | .name = "Input Source", | |
6968 | .count = 2, | |
6969 | .info = alc883_mux_enum_info, | |
6970 | .get = alc883_mux_enum_get, | |
6971 | .put = alc883_mux_enum_put, | |
6972 | }, | |
6973 | { } /* end */ | |
6974 | }; | |
df694daa | 6975 | |
9c7f852e TI |
6976 | static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = { |
6977 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6978 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
6979 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
6980 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
6981 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
6982 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
6983 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
6984 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
6985 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6986 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6987 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6988 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6989 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6990 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 6991 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
6992 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
6993 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 6994 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
6995 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
6996 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
6997 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
6998 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6999 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
7000 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
7001 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
7002 | { | |
7003 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7004 | /* .name = "Capture Source", */ | |
7005 | .name = "Input Source", | |
7006 | .count = 2, | |
7007 | .info = alc883_mux_enum_info, | |
7008 | .get = alc883_mux_enum_get, | |
7009 | .put = alc883_mux_enum_put, | |
7010 | }, | |
7011 | { } /* end */ | |
7012 | }; | |
7013 | ||
17bba1b7 J |
7014 | static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = { |
7015 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7016 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
7017 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7018 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
7019 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, | |
7020 | HDA_OUTPUT), | |
7021 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
7022 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
7023 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
7024 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
7025 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7026 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7027 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7028 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7029 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7030 | HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT), | |
7031 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
7032 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7033 | HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT), | |
7034 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7035 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
7036 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
7037 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
7038 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
7039 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
7040 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
7041 | { | |
7042 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7043 | /* .name = "Capture Source", */ | |
7044 | .name = "Input Source", | |
7045 | .count = 2, | |
7046 | .info = alc883_mux_enum_info, | |
7047 | .get = alc883_mux_enum_get, | |
7048 | .put = alc883_mux_enum_put, | |
7049 | }, | |
7050 | { } /* end */ | |
7051 | }; | |
7052 | ||
d1d985f0 | 7053 | static struct snd_kcontrol_new alc883_fivestack_mixer[] = { |
c07584c8 | 7054 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
0701e064 | 7055 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
c07584c8 | 7056 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
0701e064 | 7057 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
c07584c8 TD |
7058 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
7059 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
0701e064 TI |
7060 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
7061 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
c07584c8 TD |
7062 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
7063 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7064 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7065 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7066 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7067 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 7068 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
c07584c8 TD |
7069 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
7070 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 7071 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
c07584c8 TD |
7072 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
7073 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
7074 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
7075 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
7076 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
7077 | ||
7078 | { | |
7079 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7080 | /* .name = "Capture Source", */ | |
7081 | .name = "Input Source", | |
7082 | .count = 1, | |
7083 | .info = alc883_mux_enum_info, | |
7084 | .get = alc883_mux_enum_get, | |
7085 | .put = alc883_mux_enum_put, | |
7086 | }, | |
7087 | { } /* end */ | |
7088 | }; | |
7089 | ||
ccc656ce KY |
7090 | static struct snd_kcontrol_new alc883_tagra_mixer[] = { |
7091 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7092 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7093 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7094 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7095 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
7096 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
7097 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
7098 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
7099 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
7100 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7101 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7102 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7103 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7104 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 7105 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce KY |
7106 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
7107 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
7108 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
7109 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
7110 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
7111 | { | |
7112 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7113 | /* .name = "Capture Source", */ | |
7114 | .name = "Input Source", | |
7115 | .count = 2, | |
7116 | .info = alc883_mux_enum_info, | |
7117 | .get = alc883_mux_enum_get, | |
7118 | .put = alc883_mux_enum_put, | |
7119 | }, | |
7120 | { } /* end */ | |
f12ab1e0 | 7121 | }; |
ccc656ce KY |
7122 | |
7123 | static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = { | |
7124 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7125 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7126 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7127 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7128 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7129 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 7130 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce | 7131 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
4383fae0 J |
7132 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
7133 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
7134 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
ccc656ce KY |
7135 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
7136 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
7137 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
7138 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
7139 | { | |
7140 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7141 | /* .name = "Capture Source", */ | |
7142 | .name = "Input Source", | |
7143 | .count = 2, | |
7144 | .info = alc883_mux_enum_info, | |
7145 | .get = alc883_mux_enum_get, | |
7146 | .put = alc883_mux_enum_put, | |
7147 | }, | |
7148 | { } /* end */ | |
f12ab1e0 | 7149 | }; |
ccc656ce | 7150 | |
bc9f98a9 KY |
7151 | static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = { |
7152 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7153 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
86cd9298 TI |
7154 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
7155 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
bc9f98a9 KY |
7156 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
7157 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7158 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7159 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
7160 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
7161 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
7162 | { | |
7163 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7164 | /* .name = "Capture Source", */ | |
7165 | .name = "Input Source", | |
7166 | .count = 1, | |
7167 | .info = alc883_mux_enum_info, | |
7168 | .get = alc883_mux_enum_get, | |
7169 | .put = alc883_mux_enum_put, | |
7170 | }, | |
7171 | { } /* end */ | |
f12ab1e0 | 7172 | }; |
bc9f98a9 | 7173 | |
272a527c KY |
7174 | static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = { |
7175 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7176 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT), | |
7177 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7178 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7179 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7180 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7181 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7182 | HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7183 | HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
7184 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
7185 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
7186 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
7187 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
7188 | { | |
7189 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7190 | /* .name = "Capture Source", */ | |
7191 | .name = "Input Source", | |
7192 | .count = 2, | |
7193 | .info = alc883_mux_enum_info, | |
7194 | .get = alc883_mux_enum_get, | |
7195 | .put = alc883_mux_enum_put, | |
7196 | }, | |
7197 | { } /* end */ | |
7198 | }; | |
7199 | ||
7200 | static struct snd_kcontrol_new alc883_medion_md2_mixer[] = { | |
7201 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7202 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7203 | HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
7204 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7205 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7206 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7207 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7208 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7209 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7210 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
7211 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
7212 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
7213 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
7214 | { | |
7215 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7216 | /* .name = "Capture Source", */ | |
7217 | .name = "Input Source", | |
7218 | .count = 2, | |
7219 | .info = alc883_mux_enum_info, | |
7220 | .get = alc883_mux_enum_get, | |
7221 | .put = alc883_mux_enum_put, | |
7222 | }, | |
7223 | { } /* end */ | |
7224 | }; | |
7225 | ||
2880a867 | 7226 | static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = { |
d1a991a6 KY |
7227 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
7228 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
2880a867 | 7229 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), |
2880a867 TD |
7230 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
7231 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
d1a991a6 KY |
7232 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
7233 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7234 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2880a867 TD |
7235 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
7236 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
7237 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
7238 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
7239 | { | |
7240 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7241 | /* .name = "Capture Source", */ | |
7242 | .name = "Input Source", | |
7243 | .count = 2, | |
7244 | .info = alc883_mux_enum_info, | |
7245 | .get = alc883_mux_enum_get, | |
7246 | .put = alc883_mux_enum_put, | |
7247 | }, | |
7248 | { } /* end */ | |
d1a991a6 | 7249 | }; |
2880a867 | 7250 | |
9c7f852e TI |
7251 | static struct snd_kcontrol_new alc883_chmode_mixer[] = { |
7252 | { | |
7253 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7254 | .name = "Channel Mode", | |
7255 | .info = alc_ch_mode_info, | |
7256 | .get = alc_ch_mode_get, | |
7257 | .put = alc_ch_mode_put, | |
7258 | }, | |
7259 | { } /* end */ | |
7260 | }; | |
7261 | ||
7262 | static struct hda_verb alc883_init_verbs[] = { | |
7263 | /* ADC1: mute amp left and right */ | |
7264 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
df694daa | 7265 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
9c7f852e TI |
7266 | /* ADC2: mute amp left and right */ |
7267 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
df694daa | 7268 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
9c7f852e TI |
7269 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ |
7270 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7271 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7272 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7273 | /* Rear mixer */ | |
7274 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7275 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7276 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7277 | /* CLFE mixer */ | |
7278 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7279 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7280 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7281 | /* Side mixer */ | |
7282 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7283 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7284 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
df694daa | 7285 | |
cb53c626 TI |
7286 | /* mute analog input loopbacks */ |
7287 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7288 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7289 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
7290 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
7291 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa | 7292 | |
9c7f852e TI |
7293 | /* Front Pin: output 0 (0x0c) */ |
7294 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7295 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7296 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7297 | /* Rear Pin: output 1 (0x0d) */ | |
7298 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7299 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7300 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
7301 | /* CLFE Pin: output 2 (0x0e) */ | |
7302 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7303 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7304 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
7305 | /* Side Pin: output 3 (0x0f) */ | |
7306 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7307 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7308 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
7309 | /* Mic (rear) pin: input vref at 80% */ | |
7310 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
7311 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
7312 | /* Front Mic pin: input vref at 80% */ | |
7313 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
7314 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
7315 | /* Line In pin: input */ | |
7316 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
7317 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
7318 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
7319 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7320 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7321 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7322 | /* CD pin widget for input */ | |
7323 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
7324 | ||
7325 | /* FIXME: use matrix-type input source selection */ | |
7326 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
7327 | /* Input mixer2 */ | |
7328 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7329 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7330 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
7331 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
7332 | /* Input mixer3 */ | |
7333 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7334 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7335 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
7336 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
7337 | { } | |
7338 | }; | |
7339 | ||
a8848bd6 AS |
7340 | /* toggle speaker-output according to the hp-jack state */ |
7341 | static void alc883_mitac_hp_automute(struct hda_codec *codec) | |
7342 | { | |
7343 | unsigned int present; | |
7344 | ||
7345 | present = snd_hda_codec_read(codec, 0x15, 0, | |
7346 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
7347 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
7348 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7349 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
7350 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7351 | } | |
7352 | ||
7353 | /* auto-toggle front mic */ | |
7354 | /* | |
7355 | static void alc883_mitac_mic_automute(struct hda_codec *codec) | |
7356 | { | |
7357 | unsigned int present; | |
7358 | unsigned char bits; | |
7359 | ||
7360 | present = snd_hda_codec_read(codec, 0x18, 0, | |
7361 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
7362 | bits = present ? HDA_AMP_MUTE : 0; | |
7363 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); | |
7364 | } | |
7365 | */ | |
7366 | ||
7367 | static void alc883_mitac_automute(struct hda_codec *codec) | |
7368 | { | |
7369 | alc883_mitac_hp_automute(codec); | |
7370 | /* alc883_mitac_mic_automute(codec); */ | |
7371 | } | |
7372 | ||
7373 | static void alc883_mitac_unsol_event(struct hda_codec *codec, | |
7374 | unsigned int res) | |
7375 | { | |
7376 | switch (res >> 26) { | |
7377 | case ALC880_HP_EVENT: | |
7378 | alc883_mitac_hp_automute(codec); | |
7379 | break; | |
7380 | case ALC880_MIC_EVENT: | |
7381 | /* alc883_mitac_mic_automute(codec); */ | |
7382 | break; | |
7383 | } | |
7384 | } | |
7385 | ||
7386 | static struct hda_verb alc883_mitac_verbs[] = { | |
7387 | /* HP */ | |
7388 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7389 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7390 | /* Subwoofer */ | |
7391 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
7392 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7393 | ||
7394 | /* enable unsolicited event */ | |
7395 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7396 | /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */ | |
7397 | ||
7398 | { } /* end */ | |
7399 | }; | |
7400 | ||
0c4cc443 | 7401 | static struct hda_verb alc883_clevo_m720_verbs[] = { |
368c7a95 J |
7402 | /* HP */ |
7403 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7404 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7405 | /* Int speaker */ | |
7406 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
7407 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7408 | ||
7409 | /* enable unsolicited event */ | |
7410 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
0c4cc443 | 7411 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, |
368c7a95 J |
7412 | |
7413 | { } /* end */ | |
7414 | }; | |
7415 | ||
fb97dc67 J |
7416 | static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = { |
7417 | /* HP */ | |
7418 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7419 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7420 | /* Subwoofer */ | |
7421 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
7422 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7423 | ||
7424 | /* enable unsolicited event */ | |
7425 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7426 | ||
7427 | { } /* end */ | |
7428 | }; | |
7429 | ||
ccc656ce KY |
7430 | static struct hda_verb alc883_tagra_verbs[] = { |
7431 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7432 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7433 | ||
7434 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7435 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7436 | ||
7437 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
7438 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
7439 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
7440 | ||
7441 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
f12ab1e0 TI |
7442 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
7443 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | |
7444 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | |
ccc656ce KY |
7445 | |
7446 | { } /* end */ | |
7447 | }; | |
7448 | ||
bc9f98a9 KY |
7449 | static struct hda_verb alc883_lenovo_101e_verbs[] = { |
7450 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7451 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN}, | |
7452 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN}, | |
7453 | { } /* end */ | |
7454 | }; | |
7455 | ||
272a527c KY |
7456 | static struct hda_verb alc883_lenovo_nb0763_verbs[] = { |
7457 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7458 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7459 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7460 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7461 | { } /* end */ | |
7462 | }; | |
7463 | ||
7464 | static struct hda_verb alc888_lenovo_ms7195_verbs[] = { | |
7465 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7466 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7467 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7468 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN}, | |
7469 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7470 | { } /* end */ | |
7471 | }; | |
7472 | ||
189609ae KY |
7473 | static struct hda_verb alc883_haier_w66_verbs[] = { |
7474 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7475 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7476 | ||
7477 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7478 | ||
7479 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7480 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7481 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7482 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7483 | { } /* end */ | |
7484 | }; | |
7485 | ||
4723c022 | 7486 | static struct hda_verb alc888_3st_hp_verbs[] = { |
8341de60 | 7487 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */ |
f32a19e3 HRK |
7488 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */ |
7489 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */ | |
8341de60 CM |
7490 | { } |
7491 | }; | |
7492 | ||
5795b9e6 | 7493 | static struct hda_verb alc888_6st_dell_verbs[] = { |
5795b9e6 CM |
7494 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
7495 | { } | |
7496 | }; | |
7497 | ||
4723c022 | 7498 | static struct hda_verb alc888_3st_hp_2ch_init[] = { |
8341de60 CM |
7499 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
7500 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7501 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
7502 | { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7503 | { } | |
7504 | }; | |
7505 | ||
4723c022 | 7506 | static struct hda_verb alc888_3st_hp_6ch_init[] = { |
8341de60 CM |
7507 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
7508 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7509 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7510 | { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7511 | { } | |
7512 | }; | |
7513 | ||
4723c022 CM |
7514 | static struct hda_channel_mode alc888_3st_hp_modes[2] = { |
7515 | { 2, alc888_3st_hp_2ch_init }, | |
7516 | { 6, alc888_3st_hp_6ch_init }, | |
8341de60 CM |
7517 | }; |
7518 | ||
272a527c KY |
7519 | /* toggle front-jack and RCA according to the hp-jack state */ |
7520 | static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec) | |
7521 | { | |
7522 | unsigned int present; | |
7523 | ||
7524 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
7525 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
7526 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
7527 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7528 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
7529 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c KY |
7530 | } |
7531 | ||
7532 | /* toggle RCA according to the front-jack state */ | |
7533 | static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec) | |
7534 | { | |
7535 | unsigned int present; | |
7536 | ||
7537 | present = snd_hda_codec_read(codec, 0x14, 0, | |
7538 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
7539 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
7540 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c | 7541 | } |
47fd830a | 7542 | |
272a527c KY |
7543 | static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec, |
7544 | unsigned int res) | |
7545 | { | |
7546 | if ((res >> 26) == ALC880_HP_EVENT) | |
7547 | alc888_lenovo_ms7195_front_automute(codec); | |
7548 | if ((res >> 26) == ALC880_FRONT_EVENT) | |
7549 | alc888_lenovo_ms7195_rca_automute(codec); | |
7550 | } | |
7551 | ||
7552 | static struct hda_verb alc883_medion_md2_verbs[] = { | |
7553 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7554 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7555 | ||
7556 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7557 | ||
7558 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7559 | { } /* end */ | |
7560 | }; | |
7561 | ||
7562 | /* toggle speaker-output according to the hp-jack state */ | |
7563 | static void alc883_medion_md2_automute(struct hda_codec *codec) | |
7564 | { | |
7565 | unsigned int present; | |
7566 | ||
7567 | present = snd_hda_codec_read(codec, 0x14, 0, | |
7568 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
7569 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
7570 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c KY |
7571 | } |
7572 | ||
7573 | static void alc883_medion_md2_unsol_event(struct hda_codec *codec, | |
7574 | unsigned int res) | |
7575 | { | |
7576 | if ((res >> 26) == ALC880_HP_EVENT) | |
7577 | alc883_medion_md2_automute(codec); | |
7578 | } | |
7579 | ||
ccc656ce KY |
7580 | /* toggle speaker-output according to the hp-jack state */ |
7581 | static void alc883_tagra_automute(struct hda_codec *codec) | |
7582 | { | |
7583 | unsigned int present; | |
f12ab1e0 | 7584 | unsigned char bits; |
ccc656ce KY |
7585 | |
7586 | present = snd_hda_codec_read(codec, 0x14, 0, | |
7587 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
7588 | bits = present ? HDA_AMP_MUTE : 0; |
7589 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
7590 | HDA_AMP_MUTE, bits); | |
82beb8fd TI |
7591 | snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA, |
7592 | present ? 1 : 3); | |
ccc656ce KY |
7593 | } |
7594 | ||
7595 | static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res) | |
7596 | { | |
7597 | if ((res >> 26) == ALC880_HP_EVENT) | |
7598 | alc883_tagra_automute(codec); | |
7599 | } | |
7600 | ||
368c7a95 | 7601 | /* toggle speaker-output according to the hp-jack state */ |
0c4cc443 | 7602 | static void alc883_clevo_m720_hp_automute(struct hda_codec *codec) |
368c7a95 J |
7603 | { |
7604 | unsigned int present; | |
7605 | unsigned char bits; | |
7606 | ||
7607 | present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0) | |
7608 | & AC_PINSENSE_PRESENCE; | |
7609 | bits = present ? HDA_AMP_MUTE : 0; | |
7610 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
7611 | HDA_AMP_MUTE, bits); | |
7612 | } | |
7613 | ||
0c4cc443 HRK |
7614 | static void alc883_clevo_m720_mic_automute(struct hda_codec *codec) |
7615 | { | |
7616 | unsigned int present; | |
7617 | ||
7618 | present = snd_hda_codec_read(codec, 0x18, 0, | |
7619 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
7620 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, | |
7621 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7622 | } | |
7623 | ||
7624 | static void alc883_clevo_m720_automute(struct hda_codec *codec) | |
7625 | { | |
7626 | alc883_clevo_m720_hp_automute(codec); | |
7627 | alc883_clevo_m720_mic_automute(codec); | |
7628 | } | |
7629 | ||
7630 | static void alc883_clevo_m720_unsol_event(struct hda_codec *codec, | |
368c7a95 J |
7631 | unsigned int res) |
7632 | { | |
0c4cc443 HRK |
7633 | switch (res >> 26) { |
7634 | case ALC880_HP_EVENT: | |
7635 | alc883_clevo_m720_hp_automute(codec); | |
7636 | break; | |
7637 | case ALC880_MIC_EVENT: | |
7638 | alc883_clevo_m720_mic_automute(codec); | |
7639 | break; | |
7640 | } | |
368c7a95 J |
7641 | } |
7642 | ||
fb97dc67 J |
7643 | /* toggle speaker-output according to the hp-jack state */ |
7644 | static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec) | |
7645 | { | |
7646 | unsigned int present; | |
7647 | unsigned char bits; | |
7648 | ||
7649 | present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0) | |
7650 | & AC_PINSENSE_PRESENCE; | |
7651 | bits = present ? HDA_AMP_MUTE : 0; | |
7652 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
7653 | HDA_AMP_MUTE, bits); | |
7654 | } | |
7655 | ||
7656 | static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec, | |
7657 | unsigned int res) | |
7658 | { | |
7659 | if ((res >> 26) == ALC880_HP_EVENT) | |
7660 | alc883_2ch_fujitsu_pi2515_automute(codec); | |
7661 | } | |
7662 | ||
189609ae KY |
7663 | static void alc883_haier_w66_automute(struct hda_codec *codec) |
7664 | { | |
7665 | unsigned int present; | |
7666 | unsigned char bits; | |
7667 | ||
7668 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
7669 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
7670 | bits = present ? 0x80 : 0; | |
7671 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
7672 | 0x80, bits); | |
7673 | } | |
7674 | ||
7675 | static void alc883_haier_w66_unsol_event(struct hda_codec *codec, | |
7676 | unsigned int res) | |
7677 | { | |
7678 | if ((res >> 26) == ALC880_HP_EVENT) | |
7679 | alc883_haier_w66_automute(codec); | |
7680 | } | |
7681 | ||
bc9f98a9 KY |
7682 | static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec) |
7683 | { | |
7684 | unsigned int present; | |
f12ab1e0 | 7685 | unsigned char bits; |
bc9f98a9 KY |
7686 | |
7687 | present = snd_hda_codec_read(codec, 0x14, 0, | |
7688 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
7689 | bits = present ? HDA_AMP_MUTE : 0; |
7690 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
7691 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
7692 | } |
7693 | ||
7694 | static void alc883_lenovo_101e_all_automute(struct hda_codec *codec) | |
7695 | { | |
7696 | unsigned int present; | |
f12ab1e0 | 7697 | unsigned char bits; |
bc9f98a9 KY |
7698 | |
7699 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
7700 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
7701 | bits = present ? HDA_AMP_MUTE : 0; |
7702 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
7703 | HDA_AMP_MUTE, bits); | |
7704 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
7705 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
7706 | } |
7707 | ||
7708 | static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec, | |
7709 | unsigned int res) | |
7710 | { | |
7711 | if ((res >> 26) == ALC880_HP_EVENT) | |
7712 | alc883_lenovo_101e_all_automute(codec); | |
7713 | if ((res >> 26) == ALC880_FRONT_EVENT) | |
7714 | alc883_lenovo_101e_ispeaker_automute(codec); | |
7715 | } | |
7716 | ||
676a9b53 TI |
7717 | /* toggle speaker-output according to the hp-jack state */ |
7718 | static void alc883_acer_aspire_automute(struct hda_codec *codec) | |
7719 | { | |
7720 | unsigned int present; | |
7721 | ||
7722 | present = snd_hda_codec_read(codec, 0x14, 0, | |
7723 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
7724 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
7725 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7726 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
7727 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7728 | } | |
7729 | ||
7730 | static void alc883_acer_aspire_unsol_event(struct hda_codec *codec, | |
7731 | unsigned int res) | |
7732 | { | |
7733 | if ((res >> 26) == ALC880_HP_EVENT) | |
7734 | alc883_acer_aspire_automute(codec); | |
7735 | } | |
7736 | ||
d1a991a6 KY |
7737 | static struct hda_verb alc883_acer_eapd_verbs[] = { |
7738 | /* HP Pin: output 0 (0x0c) */ | |
7739 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7740 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7741 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7742 | /* Front Pin: output 0 (0x0c) */ | |
676a9b53 TI |
7743 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
7744 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
d1a991a6 | 7745 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
d1a991a6 KY |
7746 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, |
7747 | /* eanable EAPD on medion laptop */ | |
7748 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
7749 | {0x20, AC_VERB_SET_PROC_COEF, 0x3050}, | |
676a9b53 TI |
7750 | /* enable unsolicited event */ |
7751 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
d1a991a6 KY |
7752 | { } |
7753 | }; | |
7754 | ||
5795b9e6 CM |
7755 | static void alc888_6st_dell_front_automute(struct hda_codec *codec) |
7756 | { | |
7757 | unsigned int present; | |
7758 | ||
7759 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
7760 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
7761 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
7762 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7763 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
7764 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7765 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
7766 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7767 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
7768 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7769 | } | |
7770 | ||
7771 | static void alc888_6st_dell_unsol_event(struct hda_codec *codec, | |
7772 | unsigned int res) | |
7773 | { | |
7774 | switch (res >> 26) { | |
7775 | case ALC880_HP_EVENT: | |
7776 | printk("hp_event\n"); | |
7777 | alc888_6st_dell_front_automute(codec); | |
7778 | break; | |
7779 | } | |
7780 | } | |
7781 | ||
9c7f852e TI |
7782 | /* |
7783 | * generic initialization of ADC, input mixers and output mixers | |
7784 | */ | |
7785 | static struct hda_verb alc883_auto_init_verbs[] = { | |
7786 | /* | |
7787 | * Unmute ADC0-2 and set the default input to mic-in | |
7788 | */ | |
7789 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7790 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7791 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7792 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7793 | ||
cb53c626 | 7794 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
9c7f852e | 7795 | * mixer widget |
f12ab1e0 TI |
7796 | * Note: PASD motherboards uses the Line In 2 as the input for |
7797 | * front panel mic (mic 2) | |
9c7f852e TI |
7798 | */ |
7799 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
7800 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
7801 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7802 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
7803 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
7804 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9c7f852e TI |
7805 | |
7806 | /* | |
7807 | * Set up output mixers (0x0c - 0x0f) | |
7808 | */ | |
7809 | /* set vol=0 to output mixers */ | |
7810 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7811 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7812 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7813 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7814 | /* set up input amps for analog loopback */ | |
7815 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
7816 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7817 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7818 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7819 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7820 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7821 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7822 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7823 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7824 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7825 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7826 | ||
7827 | /* FIXME: use matrix-type input source selection */ | |
7828 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
7829 | /* Input mixer1 */ | |
7830 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7831 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7832 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 7833 | /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */ |
9c7f852e TI |
7834 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
7835 | /* Input mixer2 */ | |
7836 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7837 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7838 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 7839 | /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */ |
e3cde64a | 7840 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
9c7f852e TI |
7841 | |
7842 | { } | |
7843 | }; | |
7844 | ||
7845 | /* capture mixer elements */ | |
7846 | static struct snd_kcontrol_new alc883_capture_mixer[] = { | |
7847 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
7848 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
7849 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
7850 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
7851 | { | |
7852 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7853 | /* The multiple "Capture Source" controls confuse alsamixer | |
7854 | * So call somewhat different.. | |
9c7f852e TI |
7855 | */ |
7856 | /* .name = "Capture Source", */ | |
7857 | .name = "Input Source", | |
7858 | .count = 2, | |
7859 | .info = alc882_mux_enum_info, | |
7860 | .get = alc882_mux_enum_get, | |
7861 | .put = alc882_mux_enum_put, | |
7862 | }, | |
7863 | { } /* end */ | |
7864 | }; | |
7865 | ||
cb53c626 TI |
7866 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
7867 | #define alc883_loopbacks alc880_loopbacks | |
7868 | #endif | |
7869 | ||
9c7f852e TI |
7870 | /* pcm configuration: identiacal with ALC880 */ |
7871 | #define alc883_pcm_analog_playback alc880_pcm_analog_playback | |
7872 | #define alc883_pcm_analog_capture alc880_pcm_analog_capture | |
6330079f | 7873 | #define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture |
9c7f852e TI |
7874 | #define alc883_pcm_digital_playback alc880_pcm_digital_playback |
7875 | #define alc883_pcm_digital_capture alc880_pcm_digital_capture | |
7876 | ||
7877 | /* | |
7878 | * configuration and preset | |
7879 | */ | |
f5fcc13c TI |
7880 | static const char *alc883_models[ALC883_MODEL_LAST] = { |
7881 | [ALC883_3ST_2ch_DIG] = "3stack-dig", | |
7882 | [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig", | |
7883 | [ALC883_3ST_6ch] = "3stack-6ch", | |
7884 | [ALC883_6ST_DIG] = "6stack-dig", | |
7885 | [ALC883_TARGA_DIG] = "targa-dig", | |
7886 | [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig", | |
f5fcc13c | 7887 | [ALC883_ACER] = "acer", |
2880a867 | 7888 | [ALC883_ACER_ASPIRE] = "acer-aspire", |
f5fcc13c | 7889 | [ALC883_MEDION] = "medion", |
272a527c | 7890 | [ALC883_MEDION_MD2] = "medion-md2", |
f5fcc13c | 7891 | [ALC883_LAPTOP_EAPD] = "laptop-eapd", |
bc9f98a9 | 7892 | [ALC883_LENOVO_101E_2ch] = "lenovo-101e", |
272a527c KY |
7893 | [ALC883_LENOVO_NB0763] = "lenovo-nb0763", |
7894 | [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig", | |
189609ae | 7895 | [ALC883_HAIER_W66] = "haier-w66", |
4723c022 | 7896 | [ALC888_3ST_HP] = "3stack-hp", |
5795b9e6 | 7897 | [ALC888_6ST_DELL] = "6stack-dell", |
a8848bd6 | 7898 | [ALC883_MITAC] = "mitac", |
0c4cc443 | 7899 | [ALC883_CLEVO_M720] = "clevo-m720", |
fb97dc67 | 7900 | [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515", |
17bba1b7 | 7901 | [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel", |
f5fcc13c TI |
7902 | [ALC883_AUTO] = "auto", |
7903 | }; | |
7904 | ||
7905 | static struct snd_pci_quirk alc883_cfg_tbl[] = { | |
7906 | SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG), | |
ac3e3741 TI |
7907 | SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE), |
7908 | SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE), | |
7909 | SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE), | |
fe7e873f | 7910 | SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE), |
ac3e3741 | 7911 | SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */ |
5795b9e6 | 7912 | SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL), |
febe3375 | 7913 | SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG), |
ac3e3741 TI |
7914 | SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP), |
7915 | SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP), | |
5d85f8d0 | 7916 | SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG), |
ac3e3741 | 7917 | SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG), |
97ec710c | 7918 | SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG), |
f5fcc13c | 7919 | SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG), |
ac3e3741 TI |
7920 | SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC), |
7921 | SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD), | |
7922 | SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch), | |
57b14f24 | 7923 | SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG), |
6f3bf657 | 7924 | SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG), |
bba8dee7 | 7925 | SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG), |
ac3e3741 | 7926 | SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG), |
4383fae0 | 7927 | SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG), |
dd146a60 | 7928 | SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG), |
82808236 | 7929 | SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG), |
f5fcc13c | 7930 | SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG), |
ac3e3741 | 7931 | SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG), |
f5fcc13c TI |
7932 | SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG), |
7933 | SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG), | |
ac3e3741 | 7934 | SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG), |
64ca1c29 | 7935 | SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG), |
f5fcc13c TI |
7936 | SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG), |
7937 | SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG), | |
7938 | SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG), | |
ac3e3741 TI |
7939 | SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG), |
7940 | SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG), | |
7941 | SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG), | |
86d34b7e | 7942 | SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG), |
ac3e3741 TI |
7943 | SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG), |
7944 | SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG), | |
f5fcc13c | 7945 | SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG), |
ac3e3741 | 7946 | SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG), |
0c4cc443 HRK |
7947 | SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720), |
7948 | SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720), | |
ac3e3741 | 7949 | SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD), |
e60623b4 | 7950 | SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch), |
f5fcc13c | 7951 | SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), |
fb97dc67 | 7952 | SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515), |
272a527c | 7953 | SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch), |
272a527c | 7954 | SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763), |
ac3e3741 TI |
7955 | SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763), |
7956 | SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763), | |
272a527c | 7957 | SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2), |
0b167bf4 | 7958 | SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG), |
189609ae | 7959 | SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66), |
17bba1b7 J |
7960 | SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL), |
7961 | SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL), | |
ac3e3741 | 7962 | SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), |
9c7f852e TI |
7963 | {} |
7964 | }; | |
7965 | ||
7966 | static struct alc_config_preset alc883_presets[] = { | |
7967 | [ALC883_3ST_2ch_DIG] = { | |
7968 | .mixers = { alc883_3ST_2ch_mixer }, | |
7969 | .init_verbs = { alc883_init_verbs }, | |
7970 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7971 | .dac_nids = alc883_dac_nids, | |
7972 | .dig_out_nid = ALC883_DIGOUT_NID, | |
9c7f852e TI |
7973 | .dig_in_nid = ALC883_DIGIN_NID, |
7974 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
7975 | .channel_mode = alc883_3ST_2ch_modes, | |
7976 | .input_mux = &alc883_capture_source, | |
7977 | }, | |
7978 | [ALC883_3ST_6ch_DIG] = { | |
7979 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
7980 | .init_verbs = { alc883_init_verbs }, | |
7981 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7982 | .dac_nids = alc883_dac_nids, | |
7983 | .dig_out_nid = ALC883_DIGOUT_NID, | |
9c7f852e TI |
7984 | .dig_in_nid = ALC883_DIGIN_NID, |
7985 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
7986 | .channel_mode = alc883_3ST_6ch_modes, | |
4e195a7b | 7987 | .need_dac_fix = 1, |
9c7f852e | 7988 | .input_mux = &alc883_capture_source, |
f12ab1e0 | 7989 | }, |
9c7f852e TI |
7990 | [ALC883_3ST_6ch] = { |
7991 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
7992 | .init_verbs = { alc883_init_verbs }, | |
7993 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7994 | .dac_nids = alc883_dac_nids, | |
9c7f852e TI |
7995 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), |
7996 | .channel_mode = alc883_3ST_6ch_modes, | |
4e195a7b | 7997 | .need_dac_fix = 1, |
9c7f852e | 7998 | .input_mux = &alc883_capture_source, |
f12ab1e0 | 7999 | }, |
17bba1b7 J |
8000 | [ALC883_3ST_6ch_INTEL] = { |
8001 | .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer }, | |
8002 | .init_verbs = { alc883_init_verbs }, | |
8003 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8004 | .dac_nids = alc883_dac_nids, | |
8005 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8006 | .dig_in_nid = ALC883_DIGIN_NID, | |
8007 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes), | |
8008 | .channel_mode = alc883_3ST_6ch_intel_modes, | |
8009 | .need_dac_fix = 1, | |
8010 | .input_mux = &alc883_3stack_6ch_intel, | |
8011 | }, | |
9c7f852e TI |
8012 | [ALC883_6ST_DIG] = { |
8013 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, | |
8014 | .init_verbs = { alc883_init_verbs }, | |
8015 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8016 | .dac_nids = alc883_dac_nids, | |
8017 | .dig_out_nid = ALC883_DIGOUT_NID, | |
9c7f852e TI |
8018 | .dig_in_nid = ALC883_DIGIN_NID, |
8019 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | |
8020 | .channel_mode = alc883_sixstack_modes, | |
8021 | .input_mux = &alc883_capture_source, | |
8022 | }, | |
ccc656ce KY |
8023 | [ALC883_TARGA_DIG] = { |
8024 | .mixers = { alc883_tagra_mixer, alc883_chmode_mixer }, | |
8025 | .init_verbs = { alc883_init_verbs, alc883_tagra_verbs}, | |
8026 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8027 | .dac_nids = alc883_dac_nids, | |
8028 | .dig_out_nid = ALC883_DIGOUT_NID, | |
ccc656ce KY |
8029 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), |
8030 | .channel_mode = alc883_3ST_6ch_modes, | |
8031 | .need_dac_fix = 1, | |
8032 | .input_mux = &alc883_capture_source, | |
8033 | .unsol_event = alc883_tagra_unsol_event, | |
8034 | .init_hook = alc883_tagra_automute, | |
8035 | }, | |
8036 | [ALC883_TARGA_2ch_DIG] = { | |
8037 | .mixers = { alc883_tagra_2ch_mixer}, | |
8038 | .init_verbs = { alc883_init_verbs, alc883_tagra_verbs}, | |
8039 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8040 | .dac_nids = alc883_dac_nids, | |
8041 | .dig_out_nid = ALC883_DIGOUT_NID, | |
ccc656ce KY |
8042 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8043 | .channel_mode = alc883_3ST_2ch_modes, | |
8044 | .input_mux = &alc883_capture_source, | |
8045 | .unsol_event = alc883_tagra_unsol_event, | |
8046 | .init_hook = alc883_tagra_automute, | |
8047 | }, | |
bab282b9 | 8048 | [ALC883_ACER] = { |
676a9b53 | 8049 | .mixers = { alc883_base_mixer }, |
bab282b9 VA |
8050 | /* On TravelMate laptops, GPIO 0 enables the internal speaker |
8051 | * and the headphone jack. Turn this on and rely on the | |
8052 | * standard mute methods whenever the user wants to turn | |
8053 | * these outputs off. | |
8054 | */ | |
8055 | .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs }, | |
8056 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8057 | .dac_nids = alc883_dac_nids, | |
bab282b9 VA |
8058 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8059 | .channel_mode = alc883_3ST_2ch_modes, | |
8060 | .input_mux = &alc883_capture_source, | |
8061 | }, | |
2880a867 | 8062 | [ALC883_ACER_ASPIRE] = { |
676a9b53 | 8063 | .mixers = { alc883_acer_aspire_mixer }, |
d1a991a6 | 8064 | .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs }, |
2880a867 TD |
8065 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
8066 | .dac_nids = alc883_dac_nids, | |
8067 | .dig_out_nid = ALC883_DIGOUT_NID, | |
2880a867 TD |
8068 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8069 | .channel_mode = alc883_3ST_2ch_modes, | |
8070 | .input_mux = &alc883_capture_source, | |
676a9b53 TI |
8071 | .unsol_event = alc883_acer_aspire_unsol_event, |
8072 | .init_hook = alc883_acer_aspire_automute, | |
d1a991a6 | 8073 | }, |
c07584c8 TD |
8074 | [ALC883_MEDION] = { |
8075 | .mixers = { alc883_fivestack_mixer, | |
8076 | alc883_chmode_mixer }, | |
8077 | .init_verbs = { alc883_init_verbs, | |
b373bdeb | 8078 | alc883_medion_eapd_verbs }, |
c07584c8 TD |
8079 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
8080 | .dac_nids = alc883_dac_nids, | |
c07584c8 TD |
8081 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), |
8082 | .channel_mode = alc883_sixstack_modes, | |
8083 | .input_mux = &alc883_capture_source, | |
b373bdeb | 8084 | }, |
272a527c KY |
8085 | [ALC883_MEDION_MD2] = { |
8086 | .mixers = { alc883_medion_md2_mixer}, | |
8087 | .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs}, | |
8088 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8089 | .dac_nids = alc883_dac_nids, | |
8090 | .dig_out_nid = ALC883_DIGOUT_NID, | |
272a527c KY |
8091 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8092 | .channel_mode = alc883_3ST_2ch_modes, | |
8093 | .input_mux = &alc883_capture_source, | |
8094 | .unsol_event = alc883_medion_md2_unsol_event, | |
8095 | .init_hook = alc883_medion_md2_automute, | |
8096 | }, | |
b373bdeb | 8097 | [ALC883_LAPTOP_EAPD] = { |
676a9b53 | 8098 | .mixers = { alc883_base_mixer }, |
b373bdeb AN |
8099 | .init_verbs = { alc883_init_verbs, alc882_eapd_verbs }, |
8100 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8101 | .dac_nids = alc883_dac_nids, | |
b373bdeb AN |
8102 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8103 | .channel_mode = alc883_3ST_2ch_modes, | |
8104 | .input_mux = &alc883_capture_source, | |
8105 | }, | |
0c4cc443 HRK |
8106 | [ALC883_CLEVO_M720] = { |
8107 | .mixers = { alc883_clevo_m720_mixer }, | |
8108 | .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs }, | |
368c7a95 J |
8109 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
8110 | .dac_nids = alc883_dac_nids, | |
8111 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8112 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
8113 | .channel_mode = alc883_3ST_2ch_modes, | |
8114 | .input_mux = &alc883_capture_source, | |
0c4cc443 HRK |
8115 | .unsol_event = alc883_clevo_m720_unsol_event, |
8116 | .init_hook = alc883_clevo_m720_automute, | |
368c7a95 | 8117 | }, |
bc9f98a9 KY |
8118 | [ALC883_LENOVO_101E_2ch] = { |
8119 | .mixers = { alc883_lenovo_101e_2ch_mixer}, | |
8120 | .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs}, | |
8121 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8122 | .dac_nids = alc883_dac_nids, | |
bc9f98a9 KY |
8123 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8124 | .channel_mode = alc883_3ST_2ch_modes, | |
8125 | .input_mux = &alc883_lenovo_101e_capture_source, | |
8126 | .unsol_event = alc883_lenovo_101e_unsol_event, | |
8127 | .init_hook = alc883_lenovo_101e_all_automute, | |
8128 | }, | |
272a527c KY |
8129 | [ALC883_LENOVO_NB0763] = { |
8130 | .mixers = { alc883_lenovo_nb0763_mixer }, | |
8131 | .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs}, | |
8132 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8133 | .dac_nids = alc883_dac_nids, | |
272a527c KY |
8134 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8135 | .channel_mode = alc883_3ST_2ch_modes, | |
8136 | .need_dac_fix = 1, | |
8137 | .input_mux = &alc883_lenovo_nb0763_capture_source, | |
8138 | .unsol_event = alc883_medion_md2_unsol_event, | |
8139 | .init_hook = alc883_medion_md2_automute, | |
8140 | }, | |
8141 | [ALC888_LENOVO_MS7195_DIG] = { | |
8142 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
8143 | .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs}, | |
8144 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8145 | .dac_nids = alc883_dac_nids, | |
8146 | .dig_out_nid = ALC883_DIGOUT_NID, | |
272a527c KY |
8147 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), |
8148 | .channel_mode = alc883_3ST_6ch_modes, | |
8149 | .need_dac_fix = 1, | |
8150 | .input_mux = &alc883_capture_source, | |
8151 | .unsol_event = alc883_lenovo_ms7195_unsol_event, | |
8152 | .init_hook = alc888_lenovo_ms7195_front_automute, | |
189609ae KY |
8153 | }, |
8154 | [ALC883_HAIER_W66] = { | |
8155 | .mixers = { alc883_tagra_2ch_mixer}, | |
8156 | .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs}, | |
8157 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8158 | .dac_nids = alc883_dac_nids, | |
8159 | .dig_out_nid = ALC883_DIGOUT_NID, | |
189609ae KY |
8160 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8161 | .channel_mode = alc883_3ST_2ch_modes, | |
8162 | .input_mux = &alc883_capture_source, | |
8163 | .unsol_event = alc883_haier_w66_unsol_event, | |
8164 | .init_hook = alc883_haier_w66_automute, | |
eea6419e | 8165 | }, |
4723c022 | 8166 | [ALC888_3ST_HP] = { |
eea6419e | 8167 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, |
4723c022 | 8168 | .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs }, |
8341de60 CM |
8169 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
8170 | .dac_nids = alc883_dac_nids, | |
4723c022 CM |
8171 | .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes), |
8172 | .channel_mode = alc888_3st_hp_modes, | |
8341de60 CM |
8173 | .need_dac_fix = 1, |
8174 | .input_mux = &alc883_capture_source, | |
8175 | }, | |
5795b9e6 | 8176 | [ALC888_6ST_DELL] = { |
f24dbdc6 | 8177 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, |
5795b9e6 CM |
8178 | .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs }, |
8179 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8180 | .dac_nids = alc883_dac_nids, | |
8181 | .dig_out_nid = ALC883_DIGOUT_NID, | |
5795b9e6 CM |
8182 | .dig_in_nid = ALC883_DIGIN_NID, |
8183 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | |
8184 | .channel_mode = alc883_sixstack_modes, | |
8185 | .input_mux = &alc883_capture_source, | |
8186 | .unsol_event = alc888_6st_dell_unsol_event, | |
8187 | .init_hook = alc888_6st_dell_front_automute, | |
8188 | }, | |
a8848bd6 AS |
8189 | [ALC883_MITAC] = { |
8190 | .mixers = { alc883_mitac_mixer }, | |
8191 | .init_verbs = { alc883_init_verbs, alc883_mitac_verbs }, | |
8192 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8193 | .dac_nids = alc883_dac_nids, | |
a8848bd6 AS |
8194 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8195 | .channel_mode = alc883_3ST_2ch_modes, | |
8196 | .input_mux = &alc883_capture_source, | |
8197 | .unsol_event = alc883_mitac_unsol_event, | |
8198 | .init_hook = alc883_mitac_automute, | |
8199 | }, | |
fb97dc67 J |
8200 | [ALC883_FUJITSU_PI2515] = { |
8201 | .mixers = { alc883_2ch_fujitsu_pi2515_mixer }, | |
8202 | .init_verbs = { alc883_init_verbs, | |
8203 | alc883_2ch_fujitsu_pi2515_verbs}, | |
8204 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8205 | .dac_nids = alc883_dac_nids, | |
8206 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8207 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
8208 | .channel_mode = alc883_3ST_2ch_modes, | |
8209 | .input_mux = &alc883_fujitsu_pi2515_capture_source, | |
8210 | .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event, | |
8211 | .init_hook = alc883_2ch_fujitsu_pi2515_automute, | |
8212 | }, | |
9c7f852e TI |
8213 | }; |
8214 | ||
8215 | ||
8216 | /* | |
8217 | * BIOS auto configuration | |
8218 | */ | |
8219 | static void alc883_auto_set_output_and_unmute(struct hda_codec *codec, | |
8220 | hda_nid_t nid, int pin_type, | |
8221 | int dac_idx) | |
8222 | { | |
8223 | /* set as output */ | |
8224 | struct alc_spec *spec = codec->spec; | |
f12ab1e0 TI |
8225 | int idx; |
8226 | ||
f6c7e546 | 8227 | alc_set_pin_output(codec, nid, pin_type); |
9c7f852e TI |
8228 | if (spec->multiout.dac_nids[dac_idx] == 0x25) |
8229 | idx = 4; | |
8230 | else | |
8231 | idx = spec->multiout.dac_nids[dac_idx] - 2; | |
9c7f852e TI |
8232 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); |
8233 | ||
8234 | } | |
8235 | ||
8236 | static void alc883_auto_init_multi_out(struct hda_codec *codec) | |
8237 | { | |
8238 | struct alc_spec *spec = codec->spec; | |
8239 | int i; | |
8240 | ||
bc9f98a9 | 8241 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
9c7f852e | 8242 | for (i = 0; i <= HDA_SIDE; i++) { |
f12ab1e0 | 8243 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
baba8ee9 | 8244 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
9c7f852e | 8245 | if (nid) |
baba8ee9 | 8246 | alc883_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 8247 | i); |
9c7f852e TI |
8248 | } |
8249 | } | |
8250 | ||
8251 | static void alc883_auto_init_hp_out(struct hda_codec *codec) | |
8252 | { | |
8253 | struct alc_spec *spec = codec->spec; | |
8254 | hda_nid_t pin; | |
8255 | ||
eb06ed8f | 8256 | pin = spec->autocfg.hp_pins[0]; |
9c7f852e TI |
8257 | if (pin) /* connect to front */ |
8258 | /* use dac 0 */ | |
8259 | alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
f6c7e546 TI |
8260 | pin = spec->autocfg.speaker_pins[0]; |
8261 | if (pin) | |
8262 | alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
9c7f852e TI |
8263 | } |
8264 | ||
8265 | #define alc883_is_input_pin(nid) alc880_is_input_pin(nid) | |
8266 | #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID | |
8267 | ||
8268 | static void alc883_auto_init_analog_input(struct hda_codec *codec) | |
8269 | { | |
8270 | struct alc_spec *spec = codec->spec; | |
8271 | int i; | |
8272 | ||
8273 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
8274 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
8275 | if (alc883_is_input_pin(nid)) { | |
8276 | snd_hda_codec_write(codec, nid, 0, | |
8277 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8278 | (i <= AUTO_PIN_FRONT_MIC ? | |
8279 | PIN_VREF80 : PIN_IN)); | |
8280 | if (nid != ALC883_PIN_CD_NID) | |
8281 | snd_hda_codec_write(codec, nid, 0, | |
8282 | AC_VERB_SET_AMP_GAIN_MUTE, | |
8283 | AMP_OUT_MUTE); | |
8284 | } | |
8285 | } | |
8286 | } | |
8287 | ||
8288 | /* almost identical with ALC880 parser... */ | |
8289 | static int alc883_parse_auto_config(struct hda_codec *codec) | |
8290 | { | |
8291 | struct alc_spec *spec = codec->spec; | |
8292 | int err = alc880_parse_auto_config(codec); | |
8293 | ||
8294 | if (err < 0) | |
8295 | return err; | |
776e184e TI |
8296 | else if (!err) |
8297 | return 0; /* no config found */ | |
8298 | ||
8299 | err = alc_auto_add_mic_boost(codec); | |
8300 | if (err < 0) | |
8301 | return err; | |
8302 | ||
8303 | /* hack - override the init verbs */ | |
8304 | spec->init_verbs[0] = alc883_auto_init_verbs; | |
bc9f98a9 KY |
8305 | spec->mixers[spec->num_mixers] = alc883_capture_mixer; |
8306 | spec->num_mixers++; | |
776e184e TI |
8307 | |
8308 | return 1; /* config found */ | |
9c7f852e TI |
8309 | } |
8310 | ||
8311 | /* additional initialization for auto-configuration model */ | |
8312 | static void alc883_auto_init(struct hda_codec *codec) | |
8313 | { | |
f6c7e546 | 8314 | struct alc_spec *spec = codec->spec; |
9c7f852e TI |
8315 | alc883_auto_init_multi_out(codec); |
8316 | alc883_auto_init_hp_out(codec); | |
8317 | alc883_auto_init_analog_input(codec); | |
f6c7e546 TI |
8318 | if (spec->unsol_event) |
8319 | alc_sku_automute(codec); | |
9c7f852e TI |
8320 | } |
8321 | ||
8322 | static int patch_alc883(struct hda_codec *codec) | |
8323 | { | |
8324 | struct alc_spec *spec; | |
8325 | int err, board_config; | |
8326 | ||
8327 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
8328 | if (spec == NULL) | |
8329 | return -ENOMEM; | |
8330 | ||
8331 | codec->spec = spec; | |
8332 | ||
2c3bf9ab TI |
8333 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
8334 | ||
f5fcc13c TI |
8335 | board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST, |
8336 | alc883_models, | |
8337 | alc883_cfg_tbl); | |
8338 | if (board_config < 0) { | |
9c7f852e TI |
8339 | printk(KERN_INFO "hda_codec: Unknown model for ALC883, " |
8340 | "trying auto-probe from BIOS...\n"); | |
8341 | board_config = ALC883_AUTO; | |
8342 | } | |
8343 | ||
8344 | if (board_config == ALC883_AUTO) { | |
8345 | /* automatic parse from the BIOS config */ | |
8346 | err = alc883_parse_auto_config(codec); | |
8347 | if (err < 0) { | |
8348 | alc_free(codec); | |
8349 | return err; | |
f12ab1e0 | 8350 | } else if (!err) { |
9c7f852e TI |
8351 | printk(KERN_INFO |
8352 | "hda_codec: Cannot set up configuration " | |
8353 | "from BIOS. Using base mode...\n"); | |
8354 | board_config = ALC883_3ST_2ch_DIG; | |
8355 | } | |
8356 | } | |
8357 | ||
8358 | if (board_config != ALC883_AUTO) | |
8359 | setup_preset(spec, &alc883_presets[board_config]); | |
8360 | ||
2f893286 KY |
8361 | switch (codec->vendor_id) { |
8362 | case 0x10ec0888: | |
8363 | spec->stream_name_analog = "ALC888 Analog"; | |
8364 | spec->stream_name_digital = "ALC888 Digital"; | |
8365 | break; | |
8366 | case 0x10ec0889: | |
8367 | spec->stream_name_analog = "ALC889 Analog"; | |
8368 | spec->stream_name_digital = "ALC889 Digital"; | |
8369 | break; | |
8370 | default: | |
8371 | spec->stream_name_analog = "ALC883 Analog"; | |
8372 | spec->stream_name_digital = "ALC883 Digital"; | |
8373 | break; | |
8374 | } | |
8375 | ||
9c7f852e TI |
8376 | spec->stream_analog_playback = &alc883_pcm_analog_playback; |
8377 | spec->stream_analog_capture = &alc883_pcm_analog_capture; | |
6330079f | 8378 | spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture; |
9c7f852e | 8379 | |
9c7f852e TI |
8380 | spec->stream_digital_playback = &alc883_pcm_digital_playback; |
8381 | spec->stream_digital_capture = &alc883_pcm_digital_capture; | |
8382 | ||
e1406348 TI |
8383 | spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); |
8384 | spec->adc_nids = alc883_adc_nids; | |
8385 | spec->capsrc_nids = alc883_capsrc_nids; | |
9c7f852e | 8386 | |
2134ea4f TI |
8387 | spec->vmaster_nid = 0x0c; |
8388 | ||
9c7f852e TI |
8389 | codec->patch_ops = alc_patch_ops; |
8390 | if (board_config == ALC883_AUTO) | |
8391 | spec->init_hook = alc883_auto_init; | |
f9423e7a KY |
8392 | else if (codec->vendor_id == 0x10ec0888) |
8393 | spec->init_hook = alc888_coef_init; | |
8394 | ||
cb53c626 TI |
8395 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
8396 | if (!spec->loopback.amplist) | |
8397 | spec->loopback.amplist = alc883_loopbacks; | |
8398 | #endif | |
9c7f852e TI |
8399 | |
8400 | return 0; | |
8401 | } | |
8402 | ||
8403 | /* | |
8404 | * ALC262 support | |
8405 | */ | |
8406 | ||
8407 | #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID | |
8408 | #define ALC262_DIGIN_NID ALC880_DIGIN_NID | |
8409 | ||
8410 | #define alc262_dac_nids alc260_dac_nids | |
8411 | #define alc262_adc_nids alc882_adc_nids | |
8412 | #define alc262_adc_nids_alt alc882_adc_nids_alt | |
88c71a99 TI |
8413 | #define alc262_capsrc_nids alc882_capsrc_nids |
8414 | #define alc262_capsrc_nids_alt alc882_capsrc_nids_alt | |
9c7f852e TI |
8415 | |
8416 | #define alc262_modes alc260_modes | |
8417 | #define alc262_capture_source alc882_capture_source | |
8418 | ||
8419 | static struct snd_kcontrol_new alc262_base_mixer[] = { | |
8420 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
8421 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
8422 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
8423 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
8424 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
8425 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
8426 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
8427 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 8428 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
8429 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
8430 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 8431 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e | 8432 | /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), |
31bffaa9 | 8433 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */ |
9c7f852e TI |
8434 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT), |
8435 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
8436 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
8437 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | |
8438 | { } /* end */ | |
8439 | }; | |
8440 | ||
ccc656ce KY |
8441 | static struct snd_kcontrol_new alc262_hippo1_mixer[] = { |
8442 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
8443 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
8444 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
8445 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
8446 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
8447 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
8448 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
8449 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 8450 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce KY |
8451 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
8452 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 8453 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
ccc656ce | 8454 | /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), |
31bffaa9 | 8455 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */ |
ccc656ce KY |
8456 | /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/ |
8457 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
8458 | { } /* end */ | |
8459 | }; | |
8460 | ||
ce875f07 TI |
8461 | /* update HP, line and mono-out pins according to the master switch */ |
8462 | static void alc262_hp_master_update(struct hda_codec *codec) | |
8463 | { | |
8464 | struct alc_spec *spec = codec->spec; | |
8465 | int val = spec->master_sw; | |
8466 | ||
8467 | /* HP & line-out */ | |
8468 | snd_hda_codec_write_cache(codec, 0x1b, 0, | |
8469 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8470 | val ? PIN_HP : 0); | |
8471 | snd_hda_codec_write_cache(codec, 0x15, 0, | |
8472 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8473 | val ? PIN_HP : 0); | |
8474 | /* mono (speaker) depending on the HP jack sense */ | |
8475 | val = val && !spec->jack_present; | |
8476 | snd_hda_codec_write_cache(codec, 0x16, 0, | |
8477 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8478 | val ? PIN_OUT : 0); | |
8479 | } | |
8480 | ||
8481 | static void alc262_hp_bpc_automute(struct hda_codec *codec) | |
8482 | { | |
8483 | struct alc_spec *spec = codec->spec; | |
8484 | unsigned int presence; | |
8485 | presence = snd_hda_codec_read(codec, 0x1b, 0, | |
8486 | AC_VERB_GET_PIN_SENSE, 0); | |
8487 | spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE); | |
8488 | alc262_hp_master_update(codec); | |
8489 | } | |
8490 | ||
8491 | static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res) | |
8492 | { | |
8493 | if ((res >> 26) != ALC880_HP_EVENT) | |
8494 | return; | |
8495 | alc262_hp_bpc_automute(codec); | |
8496 | } | |
8497 | ||
8498 | static void alc262_hp_wildwest_automute(struct hda_codec *codec) | |
8499 | { | |
8500 | struct alc_spec *spec = codec->spec; | |
8501 | unsigned int presence; | |
8502 | presence = snd_hda_codec_read(codec, 0x15, 0, | |
8503 | AC_VERB_GET_PIN_SENSE, 0); | |
8504 | spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE); | |
8505 | alc262_hp_master_update(codec); | |
8506 | } | |
8507 | ||
8508 | static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec, | |
8509 | unsigned int res) | |
8510 | { | |
8511 | if ((res >> 26) != ALC880_HP_EVENT) | |
8512 | return; | |
8513 | alc262_hp_wildwest_automute(codec); | |
8514 | } | |
8515 | ||
8516 | static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol, | |
8517 | struct snd_ctl_elem_value *ucontrol) | |
8518 | { | |
8519 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
8520 | struct alc_spec *spec = codec->spec; | |
8521 | *ucontrol->value.integer.value = spec->master_sw; | |
8522 | return 0; | |
8523 | } | |
8524 | ||
8525 | static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |
8526 | struct snd_ctl_elem_value *ucontrol) | |
8527 | { | |
8528 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
8529 | struct alc_spec *spec = codec->spec; | |
8530 | int val = !!*ucontrol->value.integer.value; | |
8531 | ||
8532 | if (val == spec->master_sw) | |
8533 | return 0; | |
8534 | spec->master_sw = val; | |
8535 | alc262_hp_master_update(codec); | |
8536 | return 1; | |
8537 | } | |
8538 | ||
9c7f852e | 8539 | static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = { |
ce875f07 TI |
8540 | { |
8541 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
8542 | .name = "Master Playback Switch", | |
8543 | .info = snd_ctl_boolean_mono_info, | |
8544 | .get = alc262_hp_master_sw_get, | |
8545 | .put = alc262_hp_master_sw_put, | |
8546 | }, | |
9c7f852e TI |
8547 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
8548 | HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
8549 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
ce875f07 TI |
8550 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0, |
8551 | HDA_OUTPUT), | |
8552 | HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0, | |
8553 | HDA_OUTPUT), | |
9c7f852e TI |
8554 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
8555 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 8556 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
8557 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
8558 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 8559 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
8560 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
8561 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
8562 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
8563 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
8564 | HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
8565 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
8566 | HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT), | |
8567 | HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT), | |
8568 | { } /* end */ | |
8569 | }; | |
8570 | ||
cd7509a4 | 8571 | static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = { |
ce875f07 TI |
8572 | { |
8573 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
8574 | .name = "Master Playback Switch", | |
8575 | .info = snd_ctl_boolean_mono_info, | |
8576 | .get = alc262_hp_master_sw_get, | |
8577 | .put = alc262_hp_master_sw_put, | |
8578 | }, | |
cd7509a4 KY |
8579 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
8580 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
8581 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
8582 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
ce875f07 TI |
8583 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0, |
8584 | HDA_OUTPUT), | |
8585 | HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0, | |
8586 | HDA_OUTPUT), | |
cd7509a4 KY |
8587 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT), |
8588 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
cc69d12d | 8589 | HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT), |
cd7509a4 KY |
8590 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), |
8591 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
8592 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
8593 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
8594 | HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
8595 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
8596 | { } /* end */ | |
8597 | }; | |
8598 | ||
8599 | static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = { | |
8600 | HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
8601 | HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 8602 | HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT), |
cd7509a4 KY |
8603 | { } /* end */ |
8604 | }; | |
8605 | ||
66d2a9d6 KY |
8606 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
8607 | static void alc262_hp_t5735_automute(struct hda_codec *codec, int force) | |
8608 | { | |
8609 | struct alc_spec *spec = codec->spec; | |
66d2a9d6 KY |
8610 | |
8611 | if (force || !spec->sense_updated) { | |
8612 | unsigned int present; | |
8613 | present = snd_hda_codec_read(codec, 0x15, 0, | |
8614 | AC_VERB_GET_PIN_SENSE, 0); | |
4bb26130 | 8615 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; |
66d2a9d6 KY |
8616 | spec->sense_updated = 1; |
8617 | } | |
4bb26130 TI |
8618 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE, |
8619 | spec->jack_present ? HDA_AMP_MUTE : 0); | |
66d2a9d6 KY |
8620 | } |
8621 | ||
8622 | static void alc262_hp_t5735_unsol_event(struct hda_codec *codec, | |
8623 | unsigned int res) | |
8624 | { | |
8625 | if ((res >> 26) != ALC880_HP_EVENT) | |
8626 | return; | |
8627 | alc262_hp_t5735_automute(codec, 1); | |
8628 | } | |
8629 | ||
8630 | static void alc262_hp_t5735_init_hook(struct hda_codec *codec) | |
8631 | { | |
8632 | alc262_hp_t5735_automute(codec, 1); | |
8633 | } | |
8634 | ||
8635 | static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = { | |
86cd9298 TI |
8636 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
8637 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
66d2a9d6 KY |
8638 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
8639 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
8640 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
8641 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
8642 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
8643 | { } /* end */ | |
8644 | }; | |
8645 | ||
8646 | static struct hda_verb alc262_hp_t5735_verbs[] = { | |
8647 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
8648 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
8649 | ||
8650 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
8651 | { } | |
8652 | }; | |
8653 | ||
8c427226 | 8654 | static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = { |
f2f48e18 TI |
8655 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
8656 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
86cd9298 TI |
8657 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT), |
8658 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT), | |
8c427226 KY |
8659 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), |
8660 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
8661 | { } /* end */ | |
8662 | }; | |
8663 | ||
8664 | static struct hda_verb alc262_hp_rp5700_verbs[] = { | |
8665 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8666 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8667 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
8668 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
8669 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
8670 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8671 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
8672 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
8673 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))}, | |
8674 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))}, | |
8675 | {} | |
8676 | }; | |
8677 | ||
8678 | static struct hda_input_mux alc262_hp_rp5700_capture_source = { | |
8679 | .num_items = 1, | |
8680 | .items = { | |
8681 | { "Line", 0x1 }, | |
8682 | }, | |
8683 | }; | |
8684 | ||
0724ea2a TI |
8685 | /* bind hp and internal speaker mute (with plug check) */ |
8686 | static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol, | |
8687 | struct snd_ctl_elem_value *ucontrol) | |
8688 | { | |
8689 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
8690 | long *valp = ucontrol->value.integer.value; | |
8691 | int change; | |
8692 | ||
8693 | /* change hp mute */ | |
8694 | change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, | |
8695 | HDA_AMP_MUTE, | |
8696 | valp[0] ? 0 : HDA_AMP_MUTE); | |
8697 | change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, | |
8698 | HDA_AMP_MUTE, | |
8699 | valp[1] ? 0 : HDA_AMP_MUTE); | |
8700 | if (change) { | |
8701 | /* change speaker according to HP jack state */ | |
8702 | struct alc_spec *spec = codec->spec; | |
8703 | unsigned int mute; | |
8704 | if (spec->jack_present) | |
8705 | mute = HDA_AMP_MUTE; | |
8706 | else | |
8707 | mute = snd_hda_codec_amp_read(codec, 0x15, 0, | |
8708 | HDA_OUTPUT, 0); | |
8709 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
8710 | HDA_AMP_MUTE, mute); | |
8711 | } | |
8712 | return change; | |
8713 | } | |
5b31954e | 8714 | |
272a527c | 8715 | static struct snd_kcontrol_new alc262_sony_mixer[] = { |
0724ea2a TI |
8716 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
8717 | { | |
8718 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
8719 | .name = "Master Playback Switch", | |
8720 | .info = snd_hda_mixer_amp_switch_info, | |
8721 | .get = snd_hda_mixer_amp_switch_get, | |
8722 | .put = alc262_sony_master_sw_put, | |
8723 | .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | |
8724 | }, | |
272a527c KY |
8725 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
8726 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
8727 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
8728 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
8729 | { } /* end */ | |
8730 | }; | |
8731 | ||
83c34218 KY |
8732 | static struct snd_kcontrol_new alc262_benq_t31_mixer[] = { |
8733 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
8734 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
8735 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
8736 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
8737 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
8738 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
8739 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
8740 | { } /* end */ | |
8741 | }; | |
272a527c | 8742 | |
9c7f852e TI |
8743 | #define alc262_capture_mixer alc882_capture_mixer |
8744 | #define alc262_capture_alt_mixer alc882_capture_alt_mixer | |
8745 | ||
8746 | /* | |
8747 | * generic initialization of ADC, input mixers and output mixers | |
8748 | */ | |
8749 | static struct hda_verb alc262_init_verbs[] = { | |
8750 | /* | |
8751 | * Unmute ADC0-2 and set the default input to mic-in | |
8752 | */ | |
8753 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8754 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8755 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8756 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8757 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8758 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8759 | ||
cb53c626 | 8760 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
9c7f852e | 8761 | * mixer widget |
f12ab1e0 TI |
8762 | * Note: PASD motherboards uses the Line In 2 as the input for |
8763 | * front panel mic (mic 2) | |
9c7f852e TI |
8764 | */ |
8765 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
8766 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
8767 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
8768 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
8769 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
8770 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9c7f852e TI |
8771 | |
8772 | /* | |
df694daa KY |
8773 | * Set up output mixers (0x0c - 0x0e) |
8774 | */ | |
8775 | /* set vol=0 to output mixers */ | |
8776 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8777 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8778 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8779 | /* set up input amps for analog loopback */ | |
8780 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
8781 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8782 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8783 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8784 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8785 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8786 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8787 | ||
8788 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
8789 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
8790 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
8791 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
8792 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
8793 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
8794 | ||
8795 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
8796 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
8797 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
8798 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
8799 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
8800 | ||
8801 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8802 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
8803 | ||
8804 | /* FIXME: use matrix-type input source selection */ | |
8805 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
8806 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
8807 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
8808 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
8809 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
8810 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
8811 | /* Input mixer2 */ | |
8812 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
8813 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
8814 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
8815 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
8816 | /* Input mixer3 */ | |
8817 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
8818 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
8819 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
f12ab1e0 | 8820 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
df694daa KY |
8821 | |
8822 | { } | |
8823 | }; | |
1da177e4 | 8824 | |
ccc656ce KY |
8825 | static struct hda_verb alc262_hippo_unsol_verbs[] = { |
8826 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
8827 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
8828 | {} | |
8829 | }; | |
8830 | ||
8831 | static struct hda_verb alc262_hippo1_unsol_verbs[] = { | |
8832 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
8833 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8834 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
8835 | ||
8836 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
8837 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
8838 | {} | |
8839 | }; | |
8840 | ||
272a527c KY |
8841 | static struct hda_verb alc262_sony_unsol_verbs[] = { |
8842 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
8843 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8844 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic | |
8845 | ||
8846 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
8847 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7b1e8795 | 8848 | {} |
272a527c KY |
8849 | }; |
8850 | ||
ccc656ce | 8851 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
5b31954e | 8852 | static void alc262_hippo_automute(struct hda_codec *codec) |
ccc656ce KY |
8853 | { |
8854 | struct alc_spec *spec = codec->spec; | |
8855 | unsigned int mute; | |
5b31954e | 8856 | unsigned int present; |
ccc656ce | 8857 | |
5b31954e TI |
8858 | /* need to execute and sync at first */ |
8859 | snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); | |
8860 | present = snd_hda_codec_read(codec, 0x15, 0, | |
8861 | AC_VERB_GET_PIN_SENSE, 0); | |
8862 | spec->jack_present = (present & 0x80000000) != 0; | |
ccc656ce KY |
8863 | if (spec->jack_present) { |
8864 | /* mute internal speaker */ | |
47fd830a TI |
8865 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
8866 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
ccc656ce KY |
8867 | } else { |
8868 | /* unmute internal speaker if necessary */ | |
8869 | mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0); | |
47fd830a TI |
8870 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
8871 | HDA_AMP_MUTE, mute); | |
ccc656ce KY |
8872 | } |
8873 | } | |
8874 | ||
8875 | /* unsolicited event for HP jack sensing */ | |
8876 | static void alc262_hippo_unsol_event(struct hda_codec *codec, | |
8877 | unsigned int res) | |
8878 | { | |
8879 | if ((res >> 26) != ALC880_HP_EVENT) | |
8880 | return; | |
5b31954e | 8881 | alc262_hippo_automute(codec); |
ccc656ce KY |
8882 | } |
8883 | ||
5b31954e | 8884 | static void alc262_hippo1_automute(struct hda_codec *codec) |
ccc656ce | 8885 | { |
ccc656ce | 8886 | unsigned int mute; |
5b31954e | 8887 | unsigned int present; |
ccc656ce | 8888 | |
5b31954e TI |
8889 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); |
8890 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
8891 | AC_VERB_GET_PIN_SENSE, 0); | |
8892 | present = (present & 0x80000000) != 0; | |
8893 | if (present) { | |
ccc656ce | 8894 | /* mute internal speaker */ |
47fd830a TI |
8895 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
8896 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
ccc656ce KY |
8897 | } else { |
8898 | /* unmute internal speaker if necessary */ | |
8899 | mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); | |
47fd830a TI |
8900 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
8901 | HDA_AMP_MUTE, mute); | |
ccc656ce KY |
8902 | } |
8903 | } | |
8904 | ||
8905 | /* unsolicited event for HP jack sensing */ | |
8906 | static void alc262_hippo1_unsol_event(struct hda_codec *codec, | |
8907 | unsigned int res) | |
8908 | { | |
8909 | if ((res >> 26) != ALC880_HP_EVENT) | |
8910 | return; | |
5b31954e | 8911 | alc262_hippo1_automute(codec); |
ccc656ce KY |
8912 | } |
8913 | ||
834be88d TI |
8914 | /* |
8915 | * fujitsu model | |
5d9fab2d TV |
8916 | * 0x14 = headphone/spdif-out, 0x15 = internal speaker, |
8917 | * 0x1b = port replicator headphone out | |
834be88d TI |
8918 | */ |
8919 | ||
8920 | #define ALC_HP_EVENT 0x37 | |
8921 | ||
8922 | static struct hda_verb alc262_fujitsu_unsol_verbs[] = { | |
8923 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, | |
8924 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5d9fab2d TV |
8925 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, |
8926 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
834be88d TI |
8927 | {} |
8928 | }; | |
8929 | ||
0e31daf7 J |
8930 | static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = { |
8931 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, | |
8932 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
8933 | {} | |
8934 | }; | |
8935 | ||
834be88d | 8936 | static struct hda_input_mux alc262_fujitsu_capture_source = { |
39d3ed38 | 8937 | .num_items = 3, |
834be88d TI |
8938 | .items = { |
8939 | { "Mic", 0x0 }, | |
39d3ed38 | 8940 | { "Int Mic", 0x1 }, |
834be88d TI |
8941 | { "CD", 0x4 }, |
8942 | }, | |
8943 | }; | |
8944 | ||
9c7f852e TI |
8945 | static struct hda_input_mux alc262_HP_capture_source = { |
8946 | .num_items = 5, | |
8947 | .items = { | |
8948 | { "Mic", 0x0 }, | |
accbe498 | 8949 | { "Front Mic", 0x1 }, |
9c7f852e TI |
8950 | { "Line", 0x2 }, |
8951 | { "CD", 0x4 }, | |
8952 | { "AUX IN", 0x6 }, | |
8953 | }, | |
8954 | }; | |
8955 | ||
accbe498 | 8956 | static struct hda_input_mux alc262_HP_D7000_capture_source = { |
8957 | .num_items = 4, | |
8958 | .items = { | |
8959 | { "Mic", 0x0 }, | |
8960 | { "Front Mic", 0x2 }, | |
8961 | { "Line", 0x1 }, | |
8962 | { "CD", 0x4 }, | |
8963 | }, | |
8964 | }; | |
8965 | ||
ebc7a406 | 8966 | /* mute/unmute internal speaker according to the hp jacks and mute state */ |
834be88d TI |
8967 | static void alc262_fujitsu_automute(struct hda_codec *codec, int force) |
8968 | { | |
8969 | struct alc_spec *spec = codec->spec; | |
8970 | unsigned int mute; | |
8971 | ||
f12ab1e0 | 8972 | if (force || !spec->sense_updated) { |
ebc7a406 | 8973 | unsigned int present; |
834be88d TI |
8974 | /* need to execute and sync at first */ |
8975 | snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); | |
ebc7a406 TI |
8976 | /* check laptop HP jack */ |
8977 | present = snd_hda_codec_read(codec, 0x14, 0, | |
8978 | AC_VERB_GET_PIN_SENSE, 0); | |
8979 | /* need to execute and sync at first */ | |
8980 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); | |
8981 | /* check docking HP jack */ | |
8982 | present |= snd_hda_codec_read(codec, 0x1b, 0, | |
8983 | AC_VERB_GET_PIN_SENSE, 0); | |
8984 | if (present & AC_PINSENSE_PRESENCE) | |
8985 | spec->jack_present = 1; | |
8986 | else | |
8987 | spec->jack_present = 0; | |
834be88d TI |
8988 | spec->sense_updated = 1; |
8989 | } | |
ebc7a406 TI |
8990 | /* unmute internal speaker only if both HPs are unplugged and |
8991 | * master switch is on | |
8992 | */ | |
8993 | if (spec->jack_present) | |
8994 | mute = HDA_AMP_MUTE; | |
8995 | else | |
834be88d | 8996 | mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); |
ebc7a406 TI |
8997 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
8998 | HDA_AMP_MUTE, mute); | |
834be88d TI |
8999 | } |
9000 | ||
9001 | /* unsolicited event for HP jack sensing */ | |
9002 | static void alc262_fujitsu_unsol_event(struct hda_codec *codec, | |
9003 | unsigned int res) | |
9004 | { | |
9005 | if ((res >> 26) != ALC_HP_EVENT) | |
9006 | return; | |
9007 | alc262_fujitsu_automute(codec, 1); | |
9008 | } | |
9009 | ||
ebc7a406 TI |
9010 | static void alc262_fujitsu_init_hook(struct hda_codec *codec) |
9011 | { | |
9012 | alc262_fujitsu_automute(codec, 1); | |
9013 | } | |
9014 | ||
834be88d | 9015 | /* bind volumes of both NID 0x0c and 0x0d */ |
cca3b371 TI |
9016 | static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = { |
9017 | .ops = &snd_hda_bind_vol, | |
9018 | .values = { | |
9019 | HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT), | |
9020 | HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT), | |
9021 | 0 | |
9022 | }, | |
9023 | }; | |
834be88d | 9024 | |
0e31daf7 J |
9025 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
9026 | static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force) | |
9027 | { | |
9028 | struct alc_spec *spec = codec->spec; | |
9029 | unsigned int mute; | |
9030 | ||
9031 | if (force || !spec->sense_updated) { | |
9032 | unsigned int present_int_hp; | |
9033 | /* need to execute and sync at first */ | |
9034 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); | |
9035 | present_int_hp = snd_hda_codec_read(codec, 0x1b, 0, | |
9036 | AC_VERB_GET_PIN_SENSE, 0); | |
9037 | spec->jack_present = (present_int_hp & 0x80000000) != 0; | |
9038 | spec->sense_updated = 1; | |
9039 | } | |
9040 | if (spec->jack_present) { | |
9041 | /* mute internal speaker */ | |
9042 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
9043 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
9044 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
9045 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
9046 | } else { | |
9047 | /* unmute internal speaker if necessary */ | |
9048 | mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); | |
9049 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
9050 | HDA_AMP_MUTE, mute); | |
9051 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
9052 | HDA_AMP_MUTE, mute); | |
9053 | } | |
9054 | } | |
9055 | ||
9056 | /* unsolicited event for HP jack sensing */ | |
9057 | static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec, | |
9058 | unsigned int res) | |
9059 | { | |
9060 | if ((res >> 26) != ALC_HP_EVENT) | |
9061 | return; | |
9062 | alc262_lenovo_3000_automute(codec, 1); | |
9063 | } | |
9064 | ||
834be88d TI |
9065 | /* bind hp and internal speaker mute (with plug check) */ |
9066 | static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol, | |
9067 | struct snd_ctl_elem_value *ucontrol) | |
9068 | { | |
9069 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
9070 | long *valp = ucontrol->value.integer.value; | |
9071 | int change; | |
9072 | ||
5d9fab2d TV |
9073 | change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
9074 | HDA_AMP_MUTE, | |
9075 | valp ? 0 : HDA_AMP_MUTE); | |
9076 | change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
9077 | HDA_AMP_MUTE, | |
9078 | valp ? 0 : HDA_AMP_MUTE); | |
9079 | ||
82beb8fd TI |
9080 | if (change) |
9081 | alc262_fujitsu_automute(codec, 0); | |
834be88d TI |
9082 | return change; |
9083 | } | |
9084 | ||
9085 | static struct snd_kcontrol_new alc262_fujitsu_mixer[] = { | |
cca3b371 | 9086 | HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol), |
834be88d TI |
9087 | { |
9088 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9089 | .name = "Master Playback Switch", | |
9090 | .info = snd_hda_mixer_amp_switch_info, | |
9091 | .get = snd_hda_mixer_amp_switch_get, | |
9092 | .put = alc262_fujitsu_master_sw_put, | |
9093 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
9094 | }, | |
9095 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
9096 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
06a9c30c TV |
9097 | HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT), |
9098 | HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT), | |
834be88d TI |
9099 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9100 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9101 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
39d3ed38 TI |
9102 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), |
9103 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
9104 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
834be88d TI |
9105 | { } /* end */ |
9106 | }; | |
9107 | ||
0e31daf7 J |
9108 | /* bind hp and internal speaker mute (with plug check) */ |
9109 | static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol, | |
9110 | struct snd_ctl_elem_value *ucontrol) | |
9111 | { | |
9112 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
9113 | long *valp = ucontrol->value.integer.value; | |
9114 | int change; | |
9115 | ||
9116 | change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
9117 | HDA_AMP_MUTE, | |
9118 | valp ? 0 : HDA_AMP_MUTE); | |
9119 | ||
9120 | if (change) | |
9121 | alc262_lenovo_3000_automute(codec, 0); | |
9122 | return change; | |
9123 | } | |
9124 | ||
9125 | static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = { | |
9126 | HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol), | |
9127 | { | |
9128 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9129 | .name = "Master Playback Switch", | |
9130 | .info = snd_hda_mixer_amp_switch_info, | |
9131 | .get = snd_hda_mixer_amp_switch_get, | |
9132 | .put = alc262_lenovo_3000_master_sw_put, | |
9133 | .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), | |
9134 | }, | |
9135 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
9136 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
9137 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
9138 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9139 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9140 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
9141 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
9142 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
9143 | { } /* end */ | |
9144 | }; | |
9145 | ||
304dcaac TI |
9146 | /* additional init verbs for Benq laptops */ |
9147 | static struct hda_verb alc262_EAPD_verbs[] = { | |
9148 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
9149 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
9150 | {} | |
9151 | }; | |
9152 | ||
83c34218 KY |
9153 | static struct hda_verb alc262_benq_t31_EAPD_verbs[] = { |
9154 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9155 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
9156 | ||
9157 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
9158 | {0x20, AC_VERB_SET_PROC_COEF, 0x3050}, | |
9159 | {} | |
9160 | }; | |
9161 | ||
f651b50b TD |
9162 | /* Samsung Q1 Ultra Vista model setup */ |
9163 | static struct snd_kcontrol_new alc262_ultra_mixer[] = { | |
bb9f76cd TI |
9164 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9165 | HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT), | |
f651b50b TD |
9166 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
9167 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
9168 | HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT), | |
bb9f76cd | 9169 | HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT), |
f651b50b TD |
9170 | { } /* end */ |
9171 | }; | |
9172 | ||
9173 | static struct hda_verb alc262_ultra_verbs[] = { | |
bb9f76cd TI |
9174 | /* output mixer */ |
9175 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
9176 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
9177 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9178 | /* speaker */ | |
9179 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9180 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9181 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9182 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9183 | /* HP */ | |
f651b50b | 9184 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
bb9f76cd TI |
9185 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
9186 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9187 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9188 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
9189 | /* internal mic */ | |
9190 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
9191 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
9192 | /* ADC, choose mic */ | |
9193 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
9194 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
9195 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9196 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
9197 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
9198 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9199 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
9200 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
9201 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
9202 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)}, | |
f651b50b TD |
9203 | {} |
9204 | }; | |
9205 | ||
f651b50b TD |
9206 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
9207 | static void alc262_ultra_automute(struct hda_codec *codec) | |
9208 | { | |
9209 | struct alc_spec *spec = codec->spec; | |
9210 | unsigned int mute; | |
f651b50b | 9211 | |
bb9f76cd TI |
9212 | mute = 0; |
9213 | /* auto-mute only when HP is used as HP */ | |
9214 | if (!spec->cur_mux[0]) { | |
9215 | unsigned int present; | |
9216 | /* need to execute and sync at first */ | |
9217 | snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); | |
9218 | present = snd_hda_codec_read(codec, 0x15, 0, | |
9219 | AC_VERB_GET_PIN_SENSE, 0); | |
9220 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; | |
9221 | if (spec->jack_present) | |
9222 | mute = HDA_AMP_MUTE; | |
f651b50b | 9223 | } |
bb9f76cd TI |
9224 | /* mute/unmute internal speaker */ |
9225 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
9226 | HDA_AMP_MUTE, mute); | |
9227 | /* mute/unmute HP */ | |
9228 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
9229 | HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE); | |
f651b50b TD |
9230 | } |
9231 | ||
9232 | /* unsolicited event for HP jack sensing */ | |
9233 | static void alc262_ultra_unsol_event(struct hda_codec *codec, | |
9234 | unsigned int res) | |
9235 | { | |
9236 | if ((res >> 26) != ALC880_HP_EVENT) | |
9237 | return; | |
9238 | alc262_ultra_automute(codec); | |
9239 | } | |
9240 | ||
bb9f76cd TI |
9241 | static struct hda_input_mux alc262_ultra_capture_source = { |
9242 | .num_items = 2, | |
9243 | .items = { | |
9244 | { "Mic", 0x1 }, | |
9245 | { "Headphone", 0x7 }, | |
9246 | }, | |
9247 | }; | |
9248 | ||
9249 | static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol, | |
9250 | struct snd_ctl_elem_value *ucontrol) | |
9251 | { | |
9252 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
9253 | struct alc_spec *spec = codec->spec; | |
9254 | int ret; | |
9255 | ||
9256 | ret = alc882_mux_enum_put(kcontrol, ucontrol); | |
9257 | if (!ret) | |
9258 | return 0; | |
9259 | /* reprogram the HP pin as mic or HP according to the input source */ | |
9260 | snd_hda_codec_write_cache(codec, 0x15, 0, | |
9261 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
9262 | spec->cur_mux[0] ? PIN_VREF80 : PIN_HP); | |
9263 | alc262_ultra_automute(codec); /* mute/unmute HP */ | |
9264 | return ret; | |
9265 | } | |
9266 | ||
9267 | static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = { | |
9268 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), | |
9269 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), | |
9270 | { | |
9271 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9272 | .name = "Capture Source", | |
9273 | .info = alc882_mux_enum_info, | |
9274 | .get = alc882_mux_enum_get, | |
9275 | .put = alc262_ultra_mux_enum_put, | |
9276 | }, | |
9277 | { } /* end */ | |
9278 | }; | |
9279 | ||
df694daa | 9280 | /* add playback controls from the parsed DAC table */ |
f12ab1e0 TI |
9281 | static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, |
9282 | const struct auto_pin_cfg *cfg) | |
df694daa KY |
9283 | { |
9284 | hda_nid_t nid; | |
9285 | int err; | |
9286 | ||
9287 | spec->multiout.num_dacs = 1; /* only use one dac */ | |
9288 | spec->multiout.dac_nids = spec->private_dac_nids; | |
9289 | spec->multiout.dac_nids[0] = 2; | |
9290 | ||
9291 | nid = cfg->line_out_pins[0]; | |
9292 | if (nid) { | |
f12ab1e0 TI |
9293 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
9294 | "Front Playback Volume", | |
9295 | HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT)); | |
9296 | if (err < 0) | |
df694daa | 9297 | return err; |
f12ab1e0 TI |
9298 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
9299 | "Front Playback Switch", | |
9300 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
9301 | if (err < 0) | |
df694daa KY |
9302 | return err; |
9303 | } | |
9304 | ||
82bc955f | 9305 | nid = cfg->speaker_pins[0]; |
df694daa KY |
9306 | if (nid) { |
9307 | if (nid == 0x16) { | |
f12ab1e0 TI |
9308 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
9309 | "Speaker Playback Volume", | |
9310 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, | |
9311 | HDA_OUTPUT)); | |
9312 | if (err < 0) | |
df694daa | 9313 | return err; |
f12ab1e0 TI |
9314 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
9315 | "Speaker Playback Switch", | |
9316 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
9317 | HDA_OUTPUT)); | |
9318 | if (err < 0) | |
df694daa KY |
9319 | return err; |
9320 | } else { | |
f12ab1e0 TI |
9321 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
9322 | "Speaker Playback Switch", | |
9323 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
9324 | HDA_OUTPUT)); | |
9325 | if (err < 0) | |
df694daa KY |
9326 | return err; |
9327 | } | |
9328 | } | |
eb06ed8f | 9329 | nid = cfg->hp_pins[0]; |
df694daa KY |
9330 | if (nid) { |
9331 | /* spec->multiout.hp_nid = 2; */ | |
9332 | if (nid == 0x16) { | |
f12ab1e0 TI |
9333 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
9334 | "Headphone Playback Volume", | |
9335 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, | |
9336 | HDA_OUTPUT)); | |
9337 | if (err < 0) | |
df694daa | 9338 | return err; |
f12ab1e0 TI |
9339 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
9340 | "Headphone Playback Switch", | |
9341 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
9342 | HDA_OUTPUT)); | |
9343 | if (err < 0) | |
df694daa KY |
9344 | return err; |
9345 | } else { | |
f12ab1e0 TI |
9346 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
9347 | "Headphone Playback Switch", | |
9348 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
9349 | HDA_OUTPUT)); | |
9350 | if (err < 0) | |
df694daa KY |
9351 | return err; |
9352 | } | |
9353 | } | |
f12ab1e0 | 9354 | return 0; |
df694daa KY |
9355 | } |
9356 | ||
9357 | /* identical with ALC880 */ | |
f12ab1e0 TI |
9358 | #define alc262_auto_create_analog_input_ctls \ |
9359 | alc880_auto_create_analog_input_ctls | |
df694daa KY |
9360 | |
9361 | /* | |
9362 | * generic initialization of ADC, input mixers and output mixers | |
9363 | */ | |
9364 | static struct hda_verb alc262_volume_init_verbs[] = { | |
9365 | /* | |
9366 | * Unmute ADC0-2 and set the default input to mic-in | |
9367 | */ | |
9368 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9369 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9370 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9371 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9372 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9373 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9374 | ||
cb53c626 | 9375 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
df694daa | 9376 | * mixer widget |
f12ab1e0 TI |
9377 | * Note: PASD motherboards uses the Line In 2 as the input for |
9378 | * front panel mic (mic 2) | |
df694daa KY |
9379 | */ |
9380 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
9381 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
9382 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
9383 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
9384 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
9385 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
9386 | |
9387 | /* | |
9388 | * Set up output mixers (0x0c - 0x0f) | |
9389 | */ | |
9390 | /* set vol=0 to output mixers */ | |
9391 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9392 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9393 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9394 | ||
9395 | /* set up input amps for analog loopback */ | |
9396 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
9397 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9398 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9399 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9400 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9401 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9402 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9403 | ||
9404 | /* FIXME: use matrix-type input source selection */ | |
9405 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
9406 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
9407 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9408 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
9409 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
9410 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
9411 | /* Input mixer2 */ | |
9412 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9413 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
9414 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
9415 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
9416 | /* Input mixer3 */ | |
9417 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9418 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
9419 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
9420 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
9421 | ||
9422 | { } | |
9423 | }; | |
9424 | ||
9c7f852e TI |
9425 | static struct hda_verb alc262_HP_BPC_init_verbs[] = { |
9426 | /* | |
9427 | * Unmute ADC0-2 and set the default input to mic-in | |
9428 | */ | |
9429 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9430 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9431 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9432 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9433 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9434 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9435 | ||
cb53c626 | 9436 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
9c7f852e | 9437 | * mixer widget |
f12ab1e0 TI |
9438 | * Note: PASD motherboards uses the Line In 2 as the input for |
9439 | * front panel mic (mic 2) | |
9c7f852e TI |
9440 | */ |
9441 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
9442 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
9443 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
9444 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
9445 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
9446 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9447 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
9448 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
9c7f852e TI |
9449 | |
9450 | /* | |
9451 | * Set up output mixers (0x0c - 0x0e) | |
9452 | */ | |
9453 | /* set vol=0 to output mixers */ | |
9454 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9455 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9456 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9457 | ||
9458 | /* set up input amps for analog loopback */ | |
9459 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
9460 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9461 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9462 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9463 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9464 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9465 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9466 | ||
ce875f07 | 9467 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
9c7f852e TI |
9468 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
9469 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
9470 | ||
9471 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
9472 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
9473 | ||
9474 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9475 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9476 | ||
9477 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
9478 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
9479 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
9480 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
9481 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
9482 | ||
9483 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
9484 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
9485 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
9486 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
9487 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
9488 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
9489 | ||
9490 | ||
9491 | /* FIXME: use matrix-type input source selection */ | |
9492 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
9493 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
9494 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9495 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
9496 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
9497 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
9498 | /* Input mixer2 */ | |
9499 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9500 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
9501 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
9502 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
9503 | /* Input mixer3 */ | |
9504 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9505 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
9506 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
9507 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
9508 | ||
ce875f07 TI |
9509 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
9510 | ||
9c7f852e TI |
9511 | { } |
9512 | }; | |
9513 | ||
cd7509a4 KY |
9514 | static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = { |
9515 | /* | |
9516 | * Unmute ADC0-2 and set the default input to mic-in | |
9517 | */ | |
9518 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9519 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9520 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9521 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9522 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9523 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9524 | ||
cb53c626 | 9525 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
cd7509a4 KY |
9526 | * mixer widget |
9527 | * Note: PASD motherboards uses the Line In 2 as the input for front | |
9528 | * panel mic (mic 2) | |
9529 | */ | |
9530 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
9531 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
9532 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
9533 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
9534 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
9535 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9536 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
9537 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
9538 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
cd7509a4 KY |
9539 | /* |
9540 | * Set up output mixers (0x0c - 0x0e) | |
9541 | */ | |
9542 | /* set vol=0 to output mixers */ | |
9543 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9544 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9545 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9546 | ||
9547 | /* set up input amps for analog loopback */ | |
9548 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
9549 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9550 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9551 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9552 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9553 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9554 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9555 | ||
9556 | ||
9557 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */ | |
9558 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */ | |
9559 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */ | |
9560 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */ | |
9561 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */ | |
9562 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */ | |
9563 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */ | |
9564 | ||
9565 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
9566 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
9567 | ||
9568 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9569 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
9570 | ||
9571 | /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */ | |
9572 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
9573 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
9574 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
9575 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
9576 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
9577 | ||
9578 | /* FIXME: use matrix-type input source selection */ | |
9579 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
9580 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
9581 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/ | |
9582 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/ | |
9583 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/ | |
9584 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/ | |
9585 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/ | |
9586 | /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
9587 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/ | |
9588 | /* Input mixer2 */ | |
9589 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9590 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
9591 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
9592 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
9593 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
9594 | /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
9595 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, | |
9596 | /* Input mixer3 */ | |
9597 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9598 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
9599 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
9600 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
9601 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
9602 | /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
9603 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, | |
9604 | ||
ce875f07 TI |
9605 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
9606 | ||
cd7509a4 KY |
9607 | { } |
9608 | }; | |
9609 | ||
cb53c626 TI |
9610 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
9611 | #define alc262_loopbacks alc880_loopbacks | |
9612 | #endif | |
9613 | ||
df694daa KY |
9614 | /* pcm configuration: identiacal with ALC880 */ |
9615 | #define alc262_pcm_analog_playback alc880_pcm_analog_playback | |
9616 | #define alc262_pcm_analog_capture alc880_pcm_analog_capture | |
9617 | #define alc262_pcm_digital_playback alc880_pcm_digital_playback | |
9618 | #define alc262_pcm_digital_capture alc880_pcm_digital_capture | |
9619 | ||
9620 | /* | |
9621 | * BIOS auto configuration | |
9622 | */ | |
9623 | static int alc262_parse_auto_config(struct hda_codec *codec) | |
9624 | { | |
9625 | struct alc_spec *spec = codec->spec; | |
9626 | int err; | |
9627 | static hda_nid_t alc262_ignore[] = { 0x1d, 0 }; | |
9628 | ||
f12ab1e0 TI |
9629 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
9630 | alc262_ignore); | |
9631 | if (err < 0) | |
df694daa | 9632 | return err; |
f12ab1e0 | 9633 | if (!spec->autocfg.line_outs) |
df694daa | 9634 | return 0; /* can't find valid BIOS pin config */ |
f12ab1e0 TI |
9635 | err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg); |
9636 | if (err < 0) | |
9637 | return err; | |
9638 | err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
9639 | if (err < 0) | |
df694daa KY |
9640 | return err; |
9641 | ||
9642 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
9643 | ||
9644 | if (spec->autocfg.dig_out_pin) | |
9645 | spec->multiout.dig_out_nid = ALC262_DIGOUT_NID; | |
9646 | if (spec->autocfg.dig_in_pin) | |
9647 | spec->dig_in_nid = ALC262_DIGIN_NID; | |
9648 | ||
9649 | if (spec->kctl_alloc) | |
9650 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
9651 | ||
9652 | spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs; | |
a1e8d2da | 9653 | spec->num_mux_defs = 1; |
df694daa KY |
9654 | spec->input_mux = &spec->private_imux; |
9655 | ||
776e184e TI |
9656 | err = alc_auto_add_mic_boost(codec); |
9657 | if (err < 0) | |
9658 | return err; | |
9659 | ||
df694daa KY |
9660 | return 1; |
9661 | } | |
9662 | ||
9663 | #define alc262_auto_init_multi_out alc882_auto_init_multi_out | |
9664 | #define alc262_auto_init_hp_out alc882_auto_init_hp_out | |
9665 | #define alc262_auto_init_analog_input alc882_auto_init_analog_input | |
9666 | ||
9667 | ||
9668 | /* init callback for auto-configuration model -- overriding the default init */ | |
ae6b813a | 9669 | static void alc262_auto_init(struct hda_codec *codec) |
df694daa | 9670 | { |
f6c7e546 | 9671 | struct alc_spec *spec = codec->spec; |
df694daa KY |
9672 | alc262_auto_init_multi_out(codec); |
9673 | alc262_auto_init_hp_out(codec); | |
9674 | alc262_auto_init_analog_input(codec); | |
f6c7e546 TI |
9675 | if (spec->unsol_event) |
9676 | alc_sku_automute(codec); | |
df694daa KY |
9677 | } |
9678 | ||
9679 | /* | |
9680 | * configuration and preset | |
9681 | */ | |
f5fcc13c TI |
9682 | static const char *alc262_models[ALC262_MODEL_LAST] = { |
9683 | [ALC262_BASIC] = "basic", | |
9684 | [ALC262_HIPPO] = "hippo", | |
9685 | [ALC262_HIPPO_1] = "hippo_1", | |
9686 | [ALC262_FUJITSU] = "fujitsu", | |
9687 | [ALC262_HP_BPC] = "hp-bpc", | |
cd7509a4 | 9688 | [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000", |
61dc35de | 9689 | [ALC262_HP_TC_T5735] = "hp-tc-t5735", |
8c427226 | 9690 | [ALC262_HP_RP5700] = "hp-rp5700", |
f5fcc13c | 9691 | [ALC262_BENQ_ED8] = "benq", |
0f40502e TI |
9692 | [ALC262_BENQ_T31] = "benq-t31", |
9693 | [ALC262_SONY_ASSAMD] = "sony-assamd", | |
f651b50b | 9694 | [ALC262_ULTRA] = "ultra", |
0e31daf7 | 9695 | [ALC262_LENOVO_3000] = "lenovo-3000", |
f5fcc13c TI |
9696 | [ALC262_AUTO] = "auto", |
9697 | }; | |
9698 | ||
9699 | static struct snd_pci_quirk alc262_cfg_tbl[] = { | |
9700 | SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO), | |
9701 | SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC), | |
7d87de2d | 9702 | SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC), |
ac3e3741 TI |
9703 | SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC), |
9704 | SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC), | |
7d87de2d | 9705 | SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC), |
b98f9334 | 9706 | SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC), |
b98f9334 | 9707 | SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC), |
b98f9334 | 9708 | SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC), |
cd7509a4 | 9709 | SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL), |
cd7509a4 | 9710 | SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF), |
ac3e3741 | 9711 | SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL), |
cd7509a4 | 9712 | SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF), |
ac3e3741 | 9713 | SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL), |
cd7509a4 | 9714 | SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF), |
ac3e3741 | 9715 | SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL), |
cd7509a4 | 9716 | SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF), |
ac3e3741 TI |
9717 | SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC), |
9718 | SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC), | |
9719 | SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC), | |
66d2a9d6 KY |
9720 | SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735", |
9721 | ALC262_HP_TC_T5735), | |
8c427226 | 9722 | SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700), |
ac3e3741 | 9723 | SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD), |
f5fcc13c | 9724 | SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO), |
5b31954e | 9725 | SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD), |
272a527c | 9726 | SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD), |
ac3e3741 | 9727 | SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD), |
36ca6e13 AI |
9728 | SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1", |
9729 | ALC262_SONY_ASSAMD), | |
ac3e3741 | 9730 | SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU), |
3f1eeaed | 9731 | SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU), |
f651b50b | 9732 | SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA), |
bb9f76cd | 9733 | SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA), |
0e31daf7 | 9734 | SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000), |
ac3e3741 TI |
9735 | SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8), |
9736 | SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31), | |
9737 | SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1), | |
df694daa KY |
9738 | {} |
9739 | }; | |
9740 | ||
9741 | static struct alc_config_preset alc262_presets[] = { | |
9742 | [ALC262_BASIC] = { | |
9743 | .mixers = { alc262_base_mixer }, | |
9744 | .init_verbs = { alc262_init_verbs }, | |
9745 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
9746 | .dac_nids = alc262_dac_nids, | |
9747 | .hp_nid = 0x03, | |
9748 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
9749 | .channel_mode = alc262_modes, | |
a3bcba38 | 9750 | .input_mux = &alc262_capture_source, |
df694daa | 9751 | }, |
ccc656ce KY |
9752 | [ALC262_HIPPO] = { |
9753 | .mixers = { alc262_base_mixer }, | |
9754 | .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs}, | |
9755 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
9756 | .dac_nids = alc262_dac_nids, | |
9757 | .hp_nid = 0x03, | |
9758 | .dig_out_nid = ALC262_DIGOUT_NID, | |
9759 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
9760 | .channel_mode = alc262_modes, | |
9761 | .input_mux = &alc262_capture_source, | |
9762 | .unsol_event = alc262_hippo_unsol_event, | |
5b31954e | 9763 | .init_hook = alc262_hippo_automute, |
ccc656ce KY |
9764 | }, |
9765 | [ALC262_HIPPO_1] = { | |
9766 | .mixers = { alc262_hippo1_mixer }, | |
9767 | .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs}, | |
9768 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
9769 | .dac_nids = alc262_dac_nids, | |
9770 | .hp_nid = 0x02, | |
9771 | .dig_out_nid = ALC262_DIGOUT_NID, | |
9772 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
9773 | .channel_mode = alc262_modes, | |
9774 | .input_mux = &alc262_capture_source, | |
9775 | .unsol_event = alc262_hippo1_unsol_event, | |
5b31954e | 9776 | .init_hook = alc262_hippo1_automute, |
ccc656ce | 9777 | }, |
834be88d TI |
9778 | [ALC262_FUJITSU] = { |
9779 | .mixers = { alc262_fujitsu_mixer }, | |
39d3ed38 TI |
9780 | .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs, |
9781 | alc262_fujitsu_unsol_verbs }, | |
834be88d TI |
9782 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), |
9783 | .dac_nids = alc262_dac_nids, | |
9784 | .hp_nid = 0x03, | |
9785 | .dig_out_nid = ALC262_DIGOUT_NID, | |
9786 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
9787 | .channel_mode = alc262_modes, | |
9788 | .input_mux = &alc262_fujitsu_capture_source, | |
ae6b813a | 9789 | .unsol_event = alc262_fujitsu_unsol_event, |
ebc7a406 | 9790 | .init_hook = alc262_fujitsu_init_hook, |
834be88d | 9791 | }, |
9c7f852e TI |
9792 | [ALC262_HP_BPC] = { |
9793 | .mixers = { alc262_HP_BPC_mixer }, | |
9794 | .init_verbs = { alc262_HP_BPC_init_verbs }, | |
9795 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
9796 | .dac_nids = alc262_dac_nids, | |
9797 | .hp_nid = 0x03, | |
9798 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
9799 | .channel_mode = alc262_modes, | |
9800 | .input_mux = &alc262_HP_capture_source, | |
ce875f07 TI |
9801 | .unsol_event = alc262_hp_bpc_unsol_event, |
9802 | .init_hook = alc262_hp_bpc_automute, | |
f12ab1e0 | 9803 | }, |
cd7509a4 KY |
9804 | [ALC262_HP_BPC_D7000_WF] = { |
9805 | .mixers = { alc262_HP_BPC_WildWest_mixer }, | |
9806 | .init_verbs = { alc262_HP_BPC_WildWest_init_verbs }, | |
9807 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
9808 | .dac_nids = alc262_dac_nids, | |
9809 | .hp_nid = 0x03, | |
9810 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
9811 | .channel_mode = alc262_modes, | |
accbe498 | 9812 | .input_mux = &alc262_HP_D7000_capture_source, |
ce875f07 TI |
9813 | .unsol_event = alc262_hp_wildwest_unsol_event, |
9814 | .init_hook = alc262_hp_wildwest_automute, | |
f12ab1e0 | 9815 | }, |
cd7509a4 KY |
9816 | [ALC262_HP_BPC_D7000_WL] = { |
9817 | .mixers = { alc262_HP_BPC_WildWest_mixer, | |
9818 | alc262_HP_BPC_WildWest_option_mixer }, | |
9819 | .init_verbs = { alc262_HP_BPC_WildWest_init_verbs }, | |
9820 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
9821 | .dac_nids = alc262_dac_nids, | |
9822 | .hp_nid = 0x03, | |
9823 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
9824 | .channel_mode = alc262_modes, | |
accbe498 | 9825 | .input_mux = &alc262_HP_D7000_capture_source, |
ce875f07 TI |
9826 | .unsol_event = alc262_hp_wildwest_unsol_event, |
9827 | .init_hook = alc262_hp_wildwest_automute, | |
f12ab1e0 | 9828 | }, |
66d2a9d6 KY |
9829 | [ALC262_HP_TC_T5735] = { |
9830 | .mixers = { alc262_hp_t5735_mixer }, | |
9831 | .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs }, | |
9832 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
9833 | .dac_nids = alc262_dac_nids, | |
9834 | .hp_nid = 0x03, | |
9835 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
9836 | .channel_mode = alc262_modes, | |
9837 | .input_mux = &alc262_capture_source, | |
9838 | .unsol_event = alc262_hp_t5735_unsol_event, | |
9839 | .init_hook = alc262_hp_t5735_init_hook, | |
8c427226 KY |
9840 | }, |
9841 | [ALC262_HP_RP5700] = { | |
9842 | .mixers = { alc262_hp_rp5700_mixer }, | |
9843 | .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs }, | |
9844 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
9845 | .dac_nids = alc262_dac_nids, | |
9846 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
9847 | .channel_mode = alc262_modes, | |
9848 | .input_mux = &alc262_hp_rp5700_capture_source, | |
66d2a9d6 | 9849 | }, |
304dcaac TI |
9850 | [ALC262_BENQ_ED8] = { |
9851 | .mixers = { alc262_base_mixer }, | |
9852 | .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs }, | |
9853 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
9854 | .dac_nids = alc262_dac_nids, | |
9855 | .hp_nid = 0x03, | |
9856 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
9857 | .channel_mode = alc262_modes, | |
9858 | .input_mux = &alc262_capture_source, | |
f12ab1e0 | 9859 | }, |
272a527c KY |
9860 | [ALC262_SONY_ASSAMD] = { |
9861 | .mixers = { alc262_sony_mixer }, | |
9862 | .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs}, | |
9863 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
9864 | .dac_nids = alc262_dac_nids, | |
9865 | .hp_nid = 0x02, | |
9866 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
9867 | .channel_mode = alc262_modes, | |
9868 | .input_mux = &alc262_capture_source, | |
9869 | .unsol_event = alc262_hippo_unsol_event, | |
5b31954e | 9870 | .init_hook = alc262_hippo_automute, |
83c34218 KY |
9871 | }, |
9872 | [ALC262_BENQ_T31] = { | |
9873 | .mixers = { alc262_benq_t31_mixer }, | |
9874 | .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs }, | |
9875 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
9876 | .dac_nids = alc262_dac_nids, | |
9877 | .hp_nid = 0x03, | |
9878 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
9879 | .channel_mode = alc262_modes, | |
9880 | .input_mux = &alc262_capture_source, | |
9881 | .unsol_event = alc262_hippo_unsol_event, | |
5b31954e | 9882 | .init_hook = alc262_hippo_automute, |
272a527c | 9883 | }, |
f651b50b | 9884 | [ALC262_ULTRA] = { |
bb9f76cd TI |
9885 | .mixers = { alc262_ultra_mixer, alc262_ultra_capture_mixer }, |
9886 | .init_verbs = { alc262_ultra_verbs }, | |
f651b50b TD |
9887 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), |
9888 | .dac_nids = alc262_dac_nids, | |
f651b50b TD |
9889 | .num_channel_mode = ARRAY_SIZE(alc262_modes), |
9890 | .channel_mode = alc262_modes, | |
9891 | .input_mux = &alc262_ultra_capture_source, | |
bb9f76cd TI |
9892 | .adc_nids = alc262_adc_nids, /* ADC0 */ |
9893 | .capsrc_nids = alc262_capsrc_nids, | |
9894 | .num_adc_nids = 1, /* single ADC */ | |
f651b50b TD |
9895 | .unsol_event = alc262_ultra_unsol_event, |
9896 | .init_hook = alc262_ultra_automute, | |
9897 | }, | |
0e31daf7 J |
9898 | [ALC262_LENOVO_3000] = { |
9899 | .mixers = { alc262_lenovo_3000_mixer }, | |
9900 | .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs, | |
9901 | alc262_lenovo_3000_unsol_verbs }, | |
9902 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
9903 | .dac_nids = alc262_dac_nids, | |
9904 | .hp_nid = 0x03, | |
9905 | .dig_out_nid = ALC262_DIGOUT_NID, | |
9906 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
9907 | .channel_mode = alc262_modes, | |
9908 | .input_mux = &alc262_fujitsu_capture_source, | |
9909 | .unsol_event = alc262_lenovo_3000_unsol_event, | |
9910 | }, | |
df694daa KY |
9911 | }; |
9912 | ||
9913 | static int patch_alc262(struct hda_codec *codec) | |
9914 | { | |
9915 | struct alc_spec *spec; | |
9916 | int board_config; | |
9917 | int err; | |
9918 | ||
dc041e0b | 9919 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
df694daa KY |
9920 | if (spec == NULL) |
9921 | return -ENOMEM; | |
9922 | ||
9923 | codec->spec = spec; | |
9924 | #if 0 | |
f12ab1e0 TI |
9925 | /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is |
9926 | * under-run | |
9927 | */ | |
df694daa KY |
9928 | { |
9929 | int tmp; | |
9930 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); | |
9931 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); | |
9932 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); | |
9933 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); | |
9934 | } | |
9935 | #endif | |
9936 | ||
2c3bf9ab TI |
9937 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
9938 | ||
f5fcc13c TI |
9939 | board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST, |
9940 | alc262_models, | |
9941 | alc262_cfg_tbl); | |
cd7509a4 | 9942 | |
f5fcc13c | 9943 | if (board_config < 0) { |
9c7f852e TI |
9944 | printk(KERN_INFO "hda_codec: Unknown model for ALC262, " |
9945 | "trying auto-probe from BIOS...\n"); | |
df694daa KY |
9946 | board_config = ALC262_AUTO; |
9947 | } | |
9948 | ||
9949 | if (board_config == ALC262_AUTO) { | |
9950 | /* automatic parse from the BIOS config */ | |
9951 | err = alc262_parse_auto_config(codec); | |
9952 | if (err < 0) { | |
9953 | alc_free(codec); | |
9954 | return err; | |
f12ab1e0 | 9955 | } else if (!err) { |
9c7f852e TI |
9956 | printk(KERN_INFO |
9957 | "hda_codec: Cannot set up configuration " | |
9958 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
9959 | board_config = ALC262_BASIC; |
9960 | } | |
9961 | } | |
9962 | ||
9963 | if (board_config != ALC262_AUTO) | |
9964 | setup_preset(spec, &alc262_presets[board_config]); | |
9965 | ||
9966 | spec->stream_name_analog = "ALC262 Analog"; | |
9967 | spec->stream_analog_playback = &alc262_pcm_analog_playback; | |
9968 | spec->stream_analog_capture = &alc262_pcm_analog_capture; | |
9969 | ||
9970 | spec->stream_name_digital = "ALC262 Digital"; | |
9971 | spec->stream_digital_playback = &alc262_pcm_digital_playback; | |
9972 | spec->stream_digital_capture = &alc262_pcm_digital_capture; | |
9973 | ||
f12ab1e0 | 9974 | if (!spec->adc_nids && spec->input_mux) { |
df694daa | 9975 | /* check whether NID 0x07 is valid */ |
4a471b7d TI |
9976 | unsigned int wcap = get_wcaps(codec, 0x07); |
9977 | ||
f12ab1e0 TI |
9978 | /* get type */ |
9979 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
df694daa KY |
9980 | if (wcap != AC_WID_AUD_IN) { |
9981 | spec->adc_nids = alc262_adc_nids_alt; | |
9982 | spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt); | |
88c71a99 | 9983 | spec->capsrc_nids = alc262_capsrc_nids_alt; |
f12ab1e0 TI |
9984 | spec->mixers[spec->num_mixers] = |
9985 | alc262_capture_alt_mixer; | |
df694daa KY |
9986 | spec->num_mixers++; |
9987 | } else { | |
9988 | spec->adc_nids = alc262_adc_nids; | |
9989 | spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids); | |
88c71a99 | 9990 | spec->capsrc_nids = alc262_capsrc_nids; |
df694daa KY |
9991 | spec->mixers[spec->num_mixers] = alc262_capture_mixer; |
9992 | spec->num_mixers++; | |
9993 | } | |
9994 | } | |
9995 | ||
2134ea4f TI |
9996 | spec->vmaster_nid = 0x0c; |
9997 | ||
df694daa KY |
9998 | codec->patch_ops = alc_patch_ops; |
9999 | if (board_config == ALC262_AUTO) | |
ae6b813a | 10000 | spec->init_hook = alc262_auto_init; |
cb53c626 TI |
10001 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
10002 | if (!spec->loopback.amplist) | |
10003 | spec->loopback.amplist = alc262_loopbacks; | |
10004 | #endif | |
834be88d | 10005 | |
df694daa KY |
10006 | return 0; |
10007 | } | |
10008 | ||
a361d84b KY |
10009 | /* |
10010 | * ALC268 channel source setting (2 channel) | |
10011 | */ | |
10012 | #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID | |
10013 | #define alc268_modes alc260_modes | |
10014 | ||
10015 | static hda_nid_t alc268_dac_nids[2] = { | |
10016 | /* front, hp */ | |
10017 | 0x02, 0x03 | |
10018 | }; | |
10019 | ||
10020 | static hda_nid_t alc268_adc_nids[2] = { | |
10021 | /* ADC0-1 */ | |
10022 | 0x08, 0x07 | |
10023 | }; | |
10024 | ||
10025 | static hda_nid_t alc268_adc_nids_alt[1] = { | |
10026 | /* ADC0 */ | |
10027 | 0x08 | |
10028 | }; | |
10029 | ||
e1406348 TI |
10030 | static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 }; |
10031 | ||
a361d84b KY |
10032 | static struct snd_kcontrol_new alc268_base_mixer[] = { |
10033 | /* output mixer control */ | |
10034 | HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT), | |
10035 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
10036 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT), | |
10037 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
33bf17ab TI |
10038 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
10039 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
10040 | HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT), | |
a361d84b KY |
10041 | { } |
10042 | }; | |
10043 | ||
aef9d318 TI |
10044 | /* bind Beep switches of both NID 0x0f and 0x10 */ |
10045 | static struct hda_bind_ctls alc268_bind_beep_sw = { | |
10046 | .ops = &snd_hda_bind_sw, | |
10047 | .values = { | |
10048 | HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT), | |
10049 | HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT), | |
10050 | 0 | |
10051 | }, | |
10052 | }; | |
10053 | ||
10054 | static struct snd_kcontrol_new alc268_beep_mixer[] = { | |
10055 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT), | |
10056 | HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw), | |
10057 | { } | |
10058 | }; | |
10059 | ||
d1a991a6 KY |
10060 | static struct hda_verb alc268_eapd_verbs[] = { |
10061 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
10062 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
10063 | { } | |
10064 | }; | |
10065 | ||
d273809e TI |
10066 | /* Toshiba specific */ |
10067 | #define alc268_toshiba_automute alc262_hippo_automute | |
10068 | ||
10069 | static struct hda_verb alc268_toshiba_verbs[] = { | |
10070 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
10071 | { } /* end */ | |
10072 | }; | |
10073 | ||
10074 | /* Acer specific */ | |
889c4395 | 10075 | /* bind volumes of both NID 0x02 and 0x03 */ |
6bc96857 TI |
10076 | static struct hda_bind_ctls alc268_acer_bind_master_vol = { |
10077 | .ops = &snd_hda_bind_vol, | |
10078 | .values = { | |
10079 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), | |
10080 | HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT), | |
10081 | 0 | |
10082 | }, | |
10083 | }; | |
10084 | ||
889c4395 TI |
10085 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
10086 | static void alc268_acer_automute(struct hda_codec *codec, int force) | |
10087 | { | |
10088 | struct alc_spec *spec = codec->spec; | |
10089 | unsigned int mute; | |
10090 | ||
10091 | if (force || !spec->sense_updated) { | |
10092 | unsigned int present; | |
10093 | present = snd_hda_codec_read(codec, 0x14, 0, | |
10094 | AC_VERB_GET_PIN_SENSE, 0); | |
10095 | spec->jack_present = (present & 0x80000000) != 0; | |
10096 | spec->sense_updated = 1; | |
10097 | } | |
10098 | if (spec->jack_present) | |
10099 | mute = HDA_AMP_MUTE; /* mute internal speaker */ | |
10100 | else /* unmute internal speaker if necessary */ | |
10101 | mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); | |
10102 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
10103 | HDA_AMP_MUTE, mute); | |
10104 | } | |
10105 | ||
10106 | ||
10107 | /* bind hp and internal speaker mute (with plug check) */ | |
10108 | static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol, | |
10109 | struct snd_ctl_elem_value *ucontrol) | |
10110 | { | |
10111 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
10112 | long *valp = ucontrol->value.integer.value; | |
10113 | int change; | |
10114 | ||
10115 | change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, | |
10116 | HDA_AMP_MUTE, | |
10117 | valp[0] ? 0 : HDA_AMP_MUTE); | |
10118 | change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, | |
10119 | HDA_AMP_MUTE, | |
10120 | valp[1] ? 0 : HDA_AMP_MUTE); | |
10121 | if (change) | |
10122 | alc268_acer_automute(codec, 0); | |
10123 | return change; | |
10124 | } | |
d273809e TI |
10125 | |
10126 | static struct snd_kcontrol_new alc268_acer_mixer[] = { | |
10127 | /* output mixer control */ | |
10128 | HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol), | |
10129 | { | |
10130 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10131 | .name = "Master Playback Switch", | |
10132 | .info = snd_hda_mixer_amp_switch_info, | |
10133 | .get = snd_hda_mixer_amp_switch_get, | |
10134 | .put = alc268_acer_master_sw_put, | |
10135 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
10136 | }, | |
33bf17ab TI |
10137 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
10138 | HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT), | |
10139 | HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT), | |
d273809e TI |
10140 | { } |
10141 | }; | |
10142 | ||
10143 | static struct hda_verb alc268_acer_verbs[] = { | |
0ccb541c TI |
10144 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */ |
10145 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
d273809e TI |
10146 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
10147 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
0ccb541c TI |
10148 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
10149 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
d273809e TI |
10150 | |
10151 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
10152 | { } | |
10153 | }; | |
10154 | ||
10155 | /* unsolicited event for HP jack sensing */ | |
10156 | static void alc268_toshiba_unsol_event(struct hda_codec *codec, | |
10157 | unsigned int res) | |
10158 | { | |
889c4395 | 10159 | if ((res >> 26) != ALC880_HP_EVENT) |
d273809e TI |
10160 | return; |
10161 | alc268_toshiba_automute(codec); | |
10162 | } | |
10163 | ||
10164 | static void alc268_acer_unsol_event(struct hda_codec *codec, | |
10165 | unsigned int res) | |
10166 | { | |
889c4395 | 10167 | if ((res >> 26) != ALC880_HP_EVENT) |
d273809e TI |
10168 | return; |
10169 | alc268_acer_automute(codec, 1); | |
10170 | } | |
10171 | ||
889c4395 TI |
10172 | static void alc268_acer_init_hook(struct hda_codec *codec) |
10173 | { | |
10174 | alc268_acer_automute(codec, 1); | |
10175 | } | |
10176 | ||
3866f0b0 TI |
10177 | static struct snd_kcontrol_new alc268_dell_mixer[] = { |
10178 | /* output mixer control */ | |
10179 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
10180 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
10181 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
10182 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
10183 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
10184 | HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT), | |
10185 | { } | |
10186 | }; | |
10187 | ||
10188 | static struct hda_verb alc268_dell_verbs[] = { | |
10189 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
10190 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
10191 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
10192 | { } | |
10193 | }; | |
10194 | ||
10195 | /* mute/unmute internal speaker according to the hp jack and mute state */ | |
10196 | static void alc268_dell_automute(struct hda_codec *codec) | |
10197 | { | |
10198 | unsigned int present; | |
10199 | unsigned int mute; | |
10200 | ||
10201 | present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0); | |
10202 | if (present & 0x80000000) | |
10203 | mute = HDA_AMP_MUTE; | |
10204 | else | |
10205 | mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0); | |
10206 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
10207 | HDA_AMP_MUTE, mute); | |
10208 | } | |
10209 | ||
10210 | static void alc268_dell_unsol_event(struct hda_codec *codec, | |
10211 | unsigned int res) | |
10212 | { | |
10213 | if ((res >> 26) != ALC880_HP_EVENT) | |
10214 | return; | |
10215 | alc268_dell_automute(codec); | |
10216 | } | |
10217 | ||
10218 | #define alc268_dell_init_hook alc268_dell_automute | |
10219 | ||
eb5a6621 HRK |
10220 | static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = { |
10221 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT), | |
10222 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
10223 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT), | |
10224 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
10225 | HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT), | |
10226 | HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT), | |
10227 | HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT), | |
10228 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
10229 | { } | |
10230 | }; | |
10231 | ||
10232 | static struct hda_verb alc267_quanta_il1_verbs[] = { | |
10233 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
10234 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, | |
10235 | { } | |
10236 | }; | |
10237 | ||
10238 | static void alc267_quanta_il1_hp_automute(struct hda_codec *codec) | |
10239 | { | |
10240 | unsigned int present; | |
10241 | ||
10242 | present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0) | |
10243 | & AC_PINSENSE_PRESENCE; | |
10244 | snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
10245 | present ? 0 : PIN_OUT); | |
10246 | } | |
10247 | ||
10248 | static void alc267_quanta_il1_mic_automute(struct hda_codec *codec) | |
10249 | { | |
10250 | unsigned int present; | |
10251 | ||
10252 | present = snd_hda_codec_read(codec, 0x18, 0, | |
10253 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
10254 | snd_hda_codec_write(codec, 0x23, 0, | |
10255 | AC_VERB_SET_CONNECT_SEL, | |
10256 | present ? 0x00 : 0x01); | |
10257 | } | |
10258 | ||
10259 | static void alc267_quanta_il1_automute(struct hda_codec *codec) | |
10260 | { | |
10261 | alc267_quanta_il1_hp_automute(codec); | |
10262 | alc267_quanta_il1_mic_automute(codec); | |
10263 | } | |
10264 | ||
10265 | static void alc267_quanta_il1_unsol_event(struct hda_codec *codec, | |
10266 | unsigned int res) | |
10267 | { | |
10268 | switch (res >> 26) { | |
10269 | case ALC880_HP_EVENT: | |
10270 | alc267_quanta_il1_hp_automute(codec); | |
10271 | break; | |
10272 | case ALC880_MIC_EVENT: | |
10273 | alc267_quanta_il1_mic_automute(codec); | |
10274 | break; | |
10275 | } | |
10276 | } | |
10277 | ||
a361d84b KY |
10278 | /* |
10279 | * generic initialization of ADC, input mixers and output mixers | |
10280 | */ | |
10281 | static struct hda_verb alc268_base_init_verbs[] = { | |
10282 | /* Unmute DAC0-1 and set vol = 0 */ | |
10283 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10284 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10285 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10286 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10287 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10288 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10289 | ||
10290 | /* | |
10291 | * Set up output mixers (0x0c - 0x0e) | |
10292 | */ | |
10293 | /* set vol=0 to output mixers */ | |
10294 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10295 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10296 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10297 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10298 | ||
10299 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10300 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10301 | ||
10302 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
10303 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
10304 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
10305 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
10306 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
10307 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
10308 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
10309 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
10310 | ||
10311 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10312 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10313 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10314 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10315 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10316 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10317 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
aef9d318 TI |
10318 | |
10319 | /* set PCBEEP vol = 0, mute connections */ | |
10320 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10321 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10322 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
a361d84b | 10323 | |
a9b3aa8a JZ |
10324 | /* Unmute Selector 23h,24h and set the default input to mic-in */ |
10325 | ||
10326 | {0x23, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10327 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10328 | {0x24, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10329 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
a361d84b | 10330 | |
a361d84b KY |
10331 | { } |
10332 | }; | |
10333 | ||
10334 | /* | |
10335 | * generic initialization of ADC, input mixers and output mixers | |
10336 | */ | |
10337 | static struct hda_verb alc268_volume_init_verbs[] = { | |
10338 | /* set output DAC */ | |
10339 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10340 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10341 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10342 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10343 | ||
10344 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
10345 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
10346 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
10347 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
10348 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
10349 | ||
10350 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10351 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10352 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10353 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10354 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10355 | ||
10356 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10357 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10358 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10359 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10360 | ||
aef9d318 TI |
10361 | /* set PCBEEP vol = 0, mute connections */ |
10362 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10363 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10364 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
a361d84b KY |
10365 | |
10366 | { } | |
10367 | }; | |
10368 | ||
10369 | #define alc268_mux_enum_info alc_mux_enum_info | |
10370 | #define alc268_mux_enum_get alc_mux_enum_get | |
e1406348 | 10371 | #define alc268_mux_enum_put alc_mux_enum_put |
a361d84b KY |
10372 | |
10373 | static struct snd_kcontrol_new alc268_capture_alt_mixer[] = { | |
10374 | HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), | |
10375 | HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), | |
10376 | { | |
10377 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10378 | /* The multiple "Capture Source" controls confuse alsamixer | |
10379 | * So call somewhat different.. | |
a361d84b KY |
10380 | */ |
10381 | /* .name = "Capture Source", */ | |
10382 | .name = "Input Source", | |
10383 | .count = 1, | |
10384 | .info = alc268_mux_enum_info, | |
10385 | .get = alc268_mux_enum_get, | |
10386 | .put = alc268_mux_enum_put, | |
10387 | }, | |
10388 | { } /* end */ | |
10389 | }; | |
10390 | ||
10391 | static struct snd_kcontrol_new alc268_capture_mixer[] = { | |
10392 | HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), | |
10393 | HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), | |
10394 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT), | |
10395 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT), | |
10396 | { | |
10397 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10398 | /* The multiple "Capture Source" controls confuse alsamixer | |
10399 | * So call somewhat different.. | |
a361d84b KY |
10400 | */ |
10401 | /* .name = "Capture Source", */ | |
10402 | .name = "Input Source", | |
10403 | .count = 2, | |
10404 | .info = alc268_mux_enum_info, | |
10405 | .get = alc268_mux_enum_get, | |
10406 | .put = alc268_mux_enum_put, | |
10407 | }, | |
10408 | { } /* end */ | |
10409 | }; | |
10410 | ||
10411 | static struct hda_input_mux alc268_capture_source = { | |
10412 | .num_items = 4, | |
10413 | .items = { | |
10414 | { "Mic", 0x0 }, | |
10415 | { "Front Mic", 0x1 }, | |
10416 | { "Line", 0x2 }, | |
10417 | { "CD", 0x3 }, | |
10418 | }, | |
10419 | }; | |
10420 | ||
0ccb541c TI |
10421 | static struct hda_input_mux alc268_acer_capture_source = { |
10422 | .num_items = 3, | |
10423 | .items = { | |
10424 | { "Mic", 0x0 }, | |
10425 | { "Internal Mic", 0x6 }, | |
10426 | { "Line", 0x2 }, | |
10427 | }, | |
10428 | }; | |
10429 | ||
86c53bd2 JW |
10430 | #ifdef CONFIG_SND_DEBUG |
10431 | static struct snd_kcontrol_new alc268_test_mixer[] = { | |
86c53bd2 JW |
10432 | /* Volume widgets */ |
10433 | HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
10434 | HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
10435 | HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
10436 | HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT), | |
10437 | HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT), | |
10438 | HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT), | |
10439 | HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT), | |
10440 | HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT), | |
10441 | HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT), | |
10442 | HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT), | |
10443 | HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT), | |
10444 | HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT), | |
10445 | HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT), | |
f0747ee6 TI |
10446 | /* The below appears problematic on some hardwares */ |
10447 | /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/ | |
86c53bd2 JW |
10448 | HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT), |
10449 | HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT), | |
10450 | HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT), | |
10451 | HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT), | |
10452 | ||
10453 | /* Modes for retasking pin widgets */ | |
10454 | ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT), | |
10455 | ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT), | |
10456 | ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT), | |
10457 | ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT), | |
10458 | ||
10459 | /* Controls for GPIO pins, assuming they are configured as outputs */ | |
10460 | ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01), | |
10461 | ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02), | |
10462 | ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04), | |
10463 | ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08), | |
10464 | ||
10465 | /* Switches to allow the digital SPDIF output pin to be enabled. | |
10466 | * The ALC268 does not have an SPDIF input. | |
10467 | */ | |
10468 | ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01), | |
10469 | ||
10470 | /* A switch allowing EAPD to be enabled. Some laptops seem to use | |
10471 | * this output to turn on an external amplifier. | |
10472 | */ | |
10473 | ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02), | |
10474 | ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02), | |
10475 | ||
10476 | { } /* end */ | |
10477 | }; | |
10478 | #endif | |
10479 | ||
a361d84b KY |
10480 | /* create input playback/capture controls for the given pin */ |
10481 | static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid, | |
10482 | const char *ctlname, int idx) | |
10483 | { | |
10484 | char name[32]; | |
10485 | int err; | |
10486 | ||
10487 | sprintf(name, "%s Playback Volume", ctlname); | |
10488 | if (nid == 0x14) { | |
10489 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
10490 | HDA_COMPOSE_AMP_VAL(0x02, 3, idx, | |
10491 | HDA_OUTPUT)); | |
10492 | if (err < 0) | |
10493 | return err; | |
10494 | } else if (nid == 0x15) { | |
10495 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
10496 | HDA_COMPOSE_AMP_VAL(0x03, 3, idx, | |
10497 | HDA_OUTPUT)); | |
10498 | if (err < 0) | |
10499 | return err; | |
10500 | } else | |
10501 | return -1; | |
10502 | sprintf(name, "%s Playback Switch", ctlname); | |
10503 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | |
10504 | HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT)); | |
10505 | if (err < 0) | |
10506 | return err; | |
10507 | return 0; | |
10508 | } | |
10509 | ||
10510 | /* add playback controls from the parsed DAC table */ | |
10511 | static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec, | |
10512 | const struct auto_pin_cfg *cfg) | |
10513 | { | |
10514 | hda_nid_t nid; | |
10515 | int err; | |
10516 | ||
10517 | spec->multiout.num_dacs = 2; /* only use one dac */ | |
10518 | spec->multiout.dac_nids = spec->private_dac_nids; | |
10519 | spec->multiout.dac_nids[0] = 2; | |
10520 | spec->multiout.dac_nids[1] = 3; | |
10521 | ||
10522 | nid = cfg->line_out_pins[0]; | |
10523 | if (nid) | |
10524 | alc268_new_analog_output(spec, nid, "Front", 0); | |
10525 | ||
10526 | nid = cfg->speaker_pins[0]; | |
10527 | if (nid == 0x1d) { | |
10528 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
10529 | "Speaker Playback Volume", | |
10530 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | |
10531 | if (err < 0) | |
10532 | return err; | |
10533 | } | |
10534 | nid = cfg->hp_pins[0]; | |
10535 | if (nid) | |
10536 | alc268_new_analog_output(spec, nid, "Headphone", 0); | |
10537 | ||
10538 | nid = cfg->line_out_pins[1] | cfg->line_out_pins[2]; | |
10539 | if (nid == 0x16) { | |
10540 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
10541 | "Mono Playback Switch", | |
10542 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT)); | |
10543 | if (err < 0) | |
10544 | return err; | |
10545 | } | |
10546 | return 0; | |
10547 | } | |
10548 | ||
10549 | /* create playback/capture controls for input pins */ | |
10550 | static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec, | |
10551 | const struct auto_pin_cfg *cfg) | |
10552 | { | |
10553 | struct hda_input_mux *imux = &spec->private_imux; | |
10554 | int i, idx1; | |
10555 | ||
10556 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
10557 | switch(cfg->input_pins[i]) { | |
10558 | case 0x18: | |
10559 | idx1 = 0; /* Mic 1 */ | |
10560 | break; | |
10561 | case 0x19: | |
10562 | idx1 = 1; /* Mic 2 */ | |
10563 | break; | |
10564 | case 0x1a: | |
10565 | idx1 = 2; /* Line In */ | |
10566 | break; | |
10567 | case 0x1c: | |
10568 | idx1 = 3; /* CD */ | |
10569 | break; | |
7194cae6 TI |
10570 | case 0x12: |
10571 | case 0x13: | |
10572 | idx1 = 6; /* digital mics */ | |
10573 | break; | |
a361d84b KY |
10574 | default: |
10575 | continue; | |
10576 | } | |
10577 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; | |
10578 | imux->items[imux->num_items].index = idx1; | |
10579 | imux->num_items++; | |
10580 | } | |
10581 | return 0; | |
10582 | } | |
10583 | ||
10584 | static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec) | |
10585 | { | |
10586 | struct alc_spec *spec = codec->spec; | |
10587 | hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0]; | |
10588 | hda_nid_t hp_nid = spec->autocfg.hp_pins[0]; | |
10589 | hda_nid_t line_nid = spec->autocfg.line_out_pins[0]; | |
10590 | unsigned int dac_vol1, dac_vol2; | |
10591 | ||
10592 | if (speaker_nid) { | |
10593 | snd_hda_codec_write(codec, speaker_nid, 0, | |
10594 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | |
10595 | snd_hda_codec_write(codec, 0x0f, 0, | |
10596 | AC_VERB_SET_AMP_GAIN_MUTE, | |
10597 | AMP_IN_UNMUTE(1)); | |
10598 | snd_hda_codec_write(codec, 0x10, 0, | |
10599 | AC_VERB_SET_AMP_GAIN_MUTE, | |
10600 | AMP_IN_UNMUTE(1)); | |
10601 | } else { | |
10602 | snd_hda_codec_write(codec, 0x0f, 0, | |
10603 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)); | |
10604 | snd_hda_codec_write(codec, 0x10, 0, | |
10605 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)); | |
10606 | } | |
10607 | ||
10608 | dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */ | |
10609 | if (line_nid == 0x14) | |
10610 | dac_vol2 = AMP_OUT_ZERO; | |
10611 | else if (line_nid == 0x15) | |
10612 | dac_vol1 = AMP_OUT_ZERO; | |
10613 | if (hp_nid == 0x14) | |
10614 | dac_vol2 = AMP_OUT_ZERO; | |
10615 | else if (hp_nid == 0x15) | |
10616 | dac_vol1 = AMP_OUT_ZERO; | |
10617 | if (line_nid != 0x16 || hp_nid != 0x16 || | |
10618 | spec->autocfg.line_out_pins[1] != 0x16 || | |
10619 | spec->autocfg.line_out_pins[2] != 0x16) | |
10620 | dac_vol1 = dac_vol2 = AMP_OUT_ZERO; | |
10621 | ||
10622 | snd_hda_codec_write(codec, 0x02, 0, | |
10623 | AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1); | |
10624 | snd_hda_codec_write(codec, 0x03, 0, | |
10625 | AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2); | |
10626 | } | |
10627 | ||
10628 | /* pcm configuration: identiacal with ALC880 */ | |
10629 | #define alc268_pcm_analog_playback alc880_pcm_analog_playback | |
10630 | #define alc268_pcm_analog_capture alc880_pcm_analog_capture | |
6330079f | 10631 | #define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture |
a361d84b KY |
10632 | #define alc268_pcm_digital_playback alc880_pcm_digital_playback |
10633 | ||
10634 | /* | |
10635 | * BIOS auto configuration | |
10636 | */ | |
10637 | static int alc268_parse_auto_config(struct hda_codec *codec) | |
10638 | { | |
10639 | struct alc_spec *spec = codec->spec; | |
10640 | int err; | |
10641 | static hda_nid_t alc268_ignore[] = { 0 }; | |
10642 | ||
10643 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | |
10644 | alc268_ignore); | |
10645 | if (err < 0) | |
10646 | return err; | |
10647 | if (!spec->autocfg.line_outs) | |
10648 | return 0; /* can't find valid BIOS pin config */ | |
10649 | ||
10650 | err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
10651 | if (err < 0) | |
10652 | return err; | |
10653 | err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
10654 | if (err < 0) | |
10655 | return err; | |
10656 | ||
10657 | spec->multiout.max_channels = 2; | |
10658 | ||
10659 | /* digital only support output */ | |
10660 | if (spec->autocfg.dig_out_pin) | |
10661 | spec->multiout.dig_out_nid = ALC268_DIGOUT_NID; | |
10662 | ||
10663 | if (spec->kctl_alloc) | |
10664 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
10665 | ||
aef9d318 TI |
10666 | if (spec->autocfg.speaker_pins[0] != 0x1d) |
10667 | spec->mixers[spec->num_mixers++] = alc268_beep_mixer; | |
10668 | ||
a361d84b KY |
10669 | spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs; |
10670 | spec->num_mux_defs = 1; | |
10671 | spec->input_mux = &spec->private_imux; | |
10672 | ||
776e184e TI |
10673 | err = alc_auto_add_mic_boost(codec); |
10674 | if (err < 0) | |
10675 | return err; | |
10676 | ||
a361d84b KY |
10677 | return 1; |
10678 | } | |
10679 | ||
10680 | #define alc268_auto_init_multi_out alc882_auto_init_multi_out | |
10681 | #define alc268_auto_init_hp_out alc882_auto_init_hp_out | |
10682 | #define alc268_auto_init_analog_input alc882_auto_init_analog_input | |
10683 | ||
10684 | /* init callback for auto-configuration model -- overriding the default init */ | |
10685 | static void alc268_auto_init(struct hda_codec *codec) | |
10686 | { | |
f6c7e546 | 10687 | struct alc_spec *spec = codec->spec; |
a361d84b KY |
10688 | alc268_auto_init_multi_out(codec); |
10689 | alc268_auto_init_hp_out(codec); | |
10690 | alc268_auto_init_mono_speaker_out(codec); | |
10691 | alc268_auto_init_analog_input(codec); | |
f6c7e546 TI |
10692 | if (spec->unsol_event) |
10693 | alc_sku_automute(codec); | |
a361d84b KY |
10694 | } |
10695 | ||
10696 | /* | |
10697 | * configuration and preset | |
10698 | */ | |
10699 | static const char *alc268_models[ALC268_MODEL_LAST] = { | |
eb5a6621 | 10700 | [ALC267_QUANTA_IL1] = "quanta-il1", |
a361d84b | 10701 | [ALC268_3ST] = "3stack", |
983f8ae4 | 10702 | [ALC268_TOSHIBA] = "toshiba", |
d273809e | 10703 | [ALC268_ACER] = "acer", |
3866f0b0 | 10704 | [ALC268_DELL] = "dell", |
f12462c5 | 10705 | [ALC268_ZEPTO] = "zepto", |
86c53bd2 JW |
10706 | #ifdef CONFIG_SND_DEBUG |
10707 | [ALC268_TEST] = "test", | |
10708 | #endif | |
a361d84b KY |
10709 | [ALC268_AUTO] = "auto", |
10710 | }; | |
10711 | ||
10712 | static struct snd_pci_quirk alc268_cfg_tbl[] = { | |
a0b8f7d8 | 10713 | SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER), |
ac3e3741 | 10714 | SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER), |
dafc8357 | 10715 | SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER), |
ac3e3741 | 10716 | SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER), |
29a52c24 | 10717 | SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER), |
3866f0b0 | 10718 | SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL), |
ac3e3741 | 10719 | SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA), |
a361d84b | 10720 | SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST), |
d1a991a6 | 10721 | SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA), |
8e7f00f9 | 10722 | SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA), |
378bd6a5 | 10723 | SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA), |
b875bf3a | 10724 | SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER), |
eb5a6621 | 10725 | SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1), |
f12462c5 | 10726 | SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO), |
a361d84b KY |
10727 | {} |
10728 | }; | |
10729 | ||
10730 | static struct alc_config_preset alc268_presets[] = { | |
eb5a6621 HRK |
10731 | [ALC267_QUANTA_IL1] = { |
10732 | .mixers = { alc267_quanta_il1_mixer }, | |
10733 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, | |
10734 | alc267_quanta_il1_verbs }, | |
10735 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
10736 | .dac_nids = alc268_dac_nids, | |
10737 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
10738 | .adc_nids = alc268_adc_nids_alt, | |
10739 | .hp_nid = 0x03, | |
10740 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
10741 | .channel_mode = alc268_modes, | |
10742 | .input_mux = &alc268_capture_source, | |
10743 | .unsol_event = alc267_quanta_il1_unsol_event, | |
10744 | .init_hook = alc267_quanta_il1_automute, | |
10745 | }, | |
a361d84b | 10746 | [ALC268_3ST] = { |
aef9d318 TI |
10747 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, |
10748 | alc268_beep_mixer }, | |
a361d84b KY |
10749 | .init_verbs = { alc268_base_init_verbs }, |
10750 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
10751 | .dac_nids = alc268_dac_nids, | |
10752 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
10753 | .adc_nids = alc268_adc_nids_alt, | |
e1406348 | 10754 | .capsrc_nids = alc268_capsrc_nids, |
a361d84b KY |
10755 | .hp_nid = 0x03, |
10756 | .dig_out_nid = ALC268_DIGOUT_NID, | |
10757 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
10758 | .channel_mode = alc268_modes, | |
10759 | .input_mux = &alc268_capture_source, | |
10760 | }, | |
d1a991a6 | 10761 | [ALC268_TOSHIBA] = { |
aef9d318 TI |
10762 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, |
10763 | alc268_beep_mixer }, | |
d273809e TI |
10764 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
10765 | alc268_toshiba_verbs }, | |
d1a991a6 KY |
10766 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), |
10767 | .dac_nids = alc268_dac_nids, | |
10768 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
10769 | .adc_nids = alc268_adc_nids_alt, | |
e1406348 | 10770 | .capsrc_nids = alc268_capsrc_nids, |
d1a991a6 KY |
10771 | .hp_nid = 0x03, |
10772 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
10773 | .channel_mode = alc268_modes, | |
10774 | .input_mux = &alc268_capture_source, | |
d273809e TI |
10775 | .unsol_event = alc268_toshiba_unsol_event, |
10776 | .init_hook = alc268_toshiba_automute, | |
10777 | }, | |
10778 | [ALC268_ACER] = { | |
aef9d318 TI |
10779 | .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer, |
10780 | alc268_beep_mixer }, | |
d273809e TI |
10781 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
10782 | alc268_acer_verbs }, | |
10783 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
10784 | .dac_nids = alc268_dac_nids, | |
10785 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
10786 | .adc_nids = alc268_adc_nids_alt, | |
e1406348 | 10787 | .capsrc_nids = alc268_capsrc_nids, |
d273809e TI |
10788 | .hp_nid = 0x02, |
10789 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
10790 | .channel_mode = alc268_modes, | |
0ccb541c | 10791 | .input_mux = &alc268_acer_capture_source, |
d273809e | 10792 | .unsol_event = alc268_acer_unsol_event, |
889c4395 | 10793 | .init_hook = alc268_acer_init_hook, |
d1a991a6 | 10794 | }, |
3866f0b0 | 10795 | [ALC268_DELL] = { |
aef9d318 | 10796 | .mixers = { alc268_dell_mixer, alc268_beep_mixer }, |
3866f0b0 TI |
10797 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
10798 | alc268_dell_verbs }, | |
10799 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
10800 | .dac_nids = alc268_dac_nids, | |
10801 | .hp_nid = 0x02, | |
10802 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
10803 | .channel_mode = alc268_modes, | |
10804 | .unsol_event = alc268_dell_unsol_event, | |
10805 | .init_hook = alc268_dell_init_hook, | |
10806 | .input_mux = &alc268_capture_source, | |
10807 | }, | |
f12462c5 | 10808 | [ALC268_ZEPTO] = { |
aef9d318 TI |
10809 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, |
10810 | alc268_beep_mixer }, | |
f12462c5 MT |
10811 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
10812 | alc268_toshiba_verbs }, | |
10813 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
10814 | .dac_nids = alc268_dac_nids, | |
10815 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
10816 | .adc_nids = alc268_adc_nids_alt, | |
e1406348 | 10817 | .capsrc_nids = alc268_capsrc_nids, |
f12462c5 MT |
10818 | .hp_nid = 0x03, |
10819 | .dig_out_nid = ALC268_DIGOUT_NID, | |
10820 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
10821 | .channel_mode = alc268_modes, | |
10822 | .input_mux = &alc268_capture_source, | |
10823 | .unsol_event = alc268_toshiba_unsol_event, | |
10824 | .init_hook = alc268_toshiba_automute | |
10825 | }, | |
86c53bd2 JW |
10826 | #ifdef CONFIG_SND_DEBUG |
10827 | [ALC268_TEST] = { | |
10828 | .mixers = { alc268_test_mixer, alc268_capture_mixer }, | |
10829 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, | |
10830 | alc268_volume_init_verbs }, | |
10831 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
10832 | .dac_nids = alc268_dac_nids, | |
10833 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
10834 | .adc_nids = alc268_adc_nids_alt, | |
e1406348 | 10835 | .capsrc_nids = alc268_capsrc_nids, |
86c53bd2 JW |
10836 | .hp_nid = 0x03, |
10837 | .dig_out_nid = ALC268_DIGOUT_NID, | |
10838 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
10839 | .channel_mode = alc268_modes, | |
10840 | .input_mux = &alc268_capture_source, | |
10841 | }, | |
10842 | #endif | |
a361d84b KY |
10843 | }; |
10844 | ||
10845 | static int patch_alc268(struct hda_codec *codec) | |
10846 | { | |
10847 | struct alc_spec *spec; | |
10848 | int board_config; | |
10849 | int err; | |
10850 | ||
10851 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); | |
10852 | if (spec == NULL) | |
10853 | return -ENOMEM; | |
10854 | ||
10855 | codec->spec = spec; | |
10856 | ||
10857 | board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST, | |
10858 | alc268_models, | |
10859 | alc268_cfg_tbl); | |
10860 | ||
10861 | if (board_config < 0 || board_config >= ALC268_MODEL_LAST) { | |
10862 | printk(KERN_INFO "hda_codec: Unknown model for ALC268, " | |
10863 | "trying auto-probe from BIOS...\n"); | |
10864 | board_config = ALC268_AUTO; | |
10865 | } | |
10866 | ||
10867 | if (board_config == ALC268_AUTO) { | |
10868 | /* automatic parse from the BIOS config */ | |
10869 | err = alc268_parse_auto_config(codec); | |
10870 | if (err < 0) { | |
10871 | alc_free(codec); | |
10872 | return err; | |
10873 | } else if (!err) { | |
10874 | printk(KERN_INFO | |
10875 | "hda_codec: Cannot set up configuration " | |
10876 | "from BIOS. Using base mode...\n"); | |
10877 | board_config = ALC268_3ST; | |
10878 | } | |
10879 | } | |
10880 | ||
10881 | if (board_config != ALC268_AUTO) | |
10882 | setup_preset(spec, &alc268_presets[board_config]); | |
10883 | ||
2f893286 KY |
10884 | if (codec->vendor_id == 0x10ec0267) { |
10885 | spec->stream_name_analog = "ALC267 Analog"; | |
10886 | spec->stream_name_digital = "ALC267 Digital"; | |
10887 | } else { | |
10888 | spec->stream_name_analog = "ALC268 Analog"; | |
10889 | spec->stream_name_digital = "ALC268 Digital"; | |
10890 | } | |
10891 | ||
a361d84b KY |
10892 | spec->stream_analog_playback = &alc268_pcm_analog_playback; |
10893 | spec->stream_analog_capture = &alc268_pcm_analog_capture; | |
6330079f | 10894 | spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture; |
a361d84b | 10895 | |
a361d84b KY |
10896 | spec->stream_digital_playback = &alc268_pcm_digital_playback; |
10897 | ||
aef9d318 TI |
10898 | if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) |
10899 | /* override the amp caps for beep generator */ | |
10900 | snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, | |
10901 | (0x0c << AC_AMPCAP_OFFSET_SHIFT) | | |
10902 | (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) | | |
10903 | (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) | | |
10904 | (0 << AC_AMPCAP_MUTE_SHIFT)); | |
10905 | ||
3866f0b0 TI |
10906 | if (!spec->adc_nids && spec->input_mux) { |
10907 | /* check whether NID 0x07 is valid */ | |
10908 | unsigned int wcap = get_wcaps(codec, 0x07); | |
85860c06 | 10909 | int i; |
3866f0b0 TI |
10910 | |
10911 | /* get type */ | |
10912 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
67ebcb03 | 10913 | if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) { |
3866f0b0 TI |
10914 | spec->adc_nids = alc268_adc_nids_alt; |
10915 | spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt); | |
10916 | spec->mixers[spec->num_mixers] = | |
a361d84b | 10917 | alc268_capture_alt_mixer; |
3866f0b0 TI |
10918 | spec->num_mixers++; |
10919 | } else { | |
10920 | spec->adc_nids = alc268_adc_nids; | |
10921 | spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids); | |
10922 | spec->mixers[spec->num_mixers] = | |
10923 | alc268_capture_mixer; | |
10924 | spec->num_mixers++; | |
a361d84b | 10925 | } |
e1406348 | 10926 | spec->capsrc_nids = alc268_capsrc_nids; |
85860c06 TI |
10927 | /* set default input source */ |
10928 | for (i = 0; i < spec->num_adc_nids; i++) | |
10929 | snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i], | |
10930 | 0, AC_VERB_SET_CONNECT_SEL, | |
10931 | spec->input_mux->items[0].index); | |
a361d84b | 10932 | } |
2134ea4f TI |
10933 | |
10934 | spec->vmaster_nid = 0x02; | |
10935 | ||
a361d84b KY |
10936 | codec->patch_ops = alc_patch_ops; |
10937 | if (board_config == ALC268_AUTO) | |
10938 | spec->init_hook = alc268_auto_init; | |
10939 | ||
10940 | return 0; | |
10941 | } | |
10942 | ||
f6a92248 KY |
10943 | /* |
10944 | * ALC269 channel source setting (2 channel) | |
10945 | */ | |
10946 | #define ALC269_DIGOUT_NID ALC880_DIGOUT_NID | |
10947 | ||
10948 | #define alc269_dac_nids alc260_dac_nids | |
10949 | ||
10950 | static hda_nid_t alc269_adc_nids[1] = { | |
10951 | /* ADC1 */ | |
f53281e6 KY |
10952 | 0x08, |
10953 | }; | |
10954 | ||
10955 | static struct hda_input_mux alc269_eeepc_dmic_capture_source = { | |
10956 | .num_items = 2, | |
10957 | .items = { | |
10958 | { "i-Mic", 0x5 }, | |
10959 | { "e-Mic", 0x0 }, | |
10960 | }, | |
10961 | }; | |
10962 | ||
10963 | static struct hda_input_mux alc269_eeepc_amic_capture_source = { | |
10964 | .num_items = 2, | |
10965 | .items = { | |
10966 | { "i-Mic", 0x1 }, | |
10967 | { "e-Mic", 0x0 }, | |
10968 | }, | |
f6a92248 KY |
10969 | }; |
10970 | ||
10971 | #define alc269_modes alc260_modes | |
10972 | #define alc269_capture_source alc880_lg_lw_capture_source | |
10973 | ||
10974 | static struct snd_kcontrol_new alc269_base_mixer[] = { | |
10975 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
10976 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
10977 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
10978 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
10979 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
10980 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
10981 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
10982 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
10983 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
10984 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
10985 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
10986 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | |
10987 | { } /* end */ | |
10988 | }; | |
10989 | ||
f53281e6 KY |
10990 | /* bind volumes of both NID 0x0c and 0x0d */ |
10991 | static struct hda_bind_ctls alc269_epc_bind_vol = { | |
10992 | .ops = &snd_hda_bind_vol, | |
10993 | .values = { | |
10994 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), | |
10995 | HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT), | |
10996 | 0 | |
10997 | }, | |
10998 | }; | |
10999 | ||
11000 | static struct snd_kcontrol_new alc269_eeepc_mixer[] = { | |
11001 | HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
11002 | HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol), | |
11003 | HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
11004 | { } /* end */ | |
11005 | }; | |
11006 | ||
f6a92248 KY |
11007 | /* capture mixer elements */ |
11008 | static struct snd_kcontrol_new alc269_capture_mixer[] = { | |
f53281e6 KY |
11009 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
11010 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
f6a92248 KY |
11011 | { |
11012 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11013 | /* The multiple "Capture Source" controls confuse alsamixer | |
11014 | * So call somewhat different.. | |
f6a92248 KY |
11015 | */ |
11016 | /* .name = "Capture Source", */ | |
11017 | .name = "Input Source", | |
11018 | .count = 1, | |
11019 | .info = alc_mux_enum_info, | |
11020 | .get = alc_mux_enum_get, | |
11021 | .put = alc_mux_enum_put, | |
11022 | }, | |
11023 | { } /* end */ | |
11024 | }; | |
11025 | ||
f53281e6 KY |
11026 | /* capture mixer elements */ |
11027 | static struct snd_kcontrol_new alc269_epc_capture_mixer[] = { | |
11028 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
11029 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
11030 | { } /* end */ | |
11031 | }; | |
11032 | ||
f6a92248 KY |
11033 | /* |
11034 | * generic initialization of ADC, input mixers and output mixers | |
11035 | */ | |
11036 | static struct hda_verb alc269_init_verbs[] = { | |
11037 | /* | |
11038 | * Unmute ADC0 and set the default input to mic-in | |
11039 | */ | |
f53281e6 | 11040 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
f6a92248 KY |
11041 | |
11042 | /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the | |
11043 | * analog-loopback mixer widget | |
11044 | * Note: PASD motherboards uses the Line In 2 as the input for | |
11045 | * front panel mic (mic 2) | |
11046 | */ | |
11047 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
11048 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
11049 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
11050 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
11051 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
11052 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
11053 | ||
11054 | /* | |
11055 | * Set up output mixers (0x0c - 0x0e) | |
11056 | */ | |
11057 | /* set vol=0 to output mixers */ | |
11058 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
11059 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
11060 | ||
11061 | /* set up input amps for analog loopback */ | |
11062 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
11063 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11064 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11065 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11066 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11067 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11068 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11069 | ||
11070 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
11071 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
11072 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
11073 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
11074 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
11075 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
11076 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
11077 | ||
11078 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11079 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11080 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11081 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11082 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11083 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11084 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11085 | ||
11086 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
11087 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
11088 | ||
11089 | /* FIXME: use matrix-type input source selection */ | |
11090 | /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */ | |
11091 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
11092 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11093 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
11094 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
11095 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
11096 | ||
11097 | /* set EAPD */ | |
11098 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
11099 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
11100 | { } | |
11101 | }; | |
11102 | ||
f53281e6 KY |
11103 | static struct hda_verb alc269_eeepc_dmic_init_verbs[] = { |
11104 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
11105 | {0x23, AC_VERB_SET_CONNECT_SEL, 0x05}, | |
11106 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 }, | |
11107 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))}, | |
11108 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
11109 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
11110 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
11111 | {} | |
11112 | }; | |
11113 | ||
11114 | static struct hda_verb alc269_eeepc_amic_init_verbs[] = { | |
11115 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
11116 | {0x23, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
11117 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 }, | |
11118 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))}, | |
11119 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
11120 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
11121 | {} | |
11122 | }; | |
11123 | ||
11124 | /* toggle speaker-output according to the hp-jack state */ | |
11125 | static void alc269_speaker_automute(struct hda_codec *codec) | |
11126 | { | |
11127 | unsigned int present; | |
11128 | unsigned int bits; | |
11129 | ||
11130 | present = snd_hda_codec_read(codec, 0x15, 0, | |
11131 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
11132 | bits = present ? AMP_IN_MUTE(0) : 0; | |
11133 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
11134 | AMP_IN_MUTE(0), bits); | |
11135 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
11136 | AMP_IN_MUTE(0), bits); | |
11137 | } | |
11138 | ||
11139 | static void alc269_eeepc_dmic_automute(struct hda_codec *codec) | |
11140 | { | |
11141 | unsigned int present; | |
11142 | ||
11143 | present = snd_hda_codec_read(codec, 0x18, 0, AC_VERB_GET_PIN_SENSE, 0) | |
11144 | & AC_PINSENSE_PRESENCE; | |
11145 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL, | |
11146 | present ? 0 : 5); | |
11147 | } | |
11148 | ||
11149 | static void alc269_eeepc_amic_automute(struct hda_codec *codec) | |
11150 | { | |
11151 | unsigned int present; | |
11152 | ||
11153 | present = snd_hda_codec_read(codec, 0x18, 0, AC_VERB_GET_PIN_SENSE, 0) | |
11154 | & AC_PINSENSE_PRESENCE; | |
11155 | snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
11156 | present ? AMP_IN_UNMUTE(0) : AMP_IN_MUTE(0)); | |
11157 | snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
11158 | present ? AMP_IN_MUTE(1) : AMP_IN_UNMUTE(1)); | |
11159 | } | |
11160 | ||
11161 | /* unsolicited event for HP jack sensing */ | |
11162 | static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec, | |
11163 | unsigned int res) | |
11164 | { | |
11165 | if ((res >> 26) == ALC880_HP_EVENT) | |
11166 | alc269_speaker_automute(codec); | |
11167 | ||
11168 | if ((res >> 26) == ALC880_MIC_EVENT) | |
11169 | alc269_eeepc_dmic_automute(codec); | |
11170 | } | |
11171 | ||
11172 | static void alc269_eeepc_dmic_inithook(struct hda_codec *codec) | |
11173 | { | |
11174 | alc269_speaker_automute(codec); | |
11175 | alc269_eeepc_dmic_automute(codec); | |
11176 | } | |
11177 | ||
11178 | /* unsolicited event for HP jack sensing */ | |
11179 | static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec, | |
11180 | unsigned int res) | |
11181 | { | |
11182 | if ((res >> 26) == ALC880_HP_EVENT) | |
11183 | alc269_speaker_automute(codec); | |
11184 | ||
11185 | if ((res >> 26) == ALC880_MIC_EVENT) | |
11186 | alc269_eeepc_amic_automute(codec); | |
11187 | } | |
11188 | ||
11189 | static void alc269_eeepc_amic_inithook(struct hda_codec *codec) | |
11190 | { | |
11191 | alc269_speaker_automute(codec); | |
11192 | alc269_eeepc_amic_automute(codec); | |
11193 | } | |
11194 | ||
f6a92248 KY |
11195 | /* add playback controls from the parsed DAC table */ |
11196 | static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec, | |
11197 | const struct auto_pin_cfg *cfg) | |
11198 | { | |
11199 | hda_nid_t nid; | |
11200 | int err; | |
11201 | ||
11202 | spec->multiout.num_dacs = 1; /* only use one dac */ | |
11203 | spec->multiout.dac_nids = spec->private_dac_nids; | |
11204 | spec->multiout.dac_nids[0] = 2; | |
11205 | ||
11206 | nid = cfg->line_out_pins[0]; | |
11207 | if (nid) { | |
11208 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
11209 | "Front Playback Volume", | |
11210 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT)); | |
11211 | if (err < 0) | |
11212 | return err; | |
11213 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
11214 | "Front Playback Switch", | |
11215 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
11216 | if (err < 0) | |
11217 | return err; | |
11218 | } | |
11219 | ||
11220 | nid = cfg->speaker_pins[0]; | |
11221 | if (nid) { | |
11222 | if (!cfg->line_out_pins[0]) { | |
11223 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
11224 | "Speaker Playback Volume", | |
11225 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, | |
11226 | HDA_OUTPUT)); | |
11227 | if (err < 0) | |
11228 | return err; | |
11229 | } | |
11230 | if (nid == 0x16) { | |
11231 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
11232 | "Speaker Playback Switch", | |
11233 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
11234 | HDA_OUTPUT)); | |
11235 | if (err < 0) | |
11236 | return err; | |
11237 | } else { | |
11238 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
11239 | "Speaker Playback Switch", | |
11240 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
11241 | HDA_OUTPUT)); | |
11242 | if (err < 0) | |
11243 | return err; | |
11244 | } | |
11245 | } | |
11246 | nid = cfg->hp_pins[0]; | |
11247 | if (nid) { | |
11248 | /* spec->multiout.hp_nid = 2; */ | |
11249 | if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) { | |
11250 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
11251 | "Headphone Playback Volume", | |
11252 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, | |
11253 | HDA_OUTPUT)); | |
11254 | if (err < 0) | |
11255 | return err; | |
11256 | } | |
11257 | if (nid == 0x16) { | |
11258 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
11259 | "Headphone Playback Switch", | |
11260 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
11261 | HDA_OUTPUT)); | |
11262 | if (err < 0) | |
11263 | return err; | |
11264 | } else { | |
11265 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
11266 | "Headphone Playback Switch", | |
11267 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
11268 | HDA_OUTPUT)); | |
11269 | if (err < 0) | |
11270 | return err; | |
11271 | } | |
11272 | } | |
11273 | return 0; | |
11274 | } | |
11275 | ||
11276 | #define alc269_auto_create_analog_input_ctls \ | |
11277 | alc880_auto_create_analog_input_ctls | |
11278 | ||
11279 | #ifdef CONFIG_SND_HDA_POWER_SAVE | |
11280 | #define alc269_loopbacks alc880_loopbacks | |
11281 | #endif | |
11282 | ||
11283 | /* pcm configuration: identiacal with ALC880 */ | |
11284 | #define alc269_pcm_analog_playback alc880_pcm_analog_playback | |
11285 | #define alc269_pcm_analog_capture alc880_pcm_analog_capture | |
11286 | #define alc269_pcm_digital_playback alc880_pcm_digital_playback | |
11287 | #define alc269_pcm_digital_capture alc880_pcm_digital_capture | |
11288 | ||
11289 | /* | |
11290 | * BIOS auto configuration | |
11291 | */ | |
11292 | static int alc269_parse_auto_config(struct hda_codec *codec) | |
11293 | { | |
11294 | struct alc_spec *spec = codec->spec; | |
11295 | int err; | |
11296 | static hda_nid_t alc269_ignore[] = { 0x1d, 0 }; | |
11297 | ||
11298 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | |
11299 | alc269_ignore); | |
11300 | if (err < 0) | |
11301 | return err; | |
11302 | ||
11303 | err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
11304 | if (err < 0) | |
11305 | return err; | |
11306 | err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
11307 | if (err < 0) | |
11308 | return err; | |
11309 | ||
11310 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
11311 | ||
11312 | if (spec->autocfg.dig_out_pin) | |
11313 | spec->multiout.dig_out_nid = ALC269_DIGOUT_NID; | |
11314 | ||
11315 | if (spec->kctl_alloc) | |
11316 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
11317 | ||
11318 | spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs; | |
11319 | spec->num_mux_defs = 1; | |
11320 | spec->input_mux = &spec->private_imux; | |
11321 | ||
11322 | err = alc_auto_add_mic_boost(codec); | |
11323 | if (err < 0) | |
11324 | return err; | |
11325 | ||
f53281e6 KY |
11326 | spec->mixers[spec->num_mixers] = alc269_capture_mixer; |
11327 | spec->num_mixers++; | |
11328 | ||
f6a92248 KY |
11329 | return 1; |
11330 | } | |
11331 | ||
11332 | #define alc269_auto_init_multi_out alc882_auto_init_multi_out | |
11333 | #define alc269_auto_init_hp_out alc882_auto_init_hp_out | |
11334 | #define alc269_auto_init_analog_input alc882_auto_init_analog_input | |
11335 | ||
11336 | ||
11337 | /* init callback for auto-configuration model -- overriding the default init */ | |
11338 | static void alc269_auto_init(struct hda_codec *codec) | |
11339 | { | |
f6c7e546 | 11340 | struct alc_spec *spec = codec->spec; |
f6a92248 KY |
11341 | alc269_auto_init_multi_out(codec); |
11342 | alc269_auto_init_hp_out(codec); | |
11343 | alc269_auto_init_analog_input(codec); | |
f6c7e546 TI |
11344 | if (spec->unsol_event) |
11345 | alc_sku_automute(codec); | |
f6a92248 KY |
11346 | } |
11347 | ||
11348 | /* | |
11349 | * configuration and preset | |
11350 | */ | |
11351 | static const char *alc269_models[ALC269_MODEL_LAST] = { | |
11352 | [ALC269_BASIC] = "basic", | |
11353 | }; | |
11354 | ||
11355 | static struct snd_pci_quirk alc269_cfg_tbl[] = { | |
f53281e6 KY |
11356 | SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", |
11357 | ALC269_ASUS_EEEPC_P703), | |
11358 | SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901", | |
11359 | ALC269_ASUS_EEEPC_P901), | |
f6a92248 KY |
11360 | {} |
11361 | }; | |
11362 | ||
11363 | static struct alc_config_preset alc269_presets[] = { | |
11364 | [ALC269_BASIC] = { | |
f53281e6 | 11365 | .mixers = { alc269_base_mixer, alc269_capture_mixer }, |
f6a92248 KY |
11366 | .init_verbs = { alc269_init_verbs }, |
11367 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | |
11368 | .dac_nids = alc269_dac_nids, | |
11369 | .hp_nid = 0x03, | |
11370 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | |
11371 | .channel_mode = alc269_modes, | |
11372 | .input_mux = &alc269_capture_source, | |
11373 | }, | |
f53281e6 KY |
11374 | [ALC269_ASUS_EEEPC_P703] = { |
11375 | .mixers = { alc269_eeepc_mixer, alc269_epc_capture_mixer }, | |
11376 | .init_verbs = { alc269_init_verbs, | |
11377 | alc269_eeepc_amic_init_verbs }, | |
11378 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | |
11379 | .dac_nids = alc269_dac_nids, | |
11380 | .hp_nid = 0x03, | |
11381 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | |
11382 | .channel_mode = alc269_modes, | |
11383 | .input_mux = &alc269_eeepc_amic_capture_source, | |
11384 | .unsol_event = alc269_eeepc_amic_unsol_event, | |
11385 | .init_hook = alc269_eeepc_amic_inithook, | |
11386 | }, | |
11387 | [ALC269_ASUS_EEEPC_P901] = { | |
11388 | .mixers = { alc269_eeepc_mixer, alc269_epc_capture_mixer}, | |
11389 | .init_verbs = { alc269_init_verbs, | |
11390 | alc269_eeepc_dmic_init_verbs }, | |
11391 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | |
11392 | .dac_nids = alc269_dac_nids, | |
11393 | .hp_nid = 0x03, | |
11394 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | |
11395 | .channel_mode = alc269_modes, | |
11396 | .input_mux = &alc269_eeepc_dmic_capture_source, | |
11397 | .unsol_event = alc269_eeepc_dmic_unsol_event, | |
11398 | .init_hook = alc269_eeepc_dmic_inithook, | |
11399 | }, | |
f6a92248 KY |
11400 | }; |
11401 | ||
11402 | static int patch_alc269(struct hda_codec *codec) | |
11403 | { | |
11404 | struct alc_spec *spec; | |
11405 | int board_config; | |
11406 | int err; | |
11407 | ||
11408 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
11409 | if (spec == NULL) | |
11410 | return -ENOMEM; | |
11411 | ||
11412 | codec->spec = spec; | |
11413 | ||
2c3bf9ab TI |
11414 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
11415 | ||
f6a92248 KY |
11416 | board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST, |
11417 | alc269_models, | |
11418 | alc269_cfg_tbl); | |
11419 | ||
11420 | if (board_config < 0) { | |
11421 | printk(KERN_INFO "hda_codec: Unknown model for ALC269, " | |
11422 | "trying auto-probe from BIOS...\n"); | |
11423 | board_config = ALC269_AUTO; | |
11424 | } | |
11425 | ||
11426 | if (board_config == ALC269_AUTO) { | |
11427 | /* automatic parse from the BIOS config */ | |
11428 | err = alc269_parse_auto_config(codec); | |
11429 | if (err < 0) { | |
11430 | alc_free(codec); | |
11431 | return err; | |
11432 | } else if (!err) { | |
11433 | printk(KERN_INFO | |
11434 | "hda_codec: Cannot set up configuration " | |
11435 | "from BIOS. Using base mode...\n"); | |
11436 | board_config = ALC269_BASIC; | |
11437 | } | |
11438 | } | |
11439 | ||
11440 | if (board_config != ALC269_AUTO) | |
11441 | setup_preset(spec, &alc269_presets[board_config]); | |
11442 | ||
11443 | spec->stream_name_analog = "ALC269 Analog"; | |
11444 | spec->stream_analog_playback = &alc269_pcm_analog_playback; | |
11445 | spec->stream_analog_capture = &alc269_pcm_analog_capture; | |
11446 | ||
11447 | spec->stream_name_digital = "ALC269 Digital"; | |
11448 | spec->stream_digital_playback = &alc269_pcm_digital_playback; | |
11449 | spec->stream_digital_capture = &alc269_pcm_digital_capture; | |
11450 | ||
11451 | spec->adc_nids = alc269_adc_nids; | |
11452 | spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids); | |
f6a92248 KY |
11453 | |
11454 | codec->patch_ops = alc_patch_ops; | |
11455 | if (board_config == ALC269_AUTO) | |
11456 | spec->init_hook = alc269_auto_init; | |
11457 | #ifdef CONFIG_SND_HDA_POWER_SAVE | |
11458 | if (!spec->loopback.amplist) | |
11459 | spec->loopback.amplist = alc269_loopbacks; | |
11460 | #endif | |
11461 | ||
11462 | return 0; | |
11463 | } | |
11464 | ||
df694daa KY |
11465 | /* |
11466 | * ALC861 channel source setting (2/6 channel selection for 3-stack) | |
11467 | */ | |
11468 | ||
11469 | /* | |
11470 | * set the path ways for 2 channel output | |
11471 | * need to set the codec line out and mic 1 pin widgets to inputs | |
11472 | */ | |
11473 | static struct hda_verb alc861_threestack_ch2_init[] = { | |
11474 | /* set pin widget 1Ah (line in) for input */ | |
11475 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
f12ab1e0 TI |
11476 | /* set pin widget 18h (mic1/2) for input, for mic also enable |
11477 | * the vref | |
11478 | */ | |
df694daa KY |
11479 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
11480 | ||
9c7f852e TI |
11481 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, |
11482 | #if 0 | |
11483 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
11484 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/ | |
11485 | #endif | |
df694daa KY |
11486 | { } /* end */ |
11487 | }; | |
11488 | /* | |
11489 | * 6ch mode | |
11490 | * need to set the codec line out and mic 1 pin widgets to outputs | |
11491 | */ | |
11492 | static struct hda_verb alc861_threestack_ch6_init[] = { | |
11493 | /* set pin widget 1Ah (line in) for output (Back Surround)*/ | |
11494 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
11495 | /* set pin widget 18h (mic1) for output (CLFE)*/ | |
11496 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
11497 | ||
11498 | { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
9c7f852e | 11499 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa | 11500 | |
9c7f852e TI |
11501 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, |
11502 | #if 0 | |
11503 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
11504 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/ | |
11505 | #endif | |
df694daa KY |
11506 | { } /* end */ |
11507 | }; | |
11508 | ||
11509 | static struct hda_channel_mode alc861_threestack_modes[2] = { | |
11510 | { 2, alc861_threestack_ch2_init }, | |
11511 | { 6, alc861_threestack_ch6_init }, | |
11512 | }; | |
22309c3e TI |
11513 | /* Set mic1 as input and unmute the mixer */ |
11514 | static struct hda_verb alc861_uniwill_m31_ch2_init[] = { | |
11515 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
11516 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
11517 | { } /* end */ | |
11518 | }; | |
11519 | /* Set mic1 as output and mute mixer */ | |
11520 | static struct hda_verb alc861_uniwill_m31_ch4_init[] = { | |
11521 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
11522 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
11523 | { } /* end */ | |
11524 | }; | |
11525 | ||
11526 | static struct hda_channel_mode alc861_uniwill_m31_modes[2] = { | |
11527 | { 2, alc861_uniwill_m31_ch2_init }, | |
11528 | { 4, alc861_uniwill_m31_ch4_init }, | |
11529 | }; | |
df694daa | 11530 | |
7cdbff94 MD |
11531 | /* Set mic1 and line-in as input and unmute the mixer */ |
11532 | static struct hda_verb alc861_asus_ch2_init[] = { | |
11533 | /* set pin widget 1Ah (line in) for input */ | |
11534 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
f12ab1e0 TI |
11535 | /* set pin widget 18h (mic1/2) for input, for mic also enable |
11536 | * the vref | |
11537 | */ | |
7cdbff94 MD |
11538 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
11539 | ||
11540 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, | |
11541 | #if 0 | |
11542 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
11543 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/ | |
11544 | #endif | |
11545 | { } /* end */ | |
11546 | }; | |
11547 | /* Set mic1 nad line-in as output and mute mixer */ | |
11548 | static struct hda_verb alc861_asus_ch6_init[] = { | |
11549 | /* set pin widget 1Ah (line in) for output (Back Surround)*/ | |
11550 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
11551 | /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */ | |
11552 | /* set pin widget 18h (mic1) for output (CLFE)*/ | |
11553 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
11554 | /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */ | |
11555 | { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
11556 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
11557 | ||
11558 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, | |
11559 | #if 0 | |
11560 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
11561 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/ | |
11562 | #endif | |
11563 | { } /* end */ | |
11564 | }; | |
11565 | ||
11566 | static struct hda_channel_mode alc861_asus_modes[2] = { | |
11567 | { 2, alc861_asus_ch2_init }, | |
11568 | { 6, alc861_asus_ch6_init }, | |
11569 | }; | |
11570 | ||
df694daa KY |
11571 | /* patch-ALC861 */ |
11572 | ||
11573 | static struct snd_kcontrol_new alc861_base_mixer[] = { | |
11574 | /* output mixer control */ | |
11575 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
11576 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
11577 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
11578 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
11579 | HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), | |
11580 | ||
11581 | /*Input mixer control */ | |
11582 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
11583 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
11584 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
11585 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
11586 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
11587 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
11588 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
11589 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
11590 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
11591 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 11592 | |
df694daa KY |
11593 | /* Capture mixer control */ |
11594 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
11595 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
11596 | { | |
11597 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11598 | .name = "Capture Source", | |
11599 | .count = 1, | |
11600 | .info = alc_mux_enum_info, | |
11601 | .get = alc_mux_enum_get, | |
11602 | .put = alc_mux_enum_put, | |
11603 | }, | |
11604 | { } /* end */ | |
11605 | }; | |
11606 | ||
11607 | static struct snd_kcontrol_new alc861_3ST_mixer[] = { | |
11608 | /* output mixer control */ | |
11609 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
11610 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
11611 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
11612 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
11613 | /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ | |
11614 | ||
11615 | /* Input mixer control */ | |
11616 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
11617 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
11618 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
11619 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
11620 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
11621 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
11622 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
11623 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
11624 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
11625 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 11626 | |
df694daa KY |
11627 | /* Capture mixer control */ |
11628 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
11629 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
11630 | { | |
11631 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11632 | .name = "Capture Source", | |
11633 | .count = 1, | |
11634 | .info = alc_mux_enum_info, | |
11635 | .get = alc_mux_enum_get, | |
11636 | .put = alc_mux_enum_put, | |
11637 | }, | |
11638 | { | |
11639 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11640 | .name = "Channel Mode", | |
11641 | .info = alc_ch_mode_info, | |
11642 | .get = alc_ch_mode_get, | |
11643 | .put = alc_ch_mode_put, | |
11644 | .private_value = ARRAY_SIZE(alc861_threestack_modes), | |
11645 | }, | |
11646 | { } /* end */ | |
a53d1aec TD |
11647 | }; |
11648 | ||
d1d985f0 | 11649 | static struct snd_kcontrol_new alc861_toshiba_mixer[] = { |
a53d1aec TD |
11650 | /* output mixer control */ |
11651 | HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
11652 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
11653 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
11654 | ||
11655 | /*Capture mixer control */ | |
11656 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
11657 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
11658 | { | |
11659 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11660 | .name = "Capture Source", | |
11661 | .count = 1, | |
11662 | .info = alc_mux_enum_info, | |
11663 | .get = alc_mux_enum_get, | |
11664 | .put = alc_mux_enum_put, | |
11665 | }, | |
11666 | ||
11667 | { } /* end */ | |
f12ab1e0 | 11668 | }; |
a53d1aec | 11669 | |
22309c3e TI |
11670 | static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = { |
11671 | /* output mixer control */ | |
11672 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
11673 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
11674 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
11675 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
11676 | /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ | |
11677 | ||
11678 | /* Input mixer control */ | |
11679 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
11680 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
11681 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
11682 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
11683 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
11684 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
11685 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
11686 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
11687 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
11688 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 11689 | |
22309c3e TI |
11690 | /* Capture mixer control */ |
11691 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
11692 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
11693 | { | |
11694 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11695 | .name = "Capture Source", | |
11696 | .count = 1, | |
11697 | .info = alc_mux_enum_info, | |
11698 | .get = alc_mux_enum_get, | |
11699 | .put = alc_mux_enum_put, | |
11700 | }, | |
11701 | { | |
11702 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11703 | .name = "Channel Mode", | |
11704 | .info = alc_ch_mode_info, | |
11705 | .get = alc_ch_mode_get, | |
11706 | .put = alc_ch_mode_put, | |
11707 | .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes), | |
11708 | }, | |
11709 | { } /* end */ | |
f12ab1e0 | 11710 | }; |
7cdbff94 MD |
11711 | |
11712 | static struct snd_kcontrol_new alc861_asus_mixer[] = { | |
11713 | /* output mixer control */ | |
11714 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
11715 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
11716 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
11717 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
11718 | HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), | |
11719 | ||
11720 | /* Input mixer control */ | |
11721 | HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
11722 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
11723 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
11724 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
11725 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
11726 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
11727 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
11728 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
11729 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
f12ab1e0 TI |
11730 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), |
11731 | ||
7cdbff94 MD |
11732 | /* Capture mixer control */ |
11733 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
11734 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
11735 | { | |
11736 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11737 | .name = "Capture Source", | |
11738 | .count = 1, | |
11739 | .info = alc_mux_enum_info, | |
11740 | .get = alc_mux_enum_get, | |
11741 | .put = alc_mux_enum_put, | |
11742 | }, | |
11743 | { | |
11744 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11745 | .name = "Channel Mode", | |
11746 | .info = alc_ch_mode_info, | |
11747 | .get = alc_ch_mode_get, | |
11748 | .put = alc_ch_mode_put, | |
11749 | .private_value = ARRAY_SIZE(alc861_asus_modes), | |
11750 | }, | |
11751 | { } | |
56bb0cab TI |
11752 | }; |
11753 | ||
11754 | /* additional mixer */ | |
d1d985f0 | 11755 | static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = { |
56bb0cab TI |
11756 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), |
11757 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
11758 | HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT), | |
11759 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT), | |
11760 | { } | |
11761 | }; | |
7cdbff94 | 11762 | |
df694daa KY |
11763 | /* |
11764 | * generic initialization of ADC, input mixers and output mixers | |
11765 | */ | |
11766 | static struct hda_verb alc861_base_init_verbs[] = { | |
11767 | /* | |
11768 | * Unmute ADC0 and set the default input to mic-in | |
11769 | */ | |
11770 | /* port-A for surround (rear panel) */ | |
11771 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
11772 | { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
11773 | /* port-B for mic-in (rear panel) with vref */ | |
11774 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
11775 | /* port-C for line-in (rear panel) */ | |
11776 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
11777 | /* port-D for Front */ | |
11778 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
11779 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
11780 | /* port-E for HP out (front panel) */ | |
11781 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | |
11782 | /* route front PCM to HP */ | |
9dece1d7 | 11783 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa KY |
11784 | /* port-F for mic-in (front panel) with vref */ |
11785 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
11786 | /* port-G for CLFE (rear panel) */ | |
11787 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
11788 | { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
11789 | /* port-H for side (rear panel) */ | |
11790 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
11791 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
11792 | /* CD-in */ | |
11793 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
11794 | /* route front mic to ADC1*/ | |
11795 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
11796 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11797 | ||
11798 | /* Unmute DAC0~3 & spdif out*/ | |
11799 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11800 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11801 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11802 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11803 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11804 | ||
11805 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
11806 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11807 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11808 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11809 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11810 | ||
11811 | /* Unmute Stereo Mixer 15 */ | |
11812 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11813 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11814 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 11815 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
df694daa KY |
11816 | |
11817 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11818 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11819 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11820 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11821 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11822 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11823 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11824 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
11825 | /* hp used DAC 3 (Front) */ |
11826 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
11827 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
11828 | ||
11829 | { } | |
11830 | }; | |
11831 | ||
11832 | static struct hda_verb alc861_threestack_init_verbs[] = { | |
11833 | /* | |
11834 | * Unmute ADC0 and set the default input to mic-in | |
11835 | */ | |
11836 | /* port-A for surround (rear panel) */ | |
11837 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
11838 | /* port-B for mic-in (rear panel) with vref */ | |
11839 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
11840 | /* port-C for line-in (rear panel) */ | |
11841 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
11842 | /* port-D for Front */ | |
11843 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
11844 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
11845 | /* port-E for HP out (front panel) */ | |
11846 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | |
11847 | /* route front PCM to HP */ | |
9dece1d7 | 11848 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa KY |
11849 | /* port-F for mic-in (front panel) with vref */ |
11850 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
11851 | /* port-G for CLFE (rear panel) */ | |
11852 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
11853 | /* port-H for side (rear panel) */ | |
11854 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
11855 | /* CD-in */ | |
11856 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
11857 | /* route front mic to ADC1*/ | |
11858 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
11859 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11860 | /* Unmute DAC0~3 & spdif out*/ | |
11861 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11862 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11863 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11864 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11865 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11866 | ||
11867 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
11868 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11869 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11870 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11871 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11872 | ||
11873 | /* Unmute Stereo Mixer 15 */ | |
11874 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11875 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11876 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 11877 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
df694daa KY |
11878 | |
11879 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11880 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11881 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11882 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11883 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11884 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11885 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11886 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
11887 | /* hp used DAC 3 (Front) */ |
11888 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
11889 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
11890 | { } | |
11891 | }; | |
22309c3e TI |
11892 | |
11893 | static struct hda_verb alc861_uniwill_m31_init_verbs[] = { | |
11894 | /* | |
11895 | * Unmute ADC0 and set the default input to mic-in | |
11896 | */ | |
11897 | /* port-A for surround (rear panel) */ | |
11898 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
11899 | /* port-B for mic-in (rear panel) with vref */ | |
11900 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
11901 | /* port-C for line-in (rear panel) */ | |
11902 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
11903 | /* port-D for Front */ | |
11904 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
11905 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
11906 | /* port-E for HP out (front panel) */ | |
f12ab1e0 TI |
11907 | /* this has to be set to VREF80 */ |
11908 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
22309c3e | 11909 | /* route front PCM to HP */ |
9dece1d7 | 11910 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
22309c3e TI |
11911 | /* port-F for mic-in (front panel) with vref */ |
11912 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
11913 | /* port-G for CLFE (rear panel) */ | |
11914 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
11915 | /* port-H for side (rear panel) */ | |
11916 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
11917 | /* CD-in */ | |
11918 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
11919 | /* route front mic to ADC1*/ | |
11920 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
11921 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11922 | /* Unmute DAC0~3 & spdif out*/ | |
11923 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11924 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11925 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11926 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11927 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11928 | ||
11929 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
11930 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11931 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11932 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11933 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11934 | ||
11935 | /* Unmute Stereo Mixer 15 */ | |
11936 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11937 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11938 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 11939 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
22309c3e TI |
11940 | |
11941 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11942 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11943 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11944 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11945 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11946 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11947 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11948 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
11949 | /* hp used DAC 3 (Front) */ |
11950 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
22309c3e TI |
11951 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
11952 | { } | |
11953 | }; | |
11954 | ||
7cdbff94 MD |
11955 | static struct hda_verb alc861_asus_init_verbs[] = { |
11956 | /* | |
11957 | * Unmute ADC0 and set the default input to mic-in | |
11958 | */ | |
f12ab1e0 TI |
11959 | /* port-A for surround (rear panel) |
11960 | * according to codec#0 this is the HP jack | |
11961 | */ | |
7cdbff94 MD |
11962 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */ |
11963 | /* route front PCM to HP */ | |
11964 | { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
11965 | /* port-B for mic-in (rear panel) with vref */ | |
11966 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
11967 | /* port-C for line-in (rear panel) */ | |
11968 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
11969 | /* port-D for Front */ | |
11970 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
11971 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
11972 | /* port-E for HP out (front panel) */ | |
f12ab1e0 TI |
11973 | /* this has to be set to VREF80 */ |
11974 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
7cdbff94 | 11975 | /* route front PCM to HP */ |
9dece1d7 | 11976 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
7cdbff94 MD |
11977 | /* port-F for mic-in (front panel) with vref */ |
11978 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
11979 | /* port-G for CLFE (rear panel) */ | |
11980 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
11981 | /* port-H for side (rear panel) */ | |
11982 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
11983 | /* CD-in */ | |
11984 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
11985 | /* route front mic to ADC1*/ | |
11986 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
11987 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11988 | /* Unmute DAC0~3 & spdif out*/ | |
11989 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11990 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11991 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11992 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11993 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11994 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
11995 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11996 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11997 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11998 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11999 | ||
12000 | /* Unmute Stereo Mixer 15 */ | |
12001 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12002 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12003 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 12004 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
7cdbff94 MD |
12005 | |
12006 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12007 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12008 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12009 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12010 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12011 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12012 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12013 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
12014 | /* hp used DAC 3 (Front) */ |
12015 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
7cdbff94 MD |
12016 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
12017 | { } | |
12018 | }; | |
12019 | ||
56bb0cab TI |
12020 | /* additional init verbs for ASUS laptops */ |
12021 | static struct hda_verb alc861_asus_laptop_init_verbs[] = { | |
12022 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */ | |
12023 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */ | |
12024 | { } | |
12025 | }; | |
7cdbff94 | 12026 | |
df694daa KY |
12027 | /* |
12028 | * generic initialization of ADC, input mixers and output mixers | |
12029 | */ | |
12030 | static struct hda_verb alc861_auto_init_verbs[] = { | |
12031 | /* | |
12032 | * Unmute ADC0 and set the default input to mic-in | |
12033 | */ | |
f12ab1e0 | 12034 | /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */ |
df694daa KY |
12035 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
12036 | ||
12037 | /* Unmute DAC0~3 & spdif out*/ | |
12038 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12039 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12040 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12041 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12042 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12043 | ||
12044 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
12045 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12046 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12047 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12048 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12049 | ||
12050 | /* Unmute Stereo Mixer 15 */ | |
12051 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12052 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12053 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
12054 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, | |
12055 | ||
12056 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12057 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12058 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12059 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12060 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12061 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12062 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12063 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12064 | ||
12065 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
12066 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
f12ab1e0 TI |
12067 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
12068 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
12069 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
12070 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
f12ab1e0 TI |
12071 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
12072 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa | 12073 | |
f12ab1e0 | 12074 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */ |
df694daa KY |
12075 | |
12076 | { } | |
12077 | }; | |
12078 | ||
a53d1aec TD |
12079 | static struct hda_verb alc861_toshiba_init_verbs[] = { |
12080 | {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
f12ab1e0 | 12081 | |
a53d1aec TD |
12082 | { } |
12083 | }; | |
12084 | ||
12085 | /* toggle speaker-output according to the hp-jack state */ | |
12086 | static void alc861_toshiba_automute(struct hda_codec *codec) | |
12087 | { | |
12088 | unsigned int present; | |
12089 | ||
12090 | present = snd_hda_codec_read(codec, 0x0f, 0, | |
12091 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
12092 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0, |
12093 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
12094 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3, | |
12095 | HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE); | |
a53d1aec TD |
12096 | } |
12097 | ||
12098 | static void alc861_toshiba_unsol_event(struct hda_codec *codec, | |
12099 | unsigned int res) | |
12100 | { | |
a53d1aec TD |
12101 | if ((res >> 26) == ALC880_HP_EVENT) |
12102 | alc861_toshiba_automute(codec); | |
12103 | } | |
12104 | ||
df694daa KY |
12105 | /* pcm configuration: identiacal with ALC880 */ |
12106 | #define alc861_pcm_analog_playback alc880_pcm_analog_playback | |
12107 | #define alc861_pcm_analog_capture alc880_pcm_analog_capture | |
12108 | #define alc861_pcm_digital_playback alc880_pcm_digital_playback | |
12109 | #define alc861_pcm_digital_capture alc880_pcm_digital_capture | |
12110 | ||
12111 | ||
12112 | #define ALC861_DIGOUT_NID 0x07 | |
12113 | ||
12114 | static struct hda_channel_mode alc861_8ch_modes[1] = { | |
12115 | { 8, NULL } | |
12116 | }; | |
12117 | ||
12118 | static hda_nid_t alc861_dac_nids[4] = { | |
12119 | /* front, surround, clfe, side */ | |
12120 | 0x03, 0x06, 0x05, 0x04 | |
12121 | }; | |
12122 | ||
9c7f852e TI |
12123 | static hda_nid_t alc660_dac_nids[3] = { |
12124 | /* front, clfe, surround */ | |
12125 | 0x03, 0x05, 0x06 | |
12126 | }; | |
12127 | ||
df694daa KY |
12128 | static hda_nid_t alc861_adc_nids[1] = { |
12129 | /* ADC0-2 */ | |
12130 | 0x08, | |
12131 | }; | |
12132 | ||
12133 | static struct hda_input_mux alc861_capture_source = { | |
12134 | .num_items = 5, | |
12135 | .items = { | |
12136 | { "Mic", 0x0 }, | |
12137 | { "Front Mic", 0x3 }, | |
12138 | { "Line", 0x1 }, | |
12139 | { "CD", 0x4 }, | |
12140 | { "Mixer", 0x5 }, | |
12141 | }, | |
12142 | }; | |
12143 | ||
12144 | /* fill in the dac_nids table from the parsed pin configuration */ | |
f12ab1e0 TI |
12145 | static int alc861_auto_fill_dac_nids(struct alc_spec *spec, |
12146 | const struct auto_pin_cfg *cfg) | |
df694daa KY |
12147 | { |
12148 | int i; | |
12149 | hda_nid_t nid; | |
12150 | ||
12151 | spec->multiout.dac_nids = spec->private_dac_nids; | |
12152 | for (i = 0; i < cfg->line_outs; i++) { | |
12153 | nid = cfg->line_out_pins[i]; | |
12154 | if (nid) { | |
12155 | if (i >= ARRAY_SIZE(alc861_dac_nids)) | |
12156 | continue; | |
12157 | spec->multiout.dac_nids[i] = alc861_dac_nids[i]; | |
12158 | } | |
12159 | } | |
12160 | spec->multiout.num_dacs = cfg->line_outs; | |
12161 | return 0; | |
12162 | } | |
12163 | ||
12164 | /* add playback controls from the parsed DAC table */ | |
12165 | static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec, | |
12166 | const struct auto_pin_cfg *cfg) | |
12167 | { | |
12168 | char name[32]; | |
f12ab1e0 TI |
12169 | static const char *chname[4] = { |
12170 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
12171 | }; | |
df694daa KY |
12172 | hda_nid_t nid; |
12173 | int i, idx, err; | |
12174 | ||
12175 | for (i = 0; i < cfg->line_outs; i++) { | |
12176 | nid = spec->multiout.dac_nids[i]; | |
f12ab1e0 | 12177 | if (!nid) |
df694daa KY |
12178 | continue; |
12179 | if (nid == 0x05) { | |
12180 | /* Center/LFE */ | |
f12ab1e0 TI |
12181 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
12182 | "Center Playback Switch", | |
12183 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, | |
12184 | HDA_OUTPUT)); | |
12185 | if (err < 0) | |
df694daa | 12186 | return err; |
f12ab1e0 TI |
12187 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
12188 | "LFE Playback Switch", | |
12189 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
12190 | HDA_OUTPUT)); | |
12191 | if (err < 0) | |
df694daa KY |
12192 | return err; |
12193 | } else { | |
f12ab1e0 TI |
12194 | for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; |
12195 | idx++) | |
df694daa KY |
12196 | if (nid == alc861_dac_nids[idx]) |
12197 | break; | |
12198 | sprintf(name, "%s Playback Switch", chname[idx]); | |
f12ab1e0 TI |
12199 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
12200 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
12201 | HDA_OUTPUT)); | |
12202 | if (err < 0) | |
df694daa KY |
12203 | return err; |
12204 | } | |
12205 | } | |
12206 | return 0; | |
12207 | } | |
12208 | ||
12209 | static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin) | |
12210 | { | |
12211 | int err; | |
12212 | hda_nid_t nid; | |
12213 | ||
f12ab1e0 | 12214 | if (!pin) |
df694daa KY |
12215 | return 0; |
12216 | ||
12217 | if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) { | |
12218 | nid = 0x03; | |
f12ab1e0 TI |
12219 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
12220 | "Headphone Playback Switch", | |
12221 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
12222 | if (err < 0) | |
df694daa KY |
12223 | return err; |
12224 | spec->multiout.hp_nid = nid; | |
12225 | } | |
12226 | return 0; | |
12227 | } | |
12228 | ||
12229 | /* create playback/capture controls for input pins */ | |
f12ab1e0 TI |
12230 | static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, |
12231 | const struct auto_pin_cfg *cfg) | |
df694daa | 12232 | { |
df694daa KY |
12233 | struct hda_input_mux *imux = &spec->private_imux; |
12234 | int i, err, idx, idx1; | |
12235 | ||
12236 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
f12ab1e0 | 12237 | switch (cfg->input_pins[i]) { |
df694daa KY |
12238 | case 0x0c: |
12239 | idx1 = 1; | |
f12ab1e0 | 12240 | idx = 2; /* Line In */ |
df694daa KY |
12241 | break; |
12242 | case 0x0f: | |
12243 | idx1 = 2; | |
f12ab1e0 | 12244 | idx = 2; /* Line In */ |
df694daa KY |
12245 | break; |
12246 | case 0x0d: | |
12247 | idx1 = 0; | |
f12ab1e0 | 12248 | idx = 1; /* Mic In */ |
df694daa | 12249 | break; |
f12ab1e0 | 12250 | case 0x10: |
df694daa | 12251 | idx1 = 3; |
f12ab1e0 | 12252 | idx = 1; /* Mic In */ |
df694daa KY |
12253 | break; |
12254 | case 0x11: | |
12255 | idx1 = 4; | |
f12ab1e0 | 12256 | idx = 0; /* CD */ |
df694daa KY |
12257 | break; |
12258 | default: | |
12259 | continue; | |
12260 | } | |
12261 | ||
4a471b7d TI |
12262 | err = new_analog_input(spec, cfg->input_pins[i], |
12263 | auto_pin_cfg_labels[i], idx, 0x15); | |
df694daa KY |
12264 | if (err < 0) |
12265 | return err; | |
12266 | ||
4a471b7d | 12267 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
df694daa | 12268 | imux->items[imux->num_items].index = idx1; |
f12ab1e0 | 12269 | imux->num_items++; |
df694daa KY |
12270 | } |
12271 | return 0; | |
12272 | } | |
12273 | ||
12274 | static struct snd_kcontrol_new alc861_capture_mixer[] = { | |
12275 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
12276 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
12277 | ||
12278 | { | |
12279 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
12280 | /* The multiple "Capture Source" controls confuse alsamixer | |
12281 | * So call somewhat different.. | |
df694daa KY |
12282 | */ |
12283 | /* .name = "Capture Source", */ | |
12284 | .name = "Input Source", | |
12285 | .count = 1, | |
12286 | .info = alc_mux_enum_info, | |
12287 | .get = alc_mux_enum_get, | |
12288 | .put = alc_mux_enum_put, | |
12289 | }, | |
12290 | { } /* end */ | |
12291 | }; | |
12292 | ||
f12ab1e0 TI |
12293 | static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, |
12294 | hda_nid_t nid, | |
df694daa KY |
12295 | int pin_type, int dac_idx) |
12296 | { | |
564c5bea JL |
12297 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
12298 | pin_type); | |
12299 | snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
12300 | AMP_OUT_UNMUTE); | |
df694daa KY |
12301 | } |
12302 | ||
12303 | static void alc861_auto_init_multi_out(struct hda_codec *codec) | |
12304 | { | |
12305 | struct alc_spec *spec = codec->spec; | |
12306 | int i; | |
12307 | ||
bc9f98a9 | 12308 | alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b); |
df694daa KY |
12309 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
12310 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 12311 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
df694daa | 12312 | if (nid) |
baba8ee9 | 12313 | alc861_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 12314 | spec->multiout.dac_nids[i]); |
df694daa KY |
12315 | } |
12316 | } | |
12317 | ||
12318 | static void alc861_auto_init_hp_out(struct hda_codec *codec) | |
12319 | { | |
12320 | struct alc_spec *spec = codec->spec; | |
12321 | hda_nid_t pin; | |
12322 | ||
eb06ed8f | 12323 | pin = spec->autocfg.hp_pins[0]; |
df694daa | 12324 | if (pin) /* connect to front */ |
f12ab1e0 TI |
12325 | alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, |
12326 | spec->multiout.dac_nids[0]); | |
f6c7e546 TI |
12327 | pin = spec->autocfg.speaker_pins[0]; |
12328 | if (pin) | |
12329 | alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
df694daa KY |
12330 | } |
12331 | ||
12332 | static void alc861_auto_init_analog_input(struct hda_codec *codec) | |
12333 | { | |
12334 | struct alc_spec *spec = codec->spec; | |
12335 | int i; | |
12336 | ||
12337 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
12338 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
f12ab1e0 TI |
12339 | if (nid >= 0x0c && nid <= 0x11) { |
12340 | snd_hda_codec_write(codec, nid, 0, | |
12341 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
12342 | i <= AUTO_PIN_FRONT_MIC ? | |
12343 | PIN_VREF80 : PIN_IN); | |
df694daa KY |
12344 | } |
12345 | } | |
12346 | } | |
12347 | ||
12348 | /* parse the BIOS configuration and set up the alc_spec */ | |
f12ab1e0 TI |
12349 | /* return 1 if successful, 0 if the proper config is not found, |
12350 | * or a negative error code | |
12351 | */ | |
df694daa KY |
12352 | static int alc861_parse_auto_config(struct hda_codec *codec) |
12353 | { | |
12354 | struct alc_spec *spec = codec->spec; | |
12355 | int err; | |
12356 | static hda_nid_t alc861_ignore[] = { 0x1d, 0 }; | |
12357 | ||
f12ab1e0 TI |
12358 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
12359 | alc861_ignore); | |
12360 | if (err < 0) | |
df694daa | 12361 | return err; |
f12ab1e0 | 12362 | if (!spec->autocfg.line_outs) |
df694daa KY |
12363 | return 0; /* can't find valid BIOS pin config */ |
12364 | ||
f12ab1e0 TI |
12365 | err = alc861_auto_fill_dac_nids(spec, &spec->autocfg); |
12366 | if (err < 0) | |
12367 | return err; | |
12368 | err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
12369 | if (err < 0) | |
12370 | return err; | |
12371 | err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); | |
12372 | if (err < 0) | |
12373 | return err; | |
12374 | err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
12375 | if (err < 0) | |
df694daa KY |
12376 | return err; |
12377 | ||
12378 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
12379 | ||
12380 | if (spec->autocfg.dig_out_pin) | |
12381 | spec->multiout.dig_out_nid = ALC861_DIGOUT_NID; | |
12382 | ||
12383 | if (spec->kctl_alloc) | |
12384 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
12385 | ||
12386 | spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs; | |
12387 | ||
a1e8d2da | 12388 | spec->num_mux_defs = 1; |
df694daa KY |
12389 | spec->input_mux = &spec->private_imux; |
12390 | ||
12391 | spec->adc_nids = alc861_adc_nids; | |
12392 | spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); | |
12393 | spec->mixers[spec->num_mixers] = alc861_capture_mixer; | |
12394 | spec->num_mixers++; | |
12395 | ||
12396 | return 1; | |
12397 | } | |
12398 | ||
ae6b813a TI |
12399 | /* additional initialization for auto-configuration model */ |
12400 | static void alc861_auto_init(struct hda_codec *codec) | |
df694daa | 12401 | { |
f6c7e546 | 12402 | struct alc_spec *spec = codec->spec; |
df694daa KY |
12403 | alc861_auto_init_multi_out(codec); |
12404 | alc861_auto_init_hp_out(codec); | |
12405 | alc861_auto_init_analog_input(codec); | |
f6c7e546 TI |
12406 | if (spec->unsol_event) |
12407 | alc_sku_automute(codec); | |
df694daa KY |
12408 | } |
12409 | ||
cb53c626 TI |
12410 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
12411 | static struct hda_amp_list alc861_loopbacks[] = { | |
12412 | { 0x15, HDA_INPUT, 0 }, | |
12413 | { 0x15, HDA_INPUT, 1 }, | |
12414 | { 0x15, HDA_INPUT, 2 }, | |
12415 | { 0x15, HDA_INPUT, 3 }, | |
12416 | { } /* end */ | |
12417 | }; | |
12418 | #endif | |
12419 | ||
df694daa KY |
12420 | |
12421 | /* | |
12422 | * configuration and preset | |
12423 | */ | |
f5fcc13c TI |
12424 | static const char *alc861_models[ALC861_MODEL_LAST] = { |
12425 | [ALC861_3ST] = "3stack", | |
12426 | [ALC660_3ST] = "3stack-660", | |
12427 | [ALC861_3ST_DIG] = "3stack-dig", | |
12428 | [ALC861_6ST_DIG] = "6stack-dig", | |
12429 | [ALC861_UNIWILL_M31] = "uniwill-m31", | |
12430 | [ALC861_TOSHIBA] = "toshiba", | |
12431 | [ALC861_ASUS] = "asus", | |
12432 | [ALC861_ASUS_LAPTOP] = "asus-laptop", | |
12433 | [ALC861_AUTO] = "auto", | |
12434 | }; | |
12435 | ||
12436 | static struct snd_pci_quirk alc861_cfg_tbl[] = { | |
687a47bd | 12437 | SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST), |
f5fcc13c TI |
12438 | SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP), |
12439 | SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP), | |
12440 | SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS), | |
ac3e3741 | 12441 | SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP), |
83c34218 | 12442 | SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG), |
ad5e7737 | 12443 | SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA), |
341d4eb0 TI |
12444 | /* FIXME: the entry below breaks Toshiba A100 (model=auto works!) |
12445 | * Any other models that need this preset? | |
12446 | */ | |
12447 | /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */ | |
ac3e3741 TI |
12448 | SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST), |
12449 | SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST), | |
4147dab6 | 12450 | SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31), |
ac3e3741 TI |
12451 | SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31), |
12452 | SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP), | |
12453 | /* FIXME: the below seems conflict */ | |
12454 | /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */ | |
07e038b3 | 12455 | SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST), |
f5fcc13c | 12456 | SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST), |
df694daa KY |
12457 | {} |
12458 | }; | |
12459 | ||
12460 | static struct alc_config_preset alc861_presets[] = { | |
12461 | [ALC861_3ST] = { | |
12462 | .mixers = { alc861_3ST_mixer }, | |
12463 | .init_verbs = { alc861_threestack_init_verbs }, | |
12464 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
12465 | .dac_nids = alc861_dac_nids, | |
12466 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
12467 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 12468 | .need_dac_fix = 1, |
df694daa KY |
12469 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
12470 | .adc_nids = alc861_adc_nids, | |
12471 | .input_mux = &alc861_capture_source, | |
12472 | }, | |
12473 | [ALC861_3ST_DIG] = { | |
12474 | .mixers = { alc861_base_mixer }, | |
12475 | .init_verbs = { alc861_threestack_init_verbs }, | |
12476 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
12477 | .dac_nids = alc861_dac_nids, | |
12478 | .dig_out_nid = ALC861_DIGOUT_NID, | |
12479 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
12480 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 12481 | .need_dac_fix = 1, |
df694daa KY |
12482 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
12483 | .adc_nids = alc861_adc_nids, | |
12484 | .input_mux = &alc861_capture_source, | |
12485 | }, | |
12486 | [ALC861_6ST_DIG] = { | |
12487 | .mixers = { alc861_base_mixer }, | |
12488 | .init_verbs = { alc861_base_init_verbs }, | |
12489 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
12490 | .dac_nids = alc861_dac_nids, | |
12491 | .dig_out_nid = ALC861_DIGOUT_NID, | |
12492 | .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes), | |
12493 | .channel_mode = alc861_8ch_modes, | |
12494 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
12495 | .adc_nids = alc861_adc_nids, | |
12496 | .input_mux = &alc861_capture_source, | |
12497 | }, | |
9c7f852e TI |
12498 | [ALC660_3ST] = { |
12499 | .mixers = { alc861_3ST_mixer }, | |
12500 | .init_verbs = { alc861_threestack_init_verbs }, | |
12501 | .num_dacs = ARRAY_SIZE(alc660_dac_nids), | |
12502 | .dac_nids = alc660_dac_nids, | |
12503 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
12504 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 12505 | .need_dac_fix = 1, |
9c7f852e TI |
12506 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
12507 | .adc_nids = alc861_adc_nids, | |
12508 | .input_mux = &alc861_capture_source, | |
12509 | }, | |
22309c3e TI |
12510 | [ALC861_UNIWILL_M31] = { |
12511 | .mixers = { alc861_uniwill_m31_mixer }, | |
12512 | .init_verbs = { alc861_uniwill_m31_init_verbs }, | |
12513 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
12514 | .dac_nids = alc861_dac_nids, | |
12515 | .dig_out_nid = ALC861_DIGOUT_NID, | |
12516 | .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes), | |
12517 | .channel_mode = alc861_uniwill_m31_modes, | |
12518 | .need_dac_fix = 1, | |
12519 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
12520 | .adc_nids = alc861_adc_nids, | |
12521 | .input_mux = &alc861_capture_source, | |
12522 | }, | |
a53d1aec TD |
12523 | [ALC861_TOSHIBA] = { |
12524 | .mixers = { alc861_toshiba_mixer }, | |
f12ab1e0 TI |
12525 | .init_verbs = { alc861_base_init_verbs, |
12526 | alc861_toshiba_init_verbs }, | |
a53d1aec TD |
12527 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), |
12528 | .dac_nids = alc861_dac_nids, | |
12529 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
12530 | .channel_mode = alc883_3ST_2ch_modes, | |
12531 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
12532 | .adc_nids = alc861_adc_nids, | |
12533 | .input_mux = &alc861_capture_source, | |
12534 | .unsol_event = alc861_toshiba_unsol_event, | |
12535 | .init_hook = alc861_toshiba_automute, | |
12536 | }, | |
7cdbff94 MD |
12537 | [ALC861_ASUS] = { |
12538 | .mixers = { alc861_asus_mixer }, | |
12539 | .init_verbs = { alc861_asus_init_verbs }, | |
12540 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
12541 | .dac_nids = alc861_dac_nids, | |
12542 | .dig_out_nid = ALC861_DIGOUT_NID, | |
12543 | .num_channel_mode = ARRAY_SIZE(alc861_asus_modes), | |
12544 | .channel_mode = alc861_asus_modes, | |
12545 | .need_dac_fix = 1, | |
12546 | .hp_nid = 0x06, | |
12547 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
12548 | .adc_nids = alc861_adc_nids, | |
12549 | .input_mux = &alc861_capture_source, | |
12550 | }, | |
56bb0cab TI |
12551 | [ALC861_ASUS_LAPTOP] = { |
12552 | .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer }, | |
12553 | .init_verbs = { alc861_asus_init_verbs, | |
12554 | alc861_asus_laptop_init_verbs }, | |
12555 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
12556 | .dac_nids = alc861_dac_nids, | |
12557 | .dig_out_nid = ALC861_DIGOUT_NID, | |
12558 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
12559 | .channel_mode = alc883_3ST_2ch_modes, | |
12560 | .need_dac_fix = 1, | |
12561 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
12562 | .adc_nids = alc861_adc_nids, | |
12563 | .input_mux = &alc861_capture_source, | |
12564 | }, | |
12565 | }; | |
df694daa KY |
12566 | |
12567 | ||
12568 | static int patch_alc861(struct hda_codec *codec) | |
12569 | { | |
12570 | struct alc_spec *spec; | |
12571 | int board_config; | |
12572 | int err; | |
12573 | ||
dc041e0b | 12574 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
df694daa KY |
12575 | if (spec == NULL) |
12576 | return -ENOMEM; | |
12577 | ||
f12ab1e0 | 12578 | codec->spec = spec; |
df694daa | 12579 | |
f5fcc13c TI |
12580 | board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST, |
12581 | alc861_models, | |
12582 | alc861_cfg_tbl); | |
9c7f852e | 12583 | |
f5fcc13c | 12584 | if (board_config < 0) { |
9c7f852e TI |
12585 | printk(KERN_INFO "hda_codec: Unknown model for ALC861, " |
12586 | "trying auto-probe from BIOS...\n"); | |
df694daa KY |
12587 | board_config = ALC861_AUTO; |
12588 | } | |
12589 | ||
12590 | if (board_config == ALC861_AUTO) { | |
12591 | /* automatic parse from the BIOS config */ | |
12592 | err = alc861_parse_auto_config(codec); | |
12593 | if (err < 0) { | |
12594 | alc_free(codec); | |
12595 | return err; | |
f12ab1e0 | 12596 | } else if (!err) { |
9c7f852e TI |
12597 | printk(KERN_INFO |
12598 | "hda_codec: Cannot set up configuration " | |
12599 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
12600 | board_config = ALC861_3ST_DIG; |
12601 | } | |
12602 | } | |
12603 | ||
12604 | if (board_config != ALC861_AUTO) | |
12605 | setup_preset(spec, &alc861_presets[board_config]); | |
12606 | ||
12607 | spec->stream_name_analog = "ALC861 Analog"; | |
12608 | spec->stream_analog_playback = &alc861_pcm_analog_playback; | |
12609 | spec->stream_analog_capture = &alc861_pcm_analog_capture; | |
12610 | ||
12611 | spec->stream_name_digital = "ALC861 Digital"; | |
12612 | spec->stream_digital_playback = &alc861_pcm_digital_playback; | |
12613 | spec->stream_digital_capture = &alc861_pcm_digital_capture; | |
12614 | ||
2134ea4f TI |
12615 | spec->vmaster_nid = 0x03; |
12616 | ||
df694daa KY |
12617 | codec->patch_ops = alc_patch_ops; |
12618 | if (board_config == ALC861_AUTO) | |
ae6b813a | 12619 | spec->init_hook = alc861_auto_init; |
cb53c626 TI |
12620 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
12621 | if (!spec->loopback.amplist) | |
12622 | spec->loopback.amplist = alc861_loopbacks; | |
12623 | #endif | |
df694daa | 12624 | |
1da177e4 LT |
12625 | return 0; |
12626 | } | |
12627 | ||
f32610ed JS |
12628 | /* |
12629 | * ALC861-VD support | |
12630 | * | |
12631 | * Based on ALC882 | |
12632 | * | |
12633 | * In addition, an independent DAC | |
12634 | */ | |
12635 | #define ALC861VD_DIGOUT_NID 0x06 | |
12636 | ||
12637 | static hda_nid_t alc861vd_dac_nids[4] = { | |
12638 | /* front, surr, clfe, side surr */ | |
12639 | 0x02, 0x03, 0x04, 0x05 | |
12640 | }; | |
12641 | ||
12642 | /* dac_nids for ALC660vd are in a different order - according to | |
12643 | * Realtek's driver. | |
12644 | * This should probably tesult in a different mixer for 6stack models | |
12645 | * of ALC660vd codecs, but for now there is only 3stack mixer | |
12646 | * - and it is the same as in 861vd. | |
12647 | * adc_nids in ALC660vd are (is) the same as in 861vd | |
12648 | */ | |
12649 | static hda_nid_t alc660vd_dac_nids[3] = { | |
12650 | /* front, rear, clfe, rear_surr */ | |
12651 | 0x02, 0x04, 0x03 | |
12652 | }; | |
12653 | ||
12654 | static hda_nid_t alc861vd_adc_nids[1] = { | |
12655 | /* ADC0 */ | |
12656 | 0x09, | |
12657 | }; | |
12658 | ||
e1406348 TI |
12659 | static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 }; |
12660 | ||
f32610ed JS |
12661 | /* input MUX */ |
12662 | /* FIXME: should be a matrix-type input source selection */ | |
12663 | static struct hda_input_mux alc861vd_capture_source = { | |
12664 | .num_items = 4, | |
12665 | .items = { | |
12666 | { "Mic", 0x0 }, | |
12667 | { "Front Mic", 0x1 }, | |
12668 | { "Line", 0x2 }, | |
12669 | { "CD", 0x4 }, | |
12670 | }, | |
12671 | }; | |
12672 | ||
272a527c | 12673 | static struct hda_input_mux alc861vd_dallas_capture_source = { |
b419f346 | 12674 | .num_items = 2, |
272a527c | 12675 | .items = { |
b419f346 TD |
12676 | { "Ext Mic", 0x0 }, |
12677 | { "Int Mic", 0x1 }, | |
272a527c KY |
12678 | }, |
12679 | }; | |
12680 | ||
d1a991a6 KY |
12681 | static struct hda_input_mux alc861vd_hp_capture_source = { |
12682 | .num_items = 2, | |
12683 | .items = { | |
12684 | { "Front Mic", 0x0 }, | |
12685 | { "ATAPI Mic", 0x1 }, | |
12686 | }, | |
12687 | }; | |
12688 | ||
f32610ed JS |
12689 | #define alc861vd_mux_enum_info alc_mux_enum_info |
12690 | #define alc861vd_mux_enum_get alc_mux_enum_get | |
e1406348 TI |
12691 | /* ALC861VD has the ALC882-type input selection (but has only one ADC) */ |
12692 | #define alc861vd_mux_enum_put alc882_mux_enum_put | |
f32610ed JS |
12693 | |
12694 | /* | |
12695 | * 2ch mode | |
12696 | */ | |
12697 | static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = { | |
12698 | { 2, NULL } | |
12699 | }; | |
12700 | ||
12701 | /* | |
12702 | * 6ch mode | |
12703 | */ | |
12704 | static struct hda_verb alc861vd_6stack_ch6_init[] = { | |
12705 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
12706 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
12707 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
12708 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
12709 | { } /* end */ | |
12710 | }; | |
12711 | ||
12712 | /* | |
12713 | * 8ch mode | |
12714 | */ | |
12715 | static struct hda_verb alc861vd_6stack_ch8_init[] = { | |
12716 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
12717 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
12718 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
12719 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
12720 | { } /* end */ | |
12721 | }; | |
12722 | ||
12723 | static struct hda_channel_mode alc861vd_6stack_modes[2] = { | |
12724 | { 6, alc861vd_6stack_ch6_init }, | |
12725 | { 8, alc861vd_6stack_ch8_init }, | |
12726 | }; | |
12727 | ||
12728 | static struct snd_kcontrol_new alc861vd_chmode_mixer[] = { | |
12729 | { | |
12730 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
12731 | .name = "Channel Mode", | |
12732 | .info = alc_ch_mode_info, | |
12733 | .get = alc_ch_mode_get, | |
12734 | .put = alc_ch_mode_put, | |
12735 | }, | |
12736 | { } /* end */ | |
12737 | }; | |
12738 | ||
12739 | static struct snd_kcontrol_new alc861vd_capture_mixer[] = { | |
12740 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
12741 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
12742 | ||
12743 | { | |
12744 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
12745 | /* The multiple "Capture Source" controls confuse alsamixer | |
12746 | * So call somewhat different.. | |
f32610ed JS |
12747 | */ |
12748 | /* .name = "Capture Source", */ | |
12749 | .name = "Input Source", | |
12750 | .count = 1, | |
12751 | .info = alc861vd_mux_enum_info, | |
12752 | .get = alc861vd_mux_enum_get, | |
12753 | .put = alc861vd_mux_enum_put, | |
12754 | }, | |
12755 | { } /* end */ | |
12756 | }; | |
12757 | ||
12758 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 | |
12759 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
12760 | */ | |
12761 | static struct snd_kcontrol_new alc861vd_6st_mixer[] = { | |
12762 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
12763 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
12764 | ||
12765 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
12766 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
12767 | ||
12768 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, | |
12769 | HDA_OUTPUT), | |
12770 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, | |
12771 | HDA_OUTPUT), | |
12772 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
12773 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
12774 | ||
12775 | HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT), | |
12776 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
12777 | ||
12778 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
12779 | ||
12780 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
12781 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
12782 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
12783 | ||
12784 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
12785 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
12786 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
12787 | ||
12788 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
12789 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
12790 | ||
12791 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
12792 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
12793 | ||
12794 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
12795 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
12796 | ||
12797 | { } /* end */ | |
12798 | }; | |
12799 | ||
12800 | static struct snd_kcontrol_new alc861vd_3st_mixer[] = { | |
12801 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
12802 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
12803 | ||
12804 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
12805 | ||
12806 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
12807 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
12808 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
12809 | ||
12810 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
12811 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
12812 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
12813 | ||
12814 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
12815 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
12816 | ||
12817 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
12818 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
12819 | ||
12820 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
12821 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
12822 | ||
12823 | { } /* end */ | |
12824 | }; | |
12825 | ||
bdd148a3 KY |
12826 | static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = { |
12827 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
12828 | /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/ | |
12829 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
12830 | ||
12831 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
12832 | ||
12833 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
12834 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
12835 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
12836 | ||
12837 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
12838 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
12839 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
12840 | ||
12841 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
12842 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
12843 | ||
12844 | { } /* end */ | |
12845 | }; | |
12846 | ||
b419f346 TD |
12847 | /* Pin assignment: Speaker=0x14, HP = 0x15, |
12848 | * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d | |
272a527c KY |
12849 | */ |
12850 | static struct snd_kcontrol_new alc861vd_dallas_mixer[] = { | |
b419f346 TD |
12851 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), |
12852 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT), | |
272a527c KY |
12853 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
12854 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), | |
b419f346 TD |
12855 | HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT), |
12856 | HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
12857 | HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
12858 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
12859 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
12860 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
12861 | HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT), | |
12862 | HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT), | |
272a527c KY |
12863 | { } /* end */ |
12864 | }; | |
12865 | ||
d1a991a6 KY |
12866 | /* Pin assignment: Speaker=0x14, Line-out = 0x15, |
12867 | * Front Mic=0x18, ATAPI Mic = 0x19, | |
12868 | */ | |
12869 | static struct snd_kcontrol_new alc861vd_hp_mixer[] = { | |
12870 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
12871 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
12872 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
12873 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), | |
12874 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
12875 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
12876 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
12877 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
12878 | ||
12879 | { } /* end */ | |
12880 | }; | |
12881 | ||
f32610ed JS |
12882 | /* |
12883 | * generic initialization of ADC, input mixers and output mixers | |
12884 | */ | |
12885 | static struct hda_verb alc861vd_volume_init_verbs[] = { | |
12886 | /* | |
12887 | * Unmute ADC0 and set the default input to mic-in | |
12888 | */ | |
12889 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
12890 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12891 | ||
12892 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of | |
12893 | * the analog-loopback mixer widget | |
12894 | */ | |
12895 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
12896 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
12897 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
12898 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
12899 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
12900 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
f32610ed JS |
12901 | |
12902 | /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */ | |
bdd148a3 KY |
12903 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
12904 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12905 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f32610ed | 12906 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
f32610ed JS |
12907 | |
12908 | /* | |
12909 | * Set up output mixers (0x02 - 0x05) | |
12910 | */ | |
12911 | /* set vol=0 to output mixers */ | |
12912 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
12913 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
12914 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
12915 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
12916 | ||
12917 | /* set up input amps for analog loopback */ | |
12918 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
12919 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
12920 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
12921 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
12922 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
12923 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
12924 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
12925 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
12926 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
12927 | ||
12928 | { } | |
12929 | }; | |
12930 | ||
12931 | /* | |
12932 | * 3-stack pin configuration: | |
12933 | * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b | |
12934 | */ | |
12935 | static struct hda_verb alc861vd_3stack_init_verbs[] = { | |
12936 | /* | |
12937 | * Set pin mode and muting | |
12938 | */ | |
12939 | /* set front pin widgets 0x14 for output */ | |
12940 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
12941 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12942 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
12943 | ||
12944 | /* Mic (rear) pin: input vref at 80% */ | |
12945 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
12946 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12947 | /* Front Mic pin: input vref at 80% */ | |
12948 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
12949 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12950 | /* Line In pin: input */ | |
12951 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12952 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12953 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
12954 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
12955 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12956 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
12957 | /* CD pin widget for input */ | |
12958 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12959 | ||
12960 | { } | |
12961 | }; | |
12962 | ||
12963 | /* | |
12964 | * 6-stack pin configuration: | |
12965 | */ | |
12966 | static struct hda_verb alc861vd_6stack_init_verbs[] = { | |
12967 | /* | |
12968 | * Set pin mode and muting | |
12969 | */ | |
12970 | /* set front pin widgets 0x14 for output */ | |
12971 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
12972 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12973 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
12974 | ||
12975 | /* Rear Pin: output 1 (0x0d) */ | |
12976 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
12977 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12978 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
12979 | /* CLFE Pin: output 2 (0x0e) */ | |
12980 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
12981 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12982 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
12983 | /* Side Pin: output 3 (0x0f) */ | |
12984 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
12985 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12986 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
12987 | ||
12988 | /* Mic (rear) pin: input vref at 80% */ | |
12989 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
12990 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12991 | /* Front Mic pin: input vref at 80% */ | |
12992 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
12993 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12994 | /* Line In pin: input */ | |
12995 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12996 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12997 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
12998 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
12999 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13000 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
13001 | /* CD pin widget for input */ | |
13002 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
13003 | ||
13004 | { } | |
13005 | }; | |
13006 | ||
bdd148a3 KY |
13007 | static struct hda_verb alc861vd_eapd_verbs[] = { |
13008 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
13009 | { } | |
13010 | }; | |
13011 | ||
f9423e7a KY |
13012 | static struct hda_verb alc660vd_eapd_verbs[] = { |
13013 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
13014 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
13015 | { } | |
13016 | }; | |
13017 | ||
bdd148a3 KY |
13018 | static struct hda_verb alc861vd_lenovo_unsol_verbs[] = { |
13019 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13020 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13021 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
13022 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
13023 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
13024 | {} | |
13025 | }; | |
13026 | ||
13027 | /* toggle speaker-output according to the hp-jack state */ | |
13028 | static void alc861vd_lenovo_hp_automute(struct hda_codec *codec) | |
13029 | { | |
13030 | unsigned int present; | |
13031 | unsigned char bits; | |
13032 | ||
13033 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
13034 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
13035 | bits = present ? HDA_AMP_MUTE : 0; |
13036 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
13037 | HDA_AMP_MUTE, bits); | |
bdd148a3 KY |
13038 | } |
13039 | ||
13040 | static void alc861vd_lenovo_mic_automute(struct hda_codec *codec) | |
13041 | { | |
13042 | unsigned int present; | |
13043 | unsigned char bits; | |
13044 | ||
13045 | present = snd_hda_codec_read(codec, 0x18, 0, | |
13046 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
13047 | bits = present ? HDA_AMP_MUTE : 0; |
13048 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, | |
13049 | HDA_AMP_MUTE, bits); | |
bdd148a3 KY |
13050 | } |
13051 | ||
13052 | static void alc861vd_lenovo_automute(struct hda_codec *codec) | |
13053 | { | |
13054 | alc861vd_lenovo_hp_automute(codec); | |
13055 | alc861vd_lenovo_mic_automute(codec); | |
13056 | } | |
13057 | ||
13058 | static void alc861vd_lenovo_unsol_event(struct hda_codec *codec, | |
13059 | unsigned int res) | |
13060 | { | |
13061 | switch (res >> 26) { | |
13062 | case ALC880_HP_EVENT: | |
13063 | alc861vd_lenovo_hp_automute(codec); | |
13064 | break; | |
13065 | case ALC880_MIC_EVENT: | |
13066 | alc861vd_lenovo_mic_automute(codec); | |
13067 | break; | |
13068 | } | |
13069 | } | |
13070 | ||
272a527c KY |
13071 | static struct hda_verb alc861vd_dallas_verbs[] = { |
13072 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
13073 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
13074 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
13075 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
13076 | ||
13077 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13078 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13079 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
13080 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
13081 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
13082 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
13083 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
13084 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
13085 | ||
13086 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
13087 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13088 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
13089 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13090 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
13091 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13092 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
13093 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13094 | ||
13095 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | |
13096 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13097 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | |
13098 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13099 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
13100 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
13101 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
13102 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
13103 | ||
13104 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13105 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
13106 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
13107 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
13108 | ||
13109 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
13110 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
13111 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
13112 | ||
13113 | { } /* end */ | |
13114 | }; | |
13115 | ||
13116 | /* toggle speaker-output according to the hp-jack state */ | |
13117 | static void alc861vd_dallas_automute(struct hda_codec *codec) | |
13118 | { | |
13119 | unsigned int present; | |
13120 | ||
13121 | present = snd_hda_codec_read(codec, 0x15, 0, | |
13122 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
13123 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
13124 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c KY |
13125 | } |
13126 | ||
13127 | static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res) | |
13128 | { | |
13129 | if ((res >> 26) == ALC880_HP_EVENT) | |
13130 | alc861vd_dallas_automute(codec); | |
13131 | } | |
13132 | ||
cb53c626 TI |
13133 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
13134 | #define alc861vd_loopbacks alc880_loopbacks | |
13135 | #endif | |
13136 | ||
f32610ed JS |
13137 | /* pcm configuration: identiacal with ALC880 */ |
13138 | #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback | |
13139 | #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture | |
13140 | #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback | |
13141 | #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture | |
13142 | ||
13143 | /* | |
13144 | * configuration and preset | |
13145 | */ | |
13146 | static const char *alc861vd_models[ALC861VD_MODEL_LAST] = { | |
13147 | [ALC660VD_3ST] = "3stack-660", | |
983f8ae4 | 13148 | [ALC660VD_3ST_DIG] = "3stack-660-digout", |
f32610ed JS |
13149 | [ALC861VD_3ST] = "3stack", |
13150 | [ALC861VD_3ST_DIG] = "3stack-digout", | |
13151 | [ALC861VD_6ST_DIG] = "6stack-digout", | |
bdd148a3 | 13152 | [ALC861VD_LENOVO] = "lenovo", |
272a527c | 13153 | [ALC861VD_DALLAS] = "dallas", |
983f8ae4 | 13154 | [ALC861VD_HP] = "hp", |
f32610ed JS |
13155 | [ALC861VD_AUTO] = "auto", |
13156 | }; | |
13157 | ||
13158 | static struct snd_pci_quirk alc861vd_cfg_tbl[] = { | |
ac3e3741 TI |
13159 | SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST), |
13160 | SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP), | |
07e038b3 | 13161 | SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST), |
f32610ed | 13162 | SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST), |
2522d735 | 13163 | SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC861VD_LENOVO), |
6963f84c | 13164 | SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG), |
f32610ed | 13165 | SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST), |
ac3e3741 | 13166 | SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO), |
38baf5ad | 13167 | /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/ |
272a527c | 13168 | SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS), |
542d7c66 | 13169 | SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO), |
b419f346 | 13170 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS), |
39c5d41f | 13171 | SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG), |
ac3e3741 TI |
13172 | SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO), |
13173 | SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO), | |
be321a89 | 13174 | SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 N200", ALC861VD_LENOVO), |
625dc0bf | 13175 | SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG), |
f32610ed JS |
13176 | {} |
13177 | }; | |
13178 | ||
13179 | static struct alc_config_preset alc861vd_presets[] = { | |
13180 | [ALC660VD_3ST] = { | |
13181 | .mixers = { alc861vd_3st_mixer }, | |
13182 | .init_verbs = { alc861vd_volume_init_verbs, | |
13183 | alc861vd_3stack_init_verbs }, | |
13184 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
13185 | .dac_nids = alc660vd_dac_nids, | |
f32610ed JS |
13186 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
13187 | .channel_mode = alc861vd_3stack_2ch_modes, | |
13188 | .input_mux = &alc861vd_capture_source, | |
13189 | }, | |
6963f84c MC |
13190 | [ALC660VD_3ST_DIG] = { |
13191 | .mixers = { alc861vd_3st_mixer }, | |
13192 | .init_verbs = { alc861vd_volume_init_verbs, | |
13193 | alc861vd_3stack_init_verbs }, | |
13194 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
13195 | .dac_nids = alc660vd_dac_nids, | |
13196 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
6963f84c MC |
13197 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
13198 | .channel_mode = alc861vd_3stack_2ch_modes, | |
13199 | .input_mux = &alc861vd_capture_source, | |
13200 | }, | |
f32610ed JS |
13201 | [ALC861VD_3ST] = { |
13202 | .mixers = { alc861vd_3st_mixer }, | |
13203 | .init_verbs = { alc861vd_volume_init_verbs, | |
13204 | alc861vd_3stack_init_verbs }, | |
13205 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
13206 | .dac_nids = alc861vd_dac_nids, | |
13207 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
13208 | .channel_mode = alc861vd_3stack_2ch_modes, | |
13209 | .input_mux = &alc861vd_capture_source, | |
13210 | }, | |
13211 | [ALC861VD_3ST_DIG] = { | |
13212 | .mixers = { alc861vd_3st_mixer }, | |
13213 | .init_verbs = { alc861vd_volume_init_verbs, | |
13214 | alc861vd_3stack_init_verbs }, | |
13215 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
13216 | .dac_nids = alc861vd_dac_nids, | |
13217 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
13218 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
13219 | .channel_mode = alc861vd_3stack_2ch_modes, | |
13220 | .input_mux = &alc861vd_capture_source, | |
13221 | }, | |
13222 | [ALC861VD_6ST_DIG] = { | |
13223 | .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer }, | |
13224 | .init_verbs = { alc861vd_volume_init_verbs, | |
13225 | alc861vd_6stack_init_verbs }, | |
13226 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
13227 | .dac_nids = alc861vd_dac_nids, | |
13228 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
13229 | .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes), | |
13230 | .channel_mode = alc861vd_6stack_modes, | |
13231 | .input_mux = &alc861vd_capture_source, | |
13232 | }, | |
bdd148a3 KY |
13233 | [ALC861VD_LENOVO] = { |
13234 | .mixers = { alc861vd_lenovo_mixer }, | |
13235 | .init_verbs = { alc861vd_volume_init_verbs, | |
13236 | alc861vd_3stack_init_verbs, | |
13237 | alc861vd_eapd_verbs, | |
13238 | alc861vd_lenovo_unsol_verbs }, | |
13239 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
13240 | .dac_nids = alc660vd_dac_nids, | |
bdd148a3 KY |
13241 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
13242 | .channel_mode = alc861vd_3stack_2ch_modes, | |
13243 | .input_mux = &alc861vd_capture_source, | |
13244 | .unsol_event = alc861vd_lenovo_unsol_event, | |
13245 | .init_hook = alc861vd_lenovo_automute, | |
13246 | }, | |
272a527c KY |
13247 | [ALC861VD_DALLAS] = { |
13248 | .mixers = { alc861vd_dallas_mixer }, | |
13249 | .init_verbs = { alc861vd_dallas_verbs }, | |
13250 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
13251 | .dac_nids = alc861vd_dac_nids, | |
272a527c KY |
13252 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
13253 | .channel_mode = alc861vd_3stack_2ch_modes, | |
13254 | .input_mux = &alc861vd_dallas_capture_source, | |
13255 | .unsol_event = alc861vd_dallas_unsol_event, | |
13256 | .init_hook = alc861vd_dallas_automute, | |
d1a991a6 KY |
13257 | }, |
13258 | [ALC861VD_HP] = { | |
13259 | .mixers = { alc861vd_hp_mixer }, | |
13260 | .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs }, | |
13261 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
13262 | .dac_nids = alc861vd_dac_nids, | |
d1a991a6 | 13263 | .dig_out_nid = ALC861VD_DIGOUT_NID, |
d1a991a6 KY |
13264 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
13265 | .channel_mode = alc861vd_3stack_2ch_modes, | |
13266 | .input_mux = &alc861vd_hp_capture_source, | |
13267 | .unsol_event = alc861vd_dallas_unsol_event, | |
13268 | .init_hook = alc861vd_dallas_automute, | |
13269 | }, | |
f32610ed JS |
13270 | }; |
13271 | ||
13272 | /* | |
13273 | * BIOS auto configuration | |
13274 | */ | |
13275 | static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec, | |
13276 | hda_nid_t nid, int pin_type, int dac_idx) | |
13277 | { | |
f6c7e546 | 13278 | alc_set_pin_output(codec, nid, pin_type); |
f32610ed JS |
13279 | } |
13280 | ||
13281 | static void alc861vd_auto_init_multi_out(struct hda_codec *codec) | |
13282 | { | |
13283 | struct alc_spec *spec = codec->spec; | |
13284 | int i; | |
13285 | ||
bc9f98a9 | 13286 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
f32610ed JS |
13287 | for (i = 0; i <= HDA_SIDE; i++) { |
13288 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 13289 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
f32610ed JS |
13290 | if (nid) |
13291 | alc861vd_auto_set_output_and_unmute(codec, nid, | |
baba8ee9 | 13292 | pin_type, i); |
f32610ed JS |
13293 | } |
13294 | } | |
13295 | ||
13296 | ||
13297 | static void alc861vd_auto_init_hp_out(struct hda_codec *codec) | |
13298 | { | |
13299 | struct alc_spec *spec = codec->spec; | |
13300 | hda_nid_t pin; | |
13301 | ||
13302 | pin = spec->autocfg.hp_pins[0]; | |
13303 | if (pin) /* connect to front and use dac 0 */ | |
13304 | alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
f6c7e546 TI |
13305 | pin = spec->autocfg.speaker_pins[0]; |
13306 | if (pin) | |
13307 | alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
f32610ed JS |
13308 | } |
13309 | ||
13310 | #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid) | |
13311 | #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID | |
13312 | ||
13313 | static void alc861vd_auto_init_analog_input(struct hda_codec *codec) | |
13314 | { | |
13315 | struct alc_spec *spec = codec->spec; | |
13316 | int i; | |
13317 | ||
13318 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
13319 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
13320 | if (alc861vd_is_input_pin(nid)) { | |
13321 | snd_hda_codec_write(codec, nid, 0, | |
13322 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
13323 | i <= AUTO_PIN_FRONT_MIC ? | |
13324 | PIN_VREF80 : PIN_IN); | |
13325 | if (nid != ALC861VD_PIN_CD_NID) | |
13326 | snd_hda_codec_write(codec, nid, 0, | |
13327 | AC_VERB_SET_AMP_GAIN_MUTE, | |
13328 | AMP_OUT_MUTE); | |
13329 | } | |
13330 | } | |
13331 | } | |
13332 | ||
13333 | #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02) | |
13334 | #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c) | |
13335 | ||
13336 | /* add playback controls from the parsed DAC table */ | |
13337 | /* Based on ALC880 version. But ALC861VD has separate, | |
13338 | * different NIDs for mute/unmute switch and volume control */ | |
13339 | static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec, | |
13340 | const struct auto_pin_cfg *cfg) | |
13341 | { | |
13342 | char name[32]; | |
13343 | static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"}; | |
13344 | hda_nid_t nid_v, nid_s; | |
13345 | int i, err; | |
13346 | ||
13347 | for (i = 0; i < cfg->line_outs; i++) { | |
f12ab1e0 | 13348 | if (!spec->multiout.dac_nids[i]) |
f32610ed JS |
13349 | continue; |
13350 | nid_v = alc861vd_idx_to_mixer_vol( | |
13351 | alc880_dac_to_idx( | |
13352 | spec->multiout.dac_nids[i])); | |
13353 | nid_s = alc861vd_idx_to_mixer_switch( | |
13354 | alc880_dac_to_idx( | |
13355 | spec->multiout.dac_nids[i])); | |
13356 | ||
13357 | if (i == 2) { | |
13358 | /* Center/LFE */ | |
f12ab1e0 TI |
13359 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
13360 | "Center Playback Volume", | |
13361 | HDA_COMPOSE_AMP_VAL(nid_v, 1, 0, | |
13362 | HDA_OUTPUT)); | |
13363 | if (err < 0) | |
f32610ed | 13364 | return err; |
f12ab1e0 TI |
13365 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
13366 | "LFE Playback Volume", | |
13367 | HDA_COMPOSE_AMP_VAL(nid_v, 2, 0, | |
13368 | HDA_OUTPUT)); | |
13369 | if (err < 0) | |
f32610ed | 13370 | return err; |
f12ab1e0 TI |
13371 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
13372 | "Center Playback Switch", | |
13373 | HDA_COMPOSE_AMP_VAL(nid_s, 1, 2, | |
13374 | HDA_INPUT)); | |
13375 | if (err < 0) | |
f32610ed | 13376 | return err; |
f12ab1e0 TI |
13377 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
13378 | "LFE Playback Switch", | |
13379 | HDA_COMPOSE_AMP_VAL(nid_s, 2, 2, | |
13380 | HDA_INPUT)); | |
13381 | if (err < 0) | |
f32610ed JS |
13382 | return err; |
13383 | } else { | |
13384 | sprintf(name, "%s Playback Volume", chname[i]); | |
f12ab1e0 TI |
13385 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
13386 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, | |
13387 | HDA_OUTPUT)); | |
13388 | if (err < 0) | |
f32610ed JS |
13389 | return err; |
13390 | sprintf(name, "%s Playback Switch", chname[i]); | |
f12ab1e0 | 13391 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
bdd148a3 | 13392 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, |
f12ab1e0 TI |
13393 | HDA_INPUT)); |
13394 | if (err < 0) | |
f32610ed JS |
13395 | return err; |
13396 | } | |
13397 | } | |
13398 | return 0; | |
13399 | } | |
13400 | ||
13401 | /* add playback controls for speaker and HP outputs */ | |
13402 | /* Based on ALC880 version. But ALC861VD has separate, | |
13403 | * different NIDs for mute/unmute switch and volume control */ | |
13404 | static int alc861vd_auto_create_extra_out(struct alc_spec *spec, | |
13405 | hda_nid_t pin, const char *pfx) | |
13406 | { | |
13407 | hda_nid_t nid_v, nid_s; | |
13408 | int err; | |
13409 | char name[32]; | |
13410 | ||
f12ab1e0 | 13411 | if (!pin) |
f32610ed JS |
13412 | return 0; |
13413 | ||
13414 | if (alc880_is_fixed_pin(pin)) { | |
13415 | nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
13416 | /* specify the DAC as the extra output */ | |
f12ab1e0 | 13417 | if (!spec->multiout.hp_nid) |
f32610ed JS |
13418 | spec->multiout.hp_nid = nid_v; |
13419 | else | |
13420 | spec->multiout.extra_out_nid[0] = nid_v; | |
13421 | /* control HP volume/switch on the output mixer amp */ | |
13422 | nid_v = alc861vd_idx_to_mixer_vol( | |
13423 | alc880_fixed_pin_idx(pin)); | |
13424 | nid_s = alc861vd_idx_to_mixer_switch( | |
13425 | alc880_fixed_pin_idx(pin)); | |
13426 | ||
13427 | sprintf(name, "%s Playback Volume", pfx); | |
f12ab1e0 TI |
13428 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
13429 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT)); | |
13430 | if (err < 0) | |
f32610ed JS |
13431 | return err; |
13432 | sprintf(name, "%s Playback Switch", pfx); | |
f12ab1e0 TI |
13433 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
13434 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT)); | |
13435 | if (err < 0) | |
f32610ed JS |
13436 | return err; |
13437 | } else if (alc880_is_multi_pin(pin)) { | |
13438 | /* set manual connection */ | |
13439 | /* we have only a switch on HP-out PIN */ | |
13440 | sprintf(name, "%s Playback Switch", pfx); | |
f12ab1e0 TI |
13441 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
13442 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
13443 | if (err < 0) | |
f32610ed JS |
13444 | return err; |
13445 | } | |
13446 | return 0; | |
13447 | } | |
13448 | ||
13449 | /* parse the BIOS configuration and set up the alc_spec | |
13450 | * return 1 if successful, 0 if the proper config is not found, | |
13451 | * or a negative error code | |
13452 | * Based on ALC880 version - had to change it to override | |
13453 | * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */ | |
13454 | static int alc861vd_parse_auto_config(struct hda_codec *codec) | |
13455 | { | |
13456 | struct alc_spec *spec = codec->spec; | |
13457 | int err; | |
13458 | static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; | |
13459 | ||
f12ab1e0 TI |
13460 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
13461 | alc861vd_ignore); | |
13462 | if (err < 0) | |
f32610ed | 13463 | return err; |
f12ab1e0 | 13464 | if (!spec->autocfg.line_outs) |
f32610ed JS |
13465 | return 0; /* can't find valid BIOS pin config */ |
13466 | ||
f12ab1e0 TI |
13467 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
13468 | if (err < 0) | |
13469 | return err; | |
13470 | err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
13471 | if (err < 0) | |
13472 | return err; | |
13473 | err = alc861vd_auto_create_extra_out(spec, | |
13474 | spec->autocfg.speaker_pins[0], | |
13475 | "Speaker"); | |
13476 | if (err < 0) | |
13477 | return err; | |
13478 | err = alc861vd_auto_create_extra_out(spec, | |
13479 | spec->autocfg.hp_pins[0], | |
13480 | "Headphone"); | |
13481 | if (err < 0) | |
13482 | return err; | |
13483 | err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
13484 | if (err < 0) | |
f32610ed JS |
13485 | return err; |
13486 | ||
13487 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
13488 | ||
13489 | if (spec->autocfg.dig_out_pin) | |
13490 | spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID; | |
13491 | ||
13492 | if (spec->kctl_alloc) | |
13493 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
13494 | ||
13495 | spec->init_verbs[spec->num_init_verbs++] | |
13496 | = alc861vd_volume_init_verbs; | |
13497 | ||
13498 | spec->num_mux_defs = 1; | |
13499 | spec->input_mux = &spec->private_imux; | |
13500 | ||
776e184e TI |
13501 | err = alc_auto_add_mic_boost(codec); |
13502 | if (err < 0) | |
13503 | return err; | |
13504 | ||
f32610ed JS |
13505 | return 1; |
13506 | } | |
13507 | ||
13508 | /* additional initialization for auto-configuration model */ | |
13509 | static void alc861vd_auto_init(struct hda_codec *codec) | |
13510 | { | |
f6c7e546 | 13511 | struct alc_spec *spec = codec->spec; |
f32610ed JS |
13512 | alc861vd_auto_init_multi_out(codec); |
13513 | alc861vd_auto_init_hp_out(codec); | |
13514 | alc861vd_auto_init_analog_input(codec); | |
f6c7e546 TI |
13515 | if (spec->unsol_event) |
13516 | alc_sku_automute(codec); | |
f32610ed JS |
13517 | } |
13518 | ||
13519 | static int patch_alc861vd(struct hda_codec *codec) | |
13520 | { | |
13521 | struct alc_spec *spec; | |
13522 | int err, board_config; | |
13523 | ||
13524 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
13525 | if (spec == NULL) | |
13526 | return -ENOMEM; | |
13527 | ||
13528 | codec->spec = spec; | |
13529 | ||
13530 | board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST, | |
13531 | alc861vd_models, | |
13532 | alc861vd_cfg_tbl); | |
13533 | ||
13534 | if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) { | |
13535 | printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/" | |
13536 | "ALC861VD, trying auto-probe from BIOS...\n"); | |
13537 | board_config = ALC861VD_AUTO; | |
13538 | } | |
13539 | ||
13540 | if (board_config == ALC861VD_AUTO) { | |
13541 | /* automatic parse from the BIOS config */ | |
13542 | err = alc861vd_parse_auto_config(codec); | |
13543 | if (err < 0) { | |
13544 | alc_free(codec); | |
13545 | return err; | |
f12ab1e0 | 13546 | } else if (!err) { |
f32610ed JS |
13547 | printk(KERN_INFO |
13548 | "hda_codec: Cannot set up configuration " | |
13549 | "from BIOS. Using base mode...\n"); | |
13550 | board_config = ALC861VD_3ST; | |
13551 | } | |
13552 | } | |
13553 | ||
13554 | if (board_config != ALC861VD_AUTO) | |
13555 | setup_preset(spec, &alc861vd_presets[board_config]); | |
13556 | ||
2f893286 KY |
13557 | if (codec->vendor_id == 0x10ec0660) { |
13558 | spec->stream_name_analog = "ALC660-VD Analog"; | |
13559 | spec->stream_name_digital = "ALC660-VD Digital"; | |
f9423e7a KY |
13560 | /* always turn on EAPD */ |
13561 | spec->init_verbs[spec->num_init_verbs++] = alc660vd_eapd_verbs; | |
2f893286 KY |
13562 | } else { |
13563 | spec->stream_name_analog = "ALC861VD Analog"; | |
13564 | spec->stream_name_digital = "ALC861VD Digital"; | |
13565 | } | |
13566 | ||
f32610ed JS |
13567 | spec->stream_analog_playback = &alc861vd_pcm_analog_playback; |
13568 | spec->stream_analog_capture = &alc861vd_pcm_analog_capture; | |
13569 | ||
f32610ed JS |
13570 | spec->stream_digital_playback = &alc861vd_pcm_digital_playback; |
13571 | spec->stream_digital_capture = &alc861vd_pcm_digital_capture; | |
13572 | ||
13573 | spec->adc_nids = alc861vd_adc_nids; | |
13574 | spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids); | |
e1406348 | 13575 | spec->capsrc_nids = alc861vd_capsrc_nids; |
f32610ed JS |
13576 | |
13577 | spec->mixers[spec->num_mixers] = alc861vd_capture_mixer; | |
13578 | spec->num_mixers++; | |
13579 | ||
2134ea4f TI |
13580 | spec->vmaster_nid = 0x02; |
13581 | ||
f32610ed JS |
13582 | codec->patch_ops = alc_patch_ops; |
13583 | ||
13584 | if (board_config == ALC861VD_AUTO) | |
13585 | spec->init_hook = alc861vd_auto_init; | |
cb53c626 TI |
13586 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
13587 | if (!spec->loopback.amplist) | |
13588 | spec->loopback.amplist = alc861vd_loopbacks; | |
13589 | #endif | |
f32610ed JS |
13590 | |
13591 | return 0; | |
13592 | } | |
13593 | ||
bc9f98a9 KY |
13594 | /* |
13595 | * ALC662 support | |
13596 | * | |
13597 | * ALC662 is almost identical with ALC880 but has cleaner and more flexible | |
13598 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
13599 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
13600 | * 6-channel independent captures. | |
13601 | * | |
13602 | * In addition, an independent DAC for the multi-playback (not used in this | |
13603 | * driver yet). | |
13604 | */ | |
13605 | #define ALC662_DIGOUT_NID 0x06 | |
13606 | #define ALC662_DIGIN_NID 0x0a | |
13607 | ||
13608 | static hda_nid_t alc662_dac_nids[4] = { | |
13609 | /* front, rear, clfe, rear_surr */ | |
13610 | 0x02, 0x03, 0x04 | |
13611 | }; | |
13612 | ||
13613 | static hda_nid_t alc662_adc_nids[1] = { | |
13614 | /* ADC1-2 */ | |
13615 | 0x09, | |
13616 | }; | |
e1406348 | 13617 | |
77a261b7 | 13618 | static hda_nid_t alc662_capsrc_nids[1] = { 0x22 }; |
e1406348 | 13619 | |
bc9f98a9 KY |
13620 | /* input MUX */ |
13621 | /* FIXME: should be a matrix-type input source selection */ | |
bc9f98a9 KY |
13622 | static struct hda_input_mux alc662_capture_source = { |
13623 | .num_items = 4, | |
13624 | .items = { | |
13625 | { "Mic", 0x0 }, | |
13626 | { "Front Mic", 0x1 }, | |
13627 | { "Line", 0x2 }, | |
13628 | { "CD", 0x4 }, | |
13629 | }, | |
13630 | }; | |
13631 | ||
13632 | static struct hda_input_mux alc662_lenovo_101e_capture_source = { | |
13633 | .num_items = 2, | |
13634 | .items = { | |
13635 | { "Mic", 0x1 }, | |
13636 | { "Line", 0x2 }, | |
13637 | }, | |
13638 | }; | |
291702f0 KY |
13639 | |
13640 | static struct hda_input_mux alc662_eeepc_capture_source = { | |
13641 | .num_items = 2, | |
13642 | .items = { | |
13643 | { "i-Mic", 0x1 }, | |
13644 | { "e-Mic", 0x0 }, | |
13645 | }, | |
13646 | }; | |
13647 | ||
6dda9f4a KY |
13648 | static struct hda_input_mux alc663_capture_source = { |
13649 | .num_items = 3, | |
13650 | .items = { | |
13651 | { "Mic", 0x0 }, | |
13652 | { "Front Mic", 0x1 }, | |
13653 | { "Line", 0x2 }, | |
13654 | }, | |
13655 | }; | |
13656 | ||
13657 | static struct hda_input_mux alc663_m51va_capture_source = { | |
13658 | .num_items = 2, | |
13659 | .items = { | |
13660 | { "Ext-Mic", 0x0 }, | |
13661 | { "D-Mic", 0x9 }, | |
13662 | }, | |
13663 | }; | |
13664 | ||
bc9f98a9 KY |
13665 | #define alc662_mux_enum_info alc_mux_enum_info |
13666 | #define alc662_mux_enum_get alc_mux_enum_get | |
e1406348 | 13667 | #define alc662_mux_enum_put alc882_mux_enum_put |
bc9f98a9 | 13668 | |
bc9f98a9 KY |
13669 | /* |
13670 | * 2ch mode | |
13671 | */ | |
13672 | static struct hda_channel_mode alc662_3ST_2ch_modes[1] = { | |
13673 | { 2, NULL } | |
13674 | }; | |
13675 | ||
13676 | /* | |
13677 | * 2ch mode | |
13678 | */ | |
13679 | static struct hda_verb alc662_3ST_ch2_init[] = { | |
13680 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
13681 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
13682 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
13683 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
13684 | { } /* end */ | |
13685 | }; | |
13686 | ||
13687 | /* | |
13688 | * 6ch mode | |
13689 | */ | |
13690 | static struct hda_verb alc662_3ST_ch6_init[] = { | |
13691 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13692 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
13693 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
13694 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13695 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
13696 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
13697 | { } /* end */ | |
13698 | }; | |
13699 | ||
13700 | static struct hda_channel_mode alc662_3ST_6ch_modes[2] = { | |
13701 | { 2, alc662_3ST_ch2_init }, | |
13702 | { 6, alc662_3ST_ch6_init }, | |
13703 | }; | |
13704 | ||
13705 | /* | |
13706 | * 2ch mode | |
13707 | */ | |
13708 | static struct hda_verb alc662_sixstack_ch6_init[] = { | |
13709 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
13710 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
13711 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13712 | { } /* end */ | |
13713 | }; | |
13714 | ||
13715 | /* | |
13716 | * 6ch mode | |
13717 | */ | |
13718 | static struct hda_verb alc662_sixstack_ch8_init[] = { | |
13719 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13720 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13721 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13722 | { } /* end */ | |
13723 | }; | |
13724 | ||
13725 | static struct hda_channel_mode alc662_5stack_modes[2] = { | |
13726 | { 2, alc662_sixstack_ch6_init }, | |
13727 | { 6, alc662_sixstack_ch8_init }, | |
13728 | }; | |
13729 | ||
13730 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 | |
13731 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
13732 | */ | |
13733 | ||
13734 | static struct snd_kcontrol_new alc662_base_mixer[] = { | |
13735 | /* output mixer control */ | |
13736 | HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT), | |
7055ad8a | 13737 | HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT), |
bc9f98a9 | 13738 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT), |
7055ad8a | 13739 | HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT), |
bc9f98a9 KY |
13740 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), |
13741 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), | |
7055ad8a HRK |
13742 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT), |
13743 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT), | |
bc9f98a9 KY |
13744 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
13745 | ||
13746 | /*Input mixer control */ | |
13747 | HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT), | |
13748 | HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT), | |
13749 | HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT), | |
13750 | HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT), | |
13751 | HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT), | |
13752 | HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT), | |
13753 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT), | |
13754 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT), | |
bc9f98a9 KY |
13755 | { } /* end */ |
13756 | }; | |
13757 | ||
13758 | static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = { | |
13759 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
7055ad8a | 13760 | HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT), |
bc9f98a9 KY |
13761 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
13762 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
13763 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
13764 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
13765 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
13766 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
13767 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
13768 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
13769 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
13770 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
13771 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
bc9f98a9 KY |
13772 | { } /* end */ |
13773 | }; | |
13774 | ||
13775 | static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = { | |
13776 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
7055ad8a | 13777 | HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT), |
bc9f98a9 | 13778 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
7055ad8a | 13779 | HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT), |
bc9f98a9 KY |
13780 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), |
13781 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), | |
7055ad8a HRK |
13782 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT), |
13783 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT), | |
bc9f98a9 KY |
13784 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
13785 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
13786 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
13787 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
13788 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
13789 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
13790 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
13791 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
13792 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
13793 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
13794 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
bc9f98a9 KY |
13795 | { } /* end */ |
13796 | }; | |
13797 | ||
13798 | static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = { | |
13799 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
13800 | HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT), | |
86cd9298 TI |
13801 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
13802 | HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT), | |
bc9f98a9 KY |
13803 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
13804 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
13805 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
13806 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
13807 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
bc9f98a9 KY |
13808 | { } /* end */ |
13809 | }; | |
13810 | ||
291702f0 | 13811 | static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = { |
86cd9298 | 13812 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), |
291702f0 | 13813 | |
b4818494 HRK |
13814 | HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT), |
13815 | HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
291702f0 KY |
13816 | |
13817 | HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT), | |
13818 | HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
13819 | HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
13820 | ||
13821 | HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT), | |
13822 | HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
13823 | HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
13824 | { } /* end */ | |
13825 | }; | |
13826 | ||
8c427226 | 13827 | static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = { |
31bffaa9 TI |
13828 | HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT), |
13829 | HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
8c427226 KY |
13830 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
13831 | HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT), | |
13832 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), | |
13833 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), | |
13834 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT), | |
13835 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT), | |
86cd9298 | 13836 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
8c427226 KY |
13837 | HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT), |
13838 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
13839 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
13840 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
13841 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
13842 | { } /* end */ | |
13843 | }; | |
13844 | ||
6dda9f4a KY |
13845 | static struct snd_kcontrol_new alc663_m51va_mixer[] = { |
13846 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
13847 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
13848 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT), | |
13849 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
13850 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
13851 | HDA_CODEC_MUTE("DMic Playback Switch", 0x23, 0x9, HDA_INPUT), | |
13852 | { } /* end */ | |
13853 | }; | |
13854 | ||
13855 | static struct snd_kcontrol_new alc663_g71v_mixer[] = { | |
13856 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
13857 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
13858 | HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
13859 | HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
13860 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT), | |
13861 | ||
13862 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
13863 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
13864 | HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
13865 | HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
13866 | { } /* end */ | |
13867 | }; | |
13868 | ||
13869 | static struct snd_kcontrol_new alc663_g50v_mixer[] = { | |
13870 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
13871 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
13872 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT), | |
13873 | ||
13874 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
13875 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
13876 | HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
13877 | HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
13878 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
13879 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
13880 | { } /* end */ | |
13881 | }; | |
13882 | ||
bc9f98a9 KY |
13883 | static struct snd_kcontrol_new alc662_chmode_mixer[] = { |
13884 | { | |
13885 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
13886 | .name = "Channel Mode", | |
13887 | .info = alc_ch_mode_info, | |
13888 | .get = alc_ch_mode_get, | |
13889 | .put = alc_ch_mode_put, | |
13890 | }, | |
13891 | { } /* end */ | |
13892 | }; | |
13893 | ||
13894 | static struct hda_verb alc662_init_verbs[] = { | |
13895 | /* ADC: mute amp left and right */ | |
13896 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
13897 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
13898 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
13899 | ||
cb53c626 TI |
13900 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
13901 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
13902 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
13903 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
13904 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
bc9f98a9 | 13905 | |
b60dd394 KY |
13906 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
13907 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13908 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13909 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13910 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13911 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
bc9f98a9 KY |
13912 | |
13913 | /* Front Pin: output 0 (0x0c) */ | |
13914 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
13915 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13916 | ||
13917 | /* Rear Pin: output 1 (0x0d) */ | |
13918 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
13919 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13920 | ||
13921 | /* CLFE Pin: output 2 (0x0e) */ | |
13922 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
13923 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13924 | ||
13925 | /* Mic (rear) pin: input vref at 80% */ | |
13926 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
13927 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13928 | /* Front Mic pin: input vref at 80% */ | |
13929 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
13930 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13931 | /* Line In pin: input */ | |
13932 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
13933 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13934 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
13935 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
13936 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13937 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
13938 | /* CD pin widget for input */ | |
13939 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
13940 | ||
13941 | /* FIXME: use matrix-type input source selection */ | |
13942 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
13943 | /* Input mixer */ | |
13944 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13945 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13946 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
13947 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
291702f0 KY |
13948 | |
13949 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13950 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13951 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
13952 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
6dda9f4a KY |
13953 | |
13954 | /* always trun on EAPD */ | |
13955 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
13956 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
13957 | ||
bc9f98a9 KY |
13958 | { } |
13959 | }; | |
13960 | ||
13961 | static struct hda_verb alc662_sue_init_verbs[] = { | |
13962 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT}, | |
13963 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT}, | |
291702f0 KY |
13964 | {} |
13965 | }; | |
13966 | ||
13967 | static struct hda_verb alc662_eeepc_sue_init_verbs[] = { | |
13968 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
13969 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
13970 | {} | |
bc9f98a9 KY |
13971 | }; |
13972 | ||
8c427226 KY |
13973 | /* Set Unsolicited Event*/ |
13974 | static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = { | |
13975 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
13976 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
13977 | {} | |
13978 | }; | |
13979 | ||
bc9f98a9 KY |
13980 | /* |
13981 | * generic initialization of ADC, input mixers and output mixers | |
13982 | */ | |
13983 | static struct hda_verb alc662_auto_init_verbs[] = { | |
13984 | /* | |
13985 | * Unmute ADC and set the default input to mic-in | |
13986 | */ | |
13987 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
13988 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13989 | ||
13990 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | |
13991 | * mixer widget | |
13992 | * Note: PASD motherboards uses the Line In 2 as the input for front | |
13993 | * panel mic (mic 2) | |
13994 | */ | |
13995 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
13996 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
13997 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
13998 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
13999 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
14000 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
bc9f98a9 KY |
14001 | |
14002 | /* | |
14003 | * Set up output mixers (0x0c - 0x0f) | |
14004 | */ | |
14005 | /* set vol=0 to output mixers */ | |
14006 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14007 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14008 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14009 | ||
14010 | /* set up input amps for analog loopback */ | |
14011 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
b60dd394 KY |
14012 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
14013 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
14014 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
14015 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
14016 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
14017 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
bc9f98a9 KY |
14018 | |
14019 | ||
14020 | /* FIXME: use matrix-type input source selection */ | |
14021 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
14022 | /* Input mixer */ | |
14023 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
d1a991a6 | 14024 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
bc9f98a9 KY |
14025 | { } |
14026 | }; | |
14027 | ||
6dda9f4a KY |
14028 | static struct hda_verb alc663_m51va_init_verbs[] = { |
14029 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
14030 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14031 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */ | |
14032 | ||
14033 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)}, | |
14034 | ||
14035 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
14036 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
14037 | {} | |
14038 | }; | |
14039 | ||
14040 | static struct hda_verb alc663_g71v_init_verbs[] = { | |
14041 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
14042 | /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */ | |
14043 | /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */ | |
14044 | ||
14045 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
14046 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14047 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */ | |
14048 | ||
14049 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT}, | |
14050 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT}, | |
14051 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT}, | |
14052 | {} | |
14053 | }; | |
14054 | ||
14055 | static struct hda_verb alc663_g50v_init_verbs[] = { | |
14056 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
14057 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14058 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */ | |
14059 | ||
14060 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
14061 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
14062 | {} | |
14063 | }; | |
14064 | ||
bc9f98a9 KY |
14065 | /* capture mixer elements */ |
14066 | static struct snd_kcontrol_new alc662_capture_mixer[] = { | |
14067 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
14068 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
14069 | { | |
14070 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
14071 | /* The multiple "Capture Source" controls confuse alsamixer | |
14072 | * So call somewhat different.. | |
bc9f98a9 KY |
14073 | */ |
14074 | /* .name = "Capture Source", */ | |
14075 | .name = "Input Source", | |
14076 | .count = 1, | |
6e7939bb HRK |
14077 | .info = alc662_mux_enum_info, |
14078 | .get = alc662_mux_enum_get, | |
14079 | .put = alc662_mux_enum_put, | |
bc9f98a9 KY |
14080 | }, |
14081 | { } /* end */ | |
14082 | }; | |
14083 | ||
14084 | static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec) | |
14085 | { | |
14086 | unsigned int present; | |
f12ab1e0 | 14087 | unsigned char bits; |
bc9f98a9 KY |
14088 | |
14089 | present = snd_hda_codec_read(codec, 0x14, 0, | |
14090 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
14091 | bits = present ? HDA_AMP_MUTE : 0; |
14092 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
14093 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
14094 | } |
14095 | ||
14096 | static void alc662_lenovo_101e_all_automute(struct hda_codec *codec) | |
14097 | { | |
14098 | unsigned int present; | |
f12ab1e0 | 14099 | unsigned char bits; |
bc9f98a9 KY |
14100 | |
14101 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
14102 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
14103 | bits = present ? HDA_AMP_MUTE : 0; |
14104 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
14105 | HDA_AMP_MUTE, bits); | |
14106 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
14107 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
14108 | } |
14109 | ||
14110 | static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec, | |
14111 | unsigned int res) | |
14112 | { | |
14113 | if ((res >> 26) == ALC880_HP_EVENT) | |
14114 | alc662_lenovo_101e_all_automute(codec); | |
14115 | if ((res >> 26) == ALC880_FRONT_EVENT) | |
14116 | alc662_lenovo_101e_ispeaker_automute(codec); | |
14117 | } | |
14118 | ||
291702f0 KY |
14119 | static void alc662_eeepc_mic_automute(struct hda_codec *codec) |
14120 | { | |
14121 | unsigned int present; | |
14122 | ||
14123 | present = snd_hda_codec_read(codec, 0x18, 0, | |
14124 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
14125 | snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
14126 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | |
14127 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
14128 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | |
14129 | snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
14130 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); | |
14131 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
14132 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); | |
14133 | } | |
14134 | ||
14135 | /* unsolicited event for HP jack sensing */ | |
14136 | static void alc662_eeepc_unsol_event(struct hda_codec *codec, | |
14137 | unsigned int res) | |
14138 | { | |
14139 | if ((res >> 26) == ALC880_HP_EVENT) | |
14140 | alc262_hippo1_automute( codec ); | |
14141 | ||
14142 | if ((res >> 26) == ALC880_MIC_EVENT) | |
14143 | alc662_eeepc_mic_automute(codec); | |
14144 | } | |
14145 | ||
14146 | static void alc662_eeepc_inithook(struct hda_codec *codec) | |
14147 | { | |
14148 | alc262_hippo1_automute( codec ); | |
14149 | alc662_eeepc_mic_automute(codec); | |
14150 | } | |
14151 | ||
8c427226 KY |
14152 | static void alc662_eeepc_ep20_automute(struct hda_codec *codec) |
14153 | { | |
14154 | unsigned int mute; | |
14155 | unsigned int present; | |
14156 | ||
14157 | snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); | |
14158 | present = snd_hda_codec_read(codec, 0x14, 0, | |
14159 | AC_VERB_GET_PIN_SENSE, 0); | |
14160 | present = (present & 0x80000000) != 0; | |
14161 | if (present) { | |
14162 | /* mute internal speaker */ | |
14163 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
14164 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
14165 | } else { | |
14166 | /* unmute internal speaker if necessary */ | |
14167 | mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); | |
14168 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
14169 | HDA_AMP_MUTE, mute); | |
14170 | } | |
14171 | } | |
14172 | ||
14173 | /* unsolicited event for HP jack sensing */ | |
14174 | static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec, | |
14175 | unsigned int res) | |
14176 | { | |
14177 | if ((res >> 26) == ALC880_HP_EVENT) | |
14178 | alc662_eeepc_ep20_automute(codec); | |
14179 | } | |
14180 | ||
14181 | static void alc662_eeepc_ep20_inithook(struct hda_codec *codec) | |
14182 | { | |
14183 | alc662_eeepc_ep20_automute(codec); | |
14184 | } | |
14185 | ||
6dda9f4a KY |
14186 | static void alc663_m51va_speaker_automute(struct hda_codec *codec) |
14187 | { | |
14188 | unsigned int present; | |
14189 | unsigned char bits; | |
14190 | ||
14191 | present = snd_hda_codec_read(codec, 0x21, 0, | |
14192 | AC_VERB_GET_PIN_SENSE, 0) | |
14193 | & AC_PINSENSE_PRESENCE; | |
14194 | bits = present ? HDA_AMP_MUTE : 0; | |
14195 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
14196 | HDA_AMP_MUTE, bits); | |
14197 | } | |
14198 | ||
14199 | static void alc663_m51va_mic_automute(struct hda_codec *codec) | |
14200 | { | |
14201 | unsigned int present; | |
14202 | ||
14203 | present = snd_hda_codec_read(codec, 0x18, 0, | |
14204 | AC_VERB_GET_PIN_SENSE, 0) | |
14205 | & AC_PINSENSE_PRESENCE; | |
14206 | snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
14207 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | |
14208 | snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
14209 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | |
14210 | snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
14211 | 0x7000 | (0x09 << 8) | (present ? 0x80 : 0)); | |
14212 | snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
14213 | 0x7000 | (0x09 << 8) | (present ? 0x80 : 0)); | |
14214 | } | |
14215 | ||
14216 | static void alc663_m51va_unsol_event(struct hda_codec *codec, | |
14217 | unsigned int res) | |
14218 | { | |
14219 | switch (res >> 26) { | |
14220 | case ALC880_HP_EVENT: | |
14221 | alc663_m51va_speaker_automute(codec); | |
14222 | break; | |
14223 | case ALC880_MIC_EVENT: | |
14224 | alc663_m51va_mic_automute(codec); | |
14225 | break; | |
14226 | } | |
14227 | } | |
14228 | ||
14229 | static void alc663_m51va_inithook(struct hda_codec *codec) | |
14230 | { | |
14231 | alc663_m51va_speaker_automute(codec); | |
14232 | alc663_m51va_mic_automute(codec); | |
14233 | } | |
14234 | ||
14235 | static void alc663_g71v_hp_automute(struct hda_codec *codec) | |
14236 | { | |
14237 | unsigned int present; | |
14238 | unsigned char bits; | |
14239 | ||
14240 | present = snd_hda_codec_read(codec, 0x21, 0, | |
14241 | AC_VERB_GET_PIN_SENSE, 0) | |
14242 | & AC_PINSENSE_PRESENCE; | |
14243 | bits = present ? HDA_AMP_MUTE : 0; | |
14244 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
14245 | HDA_AMP_MUTE, bits); | |
14246 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
14247 | HDA_AMP_MUTE, bits); | |
14248 | } | |
14249 | ||
14250 | static void alc663_g71v_front_automute(struct hda_codec *codec) | |
14251 | { | |
14252 | unsigned int present; | |
14253 | unsigned char bits; | |
14254 | ||
14255 | present = snd_hda_codec_read(codec, 0x15, 0, | |
14256 | AC_VERB_GET_PIN_SENSE, 0) | |
14257 | & AC_PINSENSE_PRESENCE; | |
14258 | bits = present ? HDA_AMP_MUTE : 0; | |
14259 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
14260 | HDA_AMP_MUTE, bits); | |
14261 | } | |
14262 | ||
14263 | static void alc663_g71v_unsol_event(struct hda_codec *codec, | |
14264 | unsigned int res) | |
14265 | { | |
14266 | switch (res >> 26) { | |
14267 | case ALC880_HP_EVENT: | |
14268 | alc663_g71v_hp_automute(codec); | |
14269 | break; | |
14270 | case ALC880_FRONT_EVENT: | |
14271 | alc663_g71v_front_automute(codec); | |
14272 | break; | |
14273 | case ALC880_MIC_EVENT: | |
14274 | alc662_eeepc_mic_automute(codec); | |
14275 | break; | |
14276 | } | |
14277 | } | |
14278 | ||
14279 | static void alc663_g71v_inithook(struct hda_codec *codec) | |
14280 | { | |
14281 | alc663_g71v_front_automute(codec); | |
14282 | alc663_g71v_hp_automute(codec); | |
14283 | alc662_eeepc_mic_automute(codec); | |
14284 | } | |
14285 | ||
14286 | static void alc663_g50v_unsol_event(struct hda_codec *codec, | |
14287 | unsigned int res) | |
14288 | { | |
14289 | switch (res >> 26) { | |
14290 | case ALC880_HP_EVENT: | |
14291 | alc663_m51va_speaker_automute(codec); | |
14292 | break; | |
14293 | case ALC880_MIC_EVENT: | |
14294 | alc662_eeepc_mic_automute(codec); | |
14295 | break; | |
14296 | } | |
14297 | } | |
14298 | ||
14299 | static void alc663_g50v_inithook(struct hda_codec *codec) | |
14300 | { | |
14301 | alc663_m51va_speaker_automute(codec); | |
14302 | alc662_eeepc_mic_automute(codec); | |
14303 | } | |
14304 | ||
cb53c626 TI |
14305 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
14306 | #define alc662_loopbacks alc880_loopbacks | |
14307 | #endif | |
14308 | ||
bc9f98a9 KY |
14309 | |
14310 | /* pcm configuration: identiacal with ALC880 */ | |
14311 | #define alc662_pcm_analog_playback alc880_pcm_analog_playback | |
14312 | #define alc662_pcm_analog_capture alc880_pcm_analog_capture | |
14313 | #define alc662_pcm_digital_playback alc880_pcm_digital_playback | |
14314 | #define alc662_pcm_digital_capture alc880_pcm_digital_capture | |
14315 | ||
14316 | /* | |
14317 | * configuration and preset | |
14318 | */ | |
14319 | static const char *alc662_models[ALC662_MODEL_LAST] = { | |
14320 | [ALC662_3ST_2ch_DIG] = "3stack-dig", | |
14321 | [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig", | |
14322 | [ALC662_3ST_6ch] = "3stack-6ch", | |
14323 | [ALC662_5ST_DIG] = "6stack-dig", | |
14324 | [ALC662_LENOVO_101E] = "lenovo-101e", | |
b995d76d | 14325 | [ALC662_ASUS_EEEPC_P701] = "eeepc-p701", |
8c427226 | 14326 | [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20", |
6dda9f4a KY |
14327 | [ALC663_ASUS_M51VA] = "m51va", |
14328 | [ALC663_ASUS_G71V] = "g71v", | |
14329 | [ALC663_ASUS_H13] = "h13", | |
14330 | [ALC663_ASUS_G50V] = "g50v", | |
bc9f98a9 KY |
14331 | [ALC662_AUTO] = "auto", |
14332 | }; | |
14333 | ||
14334 | static struct snd_pci_quirk alc662_cfg_tbl[] = { | |
6dda9f4a KY |
14335 | SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS G71V", ALC663_ASUS_G71V), |
14336 | SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA), | |
14337 | SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS M51VA", ALC663_ASUS_G50V), | |
3da23cac | 14338 | SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG), |
291702f0 | 14339 | SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701), |
8c427226 | 14340 | SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20), |
ac3e3741 | 14341 | SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E), |
6dda9f4a KY |
14342 | SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13), |
14343 | SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13), | |
14344 | SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13), | |
bc9f98a9 KY |
14345 | {} |
14346 | }; | |
14347 | ||
14348 | static struct alc_config_preset alc662_presets[] = { | |
14349 | [ALC662_3ST_2ch_DIG] = { | |
291702f0 | 14350 | .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer }, |
bc9f98a9 KY |
14351 | .init_verbs = { alc662_init_verbs }, |
14352 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
14353 | .dac_nids = alc662_dac_nids, | |
14354 | .dig_out_nid = ALC662_DIGOUT_NID, | |
bc9f98a9 KY |
14355 | .dig_in_nid = ALC662_DIGIN_NID, |
14356 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
14357 | .channel_mode = alc662_3ST_2ch_modes, | |
14358 | .input_mux = &alc662_capture_source, | |
14359 | }, | |
14360 | [ALC662_3ST_6ch_DIG] = { | |
291702f0 KY |
14361 | .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer, |
14362 | alc662_capture_mixer }, | |
bc9f98a9 KY |
14363 | .init_verbs = { alc662_init_verbs }, |
14364 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
14365 | .dac_nids = alc662_dac_nids, | |
14366 | .dig_out_nid = ALC662_DIGOUT_NID, | |
bc9f98a9 KY |
14367 | .dig_in_nid = ALC662_DIGIN_NID, |
14368 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), | |
14369 | .channel_mode = alc662_3ST_6ch_modes, | |
14370 | .need_dac_fix = 1, | |
14371 | .input_mux = &alc662_capture_source, | |
f12ab1e0 | 14372 | }, |
bc9f98a9 | 14373 | [ALC662_3ST_6ch] = { |
291702f0 KY |
14374 | .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer, |
14375 | alc662_capture_mixer }, | |
bc9f98a9 KY |
14376 | .init_verbs = { alc662_init_verbs }, |
14377 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
14378 | .dac_nids = alc662_dac_nids, | |
bc9f98a9 KY |
14379 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), |
14380 | .channel_mode = alc662_3ST_6ch_modes, | |
14381 | .need_dac_fix = 1, | |
14382 | .input_mux = &alc662_capture_source, | |
f12ab1e0 | 14383 | }, |
bc9f98a9 | 14384 | [ALC662_5ST_DIG] = { |
291702f0 KY |
14385 | .mixers = { alc662_base_mixer, alc662_chmode_mixer, |
14386 | alc662_capture_mixer }, | |
bc9f98a9 KY |
14387 | .init_verbs = { alc662_init_verbs }, |
14388 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
14389 | .dac_nids = alc662_dac_nids, | |
14390 | .dig_out_nid = ALC662_DIGOUT_NID, | |
bc9f98a9 KY |
14391 | .dig_in_nid = ALC662_DIGIN_NID, |
14392 | .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes), | |
14393 | .channel_mode = alc662_5stack_modes, | |
14394 | .input_mux = &alc662_capture_source, | |
14395 | }, | |
14396 | [ALC662_LENOVO_101E] = { | |
291702f0 | 14397 | .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer }, |
bc9f98a9 KY |
14398 | .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs }, |
14399 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
14400 | .dac_nids = alc662_dac_nids, | |
bc9f98a9 KY |
14401 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
14402 | .channel_mode = alc662_3ST_2ch_modes, | |
14403 | .input_mux = &alc662_lenovo_101e_capture_source, | |
14404 | .unsol_event = alc662_lenovo_101e_unsol_event, | |
14405 | .init_hook = alc662_lenovo_101e_all_automute, | |
14406 | }, | |
291702f0 KY |
14407 | [ALC662_ASUS_EEEPC_P701] = { |
14408 | .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer }, | |
14409 | .init_verbs = { alc662_init_verbs, | |
14410 | alc662_eeepc_sue_init_verbs }, | |
14411 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
14412 | .dac_nids = alc662_dac_nids, | |
291702f0 KY |
14413 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
14414 | .channel_mode = alc662_3ST_2ch_modes, | |
14415 | .input_mux = &alc662_eeepc_capture_source, | |
14416 | .unsol_event = alc662_eeepc_unsol_event, | |
14417 | .init_hook = alc662_eeepc_inithook, | |
14418 | }, | |
8c427226 KY |
14419 | [ALC662_ASUS_EEEPC_EP20] = { |
14420 | .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer, | |
14421 | alc662_chmode_mixer }, | |
14422 | .init_verbs = { alc662_init_verbs, | |
14423 | alc662_eeepc_ep20_sue_init_verbs }, | |
14424 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
14425 | .dac_nids = alc662_dac_nids, | |
8c427226 KY |
14426 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), |
14427 | .channel_mode = alc662_3ST_6ch_modes, | |
14428 | .input_mux = &alc662_lenovo_101e_capture_source, | |
14429 | .unsol_event = alc662_eeepc_ep20_unsol_event, | |
14430 | .init_hook = alc662_eeepc_ep20_inithook, | |
14431 | }, | |
6dda9f4a KY |
14432 | [ALC663_ASUS_M51VA] = { |
14433 | .mixers = { alc663_m51va_mixer, alc662_capture_mixer}, | |
14434 | .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs }, | |
14435 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
14436 | .dac_nids = alc662_dac_nids, | |
14437 | .dig_out_nid = ALC662_DIGOUT_NID, | |
14438 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
14439 | .channel_mode = alc662_3ST_2ch_modes, | |
14440 | .input_mux = &alc663_m51va_capture_source, | |
14441 | .unsol_event = alc663_m51va_unsol_event, | |
14442 | .init_hook = alc663_m51va_inithook, | |
14443 | }, | |
14444 | [ALC663_ASUS_G71V] = { | |
14445 | .mixers = { alc663_g71v_mixer, alc662_capture_mixer}, | |
14446 | .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs }, | |
14447 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
14448 | .dac_nids = alc662_dac_nids, | |
14449 | .dig_out_nid = ALC662_DIGOUT_NID, | |
14450 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
14451 | .channel_mode = alc662_3ST_2ch_modes, | |
14452 | .input_mux = &alc662_eeepc_capture_source, | |
14453 | .unsol_event = alc663_g71v_unsol_event, | |
14454 | .init_hook = alc663_g71v_inithook, | |
14455 | }, | |
14456 | [ALC663_ASUS_H13] = { | |
14457 | .mixers = { alc663_m51va_mixer, alc662_capture_mixer}, | |
14458 | .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs }, | |
14459 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
14460 | .dac_nids = alc662_dac_nids, | |
14461 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
14462 | .channel_mode = alc662_3ST_2ch_modes, | |
14463 | .input_mux = &alc663_m51va_capture_source, | |
14464 | .unsol_event = alc663_m51va_unsol_event, | |
14465 | .init_hook = alc663_m51va_inithook, | |
14466 | }, | |
14467 | [ALC663_ASUS_G50V] = { | |
14468 | .mixers = { alc663_g50v_mixer, alc662_capture_mixer}, | |
14469 | .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs }, | |
14470 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
14471 | .dac_nids = alc662_dac_nids, | |
14472 | .dig_out_nid = ALC662_DIGOUT_NID, | |
14473 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), | |
14474 | .channel_mode = alc662_3ST_6ch_modes, | |
14475 | .input_mux = &alc663_capture_source, | |
14476 | .unsol_event = alc663_g50v_unsol_event, | |
14477 | .init_hook = alc663_g50v_inithook, | |
14478 | }, | |
bc9f98a9 KY |
14479 | }; |
14480 | ||
14481 | ||
14482 | /* | |
14483 | * BIOS auto configuration | |
14484 | */ | |
14485 | ||
14486 | /* add playback controls from the parsed DAC table */ | |
14487 | static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec, | |
14488 | const struct auto_pin_cfg *cfg) | |
14489 | { | |
14490 | char name[32]; | |
14491 | static const char *chname[4] = { | |
14492 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
14493 | }; | |
14494 | hda_nid_t nid; | |
14495 | int i, err; | |
14496 | ||
14497 | for (i = 0; i < cfg->line_outs; i++) { | |
14498 | if (!spec->multiout.dac_nids[i]) | |
14499 | continue; | |
b60dd394 | 14500 | nid = alc880_idx_to_dac(i); |
bc9f98a9 KY |
14501 | if (i == 2) { |
14502 | /* Center/LFE */ | |
14503 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
14504 | "Center Playback Volume", | |
f12ab1e0 TI |
14505 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, |
14506 | HDA_OUTPUT)); | |
bc9f98a9 KY |
14507 | if (err < 0) |
14508 | return err; | |
14509 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
14510 | "LFE Playback Volume", | |
f12ab1e0 TI |
14511 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, |
14512 | HDA_OUTPUT)); | |
bc9f98a9 KY |
14513 | if (err < 0) |
14514 | return err; | |
14515 | err = add_control(spec, ALC_CTL_BIND_MUTE, | |
14516 | "Center Playback Switch", | |
f12ab1e0 TI |
14517 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, |
14518 | HDA_INPUT)); | |
bc9f98a9 KY |
14519 | if (err < 0) |
14520 | return err; | |
14521 | err = add_control(spec, ALC_CTL_BIND_MUTE, | |
14522 | "LFE Playback Switch", | |
f12ab1e0 TI |
14523 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, |
14524 | HDA_INPUT)); | |
bc9f98a9 KY |
14525 | if (err < 0) |
14526 | return err; | |
14527 | } else { | |
14528 | sprintf(name, "%s Playback Volume", chname[i]); | |
14529 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
f12ab1e0 TI |
14530 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, |
14531 | HDA_OUTPUT)); | |
bc9f98a9 KY |
14532 | if (err < 0) |
14533 | return err; | |
14534 | sprintf(name, "%s Playback Switch", chname[i]); | |
14535 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | |
f12ab1e0 TI |
14536 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, |
14537 | HDA_INPUT)); | |
bc9f98a9 KY |
14538 | if (err < 0) |
14539 | return err; | |
14540 | } | |
14541 | } | |
14542 | return 0; | |
14543 | } | |
14544 | ||
14545 | /* add playback controls for speaker and HP outputs */ | |
14546 | static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, | |
14547 | const char *pfx) | |
14548 | { | |
14549 | hda_nid_t nid; | |
14550 | int err; | |
14551 | char name[32]; | |
14552 | ||
14553 | if (!pin) | |
14554 | return 0; | |
14555 | ||
14556 | if (alc880_is_fixed_pin(pin)) { | |
14557 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
14558 | /* printk("DAC nid=%x\n",nid); */ | |
14559 | /* specify the DAC as the extra output */ | |
14560 | if (!spec->multiout.hp_nid) | |
14561 | spec->multiout.hp_nid = nid; | |
14562 | else | |
14563 | spec->multiout.extra_out_nid[0] = nid; | |
14564 | /* control HP volume/switch on the output mixer amp */ | |
14565 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
14566 | sprintf(name, "%s Playback Volume", pfx); | |
14567 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
14568 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
14569 | if (err < 0) | |
14570 | return err; | |
14571 | sprintf(name, "%s Playback Switch", pfx); | |
14572 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | |
14573 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); | |
14574 | if (err < 0) | |
14575 | return err; | |
14576 | } else if (alc880_is_multi_pin(pin)) { | |
14577 | /* set manual connection */ | |
14578 | /* we have only a switch on HP-out PIN */ | |
14579 | sprintf(name, "%s Playback Switch", pfx); | |
14580 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | |
14581 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
14582 | if (err < 0) | |
14583 | return err; | |
14584 | } | |
14585 | return 0; | |
14586 | } | |
14587 | ||
14588 | /* create playback/capture controls for input pins */ | |
14589 | static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec, | |
14590 | const struct auto_pin_cfg *cfg) | |
14591 | { | |
14592 | struct hda_input_mux *imux = &spec->private_imux; | |
14593 | int i, err, idx; | |
14594 | ||
14595 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
14596 | if (alc880_is_input_pin(cfg->input_pins[i])) { | |
14597 | idx = alc880_input_pin_idx(cfg->input_pins[i]); | |
14598 | err = new_analog_input(spec, cfg->input_pins[i], | |
14599 | auto_pin_cfg_labels[i], | |
14600 | idx, 0x0b); | |
14601 | if (err < 0) | |
14602 | return err; | |
14603 | imux->items[imux->num_items].label = | |
14604 | auto_pin_cfg_labels[i]; | |
14605 | imux->items[imux->num_items].index = | |
14606 | alc880_input_pin_idx(cfg->input_pins[i]); | |
14607 | imux->num_items++; | |
14608 | } | |
14609 | } | |
14610 | return 0; | |
14611 | } | |
14612 | ||
14613 | static void alc662_auto_set_output_and_unmute(struct hda_codec *codec, | |
14614 | hda_nid_t nid, int pin_type, | |
14615 | int dac_idx) | |
14616 | { | |
f6c7e546 | 14617 | alc_set_pin_output(codec, nid, pin_type); |
bc9f98a9 KY |
14618 | /* need the manual connection? */ |
14619 | if (alc880_is_multi_pin(nid)) { | |
14620 | struct alc_spec *spec = codec->spec; | |
14621 | int idx = alc880_multi_pin_idx(nid); | |
14622 | snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, | |
14623 | AC_VERB_SET_CONNECT_SEL, | |
14624 | alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); | |
14625 | } | |
14626 | } | |
14627 | ||
14628 | static void alc662_auto_init_multi_out(struct hda_codec *codec) | |
14629 | { | |
14630 | struct alc_spec *spec = codec->spec; | |
14631 | int i; | |
14632 | ||
8c427226 | 14633 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
bc9f98a9 KY |
14634 | for (i = 0; i <= HDA_SIDE; i++) { |
14635 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 14636 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
bc9f98a9 | 14637 | if (nid) |
baba8ee9 | 14638 | alc662_auto_set_output_and_unmute(codec, nid, pin_type, |
bc9f98a9 KY |
14639 | i); |
14640 | } | |
14641 | } | |
14642 | ||
14643 | static void alc662_auto_init_hp_out(struct hda_codec *codec) | |
14644 | { | |
14645 | struct alc_spec *spec = codec->spec; | |
14646 | hda_nid_t pin; | |
14647 | ||
14648 | pin = spec->autocfg.hp_pins[0]; | |
14649 | if (pin) /* connect to front */ | |
14650 | /* use dac 0 */ | |
14651 | alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
f6c7e546 TI |
14652 | pin = spec->autocfg.speaker_pins[0]; |
14653 | if (pin) | |
14654 | alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
bc9f98a9 KY |
14655 | } |
14656 | ||
14657 | #define alc662_is_input_pin(nid) alc880_is_input_pin(nid) | |
14658 | #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID | |
14659 | ||
14660 | static void alc662_auto_init_analog_input(struct hda_codec *codec) | |
14661 | { | |
14662 | struct alc_spec *spec = codec->spec; | |
14663 | int i; | |
14664 | ||
14665 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
14666 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
14667 | if (alc662_is_input_pin(nid)) { | |
14668 | snd_hda_codec_write(codec, nid, 0, | |
14669 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
14670 | (i <= AUTO_PIN_FRONT_MIC ? | |
14671 | PIN_VREF80 : PIN_IN)); | |
14672 | if (nid != ALC662_PIN_CD_NID) | |
14673 | snd_hda_codec_write(codec, nid, 0, | |
14674 | AC_VERB_SET_AMP_GAIN_MUTE, | |
14675 | AMP_OUT_MUTE); | |
14676 | } | |
14677 | } | |
14678 | } | |
14679 | ||
14680 | static int alc662_parse_auto_config(struct hda_codec *codec) | |
14681 | { | |
14682 | struct alc_spec *spec = codec->spec; | |
14683 | int err; | |
14684 | static hda_nid_t alc662_ignore[] = { 0x1d, 0 }; | |
14685 | ||
14686 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | |
14687 | alc662_ignore); | |
14688 | if (err < 0) | |
14689 | return err; | |
14690 | if (!spec->autocfg.line_outs) | |
14691 | return 0; /* can't find valid BIOS pin config */ | |
14692 | ||
f12ab1e0 TI |
14693 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
14694 | if (err < 0) | |
14695 | return err; | |
14696 | err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
14697 | if (err < 0) | |
14698 | return err; | |
14699 | err = alc662_auto_create_extra_out(spec, | |
14700 | spec->autocfg.speaker_pins[0], | |
14701 | "Speaker"); | |
14702 | if (err < 0) | |
14703 | return err; | |
14704 | err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], | |
14705 | "Headphone"); | |
14706 | if (err < 0) | |
14707 | return err; | |
14708 | err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
14709 | if (err < 0) | |
bc9f98a9 KY |
14710 | return err; |
14711 | ||
14712 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
14713 | ||
14714 | if (spec->autocfg.dig_out_pin) | |
14715 | spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; | |
14716 | ||
14717 | if (spec->kctl_alloc) | |
14718 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
14719 | ||
14720 | spec->num_mux_defs = 1; | |
14721 | spec->input_mux = &spec->private_imux; | |
14722 | ||
8c87286f | 14723 | spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs; |
bc9f98a9 KY |
14724 | spec->mixers[spec->num_mixers] = alc662_capture_mixer; |
14725 | spec->num_mixers++; | |
8c87286f | 14726 | return 1; |
bc9f98a9 KY |
14727 | } |
14728 | ||
14729 | /* additional initialization for auto-configuration model */ | |
14730 | static void alc662_auto_init(struct hda_codec *codec) | |
14731 | { | |
f6c7e546 | 14732 | struct alc_spec *spec = codec->spec; |
bc9f98a9 KY |
14733 | alc662_auto_init_multi_out(codec); |
14734 | alc662_auto_init_hp_out(codec); | |
14735 | alc662_auto_init_analog_input(codec); | |
f6c7e546 TI |
14736 | if (spec->unsol_event) |
14737 | alc_sku_automute(codec); | |
bc9f98a9 KY |
14738 | } |
14739 | ||
14740 | static int patch_alc662(struct hda_codec *codec) | |
14741 | { | |
14742 | struct alc_spec *spec; | |
14743 | int err, board_config; | |
14744 | ||
14745 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
14746 | if (!spec) | |
14747 | return -ENOMEM; | |
14748 | ||
14749 | codec->spec = spec; | |
14750 | ||
2c3bf9ab TI |
14751 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
14752 | ||
bc9f98a9 KY |
14753 | board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST, |
14754 | alc662_models, | |
14755 | alc662_cfg_tbl); | |
14756 | if (board_config < 0) { | |
14757 | printk(KERN_INFO "hda_codec: Unknown model for ALC662, " | |
14758 | "trying auto-probe from BIOS...\n"); | |
14759 | board_config = ALC662_AUTO; | |
14760 | } | |
14761 | ||
14762 | if (board_config == ALC662_AUTO) { | |
14763 | /* automatic parse from the BIOS config */ | |
14764 | err = alc662_parse_auto_config(codec); | |
14765 | if (err < 0) { | |
14766 | alc_free(codec); | |
14767 | return err; | |
8c87286f | 14768 | } else if (!err) { |
bc9f98a9 KY |
14769 | printk(KERN_INFO |
14770 | "hda_codec: Cannot set up configuration " | |
14771 | "from BIOS. Using base mode...\n"); | |
14772 | board_config = ALC662_3ST_2ch_DIG; | |
14773 | } | |
14774 | } | |
14775 | ||
14776 | if (board_config != ALC662_AUTO) | |
14777 | setup_preset(spec, &alc662_presets[board_config]); | |
14778 | ||
6dda9f4a KY |
14779 | if (codec->vendor_id == 0x10ec0663) { |
14780 | spec->stream_name_analog = "ALC663 Analog"; | |
14781 | spec->stream_name_digital = "ALC663 Digital"; | |
14782 | } else { | |
14783 | spec->stream_name_analog = "ALC662 Analog"; | |
14784 | spec->stream_name_digital = "ALC662 Digital"; | |
14785 | } | |
14786 | ||
bc9f98a9 KY |
14787 | spec->stream_analog_playback = &alc662_pcm_analog_playback; |
14788 | spec->stream_analog_capture = &alc662_pcm_analog_capture; | |
14789 | ||
bc9f98a9 KY |
14790 | spec->stream_digital_playback = &alc662_pcm_digital_playback; |
14791 | spec->stream_digital_capture = &alc662_pcm_digital_capture; | |
14792 | ||
e1406348 TI |
14793 | spec->adc_nids = alc662_adc_nids; |
14794 | spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids); | |
14795 | spec->capsrc_nids = alc662_capsrc_nids; | |
bc9f98a9 | 14796 | |
2134ea4f TI |
14797 | spec->vmaster_nid = 0x02; |
14798 | ||
bc9f98a9 KY |
14799 | codec->patch_ops = alc_patch_ops; |
14800 | if (board_config == ALC662_AUTO) | |
14801 | spec->init_hook = alc662_auto_init; | |
cb53c626 TI |
14802 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
14803 | if (!spec->loopback.amplist) | |
14804 | spec->loopback.amplist = alc662_loopbacks; | |
14805 | #endif | |
bc9f98a9 KY |
14806 | |
14807 | return 0; | |
14808 | } | |
14809 | ||
1da177e4 LT |
14810 | /* |
14811 | * patch entries | |
14812 | */ | |
14813 | struct hda_codec_preset snd_hda_preset_realtek[] = { | |
14814 | { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, | |
df694daa | 14815 | { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, |
f6a92248 | 14816 | { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, |
a361d84b | 14817 | { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, |
f6a92248 | 14818 | { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 }, |
f32610ed | 14819 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", |
bc9f98a9 | 14820 | .patch = patch_alc861 }, |
f32610ed JS |
14821 | { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, |
14822 | { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, | |
14823 | { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, | |
bc9f98a9 KY |
14824 | { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", |
14825 | .patch = patch_alc883 }, | |
14826 | { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", | |
14827 | .patch = patch_alc662 }, | |
6dda9f4a | 14828 | { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, |
f32610ed | 14829 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
1da177e4 | 14830 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, |
9c7f852e | 14831 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 }, |
cb308f97 | 14832 | { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", |
7943a8ab | 14833 | .patch = patch_alc882 }, /* should be patch_alc883() in future */ |
df694daa | 14834 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, |
9c7f852e | 14835 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 }, |
f6a92248 | 14836 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 }, |
1da177e4 LT |
14837 | {} /* terminator */ |
14838 | }; |