]>
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 | ||
26 | #include <sound/driver.h> | |
27 | #include <linux/init.h> | |
28 | #include <linux/delay.h> | |
29 | #include <linux/slab.h> | |
30 | #include <linux/pci.h> | |
31 | #include <sound/core.h> | |
32 | #include "hda_codec.h" | |
33 | #include "hda_local.h" | |
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, |
e9edcee0 TI |
63 | #ifdef CONFIG_SND_DEBUG |
64 | ALC880_TEST, | |
65 | #endif | |
df694daa | 66 | ALC880_AUTO, |
16ded525 TI |
67 | ALC880_MODEL_LAST /* last tag */ |
68 | }; | |
69 | ||
70 | /* ALC260 models */ | |
71 | enum { | |
72 | ALC260_BASIC, | |
73 | ALC260_HP, | |
df694daa KY |
74 | ALC260_HP_3013, |
75 | ALC260_FUJITSU_S702X, | |
0bfc90e9 | 76 | ALC260_ACER, |
bc9f98a9 KY |
77 | ALC260_WILL, |
78 | ALC260_REPLACER_672V, | |
7cf51e48 JW |
79 | #ifdef CONFIG_SND_DEBUG |
80 | ALC260_TEST, | |
81 | #endif | |
df694daa | 82 | ALC260_AUTO, |
16ded525 | 83 | ALC260_MODEL_LAST /* last tag */ |
1da177e4 LT |
84 | }; |
85 | ||
df694daa KY |
86 | /* ALC262 models */ |
87 | enum { | |
88 | ALC262_BASIC, | |
ccc656ce KY |
89 | ALC262_HIPPO, |
90 | ALC262_HIPPO_1, | |
834be88d | 91 | ALC262_FUJITSU, |
9c7f852e | 92 | ALC262_HP_BPC, |
cd7509a4 KY |
93 | ALC262_HP_BPC_D7000_WL, |
94 | ALC262_HP_BPC_D7000_WF, | |
304dcaac | 95 | ALC262_BENQ_ED8, |
272a527c | 96 | ALC262_SONY_ASSAMD, |
83c34218 | 97 | ALC262_BENQ_T31, |
df694daa KY |
98 | ALC262_AUTO, |
99 | ALC262_MODEL_LAST /* last tag */ | |
100 | }; | |
101 | ||
a361d84b KY |
102 | /* ALC268 models */ |
103 | enum { | |
104 | ALC268_3ST, | |
105 | ALC268_AUTO, | |
106 | ALC268_MODEL_LAST /* last tag */ | |
107 | }; | |
108 | ||
df694daa KY |
109 | /* ALC861 models */ |
110 | enum { | |
111 | ALC861_3ST, | |
9c7f852e | 112 | ALC660_3ST, |
df694daa KY |
113 | ALC861_3ST_DIG, |
114 | ALC861_6ST_DIG, | |
22309c3e | 115 | ALC861_UNIWILL_M31, |
a53d1aec | 116 | ALC861_TOSHIBA, |
7cdbff94 | 117 | ALC861_ASUS, |
56bb0cab | 118 | ALC861_ASUS_LAPTOP, |
df694daa KY |
119 | ALC861_AUTO, |
120 | ALC861_MODEL_LAST, | |
121 | }; | |
122 | ||
f32610ed JS |
123 | /* ALC861-VD models */ |
124 | enum { | |
125 | ALC660VD_3ST, | |
6963f84c | 126 | ALC660VD_3ST_DIG, |
f32610ed JS |
127 | ALC861VD_3ST, |
128 | ALC861VD_3ST_DIG, | |
129 | ALC861VD_6ST_DIG, | |
bdd148a3 | 130 | ALC861VD_LENOVO, |
272a527c | 131 | ALC861VD_DALLAS, |
f32610ed JS |
132 | ALC861VD_AUTO, |
133 | ALC861VD_MODEL_LAST, | |
134 | }; | |
135 | ||
bc9f98a9 KY |
136 | /* ALC662 models */ |
137 | enum { | |
138 | ALC662_3ST_2ch_DIG, | |
139 | ALC662_3ST_6ch_DIG, | |
140 | ALC662_3ST_6ch, | |
141 | ALC662_5ST_DIG, | |
142 | ALC662_LENOVO_101E, | |
143 | ALC662_AUTO, | |
144 | ALC662_MODEL_LAST, | |
145 | }; | |
146 | ||
df694daa KY |
147 | /* ALC882 models */ |
148 | enum { | |
149 | ALC882_3ST_DIG, | |
150 | ALC882_6ST_DIG, | |
4b146cb0 | 151 | ALC882_ARIMA, |
bdd148a3 | 152 | ALC882_W2JC, |
272a527c KY |
153 | ALC882_TARGA, |
154 | ALC882_ASUS_A7J, | |
9102cd1c | 155 | ALC885_MACPRO, |
272a527c | 156 | ALC882_AUTO, |
df694daa KY |
157 | ALC882_MODEL_LAST, |
158 | }; | |
159 | ||
9c7f852e TI |
160 | /* ALC883 models */ |
161 | enum { | |
162 | ALC883_3ST_2ch_DIG, | |
163 | ALC883_3ST_6ch_DIG, | |
164 | ALC883_3ST_6ch, | |
165 | ALC883_6ST_DIG, | |
ccc656ce KY |
166 | ALC883_TARGA_DIG, |
167 | ALC883_TARGA_2ch_DIG, | |
bab282b9 | 168 | ALC883_ACER, |
c07584c8 | 169 | ALC883_MEDION, |
272a527c | 170 | ALC883_MEDION_MD2, |
b373bdeb | 171 | ALC883_LAPTOP_EAPD, |
bc9f98a9 | 172 | ALC883_LENOVO_101E_2ch, |
272a527c KY |
173 | ALC883_LENOVO_NB0763, |
174 | ALC888_LENOVO_MS7195_DIG, | |
cd1e3b40 | 175 | ALC888_HP_NETTLE, |
9c7f852e TI |
176 | ALC883_AUTO, |
177 | ALC883_MODEL_LAST, | |
178 | }; | |
179 | ||
df694daa KY |
180 | /* for GPIO Poll */ |
181 | #define GPIO_MASK 0x03 | |
182 | ||
1da177e4 LT |
183 | struct alc_spec { |
184 | /* codec parameterization */ | |
df694daa | 185 | struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ |
1da177e4 LT |
186 | unsigned int num_mixers; |
187 | ||
df694daa | 188 | const struct hda_verb *init_verbs[5]; /* initialization verbs |
9c7f852e TI |
189 | * don't forget NULL |
190 | * termination! | |
e9edcee0 TI |
191 | */ |
192 | unsigned int num_init_verbs; | |
1da177e4 | 193 | |
16ded525 | 194 | char *stream_name_analog; /* analog PCM stream */ |
1da177e4 LT |
195 | struct hda_pcm_stream *stream_analog_playback; |
196 | struct hda_pcm_stream *stream_analog_capture; | |
197 | ||
f12ab1e0 | 198 | char *stream_name_digital; /* digital PCM stream */ |
1da177e4 LT |
199 | struct hda_pcm_stream *stream_digital_playback; |
200 | struct hda_pcm_stream *stream_digital_capture; | |
201 | ||
202 | /* playback */ | |
16ded525 TI |
203 | struct hda_multi_out multiout; /* playback set-up |
204 | * max_channels, dacs must be set | |
205 | * dig_out_nid and hp_nid are optional | |
206 | */ | |
1da177e4 LT |
207 | |
208 | /* capture */ | |
209 | unsigned int num_adc_nids; | |
210 | hda_nid_t *adc_nids; | |
16ded525 | 211 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
1da177e4 LT |
212 | |
213 | /* capture source */ | |
a1e8d2da | 214 | unsigned int num_mux_defs; |
1da177e4 LT |
215 | const struct hda_input_mux *input_mux; |
216 | unsigned int cur_mux[3]; | |
217 | ||
218 | /* channel model */ | |
d2a6d7dc | 219 | const struct hda_channel_mode *channel_mode; |
1da177e4 | 220 | int num_channel_mode; |
4e195a7b | 221 | int need_dac_fix; |
1da177e4 LT |
222 | |
223 | /* PCM information */ | |
4c5186ed | 224 | struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ |
41e41f1f | 225 | |
e9edcee0 TI |
226 | /* dynamic controls, init_verbs and input_mux */ |
227 | struct auto_pin_cfg autocfg; | |
228 | unsigned int num_kctl_alloc, num_kctl_used; | |
c8b6bf9b | 229 | struct snd_kcontrol_new *kctl_alloc; |
e9edcee0 | 230 | struct hda_input_mux private_imux; |
df694daa | 231 | hda_nid_t private_dac_nids[5]; |
834be88d | 232 | |
ae6b813a TI |
233 | /* hooks */ |
234 | void (*init_hook)(struct hda_codec *codec); | |
235 | void (*unsol_event)(struct hda_codec *codec, unsigned int res); | |
236 | ||
834be88d TI |
237 | /* for pin sensing */ |
238 | unsigned int sense_updated: 1; | |
239 | unsigned int jack_present: 1; | |
df694daa KY |
240 | }; |
241 | ||
242 | /* | |
243 | * configuration template - to be copied to the spec instance | |
244 | */ | |
245 | struct alc_config_preset { | |
9c7f852e TI |
246 | struct snd_kcontrol_new *mixers[5]; /* should be identical size |
247 | * with spec | |
248 | */ | |
df694daa KY |
249 | const struct hda_verb *init_verbs[5]; |
250 | unsigned int num_dacs; | |
251 | hda_nid_t *dac_nids; | |
252 | hda_nid_t dig_out_nid; /* optional */ | |
253 | hda_nid_t hp_nid; /* optional */ | |
254 | unsigned int num_adc_nids; | |
255 | hda_nid_t *adc_nids; | |
256 | hda_nid_t dig_in_nid; | |
257 | unsigned int num_channel_mode; | |
258 | const struct hda_channel_mode *channel_mode; | |
4e195a7b | 259 | int need_dac_fix; |
a1e8d2da | 260 | unsigned int num_mux_defs; |
df694daa | 261 | const struct hda_input_mux *input_mux; |
ae6b813a TI |
262 | void (*unsol_event)(struct hda_codec *, unsigned int); |
263 | void (*init_hook)(struct hda_codec *); | |
1da177e4 LT |
264 | }; |
265 | ||
1da177e4 LT |
266 | |
267 | /* | |
268 | * input MUX handling | |
269 | */ | |
9c7f852e TI |
270 | static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, |
271 | struct snd_ctl_elem_info *uinfo) | |
1da177e4 LT |
272 | { |
273 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
274 | struct alc_spec *spec = codec->spec; | |
a1e8d2da JW |
275 | unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id); |
276 | if (mux_idx >= spec->num_mux_defs) | |
277 | mux_idx = 0; | |
278 | return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo); | |
1da177e4 LT |
279 | } |
280 | ||
9c7f852e TI |
281 | static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, |
282 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
283 | { |
284 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
285 | struct alc_spec *spec = codec->spec; | |
286 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
287 | ||
288 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; | |
289 | return 0; | |
290 | } | |
291 | ||
9c7f852e TI |
292 | static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, |
293 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
294 | { |
295 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
296 | struct alc_spec *spec = codec->spec; | |
297 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
a1e8d2da JW |
298 | unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; |
299 | return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol, | |
9c7f852e TI |
300 | spec->adc_nids[adc_idx], |
301 | &spec->cur_mux[adc_idx]); | |
1da177e4 LT |
302 | } |
303 | ||
e9edcee0 | 304 | |
1da177e4 LT |
305 | /* |
306 | * channel mode setting | |
307 | */ | |
9c7f852e TI |
308 | static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, |
309 | struct snd_ctl_elem_info *uinfo) | |
1da177e4 LT |
310 | { |
311 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
312 | struct alc_spec *spec = codec->spec; | |
d2a6d7dc TI |
313 | return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, |
314 | spec->num_channel_mode); | |
1da177e4 LT |
315 | } |
316 | ||
9c7f852e TI |
317 | static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, |
318 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
319 | { |
320 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
321 | struct alc_spec *spec = codec->spec; | |
d2a6d7dc | 322 | return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, |
9c7f852e TI |
323 | spec->num_channel_mode, |
324 | spec->multiout.max_channels); | |
1da177e4 LT |
325 | } |
326 | ||
9c7f852e TI |
327 | static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, |
328 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
329 | { |
330 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
331 | struct alc_spec *spec = codec->spec; | |
4e195a7b TI |
332 | int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, |
333 | spec->num_channel_mode, | |
334 | &spec->multiout.max_channels); | |
bd2033f2 | 335 | if (err >= 0 && spec->need_dac_fix) |
4e195a7b TI |
336 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; |
337 | return err; | |
1da177e4 LT |
338 | } |
339 | ||
a9430dd8 | 340 | /* |
4c5186ed JW |
341 | * Control the mode of pin widget settings via the mixer. "pc" is used |
342 | * instead of "%" to avoid consequences of accidently treating the % as | |
343 | * being part of a format specifier. Maximum allowed length of a value is | |
344 | * 63 characters plus NULL terminator. | |
7cf51e48 JW |
345 | * |
346 | * Note: some retasking pin complexes seem to ignore requests for input | |
347 | * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these | |
348 | * are requested. Therefore order this list so that this behaviour will not | |
349 | * cause problems when mixer clients move through the enum sequentially. | |
a1e8d2da JW |
350 | * NIDs 0x0f and 0x10 have been observed to have this behaviour as of |
351 | * March 2006. | |
4c5186ed JW |
352 | */ |
353 | static char *alc_pin_mode_names[] = { | |
7cf51e48 JW |
354 | "Mic 50pc bias", "Mic 80pc bias", |
355 | "Line in", "Line out", "Headphone out", | |
4c5186ed JW |
356 | }; |
357 | static unsigned char alc_pin_mode_values[] = { | |
7cf51e48 | 358 | PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP, |
4c5186ed JW |
359 | }; |
360 | /* The control can present all 5 options, or it can limit the options based | |
a1e8d2da JW |
361 | * in the pin being assumed to be exclusively an input or an output pin. In |
362 | * addition, "input" pins may or may not process the mic bias option | |
363 | * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to | |
364 | * accept requests for bias as of chip versions up to March 2006) and/or | |
365 | * wiring in the computer. | |
a9430dd8 | 366 | */ |
a1e8d2da JW |
367 | #define ALC_PIN_DIR_IN 0x00 |
368 | #define ALC_PIN_DIR_OUT 0x01 | |
369 | #define ALC_PIN_DIR_INOUT 0x02 | |
370 | #define ALC_PIN_DIR_IN_NOMICBIAS 0x03 | |
371 | #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04 | |
4c5186ed | 372 | |
a1e8d2da | 373 | /* Info about the pin modes supported by the different pin direction modes. |
4c5186ed JW |
374 | * For each direction the minimum and maximum values are given. |
375 | */ | |
a1e8d2da | 376 | static signed char alc_pin_mode_dir_info[5][2] = { |
4c5186ed JW |
377 | { 0, 2 }, /* ALC_PIN_DIR_IN */ |
378 | { 3, 4 }, /* ALC_PIN_DIR_OUT */ | |
379 | { 0, 4 }, /* ALC_PIN_DIR_INOUT */ | |
a1e8d2da JW |
380 | { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */ |
381 | { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */ | |
4c5186ed JW |
382 | }; |
383 | #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0]) | |
384 | #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1]) | |
385 | #define alc_pin_mode_n_items(_dir) \ | |
386 | (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1) | |
387 | ||
9c7f852e TI |
388 | static int alc_pin_mode_info(struct snd_kcontrol *kcontrol, |
389 | struct snd_ctl_elem_info *uinfo) | |
a9430dd8 | 390 | { |
4c5186ed JW |
391 | unsigned int item_num = uinfo->value.enumerated.item; |
392 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; | |
393 | ||
394 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
a9430dd8 | 395 | uinfo->count = 1; |
4c5186ed JW |
396 | uinfo->value.enumerated.items = alc_pin_mode_n_items(dir); |
397 | ||
398 | if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir)) | |
399 | item_num = alc_pin_mode_min(dir); | |
400 | strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]); | |
a9430dd8 JW |
401 | return 0; |
402 | } | |
403 | ||
9c7f852e TI |
404 | static int alc_pin_mode_get(struct snd_kcontrol *kcontrol, |
405 | struct snd_ctl_elem_value *ucontrol) | |
a9430dd8 | 406 | { |
4c5186ed | 407 | unsigned int i; |
a9430dd8 JW |
408 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
409 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
4c5186ed | 410 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
a9430dd8 | 411 | long *valp = ucontrol->value.integer.value; |
9c7f852e TI |
412 | unsigned int pinctl = snd_hda_codec_read(codec, nid, 0, |
413 | AC_VERB_GET_PIN_WIDGET_CONTROL, | |
414 | 0x00); | |
a9430dd8 | 415 | |
4c5186ed JW |
416 | /* Find enumerated value for current pinctl setting */ |
417 | i = alc_pin_mode_min(dir); | |
9c7f852e | 418 | while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir)) |
4c5186ed | 419 | i++; |
9c7f852e | 420 | *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir); |
a9430dd8 JW |
421 | return 0; |
422 | } | |
423 | ||
9c7f852e TI |
424 | static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, |
425 | struct snd_ctl_elem_value *ucontrol) | |
a9430dd8 | 426 | { |
4c5186ed | 427 | signed int change; |
a9430dd8 JW |
428 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
429 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
4c5186ed JW |
430 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
431 | long val = *ucontrol->value.integer.value; | |
9c7f852e TI |
432 | unsigned int pinctl = snd_hda_codec_read(codec, nid, 0, |
433 | AC_VERB_GET_PIN_WIDGET_CONTROL, | |
434 | 0x00); | |
a9430dd8 | 435 | |
f12ab1e0 | 436 | if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir)) |
4c5186ed JW |
437 | val = alc_pin_mode_min(dir); |
438 | ||
439 | change = pinctl != alc_pin_mode_values[val]; | |
cdcd9268 JW |
440 | if (change) { |
441 | /* Set pin mode to that requested */ | |
a9430dd8 | 442 | snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL, |
9c7f852e | 443 | alc_pin_mode_values[val]); |
cdcd9268 JW |
444 | |
445 | /* Also enable the retasking pin's input/output as required | |
446 | * for the requested pin mode. Enum values of 2 or less are | |
447 | * input modes. | |
448 | * | |
449 | * Dynamically switching the input/output buffers probably | |
a1e8d2da JW |
450 | * reduces noise slightly (particularly on input) so we'll |
451 | * do it. However, having both input and output buffers | |
452 | * enabled simultaneously doesn't seem to be problematic if | |
453 | * this turns out to be necessary in the future. | |
cdcd9268 JW |
454 | */ |
455 | if (val <= 2) { | |
9c7f852e TI |
456 | snd_hda_codec_write(codec, nid, 0, |
457 | AC_VERB_SET_AMP_GAIN_MUTE, | |
458 | AMP_OUT_MUTE); | |
459 | snd_hda_codec_write(codec, nid, 0, | |
460 | AC_VERB_SET_AMP_GAIN_MUTE, | |
461 | AMP_IN_UNMUTE(0)); | |
cdcd9268 | 462 | } else { |
9c7f852e TI |
463 | snd_hda_codec_write(codec, nid, 0, |
464 | AC_VERB_SET_AMP_GAIN_MUTE, | |
465 | AMP_IN_MUTE(0)); | |
466 | snd_hda_codec_write(codec, nid, 0, | |
467 | AC_VERB_SET_AMP_GAIN_MUTE, | |
468 | AMP_OUT_UNMUTE); | |
cdcd9268 JW |
469 | } |
470 | } | |
a9430dd8 JW |
471 | return change; |
472 | } | |
473 | ||
4c5186ed | 474 | #define ALC_PIN_MODE(xname, nid, dir) \ |
a9430dd8 | 475 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ |
4c5186ed JW |
476 | .info = alc_pin_mode_info, \ |
477 | .get = alc_pin_mode_get, \ | |
478 | .put = alc_pin_mode_put, \ | |
479 | .private_value = nid | (dir<<16) } | |
df694daa | 480 | |
5c8f858d JW |
481 | /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged |
482 | * together using a mask with more than one bit set. This control is | |
483 | * currently used only by the ALC260 test model. At this stage they are not | |
484 | * needed for any "production" models. | |
485 | */ | |
486 | #ifdef CONFIG_SND_DEBUG | |
9c7f852e TI |
487 | static int alc_gpio_data_info(struct snd_kcontrol *kcontrol, |
488 | struct snd_ctl_elem_info *uinfo) | |
5c8f858d JW |
489 | { |
490 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | |
491 | uinfo->count = 1; | |
492 | uinfo->value.integer.min = 0; | |
493 | uinfo->value.integer.max = 1; | |
494 | return 0; | |
f12ab1e0 TI |
495 | } |
496 | ||
9c7f852e TI |
497 | static int alc_gpio_data_get(struct snd_kcontrol *kcontrol, |
498 | struct snd_ctl_elem_value *ucontrol) | |
5c8f858d JW |
499 | { |
500 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
501 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
502 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
503 | long *valp = ucontrol->value.integer.value; | |
9c7f852e TI |
504 | unsigned int val = snd_hda_codec_read(codec, nid, 0, |
505 | AC_VERB_GET_GPIO_DATA, 0x00); | |
5c8f858d JW |
506 | |
507 | *valp = (val & mask) != 0; | |
508 | return 0; | |
509 | } | |
9c7f852e TI |
510 | static int alc_gpio_data_put(struct snd_kcontrol *kcontrol, |
511 | struct snd_ctl_elem_value *ucontrol) | |
5c8f858d JW |
512 | { |
513 | signed int change; | |
514 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
515 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
516 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
517 | long val = *ucontrol->value.integer.value; | |
9c7f852e TI |
518 | unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0, |
519 | AC_VERB_GET_GPIO_DATA, | |
520 | 0x00); | |
5c8f858d JW |
521 | |
522 | /* Set/unset the masked GPIO bit(s) as needed */ | |
9c7f852e TI |
523 | change = (val == 0 ? 0 : mask) != (gpio_data & mask); |
524 | if (val == 0) | |
5c8f858d JW |
525 | gpio_data &= ~mask; |
526 | else | |
527 | gpio_data |= mask; | |
9c7f852e | 528 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data); |
5c8f858d JW |
529 | |
530 | return change; | |
531 | } | |
532 | #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \ | |
533 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
534 | .info = alc_gpio_data_info, \ | |
535 | .get = alc_gpio_data_get, \ | |
536 | .put = alc_gpio_data_put, \ | |
537 | .private_value = nid | (mask<<16) } | |
538 | #endif /* CONFIG_SND_DEBUG */ | |
539 | ||
92621f13 JW |
540 | /* A switch control to allow the enabling of the digital IO pins on the |
541 | * ALC260. This is incredibly simplistic; the intention of this control is | |
542 | * to provide something in the test model allowing digital outputs to be | |
543 | * identified if present. If models are found which can utilise these | |
544 | * outputs a more complete mixer control can be devised for those models if | |
545 | * necessary. | |
546 | */ | |
547 | #ifdef CONFIG_SND_DEBUG | |
9c7f852e TI |
548 | static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol, |
549 | struct snd_ctl_elem_info *uinfo) | |
92621f13 JW |
550 | { |
551 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | |
552 | uinfo->count = 1; | |
553 | uinfo->value.integer.min = 0; | |
554 | uinfo->value.integer.max = 1; | |
555 | return 0; | |
f12ab1e0 TI |
556 | } |
557 | ||
9c7f852e TI |
558 | static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol, |
559 | struct snd_ctl_elem_value *ucontrol) | |
92621f13 JW |
560 | { |
561 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
562 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
563 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
564 | long *valp = ucontrol->value.integer.value; | |
9c7f852e TI |
565 | unsigned int val = snd_hda_codec_read(codec, nid, 0, |
566 | AC_VERB_GET_DIGI_CONVERT, 0x00); | |
92621f13 JW |
567 | |
568 | *valp = (val & mask) != 0; | |
569 | return 0; | |
570 | } | |
9c7f852e TI |
571 | static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol, |
572 | struct snd_ctl_elem_value *ucontrol) | |
92621f13 JW |
573 | { |
574 | signed int change; | |
575 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
576 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
577 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
578 | long val = *ucontrol->value.integer.value; | |
9c7f852e TI |
579 | unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0, |
580 | AC_VERB_GET_DIGI_CONVERT, | |
581 | 0x00); | |
92621f13 JW |
582 | |
583 | /* Set/unset the masked control bit(s) as needed */ | |
9c7f852e | 584 | change = (val == 0 ? 0 : mask) != (ctrl_data & mask); |
92621f13 JW |
585 | if (val==0) |
586 | ctrl_data &= ~mask; | |
587 | else | |
588 | ctrl_data |= mask; | |
9c7f852e TI |
589 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, |
590 | ctrl_data); | |
92621f13 JW |
591 | |
592 | return change; | |
593 | } | |
594 | #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \ | |
595 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
596 | .info = alc_spdif_ctrl_info, \ | |
597 | .get = alc_spdif_ctrl_get, \ | |
598 | .put = alc_spdif_ctrl_put, \ | |
599 | .private_value = nid | (mask<<16) } | |
600 | #endif /* CONFIG_SND_DEBUG */ | |
601 | ||
df694daa KY |
602 | /* |
603 | * set up from the preset table | |
604 | */ | |
9c7f852e TI |
605 | static void setup_preset(struct alc_spec *spec, |
606 | const struct alc_config_preset *preset) | |
df694daa KY |
607 | { |
608 | int i; | |
609 | ||
610 | for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++) | |
611 | spec->mixers[spec->num_mixers++] = preset->mixers[i]; | |
9c7f852e TI |
612 | for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; |
613 | i++) | |
614 | spec->init_verbs[spec->num_init_verbs++] = | |
615 | preset->init_verbs[i]; | |
df694daa KY |
616 | |
617 | spec->channel_mode = preset->channel_mode; | |
618 | spec->num_channel_mode = preset->num_channel_mode; | |
4e195a7b | 619 | spec->need_dac_fix = preset->need_dac_fix; |
df694daa KY |
620 | |
621 | spec->multiout.max_channels = spec->channel_mode[0].channels; | |
622 | ||
623 | spec->multiout.num_dacs = preset->num_dacs; | |
624 | spec->multiout.dac_nids = preset->dac_nids; | |
625 | spec->multiout.dig_out_nid = preset->dig_out_nid; | |
626 | spec->multiout.hp_nid = preset->hp_nid; | |
627 | ||
a1e8d2da | 628 | spec->num_mux_defs = preset->num_mux_defs; |
f12ab1e0 | 629 | if (!spec->num_mux_defs) |
a1e8d2da | 630 | spec->num_mux_defs = 1; |
df694daa KY |
631 | spec->input_mux = preset->input_mux; |
632 | ||
633 | spec->num_adc_nids = preset->num_adc_nids; | |
634 | spec->adc_nids = preset->adc_nids; | |
635 | spec->dig_in_nid = preset->dig_in_nid; | |
ae6b813a TI |
636 | |
637 | spec->unsol_event = preset->unsol_event; | |
638 | spec->init_hook = preset->init_hook; | |
df694daa KY |
639 | } |
640 | ||
bc9f98a9 KY |
641 | /* Enable GPIO mask and set output */ |
642 | static struct hda_verb alc_gpio1_init_verbs[] = { | |
643 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
644 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
645 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, | |
646 | { } | |
647 | }; | |
648 | ||
649 | static struct hda_verb alc_gpio2_init_verbs[] = { | |
650 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, | |
651 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, | |
652 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, | |
653 | { } | |
654 | }; | |
655 | ||
bdd148a3 KY |
656 | static struct hda_verb alc_gpio3_init_verbs[] = { |
657 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, | |
658 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | |
659 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | |
660 | { } | |
661 | }; | |
662 | ||
bc9f98a9 KY |
663 | /* 32-bit subsystem ID for BIOS loading in HD Audio codec. |
664 | * 31 ~ 16 : Manufacture ID | |
665 | * 15 ~ 8 : SKU ID | |
666 | * 7 ~ 0 : Assembly ID | |
667 | * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36 | |
668 | */ | |
669 | static void alc_subsystem_id(struct hda_codec *codec, | |
670 | unsigned int porta, unsigned int porte, | |
671 | unsigned int portd) | |
672 | { | |
673 | unsigned int ass, tmp; | |
674 | ||
675 | ass = codec->subsystem_id; | |
676 | if (!(ass & 1)) | |
677 | return; | |
678 | ||
679 | /* Override */ | |
680 | tmp = (ass & 0x38) >> 3; /* external Amp control */ | |
681 | switch (tmp) { | |
682 | case 1: | |
683 | snd_hda_sequence_write(codec, alc_gpio1_init_verbs); | |
684 | break; | |
685 | case 3: | |
686 | snd_hda_sequence_write(codec, alc_gpio2_init_verbs); | |
687 | break; | |
bdd148a3 KY |
688 | case 7: |
689 | snd_hda_sequence_write(codec, alc_gpio3_init_verbs); | |
690 | break; | |
bc9f98a9 | 691 | case 5: |
bdd148a3 KY |
692 | switch (codec->vendor_id) { |
693 | case 0x10ec0862: | |
694 | case 0x10ec0660: | |
695 | case 0x10ec0662: | |
696 | case 0x10ec0267: | |
697 | case 0x10ec0268: | |
698 | snd_hda_codec_write(codec, 0x14, 0, | |
699 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
700 | snd_hda_codec_write(codec, 0x15, 0, | |
701 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
702 | return; | |
703 | } | |
bc9f98a9 KY |
704 | case 6: |
705 | if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */ | |
706 | hda_nid_t port = 0; | |
707 | tmp = (ass & 0x1800) >> 11; | |
708 | switch (tmp) { | |
709 | case 0: port = porta; break; | |
710 | case 1: port = porte; break; | |
711 | case 2: port = portd; break; | |
712 | } | |
713 | if (port) | |
714 | snd_hda_codec_write(codec, port, 0, | |
715 | AC_VERB_SET_EAPD_BTLENABLE, | |
716 | 2); | |
717 | } | |
718 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); | |
719 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, | |
720 | (tmp == 5 ? 0x3040 : 0x3050)); | |
721 | break; | |
722 | } | |
723 | } | |
724 | ||
1da177e4 | 725 | /* |
e9edcee0 TI |
726 | * ALC880 3-stack model |
727 | * | |
728 | * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e) | |
9c7f852e TI |
729 | * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, |
730 | * F-Mic = 0x1b, HP = 0x19 | |
1da177e4 LT |
731 | */ |
732 | ||
e9edcee0 TI |
733 | static hda_nid_t alc880_dac_nids[4] = { |
734 | /* front, rear, clfe, rear_surr */ | |
735 | 0x02, 0x05, 0x04, 0x03 | |
736 | }; | |
737 | ||
738 | static hda_nid_t alc880_adc_nids[3] = { | |
739 | /* ADC0-2 */ | |
740 | 0x07, 0x08, 0x09, | |
741 | }; | |
742 | ||
743 | /* The datasheet says the node 0x07 is connected from inputs, | |
744 | * but it shows zero connection in the real implementation on some devices. | |
df694daa | 745 | * Note: this is a 915GAV bug, fixed on 915GLV |
1da177e4 | 746 | */ |
e9edcee0 TI |
747 | static hda_nid_t alc880_adc_nids_alt[2] = { |
748 | /* ADC1-2 */ | |
749 | 0x08, 0x09, | |
750 | }; | |
751 | ||
752 | #define ALC880_DIGOUT_NID 0x06 | |
753 | #define ALC880_DIGIN_NID 0x0a | |
754 | ||
755 | static struct hda_input_mux alc880_capture_source = { | |
756 | .num_items = 4, | |
757 | .items = { | |
758 | { "Mic", 0x0 }, | |
759 | { "Front Mic", 0x3 }, | |
760 | { "Line", 0x2 }, | |
761 | { "CD", 0x4 }, | |
762 | }, | |
763 | }; | |
764 | ||
765 | /* channel source setting (2/6 channel selection for 3-stack) */ | |
766 | /* 2ch mode */ | |
767 | static struct hda_verb alc880_threestack_ch2_init[] = { | |
768 | /* set line-in to input, mute it */ | |
769 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
770 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
771 | /* set mic-in to input vref 80%, mute it */ | |
772 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
773 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
774 | { } /* end */ | |
775 | }; | |
776 | ||
777 | /* 6ch mode */ | |
778 | static struct hda_verb alc880_threestack_ch6_init[] = { | |
779 | /* set line-in to output, unmute it */ | |
780 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
781 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
782 | /* set mic-in to output, unmute it */ | |
783 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
784 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
785 | { } /* end */ | |
786 | }; | |
787 | ||
d2a6d7dc | 788 | static struct hda_channel_mode alc880_threestack_modes[2] = { |
e9edcee0 TI |
789 | { 2, alc880_threestack_ch2_init }, |
790 | { 6, alc880_threestack_ch6_init }, | |
791 | }; | |
792 | ||
c8b6bf9b | 793 | static struct snd_kcontrol_new alc880_three_stack_mixer[] = { |
05acb863 | 794 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 795 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
05acb863 | 796 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 797 | HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT), |
05acb863 TI |
798 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
799 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
800 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
801 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
1da177e4 LT |
802 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
803 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
804 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
805 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
806 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
807 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
808 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT), | |
809 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT), | |
810 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
811 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
e9edcee0 TI |
812 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT), |
813 | { | |
814 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
815 | .name = "Channel Mode", | |
df694daa KY |
816 | .info = alc_ch_mode_info, |
817 | .get = alc_ch_mode_get, | |
818 | .put = alc_ch_mode_put, | |
e9edcee0 TI |
819 | }, |
820 | { } /* end */ | |
821 | }; | |
822 | ||
823 | /* capture mixer elements */ | |
c8b6bf9b | 824 | static struct snd_kcontrol_new alc880_capture_mixer[] = { |
e9edcee0 TI |
825 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), |
826 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), | |
827 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), | |
828 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), | |
829 | HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), | |
830 | HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), | |
1da177e4 LT |
831 | { |
832 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
833 | /* The multiple "Capture Source" controls confuse alsamixer | |
834 | * So call somewhat different.. | |
835 | * FIXME: the controls appear in the "playback" view! | |
836 | */ | |
837 | /* .name = "Capture Source", */ | |
838 | .name = "Input Source", | |
e9edcee0 | 839 | .count = 3, |
1da177e4 LT |
840 | .info = alc_mux_enum_info, |
841 | .get = alc_mux_enum_get, | |
842 | .put = alc_mux_enum_put, | |
843 | }, | |
1da177e4 LT |
844 | { } /* end */ |
845 | }; | |
846 | ||
e9edcee0 | 847 | /* capture mixer elements (in case NID 0x07 not available) */ |
c8b6bf9b | 848 | static struct snd_kcontrol_new alc880_capture_alt_mixer[] = { |
71fe7b82 TI |
849 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
850 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
851 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
852 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
1da177e4 LT |
853 | { |
854 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
855 | /* The multiple "Capture Source" controls confuse alsamixer | |
856 | * So call somewhat different.. | |
857 | * FIXME: the controls appear in the "playback" view! | |
858 | */ | |
859 | /* .name = "Capture Source", */ | |
860 | .name = "Input Source", | |
861 | .count = 2, | |
862 | .info = alc_mux_enum_info, | |
863 | .get = alc_mux_enum_get, | |
864 | .put = alc_mux_enum_put, | |
865 | }, | |
1da177e4 LT |
866 | { } /* end */ |
867 | }; | |
868 | ||
e9edcee0 TI |
869 | |
870 | ||
871 | /* | |
872 | * ALC880 5-stack model | |
873 | * | |
9c7f852e TI |
874 | * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), |
875 | * Side = 0x02 (0xd) | |
e9edcee0 TI |
876 | * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16 |
877 | * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19 | |
878 | */ | |
879 | ||
880 | /* additional mixers to alc880_three_stack_mixer */ | |
c8b6bf9b | 881 | static struct snd_kcontrol_new alc880_five_stack_mixer[] = { |
e9edcee0 | 882 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 883 | HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT), |
1da177e4 LT |
884 | { } /* end */ |
885 | }; | |
886 | ||
e9edcee0 TI |
887 | /* channel source setting (6/8 channel selection for 5-stack) */ |
888 | /* 6ch mode */ | |
889 | static struct hda_verb alc880_fivestack_ch6_init[] = { | |
890 | /* set line-in to input, mute it */ | |
891 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
892 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
dfc0ff62 TI |
893 | { } /* end */ |
894 | }; | |
895 | ||
e9edcee0 TI |
896 | /* 8ch mode */ |
897 | static struct hda_verb alc880_fivestack_ch8_init[] = { | |
898 | /* set line-in to output, unmute it */ | |
899 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
900 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
901 | { } /* end */ | |
902 | }; | |
903 | ||
d2a6d7dc | 904 | static struct hda_channel_mode alc880_fivestack_modes[2] = { |
e9edcee0 TI |
905 | { 6, alc880_fivestack_ch6_init }, |
906 | { 8, alc880_fivestack_ch8_init }, | |
907 | }; | |
908 | ||
909 | ||
910 | /* | |
911 | * ALC880 6-stack model | |
912 | * | |
9c7f852e TI |
913 | * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), |
914 | * Side = 0x05 (0x0f) | |
e9edcee0 TI |
915 | * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17, |
916 | * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b | |
917 | */ | |
918 | ||
919 | static hda_nid_t alc880_6st_dac_nids[4] = { | |
920 | /* front, rear, clfe, rear_surr */ | |
921 | 0x02, 0x03, 0x04, 0x05 | |
f12ab1e0 | 922 | }; |
e9edcee0 TI |
923 | |
924 | static struct hda_input_mux alc880_6stack_capture_source = { | |
925 | .num_items = 4, | |
926 | .items = { | |
927 | { "Mic", 0x0 }, | |
928 | { "Front Mic", 0x1 }, | |
929 | { "Line", 0x2 }, | |
930 | { "CD", 0x4 }, | |
931 | }, | |
932 | }; | |
933 | ||
934 | /* fixed 8-channels */ | |
d2a6d7dc | 935 | static struct hda_channel_mode alc880_sixstack_modes[1] = { |
e9edcee0 TI |
936 | { 8, NULL }, |
937 | }; | |
938 | ||
c8b6bf9b | 939 | static struct snd_kcontrol_new alc880_six_stack_mixer[] = { |
16ded525 | 940 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 941 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 942 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 943 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
944 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
945 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
946 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
947 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
16ded525 | 948 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 949 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
16ded525 TI |
950 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
951 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
952 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
953 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
954 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
955 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
956 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
957 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
958 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
959 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
16ded525 TI |
960 | { |
961 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
962 | .name = "Channel Mode", | |
df694daa KY |
963 | .info = alc_ch_mode_info, |
964 | .get = alc_ch_mode_get, | |
965 | .put = alc_ch_mode_put, | |
16ded525 TI |
966 | }, |
967 | { } /* end */ | |
968 | }; | |
969 | ||
e9edcee0 TI |
970 | |
971 | /* | |
972 | * ALC880 W810 model | |
973 | * | |
974 | * W810 has rear IO for: | |
975 | * Front (DAC 02) | |
976 | * Surround (DAC 03) | |
977 | * Center/LFE (DAC 04) | |
978 | * Digital out (06) | |
979 | * | |
980 | * The system also has a pair of internal speakers, and a headphone jack. | |
981 | * These are both connected to Line2 on the codec, hence to DAC 02. | |
982 | * | |
983 | * There is a variable resistor to control the speaker or headphone | |
984 | * volume. This is a hardware-only device without a software API. | |
985 | * | |
986 | * Plugging headphones in will disable the internal speakers. This is | |
987 | * implemented in hardware, not via the driver using jack sense. In | |
988 | * a similar fashion, plugging into the rear socket marked "front" will | |
989 | * disable both the speakers and headphones. | |
990 | * | |
991 | * For input, there's a microphone jack, and an "audio in" jack. | |
992 | * These may not do anything useful with this driver yet, because I | |
993 | * haven't setup any initialization verbs for these yet... | |
994 | */ | |
995 | ||
996 | static hda_nid_t alc880_w810_dac_nids[3] = { | |
997 | /* front, rear/surround, clfe */ | |
998 | 0x02, 0x03, 0x04 | |
16ded525 TI |
999 | }; |
1000 | ||
e9edcee0 | 1001 | /* fixed 6 channels */ |
d2a6d7dc | 1002 | static struct hda_channel_mode alc880_w810_modes[1] = { |
e9edcee0 TI |
1003 | { 6, NULL } |
1004 | }; | |
1005 | ||
1006 | /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */ | |
c8b6bf9b | 1007 | static struct snd_kcontrol_new alc880_w810_base_mixer[] = { |
16ded525 | 1008 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1009 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 1010 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1011 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1012 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1013 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1014 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1015 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
e9edcee0 TI |
1016 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
1017 | { } /* end */ | |
1018 | }; | |
1019 | ||
1020 | ||
1021 | /* | |
1022 | * Z710V model | |
1023 | * | |
1024 | * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d) | |
9c7f852e TI |
1025 | * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), |
1026 | * Line = 0x1a | |
e9edcee0 TI |
1027 | */ |
1028 | ||
1029 | static hda_nid_t alc880_z71v_dac_nids[1] = { | |
1030 | 0x02 | |
1031 | }; | |
1032 | #define ALC880_Z71V_HP_DAC 0x03 | |
1033 | ||
1034 | /* fixed 2 channels */ | |
d2a6d7dc | 1035 | static struct hda_channel_mode alc880_2_jack_modes[1] = { |
e9edcee0 TI |
1036 | { 2, NULL } |
1037 | }; | |
1038 | ||
c8b6bf9b | 1039 | static struct snd_kcontrol_new alc880_z71v_mixer[] = { |
e9edcee0 | 1040 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1041 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
e9edcee0 | 1042 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1043 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1044 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1045 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
16ded525 TI |
1046 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
1047 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
16ded525 TI |
1048 | { } /* end */ |
1049 | }; | |
1050 | ||
e9edcee0 TI |
1051 | |
1052 | /* FIXME! */ | |
1053 | /* | |
1054 | * ALC880 F1734 model | |
1055 | * | |
1056 | * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d) | |
1057 | * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18 | |
1058 | */ | |
1059 | ||
1060 | static hda_nid_t alc880_f1734_dac_nids[1] = { | |
1061 | 0x03 | |
1062 | }; | |
1063 | #define ALC880_F1734_HP_DAC 0x02 | |
1064 | ||
c8b6bf9b | 1065 | static struct snd_kcontrol_new alc880_f1734_mixer[] = { |
e9edcee0 | 1066 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1067 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), |
e9edcee0 | 1068 | HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1069 | HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT), |
e9edcee0 TI |
1070 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1071 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1072 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1073 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1074 | { } /* end */ | |
1075 | }; | |
1076 | ||
1077 | ||
1078 | /* FIXME! */ | |
1079 | /* | |
1080 | * ALC880 ASUS model | |
1081 | * | |
1082 | * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) | |
1083 | * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, | |
1084 | * Mic = 0x18, Line = 0x1a | |
1085 | */ | |
1086 | ||
1087 | #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */ | |
1088 | #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */ | |
1089 | ||
c8b6bf9b | 1090 | static struct snd_kcontrol_new alc880_asus_mixer[] = { |
16ded525 | 1091 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1092 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 1093 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1094 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1095 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1096 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1097 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1098 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
16ded525 TI |
1099 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1100 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1101 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1102 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
16ded525 TI |
1103 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
1104 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
16ded525 TI |
1105 | { |
1106 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1107 | .name = "Channel Mode", | |
df694daa KY |
1108 | .info = alc_ch_mode_info, |
1109 | .get = alc_ch_mode_get, | |
1110 | .put = alc_ch_mode_put, | |
16ded525 TI |
1111 | }, |
1112 | { } /* end */ | |
1113 | }; | |
e9edcee0 TI |
1114 | |
1115 | /* FIXME! */ | |
1116 | /* | |
1117 | * ALC880 ASUS W1V model | |
1118 | * | |
1119 | * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) | |
1120 | * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, | |
1121 | * Mic = 0x18, Line = 0x1a, Line2 = 0x1b | |
1122 | */ | |
1123 | ||
1124 | /* additional mixers to alc880_asus_mixer */ | |
c8b6bf9b | 1125 | static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = { |
e9edcee0 TI |
1126 | HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT), |
1127 | HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT), | |
1128 | { } /* end */ | |
1129 | }; | |
1130 | ||
3c10a9d9 | 1131 | /* additional mixers to alc880_asus_mixer */ |
c8b6bf9b | 1132 | static struct snd_kcontrol_new alc880_pcbeep_mixer[] = { |
3c10a9d9 TI |
1133 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), |
1134 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
1135 | { } /* end */ | |
1136 | }; | |
e9edcee0 | 1137 | |
df694daa KY |
1138 | /* TCL S700 */ |
1139 | static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = { | |
1140 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1141 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
1142 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
1143 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT), | |
1144 | HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT), | |
1145 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT), | |
1146 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT), | |
1147 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
1148 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
1149 | { | |
1150 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1151 | /* The multiple "Capture Source" controls confuse alsamixer | |
1152 | * So call somewhat different.. | |
1153 | * FIXME: the controls appear in the "playback" view! | |
1154 | */ | |
1155 | /* .name = "Capture Source", */ | |
1156 | .name = "Input Source", | |
1157 | .count = 1, | |
1158 | .info = alc_mux_enum_info, | |
1159 | .get = alc_mux_enum_get, | |
1160 | .put = alc_mux_enum_put, | |
1161 | }, | |
1162 | { } /* end */ | |
1163 | }; | |
1164 | ||
ccc656ce KY |
1165 | /* Uniwill */ |
1166 | static struct snd_kcontrol_new alc880_uniwill_mixer[] = { | |
1167 | HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1168 | HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1169 | HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1170 | HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
1171 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
1172 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
1173 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
1174 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
1175 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
1176 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1177 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1178 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
1179 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1180 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1181 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1182 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1183 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
1184 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
1185 | { | |
1186 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1187 | .name = "Channel Mode", | |
1188 | .info = alc_ch_mode_info, | |
1189 | .get = alc_ch_mode_get, | |
1190 | .put = alc_ch_mode_put, | |
1191 | }, | |
1192 | { } /* end */ | |
1193 | }; | |
1194 | ||
2cf9f0fc TD |
1195 | static struct snd_kcontrol_new alc880_fujitsu_mixer[] = { |
1196 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1197 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1198 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1199 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
1200 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
1201 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1202 | HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1203 | HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1204 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1205 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1206 | { } /* end */ | |
1207 | }; | |
1208 | ||
ccc656ce KY |
1209 | static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = { |
1210 | HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1211 | HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1212 | HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1213 | HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
1214 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1215 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1216 | { } /* end */ | |
1217 | }; | |
1218 | ||
1da177e4 | 1219 | /* |
e9edcee0 | 1220 | * build control elements |
1da177e4 LT |
1221 | */ |
1222 | static int alc_build_controls(struct hda_codec *codec) | |
1223 | { | |
1224 | struct alc_spec *spec = codec->spec; | |
1225 | int err; | |
1226 | int i; | |
1227 | ||
1228 | for (i = 0; i < spec->num_mixers; i++) { | |
1229 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); | |
1230 | if (err < 0) | |
1231 | return err; | |
1232 | } | |
1233 | ||
1234 | if (spec->multiout.dig_out_nid) { | |
9c7f852e TI |
1235 | err = snd_hda_create_spdif_out_ctls(codec, |
1236 | spec->multiout.dig_out_nid); | |
1da177e4 LT |
1237 | if (err < 0) |
1238 | return err; | |
1239 | } | |
1240 | if (spec->dig_in_nid) { | |
1241 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); | |
1242 | if (err < 0) | |
1243 | return err; | |
1244 | } | |
1245 | return 0; | |
1246 | } | |
1247 | ||
e9edcee0 | 1248 | |
1da177e4 LT |
1249 | /* |
1250 | * initialize the codec volumes, etc | |
1251 | */ | |
1252 | ||
e9edcee0 TI |
1253 | /* |
1254 | * generic initialization of ADC, input mixers and output mixers | |
1255 | */ | |
1256 | static struct hda_verb alc880_volume_init_verbs[] = { | |
1257 | /* | |
1258 | * Unmute ADC0-2 and set the default input to mic-in | |
1259 | */ | |
71fe7b82 | 1260 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 1261 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
71fe7b82 | 1262 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 1263 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
71fe7b82 | 1264 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 1265 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1da177e4 | 1266 | |
e9edcee0 TI |
1267 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
1268 | * mixer widget | |
9c7f852e TI |
1269 | * Note: PASD motherboards uses the Line In 2 as the input for front |
1270 | * panel mic (mic 2) | |
1da177e4 | 1271 | */ |
e9edcee0 | 1272 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ |
16ded525 | 1273 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
e9edcee0 TI |
1274 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
1275 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
1276 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
1277 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
1da177e4 | 1278 | |
e9edcee0 TI |
1279 | /* |
1280 | * Set up output mixers (0x0c - 0x0f) | |
1da177e4 | 1281 | */ |
e9edcee0 TI |
1282 | /* set vol=0 to output mixers */ |
1283 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1284 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1285 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1286 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1287 | /* set up input amps for analog loopback */ | |
1288 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
05acb863 TI |
1289 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1290 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
1291 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1292 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
1293 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1294 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
1295 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1296 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 LT |
1297 | |
1298 | { } | |
1299 | }; | |
1300 | ||
e9edcee0 TI |
1301 | /* |
1302 | * 3-stack pin configuration: | |
1303 | * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b | |
1304 | */ | |
1305 | static struct hda_verb alc880_pin_3stack_init_verbs[] = { | |
1306 | /* | |
1307 | * preset connection lists of input pins | |
1308 | * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround | |
1309 | */ | |
1310 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
1311 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
1312 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */ | |
1313 | ||
1314 | /* | |
1315 | * Set pin mode and muting | |
1316 | */ | |
1317 | /* set front pin widgets 0x14 for output */ | |
05acb863 | 1318 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
1319 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1320 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
1321 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1322 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1323 | /* Mic2 (as headphone out) for HP output */ | |
1324 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1325 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1da177e4 | 1326 | /* Line In pin widget for input */ |
05acb863 | 1327 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 TI |
1328 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
1329 | /* Line2 (as front mic) pin widget for input and vref at 80% */ | |
1330 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1331 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1da177e4 | 1332 | /* CD pin widget for input */ |
05acb863 | 1333 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 1334 | |
e9edcee0 TI |
1335 | { } |
1336 | }; | |
1da177e4 | 1337 | |
e9edcee0 TI |
1338 | /* |
1339 | * 5-stack pin configuration: | |
1340 | * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19, | |
1341 | * line-in/side = 0x1a, f-mic = 0x1b | |
1342 | */ | |
1343 | static struct hda_verb alc880_pin_5stack_init_verbs[] = { | |
1344 | /* | |
1345 | * preset connection lists of input pins | |
1346 | * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround | |
1da177e4 | 1347 | */ |
e9edcee0 TI |
1348 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
1349 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */ | |
1da177e4 | 1350 | |
e9edcee0 TI |
1351 | /* |
1352 | * Set pin mode and muting | |
1da177e4 | 1353 | */ |
e9edcee0 TI |
1354 | /* set pin widgets 0x14-0x17 for output */ |
1355 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1356 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1357 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1358 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1359 | /* unmute pins for output (no gain on this amp) */ | |
1360 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1361 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1362 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1363 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1364 | ||
1365 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
1366 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1367 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1368 | /* Mic2 (as headphone out) for HP output */ | |
1369 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1370 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1371 | /* Line In pin widget for input */ | |
1372 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1373 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1374 | /* Line2 (as front mic) pin widget for input and vref at 80% */ | |
1375 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1376 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1377 | /* CD pin widget for input */ | |
1378 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1da177e4 LT |
1379 | |
1380 | { } | |
1381 | }; | |
1382 | ||
e9edcee0 TI |
1383 | /* |
1384 | * W810 pin configuration: | |
1385 | * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b | |
1386 | */ | |
1387 | static struct hda_verb alc880_pin_w810_init_verbs[] = { | |
1388 | /* hphone/speaker input selector: front DAC */ | |
1389 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
1da177e4 | 1390 | |
05acb863 | 1391 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1392 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 1393 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1394 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 1395 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1396 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 1397 | |
e9edcee0 | 1398 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
05acb863 | 1399 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
1da177e4 | 1400 | |
1da177e4 LT |
1401 | { } |
1402 | }; | |
1403 | ||
e9edcee0 TI |
1404 | /* |
1405 | * Z71V pin configuration: | |
1406 | * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?) | |
1407 | */ | |
1408 | static struct hda_verb alc880_pin_z71v_init_verbs[] = { | |
05acb863 | 1409 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1410 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 1411 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
e9edcee0 | 1412 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
dfc0ff62 | 1413 | |
16ded525 | 1414 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1415 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
16ded525 | 1416 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1417 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
16ded525 TI |
1418 | |
1419 | { } | |
1420 | }; | |
1421 | ||
e9edcee0 TI |
1422 | /* |
1423 | * 6-stack pin configuration: | |
9c7f852e TI |
1424 | * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, |
1425 | * f-mic = 0x19, line = 0x1a, HP = 0x1b | |
e9edcee0 TI |
1426 | */ |
1427 | static struct hda_verb alc880_pin_6stack_init_verbs[] = { | |
1428 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
1429 | ||
16ded525 | 1430 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1431 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1432 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1433 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1434 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1435 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1436 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
1437 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1438 | ||
16ded525 | 1439 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1440 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 1441 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1442 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 1443 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 | 1444 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 1445 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
e9edcee0 | 1446 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 TI |
1447 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1448 | ||
e9edcee0 TI |
1449 | { } |
1450 | }; | |
1451 | ||
ccc656ce KY |
1452 | /* |
1453 | * Uniwill pin configuration: | |
1454 | * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19, | |
1455 | * line = 0x1a | |
1456 | */ | |
1457 | static struct hda_verb alc880_uniwill_init_verbs[] = { | |
1458 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
1459 | ||
1460 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1461 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1462 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1463 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1464 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1465 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1466 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1467 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1468 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1469 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1470 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1471 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1472 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1473 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1474 | ||
1475 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1476 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1477 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1478 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1479 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1480 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1481 | /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */ | |
1482 | /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */ | |
1483 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1484 | ||
1485 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
1486 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
1487 | ||
1488 | { } | |
1489 | }; | |
1490 | ||
1491 | /* | |
1492 | * Uniwill P53 | |
1493 | * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19, | |
1494 | */ | |
1495 | static struct hda_verb alc880_uniwill_p53_init_verbs[] = { | |
1496 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
1497 | ||
1498 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1499 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1500 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1501 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1502 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1503 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1504 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1505 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1506 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1507 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1508 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1509 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1510 | ||
1511 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1512 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1513 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1514 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1515 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1516 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1517 | ||
1518 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
1519 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT}, | |
1520 | ||
1521 | { } | |
1522 | }; | |
1523 | ||
2cf9f0fc TD |
1524 | static struct hda_verb alc880_beep_init_verbs[] = { |
1525 | { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) }, | |
1526 | { } | |
1527 | }; | |
1528 | ||
ccc656ce | 1529 | /* toggle speaker-output according to the hp-jack state */ |
458a4fab | 1530 | static void alc880_uniwill_hp_automute(struct hda_codec *codec) |
ccc656ce KY |
1531 | { |
1532 | unsigned int present; | |
f12ab1e0 | 1533 | unsigned char bits; |
ccc656ce KY |
1534 | |
1535 | present = snd_hda_codec_read(codec, 0x14, 0, | |
1536 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
f12ab1e0 | 1537 | bits = present ? 0x80 : 0; |
ccc656ce | 1538 | snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, |
f12ab1e0 | 1539 | 0x80, bits); |
ccc656ce | 1540 | snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, |
f12ab1e0 | 1541 | 0x80, bits); |
ccc656ce | 1542 | snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0, |
f12ab1e0 | 1543 | 0x80, bits); |
ccc656ce | 1544 | snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0, |
f12ab1e0 | 1545 | 0x80, bits); |
458a4fab TI |
1546 | } |
1547 | ||
1548 | /* auto-toggle front mic */ | |
1549 | static void alc880_uniwill_mic_automute(struct hda_codec *codec) | |
1550 | { | |
1551 | unsigned int present; | |
1552 | unsigned char bits; | |
ccc656ce KY |
1553 | |
1554 | present = snd_hda_codec_read(codec, 0x18, 0, | |
1555 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
458a4fab TI |
1556 | bits = present ? 0x80 : 0; |
1557 | snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1, | |
1558 | 0x80, bits); | |
1559 | snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1, | |
1560 | 0x80, bits); | |
1561 | } | |
1562 | ||
1563 | static void alc880_uniwill_automute(struct hda_codec *codec) | |
1564 | { | |
1565 | alc880_uniwill_hp_automute(codec); | |
1566 | alc880_uniwill_mic_automute(codec); | |
ccc656ce KY |
1567 | } |
1568 | ||
1569 | static void alc880_uniwill_unsol_event(struct hda_codec *codec, | |
1570 | unsigned int res) | |
1571 | { | |
1572 | /* Looks like the unsol event is incompatible with the standard | |
1573 | * definition. 4bit tag is placed at 28 bit! | |
1574 | */ | |
458a4fab TI |
1575 | switch (res >> 28) { |
1576 | case ALC880_HP_EVENT: | |
1577 | alc880_uniwill_hp_automute(codec); | |
1578 | break; | |
1579 | case ALC880_MIC_EVENT: | |
1580 | alc880_uniwill_mic_automute(codec); | |
1581 | break; | |
1582 | } | |
ccc656ce KY |
1583 | } |
1584 | ||
1585 | static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec) | |
1586 | { | |
1587 | unsigned int present; | |
f12ab1e0 | 1588 | unsigned char bits; |
ccc656ce KY |
1589 | |
1590 | present = snd_hda_codec_read(codec, 0x14, 0, | |
1591 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
f12ab1e0 | 1592 | bits = present ? 0x80 : 0; |
ccc656ce | 1593 | snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0, |
f12ab1e0 | 1594 | 0x80, bits); |
ccc656ce | 1595 | snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0, |
f12ab1e0 | 1596 | 0x80, bits); |
ccc656ce KY |
1597 | } |
1598 | ||
1599 | static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) | |
1600 | { | |
1601 | unsigned int present; | |
1602 | ||
1603 | present = snd_hda_codec_read(codec, 0x21, 0, | |
1604 | AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f; | |
1605 | ||
1606 | snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0, | |
1607 | 0x7f, present); | |
1608 | snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0, | |
1609 | 0x7f, present); | |
1610 | ||
1611 | snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0, | |
1612 | 0x7f, present); | |
1613 | snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0, | |
1614 | 0x7f, present); | |
1615 | ||
1616 | } | |
1617 | static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec, | |
1618 | unsigned int res) | |
1619 | { | |
1620 | /* Looks like the unsol event is incompatible with the standard | |
1621 | * definition. 4bit tag is placed at 28 bit! | |
1622 | */ | |
1623 | if ((res >> 28) == ALC880_HP_EVENT) | |
1624 | alc880_uniwill_p53_hp_automute(codec); | |
f12ab1e0 | 1625 | if ((res >> 28) == ALC880_DCVOL_EVENT) |
ccc656ce KY |
1626 | alc880_uniwill_p53_dcvol_automute(codec); |
1627 | } | |
1628 | ||
e9edcee0 TI |
1629 | /* FIXME! */ |
1630 | /* | |
1631 | * F1734 pin configuration: | |
1632 | * HP = 0x14, speaker-out = 0x15, mic = 0x18 | |
1633 | */ | |
1634 | static struct hda_verb alc880_pin_f1734_init_verbs[] = { | |
16ded525 TI |
1635 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, |
1636 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1637 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
1638 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1639 | ||
e9edcee0 | 1640 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
16ded525 | 1641 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
e9edcee0 | 1642 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
16ded525 | 1643 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1644 | |
e9edcee0 TI |
1645 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1646 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
16ded525 | 1647 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1648 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 1649 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1650 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1651 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1652 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1653 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
dfc0ff62 TI |
1654 | |
1655 | { } | |
1656 | }; | |
1657 | ||
e9edcee0 TI |
1658 | /* FIXME! */ |
1659 | /* | |
1660 | * ASUS pin configuration: | |
1661 | * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a | |
1662 | */ | |
1663 | static struct hda_verb alc880_pin_asus_init_verbs[] = { | |
16ded525 TI |
1664 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, |
1665 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1666 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
1667 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1668 | ||
1669 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
e9edcee0 | 1670 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1671 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1672 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1673 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1674 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1675 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
1676 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1677 | ||
1678 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1679 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1680 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1681 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1682 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1683 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
16ded525 | 1684 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1685 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 TI |
1686 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1687 | ||
e9edcee0 TI |
1688 | { } |
1689 | }; | |
16ded525 | 1690 | |
e9edcee0 | 1691 | /* Enable GPIO mask and set output */ |
bc9f98a9 KY |
1692 | #define alc880_gpio1_init_verbs alc_gpio1_init_verbs |
1693 | #define alc880_gpio2_init_verbs alc_gpio2_init_verbs | |
df694daa KY |
1694 | |
1695 | /* Clevo m520g init */ | |
1696 | static struct hda_verb alc880_pin_clevo_init_verbs[] = { | |
1697 | /* headphone output */ | |
1698 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
1699 | /* line-out */ | |
1700 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1701 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1702 | /* Line-in */ | |
1703 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1704 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1705 | /* CD */ | |
1706 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1707 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1708 | /* Mic1 (rear panel) */ | |
1709 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1710 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1711 | /* Mic2 (front panel) */ | |
1712 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1713 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1714 | /* headphone */ | |
1715 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1716 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1717 | /* change to EAPD mode */ | |
1718 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
1719 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, | |
1720 | ||
1721 | { } | |
16ded525 TI |
1722 | }; |
1723 | ||
df694daa | 1724 | static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = { |
4b146cb0 TI |
1725 | /* change to EAPD mode */ |
1726 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
1727 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, | |
1728 | ||
df694daa KY |
1729 | /* Headphone output */ |
1730 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1731 | /* Front output*/ | |
1732 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1733 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1734 | ||
1735 | /* Line In pin widget for input */ | |
1736 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1737 | /* CD pin widget for input */ | |
1738 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1739 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
1740 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1741 | ||
1742 | /* change to EAPD mode */ | |
1743 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
1744 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
1745 | ||
1746 | { } | |
1747 | }; | |
16ded525 | 1748 | |
e9edcee0 | 1749 | /* |
ae6b813a TI |
1750 | * LG m1 express dual |
1751 | * | |
1752 | * Pin assignment: | |
1753 | * Rear Line-In/Out (blue): 0x14 | |
1754 | * Build-in Mic-In: 0x15 | |
1755 | * Speaker-out: 0x17 | |
1756 | * HP-Out (green): 0x1b | |
1757 | * Mic-In/Out (red): 0x19 | |
1758 | * SPDIF-Out: 0x1e | |
1759 | */ | |
1760 | ||
1761 | /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */ | |
1762 | static hda_nid_t alc880_lg_dac_nids[3] = { | |
1763 | 0x05, 0x02, 0x03 | |
1764 | }; | |
1765 | ||
1766 | /* seems analog CD is not working */ | |
1767 | static struct hda_input_mux alc880_lg_capture_source = { | |
1768 | .num_items = 3, | |
1769 | .items = { | |
1770 | { "Mic", 0x1 }, | |
1771 | { "Line", 0x5 }, | |
1772 | { "Internal Mic", 0x6 }, | |
1773 | }, | |
1774 | }; | |
1775 | ||
1776 | /* 2,4,6 channel modes */ | |
1777 | static struct hda_verb alc880_lg_ch2_init[] = { | |
1778 | /* set line-in and mic-in to input */ | |
1779 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
1780 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
1781 | { } | |
1782 | }; | |
1783 | ||
1784 | static struct hda_verb alc880_lg_ch4_init[] = { | |
1785 | /* set line-in to out and mic-in to input */ | |
1786 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
1787 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
1788 | { } | |
1789 | }; | |
1790 | ||
1791 | static struct hda_verb alc880_lg_ch6_init[] = { | |
1792 | /* set line-in and mic-in to output */ | |
1793 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
1794 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
1795 | { } | |
1796 | }; | |
1797 | ||
1798 | static struct hda_channel_mode alc880_lg_ch_modes[3] = { | |
1799 | { 2, alc880_lg_ch2_init }, | |
1800 | { 4, alc880_lg_ch4_init }, | |
1801 | { 6, alc880_lg_ch6_init }, | |
1802 | }; | |
1803 | ||
1804 | static struct snd_kcontrol_new alc880_lg_mixer[] = { | |
1805 | /* FIXME: it's not really "master" but front channels */ | |
1806 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
1807 | HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT), | |
1808 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1809 | HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT), | |
1810 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), | |
1811 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT), | |
1812 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT), | |
1813 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), | |
1814 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1815 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1816 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT), | |
1817 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT), | |
1818 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT), | |
1819 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT), | |
1820 | { | |
1821 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1822 | .name = "Channel Mode", | |
1823 | .info = alc_ch_mode_info, | |
1824 | .get = alc_ch_mode_get, | |
1825 | .put = alc_ch_mode_put, | |
1826 | }, | |
1827 | { } /* end */ | |
1828 | }; | |
1829 | ||
1830 | static struct hda_verb alc880_lg_init_verbs[] = { | |
1831 | /* set capture source to mic-in */ | |
1832 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
1833 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
1834 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
1835 | /* mute all amp mixer inputs */ | |
1836 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)}, | |
1837 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)}, | |
1838 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)}, | |
1839 | /* line-in to input */ | |
1840 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1841 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1842 | /* built-in mic */ | |
1843 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1844 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1845 | /* speaker-out */ | |
1846 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1847 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1848 | /* mic-in to input */ | |
1849 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
1850 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1851 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1852 | /* HP-out */ | |
1853 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
1854 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1855 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1856 | /* jack sense */ | |
1857 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, | |
1858 | { } | |
1859 | }; | |
1860 | ||
1861 | /* toggle speaker-output according to the hp-jack state */ | |
1862 | static void alc880_lg_automute(struct hda_codec *codec) | |
1863 | { | |
1864 | unsigned int present; | |
f12ab1e0 | 1865 | unsigned char bits; |
ae6b813a TI |
1866 | |
1867 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
1868 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
f12ab1e0 | 1869 | bits = present ? 0x80 : 0; |
ae6b813a | 1870 | snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0, |
f12ab1e0 | 1871 | 0x80, bits); |
ae6b813a | 1872 | snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0, |
f12ab1e0 | 1873 | 0x80, bits); |
ae6b813a TI |
1874 | } |
1875 | ||
1876 | static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res) | |
1877 | { | |
1878 | /* Looks like the unsol event is incompatible with the standard | |
1879 | * definition. 4bit tag is placed at 28 bit! | |
1880 | */ | |
1881 | if ((res >> 28) == 0x01) | |
1882 | alc880_lg_automute(codec); | |
1883 | } | |
1884 | ||
d681518a TI |
1885 | /* |
1886 | * LG LW20 | |
1887 | * | |
1888 | * Pin assignment: | |
1889 | * Speaker-out: 0x14 | |
1890 | * Mic-In: 0x18 | |
1891 | * Built-in Mic-In: 0x19 (?) | |
1892 | * HP-Out: 0x1b | |
1893 | * SPDIF-Out: 0x1e | |
1894 | */ | |
1895 | ||
1896 | /* seems analog CD is not working */ | |
1897 | static struct hda_input_mux alc880_lg_lw_capture_source = { | |
1898 | .num_items = 2, | |
1899 | .items = { | |
1900 | { "Mic", 0x0 }, | |
1901 | { "Internal Mic", 0x1 }, | |
1902 | }, | |
1903 | }; | |
1904 | ||
0a8c5da3 CM |
1905 | #define alc880_lg_lw_modes alc880_threestack_modes |
1906 | ||
d681518a | 1907 | static struct snd_kcontrol_new alc880_lg_lw_mixer[] = { |
0a8c5da3 CM |
1908 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
1909 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
1910 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
1911 | HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT), | |
1912 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
1913 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
1914 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
1915 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
1916 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1917 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
d681518a TI |
1918 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
1919 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1920 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
1921 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
0a8c5da3 CM |
1922 | { |
1923 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1924 | .name = "Channel Mode", | |
1925 | .info = alc_ch_mode_info, | |
1926 | .get = alc_ch_mode_get, | |
1927 | .put = alc_ch_mode_put, | |
1928 | }, | |
d681518a TI |
1929 | { } /* end */ |
1930 | }; | |
1931 | ||
1932 | static struct hda_verb alc880_lg_lw_init_verbs[] = { | |
0a8c5da3 CM |
1933 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
1934 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
1935 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */ | |
1936 | ||
d681518a TI |
1937 | /* set capture source to mic-in */ |
1938 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
1939 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
1940 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
1941 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)}, | |
1942 | /* speaker-out */ | |
1943 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1944 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1945 | /* HP-out */ | |
d681518a TI |
1946 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
1947 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1948 | /* mic-in to input */ | |
1949 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1950 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1951 | /* built-in mic */ | |
1952 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1953 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1954 | /* jack sense */ | |
1955 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, | |
1956 | { } | |
1957 | }; | |
1958 | ||
1959 | /* toggle speaker-output according to the hp-jack state */ | |
1960 | static void alc880_lg_lw_automute(struct hda_codec *codec) | |
1961 | { | |
1962 | unsigned int present; | |
f12ab1e0 | 1963 | unsigned char bits; |
d681518a TI |
1964 | |
1965 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
1966 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
f12ab1e0 | 1967 | bits = present ? 0x80 : 0; |
d681518a | 1968 | snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, |
f12ab1e0 | 1969 | 0x80, bits); |
d681518a | 1970 | snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, |
f12ab1e0 | 1971 | 0x80, bits); |
d681518a TI |
1972 | } |
1973 | ||
1974 | static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res) | |
1975 | { | |
1976 | /* Looks like the unsol event is incompatible with the standard | |
1977 | * definition. 4bit tag is placed at 28 bit! | |
1978 | */ | |
1979 | if ((res >> 28) == 0x01) | |
1980 | alc880_lg_lw_automute(codec); | |
1981 | } | |
1982 | ||
ae6b813a TI |
1983 | /* |
1984 | * Common callbacks | |
e9edcee0 TI |
1985 | */ |
1986 | ||
1da177e4 LT |
1987 | static int alc_init(struct hda_codec *codec) |
1988 | { | |
1989 | struct alc_spec *spec = codec->spec; | |
e9edcee0 TI |
1990 | unsigned int i; |
1991 | ||
1992 | for (i = 0; i < spec->num_init_verbs; i++) | |
1993 | snd_hda_sequence_write(codec, spec->init_verbs[i]); | |
ae6b813a TI |
1994 | |
1995 | if (spec->init_hook) | |
1996 | spec->init_hook(codec); | |
1997 | ||
1da177e4 LT |
1998 | return 0; |
1999 | } | |
2000 | ||
ae6b813a TI |
2001 | static void alc_unsol_event(struct hda_codec *codec, unsigned int res) |
2002 | { | |
2003 | struct alc_spec *spec = codec->spec; | |
2004 | ||
2005 | if (spec->unsol_event) | |
2006 | spec->unsol_event(codec, res); | |
2007 | } | |
2008 | ||
1da177e4 LT |
2009 | #ifdef CONFIG_PM |
2010 | /* | |
2011 | * resume | |
2012 | */ | |
2013 | static int alc_resume(struct hda_codec *codec) | |
2014 | { | |
2015 | struct alc_spec *spec = codec->spec; | |
2016 | int i; | |
2017 | ||
2018 | alc_init(codec); | |
e9edcee0 | 2019 | for (i = 0; i < spec->num_mixers; i++) |
1da177e4 | 2020 | snd_hda_resume_ctls(codec, spec->mixers[i]); |
1da177e4 LT |
2021 | if (spec->multiout.dig_out_nid) |
2022 | snd_hda_resume_spdif_out(codec); | |
2023 | if (spec->dig_in_nid) | |
2024 | snd_hda_resume_spdif_in(codec); | |
2025 | ||
2026 | return 0; | |
2027 | } | |
2028 | #endif | |
2029 | ||
2030 | /* | |
2031 | * Analog playback callbacks | |
2032 | */ | |
2033 | static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo, | |
2034 | struct hda_codec *codec, | |
c8b6bf9b | 2035 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2036 | { |
2037 | struct alc_spec *spec = codec->spec; | |
2038 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); | |
2039 | } | |
2040 | ||
2041 | static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | |
2042 | struct hda_codec *codec, | |
2043 | unsigned int stream_tag, | |
2044 | unsigned int format, | |
c8b6bf9b | 2045 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2046 | { |
2047 | struct alc_spec *spec = codec->spec; | |
9c7f852e TI |
2048 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, |
2049 | stream_tag, format, substream); | |
1da177e4 LT |
2050 | } |
2051 | ||
2052 | static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, | |
2053 | struct hda_codec *codec, | |
c8b6bf9b | 2054 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2055 | { |
2056 | struct alc_spec *spec = codec->spec; | |
2057 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); | |
2058 | } | |
2059 | ||
2060 | /* | |
2061 | * Digital out | |
2062 | */ | |
2063 | static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, | |
2064 | struct hda_codec *codec, | |
c8b6bf9b | 2065 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2066 | { |
2067 | struct alc_spec *spec = codec->spec; | |
2068 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); | |
2069 | } | |
2070 | ||
6b97eb45 TI |
2071 | static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
2072 | struct hda_codec *codec, | |
2073 | unsigned int stream_tag, | |
2074 | unsigned int format, | |
2075 | struct snd_pcm_substream *substream) | |
2076 | { | |
2077 | struct alc_spec *spec = codec->spec; | |
2078 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, | |
2079 | stream_tag, format, substream); | |
2080 | } | |
2081 | ||
1da177e4 LT |
2082 | static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
2083 | struct hda_codec *codec, | |
c8b6bf9b | 2084 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2085 | { |
2086 | struct alc_spec *spec = codec->spec; | |
2087 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); | |
2088 | } | |
2089 | ||
2090 | /* | |
2091 | * Analog capture | |
2092 | */ | |
2093 | static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo, | |
2094 | struct hda_codec *codec, | |
2095 | unsigned int stream_tag, | |
2096 | unsigned int format, | |
c8b6bf9b | 2097 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2098 | { |
2099 | struct alc_spec *spec = codec->spec; | |
2100 | ||
2101 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], | |
2102 | stream_tag, 0, format); | |
2103 | return 0; | |
2104 | } | |
2105 | ||
2106 | static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, | |
2107 | struct hda_codec *codec, | |
c8b6bf9b | 2108 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2109 | { |
2110 | struct alc_spec *spec = codec->spec; | |
2111 | ||
9c7f852e TI |
2112 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], |
2113 | 0, 0, 0); | |
1da177e4 LT |
2114 | return 0; |
2115 | } | |
2116 | ||
2117 | ||
2118 | /* | |
2119 | */ | |
2120 | static struct hda_pcm_stream alc880_pcm_analog_playback = { | |
2121 | .substreams = 1, | |
2122 | .channels_min = 2, | |
2123 | .channels_max = 8, | |
e9edcee0 | 2124 | /* NID is set in alc_build_pcms */ |
1da177e4 LT |
2125 | .ops = { |
2126 | .open = alc880_playback_pcm_open, | |
2127 | .prepare = alc880_playback_pcm_prepare, | |
2128 | .cleanup = alc880_playback_pcm_cleanup | |
2129 | }, | |
2130 | }; | |
2131 | ||
2132 | static struct hda_pcm_stream alc880_pcm_analog_capture = { | |
2133 | .substreams = 2, | |
2134 | .channels_min = 2, | |
2135 | .channels_max = 2, | |
e9edcee0 | 2136 | /* NID is set in alc_build_pcms */ |
1da177e4 LT |
2137 | .ops = { |
2138 | .prepare = alc880_capture_pcm_prepare, | |
2139 | .cleanup = alc880_capture_pcm_cleanup | |
2140 | }, | |
2141 | }; | |
2142 | ||
2143 | static struct hda_pcm_stream alc880_pcm_digital_playback = { | |
2144 | .substreams = 1, | |
2145 | .channels_min = 2, | |
2146 | .channels_max = 2, | |
2147 | /* NID is set in alc_build_pcms */ | |
2148 | .ops = { | |
2149 | .open = alc880_dig_playback_pcm_open, | |
6b97eb45 TI |
2150 | .close = alc880_dig_playback_pcm_close, |
2151 | .prepare = alc880_dig_playback_pcm_prepare | |
1da177e4 LT |
2152 | }, |
2153 | }; | |
2154 | ||
2155 | static struct hda_pcm_stream alc880_pcm_digital_capture = { | |
2156 | .substreams = 1, | |
2157 | .channels_min = 2, | |
2158 | .channels_max = 2, | |
2159 | /* NID is set in alc_build_pcms */ | |
2160 | }; | |
2161 | ||
4c5186ed JW |
2162 | /* Used by alc_build_pcms to flag that a PCM has no playback stream */ |
2163 | static struct hda_pcm_stream alc_pcm_null_playback = { | |
2164 | .substreams = 0, | |
2165 | .channels_min = 0, | |
2166 | .channels_max = 0, | |
2167 | }; | |
2168 | ||
1da177e4 LT |
2169 | static int alc_build_pcms(struct hda_codec *codec) |
2170 | { | |
2171 | struct alc_spec *spec = codec->spec; | |
2172 | struct hda_pcm *info = spec->pcm_rec; | |
2173 | int i; | |
2174 | ||
2175 | codec->num_pcms = 1; | |
2176 | codec->pcm_info = info; | |
2177 | ||
2178 | info->name = spec->stream_name_analog; | |
4a471b7d TI |
2179 | if (spec->stream_analog_playback) { |
2180 | snd_assert(spec->multiout.dac_nids, return -EINVAL); | |
2181 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback); | |
2182 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; | |
2183 | } | |
2184 | if (spec->stream_analog_capture) { | |
2185 | snd_assert(spec->adc_nids, return -EINVAL); | |
2186 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); | |
2187 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; | |
2188 | } | |
2189 | ||
2190 | if (spec->channel_mode) { | |
2191 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; | |
2192 | for (i = 0; i < spec->num_channel_mode; i++) { | |
2193 | if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { | |
2194 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; | |
2195 | } | |
1da177e4 LT |
2196 | } |
2197 | } | |
2198 | ||
e08a007d | 2199 | /* SPDIF for stream index #1 */ |
1da177e4 | 2200 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
e08a007d | 2201 | codec->num_pcms = 2; |
c06134d7 | 2202 | info = spec->pcm_rec + 1; |
1da177e4 | 2203 | info->name = spec->stream_name_digital; |
4a471b7d TI |
2204 | if (spec->multiout.dig_out_nid && |
2205 | spec->stream_digital_playback) { | |
1da177e4 LT |
2206 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback); |
2207 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; | |
2208 | } | |
4a471b7d TI |
2209 | if (spec->dig_in_nid && |
2210 | spec->stream_digital_capture) { | |
1da177e4 LT |
2211 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture); |
2212 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; | |
2213 | } | |
2214 | } | |
2215 | ||
e08a007d TI |
2216 | /* If the use of more than one ADC is requested for the current |
2217 | * model, configure a second analog capture-only PCM. | |
2218 | */ | |
2219 | /* Additional Analaog capture for index #2 */ | |
2220 | if (spec->num_adc_nids > 1 && spec->stream_analog_capture && | |
2221 | spec->adc_nids) { | |
2222 | codec->num_pcms = 3; | |
c06134d7 | 2223 | info = spec->pcm_rec + 2; |
e08a007d TI |
2224 | info->name = spec->stream_name_analog; |
2225 | /* No playback stream for second PCM */ | |
2226 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback; | |
2227 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; | |
2228 | if (spec->stream_analog_capture) { | |
2229 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); | |
2230 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1]; | |
2231 | } | |
2232 | } | |
2233 | ||
1da177e4 LT |
2234 | return 0; |
2235 | } | |
2236 | ||
2237 | static void alc_free(struct hda_codec *codec) | |
2238 | { | |
e9edcee0 TI |
2239 | struct alc_spec *spec = codec->spec; |
2240 | unsigned int i; | |
2241 | ||
f12ab1e0 | 2242 | if (!spec) |
e9edcee0 TI |
2243 | return; |
2244 | ||
2245 | if (spec->kctl_alloc) { | |
2246 | for (i = 0; i < spec->num_kctl_used; i++) | |
2247 | kfree(spec->kctl_alloc[i].name); | |
2248 | kfree(spec->kctl_alloc); | |
2249 | } | |
2250 | kfree(spec); | |
1da177e4 LT |
2251 | } |
2252 | ||
2253 | /* | |
2254 | */ | |
2255 | static struct hda_codec_ops alc_patch_ops = { | |
2256 | .build_controls = alc_build_controls, | |
2257 | .build_pcms = alc_build_pcms, | |
2258 | .init = alc_init, | |
2259 | .free = alc_free, | |
ae6b813a | 2260 | .unsol_event = alc_unsol_event, |
1da177e4 LT |
2261 | #ifdef CONFIG_PM |
2262 | .resume = alc_resume, | |
2263 | #endif | |
2264 | }; | |
2265 | ||
2fa522be TI |
2266 | |
2267 | /* | |
2268 | * Test configuration for debugging | |
2269 | * | |
2270 | * Almost all inputs/outputs are enabled. I/O pins can be configured via | |
2271 | * enum controls. | |
2272 | */ | |
2273 | #ifdef CONFIG_SND_DEBUG | |
2274 | static hda_nid_t alc880_test_dac_nids[4] = { | |
2275 | 0x02, 0x03, 0x04, 0x05 | |
2276 | }; | |
2277 | ||
2278 | static struct hda_input_mux alc880_test_capture_source = { | |
ae6b813a | 2279 | .num_items = 7, |
2fa522be TI |
2280 | .items = { |
2281 | { "In-1", 0x0 }, | |
2282 | { "In-2", 0x1 }, | |
2283 | { "In-3", 0x2 }, | |
2284 | { "In-4", 0x3 }, | |
2285 | { "CD", 0x4 }, | |
ae6b813a TI |
2286 | { "Front", 0x5 }, |
2287 | { "Surround", 0x6 }, | |
2fa522be TI |
2288 | }, |
2289 | }; | |
2290 | ||
d2a6d7dc | 2291 | static struct hda_channel_mode alc880_test_modes[4] = { |
2fa522be | 2292 | { 2, NULL }, |
fd2c326d | 2293 | { 4, NULL }, |
2fa522be | 2294 | { 6, NULL }, |
fd2c326d | 2295 | { 8, NULL }, |
2fa522be TI |
2296 | }; |
2297 | ||
9c7f852e TI |
2298 | static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, |
2299 | struct snd_ctl_elem_info *uinfo) | |
2fa522be TI |
2300 | { |
2301 | static char *texts[] = { | |
2302 | "N/A", "Line Out", "HP Out", | |
2303 | "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%" | |
2304 | }; | |
2305 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
2306 | uinfo->count = 1; | |
2307 | uinfo->value.enumerated.items = 8; | |
2308 | if (uinfo->value.enumerated.item >= 8) | |
2309 | uinfo->value.enumerated.item = 7; | |
2310 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | |
2311 | return 0; | |
2312 | } | |
2313 | ||
9c7f852e TI |
2314 | static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, |
2315 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
2316 | { |
2317 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2318 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
2319 | unsigned int pin_ctl, item = 0; | |
2320 | ||
2321 | pin_ctl = snd_hda_codec_read(codec, nid, 0, | |
2322 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | |
2323 | if (pin_ctl & AC_PINCTL_OUT_EN) { | |
2324 | if (pin_ctl & AC_PINCTL_HP_EN) | |
2325 | item = 2; | |
2326 | else | |
2327 | item = 1; | |
2328 | } else if (pin_ctl & AC_PINCTL_IN_EN) { | |
2329 | switch (pin_ctl & AC_PINCTL_VREFEN) { | |
2330 | case AC_PINCTL_VREF_HIZ: item = 3; break; | |
2331 | case AC_PINCTL_VREF_50: item = 4; break; | |
2332 | case AC_PINCTL_VREF_GRD: item = 5; break; | |
2333 | case AC_PINCTL_VREF_80: item = 6; break; | |
2334 | case AC_PINCTL_VREF_100: item = 7; break; | |
2335 | } | |
2336 | } | |
2337 | ucontrol->value.enumerated.item[0] = item; | |
2338 | return 0; | |
2339 | } | |
2340 | ||
9c7f852e TI |
2341 | static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, |
2342 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
2343 | { |
2344 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2345 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
2346 | static unsigned int ctls[] = { | |
2347 | 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN, | |
2348 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ, | |
2349 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_50, | |
2350 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD, | |
2351 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_80, | |
2352 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_100, | |
2353 | }; | |
2354 | unsigned int old_ctl, new_ctl; | |
2355 | ||
2356 | old_ctl = snd_hda_codec_read(codec, nid, 0, | |
2357 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | |
2358 | new_ctl = ctls[ucontrol->value.enumerated.item[0]]; | |
2359 | if (old_ctl != new_ctl) { | |
9c7f852e TI |
2360 | snd_hda_codec_write(codec, nid, 0, |
2361 | AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl); | |
2fa522be | 2362 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
9c7f852e TI |
2363 | (ucontrol->value.enumerated.item[0] >= 3 ? |
2364 | 0xb080 : 0xb000)); | |
2fa522be TI |
2365 | return 1; |
2366 | } | |
2367 | return 0; | |
2368 | } | |
2369 | ||
9c7f852e TI |
2370 | static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, |
2371 | struct snd_ctl_elem_info *uinfo) | |
2fa522be TI |
2372 | { |
2373 | static char *texts[] = { | |
2374 | "Front", "Surround", "CLFE", "Side" | |
2375 | }; | |
2376 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
2377 | uinfo->count = 1; | |
2378 | uinfo->value.enumerated.items = 4; | |
2379 | if (uinfo->value.enumerated.item >= 4) | |
2380 | uinfo->value.enumerated.item = 3; | |
2381 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | |
2382 | return 0; | |
2383 | } | |
2384 | ||
9c7f852e TI |
2385 | static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, |
2386 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
2387 | { |
2388 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2389 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
2390 | unsigned int sel; | |
2391 | ||
2392 | sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0); | |
2393 | ucontrol->value.enumerated.item[0] = sel & 3; | |
2394 | return 0; | |
2395 | } | |
2396 | ||
9c7f852e TI |
2397 | static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, |
2398 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
2399 | { |
2400 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2401 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
2402 | unsigned int sel; | |
2403 | ||
2404 | sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3; | |
2405 | if (ucontrol->value.enumerated.item[0] != sel) { | |
2406 | sel = ucontrol->value.enumerated.item[0] & 3; | |
2407 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel); | |
2408 | return 1; | |
2409 | } | |
2410 | return 0; | |
2411 | } | |
2412 | ||
2413 | #define PIN_CTL_TEST(xname,nid) { \ | |
2414 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
2415 | .name = xname, \ | |
2416 | .info = alc_test_pin_ctl_info, \ | |
2417 | .get = alc_test_pin_ctl_get, \ | |
2418 | .put = alc_test_pin_ctl_put, \ | |
2419 | .private_value = nid \ | |
2420 | } | |
2421 | ||
2422 | #define PIN_SRC_TEST(xname,nid) { \ | |
2423 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
2424 | .name = xname, \ | |
2425 | .info = alc_test_pin_src_info, \ | |
2426 | .get = alc_test_pin_src_get, \ | |
2427 | .put = alc_test_pin_src_put, \ | |
2428 | .private_value = nid \ | |
2429 | } | |
2430 | ||
c8b6bf9b | 2431 | static struct snd_kcontrol_new alc880_test_mixer[] = { |
05acb863 TI |
2432 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
2433 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
2434 | HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT), | |
2435 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
985be54b TI |
2436 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
2437 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
2438 | HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT), | |
2439 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
2fa522be TI |
2440 | PIN_CTL_TEST("Front Pin Mode", 0x14), |
2441 | PIN_CTL_TEST("Surround Pin Mode", 0x15), | |
2442 | PIN_CTL_TEST("CLFE Pin Mode", 0x16), | |
2443 | PIN_CTL_TEST("Side Pin Mode", 0x17), | |
2444 | PIN_CTL_TEST("In-1 Pin Mode", 0x18), | |
2445 | PIN_CTL_TEST("In-2 Pin Mode", 0x19), | |
2446 | PIN_CTL_TEST("In-3 Pin Mode", 0x1a), | |
2447 | PIN_CTL_TEST("In-4 Pin Mode", 0x1b), | |
2448 | PIN_SRC_TEST("In-1 Pin Source", 0x18), | |
2449 | PIN_SRC_TEST("In-2 Pin Source", 0x19), | |
2450 | PIN_SRC_TEST("In-3 Pin Source", 0x1a), | |
2451 | PIN_SRC_TEST("In-4 Pin Source", 0x1b), | |
2452 | HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
2453 | HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2454 | HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
2455 | HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
2456 | HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT), | |
2457 | HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT), | |
2458 | HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT), | |
2459 | HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT), | |
2460 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT), | |
2461 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT), | |
2fa522be TI |
2462 | { |
2463 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2464 | .name = "Channel Mode", | |
df694daa KY |
2465 | .info = alc_ch_mode_info, |
2466 | .get = alc_ch_mode_get, | |
2467 | .put = alc_ch_mode_put, | |
2fa522be TI |
2468 | }, |
2469 | { } /* end */ | |
2470 | }; | |
2471 | ||
2472 | static struct hda_verb alc880_test_init_verbs[] = { | |
2473 | /* Unmute inputs of 0x0c - 0x0f */ | |
05acb863 TI |
2474 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
2475 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2476 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2477 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2478 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2479 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2480 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2481 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2fa522be | 2482 | /* Vol output for 0x0c-0x0f */ |
05acb863 TI |
2483 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
2484 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2485 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2486 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2fa522be | 2487 | /* Set output pins 0x14-0x17 */ |
05acb863 TI |
2488 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
2489 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2490 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2491 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2fa522be | 2492 | /* Unmute output pins 0x14-0x17 */ |
05acb863 TI |
2493 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
2494 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2495 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2496 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2fa522be | 2497 | /* Set input pins 0x18-0x1c */ |
16ded525 TI |
2498 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
2499 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
05acb863 TI |
2500 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
2501 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2502 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2fa522be | 2503 | /* Mute input pins 0x18-0x1b */ |
05acb863 TI |
2504 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
2505 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2506 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2507 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
71fe7b82 | 2508 | /* ADC set up */ |
05acb863 | 2509 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 2510 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 | 2511 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 2512 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 | 2513 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 2514 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
2515 | /* Analog input/passthru */ |
2516 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
2517 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2518 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
2519 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
2520 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
2fa522be TI |
2521 | { } |
2522 | }; | |
2523 | #endif | |
2524 | ||
1da177e4 LT |
2525 | /* |
2526 | */ | |
2527 | ||
f5fcc13c TI |
2528 | static const char *alc880_models[ALC880_MODEL_LAST] = { |
2529 | [ALC880_3ST] = "3stack", | |
2530 | [ALC880_TCL_S700] = "tcl", | |
2531 | [ALC880_3ST_DIG] = "3stack-digout", | |
2532 | [ALC880_CLEVO] = "clevo", | |
2533 | [ALC880_5ST] = "5stack", | |
2534 | [ALC880_5ST_DIG] = "5stack-digout", | |
2535 | [ALC880_W810] = "w810", | |
2536 | [ALC880_Z71V] = "z71v", | |
2537 | [ALC880_6ST] = "6stack", | |
2538 | [ALC880_6ST_DIG] = "6stack-digout", | |
2539 | [ALC880_ASUS] = "asus", | |
2540 | [ALC880_ASUS_W1V] = "asus-w1v", | |
2541 | [ALC880_ASUS_DIG] = "asus-dig", | |
2542 | [ALC880_ASUS_DIG2] = "asus-dig2", | |
2543 | [ALC880_UNIWILL_DIG] = "uniwill", | |
2cf9f0fc TD |
2544 | [ALC880_UNIWILL_P53] = "uniwill-p53", |
2545 | [ALC880_FUJITSU] = "fujitsu", | |
f5fcc13c TI |
2546 | [ALC880_F1734] = "F1734", |
2547 | [ALC880_LG] = "lg", | |
2548 | [ALC880_LG_LW] = "lg-lw", | |
2fa522be | 2549 | #ifdef CONFIG_SND_DEBUG |
f5fcc13c | 2550 | [ALC880_TEST] = "test", |
2fa522be | 2551 | #endif |
f5fcc13c TI |
2552 | [ALC880_AUTO] = "auto", |
2553 | }; | |
2554 | ||
2555 | static struct snd_pci_quirk alc880_cfg_tbl[] = { | |
2556 | /* Broken BIOS configuration */ | |
2557 | SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), | |
2558 | SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG), | |
2559 | ||
2560 | SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG), | |
2561 | SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST), | |
4dc53e28 | 2562 | SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810), |
f5fcc13c TI |
2563 | SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG), |
2564 | SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG), | |
2565 | SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG), | |
2566 | SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG), | |
2567 | SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG), | |
2568 | SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST), | |
2569 | ||
2570 | SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG), | |
2571 | SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST), | |
2572 | ||
2573 | SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V), | |
2574 | SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG), | |
2575 | SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG), | |
2576 | SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG), | |
2577 | SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG), | |
2578 | SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG), | |
2579 | SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V), | |
2580 | /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */ | |
2581 | SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG), | |
2582 | SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG), | |
0e4ceb75 | 2583 | SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS), |
f5fcc13c TI |
2584 | SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG), |
2585 | SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST), | |
2586 | SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST), | |
2587 | SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), | |
2588 | ||
2589 | SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST), | |
2590 | SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST), | |
2591 | SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST), | |
2592 | SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST), | |
2593 | SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST), | |
2594 | SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO), | |
2595 | SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO), | |
2596 | SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG), | |
2597 | SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810), | |
2598 | SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG), | |
2599 | SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700), | |
2600 | SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG), | |
2601 | SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG), | |
2602 | SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG), | |
2603 | SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG), | |
2604 | SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG), | |
2605 | SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG), | |
2606 | SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2), | |
2607 | ||
2608 | SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG), | |
2609 | SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL), | |
2610 | SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53), | |
2611 | SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734), | |
2612 | ||
2613 | SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG), | |
2614 | SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL), | |
2615 | SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734), | |
2cf9f0fc | 2616 | SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU), |
f5fcc13c TI |
2617 | |
2618 | SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG), | |
2619 | SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG), | |
2620 | SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW), | |
2621 | SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW), | |
2622 | ||
2623 | SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG), | |
2624 | SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG), | |
2625 | SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG), | |
2626 | SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG), | |
2627 | SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG), | |
2628 | SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG), | |
2629 | SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG), | |
2630 | SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG), | |
2631 | SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG), | |
2632 | SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG), | |
2633 | SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), | |
2fa522be | 2634 | |
1da177e4 LT |
2635 | {} |
2636 | }; | |
2637 | ||
16ded525 | 2638 | /* |
df694daa | 2639 | * ALC880 codec presets |
16ded525 | 2640 | */ |
16ded525 TI |
2641 | static struct alc_config_preset alc880_presets[] = { |
2642 | [ALC880_3ST] = { | |
e9edcee0 | 2643 | .mixers = { alc880_three_stack_mixer }, |
f12ab1e0 TI |
2644 | .init_verbs = { alc880_volume_init_verbs, |
2645 | alc880_pin_3stack_init_verbs }, | |
16ded525 | 2646 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
16ded525 | 2647 | .dac_nids = alc880_dac_nids, |
16ded525 TI |
2648 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
2649 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 2650 | .need_dac_fix = 1, |
16ded525 TI |
2651 | .input_mux = &alc880_capture_source, |
2652 | }, | |
2653 | [ALC880_3ST_DIG] = { | |
e9edcee0 | 2654 | .mixers = { alc880_three_stack_mixer }, |
f12ab1e0 TI |
2655 | .init_verbs = { alc880_volume_init_verbs, |
2656 | alc880_pin_3stack_init_verbs }, | |
16ded525 | 2657 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
16ded525 TI |
2658 | .dac_nids = alc880_dac_nids, |
2659 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
2660 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
2661 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 2662 | .need_dac_fix = 1, |
16ded525 TI |
2663 | .input_mux = &alc880_capture_source, |
2664 | }, | |
df694daa KY |
2665 | [ALC880_TCL_S700] = { |
2666 | .mixers = { alc880_tcl_s700_mixer }, | |
2667 | .init_verbs = { alc880_volume_init_verbs, | |
2668 | alc880_pin_tcl_S700_init_verbs, | |
2669 | alc880_gpio2_init_verbs }, | |
2670 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
2671 | .dac_nids = alc880_dac_nids, | |
2672 | .hp_nid = 0x03, | |
2673 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
2674 | .channel_mode = alc880_2_jack_modes, | |
2675 | .input_mux = &alc880_capture_source, | |
2676 | }, | |
16ded525 | 2677 | [ALC880_5ST] = { |
f12ab1e0 TI |
2678 | .mixers = { alc880_three_stack_mixer, |
2679 | alc880_five_stack_mixer}, | |
2680 | .init_verbs = { alc880_volume_init_verbs, | |
2681 | alc880_pin_5stack_init_verbs }, | |
16ded525 TI |
2682 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
2683 | .dac_nids = alc880_dac_nids, | |
16ded525 TI |
2684 | .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), |
2685 | .channel_mode = alc880_fivestack_modes, | |
2686 | .input_mux = &alc880_capture_source, | |
2687 | }, | |
2688 | [ALC880_5ST_DIG] = { | |
f12ab1e0 TI |
2689 | .mixers = { alc880_three_stack_mixer, |
2690 | alc880_five_stack_mixer }, | |
2691 | .init_verbs = { alc880_volume_init_verbs, | |
2692 | alc880_pin_5stack_init_verbs }, | |
16ded525 TI |
2693 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
2694 | .dac_nids = alc880_dac_nids, | |
2695 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
2696 | .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), |
2697 | .channel_mode = alc880_fivestack_modes, | |
2698 | .input_mux = &alc880_capture_source, | |
2699 | }, | |
b6482d48 TI |
2700 | [ALC880_6ST] = { |
2701 | .mixers = { alc880_six_stack_mixer }, | |
f12ab1e0 TI |
2702 | .init_verbs = { alc880_volume_init_verbs, |
2703 | alc880_pin_6stack_init_verbs }, | |
b6482d48 TI |
2704 | .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), |
2705 | .dac_nids = alc880_6st_dac_nids, | |
2706 | .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), | |
2707 | .channel_mode = alc880_sixstack_modes, | |
2708 | .input_mux = &alc880_6stack_capture_source, | |
2709 | }, | |
16ded525 | 2710 | [ALC880_6ST_DIG] = { |
e9edcee0 | 2711 | .mixers = { alc880_six_stack_mixer }, |
f12ab1e0 TI |
2712 | .init_verbs = { alc880_volume_init_verbs, |
2713 | alc880_pin_6stack_init_verbs }, | |
16ded525 TI |
2714 | .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), |
2715 | .dac_nids = alc880_6st_dac_nids, | |
2716 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
2717 | .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), |
2718 | .channel_mode = alc880_sixstack_modes, | |
2719 | .input_mux = &alc880_6stack_capture_source, | |
2720 | }, | |
2721 | [ALC880_W810] = { | |
e9edcee0 | 2722 | .mixers = { alc880_w810_base_mixer }, |
f12ab1e0 TI |
2723 | .init_verbs = { alc880_volume_init_verbs, |
2724 | alc880_pin_w810_init_verbs, | |
b0af0de5 | 2725 | alc880_gpio2_init_verbs }, |
16ded525 TI |
2726 | .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids), |
2727 | .dac_nids = alc880_w810_dac_nids, | |
2728 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
2729 | .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), |
2730 | .channel_mode = alc880_w810_modes, | |
2731 | .input_mux = &alc880_capture_source, | |
2732 | }, | |
2733 | [ALC880_Z71V] = { | |
e9edcee0 | 2734 | .mixers = { alc880_z71v_mixer }, |
f12ab1e0 TI |
2735 | .init_verbs = { alc880_volume_init_verbs, |
2736 | alc880_pin_z71v_init_verbs }, | |
16ded525 TI |
2737 | .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids), |
2738 | .dac_nids = alc880_z71v_dac_nids, | |
2739 | .dig_out_nid = ALC880_DIGOUT_NID, | |
2740 | .hp_nid = 0x03, | |
e9edcee0 TI |
2741 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), |
2742 | .channel_mode = alc880_2_jack_modes, | |
16ded525 TI |
2743 | .input_mux = &alc880_capture_source, |
2744 | }, | |
2745 | [ALC880_F1734] = { | |
e9edcee0 | 2746 | .mixers = { alc880_f1734_mixer }, |
f12ab1e0 TI |
2747 | .init_verbs = { alc880_volume_init_verbs, |
2748 | alc880_pin_f1734_init_verbs }, | |
e9edcee0 TI |
2749 | .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids), |
2750 | .dac_nids = alc880_f1734_dac_nids, | |
2751 | .hp_nid = 0x02, | |
2752 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
2753 | .channel_mode = alc880_2_jack_modes, | |
16ded525 TI |
2754 | .input_mux = &alc880_capture_source, |
2755 | }, | |
2756 | [ALC880_ASUS] = { | |
e9edcee0 | 2757 | .mixers = { alc880_asus_mixer }, |
f12ab1e0 TI |
2758 | .init_verbs = { alc880_volume_init_verbs, |
2759 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
2760 | alc880_gpio1_init_verbs }, |
2761 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
2762 | .dac_nids = alc880_asus_dac_nids, | |
2763 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), | |
2764 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 2765 | .need_dac_fix = 1, |
16ded525 TI |
2766 | .input_mux = &alc880_capture_source, |
2767 | }, | |
2768 | [ALC880_ASUS_DIG] = { | |
e9edcee0 | 2769 | .mixers = { alc880_asus_mixer }, |
f12ab1e0 TI |
2770 | .init_verbs = { alc880_volume_init_verbs, |
2771 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
2772 | alc880_gpio1_init_verbs }, |
2773 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
2774 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 2775 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
2776 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
2777 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 2778 | .need_dac_fix = 1, |
16ded525 TI |
2779 | .input_mux = &alc880_capture_source, |
2780 | }, | |
df694daa KY |
2781 | [ALC880_ASUS_DIG2] = { |
2782 | .mixers = { alc880_asus_mixer }, | |
f12ab1e0 TI |
2783 | .init_verbs = { alc880_volume_init_verbs, |
2784 | alc880_pin_asus_init_verbs, | |
df694daa KY |
2785 | alc880_gpio2_init_verbs }, /* use GPIO2 */ |
2786 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
2787 | .dac_nids = alc880_asus_dac_nids, | |
2788 | .dig_out_nid = ALC880_DIGOUT_NID, | |
2789 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), | |
2790 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 2791 | .need_dac_fix = 1, |
df694daa KY |
2792 | .input_mux = &alc880_capture_source, |
2793 | }, | |
16ded525 | 2794 | [ALC880_ASUS_W1V] = { |
e9edcee0 | 2795 | .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer }, |
f12ab1e0 TI |
2796 | .init_verbs = { alc880_volume_init_verbs, |
2797 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
2798 | alc880_gpio1_init_verbs }, |
2799 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
2800 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 2801 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
2802 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
2803 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 2804 | .need_dac_fix = 1, |
16ded525 TI |
2805 | .input_mux = &alc880_capture_source, |
2806 | }, | |
2807 | [ALC880_UNIWILL_DIG] = { | |
3c10a9d9 | 2808 | .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer }, |
ccc656ce KY |
2809 | .init_verbs = { alc880_volume_init_verbs, |
2810 | alc880_pin_asus_init_verbs }, | |
e9edcee0 TI |
2811 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), |
2812 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 2813 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
2814 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
2815 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 2816 | .need_dac_fix = 1, |
16ded525 TI |
2817 | .input_mux = &alc880_capture_source, |
2818 | }, | |
ccc656ce KY |
2819 | [ALC880_UNIWILL] = { |
2820 | .mixers = { alc880_uniwill_mixer }, | |
2821 | .init_verbs = { alc880_volume_init_verbs, | |
2822 | alc880_uniwill_init_verbs }, | |
2823 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
2824 | .dac_nids = alc880_asus_dac_nids, | |
2825 | .dig_out_nid = ALC880_DIGOUT_NID, | |
2826 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
2827 | .channel_mode = alc880_threestack_modes, | |
2828 | .need_dac_fix = 1, | |
2829 | .input_mux = &alc880_capture_source, | |
2830 | .unsol_event = alc880_uniwill_unsol_event, | |
2831 | .init_hook = alc880_uniwill_automute, | |
2832 | }, | |
2833 | [ALC880_UNIWILL_P53] = { | |
2834 | .mixers = { alc880_uniwill_p53_mixer }, | |
2835 | .init_verbs = { alc880_volume_init_verbs, | |
2836 | alc880_uniwill_p53_init_verbs }, | |
2837 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
2838 | .dac_nids = alc880_asus_dac_nids, | |
2839 | .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), | |
2cf9f0fc TD |
2840 | .channel_mode = alc880_threestack_modes, |
2841 | .input_mux = &alc880_capture_source, | |
2842 | .unsol_event = alc880_uniwill_p53_unsol_event, | |
2843 | .init_hook = alc880_uniwill_p53_hp_automute, | |
2844 | }, | |
2845 | [ALC880_FUJITSU] = { | |
f12ab1e0 | 2846 | .mixers = { alc880_fujitsu_mixer, |
2cf9f0fc TD |
2847 | alc880_pcbeep_mixer, }, |
2848 | .init_verbs = { alc880_volume_init_verbs, | |
2849 | alc880_uniwill_p53_init_verbs, | |
2850 | alc880_beep_init_verbs }, | |
2851 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
2852 | .dac_nids = alc880_dac_nids, | |
2853 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
2854 | .channel_mode = alc880_2_jack_modes, | |
ccc656ce KY |
2855 | .input_mux = &alc880_capture_source, |
2856 | .unsol_event = alc880_uniwill_p53_unsol_event, | |
2857 | .init_hook = alc880_uniwill_p53_hp_automute, | |
2858 | }, | |
df694daa KY |
2859 | [ALC880_CLEVO] = { |
2860 | .mixers = { alc880_three_stack_mixer }, | |
2861 | .init_verbs = { alc880_volume_init_verbs, | |
2862 | alc880_pin_clevo_init_verbs }, | |
2863 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
2864 | .dac_nids = alc880_dac_nids, | |
2865 | .hp_nid = 0x03, | |
2866 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
2867 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 2868 | .need_dac_fix = 1, |
df694daa KY |
2869 | .input_mux = &alc880_capture_source, |
2870 | }, | |
ae6b813a TI |
2871 | [ALC880_LG] = { |
2872 | .mixers = { alc880_lg_mixer }, | |
2873 | .init_verbs = { alc880_volume_init_verbs, | |
2874 | alc880_lg_init_verbs }, | |
2875 | .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids), | |
2876 | .dac_nids = alc880_lg_dac_nids, | |
2877 | .dig_out_nid = ALC880_DIGOUT_NID, | |
2878 | .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes), | |
2879 | .channel_mode = alc880_lg_ch_modes, | |
4e195a7b | 2880 | .need_dac_fix = 1, |
ae6b813a TI |
2881 | .input_mux = &alc880_lg_capture_source, |
2882 | .unsol_event = alc880_lg_unsol_event, | |
2883 | .init_hook = alc880_lg_automute, | |
2884 | }, | |
d681518a TI |
2885 | [ALC880_LG_LW] = { |
2886 | .mixers = { alc880_lg_lw_mixer }, | |
2887 | .init_verbs = { alc880_volume_init_verbs, | |
2888 | alc880_lg_lw_init_verbs }, | |
0a8c5da3 | 2889 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
d681518a TI |
2890 | .dac_nids = alc880_dac_nids, |
2891 | .dig_out_nid = ALC880_DIGOUT_NID, | |
0a8c5da3 CM |
2892 | .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes), |
2893 | .channel_mode = alc880_lg_lw_modes, | |
d681518a TI |
2894 | .input_mux = &alc880_lg_lw_capture_source, |
2895 | .unsol_event = alc880_lg_lw_unsol_event, | |
2896 | .init_hook = alc880_lg_lw_automute, | |
2897 | }, | |
16ded525 TI |
2898 | #ifdef CONFIG_SND_DEBUG |
2899 | [ALC880_TEST] = { | |
e9edcee0 TI |
2900 | .mixers = { alc880_test_mixer }, |
2901 | .init_verbs = { alc880_test_init_verbs }, | |
16ded525 TI |
2902 | .num_dacs = ARRAY_SIZE(alc880_test_dac_nids), |
2903 | .dac_nids = alc880_test_dac_nids, | |
2904 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
2905 | .num_channel_mode = ARRAY_SIZE(alc880_test_modes), |
2906 | .channel_mode = alc880_test_modes, | |
2907 | .input_mux = &alc880_test_capture_source, | |
2908 | }, | |
2909 | #endif | |
2910 | }; | |
2911 | ||
e9edcee0 TI |
2912 | /* |
2913 | * Automatic parse of I/O pins from the BIOS configuration | |
2914 | */ | |
2915 | ||
2916 | #define NUM_CONTROL_ALLOC 32 | |
2917 | #define NUM_VERB_ALLOC 32 | |
2918 | ||
2919 | enum { | |
2920 | ALC_CTL_WIDGET_VOL, | |
2921 | ALC_CTL_WIDGET_MUTE, | |
2922 | ALC_CTL_BIND_MUTE, | |
2923 | }; | |
c8b6bf9b | 2924 | static struct snd_kcontrol_new alc880_control_templates[] = { |
e9edcee0 TI |
2925 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
2926 | HDA_CODEC_MUTE(NULL, 0, 0, 0), | |
985be54b | 2927 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
e9edcee0 TI |
2928 | }; |
2929 | ||
2930 | /* add dynamic controls */ | |
f12ab1e0 TI |
2931 | static int add_control(struct alc_spec *spec, int type, const char *name, |
2932 | unsigned long val) | |
e9edcee0 | 2933 | { |
c8b6bf9b | 2934 | struct snd_kcontrol_new *knew; |
e9edcee0 TI |
2935 | |
2936 | if (spec->num_kctl_used >= spec->num_kctl_alloc) { | |
2937 | int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; | |
2938 | ||
f12ab1e0 TI |
2939 | /* array + terminator */ |
2940 | knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); | |
2941 | if (!knew) | |
e9edcee0 TI |
2942 | return -ENOMEM; |
2943 | if (spec->kctl_alloc) { | |
f12ab1e0 TI |
2944 | memcpy(knew, spec->kctl_alloc, |
2945 | sizeof(*knew) * spec->num_kctl_alloc); | |
e9edcee0 TI |
2946 | kfree(spec->kctl_alloc); |
2947 | } | |
2948 | spec->kctl_alloc = knew; | |
2949 | spec->num_kctl_alloc = num; | |
2950 | } | |
2951 | ||
2952 | knew = &spec->kctl_alloc[spec->num_kctl_used]; | |
2953 | *knew = alc880_control_templates[type]; | |
543537bd | 2954 | knew->name = kstrdup(name, GFP_KERNEL); |
f12ab1e0 | 2955 | if (!knew->name) |
e9edcee0 TI |
2956 | return -ENOMEM; |
2957 | knew->private_value = val; | |
2958 | spec->num_kctl_used++; | |
2959 | return 0; | |
2960 | } | |
2961 | ||
2962 | #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17) | |
2963 | #define alc880_fixed_pin_idx(nid) ((nid) - 0x14) | |
2964 | #define alc880_is_multi_pin(nid) ((nid) >= 0x18) | |
2965 | #define alc880_multi_pin_idx(nid) ((nid) - 0x18) | |
2966 | #define alc880_is_input_pin(nid) ((nid) >= 0x18) | |
2967 | #define alc880_input_pin_idx(nid) ((nid) - 0x18) | |
2968 | #define alc880_idx_to_dac(nid) ((nid) + 0x02) | |
2969 | #define alc880_dac_to_idx(nid) ((nid) - 0x02) | |
2970 | #define alc880_idx_to_mixer(nid) ((nid) + 0x0c) | |
2971 | #define alc880_idx_to_selector(nid) ((nid) + 0x10) | |
2972 | #define ALC880_PIN_CD_NID 0x1c | |
2973 | ||
2974 | /* fill in the dac_nids table from the parsed pin configuration */ | |
f12ab1e0 TI |
2975 | static int alc880_auto_fill_dac_nids(struct alc_spec *spec, |
2976 | const struct auto_pin_cfg *cfg) | |
e9edcee0 TI |
2977 | { |
2978 | hda_nid_t nid; | |
2979 | int assigned[4]; | |
2980 | int i, j; | |
2981 | ||
2982 | memset(assigned, 0, sizeof(assigned)); | |
b0af0de5 | 2983 | spec->multiout.dac_nids = spec->private_dac_nids; |
e9edcee0 TI |
2984 | |
2985 | /* check the pins hardwired to audio widget */ | |
2986 | for (i = 0; i < cfg->line_outs; i++) { | |
2987 | nid = cfg->line_out_pins[i]; | |
2988 | if (alc880_is_fixed_pin(nid)) { | |
2989 | int idx = alc880_fixed_pin_idx(nid); | |
5014f193 | 2990 | spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx); |
e9edcee0 TI |
2991 | assigned[idx] = 1; |
2992 | } | |
2993 | } | |
2994 | /* left pins can be connect to any audio widget */ | |
2995 | for (i = 0; i < cfg->line_outs; i++) { | |
2996 | nid = cfg->line_out_pins[i]; | |
2997 | if (alc880_is_fixed_pin(nid)) | |
2998 | continue; | |
2999 | /* search for an empty channel */ | |
3000 | for (j = 0; j < cfg->line_outs; j++) { | |
f12ab1e0 TI |
3001 | if (!assigned[j]) { |
3002 | spec->multiout.dac_nids[i] = | |
3003 | alc880_idx_to_dac(j); | |
e9edcee0 TI |
3004 | assigned[j] = 1; |
3005 | break; | |
3006 | } | |
3007 | } | |
3008 | } | |
3009 | spec->multiout.num_dacs = cfg->line_outs; | |
3010 | return 0; | |
3011 | } | |
3012 | ||
3013 | /* add playback controls from the parsed DAC table */ | |
df694daa KY |
3014 | static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, |
3015 | const struct auto_pin_cfg *cfg) | |
e9edcee0 TI |
3016 | { |
3017 | char name[32]; | |
f12ab1e0 TI |
3018 | static const char *chname[4] = { |
3019 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
3020 | }; | |
e9edcee0 TI |
3021 | hda_nid_t nid; |
3022 | int i, err; | |
3023 | ||
3024 | for (i = 0; i < cfg->line_outs; i++) { | |
f12ab1e0 | 3025 | if (!spec->multiout.dac_nids[i]) |
e9edcee0 TI |
3026 | continue; |
3027 | nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i])); | |
3028 | if (i == 2) { | |
3029 | /* Center/LFE */ | |
f12ab1e0 TI |
3030 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
3031 | "Center Playback Volume", | |
3032 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, | |
3033 | HDA_OUTPUT)); | |
3034 | if (err < 0) | |
e9edcee0 | 3035 | return err; |
f12ab1e0 TI |
3036 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
3037 | "LFE Playback Volume", | |
3038 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
3039 | HDA_OUTPUT)); | |
3040 | if (err < 0) | |
e9edcee0 | 3041 | return err; |
f12ab1e0 TI |
3042 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
3043 | "Center Playback Switch", | |
3044 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, | |
3045 | HDA_INPUT)); | |
3046 | if (err < 0) | |
e9edcee0 | 3047 | return err; |
f12ab1e0 TI |
3048 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
3049 | "LFE Playback Switch", | |
3050 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, | |
3051 | HDA_INPUT)); | |
3052 | if (err < 0) | |
e9edcee0 TI |
3053 | return err; |
3054 | } else { | |
3055 | sprintf(name, "%s Playback Volume", chname[i]); | |
f12ab1e0 TI |
3056 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
3057 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
3058 | HDA_OUTPUT)); | |
3059 | if (err < 0) | |
e9edcee0 TI |
3060 | return err; |
3061 | sprintf(name, "%s Playback Switch", chname[i]); | |
f12ab1e0 TI |
3062 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
3063 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, | |
3064 | HDA_INPUT)); | |
3065 | if (err < 0) | |
e9edcee0 TI |
3066 | return err; |
3067 | } | |
3068 | } | |
e9edcee0 TI |
3069 | return 0; |
3070 | } | |
3071 | ||
8d88bc3d TI |
3072 | /* add playback controls for speaker and HP outputs */ |
3073 | static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, | |
3074 | const char *pfx) | |
e9edcee0 TI |
3075 | { |
3076 | hda_nid_t nid; | |
3077 | int err; | |
8d88bc3d | 3078 | char name[32]; |
e9edcee0 | 3079 | |
f12ab1e0 | 3080 | if (!pin) |
e9edcee0 TI |
3081 | return 0; |
3082 | ||
3083 | if (alc880_is_fixed_pin(pin)) { | |
3084 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
82bc955f | 3085 | /* specify the DAC as the extra output */ |
f12ab1e0 | 3086 | if (!spec->multiout.hp_nid) |
e9edcee0 | 3087 | spec->multiout.hp_nid = nid; |
82bc955f TI |
3088 | else |
3089 | spec->multiout.extra_out_nid[0] = nid; | |
e9edcee0 TI |
3090 | /* control HP volume/switch on the output mixer amp */ |
3091 | nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin)); | |
8d88bc3d | 3092 | sprintf(name, "%s Playback Volume", pfx); |
f12ab1e0 TI |
3093 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
3094 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
3095 | if (err < 0) | |
e9edcee0 | 3096 | return err; |
8d88bc3d | 3097 | sprintf(name, "%s Playback Switch", pfx); |
f12ab1e0 TI |
3098 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
3099 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); | |
3100 | if (err < 0) | |
e9edcee0 TI |
3101 | return err; |
3102 | } else if (alc880_is_multi_pin(pin)) { | |
3103 | /* set manual connection */ | |
e9edcee0 | 3104 | /* we have only a switch on HP-out PIN */ |
8d88bc3d | 3105 | sprintf(name, "%s Playback Switch", pfx); |
f12ab1e0 TI |
3106 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
3107 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
3108 | if (err < 0) | |
e9edcee0 TI |
3109 | return err; |
3110 | } | |
3111 | return 0; | |
3112 | } | |
3113 | ||
3114 | /* create input playback/capture controls for the given pin */ | |
f12ab1e0 TI |
3115 | static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, |
3116 | const char *ctlname, | |
df694daa | 3117 | int idx, hda_nid_t mix_nid) |
e9edcee0 TI |
3118 | { |
3119 | char name[32]; | |
df694daa | 3120 | int err; |
e9edcee0 TI |
3121 | |
3122 | sprintf(name, "%s Playback Volume", ctlname); | |
f12ab1e0 TI |
3123 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
3124 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); | |
3125 | if (err < 0) | |
e9edcee0 TI |
3126 | return err; |
3127 | sprintf(name, "%s Playback Switch", ctlname); | |
f12ab1e0 TI |
3128 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
3129 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); | |
3130 | if (err < 0) | |
e9edcee0 TI |
3131 | return err; |
3132 | return 0; | |
3133 | } | |
3134 | ||
3135 | /* create playback/capture controls for input pins */ | |
df694daa KY |
3136 | static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, |
3137 | const struct auto_pin_cfg *cfg) | |
e9edcee0 | 3138 | { |
e9edcee0 | 3139 | struct hda_input_mux *imux = &spec->private_imux; |
df694daa | 3140 | int i, err, idx; |
e9edcee0 TI |
3141 | |
3142 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
3143 | if (alc880_is_input_pin(cfg->input_pins[i])) { | |
df694daa | 3144 | idx = alc880_input_pin_idx(cfg->input_pins[i]); |
4a471b7d TI |
3145 | err = new_analog_input(spec, cfg->input_pins[i], |
3146 | auto_pin_cfg_labels[i], | |
df694daa | 3147 | idx, 0x0b); |
e9edcee0 TI |
3148 | if (err < 0) |
3149 | return err; | |
f12ab1e0 TI |
3150 | imux->items[imux->num_items].label = |
3151 | auto_pin_cfg_labels[i]; | |
3152 | imux->items[imux->num_items].index = | |
3153 | alc880_input_pin_idx(cfg->input_pins[i]); | |
e9edcee0 TI |
3154 | imux->num_items++; |
3155 | } | |
3156 | } | |
3157 | return 0; | |
3158 | } | |
3159 | ||
df694daa KY |
3160 | static void alc880_auto_set_output_and_unmute(struct hda_codec *codec, |
3161 | hda_nid_t nid, int pin_type, | |
e9edcee0 TI |
3162 | int dac_idx) |
3163 | { | |
3164 | /* set as output */ | |
f12ab1e0 TI |
3165 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
3166 | pin_type); | |
3167 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
3168 | AMP_OUT_UNMUTE); | |
e9edcee0 TI |
3169 | /* need the manual connection? */ |
3170 | if (alc880_is_multi_pin(nid)) { | |
3171 | struct alc_spec *spec = codec->spec; | |
3172 | int idx = alc880_multi_pin_idx(nid); | |
3173 | snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, | |
3174 | AC_VERB_SET_CONNECT_SEL, | |
3175 | alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); | |
3176 | } | |
3177 | } | |
3178 | ||
baba8ee9 TI |
3179 | static int get_pin_type(int line_out_type) |
3180 | { | |
3181 | if (line_out_type == AUTO_PIN_HP_OUT) | |
3182 | return PIN_HP; | |
3183 | else | |
3184 | return PIN_OUT; | |
3185 | } | |
3186 | ||
e9edcee0 TI |
3187 | static void alc880_auto_init_multi_out(struct hda_codec *codec) |
3188 | { | |
3189 | struct alc_spec *spec = codec->spec; | |
3190 | int i; | |
bc9f98a9 KY |
3191 | |
3192 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); | |
e9edcee0 TI |
3193 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
3194 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 TI |
3195 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
3196 | alc880_auto_set_output_and_unmute(codec, nid, pin_type, i); | |
e9edcee0 TI |
3197 | } |
3198 | } | |
3199 | ||
8d88bc3d | 3200 | static void alc880_auto_init_extra_out(struct hda_codec *codec) |
e9edcee0 TI |
3201 | { |
3202 | struct alc_spec *spec = codec->spec; | |
3203 | hda_nid_t pin; | |
3204 | ||
82bc955f | 3205 | pin = spec->autocfg.speaker_pins[0]; |
8d88bc3d TI |
3206 | if (pin) /* connect to front */ |
3207 | alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
eb06ed8f | 3208 | pin = spec->autocfg.hp_pins[0]; |
e9edcee0 TI |
3209 | if (pin) /* connect to front */ |
3210 | alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
3211 | } | |
3212 | ||
3213 | static void alc880_auto_init_analog_input(struct hda_codec *codec) | |
3214 | { | |
3215 | struct alc_spec *spec = codec->spec; | |
3216 | int i; | |
3217 | ||
3218 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
3219 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
3220 | if (alc880_is_input_pin(nid)) { | |
f12ab1e0 TI |
3221 | snd_hda_codec_write(codec, nid, 0, |
3222 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
3223 | i <= AUTO_PIN_FRONT_MIC ? | |
3224 | PIN_VREF80 : PIN_IN); | |
e9edcee0 | 3225 | if (nid != ALC880_PIN_CD_NID) |
f12ab1e0 TI |
3226 | snd_hda_codec_write(codec, nid, 0, |
3227 | AC_VERB_SET_AMP_GAIN_MUTE, | |
e9edcee0 TI |
3228 | AMP_OUT_MUTE); |
3229 | } | |
3230 | } | |
3231 | } | |
3232 | ||
3233 | /* parse the BIOS configuration and set up the alc_spec */ | |
f12ab1e0 TI |
3234 | /* return 1 if successful, 0 if the proper config is not found, |
3235 | * or a negative error code | |
3236 | */ | |
e9edcee0 TI |
3237 | static int alc880_parse_auto_config(struct hda_codec *codec) |
3238 | { | |
3239 | struct alc_spec *spec = codec->spec; | |
3240 | int err; | |
df694daa | 3241 | static hda_nid_t alc880_ignore[] = { 0x1d, 0 }; |
e9edcee0 | 3242 | |
f12ab1e0 TI |
3243 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
3244 | alc880_ignore); | |
3245 | if (err < 0) | |
e9edcee0 | 3246 | return err; |
f12ab1e0 | 3247 | if (!spec->autocfg.line_outs) |
e9edcee0 | 3248 | return 0; /* can't find valid BIOS pin config */ |
df694daa | 3249 | |
f12ab1e0 TI |
3250 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
3251 | if (err < 0) | |
3252 | return err; | |
3253 | err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
3254 | if (err < 0) | |
3255 | return err; | |
3256 | err = alc880_auto_create_extra_out(spec, | |
3257 | spec->autocfg.speaker_pins[0], | |
3258 | "Speaker"); | |
3259 | if (err < 0) | |
3260 | return err; | |
3261 | err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], | |
3262 | "Headphone"); | |
3263 | if (err < 0) | |
3264 | return err; | |
3265 | err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
3266 | if (err < 0) | |
e9edcee0 TI |
3267 | return err; |
3268 | ||
3269 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
3270 | ||
3271 | if (spec->autocfg.dig_out_pin) | |
3272 | spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; | |
3273 | if (spec->autocfg.dig_in_pin) | |
3274 | spec->dig_in_nid = ALC880_DIGIN_NID; | |
3275 | ||
3276 | if (spec->kctl_alloc) | |
3277 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
3278 | ||
3279 | spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs; | |
3280 | ||
a1e8d2da | 3281 | spec->num_mux_defs = 1; |
e9edcee0 TI |
3282 | spec->input_mux = &spec->private_imux; |
3283 | ||
3284 | return 1; | |
3285 | } | |
3286 | ||
ae6b813a TI |
3287 | /* additional initialization for auto-configuration model */ |
3288 | static void alc880_auto_init(struct hda_codec *codec) | |
e9edcee0 | 3289 | { |
e9edcee0 | 3290 | alc880_auto_init_multi_out(codec); |
8d88bc3d | 3291 | alc880_auto_init_extra_out(codec); |
e9edcee0 | 3292 | alc880_auto_init_analog_input(codec); |
e9edcee0 TI |
3293 | } |
3294 | ||
3295 | /* | |
3296 | * OK, here we have finally the patch for ALC880 | |
3297 | */ | |
3298 | ||
1da177e4 LT |
3299 | static int patch_alc880(struct hda_codec *codec) |
3300 | { | |
3301 | struct alc_spec *spec; | |
3302 | int board_config; | |
df694daa | 3303 | int err; |
1da177e4 | 3304 | |
e560d8d8 | 3305 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
1da177e4 LT |
3306 | if (spec == NULL) |
3307 | return -ENOMEM; | |
3308 | ||
3309 | codec->spec = spec; | |
3310 | ||
f5fcc13c TI |
3311 | board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST, |
3312 | alc880_models, | |
3313 | alc880_cfg_tbl); | |
3314 | if (board_config < 0) { | |
9c7f852e TI |
3315 | printk(KERN_INFO "hda_codec: Unknown model for ALC880, " |
3316 | "trying auto-probe from BIOS...\n"); | |
e9edcee0 | 3317 | board_config = ALC880_AUTO; |
1da177e4 | 3318 | } |
1da177e4 | 3319 | |
e9edcee0 TI |
3320 | if (board_config == ALC880_AUTO) { |
3321 | /* automatic parse from the BIOS config */ | |
3322 | err = alc880_parse_auto_config(codec); | |
3323 | if (err < 0) { | |
3324 | alc_free(codec); | |
3325 | return err; | |
f12ab1e0 | 3326 | } else if (!err) { |
9c7f852e TI |
3327 | printk(KERN_INFO |
3328 | "hda_codec: Cannot set up configuration " | |
3329 | "from BIOS. Using 3-stack mode...\n"); | |
e9edcee0 TI |
3330 | board_config = ALC880_3ST; |
3331 | } | |
1da177e4 LT |
3332 | } |
3333 | ||
df694daa KY |
3334 | if (board_config != ALC880_AUTO) |
3335 | setup_preset(spec, &alc880_presets[board_config]); | |
1da177e4 LT |
3336 | |
3337 | spec->stream_name_analog = "ALC880 Analog"; | |
3338 | spec->stream_analog_playback = &alc880_pcm_analog_playback; | |
3339 | spec->stream_analog_capture = &alc880_pcm_analog_capture; | |
3340 | ||
3341 | spec->stream_name_digital = "ALC880 Digital"; | |
3342 | spec->stream_digital_playback = &alc880_pcm_digital_playback; | |
3343 | spec->stream_digital_capture = &alc880_pcm_digital_capture; | |
3344 | ||
f12ab1e0 | 3345 | if (!spec->adc_nids && spec->input_mux) { |
e9edcee0 | 3346 | /* check whether NID 0x07 is valid */ |
54d17403 | 3347 | unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); |
f12ab1e0 TI |
3348 | /* get type */ |
3349 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
e9edcee0 TI |
3350 | if (wcap != AC_WID_AUD_IN) { |
3351 | spec->adc_nids = alc880_adc_nids_alt; | |
3352 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); | |
f12ab1e0 TI |
3353 | spec->mixers[spec->num_mixers] = |
3354 | alc880_capture_alt_mixer; | |
e9edcee0 TI |
3355 | spec->num_mixers++; |
3356 | } else { | |
3357 | spec->adc_nids = alc880_adc_nids; | |
3358 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids); | |
3359 | spec->mixers[spec->num_mixers] = alc880_capture_mixer; | |
3360 | spec->num_mixers++; | |
3361 | } | |
3362 | } | |
1da177e4 LT |
3363 | |
3364 | codec->patch_ops = alc_patch_ops; | |
e9edcee0 | 3365 | if (board_config == ALC880_AUTO) |
ae6b813a | 3366 | spec->init_hook = alc880_auto_init; |
1da177e4 LT |
3367 | |
3368 | return 0; | |
3369 | } | |
3370 | ||
e9edcee0 | 3371 | |
1da177e4 LT |
3372 | /* |
3373 | * ALC260 support | |
3374 | */ | |
3375 | ||
e9edcee0 TI |
3376 | static hda_nid_t alc260_dac_nids[1] = { |
3377 | /* front */ | |
3378 | 0x02, | |
3379 | }; | |
3380 | ||
3381 | static hda_nid_t alc260_adc_nids[1] = { | |
3382 | /* ADC0 */ | |
3383 | 0x04, | |
3384 | }; | |
3385 | ||
df694daa | 3386 | static hda_nid_t alc260_adc_nids_alt[1] = { |
e9edcee0 TI |
3387 | /* ADC1 */ |
3388 | 0x05, | |
3389 | }; | |
3390 | ||
df694daa KY |
3391 | static hda_nid_t alc260_hp_adc_nids[2] = { |
3392 | /* ADC1, 0 */ | |
3393 | 0x05, 0x04 | |
3394 | }; | |
3395 | ||
d57fdac0 JW |
3396 | /* NIDs used when simultaneous access to both ADCs makes sense. Note that |
3397 | * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC. | |
3398 | */ | |
3399 | static hda_nid_t alc260_dual_adc_nids[2] = { | |
4c5186ed JW |
3400 | /* ADC0, ADC1 */ |
3401 | 0x04, 0x05 | |
3402 | }; | |
3403 | ||
e9edcee0 TI |
3404 | #define ALC260_DIGOUT_NID 0x03 |
3405 | #define ALC260_DIGIN_NID 0x06 | |
3406 | ||
3407 | static struct hda_input_mux alc260_capture_source = { | |
3408 | .num_items = 4, | |
3409 | .items = { | |
3410 | { "Mic", 0x0 }, | |
3411 | { "Front Mic", 0x1 }, | |
3412 | { "Line", 0x2 }, | |
3413 | { "CD", 0x4 }, | |
3414 | }, | |
3415 | }; | |
3416 | ||
17e7aec6 | 3417 | /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack, |
a1e8d2da JW |
3418 | * headphone jack and the internal CD lines since these are the only pins at |
3419 | * which audio can appear. For flexibility, also allow the option of | |
3420 | * recording the mixer output on the second ADC (ADC0 doesn't have a | |
3421 | * connection to the mixer output). | |
a9430dd8 | 3422 | */ |
a1e8d2da JW |
3423 | static struct hda_input_mux alc260_fujitsu_capture_sources[2] = { |
3424 | { | |
3425 | .num_items = 3, | |
3426 | .items = { | |
3427 | { "Mic/Line", 0x0 }, | |
3428 | { "CD", 0x4 }, | |
3429 | { "Headphone", 0x2 }, | |
3430 | }, | |
a9430dd8 | 3431 | }, |
a1e8d2da JW |
3432 | { |
3433 | .num_items = 4, | |
3434 | .items = { | |
3435 | { "Mic/Line", 0x0 }, | |
3436 | { "CD", 0x4 }, | |
3437 | { "Headphone", 0x2 }, | |
3438 | { "Mixer", 0x5 }, | |
3439 | }, | |
3440 | }, | |
3441 | ||
a9430dd8 JW |
3442 | }; |
3443 | ||
a1e8d2da JW |
3444 | /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to |
3445 | * the Fujitsu S702x, but jacks are marked differently. | |
0bfc90e9 | 3446 | */ |
a1e8d2da JW |
3447 | static struct hda_input_mux alc260_acer_capture_sources[2] = { |
3448 | { | |
3449 | .num_items = 4, | |
3450 | .items = { | |
3451 | { "Mic", 0x0 }, | |
3452 | { "Line", 0x2 }, | |
3453 | { "CD", 0x4 }, | |
3454 | { "Headphone", 0x5 }, | |
3455 | }, | |
3456 | }, | |
3457 | { | |
3458 | .num_items = 5, | |
3459 | .items = { | |
3460 | { "Mic", 0x0 }, | |
3461 | { "Line", 0x2 }, | |
3462 | { "CD", 0x4 }, | |
3463 | { "Headphone", 0x6 }, | |
3464 | { "Mixer", 0x5 }, | |
3465 | }, | |
0bfc90e9 JW |
3466 | }, |
3467 | }; | |
1da177e4 LT |
3468 | /* |
3469 | * This is just place-holder, so there's something for alc_build_pcms to look | |
3470 | * at when it calculates the maximum number of channels. ALC260 has no mixer | |
3471 | * element which allows changing the channel mode, so the verb list is | |
3472 | * never used. | |
3473 | */ | |
d2a6d7dc | 3474 | static struct hda_channel_mode alc260_modes[1] = { |
1da177e4 LT |
3475 | { 2, NULL }, |
3476 | }; | |
3477 | ||
df694daa KY |
3478 | |
3479 | /* Mixer combinations | |
3480 | * | |
3481 | * basic: base_output + input + pc_beep + capture | |
3482 | * HP: base_output + input + capture_alt | |
3483 | * HP_3013: hp_3013 + input + capture | |
3484 | * fujitsu: fujitsu + capture | |
0bfc90e9 | 3485 | * acer: acer + capture |
df694daa KY |
3486 | */ |
3487 | ||
3488 | static struct snd_kcontrol_new alc260_base_output_mixer[] = { | |
05acb863 | 3489 | HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
985be54b | 3490 | HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), |
05acb863 | 3491 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
985be54b | 3492 | HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), |
05acb863 | 3493 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
985be54b | 3494 | HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), |
1da177e4 | 3495 | { } /* end */ |
f12ab1e0 | 3496 | }; |
1da177e4 | 3497 | |
df694daa | 3498 | static struct snd_kcontrol_new alc260_input_mixer[] = { |
16ded525 TI |
3499 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
3500 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
3501 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
3502 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
3503 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
3504 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
3505 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT), | |
3506 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT), | |
df694daa KY |
3507 | { } /* end */ |
3508 | }; | |
3509 | ||
3510 | static struct snd_kcontrol_new alc260_pc_beep_mixer[] = { | |
3511 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT), | |
3512 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT), | |
3513 | { } /* end */ | |
3514 | }; | |
3515 | ||
3516 | static struct snd_kcontrol_new alc260_hp_3013_mixer[] = { | |
3517 | HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT), | |
3518 | HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT), | |
3519 | HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT), | |
3520 | HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT), | |
3521 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
3522 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
3523 | HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), | |
3524 | HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT), | |
16ded525 TI |
3525 | { } /* end */ |
3526 | }; | |
3527 | ||
a1e8d2da JW |
3528 | /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12, |
3529 | * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10. | |
3530 | */ | |
c8b6bf9b | 3531 | static struct snd_kcontrol_new alc260_fujitsu_mixer[] = { |
a9430dd8 | 3532 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
985be54b | 3533 | HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT), |
4c5186ed | 3534 | ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT), |
a9430dd8 JW |
3535 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
3536 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
3537 | HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT), | |
3538 | HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4c5186ed | 3539 | ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN), |
a9430dd8 JW |
3540 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), |
3541 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
3542 | HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT), | |
985be54b | 3543 | HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT), |
df694daa KY |
3544 | { } /* end */ |
3545 | }; | |
3546 | ||
a1e8d2da JW |
3547 | /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current |
3548 | * versions of the ALC260 don't act on requests to enable mic bias from NID | |
3549 | * 0x0f (used to drive the headphone jack in these laptops). The ALC260 | |
3550 | * datasheet doesn't mention this restriction. At this stage it's not clear | |
3551 | * whether this behaviour is intentional or is a hardware bug in chip | |
3552 | * revisions available in early 2006. Therefore for now allow the | |
3553 | * "Headphone Jack Mode" control to span all choices, but if it turns out | |
3554 | * that the lack of mic bias for this NID is intentional we could change the | |
3555 | * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
3556 | * | |
3557 | * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006 | |
3558 | * don't appear to make the mic bias available from the "line" jack, even | |
3559 | * though the NID used for this jack (0x14) can supply it. The theory is | |
3560 | * that perhaps Acer have included blocking capacitors between the ALC260 | |
3561 | * and the output jack. If this turns out to be the case for all such | |
3562 | * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT | |
3563 | * to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
bd869485 JW |
3564 | * |
3565 | * The C20x Tablet series have a mono internal speaker which is controlled | |
3566 | * via the chip's Mono sum widget and pin complex, so include the necessary | |
3567 | * controls for such models. On models without a "mono speaker" the control | |
3568 | * won't do anything. | |
a1e8d2da | 3569 | */ |
0bfc90e9 JW |
3570 | static struct snd_kcontrol_new alc260_acer_mixer[] = { |
3571 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
3572 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT), | |
a1e8d2da | 3573 | ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT), |
bd869485 JW |
3574 | HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0, |
3575 | HDA_OUTPUT), | |
3576 | HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2, | |
3577 | HDA_INPUT), | |
0bfc90e9 JW |
3578 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
3579 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
3580 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
3581 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
3582 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
3583 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
3584 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
3585 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
3586 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), | |
3587 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
3588 | { } /* end */ | |
3589 | }; | |
3590 | ||
bc9f98a9 KY |
3591 | /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12, |
3592 | * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17. | |
3593 | */ | |
3594 | static struct snd_kcontrol_new alc260_will_mixer[] = { | |
3595 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
3596 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT), | |
3597 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
3598 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
3599 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
3600 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
3601 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
3602 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
3603 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), | |
3604 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
3605 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), | |
3606 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
3607 | { } /* end */ | |
3608 | }; | |
3609 | ||
3610 | /* Replacer 672V ALC260 pin usage: Mic jack = 0x12, | |
3611 | * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f. | |
3612 | */ | |
3613 | static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = { | |
3614 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
3615 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT), | |
3616 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
3617 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
3618 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
3619 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT), | |
3620 | HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT), | |
3621 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
3622 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
3623 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
3624 | { } /* end */ | |
3625 | }; | |
3626 | ||
df694daa KY |
3627 | /* capture mixer elements */ |
3628 | static struct snd_kcontrol_new alc260_capture_mixer[] = { | |
a9430dd8 JW |
3629 | HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT), |
3630 | HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT), | |
df694daa KY |
3631 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT), |
3632 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT), | |
a9430dd8 JW |
3633 | { |
3634 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
df694daa KY |
3635 | /* The multiple "Capture Source" controls confuse alsamixer |
3636 | * So call somewhat different.. | |
3637 | * FIXME: the controls appear in the "playback" view! | |
3638 | */ | |
3639 | /* .name = "Capture Source", */ | |
3640 | .name = "Input Source", | |
3641 | .count = 2, | |
3642 | .info = alc_mux_enum_info, | |
3643 | .get = alc_mux_enum_get, | |
3644 | .put = alc_mux_enum_put, | |
3645 | }, | |
3646 | { } /* end */ | |
3647 | }; | |
3648 | ||
3649 | static struct snd_kcontrol_new alc260_capture_alt_mixer[] = { | |
3650 | HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT), | |
3651 | HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT), | |
3652 | { | |
3653 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
3654 | /* The multiple "Capture Source" controls confuse alsamixer | |
3655 | * So call somewhat different.. | |
3656 | * FIXME: the controls appear in the "playback" view! | |
3657 | */ | |
3658 | /* .name = "Capture Source", */ | |
3659 | .name = "Input Source", | |
3660 | .count = 1, | |
a9430dd8 JW |
3661 | .info = alc_mux_enum_info, |
3662 | .get = alc_mux_enum_get, | |
3663 | .put = alc_mux_enum_put, | |
3664 | }, | |
3665 | { } /* end */ | |
3666 | }; | |
3667 | ||
df694daa KY |
3668 | /* |
3669 | * initialization verbs | |
3670 | */ | |
1da177e4 LT |
3671 | static struct hda_verb alc260_init_verbs[] = { |
3672 | /* Line In pin widget for input */ | |
05acb863 | 3673 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 3674 | /* CD pin widget for input */ |
05acb863 | 3675 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 3676 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
16ded525 | 3677 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1da177e4 | 3678 | /* Mic2 (front panel) pin widget for input and vref at 80% */ |
16ded525 | 3679 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1da177e4 | 3680 | /* LINE-2 is used for line-out in rear */ |
05acb863 | 3681 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1da177e4 | 3682 | /* select line-out */ |
fd56f2db | 3683 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00}, |
1da177e4 | 3684 | /* LINE-OUT pin */ |
05acb863 | 3685 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1da177e4 | 3686 | /* enable HP */ |
05acb863 | 3687 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
1da177e4 | 3688 | /* enable Mono */ |
05acb863 TI |
3689 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
3690 | /* mute capture amp left and right */ | |
16ded525 | 3691 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1da177e4 LT |
3692 | /* set connection select to line in (default select for this ADC) */ |
3693 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
16ded525 TI |
3694 | /* mute capture amp left and right */ |
3695 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
3696 | /* set connection select to line in (default select for this ADC) */ | |
3697 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
05acb863 TI |
3698 | /* set vol=0 Line-Out mixer amp left and right */ |
3699 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3700 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
3701 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3702 | /* set vol=0 HP mixer amp left and right */ | |
3703 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3704 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
3705 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3706 | /* set vol=0 Mono mixer amp left and right */ | |
3707 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3708 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
3709 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3710 | /* unmute LINE-2 out pin */ | |
3711 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
f12ab1e0 TI |
3712 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
3713 | * Line In 2 = 0x03 | |
3714 | */ | |
05acb863 | 3715 | /* mute CD */ |
16ded525 | 3716 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
05acb863 | 3717 | /* mute Line In */ |
16ded525 | 3718 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
05acb863 | 3719 | /* mute Mic */ |
16ded525 | 3720 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1da177e4 | 3721 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
05acb863 TI |
3722 | /* mute Front out path */ |
3723 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3724 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3725 | /* mute Headphone out path */ | |
3726 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3727 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3728 | /* mute Mono out path */ | |
3729 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3730 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 LT |
3731 | { } |
3732 | }; | |
3733 | ||
474167d6 | 3734 | #if 0 /* should be identical with alc260_init_verbs? */ |
df694daa KY |
3735 | static struct hda_verb alc260_hp_init_verbs[] = { |
3736 | /* Headphone and output */ | |
3737 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
3738 | /* mono output */ | |
3739 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
3740 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
3741 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
3742 | /* Mic2 (front panel) pin widget for input and vref at 80% */ | |
3743 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
3744 | /* Line In pin widget for input */ | |
3745 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
3746 | /* Line-2 pin widget for output */ | |
3747 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
3748 | /* CD pin widget for input */ | |
3749 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
3750 | /* unmute amp left and right */ | |
3751 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | |
3752 | /* set connection select to line in (default select for this ADC) */ | |
3753 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
3754 | /* unmute Line-Out mixer amp left and right (volume = 0) */ | |
3755 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
3756 | /* mute pin widget amp left and right (no gain on this amp) */ | |
3757 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
3758 | /* unmute HP mixer amp left and right (volume = 0) */ | |
3759 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
3760 | /* mute pin widget amp left and right (no gain on this amp) */ | |
3761 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
f12ab1e0 TI |
3762 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
3763 | * Line In 2 = 0x03 | |
3764 | */ | |
df694daa KY |
3765 | /* unmute CD */ |
3766 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
3767 | /* unmute Line In */ | |
3768 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
3769 | /* unmute Mic */ | |
3770 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3771 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ | |
3772 | /* Unmute Front out path */ | |
3773 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3774 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
3775 | /* Unmute Headphone out path */ | |
3776 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3777 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
3778 | /* Unmute Mono out path */ | |
3779 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3780 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
3781 | { } | |
3782 | }; | |
474167d6 | 3783 | #endif |
df694daa KY |
3784 | |
3785 | static struct hda_verb alc260_hp_3013_init_verbs[] = { | |
3786 | /* Line out and output */ | |
3787 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
3788 | /* mono output */ | |
3789 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
3790 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
3791 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
3792 | /* Mic2 (front panel) pin widget for input and vref at 80% */ | |
3793 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
3794 | /* Line In pin widget for input */ | |
3795 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
3796 | /* Headphone pin widget for output */ | |
3797 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
3798 | /* CD pin widget for input */ | |
3799 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
3800 | /* unmute amp left and right */ | |
3801 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | |
3802 | /* set connection select to line in (default select for this ADC) */ | |
3803 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
3804 | /* unmute Line-Out mixer amp left and right (volume = 0) */ | |
3805 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
3806 | /* mute pin widget amp left and right (no gain on this amp) */ | |
3807 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
3808 | /* unmute HP mixer amp left and right (volume = 0) */ | |
3809 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
3810 | /* mute pin widget amp left and right (no gain on this amp) */ | |
3811 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
f12ab1e0 TI |
3812 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
3813 | * Line In 2 = 0x03 | |
3814 | */ | |
df694daa KY |
3815 | /* unmute CD */ |
3816 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
3817 | /* unmute Line In */ | |
3818 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
3819 | /* unmute Mic */ | |
3820 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3821 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ | |
3822 | /* Unmute Front out path */ | |
3823 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3824 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
3825 | /* Unmute Headphone out path */ | |
3826 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3827 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
3828 | /* Unmute Mono out path */ | |
3829 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3830 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
3831 | { } | |
3832 | }; | |
3833 | ||
a9430dd8 | 3834 | /* Initialisation sequence for ALC260 as configured in Fujitsu S702x |
a1e8d2da JW |
3835 | * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD |
3836 | * audio = 0x16, internal speaker = 0x10. | |
a9430dd8 JW |
3837 | */ |
3838 | static struct hda_verb alc260_fujitsu_init_verbs[] = { | |
3839 | /* Disable all GPIOs */ | |
3840 | {0x01, AC_VERB_SET_GPIO_MASK, 0}, | |
3841 | /* Internal speaker is connected to headphone pin */ | |
3842 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
3843 | /* Headphone/Line-out jack connects to Line1 pin; make it an output */ | |
3844 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
f7ace40d JW |
3845 | /* Mic/Line-in jack is connected to mic1 pin, so make it an input */ |
3846 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
3847 | /* Ensure all other unused pins are disabled and muted. */ | |
3848 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
3849 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
a9430dd8 | 3850 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
f7ace40d | 3851 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
a9430dd8 | 3852 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
f7ace40d JW |
3853 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
3854 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
3855 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3856 | ||
3857 | /* Disable digital (SPDIF) pins */ | |
3858 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
3859 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
a9430dd8 | 3860 | |
f7ace40d JW |
3861 | /* Ensure Line1 pin widget takes its input from the OUT1 sum bus |
3862 | * when acting as an output. | |
3863 | */ | |
3864 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
4c5186ed | 3865 | |
f7ace40d | 3866 | /* Start with output sum widgets muted and their output gains at min */ |
8b33a5aa TI |
3867 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
3868 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3869 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3870 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3871 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3872 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3873 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3874 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3875 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
a9430dd8 | 3876 | |
f7ace40d JW |
3877 | /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */ |
3878 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3879 | /* Unmute Line1 pin widget output buffer since it starts as an output. | |
3880 | * If the pin mode is changed by the user the pin mode control will | |
3881 | * take care of enabling the pin's input/output buffers as needed. | |
3882 | * Therefore there's no need to enable the input buffer at this | |
3883 | * stage. | |
cdcd9268 | 3884 | */ |
f7ace40d | 3885 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
cdcd9268 JW |
3886 | /* Unmute input buffer of pin widget used for Line-in (no equiv |
3887 | * mixer ctrl) | |
3888 | */ | |
f7ace40d JW |
3889 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
3890 | ||
3891 | /* Mute capture amp left and right */ | |
3892 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3893 | /* Set ADC connection select to match default mixer setting - line | |
3894 | * in (on mic1 pin) | |
3895 | */ | |
3896 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
3897 | ||
3898 | /* Do the same for the second ADC: mute capture input amp and | |
3899 | * set ADC connection to line in (on mic1 pin) | |
3900 | */ | |
3901 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3902 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
3903 | ||
3904 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
3905 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
3906 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
3907 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
3908 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
3909 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
3910 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
3911 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
3912 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
4a471b7d TI |
3913 | |
3914 | { } | |
a9430dd8 JW |
3915 | }; |
3916 | ||
0bfc90e9 JW |
3917 | /* Initialisation sequence for ALC260 as configured in Acer TravelMate and |
3918 | * similar laptops (adapted from Fujitsu init verbs). | |
3919 | */ | |
3920 | static struct hda_verb alc260_acer_init_verbs[] = { | |
3921 | /* On TravelMate laptops, GPIO 0 enables the internal speaker and | |
3922 | * the headphone jack. Turn this on and rely on the standard mute | |
3923 | * methods whenever the user wants to turn these outputs off. | |
3924 | */ | |
3925 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
3926 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
3927 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, | |
3928 | /* Internal speaker/Headphone jack is connected to Line-out pin */ | |
3929 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
3930 | /* Internal microphone/Mic jack is connected to Mic1 pin */ | |
3931 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | |
3932 | /* Line In jack is connected to Line1 pin */ | |
3933 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
bd869485 JW |
3934 | /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */ |
3935 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
0bfc90e9 JW |
3936 | /* Ensure all other unused pins are disabled and muted. */ |
3937 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
3938 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
0bfc90e9 JW |
3939 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
3940 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3941 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
3942 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3943 | /* Disable digital (SPDIF) pins */ | |
3944 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
3945 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
3946 | ||
3947 | /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum | |
3948 | * bus when acting as outputs. | |
3949 | */ | |
3950 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, | |
3951 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
3952 | ||
3953 | /* Start with output sum widgets muted and their output gains at min */ | |
3954 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3955 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3956 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3957 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3958 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3959 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3960 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3961 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3962 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3963 | ||
f12ab1e0 TI |
3964 | /* Unmute Line-out pin widget amp left and right |
3965 | * (no equiv mixer ctrl) | |
3966 | */ | |
0bfc90e9 | 3967 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
bd869485 JW |
3968 | /* Unmute mono pin widget amp output (no equiv mixer ctrl) */ |
3969 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
0bfc90e9 JW |
3970 | /* Unmute Mic1 and Line1 pin widget input buffers since they start as |
3971 | * inputs. If the pin mode is changed by the user the pin mode control | |
3972 | * will take care of enabling the pin's input/output buffers as needed. | |
3973 | * Therefore there's no need to enable the input buffer at this | |
3974 | * stage. | |
3975 | */ | |
3976 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
3977 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
3978 | ||
3979 | /* Mute capture amp left and right */ | |
3980 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3981 | /* Set ADC connection select to match default mixer setting - mic | |
3982 | * (on mic1 pin) | |
3983 | */ | |
3984 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
3985 | ||
3986 | /* Do similar with the second ADC: mute capture input amp and | |
a1e8d2da | 3987 | * set ADC connection to mic to match ALSA's default state. |
0bfc90e9 JW |
3988 | */ |
3989 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
a1e8d2da | 3990 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, |
0bfc90e9 JW |
3991 | |
3992 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
3993 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
3994 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
3995 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
3996 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
3997 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
3998 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
3999 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
4000 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
4001 | ||
4002 | { } | |
4003 | }; | |
4004 | ||
bc9f98a9 KY |
4005 | static struct hda_verb alc260_will_verbs[] = { |
4006 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
4007 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4008 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4009 | {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, | |
4010 | {0x1a, AC_VERB_SET_COEF_INDEX, 0x07}, | |
4011 | {0x1a, AC_VERB_SET_PROC_COEF, 0x3040}, | |
4012 | {} | |
4013 | }; | |
4014 | ||
4015 | static struct hda_verb alc260_replacer_672v_verbs[] = { | |
4016 | {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, | |
4017 | {0x1a, AC_VERB_SET_COEF_INDEX, 0x07}, | |
4018 | {0x1a, AC_VERB_SET_PROC_COEF, 0x3050}, | |
4019 | ||
4020 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
4021 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
4022 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, | |
4023 | ||
4024 | {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
4025 | {} | |
4026 | }; | |
4027 | ||
4028 | /* toggle speaker-output according to the hp-jack state */ | |
4029 | static void alc260_replacer_672v_automute(struct hda_codec *codec) | |
4030 | { | |
4031 | unsigned int present; | |
4032 | ||
4033 | /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */ | |
4034 | present = snd_hda_codec_read(codec, 0x0f, 0, | |
4035 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
4036 | if (present) { | |
4037 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1); | |
4038 | snd_hda_codec_write(codec, 0x0f, 0, | |
4039 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP); | |
4040 | } else { | |
4041 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0); | |
4042 | snd_hda_codec_write(codec, 0x0f, 0, | |
4043 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | |
4044 | } | |
4045 | } | |
4046 | ||
4047 | static void alc260_replacer_672v_unsol_event(struct hda_codec *codec, | |
4048 | unsigned int res) | |
4049 | { | |
4050 | if ((res >> 26) == ALC880_HP_EVENT) | |
4051 | alc260_replacer_672v_automute(codec); | |
4052 | } | |
4053 | ||
7cf51e48 JW |
4054 | /* Test configuration for debugging, modelled after the ALC880 test |
4055 | * configuration. | |
4056 | */ | |
4057 | #ifdef CONFIG_SND_DEBUG | |
4058 | static hda_nid_t alc260_test_dac_nids[1] = { | |
4059 | 0x02, | |
4060 | }; | |
4061 | static hda_nid_t alc260_test_adc_nids[2] = { | |
4062 | 0x04, 0x05, | |
4063 | }; | |
a1e8d2da JW |
4064 | /* For testing the ALC260, each input MUX needs its own definition since |
4065 | * the signal assignments are different. This assumes that the first ADC | |
4066 | * is NID 0x04. | |
17e7aec6 | 4067 | */ |
a1e8d2da JW |
4068 | static struct hda_input_mux alc260_test_capture_sources[2] = { |
4069 | { | |
4070 | .num_items = 7, | |
4071 | .items = { | |
4072 | { "MIC1 pin", 0x0 }, | |
4073 | { "MIC2 pin", 0x1 }, | |
4074 | { "LINE1 pin", 0x2 }, | |
4075 | { "LINE2 pin", 0x3 }, | |
4076 | { "CD pin", 0x4 }, | |
4077 | { "LINE-OUT pin", 0x5 }, | |
4078 | { "HP-OUT pin", 0x6 }, | |
4079 | }, | |
4080 | }, | |
4081 | { | |
4082 | .num_items = 8, | |
4083 | .items = { | |
4084 | { "MIC1 pin", 0x0 }, | |
4085 | { "MIC2 pin", 0x1 }, | |
4086 | { "LINE1 pin", 0x2 }, | |
4087 | { "LINE2 pin", 0x3 }, | |
4088 | { "CD pin", 0x4 }, | |
4089 | { "Mixer", 0x5 }, | |
4090 | { "LINE-OUT pin", 0x6 }, | |
4091 | { "HP-OUT pin", 0x7 }, | |
4092 | }, | |
7cf51e48 JW |
4093 | }, |
4094 | }; | |
4095 | static struct snd_kcontrol_new alc260_test_mixer[] = { | |
4096 | /* Output driver widgets */ | |
4097 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), | |
4098 | HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), | |
4099 | HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT), | |
4100 | HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT), | |
4101 | HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4102 | HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT), | |
4103 | ||
a1e8d2da JW |
4104 | /* Modes for retasking pin widgets |
4105 | * Note: the ALC260 doesn't seem to act on requests to enable mic | |
4106 | * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't | |
4107 | * mention this restriction. At this stage it's not clear whether | |
4108 | * this behaviour is intentional or is a hardware bug in chip | |
4109 | * revisions available at least up until early 2006. Therefore for | |
4110 | * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all | |
4111 | * choices, but if it turns out that the lack of mic bias for these | |
4112 | * NIDs is intentional we could change their modes from | |
4113 | * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
4114 | */ | |
7cf51e48 JW |
4115 | ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT), |
4116 | ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT), | |
4117 | ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT), | |
4118 | ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT), | |
4119 | ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT), | |
4120 | ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT), | |
4121 | ||
4122 | /* Loopback mixer controls */ | |
4123 | HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT), | |
4124 | HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT), | |
4125 | HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT), | |
4126 | HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT), | |
4127 | HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4128 | HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4129 | HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT), | |
4130 | HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT), | |
4131 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), | |
4132 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
4133 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), | |
4134 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
4135 | HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT), | |
4136 | HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT), | |
4137 | HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT), | |
4138 | HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT), | |
5c8f858d JW |
4139 | |
4140 | /* Controls for GPIO pins, assuming they are configured as outputs */ | |
4141 | ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01), | |
4142 | ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02), | |
4143 | ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04), | |
4144 | ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08), | |
4145 | ||
92621f13 JW |
4146 | /* Switches to allow the digital IO pins to be enabled. The datasheet |
4147 | * is ambigious as to which NID is which; testing on laptops which | |
4148 | * make this output available should provide clarification. | |
4149 | */ | |
4150 | ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01), | |
4151 | ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01), | |
4152 | ||
7cf51e48 JW |
4153 | { } /* end */ |
4154 | }; | |
4155 | static struct hda_verb alc260_test_init_verbs[] = { | |
5c8f858d JW |
4156 | /* Enable all GPIOs as outputs with an initial value of 0 */ |
4157 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f}, | |
4158 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, | |
4159 | {0x01, AC_VERB_SET_GPIO_MASK, 0x0f}, | |
4160 | ||
7cf51e48 JW |
4161 | /* Enable retasking pins as output, initially without power amp */ |
4162 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4163 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4164 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4165 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4166 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4167 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4168 | ||
92621f13 JW |
4169 | /* Disable digital (SPDIF) pins initially, but users can enable |
4170 | * them via a mixer switch. In the case of SPDIF-out, this initverb | |
4171 | * payload also sets the generation to 0, output to be in "consumer" | |
4172 | * PCM format, copyright asserted, no pre-emphasis and no validity | |
4173 | * control. | |
4174 | */ | |
7cf51e48 JW |
4175 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, |
4176 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
4177 | ||
f7ace40d | 4178 | /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the |
7cf51e48 JW |
4179 | * OUT1 sum bus when acting as an output. |
4180 | */ | |
4181 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, | |
4182 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0}, | |
4183 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
4184 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0}, | |
4185 | ||
4186 | /* Start with output sum widgets muted and their output gains at min */ | |
4187 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4188 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4189 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4190 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4191 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4192 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4193 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4194 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4195 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4196 | ||
cdcd9268 JW |
4197 | /* Unmute retasking pin widget output buffers since the default |
4198 | * state appears to be output. As the pin mode is changed by the | |
4199 | * user the pin mode control will take care of enabling the pin's | |
4200 | * input/output buffers as needed. | |
4201 | */ | |
7cf51e48 JW |
4202 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
4203 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4204 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4205 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4206 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4207 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4208 | /* Also unmute the mono-out pin widget */ | |
4209 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4210 | ||
7cf51e48 JW |
4211 | /* Mute capture amp left and right */ |
4212 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
f7ace40d JW |
4213 | /* Set ADC connection select to match default mixer setting (mic1 |
4214 | * pin) | |
7cf51e48 JW |
4215 | */ |
4216 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4217 | ||
4218 | /* Do the same for the second ADC: mute capture input amp and | |
f7ace40d | 4219 | * set ADC connection to mic1 pin |
7cf51e48 JW |
4220 | */ |
4221 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4222 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4223 | ||
4224 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
4225 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
4226 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
4227 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
4228 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
4229 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
4230 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
4231 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
4232 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
4233 | ||
4234 | { } | |
4235 | }; | |
4236 | #endif | |
4237 | ||
1da177e4 LT |
4238 | static struct hda_pcm_stream alc260_pcm_analog_playback = { |
4239 | .substreams = 1, | |
4240 | .channels_min = 2, | |
4241 | .channels_max = 2, | |
1da177e4 LT |
4242 | }; |
4243 | ||
4244 | static struct hda_pcm_stream alc260_pcm_analog_capture = { | |
4245 | .substreams = 1, | |
4246 | .channels_min = 2, | |
4247 | .channels_max = 2, | |
1da177e4 LT |
4248 | }; |
4249 | ||
a3bcba38 TI |
4250 | #define alc260_pcm_digital_playback alc880_pcm_digital_playback |
4251 | #define alc260_pcm_digital_capture alc880_pcm_digital_capture | |
4252 | ||
df694daa KY |
4253 | /* |
4254 | * for BIOS auto-configuration | |
4255 | */ | |
16ded525 | 4256 | |
df694daa KY |
4257 | static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid, |
4258 | const char *pfx) | |
4259 | { | |
4260 | hda_nid_t nid_vol; | |
4261 | unsigned long vol_val, sw_val; | |
4262 | char name[32]; | |
4263 | int err; | |
4264 | ||
4265 | if (nid >= 0x0f && nid < 0x11) { | |
4266 | nid_vol = nid - 0x7; | |
4267 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); | |
4268 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); | |
4269 | } else if (nid == 0x11) { | |
4270 | nid_vol = nid - 0x7; | |
4271 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT); | |
4272 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT); | |
4273 | } else if (nid >= 0x12 && nid <= 0x15) { | |
4274 | nid_vol = 0x08; | |
4275 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); | |
4276 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); | |
4277 | } else | |
4278 | return 0; /* N/A */ | |
4279 | ||
4280 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); | |
f12ab1e0 TI |
4281 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val); |
4282 | if (err < 0) | |
df694daa KY |
4283 | return err; |
4284 | snprintf(name, sizeof(name), "%s Playback Switch", pfx); | |
f12ab1e0 TI |
4285 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val); |
4286 | if (err < 0) | |
df694daa KY |
4287 | return err; |
4288 | return 1; | |
4289 | } | |
4290 | ||
4291 | /* add playback controls from the parsed DAC table */ | |
4292 | static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec, | |
4293 | const struct auto_pin_cfg *cfg) | |
4294 | { | |
4295 | hda_nid_t nid; | |
4296 | int err; | |
4297 | ||
4298 | spec->multiout.num_dacs = 1; | |
4299 | spec->multiout.dac_nids = spec->private_dac_nids; | |
4300 | spec->multiout.dac_nids[0] = 0x02; | |
4301 | ||
4302 | nid = cfg->line_out_pins[0]; | |
4303 | if (nid) { | |
4304 | err = alc260_add_playback_controls(spec, nid, "Front"); | |
4305 | if (err < 0) | |
4306 | return err; | |
4307 | } | |
4308 | ||
82bc955f | 4309 | nid = cfg->speaker_pins[0]; |
df694daa KY |
4310 | if (nid) { |
4311 | err = alc260_add_playback_controls(spec, nid, "Speaker"); | |
4312 | if (err < 0) | |
4313 | return err; | |
4314 | } | |
4315 | ||
eb06ed8f | 4316 | nid = cfg->hp_pins[0]; |
df694daa KY |
4317 | if (nid) { |
4318 | err = alc260_add_playback_controls(spec, nid, "Headphone"); | |
4319 | if (err < 0) | |
4320 | return err; | |
4321 | } | |
f12ab1e0 | 4322 | return 0; |
df694daa KY |
4323 | } |
4324 | ||
4325 | /* create playback/capture controls for input pins */ | |
4326 | static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec, | |
4327 | const struct auto_pin_cfg *cfg) | |
4328 | { | |
df694daa KY |
4329 | struct hda_input_mux *imux = &spec->private_imux; |
4330 | int i, err, idx; | |
4331 | ||
4332 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
4333 | if (cfg->input_pins[i] >= 0x12) { | |
4334 | idx = cfg->input_pins[i] - 0x12; | |
4a471b7d | 4335 | err = new_analog_input(spec, cfg->input_pins[i], |
f12ab1e0 TI |
4336 | auto_pin_cfg_labels[i], idx, |
4337 | 0x07); | |
df694daa KY |
4338 | if (err < 0) |
4339 | return err; | |
f12ab1e0 TI |
4340 | imux->items[imux->num_items].label = |
4341 | auto_pin_cfg_labels[i]; | |
df694daa KY |
4342 | imux->items[imux->num_items].index = idx; |
4343 | imux->num_items++; | |
4344 | } | |
f12ab1e0 | 4345 | if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){ |
df694daa | 4346 | idx = cfg->input_pins[i] - 0x09; |
4a471b7d | 4347 | err = new_analog_input(spec, cfg->input_pins[i], |
f12ab1e0 TI |
4348 | auto_pin_cfg_labels[i], idx, |
4349 | 0x07); | |
df694daa KY |
4350 | if (err < 0) |
4351 | return err; | |
f12ab1e0 TI |
4352 | imux->items[imux->num_items].label = |
4353 | auto_pin_cfg_labels[i]; | |
df694daa KY |
4354 | imux->items[imux->num_items].index = idx; |
4355 | imux->num_items++; | |
4356 | } | |
4357 | } | |
4358 | return 0; | |
4359 | } | |
4360 | ||
4361 | static void alc260_auto_set_output_and_unmute(struct hda_codec *codec, | |
4362 | hda_nid_t nid, int pin_type, | |
4363 | int sel_idx) | |
4364 | { | |
4365 | /* set as output */ | |
f12ab1e0 TI |
4366 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
4367 | pin_type); | |
4368 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
4369 | AMP_OUT_UNMUTE); | |
df694daa KY |
4370 | /* need the manual connection? */ |
4371 | if (nid >= 0x12) { | |
4372 | int idx = nid - 0x12; | |
4373 | snd_hda_codec_write(codec, idx + 0x0b, 0, | |
4374 | AC_VERB_SET_CONNECT_SEL, sel_idx); | |
df694daa KY |
4375 | } |
4376 | } | |
4377 | ||
4378 | static void alc260_auto_init_multi_out(struct hda_codec *codec) | |
4379 | { | |
4380 | struct alc_spec *spec = codec->spec; | |
4381 | hda_nid_t nid; | |
4382 | ||
bc9f98a9 | 4383 | alc_subsystem_id(codec, 0x10, 0x15, 0x0f); |
f12ab1e0 | 4384 | nid = spec->autocfg.line_out_pins[0]; |
baba8ee9 TI |
4385 | if (nid) { |
4386 | int pin_type = get_pin_type(spec->autocfg.line_out_type); | |
4387 | alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0); | |
4388 | } | |
df694daa | 4389 | |
82bc955f | 4390 | nid = spec->autocfg.speaker_pins[0]; |
df694daa KY |
4391 | if (nid) |
4392 | alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); | |
4393 | ||
eb06ed8f | 4394 | nid = spec->autocfg.hp_pins[0]; |
df694daa | 4395 | if (nid) |
baba8ee9 | 4396 | alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0); |
f12ab1e0 | 4397 | } |
df694daa KY |
4398 | |
4399 | #define ALC260_PIN_CD_NID 0x16 | |
4400 | static void alc260_auto_init_analog_input(struct hda_codec *codec) | |
4401 | { | |
4402 | struct alc_spec *spec = codec->spec; | |
4403 | int i; | |
4404 | ||
4405 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
4406 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
4407 | if (nid >= 0x12) { | |
f12ab1e0 TI |
4408 | snd_hda_codec_write(codec, nid, 0, |
4409 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4410 | i <= AUTO_PIN_FRONT_MIC ? | |
4411 | PIN_VREF80 : PIN_IN); | |
df694daa | 4412 | if (nid != ALC260_PIN_CD_NID) |
f12ab1e0 TI |
4413 | snd_hda_codec_write(codec, nid, 0, |
4414 | AC_VERB_SET_AMP_GAIN_MUTE, | |
df694daa KY |
4415 | AMP_OUT_MUTE); |
4416 | } | |
4417 | } | |
4418 | } | |
4419 | ||
4420 | /* | |
4421 | * generic initialization of ADC, input mixers and output mixers | |
4422 | */ | |
4423 | static struct hda_verb alc260_volume_init_verbs[] = { | |
4424 | /* | |
4425 | * Unmute ADC0-1 and set the default input to mic-in | |
4426 | */ | |
4427 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4428 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4429 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4430 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4431 | ||
4432 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | |
4433 | * mixer widget | |
f12ab1e0 TI |
4434 | * Note: PASD motherboards uses the Line In 2 as the input for |
4435 | * front panel mic (mic 2) | |
df694daa KY |
4436 | */ |
4437 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
4438 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4439 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4440 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
4441 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
4442 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
4443 | ||
4444 | /* | |
4445 | * Set up output mixers (0x08 - 0x0a) | |
4446 | */ | |
4447 | /* set vol=0 to output mixers */ | |
4448 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4449 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4450 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4451 | /* set up input amps for analog loopback */ | |
4452 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
4453 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4454 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4455 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4456 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4457 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4458 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4459 | ||
4460 | { } | |
4461 | }; | |
4462 | ||
4463 | static int alc260_parse_auto_config(struct hda_codec *codec) | |
4464 | { | |
4465 | struct alc_spec *spec = codec->spec; | |
4466 | unsigned int wcap; | |
4467 | int err; | |
4468 | static hda_nid_t alc260_ignore[] = { 0x17, 0 }; | |
4469 | ||
f12ab1e0 TI |
4470 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
4471 | alc260_ignore); | |
4472 | if (err < 0) | |
df694daa | 4473 | return err; |
f12ab1e0 TI |
4474 | err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg); |
4475 | if (err < 0) | |
4a471b7d | 4476 | return err; |
f12ab1e0 | 4477 | if (!spec->kctl_alloc) |
df694daa | 4478 | return 0; /* can't find valid BIOS pin config */ |
f12ab1e0 TI |
4479 | err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg); |
4480 | if (err < 0) | |
df694daa KY |
4481 | return err; |
4482 | ||
4483 | spec->multiout.max_channels = 2; | |
4484 | ||
4485 | if (spec->autocfg.dig_out_pin) | |
4486 | spec->multiout.dig_out_nid = ALC260_DIGOUT_NID; | |
4487 | if (spec->kctl_alloc) | |
4488 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
4489 | ||
4490 | spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs; | |
4491 | ||
a1e8d2da | 4492 | spec->num_mux_defs = 1; |
df694daa KY |
4493 | spec->input_mux = &spec->private_imux; |
4494 | ||
4495 | /* check whether NID 0x04 is valid */ | |
4a471b7d | 4496 | wcap = get_wcaps(codec, 0x04); |
df694daa KY |
4497 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ |
4498 | if (wcap != AC_WID_AUD_IN) { | |
4499 | spec->adc_nids = alc260_adc_nids_alt; | |
4500 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt); | |
4501 | spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer; | |
df694daa KY |
4502 | } else { |
4503 | spec->adc_nids = alc260_adc_nids; | |
4504 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); | |
4505 | spec->mixers[spec->num_mixers] = alc260_capture_mixer; | |
df694daa | 4506 | } |
4a471b7d | 4507 | spec->num_mixers++; |
df694daa KY |
4508 | |
4509 | return 1; | |
4510 | } | |
4511 | ||
ae6b813a TI |
4512 | /* additional initialization for auto-configuration model */ |
4513 | static void alc260_auto_init(struct hda_codec *codec) | |
df694daa | 4514 | { |
df694daa KY |
4515 | alc260_auto_init_multi_out(codec); |
4516 | alc260_auto_init_analog_input(codec); | |
df694daa KY |
4517 | } |
4518 | ||
4519 | /* | |
4520 | * ALC260 configurations | |
4521 | */ | |
f5fcc13c TI |
4522 | static const char *alc260_models[ALC260_MODEL_LAST] = { |
4523 | [ALC260_BASIC] = "basic", | |
4524 | [ALC260_HP] = "hp", | |
4525 | [ALC260_HP_3013] = "hp-3013", | |
4526 | [ALC260_FUJITSU_S702X] = "fujitsu", | |
4527 | [ALC260_ACER] = "acer", | |
bc9f98a9 KY |
4528 | [ALC260_WILL] = "will", |
4529 | [ALC260_REPLACER_672V] = "replacer", | |
7cf51e48 | 4530 | #ifdef CONFIG_SND_DEBUG |
f5fcc13c | 4531 | [ALC260_TEST] = "test", |
7cf51e48 | 4532 | #endif |
f5fcc13c TI |
4533 | [ALC260_AUTO] = "auto", |
4534 | }; | |
4535 | ||
4536 | static struct snd_pci_quirk alc260_cfg_tbl[] = { | |
bd869485 | 4537 | SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER), |
f5fcc13c | 4538 | SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER), |
9720b718 | 4539 | SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013), |
a8a5d067 | 4540 | SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013), |
f5fcc13c TI |
4541 | SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013), |
4542 | SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP), | |
4543 | SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013), | |
4544 | SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013), | |
4545 | SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP), | |
4546 | SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP), | |
4547 | SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP), | |
4548 | SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC), | |
4549 | SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC), | |
4550 | SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC), | |
4551 | SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X), | |
4552 | SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC), | |
bc9f98a9 KY |
4553 | SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL), |
4554 | SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V), | |
df694daa KY |
4555 | {} |
4556 | }; | |
4557 | ||
4558 | static struct alc_config_preset alc260_presets[] = { | |
4559 | [ALC260_BASIC] = { | |
4560 | .mixers = { alc260_base_output_mixer, | |
4561 | alc260_input_mixer, | |
4562 | alc260_pc_beep_mixer, | |
4563 | alc260_capture_mixer }, | |
4564 | .init_verbs = { alc260_init_verbs }, | |
4565 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
4566 | .dac_nids = alc260_dac_nids, | |
4567 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), | |
4568 | .adc_nids = alc260_adc_nids, | |
4569 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
4570 | .channel_mode = alc260_modes, | |
4571 | .input_mux = &alc260_capture_source, | |
4572 | }, | |
4573 | [ALC260_HP] = { | |
4574 | .mixers = { alc260_base_output_mixer, | |
4575 | alc260_input_mixer, | |
4576 | alc260_capture_alt_mixer }, | |
474167d6 | 4577 | .init_verbs = { alc260_init_verbs }, |
df694daa KY |
4578 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), |
4579 | .dac_nids = alc260_dac_nids, | |
4580 | .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), | |
4581 | .adc_nids = alc260_hp_adc_nids, | |
4582 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
4583 | .channel_mode = alc260_modes, | |
4584 | .input_mux = &alc260_capture_source, | |
4585 | }, | |
4586 | [ALC260_HP_3013] = { | |
4587 | .mixers = { alc260_hp_3013_mixer, | |
4588 | alc260_input_mixer, | |
4589 | alc260_capture_alt_mixer }, | |
4590 | .init_verbs = { alc260_hp_3013_init_verbs }, | |
4591 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
4592 | .dac_nids = alc260_dac_nids, | |
4593 | .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), | |
4594 | .adc_nids = alc260_hp_adc_nids, | |
4595 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
4596 | .channel_mode = alc260_modes, | |
4597 | .input_mux = &alc260_capture_source, | |
4598 | }, | |
4599 | [ALC260_FUJITSU_S702X] = { | |
4600 | .mixers = { alc260_fujitsu_mixer, | |
4601 | alc260_capture_mixer }, | |
4602 | .init_verbs = { alc260_fujitsu_init_verbs }, | |
4603 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
4604 | .dac_nids = alc260_dac_nids, | |
d57fdac0 JW |
4605 | .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), |
4606 | .adc_nids = alc260_dual_adc_nids, | |
df694daa KY |
4607 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
4608 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
4609 | .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources), |
4610 | .input_mux = alc260_fujitsu_capture_sources, | |
df694daa | 4611 | }, |
0bfc90e9 JW |
4612 | [ALC260_ACER] = { |
4613 | .mixers = { alc260_acer_mixer, | |
4614 | alc260_capture_mixer }, | |
4615 | .init_verbs = { alc260_acer_init_verbs }, | |
4616 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
4617 | .dac_nids = alc260_dac_nids, | |
4618 | .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), | |
4619 | .adc_nids = alc260_dual_adc_nids, | |
4620 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
4621 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
4622 | .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources), |
4623 | .input_mux = alc260_acer_capture_sources, | |
0bfc90e9 | 4624 | }, |
bc9f98a9 KY |
4625 | [ALC260_WILL] = { |
4626 | .mixers = { alc260_will_mixer, | |
4627 | alc260_capture_mixer }, | |
4628 | .init_verbs = { alc260_init_verbs, alc260_will_verbs }, | |
4629 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
4630 | .dac_nids = alc260_dac_nids, | |
4631 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), | |
4632 | .adc_nids = alc260_adc_nids, | |
4633 | .dig_out_nid = ALC260_DIGOUT_NID, | |
4634 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
4635 | .channel_mode = alc260_modes, | |
4636 | .input_mux = &alc260_capture_source, | |
4637 | }, | |
4638 | [ALC260_REPLACER_672V] = { | |
4639 | .mixers = { alc260_replacer_672v_mixer, | |
4640 | alc260_capture_mixer }, | |
4641 | .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs }, | |
4642 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
4643 | .dac_nids = alc260_dac_nids, | |
4644 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), | |
4645 | .adc_nids = alc260_adc_nids, | |
4646 | .dig_out_nid = ALC260_DIGOUT_NID, | |
4647 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
4648 | .channel_mode = alc260_modes, | |
4649 | .input_mux = &alc260_capture_source, | |
4650 | .unsol_event = alc260_replacer_672v_unsol_event, | |
4651 | .init_hook = alc260_replacer_672v_automute, | |
4652 | }, | |
7cf51e48 JW |
4653 | #ifdef CONFIG_SND_DEBUG |
4654 | [ALC260_TEST] = { | |
4655 | .mixers = { alc260_test_mixer, | |
4656 | alc260_capture_mixer }, | |
4657 | .init_verbs = { alc260_test_init_verbs }, | |
4658 | .num_dacs = ARRAY_SIZE(alc260_test_dac_nids), | |
4659 | .dac_nids = alc260_test_dac_nids, | |
4660 | .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids), | |
4661 | .adc_nids = alc260_test_adc_nids, | |
4662 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
4663 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
4664 | .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources), |
4665 | .input_mux = alc260_test_capture_sources, | |
7cf51e48 JW |
4666 | }, |
4667 | #endif | |
df694daa KY |
4668 | }; |
4669 | ||
4670 | static int patch_alc260(struct hda_codec *codec) | |
1da177e4 LT |
4671 | { |
4672 | struct alc_spec *spec; | |
df694daa | 4673 | int err, board_config; |
1da177e4 | 4674 | |
e560d8d8 | 4675 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
1da177e4 LT |
4676 | if (spec == NULL) |
4677 | return -ENOMEM; | |
4678 | ||
4679 | codec->spec = spec; | |
4680 | ||
f5fcc13c TI |
4681 | board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST, |
4682 | alc260_models, | |
4683 | alc260_cfg_tbl); | |
4684 | if (board_config < 0) { | |
9c7f852e TI |
4685 | snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, " |
4686 | "trying auto-probe from BIOS...\n"); | |
df694daa | 4687 | board_config = ALC260_AUTO; |
16ded525 | 4688 | } |
1da177e4 | 4689 | |
df694daa KY |
4690 | if (board_config == ALC260_AUTO) { |
4691 | /* automatic parse from the BIOS config */ | |
4692 | err = alc260_parse_auto_config(codec); | |
4693 | if (err < 0) { | |
4694 | alc_free(codec); | |
4695 | return err; | |
f12ab1e0 | 4696 | } else if (!err) { |
9c7f852e TI |
4697 | printk(KERN_INFO |
4698 | "hda_codec: Cannot set up configuration " | |
4699 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
4700 | board_config = ALC260_BASIC; |
4701 | } | |
a9430dd8 | 4702 | } |
e9edcee0 | 4703 | |
df694daa KY |
4704 | if (board_config != ALC260_AUTO) |
4705 | setup_preset(spec, &alc260_presets[board_config]); | |
1da177e4 LT |
4706 | |
4707 | spec->stream_name_analog = "ALC260 Analog"; | |
4708 | spec->stream_analog_playback = &alc260_pcm_analog_playback; | |
4709 | spec->stream_analog_capture = &alc260_pcm_analog_capture; | |
4710 | ||
a3bcba38 TI |
4711 | spec->stream_name_digital = "ALC260 Digital"; |
4712 | spec->stream_digital_playback = &alc260_pcm_digital_playback; | |
4713 | spec->stream_digital_capture = &alc260_pcm_digital_capture; | |
4714 | ||
1da177e4 | 4715 | codec->patch_ops = alc_patch_ops; |
df694daa | 4716 | if (board_config == ALC260_AUTO) |
ae6b813a | 4717 | spec->init_hook = alc260_auto_init; |
1da177e4 LT |
4718 | |
4719 | return 0; | |
4720 | } | |
4721 | ||
e9edcee0 | 4722 | |
1da177e4 LT |
4723 | /* |
4724 | * ALC882 support | |
4725 | * | |
4726 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible | |
4727 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
4728 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
4729 | * 6-channel independent captures. | |
4730 | * | |
4731 | * In addition, an independent DAC for the multi-playback (not used in this | |
4732 | * driver yet). | |
4733 | */ | |
df694daa KY |
4734 | #define ALC882_DIGOUT_NID 0x06 |
4735 | #define ALC882_DIGIN_NID 0x0a | |
1da177e4 | 4736 | |
d2a6d7dc | 4737 | static struct hda_channel_mode alc882_ch_modes[1] = { |
1da177e4 LT |
4738 | { 8, NULL } |
4739 | }; | |
4740 | ||
4741 | static hda_nid_t alc882_dac_nids[4] = { | |
4742 | /* front, rear, clfe, rear_surr */ | |
4743 | 0x02, 0x03, 0x04, 0x05 | |
4744 | }; | |
4745 | ||
df694daa KY |
4746 | /* identical with ALC880 */ |
4747 | #define alc882_adc_nids alc880_adc_nids | |
4748 | #define alc882_adc_nids_alt alc880_adc_nids_alt | |
1da177e4 LT |
4749 | |
4750 | /* input MUX */ | |
4751 | /* FIXME: should be a matrix-type input source selection */ | |
4752 | ||
4753 | static struct hda_input_mux alc882_capture_source = { | |
4754 | .num_items = 4, | |
4755 | .items = { | |
4756 | { "Mic", 0x0 }, | |
4757 | { "Front Mic", 0x1 }, | |
4758 | { "Line", 0x2 }, | |
4759 | { "CD", 0x4 }, | |
4760 | }, | |
4761 | }; | |
1da177e4 LT |
4762 | #define alc882_mux_enum_info alc_mux_enum_info |
4763 | #define alc882_mux_enum_get alc_mux_enum_get | |
4764 | ||
f12ab1e0 TI |
4765 | static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, |
4766 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
4767 | { |
4768 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
4769 | struct alc_spec *spec = codec->spec; | |
4770 | const struct hda_input_mux *imux = spec->input_mux; | |
4771 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
4772 | static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 }; | |
4773 | hda_nid_t nid = capture_mixers[adc_idx]; | |
4774 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; | |
4775 | unsigned int i, idx; | |
4776 | ||
4777 | idx = ucontrol->value.enumerated.item[0]; | |
4778 | if (idx >= imux->num_items) | |
4779 | idx = imux->num_items - 1; | |
f12ab1e0 | 4780 | if (*cur_val == idx && !codec->in_resume) |
1da177e4 LT |
4781 | return 0; |
4782 | for (i = 0; i < imux->num_items; i++) { | |
4783 | unsigned int v = (i == idx) ? 0x7000 : 0x7080; | |
4784 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
4785 | v | (imux->items[i].index << 8)); | |
4786 | } | |
4787 | *cur_val = idx; | |
4788 | return 1; | |
4789 | } | |
4790 | ||
272a527c KY |
4791 | /* |
4792 | * 2ch mode | |
4793 | */ | |
4794 | static struct hda_verb alc882_3ST_ch2_init[] = { | |
4795 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
4796 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
4797 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
4798 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
4799 | { } /* end */ | |
4800 | }; | |
4801 | ||
4802 | /* | |
4803 | * 6ch mode | |
4804 | */ | |
4805 | static struct hda_verb alc882_3ST_ch6_init[] = { | |
4806 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
4807 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
4808 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
4809 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
4810 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
4811 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
4812 | { } /* end */ | |
4813 | }; | |
4814 | ||
4815 | static struct hda_channel_mode alc882_3ST_6ch_modes[2] = { | |
4816 | { 2, alc882_3ST_ch2_init }, | |
4817 | { 6, alc882_3ST_ch6_init }, | |
4818 | }; | |
4819 | ||
df694daa KY |
4820 | /* |
4821 | * 6ch mode | |
4822 | */ | |
4823 | static struct hda_verb alc882_sixstack_ch6_init[] = { | |
4824 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
4825 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
4826 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
4827 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
4828 | { } /* end */ | |
4829 | }; | |
4830 | ||
4831 | /* | |
4832 | * 8ch mode | |
4833 | */ | |
4834 | static struct hda_verb alc882_sixstack_ch8_init[] = { | |
4835 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
4836 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
4837 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
4838 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
4839 | { } /* end */ | |
4840 | }; | |
4841 | ||
4842 | static struct hda_channel_mode alc882_sixstack_modes[2] = { | |
4843 | { 6, alc882_sixstack_ch6_init }, | |
4844 | { 8, alc882_sixstack_ch8_init }, | |
4845 | }; | |
4846 | ||
1da177e4 LT |
4847 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
4848 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
4849 | */ | |
c8b6bf9b | 4850 | static struct snd_kcontrol_new alc882_base_mixer[] = { |
05acb863 | 4851 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 4852 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
05acb863 | 4853 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 4854 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
05acb863 TI |
4855 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
4856 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
4857 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
4858 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
05acb863 | 4859 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 4860 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
1da177e4 LT |
4861 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
4862 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
4863 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
4864 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
4865 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
4866 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 4867 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
1da177e4 LT |
4868 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
4869 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 4870 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
1da177e4 LT |
4871 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
4872 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
4873 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
1da177e4 LT |
4874 | { } /* end */ |
4875 | }; | |
4876 | ||
bdd148a3 KY |
4877 | static struct snd_kcontrol_new alc882_w2jc_mixer[] = { |
4878 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
4879 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
4880 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
4881 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
4882 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
4883 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
4884 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
4885 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
4886 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
4887 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
4888 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
4889 | { } /* end */ | |
4890 | }; | |
4891 | ||
272a527c KY |
4892 | static struct snd_kcontrol_new alc882_targa_mixer[] = { |
4893 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
4894 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
4895 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
4896 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
4897 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
4898 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
4899 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
4900 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
4901 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
4902 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
4903 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
4904 | { } /* end */ | |
4905 | }; | |
4906 | ||
4907 | /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ??? | |
4908 | * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c | |
4909 | */ | |
4910 | static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = { | |
4911 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
4912 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
4913 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
4914 | HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT), | |
4915 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
4916 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
4917 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
4918 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
4919 | HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT), | |
4920 | HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT), | |
4921 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
4922 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
4923 | { } /* end */ | |
4924 | }; | |
4925 | ||
df694daa KY |
4926 | static struct snd_kcontrol_new alc882_chmode_mixer[] = { |
4927 | { | |
4928 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
4929 | .name = "Channel Mode", | |
4930 | .info = alc_ch_mode_info, | |
4931 | .get = alc_ch_mode_get, | |
4932 | .put = alc_ch_mode_put, | |
4933 | }, | |
4934 | { } /* end */ | |
4935 | }; | |
4936 | ||
1da177e4 LT |
4937 | static struct hda_verb alc882_init_verbs[] = { |
4938 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
05acb863 TI |
4939 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
4940 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4941 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 4942 | /* Rear mixer */ |
05acb863 TI |
4943 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
4944 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4945 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 4946 | /* CLFE mixer */ |
05acb863 TI |
4947 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
4948 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4949 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 4950 | /* Side mixer */ |
05acb863 TI |
4951 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
4952 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4953 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 4954 | |
e9edcee0 | 4955 | /* Front Pin: output 0 (0x0c) */ |
05acb863 | 4956 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 4957 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 4958 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 4959 | /* Rear Pin: output 1 (0x0d) */ |
05acb863 | 4960 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 4961 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 4962 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, |
e9edcee0 | 4963 | /* CLFE Pin: output 2 (0x0e) */ |
05acb863 | 4964 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 4965 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 4966 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, |
e9edcee0 | 4967 | /* Side Pin: output 3 (0x0f) */ |
05acb863 | 4968 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 4969 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 4970 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, |
e9edcee0 | 4971 | /* Mic (rear) pin: input vref at 80% */ |
16ded525 | 4972 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 TI |
4973 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
4974 | /* Front Mic pin: input vref at 80% */ | |
16ded525 | 4975 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 TI |
4976 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
4977 | /* Line In pin: input */ | |
05acb863 | 4978 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 TI |
4979 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
4980 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
4981 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
4982 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4983 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1da177e4 | 4984 | /* CD pin widget for input */ |
05acb863 | 4985 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 LT |
4986 | |
4987 | /* FIXME: use matrix-type input source selection */ | |
4988 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
4989 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
05acb863 TI |
4990 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
4991 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4992 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4993 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 4994 | /* Input mixer2 */ |
05acb863 TI |
4995 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
4996 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4997 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4998 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 4999 | /* Input mixer3 */ |
05acb863 TI |
5000 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
5001 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5002 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5003 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5004 | /* ADC1: mute amp left and right */ | |
5005 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 5006 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
5007 | /* ADC2: mute amp left and right */ |
5008 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 5009 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
5010 | /* ADC3: mute amp left and right */ |
5011 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 5012 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
1da177e4 LT |
5013 | |
5014 | { } | |
5015 | }; | |
5016 | ||
4b146cb0 TI |
5017 | static struct hda_verb alc882_eapd_verbs[] = { |
5018 | /* change to EAPD mode */ | |
5019 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
b373bdeb | 5020 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, |
f12ab1e0 | 5021 | { } |
4b146cb0 TI |
5022 | }; |
5023 | ||
9102cd1c TD |
5024 | /* Mac Pro test */ |
5025 | static struct snd_kcontrol_new alc882_macpro_mixer[] = { | |
5026 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5027 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
5028 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT), | |
5029 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
5030 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
5031 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5032 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5033 | { } /* end */ | |
5034 | }; | |
5035 | ||
5036 | static struct hda_verb alc882_macpro_init_verbs[] = { | |
5037 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
5038 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5039 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5040 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5041 | /* Front Pin: output 0 (0x0c) */ | |
5042 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5043 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5044 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5045 | /* Front Mic pin: input vref at 80% */ | |
5046 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
5047 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5048 | /* Speaker: output */ | |
5049 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5050 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5051 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04}, | |
5052 | /* Headphone output (output 0 - 0x0c) */ | |
5053 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5054 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5055 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5056 | ||
5057 | /* FIXME: use matrix-type input source selection */ | |
5058 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
5059 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
5060 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5061 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5062 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5063 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5064 | /* Input mixer2 */ | |
5065 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5066 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5067 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5068 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5069 | /* Input mixer3 */ | |
5070 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5071 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5072 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5073 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5074 | /* ADC1: mute amp left and right */ | |
5075 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5076 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5077 | /* ADC2: mute amp left and right */ | |
5078 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5079 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5080 | /* ADC3: mute amp left and right */ | |
5081 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5082 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5083 | ||
5084 | { } | |
5085 | }; | |
f12ab1e0 | 5086 | |
272a527c KY |
5087 | static struct hda_verb alc882_targa_verbs[] = { |
5088 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5089 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5090 | ||
5091 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5092 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5093 | ||
5094 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
5095 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
5096 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
5097 | ||
5098 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
5099 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, | |
5100 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | |
5101 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | |
5102 | { } /* end */ | |
5103 | }; | |
5104 | ||
5105 | /* toggle speaker-output according to the hp-jack state */ | |
5106 | static void alc882_targa_automute(struct hda_codec *codec) | |
5107 | { | |
5108 | unsigned int present; | |
5109 | ||
5110 | present = snd_hda_codec_read(codec, 0x14, 0, | |
5111 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
5112 | snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0, | |
5113 | 0x80, present ? 0x80 : 0); | |
5114 | snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0, | |
5115 | 0x80, present ? 0x80 : 0); | |
5116 | snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3); | |
5117 | } | |
5118 | ||
5119 | static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res) | |
5120 | { | |
5121 | /* Looks like the unsol event is incompatible with the standard | |
5122 | * definition. 4bit tag is placed at 26 bit! | |
5123 | */ | |
5124 | if (((res >> 26) == ALC880_HP_EVENT)) { | |
5125 | alc882_targa_automute(codec); | |
5126 | } | |
5127 | } | |
5128 | ||
5129 | static struct hda_verb alc882_asus_a7j_verbs[] = { | |
5130 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5131 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5132 | ||
5133 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5134 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5135 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5136 | ||
5137 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ | |
5138 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
5139 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ | |
5140 | ||
5141 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
5142 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
5143 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
5144 | { } /* end */ | |
5145 | }; | |
5146 | ||
9102cd1c TD |
5147 | static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) |
5148 | { | |
5149 | unsigned int gpiostate, gpiomask, gpiodir; | |
5150 | ||
5151 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, | |
5152 | AC_VERB_GET_GPIO_DATA, 0); | |
5153 | ||
5154 | if (!muted) | |
5155 | gpiostate |= (1 << pin); | |
5156 | else | |
5157 | gpiostate &= ~(1 << pin); | |
5158 | ||
5159 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, | |
5160 | AC_VERB_GET_GPIO_MASK, 0); | |
5161 | gpiomask |= (1 << pin); | |
5162 | ||
5163 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, | |
5164 | AC_VERB_GET_GPIO_DIRECTION, 0); | |
5165 | gpiodir |= (1 << pin); | |
5166 | ||
5167 | ||
5168 | snd_hda_codec_write(codec, codec->afg, 0, | |
5169 | AC_VERB_SET_GPIO_MASK, gpiomask); | |
5170 | snd_hda_codec_write(codec, codec->afg, 0, | |
5171 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); | |
5172 | ||
5173 | msleep(1); | |
5174 | ||
5175 | snd_hda_codec_write(codec, codec->afg, 0, | |
5176 | AC_VERB_SET_GPIO_DATA, gpiostate); | |
5177 | } | |
5178 | ||
df694daa KY |
5179 | /* |
5180 | * generic initialization of ADC, input mixers and output mixers | |
5181 | */ | |
5182 | static struct hda_verb alc882_auto_init_verbs[] = { | |
5183 | /* | |
5184 | * Unmute ADC0-2 and set the default input to mic-in | |
5185 | */ | |
5186 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5187 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5188 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5189 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5190 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5191 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
1da177e4 | 5192 | |
df694daa KY |
5193 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
5194 | * mixer widget | |
f12ab1e0 TI |
5195 | * Note: PASD motherboards uses the Line In 2 as the input for |
5196 | * front panel mic (mic 2) | |
df694daa KY |
5197 | */ |
5198 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
5199 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5200 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5201 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
5202 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
5203 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
e9edcee0 | 5204 | |
df694daa KY |
5205 | /* |
5206 | * Set up output mixers (0x0c - 0x0f) | |
5207 | */ | |
5208 | /* set vol=0 to output mixers */ | |
5209 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5210 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5211 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5212 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5213 | /* set up input amps for analog loopback */ | |
5214 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
5215 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5216 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5217 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5218 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5219 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5220 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5221 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5222 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5223 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5224 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5225 | ||
5226 | /* FIXME: use matrix-type input source selection */ | |
5227 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
5228 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
5229 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
5230 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
5231 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
5232 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
5233 | /* Input mixer2 */ | |
5234 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
5235 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
5236 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
5237 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
5238 | /* Input mixer3 */ | |
5239 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
5240 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
5241 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
5242 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
5243 | ||
5244 | { } | |
5245 | }; | |
5246 | ||
5247 | /* capture mixer elements */ | |
5248 | static struct snd_kcontrol_new alc882_capture_alt_mixer[] = { | |
5249 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
5250 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
5251 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
5252 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
5253 | { | |
5254 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5255 | /* The multiple "Capture Source" controls confuse alsamixer | |
5256 | * So call somewhat different.. | |
5257 | * FIXME: the controls appear in the "playback" view! | |
5258 | */ | |
5259 | /* .name = "Capture Source", */ | |
5260 | .name = "Input Source", | |
5261 | .count = 2, | |
5262 | .info = alc882_mux_enum_info, | |
5263 | .get = alc882_mux_enum_get, | |
5264 | .put = alc882_mux_enum_put, | |
5265 | }, | |
5266 | { } /* end */ | |
5267 | }; | |
5268 | ||
5269 | static struct snd_kcontrol_new alc882_capture_mixer[] = { | |
5270 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), | |
5271 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), | |
5272 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), | |
5273 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), | |
5274 | HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), | |
5275 | HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), | |
5276 | { | |
5277 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5278 | /* The multiple "Capture Source" controls confuse alsamixer | |
5279 | * So call somewhat different.. | |
5280 | * FIXME: the controls appear in the "playback" view! | |
5281 | */ | |
5282 | /* .name = "Capture Source", */ | |
5283 | .name = "Input Source", | |
5284 | .count = 3, | |
5285 | .info = alc882_mux_enum_info, | |
5286 | .get = alc882_mux_enum_get, | |
5287 | .put = alc882_mux_enum_put, | |
5288 | }, | |
5289 | { } /* end */ | |
5290 | }; | |
5291 | ||
5292 | /* pcm configuration: identiacal with ALC880 */ | |
5293 | #define alc882_pcm_analog_playback alc880_pcm_analog_playback | |
5294 | #define alc882_pcm_analog_capture alc880_pcm_analog_capture | |
5295 | #define alc882_pcm_digital_playback alc880_pcm_digital_playback | |
5296 | #define alc882_pcm_digital_capture alc880_pcm_digital_capture | |
5297 | ||
5298 | /* | |
5299 | * configuration and preset | |
5300 | */ | |
f5fcc13c TI |
5301 | static const char *alc882_models[ALC882_MODEL_LAST] = { |
5302 | [ALC882_3ST_DIG] = "3stack-dig", | |
5303 | [ALC882_6ST_DIG] = "6stack-dig", | |
5304 | [ALC882_ARIMA] = "arima", | |
bdd148a3 | 5305 | [ALC882_W2JC] = "w2jc", |
9102cd1c | 5306 | [ALC885_MACPRO] = "macpro", |
f5fcc13c TI |
5307 | [ALC882_AUTO] = "auto", |
5308 | }; | |
5309 | ||
5310 | static struct snd_pci_quirk alc882_cfg_tbl[] = { | |
5311 | SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG), | |
5312 | SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG), | |
5313 | SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG), | |
272a527c | 5314 | SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */ |
f5fcc13c | 5315 | SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), |
272a527c | 5316 | SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J), |
7b9470d8 | 5317 | SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG), |
bdd148a3 | 5318 | SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC), |
df694daa KY |
5319 | {} |
5320 | }; | |
5321 | ||
5322 | static struct alc_config_preset alc882_presets[] = { | |
5323 | [ALC882_3ST_DIG] = { | |
5324 | .mixers = { alc882_base_mixer }, | |
5325 | .init_verbs = { alc882_init_verbs }, | |
5326 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
5327 | .dac_nids = alc882_dac_nids, | |
5328 | .dig_out_nid = ALC882_DIGOUT_NID, | |
df694daa KY |
5329 | .dig_in_nid = ALC882_DIGIN_NID, |
5330 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | |
5331 | .channel_mode = alc882_ch_modes, | |
4e195a7b | 5332 | .need_dac_fix = 1, |
df694daa KY |
5333 | .input_mux = &alc882_capture_source, |
5334 | }, | |
5335 | [ALC882_6ST_DIG] = { | |
5336 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, | |
5337 | .init_verbs = { alc882_init_verbs }, | |
5338 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
5339 | .dac_nids = alc882_dac_nids, | |
5340 | .dig_out_nid = ALC882_DIGOUT_NID, | |
df694daa KY |
5341 | .dig_in_nid = ALC882_DIGIN_NID, |
5342 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), | |
5343 | .channel_mode = alc882_sixstack_modes, | |
5344 | .input_mux = &alc882_capture_source, | |
5345 | }, | |
4b146cb0 TI |
5346 | [ALC882_ARIMA] = { |
5347 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, | |
5348 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs }, | |
5349 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
5350 | .dac_nids = alc882_dac_nids, | |
5351 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), | |
5352 | .channel_mode = alc882_sixstack_modes, | |
5353 | .input_mux = &alc882_capture_source, | |
5354 | }, | |
bdd148a3 KY |
5355 | [ALC882_W2JC] = { |
5356 | .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer }, | |
5357 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs, | |
5358 | alc880_gpio1_init_verbs }, | |
5359 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
5360 | .dac_nids = alc882_dac_nids, | |
5361 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
5362 | .channel_mode = alc880_threestack_modes, | |
5363 | .need_dac_fix = 1, | |
5364 | .input_mux = &alc882_capture_source, | |
5365 | .dig_out_nid = ALC882_DIGOUT_NID, | |
5366 | }, | |
9102cd1c TD |
5367 | [ALC885_MACPRO] = { |
5368 | .mixers = { alc882_macpro_mixer }, | |
5369 | .init_verbs = { alc882_macpro_init_verbs }, | |
5370 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
5371 | .dac_nids = alc882_dac_nids, | |
5372 | .dig_out_nid = ALC882_DIGOUT_NID, | |
5373 | .dig_in_nid = ALC882_DIGIN_NID, | |
5374 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | |
5375 | .channel_mode = alc882_ch_modes, | |
5376 | .input_mux = &alc882_capture_source, | |
5377 | }, | |
272a527c KY |
5378 | [ALC882_TARGA] = { |
5379 | .mixers = { alc882_targa_mixer, alc882_chmode_mixer, | |
5380 | alc882_capture_mixer }, | |
5381 | .init_verbs = { alc882_init_verbs, alc882_targa_verbs}, | |
5382 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
5383 | .dac_nids = alc882_dac_nids, | |
5384 | .dig_out_nid = ALC882_DIGOUT_NID, | |
5385 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), | |
5386 | .adc_nids = alc882_adc_nids, | |
5387 | .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), | |
5388 | .channel_mode = alc882_3ST_6ch_modes, | |
5389 | .need_dac_fix = 1, | |
5390 | .input_mux = &alc882_capture_source, | |
5391 | .unsol_event = alc882_targa_unsol_event, | |
5392 | .init_hook = alc882_targa_automute, | |
5393 | }, | |
5394 | [ALC882_ASUS_A7J] = { | |
5395 | .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer, | |
5396 | alc882_capture_mixer }, | |
5397 | .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs}, | |
5398 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
5399 | .dac_nids = alc882_dac_nids, | |
5400 | .dig_out_nid = ALC882_DIGOUT_NID, | |
5401 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), | |
5402 | .adc_nids = alc882_adc_nids, | |
5403 | .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), | |
5404 | .channel_mode = alc882_3ST_6ch_modes, | |
5405 | .need_dac_fix = 1, | |
5406 | .input_mux = &alc882_capture_source, | |
5407 | }, | |
df694daa KY |
5408 | }; |
5409 | ||
5410 | ||
5411 | /* | |
5412 | * BIOS auto configuration | |
5413 | */ | |
5414 | static void alc882_auto_set_output_and_unmute(struct hda_codec *codec, | |
5415 | hda_nid_t nid, int pin_type, | |
5416 | int dac_idx) | |
5417 | { | |
5418 | /* set as output */ | |
5419 | struct alc_spec *spec = codec->spec; | |
f12ab1e0 TI |
5420 | int idx; |
5421 | ||
df694daa KY |
5422 | if (spec->multiout.dac_nids[dac_idx] == 0x25) |
5423 | idx = 4; | |
5424 | else | |
5425 | idx = spec->multiout.dac_nids[dac_idx] - 2; | |
5426 | ||
f12ab1e0 TI |
5427 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
5428 | pin_type); | |
5429 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
5430 | AMP_OUT_UNMUTE); | |
df694daa KY |
5431 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); |
5432 | ||
5433 | } | |
5434 | ||
5435 | static void alc882_auto_init_multi_out(struct hda_codec *codec) | |
5436 | { | |
5437 | struct alc_spec *spec = codec->spec; | |
5438 | int i; | |
5439 | ||
bc9f98a9 | 5440 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
df694daa | 5441 | for (i = 0; i <= HDA_SIDE; i++) { |
f12ab1e0 | 5442 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
baba8ee9 | 5443 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
df694daa | 5444 | if (nid) |
baba8ee9 | 5445 | alc882_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 5446 | i); |
df694daa KY |
5447 | } |
5448 | } | |
5449 | ||
5450 | static void alc882_auto_init_hp_out(struct hda_codec *codec) | |
5451 | { | |
5452 | struct alc_spec *spec = codec->spec; | |
5453 | hda_nid_t pin; | |
5454 | ||
eb06ed8f | 5455 | pin = spec->autocfg.hp_pins[0]; |
df694daa | 5456 | if (pin) /* connect to front */ |
f12ab1e0 TI |
5457 | /* use dac 0 */ |
5458 | alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
df694daa KY |
5459 | } |
5460 | ||
5461 | #define alc882_is_input_pin(nid) alc880_is_input_pin(nid) | |
5462 | #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID | |
5463 | ||
5464 | static void alc882_auto_init_analog_input(struct hda_codec *codec) | |
5465 | { | |
5466 | struct alc_spec *spec = codec->spec; | |
5467 | int i; | |
5468 | ||
5469 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
5470 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
5471 | if (alc882_is_input_pin(nid)) { | |
f12ab1e0 TI |
5472 | snd_hda_codec_write(codec, nid, 0, |
5473 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
5474 | i <= AUTO_PIN_FRONT_MIC ? | |
5475 | PIN_VREF80 : PIN_IN); | |
df694daa | 5476 | if (nid != ALC882_PIN_CD_NID) |
f12ab1e0 TI |
5477 | snd_hda_codec_write(codec, nid, 0, |
5478 | AC_VERB_SET_AMP_GAIN_MUTE, | |
df694daa KY |
5479 | AMP_OUT_MUTE); |
5480 | } | |
5481 | } | |
5482 | } | |
5483 | ||
5484 | /* almost identical with ALC880 parser... */ | |
5485 | static int alc882_parse_auto_config(struct hda_codec *codec) | |
5486 | { | |
5487 | struct alc_spec *spec = codec->spec; | |
5488 | int err = alc880_parse_auto_config(codec); | |
5489 | ||
5490 | if (err < 0) | |
5491 | return err; | |
c5f2ea08 TI |
5492 | else if (err > 0) |
5493 | /* hack - override the init verbs */ | |
5494 | spec->init_verbs[0] = alc882_auto_init_verbs; | |
5495 | return err; | |
df694daa KY |
5496 | } |
5497 | ||
ae6b813a TI |
5498 | /* additional initialization for auto-configuration model */ |
5499 | static void alc882_auto_init(struct hda_codec *codec) | |
df694daa | 5500 | { |
df694daa KY |
5501 | alc882_auto_init_multi_out(codec); |
5502 | alc882_auto_init_hp_out(codec); | |
5503 | alc882_auto_init_analog_input(codec); | |
df694daa KY |
5504 | } |
5505 | ||
df694daa KY |
5506 | static int patch_alc882(struct hda_codec *codec) |
5507 | { | |
5508 | struct alc_spec *spec; | |
5509 | int err, board_config; | |
5510 | ||
5511 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
5512 | if (spec == NULL) | |
5513 | return -ENOMEM; | |
5514 | ||
5515 | codec->spec = spec; | |
5516 | ||
f5fcc13c TI |
5517 | board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST, |
5518 | alc882_models, | |
5519 | alc882_cfg_tbl); | |
df694daa KY |
5520 | |
5521 | if (board_config < 0 || board_config >= ALC882_MODEL_LAST) { | |
081d17c4 TD |
5522 | /* Pick up systems that don't supply PCI SSID */ |
5523 | switch (codec->subsystem_id) { | |
5524 | case 0x106b0c00: /* Mac Pro */ | |
5525 | board_config = ALC885_MACPRO; | |
5526 | break; | |
5527 | default: | |
5528 | printk(KERN_INFO "hda_codec: Unknown model for ALC882, " | |
5529 | "trying auto-probe from BIOS...\n"); | |
5530 | board_config = ALC882_AUTO; | |
5531 | } | |
df694daa KY |
5532 | } |
5533 | ||
5534 | if (board_config == ALC882_AUTO) { | |
5535 | /* automatic parse from the BIOS config */ | |
5536 | err = alc882_parse_auto_config(codec); | |
5537 | if (err < 0) { | |
5538 | alc_free(codec); | |
5539 | return err; | |
f12ab1e0 | 5540 | } else if (!err) { |
9c7f852e TI |
5541 | printk(KERN_INFO |
5542 | "hda_codec: Cannot set up configuration " | |
5543 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
5544 | board_config = ALC882_3ST_DIG; |
5545 | } | |
5546 | } | |
5547 | ||
5548 | if (board_config != ALC882_AUTO) | |
5549 | setup_preset(spec, &alc882_presets[board_config]); | |
1da177e4 | 5550 | |
9102cd1c TD |
5551 | if (board_config == ALC885_MACPRO) { |
5552 | alc882_gpio_mute(codec, 0, 0); | |
5553 | alc882_gpio_mute(codec, 1, 0); | |
5554 | } | |
5555 | ||
1da177e4 | 5556 | spec->stream_name_analog = "ALC882 Analog"; |
df694daa KY |
5557 | spec->stream_analog_playback = &alc882_pcm_analog_playback; |
5558 | spec->stream_analog_capture = &alc882_pcm_analog_capture; | |
1da177e4 LT |
5559 | |
5560 | spec->stream_name_digital = "ALC882 Digital"; | |
df694daa KY |
5561 | spec->stream_digital_playback = &alc882_pcm_digital_playback; |
5562 | spec->stream_digital_capture = &alc882_pcm_digital_capture; | |
1da177e4 | 5563 | |
f12ab1e0 | 5564 | if (!spec->adc_nids && spec->input_mux) { |
df694daa | 5565 | /* check whether NID 0x07 is valid */ |
4a471b7d | 5566 | unsigned int wcap = get_wcaps(codec, 0x07); |
f12ab1e0 TI |
5567 | /* get type */ |
5568 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
df694daa KY |
5569 | if (wcap != AC_WID_AUD_IN) { |
5570 | spec->adc_nids = alc882_adc_nids_alt; | |
5571 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt); | |
f12ab1e0 TI |
5572 | spec->mixers[spec->num_mixers] = |
5573 | alc882_capture_alt_mixer; | |
df694daa KY |
5574 | spec->num_mixers++; |
5575 | } else { | |
5576 | spec->adc_nids = alc882_adc_nids; | |
5577 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids); | |
5578 | spec->mixers[spec->num_mixers] = alc882_capture_mixer; | |
5579 | spec->num_mixers++; | |
5580 | } | |
5581 | } | |
1da177e4 LT |
5582 | |
5583 | codec->patch_ops = alc_patch_ops; | |
df694daa | 5584 | if (board_config == ALC882_AUTO) |
ae6b813a | 5585 | spec->init_hook = alc882_auto_init; |
df694daa KY |
5586 | |
5587 | return 0; | |
5588 | } | |
5589 | ||
5590 | /* | |
9c7f852e TI |
5591 | * ALC883 support |
5592 | * | |
5593 | * ALC883 is almost identical with ALC880 but has cleaner and more flexible | |
5594 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
5595 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
5596 | * 6-channel independent captures. | |
5597 | * | |
5598 | * In addition, an independent DAC for the multi-playback (not used in this | |
5599 | * driver yet). | |
df694daa | 5600 | */ |
9c7f852e TI |
5601 | #define ALC883_DIGOUT_NID 0x06 |
5602 | #define ALC883_DIGIN_NID 0x0a | |
df694daa | 5603 | |
9c7f852e TI |
5604 | static hda_nid_t alc883_dac_nids[4] = { |
5605 | /* front, rear, clfe, rear_surr */ | |
5606 | 0x02, 0x04, 0x03, 0x05 | |
5607 | }; | |
df694daa | 5608 | |
9c7f852e TI |
5609 | static hda_nid_t alc883_adc_nids[2] = { |
5610 | /* ADC1-2 */ | |
5611 | 0x08, 0x09, | |
5612 | }; | |
f12ab1e0 | 5613 | |
9c7f852e TI |
5614 | /* input MUX */ |
5615 | /* FIXME: should be a matrix-type input source selection */ | |
df694daa | 5616 | |
9c7f852e TI |
5617 | static struct hda_input_mux alc883_capture_source = { |
5618 | .num_items = 4, | |
5619 | .items = { | |
5620 | { "Mic", 0x0 }, | |
5621 | { "Front Mic", 0x1 }, | |
5622 | { "Line", 0x2 }, | |
5623 | { "CD", 0x4 }, | |
5624 | }, | |
5625 | }; | |
bc9f98a9 KY |
5626 | |
5627 | static struct hda_input_mux alc883_lenovo_101e_capture_source = { | |
5628 | .num_items = 2, | |
5629 | .items = { | |
5630 | { "Mic", 0x1 }, | |
5631 | { "Line", 0x2 }, | |
5632 | }, | |
5633 | }; | |
5634 | ||
272a527c KY |
5635 | static struct hda_input_mux alc883_lenovo_nb0763_capture_source = { |
5636 | .num_items = 4, | |
5637 | .items = { | |
5638 | { "Mic", 0x0 }, | |
5639 | { "iMic", 0x1 }, | |
5640 | { "Line", 0x2 }, | |
5641 | { "CD", 0x4 }, | |
5642 | }, | |
5643 | }; | |
5644 | ||
9c7f852e TI |
5645 | #define alc883_mux_enum_info alc_mux_enum_info |
5646 | #define alc883_mux_enum_get alc_mux_enum_get | |
df694daa | 5647 | |
9c7f852e TI |
5648 | static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol, |
5649 | struct snd_ctl_elem_value *ucontrol) | |
5650 | { | |
5651 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
5652 | struct alc_spec *spec = codec->spec; | |
5653 | const struct hda_input_mux *imux = spec->input_mux; | |
5654 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
5655 | static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 }; | |
5656 | hda_nid_t nid = capture_mixers[adc_idx]; | |
5657 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; | |
5658 | unsigned int i, idx; | |
5659 | ||
5660 | idx = ucontrol->value.enumerated.item[0]; | |
5661 | if (idx >= imux->num_items) | |
5662 | idx = imux->num_items - 1; | |
f12ab1e0 | 5663 | if (*cur_val == idx && !codec->in_resume) |
9c7f852e TI |
5664 | return 0; |
5665 | for (i = 0; i < imux->num_items; i++) { | |
5666 | unsigned int v = (i == idx) ? 0x7000 : 0x7080; | |
5667 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
5668 | v | (imux->items[i].index << 8)); | |
5669 | } | |
5670 | *cur_val = idx; | |
5671 | return 1; | |
5672 | } | |
f12ab1e0 | 5673 | |
9c7f852e TI |
5674 | /* |
5675 | * 2ch mode | |
5676 | */ | |
5677 | static struct hda_channel_mode alc883_3ST_2ch_modes[1] = { | |
5678 | { 2, NULL } | |
5679 | }; | |
5680 | ||
5681 | /* | |
5682 | * 2ch mode | |
5683 | */ | |
5684 | static struct hda_verb alc883_3ST_ch2_init[] = { | |
5685 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
5686 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
5687 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
5688 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
5689 | { } /* end */ | |
5690 | }; | |
5691 | ||
5692 | /* | |
5693 | * 6ch mode | |
5694 | */ | |
5695 | static struct hda_verb alc883_3ST_ch6_init[] = { | |
5696 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5697 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
5698 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
5699 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5700 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
5701 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
5702 | { } /* end */ | |
5703 | }; | |
5704 | ||
5705 | static struct hda_channel_mode alc883_3ST_6ch_modes[2] = { | |
5706 | { 2, alc883_3ST_ch2_init }, | |
5707 | { 6, alc883_3ST_ch6_init }, | |
5708 | }; | |
5709 | ||
5710 | /* | |
5711 | * 6ch mode | |
5712 | */ | |
5713 | static struct hda_verb alc883_sixstack_ch6_init[] = { | |
5714 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
5715 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5716 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5717 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5718 | { } /* end */ | |
5719 | }; | |
5720 | ||
5721 | /* | |
5722 | * 8ch mode | |
5723 | */ | |
5724 | static struct hda_verb alc883_sixstack_ch8_init[] = { | |
5725 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5726 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5727 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5728 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5729 | { } /* end */ | |
5730 | }; | |
5731 | ||
5732 | static struct hda_channel_mode alc883_sixstack_modes[2] = { | |
5733 | { 6, alc883_sixstack_ch6_init }, | |
5734 | { 8, alc883_sixstack_ch8_init }, | |
5735 | }; | |
5736 | ||
b373bdeb AN |
5737 | static struct hda_verb alc883_medion_eapd_verbs[] = { |
5738 | /* eanable EAPD on medion laptop */ | |
5739 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
5740 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
5741 | { } | |
5742 | }; | |
5743 | ||
9c7f852e TI |
5744 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
5745 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
5746 | */ | |
5747 | ||
5748 | static struct snd_kcontrol_new alc883_base_mixer[] = { | |
df694daa | 5749 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9c7f852e TI |
5750 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
5751 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
5752 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
5753 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
5754 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
5755 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
5756 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
5757 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
5758 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
5759 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
df694daa KY |
5760 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
5761 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5762 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5763 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5764 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 5765 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
df694daa | 5766 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
9c7f852e | 5767 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
32360416 | 5768 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
5769 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
5770 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
5771 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
5772 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
5773 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
5774 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
5775 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
5776 | { | |
5777 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5778 | /* .name = "Capture Source", */ | |
5779 | .name = "Input Source", | |
5780 | .count = 2, | |
5781 | .info = alc883_mux_enum_info, | |
5782 | .get = alc883_mux_enum_get, | |
5783 | .put = alc883_mux_enum_put, | |
5784 | }, | |
df694daa | 5785 | { } /* end */ |
834be88d TI |
5786 | }; |
5787 | ||
9c7f852e TI |
5788 | static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = { |
5789 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5790 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
5791 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
5792 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5793 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5794 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5795 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5796 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 5797 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
5798 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
5799 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 5800 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
5801 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
5802 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
5803 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
5804 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
5805 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
5806 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
5807 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
5808 | { | |
5809 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5810 | /* .name = "Capture Source", */ | |
5811 | .name = "Input Source", | |
5812 | .count = 2, | |
5813 | .info = alc883_mux_enum_info, | |
5814 | .get = alc883_mux_enum_get, | |
5815 | .put = alc883_mux_enum_put, | |
5816 | }, | |
5817 | { } /* end */ | |
5818 | }; | |
df694daa | 5819 | |
9c7f852e TI |
5820 | static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = { |
5821 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5822 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
5823 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
5824 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
5825 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
5826 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
5827 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
5828 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
5829 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
5830 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5831 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5832 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5833 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5834 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 5835 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
5836 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
5837 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 5838 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
5839 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
5840 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
5841 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
5842 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
5843 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
5844 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
5845 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
5846 | { | |
5847 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5848 | /* .name = "Capture Source", */ | |
5849 | .name = "Input Source", | |
5850 | .count = 2, | |
5851 | .info = alc883_mux_enum_info, | |
5852 | .get = alc883_mux_enum_get, | |
5853 | .put = alc883_mux_enum_put, | |
5854 | }, | |
5855 | { } /* end */ | |
5856 | }; | |
5857 | ||
d1d985f0 | 5858 | static struct snd_kcontrol_new alc883_fivestack_mixer[] = { |
c07584c8 TD |
5859 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
5860 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
5861 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
5862 | HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
5863 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
5864 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
5865 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT), | |
5866 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | |
5867 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
5868 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5869 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5870 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5871 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5872 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 5873 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
c07584c8 TD |
5874 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
5875 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 5876 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
c07584c8 TD |
5877 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
5878 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
5879 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
5880 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
5881 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
5882 | ||
5883 | { | |
5884 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5885 | /* .name = "Capture Source", */ | |
5886 | .name = "Input Source", | |
5887 | .count = 1, | |
5888 | .info = alc883_mux_enum_info, | |
5889 | .get = alc883_mux_enum_get, | |
5890 | .put = alc883_mux_enum_put, | |
5891 | }, | |
5892 | { } /* end */ | |
5893 | }; | |
5894 | ||
ccc656ce KY |
5895 | static struct snd_kcontrol_new alc883_tagra_mixer[] = { |
5896 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5897 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
5898 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
5899 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
5900 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
5901 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
5902 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
5903 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
5904 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
5905 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5906 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5907 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5908 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5909 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 5910 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce KY |
5911 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
5912 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
5913 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
5914 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
5915 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
5916 | { | |
5917 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5918 | /* .name = "Capture Source", */ | |
5919 | .name = "Input Source", | |
5920 | .count = 2, | |
5921 | .info = alc883_mux_enum_info, | |
5922 | .get = alc883_mux_enum_get, | |
5923 | .put = alc883_mux_enum_put, | |
5924 | }, | |
5925 | { } /* end */ | |
f12ab1e0 | 5926 | }; |
ccc656ce KY |
5927 | |
5928 | static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = { | |
5929 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5930 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
5931 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
5932 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5933 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5934 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 5935 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce KY |
5936 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
5937 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
5938 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
5939 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
5940 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
5941 | { | |
5942 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5943 | /* .name = "Capture Source", */ | |
5944 | .name = "Input Source", | |
5945 | .count = 2, | |
5946 | .info = alc883_mux_enum_info, | |
5947 | .get = alc883_mux_enum_get, | |
5948 | .put = alc883_mux_enum_put, | |
5949 | }, | |
5950 | { } /* end */ | |
f12ab1e0 | 5951 | }; |
ccc656ce | 5952 | |
bc9f98a9 KY |
5953 | static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = { |
5954 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5955 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
5956 | HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
5957 | HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
5958 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
5959 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
5960 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
5961 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
5962 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
5963 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
5964 | { | |
5965 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5966 | /* .name = "Capture Source", */ | |
5967 | .name = "Input Source", | |
5968 | .count = 1, | |
5969 | .info = alc883_mux_enum_info, | |
5970 | .get = alc883_mux_enum_get, | |
5971 | .put = alc883_mux_enum_put, | |
5972 | }, | |
5973 | { } /* end */ | |
f12ab1e0 | 5974 | }; |
bc9f98a9 | 5975 | |
272a527c KY |
5976 | static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = { |
5977 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5978 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT), | |
5979 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
5980 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5981 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5982 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
5983 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
5984 | HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
5985 | HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
5986 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
5987 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
5988 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
5989 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
5990 | { | |
5991 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5992 | /* .name = "Capture Source", */ | |
5993 | .name = "Input Source", | |
5994 | .count = 2, | |
5995 | .info = alc883_mux_enum_info, | |
5996 | .get = alc883_mux_enum_get, | |
5997 | .put = alc883_mux_enum_put, | |
5998 | }, | |
5999 | { } /* end */ | |
6000 | }; | |
6001 | ||
6002 | static struct snd_kcontrol_new alc883_medion_md2_mixer[] = { | |
6003 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6004 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
6005 | HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
6006 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6007 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6008 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6009 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
6010 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6011 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6012 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6013 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6014 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6015 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6016 | { | |
6017 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6018 | /* .name = "Capture Source", */ | |
6019 | .name = "Input Source", | |
6020 | .count = 2, | |
6021 | .info = alc883_mux_enum_info, | |
6022 | .get = alc883_mux_enum_get, | |
6023 | .put = alc883_mux_enum_put, | |
6024 | }, | |
6025 | { } /* end */ | |
6026 | }; | |
6027 | ||
cd1e3b40 CM |
6028 | static struct snd_kcontrol_new alc888_hp_nettle_mixer[] = { |
6029 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6030 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
6031 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT), | |
6032 | HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT), | |
6033 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), | |
6034 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT), | |
6035 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT), | |
6036 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), | |
6037 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
6038 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
6039 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6040 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6041 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6042 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6043 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6044 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6045 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
6046 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
6047 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
6048 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
6049 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
6050 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
6051 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
6052 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6053 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6054 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6055 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6056 | { | |
6057 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6058 | /* .name = "Capture Source", */ | |
6059 | .name = "Input Source", | |
6060 | .count = 2, | |
6061 | .info = alc883_mux_enum_info, | |
6062 | .get = alc883_mux_enum_get, | |
6063 | .put = alc883_mux_enum_put, | |
6064 | }, | |
6065 | { } /* end */ | |
6066 | }; | |
6067 | ||
9c7f852e TI |
6068 | static struct snd_kcontrol_new alc883_chmode_mixer[] = { |
6069 | { | |
6070 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6071 | .name = "Channel Mode", | |
6072 | .info = alc_ch_mode_info, | |
6073 | .get = alc_ch_mode_get, | |
6074 | .put = alc_ch_mode_put, | |
6075 | }, | |
6076 | { } /* end */ | |
6077 | }; | |
6078 | ||
6079 | static struct hda_verb alc883_init_verbs[] = { | |
6080 | /* ADC1: mute amp left and right */ | |
6081 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
df694daa | 6082 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
9c7f852e TI |
6083 | /* ADC2: mute amp left and right */ |
6084 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
df694daa | 6085 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
9c7f852e TI |
6086 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ |
6087 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6088 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6089 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
6090 | /* Rear mixer */ | |
6091 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6092 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6093 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
6094 | /* CLFE mixer */ | |
6095 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6096 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6097 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
6098 | /* Side mixer */ | |
6099 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6100 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6101 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
df694daa | 6102 | |
df694daa KY |
6103 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
6104 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6105 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
6106 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
6107 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
6108 | ||
9c7f852e TI |
6109 | /* Front Pin: output 0 (0x0c) */ |
6110 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6111 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6112 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6113 | /* Rear Pin: output 1 (0x0d) */ | |
6114 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6115 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6116 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
6117 | /* CLFE Pin: output 2 (0x0e) */ | |
6118 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6119 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6120 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
6121 | /* Side Pin: output 3 (0x0f) */ | |
6122 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6123 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6124 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
6125 | /* Mic (rear) pin: input vref at 80% */ | |
6126 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
6127 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
6128 | /* Front Mic pin: input vref at 80% */ | |
6129 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
6130 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
6131 | /* Line In pin: input */ | |
6132 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
6133 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
6134 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
6135 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6136 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6137 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6138 | /* CD pin widget for input */ | |
6139 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
6140 | ||
6141 | /* FIXME: use matrix-type input source selection */ | |
6142 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
6143 | /* Input mixer2 */ | |
6144 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6145 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6146 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
6147 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
6148 | /* Input mixer3 */ | |
6149 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6150 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6151 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
6152 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
6153 | { } | |
6154 | }; | |
6155 | ||
ccc656ce KY |
6156 | static struct hda_verb alc883_tagra_verbs[] = { |
6157 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6158 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6159 | ||
6160 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6161 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6162 | ||
6163 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
6164 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
6165 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
6166 | ||
6167 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
f12ab1e0 TI |
6168 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
6169 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | |
6170 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | |
ccc656ce KY |
6171 | |
6172 | { } /* end */ | |
6173 | }; | |
6174 | ||
bc9f98a9 KY |
6175 | static struct hda_verb alc883_lenovo_101e_verbs[] = { |
6176 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6177 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN}, | |
6178 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN}, | |
6179 | { } /* end */ | |
6180 | }; | |
6181 | ||
272a527c KY |
6182 | static struct hda_verb alc883_lenovo_nb0763_verbs[] = { |
6183 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6184 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6185 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
6186 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6187 | { } /* end */ | |
6188 | }; | |
6189 | ||
6190 | static struct hda_verb alc888_lenovo_ms7195_verbs[] = { | |
6191 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6192 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6193 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6194 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN}, | |
6195 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
6196 | { } /* end */ | |
6197 | }; | |
6198 | ||
cd1e3b40 CM |
6199 | static struct hda_verb alc888_hp_nettle_verbs[] = { |
6200 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */ | |
6201 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */ | |
6202 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */ | |
6203 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */ | |
6204 | { } | |
6205 | }; | |
6206 | ||
272a527c KY |
6207 | /* toggle front-jack and RCA according to the hp-jack state */ |
6208 | static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec) | |
6209 | { | |
6210 | unsigned int present; | |
6211 | ||
6212 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
6213 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
6214 | snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, | |
6215 | 0x80, present ? 0x80 : 0); | |
6216 | snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, | |
6217 | 0x80, present ? 0x80 : 0); | |
6218 | snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, | |
6219 | 0x80, present ? 0x80 : 0); | |
6220 | snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, | |
6221 | 0x80, present ? 0x80 : 0); | |
6222 | ||
6223 | } | |
6224 | ||
6225 | /* toggle RCA according to the front-jack state */ | |
6226 | static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec) | |
6227 | { | |
6228 | unsigned int present; | |
6229 | ||
6230 | present = snd_hda_codec_read(codec, 0x14, 0, | |
6231 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
6232 | snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, | |
6233 | 0x80, present ? 0x80 : 0); | |
6234 | snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, | |
6235 | 0x80, present ? 0x80 : 0); | |
6236 | ||
6237 | } | |
6238 | static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec, | |
6239 | unsigned int res) | |
6240 | { | |
6241 | if ((res >> 26) == ALC880_HP_EVENT) | |
6242 | alc888_lenovo_ms7195_front_automute(codec); | |
6243 | if ((res >> 26) == ALC880_FRONT_EVENT) | |
6244 | alc888_lenovo_ms7195_rca_automute(codec); | |
6245 | } | |
6246 | ||
6247 | static struct hda_verb alc883_medion_md2_verbs[] = { | |
6248 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6249 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6250 | ||
6251 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6252 | ||
6253 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
6254 | { } /* end */ | |
6255 | }; | |
6256 | ||
6257 | /* toggle speaker-output according to the hp-jack state */ | |
6258 | static void alc883_medion_md2_automute(struct hda_codec *codec) | |
6259 | { | |
6260 | unsigned int present; | |
6261 | ||
6262 | present = snd_hda_codec_read(codec, 0x14, 0, | |
6263 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
6264 | snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, | |
6265 | 0x80, present ? 0x80 : 0); | |
6266 | snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, | |
6267 | 0x80, present ? 0x80 : 0); | |
6268 | } | |
6269 | ||
6270 | static void alc883_medion_md2_unsol_event(struct hda_codec *codec, | |
6271 | unsigned int res) | |
6272 | { | |
6273 | if ((res >> 26) == ALC880_HP_EVENT) | |
6274 | alc883_medion_md2_automute(codec); | |
6275 | } | |
6276 | ||
ccc656ce KY |
6277 | /* toggle speaker-output according to the hp-jack state */ |
6278 | static void alc883_tagra_automute(struct hda_codec *codec) | |
6279 | { | |
6280 | unsigned int present; | |
f12ab1e0 | 6281 | unsigned char bits; |
ccc656ce KY |
6282 | |
6283 | present = snd_hda_codec_read(codec, 0x14, 0, | |
6284 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
f12ab1e0 | 6285 | bits = present ? 0x80 : 0; |
ccc656ce | 6286 | snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0, |
f12ab1e0 | 6287 | 0x80, bits); |
ccc656ce | 6288 | snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0, |
f12ab1e0 TI |
6289 | 0x80, bits); |
6290 | snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, | |
6291 | present ? 1 : 3); | |
ccc656ce KY |
6292 | } |
6293 | ||
6294 | static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res) | |
6295 | { | |
6296 | if ((res >> 26) == ALC880_HP_EVENT) | |
6297 | alc883_tagra_automute(codec); | |
6298 | } | |
6299 | ||
bc9f98a9 KY |
6300 | static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec) |
6301 | { | |
6302 | unsigned int present; | |
f12ab1e0 | 6303 | unsigned char bits; |
bc9f98a9 KY |
6304 | |
6305 | present = snd_hda_codec_read(codec, 0x14, 0, | |
6306 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
f12ab1e0 | 6307 | bits = present ? 0x80 : 0; |
bc9f98a9 | 6308 | snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, |
f12ab1e0 | 6309 | 0x80, bits); |
bc9f98a9 | 6310 | snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, |
f12ab1e0 | 6311 | 0x80, bits); |
bc9f98a9 KY |
6312 | } |
6313 | ||
6314 | static void alc883_lenovo_101e_all_automute(struct hda_codec *codec) | |
6315 | { | |
6316 | unsigned int present; | |
f12ab1e0 | 6317 | unsigned char bits; |
bc9f98a9 KY |
6318 | |
6319 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
6320 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
f12ab1e0 | 6321 | bits = present ? 0x80 : 0; |
bc9f98a9 | 6322 | snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, |
f12ab1e0 | 6323 | 0x80, bits); |
bc9f98a9 | 6324 | snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, |
f12ab1e0 | 6325 | 0x80, bits); |
bc9f98a9 | 6326 | snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, |
f12ab1e0 | 6327 | 0x80, bits); |
bc9f98a9 | 6328 | snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, |
f12ab1e0 | 6329 | 0x80, bits); |
bc9f98a9 KY |
6330 | } |
6331 | ||
6332 | static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec, | |
6333 | unsigned int res) | |
6334 | { | |
6335 | if ((res >> 26) == ALC880_HP_EVENT) | |
6336 | alc883_lenovo_101e_all_automute(codec); | |
6337 | if ((res >> 26) == ALC880_FRONT_EVENT) | |
6338 | alc883_lenovo_101e_ispeaker_automute(codec); | |
6339 | } | |
6340 | ||
9c7f852e TI |
6341 | /* |
6342 | * generic initialization of ADC, input mixers and output mixers | |
6343 | */ | |
6344 | static struct hda_verb alc883_auto_init_verbs[] = { | |
6345 | /* | |
6346 | * Unmute ADC0-2 and set the default input to mic-in | |
6347 | */ | |
6348 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6349 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6350 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6351 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6352 | ||
6353 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | |
6354 | * mixer widget | |
f12ab1e0 TI |
6355 | * Note: PASD motherboards uses the Line In 2 as the input for |
6356 | * front panel mic (mic 2) | |
9c7f852e TI |
6357 | */ |
6358 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
6359 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6360 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6361 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
6362 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
6363 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
6364 | ||
6365 | /* | |
6366 | * Set up output mixers (0x0c - 0x0f) | |
6367 | */ | |
6368 | /* set vol=0 to output mixers */ | |
6369 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6370 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6371 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6372 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6373 | /* set up input amps for analog loopback */ | |
6374 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
6375 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6376 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6377 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6378 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6379 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6380 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6381 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6382 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6383 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6384 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6385 | ||
6386 | /* FIXME: use matrix-type input source selection */ | |
6387 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
6388 | /* Input mixer1 */ | |
6389 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6390 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6391 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 6392 | /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */ |
9c7f852e TI |
6393 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
6394 | /* Input mixer2 */ | |
6395 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6396 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6397 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 6398 | /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */ |
9c7f852e TI |
6399 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
6400 | ||
6401 | { } | |
6402 | }; | |
6403 | ||
6404 | /* capture mixer elements */ | |
6405 | static struct snd_kcontrol_new alc883_capture_mixer[] = { | |
6406 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6407 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6408 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6409 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6410 | { | |
6411 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6412 | /* The multiple "Capture Source" controls confuse alsamixer | |
6413 | * So call somewhat different.. | |
6414 | * FIXME: the controls appear in the "playback" view! | |
6415 | */ | |
6416 | /* .name = "Capture Source", */ | |
6417 | .name = "Input Source", | |
6418 | .count = 2, | |
6419 | .info = alc882_mux_enum_info, | |
6420 | .get = alc882_mux_enum_get, | |
6421 | .put = alc882_mux_enum_put, | |
6422 | }, | |
6423 | { } /* end */ | |
6424 | }; | |
6425 | ||
6426 | /* pcm configuration: identiacal with ALC880 */ | |
6427 | #define alc883_pcm_analog_playback alc880_pcm_analog_playback | |
6428 | #define alc883_pcm_analog_capture alc880_pcm_analog_capture | |
6429 | #define alc883_pcm_digital_playback alc880_pcm_digital_playback | |
6430 | #define alc883_pcm_digital_capture alc880_pcm_digital_capture | |
6431 | ||
6432 | /* | |
6433 | * configuration and preset | |
6434 | */ | |
f5fcc13c TI |
6435 | static const char *alc883_models[ALC883_MODEL_LAST] = { |
6436 | [ALC883_3ST_2ch_DIG] = "3stack-dig", | |
6437 | [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig", | |
6438 | [ALC883_3ST_6ch] = "3stack-6ch", | |
6439 | [ALC883_6ST_DIG] = "6stack-dig", | |
6440 | [ALC883_TARGA_DIG] = "targa-dig", | |
6441 | [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig", | |
f5fcc13c TI |
6442 | [ALC883_ACER] = "acer", |
6443 | [ALC883_MEDION] = "medion", | |
272a527c | 6444 | [ALC883_MEDION_MD2] = "medion-md2", |
f5fcc13c | 6445 | [ALC883_LAPTOP_EAPD] = "laptop-eapd", |
bc9f98a9 | 6446 | [ALC883_LENOVO_101E_2ch] = "lenovo-101e", |
272a527c KY |
6447 | [ALC883_LENOVO_NB0763] = "lenovo-nb0763", |
6448 | [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig", | |
cd1e3b40 | 6449 | [ALC888_HP_NETTLE] = "hp-nettle", |
f5fcc13c TI |
6450 | [ALC883_AUTO] = "auto", |
6451 | }; | |
6452 | ||
6453 | static struct snd_pci_quirk alc883_cfg_tbl[] = { | |
6454 | SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG), | |
febe3375 | 6455 | SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG), |
f5fcc13c TI |
6456 | SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch), |
6457 | SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD), | |
6458 | SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG), | |
57b14f24 | 6459 | SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG), |
f5fcc13c TI |
6460 | SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG), |
6461 | SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG), | |
799f88a3 | 6462 | SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG), |
2a296cb6 | 6463 | SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG), |
6f3bf657 | 6464 | SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG), |
f5fcc13c | 6465 | SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG), |
dd146a60 | 6466 | SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG), |
f5fcc13c TI |
6467 | SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG), |
6468 | SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG), | |
6469 | SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG), | |
6470 | SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG), | |
6471 | SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG), | |
6472 | SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG), | |
6473 | SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG), | |
6474 | SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG), | |
6475 | SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG), | |
6476 | SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), | |
e60623b4 | 6477 | SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch), |
f5fcc13c TI |
6478 | SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), |
6479 | SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD), | |
6480 | SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), | |
272a527c KY |
6481 | SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch), |
6482 | SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763), | |
6483 | SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763), | |
cd1e3b40 | 6484 | SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_HP_NETTLE), |
272a527c | 6485 | SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2), |
9c7f852e TI |
6486 | {} |
6487 | }; | |
6488 | ||
6489 | static struct alc_config_preset alc883_presets[] = { | |
6490 | [ALC883_3ST_2ch_DIG] = { | |
6491 | .mixers = { alc883_3ST_2ch_mixer }, | |
6492 | .init_verbs = { alc883_init_verbs }, | |
6493 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
6494 | .dac_nids = alc883_dac_nids, | |
6495 | .dig_out_nid = ALC883_DIGOUT_NID, | |
6496 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
6497 | .adc_nids = alc883_adc_nids, | |
6498 | .dig_in_nid = ALC883_DIGIN_NID, | |
6499 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
6500 | .channel_mode = alc883_3ST_2ch_modes, | |
6501 | .input_mux = &alc883_capture_source, | |
6502 | }, | |
6503 | [ALC883_3ST_6ch_DIG] = { | |
6504 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
6505 | .init_verbs = { alc883_init_verbs }, | |
6506 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
6507 | .dac_nids = alc883_dac_nids, | |
6508 | .dig_out_nid = ALC883_DIGOUT_NID, | |
6509 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
6510 | .adc_nids = alc883_adc_nids, | |
6511 | .dig_in_nid = ALC883_DIGIN_NID, | |
6512 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
6513 | .channel_mode = alc883_3ST_6ch_modes, | |
4e195a7b | 6514 | .need_dac_fix = 1, |
9c7f852e | 6515 | .input_mux = &alc883_capture_source, |
f12ab1e0 | 6516 | }, |
9c7f852e TI |
6517 | [ALC883_3ST_6ch] = { |
6518 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
6519 | .init_verbs = { alc883_init_verbs }, | |
6520 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
6521 | .dac_nids = alc883_dac_nids, | |
6522 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
6523 | .adc_nids = alc883_adc_nids, | |
6524 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
6525 | .channel_mode = alc883_3ST_6ch_modes, | |
4e195a7b | 6526 | .need_dac_fix = 1, |
9c7f852e | 6527 | .input_mux = &alc883_capture_source, |
f12ab1e0 | 6528 | }, |
9c7f852e TI |
6529 | [ALC883_6ST_DIG] = { |
6530 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, | |
6531 | .init_verbs = { alc883_init_verbs }, | |
6532 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
6533 | .dac_nids = alc883_dac_nids, | |
6534 | .dig_out_nid = ALC883_DIGOUT_NID, | |
6535 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
6536 | .adc_nids = alc883_adc_nids, | |
6537 | .dig_in_nid = ALC883_DIGIN_NID, | |
6538 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | |
6539 | .channel_mode = alc883_sixstack_modes, | |
6540 | .input_mux = &alc883_capture_source, | |
6541 | }, | |
ccc656ce KY |
6542 | [ALC883_TARGA_DIG] = { |
6543 | .mixers = { alc883_tagra_mixer, alc883_chmode_mixer }, | |
6544 | .init_verbs = { alc883_init_verbs, alc883_tagra_verbs}, | |
6545 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
6546 | .dac_nids = alc883_dac_nids, | |
6547 | .dig_out_nid = ALC883_DIGOUT_NID, | |
6548 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
6549 | .adc_nids = alc883_adc_nids, | |
6550 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
6551 | .channel_mode = alc883_3ST_6ch_modes, | |
6552 | .need_dac_fix = 1, | |
6553 | .input_mux = &alc883_capture_source, | |
6554 | .unsol_event = alc883_tagra_unsol_event, | |
6555 | .init_hook = alc883_tagra_automute, | |
6556 | }, | |
6557 | [ALC883_TARGA_2ch_DIG] = { | |
6558 | .mixers = { alc883_tagra_2ch_mixer}, | |
6559 | .init_verbs = { alc883_init_verbs, alc883_tagra_verbs}, | |
6560 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
6561 | .dac_nids = alc883_dac_nids, | |
6562 | .dig_out_nid = ALC883_DIGOUT_NID, | |
6563 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
6564 | .adc_nids = alc883_adc_nids, | |
6565 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
6566 | .channel_mode = alc883_3ST_2ch_modes, | |
6567 | .input_mux = &alc883_capture_source, | |
6568 | .unsol_event = alc883_tagra_unsol_event, | |
6569 | .init_hook = alc883_tagra_automute, | |
6570 | }, | |
bab282b9 VA |
6571 | [ALC883_ACER] = { |
6572 | .mixers = { alc883_base_mixer, | |
6573 | alc883_chmode_mixer }, | |
6574 | /* On TravelMate laptops, GPIO 0 enables the internal speaker | |
6575 | * and the headphone jack. Turn this on and rely on the | |
6576 | * standard mute methods whenever the user wants to turn | |
6577 | * these outputs off. | |
6578 | */ | |
6579 | .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs }, | |
6580 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
6581 | .dac_nids = alc883_dac_nids, | |
6582 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
6583 | .adc_nids = alc883_adc_nids, | |
6584 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
6585 | .channel_mode = alc883_3ST_2ch_modes, | |
6586 | .input_mux = &alc883_capture_source, | |
6587 | }, | |
c07584c8 TD |
6588 | [ALC883_MEDION] = { |
6589 | .mixers = { alc883_fivestack_mixer, | |
6590 | alc883_chmode_mixer }, | |
6591 | .init_verbs = { alc883_init_verbs, | |
b373bdeb | 6592 | alc883_medion_eapd_verbs }, |
c07584c8 TD |
6593 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
6594 | .dac_nids = alc883_dac_nids, | |
6595 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
6596 | .adc_nids = alc883_adc_nids, | |
6597 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | |
6598 | .channel_mode = alc883_sixstack_modes, | |
6599 | .input_mux = &alc883_capture_source, | |
b373bdeb | 6600 | }, |
272a527c KY |
6601 | [ALC883_MEDION_MD2] = { |
6602 | .mixers = { alc883_medion_md2_mixer}, | |
6603 | .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs}, | |
6604 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
6605 | .dac_nids = alc883_dac_nids, | |
6606 | .dig_out_nid = ALC883_DIGOUT_NID, | |
6607 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
6608 | .adc_nids = alc883_adc_nids, | |
6609 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
6610 | .channel_mode = alc883_3ST_2ch_modes, | |
6611 | .input_mux = &alc883_capture_source, | |
6612 | .unsol_event = alc883_medion_md2_unsol_event, | |
6613 | .init_hook = alc883_medion_md2_automute, | |
6614 | }, | |
b373bdeb AN |
6615 | [ALC883_LAPTOP_EAPD] = { |
6616 | .mixers = { alc883_base_mixer, | |
6617 | alc883_chmode_mixer }, | |
6618 | .init_verbs = { alc883_init_verbs, alc882_eapd_verbs }, | |
6619 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
6620 | .dac_nids = alc883_dac_nids, | |
6621 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
6622 | .adc_nids = alc883_adc_nids, | |
6623 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
6624 | .channel_mode = alc883_3ST_2ch_modes, | |
6625 | .input_mux = &alc883_capture_source, | |
6626 | }, | |
bc9f98a9 KY |
6627 | [ALC883_LENOVO_101E_2ch] = { |
6628 | .mixers = { alc883_lenovo_101e_2ch_mixer}, | |
6629 | .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs}, | |
6630 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
6631 | .dac_nids = alc883_dac_nids, | |
6632 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
6633 | .adc_nids = alc883_adc_nids, | |
6634 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
6635 | .channel_mode = alc883_3ST_2ch_modes, | |
6636 | .input_mux = &alc883_lenovo_101e_capture_source, | |
6637 | .unsol_event = alc883_lenovo_101e_unsol_event, | |
6638 | .init_hook = alc883_lenovo_101e_all_automute, | |
6639 | }, | |
272a527c KY |
6640 | [ALC883_LENOVO_NB0763] = { |
6641 | .mixers = { alc883_lenovo_nb0763_mixer }, | |
6642 | .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs}, | |
6643 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
6644 | .dac_nids = alc883_dac_nids, | |
6645 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
6646 | .adc_nids = alc883_adc_nids, | |
6647 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
6648 | .channel_mode = alc883_3ST_2ch_modes, | |
6649 | .need_dac_fix = 1, | |
6650 | .input_mux = &alc883_lenovo_nb0763_capture_source, | |
6651 | .unsol_event = alc883_medion_md2_unsol_event, | |
6652 | .init_hook = alc883_medion_md2_automute, | |
6653 | }, | |
6654 | [ALC888_LENOVO_MS7195_DIG] = { | |
6655 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
6656 | .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs}, | |
6657 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
6658 | .dac_nids = alc883_dac_nids, | |
6659 | .dig_out_nid = ALC883_DIGOUT_NID, | |
6660 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
6661 | .adc_nids = alc883_adc_nids, | |
6662 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
6663 | .channel_mode = alc883_3ST_6ch_modes, | |
6664 | .need_dac_fix = 1, | |
6665 | .input_mux = &alc883_capture_source, | |
6666 | .unsol_event = alc883_lenovo_ms7195_unsol_event, | |
6667 | .init_hook = alc888_lenovo_ms7195_front_automute, | |
6668 | }, | |
cd1e3b40 CM |
6669 | [ALC888_HP_NETTLE] = { |
6670 | .mixers = { alc888_hp_nettle_mixer, alc883_chmode_mixer }, | |
6671 | .init_verbs = { alc883_init_verbs, alc888_hp_nettle_verbs }, | |
6672 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
6673 | .dac_nids = alc883_dac_nids, | |
6674 | .dig_out_nid = ALC883_DIGOUT_NID, | |
6675 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
6676 | .adc_nids = alc883_adc_nids, | |
6677 | .dig_in_nid = ALC883_DIGIN_NID, | |
6678 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | |
6679 | .channel_mode = alc883_sixstack_modes, | |
6680 | .input_mux = &alc883_capture_source, | |
6681 | }, | |
9c7f852e TI |
6682 | }; |
6683 | ||
6684 | ||
6685 | /* | |
6686 | * BIOS auto configuration | |
6687 | */ | |
6688 | static void alc883_auto_set_output_and_unmute(struct hda_codec *codec, | |
6689 | hda_nid_t nid, int pin_type, | |
6690 | int dac_idx) | |
6691 | { | |
6692 | /* set as output */ | |
6693 | struct alc_spec *spec = codec->spec; | |
f12ab1e0 TI |
6694 | int idx; |
6695 | ||
9c7f852e TI |
6696 | if (spec->multiout.dac_nids[dac_idx] == 0x25) |
6697 | idx = 4; | |
6698 | else | |
6699 | idx = spec->multiout.dac_nids[dac_idx] - 2; | |
6700 | ||
6701 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
6702 | pin_type); | |
6703 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
6704 | AMP_OUT_UNMUTE); | |
6705 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); | |
6706 | ||
6707 | } | |
6708 | ||
6709 | static void alc883_auto_init_multi_out(struct hda_codec *codec) | |
6710 | { | |
6711 | struct alc_spec *spec = codec->spec; | |
6712 | int i; | |
6713 | ||
bc9f98a9 | 6714 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
9c7f852e | 6715 | for (i = 0; i <= HDA_SIDE; i++) { |
f12ab1e0 | 6716 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
baba8ee9 | 6717 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
9c7f852e | 6718 | if (nid) |
baba8ee9 | 6719 | alc883_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 6720 | i); |
9c7f852e TI |
6721 | } |
6722 | } | |
6723 | ||
6724 | static void alc883_auto_init_hp_out(struct hda_codec *codec) | |
6725 | { | |
6726 | struct alc_spec *spec = codec->spec; | |
6727 | hda_nid_t pin; | |
6728 | ||
eb06ed8f | 6729 | pin = spec->autocfg.hp_pins[0]; |
9c7f852e TI |
6730 | if (pin) /* connect to front */ |
6731 | /* use dac 0 */ | |
6732 | alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
6733 | } | |
6734 | ||
6735 | #define alc883_is_input_pin(nid) alc880_is_input_pin(nid) | |
6736 | #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID | |
6737 | ||
6738 | static void alc883_auto_init_analog_input(struct hda_codec *codec) | |
6739 | { | |
6740 | struct alc_spec *spec = codec->spec; | |
6741 | int i; | |
6742 | ||
6743 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
6744 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
6745 | if (alc883_is_input_pin(nid)) { | |
6746 | snd_hda_codec_write(codec, nid, 0, | |
6747 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
6748 | (i <= AUTO_PIN_FRONT_MIC ? | |
6749 | PIN_VREF80 : PIN_IN)); | |
6750 | if (nid != ALC883_PIN_CD_NID) | |
6751 | snd_hda_codec_write(codec, nid, 0, | |
6752 | AC_VERB_SET_AMP_GAIN_MUTE, | |
6753 | AMP_OUT_MUTE); | |
6754 | } | |
6755 | } | |
6756 | } | |
6757 | ||
6758 | /* almost identical with ALC880 parser... */ | |
6759 | static int alc883_parse_auto_config(struct hda_codec *codec) | |
6760 | { | |
6761 | struct alc_spec *spec = codec->spec; | |
6762 | int err = alc880_parse_auto_config(codec); | |
6763 | ||
6764 | if (err < 0) | |
6765 | return err; | |
6766 | else if (err > 0) | |
6767 | /* hack - override the init verbs */ | |
6768 | spec->init_verbs[0] = alc883_auto_init_verbs; | |
bc9f98a9 KY |
6769 | spec->mixers[spec->num_mixers] = alc883_capture_mixer; |
6770 | spec->num_mixers++; | |
9c7f852e TI |
6771 | return err; |
6772 | } | |
6773 | ||
6774 | /* additional initialization for auto-configuration model */ | |
6775 | static void alc883_auto_init(struct hda_codec *codec) | |
6776 | { | |
6777 | alc883_auto_init_multi_out(codec); | |
6778 | alc883_auto_init_hp_out(codec); | |
6779 | alc883_auto_init_analog_input(codec); | |
6780 | } | |
6781 | ||
6782 | static int patch_alc883(struct hda_codec *codec) | |
6783 | { | |
6784 | struct alc_spec *spec; | |
6785 | int err, board_config; | |
6786 | ||
6787 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
6788 | if (spec == NULL) | |
6789 | return -ENOMEM; | |
6790 | ||
6791 | codec->spec = spec; | |
6792 | ||
f5fcc13c TI |
6793 | board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST, |
6794 | alc883_models, | |
6795 | alc883_cfg_tbl); | |
6796 | if (board_config < 0) { | |
9c7f852e TI |
6797 | printk(KERN_INFO "hda_codec: Unknown model for ALC883, " |
6798 | "trying auto-probe from BIOS...\n"); | |
6799 | board_config = ALC883_AUTO; | |
6800 | } | |
6801 | ||
6802 | if (board_config == ALC883_AUTO) { | |
6803 | /* automatic parse from the BIOS config */ | |
6804 | err = alc883_parse_auto_config(codec); | |
6805 | if (err < 0) { | |
6806 | alc_free(codec); | |
6807 | return err; | |
f12ab1e0 | 6808 | } else if (!err) { |
9c7f852e TI |
6809 | printk(KERN_INFO |
6810 | "hda_codec: Cannot set up configuration " | |
6811 | "from BIOS. Using base mode...\n"); | |
6812 | board_config = ALC883_3ST_2ch_DIG; | |
6813 | } | |
6814 | } | |
6815 | ||
6816 | if (board_config != ALC883_AUTO) | |
6817 | setup_preset(spec, &alc883_presets[board_config]); | |
6818 | ||
6819 | spec->stream_name_analog = "ALC883 Analog"; | |
6820 | spec->stream_analog_playback = &alc883_pcm_analog_playback; | |
6821 | spec->stream_analog_capture = &alc883_pcm_analog_capture; | |
6822 | ||
6823 | spec->stream_name_digital = "ALC883 Digital"; | |
6824 | spec->stream_digital_playback = &alc883_pcm_digital_playback; | |
6825 | spec->stream_digital_capture = &alc883_pcm_digital_capture; | |
6826 | ||
f12ab1e0 | 6827 | if (!spec->adc_nids && spec->input_mux) { |
4b146cb0 TI |
6828 | spec->adc_nids = alc883_adc_nids; |
6829 | spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); | |
6830 | } | |
9c7f852e TI |
6831 | |
6832 | codec->patch_ops = alc_patch_ops; | |
6833 | if (board_config == ALC883_AUTO) | |
6834 | spec->init_hook = alc883_auto_init; | |
6835 | ||
6836 | return 0; | |
6837 | } | |
6838 | ||
6839 | /* | |
6840 | * ALC262 support | |
6841 | */ | |
6842 | ||
6843 | #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID | |
6844 | #define ALC262_DIGIN_NID ALC880_DIGIN_NID | |
6845 | ||
6846 | #define alc262_dac_nids alc260_dac_nids | |
6847 | #define alc262_adc_nids alc882_adc_nids | |
6848 | #define alc262_adc_nids_alt alc882_adc_nids_alt | |
6849 | ||
6850 | #define alc262_modes alc260_modes | |
6851 | #define alc262_capture_source alc882_capture_source | |
6852 | ||
6853 | static struct snd_kcontrol_new alc262_base_mixer[] = { | |
6854 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6855 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
6856 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6857 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6858 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6859 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6860 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6861 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 6862 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
6863 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
6864 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 6865 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
6866 | /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), |
6867 | HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */ | |
6868 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT), | |
6869 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
6870 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
6871 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | |
6872 | { } /* end */ | |
6873 | }; | |
6874 | ||
ccc656ce KY |
6875 | static struct snd_kcontrol_new alc262_hippo1_mixer[] = { |
6876 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6877 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
6878 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6879 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6880 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6881 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6882 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6883 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 6884 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce KY |
6885 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
6886 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 6887 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
ccc656ce KY |
6888 | /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), |
6889 | HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */ | |
6890 | /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/ | |
6891 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6892 | { } /* end */ | |
6893 | }; | |
6894 | ||
9c7f852e TI |
6895 | static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = { |
6896 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6897 | HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
6898 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6899 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
6900 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | |
6901 | ||
6902 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6903 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 6904 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
6905 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
6906 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 6907 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
6908 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
6909 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6910 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6911 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6912 | HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
6913 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
6914 | HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT), | |
6915 | HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT), | |
6916 | { } /* end */ | |
6917 | }; | |
6918 | ||
cd7509a4 KY |
6919 | static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = { |
6920 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6921 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6922 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
6923 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
6924 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
6925 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | |
6926 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6927 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
cc69d12d | 6928 | HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT), |
cd7509a4 KY |
6929 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), |
6930 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
6931 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6932 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6933 | HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
6934 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
6935 | { } /* end */ | |
6936 | }; | |
6937 | ||
6938 | static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = { | |
6939 | HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6940 | HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 6941 | HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT), |
cd7509a4 KY |
6942 | { } /* end */ |
6943 | }; | |
6944 | ||
272a527c KY |
6945 | static struct snd_kcontrol_new alc262_sony_mixer[] = { |
6946 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6947 | HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
6948 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6949 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
6950 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
6951 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
6952 | { } /* end */ | |
6953 | }; | |
6954 | ||
83c34218 KY |
6955 | static struct snd_kcontrol_new alc262_benq_t31_mixer[] = { |
6956 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6957 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
6958 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
6959 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6960 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
6961 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
6962 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
6963 | { } /* end */ | |
6964 | }; | |
272a527c | 6965 | |
9c7f852e TI |
6966 | #define alc262_capture_mixer alc882_capture_mixer |
6967 | #define alc262_capture_alt_mixer alc882_capture_alt_mixer | |
6968 | ||
6969 | /* | |
6970 | * generic initialization of ADC, input mixers and output mixers | |
6971 | */ | |
6972 | static struct hda_verb alc262_init_verbs[] = { | |
6973 | /* | |
6974 | * Unmute ADC0-2 and set the default input to mic-in | |
6975 | */ | |
6976 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6977 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6978 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6979 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6980 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6981 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6982 | ||
6983 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | |
6984 | * mixer widget | |
f12ab1e0 TI |
6985 | * Note: PASD motherboards uses the Line In 2 as the input for |
6986 | * front panel mic (mic 2) | |
9c7f852e TI |
6987 | */ |
6988 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
6989 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6990 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6991 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
6992 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
6993 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
6994 | ||
6995 | /* | |
df694daa KY |
6996 | * Set up output mixers (0x0c - 0x0e) |
6997 | */ | |
6998 | /* set vol=0 to output mixers */ | |
6999 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7000 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7001 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7002 | /* set up input amps for analog loopback */ | |
7003 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
7004 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7005 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7006 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7007 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7008 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7009 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7010 | ||
7011 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
7012 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
7013 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
7014 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
7015 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
7016 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
7017 | ||
7018 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
7019 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
7020 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
7021 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
7022 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
7023 | ||
7024 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7025 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
7026 | ||
7027 | /* FIXME: use matrix-type input source selection */ | |
7028 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
7029 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
7030 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
7031 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
7032 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
7033 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
7034 | /* Input mixer2 */ | |
7035 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
7036 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
7037 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
7038 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
7039 | /* Input mixer3 */ | |
7040 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
7041 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
7042 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
f12ab1e0 | 7043 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
df694daa KY |
7044 | |
7045 | { } | |
7046 | }; | |
1da177e4 | 7047 | |
ccc656ce KY |
7048 | static struct hda_verb alc262_hippo_unsol_verbs[] = { |
7049 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
7050 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7051 | {} | |
7052 | }; | |
7053 | ||
7054 | static struct hda_verb alc262_hippo1_unsol_verbs[] = { | |
7055 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
7056 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7057 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
7058 | ||
7059 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
7060 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7061 | {} | |
7062 | }; | |
7063 | ||
272a527c KY |
7064 | static struct hda_verb alc262_sony_unsol_verbs[] = { |
7065 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
7066 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7067 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic | |
7068 | ||
7069 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
7070 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7071 | }; | |
7072 | ||
ccc656ce KY |
7073 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
7074 | static void alc262_hippo_automute(struct hda_codec *codec, int force) | |
7075 | { | |
7076 | struct alc_spec *spec = codec->spec; | |
7077 | unsigned int mute; | |
7078 | ||
f12ab1e0 | 7079 | if (force || !spec->sense_updated) { |
ccc656ce KY |
7080 | unsigned int present; |
7081 | /* need to execute and sync at first */ | |
7082 | snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); | |
7083 | present = snd_hda_codec_read(codec, 0x15, 0, | |
7084 | AC_VERB_GET_PIN_SENSE, 0); | |
7085 | spec->jack_present = (present & 0x80000000) != 0; | |
7086 | spec->sense_updated = 1; | |
7087 | } | |
7088 | if (spec->jack_present) { | |
7089 | /* mute internal speaker */ | |
7090 | snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, | |
7091 | 0x80, 0x80); | |
7092 | snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, | |
7093 | 0x80, 0x80); | |
7094 | } else { | |
7095 | /* unmute internal speaker if necessary */ | |
7096 | mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0); | |
7097 | snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, | |
7098 | 0x80, mute & 0x80); | |
7099 | mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0); | |
7100 | snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, | |
7101 | 0x80, mute & 0x80); | |
7102 | } | |
7103 | } | |
7104 | ||
7105 | /* unsolicited event for HP jack sensing */ | |
7106 | static void alc262_hippo_unsol_event(struct hda_codec *codec, | |
7107 | unsigned int res) | |
7108 | { | |
7109 | if ((res >> 26) != ALC880_HP_EVENT) | |
7110 | return; | |
7111 | alc262_hippo_automute(codec, 1); | |
7112 | } | |
7113 | ||
7114 | static void alc262_hippo1_automute(struct hda_codec *codec, int force) | |
7115 | { | |
7116 | struct alc_spec *spec = codec->spec; | |
7117 | unsigned int mute; | |
7118 | ||
f12ab1e0 | 7119 | if (force || !spec->sense_updated) { |
ccc656ce KY |
7120 | unsigned int present; |
7121 | /* need to execute and sync at first */ | |
7122 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); | |
7123 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
7124 | AC_VERB_GET_PIN_SENSE, 0); | |
7125 | spec->jack_present = (present & 0x80000000) != 0; | |
7126 | spec->sense_updated = 1; | |
7127 | } | |
7128 | if (spec->jack_present) { | |
7129 | /* mute internal speaker */ | |
7130 | snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, | |
7131 | 0x80, 0x80); | |
7132 | snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, | |
7133 | 0x80, 0x80); | |
7134 | } else { | |
7135 | /* unmute internal speaker if necessary */ | |
7136 | mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); | |
7137 | snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, | |
7138 | 0x80, mute & 0x80); | |
7139 | mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0); | |
7140 | snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, | |
7141 | 0x80, mute & 0x80); | |
7142 | } | |
7143 | } | |
7144 | ||
7145 | /* unsolicited event for HP jack sensing */ | |
7146 | static void alc262_hippo1_unsol_event(struct hda_codec *codec, | |
7147 | unsigned int res) | |
7148 | { | |
7149 | if ((res >> 26) != ALC880_HP_EVENT) | |
7150 | return; | |
7151 | alc262_hippo1_automute(codec, 1); | |
7152 | } | |
7153 | ||
834be88d TI |
7154 | /* |
7155 | * fujitsu model | |
7156 | * 0x14 = headphone/spdif-out, 0x15 = internal speaker | |
7157 | */ | |
7158 | ||
7159 | #define ALC_HP_EVENT 0x37 | |
7160 | ||
7161 | static struct hda_verb alc262_fujitsu_unsol_verbs[] = { | |
7162 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, | |
7163 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7164 | {} | |
7165 | }; | |
7166 | ||
7167 | static struct hda_input_mux alc262_fujitsu_capture_source = { | |
7168 | .num_items = 2, | |
7169 | .items = { | |
7170 | { "Mic", 0x0 }, | |
7171 | { "CD", 0x4 }, | |
7172 | }, | |
7173 | }; | |
7174 | ||
9c7f852e TI |
7175 | static struct hda_input_mux alc262_HP_capture_source = { |
7176 | .num_items = 5, | |
7177 | .items = { | |
7178 | { "Mic", 0x0 }, | |
7179 | { "Front Mic", 0x3 }, | |
7180 | { "Line", 0x2 }, | |
7181 | { "CD", 0x4 }, | |
7182 | { "AUX IN", 0x6 }, | |
7183 | }, | |
7184 | }; | |
7185 | ||
834be88d TI |
7186 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
7187 | static void alc262_fujitsu_automute(struct hda_codec *codec, int force) | |
7188 | { | |
7189 | struct alc_spec *spec = codec->spec; | |
7190 | unsigned int mute; | |
7191 | ||
f12ab1e0 | 7192 | if (force || !spec->sense_updated) { |
834be88d TI |
7193 | unsigned int present; |
7194 | /* need to execute and sync at first */ | |
7195 | snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); | |
7196 | present = snd_hda_codec_read(codec, 0x14, 0, | |
7197 | AC_VERB_GET_PIN_SENSE, 0); | |
7198 | spec->jack_present = (present & 0x80000000) != 0; | |
7199 | spec->sense_updated = 1; | |
7200 | } | |
7201 | if (spec->jack_present) { | |
7202 | /* mute internal speaker */ | |
7203 | snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, | |
7204 | 0x80, 0x80); | |
7205 | snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, | |
7206 | 0x80, 0x80); | |
7207 | } else { | |
7208 | /* unmute internal speaker if necessary */ | |
7209 | mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); | |
7210 | snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, | |
7211 | 0x80, mute & 0x80); | |
7212 | mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0); | |
7213 | snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, | |
7214 | 0x80, mute & 0x80); | |
7215 | } | |
7216 | } | |
7217 | ||
7218 | /* unsolicited event for HP jack sensing */ | |
7219 | static void alc262_fujitsu_unsol_event(struct hda_codec *codec, | |
7220 | unsigned int res) | |
7221 | { | |
7222 | if ((res >> 26) != ALC_HP_EVENT) | |
7223 | return; | |
7224 | alc262_fujitsu_automute(codec, 1); | |
7225 | } | |
7226 | ||
7227 | /* bind volumes of both NID 0x0c and 0x0d */ | |
7228 | static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol, | |
7229 | struct snd_ctl_elem_value *ucontrol) | |
7230 | { | |
7231 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
7232 | long *valp = ucontrol->value.integer.value; | |
7233 | int change; | |
7234 | ||
7235 | change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0, | |
7236 | 0x7f, valp[0] & 0x7f); | |
7237 | change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0, | |
7238 | 0x7f, valp[1] & 0x7f); | |
7239 | snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0, | |
7240 | 0x7f, valp[0] & 0x7f); | |
7241 | snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0, | |
7242 | 0x7f, valp[1] & 0x7f); | |
7243 | return change; | |
7244 | } | |
7245 | ||
7246 | /* bind hp and internal speaker mute (with plug check) */ | |
7247 | static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol, | |
7248 | struct snd_ctl_elem_value *ucontrol) | |
7249 | { | |
7250 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
7251 | long *valp = ucontrol->value.integer.value; | |
7252 | int change; | |
7253 | ||
7254 | change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, | |
7255 | 0x80, valp[0] ? 0 : 0x80); | |
7256 | change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, | |
7257 | 0x80, valp[1] ? 0 : 0x80); | |
7258 | if (change || codec->in_resume) | |
7259 | alc262_fujitsu_automute(codec, codec->in_resume); | |
7260 | return change; | |
7261 | } | |
7262 | ||
7263 | static struct snd_kcontrol_new alc262_fujitsu_mixer[] = { | |
7264 | { | |
7265 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7266 | .name = "Master Playback Volume", | |
7267 | .info = snd_hda_mixer_amp_volume_info, | |
7268 | .get = snd_hda_mixer_amp_volume_get, | |
7269 | .put = alc262_fujitsu_master_vol_put, | |
c2566524 | 7270 | .tlv = { .c = snd_hda_mixer_amp_tlv }, |
834be88d TI |
7271 | .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT), |
7272 | }, | |
7273 | { | |
7274 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7275 | .name = "Master Playback Switch", | |
7276 | .info = snd_hda_mixer_amp_switch_info, | |
7277 | .get = snd_hda_mixer_amp_switch_get, | |
7278 | .put = alc262_fujitsu_master_sw_put, | |
7279 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
7280 | }, | |
7281 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7282 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7283 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7284 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7285 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7286 | { } /* end */ | |
7287 | }; | |
7288 | ||
304dcaac TI |
7289 | /* additional init verbs for Benq laptops */ |
7290 | static struct hda_verb alc262_EAPD_verbs[] = { | |
7291 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
7292 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
7293 | {} | |
7294 | }; | |
7295 | ||
83c34218 KY |
7296 | static struct hda_verb alc262_benq_t31_EAPD_verbs[] = { |
7297 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7298 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
7299 | ||
7300 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
7301 | {0x20, AC_VERB_SET_PROC_COEF, 0x3050}, | |
7302 | {} | |
7303 | }; | |
7304 | ||
df694daa | 7305 | /* add playback controls from the parsed DAC table */ |
f12ab1e0 TI |
7306 | static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, |
7307 | const struct auto_pin_cfg *cfg) | |
df694daa KY |
7308 | { |
7309 | hda_nid_t nid; | |
7310 | int err; | |
7311 | ||
7312 | spec->multiout.num_dacs = 1; /* only use one dac */ | |
7313 | spec->multiout.dac_nids = spec->private_dac_nids; | |
7314 | spec->multiout.dac_nids[0] = 2; | |
7315 | ||
7316 | nid = cfg->line_out_pins[0]; | |
7317 | if (nid) { | |
f12ab1e0 TI |
7318 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
7319 | "Front Playback Volume", | |
7320 | HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT)); | |
7321 | if (err < 0) | |
df694daa | 7322 | return err; |
f12ab1e0 TI |
7323 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
7324 | "Front Playback Switch", | |
7325 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
7326 | if (err < 0) | |
df694daa KY |
7327 | return err; |
7328 | } | |
7329 | ||
82bc955f | 7330 | nid = cfg->speaker_pins[0]; |
df694daa KY |
7331 | if (nid) { |
7332 | if (nid == 0x16) { | |
f12ab1e0 TI |
7333 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
7334 | "Speaker Playback Volume", | |
7335 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, | |
7336 | HDA_OUTPUT)); | |
7337 | if (err < 0) | |
df694daa | 7338 | return err; |
f12ab1e0 TI |
7339 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
7340 | "Speaker Playback Switch", | |
7341 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
7342 | HDA_OUTPUT)); | |
7343 | if (err < 0) | |
df694daa KY |
7344 | return err; |
7345 | } else { | |
f12ab1e0 TI |
7346 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
7347 | "Speaker Playback Switch", | |
7348 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
7349 | HDA_OUTPUT)); | |
7350 | if (err < 0) | |
df694daa KY |
7351 | return err; |
7352 | } | |
7353 | } | |
eb06ed8f | 7354 | nid = cfg->hp_pins[0]; |
df694daa KY |
7355 | if (nid) { |
7356 | /* spec->multiout.hp_nid = 2; */ | |
7357 | if (nid == 0x16) { | |
f12ab1e0 TI |
7358 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
7359 | "Headphone Playback Volume", | |
7360 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, | |
7361 | HDA_OUTPUT)); | |
7362 | if (err < 0) | |
df694daa | 7363 | return err; |
f12ab1e0 TI |
7364 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
7365 | "Headphone Playback Switch", | |
7366 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
7367 | HDA_OUTPUT)); | |
7368 | if (err < 0) | |
df694daa KY |
7369 | return err; |
7370 | } else { | |
f12ab1e0 TI |
7371 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
7372 | "Headphone Playback Switch", | |
7373 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
7374 | HDA_OUTPUT)); | |
7375 | if (err < 0) | |
df694daa KY |
7376 | return err; |
7377 | } | |
7378 | } | |
f12ab1e0 | 7379 | return 0; |
df694daa KY |
7380 | } |
7381 | ||
7382 | /* identical with ALC880 */ | |
f12ab1e0 TI |
7383 | #define alc262_auto_create_analog_input_ctls \ |
7384 | alc880_auto_create_analog_input_ctls | |
df694daa KY |
7385 | |
7386 | /* | |
7387 | * generic initialization of ADC, input mixers and output mixers | |
7388 | */ | |
7389 | static struct hda_verb alc262_volume_init_verbs[] = { | |
7390 | /* | |
7391 | * Unmute ADC0-2 and set the default input to mic-in | |
7392 | */ | |
7393 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7394 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7395 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7396 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7397 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7398 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7399 | ||
7400 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | |
7401 | * mixer widget | |
f12ab1e0 TI |
7402 | * Note: PASD motherboards uses the Line In 2 as the input for |
7403 | * front panel mic (mic 2) | |
df694daa KY |
7404 | */ |
7405 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
7406 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7407 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7408 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
7409 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
7410 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
7411 | ||
7412 | /* | |
7413 | * Set up output mixers (0x0c - 0x0f) | |
7414 | */ | |
7415 | /* set vol=0 to output mixers */ | |
7416 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7417 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7418 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7419 | ||
7420 | /* set up input amps for analog loopback */ | |
7421 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
7422 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7423 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7424 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7425 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7426 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7427 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7428 | ||
7429 | /* FIXME: use matrix-type input source selection */ | |
7430 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
7431 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
7432 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
7433 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
7434 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
7435 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
7436 | /* Input mixer2 */ | |
7437 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
7438 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
7439 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
7440 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
7441 | /* Input mixer3 */ | |
7442 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
7443 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
7444 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
7445 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
7446 | ||
7447 | { } | |
7448 | }; | |
7449 | ||
9c7f852e TI |
7450 | static struct hda_verb alc262_HP_BPC_init_verbs[] = { |
7451 | /* | |
7452 | * Unmute ADC0-2 and set the default input to mic-in | |
7453 | */ | |
7454 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7455 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7456 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7457 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7458 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7459 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7460 | ||
7461 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | |
7462 | * mixer widget | |
f12ab1e0 TI |
7463 | * Note: PASD motherboards uses the Line In 2 as the input for |
7464 | * front panel mic (mic 2) | |
9c7f852e TI |
7465 | */ |
7466 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
7467 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7468 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7469 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
7470 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
7471 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
7472 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)}, | |
7473 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)}, | |
7474 | ||
7475 | /* | |
7476 | * Set up output mixers (0x0c - 0x0e) | |
7477 | */ | |
7478 | /* set vol=0 to output mixers */ | |
7479 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7480 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7481 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7482 | ||
7483 | /* set up input amps for analog loopback */ | |
7484 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
7485 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7486 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7487 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7488 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7489 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7490 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7491 | ||
7492 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
7493 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7494 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7495 | ||
7496 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7497 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7498 | ||
7499 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7500 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7501 | ||
7502 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
7503 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
7504 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
7505 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
7506 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
7507 | ||
7508 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
7509 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
7510 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
7511 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
7512 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
7513 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
7514 | ||
7515 | ||
7516 | /* FIXME: use matrix-type input source selection */ | |
7517 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
7518 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
7519 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
7520 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
7521 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
7522 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
7523 | /* Input mixer2 */ | |
7524 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
7525 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
7526 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
7527 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
7528 | /* Input mixer3 */ | |
7529 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
7530 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
7531 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
7532 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
7533 | ||
7534 | { } | |
7535 | }; | |
7536 | ||
cd7509a4 KY |
7537 | static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = { |
7538 | /* | |
7539 | * Unmute ADC0-2 and set the default input to mic-in | |
7540 | */ | |
7541 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7542 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7543 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7544 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7545 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7546 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7547 | ||
7548 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | |
7549 | * mixer widget | |
7550 | * Note: PASD motherboards uses the Line In 2 as the input for front | |
7551 | * panel mic (mic 2) | |
7552 | */ | |
7553 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
7554 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7555 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7556 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
7557 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
7558 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
7559 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)}, | |
7560 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)}, | |
7561 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)}, | |
7562 | /* | |
7563 | * Set up output mixers (0x0c - 0x0e) | |
7564 | */ | |
7565 | /* set vol=0 to output mixers */ | |
7566 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7567 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7568 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7569 | ||
7570 | /* set up input amps for analog loopback */ | |
7571 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
7572 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7573 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7574 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7575 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7576 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7577 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7578 | ||
7579 | ||
7580 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */ | |
7581 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */ | |
7582 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */ | |
7583 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */ | |
7584 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */ | |
7585 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */ | |
7586 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */ | |
7587 | ||
7588 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7589 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7590 | ||
7591 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7592 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
7593 | ||
7594 | /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */ | |
7595 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
7596 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
7597 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
7598 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
7599 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
7600 | ||
7601 | /* FIXME: use matrix-type input source selection */ | |
7602 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
7603 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
7604 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/ | |
7605 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/ | |
7606 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/ | |
7607 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/ | |
7608 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/ | |
7609 | /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
7610 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/ | |
7611 | /* Input mixer2 */ | |
7612 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
7613 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
7614 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
7615 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
7616 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
7617 | /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
7618 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, | |
7619 | /* Input mixer3 */ | |
7620 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
7621 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
7622 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
7623 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
7624 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
7625 | /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
7626 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, | |
7627 | ||
7628 | { } | |
7629 | }; | |
7630 | ||
df694daa KY |
7631 | /* pcm configuration: identiacal with ALC880 */ |
7632 | #define alc262_pcm_analog_playback alc880_pcm_analog_playback | |
7633 | #define alc262_pcm_analog_capture alc880_pcm_analog_capture | |
7634 | #define alc262_pcm_digital_playback alc880_pcm_digital_playback | |
7635 | #define alc262_pcm_digital_capture alc880_pcm_digital_capture | |
7636 | ||
7637 | /* | |
7638 | * BIOS auto configuration | |
7639 | */ | |
7640 | static int alc262_parse_auto_config(struct hda_codec *codec) | |
7641 | { | |
7642 | struct alc_spec *spec = codec->spec; | |
7643 | int err; | |
7644 | static hda_nid_t alc262_ignore[] = { 0x1d, 0 }; | |
7645 | ||
f12ab1e0 TI |
7646 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
7647 | alc262_ignore); | |
7648 | if (err < 0) | |
df694daa | 7649 | return err; |
f12ab1e0 | 7650 | if (!spec->autocfg.line_outs) |
df694daa | 7651 | return 0; /* can't find valid BIOS pin config */ |
f12ab1e0 TI |
7652 | err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg); |
7653 | if (err < 0) | |
7654 | return err; | |
7655 | err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
7656 | if (err < 0) | |
df694daa KY |
7657 | return err; |
7658 | ||
7659 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
7660 | ||
7661 | if (spec->autocfg.dig_out_pin) | |
7662 | spec->multiout.dig_out_nid = ALC262_DIGOUT_NID; | |
7663 | if (spec->autocfg.dig_in_pin) | |
7664 | spec->dig_in_nid = ALC262_DIGIN_NID; | |
7665 | ||
7666 | if (spec->kctl_alloc) | |
7667 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
7668 | ||
7669 | spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs; | |
a1e8d2da | 7670 | spec->num_mux_defs = 1; |
df694daa KY |
7671 | spec->input_mux = &spec->private_imux; |
7672 | ||
7673 | return 1; | |
7674 | } | |
7675 | ||
7676 | #define alc262_auto_init_multi_out alc882_auto_init_multi_out | |
7677 | #define alc262_auto_init_hp_out alc882_auto_init_hp_out | |
7678 | #define alc262_auto_init_analog_input alc882_auto_init_analog_input | |
7679 | ||
7680 | ||
7681 | /* init callback for auto-configuration model -- overriding the default init */ | |
ae6b813a | 7682 | static void alc262_auto_init(struct hda_codec *codec) |
df694daa | 7683 | { |
df694daa KY |
7684 | alc262_auto_init_multi_out(codec); |
7685 | alc262_auto_init_hp_out(codec); | |
7686 | alc262_auto_init_analog_input(codec); | |
df694daa KY |
7687 | } |
7688 | ||
7689 | /* | |
7690 | * configuration and preset | |
7691 | */ | |
f5fcc13c TI |
7692 | static const char *alc262_models[ALC262_MODEL_LAST] = { |
7693 | [ALC262_BASIC] = "basic", | |
7694 | [ALC262_HIPPO] = "hippo", | |
7695 | [ALC262_HIPPO_1] = "hippo_1", | |
7696 | [ALC262_FUJITSU] = "fujitsu", | |
7697 | [ALC262_HP_BPC] = "hp-bpc", | |
cd7509a4 | 7698 | [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000", |
f5fcc13c | 7699 | [ALC262_BENQ_ED8] = "benq", |
272a527c | 7700 | [ALC262_BENQ_ED8] = "sony-assamd", |
f5fcc13c TI |
7701 | [ALC262_AUTO] = "auto", |
7702 | }; | |
7703 | ||
7704 | static struct snd_pci_quirk alc262_cfg_tbl[] = { | |
7705 | SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO), | |
7706 | SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC), | |
7707 | SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC), | |
7d87de2d KY |
7708 | SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC), |
7709 | SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC), | |
f5fcc13c | 7710 | SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC), |
7d87de2d | 7711 | SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC), |
f5fcc13c | 7712 | SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC), |
7d87de2d | 7713 | SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC), |
cd7509a4 KY |
7714 | SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL), |
7715 | SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL), | |
7716 | SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL), | |
7717 | SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL), | |
7718 | SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF), | |
7719 | SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF), | |
7720 | SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF), | |
7721 | SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF), | |
f5fcc13c TI |
7722 | SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO), |
7723 | SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU), | |
7724 | SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1), | |
7725 | SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8), | |
83c34218 | 7726 | SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31), |
272a527c KY |
7727 | SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD), |
7728 | SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD), | |
7729 | SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD), | |
df694daa KY |
7730 | {} |
7731 | }; | |
7732 | ||
7733 | static struct alc_config_preset alc262_presets[] = { | |
7734 | [ALC262_BASIC] = { | |
7735 | .mixers = { alc262_base_mixer }, | |
7736 | .init_verbs = { alc262_init_verbs }, | |
7737 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
7738 | .dac_nids = alc262_dac_nids, | |
7739 | .hp_nid = 0x03, | |
7740 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
7741 | .channel_mode = alc262_modes, | |
a3bcba38 | 7742 | .input_mux = &alc262_capture_source, |
df694daa | 7743 | }, |
ccc656ce KY |
7744 | [ALC262_HIPPO] = { |
7745 | .mixers = { alc262_base_mixer }, | |
7746 | .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs}, | |
7747 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
7748 | .dac_nids = alc262_dac_nids, | |
7749 | .hp_nid = 0x03, | |
7750 | .dig_out_nid = ALC262_DIGOUT_NID, | |
7751 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
7752 | .channel_mode = alc262_modes, | |
7753 | .input_mux = &alc262_capture_source, | |
7754 | .unsol_event = alc262_hippo_unsol_event, | |
7755 | }, | |
7756 | [ALC262_HIPPO_1] = { | |
7757 | .mixers = { alc262_hippo1_mixer }, | |
7758 | .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs}, | |
7759 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
7760 | .dac_nids = alc262_dac_nids, | |
7761 | .hp_nid = 0x02, | |
7762 | .dig_out_nid = ALC262_DIGOUT_NID, | |
7763 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
7764 | .channel_mode = alc262_modes, | |
7765 | .input_mux = &alc262_capture_source, | |
7766 | .unsol_event = alc262_hippo1_unsol_event, | |
7767 | }, | |
834be88d TI |
7768 | [ALC262_FUJITSU] = { |
7769 | .mixers = { alc262_fujitsu_mixer }, | |
7770 | .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs }, | |
7771 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
7772 | .dac_nids = alc262_dac_nids, | |
7773 | .hp_nid = 0x03, | |
7774 | .dig_out_nid = ALC262_DIGOUT_NID, | |
7775 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
7776 | .channel_mode = alc262_modes, | |
7777 | .input_mux = &alc262_fujitsu_capture_source, | |
ae6b813a | 7778 | .unsol_event = alc262_fujitsu_unsol_event, |
834be88d | 7779 | }, |
9c7f852e TI |
7780 | [ALC262_HP_BPC] = { |
7781 | .mixers = { alc262_HP_BPC_mixer }, | |
7782 | .init_verbs = { alc262_HP_BPC_init_verbs }, | |
7783 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
7784 | .dac_nids = alc262_dac_nids, | |
7785 | .hp_nid = 0x03, | |
7786 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
7787 | .channel_mode = alc262_modes, | |
7788 | .input_mux = &alc262_HP_capture_source, | |
f12ab1e0 | 7789 | }, |
cd7509a4 KY |
7790 | [ALC262_HP_BPC_D7000_WF] = { |
7791 | .mixers = { alc262_HP_BPC_WildWest_mixer }, | |
7792 | .init_verbs = { alc262_HP_BPC_WildWest_init_verbs }, | |
7793 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
7794 | .dac_nids = alc262_dac_nids, | |
7795 | .hp_nid = 0x03, | |
7796 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
7797 | .channel_mode = alc262_modes, | |
7798 | .input_mux = &alc262_HP_capture_source, | |
f12ab1e0 | 7799 | }, |
cd7509a4 KY |
7800 | [ALC262_HP_BPC_D7000_WL] = { |
7801 | .mixers = { alc262_HP_BPC_WildWest_mixer, | |
7802 | alc262_HP_BPC_WildWest_option_mixer }, | |
7803 | .init_verbs = { alc262_HP_BPC_WildWest_init_verbs }, | |
7804 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
7805 | .dac_nids = alc262_dac_nids, | |
7806 | .hp_nid = 0x03, | |
7807 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
7808 | .channel_mode = alc262_modes, | |
7809 | .input_mux = &alc262_HP_capture_source, | |
f12ab1e0 | 7810 | }, |
304dcaac TI |
7811 | [ALC262_BENQ_ED8] = { |
7812 | .mixers = { alc262_base_mixer }, | |
7813 | .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs }, | |
7814 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
7815 | .dac_nids = alc262_dac_nids, | |
7816 | .hp_nid = 0x03, | |
7817 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
7818 | .channel_mode = alc262_modes, | |
7819 | .input_mux = &alc262_capture_source, | |
f12ab1e0 | 7820 | }, |
272a527c KY |
7821 | [ALC262_SONY_ASSAMD] = { |
7822 | .mixers = { alc262_sony_mixer }, | |
7823 | .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs}, | |
7824 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
7825 | .dac_nids = alc262_dac_nids, | |
7826 | .hp_nid = 0x02, | |
7827 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
7828 | .channel_mode = alc262_modes, | |
7829 | .input_mux = &alc262_capture_source, | |
7830 | .unsol_event = alc262_hippo_unsol_event, | |
83c34218 KY |
7831 | }, |
7832 | [ALC262_BENQ_T31] = { | |
7833 | .mixers = { alc262_benq_t31_mixer }, | |
7834 | .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs }, | |
7835 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
7836 | .dac_nids = alc262_dac_nids, | |
7837 | .hp_nid = 0x03, | |
7838 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
7839 | .channel_mode = alc262_modes, | |
7840 | .input_mux = &alc262_capture_source, | |
7841 | .unsol_event = alc262_hippo_unsol_event, | |
272a527c | 7842 | }, |
df694daa KY |
7843 | }; |
7844 | ||
7845 | static int patch_alc262(struct hda_codec *codec) | |
7846 | { | |
7847 | struct alc_spec *spec; | |
7848 | int board_config; | |
7849 | int err; | |
7850 | ||
dc041e0b | 7851 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
df694daa KY |
7852 | if (spec == NULL) |
7853 | return -ENOMEM; | |
7854 | ||
7855 | codec->spec = spec; | |
7856 | #if 0 | |
f12ab1e0 TI |
7857 | /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is |
7858 | * under-run | |
7859 | */ | |
df694daa KY |
7860 | { |
7861 | int tmp; | |
7862 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); | |
7863 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); | |
7864 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); | |
7865 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); | |
7866 | } | |
7867 | #endif | |
7868 | ||
f5fcc13c TI |
7869 | board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST, |
7870 | alc262_models, | |
7871 | alc262_cfg_tbl); | |
cd7509a4 | 7872 | |
f5fcc13c | 7873 | if (board_config < 0) { |
9c7f852e TI |
7874 | printk(KERN_INFO "hda_codec: Unknown model for ALC262, " |
7875 | "trying auto-probe from BIOS...\n"); | |
df694daa KY |
7876 | board_config = ALC262_AUTO; |
7877 | } | |
7878 | ||
7879 | if (board_config == ALC262_AUTO) { | |
7880 | /* automatic parse from the BIOS config */ | |
7881 | err = alc262_parse_auto_config(codec); | |
7882 | if (err < 0) { | |
7883 | alc_free(codec); | |
7884 | return err; | |
f12ab1e0 | 7885 | } else if (!err) { |
9c7f852e TI |
7886 | printk(KERN_INFO |
7887 | "hda_codec: Cannot set up configuration " | |
7888 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
7889 | board_config = ALC262_BASIC; |
7890 | } | |
7891 | } | |
7892 | ||
7893 | if (board_config != ALC262_AUTO) | |
7894 | setup_preset(spec, &alc262_presets[board_config]); | |
7895 | ||
7896 | spec->stream_name_analog = "ALC262 Analog"; | |
7897 | spec->stream_analog_playback = &alc262_pcm_analog_playback; | |
7898 | spec->stream_analog_capture = &alc262_pcm_analog_capture; | |
7899 | ||
7900 | spec->stream_name_digital = "ALC262 Digital"; | |
7901 | spec->stream_digital_playback = &alc262_pcm_digital_playback; | |
7902 | spec->stream_digital_capture = &alc262_pcm_digital_capture; | |
7903 | ||
f12ab1e0 | 7904 | if (!spec->adc_nids && spec->input_mux) { |
df694daa | 7905 | /* check whether NID 0x07 is valid */ |
4a471b7d TI |
7906 | unsigned int wcap = get_wcaps(codec, 0x07); |
7907 | ||
f12ab1e0 TI |
7908 | /* get type */ |
7909 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
df694daa KY |
7910 | if (wcap != AC_WID_AUD_IN) { |
7911 | spec->adc_nids = alc262_adc_nids_alt; | |
7912 | spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt); | |
f12ab1e0 TI |
7913 | spec->mixers[spec->num_mixers] = |
7914 | alc262_capture_alt_mixer; | |
df694daa KY |
7915 | spec->num_mixers++; |
7916 | } else { | |
7917 | spec->adc_nids = alc262_adc_nids; | |
7918 | spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids); | |
7919 | spec->mixers[spec->num_mixers] = alc262_capture_mixer; | |
7920 | spec->num_mixers++; | |
7921 | } | |
7922 | } | |
7923 | ||
7924 | codec->patch_ops = alc_patch_ops; | |
7925 | if (board_config == ALC262_AUTO) | |
ae6b813a | 7926 | spec->init_hook = alc262_auto_init; |
834be88d | 7927 | |
df694daa KY |
7928 | return 0; |
7929 | } | |
7930 | ||
a361d84b KY |
7931 | /* |
7932 | * ALC268 channel source setting (2 channel) | |
7933 | */ | |
7934 | #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID | |
7935 | #define alc268_modes alc260_modes | |
7936 | ||
7937 | static hda_nid_t alc268_dac_nids[2] = { | |
7938 | /* front, hp */ | |
7939 | 0x02, 0x03 | |
7940 | }; | |
7941 | ||
7942 | static hda_nid_t alc268_adc_nids[2] = { | |
7943 | /* ADC0-1 */ | |
7944 | 0x08, 0x07 | |
7945 | }; | |
7946 | ||
7947 | static hda_nid_t alc268_adc_nids_alt[1] = { | |
7948 | /* ADC0 */ | |
7949 | 0x08 | |
7950 | }; | |
7951 | ||
7952 | static struct snd_kcontrol_new alc268_base_mixer[] = { | |
7953 | /* output mixer control */ | |
7954 | HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT), | |
7955 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7956 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT), | |
7957 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
7958 | { } | |
7959 | }; | |
7960 | ||
7961 | /* | |
7962 | * generic initialization of ADC, input mixers and output mixers | |
7963 | */ | |
7964 | static struct hda_verb alc268_base_init_verbs[] = { | |
7965 | /* Unmute DAC0-1 and set vol = 0 */ | |
7966 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7967 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7968 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7969 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7970 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7971 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7972 | ||
7973 | /* | |
7974 | * Set up output mixers (0x0c - 0x0e) | |
7975 | */ | |
7976 | /* set vol=0 to output mixers */ | |
7977 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7978 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7979 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7980 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7981 | ||
7982 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7983 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7984 | ||
7985 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
7986 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
7987 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
7988 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
7989 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
7990 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
7991 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
7992 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
7993 | ||
7994 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
7995 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
7996 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
7997 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
7998 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
7999 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
8000 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
8001 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
8002 | ||
8003 | /* FIXME: use matrix-type input source selection */ | |
8004 | /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */ | |
8005 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
8006 | /* Input mixer2 */ | |
8007 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
8008 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
8009 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
8010 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
8011 | ||
8012 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
8013 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
8014 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
8015 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
8016 | { } | |
8017 | }; | |
8018 | ||
8019 | /* | |
8020 | * generic initialization of ADC, input mixers and output mixers | |
8021 | */ | |
8022 | static struct hda_verb alc268_volume_init_verbs[] = { | |
8023 | /* set output DAC */ | |
8024 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8025 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8026 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8027 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8028 | ||
8029 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
8030 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
8031 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
8032 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
8033 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
8034 | ||
8035 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8036 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8037 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8038 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8039 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8040 | ||
8041 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
8042 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
8043 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
8044 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
8045 | ||
8046 | /* set PCBEEP vol = 0 */ | |
8047 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))}, | |
8048 | ||
8049 | { } | |
8050 | }; | |
8051 | ||
8052 | #define alc268_mux_enum_info alc_mux_enum_info | |
8053 | #define alc268_mux_enum_get alc_mux_enum_get | |
8054 | ||
8055 | static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol, | |
8056 | struct snd_ctl_elem_value *ucontrol) | |
8057 | { | |
8058 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
8059 | struct alc_spec *spec = codec->spec; | |
8060 | const struct hda_input_mux *imux = spec->input_mux; | |
8061 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
8062 | static hda_nid_t capture_mixers[3] = { 0x23, 0x24 }; | |
8063 | hda_nid_t nid = capture_mixers[adc_idx]; | |
8064 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; | |
8065 | unsigned int i, idx; | |
8066 | ||
8067 | idx = ucontrol->value.enumerated.item[0]; | |
8068 | if (idx >= imux->num_items) | |
8069 | idx = imux->num_items - 1; | |
8070 | if (*cur_val == idx && !codec->in_resume) | |
8071 | return 0; | |
8072 | for (i = 0; i < imux->num_items; i++) { | |
8073 | unsigned int v = (i == idx) ? 0x7000 : 0x7080; | |
8074 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
8075 | v | (imux->items[i].index << 8)); | |
8076 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, | |
8077 | idx ); | |
8078 | } | |
8079 | *cur_val = idx; | |
8080 | return 1; | |
8081 | } | |
8082 | ||
8083 | static struct snd_kcontrol_new alc268_capture_alt_mixer[] = { | |
8084 | HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), | |
8085 | HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), | |
8086 | { | |
8087 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
8088 | /* The multiple "Capture Source" controls confuse alsamixer | |
8089 | * So call somewhat different.. | |
8090 | * FIXME: the controls appear in the "playback" view! | |
8091 | */ | |
8092 | /* .name = "Capture Source", */ | |
8093 | .name = "Input Source", | |
8094 | .count = 1, | |
8095 | .info = alc268_mux_enum_info, | |
8096 | .get = alc268_mux_enum_get, | |
8097 | .put = alc268_mux_enum_put, | |
8098 | }, | |
8099 | { } /* end */ | |
8100 | }; | |
8101 | ||
8102 | static struct snd_kcontrol_new alc268_capture_mixer[] = { | |
8103 | HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), | |
8104 | HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), | |
8105 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT), | |
8106 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT), | |
8107 | { | |
8108 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
8109 | /* The multiple "Capture Source" controls confuse alsamixer | |
8110 | * So call somewhat different.. | |
8111 | * FIXME: the controls appear in the "playback" view! | |
8112 | */ | |
8113 | /* .name = "Capture Source", */ | |
8114 | .name = "Input Source", | |
8115 | .count = 2, | |
8116 | .info = alc268_mux_enum_info, | |
8117 | .get = alc268_mux_enum_get, | |
8118 | .put = alc268_mux_enum_put, | |
8119 | }, | |
8120 | { } /* end */ | |
8121 | }; | |
8122 | ||
8123 | static struct hda_input_mux alc268_capture_source = { | |
8124 | .num_items = 4, | |
8125 | .items = { | |
8126 | { "Mic", 0x0 }, | |
8127 | { "Front Mic", 0x1 }, | |
8128 | { "Line", 0x2 }, | |
8129 | { "CD", 0x3 }, | |
8130 | }, | |
8131 | }; | |
8132 | ||
8133 | /* create input playback/capture controls for the given pin */ | |
8134 | static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid, | |
8135 | const char *ctlname, int idx) | |
8136 | { | |
8137 | char name[32]; | |
8138 | int err; | |
8139 | ||
8140 | sprintf(name, "%s Playback Volume", ctlname); | |
8141 | if (nid == 0x14) { | |
8142 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
8143 | HDA_COMPOSE_AMP_VAL(0x02, 3, idx, | |
8144 | HDA_OUTPUT)); | |
8145 | if (err < 0) | |
8146 | return err; | |
8147 | } else if (nid == 0x15) { | |
8148 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
8149 | HDA_COMPOSE_AMP_VAL(0x03, 3, idx, | |
8150 | HDA_OUTPUT)); | |
8151 | if (err < 0) | |
8152 | return err; | |
8153 | } else | |
8154 | return -1; | |
8155 | sprintf(name, "%s Playback Switch", ctlname); | |
8156 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | |
8157 | HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT)); | |
8158 | if (err < 0) | |
8159 | return err; | |
8160 | return 0; | |
8161 | } | |
8162 | ||
8163 | /* add playback controls from the parsed DAC table */ | |
8164 | static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec, | |
8165 | const struct auto_pin_cfg *cfg) | |
8166 | { | |
8167 | hda_nid_t nid; | |
8168 | int err; | |
8169 | ||
8170 | spec->multiout.num_dacs = 2; /* only use one dac */ | |
8171 | spec->multiout.dac_nids = spec->private_dac_nids; | |
8172 | spec->multiout.dac_nids[0] = 2; | |
8173 | spec->multiout.dac_nids[1] = 3; | |
8174 | ||
8175 | nid = cfg->line_out_pins[0]; | |
8176 | if (nid) | |
8177 | alc268_new_analog_output(spec, nid, "Front", 0); | |
8178 | ||
8179 | nid = cfg->speaker_pins[0]; | |
8180 | if (nid == 0x1d) { | |
8181 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
8182 | "Speaker Playback Volume", | |
8183 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | |
8184 | if (err < 0) | |
8185 | return err; | |
8186 | } | |
8187 | nid = cfg->hp_pins[0]; | |
8188 | if (nid) | |
8189 | alc268_new_analog_output(spec, nid, "Headphone", 0); | |
8190 | ||
8191 | nid = cfg->line_out_pins[1] | cfg->line_out_pins[2]; | |
8192 | if (nid == 0x16) { | |
8193 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
8194 | "Mono Playback Switch", | |
8195 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT)); | |
8196 | if (err < 0) | |
8197 | return err; | |
8198 | } | |
8199 | return 0; | |
8200 | } | |
8201 | ||
8202 | /* create playback/capture controls for input pins */ | |
8203 | static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec, | |
8204 | const struct auto_pin_cfg *cfg) | |
8205 | { | |
8206 | struct hda_input_mux *imux = &spec->private_imux; | |
8207 | int i, idx1; | |
8208 | ||
8209 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
8210 | switch(cfg->input_pins[i]) { | |
8211 | case 0x18: | |
8212 | idx1 = 0; /* Mic 1 */ | |
8213 | break; | |
8214 | case 0x19: | |
8215 | idx1 = 1; /* Mic 2 */ | |
8216 | break; | |
8217 | case 0x1a: | |
8218 | idx1 = 2; /* Line In */ | |
8219 | break; | |
8220 | case 0x1c: | |
8221 | idx1 = 3; /* CD */ | |
8222 | break; | |
8223 | default: | |
8224 | continue; | |
8225 | } | |
8226 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; | |
8227 | imux->items[imux->num_items].index = idx1; | |
8228 | imux->num_items++; | |
8229 | } | |
8230 | return 0; | |
8231 | } | |
8232 | ||
8233 | static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec) | |
8234 | { | |
8235 | struct alc_spec *spec = codec->spec; | |
8236 | hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0]; | |
8237 | hda_nid_t hp_nid = spec->autocfg.hp_pins[0]; | |
8238 | hda_nid_t line_nid = spec->autocfg.line_out_pins[0]; | |
8239 | unsigned int dac_vol1, dac_vol2; | |
8240 | ||
8241 | if (speaker_nid) { | |
8242 | snd_hda_codec_write(codec, speaker_nid, 0, | |
8243 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | |
8244 | snd_hda_codec_write(codec, 0x0f, 0, | |
8245 | AC_VERB_SET_AMP_GAIN_MUTE, | |
8246 | AMP_IN_UNMUTE(1)); | |
8247 | snd_hda_codec_write(codec, 0x10, 0, | |
8248 | AC_VERB_SET_AMP_GAIN_MUTE, | |
8249 | AMP_IN_UNMUTE(1)); | |
8250 | } else { | |
8251 | snd_hda_codec_write(codec, 0x0f, 0, | |
8252 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)); | |
8253 | snd_hda_codec_write(codec, 0x10, 0, | |
8254 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)); | |
8255 | } | |
8256 | ||
8257 | dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */ | |
8258 | if (line_nid == 0x14) | |
8259 | dac_vol2 = AMP_OUT_ZERO; | |
8260 | else if (line_nid == 0x15) | |
8261 | dac_vol1 = AMP_OUT_ZERO; | |
8262 | if (hp_nid == 0x14) | |
8263 | dac_vol2 = AMP_OUT_ZERO; | |
8264 | else if (hp_nid == 0x15) | |
8265 | dac_vol1 = AMP_OUT_ZERO; | |
8266 | if (line_nid != 0x16 || hp_nid != 0x16 || | |
8267 | spec->autocfg.line_out_pins[1] != 0x16 || | |
8268 | spec->autocfg.line_out_pins[2] != 0x16) | |
8269 | dac_vol1 = dac_vol2 = AMP_OUT_ZERO; | |
8270 | ||
8271 | snd_hda_codec_write(codec, 0x02, 0, | |
8272 | AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1); | |
8273 | snd_hda_codec_write(codec, 0x03, 0, | |
8274 | AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2); | |
8275 | } | |
8276 | ||
8277 | /* pcm configuration: identiacal with ALC880 */ | |
8278 | #define alc268_pcm_analog_playback alc880_pcm_analog_playback | |
8279 | #define alc268_pcm_analog_capture alc880_pcm_analog_capture | |
8280 | #define alc268_pcm_digital_playback alc880_pcm_digital_playback | |
8281 | ||
8282 | /* | |
8283 | * BIOS auto configuration | |
8284 | */ | |
8285 | static int alc268_parse_auto_config(struct hda_codec *codec) | |
8286 | { | |
8287 | struct alc_spec *spec = codec->spec; | |
8288 | int err; | |
8289 | static hda_nid_t alc268_ignore[] = { 0 }; | |
8290 | ||
8291 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | |
8292 | alc268_ignore); | |
8293 | if (err < 0) | |
8294 | return err; | |
8295 | if (!spec->autocfg.line_outs) | |
8296 | return 0; /* can't find valid BIOS pin config */ | |
8297 | ||
8298 | err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
8299 | if (err < 0) | |
8300 | return err; | |
8301 | err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
8302 | if (err < 0) | |
8303 | return err; | |
8304 | ||
8305 | spec->multiout.max_channels = 2; | |
8306 | ||
8307 | /* digital only support output */ | |
8308 | if (spec->autocfg.dig_out_pin) | |
8309 | spec->multiout.dig_out_nid = ALC268_DIGOUT_NID; | |
8310 | ||
8311 | if (spec->kctl_alloc) | |
8312 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
8313 | ||
8314 | spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs; | |
8315 | spec->num_mux_defs = 1; | |
8316 | spec->input_mux = &spec->private_imux; | |
8317 | ||
8318 | return 1; | |
8319 | } | |
8320 | ||
8321 | #define alc268_auto_init_multi_out alc882_auto_init_multi_out | |
8322 | #define alc268_auto_init_hp_out alc882_auto_init_hp_out | |
8323 | #define alc268_auto_init_analog_input alc882_auto_init_analog_input | |
8324 | ||
8325 | /* init callback for auto-configuration model -- overriding the default init */ | |
8326 | static void alc268_auto_init(struct hda_codec *codec) | |
8327 | { | |
8328 | alc268_auto_init_multi_out(codec); | |
8329 | alc268_auto_init_hp_out(codec); | |
8330 | alc268_auto_init_mono_speaker_out(codec); | |
8331 | alc268_auto_init_analog_input(codec); | |
8332 | } | |
8333 | ||
8334 | /* | |
8335 | * configuration and preset | |
8336 | */ | |
8337 | static const char *alc268_models[ALC268_MODEL_LAST] = { | |
8338 | [ALC268_3ST] = "3stack", | |
8339 | [ALC268_AUTO] = "auto", | |
8340 | }; | |
8341 | ||
8342 | static struct snd_pci_quirk alc268_cfg_tbl[] = { | |
8343 | SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST), | |
8344 | {} | |
8345 | }; | |
8346 | ||
8347 | static struct alc_config_preset alc268_presets[] = { | |
8348 | [ALC268_3ST] = { | |
8349 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer }, | |
8350 | .init_verbs = { alc268_base_init_verbs }, | |
8351 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
8352 | .dac_nids = alc268_dac_nids, | |
8353 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
8354 | .adc_nids = alc268_adc_nids_alt, | |
8355 | .hp_nid = 0x03, | |
8356 | .dig_out_nid = ALC268_DIGOUT_NID, | |
8357 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
8358 | .channel_mode = alc268_modes, | |
8359 | .input_mux = &alc268_capture_source, | |
8360 | }, | |
8361 | }; | |
8362 | ||
8363 | static int patch_alc268(struct hda_codec *codec) | |
8364 | { | |
8365 | struct alc_spec *spec; | |
8366 | int board_config; | |
8367 | int err; | |
8368 | ||
8369 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); | |
8370 | if (spec == NULL) | |
8371 | return -ENOMEM; | |
8372 | ||
8373 | codec->spec = spec; | |
8374 | ||
8375 | board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST, | |
8376 | alc268_models, | |
8377 | alc268_cfg_tbl); | |
8378 | ||
8379 | if (board_config < 0 || board_config >= ALC268_MODEL_LAST) { | |
8380 | printk(KERN_INFO "hda_codec: Unknown model for ALC268, " | |
8381 | "trying auto-probe from BIOS...\n"); | |
8382 | board_config = ALC268_AUTO; | |
8383 | } | |
8384 | ||
8385 | if (board_config == ALC268_AUTO) { | |
8386 | /* automatic parse from the BIOS config */ | |
8387 | err = alc268_parse_auto_config(codec); | |
8388 | if (err < 0) { | |
8389 | alc_free(codec); | |
8390 | return err; | |
8391 | } else if (!err) { | |
8392 | printk(KERN_INFO | |
8393 | "hda_codec: Cannot set up configuration " | |
8394 | "from BIOS. Using base mode...\n"); | |
8395 | board_config = ALC268_3ST; | |
8396 | } | |
8397 | } | |
8398 | ||
8399 | if (board_config != ALC268_AUTO) | |
8400 | setup_preset(spec, &alc268_presets[board_config]); | |
8401 | ||
8402 | spec->stream_name_analog = "ALC268 Analog"; | |
8403 | spec->stream_analog_playback = &alc268_pcm_analog_playback; | |
8404 | spec->stream_analog_capture = &alc268_pcm_analog_capture; | |
8405 | ||
8406 | spec->stream_name_digital = "ALC268 Digital"; | |
8407 | spec->stream_digital_playback = &alc268_pcm_digital_playback; | |
8408 | ||
8409 | if (board_config == ALC268_AUTO) { | |
8410 | if (!spec->adc_nids && spec->input_mux) { | |
8411 | /* check whether NID 0x07 is valid */ | |
8412 | unsigned int wcap = get_wcaps(codec, 0x07); | |
8413 | ||
8414 | /* get type */ | |
8415 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
8416 | if (wcap != AC_WID_AUD_IN) { | |
8417 | spec->adc_nids = alc268_adc_nids_alt; | |
8418 | spec->num_adc_nids = | |
8419 | ARRAY_SIZE(alc268_adc_nids_alt); | |
8420 | spec->mixers[spec->num_mixers] = | |
8421 | alc268_capture_alt_mixer; | |
8422 | spec->num_mixers++; | |
8423 | } else { | |
8424 | spec->adc_nids = alc268_adc_nids; | |
8425 | spec->num_adc_nids = | |
8426 | ARRAY_SIZE(alc268_adc_nids); | |
8427 | spec->mixers[spec->num_mixers] = | |
8428 | alc268_capture_mixer; | |
8429 | spec->num_mixers++; | |
8430 | } | |
8431 | } | |
8432 | } | |
8433 | codec->patch_ops = alc_patch_ops; | |
8434 | if (board_config == ALC268_AUTO) | |
8435 | spec->init_hook = alc268_auto_init; | |
8436 | ||
8437 | return 0; | |
8438 | } | |
8439 | ||
df694daa KY |
8440 | /* |
8441 | * ALC861 channel source setting (2/6 channel selection for 3-stack) | |
8442 | */ | |
8443 | ||
8444 | /* | |
8445 | * set the path ways for 2 channel output | |
8446 | * need to set the codec line out and mic 1 pin widgets to inputs | |
8447 | */ | |
8448 | static struct hda_verb alc861_threestack_ch2_init[] = { | |
8449 | /* set pin widget 1Ah (line in) for input */ | |
8450 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
f12ab1e0 TI |
8451 | /* set pin widget 18h (mic1/2) for input, for mic also enable |
8452 | * the vref | |
8453 | */ | |
df694daa KY |
8454 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
8455 | ||
9c7f852e TI |
8456 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, |
8457 | #if 0 | |
8458 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
8459 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/ | |
8460 | #endif | |
df694daa KY |
8461 | { } /* end */ |
8462 | }; | |
8463 | /* | |
8464 | * 6ch mode | |
8465 | * need to set the codec line out and mic 1 pin widgets to outputs | |
8466 | */ | |
8467 | static struct hda_verb alc861_threestack_ch6_init[] = { | |
8468 | /* set pin widget 1Ah (line in) for output (Back Surround)*/ | |
8469 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
8470 | /* set pin widget 18h (mic1) for output (CLFE)*/ | |
8471 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
8472 | ||
8473 | { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
9c7f852e | 8474 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa | 8475 | |
9c7f852e TI |
8476 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, |
8477 | #if 0 | |
8478 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
8479 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/ | |
8480 | #endif | |
df694daa KY |
8481 | { } /* end */ |
8482 | }; | |
8483 | ||
8484 | static struct hda_channel_mode alc861_threestack_modes[2] = { | |
8485 | { 2, alc861_threestack_ch2_init }, | |
8486 | { 6, alc861_threestack_ch6_init }, | |
8487 | }; | |
22309c3e TI |
8488 | /* Set mic1 as input and unmute the mixer */ |
8489 | static struct hda_verb alc861_uniwill_m31_ch2_init[] = { | |
8490 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
8491 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
8492 | { } /* end */ | |
8493 | }; | |
8494 | /* Set mic1 as output and mute mixer */ | |
8495 | static struct hda_verb alc861_uniwill_m31_ch4_init[] = { | |
8496 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
8497 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
8498 | { } /* end */ | |
8499 | }; | |
8500 | ||
8501 | static struct hda_channel_mode alc861_uniwill_m31_modes[2] = { | |
8502 | { 2, alc861_uniwill_m31_ch2_init }, | |
8503 | { 4, alc861_uniwill_m31_ch4_init }, | |
8504 | }; | |
df694daa | 8505 | |
7cdbff94 MD |
8506 | /* Set mic1 and line-in as input and unmute the mixer */ |
8507 | static struct hda_verb alc861_asus_ch2_init[] = { | |
8508 | /* set pin widget 1Ah (line in) for input */ | |
8509 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
f12ab1e0 TI |
8510 | /* set pin widget 18h (mic1/2) for input, for mic also enable |
8511 | * the vref | |
8512 | */ | |
7cdbff94 MD |
8513 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
8514 | ||
8515 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, | |
8516 | #if 0 | |
8517 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
8518 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/ | |
8519 | #endif | |
8520 | { } /* end */ | |
8521 | }; | |
8522 | /* Set mic1 nad line-in as output and mute mixer */ | |
8523 | static struct hda_verb alc861_asus_ch6_init[] = { | |
8524 | /* set pin widget 1Ah (line in) for output (Back Surround)*/ | |
8525 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
8526 | /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */ | |
8527 | /* set pin widget 18h (mic1) for output (CLFE)*/ | |
8528 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
8529 | /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */ | |
8530 | { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
8531 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
8532 | ||
8533 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, | |
8534 | #if 0 | |
8535 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
8536 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/ | |
8537 | #endif | |
8538 | { } /* end */ | |
8539 | }; | |
8540 | ||
8541 | static struct hda_channel_mode alc861_asus_modes[2] = { | |
8542 | { 2, alc861_asus_ch2_init }, | |
8543 | { 6, alc861_asus_ch6_init }, | |
8544 | }; | |
8545 | ||
df694daa KY |
8546 | /* patch-ALC861 */ |
8547 | ||
8548 | static struct snd_kcontrol_new alc861_base_mixer[] = { | |
8549 | /* output mixer control */ | |
8550 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
8551 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
8552 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
8553 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
8554 | HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), | |
8555 | ||
8556 | /*Input mixer control */ | |
8557 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
8558 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
8559 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
8560 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
8561 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
8562 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
8563 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
8564 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
8565 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
8566 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 8567 | |
df694daa KY |
8568 | /* Capture mixer control */ |
8569 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
8570 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
8571 | { | |
8572 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
8573 | .name = "Capture Source", | |
8574 | .count = 1, | |
8575 | .info = alc_mux_enum_info, | |
8576 | .get = alc_mux_enum_get, | |
8577 | .put = alc_mux_enum_put, | |
8578 | }, | |
8579 | { } /* end */ | |
8580 | }; | |
8581 | ||
8582 | static struct snd_kcontrol_new alc861_3ST_mixer[] = { | |
8583 | /* output mixer control */ | |
8584 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
8585 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
8586 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
8587 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
8588 | /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ | |
8589 | ||
8590 | /* Input mixer control */ | |
8591 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
8592 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
8593 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
8594 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
8595 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
8596 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
8597 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
8598 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
8599 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
8600 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 8601 | |
df694daa KY |
8602 | /* Capture mixer control */ |
8603 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
8604 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
8605 | { | |
8606 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
8607 | .name = "Capture Source", | |
8608 | .count = 1, | |
8609 | .info = alc_mux_enum_info, | |
8610 | .get = alc_mux_enum_get, | |
8611 | .put = alc_mux_enum_put, | |
8612 | }, | |
8613 | { | |
8614 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
8615 | .name = "Channel Mode", | |
8616 | .info = alc_ch_mode_info, | |
8617 | .get = alc_ch_mode_get, | |
8618 | .put = alc_ch_mode_put, | |
8619 | .private_value = ARRAY_SIZE(alc861_threestack_modes), | |
8620 | }, | |
8621 | { } /* end */ | |
a53d1aec TD |
8622 | }; |
8623 | ||
d1d985f0 | 8624 | static struct snd_kcontrol_new alc861_toshiba_mixer[] = { |
a53d1aec TD |
8625 | /* output mixer control */ |
8626 | HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
8627 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
8628 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
8629 | ||
8630 | /*Capture mixer control */ | |
8631 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
8632 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
8633 | { | |
8634 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
8635 | .name = "Capture Source", | |
8636 | .count = 1, | |
8637 | .info = alc_mux_enum_info, | |
8638 | .get = alc_mux_enum_get, | |
8639 | .put = alc_mux_enum_put, | |
8640 | }, | |
8641 | ||
8642 | { } /* end */ | |
f12ab1e0 | 8643 | }; |
a53d1aec | 8644 | |
22309c3e TI |
8645 | static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = { |
8646 | /* output mixer control */ | |
8647 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
8648 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
8649 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
8650 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
8651 | /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ | |
8652 | ||
8653 | /* Input mixer control */ | |
8654 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
8655 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
8656 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
8657 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
8658 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
8659 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
8660 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
8661 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
8662 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
8663 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 8664 | |
22309c3e TI |
8665 | /* Capture mixer control */ |
8666 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
8667 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
8668 | { | |
8669 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
8670 | .name = "Capture Source", | |
8671 | .count = 1, | |
8672 | .info = alc_mux_enum_info, | |
8673 | .get = alc_mux_enum_get, | |
8674 | .put = alc_mux_enum_put, | |
8675 | }, | |
8676 | { | |
8677 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
8678 | .name = "Channel Mode", | |
8679 | .info = alc_ch_mode_info, | |
8680 | .get = alc_ch_mode_get, | |
8681 | .put = alc_ch_mode_put, | |
8682 | .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes), | |
8683 | }, | |
8684 | { } /* end */ | |
f12ab1e0 | 8685 | }; |
7cdbff94 MD |
8686 | |
8687 | static struct snd_kcontrol_new alc861_asus_mixer[] = { | |
8688 | /* output mixer control */ | |
8689 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
8690 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
8691 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
8692 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
8693 | HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), | |
8694 | ||
8695 | /* Input mixer control */ | |
8696 | HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
8697 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
8698 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
8699 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
8700 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
8701 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
8702 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
8703 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
8704 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
f12ab1e0 TI |
8705 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), |
8706 | ||
7cdbff94 MD |
8707 | /* Capture mixer control */ |
8708 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
8709 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
8710 | { | |
8711 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
8712 | .name = "Capture Source", | |
8713 | .count = 1, | |
8714 | .info = alc_mux_enum_info, | |
8715 | .get = alc_mux_enum_get, | |
8716 | .put = alc_mux_enum_put, | |
8717 | }, | |
8718 | { | |
8719 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
8720 | .name = "Channel Mode", | |
8721 | .info = alc_ch_mode_info, | |
8722 | .get = alc_ch_mode_get, | |
8723 | .put = alc_ch_mode_put, | |
8724 | .private_value = ARRAY_SIZE(alc861_asus_modes), | |
8725 | }, | |
8726 | { } | |
56bb0cab TI |
8727 | }; |
8728 | ||
8729 | /* additional mixer */ | |
d1d985f0 | 8730 | static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = { |
56bb0cab TI |
8731 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), |
8732 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
8733 | HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT), | |
8734 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT), | |
8735 | { } | |
8736 | }; | |
7cdbff94 | 8737 | |
df694daa KY |
8738 | /* |
8739 | * generic initialization of ADC, input mixers and output mixers | |
8740 | */ | |
8741 | static struct hda_verb alc861_base_init_verbs[] = { | |
8742 | /* | |
8743 | * Unmute ADC0 and set the default input to mic-in | |
8744 | */ | |
8745 | /* port-A for surround (rear panel) */ | |
8746 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
8747 | { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
8748 | /* port-B for mic-in (rear panel) with vref */ | |
8749 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
8750 | /* port-C for line-in (rear panel) */ | |
8751 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
8752 | /* port-D for Front */ | |
8753 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
8754 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
8755 | /* port-E for HP out (front panel) */ | |
8756 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | |
8757 | /* route front PCM to HP */ | |
9dece1d7 | 8758 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa KY |
8759 | /* port-F for mic-in (front panel) with vref */ |
8760 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
8761 | /* port-G for CLFE (rear panel) */ | |
8762 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
8763 | { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
8764 | /* port-H for side (rear panel) */ | |
8765 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
8766 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
8767 | /* CD-in */ | |
8768 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
8769 | /* route front mic to ADC1*/ | |
8770 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8771 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8772 | ||
8773 | /* Unmute DAC0~3 & spdif out*/ | |
8774 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8775 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8776 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8777 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8778 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8779 | ||
8780 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
8781 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8782 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8783 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8784 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8785 | ||
8786 | /* Unmute Stereo Mixer 15 */ | |
8787 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8788 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8789 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 8790 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
df694daa KY |
8791 | |
8792 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8793 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8794 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8795 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8796 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8797 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8798 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8799 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
8800 | /* hp used DAC 3 (Front) */ |
8801 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
8802 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
8803 | ||
8804 | { } | |
8805 | }; | |
8806 | ||
8807 | static struct hda_verb alc861_threestack_init_verbs[] = { | |
8808 | /* | |
8809 | * Unmute ADC0 and set the default input to mic-in | |
8810 | */ | |
8811 | /* port-A for surround (rear panel) */ | |
8812 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
8813 | /* port-B for mic-in (rear panel) with vref */ | |
8814 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
8815 | /* port-C for line-in (rear panel) */ | |
8816 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
8817 | /* port-D for Front */ | |
8818 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
8819 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
8820 | /* port-E for HP out (front panel) */ | |
8821 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | |
8822 | /* route front PCM to HP */ | |
9dece1d7 | 8823 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa KY |
8824 | /* port-F for mic-in (front panel) with vref */ |
8825 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
8826 | /* port-G for CLFE (rear panel) */ | |
8827 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
8828 | /* port-H for side (rear panel) */ | |
8829 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
8830 | /* CD-in */ | |
8831 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
8832 | /* route front mic to ADC1*/ | |
8833 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8834 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8835 | /* Unmute DAC0~3 & spdif out*/ | |
8836 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8837 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8838 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8839 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8840 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8841 | ||
8842 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
8843 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8844 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8845 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8846 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8847 | ||
8848 | /* Unmute Stereo Mixer 15 */ | |
8849 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8850 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8851 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 8852 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
df694daa KY |
8853 | |
8854 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8855 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8856 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8857 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8858 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8859 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8860 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8861 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
8862 | /* hp used DAC 3 (Front) */ |
8863 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
8864 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
8865 | { } | |
8866 | }; | |
22309c3e TI |
8867 | |
8868 | static struct hda_verb alc861_uniwill_m31_init_verbs[] = { | |
8869 | /* | |
8870 | * Unmute ADC0 and set the default input to mic-in | |
8871 | */ | |
8872 | /* port-A for surround (rear panel) */ | |
8873 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
8874 | /* port-B for mic-in (rear panel) with vref */ | |
8875 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
8876 | /* port-C for line-in (rear panel) */ | |
8877 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
8878 | /* port-D for Front */ | |
8879 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
8880 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
8881 | /* port-E for HP out (front panel) */ | |
f12ab1e0 TI |
8882 | /* this has to be set to VREF80 */ |
8883 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
22309c3e | 8884 | /* route front PCM to HP */ |
9dece1d7 | 8885 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
22309c3e TI |
8886 | /* port-F for mic-in (front panel) with vref */ |
8887 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
8888 | /* port-G for CLFE (rear panel) */ | |
8889 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
8890 | /* port-H for side (rear panel) */ | |
8891 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
8892 | /* CD-in */ | |
8893 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
8894 | /* route front mic to ADC1*/ | |
8895 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8896 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8897 | /* Unmute DAC0~3 & spdif out*/ | |
8898 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8899 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8900 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8901 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8902 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8903 | ||
8904 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
8905 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8906 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8907 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8908 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8909 | ||
8910 | /* Unmute Stereo Mixer 15 */ | |
8911 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8912 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8913 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 8914 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
22309c3e TI |
8915 | |
8916 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8917 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8918 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8919 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8920 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8921 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8922 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8923 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
8924 | /* hp used DAC 3 (Front) */ |
8925 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
22309c3e TI |
8926 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
8927 | { } | |
8928 | }; | |
8929 | ||
7cdbff94 MD |
8930 | static struct hda_verb alc861_asus_init_verbs[] = { |
8931 | /* | |
8932 | * Unmute ADC0 and set the default input to mic-in | |
8933 | */ | |
f12ab1e0 TI |
8934 | /* port-A for surround (rear panel) |
8935 | * according to codec#0 this is the HP jack | |
8936 | */ | |
7cdbff94 MD |
8937 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */ |
8938 | /* route front PCM to HP */ | |
8939 | { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
8940 | /* port-B for mic-in (rear panel) with vref */ | |
8941 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
8942 | /* port-C for line-in (rear panel) */ | |
8943 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
8944 | /* port-D for Front */ | |
8945 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
8946 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
8947 | /* port-E for HP out (front panel) */ | |
f12ab1e0 TI |
8948 | /* this has to be set to VREF80 */ |
8949 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
7cdbff94 | 8950 | /* route front PCM to HP */ |
9dece1d7 | 8951 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
7cdbff94 MD |
8952 | /* port-F for mic-in (front panel) with vref */ |
8953 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
8954 | /* port-G for CLFE (rear panel) */ | |
8955 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
8956 | /* port-H for side (rear panel) */ | |
8957 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
8958 | /* CD-in */ | |
8959 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
8960 | /* route front mic to ADC1*/ | |
8961 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8962 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8963 | /* Unmute DAC0~3 & spdif out*/ | |
8964 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8965 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8966 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8967 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8968 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8969 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
8970 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8971 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8972 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8973 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8974 | ||
8975 | /* Unmute Stereo Mixer 15 */ | |
8976 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8977 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8978 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 8979 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
7cdbff94 MD |
8980 | |
8981 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8982 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8983 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8984 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8985 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8986 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8987 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8988 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
8989 | /* hp used DAC 3 (Front) */ |
8990 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
7cdbff94 MD |
8991 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
8992 | { } | |
8993 | }; | |
8994 | ||
56bb0cab TI |
8995 | /* additional init verbs for ASUS laptops */ |
8996 | static struct hda_verb alc861_asus_laptop_init_verbs[] = { | |
8997 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */ | |
8998 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */ | |
8999 | { } | |
9000 | }; | |
7cdbff94 | 9001 | |
df694daa KY |
9002 | /* |
9003 | * generic initialization of ADC, input mixers and output mixers | |
9004 | */ | |
9005 | static struct hda_verb alc861_auto_init_verbs[] = { | |
9006 | /* | |
9007 | * Unmute ADC0 and set the default input to mic-in | |
9008 | */ | |
f12ab1e0 | 9009 | /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */ |
df694daa KY |
9010 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
9011 | ||
9012 | /* Unmute DAC0~3 & spdif out*/ | |
9013 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9014 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9015 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9016 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9017 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9018 | ||
9019 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
9020 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9021 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9022 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9023 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9024 | ||
9025 | /* Unmute Stereo Mixer 15 */ | |
9026 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9027 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9028 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
9029 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, | |
9030 | ||
9031 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9032 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9033 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9034 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9035 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9036 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9037 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9038 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9039 | ||
9040 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
9041 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
f12ab1e0 TI |
9042 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
9043 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
9044 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
9045 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
f12ab1e0 TI |
9046 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
9047 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa | 9048 | |
f12ab1e0 | 9049 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */ |
df694daa KY |
9050 | |
9051 | { } | |
9052 | }; | |
9053 | ||
a53d1aec TD |
9054 | static struct hda_verb alc861_toshiba_init_verbs[] = { |
9055 | {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
f12ab1e0 | 9056 | |
a53d1aec TD |
9057 | { } |
9058 | }; | |
9059 | ||
9060 | /* toggle speaker-output according to the hp-jack state */ | |
9061 | static void alc861_toshiba_automute(struct hda_codec *codec) | |
9062 | { | |
9063 | unsigned int present; | |
9064 | ||
9065 | present = snd_hda_codec_read(codec, 0x0f, 0, | |
9066 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
9067 | snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0, | |
9068 | 0x80, present ? 0x80 : 0); | |
9069 | snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0, | |
9070 | 0x80, present ? 0x80 : 0); | |
9071 | snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3, | |
9072 | 0x80, present ? 0 : 0x80); | |
9073 | snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3, | |
9074 | 0x80, present ? 0 : 0x80); | |
9075 | } | |
9076 | ||
9077 | static void alc861_toshiba_unsol_event(struct hda_codec *codec, | |
9078 | unsigned int res) | |
9079 | { | |
a53d1aec TD |
9080 | if ((res >> 26) == ALC880_HP_EVENT) |
9081 | alc861_toshiba_automute(codec); | |
9082 | } | |
9083 | ||
df694daa KY |
9084 | /* pcm configuration: identiacal with ALC880 */ |
9085 | #define alc861_pcm_analog_playback alc880_pcm_analog_playback | |
9086 | #define alc861_pcm_analog_capture alc880_pcm_analog_capture | |
9087 | #define alc861_pcm_digital_playback alc880_pcm_digital_playback | |
9088 | #define alc861_pcm_digital_capture alc880_pcm_digital_capture | |
9089 | ||
9090 | ||
9091 | #define ALC861_DIGOUT_NID 0x07 | |
9092 | ||
9093 | static struct hda_channel_mode alc861_8ch_modes[1] = { | |
9094 | { 8, NULL } | |
9095 | }; | |
9096 | ||
9097 | static hda_nid_t alc861_dac_nids[4] = { | |
9098 | /* front, surround, clfe, side */ | |
9099 | 0x03, 0x06, 0x05, 0x04 | |
9100 | }; | |
9101 | ||
9c7f852e TI |
9102 | static hda_nid_t alc660_dac_nids[3] = { |
9103 | /* front, clfe, surround */ | |
9104 | 0x03, 0x05, 0x06 | |
9105 | }; | |
9106 | ||
df694daa KY |
9107 | static hda_nid_t alc861_adc_nids[1] = { |
9108 | /* ADC0-2 */ | |
9109 | 0x08, | |
9110 | }; | |
9111 | ||
9112 | static struct hda_input_mux alc861_capture_source = { | |
9113 | .num_items = 5, | |
9114 | .items = { | |
9115 | { "Mic", 0x0 }, | |
9116 | { "Front Mic", 0x3 }, | |
9117 | { "Line", 0x1 }, | |
9118 | { "CD", 0x4 }, | |
9119 | { "Mixer", 0x5 }, | |
9120 | }, | |
9121 | }; | |
9122 | ||
9123 | /* fill in the dac_nids table from the parsed pin configuration */ | |
f12ab1e0 TI |
9124 | static int alc861_auto_fill_dac_nids(struct alc_spec *spec, |
9125 | const struct auto_pin_cfg *cfg) | |
df694daa KY |
9126 | { |
9127 | int i; | |
9128 | hda_nid_t nid; | |
9129 | ||
9130 | spec->multiout.dac_nids = spec->private_dac_nids; | |
9131 | for (i = 0; i < cfg->line_outs; i++) { | |
9132 | nid = cfg->line_out_pins[i]; | |
9133 | if (nid) { | |
9134 | if (i >= ARRAY_SIZE(alc861_dac_nids)) | |
9135 | continue; | |
9136 | spec->multiout.dac_nids[i] = alc861_dac_nids[i]; | |
9137 | } | |
9138 | } | |
9139 | spec->multiout.num_dacs = cfg->line_outs; | |
9140 | return 0; | |
9141 | } | |
9142 | ||
9143 | /* add playback controls from the parsed DAC table */ | |
9144 | static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec, | |
9145 | const struct auto_pin_cfg *cfg) | |
9146 | { | |
9147 | char name[32]; | |
f12ab1e0 TI |
9148 | static const char *chname[4] = { |
9149 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
9150 | }; | |
df694daa KY |
9151 | hda_nid_t nid; |
9152 | int i, idx, err; | |
9153 | ||
9154 | for (i = 0; i < cfg->line_outs; i++) { | |
9155 | nid = spec->multiout.dac_nids[i]; | |
f12ab1e0 | 9156 | if (!nid) |
df694daa KY |
9157 | continue; |
9158 | if (nid == 0x05) { | |
9159 | /* Center/LFE */ | |
f12ab1e0 TI |
9160 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
9161 | "Center Playback Switch", | |
9162 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, | |
9163 | HDA_OUTPUT)); | |
9164 | if (err < 0) | |
df694daa | 9165 | return err; |
f12ab1e0 TI |
9166 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
9167 | "LFE Playback Switch", | |
9168 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
9169 | HDA_OUTPUT)); | |
9170 | if (err < 0) | |
df694daa KY |
9171 | return err; |
9172 | } else { | |
f12ab1e0 TI |
9173 | for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; |
9174 | idx++) | |
df694daa KY |
9175 | if (nid == alc861_dac_nids[idx]) |
9176 | break; | |
9177 | sprintf(name, "%s Playback Switch", chname[idx]); | |
f12ab1e0 TI |
9178 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
9179 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
9180 | HDA_OUTPUT)); | |
9181 | if (err < 0) | |
df694daa KY |
9182 | return err; |
9183 | } | |
9184 | } | |
9185 | return 0; | |
9186 | } | |
9187 | ||
9188 | static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin) | |
9189 | { | |
9190 | int err; | |
9191 | hda_nid_t nid; | |
9192 | ||
f12ab1e0 | 9193 | if (!pin) |
df694daa KY |
9194 | return 0; |
9195 | ||
9196 | if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) { | |
9197 | nid = 0x03; | |
f12ab1e0 TI |
9198 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
9199 | "Headphone Playback Switch", | |
9200 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
9201 | if (err < 0) | |
df694daa KY |
9202 | return err; |
9203 | spec->multiout.hp_nid = nid; | |
9204 | } | |
9205 | return 0; | |
9206 | } | |
9207 | ||
9208 | /* create playback/capture controls for input pins */ | |
f12ab1e0 TI |
9209 | static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, |
9210 | const struct auto_pin_cfg *cfg) | |
df694daa | 9211 | { |
df694daa KY |
9212 | struct hda_input_mux *imux = &spec->private_imux; |
9213 | int i, err, idx, idx1; | |
9214 | ||
9215 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
f12ab1e0 | 9216 | switch (cfg->input_pins[i]) { |
df694daa KY |
9217 | case 0x0c: |
9218 | idx1 = 1; | |
f12ab1e0 | 9219 | idx = 2; /* Line In */ |
df694daa KY |
9220 | break; |
9221 | case 0x0f: | |
9222 | idx1 = 2; | |
f12ab1e0 | 9223 | idx = 2; /* Line In */ |
df694daa KY |
9224 | break; |
9225 | case 0x0d: | |
9226 | idx1 = 0; | |
f12ab1e0 | 9227 | idx = 1; /* Mic In */ |
df694daa | 9228 | break; |
f12ab1e0 | 9229 | case 0x10: |
df694daa | 9230 | idx1 = 3; |
f12ab1e0 | 9231 | idx = 1; /* Mic In */ |
df694daa KY |
9232 | break; |
9233 | case 0x11: | |
9234 | idx1 = 4; | |
f12ab1e0 | 9235 | idx = 0; /* CD */ |
df694daa KY |
9236 | break; |
9237 | default: | |
9238 | continue; | |
9239 | } | |
9240 | ||
4a471b7d TI |
9241 | err = new_analog_input(spec, cfg->input_pins[i], |
9242 | auto_pin_cfg_labels[i], idx, 0x15); | |
df694daa KY |
9243 | if (err < 0) |
9244 | return err; | |
9245 | ||
4a471b7d | 9246 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
df694daa | 9247 | imux->items[imux->num_items].index = idx1; |
f12ab1e0 | 9248 | imux->num_items++; |
df694daa KY |
9249 | } |
9250 | return 0; | |
9251 | } | |
9252 | ||
9253 | static struct snd_kcontrol_new alc861_capture_mixer[] = { | |
9254 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
9255 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
9256 | ||
9257 | { | |
9258 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9259 | /* The multiple "Capture Source" controls confuse alsamixer | |
9260 | * So call somewhat different.. | |
9261 | *FIXME: the controls appear in the "playback" view! | |
9262 | */ | |
9263 | /* .name = "Capture Source", */ | |
9264 | .name = "Input Source", | |
9265 | .count = 1, | |
9266 | .info = alc_mux_enum_info, | |
9267 | .get = alc_mux_enum_get, | |
9268 | .put = alc_mux_enum_put, | |
9269 | }, | |
9270 | { } /* end */ | |
9271 | }; | |
9272 | ||
f12ab1e0 TI |
9273 | static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, |
9274 | hda_nid_t nid, | |
df694daa KY |
9275 | int pin_type, int dac_idx) |
9276 | { | |
9277 | /* set as output */ | |
9278 | ||
f12ab1e0 TI |
9279 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
9280 | pin_type); | |
9281 | snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
9282 | AMP_OUT_UNMUTE); | |
df694daa KY |
9283 | |
9284 | } | |
9285 | ||
9286 | static void alc861_auto_init_multi_out(struct hda_codec *codec) | |
9287 | { | |
9288 | struct alc_spec *spec = codec->spec; | |
9289 | int i; | |
9290 | ||
bc9f98a9 | 9291 | alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b); |
df694daa KY |
9292 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
9293 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 9294 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
df694daa | 9295 | if (nid) |
baba8ee9 | 9296 | alc861_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 9297 | spec->multiout.dac_nids[i]); |
df694daa KY |
9298 | } |
9299 | } | |
9300 | ||
9301 | static void alc861_auto_init_hp_out(struct hda_codec *codec) | |
9302 | { | |
9303 | struct alc_spec *spec = codec->spec; | |
9304 | hda_nid_t pin; | |
9305 | ||
eb06ed8f | 9306 | pin = spec->autocfg.hp_pins[0]; |
df694daa | 9307 | if (pin) /* connect to front */ |
f12ab1e0 TI |
9308 | alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, |
9309 | spec->multiout.dac_nids[0]); | |
df694daa KY |
9310 | } |
9311 | ||
9312 | static void alc861_auto_init_analog_input(struct hda_codec *codec) | |
9313 | { | |
9314 | struct alc_spec *spec = codec->spec; | |
9315 | int i; | |
9316 | ||
9317 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
9318 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
f12ab1e0 TI |
9319 | if (nid >= 0x0c && nid <= 0x11) { |
9320 | snd_hda_codec_write(codec, nid, 0, | |
9321 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
9322 | i <= AUTO_PIN_FRONT_MIC ? | |
9323 | PIN_VREF80 : PIN_IN); | |
df694daa KY |
9324 | } |
9325 | } | |
9326 | } | |
9327 | ||
9328 | /* parse the BIOS configuration and set up the alc_spec */ | |
f12ab1e0 TI |
9329 | /* return 1 if successful, 0 if the proper config is not found, |
9330 | * or a negative error code | |
9331 | */ | |
df694daa KY |
9332 | static int alc861_parse_auto_config(struct hda_codec *codec) |
9333 | { | |
9334 | struct alc_spec *spec = codec->spec; | |
9335 | int err; | |
9336 | static hda_nid_t alc861_ignore[] = { 0x1d, 0 }; | |
9337 | ||
f12ab1e0 TI |
9338 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
9339 | alc861_ignore); | |
9340 | if (err < 0) | |
df694daa | 9341 | return err; |
f12ab1e0 | 9342 | if (!spec->autocfg.line_outs) |
df694daa KY |
9343 | return 0; /* can't find valid BIOS pin config */ |
9344 | ||
f12ab1e0 TI |
9345 | err = alc861_auto_fill_dac_nids(spec, &spec->autocfg); |
9346 | if (err < 0) | |
9347 | return err; | |
9348 | err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
9349 | if (err < 0) | |
9350 | return err; | |
9351 | err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); | |
9352 | if (err < 0) | |
9353 | return err; | |
9354 | err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
9355 | if (err < 0) | |
df694daa KY |
9356 | return err; |
9357 | ||
9358 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
9359 | ||
9360 | if (spec->autocfg.dig_out_pin) | |
9361 | spec->multiout.dig_out_nid = ALC861_DIGOUT_NID; | |
9362 | ||
9363 | if (spec->kctl_alloc) | |
9364 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
9365 | ||
9366 | spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs; | |
9367 | ||
a1e8d2da | 9368 | spec->num_mux_defs = 1; |
df694daa KY |
9369 | spec->input_mux = &spec->private_imux; |
9370 | ||
9371 | spec->adc_nids = alc861_adc_nids; | |
9372 | spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); | |
9373 | spec->mixers[spec->num_mixers] = alc861_capture_mixer; | |
9374 | spec->num_mixers++; | |
9375 | ||
9376 | return 1; | |
9377 | } | |
9378 | ||
ae6b813a TI |
9379 | /* additional initialization for auto-configuration model */ |
9380 | static void alc861_auto_init(struct hda_codec *codec) | |
df694daa | 9381 | { |
df694daa KY |
9382 | alc861_auto_init_multi_out(codec); |
9383 | alc861_auto_init_hp_out(codec); | |
9384 | alc861_auto_init_analog_input(codec); | |
df694daa KY |
9385 | } |
9386 | ||
9387 | ||
9388 | /* | |
9389 | * configuration and preset | |
9390 | */ | |
f5fcc13c TI |
9391 | static const char *alc861_models[ALC861_MODEL_LAST] = { |
9392 | [ALC861_3ST] = "3stack", | |
9393 | [ALC660_3ST] = "3stack-660", | |
9394 | [ALC861_3ST_DIG] = "3stack-dig", | |
9395 | [ALC861_6ST_DIG] = "6stack-dig", | |
9396 | [ALC861_UNIWILL_M31] = "uniwill-m31", | |
9397 | [ALC861_TOSHIBA] = "toshiba", | |
9398 | [ALC861_ASUS] = "asus", | |
9399 | [ALC861_ASUS_LAPTOP] = "asus-laptop", | |
9400 | [ALC861_AUTO] = "auto", | |
9401 | }; | |
9402 | ||
9403 | static struct snd_pci_quirk alc861_cfg_tbl[] = { | |
687a47bd | 9404 | SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST), |
f5fcc13c TI |
9405 | SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP), |
9406 | SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP), | |
f223a9fc | 9407 | SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP), |
83c34218 | 9408 | SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP), |
f5fcc13c | 9409 | SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS), |
83c34218 | 9410 | SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG), |
ad5e7737 | 9411 | SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA), |
f5fcc13c TI |
9412 | SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), |
9413 | SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31), | |
35739bb1 | 9414 | SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), |
4147dab6 | 9415 | SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31), |
07e038b3 | 9416 | SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST), |
f5fcc13c | 9417 | SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST), |
df694daa KY |
9418 | {} |
9419 | }; | |
9420 | ||
9421 | static struct alc_config_preset alc861_presets[] = { | |
9422 | [ALC861_3ST] = { | |
9423 | .mixers = { alc861_3ST_mixer }, | |
9424 | .init_verbs = { alc861_threestack_init_verbs }, | |
9425 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
9426 | .dac_nids = alc861_dac_nids, | |
9427 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
9428 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 9429 | .need_dac_fix = 1, |
df694daa KY |
9430 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
9431 | .adc_nids = alc861_adc_nids, | |
9432 | .input_mux = &alc861_capture_source, | |
9433 | }, | |
9434 | [ALC861_3ST_DIG] = { | |
9435 | .mixers = { alc861_base_mixer }, | |
9436 | .init_verbs = { alc861_threestack_init_verbs }, | |
9437 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
9438 | .dac_nids = alc861_dac_nids, | |
9439 | .dig_out_nid = ALC861_DIGOUT_NID, | |
9440 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
9441 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 9442 | .need_dac_fix = 1, |
df694daa KY |
9443 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
9444 | .adc_nids = alc861_adc_nids, | |
9445 | .input_mux = &alc861_capture_source, | |
9446 | }, | |
9447 | [ALC861_6ST_DIG] = { | |
9448 | .mixers = { alc861_base_mixer }, | |
9449 | .init_verbs = { alc861_base_init_verbs }, | |
9450 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
9451 | .dac_nids = alc861_dac_nids, | |
9452 | .dig_out_nid = ALC861_DIGOUT_NID, | |
9453 | .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes), | |
9454 | .channel_mode = alc861_8ch_modes, | |
9455 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
9456 | .adc_nids = alc861_adc_nids, | |
9457 | .input_mux = &alc861_capture_source, | |
9458 | }, | |
9c7f852e TI |
9459 | [ALC660_3ST] = { |
9460 | .mixers = { alc861_3ST_mixer }, | |
9461 | .init_verbs = { alc861_threestack_init_verbs }, | |
9462 | .num_dacs = ARRAY_SIZE(alc660_dac_nids), | |
9463 | .dac_nids = alc660_dac_nids, | |
9464 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
9465 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 9466 | .need_dac_fix = 1, |
9c7f852e TI |
9467 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
9468 | .adc_nids = alc861_adc_nids, | |
9469 | .input_mux = &alc861_capture_source, | |
9470 | }, | |
22309c3e TI |
9471 | [ALC861_UNIWILL_M31] = { |
9472 | .mixers = { alc861_uniwill_m31_mixer }, | |
9473 | .init_verbs = { alc861_uniwill_m31_init_verbs }, | |
9474 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
9475 | .dac_nids = alc861_dac_nids, | |
9476 | .dig_out_nid = ALC861_DIGOUT_NID, | |
9477 | .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes), | |
9478 | .channel_mode = alc861_uniwill_m31_modes, | |
9479 | .need_dac_fix = 1, | |
9480 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
9481 | .adc_nids = alc861_adc_nids, | |
9482 | .input_mux = &alc861_capture_source, | |
9483 | }, | |
a53d1aec TD |
9484 | [ALC861_TOSHIBA] = { |
9485 | .mixers = { alc861_toshiba_mixer }, | |
f12ab1e0 TI |
9486 | .init_verbs = { alc861_base_init_verbs, |
9487 | alc861_toshiba_init_verbs }, | |
a53d1aec TD |
9488 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), |
9489 | .dac_nids = alc861_dac_nids, | |
9490 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
9491 | .channel_mode = alc883_3ST_2ch_modes, | |
9492 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
9493 | .adc_nids = alc861_adc_nids, | |
9494 | .input_mux = &alc861_capture_source, | |
9495 | .unsol_event = alc861_toshiba_unsol_event, | |
9496 | .init_hook = alc861_toshiba_automute, | |
9497 | }, | |
7cdbff94 MD |
9498 | [ALC861_ASUS] = { |
9499 | .mixers = { alc861_asus_mixer }, | |
9500 | .init_verbs = { alc861_asus_init_verbs }, | |
9501 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
9502 | .dac_nids = alc861_dac_nids, | |
9503 | .dig_out_nid = ALC861_DIGOUT_NID, | |
9504 | .num_channel_mode = ARRAY_SIZE(alc861_asus_modes), | |
9505 | .channel_mode = alc861_asus_modes, | |
9506 | .need_dac_fix = 1, | |
9507 | .hp_nid = 0x06, | |
9508 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
9509 | .adc_nids = alc861_adc_nids, | |
9510 | .input_mux = &alc861_capture_source, | |
9511 | }, | |
56bb0cab TI |
9512 | [ALC861_ASUS_LAPTOP] = { |
9513 | .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer }, | |
9514 | .init_verbs = { alc861_asus_init_verbs, | |
9515 | alc861_asus_laptop_init_verbs }, | |
9516 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
9517 | .dac_nids = alc861_dac_nids, | |
9518 | .dig_out_nid = ALC861_DIGOUT_NID, | |
9519 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
9520 | .channel_mode = alc883_3ST_2ch_modes, | |
9521 | .need_dac_fix = 1, | |
9522 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
9523 | .adc_nids = alc861_adc_nids, | |
9524 | .input_mux = &alc861_capture_source, | |
9525 | }, | |
9526 | }; | |
df694daa KY |
9527 | |
9528 | ||
9529 | static int patch_alc861(struct hda_codec *codec) | |
9530 | { | |
9531 | struct alc_spec *spec; | |
9532 | int board_config; | |
9533 | int err; | |
9534 | ||
dc041e0b | 9535 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
df694daa KY |
9536 | if (spec == NULL) |
9537 | return -ENOMEM; | |
9538 | ||
f12ab1e0 | 9539 | codec->spec = spec; |
df694daa | 9540 | |
f5fcc13c TI |
9541 | board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST, |
9542 | alc861_models, | |
9543 | alc861_cfg_tbl); | |
9c7f852e | 9544 | |
f5fcc13c | 9545 | if (board_config < 0) { |
9c7f852e TI |
9546 | printk(KERN_INFO "hda_codec: Unknown model for ALC861, " |
9547 | "trying auto-probe from BIOS...\n"); | |
df694daa KY |
9548 | board_config = ALC861_AUTO; |
9549 | } | |
9550 | ||
9551 | if (board_config == ALC861_AUTO) { | |
9552 | /* automatic parse from the BIOS config */ | |
9553 | err = alc861_parse_auto_config(codec); | |
9554 | if (err < 0) { | |
9555 | alc_free(codec); | |
9556 | return err; | |
f12ab1e0 | 9557 | } else if (!err) { |
9c7f852e TI |
9558 | printk(KERN_INFO |
9559 | "hda_codec: Cannot set up configuration " | |
9560 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
9561 | board_config = ALC861_3ST_DIG; |
9562 | } | |
9563 | } | |
9564 | ||
9565 | if (board_config != ALC861_AUTO) | |
9566 | setup_preset(spec, &alc861_presets[board_config]); | |
9567 | ||
9568 | spec->stream_name_analog = "ALC861 Analog"; | |
9569 | spec->stream_analog_playback = &alc861_pcm_analog_playback; | |
9570 | spec->stream_analog_capture = &alc861_pcm_analog_capture; | |
9571 | ||
9572 | spec->stream_name_digital = "ALC861 Digital"; | |
9573 | spec->stream_digital_playback = &alc861_pcm_digital_playback; | |
9574 | spec->stream_digital_capture = &alc861_pcm_digital_capture; | |
9575 | ||
9576 | codec->patch_ops = alc_patch_ops; | |
9577 | if (board_config == ALC861_AUTO) | |
ae6b813a | 9578 | spec->init_hook = alc861_auto_init; |
df694daa | 9579 | |
1da177e4 LT |
9580 | return 0; |
9581 | } | |
9582 | ||
f32610ed JS |
9583 | /* |
9584 | * ALC861-VD support | |
9585 | * | |
9586 | * Based on ALC882 | |
9587 | * | |
9588 | * In addition, an independent DAC | |
9589 | */ | |
9590 | #define ALC861VD_DIGOUT_NID 0x06 | |
9591 | ||
9592 | static hda_nid_t alc861vd_dac_nids[4] = { | |
9593 | /* front, surr, clfe, side surr */ | |
9594 | 0x02, 0x03, 0x04, 0x05 | |
9595 | }; | |
9596 | ||
9597 | /* dac_nids for ALC660vd are in a different order - according to | |
9598 | * Realtek's driver. | |
9599 | * This should probably tesult in a different mixer for 6stack models | |
9600 | * of ALC660vd codecs, but for now there is only 3stack mixer | |
9601 | * - and it is the same as in 861vd. | |
9602 | * adc_nids in ALC660vd are (is) the same as in 861vd | |
9603 | */ | |
9604 | static hda_nid_t alc660vd_dac_nids[3] = { | |
9605 | /* front, rear, clfe, rear_surr */ | |
9606 | 0x02, 0x04, 0x03 | |
9607 | }; | |
9608 | ||
9609 | static hda_nid_t alc861vd_adc_nids[1] = { | |
9610 | /* ADC0 */ | |
9611 | 0x09, | |
9612 | }; | |
9613 | ||
9614 | /* input MUX */ | |
9615 | /* FIXME: should be a matrix-type input source selection */ | |
9616 | static struct hda_input_mux alc861vd_capture_source = { | |
9617 | .num_items = 4, | |
9618 | .items = { | |
9619 | { "Mic", 0x0 }, | |
9620 | { "Front Mic", 0x1 }, | |
9621 | { "Line", 0x2 }, | |
9622 | { "CD", 0x4 }, | |
9623 | }, | |
9624 | }; | |
9625 | ||
272a527c KY |
9626 | static struct hda_input_mux alc861vd_dallas_capture_source = { |
9627 | .num_items = 3, | |
9628 | .items = { | |
9629 | { "Front Mic", 0x0 }, | |
9630 | { "ATAPI Mic", 0x1 }, | |
9631 | { "Line In", 0x5 }, | |
9632 | }, | |
9633 | }; | |
9634 | ||
f32610ed JS |
9635 | #define alc861vd_mux_enum_info alc_mux_enum_info |
9636 | #define alc861vd_mux_enum_get alc_mux_enum_get | |
9637 | ||
9638 | static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol, | |
9639 | struct snd_ctl_elem_value *ucontrol) | |
9640 | { | |
9641 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
9642 | struct alc_spec *spec = codec->spec; | |
9643 | const struct hda_input_mux *imux = spec->input_mux; | |
9644 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
9645 | static hda_nid_t capture_mixers[1] = { 0x22 }; | |
9646 | hda_nid_t nid = capture_mixers[adc_idx]; | |
9647 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; | |
9648 | unsigned int i, idx; | |
9649 | ||
9650 | idx = ucontrol->value.enumerated.item[0]; | |
9651 | if (idx >= imux->num_items) | |
9652 | idx = imux->num_items - 1; | |
f12ab1e0 | 9653 | if (*cur_val == idx && !codec->in_resume) |
f32610ed JS |
9654 | return 0; |
9655 | for (i = 0; i < imux->num_items; i++) { | |
9656 | unsigned int v = (i == idx) ? 0x7000 : 0x7080; | |
9657 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
9658 | v | (imux->items[i].index << 8)); | |
9659 | } | |
9660 | *cur_val = idx; | |
9661 | return 1; | |
9662 | } | |
9663 | ||
9664 | /* | |
9665 | * 2ch mode | |
9666 | */ | |
9667 | static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = { | |
9668 | { 2, NULL } | |
9669 | }; | |
9670 | ||
9671 | /* | |
9672 | * 6ch mode | |
9673 | */ | |
9674 | static struct hda_verb alc861vd_6stack_ch6_init[] = { | |
9675 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
9676 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
9677 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
9678 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
9679 | { } /* end */ | |
9680 | }; | |
9681 | ||
9682 | /* | |
9683 | * 8ch mode | |
9684 | */ | |
9685 | static struct hda_verb alc861vd_6stack_ch8_init[] = { | |
9686 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
9687 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
9688 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
9689 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
9690 | { } /* end */ | |
9691 | }; | |
9692 | ||
9693 | static struct hda_channel_mode alc861vd_6stack_modes[2] = { | |
9694 | { 6, alc861vd_6stack_ch6_init }, | |
9695 | { 8, alc861vd_6stack_ch8_init }, | |
9696 | }; | |
9697 | ||
9698 | static struct snd_kcontrol_new alc861vd_chmode_mixer[] = { | |
9699 | { | |
9700 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9701 | .name = "Channel Mode", | |
9702 | .info = alc_ch_mode_info, | |
9703 | .get = alc_ch_mode_get, | |
9704 | .put = alc_ch_mode_put, | |
9705 | }, | |
9706 | { } /* end */ | |
9707 | }; | |
9708 | ||
9709 | static struct snd_kcontrol_new alc861vd_capture_mixer[] = { | |
9710 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
9711 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
9712 | ||
9713 | { | |
9714 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9715 | /* The multiple "Capture Source" controls confuse alsamixer | |
9716 | * So call somewhat different.. | |
9717 | *FIXME: the controls appear in the "playback" view! | |
9718 | */ | |
9719 | /* .name = "Capture Source", */ | |
9720 | .name = "Input Source", | |
9721 | .count = 1, | |
9722 | .info = alc861vd_mux_enum_info, | |
9723 | .get = alc861vd_mux_enum_get, | |
9724 | .put = alc861vd_mux_enum_put, | |
9725 | }, | |
9726 | { } /* end */ | |
9727 | }; | |
9728 | ||
9729 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 | |
9730 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
9731 | */ | |
9732 | static struct snd_kcontrol_new alc861vd_6st_mixer[] = { | |
9733 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
9734 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
9735 | ||
9736 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
9737 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
9738 | ||
9739 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, | |
9740 | HDA_OUTPUT), | |
9741 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, | |
9742 | HDA_OUTPUT), | |
9743 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
9744 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
9745 | ||
9746 | HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT), | |
9747 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
9748 | ||
9749 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
9750 | ||
9751 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
9752 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9753 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9754 | ||
9755 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
9756 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
9757 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
9758 | ||
9759 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
9760 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
9761 | ||
9762 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
9763 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
9764 | ||
9765 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
9766 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
9767 | ||
9768 | { } /* end */ | |
9769 | }; | |
9770 | ||
9771 | static struct snd_kcontrol_new alc861vd_3st_mixer[] = { | |
9772 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
9773 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
9774 | ||
9775 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
9776 | ||
9777 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
9778 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9779 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9780 | ||
9781 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
9782 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
9783 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
9784 | ||
9785 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
9786 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
9787 | ||
9788 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
9789 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
9790 | ||
9791 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
9792 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
9793 | ||
9794 | { } /* end */ | |
9795 | }; | |
9796 | ||
bdd148a3 KY |
9797 | static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = { |
9798 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
9799 | /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/ | |
9800 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
9801 | ||
9802 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
9803 | ||
9804 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
9805 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9806 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9807 | ||
9808 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
9809 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
9810 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
9811 | ||
9812 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
9813 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
9814 | ||
9815 | { } /* end */ | |
9816 | }; | |
9817 | ||
272a527c KY |
9818 | /* Pin assignment: Front=0x14, HP = 0x15, |
9819 | * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d | |
9820 | */ | |
9821 | static struct snd_kcontrol_new alc861vd_dallas_mixer[] = { | |
9822 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
9823 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
9824 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
9825 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), | |
9826 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9827 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9828 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
9829 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
9830 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
9831 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
9832 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
9833 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
9834 | { | |
9835 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9836 | /* .name = "Capture Source", */ | |
9837 | .name = "Input Source", | |
9838 | .count = 1, | |
9839 | .info = alc882_mux_enum_info, | |
9840 | .get = alc882_mux_enum_get, | |
9841 | .put = alc882_mux_enum_put, | |
9842 | }, | |
9843 | { } /* end */ | |
9844 | }; | |
9845 | ||
f32610ed JS |
9846 | /* |
9847 | * generic initialization of ADC, input mixers and output mixers | |
9848 | */ | |
9849 | static struct hda_verb alc861vd_volume_init_verbs[] = { | |
9850 | /* | |
9851 | * Unmute ADC0 and set the default input to mic-in | |
9852 | */ | |
9853 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9854 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9855 | ||
9856 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of | |
9857 | * the analog-loopback mixer widget | |
9858 | */ | |
9859 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
9860 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9861 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9862 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
9863 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
9864 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
9865 | ||
9866 | /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */ | |
bdd148a3 KY |
9867 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
9868 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9869 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f32610ed | 9870 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
f32610ed JS |
9871 | |
9872 | /* | |
9873 | * Set up output mixers (0x02 - 0x05) | |
9874 | */ | |
9875 | /* set vol=0 to output mixers */ | |
9876 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9877 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9878 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9879 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9880 | ||
9881 | /* set up input amps for analog loopback */ | |
9882 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
9883 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
9884 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
9885 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
9886 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
9887 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
9888 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
9889 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
9890 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
9891 | ||
9892 | { } | |
9893 | }; | |
9894 | ||
9895 | /* | |
9896 | * 3-stack pin configuration: | |
9897 | * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b | |
9898 | */ | |
9899 | static struct hda_verb alc861vd_3stack_init_verbs[] = { | |
9900 | /* | |
9901 | * Set pin mode and muting | |
9902 | */ | |
9903 | /* set front pin widgets 0x14 for output */ | |
9904 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9905 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9906 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9907 | ||
9908 | /* Mic (rear) pin: input vref at 80% */ | |
9909 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
9910 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9911 | /* Front Mic pin: input vref at 80% */ | |
9912 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
9913 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9914 | /* Line In pin: input */ | |
9915 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
9916 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9917 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
9918 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
9919 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9920 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9921 | /* CD pin widget for input */ | |
9922 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
9923 | ||
9924 | { } | |
9925 | }; | |
9926 | ||
9927 | /* | |
9928 | * 6-stack pin configuration: | |
9929 | */ | |
9930 | static struct hda_verb alc861vd_6stack_init_verbs[] = { | |
9931 | /* | |
9932 | * Set pin mode and muting | |
9933 | */ | |
9934 | /* set front pin widgets 0x14 for output */ | |
9935 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9936 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9937 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9938 | ||
9939 | /* Rear Pin: output 1 (0x0d) */ | |
9940 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9941 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9942 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
9943 | /* CLFE Pin: output 2 (0x0e) */ | |
9944 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9945 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9946 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
9947 | /* Side Pin: output 3 (0x0f) */ | |
9948 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9949 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9950 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
9951 | ||
9952 | /* Mic (rear) pin: input vref at 80% */ | |
9953 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
9954 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9955 | /* Front Mic pin: input vref at 80% */ | |
9956 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
9957 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9958 | /* Line In pin: input */ | |
9959 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
9960 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9961 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
9962 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
9963 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9964 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9965 | /* CD pin widget for input */ | |
9966 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
9967 | ||
9968 | { } | |
9969 | }; | |
9970 | ||
bdd148a3 KY |
9971 | static struct hda_verb alc861vd_eapd_verbs[] = { |
9972 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
9973 | { } | |
9974 | }; | |
9975 | ||
9976 | static struct hda_verb alc861vd_lenovo_unsol_verbs[] = { | |
9977 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9978 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9979 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
9980 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
9981 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
9982 | {} | |
9983 | }; | |
9984 | ||
9985 | /* toggle speaker-output according to the hp-jack state */ | |
9986 | static void alc861vd_lenovo_hp_automute(struct hda_codec *codec) | |
9987 | { | |
9988 | unsigned int present; | |
9989 | unsigned char bits; | |
9990 | ||
9991 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
9992 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
9993 | bits = present ? 0x80 : 0; | |
9994 | snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, | |
9995 | 0x80, bits); | |
9996 | snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, | |
9997 | 0x80, bits); | |
9998 | } | |
9999 | ||
10000 | static void alc861vd_lenovo_mic_automute(struct hda_codec *codec) | |
10001 | { | |
10002 | unsigned int present; | |
10003 | unsigned char bits; | |
10004 | ||
10005 | present = snd_hda_codec_read(codec, 0x18, 0, | |
10006 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
10007 | bits = present ? 0x80 : 0; | |
10008 | snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1, | |
10009 | 0x80, bits); | |
10010 | snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1, | |
10011 | 0x80, bits); | |
10012 | } | |
10013 | ||
10014 | static void alc861vd_lenovo_automute(struct hda_codec *codec) | |
10015 | { | |
10016 | alc861vd_lenovo_hp_automute(codec); | |
10017 | alc861vd_lenovo_mic_automute(codec); | |
10018 | } | |
10019 | ||
10020 | static void alc861vd_lenovo_unsol_event(struct hda_codec *codec, | |
10021 | unsigned int res) | |
10022 | { | |
10023 | switch (res >> 26) { | |
10024 | case ALC880_HP_EVENT: | |
10025 | alc861vd_lenovo_hp_automute(codec); | |
10026 | break; | |
10027 | case ALC880_MIC_EVENT: | |
10028 | alc861vd_lenovo_mic_automute(codec); | |
10029 | break; | |
10030 | } | |
10031 | } | |
10032 | ||
272a527c KY |
10033 | static struct hda_verb alc861vd_dallas_verbs[] = { |
10034 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10035 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10036 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10037 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10038 | ||
10039 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10040 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10041 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
10042 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10043 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
10044 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10045 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
10046 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10047 | ||
10048 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
10049 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10050 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
10051 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10052 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
10053 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10054 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
10055 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10056 | ||
10057 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | |
10058 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10059 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | |
10060 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10061 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
10062 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
10063 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
10064 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
10065 | ||
10066 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10067 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
10068 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
10069 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
10070 | ||
10071 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
10072 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10073 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
10074 | ||
10075 | { } /* end */ | |
10076 | }; | |
10077 | ||
10078 | /* toggle speaker-output according to the hp-jack state */ | |
10079 | static void alc861vd_dallas_automute(struct hda_codec *codec) | |
10080 | { | |
10081 | unsigned int present; | |
10082 | ||
10083 | present = snd_hda_codec_read(codec, 0x15, 0, | |
10084 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
10085 | snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, | |
10086 | 0x80, present ? 0x80 : 0); | |
10087 | snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, | |
10088 | 0x80, present ? 0x80 : 0); | |
10089 | } | |
10090 | ||
10091 | static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res) | |
10092 | { | |
10093 | if ((res >> 26) == ALC880_HP_EVENT) | |
10094 | alc861vd_dallas_automute(codec); | |
10095 | } | |
10096 | ||
f32610ed JS |
10097 | /* pcm configuration: identiacal with ALC880 */ |
10098 | #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback | |
10099 | #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture | |
10100 | #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback | |
10101 | #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture | |
10102 | ||
10103 | /* | |
10104 | * configuration and preset | |
10105 | */ | |
10106 | static const char *alc861vd_models[ALC861VD_MODEL_LAST] = { | |
10107 | [ALC660VD_3ST] = "3stack-660", | |
6963f84c | 10108 | [ALC660VD_3ST_DIG]= "3stack-660-digout", |
f32610ed JS |
10109 | [ALC861VD_3ST] = "3stack", |
10110 | [ALC861VD_3ST_DIG] = "3stack-digout", | |
10111 | [ALC861VD_6ST_DIG] = "6stack-digout", | |
bdd148a3 | 10112 | [ALC861VD_LENOVO] = "lenovo", |
272a527c | 10113 | [ALC861VD_DALLAS] = "dallas", |
f32610ed JS |
10114 | [ALC861VD_AUTO] = "auto", |
10115 | }; | |
10116 | ||
10117 | static struct snd_pci_quirk alc861vd_cfg_tbl[] = { | |
07e038b3 | 10118 | SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST), |
f32610ed | 10119 | SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST), |
6963f84c | 10120 | SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG), |
f32610ed JS |
10121 | SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST), |
10122 | SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST), | |
10123 | ||
272a527c KY |
10124 | SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS), |
10125 | SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS), | |
bdd148a3 KY |
10126 | SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO), |
10127 | SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO), | |
a18519e1 | 10128 | SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO), |
f32610ed JS |
10129 | {} |
10130 | }; | |
10131 | ||
10132 | static struct alc_config_preset alc861vd_presets[] = { | |
10133 | [ALC660VD_3ST] = { | |
10134 | .mixers = { alc861vd_3st_mixer }, | |
10135 | .init_verbs = { alc861vd_volume_init_verbs, | |
10136 | alc861vd_3stack_init_verbs }, | |
10137 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
10138 | .dac_nids = alc660vd_dac_nids, | |
10139 | .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids), | |
10140 | .adc_nids = alc861vd_adc_nids, | |
10141 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
10142 | .channel_mode = alc861vd_3stack_2ch_modes, | |
10143 | .input_mux = &alc861vd_capture_source, | |
10144 | }, | |
6963f84c MC |
10145 | [ALC660VD_3ST_DIG] = { |
10146 | .mixers = { alc861vd_3st_mixer }, | |
10147 | .init_verbs = { alc861vd_volume_init_verbs, | |
10148 | alc861vd_3stack_init_verbs }, | |
10149 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
10150 | .dac_nids = alc660vd_dac_nids, | |
10151 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
10152 | .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids), | |
10153 | .adc_nids = alc861vd_adc_nids, | |
10154 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
10155 | .channel_mode = alc861vd_3stack_2ch_modes, | |
10156 | .input_mux = &alc861vd_capture_source, | |
10157 | }, | |
f32610ed JS |
10158 | [ALC861VD_3ST] = { |
10159 | .mixers = { alc861vd_3st_mixer }, | |
10160 | .init_verbs = { alc861vd_volume_init_verbs, | |
10161 | alc861vd_3stack_init_verbs }, | |
10162 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
10163 | .dac_nids = alc861vd_dac_nids, | |
10164 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
10165 | .channel_mode = alc861vd_3stack_2ch_modes, | |
10166 | .input_mux = &alc861vd_capture_source, | |
10167 | }, | |
10168 | [ALC861VD_3ST_DIG] = { | |
10169 | .mixers = { alc861vd_3st_mixer }, | |
10170 | .init_verbs = { alc861vd_volume_init_verbs, | |
10171 | alc861vd_3stack_init_verbs }, | |
10172 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
10173 | .dac_nids = alc861vd_dac_nids, | |
10174 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
10175 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
10176 | .channel_mode = alc861vd_3stack_2ch_modes, | |
10177 | .input_mux = &alc861vd_capture_source, | |
10178 | }, | |
10179 | [ALC861VD_6ST_DIG] = { | |
10180 | .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer }, | |
10181 | .init_verbs = { alc861vd_volume_init_verbs, | |
10182 | alc861vd_6stack_init_verbs }, | |
10183 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
10184 | .dac_nids = alc861vd_dac_nids, | |
10185 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
10186 | .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes), | |
10187 | .channel_mode = alc861vd_6stack_modes, | |
10188 | .input_mux = &alc861vd_capture_source, | |
10189 | }, | |
bdd148a3 KY |
10190 | [ALC861VD_LENOVO] = { |
10191 | .mixers = { alc861vd_lenovo_mixer }, | |
10192 | .init_verbs = { alc861vd_volume_init_verbs, | |
10193 | alc861vd_3stack_init_verbs, | |
10194 | alc861vd_eapd_verbs, | |
10195 | alc861vd_lenovo_unsol_verbs }, | |
10196 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
10197 | .dac_nids = alc660vd_dac_nids, | |
10198 | .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids), | |
10199 | .adc_nids = alc861vd_adc_nids, | |
10200 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
10201 | .channel_mode = alc861vd_3stack_2ch_modes, | |
10202 | .input_mux = &alc861vd_capture_source, | |
10203 | .unsol_event = alc861vd_lenovo_unsol_event, | |
10204 | .init_hook = alc861vd_lenovo_automute, | |
10205 | }, | |
272a527c KY |
10206 | [ALC861VD_DALLAS] = { |
10207 | .mixers = { alc861vd_dallas_mixer }, | |
10208 | .init_verbs = { alc861vd_dallas_verbs }, | |
10209 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
10210 | .dac_nids = alc861vd_dac_nids, | |
10211 | .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids), | |
10212 | .adc_nids = alc861vd_adc_nids, | |
10213 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
10214 | .channel_mode = alc861vd_3stack_2ch_modes, | |
10215 | .input_mux = &alc861vd_dallas_capture_source, | |
10216 | .unsol_event = alc861vd_dallas_unsol_event, | |
10217 | .init_hook = alc861vd_dallas_automute, | |
10218 | }, | |
f32610ed JS |
10219 | }; |
10220 | ||
10221 | /* | |
10222 | * BIOS auto configuration | |
10223 | */ | |
10224 | static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec, | |
10225 | hda_nid_t nid, int pin_type, int dac_idx) | |
10226 | { | |
10227 | /* set as output */ | |
10228 | snd_hda_codec_write(codec, nid, 0, | |
10229 | AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); | |
10230 | snd_hda_codec_write(codec, nid, 0, | |
10231 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); | |
10232 | } | |
10233 | ||
10234 | static void alc861vd_auto_init_multi_out(struct hda_codec *codec) | |
10235 | { | |
10236 | struct alc_spec *spec = codec->spec; | |
10237 | int i; | |
10238 | ||
bc9f98a9 | 10239 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
f32610ed JS |
10240 | for (i = 0; i <= HDA_SIDE; i++) { |
10241 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 10242 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
f32610ed JS |
10243 | if (nid) |
10244 | alc861vd_auto_set_output_and_unmute(codec, nid, | |
baba8ee9 | 10245 | pin_type, i); |
f32610ed JS |
10246 | } |
10247 | } | |
10248 | ||
10249 | ||
10250 | static void alc861vd_auto_init_hp_out(struct hda_codec *codec) | |
10251 | { | |
10252 | struct alc_spec *spec = codec->spec; | |
10253 | hda_nid_t pin; | |
10254 | ||
10255 | pin = spec->autocfg.hp_pins[0]; | |
10256 | if (pin) /* connect to front and use dac 0 */ | |
10257 | alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
10258 | } | |
10259 | ||
10260 | #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid) | |
10261 | #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID | |
10262 | ||
10263 | static void alc861vd_auto_init_analog_input(struct hda_codec *codec) | |
10264 | { | |
10265 | struct alc_spec *spec = codec->spec; | |
10266 | int i; | |
10267 | ||
10268 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
10269 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
10270 | if (alc861vd_is_input_pin(nid)) { | |
10271 | snd_hda_codec_write(codec, nid, 0, | |
10272 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
10273 | i <= AUTO_PIN_FRONT_MIC ? | |
10274 | PIN_VREF80 : PIN_IN); | |
10275 | if (nid != ALC861VD_PIN_CD_NID) | |
10276 | snd_hda_codec_write(codec, nid, 0, | |
10277 | AC_VERB_SET_AMP_GAIN_MUTE, | |
10278 | AMP_OUT_MUTE); | |
10279 | } | |
10280 | } | |
10281 | } | |
10282 | ||
10283 | #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02) | |
10284 | #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c) | |
10285 | ||
10286 | /* add playback controls from the parsed DAC table */ | |
10287 | /* Based on ALC880 version. But ALC861VD has separate, | |
10288 | * different NIDs for mute/unmute switch and volume control */ | |
10289 | static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec, | |
10290 | const struct auto_pin_cfg *cfg) | |
10291 | { | |
10292 | char name[32]; | |
10293 | static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"}; | |
10294 | hda_nid_t nid_v, nid_s; | |
10295 | int i, err; | |
10296 | ||
10297 | for (i = 0; i < cfg->line_outs; i++) { | |
f12ab1e0 | 10298 | if (!spec->multiout.dac_nids[i]) |
f32610ed JS |
10299 | continue; |
10300 | nid_v = alc861vd_idx_to_mixer_vol( | |
10301 | alc880_dac_to_idx( | |
10302 | spec->multiout.dac_nids[i])); | |
10303 | nid_s = alc861vd_idx_to_mixer_switch( | |
10304 | alc880_dac_to_idx( | |
10305 | spec->multiout.dac_nids[i])); | |
10306 | ||
10307 | if (i == 2) { | |
10308 | /* Center/LFE */ | |
f12ab1e0 TI |
10309 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
10310 | "Center Playback Volume", | |
10311 | HDA_COMPOSE_AMP_VAL(nid_v, 1, 0, | |
10312 | HDA_OUTPUT)); | |
10313 | if (err < 0) | |
f32610ed | 10314 | return err; |
f12ab1e0 TI |
10315 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
10316 | "LFE Playback Volume", | |
10317 | HDA_COMPOSE_AMP_VAL(nid_v, 2, 0, | |
10318 | HDA_OUTPUT)); | |
10319 | if (err < 0) | |
f32610ed | 10320 | return err; |
f12ab1e0 TI |
10321 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
10322 | "Center Playback Switch", | |
10323 | HDA_COMPOSE_AMP_VAL(nid_s, 1, 2, | |
10324 | HDA_INPUT)); | |
10325 | if (err < 0) | |
f32610ed | 10326 | return err; |
f12ab1e0 TI |
10327 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
10328 | "LFE Playback Switch", | |
10329 | HDA_COMPOSE_AMP_VAL(nid_s, 2, 2, | |
10330 | HDA_INPUT)); | |
10331 | if (err < 0) | |
f32610ed JS |
10332 | return err; |
10333 | } else { | |
10334 | sprintf(name, "%s Playback Volume", chname[i]); | |
f12ab1e0 TI |
10335 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
10336 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, | |
10337 | HDA_OUTPUT)); | |
10338 | if (err < 0) | |
f32610ed JS |
10339 | return err; |
10340 | sprintf(name, "%s Playback Switch", chname[i]); | |
f12ab1e0 | 10341 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
bdd148a3 | 10342 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, |
f12ab1e0 TI |
10343 | HDA_INPUT)); |
10344 | if (err < 0) | |
f32610ed JS |
10345 | return err; |
10346 | } | |
10347 | } | |
10348 | return 0; | |
10349 | } | |
10350 | ||
10351 | /* add playback controls for speaker and HP outputs */ | |
10352 | /* Based on ALC880 version. But ALC861VD has separate, | |
10353 | * different NIDs for mute/unmute switch and volume control */ | |
10354 | static int alc861vd_auto_create_extra_out(struct alc_spec *spec, | |
10355 | hda_nid_t pin, const char *pfx) | |
10356 | { | |
10357 | hda_nid_t nid_v, nid_s; | |
10358 | int err; | |
10359 | char name[32]; | |
10360 | ||
f12ab1e0 | 10361 | if (!pin) |
f32610ed JS |
10362 | return 0; |
10363 | ||
10364 | if (alc880_is_fixed_pin(pin)) { | |
10365 | nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
10366 | /* specify the DAC as the extra output */ | |
f12ab1e0 | 10367 | if (!spec->multiout.hp_nid) |
f32610ed JS |
10368 | spec->multiout.hp_nid = nid_v; |
10369 | else | |
10370 | spec->multiout.extra_out_nid[0] = nid_v; | |
10371 | /* control HP volume/switch on the output mixer amp */ | |
10372 | nid_v = alc861vd_idx_to_mixer_vol( | |
10373 | alc880_fixed_pin_idx(pin)); | |
10374 | nid_s = alc861vd_idx_to_mixer_switch( | |
10375 | alc880_fixed_pin_idx(pin)); | |
10376 | ||
10377 | sprintf(name, "%s Playback Volume", pfx); | |
f12ab1e0 TI |
10378 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
10379 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT)); | |
10380 | if (err < 0) | |
f32610ed JS |
10381 | return err; |
10382 | sprintf(name, "%s Playback Switch", pfx); | |
f12ab1e0 TI |
10383 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
10384 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT)); | |
10385 | if (err < 0) | |
f32610ed JS |
10386 | return err; |
10387 | } else if (alc880_is_multi_pin(pin)) { | |
10388 | /* set manual connection */ | |
10389 | /* we have only a switch on HP-out PIN */ | |
10390 | sprintf(name, "%s Playback Switch", pfx); | |
f12ab1e0 TI |
10391 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
10392 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
10393 | if (err < 0) | |
f32610ed JS |
10394 | return err; |
10395 | } | |
10396 | return 0; | |
10397 | } | |
10398 | ||
10399 | /* parse the BIOS configuration and set up the alc_spec | |
10400 | * return 1 if successful, 0 if the proper config is not found, | |
10401 | * or a negative error code | |
10402 | * Based on ALC880 version - had to change it to override | |
10403 | * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */ | |
10404 | static int alc861vd_parse_auto_config(struct hda_codec *codec) | |
10405 | { | |
10406 | struct alc_spec *spec = codec->spec; | |
10407 | int err; | |
10408 | static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; | |
10409 | ||
f12ab1e0 TI |
10410 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
10411 | alc861vd_ignore); | |
10412 | if (err < 0) | |
f32610ed | 10413 | return err; |
f12ab1e0 | 10414 | if (!spec->autocfg.line_outs) |
f32610ed JS |
10415 | return 0; /* can't find valid BIOS pin config */ |
10416 | ||
f12ab1e0 TI |
10417 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
10418 | if (err < 0) | |
10419 | return err; | |
10420 | err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
10421 | if (err < 0) | |
10422 | return err; | |
10423 | err = alc861vd_auto_create_extra_out(spec, | |
10424 | spec->autocfg.speaker_pins[0], | |
10425 | "Speaker"); | |
10426 | if (err < 0) | |
10427 | return err; | |
10428 | err = alc861vd_auto_create_extra_out(spec, | |
10429 | spec->autocfg.hp_pins[0], | |
10430 | "Headphone"); | |
10431 | if (err < 0) | |
10432 | return err; | |
10433 | err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
10434 | if (err < 0) | |
f32610ed JS |
10435 | return err; |
10436 | ||
10437 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
10438 | ||
10439 | if (spec->autocfg.dig_out_pin) | |
10440 | spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID; | |
10441 | ||
10442 | if (spec->kctl_alloc) | |
10443 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
10444 | ||
10445 | spec->init_verbs[spec->num_init_verbs++] | |
10446 | = alc861vd_volume_init_verbs; | |
10447 | ||
10448 | spec->num_mux_defs = 1; | |
10449 | spec->input_mux = &spec->private_imux; | |
10450 | ||
10451 | return 1; | |
10452 | } | |
10453 | ||
10454 | /* additional initialization for auto-configuration model */ | |
10455 | static void alc861vd_auto_init(struct hda_codec *codec) | |
10456 | { | |
10457 | alc861vd_auto_init_multi_out(codec); | |
10458 | alc861vd_auto_init_hp_out(codec); | |
10459 | alc861vd_auto_init_analog_input(codec); | |
10460 | } | |
10461 | ||
10462 | static int patch_alc861vd(struct hda_codec *codec) | |
10463 | { | |
10464 | struct alc_spec *spec; | |
10465 | int err, board_config; | |
10466 | ||
10467 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
10468 | if (spec == NULL) | |
10469 | return -ENOMEM; | |
10470 | ||
10471 | codec->spec = spec; | |
10472 | ||
10473 | board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST, | |
10474 | alc861vd_models, | |
10475 | alc861vd_cfg_tbl); | |
10476 | ||
10477 | if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) { | |
10478 | printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/" | |
10479 | "ALC861VD, trying auto-probe from BIOS...\n"); | |
10480 | board_config = ALC861VD_AUTO; | |
10481 | } | |
10482 | ||
10483 | if (board_config == ALC861VD_AUTO) { | |
10484 | /* automatic parse from the BIOS config */ | |
10485 | err = alc861vd_parse_auto_config(codec); | |
10486 | if (err < 0) { | |
10487 | alc_free(codec); | |
10488 | return err; | |
f12ab1e0 | 10489 | } else if (!err) { |
f32610ed JS |
10490 | printk(KERN_INFO |
10491 | "hda_codec: Cannot set up configuration " | |
10492 | "from BIOS. Using base mode...\n"); | |
10493 | board_config = ALC861VD_3ST; | |
10494 | } | |
10495 | } | |
10496 | ||
10497 | if (board_config != ALC861VD_AUTO) | |
10498 | setup_preset(spec, &alc861vd_presets[board_config]); | |
10499 | ||
10500 | spec->stream_name_analog = "ALC861VD Analog"; | |
10501 | spec->stream_analog_playback = &alc861vd_pcm_analog_playback; | |
10502 | spec->stream_analog_capture = &alc861vd_pcm_analog_capture; | |
10503 | ||
10504 | spec->stream_name_digital = "ALC861VD Digital"; | |
10505 | spec->stream_digital_playback = &alc861vd_pcm_digital_playback; | |
10506 | spec->stream_digital_capture = &alc861vd_pcm_digital_capture; | |
10507 | ||
10508 | spec->adc_nids = alc861vd_adc_nids; | |
10509 | spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids); | |
10510 | ||
10511 | spec->mixers[spec->num_mixers] = alc861vd_capture_mixer; | |
10512 | spec->num_mixers++; | |
10513 | ||
10514 | codec->patch_ops = alc_patch_ops; | |
10515 | ||
10516 | if (board_config == ALC861VD_AUTO) | |
10517 | spec->init_hook = alc861vd_auto_init; | |
10518 | ||
10519 | return 0; | |
10520 | } | |
10521 | ||
bc9f98a9 KY |
10522 | /* |
10523 | * ALC662 support | |
10524 | * | |
10525 | * ALC662 is almost identical with ALC880 but has cleaner and more flexible | |
10526 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
10527 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
10528 | * 6-channel independent captures. | |
10529 | * | |
10530 | * In addition, an independent DAC for the multi-playback (not used in this | |
10531 | * driver yet). | |
10532 | */ | |
10533 | #define ALC662_DIGOUT_NID 0x06 | |
10534 | #define ALC662_DIGIN_NID 0x0a | |
10535 | ||
10536 | static hda_nid_t alc662_dac_nids[4] = { | |
10537 | /* front, rear, clfe, rear_surr */ | |
10538 | 0x02, 0x03, 0x04 | |
10539 | }; | |
10540 | ||
10541 | static hda_nid_t alc662_adc_nids[1] = { | |
10542 | /* ADC1-2 */ | |
10543 | 0x09, | |
10544 | }; | |
10545 | /* input MUX */ | |
10546 | /* FIXME: should be a matrix-type input source selection */ | |
10547 | ||
10548 | static struct hda_input_mux alc662_capture_source = { | |
10549 | .num_items = 4, | |
10550 | .items = { | |
10551 | { "Mic", 0x0 }, | |
10552 | { "Front Mic", 0x1 }, | |
10553 | { "Line", 0x2 }, | |
10554 | { "CD", 0x4 }, | |
10555 | }, | |
10556 | }; | |
10557 | ||
10558 | static struct hda_input_mux alc662_lenovo_101e_capture_source = { | |
10559 | .num_items = 2, | |
10560 | .items = { | |
10561 | { "Mic", 0x1 }, | |
10562 | { "Line", 0x2 }, | |
10563 | }, | |
10564 | }; | |
10565 | #define alc662_mux_enum_info alc_mux_enum_info | |
10566 | #define alc662_mux_enum_get alc_mux_enum_get | |
10567 | ||
10568 | static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol, | |
10569 | struct snd_ctl_elem_value *ucontrol) | |
10570 | { | |
10571 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
10572 | struct alc_spec *spec = codec->spec; | |
10573 | const struct hda_input_mux *imux = spec->input_mux; | |
10574 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
10575 | static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 }; | |
10576 | hda_nid_t nid = capture_mixers[adc_idx]; | |
10577 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; | |
10578 | unsigned int i, idx; | |
10579 | ||
10580 | idx = ucontrol->value.enumerated.item[0]; | |
10581 | if (idx >= imux->num_items) | |
10582 | idx = imux->num_items - 1; | |
f12ab1e0 | 10583 | if (*cur_val == idx && !codec->in_resume) |
bc9f98a9 KY |
10584 | return 0; |
10585 | for (i = 0; i < imux->num_items; i++) { | |
10586 | unsigned int v = (i == idx) ? 0x7000 : 0x7080; | |
10587 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
10588 | v | (imux->items[i].index << 8)); | |
10589 | } | |
10590 | *cur_val = idx; | |
10591 | return 1; | |
10592 | } | |
10593 | /* | |
10594 | * 2ch mode | |
10595 | */ | |
10596 | static struct hda_channel_mode alc662_3ST_2ch_modes[1] = { | |
10597 | { 2, NULL } | |
10598 | }; | |
10599 | ||
10600 | /* | |
10601 | * 2ch mode | |
10602 | */ | |
10603 | static struct hda_verb alc662_3ST_ch2_init[] = { | |
10604 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
10605 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
10606 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
10607 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
10608 | { } /* end */ | |
10609 | }; | |
10610 | ||
10611 | /* | |
10612 | * 6ch mode | |
10613 | */ | |
10614 | static struct hda_verb alc662_3ST_ch6_init[] = { | |
10615 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
10616 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
10617 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
10618 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
10619 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
10620 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
10621 | { } /* end */ | |
10622 | }; | |
10623 | ||
10624 | static struct hda_channel_mode alc662_3ST_6ch_modes[2] = { | |
10625 | { 2, alc662_3ST_ch2_init }, | |
10626 | { 6, alc662_3ST_ch6_init }, | |
10627 | }; | |
10628 | ||
10629 | /* | |
10630 | * 2ch mode | |
10631 | */ | |
10632 | static struct hda_verb alc662_sixstack_ch6_init[] = { | |
10633 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
10634 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
10635 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
10636 | { } /* end */ | |
10637 | }; | |
10638 | ||
10639 | /* | |
10640 | * 6ch mode | |
10641 | */ | |
10642 | static struct hda_verb alc662_sixstack_ch8_init[] = { | |
10643 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
10644 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
10645 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
10646 | { } /* end */ | |
10647 | }; | |
10648 | ||
10649 | static struct hda_channel_mode alc662_5stack_modes[2] = { | |
10650 | { 2, alc662_sixstack_ch6_init }, | |
10651 | { 6, alc662_sixstack_ch8_init }, | |
10652 | }; | |
10653 | ||
10654 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 | |
10655 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
10656 | */ | |
10657 | ||
10658 | static struct snd_kcontrol_new alc662_base_mixer[] = { | |
10659 | /* output mixer control */ | |
10660 | HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT), | |
10661 | HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT), | |
10662 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT), | |
10663 | HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
10664 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), | |
10665 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), | |
10666 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT), | |
10667 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT), | |
10668 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
10669 | ||
10670 | /*Input mixer control */ | |
10671 | HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT), | |
10672 | HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT), | |
10673 | HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT), | |
10674 | HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT), | |
10675 | HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT), | |
10676 | HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT), | |
10677 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT), | |
10678 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT), | |
10679 | ||
10680 | /* Capture mixer control */ | |
10681 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
10682 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
10683 | { | |
10684 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10685 | .name = "Capture Source", | |
10686 | .count = 1, | |
10687 | .info = alc_mux_enum_info, | |
10688 | .get = alc_mux_enum_get, | |
10689 | .put = alc_mux_enum_put, | |
10690 | }, | |
10691 | { } /* end */ | |
10692 | }; | |
10693 | ||
10694 | static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = { | |
10695 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
10696 | HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT), | |
10697 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
10698 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
10699 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
10700 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
10701 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
10702 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
10703 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
10704 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
10705 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
10706 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
10707 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
10708 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
10709 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
10710 | { | |
10711 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10712 | /* .name = "Capture Source", */ | |
10713 | .name = "Input Source", | |
10714 | .count = 1, | |
10715 | .info = alc662_mux_enum_info, | |
10716 | .get = alc662_mux_enum_get, | |
10717 | .put = alc662_mux_enum_put, | |
10718 | }, | |
10719 | { } /* end */ | |
10720 | }; | |
10721 | ||
10722 | static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = { | |
10723 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
10724 | HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT), | |
10725 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
10726 | HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT), | |
10727 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), | |
10728 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), | |
10729 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT), | |
10730 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT), | |
10731 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
10732 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
10733 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
10734 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
10735 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
10736 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
10737 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
10738 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
10739 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
10740 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
10741 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
10742 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
10743 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
10744 | { | |
10745 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10746 | /* .name = "Capture Source", */ | |
10747 | .name = "Input Source", | |
10748 | .count = 1, | |
10749 | .info = alc662_mux_enum_info, | |
10750 | .get = alc662_mux_enum_get, | |
10751 | .put = alc662_mux_enum_put, | |
10752 | }, | |
10753 | { } /* end */ | |
10754 | }; | |
10755 | ||
10756 | static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = { | |
10757 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
10758 | HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT), | |
10759 | HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
10760 | HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT), | |
10761 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
10762 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
10763 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
10764 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
10765 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
10766 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
10767 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
10768 | { | |
10769 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10770 | /* .name = "Capture Source", */ | |
10771 | .name = "Input Source", | |
10772 | .count = 1, | |
10773 | .info = alc662_mux_enum_info, | |
10774 | .get = alc662_mux_enum_get, | |
10775 | .put = alc662_mux_enum_put, | |
10776 | }, | |
10777 | { } /* end */ | |
10778 | }; | |
10779 | ||
10780 | static struct snd_kcontrol_new alc662_chmode_mixer[] = { | |
10781 | { | |
10782 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10783 | .name = "Channel Mode", | |
10784 | .info = alc_ch_mode_info, | |
10785 | .get = alc_ch_mode_get, | |
10786 | .put = alc_ch_mode_put, | |
10787 | }, | |
10788 | { } /* end */ | |
10789 | }; | |
10790 | ||
10791 | static struct hda_verb alc662_init_verbs[] = { | |
10792 | /* ADC: mute amp left and right */ | |
10793 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
10794 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10795 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
10796 | ||
10797 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10798 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10799 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
10800 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
10801 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
10802 | ||
10803 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10804 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10805 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10806 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10807 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10808 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10809 | ||
10810 | /* Front Pin: output 0 (0x0c) */ | |
10811 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
10812 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10813 | ||
10814 | /* Rear Pin: output 1 (0x0d) */ | |
10815 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
10816 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10817 | ||
10818 | /* CLFE Pin: output 2 (0x0e) */ | |
10819 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
10820 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10821 | ||
10822 | /* Mic (rear) pin: input vref at 80% */ | |
10823 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
10824 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10825 | /* Front Mic pin: input vref at 80% */ | |
10826 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
10827 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10828 | /* Line In pin: input */ | |
10829 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
10830 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10831 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
10832 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
10833 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10834 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10835 | /* CD pin widget for input */ | |
10836 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
10837 | ||
10838 | /* FIXME: use matrix-type input source selection */ | |
10839 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
10840 | /* Input mixer */ | |
10841 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10842 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10843 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
10844 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
10845 | { } | |
10846 | }; | |
10847 | ||
10848 | static struct hda_verb alc662_sue_init_verbs[] = { | |
10849 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT}, | |
10850 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT}, | |
10851 | {} | |
10852 | }; | |
10853 | ||
10854 | /* | |
10855 | * generic initialization of ADC, input mixers and output mixers | |
10856 | */ | |
10857 | static struct hda_verb alc662_auto_init_verbs[] = { | |
10858 | /* | |
10859 | * Unmute ADC and set the default input to mic-in | |
10860 | */ | |
10861 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10862 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10863 | ||
10864 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | |
10865 | * mixer widget | |
10866 | * Note: PASD motherboards uses the Line In 2 as the input for front | |
10867 | * panel mic (mic 2) | |
10868 | */ | |
10869 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
10870 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10871 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10872 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
10873 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
10874 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
10875 | ||
10876 | /* | |
10877 | * Set up output mixers (0x0c - 0x0f) | |
10878 | */ | |
10879 | /* set vol=0 to output mixers */ | |
10880 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10881 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10882 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10883 | ||
10884 | /* set up input amps for analog loopback */ | |
10885 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
10886 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10887 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10888 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10889 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10890 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10891 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10892 | ||
10893 | ||
10894 | /* FIXME: use matrix-type input source selection */ | |
10895 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
10896 | /* Input mixer */ | |
10897 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10898 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10899 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
10900 | /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/ | |
10901 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
10902 | ||
10903 | { } | |
10904 | }; | |
10905 | ||
10906 | /* capture mixer elements */ | |
10907 | static struct snd_kcontrol_new alc662_capture_mixer[] = { | |
10908 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
10909 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
10910 | { | |
10911 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10912 | /* The multiple "Capture Source" controls confuse alsamixer | |
10913 | * So call somewhat different.. | |
10914 | * FIXME: the controls appear in the "playback" view! | |
10915 | */ | |
10916 | /* .name = "Capture Source", */ | |
10917 | .name = "Input Source", | |
10918 | .count = 1, | |
10919 | .info = alc882_mux_enum_info, | |
10920 | .get = alc882_mux_enum_get, | |
10921 | .put = alc882_mux_enum_put, | |
10922 | }, | |
10923 | { } /* end */ | |
10924 | }; | |
10925 | ||
10926 | static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec) | |
10927 | { | |
10928 | unsigned int present; | |
f12ab1e0 | 10929 | unsigned char bits; |
bc9f98a9 KY |
10930 | |
10931 | present = snd_hda_codec_read(codec, 0x14, 0, | |
10932 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
f12ab1e0 | 10933 | bits = present ? 0x80 : 0; |
bc9f98a9 | 10934 | snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, |
f12ab1e0 | 10935 | 0x80, bits); |
bc9f98a9 | 10936 | snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, |
f12ab1e0 | 10937 | 0x80, bits); |
bc9f98a9 KY |
10938 | } |
10939 | ||
10940 | static void alc662_lenovo_101e_all_automute(struct hda_codec *codec) | |
10941 | { | |
10942 | unsigned int present; | |
f12ab1e0 | 10943 | unsigned char bits; |
bc9f98a9 KY |
10944 | |
10945 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
10946 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
f12ab1e0 | 10947 | bits = present ? 0x80 : 0; |
bc9f98a9 | 10948 | snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, |
f12ab1e0 | 10949 | 0x80, bits); |
bc9f98a9 | 10950 | snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, |
f12ab1e0 | 10951 | 0x80, bits); |
bc9f98a9 | 10952 | snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, |
f12ab1e0 | 10953 | 0x80, bits); |
bc9f98a9 | 10954 | snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, |
f12ab1e0 | 10955 | 0x80, bits); |
bc9f98a9 KY |
10956 | } |
10957 | ||
10958 | static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec, | |
10959 | unsigned int res) | |
10960 | { | |
10961 | if ((res >> 26) == ALC880_HP_EVENT) | |
10962 | alc662_lenovo_101e_all_automute(codec); | |
10963 | if ((res >> 26) == ALC880_FRONT_EVENT) | |
10964 | alc662_lenovo_101e_ispeaker_automute(codec); | |
10965 | } | |
10966 | ||
10967 | ||
10968 | /* pcm configuration: identiacal with ALC880 */ | |
10969 | #define alc662_pcm_analog_playback alc880_pcm_analog_playback | |
10970 | #define alc662_pcm_analog_capture alc880_pcm_analog_capture | |
10971 | #define alc662_pcm_digital_playback alc880_pcm_digital_playback | |
10972 | #define alc662_pcm_digital_capture alc880_pcm_digital_capture | |
10973 | ||
10974 | /* | |
10975 | * configuration and preset | |
10976 | */ | |
10977 | static const char *alc662_models[ALC662_MODEL_LAST] = { | |
10978 | [ALC662_3ST_2ch_DIG] = "3stack-dig", | |
10979 | [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig", | |
10980 | [ALC662_3ST_6ch] = "3stack-6ch", | |
10981 | [ALC662_5ST_DIG] = "6stack-dig", | |
10982 | [ALC662_LENOVO_101E] = "lenovo-101e", | |
10983 | [ALC662_AUTO] = "auto", | |
10984 | }; | |
10985 | ||
10986 | static struct snd_pci_quirk alc662_cfg_tbl[] = { | |
10987 | SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E), | |
10988 | {} | |
10989 | }; | |
10990 | ||
10991 | static struct alc_config_preset alc662_presets[] = { | |
10992 | [ALC662_3ST_2ch_DIG] = { | |
10993 | .mixers = { alc662_3ST_2ch_mixer }, | |
10994 | .init_verbs = { alc662_init_verbs }, | |
10995 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
10996 | .dac_nids = alc662_dac_nids, | |
10997 | .dig_out_nid = ALC662_DIGOUT_NID, | |
10998 | .num_adc_nids = ARRAY_SIZE(alc662_adc_nids), | |
10999 | .adc_nids = alc662_adc_nids, | |
11000 | .dig_in_nid = ALC662_DIGIN_NID, | |
11001 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
11002 | .channel_mode = alc662_3ST_2ch_modes, | |
11003 | .input_mux = &alc662_capture_source, | |
11004 | }, | |
11005 | [ALC662_3ST_6ch_DIG] = { | |
11006 | .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer }, | |
11007 | .init_verbs = { alc662_init_verbs }, | |
11008 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
11009 | .dac_nids = alc662_dac_nids, | |
11010 | .dig_out_nid = ALC662_DIGOUT_NID, | |
11011 | .num_adc_nids = ARRAY_SIZE(alc662_adc_nids), | |
11012 | .adc_nids = alc662_adc_nids, | |
11013 | .dig_in_nid = ALC662_DIGIN_NID, | |
11014 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), | |
11015 | .channel_mode = alc662_3ST_6ch_modes, | |
11016 | .need_dac_fix = 1, | |
11017 | .input_mux = &alc662_capture_source, | |
f12ab1e0 | 11018 | }, |
bc9f98a9 KY |
11019 | [ALC662_3ST_6ch] = { |
11020 | .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer }, | |
11021 | .init_verbs = { alc662_init_verbs }, | |
11022 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
11023 | .dac_nids = alc662_dac_nids, | |
11024 | .num_adc_nids = ARRAY_SIZE(alc662_adc_nids), | |
11025 | .adc_nids = alc662_adc_nids, | |
11026 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), | |
11027 | .channel_mode = alc662_3ST_6ch_modes, | |
11028 | .need_dac_fix = 1, | |
11029 | .input_mux = &alc662_capture_source, | |
f12ab1e0 | 11030 | }, |
bc9f98a9 KY |
11031 | [ALC662_5ST_DIG] = { |
11032 | .mixers = { alc662_base_mixer, alc662_chmode_mixer }, | |
11033 | .init_verbs = { alc662_init_verbs }, | |
11034 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
11035 | .dac_nids = alc662_dac_nids, | |
11036 | .dig_out_nid = ALC662_DIGOUT_NID, | |
11037 | .num_adc_nids = ARRAY_SIZE(alc662_adc_nids), | |
11038 | .adc_nids = alc662_adc_nids, | |
11039 | .dig_in_nid = ALC662_DIGIN_NID, | |
11040 | .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes), | |
11041 | .channel_mode = alc662_5stack_modes, | |
11042 | .input_mux = &alc662_capture_source, | |
11043 | }, | |
11044 | [ALC662_LENOVO_101E] = { | |
11045 | .mixers = { alc662_lenovo_101e_mixer }, | |
11046 | .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs }, | |
11047 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
11048 | .dac_nids = alc662_dac_nids, | |
11049 | .num_adc_nids = ARRAY_SIZE(alc662_adc_nids), | |
11050 | .adc_nids = alc662_adc_nids, | |
11051 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
11052 | .channel_mode = alc662_3ST_2ch_modes, | |
11053 | .input_mux = &alc662_lenovo_101e_capture_source, | |
11054 | .unsol_event = alc662_lenovo_101e_unsol_event, | |
11055 | .init_hook = alc662_lenovo_101e_all_automute, | |
11056 | }, | |
11057 | ||
11058 | }; | |
11059 | ||
11060 | ||
11061 | /* | |
11062 | * BIOS auto configuration | |
11063 | */ | |
11064 | ||
11065 | /* add playback controls from the parsed DAC table */ | |
11066 | static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec, | |
11067 | const struct auto_pin_cfg *cfg) | |
11068 | { | |
11069 | char name[32]; | |
11070 | static const char *chname[4] = { | |
11071 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
11072 | }; | |
11073 | hda_nid_t nid; | |
11074 | int i, err; | |
11075 | ||
11076 | for (i = 0; i < cfg->line_outs; i++) { | |
11077 | if (!spec->multiout.dac_nids[i]) | |
11078 | continue; | |
067b5a84 | 11079 | nid = alc880_idx_to_mixer(i); |
bc9f98a9 KY |
11080 | if (i == 2) { |
11081 | /* Center/LFE */ | |
11082 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
11083 | "Center Playback Volume", | |
f12ab1e0 TI |
11084 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, |
11085 | HDA_OUTPUT)); | |
bc9f98a9 KY |
11086 | if (err < 0) |
11087 | return err; | |
11088 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
11089 | "LFE Playback Volume", | |
f12ab1e0 TI |
11090 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, |
11091 | HDA_OUTPUT)); | |
bc9f98a9 KY |
11092 | if (err < 0) |
11093 | return err; | |
11094 | err = add_control(spec, ALC_CTL_BIND_MUTE, | |
11095 | "Center Playback Switch", | |
f12ab1e0 TI |
11096 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, |
11097 | HDA_INPUT)); | |
bc9f98a9 KY |
11098 | if (err < 0) |
11099 | return err; | |
11100 | err = add_control(spec, ALC_CTL_BIND_MUTE, | |
11101 | "LFE Playback Switch", | |
f12ab1e0 TI |
11102 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, |
11103 | HDA_INPUT)); | |
bc9f98a9 KY |
11104 | if (err < 0) |
11105 | return err; | |
11106 | } else { | |
11107 | sprintf(name, "%s Playback Volume", chname[i]); | |
11108 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
f12ab1e0 TI |
11109 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, |
11110 | HDA_OUTPUT)); | |
bc9f98a9 KY |
11111 | if (err < 0) |
11112 | return err; | |
11113 | sprintf(name, "%s Playback Switch", chname[i]); | |
11114 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | |
f12ab1e0 TI |
11115 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, |
11116 | HDA_INPUT)); | |
bc9f98a9 KY |
11117 | if (err < 0) |
11118 | return err; | |
11119 | } | |
11120 | } | |
11121 | return 0; | |
11122 | } | |
11123 | ||
11124 | /* add playback controls for speaker and HP outputs */ | |
11125 | static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, | |
11126 | const char *pfx) | |
11127 | { | |
11128 | hda_nid_t nid; | |
11129 | int err; | |
11130 | char name[32]; | |
11131 | ||
11132 | if (!pin) | |
11133 | return 0; | |
11134 | ||
11135 | if (alc880_is_fixed_pin(pin)) { | |
11136 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
11137 | /* printk("DAC nid=%x\n",nid); */ | |
11138 | /* specify the DAC as the extra output */ | |
11139 | if (!spec->multiout.hp_nid) | |
11140 | spec->multiout.hp_nid = nid; | |
11141 | else | |
11142 | spec->multiout.extra_out_nid[0] = nid; | |
11143 | /* control HP volume/switch on the output mixer amp */ | |
11144 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
11145 | sprintf(name, "%s Playback Volume", pfx); | |
11146 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
11147 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
11148 | if (err < 0) | |
11149 | return err; | |
11150 | sprintf(name, "%s Playback Switch", pfx); | |
11151 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | |
11152 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); | |
11153 | if (err < 0) | |
11154 | return err; | |
11155 | } else if (alc880_is_multi_pin(pin)) { | |
11156 | /* set manual connection */ | |
11157 | /* we have only a switch on HP-out PIN */ | |
11158 | sprintf(name, "%s Playback Switch", pfx); | |
11159 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | |
11160 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
11161 | if (err < 0) | |
11162 | return err; | |
11163 | } | |
11164 | return 0; | |
11165 | } | |
11166 | ||
11167 | /* create playback/capture controls for input pins */ | |
11168 | static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec, | |
11169 | const struct auto_pin_cfg *cfg) | |
11170 | { | |
11171 | struct hda_input_mux *imux = &spec->private_imux; | |
11172 | int i, err, idx; | |
11173 | ||
11174 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
11175 | if (alc880_is_input_pin(cfg->input_pins[i])) { | |
11176 | idx = alc880_input_pin_idx(cfg->input_pins[i]); | |
11177 | err = new_analog_input(spec, cfg->input_pins[i], | |
11178 | auto_pin_cfg_labels[i], | |
11179 | idx, 0x0b); | |
11180 | if (err < 0) | |
11181 | return err; | |
11182 | imux->items[imux->num_items].label = | |
11183 | auto_pin_cfg_labels[i]; | |
11184 | imux->items[imux->num_items].index = | |
11185 | alc880_input_pin_idx(cfg->input_pins[i]); | |
11186 | imux->num_items++; | |
11187 | } | |
11188 | } | |
11189 | return 0; | |
11190 | } | |
11191 | ||
11192 | static void alc662_auto_set_output_and_unmute(struct hda_codec *codec, | |
11193 | hda_nid_t nid, int pin_type, | |
11194 | int dac_idx) | |
11195 | { | |
11196 | /* set as output */ | |
11197 | snd_hda_codec_write(codec, nid, 0, | |
11198 | AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); | |
11199 | snd_hda_codec_write(codec, nid, 0, | |
11200 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); | |
11201 | /* need the manual connection? */ | |
11202 | if (alc880_is_multi_pin(nid)) { | |
11203 | struct alc_spec *spec = codec->spec; | |
11204 | int idx = alc880_multi_pin_idx(nid); | |
11205 | snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, | |
11206 | AC_VERB_SET_CONNECT_SEL, | |
11207 | alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); | |
11208 | } | |
11209 | } | |
11210 | ||
11211 | static void alc662_auto_init_multi_out(struct hda_codec *codec) | |
11212 | { | |
11213 | struct alc_spec *spec = codec->spec; | |
11214 | int i; | |
11215 | ||
11216 | for (i = 0; i <= HDA_SIDE; i++) { | |
11217 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 11218 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
bc9f98a9 | 11219 | if (nid) |
baba8ee9 | 11220 | alc662_auto_set_output_and_unmute(codec, nid, pin_type, |
bc9f98a9 KY |
11221 | i); |
11222 | } | |
11223 | } | |
11224 | ||
11225 | static void alc662_auto_init_hp_out(struct hda_codec *codec) | |
11226 | { | |
11227 | struct alc_spec *spec = codec->spec; | |
11228 | hda_nid_t pin; | |
11229 | ||
11230 | pin = spec->autocfg.hp_pins[0]; | |
11231 | if (pin) /* connect to front */ | |
11232 | /* use dac 0 */ | |
11233 | alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
11234 | } | |
11235 | ||
11236 | #define alc662_is_input_pin(nid) alc880_is_input_pin(nid) | |
11237 | #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID | |
11238 | ||
11239 | static void alc662_auto_init_analog_input(struct hda_codec *codec) | |
11240 | { | |
11241 | struct alc_spec *spec = codec->spec; | |
11242 | int i; | |
11243 | ||
11244 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
11245 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
11246 | if (alc662_is_input_pin(nid)) { | |
11247 | snd_hda_codec_write(codec, nid, 0, | |
11248 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
11249 | (i <= AUTO_PIN_FRONT_MIC ? | |
11250 | PIN_VREF80 : PIN_IN)); | |
11251 | if (nid != ALC662_PIN_CD_NID) | |
11252 | snd_hda_codec_write(codec, nid, 0, | |
11253 | AC_VERB_SET_AMP_GAIN_MUTE, | |
11254 | AMP_OUT_MUTE); | |
11255 | } | |
11256 | } | |
11257 | } | |
11258 | ||
11259 | static int alc662_parse_auto_config(struct hda_codec *codec) | |
11260 | { | |
11261 | struct alc_spec *spec = codec->spec; | |
11262 | int err; | |
11263 | static hda_nid_t alc662_ignore[] = { 0x1d, 0 }; | |
11264 | ||
11265 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | |
11266 | alc662_ignore); | |
11267 | if (err < 0) | |
11268 | return err; | |
11269 | if (!spec->autocfg.line_outs) | |
11270 | return 0; /* can't find valid BIOS pin config */ | |
11271 | ||
f12ab1e0 TI |
11272 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
11273 | if (err < 0) | |
11274 | return err; | |
11275 | err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
11276 | if (err < 0) | |
11277 | return err; | |
11278 | err = alc662_auto_create_extra_out(spec, | |
11279 | spec->autocfg.speaker_pins[0], | |
11280 | "Speaker"); | |
11281 | if (err < 0) | |
11282 | return err; | |
11283 | err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], | |
11284 | "Headphone"); | |
11285 | if (err < 0) | |
11286 | return err; | |
11287 | err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
11288 | if (err < 0) | |
bc9f98a9 KY |
11289 | return err; |
11290 | ||
11291 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
11292 | ||
11293 | if (spec->autocfg.dig_out_pin) | |
11294 | spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; | |
11295 | ||
11296 | if (spec->kctl_alloc) | |
11297 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
11298 | ||
11299 | spec->num_mux_defs = 1; | |
11300 | spec->input_mux = &spec->private_imux; | |
11301 | ||
8c87286f | 11302 | spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs; |
bc9f98a9 KY |
11303 | spec->mixers[spec->num_mixers] = alc662_capture_mixer; |
11304 | spec->num_mixers++; | |
8c87286f | 11305 | return 1; |
bc9f98a9 KY |
11306 | } |
11307 | ||
11308 | /* additional initialization for auto-configuration model */ | |
11309 | static void alc662_auto_init(struct hda_codec *codec) | |
11310 | { | |
11311 | alc662_auto_init_multi_out(codec); | |
11312 | alc662_auto_init_hp_out(codec); | |
11313 | alc662_auto_init_analog_input(codec); | |
11314 | } | |
11315 | ||
11316 | static int patch_alc662(struct hda_codec *codec) | |
11317 | { | |
11318 | struct alc_spec *spec; | |
11319 | int err, board_config; | |
11320 | ||
11321 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
11322 | if (!spec) | |
11323 | return -ENOMEM; | |
11324 | ||
11325 | codec->spec = spec; | |
11326 | ||
11327 | board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST, | |
11328 | alc662_models, | |
11329 | alc662_cfg_tbl); | |
11330 | if (board_config < 0) { | |
11331 | printk(KERN_INFO "hda_codec: Unknown model for ALC662, " | |
11332 | "trying auto-probe from BIOS...\n"); | |
11333 | board_config = ALC662_AUTO; | |
11334 | } | |
11335 | ||
11336 | if (board_config == ALC662_AUTO) { | |
11337 | /* automatic parse from the BIOS config */ | |
11338 | err = alc662_parse_auto_config(codec); | |
11339 | if (err < 0) { | |
11340 | alc_free(codec); | |
11341 | return err; | |
8c87286f | 11342 | } else if (!err) { |
bc9f98a9 KY |
11343 | printk(KERN_INFO |
11344 | "hda_codec: Cannot set up configuration " | |
11345 | "from BIOS. Using base mode...\n"); | |
11346 | board_config = ALC662_3ST_2ch_DIG; | |
11347 | } | |
11348 | } | |
11349 | ||
11350 | if (board_config != ALC662_AUTO) | |
11351 | setup_preset(spec, &alc662_presets[board_config]); | |
11352 | ||
11353 | spec->stream_name_analog = "ALC662 Analog"; | |
11354 | spec->stream_analog_playback = &alc662_pcm_analog_playback; | |
11355 | spec->stream_analog_capture = &alc662_pcm_analog_capture; | |
11356 | ||
11357 | spec->stream_name_digital = "ALC662 Digital"; | |
11358 | spec->stream_digital_playback = &alc662_pcm_digital_playback; | |
11359 | spec->stream_digital_capture = &alc662_pcm_digital_capture; | |
11360 | ||
11361 | if (!spec->adc_nids && spec->input_mux) { | |
11362 | spec->adc_nids = alc662_adc_nids; | |
11363 | spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids); | |
11364 | } | |
11365 | ||
11366 | codec->patch_ops = alc_patch_ops; | |
11367 | if (board_config == ALC662_AUTO) | |
11368 | spec->init_hook = alc662_auto_init; | |
11369 | ||
11370 | return 0; | |
11371 | } | |
11372 | ||
1da177e4 LT |
11373 | /* |
11374 | * patch entries | |
11375 | */ | |
11376 | struct hda_codec_preset snd_hda_preset_realtek[] = { | |
11377 | { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, | |
df694daa | 11378 | { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, |
a361d84b | 11379 | { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, |
f32610ed | 11380 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", |
bc9f98a9 | 11381 | .patch = patch_alc861 }, |
f32610ed JS |
11382 | { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, |
11383 | { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, | |
11384 | { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, | |
bc9f98a9 KY |
11385 | { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", |
11386 | .patch = patch_alc883 }, | |
11387 | { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", | |
11388 | .patch = patch_alc662 }, | |
f32610ed | 11389 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
1da177e4 | 11390 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, |
9c7f852e | 11391 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 }, |
df694daa | 11392 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, |
9c7f852e | 11393 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 }, |
1da177e4 LT |
11394 | {} /* terminator */ |
11395 | }; |