]>
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, |
df694daa KY |
96 | ALC262_AUTO, |
97 | ALC262_MODEL_LAST /* last tag */ | |
98 | }; | |
99 | ||
100 | /* ALC861 models */ | |
101 | enum { | |
102 | ALC861_3ST, | |
9c7f852e | 103 | ALC660_3ST, |
df694daa KY |
104 | ALC861_3ST_DIG, |
105 | ALC861_6ST_DIG, | |
22309c3e | 106 | ALC861_UNIWILL_M31, |
a53d1aec | 107 | ALC861_TOSHIBA, |
7cdbff94 | 108 | ALC861_ASUS, |
56bb0cab | 109 | ALC861_ASUS_LAPTOP, |
df694daa KY |
110 | ALC861_AUTO, |
111 | ALC861_MODEL_LAST, | |
112 | }; | |
113 | ||
f32610ed JS |
114 | /* ALC861-VD models */ |
115 | enum { | |
116 | ALC660VD_3ST, | |
117 | ALC861VD_3ST, | |
118 | ALC861VD_3ST_DIG, | |
119 | ALC861VD_6ST_DIG, | |
120 | ALC861VD_AUTO, | |
121 | ALC861VD_MODEL_LAST, | |
122 | }; | |
123 | ||
bc9f98a9 KY |
124 | /* ALC662 models */ |
125 | enum { | |
126 | ALC662_3ST_2ch_DIG, | |
127 | ALC662_3ST_6ch_DIG, | |
128 | ALC662_3ST_6ch, | |
129 | ALC662_5ST_DIG, | |
130 | ALC662_LENOVO_101E, | |
131 | ALC662_AUTO, | |
132 | ALC662_MODEL_LAST, | |
133 | }; | |
134 | ||
df694daa KY |
135 | /* ALC882 models */ |
136 | enum { | |
137 | ALC882_3ST_DIG, | |
138 | ALC882_6ST_DIG, | |
4b146cb0 | 139 | ALC882_ARIMA, |
df694daa | 140 | ALC882_AUTO, |
9102cd1c | 141 | ALC885_MACPRO, |
df694daa KY |
142 | ALC882_MODEL_LAST, |
143 | }; | |
144 | ||
9c7f852e TI |
145 | /* ALC883 models */ |
146 | enum { | |
147 | ALC883_3ST_2ch_DIG, | |
148 | ALC883_3ST_6ch_DIG, | |
149 | ALC883_3ST_6ch, | |
150 | ALC883_6ST_DIG, | |
ccc656ce KY |
151 | ALC883_TARGA_DIG, |
152 | ALC883_TARGA_2ch_DIG, | |
9c7f852e | 153 | ALC888_DEMO_BOARD, |
bab282b9 | 154 | ALC883_ACER, |
c07584c8 | 155 | ALC883_MEDION, |
b373bdeb | 156 | ALC883_LAPTOP_EAPD, |
bc9f98a9 | 157 | ALC883_LENOVO_101E_2ch, |
9c7f852e TI |
158 | ALC883_AUTO, |
159 | ALC883_MODEL_LAST, | |
160 | }; | |
161 | ||
df694daa KY |
162 | /* for GPIO Poll */ |
163 | #define GPIO_MASK 0x03 | |
164 | ||
1da177e4 LT |
165 | struct alc_spec { |
166 | /* codec parameterization */ | |
df694daa | 167 | struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ |
1da177e4 LT |
168 | unsigned int num_mixers; |
169 | ||
df694daa | 170 | const struct hda_verb *init_verbs[5]; /* initialization verbs |
9c7f852e TI |
171 | * don't forget NULL |
172 | * termination! | |
e9edcee0 TI |
173 | */ |
174 | unsigned int num_init_verbs; | |
1da177e4 | 175 | |
16ded525 | 176 | char *stream_name_analog; /* analog PCM stream */ |
1da177e4 LT |
177 | struct hda_pcm_stream *stream_analog_playback; |
178 | struct hda_pcm_stream *stream_analog_capture; | |
179 | ||
f12ab1e0 | 180 | char *stream_name_digital; /* digital PCM stream */ |
1da177e4 LT |
181 | struct hda_pcm_stream *stream_digital_playback; |
182 | struct hda_pcm_stream *stream_digital_capture; | |
183 | ||
184 | /* playback */ | |
16ded525 TI |
185 | struct hda_multi_out multiout; /* playback set-up |
186 | * max_channels, dacs must be set | |
187 | * dig_out_nid and hp_nid are optional | |
188 | */ | |
1da177e4 LT |
189 | |
190 | /* capture */ | |
191 | unsigned int num_adc_nids; | |
192 | hda_nid_t *adc_nids; | |
16ded525 | 193 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
1da177e4 LT |
194 | |
195 | /* capture source */ | |
a1e8d2da | 196 | unsigned int num_mux_defs; |
1da177e4 LT |
197 | const struct hda_input_mux *input_mux; |
198 | unsigned int cur_mux[3]; | |
199 | ||
200 | /* channel model */ | |
d2a6d7dc | 201 | const struct hda_channel_mode *channel_mode; |
1da177e4 | 202 | int num_channel_mode; |
4e195a7b | 203 | int need_dac_fix; |
1da177e4 LT |
204 | |
205 | /* PCM information */ | |
4c5186ed | 206 | struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ |
41e41f1f | 207 | |
e9edcee0 TI |
208 | /* dynamic controls, init_verbs and input_mux */ |
209 | struct auto_pin_cfg autocfg; | |
210 | unsigned int num_kctl_alloc, num_kctl_used; | |
c8b6bf9b | 211 | struct snd_kcontrol_new *kctl_alloc; |
e9edcee0 | 212 | struct hda_input_mux private_imux; |
df694daa | 213 | hda_nid_t private_dac_nids[5]; |
834be88d | 214 | |
ae6b813a TI |
215 | /* hooks */ |
216 | void (*init_hook)(struct hda_codec *codec); | |
217 | void (*unsol_event)(struct hda_codec *codec, unsigned int res); | |
218 | ||
834be88d TI |
219 | /* for pin sensing */ |
220 | unsigned int sense_updated: 1; | |
221 | unsigned int jack_present: 1; | |
df694daa KY |
222 | }; |
223 | ||
224 | /* | |
225 | * configuration template - to be copied to the spec instance | |
226 | */ | |
227 | struct alc_config_preset { | |
9c7f852e TI |
228 | struct snd_kcontrol_new *mixers[5]; /* should be identical size |
229 | * with spec | |
230 | */ | |
df694daa KY |
231 | const struct hda_verb *init_verbs[5]; |
232 | unsigned int num_dacs; | |
233 | hda_nid_t *dac_nids; | |
234 | hda_nid_t dig_out_nid; /* optional */ | |
235 | hda_nid_t hp_nid; /* optional */ | |
236 | unsigned int num_adc_nids; | |
237 | hda_nid_t *adc_nids; | |
238 | hda_nid_t dig_in_nid; | |
239 | unsigned int num_channel_mode; | |
240 | const struct hda_channel_mode *channel_mode; | |
4e195a7b | 241 | int need_dac_fix; |
a1e8d2da | 242 | unsigned int num_mux_defs; |
df694daa | 243 | const struct hda_input_mux *input_mux; |
ae6b813a TI |
244 | void (*unsol_event)(struct hda_codec *, unsigned int); |
245 | void (*init_hook)(struct hda_codec *); | |
1da177e4 LT |
246 | }; |
247 | ||
1da177e4 LT |
248 | |
249 | /* | |
250 | * input MUX handling | |
251 | */ | |
9c7f852e TI |
252 | static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, |
253 | struct snd_ctl_elem_info *uinfo) | |
1da177e4 LT |
254 | { |
255 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
256 | struct alc_spec *spec = codec->spec; | |
a1e8d2da JW |
257 | unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id); |
258 | if (mux_idx >= spec->num_mux_defs) | |
259 | mux_idx = 0; | |
260 | return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo); | |
1da177e4 LT |
261 | } |
262 | ||
9c7f852e TI |
263 | static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, |
264 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
265 | { |
266 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
267 | struct alc_spec *spec = codec->spec; | |
268 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
269 | ||
270 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; | |
271 | return 0; | |
272 | } | |
273 | ||
9c7f852e TI |
274 | static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, |
275 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
276 | { |
277 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
278 | struct alc_spec *spec = codec->spec; | |
279 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
a1e8d2da JW |
280 | unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; |
281 | return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol, | |
9c7f852e TI |
282 | spec->adc_nids[adc_idx], |
283 | &spec->cur_mux[adc_idx]); | |
1da177e4 LT |
284 | } |
285 | ||
e9edcee0 | 286 | |
1da177e4 LT |
287 | /* |
288 | * channel mode setting | |
289 | */ | |
9c7f852e TI |
290 | static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, |
291 | struct snd_ctl_elem_info *uinfo) | |
1da177e4 LT |
292 | { |
293 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
294 | struct alc_spec *spec = codec->spec; | |
d2a6d7dc TI |
295 | return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, |
296 | spec->num_channel_mode); | |
1da177e4 LT |
297 | } |
298 | ||
9c7f852e TI |
299 | static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, |
300 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
301 | { |
302 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
303 | struct alc_spec *spec = codec->spec; | |
d2a6d7dc | 304 | return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, |
9c7f852e TI |
305 | spec->num_channel_mode, |
306 | spec->multiout.max_channels); | |
1da177e4 LT |
307 | } |
308 | ||
9c7f852e TI |
309 | static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, |
310 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
311 | { |
312 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
313 | struct alc_spec *spec = codec->spec; | |
4e195a7b TI |
314 | int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, |
315 | spec->num_channel_mode, | |
316 | &spec->multiout.max_channels); | |
bd2033f2 | 317 | if (err >= 0 && spec->need_dac_fix) |
4e195a7b TI |
318 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; |
319 | return err; | |
1da177e4 LT |
320 | } |
321 | ||
a9430dd8 | 322 | /* |
4c5186ed JW |
323 | * Control the mode of pin widget settings via the mixer. "pc" is used |
324 | * instead of "%" to avoid consequences of accidently treating the % as | |
325 | * being part of a format specifier. Maximum allowed length of a value is | |
326 | * 63 characters plus NULL terminator. | |
7cf51e48 JW |
327 | * |
328 | * Note: some retasking pin complexes seem to ignore requests for input | |
329 | * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these | |
330 | * are requested. Therefore order this list so that this behaviour will not | |
331 | * cause problems when mixer clients move through the enum sequentially. | |
a1e8d2da JW |
332 | * NIDs 0x0f and 0x10 have been observed to have this behaviour as of |
333 | * March 2006. | |
4c5186ed JW |
334 | */ |
335 | static char *alc_pin_mode_names[] = { | |
7cf51e48 JW |
336 | "Mic 50pc bias", "Mic 80pc bias", |
337 | "Line in", "Line out", "Headphone out", | |
4c5186ed JW |
338 | }; |
339 | static unsigned char alc_pin_mode_values[] = { | |
7cf51e48 | 340 | PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP, |
4c5186ed JW |
341 | }; |
342 | /* The control can present all 5 options, or it can limit the options based | |
a1e8d2da JW |
343 | * in the pin being assumed to be exclusively an input or an output pin. In |
344 | * addition, "input" pins may or may not process the mic bias option | |
345 | * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to | |
346 | * accept requests for bias as of chip versions up to March 2006) and/or | |
347 | * wiring in the computer. | |
a9430dd8 | 348 | */ |
a1e8d2da JW |
349 | #define ALC_PIN_DIR_IN 0x00 |
350 | #define ALC_PIN_DIR_OUT 0x01 | |
351 | #define ALC_PIN_DIR_INOUT 0x02 | |
352 | #define ALC_PIN_DIR_IN_NOMICBIAS 0x03 | |
353 | #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04 | |
4c5186ed | 354 | |
a1e8d2da | 355 | /* Info about the pin modes supported by the different pin direction modes. |
4c5186ed JW |
356 | * For each direction the minimum and maximum values are given. |
357 | */ | |
a1e8d2da | 358 | static signed char alc_pin_mode_dir_info[5][2] = { |
4c5186ed JW |
359 | { 0, 2 }, /* ALC_PIN_DIR_IN */ |
360 | { 3, 4 }, /* ALC_PIN_DIR_OUT */ | |
361 | { 0, 4 }, /* ALC_PIN_DIR_INOUT */ | |
a1e8d2da JW |
362 | { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */ |
363 | { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */ | |
4c5186ed JW |
364 | }; |
365 | #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0]) | |
366 | #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1]) | |
367 | #define alc_pin_mode_n_items(_dir) \ | |
368 | (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1) | |
369 | ||
9c7f852e TI |
370 | static int alc_pin_mode_info(struct snd_kcontrol *kcontrol, |
371 | struct snd_ctl_elem_info *uinfo) | |
a9430dd8 | 372 | { |
4c5186ed JW |
373 | unsigned int item_num = uinfo->value.enumerated.item; |
374 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; | |
375 | ||
376 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
a9430dd8 | 377 | uinfo->count = 1; |
4c5186ed JW |
378 | uinfo->value.enumerated.items = alc_pin_mode_n_items(dir); |
379 | ||
380 | if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir)) | |
381 | item_num = alc_pin_mode_min(dir); | |
382 | strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]); | |
a9430dd8 JW |
383 | return 0; |
384 | } | |
385 | ||
9c7f852e TI |
386 | static int alc_pin_mode_get(struct snd_kcontrol *kcontrol, |
387 | struct snd_ctl_elem_value *ucontrol) | |
a9430dd8 | 388 | { |
4c5186ed | 389 | unsigned int i; |
a9430dd8 JW |
390 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
391 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
4c5186ed | 392 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
a9430dd8 | 393 | long *valp = ucontrol->value.integer.value; |
9c7f852e TI |
394 | unsigned int pinctl = snd_hda_codec_read(codec, nid, 0, |
395 | AC_VERB_GET_PIN_WIDGET_CONTROL, | |
396 | 0x00); | |
a9430dd8 | 397 | |
4c5186ed JW |
398 | /* Find enumerated value for current pinctl setting */ |
399 | i = alc_pin_mode_min(dir); | |
9c7f852e | 400 | while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir)) |
4c5186ed | 401 | i++; |
9c7f852e | 402 | *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir); |
a9430dd8 JW |
403 | return 0; |
404 | } | |
405 | ||
9c7f852e TI |
406 | static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, |
407 | struct snd_ctl_elem_value *ucontrol) | |
a9430dd8 | 408 | { |
4c5186ed | 409 | signed int change; |
a9430dd8 JW |
410 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
411 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
4c5186ed JW |
412 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
413 | long val = *ucontrol->value.integer.value; | |
9c7f852e TI |
414 | unsigned int pinctl = snd_hda_codec_read(codec, nid, 0, |
415 | AC_VERB_GET_PIN_WIDGET_CONTROL, | |
416 | 0x00); | |
a9430dd8 | 417 | |
f12ab1e0 | 418 | if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir)) |
4c5186ed JW |
419 | val = alc_pin_mode_min(dir); |
420 | ||
421 | change = pinctl != alc_pin_mode_values[val]; | |
cdcd9268 JW |
422 | if (change) { |
423 | /* Set pin mode to that requested */ | |
a9430dd8 | 424 | snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL, |
9c7f852e | 425 | alc_pin_mode_values[val]); |
cdcd9268 JW |
426 | |
427 | /* Also enable the retasking pin's input/output as required | |
428 | * for the requested pin mode. Enum values of 2 or less are | |
429 | * input modes. | |
430 | * | |
431 | * Dynamically switching the input/output buffers probably | |
a1e8d2da JW |
432 | * reduces noise slightly (particularly on input) so we'll |
433 | * do it. However, having both input and output buffers | |
434 | * enabled simultaneously doesn't seem to be problematic if | |
435 | * this turns out to be necessary in the future. | |
cdcd9268 JW |
436 | */ |
437 | if (val <= 2) { | |
9c7f852e TI |
438 | snd_hda_codec_write(codec, nid, 0, |
439 | AC_VERB_SET_AMP_GAIN_MUTE, | |
440 | AMP_OUT_MUTE); | |
441 | snd_hda_codec_write(codec, nid, 0, | |
442 | AC_VERB_SET_AMP_GAIN_MUTE, | |
443 | AMP_IN_UNMUTE(0)); | |
cdcd9268 | 444 | } else { |
9c7f852e TI |
445 | snd_hda_codec_write(codec, nid, 0, |
446 | AC_VERB_SET_AMP_GAIN_MUTE, | |
447 | AMP_IN_MUTE(0)); | |
448 | snd_hda_codec_write(codec, nid, 0, | |
449 | AC_VERB_SET_AMP_GAIN_MUTE, | |
450 | AMP_OUT_UNMUTE); | |
cdcd9268 JW |
451 | } |
452 | } | |
a9430dd8 JW |
453 | return change; |
454 | } | |
455 | ||
4c5186ed | 456 | #define ALC_PIN_MODE(xname, nid, dir) \ |
a9430dd8 | 457 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ |
4c5186ed JW |
458 | .info = alc_pin_mode_info, \ |
459 | .get = alc_pin_mode_get, \ | |
460 | .put = alc_pin_mode_put, \ | |
461 | .private_value = nid | (dir<<16) } | |
df694daa | 462 | |
5c8f858d JW |
463 | /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged |
464 | * together using a mask with more than one bit set. This control is | |
465 | * currently used only by the ALC260 test model. At this stage they are not | |
466 | * needed for any "production" models. | |
467 | */ | |
468 | #ifdef CONFIG_SND_DEBUG | |
9c7f852e TI |
469 | static int alc_gpio_data_info(struct snd_kcontrol *kcontrol, |
470 | struct snd_ctl_elem_info *uinfo) | |
5c8f858d JW |
471 | { |
472 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | |
473 | uinfo->count = 1; | |
474 | uinfo->value.integer.min = 0; | |
475 | uinfo->value.integer.max = 1; | |
476 | return 0; | |
f12ab1e0 TI |
477 | } |
478 | ||
9c7f852e TI |
479 | static int alc_gpio_data_get(struct snd_kcontrol *kcontrol, |
480 | struct snd_ctl_elem_value *ucontrol) | |
5c8f858d JW |
481 | { |
482 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
483 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
484 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
485 | long *valp = ucontrol->value.integer.value; | |
9c7f852e TI |
486 | unsigned int val = snd_hda_codec_read(codec, nid, 0, |
487 | AC_VERB_GET_GPIO_DATA, 0x00); | |
5c8f858d JW |
488 | |
489 | *valp = (val & mask) != 0; | |
490 | return 0; | |
491 | } | |
9c7f852e TI |
492 | static int alc_gpio_data_put(struct snd_kcontrol *kcontrol, |
493 | struct snd_ctl_elem_value *ucontrol) | |
5c8f858d JW |
494 | { |
495 | signed int change; | |
496 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
497 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
498 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
499 | long val = *ucontrol->value.integer.value; | |
9c7f852e TI |
500 | unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0, |
501 | AC_VERB_GET_GPIO_DATA, | |
502 | 0x00); | |
5c8f858d JW |
503 | |
504 | /* Set/unset the masked GPIO bit(s) as needed */ | |
9c7f852e TI |
505 | change = (val == 0 ? 0 : mask) != (gpio_data & mask); |
506 | if (val == 0) | |
5c8f858d JW |
507 | gpio_data &= ~mask; |
508 | else | |
509 | gpio_data |= mask; | |
9c7f852e | 510 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data); |
5c8f858d JW |
511 | |
512 | return change; | |
513 | } | |
514 | #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \ | |
515 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
516 | .info = alc_gpio_data_info, \ | |
517 | .get = alc_gpio_data_get, \ | |
518 | .put = alc_gpio_data_put, \ | |
519 | .private_value = nid | (mask<<16) } | |
520 | #endif /* CONFIG_SND_DEBUG */ | |
521 | ||
92621f13 JW |
522 | /* A switch control to allow the enabling of the digital IO pins on the |
523 | * ALC260. This is incredibly simplistic; the intention of this control is | |
524 | * to provide something in the test model allowing digital outputs to be | |
525 | * identified if present. If models are found which can utilise these | |
526 | * outputs a more complete mixer control can be devised for those models if | |
527 | * necessary. | |
528 | */ | |
529 | #ifdef CONFIG_SND_DEBUG | |
9c7f852e TI |
530 | static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol, |
531 | struct snd_ctl_elem_info *uinfo) | |
92621f13 JW |
532 | { |
533 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | |
534 | uinfo->count = 1; | |
535 | uinfo->value.integer.min = 0; | |
536 | uinfo->value.integer.max = 1; | |
537 | return 0; | |
f12ab1e0 TI |
538 | } |
539 | ||
9c7f852e TI |
540 | static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol, |
541 | struct snd_ctl_elem_value *ucontrol) | |
92621f13 JW |
542 | { |
543 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
544 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
545 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
546 | long *valp = ucontrol->value.integer.value; | |
9c7f852e TI |
547 | unsigned int val = snd_hda_codec_read(codec, nid, 0, |
548 | AC_VERB_GET_DIGI_CONVERT, 0x00); | |
92621f13 JW |
549 | |
550 | *valp = (val & mask) != 0; | |
551 | return 0; | |
552 | } | |
9c7f852e TI |
553 | static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol, |
554 | struct snd_ctl_elem_value *ucontrol) | |
92621f13 JW |
555 | { |
556 | signed int change; | |
557 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
558 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
559 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
560 | long val = *ucontrol->value.integer.value; | |
9c7f852e TI |
561 | unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0, |
562 | AC_VERB_GET_DIGI_CONVERT, | |
563 | 0x00); | |
92621f13 JW |
564 | |
565 | /* Set/unset the masked control bit(s) as needed */ | |
9c7f852e | 566 | change = (val == 0 ? 0 : mask) != (ctrl_data & mask); |
92621f13 JW |
567 | if (val==0) |
568 | ctrl_data &= ~mask; | |
569 | else | |
570 | ctrl_data |= mask; | |
9c7f852e TI |
571 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, |
572 | ctrl_data); | |
92621f13 JW |
573 | |
574 | return change; | |
575 | } | |
576 | #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \ | |
577 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
578 | .info = alc_spdif_ctrl_info, \ | |
579 | .get = alc_spdif_ctrl_get, \ | |
580 | .put = alc_spdif_ctrl_put, \ | |
581 | .private_value = nid | (mask<<16) } | |
582 | #endif /* CONFIG_SND_DEBUG */ | |
583 | ||
df694daa KY |
584 | /* |
585 | * set up from the preset table | |
586 | */ | |
9c7f852e TI |
587 | static void setup_preset(struct alc_spec *spec, |
588 | const struct alc_config_preset *preset) | |
df694daa KY |
589 | { |
590 | int i; | |
591 | ||
592 | for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++) | |
593 | spec->mixers[spec->num_mixers++] = preset->mixers[i]; | |
9c7f852e TI |
594 | for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; |
595 | i++) | |
596 | spec->init_verbs[spec->num_init_verbs++] = | |
597 | preset->init_verbs[i]; | |
df694daa KY |
598 | |
599 | spec->channel_mode = preset->channel_mode; | |
600 | spec->num_channel_mode = preset->num_channel_mode; | |
4e195a7b | 601 | spec->need_dac_fix = preset->need_dac_fix; |
df694daa KY |
602 | |
603 | spec->multiout.max_channels = spec->channel_mode[0].channels; | |
604 | ||
605 | spec->multiout.num_dacs = preset->num_dacs; | |
606 | spec->multiout.dac_nids = preset->dac_nids; | |
607 | spec->multiout.dig_out_nid = preset->dig_out_nid; | |
608 | spec->multiout.hp_nid = preset->hp_nid; | |
609 | ||
a1e8d2da | 610 | spec->num_mux_defs = preset->num_mux_defs; |
f12ab1e0 | 611 | if (!spec->num_mux_defs) |
a1e8d2da | 612 | spec->num_mux_defs = 1; |
df694daa KY |
613 | spec->input_mux = preset->input_mux; |
614 | ||
615 | spec->num_adc_nids = preset->num_adc_nids; | |
616 | spec->adc_nids = preset->adc_nids; | |
617 | spec->dig_in_nid = preset->dig_in_nid; | |
ae6b813a TI |
618 | |
619 | spec->unsol_event = preset->unsol_event; | |
620 | spec->init_hook = preset->init_hook; | |
df694daa KY |
621 | } |
622 | ||
bc9f98a9 KY |
623 | /* Enable GPIO mask and set output */ |
624 | static struct hda_verb alc_gpio1_init_verbs[] = { | |
625 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
626 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
627 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, | |
628 | { } | |
629 | }; | |
630 | ||
631 | static struct hda_verb alc_gpio2_init_verbs[] = { | |
632 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, | |
633 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, | |
634 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, | |
635 | { } | |
636 | }; | |
637 | ||
638 | /* 32-bit subsystem ID for BIOS loading in HD Audio codec. | |
639 | * 31 ~ 16 : Manufacture ID | |
640 | * 15 ~ 8 : SKU ID | |
641 | * 7 ~ 0 : Assembly ID | |
642 | * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36 | |
643 | */ | |
644 | static void alc_subsystem_id(struct hda_codec *codec, | |
645 | unsigned int porta, unsigned int porte, | |
646 | unsigned int portd) | |
647 | { | |
648 | unsigned int ass, tmp; | |
649 | ||
650 | ass = codec->subsystem_id; | |
651 | if (!(ass & 1)) | |
652 | return; | |
653 | ||
654 | /* Override */ | |
655 | tmp = (ass & 0x38) >> 3; /* external Amp control */ | |
656 | switch (tmp) { | |
657 | case 1: | |
658 | snd_hda_sequence_write(codec, alc_gpio1_init_verbs); | |
659 | break; | |
660 | case 3: | |
661 | snd_hda_sequence_write(codec, alc_gpio2_init_verbs); | |
662 | break; | |
663 | case 5: | |
664 | case 6: | |
665 | if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */ | |
666 | hda_nid_t port = 0; | |
667 | tmp = (ass & 0x1800) >> 11; | |
668 | switch (tmp) { | |
669 | case 0: port = porta; break; | |
670 | case 1: port = porte; break; | |
671 | case 2: port = portd; break; | |
672 | } | |
673 | if (port) | |
674 | snd_hda_codec_write(codec, port, 0, | |
675 | AC_VERB_SET_EAPD_BTLENABLE, | |
676 | 2); | |
677 | } | |
678 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); | |
679 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, | |
680 | (tmp == 5 ? 0x3040 : 0x3050)); | |
681 | break; | |
682 | } | |
683 | } | |
684 | ||
1da177e4 | 685 | /* |
e9edcee0 TI |
686 | * ALC880 3-stack model |
687 | * | |
688 | * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e) | |
9c7f852e TI |
689 | * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, |
690 | * F-Mic = 0x1b, HP = 0x19 | |
1da177e4 LT |
691 | */ |
692 | ||
e9edcee0 TI |
693 | static hda_nid_t alc880_dac_nids[4] = { |
694 | /* front, rear, clfe, rear_surr */ | |
695 | 0x02, 0x05, 0x04, 0x03 | |
696 | }; | |
697 | ||
698 | static hda_nid_t alc880_adc_nids[3] = { | |
699 | /* ADC0-2 */ | |
700 | 0x07, 0x08, 0x09, | |
701 | }; | |
702 | ||
703 | /* The datasheet says the node 0x07 is connected from inputs, | |
704 | * but it shows zero connection in the real implementation on some devices. | |
df694daa | 705 | * Note: this is a 915GAV bug, fixed on 915GLV |
1da177e4 | 706 | */ |
e9edcee0 TI |
707 | static hda_nid_t alc880_adc_nids_alt[2] = { |
708 | /* ADC1-2 */ | |
709 | 0x08, 0x09, | |
710 | }; | |
711 | ||
712 | #define ALC880_DIGOUT_NID 0x06 | |
713 | #define ALC880_DIGIN_NID 0x0a | |
714 | ||
715 | static struct hda_input_mux alc880_capture_source = { | |
716 | .num_items = 4, | |
717 | .items = { | |
718 | { "Mic", 0x0 }, | |
719 | { "Front Mic", 0x3 }, | |
720 | { "Line", 0x2 }, | |
721 | { "CD", 0x4 }, | |
722 | }, | |
723 | }; | |
724 | ||
725 | /* channel source setting (2/6 channel selection for 3-stack) */ | |
726 | /* 2ch mode */ | |
727 | static struct hda_verb alc880_threestack_ch2_init[] = { | |
728 | /* set line-in to input, mute it */ | |
729 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
730 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
731 | /* set mic-in to input vref 80%, mute it */ | |
732 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
733 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
734 | { } /* end */ | |
735 | }; | |
736 | ||
737 | /* 6ch mode */ | |
738 | static struct hda_verb alc880_threestack_ch6_init[] = { | |
739 | /* set line-in to output, unmute it */ | |
740 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
741 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
742 | /* set mic-in to output, unmute it */ | |
743 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
744 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
745 | { } /* end */ | |
746 | }; | |
747 | ||
d2a6d7dc | 748 | static struct hda_channel_mode alc880_threestack_modes[2] = { |
e9edcee0 TI |
749 | { 2, alc880_threestack_ch2_init }, |
750 | { 6, alc880_threestack_ch6_init }, | |
751 | }; | |
752 | ||
c8b6bf9b | 753 | static struct snd_kcontrol_new alc880_three_stack_mixer[] = { |
05acb863 | 754 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 755 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
05acb863 | 756 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 757 | HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT), |
05acb863 TI |
758 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
759 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
760 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
761 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
1da177e4 LT |
762 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
763 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
764 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
765 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
766 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
767 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
768 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT), | |
769 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT), | |
770 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
771 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
e9edcee0 TI |
772 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT), |
773 | { | |
774 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
775 | .name = "Channel Mode", | |
df694daa KY |
776 | .info = alc_ch_mode_info, |
777 | .get = alc_ch_mode_get, | |
778 | .put = alc_ch_mode_put, | |
e9edcee0 TI |
779 | }, |
780 | { } /* end */ | |
781 | }; | |
782 | ||
783 | /* capture mixer elements */ | |
c8b6bf9b | 784 | static struct snd_kcontrol_new alc880_capture_mixer[] = { |
e9edcee0 TI |
785 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), |
786 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), | |
787 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), | |
788 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), | |
789 | HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), | |
790 | HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), | |
1da177e4 LT |
791 | { |
792 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
793 | /* The multiple "Capture Source" controls confuse alsamixer | |
794 | * So call somewhat different.. | |
795 | * FIXME: the controls appear in the "playback" view! | |
796 | */ | |
797 | /* .name = "Capture Source", */ | |
798 | .name = "Input Source", | |
e9edcee0 | 799 | .count = 3, |
1da177e4 LT |
800 | .info = alc_mux_enum_info, |
801 | .get = alc_mux_enum_get, | |
802 | .put = alc_mux_enum_put, | |
803 | }, | |
1da177e4 LT |
804 | { } /* end */ |
805 | }; | |
806 | ||
e9edcee0 | 807 | /* capture mixer elements (in case NID 0x07 not available) */ |
c8b6bf9b | 808 | static struct snd_kcontrol_new alc880_capture_alt_mixer[] = { |
71fe7b82 TI |
809 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
810 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
811 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
812 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
1da177e4 LT |
813 | { |
814 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
815 | /* The multiple "Capture Source" controls confuse alsamixer | |
816 | * So call somewhat different.. | |
817 | * FIXME: the controls appear in the "playback" view! | |
818 | */ | |
819 | /* .name = "Capture Source", */ | |
820 | .name = "Input Source", | |
821 | .count = 2, | |
822 | .info = alc_mux_enum_info, | |
823 | .get = alc_mux_enum_get, | |
824 | .put = alc_mux_enum_put, | |
825 | }, | |
1da177e4 LT |
826 | { } /* end */ |
827 | }; | |
828 | ||
e9edcee0 TI |
829 | |
830 | ||
831 | /* | |
832 | * ALC880 5-stack model | |
833 | * | |
9c7f852e TI |
834 | * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), |
835 | * Side = 0x02 (0xd) | |
e9edcee0 TI |
836 | * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16 |
837 | * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19 | |
838 | */ | |
839 | ||
840 | /* additional mixers to alc880_three_stack_mixer */ | |
c8b6bf9b | 841 | static struct snd_kcontrol_new alc880_five_stack_mixer[] = { |
e9edcee0 | 842 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 843 | HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT), |
1da177e4 LT |
844 | { } /* end */ |
845 | }; | |
846 | ||
e9edcee0 TI |
847 | /* channel source setting (6/8 channel selection for 5-stack) */ |
848 | /* 6ch mode */ | |
849 | static struct hda_verb alc880_fivestack_ch6_init[] = { | |
850 | /* set line-in to input, mute it */ | |
851 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
852 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
dfc0ff62 TI |
853 | { } /* end */ |
854 | }; | |
855 | ||
e9edcee0 TI |
856 | /* 8ch mode */ |
857 | static struct hda_verb alc880_fivestack_ch8_init[] = { | |
858 | /* set line-in to output, unmute it */ | |
859 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
860 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
861 | { } /* end */ | |
862 | }; | |
863 | ||
d2a6d7dc | 864 | static struct hda_channel_mode alc880_fivestack_modes[2] = { |
e9edcee0 TI |
865 | { 6, alc880_fivestack_ch6_init }, |
866 | { 8, alc880_fivestack_ch8_init }, | |
867 | }; | |
868 | ||
869 | ||
870 | /* | |
871 | * ALC880 6-stack model | |
872 | * | |
9c7f852e TI |
873 | * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), |
874 | * Side = 0x05 (0x0f) | |
e9edcee0 TI |
875 | * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17, |
876 | * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b | |
877 | */ | |
878 | ||
879 | static hda_nid_t alc880_6st_dac_nids[4] = { | |
880 | /* front, rear, clfe, rear_surr */ | |
881 | 0x02, 0x03, 0x04, 0x05 | |
f12ab1e0 | 882 | }; |
e9edcee0 TI |
883 | |
884 | static struct hda_input_mux alc880_6stack_capture_source = { | |
885 | .num_items = 4, | |
886 | .items = { | |
887 | { "Mic", 0x0 }, | |
888 | { "Front Mic", 0x1 }, | |
889 | { "Line", 0x2 }, | |
890 | { "CD", 0x4 }, | |
891 | }, | |
892 | }; | |
893 | ||
894 | /* fixed 8-channels */ | |
d2a6d7dc | 895 | static struct hda_channel_mode alc880_sixstack_modes[1] = { |
e9edcee0 TI |
896 | { 8, NULL }, |
897 | }; | |
898 | ||
c8b6bf9b | 899 | static struct snd_kcontrol_new alc880_six_stack_mixer[] = { |
16ded525 | 900 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 901 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 902 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 903 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
904 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
905 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
906 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
907 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
16ded525 | 908 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 909 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
16ded525 TI |
910 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
911 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
912 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
913 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
914 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
915 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
916 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
917 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
918 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
919 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
16ded525 TI |
920 | { |
921 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
922 | .name = "Channel Mode", | |
df694daa KY |
923 | .info = alc_ch_mode_info, |
924 | .get = alc_ch_mode_get, | |
925 | .put = alc_ch_mode_put, | |
16ded525 TI |
926 | }, |
927 | { } /* end */ | |
928 | }; | |
929 | ||
e9edcee0 TI |
930 | |
931 | /* | |
932 | * ALC880 W810 model | |
933 | * | |
934 | * W810 has rear IO for: | |
935 | * Front (DAC 02) | |
936 | * Surround (DAC 03) | |
937 | * Center/LFE (DAC 04) | |
938 | * Digital out (06) | |
939 | * | |
940 | * The system also has a pair of internal speakers, and a headphone jack. | |
941 | * These are both connected to Line2 on the codec, hence to DAC 02. | |
942 | * | |
943 | * There is a variable resistor to control the speaker or headphone | |
944 | * volume. This is a hardware-only device without a software API. | |
945 | * | |
946 | * Plugging headphones in will disable the internal speakers. This is | |
947 | * implemented in hardware, not via the driver using jack sense. In | |
948 | * a similar fashion, plugging into the rear socket marked "front" will | |
949 | * disable both the speakers and headphones. | |
950 | * | |
951 | * For input, there's a microphone jack, and an "audio in" jack. | |
952 | * These may not do anything useful with this driver yet, because I | |
953 | * haven't setup any initialization verbs for these yet... | |
954 | */ | |
955 | ||
956 | static hda_nid_t alc880_w810_dac_nids[3] = { | |
957 | /* front, rear/surround, clfe */ | |
958 | 0x02, 0x03, 0x04 | |
16ded525 TI |
959 | }; |
960 | ||
e9edcee0 | 961 | /* fixed 6 channels */ |
d2a6d7dc | 962 | static struct hda_channel_mode alc880_w810_modes[1] = { |
e9edcee0 TI |
963 | { 6, NULL } |
964 | }; | |
965 | ||
966 | /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */ | |
c8b6bf9b | 967 | static struct snd_kcontrol_new alc880_w810_base_mixer[] = { |
16ded525 | 968 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 969 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 970 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 971 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
972 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
973 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
974 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
975 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
e9edcee0 TI |
976 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
977 | { } /* end */ | |
978 | }; | |
979 | ||
980 | ||
981 | /* | |
982 | * Z710V model | |
983 | * | |
984 | * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d) | |
9c7f852e TI |
985 | * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), |
986 | * Line = 0x1a | |
e9edcee0 TI |
987 | */ |
988 | ||
989 | static hda_nid_t alc880_z71v_dac_nids[1] = { | |
990 | 0x02 | |
991 | }; | |
992 | #define ALC880_Z71V_HP_DAC 0x03 | |
993 | ||
994 | /* fixed 2 channels */ | |
d2a6d7dc | 995 | static struct hda_channel_mode alc880_2_jack_modes[1] = { |
e9edcee0 TI |
996 | { 2, NULL } |
997 | }; | |
998 | ||
c8b6bf9b | 999 | static struct snd_kcontrol_new alc880_z71v_mixer[] = { |
e9edcee0 | 1000 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1001 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
e9edcee0 | 1002 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1003 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1004 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1005 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
16ded525 TI |
1006 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
1007 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
16ded525 TI |
1008 | { } /* end */ |
1009 | }; | |
1010 | ||
e9edcee0 TI |
1011 | |
1012 | /* FIXME! */ | |
1013 | /* | |
1014 | * ALC880 F1734 model | |
1015 | * | |
1016 | * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d) | |
1017 | * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18 | |
1018 | */ | |
1019 | ||
1020 | static hda_nid_t alc880_f1734_dac_nids[1] = { | |
1021 | 0x03 | |
1022 | }; | |
1023 | #define ALC880_F1734_HP_DAC 0x02 | |
1024 | ||
c8b6bf9b | 1025 | static struct snd_kcontrol_new alc880_f1734_mixer[] = { |
e9edcee0 | 1026 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1027 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), |
e9edcee0 | 1028 | HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1029 | HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT), |
e9edcee0 TI |
1030 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1031 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1032 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1033 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1034 | { } /* end */ | |
1035 | }; | |
1036 | ||
1037 | ||
1038 | /* FIXME! */ | |
1039 | /* | |
1040 | * ALC880 ASUS model | |
1041 | * | |
1042 | * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) | |
1043 | * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, | |
1044 | * Mic = 0x18, Line = 0x1a | |
1045 | */ | |
1046 | ||
1047 | #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */ | |
1048 | #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */ | |
1049 | ||
c8b6bf9b | 1050 | static struct snd_kcontrol_new alc880_asus_mixer[] = { |
16ded525 | 1051 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1052 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 1053 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1054 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1055 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1056 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1057 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1058 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
16ded525 TI |
1059 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1060 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1061 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1062 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
16ded525 TI |
1063 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
1064 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
16ded525 TI |
1065 | { |
1066 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1067 | .name = "Channel Mode", | |
df694daa KY |
1068 | .info = alc_ch_mode_info, |
1069 | .get = alc_ch_mode_get, | |
1070 | .put = alc_ch_mode_put, | |
16ded525 TI |
1071 | }, |
1072 | { } /* end */ | |
1073 | }; | |
e9edcee0 TI |
1074 | |
1075 | /* FIXME! */ | |
1076 | /* | |
1077 | * ALC880 ASUS W1V model | |
1078 | * | |
1079 | * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) | |
1080 | * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, | |
1081 | * Mic = 0x18, Line = 0x1a, Line2 = 0x1b | |
1082 | */ | |
1083 | ||
1084 | /* additional mixers to alc880_asus_mixer */ | |
c8b6bf9b | 1085 | static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = { |
e9edcee0 TI |
1086 | HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT), |
1087 | HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT), | |
1088 | { } /* end */ | |
1089 | }; | |
1090 | ||
3c10a9d9 | 1091 | /* additional mixers to alc880_asus_mixer */ |
c8b6bf9b | 1092 | static struct snd_kcontrol_new alc880_pcbeep_mixer[] = { |
3c10a9d9 TI |
1093 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), |
1094 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
1095 | { } /* end */ | |
1096 | }; | |
e9edcee0 | 1097 | |
df694daa KY |
1098 | /* TCL S700 */ |
1099 | static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = { | |
1100 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1101 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
1102 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
1103 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT), | |
1104 | HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT), | |
1105 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT), | |
1106 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT), | |
1107 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
1108 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
1109 | { | |
1110 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1111 | /* The multiple "Capture Source" controls confuse alsamixer | |
1112 | * So call somewhat different.. | |
1113 | * FIXME: the controls appear in the "playback" view! | |
1114 | */ | |
1115 | /* .name = "Capture Source", */ | |
1116 | .name = "Input Source", | |
1117 | .count = 1, | |
1118 | .info = alc_mux_enum_info, | |
1119 | .get = alc_mux_enum_get, | |
1120 | .put = alc_mux_enum_put, | |
1121 | }, | |
1122 | { } /* end */ | |
1123 | }; | |
1124 | ||
ccc656ce KY |
1125 | /* Uniwill */ |
1126 | static struct snd_kcontrol_new alc880_uniwill_mixer[] = { | |
1127 | HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1128 | HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1129 | HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1130 | HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
1131 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
1132 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
1133 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
1134 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
1135 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
1136 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1137 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1138 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
1139 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1140 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1141 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1142 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1143 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
1144 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
1145 | { | |
1146 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1147 | .name = "Channel Mode", | |
1148 | .info = alc_ch_mode_info, | |
1149 | .get = alc_ch_mode_get, | |
1150 | .put = alc_ch_mode_put, | |
1151 | }, | |
1152 | { } /* end */ | |
1153 | }; | |
1154 | ||
2cf9f0fc TD |
1155 | static struct snd_kcontrol_new alc880_fujitsu_mixer[] = { |
1156 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1157 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1158 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1159 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
1160 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
1161 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1162 | HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1163 | HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1164 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1165 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1166 | { } /* end */ | |
1167 | }; | |
1168 | ||
ccc656ce KY |
1169 | static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = { |
1170 | HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1171 | HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1172 | HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1173 | HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
1174 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1175 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1176 | { } /* end */ | |
1177 | }; | |
1178 | ||
1da177e4 | 1179 | /* |
e9edcee0 | 1180 | * build control elements |
1da177e4 LT |
1181 | */ |
1182 | static int alc_build_controls(struct hda_codec *codec) | |
1183 | { | |
1184 | struct alc_spec *spec = codec->spec; | |
1185 | int err; | |
1186 | int i; | |
1187 | ||
1188 | for (i = 0; i < spec->num_mixers; i++) { | |
1189 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); | |
1190 | if (err < 0) | |
1191 | return err; | |
1192 | } | |
1193 | ||
1194 | if (spec->multiout.dig_out_nid) { | |
9c7f852e TI |
1195 | err = snd_hda_create_spdif_out_ctls(codec, |
1196 | spec->multiout.dig_out_nid); | |
1da177e4 LT |
1197 | if (err < 0) |
1198 | return err; | |
1199 | } | |
1200 | if (spec->dig_in_nid) { | |
1201 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); | |
1202 | if (err < 0) | |
1203 | return err; | |
1204 | } | |
1205 | return 0; | |
1206 | } | |
1207 | ||
e9edcee0 | 1208 | |
1da177e4 LT |
1209 | /* |
1210 | * initialize the codec volumes, etc | |
1211 | */ | |
1212 | ||
e9edcee0 TI |
1213 | /* |
1214 | * generic initialization of ADC, input mixers and output mixers | |
1215 | */ | |
1216 | static struct hda_verb alc880_volume_init_verbs[] = { | |
1217 | /* | |
1218 | * Unmute ADC0-2 and set the default input to mic-in | |
1219 | */ | |
71fe7b82 | 1220 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 1221 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
71fe7b82 | 1222 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 1223 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
71fe7b82 | 1224 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 1225 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1da177e4 | 1226 | |
e9edcee0 TI |
1227 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
1228 | * mixer widget | |
9c7f852e TI |
1229 | * Note: PASD motherboards uses the Line In 2 as the input for front |
1230 | * panel mic (mic 2) | |
1da177e4 | 1231 | */ |
e9edcee0 | 1232 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ |
16ded525 | 1233 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
e9edcee0 TI |
1234 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
1235 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
1236 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
1237 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
1da177e4 | 1238 | |
e9edcee0 TI |
1239 | /* |
1240 | * Set up output mixers (0x0c - 0x0f) | |
1da177e4 | 1241 | */ |
e9edcee0 TI |
1242 | /* set vol=0 to output mixers */ |
1243 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1244 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1245 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1246 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1247 | /* set up input amps for analog loopback */ | |
1248 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
05acb863 TI |
1249 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1250 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
1251 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1252 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
1253 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1254 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
1255 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1256 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 LT |
1257 | |
1258 | { } | |
1259 | }; | |
1260 | ||
e9edcee0 TI |
1261 | /* |
1262 | * 3-stack pin configuration: | |
1263 | * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b | |
1264 | */ | |
1265 | static struct hda_verb alc880_pin_3stack_init_verbs[] = { | |
1266 | /* | |
1267 | * preset connection lists of input pins | |
1268 | * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround | |
1269 | */ | |
1270 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
1271 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
1272 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */ | |
1273 | ||
1274 | /* | |
1275 | * Set pin mode and muting | |
1276 | */ | |
1277 | /* set front pin widgets 0x14 for output */ | |
05acb863 | 1278 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
1279 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1280 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
1281 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1282 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1283 | /* Mic2 (as headphone out) for HP output */ | |
1284 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1285 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1da177e4 | 1286 | /* Line In pin widget for input */ |
05acb863 | 1287 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 TI |
1288 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
1289 | /* Line2 (as front mic) pin widget for input and vref at 80% */ | |
1290 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1291 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1da177e4 | 1292 | /* CD pin widget for input */ |
05acb863 | 1293 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 1294 | |
e9edcee0 TI |
1295 | { } |
1296 | }; | |
1da177e4 | 1297 | |
e9edcee0 TI |
1298 | /* |
1299 | * 5-stack pin configuration: | |
1300 | * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19, | |
1301 | * line-in/side = 0x1a, f-mic = 0x1b | |
1302 | */ | |
1303 | static struct hda_verb alc880_pin_5stack_init_verbs[] = { | |
1304 | /* | |
1305 | * preset connection lists of input pins | |
1306 | * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround | |
1da177e4 | 1307 | */ |
e9edcee0 TI |
1308 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
1309 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */ | |
1da177e4 | 1310 | |
e9edcee0 TI |
1311 | /* |
1312 | * Set pin mode and muting | |
1da177e4 | 1313 | */ |
e9edcee0 TI |
1314 | /* set pin widgets 0x14-0x17 for output */ |
1315 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1316 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1317 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1318 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1319 | /* unmute pins for output (no gain on this amp) */ | |
1320 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1321 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1322 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1323 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1324 | ||
1325 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
1326 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1327 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1328 | /* Mic2 (as headphone out) for HP output */ | |
1329 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1330 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1331 | /* Line In pin widget for input */ | |
1332 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1333 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1334 | /* Line2 (as front mic) pin widget for input and vref at 80% */ | |
1335 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1336 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1337 | /* CD pin widget for input */ | |
1338 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1da177e4 LT |
1339 | |
1340 | { } | |
1341 | }; | |
1342 | ||
e9edcee0 TI |
1343 | /* |
1344 | * W810 pin configuration: | |
1345 | * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b | |
1346 | */ | |
1347 | static struct hda_verb alc880_pin_w810_init_verbs[] = { | |
1348 | /* hphone/speaker input selector: front DAC */ | |
1349 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
1da177e4 | 1350 | |
05acb863 | 1351 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1352 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 1353 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1354 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 1355 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1356 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 1357 | |
e9edcee0 | 1358 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
05acb863 | 1359 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
1da177e4 | 1360 | |
1da177e4 LT |
1361 | { } |
1362 | }; | |
1363 | ||
e9edcee0 TI |
1364 | /* |
1365 | * Z71V pin configuration: | |
1366 | * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?) | |
1367 | */ | |
1368 | static struct hda_verb alc880_pin_z71v_init_verbs[] = { | |
05acb863 | 1369 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1370 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 1371 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
e9edcee0 | 1372 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
dfc0ff62 | 1373 | |
16ded525 | 1374 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1375 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
16ded525 | 1376 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1377 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
16ded525 TI |
1378 | |
1379 | { } | |
1380 | }; | |
1381 | ||
e9edcee0 TI |
1382 | /* |
1383 | * 6-stack pin configuration: | |
9c7f852e TI |
1384 | * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, |
1385 | * f-mic = 0x19, line = 0x1a, HP = 0x1b | |
e9edcee0 TI |
1386 | */ |
1387 | static struct hda_verb alc880_pin_6stack_init_verbs[] = { | |
1388 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
1389 | ||
16ded525 | 1390 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1391 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1392 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1393 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1394 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1395 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1396 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
1397 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1398 | ||
16ded525 | 1399 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1400 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 1401 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1402 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 1403 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 | 1404 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 1405 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
e9edcee0 | 1406 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 TI |
1407 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1408 | ||
e9edcee0 TI |
1409 | { } |
1410 | }; | |
1411 | ||
ccc656ce KY |
1412 | /* |
1413 | * Uniwill pin configuration: | |
1414 | * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19, | |
1415 | * line = 0x1a | |
1416 | */ | |
1417 | static struct hda_verb alc880_uniwill_init_verbs[] = { | |
1418 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
1419 | ||
1420 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1421 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1422 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1423 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1424 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1425 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1426 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1427 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1428 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1429 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1430 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1431 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1432 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1433 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1434 | ||
1435 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1436 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1437 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1438 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1439 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1440 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1441 | /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */ | |
1442 | /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */ | |
1443 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1444 | ||
1445 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
1446 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
1447 | ||
1448 | { } | |
1449 | }; | |
1450 | ||
1451 | /* | |
1452 | * Uniwill P53 | |
1453 | * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19, | |
1454 | */ | |
1455 | static struct hda_verb alc880_uniwill_p53_init_verbs[] = { | |
1456 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
1457 | ||
1458 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1459 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1460 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1461 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1462 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1463 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1464 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1465 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1466 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1467 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1468 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1469 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1470 | ||
1471 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1472 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1473 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1474 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1475 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1476 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1477 | ||
1478 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
1479 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT}, | |
1480 | ||
1481 | { } | |
1482 | }; | |
1483 | ||
2cf9f0fc TD |
1484 | static struct hda_verb alc880_beep_init_verbs[] = { |
1485 | { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) }, | |
1486 | { } | |
1487 | }; | |
1488 | ||
ccc656ce KY |
1489 | /* toggle speaker-output according to the hp-jack state */ |
1490 | static void alc880_uniwill_automute(struct hda_codec *codec) | |
1491 | { | |
1492 | unsigned int present; | |
f12ab1e0 | 1493 | unsigned char bits; |
ccc656ce KY |
1494 | |
1495 | present = snd_hda_codec_read(codec, 0x14, 0, | |
1496 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
f12ab1e0 | 1497 | bits = present ? 0x80 : 0; |
ccc656ce | 1498 | snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, |
f12ab1e0 | 1499 | 0x80, bits); |
ccc656ce | 1500 | snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, |
f12ab1e0 | 1501 | 0x80, bits); |
ccc656ce | 1502 | snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0, |
f12ab1e0 | 1503 | 0x80, bits); |
ccc656ce | 1504 | snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0, |
f12ab1e0 | 1505 | 0x80, bits); |
ccc656ce KY |
1506 | |
1507 | present = snd_hda_codec_read(codec, 0x18, 0, | |
1508 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
1509 | snd_hda_codec_write(codec, 0x0b, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
f12ab1e0 | 1510 | 0x7000 | (0x01 << 8) | bits); |
ccc656ce KY |
1511 | } |
1512 | ||
1513 | static void alc880_uniwill_unsol_event(struct hda_codec *codec, | |
1514 | unsigned int res) | |
1515 | { | |
1516 | /* Looks like the unsol event is incompatible with the standard | |
1517 | * definition. 4bit tag is placed at 28 bit! | |
1518 | */ | |
1519 | if ((res >> 28) == ALC880_HP_EVENT || | |
1520 | (res >> 28) == ALC880_MIC_EVENT) | |
1521 | alc880_uniwill_automute(codec); | |
1522 | } | |
1523 | ||
1524 | static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec) | |
1525 | { | |
1526 | unsigned int present; | |
f12ab1e0 | 1527 | unsigned char bits; |
ccc656ce KY |
1528 | |
1529 | present = snd_hda_codec_read(codec, 0x14, 0, | |
1530 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
f12ab1e0 | 1531 | bits = present ? 0x80 : 0; |
ccc656ce | 1532 | snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0, |
f12ab1e0 | 1533 | 0x80, bits); |
ccc656ce | 1534 | snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0, |
f12ab1e0 | 1535 | 0x80, bits); |
ccc656ce KY |
1536 | } |
1537 | ||
1538 | static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) | |
1539 | { | |
1540 | unsigned int present; | |
1541 | ||
1542 | present = snd_hda_codec_read(codec, 0x21, 0, | |
1543 | AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f; | |
1544 | ||
1545 | snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0, | |
1546 | 0x7f, present); | |
1547 | snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0, | |
1548 | 0x7f, present); | |
1549 | ||
1550 | snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0, | |
1551 | 0x7f, present); | |
1552 | snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0, | |
1553 | 0x7f, present); | |
1554 | ||
1555 | } | |
1556 | static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec, | |
1557 | unsigned int res) | |
1558 | { | |
1559 | /* Looks like the unsol event is incompatible with the standard | |
1560 | * definition. 4bit tag is placed at 28 bit! | |
1561 | */ | |
1562 | if ((res >> 28) == ALC880_HP_EVENT) | |
1563 | alc880_uniwill_p53_hp_automute(codec); | |
f12ab1e0 | 1564 | if ((res >> 28) == ALC880_DCVOL_EVENT) |
ccc656ce KY |
1565 | alc880_uniwill_p53_dcvol_automute(codec); |
1566 | } | |
1567 | ||
e9edcee0 TI |
1568 | /* FIXME! */ |
1569 | /* | |
1570 | * F1734 pin configuration: | |
1571 | * HP = 0x14, speaker-out = 0x15, mic = 0x18 | |
1572 | */ | |
1573 | static struct hda_verb alc880_pin_f1734_init_verbs[] = { | |
16ded525 TI |
1574 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, |
1575 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1576 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
1577 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1578 | ||
e9edcee0 | 1579 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
16ded525 | 1580 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
e9edcee0 | 1581 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
16ded525 | 1582 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1583 | |
e9edcee0 TI |
1584 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1585 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
16ded525 | 1586 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1587 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 1588 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1589 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1590 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1591 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1592 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
dfc0ff62 TI |
1593 | |
1594 | { } | |
1595 | }; | |
1596 | ||
e9edcee0 TI |
1597 | /* FIXME! */ |
1598 | /* | |
1599 | * ASUS pin configuration: | |
1600 | * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a | |
1601 | */ | |
1602 | static struct hda_verb alc880_pin_asus_init_verbs[] = { | |
16ded525 TI |
1603 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, |
1604 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1605 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
1606 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1607 | ||
1608 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
e9edcee0 | 1609 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1610 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1611 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1612 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1613 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1614 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
1615 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1616 | ||
1617 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1618 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1619 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1620 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1621 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1622 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
16ded525 | 1623 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1624 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 TI |
1625 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1626 | ||
e9edcee0 TI |
1627 | { } |
1628 | }; | |
16ded525 | 1629 | |
e9edcee0 | 1630 | /* Enable GPIO mask and set output */ |
bc9f98a9 KY |
1631 | #define alc880_gpio1_init_verbs alc_gpio1_init_verbs |
1632 | #define alc880_gpio2_init_verbs alc_gpio2_init_verbs | |
df694daa KY |
1633 | |
1634 | /* Clevo m520g init */ | |
1635 | static struct hda_verb alc880_pin_clevo_init_verbs[] = { | |
1636 | /* headphone output */ | |
1637 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
1638 | /* line-out */ | |
1639 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1640 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1641 | /* Line-in */ | |
1642 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1643 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1644 | /* CD */ | |
1645 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1646 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1647 | /* Mic1 (rear panel) */ | |
1648 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1649 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1650 | /* Mic2 (front panel) */ | |
1651 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1652 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1653 | /* headphone */ | |
1654 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1655 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1656 | /* change to EAPD mode */ | |
1657 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
1658 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, | |
1659 | ||
1660 | { } | |
16ded525 TI |
1661 | }; |
1662 | ||
df694daa | 1663 | static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = { |
4b146cb0 TI |
1664 | /* change to EAPD mode */ |
1665 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
1666 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, | |
1667 | ||
df694daa KY |
1668 | /* Headphone output */ |
1669 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1670 | /* Front output*/ | |
1671 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1672 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1673 | ||
1674 | /* Line In pin widget for input */ | |
1675 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1676 | /* CD pin widget for input */ | |
1677 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1678 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
1679 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1680 | ||
1681 | /* change to EAPD mode */ | |
1682 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
1683 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
1684 | ||
1685 | { } | |
1686 | }; | |
16ded525 | 1687 | |
e9edcee0 | 1688 | /* |
ae6b813a TI |
1689 | * LG m1 express dual |
1690 | * | |
1691 | * Pin assignment: | |
1692 | * Rear Line-In/Out (blue): 0x14 | |
1693 | * Build-in Mic-In: 0x15 | |
1694 | * Speaker-out: 0x17 | |
1695 | * HP-Out (green): 0x1b | |
1696 | * Mic-In/Out (red): 0x19 | |
1697 | * SPDIF-Out: 0x1e | |
1698 | */ | |
1699 | ||
1700 | /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */ | |
1701 | static hda_nid_t alc880_lg_dac_nids[3] = { | |
1702 | 0x05, 0x02, 0x03 | |
1703 | }; | |
1704 | ||
1705 | /* seems analog CD is not working */ | |
1706 | static struct hda_input_mux alc880_lg_capture_source = { | |
1707 | .num_items = 3, | |
1708 | .items = { | |
1709 | { "Mic", 0x1 }, | |
1710 | { "Line", 0x5 }, | |
1711 | { "Internal Mic", 0x6 }, | |
1712 | }, | |
1713 | }; | |
1714 | ||
1715 | /* 2,4,6 channel modes */ | |
1716 | static struct hda_verb alc880_lg_ch2_init[] = { | |
1717 | /* set line-in and mic-in to input */ | |
1718 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
1719 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
1720 | { } | |
1721 | }; | |
1722 | ||
1723 | static struct hda_verb alc880_lg_ch4_init[] = { | |
1724 | /* set line-in to out and mic-in to input */ | |
1725 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
1726 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
1727 | { } | |
1728 | }; | |
1729 | ||
1730 | static struct hda_verb alc880_lg_ch6_init[] = { | |
1731 | /* set line-in and mic-in to output */ | |
1732 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
1733 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
1734 | { } | |
1735 | }; | |
1736 | ||
1737 | static struct hda_channel_mode alc880_lg_ch_modes[3] = { | |
1738 | { 2, alc880_lg_ch2_init }, | |
1739 | { 4, alc880_lg_ch4_init }, | |
1740 | { 6, alc880_lg_ch6_init }, | |
1741 | }; | |
1742 | ||
1743 | static struct snd_kcontrol_new alc880_lg_mixer[] = { | |
1744 | /* FIXME: it's not really "master" but front channels */ | |
1745 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
1746 | HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT), | |
1747 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1748 | HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT), | |
1749 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), | |
1750 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT), | |
1751 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT), | |
1752 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), | |
1753 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1754 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1755 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT), | |
1756 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT), | |
1757 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT), | |
1758 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT), | |
1759 | { | |
1760 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1761 | .name = "Channel Mode", | |
1762 | .info = alc_ch_mode_info, | |
1763 | .get = alc_ch_mode_get, | |
1764 | .put = alc_ch_mode_put, | |
1765 | }, | |
1766 | { } /* end */ | |
1767 | }; | |
1768 | ||
1769 | static struct hda_verb alc880_lg_init_verbs[] = { | |
1770 | /* set capture source to mic-in */ | |
1771 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
1772 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
1773 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
1774 | /* mute all amp mixer inputs */ | |
1775 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)}, | |
1776 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)}, | |
1777 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)}, | |
1778 | /* line-in to input */ | |
1779 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1780 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1781 | /* built-in mic */ | |
1782 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1783 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1784 | /* speaker-out */ | |
1785 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1786 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1787 | /* mic-in to input */ | |
1788 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
1789 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1790 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1791 | /* HP-out */ | |
1792 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
1793 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1794 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1795 | /* jack sense */ | |
1796 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, | |
1797 | { } | |
1798 | }; | |
1799 | ||
1800 | /* toggle speaker-output according to the hp-jack state */ | |
1801 | static void alc880_lg_automute(struct hda_codec *codec) | |
1802 | { | |
1803 | unsigned int present; | |
f12ab1e0 | 1804 | unsigned char bits; |
ae6b813a TI |
1805 | |
1806 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
1807 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
f12ab1e0 | 1808 | bits = present ? 0x80 : 0; |
ae6b813a | 1809 | snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0, |
f12ab1e0 | 1810 | 0x80, bits); |
ae6b813a | 1811 | snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0, |
f12ab1e0 | 1812 | 0x80, bits); |
ae6b813a TI |
1813 | } |
1814 | ||
1815 | static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res) | |
1816 | { | |
1817 | /* Looks like the unsol event is incompatible with the standard | |
1818 | * definition. 4bit tag is placed at 28 bit! | |
1819 | */ | |
1820 | if ((res >> 28) == 0x01) | |
1821 | alc880_lg_automute(codec); | |
1822 | } | |
1823 | ||
d681518a TI |
1824 | /* |
1825 | * LG LW20 | |
1826 | * | |
1827 | * Pin assignment: | |
1828 | * Speaker-out: 0x14 | |
1829 | * Mic-In: 0x18 | |
1830 | * Built-in Mic-In: 0x19 (?) | |
1831 | * HP-Out: 0x1b | |
1832 | * SPDIF-Out: 0x1e | |
1833 | */ | |
1834 | ||
1835 | /* seems analog CD is not working */ | |
1836 | static struct hda_input_mux alc880_lg_lw_capture_source = { | |
1837 | .num_items = 2, | |
1838 | .items = { | |
1839 | { "Mic", 0x0 }, | |
1840 | { "Internal Mic", 0x1 }, | |
1841 | }, | |
1842 | }; | |
1843 | ||
1844 | static struct snd_kcontrol_new alc880_lg_lw_mixer[] = { | |
1845 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1846 | HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT), | |
1847 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1848 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1849 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
1850 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
1851 | { } /* end */ | |
1852 | }; | |
1853 | ||
1854 | static struct hda_verb alc880_lg_lw_init_verbs[] = { | |
1855 | /* set capture source to mic-in */ | |
1856 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
1857 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
1858 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
1859 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)}, | |
1860 | /* speaker-out */ | |
1861 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1862 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1863 | /* HP-out */ | |
1864 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1865 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1866 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1867 | /* mic-in to input */ | |
1868 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1869 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1870 | /* built-in mic */ | |
1871 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1872 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1873 | /* jack sense */ | |
1874 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, | |
1875 | { } | |
1876 | }; | |
1877 | ||
1878 | /* toggle speaker-output according to the hp-jack state */ | |
1879 | static void alc880_lg_lw_automute(struct hda_codec *codec) | |
1880 | { | |
1881 | unsigned int present; | |
f12ab1e0 | 1882 | unsigned char bits; |
d681518a TI |
1883 | |
1884 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
1885 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
f12ab1e0 | 1886 | bits = present ? 0x80 : 0; |
d681518a | 1887 | snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, |
f12ab1e0 | 1888 | 0x80, bits); |
d681518a | 1889 | snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, |
f12ab1e0 | 1890 | 0x80, bits); |
d681518a TI |
1891 | } |
1892 | ||
1893 | static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res) | |
1894 | { | |
1895 | /* Looks like the unsol event is incompatible with the standard | |
1896 | * definition. 4bit tag is placed at 28 bit! | |
1897 | */ | |
1898 | if ((res >> 28) == 0x01) | |
1899 | alc880_lg_lw_automute(codec); | |
1900 | } | |
1901 | ||
ae6b813a TI |
1902 | /* |
1903 | * Common callbacks | |
e9edcee0 TI |
1904 | */ |
1905 | ||
1da177e4 LT |
1906 | static int alc_init(struct hda_codec *codec) |
1907 | { | |
1908 | struct alc_spec *spec = codec->spec; | |
e9edcee0 TI |
1909 | unsigned int i; |
1910 | ||
1911 | for (i = 0; i < spec->num_init_verbs; i++) | |
1912 | snd_hda_sequence_write(codec, spec->init_verbs[i]); | |
ae6b813a TI |
1913 | |
1914 | if (spec->init_hook) | |
1915 | spec->init_hook(codec); | |
1916 | ||
1da177e4 LT |
1917 | return 0; |
1918 | } | |
1919 | ||
ae6b813a TI |
1920 | static void alc_unsol_event(struct hda_codec *codec, unsigned int res) |
1921 | { | |
1922 | struct alc_spec *spec = codec->spec; | |
1923 | ||
1924 | if (spec->unsol_event) | |
1925 | spec->unsol_event(codec, res); | |
1926 | } | |
1927 | ||
1da177e4 LT |
1928 | #ifdef CONFIG_PM |
1929 | /* | |
1930 | * resume | |
1931 | */ | |
1932 | static int alc_resume(struct hda_codec *codec) | |
1933 | { | |
1934 | struct alc_spec *spec = codec->spec; | |
1935 | int i; | |
1936 | ||
1937 | alc_init(codec); | |
e9edcee0 | 1938 | for (i = 0; i < spec->num_mixers; i++) |
1da177e4 | 1939 | snd_hda_resume_ctls(codec, spec->mixers[i]); |
1da177e4 LT |
1940 | if (spec->multiout.dig_out_nid) |
1941 | snd_hda_resume_spdif_out(codec); | |
1942 | if (spec->dig_in_nid) | |
1943 | snd_hda_resume_spdif_in(codec); | |
1944 | ||
1945 | return 0; | |
1946 | } | |
1947 | #endif | |
1948 | ||
1949 | /* | |
1950 | * Analog playback callbacks | |
1951 | */ | |
1952 | static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo, | |
1953 | struct hda_codec *codec, | |
c8b6bf9b | 1954 | struct snd_pcm_substream *substream) |
1da177e4 LT |
1955 | { |
1956 | struct alc_spec *spec = codec->spec; | |
1957 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); | |
1958 | } | |
1959 | ||
1960 | static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | |
1961 | struct hda_codec *codec, | |
1962 | unsigned int stream_tag, | |
1963 | unsigned int format, | |
c8b6bf9b | 1964 | struct snd_pcm_substream *substream) |
1da177e4 LT |
1965 | { |
1966 | struct alc_spec *spec = codec->spec; | |
9c7f852e TI |
1967 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, |
1968 | stream_tag, format, substream); | |
1da177e4 LT |
1969 | } |
1970 | ||
1971 | static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, | |
1972 | struct hda_codec *codec, | |
c8b6bf9b | 1973 | struct snd_pcm_substream *substream) |
1da177e4 LT |
1974 | { |
1975 | struct alc_spec *spec = codec->spec; | |
1976 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); | |
1977 | } | |
1978 | ||
1979 | /* | |
1980 | * Digital out | |
1981 | */ | |
1982 | static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, | |
1983 | struct hda_codec *codec, | |
c8b6bf9b | 1984 | struct snd_pcm_substream *substream) |
1da177e4 LT |
1985 | { |
1986 | struct alc_spec *spec = codec->spec; | |
1987 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); | |
1988 | } | |
1989 | ||
6b97eb45 TI |
1990 | static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
1991 | struct hda_codec *codec, | |
1992 | unsigned int stream_tag, | |
1993 | unsigned int format, | |
1994 | struct snd_pcm_substream *substream) | |
1995 | { | |
1996 | struct alc_spec *spec = codec->spec; | |
1997 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, | |
1998 | stream_tag, format, substream); | |
1999 | } | |
2000 | ||
1da177e4 LT |
2001 | static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
2002 | struct hda_codec *codec, | |
c8b6bf9b | 2003 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2004 | { |
2005 | struct alc_spec *spec = codec->spec; | |
2006 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); | |
2007 | } | |
2008 | ||
2009 | /* | |
2010 | * Analog capture | |
2011 | */ | |
2012 | static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo, | |
2013 | struct hda_codec *codec, | |
2014 | unsigned int stream_tag, | |
2015 | unsigned int format, | |
c8b6bf9b | 2016 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2017 | { |
2018 | struct alc_spec *spec = codec->spec; | |
2019 | ||
2020 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], | |
2021 | stream_tag, 0, format); | |
2022 | return 0; | |
2023 | } | |
2024 | ||
2025 | static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, | |
2026 | struct hda_codec *codec, | |
c8b6bf9b | 2027 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2028 | { |
2029 | struct alc_spec *spec = codec->spec; | |
2030 | ||
9c7f852e TI |
2031 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], |
2032 | 0, 0, 0); | |
1da177e4 LT |
2033 | return 0; |
2034 | } | |
2035 | ||
2036 | ||
2037 | /* | |
2038 | */ | |
2039 | static struct hda_pcm_stream alc880_pcm_analog_playback = { | |
2040 | .substreams = 1, | |
2041 | .channels_min = 2, | |
2042 | .channels_max = 8, | |
e9edcee0 | 2043 | /* NID is set in alc_build_pcms */ |
1da177e4 LT |
2044 | .ops = { |
2045 | .open = alc880_playback_pcm_open, | |
2046 | .prepare = alc880_playback_pcm_prepare, | |
2047 | .cleanup = alc880_playback_pcm_cleanup | |
2048 | }, | |
2049 | }; | |
2050 | ||
2051 | static struct hda_pcm_stream alc880_pcm_analog_capture = { | |
2052 | .substreams = 2, | |
2053 | .channels_min = 2, | |
2054 | .channels_max = 2, | |
e9edcee0 | 2055 | /* NID is set in alc_build_pcms */ |
1da177e4 LT |
2056 | .ops = { |
2057 | .prepare = alc880_capture_pcm_prepare, | |
2058 | .cleanup = alc880_capture_pcm_cleanup | |
2059 | }, | |
2060 | }; | |
2061 | ||
2062 | static struct hda_pcm_stream alc880_pcm_digital_playback = { | |
2063 | .substreams = 1, | |
2064 | .channels_min = 2, | |
2065 | .channels_max = 2, | |
2066 | /* NID is set in alc_build_pcms */ | |
2067 | .ops = { | |
2068 | .open = alc880_dig_playback_pcm_open, | |
6b97eb45 TI |
2069 | .close = alc880_dig_playback_pcm_close, |
2070 | .prepare = alc880_dig_playback_pcm_prepare | |
1da177e4 LT |
2071 | }, |
2072 | }; | |
2073 | ||
2074 | static struct hda_pcm_stream alc880_pcm_digital_capture = { | |
2075 | .substreams = 1, | |
2076 | .channels_min = 2, | |
2077 | .channels_max = 2, | |
2078 | /* NID is set in alc_build_pcms */ | |
2079 | }; | |
2080 | ||
4c5186ed JW |
2081 | /* Used by alc_build_pcms to flag that a PCM has no playback stream */ |
2082 | static struct hda_pcm_stream alc_pcm_null_playback = { | |
2083 | .substreams = 0, | |
2084 | .channels_min = 0, | |
2085 | .channels_max = 0, | |
2086 | }; | |
2087 | ||
1da177e4 LT |
2088 | static int alc_build_pcms(struct hda_codec *codec) |
2089 | { | |
2090 | struct alc_spec *spec = codec->spec; | |
2091 | struct hda_pcm *info = spec->pcm_rec; | |
2092 | int i; | |
2093 | ||
2094 | codec->num_pcms = 1; | |
2095 | codec->pcm_info = info; | |
2096 | ||
2097 | info->name = spec->stream_name_analog; | |
4a471b7d TI |
2098 | if (spec->stream_analog_playback) { |
2099 | snd_assert(spec->multiout.dac_nids, return -EINVAL); | |
2100 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback); | |
2101 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; | |
2102 | } | |
2103 | if (spec->stream_analog_capture) { | |
2104 | snd_assert(spec->adc_nids, return -EINVAL); | |
2105 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); | |
2106 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; | |
2107 | } | |
2108 | ||
2109 | if (spec->channel_mode) { | |
2110 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; | |
2111 | for (i = 0; i < spec->num_channel_mode; i++) { | |
2112 | if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { | |
2113 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; | |
2114 | } | |
1da177e4 LT |
2115 | } |
2116 | } | |
2117 | ||
e08a007d | 2118 | /* SPDIF for stream index #1 */ |
1da177e4 | 2119 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
e08a007d | 2120 | codec->num_pcms = 2; |
c06134d7 | 2121 | info = spec->pcm_rec + 1; |
1da177e4 | 2122 | info->name = spec->stream_name_digital; |
4a471b7d TI |
2123 | if (spec->multiout.dig_out_nid && |
2124 | spec->stream_digital_playback) { | |
1da177e4 LT |
2125 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback); |
2126 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; | |
2127 | } | |
4a471b7d TI |
2128 | if (spec->dig_in_nid && |
2129 | spec->stream_digital_capture) { | |
1da177e4 LT |
2130 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture); |
2131 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; | |
2132 | } | |
2133 | } | |
2134 | ||
e08a007d TI |
2135 | /* If the use of more than one ADC is requested for the current |
2136 | * model, configure a second analog capture-only PCM. | |
2137 | */ | |
2138 | /* Additional Analaog capture for index #2 */ | |
2139 | if (spec->num_adc_nids > 1 && spec->stream_analog_capture && | |
2140 | spec->adc_nids) { | |
2141 | codec->num_pcms = 3; | |
c06134d7 | 2142 | info = spec->pcm_rec + 2; |
e08a007d TI |
2143 | info->name = spec->stream_name_analog; |
2144 | /* No playback stream for second PCM */ | |
2145 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback; | |
2146 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; | |
2147 | if (spec->stream_analog_capture) { | |
2148 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); | |
2149 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1]; | |
2150 | } | |
2151 | } | |
2152 | ||
1da177e4 LT |
2153 | return 0; |
2154 | } | |
2155 | ||
2156 | static void alc_free(struct hda_codec *codec) | |
2157 | { | |
e9edcee0 TI |
2158 | struct alc_spec *spec = codec->spec; |
2159 | unsigned int i; | |
2160 | ||
f12ab1e0 | 2161 | if (!spec) |
e9edcee0 TI |
2162 | return; |
2163 | ||
2164 | if (spec->kctl_alloc) { | |
2165 | for (i = 0; i < spec->num_kctl_used; i++) | |
2166 | kfree(spec->kctl_alloc[i].name); | |
2167 | kfree(spec->kctl_alloc); | |
2168 | } | |
2169 | kfree(spec); | |
1da177e4 LT |
2170 | } |
2171 | ||
2172 | /* | |
2173 | */ | |
2174 | static struct hda_codec_ops alc_patch_ops = { | |
2175 | .build_controls = alc_build_controls, | |
2176 | .build_pcms = alc_build_pcms, | |
2177 | .init = alc_init, | |
2178 | .free = alc_free, | |
ae6b813a | 2179 | .unsol_event = alc_unsol_event, |
1da177e4 LT |
2180 | #ifdef CONFIG_PM |
2181 | .resume = alc_resume, | |
2182 | #endif | |
2183 | }; | |
2184 | ||
2fa522be TI |
2185 | |
2186 | /* | |
2187 | * Test configuration for debugging | |
2188 | * | |
2189 | * Almost all inputs/outputs are enabled. I/O pins can be configured via | |
2190 | * enum controls. | |
2191 | */ | |
2192 | #ifdef CONFIG_SND_DEBUG | |
2193 | static hda_nid_t alc880_test_dac_nids[4] = { | |
2194 | 0x02, 0x03, 0x04, 0x05 | |
2195 | }; | |
2196 | ||
2197 | static struct hda_input_mux alc880_test_capture_source = { | |
ae6b813a | 2198 | .num_items = 7, |
2fa522be TI |
2199 | .items = { |
2200 | { "In-1", 0x0 }, | |
2201 | { "In-2", 0x1 }, | |
2202 | { "In-3", 0x2 }, | |
2203 | { "In-4", 0x3 }, | |
2204 | { "CD", 0x4 }, | |
ae6b813a TI |
2205 | { "Front", 0x5 }, |
2206 | { "Surround", 0x6 }, | |
2fa522be TI |
2207 | }, |
2208 | }; | |
2209 | ||
d2a6d7dc | 2210 | static struct hda_channel_mode alc880_test_modes[4] = { |
2fa522be | 2211 | { 2, NULL }, |
fd2c326d | 2212 | { 4, NULL }, |
2fa522be | 2213 | { 6, NULL }, |
fd2c326d | 2214 | { 8, NULL }, |
2fa522be TI |
2215 | }; |
2216 | ||
9c7f852e TI |
2217 | static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, |
2218 | struct snd_ctl_elem_info *uinfo) | |
2fa522be TI |
2219 | { |
2220 | static char *texts[] = { | |
2221 | "N/A", "Line Out", "HP Out", | |
2222 | "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%" | |
2223 | }; | |
2224 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
2225 | uinfo->count = 1; | |
2226 | uinfo->value.enumerated.items = 8; | |
2227 | if (uinfo->value.enumerated.item >= 8) | |
2228 | uinfo->value.enumerated.item = 7; | |
2229 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | |
2230 | return 0; | |
2231 | } | |
2232 | ||
9c7f852e TI |
2233 | static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, |
2234 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
2235 | { |
2236 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2237 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
2238 | unsigned int pin_ctl, item = 0; | |
2239 | ||
2240 | pin_ctl = snd_hda_codec_read(codec, nid, 0, | |
2241 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | |
2242 | if (pin_ctl & AC_PINCTL_OUT_EN) { | |
2243 | if (pin_ctl & AC_PINCTL_HP_EN) | |
2244 | item = 2; | |
2245 | else | |
2246 | item = 1; | |
2247 | } else if (pin_ctl & AC_PINCTL_IN_EN) { | |
2248 | switch (pin_ctl & AC_PINCTL_VREFEN) { | |
2249 | case AC_PINCTL_VREF_HIZ: item = 3; break; | |
2250 | case AC_PINCTL_VREF_50: item = 4; break; | |
2251 | case AC_PINCTL_VREF_GRD: item = 5; break; | |
2252 | case AC_PINCTL_VREF_80: item = 6; break; | |
2253 | case AC_PINCTL_VREF_100: item = 7; break; | |
2254 | } | |
2255 | } | |
2256 | ucontrol->value.enumerated.item[0] = item; | |
2257 | return 0; | |
2258 | } | |
2259 | ||
9c7f852e TI |
2260 | static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, |
2261 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
2262 | { |
2263 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2264 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
2265 | static unsigned int ctls[] = { | |
2266 | 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN, | |
2267 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ, | |
2268 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_50, | |
2269 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD, | |
2270 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_80, | |
2271 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_100, | |
2272 | }; | |
2273 | unsigned int old_ctl, new_ctl; | |
2274 | ||
2275 | old_ctl = snd_hda_codec_read(codec, nid, 0, | |
2276 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | |
2277 | new_ctl = ctls[ucontrol->value.enumerated.item[0]]; | |
2278 | if (old_ctl != new_ctl) { | |
9c7f852e TI |
2279 | snd_hda_codec_write(codec, nid, 0, |
2280 | AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl); | |
2fa522be | 2281 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
9c7f852e TI |
2282 | (ucontrol->value.enumerated.item[0] >= 3 ? |
2283 | 0xb080 : 0xb000)); | |
2fa522be TI |
2284 | return 1; |
2285 | } | |
2286 | return 0; | |
2287 | } | |
2288 | ||
9c7f852e TI |
2289 | static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, |
2290 | struct snd_ctl_elem_info *uinfo) | |
2fa522be TI |
2291 | { |
2292 | static char *texts[] = { | |
2293 | "Front", "Surround", "CLFE", "Side" | |
2294 | }; | |
2295 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
2296 | uinfo->count = 1; | |
2297 | uinfo->value.enumerated.items = 4; | |
2298 | if (uinfo->value.enumerated.item >= 4) | |
2299 | uinfo->value.enumerated.item = 3; | |
2300 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | |
2301 | return 0; | |
2302 | } | |
2303 | ||
9c7f852e TI |
2304 | static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, |
2305 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
2306 | { |
2307 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2308 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
2309 | unsigned int sel; | |
2310 | ||
2311 | sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0); | |
2312 | ucontrol->value.enumerated.item[0] = sel & 3; | |
2313 | return 0; | |
2314 | } | |
2315 | ||
9c7f852e TI |
2316 | static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, |
2317 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
2318 | { |
2319 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2320 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
2321 | unsigned int sel; | |
2322 | ||
2323 | sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3; | |
2324 | if (ucontrol->value.enumerated.item[0] != sel) { | |
2325 | sel = ucontrol->value.enumerated.item[0] & 3; | |
2326 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel); | |
2327 | return 1; | |
2328 | } | |
2329 | return 0; | |
2330 | } | |
2331 | ||
2332 | #define PIN_CTL_TEST(xname,nid) { \ | |
2333 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
2334 | .name = xname, \ | |
2335 | .info = alc_test_pin_ctl_info, \ | |
2336 | .get = alc_test_pin_ctl_get, \ | |
2337 | .put = alc_test_pin_ctl_put, \ | |
2338 | .private_value = nid \ | |
2339 | } | |
2340 | ||
2341 | #define PIN_SRC_TEST(xname,nid) { \ | |
2342 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
2343 | .name = xname, \ | |
2344 | .info = alc_test_pin_src_info, \ | |
2345 | .get = alc_test_pin_src_get, \ | |
2346 | .put = alc_test_pin_src_put, \ | |
2347 | .private_value = nid \ | |
2348 | } | |
2349 | ||
c8b6bf9b | 2350 | static struct snd_kcontrol_new alc880_test_mixer[] = { |
05acb863 TI |
2351 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
2352 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
2353 | HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT), | |
2354 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
985be54b TI |
2355 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
2356 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
2357 | HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT), | |
2358 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
2fa522be TI |
2359 | PIN_CTL_TEST("Front Pin Mode", 0x14), |
2360 | PIN_CTL_TEST("Surround Pin Mode", 0x15), | |
2361 | PIN_CTL_TEST("CLFE Pin Mode", 0x16), | |
2362 | PIN_CTL_TEST("Side Pin Mode", 0x17), | |
2363 | PIN_CTL_TEST("In-1 Pin Mode", 0x18), | |
2364 | PIN_CTL_TEST("In-2 Pin Mode", 0x19), | |
2365 | PIN_CTL_TEST("In-3 Pin Mode", 0x1a), | |
2366 | PIN_CTL_TEST("In-4 Pin Mode", 0x1b), | |
2367 | PIN_SRC_TEST("In-1 Pin Source", 0x18), | |
2368 | PIN_SRC_TEST("In-2 Pin Source", 0x19), | |
2369 | PIN_SRC_TEST("In-3 Pin Source", 0x1a), | |
2370 | PIN_SRC_TEST("In-4 Pin Source", 0x1b), | |
2371 | HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
2372 | HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2373 | HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
2374 | HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
2375 | HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT), | |
2376 | HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT), | |
2377 | HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT), | |
2378 | HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT), | |
2379 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT), | |
2380 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT), | |
2fa522be TI |
2381 | { |
2382 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2383 | .name = "Channel Mode", | |
df694daa KY |
2384 | .info = alc_ch_mode_info, |
2385 | .get = alc_ch_mode_get, | |
2386 | .put = alc_ch_mode_put, | |
2fa522be TI |
2387 | }, |
2388 | { } /* end */ | |
2389 | }; | |
2390 | ||
2391 | static struct hda_verb alc880_test_init_verbs[] = { | |
2392 | /* Unmute inputs of 0x0c - 0x0f */ | |
05acb863 TI |
2393 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
2394 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2395 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2396 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2397 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2398 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2399 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2400 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2fa522be | 2401 | /* Vol output for 0x0c-0x0f */ |
05acb863 TI |
2402 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
2403 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2404 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2405 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2fa522be | 2406 | /* Set output pins 0x14-0x17 */ |
05acb863 TI |
2407 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
2408 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2409 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2410 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2fa522be | 2411 | /* Unmute output pins 0x14-0x17 */ |
05acb863 TI |
2412 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
2413 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2414 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2415 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2fa522be | 2416 | /* Set input pins 0x18-0x1c */ |
16ded525 TI |
2417 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
2418 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
05acb863 TI |
2419 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
2420 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2421 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2fa522be | 2422 | /* Mute input pins 0x18-0x1b */ |
05acb863 TI |
2423 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
2424 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2425 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2426 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
71fe7b82 | 2427 | /* ADC set up */ |
05acb863 | 2428 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 2429 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 | 2430 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 2431 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 | 2432 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 2433 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
2434 | /* Analog input/passthru */ |
2435 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
2436 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2437 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
2438 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
2439 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
2fa522be TI |
2440 | { } |
2441 | }; | |
2442 | #endif | |
2443 | ||
1da177e4 LT |
2444 | /* |
2445 | */ | |
2446 | ||
f5fcc13c TI |
2447 | static const char *alc880_models[ALC880_MODEL_LAST] = { |
2448 | [ALC880_3ST] = "3stack", | |
2449 | [ALC880_TCL_S700] = "tcl", | |
2450 | [ALC880_3ST_DIG] = "3stack-digout", | |
2451 | [ALC880_CLEVO] = "clevo", | |
2452 | [ALC880_5ST] = "5stack", | |
2453 | [ALC880_5ST_DIG] = "5stack-digout", | |
2454 | [ALC880_W810] = "w810", | |
2455 | [ALC880_Z71V] = "z71v", | |
2456 | [ALC880_6ST] = "6stack", | |
2457 | [ALC880_6ST_DIG] = "6stack-digout", | |
2458 | [ALC880_ASUS] = "asus", | |
2459 | [ALC880_ASUS_W1V] = "asus-w1v", | |
2460 | [ALC880_ASUS_DIG] = "asus-dig", | |
2461 | [ALC880_ASUS_DIG2] = "asus-dig2", | |
2462 | [ALC880_UNIWILL_DIG] = "uniwill", | |
2cf9f0fc TD |
2463 | [ALC880_UNIWILL_P53] = "uniwill-p53", |
2464 | [ALC880_FUJITSU] = "fujitsu", | |
f5fcc13c TI |
2465 | [ALC880_F1734] = "F1734", |
2466 | [ALC880_LG] = "lg", | |
2467 | [ALC880_LG_LW] = "lg-lw", | |
2fa522be | 2468 | #ifdef CONFIG_SND_DEBUG |
f5fcc13c | 2469 | [ALC880_TEST] = "test", |
2fa522be | 2470 | #endif |
f5fcc13c TI |
2471 | [ALC880_AUTO] = "auto", |
2472 | }; | |
2473 | ||
2474 | static struct snd_pci_quirk alc880_cfg_tbl[] = { | |
2475 | /* Broken BIOS configuration */ | |
2476 | SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), | |
2477 | SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG), | |
2478 | ||
2479 | SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG), | |
2480 | SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST), | |
4dc53e28 | 2481 | SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810), |
f5fcc13c TI |
2482 | SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG), |
2483 | SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG), | |
2484 | SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG), | |
2485 | SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG), | |
2486 | SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG), | |
2487 | SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST), | |
2488 | ||
2489 | SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG), | |
2490 | SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST), | |
2491 | ||
2492 | SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V), | |
2493 | SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG), | |
2494 | SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG), | |
2495 | SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG), | |
2496 | SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG), | |
2497 | SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG), | |
2498 | SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V), | |
2499 | /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */ | |
2500 | SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG), | |
2501 | SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG), | |
0e4ceb75 | 2502 | SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS), |
f5fcc13c TI |
2503 | SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG), |
2504 | SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST), | |
2505 | SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST), | |
2506 | SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), | |
2507 | ||
2508 | SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST), | |
2509 | SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST), | |
2510 | SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST), | |
2511 | SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST), | |
2512 | SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST), | |
2513 | SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO), | |
2514 | SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO), | |
2515 | SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG), | |
2516 | SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810), | |
2517 | SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG), | |
2518 | SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700), | |
2519 | SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG), | |
2520 | SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG), | |
2521 | SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG), | |
2522 | SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG), | |
2523 | SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG), | |
2524 | SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG), | |
2525 | SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2), | |
2526 | ||
2527 | SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG), | |
2528 | SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL), | |
2529 | SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53), | |
2530 | SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734), | |
2531 | ||
2532 | SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG), | |
2533 | SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL), | |
2534 | SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734), | |
2cf9f0fc | 2535 | SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU), |
f5fcc13c TI |
2536 | |
2537 | SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG), | |
2538 | SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG), | |
2539 | SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW), | |
2540 | SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW), | |
2541 | ||
2542 | SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG), | |
2543 | SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG), | |
2544 | SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG), | |
2545 | SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG), | |
2546 | SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG), | |
2547 | SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG), | |
2548 | SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG), | |
2549 | SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG), | |
2550 | SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG), | |
2551 | SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG), | |
2552 | SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), | |
2fa522be | 2553 | |
1da177e4 LT |
2554 | {} |
2555 | }; | |
2556 | ||
16ded525 | 2557 | /* |
df694daa | 2558 | * ALC880 codec presets |
16ded525 | 2559 | */ |
16ded525 TI |
2560 | static struct alc_config_preset alc880_presets[] = { |
2561 | [ALC880_3ST] = { | |
e9edcee0 | 2562 | .mixers = { alc880_three_stack_mixer }, |
f12ab1e0 TI |
2563 | .init_verbs = { alc880_volume_init_verbs, |
2564 | alc880_pin_3stack_init_verbs }, | |
16ded525 | 2565 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
16ded525 | 2566 | .dac_nids = alc880_dac_nids, |
16ded525 TI |
2567 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
2568 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 2569 | .need_dac_fix = 1, |
16ded525 TI |
2570 | .input_mux = &alc880_capture_source, |
2571 | }, | |
2572 | [ALC880_3ST_DIG] = { | |
e9edcee0 | 2573 | .mixers = { alc880_three_stack_mixer }, |
f12ab1e0 TI |
2574 | .init_verbs = { alc880_volume_init_verbs, |
2575 | alc880_pin_3stack_init_verbs }, | |
16ded525 | 2576 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
16ded525 TI |
2577 | .dac_nids = alc880_dac_nids, |
2578 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
2579 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
2580 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 2581 | .need_dac_fix = 1, |
16ded525 TI |
2582 | .input_mux = &alc880_capture_source, |
2583 | }, | |
df694daa KY |
2584 | [ALC880_TCL_S700] = { |
2585 | .mixers = { alc880_tcl_s700_mixer }, | |
2586 | .init_verbs = { alc880_volume_init_verbs, | |
2587 | alc880_pin_tcl_S700_init_verbs, | |
2588 | alc880_gpio2_init_verbs }, | |
2589 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
2590 | .dac_nids = alc880_dac_nids, | |
2591 | .hp_nid = 0x03, | |
2592 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
2593 | .channel_mode = alc880_2_jack_modes, | |
2594 | .input_mux = &alc880_capture_source, | |
2595 | }, | |
16ded525 | 2596 | [ALC880_5ST] = { |
f12ab1e0 TI |
2597 | .mixers = { alc880_three_stack_mixer, |
2598 | alc880_five_stack_mixer}, | |
2599 | .init_verbs = { alc880_volume_init_verbs, | |
2600 | alc880_pin_5stack_init_verbs }, | |
16ded525 TI |
2601 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
2602 | .dac_nids = alc880_dac_nids, | |
16ded525 TI |
2603 | .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), |
2604 | .channel_mode = alc880_fivestack_modes, | |
2605 | .input_mux = &alc880_capture_source, | |
2606 | }, | |
2607 | [ALC880_5ST_DIG] = { | |
f12ab1e0 TI |
2608 | .mixers = { alc880_three_stack_mixer, |
2609 | alc880_five_stack_mixer }, | |
2610 | .init_verbs = { alc880_volume_init_verbs, | |
2611 | alc880_pin_5stack_init_verbs }, | |
16ded525 TI |
2612 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
2613 | .dac_nids = alc880_dac_nids, | |
2614 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
2615 | .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), |
2616 | .channel_mode = alc880_fivestack_modes, | |
2617 | .input_mux = &alc880_capture_source, | |
2618 | }, | |
b6482d48 TI |
2619 | [ALC880_6ST] = { |
2620 | .mixers = { alc880_six_stack_mixer }, | |
f12ab1e0 TI |
2621 | .init_verbs = { alc880_volume_init_verbs, |
2622 | alc880_pin_6stack_init_verbs }, | |
b6482d48 TI |
2623 | .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), |
2624 | .dac_nids = alc880_6st_dac_nids, | |
2625 | .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), | |
2626 | .channel_mode = alc880_sixstack_modes, | |
2627 | .input_mux = &alc880_6stack_capture_source, | |
2628 | }, | |
16ded525 | 2629 | [ALC880_6ST_DIG] = { |
e9edcee0 | 2630 | .mixers = { alc880_six_stack_mixer }, |
f12ab1e0 TI |
2631 | .init_verbs = { alc880_volume_init_verbs, |
2632 | alc880_pin_6stack_init_verbs }, | |
16ded525 TI |
2633 | .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), |
2634 | .dac_nids = alc880_6st_dac_nids, | |
2635 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
2636 | .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), |
2637 | .channel_mode = alc880_sixstack_modes, | |
2638 | .input_mux = &alc880_6stack_capture_source, | |
2639 | }, | |
2640 | [ALC880_W810] = { | |
e9edcee0 | 2641 | .mixers = { alc880_w810_base_mixer }, |
f12ab1e0 TI |
2642 | .init_verbs = { alc880_volume_init_verbs, |
2643 | alc880_pin_w810_init_verbs, | |
b0af0de5 | 2644 | alc880_gpio2_init_verbs }, |
16ded525 TI |
2645 | .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids), |
2646 | .dac_nids = alc880_w810_dac_nids, | |
2647 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
2648 | .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), |
2649 | .channel_mode = alc880_w810_modes, | |
2650 | .input_mux = &alc880_capture_source, | |
2651 | }, | |
2652 | [ALC880_Z71V] = { | |
e9edcee0 | 2653 | .mixers = { alc880_z71v_mixer }, |
f12ab1e0 TI |
2654 | .init_verbs = { alc880_volume_init_verbs, |
2655 | alc880_pin_z71v_init_verbs }, | |
16ded525 TI |
2656 | .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids), |
2657 | .dac_nids = alc880_z71v_dac_nids, | |
2658 | .dig_out_nid = ALC880_DIGOUT_NID, | |
2659 | .hp_nid = 0x03, | |
e9edcee0 TI |
2660 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), |
2661 | .channel_mode = alc880_2_jack_modes, | |
16ded525 TI |
2662 | .input_mux = &alc880_capture_source, |
2663 | }, | |
2664 | [ALC880_F1734] = { | |
e9edcee0 | 2665 | .mixers = { alc880_f1734_mixer }, |
f12ab1e0 TI |
2666 | .init_verbs = { alc880_volume_init_verbs, |
2667 | alc880_pin_f1734_init_verbs }, | |
e9edcee0 TI |
2668 | .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids), |
2669 | .dac_nids = alc880_f1734_dac_nids, | |
2670 | .hp_nid = 0x02, | |
2671 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
2672 | .channel_mode = alc880_2_jack_modes, | |
16ded525 TI |
2673 | .input_mux = &alc880_capture_source, |
2674 | }, | |
2675 | [ALC880_ASUS] = { | |
e9edcee0 | 2676 | .mixers = { alc880_asus_mixer }, |
f12ab1e0 TI |
2677 | .init_verbs = { alc880_volume_init_verbs, |
2678 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
2679 | alc880_gpio1_init_verbs }, |
2680 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
2681 | .dac_nids = alc880_asus_dac_nids, | |
2682 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), | |
2683 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 2684 | .need_dac_fix = 1, |
16ded525 TI |
2685 | .input_mux = &alc880_capture_source, |
2686 | }, | |
2687 | [ALC880_ASUS_DIG] = { | |
e9edcee0 | 2688 | .mixers = { alc880_asus_mixer }, |
f12ab1e0 TI |
2689 | .init_verbs = { alc880_volume_init_verbs, |
2690 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
2691 | alc880_gpio1_init_verbs }, |
2692 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
2693 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 2694 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
2695 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
2696 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 2697 | .need_dac_fix = 1, |
16ded525 TI |
2698 | .input_mux = &alc880_capture_source, |
2699 | }, | |
df694daa KY |
2700 | [ALC880_ASUS_DIG2] = { |
2701 | .mixers = { alc880_asus_mixer }, | |
f12ab1e0 TI |
2702 | .init_verbs = { alc880_volume_init_verbs, |
2703 | alc880_pin_asus_init_verbs, | |
df694daa KY |
2704 | alc880_gpio2_init_verbs }, /* use GPIO2 */ |
2705 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
2706 | .dac_nids = alc880_asus_dac_nids, | |
2707 | .dig_out_nid = ALC880_DIGOUT_NID, | |
2708 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), | |
2709 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 2710 | .need_dac_fix = 1, |
df694daa KY |
2711 | .input_mux = &alc880_capture_source, |
2712 | }, | |
16ded525 | 2713 | [ALC880_ASUS_W1V] = { |
e9edcee0 | 2714 | .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer }, |
f12ab1e0 TI |
2715 | .init_verbs = { alc880_volume_init_verbs, |
2716 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
2717 | alc880_gpio1_init_verbs }, |
2718 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
2719 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 2720 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
2721 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
2722 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 2723 | .need_dac_fix = 1, |
16ded525 TI |
2724 | .input_mux = &alc880_capture_source, |
2725 | }, | |
2726 | [ALC880_UNIWILL_DIG] = { | |
3c10a9d9 | 2727 | .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer }, |
ccc656ce KY |
2728 | .init_verbs = { alc880_volume_init_verbs, |
2729 | alc880_pin_asus_init_verbs }, | |
e9edcee0 TI |
2730 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), |
2731 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 2732 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
2733 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
2734 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 2735 | .need_dac_fix = 1, |
16ded525 TI |
2736 | .input_mux = &alc880_capture_source, |
2737 | }, | |
ccc656ce KY |
2738 | [ALC880_UNIWILL] = { |
2739 | .mixers = { alc880_uniwill_mixer }, | |
2740 | .init_verbs = { alc880_volume_init_verbs, | |
2741 | alc880_uniwill_init_verbs }, | |
2742 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
2743 | .dac_nids = alc880_asus_dac_nids, | |
2744 | .dig_out_nid = ALC880_DIGOUT_NID, | |
2745 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
2746 | .channel_mode = alc880_threestack_modes, | |
2747 | .need_dac_fix = 1, | |
2748 | .input_mux = &alc880_capture_source, | |
2749 | .unsol_event = alc880_uniwill_unsol_event, | |
2750 | .init_hook = alc880_uniwill_automute, | |
2751 | }, | |
2752 | [ALC880_UNIWILL_P53] = { | |
2753 | .mixers = { alc880_uniwill_p53_mixer }, | |
2754 | .init_verbs = { alc880_volume_init_verbs, | |
2755 | alc880_uniwill_p53_init_verbs }, | |
2756 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
2757 | .dac_nids = alc880_asus_dac_nids, | |
2758 | .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), | |
2cf9f0fc TD |
2759 | .channel_mode = alc880_threestack_modes, |
2760 | .input_mux = &alc880_capture_source, | |
2761 | .unsol_event = alc880_uniwill_p53_unsol_event, | |
2762 | .init_hook = alc880_uniwill_p53_hp_automute, | |
2763 | }, | |
2764 | [ALC880_FUJITSU] = { | |
f12ab1e0 | 2765 | .mixers = { alc880_fujitsu_mixer, |
2cf9f0fc TD |
2766 | alc880_pcbeep_mixer, }, |
2767 | .init_verbs = { alc880_volume_init_verbs, | |
2768 | alc880_uniwill_p53_init_verbs, | |
2769 | alc880_beep_init_verbs }, | |
2770 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
2771 | .dac_nids = alc880_dac_nids, | |
2772 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
2773 | .channel_mode = alc880_2_jack_modes, | |
ccc656ce KY |
2774 | .input_mux = &alc880_capture_source, |
2775 | .unsol_event = alc880_uniwill_p53_unsol_event, | |
2776 | .init_hook = alc880_uniwill_p53_hp_automute, | |
2777 | }, | |
df694daa KY |
2778 | [ALC880_CLEVO] = { |
2779 | .mixers = { alc880_three_stack_mixer }, | |
2780 | .init_verbs = { alc880_volume_init_verbs, | |
2781 | alc880_pin_clevo_init_verbs }, | |
2782 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
2783 | .dac_nids = alc880_dac_nids, | |
2784 | .hp_nid = 0x03, | |
2785 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
2786 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 2787 | .need_dac_fix = 1, |
df694daa KY |
2788 | .input_mux = &alc880_capture_source, |
2789 | }, | |
ae6b813a TI |
2790 | [ALC880_LG] = { |
2791 | .mixers = { alc880_lg_mixer }, | |
2792 | .init_verbs = { alc880_volume_init_verbs, | |
2793 | alc880_lg_init_verbs }, | |
2794 | .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids), | |
2795 | .dac_nids = alc880_lg_dac_nids, | |
2796 | .dig_out_nid = ALC880_DIGOUT_NID, | |
2797 | .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes), | |
2798 | .channel_mode = alc880_lg_ch_modes, | |
4e195a7b | 2799 | .need_dac_fix = 1, |
ae6b813a TI |
2800 | .input_mux = &alc880_lg_capture_source, |
2801 | .unsol_event = alc880_lg_unsol_event, | |
2802 | .init_hook = alc880_lg_automute, | |
2803 | }, | |
d681518a TI |
2804 | [ALC880_LG_LW] = { |
2805 | .mixers = { alc880_lg_lw_mixer }, | |
2806 | .init_verbs = { alc880_volume_init_verbs, | |
2807 | alc880_lg_lw_init_verbs }, | |
f12ab1e0 | 2808 | .num_dacs = 1, |
d681518a TI |
2809 | .dac_nids = alc880_dac_nids, |
2810 | .dig_out_nid = ALC880_DIGOUT_NID, | |
2811 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
2812 | .channel_mode = alc880_2_jack_modes, | |
2813 | .input_mux = &alc880_lg_lw_capture_source, | |
2814 | .unsol_event = alc880_lg_lw_unsol_event, | |
2815 | .init_hook = alc880_lg_lw_automute, | |
2816 | }, | |
16ded525 TI |
2817 | #ifdef CONFIG_SND_DEBUG |
2818 | [ALC880_TEST] = { | |
e9edcee0 TI |
2819 | .mixers = { alc880_test_mixer }, |
2820 | .init_verbs = { alc880_test_init_verbs }, | |
16ded525 TI |
2821 | .num_dacs = ARRAY_SIZE(alc880_test_dac_nids), |
2822 | .dac_nids = alc880_test_dac_nids, | |
2823 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
2824 | .num_channel_mode = ARRAY_SIZE(alc880_test_modes), |
2825 | .channel_mode = alc880_test_modes, | |
2826 | .input_mux = &alc880_test_capture_source, | |
2827 | }, | |
2828 | #endif | |
2829 | }; | |
2830 | ||
e9edcee0 TI |
2831 | /* |
2832 | * Automatic parse of I/O pins from the BIOS configuration | |
2833 | */ | |
2834 | ||
2835 | #define NUM_CONTROL_ALLOC 32 | |
2836 | #define NUM_VERB_ALLOC 32 | |
2837 | ||
2838 | enum { | |
2839 | ALC_CTL_WIDGET_VOL, | |
2840 | ALC_CTL_WIDGET_MUTE, | |
2841 | ALC_CTL_BIND_MUTE, | |
2842 | }; | |
c8b6bf9b | 2843 | static struct snd_kcontrol_new alc880_control_templates[] = { |
e9edcee0 TI |
2844 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
2845 | HDA_CODEC_MUTE(NULL, 0, 0, 0), | |
985be54b | 2846 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
e9edcee0 TI |
2847 | }; |
2848 | ||
2849 | /* add dynamic controls */ | |
f12ab1e0 TI |
2850 | static int add_control(struct alc_spec *spec, int type, const char *name, |
2851 | unsigned long val) | |
e9edcee0 | 2852 | { |
c8b6bf9b | 2853 | struct snd_kcontrol_new *knew; |
e9edcee0 TI |
2854 | |
2855 | if (spec->num_kctl_used >= spec->num_kctl_alloc) { | |
2856 | int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; | |
2857 | ||
f12ab1e0 TI |
2858 | /* array + terminator */ |
2859 | knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); | |
2860 | if (!knew) | |
e9edcee0 TI |
2861 | return -ENOMEM; |
2862 | if (spec->kctl_alloc) { | |
f12ab1e0 TI |
2863 | memcpy(knew, spec->kctl_alloc, |
2864 | sizeof(*knew) * spec->num_kctl_alloc); | |
e9edcee0 TI |
2865 | kfree(spec->kctl_alloc); |
2866 | } | |
2867 | spec->kctl_alloc = knew; | |
2868 | spec->num_kctl_alloc = num; | |
2869 | } | |
2870 | ||
2871 | knew = &spec->kctl_alloc[spec->num_kctl_used]; | |
2872 | *knew = alc880_control_templates[type]; | |
543537bd | 2873 | knew->name = kstrdup(name, GFP_KERNEL); |
f12ab1e0 | 2874 | if (!knew->name) |
e9edcee0 TI |
2875 | return -ENOMEM; |
2876 | knew->private_value = val; | |
2877 | spec->num_kctl_used++; | |
2878 | return 0; | |
2879 | } | |
2880 | ||
2881 | #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17) | |
2882 | #define alc880_fixed_pin_idx(nid) ((nid) - 0x14) | |
2883 | #define alc880_is_multi_pin(nid) ((nid) >= 0x18) | |
2884 | #define alc880_multi_pin_idx(nid) ((nid) - 0x18) | |
2885 | #define alc880_is_input_pin(nid) ((nid) >= 0x18) | |
2886 | #define alc880_input_pin_idx(nid) ((nid) - 0x18) | |
2887 | #define alc880_idx_to_dac(nid) ((nid) + 0x02) | |
2888 | #define alc880_dac_to_idx(nid) ((nid) - 0x02) | |
2889 | #define alc880_idx_to_mixer(nid) ((nid) + 0x0c) | |
2890 | #define alc880_idx_to_selector(nid) ((nid) + 0x10) | |
2891 | #define ALC880_PIN_CD_NID 0x1c | |
2892 | ||
2893 | /* fill in the dac_nids table from the parsed pin configuration */ | |
f12ab1e0 TI |
2894 | static int alc880_auto_fill_dac_nids(struct alc_spec *spec, |
2895 | const struct auto_pin_cfg *cfg) | |
e9edcee0 TI |
2896 | { |
2897 | hda_nid_t nid; | |
2898 | int assigned[4]; | |
2899 | int i, j; | |
2900 | ||
2901 | memset(assigned, 0, sizeof(assigned)); | |
b0af0de5 | 2902 | spec->multiout.dac_nids = spec->private_dac_nids; |
e9edcee0 TI |
2903 | |
2904 | /* check the pins hardwired to audio widget */ | |
2905 | for (i = 0; i < cfg->line_outs; i++) { | |
2906 | nid = cfg->line_out_pins[i]; | |
2907 | if (alc880_is_fixed_pin(nid)) { | |
2908 | int idx = alc880_fixed_pin_idx(nid); | |
5014f193 | 2909 | spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx); |
e9edcee0 TI |
2910 | assigned[idx] = 1; |
2911 | } | |
2912 | } | |
2913 | /* left pins can be connect to any audio widget */ | |
2914 | for (i = 0; i < cfg->line_outs; i++) { | |
2915 | nid = cfg->line_out_pins[i]; | |
2916 | if (alc880_is_fixed_pin(nid)) | |
2917 | continue; | |
2918 | /* search for an empty channel */ | |
2919 | for (j = 0; j < cfg->line_outs; j++) { | |
f12ab1e0 TI |
2920 | if (!assigned[j]) { |
2921 | spec->multiout.dac_nids[i] = | |
2922 | alc880_idx_to_dac(j); | |
e9edcee0 TI |
2923 | assigned[j] = 1; |
2924 | break; | |
2925 | } | |
2926 | } | |
2927 | } | |
2928 | spec->multiout.num_dacs = cfg->line_outs; | |
2929 | return 0; | |
2930 | } | |
2931 | ||
2932 | /* add playback controls from the parsed DAC table */ | |
df694daa KY |
2933 | static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, |
2934 | const struct auto_pin_cfg *cfg) | |
e9edcee0 TI |
2935 | { |
2936 | char name[32]; | |
f12ab1e0 TI |
2937 | static const char *chname[4] = { |
2938 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
2939 | }; | |
e9edcee0 TI |
2940 | hda_nid_t nid; |
2941 | int i, err; | |
2942 | ||
2943 | for (i = 0; i < cfg->line_outs; i++) { | |
f12ab1e0 | 2944 | if (!spec->multiout.dac_nids[i]) |
e9edcee0 TI |
2945 | continue; |
2946 | nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i])); | |
2947 | if (i == 2) { | |
2948 | /* Center/LFE */ | |
f12ab1e0 TI |
2949 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
2950 | "Center Playback Volume", | |
2951 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, | |
2952 | HDA_OUTPUT)); | |
2953 | if (err < 0) | |
e9edcee0 | 2954 | return err; |
f12ab1e0 TI |
2955 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
2956 | "LFE Playback Volume", | |
2957 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
2958 | HDA_OUTPUT)); | |
2959 | if (err < 0) | |
e9edcee0 | 2960 | return err; |
f12ab1e0 TI |
2961 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
2962 | "Center Playback Switch", | |
2963 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, | |
2964 | HDA_INPUT)); | |
2965 | if (err < 0) | |
e9edcee0 | 2966 | return err; |
f12ab1e0 TI |
2967 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
2968 | "LFE Playback Switch", | |
2969 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, | |
2970 | HDA_INPUT)); | |
2971 | if (err < 0) | |
e9edcee0 TI |
2972 | return err; |
2973 | } else { | |
2974 | sprintf(name, "%s Playback Volume", chname[i]); | |
f12ab1e0 TI |
2975 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
2976 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
2977 | HDA_OUTPUT)); | |
2978 | if (err < 0) | |
e9edcee0 TI |
2979 | return err; |
2980 | sprintf(name, "%s Playback Switch", chname[i]); | |
f12ab1e0 TI |
2981 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
2982 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, | |
2983 | HDA_INPUT)); | |
2984 | if (err < 0) | |
e9edcee0 TI |
2985 | return err; |
2986 | } | |
2987 | } | |
e9edcee0 TI |
2988 | return 0; |
2989 | } | |
2990 | ||
8d88bc3d TI |
2991 | /* add playback controls for speaker and HP outputs */ |
2992 | static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, | |
2993 | const char *pfx) | |
e9edcee0 TI |
2994 | { |
2995 | hda_nid_t nid; | |
2996 | int err; | |
8d88bc3d | 2997 | char name[32]; |
e9edcee0 | 2998 | |
f12ab1e0 | 2999 | if (!pin) |
e9edcee0 TI |
3000 | return 0; |
3001 | ||
3002 | if (alc880_is_fixed_pin(pin)) { | |
3003 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
82bc955f | 3004 | /* specify the DAC as the extra output */ |
f12ab1e0 | 3005 | if (!spec->multiout.hp_nid) |
e9edcee0 | 3006 | spec->multiout.hp_nid = nid; |
82bc955f TI |
3007 | else |
3008 | spec->multiout.extra_out_nid[0] = nid; | |
e9edcee0 TI |
3009 | /* control HP volume/switch on the output mixer amp */ |
3010 | nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin)); | |
8d88bc3d | 3011 | sprintf(name, "%s Playback Volume", pfx); |
f12ab1e0 TI |
3012 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
3013 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
3014 | if (err < 0) | |
e9edcee0 | 3015 | return err; |
8d88bc3d | 3016 | sprintf(name, "%s Playback Switch", pfx); |
f12ab1e0 TI |
3017 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
3018 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); | |
3019 | if (err < 0) | |
e9edcee0 TI |
3020 | return err; |
3021 | } else if (alc880_is_multi_pin(pin)) { | |
3022 | /* set manual connection */ | |
e9edcee0 | 3023 | /* we have only a switch on HP-out PIN */ |
8d88bc3d | 3024 | sprintf(name, "%s Playback Switch", pfx); |
f12ab1e0 TI |
3025 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
3026 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
3027 | if (err < 0) | |
e9edcee0 TI |
3028 | return err; |
3029 | } | |
3030 | return 0; | |
3031 | } | |
3032 | ||
3033 | /* create input playback/capture controls for the given pin */ | |
f12ab1e0 TI |
3034 | static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, |
3035 | const char *ctlname, | |
df694daa | 3036 | int idx, hda_nid_t mix_nid) |
e9edcee0 TI |
3037 | { |
3038 | char name[32]; | |
df694daa | 3039 | int err; |
e9edcee0 TI |
3040 | |
3041 | sprintf(name, "%s Playback Volume", ctlname); | |
f12ab1e0 TI |
3042 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
3043 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); | |
3044 | if (err < 0) | |
e9edcee0 TI |
3045 | return err; |
3046 | sprintf(name, "%s Playback Switch", ctlname); | |
f12ab1e0 TI |
3047 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
3048 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); | |
3049 | if (err < 0) | |
e9edcee0 TI |
3050 | return err; |
3051 | return 0; | |
3052 | } | |
3053 | ||
3054 | /* create playback/capture controls for input pins */ | |
df694daa KY |
3055 | static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, |
3056 | const struct auto_pin_cfg *cfg) | |
e9edcee0 | 3057 | { |
e9edcee0 | 3058 | struct hda_input_mux *imux = &spec->private_imux; |
df694daa | 3059 | int i, err, idx; |
e9edcee0 TI |
3060 | |
3061 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
3062 | if (alc880_is_input_pin(cfg->input_pins[i])) { | |
df694daa | 3063 | idx = alc880_input_pin_idx(cfg->input_pins[i]); |
4a471b7d TI |
3064 | err = new_analog_input(spec, cfg->input_pins[i], |
3065 | auto_pin_cfg_labels[i], | |
df694daa | 3066 | idx, 0x0b); |
e9edcee0 TI |
3067 | if (err < 0) |
3068 | return err; | |
f12ab1e0 TI |
3069 | imux->items[imux->num_items].label = |
3070 | auto_pin_cfg_labels[i]; | |
3071 | imux->items[imux->num_items].index = | |
3072 | alc880_input_pin_idx(cfg->input_pins[i]); | |
e9edcee0 TI |
3073 | imux->num_items++; |
3074 | } | |
3075 | } | |
3076 | return 0; | |
3077 | } | |
3078 | ||
df694daa KY |
3079 | static void alc880_auto_set_output_and_unmute(struct hda_codec *codec, |
3080 | hda_nid_t nid, int pin_type, | |
e9edcee0 TI |
3081 | int dac_idx) |
3082 | { | |
3083 | /* set as output */ | |
f12ab1e0 TI |
3084 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
3085 | pin_type); | |
3086 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
3087 | AMP_OUT_UNMUTE); | |
e9edcee0 TI |
3088 | /* need the manual connection? */ |
3089 | if (alc880_is_multi_pin(nid)) { | |
3090 | struct alc_spec *spec = codec->spec; | |
3091 | int idx = alc880_multi_pin_idx(nid); | |
3092 | snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, | |
3093 | AC_VERB_SET_CONNECT_SEL, | |
3094 | alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); | |
3095 | } | |
3096 | } | |
3097 | ||
baba8ee9 TI |
3098 | static int get_pin_type(int line_out_type) |
3099 | { | |
3100 | if (line_out_type == AUTO_PIN_HP_OUT) | |
3101 | return PIN_HP; | |
3102 | else | |
3103 | return PIN_OUT; | |
3104 | } | |
3105 | ||
e9edcee0 TI |
3106 | static void alc880_auto_init_multi_out(struct hda_codec *codec) |
3107 | { | |
3108 | struct alc_spec *spec = codec->spec; | |
3109 | int i; | |
bc9f98a9 KY |
3110 | |
3111 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); | |
e9edcee0 TI |
3112 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
3113 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 TI |
3114 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
3115 | alc880_auto_set_output_and_unmute(codec, nid, pin_type, i); | |
e9edcee0 TI |
3116 | } |
3117 | } | |
3118 | ||
8d88bc3d | 3119 | static void alc880_auto_init_extra_out(struct hda_codec *codec) |
e9edcee0 TI |
3120 | { |
3121 | struct alc_spec *spec = codec->spec; | |
3122 | hda_nid_t pin; | |
3123 | ||
82bc955f | 3124 | pin = spec->autocfg.speaker_pins[0]; |
8d88bc3d TI |
3125 | if (pin) /* connect to front */ |
3126 | alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
eb06ed8f | 3127 | pin = spec->autocfg.hp_pins[0]; |
e9edcee0 TI |
3128 | if (pin) /* connect to front */ |
3129 | alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
3130 | } | |
3131 | ||
3132 | static void alc880_auto_init_analog_input(struct hda_codec *codec) | |
3133 | { | |
3134 | struct alc_spec *spec = codec->spec; | |
3135 | int i; | |
3136 | ||
3137 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
3138 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
3139 | if (alc880_is_input_pin(nid)) { | |
f12ab1e0 TI |
3140 | snd_hda_codec_write(codec, nid, 0, |
3141 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
3142 | i <= AUTO_PIN_FRONT_MIC ? | |
3143 | PIN_VREF80 : PIN_IN); | |
e9edcee0 | 3144 | if (nid != ALC880_PIN_CD_NID) |
f12ab1e0 TI |
3145 | snd_hda_codec_write(codec, nid, 0, |
3146 | AC_VERB_SET_AMP_GAIN_MUTE, | |
e9edcee0 TI |
3147 | AMP_OUT_MUTE); |
3148 | } | |
3149 | } | |
3150 | } | |
3151 | ||
3152 | /* parse the BIOS configuration and set up the alc_spec */ | |
f12ab1e0 TI |
3153 | /* return 1 if successful, 0 if the proper config is not found, |
3154 | * or a negative error code | |
3155 | */ | |
e9edcee0 TI |
3156 | static int alc880_parse_auto_config(struct hda_codec *codec) |
3157 | { | |
3158 | struct alc_spec *spec = codec->spec; | |
3159 | int err; | |
df694daa | 3160 | static hda_nid_t alc880_ignore[] = { 0x1d, 0 }; |
e9edcee0 | 3161 | |
f12ab1e0 TI |
3162 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
3163 | alc880_ignore); | |
3164 | if (err < 0) | |
e9edcee0 | 3165 | return err; |
f12ab1e0 | 3166 | if (!spec->autocfg.line_outs) |
e9edcee0 | 3167 | return 0; /* can't find valid BIOS pin config */ |
df694daa | 3168 | |
f12ab1e0 TI |
3169 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
3170 | if (err < 0) | |
3171 | return err; | |
3172 | err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
3173 | if (err < 0) | |
3174 | return err; | |
3175 | err = alc880_auto_create_extra_out(spec, | |
3176 | spec->autocfg.speaker_pins[0], | |
3177 | "Speaker"); | |
3178 | if (err < 0) | |
3179 | return err; | |
3180 | err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], | |
3181 | "Headphone"); | |
3182 | if (err < 0) | |
3183 | return err; | |
3184 | err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
3185 | if (err < 0) | |
e9edcee0 TI |
3186 | return err; |
3187 | ||
3188 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
3189 | ||
3190 | if (spec->autocfg.dig_out_pin) | |
3191 | spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; | |
3192 | if (spec->autocfg.dig_in_pin) | |
3193 | spec->dig_in_nid = ALC880_DIGIN_NID; | |
3194 | ||
3195 | if (spec->kctl_alloc) | |
3196 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
3197 | ||
3198 | spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs; | |
3199 | ||
a1e8d2da | 3200 | spec->num_mux_defs = 1; |
e9edcee0 TI |
3201 | spec->input_mux = &spec->private_imux; |
3202 | ||
3203 | return 1; | |
3204 | } | |
3205 | ||
ae6b813a TI |
3206 | /* additional initialization for auto-configuration model */ |
3207 | static void alc880_auto_init(struct hda_codec *codec) | |
e9edcee0 | 3208 | { |
e9edcee0 | 3209 | alc880_auto_init_multi_out(codec); |
8d88bc3d | 3210 | alc880_auto_init_extra_out(codec); |
e9edcee0 | 3211 | alc880_auto_init_analog_input(codec); |
e9edcee0 TI |
3212 | } |
3213 | ||
3214 | /* | |
3215 | * OK, here we have finally the patch for ALC880 | |
3216 | */ | |
3217 | ||
1da177e4 LT |
3218 | static int patch_alc880(struct hda_codec *codec) |
3219 | { | |
3220 | struct alc_spec *spec; | |
3221 | int board_config; | |
df694daa | 3222 | int err; |
1da177e4 | 3223 | |
e560d8d8 | 3224 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
1da177e4 LT |
3225 | if (spec == NULL) |
3226 | return -ENOMEM; | |
3227 | ||
3228 | codec->spec = spec; | |
3229 | ||
f5fcc13c TI |
3230 | board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST, |
3231 | alc880_models, | |
3232 | alc880_cfg_tbl); | |
3233 | if (board_config < 0) { | |
9c7f852e TI |
3234 | printk(KERN_INFO "hda_codec: Unknown model for ALC880, " |
3235 | "trying auto-probe from BIOS...\n"); | |
e9edcee0 | 3236 | board_config = ALC880_AUTO; |
1da177e4 | 3237 | } |
1da177e4 | 3238 | |
e9edcee0 TI |
3239 | if (board_config == ALC880_AUTO) { |
3240 | /* automatic parse from the BIOS config */ | |
3241 | err = alc880_parse_auto_config(codec); | |
3242 | if (err < 0) { | |
3243 | alc_free(codec); | |
3244 | return err; | |
f12ab1e0 | 3245 | } else if (!err) { |
9c7f852e TI |
3246 | printk(KERN_INFO |
3247 | "hda_codec: Cannot set up configuration " | |
3248 | "from BIOS. Using 3-stack mode...\n"); | |
e9edcee0 TI |
3249 | board_config = ALC880_3ST; |
3250 | } | |
1da177e4 LT |
3251 | } |
3252 | ||
df694daa KY |
3253 | if (board_config != ALC880_AUTO) |
3254 | setup_preset(spec, &alc880_presets[board_config]); | |
1da177e4 LT |
3255 | |
3256 | spec->stream_name_analog = "ALC880 Analog"; | |
3257 | spec->stream_analog_playback = &alc880_pcm_analog_playback; | |
3258 | spec->stream_analog_capture = &alc880_pcm_analog_capture; | |
3259 | ||
3260 | spec->stream_name_digital = "ALC880 Digital"; | |
3261 | spec->stream_digital_playback = &alc880_pcm_digital_playback; | |
3262 | spec->stream_digital_capture = &alc880_pcm_digital_capture; | |
3263 | ||
f12ab1e0 | 3264 | if (!spec->adc_nids && spec->input_mux) { |
e9edcee0 | 3265 | /* check whether NID 0x07 is valid */ |
54d17403 | 3266 | unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); |
f12ab1e0 TI |
3267 | /* get type */ |
3268 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
e9edcee0 TI |
3269 | if (wcap != AC_WID_AUD_IN) { |
3270 | spec->adc_nids = alc880_adc_nids_alt; | |
3271 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); | |
f12ab1e0 TI |
3272 | spec->mixers[spec->num_mixers] = |
3273 | alc880_capture_alt_mixer; | |
e9edcee0 TI |
3274 | spec->num_mixers++; |
3275 | } else { | |
3276 | spec->adc_nids = alc880_adc_nids; | |
3277 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids); | |
3278 | spec->mixers[spec->num_mixers] = alc880_capture_mixer; | |
3279 | spec->num_mixers++; | |
3280 | } | |
3281 | } | |
1da177e4 LT |
3282 | |
3283 | codec->patch_ops = alc_patch_ops; | |
e9edcee0 | 3284 | if (board_config == ALC880_AUTO) |
ae6b813a | 3285 | spec->init_hook = alc880_auto_init; |
1da177e4 LT |
3286 | |
3287 | return 0; | |
3288 | } | |
3289 | ||
e9edcee0 | 3290 | |
1da177e4 LT |
3291 | /* |
3292 | * ALC260 support | |
3293 | */ | |
3294 | ||
e9edcee0 TI |
3295 | static hda_nid_t alc260_dac_nids[1] = { |
3296 | /* front */ | |
3297 | 0x02, | |
3298 | }; | |
3299 | ||
3300 | static hda_nid_t alc260_adc_nids[1] = { | |
3301 | /* ADC0 */ | |
3302 | 0x04, | |
3303 | }; | |
3304 | ||
df694daa | 3305 | static hda_nid_t alc260_adc_nids_alt[1] = { |
e9edcee0 TI |
3306 | /* ADC1 */ |
3307 | 0x05, | |
3308 | }; | |
3309 | ||
df694daa KY |
3310 | static hda_nid_t alc260_hp_adc_nids[2] = { |
3311 | /* ADC1, 0 */ | |
3312 | 0x05, 0x04 | |
3313 | }; | |
3314 | ||
d57fdac0 JW |
3315 | /* NIDs used when simultaneous access to both ADCs makes sense. Note that |
3316 | * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC. | |
3317 | */ | |
3318 | static hda_nid_t alc260_dual_adc_nids[2] = { | |
4c5186ed JW |
3319 | /* ADC0, ADC1 */ |
3320 | 0x04, 0x05 | |
3321 | }; | |
3322 | ||
e9edcee0 TI |
3323 | #define ALC260_DIGOUT_NID 0x03 |
3324 | #define ALC260_DIGIN_NID 0x06 | |
3325 | ||
3326 | static struct hda_input_mux alc260_capture_source = { | |
3327 | .num_items = 4, | |
3328 | .items = { | |
3329 | { "Mic", 0x0 }, | |
3330 | { "Front Mic", 0x1 }, | |
3331 | { "Line", 0x2 }, | |
3332 | { "CD", 0x4 }, | |
3333 | }, | |
3334 | }; | |
3335 | ||
17e7aec6 | 3336 | /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack, |
a1e8d2da JW |
3337 | * headphone jack and the internal CD lines since these are the only pins at |
3338 | * which audio can appear. For flexibility, also allow the option of | |
3339 | * recording the mixer output on the second ADC (ADC0 doesn't have a | |
3340 | * connection to the mixer output). | |
a9430dd8 | 3341 | */ |
a1e8d2da JW |
3342 | static struct hda_input_mux alc260_fujitsu_capture_sources[2] = { |
3343 | { | |
3344 | .num_items = 3, | |
3345 | .items = { | |
3346 | { "Mic/Line", 0x0 }, | |
3347 | { "CD", 0x4 }, | |
3348 | { "Headphone", 0x2 }, | |
3349 | }, | |
a9430dd8 | 3350 | }, |
a1e8d2da JW |
3351 | { |
3352 | .num_items = 4, | |
3353 | .items = { | |
3354 | { "Mic/Line", 0x0 }, | |
3355 | { "CD", 0x4 }, | |
3356 | { "Headphone", 0x2 }, | |
3357 | { "Mixer", 0x5 }, | |
3358 | }, | |
3359 | }, | |
3360 | ||
a9430dd8 JW |
3361 | }; |
3362 | ||
a1e8d2da JW |
3363 | /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to |
3364 | * the Fujitsu S702x, but jacks are marked differently. | |
0bfc90e9 | 3365 | */ |
a1e8d2da JW |
3366 | static struct hda_input_mux alc260_acer_capture_sources[2] = { |
3367 | { | |
3368 | .num_items = 4, | |
3369 | .items = { | |
3370 | { "Mic", 0x0 }, | |
3371 | { "Line", 0x2 }, | |
3372 | { "CD", 0x4 }, | |
3373 | { "Headphone", 0x5 }, | |
3374 | }, | |
3375 | }, | |
3376 | { | |
3377 | .num_items = 5, | |
3378 | .items = { | |
3379 | { "Mic", 0x0 }, | |
3380 | { "Line", 0x2 }, | |
3381 | { "CD", 0x4 }, | |
3382 | { "Headphone", 0x6 }, | |
3383 | { "Mixer", 0x5 }, | |
3384 | }, | |
0bfc90e9 JW |
3385 | }, |
3386 | }; | |
1da177e4 LT |
3387 | /* |
3388 | * This is just place-holder, so there's something for alc_build_pcms to look | |
3389 | * at when it calculates the maximum number of channels. ALC260 has no mixer | |
3390 | * element which allows changing the channel mode, so the verb list is | |
3391 | * never used. | |
3392 | */ | |
d2a6d7dc | 3393 | static struct hda_channel_mode alc260_modes[1] = { |
1da177e4 LT |
3394 | { 2, NULL }, |
3395 | }; | |
3396 | ||
df694daa KY |
3397 | |
3398 | /* Mixer combinations | |
3399 | * | |
3400 | * basic: base_output + input + pc_beep + capture | |
3401 | * HP: base_output + input + capture_alt | |
3402 | * HP_3013: hp_3013 + input + capture | |
3403 | * fujitsu: fujitsu + capture | |
0bfc90e9 | 3404 | * acer: acer + capture |
df694daa KY |
3405 | */ |
3406 | ||
3407 | static struct snd_kcontrol_new alc260_base_output_mixer[] = { | |
05acb863 | 3408 | HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
985be54b | 3409 | HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), |
05acb863 | 3410 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
985be54b | 3411 | HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), |
05acb863 | 3412 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
985be54b | 3413 | HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), |
1da177e4 | 3414 | { } /* end */ |
f12ab1e0 | 3415 | }; |
1da177e4 | 3416 | |
df694daa | 3417 | static struct snd_kcontrol_new alc260_input_mixer[] = { |
16ded525 TI |
3418 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
3419 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
3420 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
3421 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
3422 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
3423 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
3424 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT), | |
3425 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT), | |
df694daa KY |
3426 | { } /* end */ |
3427 | }; | |
3428 | ||
3429 | static struct snd_kcontrol_new alc260_pc_beep_mixer[] = { | |
3430 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT), | |
3431 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT), | |
3432 | { } /* end */ | |
3433 | }; | |
3434 | ||
3435 | static struct snd_kcontrol_new alc260_hp_3013_mixer[] = { | |
3436 | HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT), | |
3437 | HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT), | |
3438 | HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT), | |
3439 | HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT), | |
3440 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
3441 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
3442 | HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), | |
3443 | HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT), | |
16ded525 TI |
3444 | { } /* end */ |
3445 | }; | |
3446 | ||
a1e8d2da JW |
3447 | /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12, |
3448 | * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10. | |
3449 | */ | |
c8b6bf9b | 3450 | static struct snd_kcontrol_new alc260_fujitsu_mixer[] = { |
a9430dd8 | 3451 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
985be54b | 3452 | HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT), |
4c5186ed | 3453 | ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT), |
a9430dd8 JW |
3454 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
3455 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
3456 | HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT), | |
3457 | HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4c5186ed | 3458 | ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN), |
a9430dd8 JW |
3459 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), |
3460 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
3461 | HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT), | |
985be54b | 3462 | HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT), |
df694daa KY |
3463 | { } /* end */ |
3464 | }; | |
3465 | ||
a1e8d2da JW |
3466 | /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current |
3467 | * versions of the ALC260 don't act on requests to enable mic bias from NID | |
3468 | * 0x0f (used to drive the headphone jack in these laptops). The ALC260 | |
3469 | * datasheet doesn't mention this restriction. At this stage it's not clear | |
3470 | * whether this behaviour is intentional or is a hardware bug in chip | |
3471 | * revisions available in early 2006. Therefore for now allow the | |
3472 | * "Headphone Jack Mode" control to span all choices, but if it turns out | |
3473 | * that the lack of mic bias for this NID is intentional we could change the | |
3474 | * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
3475 | * | |
3476 | * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006 | |
3477 | * don't appear to make the mic bias available from the "line" jack, even | |
3478 | * though the NID used for this jack (0x14) can supply it. The theory is | |
3479 | * that perhaps Acer have included blocking capacitors between the ALC260 | |
3480 | * and the output jack. If this turns out to be the case for all such | |
3481 | * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT | |
3482 | * to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
bd869485 JW |
3483 | * |
3484 | * The C20x Tablet series have a mono internal speaker which is controlled | |
3485 | * via the chip's Mono sum widget and pin complex, so include the necessary | |
3486 | * controls for such models. On models without a "mono speaker" the control | |
3487 | * won't do anything. | |
a1e8d2da | 3488 | */ |
0bfc90e9 JW |
3489 | static struct snd_kcontrol_new alc260_acer_mixer[] = { |
3490 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
3491 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT), | |
a1e8d2da | 3492 | ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT), |
bd869485 JW |
3493 | HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0, |
3494 | HDA_OUTPUT), | |
3495 | HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2, | |
3496 | HDA_INPUT), | |
0bfc90e9 JW |
3497 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
3498 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
3499 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
3500 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
3501 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
3502 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
3503 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
3504 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
3505 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), | |
3506 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
3507 | { } /* end */ | |
3508 | }; | |
3509 | ||
bc9f98a9 KY |
3510 | /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12, |
3511 | * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17. | |
3512 | */ | |
3513 | static struct snd_kcontrol_new alc260_will_mixer[] = { | |
3514 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
3515 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT), | |
3516 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
3517 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
3518 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
3519 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
3520 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
3521 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
3522 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), | |
3523 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
3524 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), | |
3525 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
3526 | { } /* end */ | |
3527 | }; | |
3528 | ||
3529 | /* Replacer 672V ALC260 pin usage: Mic jack = 0x12, | |
3530 | * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f. | |
3531 | */ | |
3532 | static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = { | |
3533 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
3534 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT), | |
3535 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
3536 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
3537 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
3538 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT), | |
3539 | HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT), | |
3540 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
3541 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
3542 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
3543 | { } /* end */ | |
3544 | }; | |
3545 | ||
df694daa KY |
3546 | /* capture mixer elements */ |
3547 | static struct snd_kcontrol_new alc260_capture_mixer[] = { | |
a9430dd8 JW |
3548 | HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT), |
3549 | HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT), | |
df694daa KY |
3550 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT), |
3551 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT), | |
a9430dd8 JW |
3552 | { |
3553 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
df694daa KY |
3554 | /* The multiple "Capture Source" controls confuse alsamixer |
3555 | * So call somewhat different.. | |
3556 | * FIXME: the controls appear in the "playback" view! | |
3557 | */ | |
3558 | /* .name = "Capture Source", */ | |
3559 | .name = "Input Source", | |
3560 | .count = 2, | |
3561 | .info = alc_mux_enum_info, | |
3562 | .get = alc_mux_enum_get, | |
3563 | .put = alc_mux_enum_put, | |
3564 | }, | |
3565 | { } /* end */ | |
3566 | }; | |
3567 | ||
3568 | static struct snd_kcontrol_new alc260_capture_alt_mixer[] = { | |
3569 | HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT), | |
3570 | HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT), | |
3571 | { | |
3572 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
3573 | /* The multiple "Capture Source" controls confuse alsamixer | |
3574 | * So call somewhat different.. | |
3575 | * FIXME: the controls appear in the "playback" view! | |
3576 | */ | |
3577 | /* .name = "Capture Source", */ | |
3578 | .name = "Input Source", | |
3579 | .count = 1, | |
a9430dd8 JW |
3580 | .info = alc_mux_enum_info, |
3581 | .get = alc_mux_enum_get, | |
3582 | .put = alc_mux_enum_put, | |
3583 | }, | |
3584 | { } /* end */ | |
3585 | }; | |
3586 | ||
df694daa KY |
3587 | /* |
3588 | * initialization verbs | |
3589 | */ | |
1da177e4 LT |
3590 | static struct hda_verb alc260_init_verbs[] = { |
3591 | /* Line In pin widget for input */ | |
05acb863 | 3592 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 3593 | /* CD pin widget for input */ |
05acb863 | 3594 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 3595 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
16ded525 | 3596 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1da177e4 | 3597 | /* Mic2 (front panel) pin widget for input and vref at 80% */ |
16ded525 | 3598 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1da177e4 | 3599 | /* LINE-2 is used for line-out in rear */ |
05acb863 | 3600 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1da177e4 | 3601 | /* select line-out */ |
fd56f2db | 3602 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00}, |
1da177e4 | 3603 | /* LINE-OUT pin */ |
05acb863 | 3604 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1da177e4 | 3605 | /* enable HP */ |
05acb863 | 3606 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
1da177e4 | 3607 | /* enable Mono */ |
05acb863 TI |
3608 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
3609 | /* mute capture amp left and right */ | |
16ded525 | 3610 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1da177e4 LT |
3611 | /* set connection select to line in (default select for this ADC) */ |
3612 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
16ded525 TI |
3613 | /* mute capture amp left and right */ |
3614 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
3615 | /* set connection select to line in (default select for this ADC) */ | |
3616 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
05acb863 TI |
3617 | /* set vol=0 Line-Out mixer amp left and right */ |
3618 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3619 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
3620 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3621 | /* set vol=0 HP mixer amp left and right */ | |
3622 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3623 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
3624 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3625 | /* set vol=0 Mono mixer amp left and right */ | |
3626 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3627 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
3628 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3629 | /* unmute LINE-2 out pin */ | |
3630 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
f12ab1e0 TI |
3631 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
3632 | * Line In 2 = 0x03 | |
3633 | */ | |
05acb863 | 3634 | /* mute CD */ |
16ded525 | 3635 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
05acb863 | 3636 | /* mute Line In */ |
16ded525 | 3637 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
05acb863 | 3638 | /* mute Mic */ |
16ded525 | 3639 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1da177e4 | 3640 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
05acb863 TI |
3641 | /* mute Front out path */ |
3642 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3643 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3644 | /* mute Headphone out path */ | |
3645 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3646 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3647 | /* mute Mono out path */ | |
3648 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3649 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 LT |
3650 | { } |
3651 | }; | |
3652 | ||
474167d6 | 3653 | #if 0 /* should be identical with alc260_init_verbs? */ |
df694daa KY |
3654 | static struct hda_verb alc260_hp_init_verbs[] = { |
3655 | /* Headphone and output */ | |
3656 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
3657 | /* mono output */ | |
3658 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
3659 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
3660 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
3661 | /* Mic2 (front panel) pin widget for input and vref at 80% */ | |
3662 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
3663 | /* Line In pin widget for input */ | |
3664 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
3665 | /* Line-2 pin widget for output */ | |
3666 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
3667 | /* CD pin widget for input */ | |
3668 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
3669 | /* unmute amp left and right */ | |
3670 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | |
3671 | /* set connection select to line in (default select for this ADC) */ | |
3672 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
3673 | /* unmute Line-Out mixer amp left and right (volume = 0) */ | |
3674 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
3675 | /* mute pin widget amp left and right (no gain on this amp) */ | |
3676 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
3677 | /* unmute HP mixer amp left and right (volume = 0) */ | |
3678 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
3679 | /* mute pin widget amp left and right (no gain on this amp) */ | |
3680 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
f12ab1e0 TI |
3681 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
3682 | * Line In 2 = 0x03 | |
3683 | */ | |
df694daa KY |
3684 | /* unmute CD */ |
3685 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
3686 | /* unmute Line In */ | |
3687 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
3688 | /* unmute Mic */ | |
3689 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3690 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ | |
3691 | /* Unmute Front out path */ | |
3692 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3693 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
3694 | /* Unmute Headphone out path */ | |
3695 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3696 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
3697 | /* Unmute Mono out path */ | |
3698 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3699 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
3700 | { } | |
3701 | }; | |
474167d6 | 3702 | #endif |
df694daa KY |
3703 | |
3704 | static struct hda_verb alc260_hp_3013_init_verbs[] = { | |
3705 | /* Line out and output */ | |
3706 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
3707 | /* mono output */ | |
3708 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
3709 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
3710 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
3711 | /* Mic2 (front panel) pin widget for input and vref at 80% */ | |
3712 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
3713 | /* Line In pin widget for input */ | |
3714 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
3715 | /* Headphone pin widget for output */ | |
3716 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
3717 | /* CD pin widget for input */ | |
3718 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
3719 | /* unmute amp left and right */ | |
3720 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | |
3721 | /* set connection select to line in (default select for this ADC) */ | |
3722 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
3723 | /* unmute Line-Out mixer amp left and right (volume = 0) */ | |
3724 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
3725 | /* mute pin widget amp left and right (no gain on this amp) */ | |
3726 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
3727 | /* unmute HP mixer amp left and right (volume = 0) */ | |
3728 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
3729 | /* mute pin widget amp left and right (no gain on this amp) */ | |
3730 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
f12ab1e0 TI |
3731 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
3732 | * Line In 2 = 0x03 | |
3733 | */ | |
df694daa KY |
3734 | /* unmute CD */ |
3735 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
3736 | /* unmute Line In */ | |
3737 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
3738 | /* unmute Mic */ | |
3739 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3740 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ | |
3741 | /* Unmute Front out path */ | |
3742 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3743 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
3744 | /* Unmute Headphone out path */ | |
3745 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3746 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
3747 | /* Unmute Mono out path */ | |
3748 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3749 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
3750 | { } | |
3751 | }; | |
3752 | ||
a9430dd8 | 3753 | /* Initialisation sequence for ALC260 as configured in Fujitsu S702x |
a1e8d2da JW |
3754 | * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD |
3755 | * audio = 0x16, internal speaker = 0x10. | |
a9430dd8 JW |
3756 | */ |
3757 | static struct hda_verb alc260_fujitsu_init_verbs[] = { | |
3758 | /* Disable all GPIOs */ | |
3759 | {0x01, AC_VERB_SET_GPIO_MASK, 0}, | |
3760 | /* Internal speaker is connected to headphone pin */ | |
3761 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
3762 | /* Headphone/Line-out jack connects to Line1 pin; make it an output */ | |
3763 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
f7ace40d JW |
3764 | /* Mic/Line-in jack is connected to mic1 pin, so make it an input */ |
3765 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
3766 | /* Ensure all other unused pins are disabled and muted. */ | |
3767 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
3768 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
a9430dd8 | 3769 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
f7ace40d | 3770 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
a9430dd8 | 3771 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
f7ace40d JW |
3772 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
3773 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
3774 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3775 | ||
3776 | /* Disable digital (SPDIF) pins */ | |
3777 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
3778 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
a9430dd8 | 3779 | |
f7ace40d JW |
3780 | /* Ensure Line1 pin widget takes its input from the OUT1 sum bus |
3781 | * when acting as an output. | |
3782 | */ | |
3783 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
4c5186ed | 3784 | |
f7ace40d | 3785 | /* Start with output sum widgets muted and their output gains at min */ |
8b33a5aa TI |
3786 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
3787 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3788 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3789 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3790 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3791 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3792 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3793 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3794 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
a9430dd8 | 3795 | |
f7ace40d JW |
3796 | /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */ |
3797 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3798 | /* Unmute Line1 pin widget output buffer since it starts as an output. | |
3799 | * If the pin mode is changed by the user the pin mode control will | |
3800 | * take care of enabling the pin's input/output buffers as needed. | |
3801 | * Therefore there's no need to enable the input buffer at this | |
3802 | * stage. | |
cdcd9268 | 3803 | */ |
f7ace40d | 3804 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
cdcd9268 JW |
3805 | /* Unmute input buffer of pin widget used for Line-in (no equiv |
3806 | * mixer ctrl) | |
3807 | */ | |
f7ace40d JW |
3808 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
3809 | ||
3810 | /* Mute capture amp left and right */ | |
3811 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3812 | /* Set ADC connection select to match default mixer setting - line | |
3813 | * in (on mic1 pin) | |
3814 | */ | |
3815 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
3816 | ||
3817 | /* Do the same for the second ADC: mute capture input amp and | |
3818 | * set ADC connection to line in (on mic1 pin) | |
3819 | */ | |
3820 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3821 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
3822 | ||
3823 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
3824 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
3825 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
3826 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
3827 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
3828 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
3829 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
3830 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
3831 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
4a471b7d TI |
3832 | |
3833 | { } | |
a9430dd8 JW |
3834 | }; |
3835 | ||
0bfc90e9 JW |
3836 | /* Initialisation sequence for ALC260 as configured in Acer TravelMate and |
3837 | * similar laptops (adapted from Fujitsu init verbs). | |
3838 | */ | |
3839 | static struct hda_verb alc260_acer_init_verbs[] = { | |
3840 | /* On TravelMate laptops, GPIO 0 enables the internal speaker and | |
3841 | * the headphone jack. Turn this on and rely on the standard mute | |
3842 | * methods whenever the user wants to turn these outputs off. | |
3843 | */ | |
3844 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
3845 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
3846 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, | |
3847 | /* Internal speaker/Headphone jack is connected to Line-out pin */ | |
3848 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
3849 | /* Internal microphone/Mic jack is connected to Mic1 pin */ | |
3850 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | |
3851 | /* Line In jack is connected to Line1 pin */ | |
3852 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
bd869485 JW |
3853 | /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */ |
3854 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
0bfc90e9 JW |
3855 | /* Ensure all other unused pins are disabled and muted. */ |
3856 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
3857 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
0bfc90e9 JW |
3858 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
3859 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3860 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
3861 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3862 | /* Disable digital (SPDIF) pins */ | |
3863 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
3864 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
3865 | ||
3866 | /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum | |
3867 | * bus when acting as outputs. | |
3868 | */ | |
3869 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, | |
3870 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
3871 | ||
3872 | /* Start with output sum widgets muted and their output gains at min */ | |
3873 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3874 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3875 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3876 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3877 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3878 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3879 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3880 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3881 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3882 | ||
f12ab1e0 TI |
3883 | /* Unmute Line-out pin widget amp left and right |
3884 | * (no equiv mixer ctrl) | |
3885 | */ | |
0bfc90e9 | 3886 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
bd869485 JW |
3887 | /* Unmute mono pin widget amp output (no equiv mixer ctrl) */ |
3888 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
0bfc90e9 JW |
3889 | /* Unmute Mic1 and Line1 pin widget input buffers since they start as |
3890 | * inputs. If the pin mode is changed by the user the pin mode control | |
3891 | * will take care of enabling the pin's input/output buffers as needed. | |
3892 | * Therefore there's no need to enable the input buffer at this | |
3893 | * stage. | |
3894 | */ | |
3895 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
3896 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
3897 | ||
3898 | /* Mute capture amp left and right */ | |
3899 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3900 | /* Set ADC connection select to match default mixer setting - mic | |
3901 | * (on mic1 pin) | |
3902 | */ | |
3903 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
3904 | ||
3905 | /* Do similar with the second ADC: mute capture input amp and | |
a1e8d2da | 3906 | * set ADC connection to mic to match ALSA's default state. |
0bfc90e9 JW |
3907 | */ |
3908 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
a1e8d2da | 3909 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, |
0bfc90e9 JW |
3910 | |
3911 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
3912 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
3913 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
3914 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
3915 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
3916 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
3917 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
3918 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
3919 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
3920 | ||
3921 | { } | |
3922 | }; | |
3923 | ||
bc9f98a9 KY |
3924 | static struct hda_verb alc260_will_verbs[] = { |
3925 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
3926 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
3927 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
3928 | {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, | |
3929 | {0x1a, AC_VERB_SET_COEF_INDEX, 0x07}, | |
3930 | {0x1a, AC_VERB_SET_PROC_COEF, 0x3040}, | |
3931 | {} | |
3932 | }; | |
3933 | ||
3934 | static struct hda_verb alc260_replacer_672v_verbs[] = { | |
3935 | {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, | |
3936 | {0x1a, AC_VERB_SET_COEF_INDEX, 0x07}, | |
3937 | {0x1a, AC_VERB_SET_PROC_COEF, 0x3050}, | |
3938 | ||
3939 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
3940 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
3941 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, | |
3942 | ||
3943 | {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
3944 | {} | |
3945 | }; | |
3946 | ||
3947 | /* toggle speaker-output according to the hp-jack state */ | |
3948 | static void alc260_replacer_672v_automute(struct hda_codec *codec) | |
3949 | { | |
3950 | unsigned int present; | |
3951 | ||
3952 | /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */ | |
3953 | present = snd_hda_codec_read(codec, 0x0f, 0, | |
3954 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
3955 | if (present) { | |
3956 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1); | |
3957 | snd_hda_codec_write(codec, 0x0f, 0, | |
3958 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP); | |
3959 | } else { | |
3960 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0); | |
3961 | snd_hda_codec_write(codec, 0x0f, 0, | |
3962 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | |
3963 | } | |
3964 | } | |
3965 | ||
3966 | static void alc260_replacer_672v_unsol_event(struct hda_codec *codec, | |
3967 | unsigned int res) | |
3968 | { | |
3969 | if ((res >> 26) == ALC880_HP_EVENT) | |
3970 | alc260_replacer_672v_automute(codec); | |
3971 | } | |
3972 | ||
7cf51e48 JW |
3973 | /* Test configuration for debugging, modelled after the ALC880 test |
3974 | * configuration. | |
3975 | */ | |
3976 | #ifdef CONFIG_SND_DEBUG | |
3977 | static hda_nid_t alc260_test_dac_nids[1] = { | |
3978 | 0x02, | |
3979 | }; | |
3980 | static hda_nid_t alc260_test_adc_nids[2] = { | |
3981 | 0x04, 0x05, | |
3982 | }; | |
a1e8d2da JW |
3983 | /* For testing the ALC260, each input MUX needs its own definition since |
3984 | * the signal assignments are different. This assumes that the first ADC | |
3985 | * is NID 0x04. | |
17e7aec6 | 3986 | */ |
a1e8d2da JW |
3987 | static struct hda_input_mux alc260_test_capture_sources[2] = { |
3988 | { | |
3989 | .num_items = 7, | |
3990 | .items = { | |
3991 | { "MIC1 pin", 0x0 }, | |
3992 | { "MIC2 pin", 0x1 }, | |
3993 | { "LINE1 pin", 0x2 }, | |
3994 | { "LINE2 pin", 0x3 }, | |
3995 | { "CD pin", 0x4 }, | |
3996 | { "LINE-OUT pin", 0x5 }, | |
3997 | { "HP-OUT pin", 0x6 }, | |
3998 | }, | |
3999 | }, | |
4000 | { | |
4001 | .num_items = 8, | |
4002 | .items = { | |
4003 | { "MIC1 pin", 0x0 }, | |
4004 | { "MIC2 pin", 0x1 }, | |
4005 | { "LINE1 pin", 0x2 }, | |
4006 | { "LINE2 pin", 0x3 }, | |
4007 | { "CD pin", 0x4 }, | |
4008 | { "Mixer", 0x5 }, | |
4009 | { "LINE-OUT pin", 0x6 }, | |
4010 | { "HP-OUT pin", 0x7 }, | |
4011 | }, | |
7cf51e48 JW |
4012 | }, |
4013 | }; | |
4014 | static struct snd_kcontrol_new alc260_test_mixer[] = { | |
4015 | /* Output driver widgets */ | |
4016 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), | |
4017 | HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), | |
4018 | HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT), | |
4019 | HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT), | |
4020 | HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4021 | HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT), | |
4022 | ||
a1e8d2da JW |
4023 | /* Modes for retasking pin widgets |
4024 | * Note: the ALC260 doesn't seem to act on requests to enable mic | |
4025 | * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't | |
4026 | * mention this restriction. At this stage it's not clear whether | |
4027 | * this behaviour is intentional or is a hardware bug in chip | |
4028 | * revisions available at least up until early 2006. Therefore for | |
4029 | * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all | |
4030 | * choices, but if it turns out that the lack of mic bias for these | |
4031 | * NIDs is intentional we could change their modes from | |
4032 | * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
4033 | */ | |
7cf51e48 JW |
4034 | ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT), |
4035 | ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT), | |
4036 | ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT), | |
4037 | ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT), | |
4038 | ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT), | |
4039 | ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT), | |
4040 | ||
4041 | /* Loopback mixer controls */ | |
4042 | HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT), | |
4043 | HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT), | |
4044 | HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT), | |
4045 | HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT), | |
4046 | HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4047 | HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4048 | HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT), | |
4049 | HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT), | |
4050 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), | |
4051 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
4052 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), | |
4053 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
4054 | HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT), | |
4055 | HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT), | |
4056 | HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT), | |
4057 | HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT), | |
5c8f858d JW |
4058 | |
4059 | /* Controls for GPIO pins, assuming they are configured as outputs */ | |
4060 | ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01), | |
4061 | ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02), | |
4062 | ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04), | |
4063 | ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08), | |
4064 | ||
92621f13 JW |
4065 | /* Switches to allow the digital IO pins to be enabled. The datasheet |
4066 | * is ambigious as to which NID is which; testing on laptops which | |
4067 | * make this output available should provide clarification. | |
4068 | */ | |
4069 | ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01), | |
4070 | ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01), | |
4071 | ||
7cf51e48 JW |
4072 | { } /* end */ |
4073 | }; | |
4074 | static struct hda_verb alc260_test_init_verbs[] = { | |
5c8f858d JW |
4075 | /* Enable all GPIOs as outputs with an initial value of 0 */ |
4076 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f}, | |
4077 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, | |
4078 | {0x01, AC_VERB_SET_GPIO_MASK, 0x0f}, | |
4079 | ||
7cf51e48 JW |
4080 | /* Enable retasking pins as output, initially without power amp */ |
4081 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4082 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4083 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4084 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4085 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4086 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4087 | ||
92621f13 JW |
4088 | /* Disable digital (SPDIF) pins initially, but users can enable |
4089 | * them via a mixer switch. In the case of SPDIF-out, this initverb | |
4090 | * payload also sets the generation to 0, output to be in "consumer" | |
4091 | * PCM format, copyright asserted, no pre-emphasis and no validity | |
4092 | * control. | |
4093 | */ | |
7cf51e48 JW |
4094 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, |
4095 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
4096 | ||
f7ace40d | 4097 | /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the |
7cf51e48 JW |
4098 | * OUT1 sum bus when acting as an output. |
4099 | */ | |
4100 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, | |
4101 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0}, | |
4102 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
4103 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0}, | |
4104 | ||
4105 | /* Start with output sum widgets muted and their output gains at min */ | |
4106 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4107 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4108 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4109 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4110 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4111 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4112 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4113 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4114 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4115 | ||
cdcd9268 JW |
4116 | /* Unmute retasking pin widget output buffers since the default |
4117 | * state appears to be output. As the pin mode is changed by the | |
4118 | * user the pin mode control will take care of enabling the pin's | |
4119 | * input/output buffers as needed. | |
4120 | */ | |
7cf51e48 JW |
4121 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
4122 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4123 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4124 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4125 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4126 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4127 | /* Also unmute the mono-out pin widget */ | |
4128 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4129 | ||
7cf51e48 JW |
4130 | /* Mute capture amp left and right */ |
4131 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
f7ace40d JW |
4132 | /* Set ADC connection select to match default mixer setting (mic1 |
4133 | * pin) | |
7cf51e48 JW |
4134 | */ |
4135 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4136 | ||
4137 | /* Do the same for the second ADC: mute capture input amp and | |
f7ace40d | 4138 | * set ADC connection to mic1 pin |
7cf51e48 JW |
4139 | */ |
4140 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4141 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4142 | ||
4143 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
4144 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
4145 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
4146 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
4147 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
4148 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
4149 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
4150 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
4151 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
4152 | ||
4153 | { } | |
4154 | }; | |
4155 | #endif | |
4156 | ||
1da177e4 LT |
4157 | static struct hda_pcm_stream alc260_pcm_analog_playback = { |
4158 | .substreams = 1, | |
4159 | .channels_min = 2, | |
4160 | .channels_max = 2, | |
1da177e4 LT |
4161 | }; |
4162 | ||
4163 | static struct hda_pcm_stream alc260_pcm_analog_capture = { | |
4164 | .substreams = 1, | |
4165 | .channels_min = 2, | |
4166 | .channels_max = 2, | |
1da177e4 LT |
4167 | }; |
4168 | ||
a3bcba38 TI |
4169 | #define alc260_pcm_digital_playback alc880_pcm_digital_playback |
4170 | #define alc260_pcm_digital_capture alc880_pcm_digital_capture | |
4171 | ||
df694daa KY |
4172 | /* |
4173 | * for BIOS auto-configuration | |
4174 | */ | |
16ded525 | 4175 | |
df694daa KY |
4176 | static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid, |
4177 | const char *pfx) | |
4178 | { | |
4179 | hda_nid_t nid_vol; | |
4180 | unsigned long vol_val, sw_val; | |
4181 | char name[32]; | |
4182 | int err; | |
4183 | ||
4184 | if (nid >= 0x0f && nid < 0x11) { | |
4185 | nid_vol = nid - 0x7; | |
4186 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); | |
4187 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); | |
4188 | } else if (nid == 0x11) { | |
4189 | nid_vol = nid - 0x7; | |
4190 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT); | |
4191 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT); | |
4192 | } else if (nid >= 0x12 && nid <= 0x15) { | |
4193 | nid_vol = 0x08; | |
4194 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); | |
4195 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); | |
4196 | } else | |
4197 | return 0; /* N/A */ | |
4198 | ||
4199 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); | |
f12ab1e0 TI |
4200 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val); |
4201 | if (err < 0) | |
df694daa KY |
4202 | return err; |
4203 | snprintf(name, sizeof(name), "%s Playback Switch", pfx); | |
f12ab1e0 TI |
4204 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val); |
4205 | if (err < 0) | |
df694daa KY |
4206 | return err; |
4207 | return 1; | |
4208 | } | |
4209 | ||
4210 | /* add playback controls from the parsed DAC table */ | |
4211 | static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec, | |
4212 | const struct auto_pin_cfg *cfg) | |
4213 | { | |
4214 | hda_nid_t nid; | |
4215 | int err; | |
4216 | ||
4217 | spec->multiout.num_dacs = 1; | |
4218 | spec->multiout.dac_nids = spec->private_dac_nids; | |
4219 | spec->multiout.dac_nids[0] = 0x02; | |
4220 | ||
4221 | nid = cfg->line_out_pins[0]; | |
4222 | if (nid) { | |
4223 | err = alc260_add_playback_controls(spec, nid, "Front"); | |
4224 | if (err < 0) | |
4225 | return err; | |
4226 | } | |
4227 | ||
82bc955f | 4228 | nid = cfg->speaker_pins[0]; |
df694daa KY |
4229 | if (nid) { |
4230 | err = alc260_add_playback_controls(spec, nid, "Speaker"); | |
4231 | if (err < 0) | |
4232 | return err; | |
4233 | } | |
4234 | ||
eb06ed8f | 4235 | nid = cfg->hp_pins[0]; |
df694daa KY |
4236 | if (nid) { |
4237 | err = alc260_add_playback_controls(spec, nid, "Headphone"); | |
4238 | if (err < 0) | |
4239 | return err; | |
4240 | } | |
f12ab1e0 | 4241 | return 0; |
df694daa KY |
4242 | } |
4243 | ||
4244 | /* create playback/capture controls for input pins */ | |
4245 | static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec, | |
4246 | const struct auto_pin_cfg *cfg) | |
4247 | { | |
df694daa KY |
4248 | struct hda_input_mux *imux = &spec->private_imux; |
4249 | int i, err, idx; | |
4250 | ||
4251 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
4252 | if (cfg->input_pins[i] >= 0x12) { | |
4253 | idx = cfg->input_pins[i] - 0x12; | |
4a471b7d | 4254 | err = new_analog_input(spec, cfg->input_pins[i], |
f12ab1e0 TI |
4255 | auto_pin_cfg_labels[i], idx, |
4256 | 0x07); | |
df694daa KY |
4257 | if (err < 0) |
4258 | return err; | |
f12ab1e0 TI |
4259 | imux->items[imux->num_items].label = |
4260 | auto_pin_cfg_labels[i]; | |
df694daa KY |
4261 | imux->items[imux->num_items].index = idx; |
4262 | imux->num_items++; | |
4263 | } | |
f12ab1e0 | 4264 | if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){ |
df694daa | 4265 | idx = cfg->input_pins[i] - 0x09; |
4a471b7d | 4266 | err = new_analog_input(spec, cfg->input_pins[i], |
f12ab1e0 TI |
4267 | auto_pin_cfg_labels[i], idx, |
4268 | 0x07); | |
df694daa KY |
4269 | if (err < 0) |
4270 | return err; | |
f12ab1e0 TI |
4271 | imux->items[imux->num_items].label = |
4272 | auto_pin_cfg_labels[i]; | |
df694daa KY |
4273 | imux->items[imux->num_items].index = idx; |
4274 | imux->num_items++; | |
4275 | } | |
4276 | } | |
4277 | return 0; | |
4278 | } | |
4279 | ||
4280 | static void alc260_auto_set_output_and_unmute(struct hda_codec *codec, | |
4281 | hda_nid_t nid, int pin_type, | |
4282 | int sel_idx) | |
4283 | { | |
4284 | /* set as output */ | |
f12ab1e0 TI |
4285 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
4286 | pin_type); | |
4287 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
4288 | AMP_OUT_UNMUTE); | |
df694daa KY |
4289 | /* need the manual connection? */ |
4290 | if (nid >= 0x12) { | |
4291 | int idx = nid - 0x12; | |
4292 | snd_hda_codec_write(codec, idx + 0x0b, 0, | |
4293 | AC_VERB_SET_CONNECT_SEL, sel_idx); | |
df694daa KY |
4294 | } |
4295 | } | |
4296 | ||
4297 | static void alc260_auto_init_multi_out(struct hda_codec *codec) | |
4298 | { | |
4299 | struct alc_spec *spec = codec->spec; | |
4300 | hda_nid_t nid; | |
4301 | ||
bc9f98a9 | 4302 | alc_subsystem_id(codec, 0x10, 0x15, 0x0f); |
f12ab1e0 | 4303 | nid = spec->autocfg.line_out_pins[0]; |
baba8ee9 TI |
4304 | if (nid) { |
4305 | int pin_type = get_pin_type(spec->autocfg.line_out_type); | |
4306 | alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0); | |
4307 | } | |
df694daa | 4308 | |
82bc955f | 4309 | nid = spec->autocfg.speaker_pins[0]; |
df694daa KY |
4310 | if (nid) |
4311 | alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); | |
4312 | ||
eb06ed8f | 4313 | nid = spec->autocfg.hp_pins[0]; |
df694daa | 4314 | if (nid) |
baba8ee9 | 4315 | alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0); |
f12ab1e0 | 4316 | } |
df694daa KY |
4317 | |
4318 | #define ALC260_PIN_CD_NID 0x16 | |
4319 | static void alc260_auto_init_analog_input(struct hda_codec *codec) | |
4320 | { | |
4321 | struct alc_spec *spec = codec->spec; | |
4322 | int i; | |
4323 | ||
4324 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
4325 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
4326 | if (nid >= 0x12) { | |
f12ab1e0 TI |
4327 | snd_hda_codec_write(codec, nid, 0, |
4328 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4329 | i <= AUTO_PIN_FRONT_MIC ? | |
4330 | PIN_VREF80 : PIN_IN); | |
df694daa | 4331 | if (nid != ALC260_PIN_CD_NID) |
f12ab1e0 TI |
4332 | snd_hda_codec_write(codec, nid, 0, |
4333 | AC_VERB_SET_AMP_GAIN_MUTE, | |
df694daa KY |
4334 | AMP_OUT_MUTE); |
4335 | } | |
4336 | } | |
4337 | } | |
4338 | ||
4339 | /* | |
4340 | * generic initialization of ADC, input mixers and output mixers | |
4341 | */ | |
4342 | static struct hda_verb alc260_volume_init_verbs[] = { | |
4343 | /* | |
4344 | * Unmute ADC0-1 and set the default input to mic-in | |
4345 | */ | |
4346 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4347 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4348 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4349 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4350 | ||
4351 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | |
4352 | * mixer widget | |
f12ab1e0 TI |
4353 | * Note: PASD motherboards uses the Line In 2 as the input for |
4354 | * front panel mic (mic 2) | |
df694daa KY |
4355 | */ |
4356 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
4357 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4358 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4359 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
4360 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
4361 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
4362 | ||
4363 | /* | |
4364 | * Set up output mixers (0x08 - 0x0a) | |
4365 | */ | |
4366 | /* set vol=0 to output mixers */ | |
4367 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4368 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4369 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4370 | /* set up input amps for analog loopback */ | |
4371 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
4372 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4373 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4374 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4375 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4376 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4377 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4378 | ||
4379 | { } | |
4380 | }; | |
4381 | ||
4382 | static int alc260_parse_auto_config(struct hda_codec *codec) | |
4383 | { | |
4384 | struct alc_spec *spec = codec->spec; | |
4385 | unsigned int wcap; | |
4386 | int err; | |
4387 | static hda_nid_t alc260_ignore[] = { 0x17, 0 }; | |
4388 | ||
f12ab1e0 TI |
4389 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
4390 | alc260_ignore); | |
4391 | if (err < 0) | |
df694daa | 4392 | return err; |
f12ab1e0 TI |
4393 | err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg); |
4394 | if (err < 0) | |
4a471b7d | 4395 | return err; |
f12ab1e0 | 4396 | if (!spec->kctl_alloc) |
df694daa | 4397 | return 0; /* can't find valid BIOS pin config */ |
f12ab1e0 TI |
4398 | err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg); |
4399 | if (err < 0) | |
df694daa KY |
4400 | return err; |
4401 | ||
4402 | spec->multiout.max_channels = 2; | |
4403 | ||
4404 | if (spec->autocfg.dig_out_pin) | |
4405 | spec->multiout.dig_out_nid = ALC260_DIGOUT_NID; | |
4406 | if (spec->kctl_alloc) | |
4407 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
4408 | ||
4409 | spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs; | |
4410 | ||
a1e8d2da | 4411 | spec->num_mux_defs = 1; |
df694daa KY |
4412 | spec->input_mux = &spec->private_imux; |
4413 | ||
4414 | /* check whether NID 0x04 is valid */ | |
4a471b7d | 4415 | wcap = get_wcaps(codec, 0x04); |
df694daa KY |
4416 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ |
4417 | if (wcap != AC_WID_AUD_IN) { | |
4418 | spec->adc_nids = alc260_adc_nids_alt; | |
4419 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt); | |
4420 | spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer; | |
df694daa KY |
4421 | } else { |
4422 | spec->adc_nids = alc260_adc_nids; | |
4423 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); | |
4424 | spec->mixers[spec->num_mixers] = alc260_capture_mixer; | |
df694daa | 4425 | } |
4a471b7d | 4426 | spec->num_mixers++; |
df694daa KY |
4427 | |
4428 | return 1; | |
4429 | } | |
4430 | ||
ae6b813a TI |
4431 | /* additional initialization for auto-configuration model */ |
4432 | static void alc260_auto_init(struct hda_codec *codec) | |
df694daa | 4433 | { |
df694daa KY |
4434 | alc260_auto_init_multi_out(codec); |
4435 | alc260_auto_init_analog_input(codec); | |
df694daa KY |
4436 | } |
4437 | ||
4438 | /* | |
4439 | * ALC260 configurations | |
4440 | */ | |
f5fcc13c TI |
4441 | static const char *alc260_models[ALC260_MODEL_LAST] = { |
4442 | [ALC260_BASIC] = "basic", | |
4443 | [ALC260_HP] = "hp", | |
4444 | [ALC260_HP_3013] = "hp-3013", | |
4445 | [ALC260_FUJITSU_S702X] = "fujitsu", | |
4446 | [ALC260_ACER] = "acer", | |
bc9f98a9 KY |
4447 | [ALC260_WILL] = "will", |
4448 | [ALC260_REPLACER_672V] = "replacer", | |
7cf51e48 | 4449 | #ifdef CONFIG_SND_DEBUG |
f5fcc13c | 4450 | [ALC260_TEST] = "test", |
7cf51e48 | 4451 | #endif |
f5fcc13c TI |
4452 | [ALC260_AUTO] = "auto", |
4453 | }; | |
4454 | ||
4455 | static struct snd_pci_quirk alc260_cfg_tbl[] = { | |
bd869485 | 4456 | SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER), |
f5fcc13c | 4457 | SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER), |
9720b718 | 4458 | SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013), |
a8a5d067 | 4459 | SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013), |
f5fcc13c TI |
4460 | SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013), |
4461 | SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP), | |
4462 | SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013), | |
4463 | SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013), | |
4464 | SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP), | |
4465 | SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP), | |
4466 | SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP), | |
4467 | SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC), | |
4468 | SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC), | |
4469 | SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC), | |
4470 | SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X), | |
4471 | SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC), | |
bc9f98a9 KY |
4472 | SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL), |
4473 | SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V), | |
df694daa KY |
4474 | {} |
4475 | }; | |
4476 | ||
4477 | static struct alc_config_preset alc260_presets[] = { | |
4478 | [ALC260_BASIC] = { | |
4479 | .mixers = { alc260_base_output_mixer, | |
4480 | alc260_input_mixer, | |
4481 | alc260_pc_beep_mixer, | |
4482 | alc260_capture_mixer }, | |
4483 | .init_verbs = { alc260_init_verbs }, | |
4484 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
4485 | .dac_nids = alc260_dac_nids, | |
4486 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), | |
4487 | .adc_nids = alc260_adc_nids, | |
4488 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
4489 | .channel_mode = alc260_modes, | |
4490 | .input_mux = &alc260_capture_source, | |
4491 | }, | |
4492 | [ALC260_HP] = { | |
4493 | .mixers = { alc260_base_output_mixer, | |
4494 | alc260_input_mixer, | |
4495 | alc260_capture_alt_mixer }, | |
474167d6 | 4496 | .init_verbs = { alc260_init_verbs }, |
df694daa KY |
4497 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), |
4498 | .dac_nids = alc260_dac_nids, | |
4499 | .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), | |
4500 | .adc_nids = alc260_hp_adc_nids, | |
4501 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
4502 | .channel_mode = alc260_modes, | |
4503 | .input_mux = &alc260_capture_source, | |
4504 | }, | |
4505 | [ALC260_HP_3013] = { | |
4506 | .mixers = { alc260_hp_3013_mixer, | |
4507 | alc260_input_mixer, | |
4508 | alc260_capture_alt_mixer }, | |
4509 | .init_verbs = { alc260_hp_3013_init_verbs }, | |
4510 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
4511 | .dac_nids = alc260_dac_nids, | |
4512 | .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), | |
4513 | .adc_nids = alc260_hp_adc_nids, | |
4514 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
4515 | .channel_mode = alc260_modes, | |
4516 | .input_mux = &alc260_capture_source, | |
4517 | }, | |
4518 | [ALC260_FUJITSU_S702X] = { | |
4519 | .mixers = { alc260_fujitsu_mixer, | |
4520 | alc260_capture_mixer }, | |
4521 | .init_verbs = { alc260_fujitsu_init_verbs }, | |
4522 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
4523 | .dac_nids = alc260_dac_nids, | |
d57fdac0 JW |
4524 | .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), |
4525 | .adc_nids = alc260_dual_adc_nids, | |
df694daa KY |
4526 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
4527 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
4528 | .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources), |
4529 | .input_mux = alc260_fujitsu_capture_sources, | |
df694daa | 4530 | }, |
0bfc90e9 JW |
4531 | [ALC260_ACER] = { |
4532 | .mixers = { alc260_acer_mixer, | |
4533 | alc260_capture_mixer }, | |
4534 | .init_verbs = { alc260_acer_init_verbs }, | |
4535 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
4536 | .dac_nids = alc260_dac_nids, | |
4537 | .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), | |
4538 | .adc_nids = alc260_dual_adc_nids, | |
4539 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
4540 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
4541 | .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources), |
4542 | .input_mux = alc260_acer_capture_sources, | |
0bfc90e9 | 4543 | }, |
bc9f98a9 KY |
4544 | [ALC260_WILL] = { |
4545 | .mixers = { alc260_will_mixer, | |
4546 | alc260_capture_mixer }, | |
4547 | .init_verbs = { alc260_init_verbs, alc260_will_verbs }, | |
4548 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
4549 | .dac_nids = alc260_dac_nids, | |
4550 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), | |
4551 | .adc_nids = alc260_adc_nids, | |
4552 | .dig_out_nid = ALC260_DIGOUT_NID, | |
4553 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
4554 | .channel_mode = alc260_modes, | |
4555 | .input_mux = &alc260_capture_source, | |
4556 | }, | |
4557 | [ALC260_REPLACER_672V] = { | |
4558 | .mixers = { alc260_replacer_672v_mixer, | |
4559 | alc260_capture_mixer }, | |
4560 | .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs }, | |
4561 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
4562 | .dac_nids = alc260_dac_nids, | |
4563 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), | |
4564 | .adc_nids = alc260_adc_nids, | |
4565 | .dig_out_nid = ALC260_DIGOUT_NID, | |
4566 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
4567 | .channel_mode = alc260_modes, | |
4568 | .input_mux = &alc260_capture_source, | |
4569 | .unsol_event = alc260_replacer_672v_unsol_event, | |
4570 | .init_hook = alc260_replacer_672v_automute, | |
4571 | }, | |
7cf51e48 JW |
4572 | #ifdef CONFIG_SND_DEBUG |
4573 | [ALC260_TEST] = { | |
4574 | .mixers = { alc260_test_mixer, | |
4575 | alc260_capture_mixer }, | |
4576 | .init_verbs = { alc260_test_init_verbs }, | |
4577 | .num_dacs = ARRAY_SIZE(alc260_test_dac_nids), | |
4578 | .dac_nids = alc260_test_dac_nids, | |
4579 | .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids), | |
4580 | .adc_nids = alc260_test_adc_nids, | |
4581 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
4582 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
4583 | .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources), |
4584 | .input_mux = alc260_test_capture_sources, | |
7cf51e48 JW |
4585 | }, |
4586 | #endif | |
df694daa KY |
4587 | }; |
4588 | ||
4589 | static int patch_alc260(struct hda_codec *codec) | |
1da177e4 LT |
4590 | { |
4591 | struct alc_spec *spec; | |
df694daa | 4592 | int err, board_config; |
1da177e4 | 4593 | |
e560d8d8 | 4594 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
1da177e4 LT |
4595 | if (spec == NULL) |
4596 | return -ENOMEM; | |
4597 | ||
4598 | codec->spec = spec; | |
4599 | ||
f5fcc13c TI |
4600 | board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST, |
4601 | alc260_models, | |
4602 | alc260_cfg_tbl); | |
4603 | if (board_config < 0) { | |
9c7f852e TI |
4604 | snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, " |
4605 | "trying auto-probe from BIOS...\n"); | |
df694daa | 4606 | board_config = ALC260_AUTO; |
16ded525 | 4607 | } |
1da177e4 | 4608 | |
df694daa KY |
4609 | if (board_config == ALC260_AUTO) { |
4610 | /* automatic parse from the BIOS config */ | |
4611 | err = alc260_parse_auto_config(codec); | |
4612 | if (err < 0) { | |
4613 | alc_free(codec); | |
4614 | return err; | |
f12ab1e0 | 4615 | } else if (!err) { |
9c7f852e TI |
4616 | printk(KERN_INFO |
4617 | "hda_codec: Cannot set up configuration " | |
4618 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
4619 | board_config = ALC260_BASIC; |
4620 | } | |
a9430dd8 | 4621 | } |
e9edcee0 | 4622 | |
df694daa KY |
4623 | if (board_config != ALC260_AUTO) |
4624 | setup_preset(spec, &alc260_presets[board_config]); | |
1da177e4 LT |
4625 | |
4626 | spec->stream_name_analog = "ALC260 Analog"; | |
4627 | spec->stream_analog_playback = &alc260_pcm_analog_playback; | |
4628 | spec->stream_analog_capture = &alc260_pcm_analog_capture; | |
4629 | ||
a3bcba38 TI |
4630 | spec->stream_name_digital = "ALC260 Digital"; |
4631 | spec->stream_digital_playback = &alc260_pcm_digital_playback; | |
4632 | spec->stream_digital_capture = &alc260_pcm_digital_capture; | |
4633 | ||
1da177e4 | 4634 | codec->patch_ops = alc_patch_ops; |
df694daa | 4635 | if (board_config == ALC260_AUTO) |
ae6b813a | 4636 | spec->init_hook = alc260_auto_init; |
1da177e4 LT |
4637 | |
4638 | return 0; | |
4639 | } | |
4640 | ||
e9edcee0 | 4641 | |
1da177e4 LT |
4642 | /* |
4643 | * ALC882 support | |
4644 | * | |
4645 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible | |
4646 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
4647 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
4648 | * 6-channel independent captures. | |
4649 | * | |
4650 | * In addition, an independent DAC for the multi-playback (not used in this | |
4651 | * driver yet). | |
4652 | */ | |
df694daa KY |
4653 | #define ALC882_DIGOUT_NID 0x06 |
4654 | #define ALC882_DIGIN_NID 0x0a | |
1da177e4 | 4655 | |
d2a6d7dc | 4656 | static struct hda_channel_mode alc882_ch_modes[1] = { |
1da177e4 LT |
4657 | { 8, NULL } |
4658 | }; | |
4659 | ||
4660 | static hda_nid_t alc882_dac_nids[4] = { | |
4661 | /* front, rear, clfe, rear_surr */ | |
4662 | 0x02, 0x03, 0x04, 0x05 | |
4663 | }; | |
4664 | ||
df694daa KY |
4665 | /* identical with ALC880 */ |
4666 | #define alc882_adc_nids alc880_adc_nids | |
4667 | #define alc882_adc_nids_alt alc880_adc_nids_alt | |
1da177e4 LT |
4668 | |
4669 | /* input MUX */ | |
4670 | /* FIXME: should be a matrix-type input source selection */ | |
4671 | ||
4672 | static struct hda_input_mux alc882_capture_source = { | |
4673 | .num_items = 4, | |
4674 | .items = { | |
4675 | { "Mic", 0x0 }, | |
4676 | { "Front Mic", 0x1 }, | |
4677 | { "Line", 0x2 }, | |
4678 | { "CD", 0x4 }, | |
4679 | }, | |
4680 | }; | |
1da177e4 LT |
4681 | #define alc882_mux_enum_info alc_mux_enum_info |
4682 | #define alc882_mux_enum_get alc_mux_enum_get | |
4683 | ||
f12ab1e0 TI |
4684 | static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, |
4685 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
4686 | { |
4687 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
4688 | struct alc_spec *spec = codec->spec; | |
4689 | const struct hda_input_mux *imux = spec->input_mux; | |
4690 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
4691 | static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 }; | |
4692 | hda_nid_t nid = capture_mixers[adc_idx]; | |
4693 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; | |
4694 | unsigned int i, idx; | |
4695 | ||
4696 | idx = ucontrol->value.enumerated.item[0]; | |
4697 | if (idx >= imux->num_items) | |
4698 | idx = imux->num_items - 1; | |
f12ab1e0 | 4699 | if (*cur_val == idx && !codec->in_resume) |
1da177e4 LT |
4700 | return 0; |
4701 | for (i = 0; i < imux->num_items; i++) { | |
4702 | unsigned int v = (i == idx) ? 0x7000 : 0x7080; | |
4703 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
4704 | v | (imux->items[i].index << 8)); | |
4705 | } | |
4706 | *cur_val = idx; | |
4707 | return 1; | |
4708 | } | |
4709 | ||
df694daa KY |
4710 | /* |
4711 | * 6ch mode | |
4712 | */ | |
4713 | static struct hda_verb alc882_sixstack_ch6_init[] = { | |
4714 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
4715 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
4716 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
4717 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
4718 | { } /* end */ | |
4719 | }; | |
4720 | ||
4721 | /* | |
4722 | * 8ch mode | |
4723 | */ | |
4724 | static struct hda_verb alc882_sixstack_ch8_init[] = { | |
4725 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
4726 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
4727 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
4728 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
4729 | { } /* end */ | |
4730 | }; | |
4731 | ||
4732 | static struct hda_channel_mode alc882_sixstack_modes[2] = { | |
4733 | { 6, alc882_sixstack_ch6_init }, | |
4734 | { 8, alc882_sixstack_ch8_init }, | |
4735 | }; | |
4736 | ||
1da177e4 LT |
4737 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
4738 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
4739 | */ | |
c8b6bf9b | 4740 | static struct snd_kcontrol_new alc882_base_mixer[] = { |
05acb863 | 4741 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 4742 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
05acb863 | 4743 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 4744 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
05acb863 TI |
4745 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
4746 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
4747 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
4748 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
05acb863 | 4749 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 4750 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
1da177e4 LT |
4751 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
4752 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
4753 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
4754 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
4755 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
4756 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 4757 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
1da177e4 LT |
4758 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
4759 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 4760 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
1da177e4 LT |
4761 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
4762 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
4763 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
1da177e4 LT |
4764 | { } /* end */ |
4765 | }; | |
4766 | ||
df694daa KY |
4767 | static struct snd_kcontrol_new alc882_chmode_mixer[] = { |
4768 | { | |
4769 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
4770 | .name = "Channel Mode", | |
4771 | .info = alc_ch_mode_info, | |
4772 | .get = alc_ch_mode_get, | |
4773 | .put = alc_ch_mode_put, | |
4774 | }, | |
4775 | { } /* end */ | |
4776 | }; | |
4777 | ||
1da177e4 LT |
4778 | static struct hda_verb alc882_init_verbs[] = { |
4779 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
05acb863 TI |
4780 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
4781 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4782 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 4783 | /* Rear mixer */ |
05acb863 TI |
4784 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
4785 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4786 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 4787 | /* CLFE mixer */ |
05acb863 TI |
4788 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
4789 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4790 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 4791 | /* Side mixer */ |
05acb863 TI |
4792 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
4793 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4794 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 4795 | |
e9edcee0 | 4796 | /* Front Pin: output 0 (0x0c) */ |
05acb863 | 4797 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 4798 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 4799 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 4800 | /* Rear Pin: output 1 (0x0d) */ |
05acb863 | 4801 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 4802 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 4803 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, |
e9edcee0 | 4804 | /* CLFE Pin: output 2 (0x0e) */ |
05acb863 | 4805 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 4806 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 4807 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, |
e9edcee0 | 4808 | /* Side Pin: output 3 (0x0f) */ |
05acb863 | 4809 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 4810 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 4811 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, |
e9edcee0 | 4812 | /* Mic (rear) pin: input vref at 80% */ |
16ded525 | 4813 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 TI |
4814 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
4815 | /* Front Mic pin: input vref at 80% */ | |
16ded525 | 4816 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 TI |
4817 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
4818 | /* Line In pin: input */ | |
05acb863 | 4819 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 TI |
4820 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
4821 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
4822 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
4823 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4824 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1da177e4 | 4825 | /* CD pin widget for input */ |
05acb863 | 4826 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 LT |
4827 | |
4828 | /* FIXME: use matrix-type input source selection */ | |
4829 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
4830 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
05acb863 TI |
4831 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
4832 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4833 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4834 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 4835 | /* Input mixer2 */ |
05acb863 TI |
4836 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
4837 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4838 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4839 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 4840 | /* Input mixer3 */ |
05acb863 TI |
4841 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
4842 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4843 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4844 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
4845 | /* ADC1: mute amp left and right */ | |
4846 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 4847 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
4848 | /* ADC2: mute amp left and right */ |
4849 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 4850 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
4851 | /* ADC3: mute amp left and right */ |
4852 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 4853 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
1da177e4 LT |
4854 | |
4855 | { } | |
4856 | }; | |
4857 | ||
4b146cb0 TI |
4858 | static struct hda_verb alc882_eapd_verbs[] = { |
4859 | /* change to EAPD mode */ | |
4860 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
b373bdeb | 4861 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, |
f12ab1e0 | 4862 | { } |
4b146cb0 TI |
4863 | }; |
4864 | ||
9102cd1c TD |
4865 | /* Mac Pro test */ |
4866 | static struct snd_kcontrol_new alc882_macpro_mixer[] = { | |
4867 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
4868 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
4869 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT), | |
4870 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
4871 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
4872 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
4873 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
4874 | { } /* end */ | |
4875 | }; | |
4876 | ||
4877 | static struct hda_verb alc882_macpro_init_verbs[] = { | |
4878 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
4879 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4880 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4881 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4882 | /* Front Pin: output 0 (0x0c) */ | |
4883 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4884 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4885 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4886 | /* Front Mic pin: input vref at 80% */ | |
4887 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
4888 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
4889 | /* Speaker: output */ | |
4890 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4891 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4892 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04}, | |
4893 | /* Headphone output (output 0 - 0x0c) */ | |
4894 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
4895 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4896 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4897 | ||
4898 | /* FIXME: use matrix-type input source selection */ | |
4899 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
4900 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
4901 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4902 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4903 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4904 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
4905 | /* Input mixer2 */ | |
4906 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4907 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4908 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4909 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
4910 | /* Input mixer3 */ | |
4911 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4912 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4913 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4914 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
4915 | /* ADC1: mute amp left and right */ | |
4916 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4917 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4918 | /* ADC2: mute amp left and right */ | |
4919 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4920 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4921 | /* ADC3: mute amp left and right */ | |
4922 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4923 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4924 | ||
4925 | { } | |
4926 | }; | |
f12ab1e0 | 4927 | |
9102cd1c TD |
4928 | static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) |
4929 | { | |
4930 | unsigned int gpiostate, gpiomask, gpiodir; | |
4931 | ||
4932 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, | |
4933 | AC_VERB_GET_GPIO_DATA, 0); | |
4934 | ||
4935 | if (!muted) | |
4936 | gpiostate |= (1 << pin); | |
4937 | else | |
4938 | gpiostate &= ~(1 << pin); | |
4939 | ||
4940 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, | |
4941 | AC_VERB_GET_GPIO_MASK, 0); | |
4942 | gpiomask |= (1 << pin); | |
4943 | ||
4944 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, | |
4945 | AC_VERB_GET_GPIO_DIRECTION, 0); | |
4946 | gpiodir |= (1 << pin); | |
4947 | ||
4948 | ||
4949 | snd_hda_codec_write(codec, codec->afg, 0, | |
4950 | AC_VERB_SET_GPIO_MASK, gpiomask); | |
4951 | snd_hda_codec_write(codec, codec->afg, 0, | |
4952 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); | |
4953 | ||
4954 | msleep(1); | |
4955 | ||
4956 | snd_hda_codec_write(codec, codec->afg, 0, | |
4957 | AC_VERB_SET_GPIO_DATA, gpiostate); | |
4958 | } | |
4959 | ||
df694daa KY |
4960 | /* |
4961 | * generic initialization of ADC, input mixers and output mixers | |
4962 | */ | |
4963 | static struct hda_verb alc882_auto_init_verbs[] = { | |
4964 | /* | |
4965 | * Unmute ADC0-2 and set the default input to mic-in | |
4966 | */ | |
4967 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4968 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4969 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4970 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4971 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4972 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
1da177e4 | 4973 | |
df694daa KY |
4974 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
4975 | * mixer widget | |
f12ab1e0 TI |
4976 | * Note: PASD motherboards uses the Line In 2 as the input for |
4977 | * front panel mic (mic 2) | |
df694daa KY |
4978 | */ |
4979 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
4980 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4981 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4982 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
4983 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
4984 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
e9edcee0 | 4985 | |
df694daa KY |
4986 | /* |
4987 | * Set up output mixers (0x0c - 0x0f) | |
4988 | */ | |
4989 | /* set vol=0 to output mixers */ | |
4990 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4991 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4992 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4993 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4994 | /* set up input amps for analog loopback */ | |
4995 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
4996 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4997 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4998 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4999 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5000 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5001 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5002 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5003 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5004 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5005 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5006 | ||
5007 | /* FIXME: use matrix-type input source selection */ | |
5008 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
5009 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
5010 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
5011 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
5012 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
5013 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
5014 | /* Input mixer2 */ | |
5015 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
5016 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
5017 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
5018 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
5019 | /* Input mixer3 */ | |
5020 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
5021 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
5022 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
5023 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
5024 | ||
5025 | { } | |
5026 | }; | |
5027 | ||
5028 | /* capture mixer elements */ | |
5029 | static struct snd_kcontrol_new alc882_capture_alt_mixer[] = { | |
5030 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
5031 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
5032 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
5033 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
5034 | { | |
5035 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5036 | /* The multiple "Capture Source" controls confuse alsamixer | |
5037 | * So call somewhat different.. | |
5038 | * FIXME: the controls appear in the "playback" view! | |
5039 | */ | |
5040 | /* .name = "Capture Source", */ | |
5041 | .name = "Input Source", | |
5042 | .count = 2, | |
5043 | .info = alc882_mux_enum_info, | |
5044 | .get = alc882_mux_enum_get, | |
5045 | .put = alc882_mux_enum_put, | |
5046 | }, | |
5047 | { } /* end */ | |
5048 | }; | |
5049 | ||
5050 | static struct snd_kcontrol_new alc882_capture_mixer[] = { | |
5051 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), | |
5052 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), | |
5053 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), | |
5054 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), | |
5055 | HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), | |
5056 | HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), | |
5057 | { | |
5058 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5059 | /* The multiple "Capture Source" controls confuse alsamixer | |
5060 | * So call somewhat different.. | |
5061 | * FIXME: the controls appear in the "playback" view! | |
5062 | */ | |
5063 | /* .name = "Capture Source", */ | |
5064 | .name = "Input Source", | |
5065 | .count = 3, | |
5066 | .info = alc882_mux_enum_info, | |
5067 | .get = alc882_mux_enum_get, | |
5068 | .put = alc882_mux_enum_put, | |
5069 | }, | |
5070 | { } /* end */ | |
5071 | }; | |
5072 | ||
5073 | /* pcm configuration: identiacal with ALC880 */ | |
5074 | #define alc882_pcm_analog_playback alc880_pcm_analog_playback | |
5075 | #define alc882_pcm_analog_capture alc880_pcm_analog_capture | |
5076 | #define alc882_pcm_digital_playback alc880_pcm_digital_playback | |
5077 | #define alc882_pcm_digital_capture alc880_pcm_digital_capture | |
5078 | ||
5079 | /* | |
5080 | * configuration and preset | |
5081 | */ | |
f5fcc13c TI |
5082 | static const char *alc882_models[ALC882_MODEL_LAST] = { |
5083 | [ALC882_3ST_DIG] = "3stack-dig", | |
5084 | [ALC882_6ST_DIG] = "6stack-dig", | |
5085 | [ALC882_ARIMA] = "arima", | |
9102cd1c | 5086 | [ALC885_MACPRO] = "macpro", |
f5fcc13c TI |
5087 | [ALC882_AUTO] = "auto", |
5088 | }; | |
5089 | ||
5090 | static struct snd_pci_quirk alc882_cfg_tbl[] = { | |
5091 | SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG), | |
5092 | SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG), | |
5093 | SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG), | |
5094 | SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), | |
7b9470d8 | 5095 | SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG), |
df694daa KY |
5096 | {} |
5097 | }; | |
5098 | ||
5099 | static struct alc_config_preset alc882_presets[] = { | |
5100 | [ALC882_3ST_DIG] = { | |
5101 | .mixers = { alc882_base_mixer }, | |
5102 | .init_verbs = { alc882_init_verbs }, | |
5103 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
5104 | .dac_nids = alc882_dac_nids, | |
5105 | .dig_out_nid = ALC882_DIGOUT_NID, | |
df694daa KY |
5106 | .dig_in_nid = ALC882_DIGIN_NID, |
5107 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | |
5108 | .channel_mode = alc882_ch_modes, | |
4e195a7b | 5109 | .need_dac_fix = 1, |
df694daa KY |
5110 | .input_mux = &alc882_capture_source, |
5111 | }, | |
5112 | [ALC882_6ST_DIG] = { | |
5113 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, | |
5114 | .init_verbs = { alc882_init_verbs }, | |
5115 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
5116 | .dac_nids = alc882_dac_nids, | |
5117 | .dig_out_nid = ALC882_DIGOUT_NID, | |
df694daa KY |
5118 | .dig_in_nid = ALC882_DIGIN_NID, |
5119 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), | |
5120 | .channel_mode = alc882_sixstack_modes, | |
5121 | .input_mux = &alc882_capture_source, | |
5122 | }, | |
4b146cb0 TI |
5123 | [ALC882_ARIMA] = { |
5124 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, | |
5125 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs }, | |
5126 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
5127 | .dac_nids = alc882_dac_nids, | |
5128 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), | |
5129 | .channel_mode = alc882_sixstack_modes, | |
5130 | .input_mux = &alc882_capture_source, | |
5131 | }, | |
9102cd1c TD |
5132 | [ALC885_MACPRO] = { |
5133 | .mixers = { alc882_macpro_mixer }, | |
5134 | .init_verbs = { alc882_macpro_init_verbs }, | |
5135 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
5136 | .dac_nids = alc882_dac_nids, | |
5137 | .dig_out_nid = ALC882_DIGOUT_NID, | |
5138 | .dig_in_nid = ALC882_DIGIN_NID, | |
5139 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | |
5140 | .channel_mode = alc882_ch_modes, | |
5141 | .input_mux = &alc882_capture_source, | |
5142 | }, | |
df694daa KY |
5143 | }; |
5144 | ||
5145 | ||
5146 | /* | |
5147 | * BIOS auto configuration | |
5148 | */ | |
5149 | static void alc882_auto_set_output_and_unmute(struct hda_codec *codec, | |
5150 | hda_nid_t nid, int pin_type, | |
5151 | int dac_idx) | |
5152 | { | |
5153 | /* set as output */ | |
5154 | struct alc_spec *spec = codec->spec; | |
f12ab1e0 TI |
5155 | int idx; |
5156 | ||
df694daa KY |
5157 | if (spec->multiout.dac_nids[dac_idx] == 0x25) |
5158 | idx = 4; | |
5159 | else | |
5160 | idx = spec->multiout.dac_nids[dac_idx] - 2; | |
5161 | ||
f12ab1e0 TI |
5162 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
5163 | pin_type); | |
5164 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
5165 | AMP_OUT_UNMUTE); | |
df694daa KY |
5166 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); |
5167 | ||
5168 | } | |
5169 | ||
5170 | static void alc882_auto_init_multi_out(struct hda_codec *codec) | |
5171 | { | |
5172 | struct alc_spec *spec = codec->spec; | |
5173 | int i; | |
5174 | ||
bc9f98a9 | 5175 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
df694daa | 5176 | for (i = 0; i <= HDA_SIDE; i++) { |
f12ab1e0 | 5177 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
baba8ee9 | 5178 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
df694daa | 5179 | if (nid) |
baba8ee9 | 5180 | alc882_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 5181 | i); |
df694daa KY |
5182 | } |
5183 | } | |
5184 | ||
5185 | static void alc882_auto_init_hp_out(struct hda_codec *codec) | |
5186 | { | |
5187 | struct alc_spec *spec = codec->spec; | |
5188 | hda_nid_t pin; | |
5189 | ||
eb06ed8f | 5190 | pin = spec->autocfg.hp_pins[0]; |
df694daa | 5191 | if (pin) /* connect to front */ |
f12ab1e0 TI |
5192 | /* use dac 0 */ |
5193 | alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
df694daa KY |
5194 | } |
5195 | ||
5196 | #define alc882_is_input_pin(nid) alc880_is_input_pin(nid) | |
5197 | #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID | |
5198 | ||
5199 | static void alc882_auto_init_analog_input(struct hda_codec *codec) | |
5200 | { | |
5201 | struct alc_spec *spec = codec->spec; | |
5202 | int i; | |
5203 | ||
5204 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
5205 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
5206 | if (alc882_is_input_pin(nid)) { | |
f12ab1e0 TI |
5207 | snd_hda_codec_write(codec, nid, 0, |
5208 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
5209 | i <= AUTO_PIN_FRONT_MIC ? | |
5210 | PIN_VREF80 : PIN_IN); | |
df694daa | 5211 | if (nid != ALC882_PIN_CD_NID) |
f12ab1e0 TI |
5212 | snd_hda_codec_write(codec, nid, 0, |
5213 | AC_VERB_SET_AMP_GAIN_MUTE, | |
df694daa KY |
5214 | AMP_OUT_MUTE); |
5215 | } | |
5216 | } | |
5217 | } | |
5218 | ||
5219 | /* almost identical with ALC880 parser... */ | |
5220 | static int alc882_parse_auto_config(struct hda_codec *codec) | |
5221 | { | |
5222 | struct alc_spec *spec = codec->spec; | |
5223 | int err = alc880_parse_auto_config(codec); | |
5224 | ||
5225 | if (err < 0) | |
5226 | return err; | |
c5f2ea08 TI |
5227 | else if (err > 0) |
5228 | /* hack - override the init verbs */ | |
5229 | spec->init_verbs[0] = alc882_auto_init_verbs; | |
5230 | return err; | |
df694daa KY |
5231 | } |
5232 | ||
ae6b813a TI |
5233 | /* additional initialization for auto-configuration model */ |
5234 | static void alc882_auto_init(struct hda_codec *codec) | |
df694daa | 5235 | { |
df694daa KY |
5236 | alc882_auto_init_multi_out(codec); |
5237 | alc882_auto_init_hp_out(codec); | |
5238 | alc882_auto_init_analog_input(codec); | |
df694daa KY |
5239 | } |
5240 | ||
df694daa KY |
5241 | static int patch_alc882(struct hda_codec *codec) |
5242 | { | |
5243 | struct alc_spec *spec; | |
5244 | int err, board_config; | |
5245 | ||
5246 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
5247 | if (spec == NULL) | |
5248 | return -ENOMEM; | |
5249 | ||
5250 | codec->spec = spec; | |
5251 | ||
f5fcc13c TI |
5252 | board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST, |
5253 | alc882_models, | |
5254 | alc882_cfg_tbl); | |
df694daa KY |
5255 | |
5256 | if (board_config < 0 || board_config >= ALC882_MODEL_LAST) { | |
081d17c4 TD |
5257 | /* Pick up systems that don't supply PCI SSID */ |
5258 | switch (codec->subsystem_id) { | |
5259 | case 0x106b0c00: /* Mac Pro */ | |
5260 | board_config = ALC885_MACPRO; | |
5261 | break; | |
5262 | default: | |
5263 | printk(KERN_INFO "hda_codec: Unknown model for ALC882, " | |
5264 | "trying auto-probe from BIOS...\n"); | |
5265 | board_config = ALC882_AUTO; | |
5266 | } | |
df694daa KY |
5267 | } |
5268 | ||
5269 | if (board_config == ALC882_AUTO) { | |
5270 | /* automatic parse from the BIOS config */ | |
5271 | err = alc882_parse_auto_config(codec); | |
5272 | if (err < 0) { | |
5273 | alc_free(codec); | |
5274 | return err; | |
f12ab1e0 | 5275 | } else if (!err) { |
9c7f852e TI |
5276 | printk(KERN_INFO |
5277 | "hda_codec: Cannot set up configuration " | |
5278 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
5279 | board_config = ALC882_3ST_DIG; |
5280 | } | |
5281 | } | |
5282 | ||
5283 | if (board_config != ALC882_AUTO) | |
5284 | setup_preset(spec, &alc882_presets[board_config]); | |
1da177e4 | 5285 | |
9102cd1c TD |
5286 | if (board_config == ALC885_MACPRO) { |
5287 | alc882_gpio_mute(codec, 0, 0); | |
5288 | alc882_gpio_mute(codec, 1, 0); | |
5289 | } | |
5290 | ||
1da177e4 | 5291 | spec->stream_name_analog = "ALC882 Analog"; |
df694daa KY |
5292 | spec->stream_analog_playback = &alc882_pcm_analog_playback; |
5293 | spec->stream_analog_capture = &alc882_pcm_analog_capture; | |
1da177e4 LT |
5294 | |
5295 | spec->stream_name_digital = "ALC882 Digital"; | |
df694daa KY |
5296 | spec->stream_digital_playback = &alc882_pcm_digital_playback; |
5297 | spec->stream_digital_capture = &alc882_pcm_digital_capture; | |
1da177e4 | 5298 | |
f12ab1e0 | 5299 | if (!spec->adc_nids && spec->input_mux) { |
df694daa | 5300 | /* check whether NID 0x07 is valid */ |
4a471b7d | 5301 | unsigned int wcap = get_wcaps(codec, 0x07); |
f12ab1e0 TI |
5302 | /* get type */ |
5303 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
df694daa KY |
5304 | if (wcap != AC_WID_AUD_IN) { |
5305 | spec->adc_nids = alc882_adc_nids_alt; | |
5306 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt); | |
f12ab1e0 TI |
5307 | spec->mixers[spec->num_mixers] = |
5308 | alc882_capture_alt_mixer; | |
df694daa KY |
5309 | spec->num_mixers++; |
5310 | } else { | |
5311 | spec->adc_nids = alc882_adc_nids; | |
5312 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids); | |
5313 | spec->mixers[spec->num_mixers] = alc882_capture_mixer; | |
5314 | spec->num_mixers++; | |
5315 | } | |
5316 | } | |
1da177e4 LT |
5317 | |
5318 | codec->patch_ops = alc_patch_ops; | |
df694daa | 5319 | if (board_config == ALC882_AUTO) |
ae6b813a | 5320 | spec->init_hook = alc882_auto_init; |
df694daa KY |
5321 | |
5322 | return 0; | |
5323 | } | |
5324 | ||
5325 | /* | |
9c7f852e TI |
5326 | * ALC883 support |
5327 | * | |
5328 | * ALC883 is almost identical with ALC880 but has cleaner and more flexible | |
5329 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
5330 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
5331 | * 6-channel independent captures. | |
5332 | * | |
5333 | * In addition, an independent DAC for the multi-playback (not used in this | |
5334 | * driver yet). | |
df694daa | 5335 | */ |
9c7f852e TI |
5336 | #define ALC883_DIGOUT_NID 0x06 |
5337 | #define ALC883_DIGIN_NID 0x0a | |
df694daa | 5338 | |
9c7f852e TI |
5339 | static hda_nid_t alc883_dac_nids[4] = { |
5340 | /* front, rear, clfe, rear_surr */ | |
5341 | 0x02, 0x04, 0x03, 0x05 | |
5342 | }; | |
df694daa | 5343 | |
9c7f852e TI |
5344 | static hda_nid_t alc883_adc_nids[2] = { |
5345 | /* ADC1-2 */ | |
5346 | 0x08, 0x09, | |
5347 | }; | |
f12ab1e0 | 5348 | |
9c7f852e TI |
5349 | /* input MUX */ |
5350 | /* FIXME: should be a matrix-type input source selection */ | |
df694daa | 5351 | |
9c7f852e TI |
5352 | static struct hda_input_mux alc883_capture_source = { |
5353 | .num_items = 4, | |
5354 | .items = { | |
5355 | { "Mic", 0x0 }, | |
5356 | { "Front Mic", 0x1 }, | |
5357 | { "Line", 0x2 }, | |
5358 | { "CD", 0x4 }, | |
5359 | }, | |
5360 | }; | |
bc9f98a9 KY |
5361 | |
5362 | static struct hda_input_mux alc883_lenovo_101e_capture_source = { | |
5363 | .num_items = 2, | |
5364 | .items = { | |
5365 | { "Mic", 0x1 }, | |
5366 | { "Line", 0x2 }, | |
5367 | }, | |
5368 | }; | |
5369 | ||
9c7f852e TI |
5370 | #define alc883_mux_enum_info alc_mux_enum_info |
5371 | #define alc883_mux_enum_get alc_mux_enum_get | |
df694daa | 5372 | |
9c7f852e TI |
5373 | static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol, |
5374 | struct snd_ctl_elem_value *ucontrol) | |
5375 | { | |
5376 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
5377 | struct alc_spec *spec = codec->spec; | |
5378 | const struct hda_input_mux *imux = spec->input_mux; | |
5379 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
5380 | static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 }; | |
5381 | hda_nid_t nid = capture_mixers[adc_idx]; | |
5382 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; | |
5383 | unsigned int i, idx; | |
5384 | ||
5385 | idx = ucontrol->value.enumerated.item[0]; | |
5386 | if (idx >= imux->num_items) | |
5387 | idx = imux->num_items - 1; | |
f12ab1e0 | 5388 | if (*cur_val == idx && !codec->in_resume) |
9c7f852e TI |
5389 | return 0; |
5390 | for (i = 0; i < imux->num_items; i++) { | |
5391 | unsigned int v = (i == idx) ? 0x7000 : 0x7080; | |
5392 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
5393 | v | (imux->items[i].index << 8)); | |
5394 | } | |
5395 | *cur_val = idx; | |
5396 | return 1; | |
5397 | } | |
f12ab1e0 | 5398 | |
9c7f852e TI |
5399 | /* |
5400 | * 2ch mode | |
5401 | */ | |
5402 | static struct hda_channel_mode alc883_3ST_2ch_modes[1] = { | |
5403 | { 2, NULL } | |
5404 | }; | |
5405 | ||
5406 | /* | |
5407 | * 2ch mode | |
5408 | */ | |
5409 | static struct hda_verb alc883_3ST_ch2_init[] = { | |
5410 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
5411 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
5412 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
5413 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
5414 | { } /* end */ | |
5415 | }; | |
5416 | ||
5417 | /* | |
5418 | * 6ch mode | |
5419 | */ | |
5420 | static struct hda_verb alc883_3ST_ch6_init[] = { | |
5421 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5422 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
5423 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
5424 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5425 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
5426 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
5427 | { } /* end */ | |
5428 | }; | |
5429 | ||
5430 | static struct hda_channel_mode alc883_3ST_6ch_modes[2] = { | |
5431 | { 2, alc883_3ST_ch2_init }, | |
5432 | { 6, alc883_3ST_ch6_init }, | |
5433 | }; | |
5434 | ||
5435 | /* | |
5436 | * 6ch mode | |
5437 | */ | |
5438 | static struct hda_verb alc883_sixstack_ch6_init[] = { | |
5439 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
5440 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5441 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5442 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5443 | { } /* end */ | |
5444 | }; | |
5445 | ||
5446 | /* | |
5447 | * 8ch mode | |
5448 | */ | |
5449 | static struct hda_verb alc883_sixstack_ch8_init[] = { | |
5450 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5451 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5452 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5453 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5454 | { } /* end */ | |
5455 | }; | |
5456 | ||
5457 | static struct hda_channel_mode alc883_sixstack_modes[2] = { | |
5458 | { 6, alc883_sixstack_ch6_init }, | |
5459 | { 8, alc883_sixstack_ch8_init }, | |
5460 | }; | |
5461 | ||
b373bdeb AN |
5462 | static struct hda_verb alc883_medion_eapd_verbs[] = { |
5463 | /* eanable EAPD on medion laptop */ | |
5464 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
5465 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
5466 | { } | |
5467 | }; | |
5468 | ||
9c7f852e TI |
5469 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
5470 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
5471 | */ | |
5472 | ||
5473 | static struct snd_kcontrol_new alc883_base_mixer[] = { | |
df694daa | 5474 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9c7f852e TI |
5475 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
5476 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
5477 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
5478 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
5479 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
5480 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
5481 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
5482 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
5483 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
5484 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
df694daa KY |
5485 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
5486 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5487 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5488 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5489 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 5490 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
df694daa | 5491 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
9c7f852e | 5492 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
32360416 | 5493 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
5494 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
5495 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
5496 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
5497 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
5498 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
5499 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
5500 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
5501 | { | |
5502 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5503 | /* .name = "Capture Source", */ | |
5504 | .name = "Input Source", | |
5505 | .count = 2, | |
5506 | .info = alc883_mux_enum_info, | |
5507 | .get = alc883_mux_enum_get, | |
5508 | .put = alc883_mux_enum_put, | |
5509 | }, | |
df694daa | 5510 | { } /* end */ |
834be88d TI |
5511 | }; |
5512 | ||
9c7f852e TI |
5513 | static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = { |
5514 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5515 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
5516 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
5517 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5518 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5519 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5520 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5521 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 5522 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
5523 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
5524 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 5525 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
5526 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
5527 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
5528 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
5529 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
5530 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
5531 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
5532 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
5533 | { | |
5534 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5535 | /* .name = "Capture Source", */ | |
5536 | .name = "Input Source", | |
5537 | .count = 2, | |
5538 | .info = alc883_mux_enum_info, | |
5539 | .get = alc883_mux_enum_get, | |
5540 | .put = alc883_mux_enum_put, | |
5541 | }, | |
5542 | { } /* end */ | |
5543 | }; | |
df694daa | 5544 | |
9c7f852e TI |
5545 | static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = { |
5546 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5547 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
5548 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
5549 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
5550 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
5551 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
5552 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
5553 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
5554 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
5555 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5556 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5557 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5558 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5559 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 5560 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
5561 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
5562 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 5563 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
5564 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
5565 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
5566 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
5567 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
5568 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
5569 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
5570 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
5571 | { | |
5572 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5573 | /* .name = "Capture Source", */ | |
5574 | .name = "Input Source", | |
5575 | .count = 2, | |
5576 | .info = alc883_mux_enum_info, | |
5577 | .get = alc883_mux_enum_get, | |
5578 | .put = alc883_mux_enum_put, | |
5579 | }, | |
5580 | { } /* end */ | |
5581 | }; | |
5582 | ||
d1d985f0 | 5583 | static struct snd_kcontrol_new alc883_fivestack_mixer[] = { |
c07584c8 TD |
5584 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
5585 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
5586 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
5587 | HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
5588 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
5589 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
5590 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT), | |
5591 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | |
5592 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
5593 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5594 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5595 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5596 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5597 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 5598 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
c07584c8 TD |
5599 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
5600 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 5601 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
c07584c8 TD |
5602 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
5603 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
5604 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
5605 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
5606 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
5607 | ||
5608 | { | |
5609 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5610 | /* .name = "Capture Source", */ | |
5611 | .name = "Input Source", | |
5612 | .count = 1, | |
5613 | .info = alc883_mux_enum_info, | |
5614 | .get = alc883_mux_enum_get, | |
5615 | .put = alc883_mux_enum_put, | |
5616 | }, | |
5617 | { } /* end */ | |
5618 | }; | |
5619 | ||
ccc656ce KY |
5620 | static struct snd_kcontrol_new alc883_tagra_mixer[] = { |
5621 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5622 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
5623 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
5624 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
5625 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
5626 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
5627 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
5628 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
5629 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
5630 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5631 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5632 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5633 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5634 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 5635 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce KY |
5636 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
5637 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
5638 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
5639 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
5640 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
5641 | { | |
5642 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5643 | /* .name = "Capture Source", */ | |
5644 | .name = "Input Source", | |
5645 | .count = 2, | |
5646 | .info = alc883_mux_enum_info, | |
5647 | .get = alc883_mux_enum_get, | |
5648 | .put = alc883_mux_enum_put, | |
5649 | }, | |
5650 | { } /* end */ | |
f12ab1e0 | 5651 | }; |
ccc656ce KY |
5652 | |
5653 | static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = { | |
5654 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5655 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
5656 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
5657 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5658 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5659 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 5660 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce KY |
5661 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
5662 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
5663 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
5664 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
5665 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
5666 | { | |
5667 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5668 | /* .name = "Capture Source", */ | |
5669 | .name = "Input Source", | |
5670 | .count = 2, | |
5671 | .info = alc883_mux_enum_info, | |
5672 | .get = alc883_mux_enum_get, | |
5673 | .put = alc883_mux_enum_put, | |
5674 | }, | |
5675 | { } /* end */ | |
f12ab1e0 | 5676 | }; |
ccc656ce | 5677 | |
bc9f98a9 KY |
5678 | static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = { |
5679 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5680 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
5681 | HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
5682 | HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
5683 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
5684 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
5685 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
5686 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
5687 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
5688 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
5689 | { | |
5690 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5691 | /* .name = "Capture Source", */ | |
5692 | .name = "Input Source", | |
5693 | .count = 1, | |
5694 | .info = alc883_mux_enum_info, | |
5695 | .get = alc883_mux_enum_get, | |
5696 | .put = alc883_mux_enum_put, | |
5697 | }, | |
5698 | { } /* end */ | |
f12ab1e0 | 5699 | }; |
bc9f98a9 | 5700 | |
9c7f852e TI |
5701 | static struct snd_kcontrol_new alc883_chmode_mixer[] = { |
5702 | { | |
5703 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5704 | .name = "Channel Mode", | |
5705 | .info = alc_ch_mode_info, | |
5706 | .get = alc_ch_mode_get, | |
5707 | .put = alc_ch_mode_put, | |
5708 | }, | |
5709 | { } /* end */ | |
5710 | }; | |
5711 | ||
5712 | static struct hda_verb alc883_init_verbs[] = { | |
5713 | /* ADC1: mute amp left and right */ | |
5714 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
df694daa | 5715 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
9c7f852e TI |
5716 | /* ADC2: mute amp left and right */ |
5717 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
df694daa | 5718 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
9c7f852e TI |
5719 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ |
5720 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5721 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5722 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5723 | /* Rear mixer */ | |
5724 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5725 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5726 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5727 | /* CLFE mixer */ | |
5728 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5729 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5730 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5731 | /* Side mixer */ | |
5732 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5733 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5734 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
df694daa | 5735 | |
df694daa KY |
5736 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
5737 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5738 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
5739 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
5740 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
5741 | ||
9c7f852e TI |
5742 | /* Front Pin: output 0 (0x0c) */ |
5743 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5744 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5745 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5746 | /* Rear Pin: output 1 (0x0d) */ | |
5747 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5748 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5749 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
5750 | /* CLFE Pin: output 2 (0x0e) */ | |
5751 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5752 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5753 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
5754 | /* Side Pin: output 3 (0x0f) */ | |
5755 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5756 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5757 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
5758 | /* Mic (rear) pin: input vref at 80% */ | |
5759 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
5760 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5761 | /* Front Mic pin: input vref at 80% */ | |
5762 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
5763 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5764 | /* Line In pin: input */ | |
5765 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
5766 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5767 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
5768 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5769 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5770 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5771 | /* CD pin widget for input */ | |
5772 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
5773 | ||
5774 | /* FIXME: use matrix-type input source selection */ | |
5775 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
5776 | /* Input mixer2 */ | |
5777 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5778 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5779 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
5780 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
5781 | /* Input mixer3 */ | |
5782 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5783 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5784 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
5785 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
5786 | { } | |
5787 | }; | |
5788 | ||
ccc656ce KY |
5789 | static struct hda_verb alc883_tagra_verbs[] = { |
5790 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5791 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5792 | ||
5793 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5794 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5795 | ||
5796 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
5797 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
5798 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
5799 | ||
5800 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
f12ab1e0 TI |
5801 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
5802 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | |
5803 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | |
ccc656ce KY |
5804 | |
5805 | { } /* end */ | |
5806 | }; | |
5807 | ||
bc9f98a9 KY |
5808 | static struct hda_verb alc883_lenovo_101e_verbs[] = { |
5809 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5810 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN}, | |
5811 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN}, | |
5812 | { } /* end */ | |
5813 | }; | |
5814 | ||
ccc656ce KY |
5815 | /* toggle speaker-output according to the hp-jack state */ |
5816 | static void alc883_tagra_automute(struct hda_codec *codec) | |
5817 | { | |
5818 | unsigned int present; | |
f12ab1e0 | 5819 | unsigned char bits; |
ccc656ce KY |
5820 | |
5821 | present = snd_hda_codec_read(codec, 0x14, 0, | |
5822 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
f12ab1e0 | 5823 | bits = present ? 0x80 : 0; |
ccc656ce | 5824 | snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0, |
f12ab1e0 | 5825 | 0x80, bits); |
ccc656ce | 5826 | snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0, |
f12ab1e0 TI |
5827 | 0x80, bits); |
5828 | snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, | |
5829 | present ? 1 : 3); | |
ccc656ce KY |
5830 | } |
5831 | ||
5832 | static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res) | |
5833 | { | |
5834 | if ((res >> 26) == ALC880_HP_EVENT) | |
5835 | alc883_tagra_automute(codec); | |
5836 | } | |
5837 | ||
bc9f98a9 KY |
5838 | static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec) |
5839 | { | |
5840 | unsigned int present; | |
f12ab1e0 | 5841 | unsigned char bits; |
bc9f98a9 KY |
5842 | |
5843 | present = snd_hda_codec_read(codec, 0x14, 0, | |
5844 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
f12ab1e0 | 5845 | bits = present ? 0x80 : 0; |
bc9f98a9 | 5846 | snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, |
f12ab1e0 | 5847 | 0x80, bits); |
bc9f98a9 | 5848 | snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, |
f12ab1e0 | 5849 | 0x80, bits); |
bc9f98a9 KY |
5850 | } |
5851 | ||
5852 | static void alc883_lenovo_101e_all_automute(struct hda_codec *codec) | |
5853 | { | |
5854 | unsigned int present; | |
f12ab1e0 | 5855 | unsigned char bits; |
bc9f98a9 KY |
5856 | |
5857 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
5858 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
f12ab1e0 | 5859 | bits = present ? 0x80 : 0; |
bc9f98a9 | 5860 | snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, |
f12ab1e0 | 5861 | 0x80, bits); |
bc9f98a9 | 5862 | snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, |
f12ab1e0 | 5863 | 0x80, bits); |
bc9f98a9 | 5864 | snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, |
f12ab1e0 | 5865 | 0x80, bits); |
bc9f98a9 | 5866 | snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, |
f12ab1e0 | 5867 | 0x80, bits); |
bc9f98a9 KY |
5868 | } |
5869 | ||
5870 | static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec, | |
5871 | unsigned int res) | |
5872 | { | |
5873 | if ((res >> 26) == ALC880_HP_EVENT) | |
5874 | alc883_lenovo_101e_all_automute(codec); | |
5875 | if ((res >> 26) == ALC880_FRONT_EVENT) | |
5876 | alc883_lenovo_101e_ispeaker_automute(codec); | |
5877 | } | |
5878 | ||
9c7f852e TI |
5879 | /* |
5880 | * generic initialization of ADC, input mixers and output mixers | |
5881 | */ | |
5882 | static struct hda_verb alc883_auto_init_verbs[] = { | |
5883 | /* | |
5884 | * Unmute ADC0-2 and set the default input to mic-in | |
5885 | */ | |
5886 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5887 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5888 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5889 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5890 | ||
5891 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | |
5892 | * mixer widget | |
f12ab1e0 TI |
5893 | * Note: PASD motherboards uses the Line In 2 as the input for |
5894 | * front panel mic (mic 2) | |
9c7f852e TI |
5895 | */ |
5896 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
5897 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5898 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5899 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
5900 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
5901 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
5902 | ||
5903 | /* | |
5904 | * Set up output mixers (0x0c - 0x0f) | |
5905 | */ | |
5906 | /* set vol=0 to output mixers */ | |
5907 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5908 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5909 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5910 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5911 | /* set up input amps for analog loopback */ | |
5912 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
5913 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5914 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5915 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5916 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5917 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5918 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5919 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5920 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5921 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5922 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5923 | ||
5924 | /* FIXME: use matrix-type input source selection */ | |
5925 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
5926 | /* Input mixer1 */ | |
5927 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5928 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5929 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 5930 | /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */ |
9c7f852e TI |
5931 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
5932 | /* Input mixer2 */ | |
5933 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5934 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5935 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 5936 | /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */ |
9c7f852e TI |
5937 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
5938 | ||
5939 | { } | |
5940 | }; | |
5941 | ||
5942 | /* capture mixer elements */ | |
5943 | static struct snd_kcontrol_new alc883_capture_mixer[] = { | |
5944 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
5945 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
5946 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
5947 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
5948 | { | |
5949 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5950 | /* The multiple "Capture Source" controls confuse alsamixer | |
5951 | * So call somewhat different.. | |
5952 | * FIXME: the controls appear in the "playback" view! | |
5953 | */ | |
5954 | /* .name = "Capture Source", */ | |
5955 | .name = "Input Source", | |
5956 | .count = 2, | |
5957 | .info = alc882_mux_enum_info, | |
5958 | .get = alc882_mux_enum_get, | |
5959 | .put = alc882_mux_enum_put, | |
5960 | }, | |
5961 | { } /* end */ | |
5962 | }; | |
5963 | ||
5964 | /* pcm configuration: identiacal with ALC880 */ | |
5965 | #define alc883_pcm_analog_playback alc880_pcm_analog_playback | |
5966 | #define alc883_pcm_analog_capture alc880_pcm_analog_capture | |
5967 | #define alc883_pcm_digital_playback alc880_pcm_digital_playback | |
5968 | #define alc883_pcm_digital_capture alc880_pcm_digital_capture | |
5969 | ||
5970 | /* | |
5971 | * configuration and preset | |
5972 | */ | |
f5fcc13c TI |
5973 | static const char *alc883_models[ALC883_MODEL_LAST] = { |
5974 | [ALC883_3ST_2ch_DIG] = "3stack-dig", | |
5975 | [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig", | |
5976 | [ALC883_3ST_6ch] = "3stack-6ch", | |
5977 | [ALC883_6ST_DIG] = "6stack-dig", | |
5978 | [ALC883_TARGA_DIG] = "targa-dig", | |
5979 | [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig", | |
5980 | [ALC888_DEMO_BOARD] = "6stack-dig-demo", | |
5981 | [ALC883_ACER] = "acer", | |
5982 | [ALC883_MEDION] = "medion", | |
5983 | [ALC883_LAPTOP_EAPD] = "laptop-eapd", | |
bc9f98a9 | 5984 | [ALC883_LENOVO_101E_2ch] = "lenovo-101e", |
f5fcc13c TI |
5985 | [ALC883_AUTO] = "auto", |
5986 | }; | |
5987 | ||
5988 | static struct snd_pci_quirk alc883_cfg_tbl[] = { | |
5989 | SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG), | |
5990 | SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch), | |
5991 | SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD), | |
5992 | SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG), | |
57b14f24 | 5993 | SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG), |
f5fcc13c TI |
5994 | SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG), |
5995 | SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG), | |
2a296cb6 | 5996 | SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG), |
f5fcc13c TI |
5997 | SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG), |
5998 | SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG), | |
5999 | SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG), | |
6000 | SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG), | |
6001 | SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG), | |
6002 | SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG), | |
6003 | SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG), | |
6004 | SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG), | |
6005 | SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG), | |
6006 | SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG), | |
6007 | SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), | |
6008 | SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), | |
6009 | SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD), | |
6010 | SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), | |
bc9f98a9 | 6011 | SND_PCI_QUIRK(0x17aa, 0x101e, "lenovo 101e", ALC883_LENOVO_101E_2ch), |
9c7f852e TI |
6012 | {} |
6013 | }; | |
6014 | ||
6015 | static struct alc_config_preset alc883_presets[] = { | |
6016 | [ALC883_3ST_2ch_DIG] = { | |
6017 | .mixers = { alc883_3ST_2ch_mixer }, | |
6018 | .init_verbs = { alc883_init_verbs }, | |
6019 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
6020 | .dac_nids = alc883_dac_nids, | |
6021 | .dig_out_nid = ALC883_DIGOUT_NID, | |
6022 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
6023 | .adc_nids = alc883_adc_nids, | |
6024 | .dig_in_nid = ALC883_DIGIN_NID, | |
6025 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
6026 | .channel_mode = alc883_3ST_2ch_modes, | |
6027 | .input_mux = &alc883_capture_source, | |
6028 | }, | |
6029 | [ALC883_3ST_6ch_DIG] = { | |
6030 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
6031 | .init_verbs = { alc883_init_verbs }, | |
6032 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
6033 | .dac_nids = alc883_dac_nids, | |
6034 | .dig_out_nid = ALC883_DIGOUT_NID, | |
6035 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
6036 | .adc_nids = alc883_adc_nids, | |
6037 | .dig_in_nid = ALC883_DIGIN_NID, | |
6038 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
6039 | .channel_mode = alc883_3ST_6ch_modes, | |
4e195a7b | 6040 | .need_dac_fix = 1, |
9c7f852e | 6041 | .input_mux = &alc883_capture_source, |
f12ab1e0 | 6042 | }, |
9c7f852e TI |
6043 | [ALC883_3ST_6ch] = { |
6044 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
6045 | .init_verbs = { alc883_init_verbs }, | |
6046 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
6047 | .dac_nids = alc883_dac_nids, | |
6048 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
6049 | .adc_nids = alc883_adc_nids, | |
6050 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
6051 | .channel_mode = alc883_3ST_6ch_modes, | |
4e195a7b | 6052 | .need_dac_fix = 1, |
9c7f852e | 6053 | .input_mux = &alc883_capture_source, |
f12ab1e0 | 6054 | }, |
9c7f852e TI |
6055 | [ALC883_6ST_DIG] = { |
6056 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, | |
6057 | .init_verbs = { alc883_init_verbs }, | |
6058 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
6059 | .dac_nids = alc883_dac_nids, | |
6060 | .dig_out_nid = ALC883_DIGOUT_NID, | |
6061 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
6062 | .adc_nids = alc883_adc_nids, | |
6063 | .dig_in_nid = ALC883_DIGIN_NID, | |
6064 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | |
6065 | .channel_mode = alc883_sixstack_modes, | |
6066 | .input_mux = &alc883_capture_source, | |
6067 | }, | |
ccc656ce KY |
6068 | [ALC883_TARGA_DIG] = { |
6069 | .mixers = { alc883_tagra_mixer, alc883_chmode_mixer }, | |
6070 | .init_verbs = { alc883_init_verbs, alc883_tagra_verbs}, | |
6071 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
6072 | .dac_nids = alc883_dac_nids, | |
6073 | .dig_out_nid = ALC883_DIGOUT_NID, | |
6074 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
6075 | .adc_nids = alc883_adc_nids, | |
6076 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
6077 | .channel_mode = alc883_3ST_6ch_modes, | |
6078 | .need_dac_fix = 1, | |
6079 | .input_mux = &alc883_capture_source, | |
6080 | .unsol_event = alc883_tagra_unsol_event, | |
6081 | .init_hook = alc883_tagra_automute, | |
6082 | }, | |
6083 | [ALC883_TARGA_2ch_DIG] = { | |
6084 | .mixers = { alc883_tagra_2ch_mixer}, | |
6085 | .init_verbs = { alc883_init_verbs, alc883_tagra_verbs}, | |
6086 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
6087 | .dac_nids = alc883_dac_nids, | |
6088 | .dig_out_nid = ALC883_DIGOUT_NID, | |
6089 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
6090 | .adc_nids = alc883_adc_nids, | |
6091 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
6092 | .channel_mode = alc883_3ST_2ch_modes, | |
6093 | .input_mux = &alc883_capture_source, | |
6094 | .unsol_event = alc883_tagra_unsol_event, | |
6095 | .init_hook = alc883_tagra_automute, | |
6096 | }, | |
9c7f852e TI |
6097 | [ALC888_DEMO_BOARD] = { |
6098 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, | |
6099 | .init_verbs = { alc883_init_verbs }, | |
6100 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
6101 | .dac_nids = alc883_dac_nids, | |
6102 | .dig_out_nid = ALC883_DIGOUT_NID, | |
6103 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
6104 | .adc_nids = alc883_adc_nids, | |
6105 | .dig_in_nid = ALC883_DIGIN_NID, | |
6106 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | |
6107 | .channel_mode = alc883_sixstack_modes, | |
6108 | .input_mux = &alc883_capture_source, | |
6109 | }, | |
bab282b9 VA |
6110 | [ALC883_ACER] = { |
6111 | .mixers = { alc883_base_mixer, | |
6112 | alc883_chmode_mixer }, | |
6113 | /* On TravelMate laptops, GPIO 0 enables the internal speaker | |
6114 | * and the headphone jack. Turn this on and rely on the | |
6115 | * standard mute methods whenever the user wants to turn | |
6116 | * these outputs off. | |
6117 | */ | |
6118 | .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs }, | |
6119 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
6120 | .dac_nids = alc883_dac_nids, | |
6121 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
6122 | .adc_nids = alc883_adc_nids, | |
6123 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
6124 | .channel_mode = alc883_3ST_2ch_modes, | |
6125 | .input_mux = &alc883_capture_source, | |
6126 | }, | |
c07584c8 TD |
6127 | [ALC883_MEDION] = { |
6128 | .mixers = { alc883_fivestack_mixer, | |
6129 | alc883_chmode_mixer }, | |
6130 | .init_verbs = { alc883_init_verbs, | |
b373bdeb | 6131 | alc883_medion_eapd_verbs }, |
c07584c8 TD |
6132 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
6133 | .dac_nids = alc883_dac_nids, | |
6134 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
6135 | .adc_nids = alc883_adc_nids, | |
6136 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | |
6137 | .channel_mode = alc883_sixstack_modes, | |
6138 | .input_mux = &alc883_capture_source, | |
b373bdeb AN |
6139 | }, |
6140 | [ALC883_LAPTOP_EAPD] = { | |
6141 | .mixers = { alc883_base_mixer, | |
6142 | alc883_chmode_mixer }, | |
6143 | .init_verbs = { alc883_init_verbs, alc882_eapd_verbs }, | |
6144 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
6145 | .dac_nids = alc883_dac_nids, | |
6146 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
6147 | .adc_nids = alc883_adc_nids, | |
6148 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
6149 | .channel_mode = alc883_3ST_2ch_modes, | |
6150 | .input_mux = &alc883_capture_source, | |
6151 | }, | |
bc9f98a9 KY |
6152 | [ALC883_LENOVO_101E_2ch] = { |
6153 | .mixers = { alc883_lenovo_101e_2ch_mixer}, | |
6154 | .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs}, | |
6155 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
6156 | .dac_nids = alc883_dac_nids, | |
6157 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
6158 | .adc_nids = alc883_adc_nids, | |
6159 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
6160 | .channel_mode = alc883_3ST_2ch_modes, | |
6161 | .input_mux = &alc883_lenovo_101e_capture_source, | |
6162 | .unsol_event = alc883_lenovo_101e_unsol_event, | |
6163 | .init_hook = alc883_lenovo_101e_all_automute, | |
6164 | }, | |
9c7f852e TI |
6165 | }; |
6166 | ||
6167 | ||
6168 | /* | |
6169 | * BIOS auto configuration | |
6170 | */ | |
6171 | static void alc883_auto_set_output_and_unmute(struct hda_codec *codec, | |
6172 | hda_nid_t nid, int pin_type, | |
6173 | int dac_idx) | |
6174 | { | |
6175 | /* set as output */ | |
6176 | struct alc_spec *spec = codec->spec; | |
f12ab1e0 TI |
6177 | int idx; |
6178 | ||
9c7f852e TI |
6179 | if (spec->multiout.dac_nids[dac_idx] == 0x25) |
6180 | idx = 4; | |
6181 | else | |
6182 | idx = spec->multiout.dac_nids[dac_idx] - 2; | |
6183 | ||
6184 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
6185 | pin_type); | |
6186 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
6187 | AMP_OUT_UNMUTE); | |
6188 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); | |
6189 | ||
6190 | } | |
6191 | ||
6192 | static void alc883_auto_init_multi_out(struct hda_codec *codec) | |
6193 | { | |
6194 | struct alc_spec *spec = codec->spec; | |
6195 | int i; | |
6196 | ||
bc9f98a9 | 6197 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
9c7f852e | 6198 | for (i = 0; i <= HDA_SIDE; i++) { |
f12ab1e0 | 6199 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
baba8ee9 | 6200 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
9c7f852e | 6201 | if (nid) |
baba8ee9 | 6202 | alc883_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 6203 | i); |
9c7f852e TI |
6204 | } |
6205 | } | |
6206 | ||
6207 | static void alc883_auto_init_hp_out(struct hda_codec *codec) | |
6208 | { | |
6209 | struct alc_spec *spec = codec->spec; | |
6210 | hda_nid_t pin; | |
6211 | ||
eb06ed8f | 6212 | pin = spec->autocfg.hp_pins[0]; |
9c7f852e TI |
6213 | if (pin) /* connect to front */ |
6214 | /* use dac 0 */ | |
6215 | alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
6216 | } | |
6217 | ||
6218 | #define alc883_is_input_pin(nid) alc880_is_input_pin(nid) | |
6219 | #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID | |
6220 | ||
6221 | static void alc883_auto_init_analog_input(struct hda_codec *codec) | |
6222 | { | |
6223 | struct alc_spec *spec = codec->spec; | |
6224 | int i; | |
6225 | ||
6226 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
6227 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
6228 | if (alc883_is_input_pin(nid)) { | |
6229 | snd_hda_codec_write(codec, nid, 0, | |
6230 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
6231 | (i <= AUTO_PIN_FRONT_MIC ? | |
6232 | PIN_VREF80 : PIN_IN)); | |
6233 | if (nid != ALC883_PIN_CD_NID) | |
6234 | snd_hda_codec_write(codec, nid, 0, | |
6235 | AC_VERB_SET_AMP_GAIN_MUTE, | |
6236 | AMP_OUT_MUTE); | |
6237 | } | |
6238 | } | |
6239 | } | |
6240 | ||
6241 | /* almost identical with ALC880 parser... */ | |
6242 | static int alc883_parse_auto_config(struct hda_codec *codec) | |
6243 | { | |
6244 | struct alc_spec *spec = codec->spec; | |
6245 | int err = alc880_parse_auto_config(codec); | |
6246 | ||
6247 | if (err < 0) | |
6248 | return err; | |
6249 | else if (err > 0) | |
6250 | /* hack - override the init verbs */ | |
6251 | spec->init_verbs[0] = alc883_auto_init_verbs; | |
bc9f98a9 KY |
6252 | spec->mixers[spec->num_mixers] = alc883_capture_mixer; |
6253 | spec->num_mixers++; | |
9c7f852e TI |
6254 | return err; |
6255 | } | |
6256 | ||
6257 | /* additional initialization for auto-configuration model */ | |
6258 | static void alc883_auto_init(struct hda_codec *codec) | |
6259 | { | |
6260 | alc883_auto_init_multi_out(codec); | |
6261 | alc883_auto_init_hp_out(codec); | |
6262 | alc883_auto_init_analog_input(codec); | |
6263 | } | |
6264 | ||
6265 | static int patch_alc883(struct hda_codec *codec) | |
6266 | { | |
6267 | struct alc_spec *spec; | |
6268 | int err, board_config; | |
6269 | ||
6270 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
6271 | if (spec == NULL) | |
6272 | return -ENOMEM; | |
6273 | ||
6274 | codec->spec = spec; | |
6275 | ||
f5fcc13c TI |
6276 | board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST, |
6277 | alc883_models, | |
6278 | alc883_cfg_tbl); | |
6279 | if (board_config < 0) { | |
9c7f852e TI |
6280 | printk(KERN_INFO "hda_codec: Unknown model for ALC883, " |
6281 | "trying auto-probe from BIOS...\n"); | |
6282 | board_config = ALC883_AUTO; | |
6283 | } | |
6284 | ||
6285 | if (board_config == ALC883_AUTO) { | |
6286 | /* automatic parse from the BIOS config */ | |
6287 | err = alc883_parse_auto_config(codec); | |
6288 | if (err < 0) { | |
6289 | alc_free(codec); | |
6290 | return err; | |
f12ab1e0 | 6291 | } else if (!err) { |
9c7f852e TI |
6292 | printk(KERN_INFO |
6293 | "hda_codec: Cannot set up configuration " | |
6294 | "from BIOS. Using base mode...\n"); | |
6295 | board_config = ALC883_3ST_2ch_DIG; | |
6296 | } | |
6297 | } | |
6298 | ||
6299 | if (board_config != ALC883_AUTO) | |
6300 | setup_preset(spec, &alc883_presets[board_config]); | |
6301 | ||
6302 | spec->stream_name_analog = "ALC883 Analog"; | |
6303 | spec->stream_analog_playback = &alc883_pcm_analog_playback; | |
6304 | spec->stream_analog_capture = &alc883_pcm_analog_capture; | |
6305 | ||
6306 | spec->stream_name_digital = "ALC883 Digital"; | |
6307 | spec->stream_digital_playback = &alc883_pcm_digital_playback; | |
6308 | spec->stream_digital_capture = &alc883_pcm_digital_capture; | |
6309 | ||
f12ab1e0 | 6310 | if (!spec->adc_nids && spec->input_mux) { |
4b146cb0 TI |
6311 | spec->adc_nids = alc883_adc_nids; |
6312 | spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); | |
6313 | } | |
9c7f852e TI |
6314 | |
6315 | codec->patch_ops = alc_patch_ops; | |
6316 | if (board_config == ALC883_AUTO) | |
6317 | spec->init_hook = alc883_auto_init; | |
6318 | ||
6319 | return 0; | |
6320 | } | |
6321 | ||
6322 | /* | |
6323 | * ALC262 support | |
6324 | */ | |
6325 | ||
6326 | #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID | |
6327 | #define ALC262_DIGIN_NID ALC880_DIGIN_NID | |
6328 | ||
6329 | #define alc262_dac_nids alc260_dac_nids | |
6330 | #define alc262_adc_nids alc882_adc_nids | |
6331 | #define alc262_adc_nids_alt alc882_adc_nids_alt | |
6332 | ||
6333 | #define alc262_modes alc260_modes | |
6334 | #define alc262_capture_source alc882_capture_source | |
6335 | ||
6336 | static struct snd_kcontrol_new alc262_base_mixer[] = { | |
6337 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6338 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
6339 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6340 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6341 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6342 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6343 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6344 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 6345 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
6346 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
6347 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 6348 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
6349 | /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), |
6350 | HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */ | |
6351 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT), | |
6352 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
6353 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
6354 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | |
6355 | { } /* end */ | |
6356 | }; | |
6357 | ||
ccc656ce KY |
6358 | static struct snd_kcontrol_new alc262_hippo1_mixer[] = { |
6359 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6360 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
6361 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6362 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6363 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6364 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6365 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6366 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 6367 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce KY |
6368 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
6369 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 6370 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
ccc656ce KY |
6371 | /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), |
6372 | HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */ | |
6373 | /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/ | |
6374 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6375 | { } /* end */ | |
6376 | }; | |
6377 | ||
9c7f852e TI |
6378 | static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = { |
6379 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6380 | HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
6381 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6382 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
6383 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | |
6384 | ||
6385 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6386 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 6387 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
6388 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
6389 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 6390 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
6391 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
6392 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6393 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6394 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6395 | HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
6396 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
6397 | HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT), | |
6398 | HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT), | |
6399 | { } /* end */ | |
6400 | }; | |
6401 | ||
cd7509a4 KY |
6402 | static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = { |
6403 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6404 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6405 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
6406 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
6407 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
6408 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | |
6409 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6410 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
cc69d12d | 6411 | HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT), |
cd7509a4 KY |
6412 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), |
6413 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
6414 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6415 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6416 | HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
6417 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
6418 | { } /* end */ | |
6419 | }; | |
6420 | ||
6421 | static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = { | |
6422 | HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6423 | HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 6424 | HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT), |
cd7509a4 KY |
6425 | { } /* end */ |
6426 | }; | |
6427 | ||
9c7f852e TI |
6428 | #define alc262_capture_mixer alc882_capture_mixer |
6429 | #define alc262_capture_alt_mixer alc882_capture_alt_mixer | |
6430 | ||
6431 | /* | |
6432 | * generic initialization of ADC, input mixers and output mixers | |
6433 | */ | |
6434 | static struct hda_verb alc262_init_verbs[] = { | |
6435 | /* | |
6436 | * Unmute ADC0-2 and set the default input to mic-in | |
6437 | */ | |
6438 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6439 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6440 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6441 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6442 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6443 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6444 | ||
6445 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | |
6446 | * mixer widget | |
f12ab1e0 TI |
6447 | * Note: PASD motherboards uses the Line In 2 as the input for |
6448 | * front panel mic (mic 2) | |
9c7f852e TI |
6449 | */ |
6450 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
6451 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6452 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6453 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
6454 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
6455 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
6456 | ||
6457 | /* | |
df694daa KY |
6458 | * Set up output mixers (0x0c - 0x0e) |
6459 | */ | |
6460 | /* set vol=0 to output mixers */ | |
6461 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6462 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6463 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6464 | /* set up input amps for analog loopback */ | |
6465 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
6466 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6467 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6468 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6469 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6470 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6471 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6472 | ||
6473 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
6474 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
6475 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
6476 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
6477 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
6478 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
6479 | ||
6480 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
6481 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
6482 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
6483 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
6484 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
6485 | ||
6486 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6487 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
6488 | ||
6489 | /* FIXME: use matrix-type input source selection */ | |
6490 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
6491 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
6492 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
6493 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
6494 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
6495 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
6496 | /* Input mixer2 */ | |
6497 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
6498 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
6499 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
6500 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
6501 | /* Input mixer3 */ | |
6502 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
6503 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
6504 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
f12ab1e0 | 6505 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
df694daa KY |
6506 | |
6507 | { } | |
6508 | }; | |
1da177e4 | 6509 | |
ccc656ce KY |
6510 | static struct hda_verb alc262_hippo_unsol_verbs[] = { |
6511 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
6512 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6513 | {} | |
6514 | }; | |
6515 | ||
6516 | static struct hda_verb alc262_hippo1_unsol_verbs[] = { | |
6517 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
6518 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6519 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
6520 | ||
6521 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
6522 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6523 | {} | |
6524 | }; | |
6525 | ||
6526 | /* mute/unmute internal speaker according to the hp jack and mute state */ | |
6527 | static void alc262_hippo_automute(struct hda_codec *codec, int force) | |
6528 | { | |
6529 | struct alc_spec *spec = codec->spec; | |
6530 | unsigned int mute; | |
6531 | ||
f12ab1e0 | 6532 | if (force || !spec->sense_updated) { |
ccc656ce KY |
6533 | unsigned int present; |
6534 | /* need to execute and sync at first */ | |
6535 | snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); | |
6536 | present = snd_hda_codec_read(codec, 0x15, 0, | |
6537 | AC_VERB_GET_PIN_SENSE, 0); | |
6538 | spec->jack_present = (present & 0x80000000) != 0; | |
6539 | spec->sense_updated = 1; | |
6540 | } | |
6541 | if (spec->jack_present) { | |
6542 | /* mute internal speaker */ | |
6543 | snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, | |
6544 | 0x80, 0x80); | |
6545 | snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, | |
6546 | 0x80, 0x80); | |
6547 | } else { | |
6548 | /* unmute internal speaker if necessary */ | |
6549 | mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0); | |
6550 | snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, | |
6551 | 0x80, mute & 0x80); | |
6552 | mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0); | |
6553 | snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, | |
6554 | 0x80, mute & 0x80); | |
6555 | } | |
6556 | } | |
6557 | ||
6558 | /* unsolicited event for HP jack sensing */ | |
6559 | static void alc262_hippo_unsol_event(struct hda_codec *codec, | |
6560 | unsigned int res) | |
6561 | { | |
6562 | if ((res >> 26) != ALC880_HP_EVENT) | |
6563 | return; | |
6564 | alc262_hippo_automute(codec, 1); | |
6565 | } | |
6566 | ||
6567 | static void alc262_hippo1_automute(struct hda_codec *codec, int force) | |
6568 | { | |
6569 | struct alc_spec *spec = codec->spec; | |
6570 | unsigned int mute; | |
6571 | ||
f12ab1e0 | 6572 | if (force || !spec->sense_updated) { |
ccc656ce KY |
6573 | unsigned int present; |
6574 | /* need to execute and sync at first */ | |
6575 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); | |
6576 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
6577 | AC_VERB_GET_PIN_SENSE, 0); | |
6578 | spec->jack_present = (present & 0x80000000) != 0; | |
6579 | spec->sense_updated = 1; | |
6580 | } | |
6581 | if (spec->jack_present) { | |
6582 | /* mute internal speaker */ | |
6583 | snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, | |
6584 | 0x80, 0x80); | |
6585 | snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, | |
6586 | 0x80, 0x80); | |
6587 | } else { | |
6588 | /* unmute internal speaker if necessary */ | |
6589 | mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); | |
6590 | snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, | |
6591 | 0x80, mute & 0x80); | |
6592 | mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0); | |
6593 | snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, | |
6594 | 0x80, mute & 0x80); | |
6595 | } | |
6596 | } | |
6597 | ||
6598 | /* unsolicited event for HP jack sensing */ | |
6599 | static void alc262_hippo1_unsol_event(struct hda_codec *codec, | |
6600 | unsigned int res) | |
6601 | { | |
6602 | if ((res >> 26) != ALC880_HP_EVENT) | |
6603 | return; | |
6604 | alc262_hippo1_automute(codec, 1); | |
6605 | } | |
6606 | ||
834be88d TI |
6607 | /* |
6608 | * fujitsu model | |
6609 | * 0x14 = headphone/spdif-out, 0x15 = internal speaker | |
6610 | */ | |
6611 | ||
6612 | #define ALC_HP_EVENT 0x37 | |
6613 | ||
6614 | static struct hda_verb alc262_fujitsu_unsol_verbs[] = { | |
6615 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, | |
6616 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6617 | {} | |
6618 | }; | |
6619 | ||
6620 | static struct hda_input_mux alc262_fujitsu_capture_source = { | |
6621 | .num_items = 2, | |
6622 | .items = { | |
6623 | { "Mic", 0x0 }, | |
6624 | { "CD", 0x4 }, | |
6625 | }, | |
6626 | }; | |
6627 | ||
9c7f852e TI |
6628 | static struct hda_input_mux alc262_HP_capture_source = { |
6629 | .num_items = 5, | |
6630 | .items = { | |
6631 | { "Mic", 0x0 }, | |
6632 | { "Front Mic", 0x3 }, | |
6633 | { "Line", 0x2 }, | |
6634 | { "CD", 0x4 }, | |
6635 | { "AUX IN", 0x6 }, | |
6636 | }, | |
6637 | }; | |
6638 | ||
834be88d TI |
6639 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
6640 | static void alc262_fujitsu_automute(struct hda_codec *codec, int force) | |
6641 | { | |
6642 | struct alc_spec *spec = codec->spec; | |
6643 | unsigned int mute; | |
6644 | ||
f12ab1e0 | 6645 | if (force || !spec->sense_updated) { |
834be88d TI |
6646 | unsigned int present; |
6647 | /* need to execute and sync at first */ | |
6648 | snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); | |
6649 | present = snd_hda_codec_read(codec, 0x14, 0, | |
6650 | AC_VERB_GET_PIN_SENSE, 0); | |
6651 | spec->jack_present = (present & 0x80000000) != 0; | |
6652 | spec->sense_updated = 1; | |
6653 | } | |
6654 | if (spec->jack_present) { | |
6655 | /* mute internal speaker */ | |
6656 | snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, | |
6657 | 0x80, 0x80); | |
6658 | snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, | |
6659 | 0x80, 0x80); | |
6660 | } else { | |
6661 | /* unmute internal speaker if necessary */ | |
6662 | mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); | |
6663 | snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, | |
6664 | 0x80, mute & 0x80); | |
6665 | mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0); | |
6666 | snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, | |
6667 | 0x80, mute & 0x80); | |
6668 | } | |
6669 | } | |
6670 | ||
6671 | /* unsolicited event for HP jack sensing */ | |
6672 | static void alc262_fujitsu_unsol_event(struct hda_codec *codec, | |
6673 | unsigned int res) | |
6674 | { | |
6675 | if ((res >> 26) != ALC_HP_EVENT) | |
6676 | return; | |
6677 | alc262_fujitsu_automute(codec, 1); | |
6678 | } | |
6679 | ||
6680 | /* bind volumes of both NID 0x0c and 0x0d */ | |
6681 | static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol, | |
6682 | struct snd_ctl_elem_value *ucontrol) | |
6683 | { | |
6684 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
6685 | long *valp = ucontrol->value.integer.value; | |
6686 | int change; | |
6687 | ||
6688 | change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0, | |
6689 | 0x7f, valp[0] & 0x7f); | |
6690 | change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0, | |
6691 | 0x7f, valp[1] & 0x7f); | |
6692 | snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0, | |
6693 | 0x7f, valp[0] & 0x7f); | |
6694 | snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0, | |
6695 | 0x7f, valp[1] & 0x7f); | |
6696 | return change; | |
6697 | } | |
6698 | ||
6699 | /* bind hp and internal speaker mute (with plug check) */ | |
6700 | static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol, | |
6701 | struct snd_ctl_elem_value *ucontrol) | |
6702 | { | |
6703 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
6704 | long *valp = ucontrol->value.integer.value; | |
6705 | int change; | |
6706 | ||
6707 | change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, | |
6708 | 0x80, valp[0] ? 0 : 0x80); | |
6709 | change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, | |
6710 | 0x80, valp[1] ? 0 : 0x80); | |
6711 | if (change || codec->in_resume) | |
6712 | alc262_fujitsu_automute(codec, codec->in_resume); | |
6713 | return change; | |
6714 | } | |
6715 | ||
6716 | static struct snd_kcontrol_new alc262_fujitsu_mixer[] = { | |
6717 | { | |
6718 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6719 | .name = "Master Playback Volume", | |
6720 | .info = snd_hda_mixer_amp_volume_info, | |
6721 | .get = snd_hda_mixer_amp_volume_get, | |
6722 | .put = alc262_fujitsu_master_vol_put, | |
c2566524 | 6723 | .tlv = { .c = snd_hda_mixer_amp_tlv }, |
834be88d TI |
6724 | .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT), |
6725 | }, | |
6726 | { | |
6727 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6728 | .name = "Master Playback Switch", | |
6729 | .info = snd_hda_mixer_amp_switch_info, | |
6730 | .get = snd_hda_mixer_amp_switch_get, | |
6731 | .put = alc262_fujitsu_master_sw_put, | |
6732 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
6733 | }, | |
6734 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6735 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6736 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
6737 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6738 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
6739 | { } /* end */ | |
6740 | }; | |
6741 | ||
304dcaac TI |
6742 | /* additional init verbs for Benq laptops */ |
6743 | static struct hda_verb alc262_EAPD_verbs[] = { | |
6744 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
6745 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
6746 | {} | |
6747 | }; | |
6748 | ||
df694daa | 6749 | /* add playback controls from the parsed DAC table */ |
f12ab1e0 TI |
6750 | static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, |
6751 | const struct auto_pin_cfg *cfg) | |
df694daa KY |
6752 | { |
6753 | hda_nid_t nid; | |
6754 | int err; | |
6755 | ||
6756 | spec->multiout.num_dacs = 1; /* only use one dac */ | |
6757 | spec->multiout.dac_nids = spec->private_dac_nids; | |
6758 | spec->multiout.dac_nids[0] = 2; | |
6759 | ||
6760 | nid = cfg->line_out_pins[0]; | |
6761 | if (nid) { | |
f12ab1e0 TI |
6762 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
6763 | "Front Playback Volume", | |
6764 | HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT)); | |
6765 | if (err < 0) | |
df694daa | 6766 | return err; |
f12ab1e0 TI |
6767 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
6768 | "Front Playback Switch", | |
6769 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
6770 | if (err < 0) | |
df694daa KY |
6771 | return err; |
6772 | } | |
6773 | ||
82bc955f | 6774 | nid = cfg->speaker_pins[0]; |
df694daa KY |
6775 | if (nid) { |
6776 | if (nid == 0x16) { | |
f12ab1e0 TI |
6777 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
6778 | "Speaker Playback Volume", | |
6779 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, | |
6780 | HDA_OUTPUT)); | |
6781 | if (err < 0) | |
df694daa | 6782 | return err; |
f12ab1e0 TI |
6783 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
6784 | "Speaker Playback Switch", | |
6785 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
6786 | HDA_OUTPUT)); | |
6787 | if (err < 0) | |
df694daa KY |
6788 | return err; |
6789 | } else { | |
f12ab1e0 TI |
6790 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
6791 | "Speaker Playback Switch", | |
6792 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
6793 | HDA_OUTPUT)); | |
6794 | if (err < 0) | |
df694daa KY |
6795 | return err; |
6796 | } | |
6797 | } | |
eb06ed8f | 6798 | nid = cfg->hp_pins[0]; |
df694daa KY |
6799 | if (nid) { |
6800 | /* spec->multiout.hp_nid = 2; */ | |
6801 | if (nid == 0x16) { | |
f12ab1e0 TI |
6802 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
6803 | "Headphone Playback Volume", | |
6804 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, | |
6805 | HDA_OUTPUT)); | |
6806 | if (err < 0) | |
df694daa | 6807 | return err; |
f12ab1e0 TI |
6808 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
6809 | "Headphone Playback Switch", | |
6810 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
6811 | HDA_OUTPUT)); | |
6812 | if (err < 0) | |
df694daa KY |
6813 | return err; |
6814 | } else { | |
f12ab1e0 TI |
6815 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
6816 | "Headphone Playback Switch", | |
6817 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
6818 | HDA_OUTPUT)); | |
6819 | if (err < 0) | |
df694daa KY |
6820 | return err; |
6821 | } | |
6822 | } | |
f12ab1e0 | 6823 | return 0; |
df694daa KY |
6824 | } |
6825 | ||
6826 | /* identical with ALC880 */ | |
f12ab1e0 TI |
6827 | #define alc262_auto_create_analog_input_ctls \ |
6828 | alc880_auto_create_analog_input_ctls | |
df694daa KY |
6829 | |
6830 | /* | |
6831 | * generic initialization of ADC, input mixers and output mixers | |
6832 | */ | |
6833 | static struct hda_verb alc262_volume_init_verbs[] = { | |
6834 | /* | |
6835 | * Unmute ADC0-2 and set the default input to mic-in | |
6836 | */ | |
6837 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6838 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6839 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6840 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6841 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6842 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6843 | ||
6844 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | |
6845 | * mixer widget | |
f12ab1e0 TI |
6846 | * Note: PASD motherboards uses the Line In 2 as the input for |
6847 | * front panel mic (mic 2) | |
df694daa KY |
6848 | */ |
6849 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
6850 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6851 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6852 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
6853 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
6854 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
6855 | ||
6856 | /* | |
6857 | * Set up output mixers (0x0c - 0x0f) | |
6858 | */ | |
6859 | /* set vol=0 to output mixers */ | |
6860 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6861 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6862 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6863 | ||
6864 | /* set up input amps for analog loopback */ | |
6865 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
6866 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6867 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6868 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6869 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6870 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6871 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6872 | ||
6873 | /* FIXME: use matrix-type input source selection */ | |
6874 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
6875 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
6876 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
6877 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
6878 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
6879 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
6880 | /* Input mixer2 */ | |
6881 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
6882 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
6883 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
6884 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
6885 | /* Input mixer3 */ | |
6886 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
6887 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
6888 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
6889 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
6890 | ||
6891 | { } | |
6892 | }; | |
6893 | ||
9c7f852e TI |
6894 | static struct hda_verb alc262_HP_BPC_init_verbs[] = { |
6895 | /* | |
6896 | * Unmute ADC0-2 and set the default input to mic-in | |
6897 | */ | |
6898 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6899 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6900 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6901 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6902 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6903 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6904 | ||
6905 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | |
6906 | * mixer widget | |
f12ab1e0 TI |
6907 | * Note: PASD motherboards uses the Line In 2 as the input for |
6908 | * front panel mic (mic 2) | |
9c7f852e TI |
6909 | */ |
6910 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
6911 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6912 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6913 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
6914 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
6915 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
6916 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)}, | |
6917 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)}, | |
6918 | ||
6919 | /* | |
6920 | * Set up output mixers (0x0c - 0x0e) | |
6921 | */ | |
6922 | /* set vol=0 to output mixers */ | |
6923 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6924 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6925 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6926 | ||
6927 | /* set up input amps for analog loopback */ | |
6928 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
6929 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6930 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6931 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6932 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6933 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6934 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6935 | ||
6936 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
6937 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6938 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6939 | ||
6940 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
6941 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
6942 | ||
6943 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6944 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6945 | ||
6946 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
6947 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
6948 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
6949 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
6950 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
6951 | ||
6952 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
6953 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
6954 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
6955 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
6956 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
6957 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
6958 | ||
6959 | ||
6960 | /* FIXME: use matrix-type input source selection */ | |
6961 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
6962 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
6963 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
6964 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
6965 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
6966 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
6967 | /* Input mixer2 */ | |
6968 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
6969 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
6970 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
6971 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
6972 | /* Input mixer3 */ | |
6973 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
6974 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
6975 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
6976 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
6977 | ||
6978 | { } | |
6979 | }; | |
6980 | ||
cd7509a4 KY |
6981 | static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = { |
6982 | /* | |
6983 | * Unmute ADC0-2 and set the default input to mic-in | |
6984 | */ | |
6985 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6986 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6987 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6988 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6989 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6990 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6991 | ||
6992 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | |
6993 | * mixer widget | |
6994 | * Note: PASD motherboards uses the Line In 2 as the input for front | |
6995 | * panel mic (mic 2) | |
6996 | */ | |
6997 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
6998 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6999 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7000 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
7001 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
7002 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
7003 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)}, | |
7004 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)}, | |
7005 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)}, | |
7006 | /* | |
7007 | * Set up output mixers (0x0c - 0x0e) | |
7008 | */ | |
7009 | /* set vol=0 to output mixers */ | |
7010 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7011 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7012 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7013 | ||
7014 | /* set up input amps for analog loopback */ | |
7015 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
7016 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7017 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7018 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7019 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7020 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7021 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7022 | ||
7023 | ||
7024 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */ | |
7025 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */ | |
7026 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */ | |
7027 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */ | |
7028 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */ | |
7029 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */ | |
7030 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */ | |
7031 | ||
7032 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7033 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7034 | ||
7035 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7036 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
7037 | ||
7038 | /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */ | |
7039 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
7040 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
7041 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
7042 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
7043 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
7044 | ||
7045 | /* FIXME: use matrix-type input source selection */ | |
7046 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
7047 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
7048 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/ | |
7049 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/ | |
7050 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/ | |
7051 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/ | |
7052 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/ | |
7053 | /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
7054 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/ | |
7055 | /* Input mixer2 */ | |
7056 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
7057 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
7058 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
7059 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
7060 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
7061 | /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
7062 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, | |
7063 | /* Input mixer3 */ | |
7064 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
7065 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
7066 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
7067 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
7068 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
7069 | /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
7070 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, | |
7071 | ||
7072 | { } | |
7073 | }; | |
7074 | ||
df694daa KY |
7075 | /* pcm configuration: identiacal with ALC880 */ |
7076 | #define alc262_pcm_analog_playback alc880_pcm_analog_playback | |
7077 | #define alc262_pcm_analog_capture alc880_pcm_analog_capture | |
7078 | #define alc262_pcm_digital_playback alc880_pcm_digital_playback | |
7079 | #define alc262_pcm_digital_capture alc880_pcm_digital_capture | |
7080 | ||
7081 | /* | |
7082 | * BIOS auto configuration | |
7083 | */ | |
7084 | static int alc262_parse_auto_config(struct hda_codec *codec) | |
7085 | { | |
7086 | struct alc_spec *spec = codec->spec; | |
7087 | int err; | |
7088 | static hda_nid_t alc262_ignore[] = { 0x1d, 0 }; | |
7089 | ||
f12ab1e0 TI |
7090 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
7091 | alc262_ignore); | |
7092 | if (err < 0) | |
df694daa | 7093 | return err; |
f12ab1e0 | 7094 | if (!spec->autocfg.line_outs) |
df694daa | 7095 | return 0; /* can't find valid BIOS pin config */ |
f12ab1e0 TI |
7096 | err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg); |
7097 | if (err < 0) | |
7098 | return err; | |
7099 | err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
7100 | if (err < 0) | |
df694daa KY |
7101 | return err; |
7102 | ||
7103 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
7104 | ||
7105 | if (spec->autocfg.dig_out_pin) | |
7106 | spec->multiout.dig_out_nid = ALC262_DIGOUT_NID; | |
7107 | if (spec->autocfg.dig_in_pin) | |
7108 | spec->dig_in_nid = ALC262_DIGIN_NID; | |
7109 | ||
7110 | if (spec->kctl_alloc) | |
7111 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
7112 | ||
7113 | spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs; | |
a1e8d2da | 7114 | spec->num_mux_defs = 1; |
df694daa KY |
7115 | spec->input_mux = &spec->private_imux; |
7116 | ||
7117 | return 1; | |
7118 | } | |
7119 | ||
7120 | #define alc262_auto_init_multi_out alc882_auto_init_multi_out | |
7121 | #define alc262_auto_init_hp_out alc882_auto_init_hp_out | |
7122 | #define alc262_auto_init_analog_input alc882_auto_init_analog_input | |
7123 | ||
7124 | ||
7125 | /* init callback for auto-configuration model -- overriding the default init */ | |
ae6b813a | 7126 | static void alc262_auto_init(struct hda_codec *codec) |
df694daa | 7127 | { |
df694daa KY |
7128 | alc262_auto_init_multi_out(codec); |
7129 | alc262_auto_init_hp_out(codec); | |
7130 | alc262_auto_init_analog_input(codec); | |
df694daa KY |
7131 | } |
7132 | ||
7133 | /* | |
7134 | * configuration and preset | |
7135 | */ | |
f5fcc13c TI |
7136 | static const char *alc262_models[ALC262_MODEL_LAST] = { |
7137 | [ALC262_BASIC] = "basic", | |
7138 | [ALC262_HIPPO] = "hippo", | |
7139 | [ALC262_HIPPO_1] = "hippo_1", | |
7140 | [ALC262_FUJITSU] = "fujitsu", | |
7141 | [ALC262_HP_BPC] = "hp-bpc", | |
cd7509a4 | 7142 | [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000", |
f5fcc13c TI |
7143 | [ALC262_BENQ_ED8] = "benq", |
7144 | [ALC262_AUTO] = "auto", | |
7145 | }; | |
7146 | ||
7147 | static struct snd_pci_quirk alc262_cfg_tbl[] = { | |
7148 | SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO), | |
7149 | SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC), | |
7150 | SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC), | |
f5fcc13c TI |
7151 | SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC), |
7152 | SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC), | |
cd7509a4 KY |
7153 | SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL), |
7154 | SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL), | |
7155 | SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL), | |
7156 | SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL), | |
7157 | SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF), | |
7158 | SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF), | |
7159 | SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF), | |
7160 | SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF), | |
f5fcc13c TI |
7161 | SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO), |
7162 | SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU), | |
7163 | SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1), | |
7164 | SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8), | |
df694daa KY |
7165 | {} |
7166 | }; | |
7167 | ||
7168 | static struct alc_config_preset alc262_presets[] = { | |
7169 | [ALC262_BASIC] = { | |
7170 | .mixers = { alc262_base_mixer }, | |
7171 | .init_verbs = { alc262_init_verbs }, | |
7172 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
7173 | .dac_nids = alc262_dac_nids, | |
7174 | .hp_nid = 0x03, | |
7175 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
7176 | .channel_mode = alc262_modes, | |
a3bcba38 | 7177 | .input_mux = &alc262_capture_source, |
df694daa | 7178 | }, |
ccc656ce KY |
7179 | [ALC262_HIPPO] = { |
7180 | .mixers = { alc262_base_mixer }, | |
7181 | .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs}, | |
7182 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
7183 | .dac_nids = alc262_dac_nids, | |
7184 | .hp_nid = 0x03, | |
7185 | .dig_out_nid = ALC262_DIGOUT_NID, | |
7186 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
7187 | .channel_mode = alc262_modes, | |
7188 | .input_mux = &alc262_capture_source, | |
7189 | .unsol_event = alc262_hippo_unsol_event, | |
7190 | }, | |
7191 | [ALC262_HIPPO_1] = { | |
7192 | .mixers = { alc262_hippo1_mixer }, | |
7193 | .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs}, | |
7194 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
7195 | .dac_nids = alc262_dac_nids, | |
7196 | .hp_nid = 0x02, | |
7197 | .dig_out_nid = ALC262_DIGOUT_NID, | |
7198 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
7199 | .channel_mode = alc262_modes, | |
7200 | .input_mux = &alc262_capture_source, | |
7201 | .unsol_event = alc262_hippo1_unsol_event, | |
7202 | }, | |
834be88d TI |
7203 | [ALC262_FUJITSU] = { |
7204 | .mixers = { alc262_fujitsu_mixer }, | |
7205 | .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs }, | |
7206 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
7207 | .dac_nids = alc262_dac_nids, | |
7208 | .hp_nid = 0x03, | |
7209 | .dig_out_nid = ALC262_DIGOUT_NID, | |
7210 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
7211 | .channel_mode = alc262_modes, | |
7212 | .input_mux = &alc262_fujitsu_capture_source, | |
ae6b813a | 7213 | .unsol_event = alc262_fujitsu_unsol_event, |
834be88d | 7214 | }, |
9c7f852e TI |
7215 | [ALC262_HP_BPC] = { |
7216 | .mixers = { alc262_HP_BPC_mixer }, | |
7217 | .init_verbs = { alc262_HP_BPC_init_verbs }, | |
7218 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
7219 | .dac_nids = alc262_dac_nids, | |
7220 | .hp_nid = 0x03, | |
7221 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
7222 | .channel_mode = alc262_modes, | |
7223 | .input_mux = &alc262_HP_capture_source, | |
f12ab1e0 | 7224 | }, |
cd7509a4 KY |
7225 | [ALC262_HP_BPC_D7000_WF] = { |
7226 | .mixers = { alc262_HP_BPC_WildWest_mixer }, | |
7227 | .init_verbs = { alc262_HP_BPC_WildWest_init_verbs }, | |
7228 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
7229 | .dac_nids = alc262_dac_nids, | |
7230 | .hp_nid = 0x03, | |
7231 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
7232 | .channel_mode = alc262_modes, | |
7233 | .input_mux = &alc262_HP_capture_source, | |
f12ab1e0 | 7234 | }, |
cd7509a4 KY |
7235 | [ALC262_HP_BPC_D7000_WL] = { |
7236 | .mixers = { alc262_HP_BPC_WildWest_mixer, | |
7237 | alc262_HP_BPC_WildWest_option_mixer }, | |
7238 | .init_verbs = { alc262_HP_BPC_WildWest_init_verbs }, | |
7239 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
7240 | .dac_nids = alc262_dac_nids, | |
7241 | .hp_nid = 0x03, | |
7242 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
7243 | .channel_mode = alc262_modes, | |
7244 | .input_mux = &alc262_HP_capture_source, | |
f12ab1e0 | 7245 | }, |
304dcaac TI |
7246 | [ALC262_BENQ_ED8] = { |
7247 | .mixers = { alc262_base_mixer }, | |
7248 | .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs }, | |
7249 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
7250 | .dac_nids = alc262_dac_nids, | |
7251 | .hp_nid = 0x03, | |
7252 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
7253 | .channel_mode = alc262_modes, | |
7254 | .input_mux = &alc262_capture_source, | |
f12ab1e0 | 7255 | }, |
df694daa KY |
7256 | }; |
7257 | ||
7258 | static int patch_alc262(struct hda_codec *codec) | |
7259 | { | |
7260 | struct alc_spec *spec; | |
7261 | int board_config; | |
7262 | int err; | |
7263 | ||
dc041e0b | 7264 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
df694daa KY |
7265 | if (spec == NULL) |
7266 | return -ENOMEM; | |
7267 | ||
7268 | codec->spec = spec; | |
7269 | #if 0 | |
f12ab1e0 TI |
7270 | /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is |
7271 | * under-run | |
7272 | */ | |
df694daa KY |
7273 | { |
7274 | int tmp; | |
7275 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); | |
7276 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); | |
7277 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); | |
7278 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); | |
7279 | } | |
7280 | #endif | |
7281 | ||
f5fcc13c TI |
7282 | board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST, |
7283 | alc262_models, | |
7284 | alc262_cfg_tbl); | |
cd7509a4 | 7285 | |
f5fcc13c | 7286 | if (board_config < 0) { |
9c7f852e TI |
7287 | printk(KERN_INFO "hda_codec: Unknown model for ALC262, " |
7288 | "trying auto-probe from BIOS...\n"); | |
df694daa KY |
7289 | board_config = ALC262_AUTO; |
7290 | } | |
7291 | ||
7292 | if (board_config == ALC262_AUTO) { | |
7293 | /* automatic parse from the BIOS config */ | |
7294 | err = alc262_parse_auto_config(codec); | |
7295 | if (err < 0) { | |
7296 | alc_free(codec); | |
7297 | return err; | |
f12ab1e0 | 7298 | } else if (!err) { |
9c7f852e TI |
7299 | printk(KERN_INFO |
7300 | "hda_codec: Cannot set up configuration " | |
7301 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
7302 | board_config = ALC262_BASIC; |
7303 | } | |
7304 | } | |
7305 | ||
7306 | if (board_config != ALC262_AUTO) | |
7307 | setup_preset(spec, &alc262_presets[board_config]); | |
7308 | ||
7309 | spec->stream_name_analog = "ALC262 Analog"; | |
7310 | spec->stream_analog_playback = &alc262_pcm_analog_playback; | |
7311 | spec->stream_analog_capture = &alc262_pcm_analog_capture; | |
7312 | ||
7313 | spec->stream_name_digital = "ALC262 Digital"; | |
7314 | spec->stream_digital_playback = &alc262_pcm_digital_playback; | |
7315 | spec->stream_digital_capture = &alc262_pcm_digital_capture; | |
7316 | ||
f12ab1e0 | 7317 | if (!spec->adc_nids && spec->input_mux) { |
df694daa | 7318 | /* check whether NID 0x07 is valid */ |
4a471b7d TI |
7319 | unsigned int wcap = get_wcaps(codec, 0x07); |
7320 | ||
f12ab1e0 TI |
7321 | /* get type */ |
7322 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
df694daa KY |
7323 | if (wcap != AC_WID_AUD_IN) { |
7324 | spec->adc_nids = alc262_adc_nids_alt; | |
7325 | spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt); | |
f12ab1e0 TI |
7326 | spec->mixers[spec->num_mixers] = |
7327 | alc262_capture_alt_mixer; | |
df694daa KY |
7328 | spec->num_mixers++; |
7329 | } else { | |
7330 | spec->adc_nids = alc262_adc_nids; | |
7331 | spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids); | |
7332 | spec->mixers[spec->num_mixers] = alc262_capture_mixer; | |
7333 | spec->num_mixers++; | |
7334 | } | |
7335 | } | |
7336 | ||
7337 | codec->patch_ops = alc_patch_ops; | |
7338 | if (board_config == ALC262_AUTO) | |
ae6b813a | 7339 | spec->init_hook = alc262_auto_init; |
834be88d | 7340 | |
df694daa KY |
7341 | return 0; |
7342 | } | |
7343 | ||
df694daa KY |
7344 | /* |
7345 | * ALC861 channel source setting (2/6 channel selection for 3-stack) | |
7346 | */ | |
7347 | ||
7348 | /* | |
7349 | * set the path ways for 2 channel output | |
7350 | * need to set the codec line out and mic 1 pin widgets to inputs | |
7351 | */ | |
7352 | static struct hda_verb alc861_threestack_ch2_init[] = { | |
7353 | /* set pin widget 1Ah (line in) for input */ | |
7354 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
f12ab1e0 TI |
7355 | /* set pin widget 18h (mic1/2) for input, for mic also enable |
7356 | * the vref | |
7357 | */ | |
df694daa KY |
7358 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
7359 | ||
9c7f852e TI |
7360 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, |
7361 | #if 0 | |
7362 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
7363 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/ | |
7364 | #endif | |
df694daa KY |
7365 | { } /* end */ |
7366 | }; | |
7367 | /* | |
7368 | * 6ch mode | |
7369 | * need to set the codec line out and mic 1 pin widgets to outputs | |
7370 | */ | |
7371 | static struct hda_verb alc861_threestack_ch6_init[] = { | |
7372 | /* set pin widget 1Ah (line in) for output (Back Surround)*/ | |
7373 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
7374 | /* set pin widget 18h (mic1) for output (CLFE)*/ | |
7375 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
7376 | ||
7377 | { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
9c7f852e | 7378 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa | 7379 | |
9c7f852e TI |
7380 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, |
7381 | #if 0 | |
7382 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
7383 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/ | |
7384 | #endif | |
df694daa KY |
7385 | { } /* end */ |
7386 | }; | |
7387 | ||
7388 | static struct hda_channel_mode alc861_threestack_modes[2] = { | |
7389 | { 2, alc861_threestack_ch2_init }, | |
7390 | { 6, alc861_threestack_ch6_init }, | |
7391 | }; | |
22309c3e TI |
7392 | /* Set mic1 as input and unmute the mixer */ |
7393 | static struct hda_verb alc861_uniwill_m31_ch2_init[] = { | |
7394 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
7395 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
7396 | { } /* end */ | |
7397 | }; | |
7398 | /* Set mic1 as output and mute mixer */ | |
7399 | static struct hda_verb alc861_uniwill_m31_ch4_init[] = { | |
7400 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
7401 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
7402 | { } /* end */ | |
7403 | }; | |
7404 | ||
7405 | static struct hda_channel_mode alc861_uniwill_m31_modes[2] = { | |
7406 | { 2, alc861_uniwill_m31_ch2_init }, | |
7407 | { 4, alc861_uniwill_m31_ch4_init }, | |
7408 | }; | |
df694daa | 7409 | |
7cdbff94 MD |
7410 | /* Set mic1 and line-in as input and unmute the mixer */ |
7411 | static struct hda_verb alc861_asus_ch2_init[] = { | |
7412 | /* set pin widget 1Ah (line in) for input */ | |
7413 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
f12ab1e0 TI |
7414 | /* set pin widget 18h (mic1/2) for input, for mic also enable |
7415 | * the vref | |
7416 | */ | |
7cdbff94 MD |
7417 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
7418 | ||
7419 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, | |
7420 | #if 0 | |
7421 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
7422 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/ | |
7423 | #endif | |
7424 | { } /* end */ | |
7425 | }; | |
7426 | /* Set mic1 nad line-in as output and mute mixer */ | |
7427 | static struct hda_verb alc861_asus_ch6_init[] = { | |
7428 | /* set pin widget 1Ah (line in) for output (Back Surround)*/ | |
7429 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
7430 | /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */ | |
7431 | /* set pin widget 18h (mic1) for output (CLFE)*/ | |
7432 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
7433 | /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */ | |
7434 | { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
7435 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
7436 | ||
7437 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, | |
7438 | #if 0 | |
7439 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
7440 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/ | |
7441 | #endif | |
7442 | { } /* end */ | |
7443 | }; | |
7444 | ||
7445 | static struct hda_channel_mode alc861_asus_modes[2] = { | |
7446 | { 2, alc861_asus_ch2_init }, | |
7447 | { 6, alc861_asus_ch6_init }, | |
7448 | }; | |
7449 | ||
df694daa KY |
7450 | /* patch-ALC861 */ |
7451 | ||
7452 | static struct snd_kcontrol_new alc861_base_mixer[] = { | |
7453 | /* output mixer control */ | |
7454 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
7455 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
7456 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
7457 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
7458 | HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), | |
7459 | ||
7460 | /*Input mixer control */ | |
7461 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
7462 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
7463 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
7464 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
7465 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
7466 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
7467 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
7468 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
7469 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
7470 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 7471 | |
df694daa KY |
7472 | /* Capture mixer control */ |
7473 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
7474 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
7475 | { | |
7476 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7477 | .name = "Capture Source", | |
7478 | .count = 1, | |
7479 | .info = alc_mux_enum_info, | |
7480 | .get = alc_mux_enum_get, | |
7481 | .put = alc_mux_enum_put, | |
7482 | }, | |
7483 | { } /* end */ | |
7484 | }; | |
7485 | ||
7486 | static struct snd_kcontrol_new alc861_3ST_mixer[] = { | |
7487 | /* output mixer control */ | |
7488 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
7489 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
7490 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
7491 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
7492 | /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ | |
7493 | ||
7494 | /* Input mixer control */ | |
7495 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
7496 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
7497 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
7498 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
7499 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
7500 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
7501 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
7502 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
7503 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
7504 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 7505 | |
df694daa KY |
7506 | /* Capture mixer control */ |
7507 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
7508 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
7509 | { | |
7510 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7511 | .name = "Capture Source", | |
7512 | .count = 1, | |
7513 | .info = alc_mux_enum_info, | |
7514 | .get = alc_mux_enum_get, | |
7515 | .put = alc_mux_enum_put, | |
7516 | }, | |
7517 | { | |
7518 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7519 | .name = "Channel Mode", | |
7520 | .info = alc_ch_mode_info, | |
7521 | .get = alc_ch_mode_get, | |
7522 | .put = alc_ch_mode_put, | |
7523 | .private_value = ARRAY_SIZE(alc861_threestack_modes), | |
7524 | }, | |
7525 | { } /* end */ | |
a53d1aec TD |
7526 | }; |
7527 | ||
d1d985f0 | 7528 | static struct snd_kcontrol_new alc861_toshiba_mixer[] = { |
a53d1aec TD |
7529 | /* output mixer control */ |
7530 | HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
7531 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
7532 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
7533 | ||
7534 | /*Capture mixer control */ | |
7535 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
7536 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
7537 | { | |
7538 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7539 | .name = "Capture Source", | |
7540 | .count = 1, | |
7541 | .info = alc_mux_enum_info, | |
7542 | .get = alc_mux_enum_get, | |
7543 | .put = alc_mux_enum_put, | |
7544 | }, | |
7545 | ||
7546 | { } /* end */ | |
f12ab1e0 | 7547 | }; |
a53d1aec | 7548 | |
22309c3e TI |
7549 | static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = { |
7550 | /* output mixer control */ | |
7551 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
7552 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
7553 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
7554 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
7555 | /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ | |
7556 | ||
7557 | /* Input mixer control */ | |
7558 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
7559 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
7560 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
7561 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
7562 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
7563 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
7564 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
7565 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
7566 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
7567 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 7568 | |
22309c3e TI |
7569 | /* Capture mixer control */ |
7570 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
7571 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
7572 | { | |
7573 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7574 | .name = "Capture Source", | |
7575 | .count = 1, | |
7576 | .info = alc_mux_enum_info, | |
7577 | .get = alc_mux_enum_get, | |
7578 | .put = alc_mux_enum_put, | |
7579 | }, | |
7580 | { | |
7581 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7582 | .name = "Channel Mode", | |
7583 | .info = alc_ch_mode_info, | |
7584 | .get = alc_ch_mode_get, | |
7585 | .put = alc_ch_mode_put, | |
7586 | .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes), | |
7587 | }, | |
7588 | { } /* end */ | |
f12ab1e0 | 7589 | }; |
7cdbff94 MD |
7590 | |
7591 | static struct snd_kcontrol_new alc861_asus_mixer[] = { | |
7592 | /* output mixer control */ | |
7593 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
7594 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
7595 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
7596 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
7597 | HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), | |
7598 | ||
7599 | /* Input mixer control */ | |
7600 | HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
7601 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
7602 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
7603 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
7604 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
7605 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
7606 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
7607 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
7608 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
f12ab1e0 TI |
7609 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), |
7610 | ||
7cdbff94 MD |
7611 | /* Capture mixer control */ |
7612 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
7613 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
7614 | { | |
7615 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7616 | .name = "Capture Source", | |
7617 | .count = 1, | |
7618 | .info = alc_mux_enum_info, | |
7619 | .get = alc_mux_enum_get, | |
7620 | .put = alc_mux_enum_put, | |
7621 | }, | |
7622 | { | |
7623 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7624 | .name = "Channel Mode", | |
7625 | .info = alc_ch_mode_info, | |
7626 | .get = alc_ch_mode_get, | |
7627 | .put = alc_ch_mode_put, | |
7628 | .private_value = ARRAY_SIZE(alc861_asus_modes), | |
7629 | }, | |
7630 | { } | |
56bb0cab TI |
7631 | }; |
7632 | ||
7633 | /* additional mixer */ | |
d1d985f0 | 7634 | static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = { |
56bb0cab TI |
7635 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), |
7636 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
7637 | HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT), | |
7638 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT), | |
7639 | { } | |
7640 | }; | |
7cdbff94 | 7641 | |
df694daa KY |
7642 | /* |
7643 | * generic initialization of ADC, input mixers and output mixers | |
7644 | */ | |
7645 | static struct hda_verb alc861_base_init_verbs[] = { | |
7646 | /* | |
7647 | * Unmute ADC0 and set the default input to mic-in | |
7648 | */ | |
7649 | /* port-A for surround (rear panel) */ | |
7650 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
7651 | { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
7652 | /* port-B for mic-in (rear panel) with vref */ | |
7653 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
7654 | /* port-C for line-in (rear panel) */ | |
7655 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
7656 | /* port-D for Front */ | |
7657 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
7658 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
7659 | /* port-E for HP out (front panel) */ | |
7660 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | |
7661 | /* route front PCM to HP */ | |
9dece1d7 | 7662 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa KY |
7663 | /* port-F for mic-in (front panel) with vref */ |
7664 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
7665 | /* port-G for CLFE (rear panel) */ | |
7666 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
7667 | { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
7668 | /* port-H for side (rear panel) */ | |
7669 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
7670 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
7671 | /* CD-in */ | |
7672 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
7673 | /* route front mic to ADC1*/ | |
7674 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7675 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7676 | ||
7677 | /* Unmute DAC0~3 & spdif out*/ | |
7678 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7679 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7680 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7681 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7682 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7683 | ||
7684 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
7685 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7686 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7687 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7688 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7689 | ||
7690 | /* Unmute Stereo Mixer 15 */ | |
7691 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7692 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7693 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 7694 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
df694daa KY |
7695 | |
7696 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7697 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7698 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7699 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7700 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7701 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7702 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7703 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
7704 | /* hp used DAC 3 (Front) */ |
7705 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
7706 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
7707 | ||
7708 | { } | |
7709 | }; | |
7710 | ||
7711 | static struct hda_verb alc861_threestack_init_verbs[] = { | |
7712 | /* | |
7713 | * Unmute ADC0 and set the default input to mic-in | |
7714 | */ | |
7715 | /* port-A for surround (rear panel) */ | |
7716 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
7717 | /* port-B for mic-in (rear panel) with vref */ | |
7718 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
7719 | /* port-C for line-in (rear panel) */ | |
7720 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
7721 | /* port-D for Front */ | |
7722 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
7723 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
7724 | /* port-E for HP out (front panel) */ | |
7725 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | |
7726 | /* route front PCM to HP */ | |
9dece1d7 | 7727 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa KY |
7728 | /* port-F for mic-in (front panel) with vref */ |
7729 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
7730 | /* port-G for CLFE (rear panel) */ | |
7731 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
7732 | /* port-H for side (rear panel) */ | |
7733 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
7734 | /* CD-in */ | |
7735 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
7736 | /* route front mic to ADC1*/ | |
7737 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7738 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7739 | /* Unmute DAC0~3 & spdif out*/ | |
7740 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7741 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7742 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7743 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7744 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7745 | ||
7746 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
7747 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7748 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7749 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7750 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7751 | ||
7752 | /* Unmute Stereo Mixer 15 */ | |
7753 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7754 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7755 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 7756 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
df694daa KY |
7757 | |
7758 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7759 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7760 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7761 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7762 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7763 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7764 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7765 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
7766 | /* hp used DAC 3 (Front) */ |
7767 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
7768 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
7769 | { } | |
7770 | }; | |
22309c3e TI |
7771 | |
7772 | static struct hda_verb alc861_uniwill_m31_init_verbs[] = { | |
7773 | /* | |
7774 | * Unmute ADC0 and set the default input to mic-in | |
7775 | */ | |
7776 | /* port-A for surround (rear panel) */ | |
7777 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
7778 | /* port-B for mic-in (rear panel) with vref */ | |
7779 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
7780 | /* port-C for line-in (rear panel) */ | |
7781 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
7782 | /* port-D for Front */ | |
7783 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
7784 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
7785 | /* port-E for HP out (front panel) */ | |
f12ab1e0 TI |
7786 | /* this has to be set to VREF80 */ |
7787 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
22309c3e | 7788 | /* route front PCM to HP */ |
9dece1d7 | 7789 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
22309c3e TI |
7790 | /* port-F for mic-in (front panel) with vref */ |
7791 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
7792 | /* port-G for CLFE (rear panel) */ | |
7793 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
7794 | /* port-H for side (rear panel) */ | |
7795 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
7796 | /* CD-in */ | |
7797 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
7798 | /* route front mic to ADC1*/ | |
7799 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7800 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7801 | /* Unmute DAC0~3 & spdif out*/ | |
7802 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7803 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7804 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7805 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7806 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7807 | ||
7808 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
7809 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7810 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7811 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7812 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7813 | ||
7814 | /* Unmute Stereo Mixer 15 */ | |
7815 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7816 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7817 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 7818 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
22309c3e TI |
7819 | |
7820 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7821 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7822 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7823 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7824 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7825 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7826 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7827 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
7828 | /* hp used DAC 3 (Front) */ |
7829 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
22309c3e TI |
7830 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
7831 | { } | |
7832 | }; | |
7833 | ||
7cdbff94 MD |
7834 | static struct hda_verb alc861_asus_init_verbs[] = { |
7835 | /* | |
7836 | * Unmute ADC0 and set the default input to mic-in | |
7837 | */ | |
f12ab1e0 TI |
7838 | /* port-A for surround (rear panel) |
7839 | * according to codec#0 this is the HP jack | |
7840 | */ | |
7cdbff94 MD |
7841 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */ |
7842 | /* route front PCM to HP */ | |
7843 | { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
7844 | /* port-B for mic-in (rear panel) with vref */ | |
7845 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
7846 | /* port-C for line-in (rear panel) */ | |
7847 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
7848 | /* port-D for Front */ | |
7849 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
7850 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
7851 | /* port-E for HP out (front panel) */ | |
f12ab1e0 TI |
7852 | /* this has to be set to VREF80 */ |
7853 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
7cdbff94 | 7854 | /* route front PCM to HP */ |
9dece1d7 | 7855 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
7cdbff94 MD |
7856 | /* port-F for mic-in (front panel) with vref */ |
7857 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
7858 | /* port-G for CLFE (rear panel) */ | |
7859 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
7860 | /* port-H for side (rear panel) */ | |
7861 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
7862 | /* CD-in */ | |
7863 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
7864 | /* route front mic to ADC1*/ | |
7865 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7866 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7867 | /* Unmute DAC0~3 & spdif out*/ | |
7868 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7869 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7870 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7871 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7872 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7873 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
7874 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7875 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7876 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7877 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7878 | ||
7879 | /* Unmute Stereo Mixer 15 */ | |
7880 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7881 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7882 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 7883 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
7cdbff94 MD |
7884 | |
7885 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7886 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7887 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7888 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7889 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7890 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7891 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7892 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
7893 | /* hp used DAC 3 (Front) */ |
7894 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
7cdbff94 MD |
7895 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
7896 | { } | |
7897 | }; | |
7898 | ||
56bb0cab TI |
7899 | /* additional init verbs for ASUS laptops */ |
7900 | static struct hda_verb alc861_asus_laptop_init_verbs[] = { | |
7901 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */ | |
7902 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */ | |
7903 | { } | |
7904 | }; | |
7cdbff94 | 7905 | |
df694daa KY |
7906 | /* |
7907 | * generic initialization of ADC, input mixers and output mixers | |
7908 | */ | |
7909 | static struct hda_verb alc861_auto_init_verbs[] = { | |
7910 | /* | |
7911 | * Unmute ADC0 and set the default input to mic-in | |
7912 | */ | |
f12ab1e0 | 7913 | /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */ |
df694daa KY |
7914 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
7915 | ||
7916 | /* Unmute DAC0~3 & spdif out*/ | |
7917 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
7918 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
7919 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
7920 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
7921 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7922 | ||
7923 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
7924 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7925 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7926 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7927 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7928 | ||
7929 | /* Unmute Stereo Mixer 15 */ | |
7930 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7931 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7932 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
7933 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, | |
7934 | ||
7935 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7936 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7937 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7938 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7939 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7940 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7941 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7942 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7943 | ||
7944 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7945 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
f12ab1e0 TI |
7946 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
7947 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
7948 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
7949 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
f12ab1e0 TI |
7950 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
7951 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa | 7952 | |
f12ab1e0 | 7953 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */ |
df694daa KY |
7954 | |
7955 | { } | |
7956 | }; | |
7957 | ||
a53d1aec TD |
7958 | static struct hda_verb alc861_toshiba_init_verbs[] = { |
7959 | {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
f12ab1e0 | 7960 | |
a53d1aec TD |
7961 | { } |
7962 | }; | |
7963 | ||
7964 | /* toggle speaker-output according to the hp-jack state */ | |
7965 | static void alc861_toshiba_automute(struct hda_codec *codec) | |
7966 | { | |
7967 | unsigned int present; | |
7968 | ||
7969 | present = snd_hda_codec_read(codec, 0x0f, 0, | |
7970 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
7971 | snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0, | |
7972 | 0x80, present ? 0x80 : 0); | |
7973 | snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0, | |
7974 | 0x80, present ? 0x80 : 0); | |
7975 | snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3, | |
7976 | 0x80, present ? 0 : 0x80); | |
7977 | snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3, | |
7978 | 0x80, present ? 0 : 0x80); | |
7979 | } | |
7980 | ||
7981 | static void alc861_toshiba_unsol_event(struct hda_codec *codec, | |
7982 | unsigned int res) | |
7983 | { | |
a53d1aec TD |
7984 | if ((res >> 26) == ALC880_HP_EVENT) |
7985 | alc861_toshiba_automute(codec); | |
7986 | } | |
7987 | ||
df694daa KY |
7988 | /* pcm configuration: identiacal with ALC880 */ |
7989 | #define alc861_pcm_analog_playback alc880_pcm_analog_playback | |
7990 | #define alc861_pcm_analog_capture alc880_pcm_analog_capture | |
7991 | #define alc861_pcm_digital_playback alc880_pcm_digital_playback | |
7992 | #define alc861_pcm_digital_capture alc880_pcm_digital_capture | |
7993 | ||
7994 | ||
7995 | #define ALC861_DIGOUT_NID 0x07 | |
7996 | ||
7997 | static struct hda_channel_mode alc861_8ch_modes[1] = { | |
7998 | { 8, NULL } | |
7999 | }; | |
8000 | ||
8001 | static hda_nid_t alc861_dac_nids[4] = { | |
8002 | /* front, surround, clfe, side */ | |
8003 | 0x03, 0x06, 0x05, 0x04 | |
8004 | }; | |
8005 | ||
9c7f852e TI |
8006 | static hda_nid_t alc660_dac_nids[3] = { |
8007 | /* front, clfe, surround */ | |
8008 | 0x03, 0x05, 0x06 | |
8009 | }; | |
8010 | ||
df694daa KY |
8011 | static hda_nid_t alc861_adc_nids[1] = { |
8012 | /* ADC0-2 */ | |
8013 | 0x08, | |
8014 | }; | |
8015 | ||
8016 | static struct hda_input_mux alc861_capture_source = { | |
8017 | .num_items = 5, | |
8018 | .items = { | |
8019 | { "Mic", 0x0 }, | |
8020 | { "Front Mic", 0x3 }, | |
8021 | { "Line", 0x1 }, | |
8022 | { "CD", 0x4 }, | |
8023 | { "Mixer", 0x5 }, | |
8024 | }, | |
8025 | }; | |
8026 | ||
8027 | /* fill in the dac_nids table from the parsed pin configuration */ | |
f12ab1e0 TI |
8028 | static int alc861_auto_fill_dac_nids(struct alc_spec *spec, |
8029 | const struct auto_pin_cfg *cfg) | |
df694daa KY |
8030 | { |
8031 | int i; | |
8032 | hda_nid_t nid; | |
8033 | ||
8034 | spec->multiout.dac_nids = spec->private_dac_nids; | |
8035 | for (i = 0; i < cfg->line_outs; i++) { | |
8036 | nid = cfg->line_out_pins[i]; | |
8037 | if (nid) { | |
8038 | if (i >= ARRAY_SIZE(alc861_dac_nids)) | |
8039 | continue; | |
8040 | spec->multiout.dac_nids[i] = alc861_dac_nids[i]; | |
8041 | } | |
8042 | } | |
8043 | spec->multiout.num_dacs = cfg->line_outs; | |
8044 | return 0; | |
8045 | } | |
8046 | ||
8047 | /* add playback controls from the parsed DAC table */ | |
8048 | static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec, | |
8049 | const struct auto_pin_cfg *cfg) | |
8050 | { | |
8051 | char name[32]; | |
f12ab1e0 TI |
8052 | static const char *chname[4] = { |
8053 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
8054 | }; | |
df694daa KY |
8055 | hda_nid_t nid; |
8056 | int i, idx, err; | |
8057 | ||
8058 | for (i = 0; i < cfg->line_outs; i++) { | |
8059 | nid = spec->multiout.dac_nids[i]; | |
f12ab1e0 | 8060 | if (!nid) |
df694daa KY |
8061 | continue; |
8062 | if (nid == 0x05) { | |
8063 | /* Center/LFE */ | |
f12ab1e0 TI |
8064 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
8065 | "Center Playback Switch", | |
8066 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, | |
8067 | HDA_OUTPUT)); | |
8068 | if (err < 0) | |
df694daa | 8069 | return err; |
f12ab1e0 TI |
8070 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
8071 | "LFE Playback Switch", | |
8072 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
8073 | HDA_OUTPUT)); | |
8074 | if (err < 0) | |
df694daa KY |
8075 | return err; |
8076 | } else { | |
f12ab1e0 TI |
8077 | for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; |
8078 | idx++) | |
df694daa KY |
8079 | if (nid == alc861_dac_nids[idx]) |
8080 | break; | |
8081 | sprintf(name, "%s Playback Switch", chname[idx]); | |
f12ab1e0 TI |
8082 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
8083 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
8084 | HDA_OUTPUT)); | |
8085 | if (err < 0) | |
df694daa KY |
8086 | return err; |
8087 | } | |
8088 | } | |
8089 | return 0; | |
8090 | } | |
8091 | ||
8092 | static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin) | |
8093 | { | |
8094 | int err; | |
8095 | hda_nid_t nid; | |
8096 | ||
f12ab1e0 | 8097 | if (!pin) |
df694daa KY |
8098 | return 0; |
8099 | ||
8100 | if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) { | |
8101 | nid = 0x03; | |
f12ab1e0 TI |
8102 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
8103 | "Headphone Playback Switch", | |
8104 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
8105 | if (err < 0) | |
df694daa KY |
8106 | return err; |
8107 | spec->multiout.hp_nid = nid; | |
8108 | } | |
8109 | return 0; | |
8110 | } | |
8111 | ||
8112 | /* create playback/capture controls for input pins */ | |
f12ab1e0 TI |
8113 | static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, |
8114 | const struct auto_pin_cfg *cfg) | |
df694daa | 8115 | { |
df694daa KY |
8116 | struct hda_input_mux *imux = &spec->private_imux; |
8117 | int i, err, idx, idx1; | |
8118 | ||
8119 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
f12ab1e0 | 8120 | switch (cfg->input_pins[i]) { |
df694daa KY |
8121 | case 0x0c: |
8122 | idx1 = 1; | |
f12ab1e0 | 8123 | idx = 2; /* Line In */ |
df694daa KY |
8124 | break; |
8125 | case 0x0f: | |
8126 | idx1 = 2; | |
f12ab1e0 | 8127 | idx = 2; /* Line In */ |
df694daa KY |
8128 | break; |
8129 | case 0x0d: | |
8130 | idx1 = 0; | |
f12ab1e0 | 8131 | idx = 1; /* Mic In */ |
df694daa | 8132 | break; |
f12ab1e0 | 8133 | case 0x10: |
df694daa | 8134 | idx1 = 3; |
f12ab1e0 | 8135 | idx = 1; /* Mic In */ |
df694daa KY |
8136 | break; |
8137 | case 0x11: | |
8138 | idx1 = 4; | |
f12ab1e0 | 8139 | idx = 0; /* CD */ |
df694daa KY |
8140 | break; |
8141 | default: | |
8142 | continue; | |
8143 | } | |
8144 | ||
4a471b7d TI |
8145 | err = new_analog_input(spec, cfg->input_pins[i], |
8146 | auto_pin_cfg_labels[i], idx, 0x15); | |
df694daa KY |
8147 | if (err < 0) |
8148 | return err; | |
8149 | ||
4a471b7d | 8150 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
df694daa | 8151 | imux->items[imux->num_items].index = idx1; |
f12ab1e0 | 8152 | imux->num_items++; |
df694daa KY |
8153 | } |
8154 | return 0; | |
8155 | } | |
8156 | ||
8157 | static struct snd_kcontrol_new alc861_capture_mixer[] = { | |
8158 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
8159 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
8160 | ||
8161 | { | |
8162 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
8163 | /* The multiple "Capture Source" controls confuse alsamixer | |
8164 | * So call somewhat different.. | |
8165 | *FIXME: the controls appear in the "playback" view! | |
8166 | */ | |
8167 | /* .name = "Capture Source", */ | |
8168 | .name = "Input Source", | |
8169 | .count = 1, | |
8170 | .info = alc_mux_enum_info, | |
8171 | .get = alc_mux_enum_get, | |
8172 | .put = alc_mux_enum_put, | |
8173 | }, | |
8174 | { } /* end */ | |
8175 | }; | |
8176 | ||
f12ab1e0 TI |
8177 | static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, |
8178 | hda_nid_t nid, | |
df694daa KY |
8179 | int pin_type, int dac_idx) |
8180 | { | |
8181 | /* set as output */ | |
8182 | ||
f12ab1e0 TI |
8183 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
8184 | pin_type); | |
8185 | snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
8186 | AMP_OUT_UNMUTE); | |
df694daa KY |
8187 | |
8188 | } | |
8189 | ||
8190 | static void alc861_auto_init_multi_out(struct hda_codec *codec) | |
8191 | { | |
8192 | struct alc_spec *spec = codec->spec; | |
8193 | int i; | |
8194 | ||
bc9f98a9 | 8195 | alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b); |
df694daa KY |
8196 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
8197 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 8198 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
df694daa | 8199 | if (nid) |
baba8ee9 | 8200 | alc861_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 8201 | spec->multiout.dac_nids[i]); |
df694daa KY |
8202 | } |
8203 | } | |
8204 | ||
8205 | static void alc861_auto_init_hp_out(struct hda_codec *codec) | |
8206 | { | |
8207 | struct alc_spec *spec = codec->spec; | |
8208 | hda_nid_t pin; | |
8209 | ||
eb06ed8f | 8210 | pin = spec->autocfg.hp_pins[0]; |
df694daa | 8211 | if (pin) /* connect to front */ |
f12ab1e0 TI |
8212 | alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, |
8213 | spec->multiout.dac_nids[0]); | |
df694daa KY |
8214 | } |
8215 | ||
8216 | static void alc861_auto_init_analog_input(struct hda_codec *codec) | |
8217 | { | |
8218 | struct alc_spec *spec = codec->spec; | |
8219 | int i; | |
8220 | ||
8221 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
8222 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
f12ab1e0 TI |
8223 | if (nid >= 0x0c && nid <= 0x11) { |
8224 | snd_hda_codec_write(codec, nid, 0, | |
8225 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8226 | i <= AUTO_PIN_FRONT_MIC ? | |
8227 | PIN_VREF80 : PIN_IN); | |
df694daa KY |
8228 | } |
8229 | } | |
8230 | } | |
8231 | ||
8232 | /* parse the BIOS configuration and set up the alc_spec */ | |
f12ab1e0 TI |
8233 | /* return 1 if successful, 0 if the proper config is not found, |
8234 | * or a negative error code | |
8235 | */ | |
df694daa KY |
8236 | static int alc861_parse_auto_config(struct hda_codec *codec) |
8237 | { | |
8238 | struct alc_spec *spec = codec->spec; | |
8239 | int err; | |
8240 | static hda_nid_t alc861_ignore[] = { 0x1d, 0 }; | |
8241 | ||
f12ab1e0 TI |
8242 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
8243 | alc861_ignore); | |
8244 | if (err < 0) | |
df694daa | 8245 | return err; |
f12ab1e0 | 8246 | if (!spec->autocfg.line_outs) |
df694daa KY |
8247 | return 0; /* can't find valid BIOS pin config */ |
8248 | ||
f12ab1e0 TI |
8249 | err = alc861_auto_fill_dac_nids(spec, &spec->autocfg); |
8250 | if (err < 0) | |
8251 | return err; | |
8252 | err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
8253 | if (err < 0) | |
8254 | return err; | |
8255 | err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); | |
8256 | if (err < 0) | |
8257 | return err; | |
8258 | err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
8259 | if (err < 0) | |
df694daa KY |
8260 | return err; |
8261 | ||
8262 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
8263 | ||
8264 | if (spec->autocfg.dig_out_pin) | |
8265 | spec->multiout.dig_out_nid = ALC861_DIGOUT_NID; | |
8266 | ||
8267 | if (spec->kctl_alloc) | |
8268 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
8269 | ||
8270 | spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs; | |
8271 | ||
a1e8d2da | 8272 | spec->num_mux_defs = 1; |
df694daa KY |
8273 | spec->input_mux = &spec->private_imux; |
8274 | ||
8275 | spec->adc_nids = alc861_adc_nids; | |
8276 | spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); | |
8277 | spec->mixers[spec->num_mixers] = alc861_capture_mixer; | |
8278 | spec->num_mixers++; | |
8279 | ||
8280 | return 1; | |
8281 | } | |
8282 | ||
ae6b813a TI |
8283 | /* additional initialization for auto-configuration model */ |
8284 | static void alc861_auto_init(struct hda_codec *codec) | |
df694daa | 8285 | { |
df694daa KY |
8286 | alc861_auto_init_multi_out(codec); |
8287 | alc861_auto_init_hp_out(codec); | |
8288 | alc861_auto_init_analog_input(codec); | |
df694daa KY |
8289 | } |
8290 | ||
8291 | ||
8292 | /* | |
8293 | * configuration and preset | |
8294 | */ | |
f5fcc13c TI |
8295 | static const char *alc861_models[ALC861_MODEL_LAST] = { |
8296 | [ALC861_3ST] = "3stack", | |
8297 | [ALC660_3ST] = "3stack-660", | |
8298 | [ALC861_3ST_DIG] = "3stack-dig", | |
8299 | [ALC861_6ST_DIG] = "6stack-dig", | |
8300 | [ALC861_UNIWILL_M31] = "uniwill-m31", | |
8301 | [ALC861_TOSHIBA] = "toshiba", | |
8302 | [ALC861_ASUS] = "asus", | |
8303 | [ALC861_ASUS_LAPTOP] = "asus-laptop", | |
8304 | [ALC861_AUTO] = "auto", | |
8305 | }; | |
8306 | ||
8307 | static struct snd_pci_quirk alc861_cfg_tbl[] = { | |
687a47bd | 8308 | SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST), |
f5fcc13c TI |
8309 | SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP), |
8310 | SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP), | |
8311 | SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS), | |
8312 | SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660_3ST), | |
ad5e7737 | 8313 | SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA), |
f5fcc13c TI |
8314 | SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), |
8315 | SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31), | |
4147dab6 | 8316 | SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31), |
07e038b3 | 8317 | SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST), |
f5fcc13c | 8318 | SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST), |
df694daa KY |
8319 | {} |
8320 | }; | |
8321 | ||
8322 | static struct alc_config_preset alc861_presets[] = { | |
8323 | [ALC861_3ST] = { | |
8324 | .mixers = { alc861_3ST_mixer }, | |
8325 | .init_verbs = { alc861_threestack_init_verbs }, | |
8326 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
8327 | .dac_nids = alc861_dac_nids, | |
8328 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
8329 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 8330 | .need_dac_fix = 1, |
df694daa KY |
8331 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
8332 | .adc_nids = alc861_adc_nids, | |
8333 | .input_mux = &alc861_capture_source, | |
8334 | }, | |
8335 | [ALC861_3ST_DIG] = { | |
8336 | .mixers = { alc861_base_mixer }, | |
8337 | .init_verbs = { alc861_threestack_init_verbs }, | |
8338 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
8339 | .dac_nids = alc861_dac_nids, | |
8340 | .dig_out_nid = ALC861_DIGOUT_NID, | |
8341 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
8342 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 8343 | .need_dac_fix = 1, |
df694daa KY |
8344 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
8345 | .adc_nids = alc861_adc_nids, | |
8346 | .input_mux = &alc861_capture_source, | |
8347 | }, | |
8348 | [ALC861_6ST_DIG] = { | |
8349 | .mixers = { alc861_base_mixer }, | |
8350 | .init_verbs = { alc861_base_init_verbs }, | |
8351 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
8352 | .dac_nids = alc861_dac_nids, | |
8353 | .dig_out_nid = ALC861_DIGOUT_NID, | |
8354 | .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes), | |
8355 | .channel_mode = alc861_8ch_modes, | |
8356 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
8357 | .adc_nids = alc861_adc_nids, | |
8358 | .input_mux = &alc861_capture_source, | |
8359 | }, | |
9c7f852e TI |
8360 | [ALC660_3ST] = { |
8361 | .mixers = { alc861_3ST_mixer }, | |
8362 | .init_verbs = { alc861_threestack_init_verbs }, | |
8363 | .num_dacs = ARRAY_SIZE(alc660_dac_nids), | |
8364 | .dac_nids = alc660_dac_nids, | |
8365 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
8366 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 8367 | .need_dac_fix = 1, |
9c7f852e TI |
8368 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
8369 | .adc_nids = alc861_adc_nids, | |
8370 | .input_mux = &alc861_capture_source, | |
8371 | }, | |
22309c3e TI |
8372 | [ALC861_UNIWILL_M31] = { |
8373 | .mixers = { alc861_uniwill_m31_mixer }, | |
8374 | .init_verbs = { alc861_uniwill_m31_init_verbs }, | |
8375 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
8376 | .dac_nids = alc861_dac_nids, | |
8377 | .dig_out_nid = ALC861_DIGOUT_NID, | |
8378 | .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes), | |
8379 | .channel_mode = alc861_uniwill_m31_modes, | |
8380 | .need_dac_fix = 1, | |
8381 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
8382 | .adc_nids = alc861_adc_nids, | |
8383 | .input_mux = &alc861_capture_source, | |
8384 | }, | |
a53d1aec TD |
8385 | [ALC861_TOSHIBA] = { |
8386 | .mixers = { alc861_toshiba_mixer }, | |
f12ab1e0 TI |
8387 | .init_verbs = { alc861_base_init_verbs, |
8388 | alc861_toshiba_init_verbs }, | |
a53d1aec TD |
8389 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), |
8390 | .dac_nids = alc861_dac_nids, | |
8391 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
8392 | .channel_mode = alc883_3ST_2ch_modes, | |
8393 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
8394 | .adc_nids = alc861_adc_nids, | |
8395 | .input_mux = &alc861_capture_source, | |
8396 | .unsol_event = alc861_toshiba_unsol_event, | |
8397 | .init_hook = alc861_toshiba_automute, | |
8398 | }, | |
7cdbff94 MD |
8399 | [ALC861_ASUS] = { |
8400 | .mixers = { alc861_asus_mixer }, | |
8401 | .init_verbs = { alc861_asus_init_verbs }, | |
8402 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
8403 | .dac_nids = alc861_dac_nids, | |
8404 | .dig_out_nid = ALC861_DIGOUT_NID, | |
8405 | .num_channel_mode = ARRAY_SIZE(alc861_asus_modes), | |
8406 | .channel_mode = alc861_asus_modes, | |
8407 | .need_dac_fix = 1, | |
8408 | .hp_nid = 0x06, | |
8409 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
8410 | .adc_nids = alc861_adc_nids, | |
8411 | .input_mux = &alc861_capture_source, | |
8412 | }, | |
56bb0cab TI |
8413 | [ALC861_ASUS_LAPTOP] = { |
8414 | .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer }, | |
8415 | .init_verbs = { alc861_asus_init_verbs, | |
8416 | alc861_asus_laptop_init_verbs }, | |
8417 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
8418 | .dac_nids = alc861_dac_nids, | |
8419 | .dig_out_nid = ALC861_DIGOUT_NID, | |
8420 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
8421 | .channel_mode = alc883_3ST_2ch_modes, | |
8422 | .need_dac_fix = 1, | |
8423 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
8424 | .adc_nids = alc861_adc_nids, | |
8425 | .input_mux = &alc861_capture_source, | |
8426 | }, | |
8427 | }; | |
df694daa KY |
8428 | |
8429 | ||
8430 | static int patch_alc861(struct hda_codec *codec) | |
8431 | { | |
8432 | struct alc_spec *spec; | |
8433 | int board_config; | |
8434 | int err; | |
8435 | ||
dc041e0b | 8436 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
df694daa KY |
8437 | if (spec == NULL) |
8438 | return -ENOMEM; | |
8439 | ||
f12ab1e0 | 8440 | codec->spec = spec; |
df694daa | 8441 | |
f5fcc13c TI |
8442 | board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST, |
8443 | alc861_models, | |
8444 | alc861_cfg_tbl); | |
9c7f852e | 8445 | |
f5fcc13c | 8446 | if (board_config < 0) { |
9c7f852e TI |
8447 | printk(KERN_INFO "hda_codec: Unknown model for ALC861, " |
8448 | "trying auto-probe from BIOS...\n"); | |
df694daa KY |
8449 | board_config = ALC861_AUTO; |
8450 | } | |
8451 | ||
8452 | if (board_config == ALC861_AUTO) { | |
8453 | /* automatic parse from the BIOS config */ | |
8454 | err = alc861_parse_auto_config(codec); | |
8455 | if (err < 0) { | |
8456 | alc_free(codec); | |
8457 | return err; | |
f12ab1e0 | 8458 | } else if (!err) { |
9c7f852e TI |
8459 | printk(KERN_INFO |
8460 | "hda_codec: Cannot set up configuration " | |
8461 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
8462 | board_config = ALC861_3ST_DIG; |
8463 | } | |
8464 | } | |
8465 | ||
8466 | if (board_config != ALC861_AUTO) | |
8467 | setup_preset(spec, &alc861_presets[board_config]); | |
8468 | ||
8469 | spec->stream_name_analog = "ALC861 Analog"; | |
8470 | spec->stream_analog_playback = &alc861_pcm_analog_playback; | |
8471 | spec->stream_analog_capture = &alc861_pcm_analog_capture; | |
8472 | ||
8473 | spec->stream_name_digital = "ALC861 Digital"; | |
8474 | spec->stream_digital_playback = &alc861_pcm_digital_playback; | |
8475 | spec->stream_digital_capture = &alc861_pcm_digital_capture; | |
8476 | ||
8477 | codec->patch_ops = alc_patch_ops; | |
8478 | if (board_config == ALC861_AUTO) | |
ae6b813a | 8479 | spec->init_hook = alc861_auto_init; |
df694daa | 8480 | |
1da177e4 LT |
8481 | return 0; |
8482 | } | |
8483 | ||
f32610ed JS |
8484 | /* |
8485 | * ALC861-VD support | |
8486 | * | |
8487 | * Based on ALC882 | |
8488 | * | |
8489 | * In addition, an independent DAC | |
8490 | */ | |
8491 | #define ALC861VD_DIGOUT_NID 0x06 | |
8492 | ||
8493 | static hda_nid_t alc861vd_dac_nids[4] = { | |
8494 | /* front, surr, clfe, side surr */ | |
8495 | 0x02, 0x03, 0x04, 0x05 | |
8496 | }; | |
8497 | ||
8498 | /* dac_nids for ALC660vd are in a different order - according to | |
8499 | * Realtek's driver. | |
8500 | * This should probably tesult in a different mixer for 6stack models | |
8501 | * of ALC660vd codecs, but for now there is only 3stack mixer | |
8502 | * - and it is the same as in 861vd. | |
8503 | * adc_nids in ALC660vd are (is) the same as in 861vd | |
8504 | */ | |
8505 | static hda_nid_t alc660vd_dac_nids[3] = { | |
8506 | /* front, rear, clfe, rear_surr */ | |
8507 | 0x02, 0x04, 0x03 | |
8508 | }; | |
8509 | ||
8510 | static hda_nid_t alc861vd_adc_nids[1] = { | |
8511 | /* ADC0 */ | |
8512 | 0x09, | |
8513 | }; | |
8514 | ||
8515 | /* input MUX */ | |
8516 | /* FIXME: should be a matrix-type input source selection */ | |
8517 | static struct hda_input_mux alc861vd_capture_source = { | |
8518 | .num_items = 4, | |
8519 | .items = { | |
8520 | { "Mic", 0x0 }, | |
8521 | { "Front Mic", 0x1 }, | |
8522 | { "Line", 0x2 }, | |
8523 | { "CD", 0x4 }, | |
8524 | }, | |
8525 | }; | |
8526 | ||
8527 | #define alc861vd_mux_enum_info alc_mux_enum_info | |
8528 | #define alc861vd_mux_enum_get alc_mux_enum_get | |
8529 | ||
8530 | static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol, | |
8531 | struct snd_ctl_elem_value *ucontrol) | |
8532 | { | |
8533 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
8534 | struct alc_spec *spec = codec->spec; | |
8535 | const struct hda_input_mux *imux = spec->input_mux; | |
8536 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
8537 | static hda_nid_t capture_mixers[1] = { 0x22 }; | |
8538 | hda_nid_t nid = capture_mixers[adc_idx]; | |
8539 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; | |
8540 | unsigned int i, idx; | |
8541 | ||
8542 | idx = ucontrol->value.enumerated.item[0]; | |
8543 | if (idx >= imux->num_items) | |
8544 | idx = imux->num_items - 1; | |
f12ab1e0 | 8545 | if (*cur_val == idx && !codec->in_resume) |
f32610ed JS |
8546 | return 0; |
8547 | for (i = 0; i < imux->num_items; i++) { | |
8548 | unsigned int v = (i == idx) ? 0x7000 : 0x7080; | |
8549 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
8550 | v | (imux->items[i].index << 8)); | |
8551 | } | |
8552 | *cur_val = idx; | |
8553 | return 1; | |
8554 | } | |
8555 | ||
8556 | /* | |
8557 | * 2ch mode | |
8558 | */ | |
8559 | static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = { | |
8560 | { 2, NULL } | |
8561 | }; | |
8562 | ||
8563 | /* | |
8564 | * 6ch mode | |
8565 | */ | |
8566 | static struct hda_verb alc861vd_6stack_ch6_init[] = { | |
8567 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
8568 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
8569 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
8570 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
8571 | { } /* end */ | |
8572 | }; | |
8573 | ||
8574 | /* | |
8575 | * 8ch mode | |
8576 | */ | |
8577 | static struct hda_verb alc861vd_6stack_ch8_init[] = { | |
8578 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
8579 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
8580 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
8581 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
8582 | { } /* end */ | |
8583 | }; | |
8584 | ||
8585 | static struct hda_channel_mode alc861vd_6stack_modes[2] = { | |
8586 | { 6, alc861vd_6stack_ch6_init }, | |
8587 | { 8, alc861vd_6stack_ch8_init }, | |
8588 | }; | |
8589 | ||
8590 | static struct snd_kcontrol_new alc861vd_chmode_mixer[] = { | |
8591 | { | |
8592 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
8593 | .name = "Channel Mode", | |
8594 | .info = alc_ch_mode_info, | |
8595 | .get = alc_ch_mode_get, | |
8596 | .put = alc_ch_mode_put, | |
8597 | }, | |
8598 | { } /* end */ | |
8599 | }; | |
8600 | ||
8601 | static struct snd_kcontrol_new alc861vd_capture_mixer[] = { | |
8602 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
8603 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
8604 | ||
8605 | { | |
8606 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
8607 | /* The multiple "Capture Source" controls confuse alsamixer | |
8608 | * So call somewhat different.. | |
8609 | *FIXME: the controls appear in the "playback" view! | |
8610 | */ | |
8611 | /* .name = "Capture Source", */ | |
8612 | .name = "Input Source", | |
8613 | .count = 1, | |
8614 | .info = alc861vd_mux_enum_info, | |
8615 | .get = alc861vd_mux_enum_get, | |
8616 | .put = alc861vd_mux_enum_put, | |
8617 | }, | |
8618 | { } /* end */ | |
8619 | }; | |
8620 | ||
8621 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 | |
8622 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
8623 | */ | |
8624 | static struct snd_kcontrol_new alc861vd_6st_mixer[] = { | |
8625 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
8626 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
8627 | ||
8628 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
8629 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
8630 | ||
8631 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, | |
8632 | HDA_OUTPUT), | |
8633 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, | |
8634 | HDA_OUTPUT), | |
8635 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
8636 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
8637 | ||
8638 | HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT), | |
8639 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
8640 | ||
8641 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
8642 | ||
8643 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
8644 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
8645 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
8646 | ||
8647 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
8648 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
8649 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
8650 | ||
8651 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
8652 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
8653 | ||
8654 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
8655 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
8656 | ||
8657 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
8658 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
8659 | ||
8660 | { } /* end */ | |
8661 | }; | |
8662 | ||
8663 | static struct snd_kcontrol_new alc861vd_3st_mixer[] = { | |
8664 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
8665 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
8666 | ||
8667 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
8668 | ||
8669 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
8670 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
8671 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
8672 | ||
8673 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
8674 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
8675 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
8676 | ||
8677 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
8678 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
8679 | ||
8680 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
8681 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
8682 | ||
8683 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
8684 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
8685 | ||
8686 | { } /* end */ | |
8687 | }; | |
8688 | ||
8689 | /* | |
8690 | * generic initialization of ADC, input mixers and output mixers | |
8691 | */ | |
8692 | static struct hda_verb alc861vd_volume_init_verbs[] = { | |
8693 | /* | |
8694 | * Unmute ADC0 and set the default input to mic-in | |
8695 | */ | |
8696 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8697 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8698 | ||
8699 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of | |
8700 | * the analog-loopback mixer widget | |
8701 | */ | |
8702 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
8703 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8704 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8705 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
8706 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
8707 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
8708 | ||
8709 | /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */ | |
8710 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
8711 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)}, | |
8712 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)}, | |
8713 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(8)}, | |
8714 | ||
8715 | /* | |
8716 | * Set up output mixers (0x02 - 0x05) | |
8717 | */ | |
8718 | /* set vol=0 to output mixers */ | |
8719 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8720 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8721 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8722 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8723 | ||
8724 | /* set up input amps for analog loopback */ | |
8725 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
8726 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
8727 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
8728 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
8729 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
8730 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
8731 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
8732 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
8733 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
8734 | ||
8735 | { } | |
8736 | }; | |
8737 | ||
8738 | /* | |
8739 | * 3-stack pin configuration: | |
8740 | * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b | |
8741 | */ | |
8742 | static struct hda_verb alc861vd_3stack_init_verbs[] = { | |
8743 | /* | |
8744 | * Set pin mode and muting | |
8745 | */ | |
8746 | /* set front pin widgets 0x14 for output */ | |
8747 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
8748 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8749 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8750 | ||
8751 | /* Mic (rear) pin: input vref at 80% */ | |
8752 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
8753 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
8754 | /* Front Mic pin: input vref at 80% */ | |
8755 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
8756 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
8757 | /* Line In pin: input */ | |
8758 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
8759 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
8760 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
8761 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
8762 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8763 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8764 | /* CD pin widget for input */ | |
8765 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
8766 | ||
8767 | { } | |
8768 | }; | |
8769 | ||
8770 | /* | |
8771 | * 6-stack pin configuration: | |
8772 | */ | |
8773 | static struct hda_verb alc861vd_6stack_init_verbs[] = { | |
8774 | /* | |
8775 | * Set pin mode and muting | |
8776 | */ | |
8777 | /* set front pin widgets 0x14 for output */ | |
8778 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
8779 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8780 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8781 | ||
8782 | /* Rear Pin: output 1 (0x0d) */ | |
8783 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
8784 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8785 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
8786 | /* CLFE Pin: output 2 (0x0e) */ | |
8787 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
8788 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8789 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
8790 | /* Side Pin: output 3 (0x0f) */ | |
8791 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
8792 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8793 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
8794 | ||
8795 | /* Mic (rear) pin: input vref at 80% */ | |
8796 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
8797 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
8798 | /* Front Mic pin: input vref at 80% */ | |
8799 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
8800 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
8801 | /* Line In pin: input */ | |
8802 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
8803 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
8804 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
8805 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
8806 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
8807 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8808 | /* CD pin widget for input */ | |
8809 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
8810 | ||
8811 | { } | |
8812 | }; | |
8813 | ||
8814 | /* pcm configuration: identiacal with ALC880 */ | |
8815 | #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback | |
8816 | #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture | |
8817 | #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback | |
8818 | #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture | |
8819 | ||
8820 | /* | |
8821 | * configuration and preset | |
8822 | */ | |
8823 | static const char *alc861vd_models[ALC861VD_MODEL_LAST] = { | |
8824 | [ALC660VD_3ST] = "3stack-660", | |
8825 | [ALC861VD_3ST] = "3stack", | |
8826 | [ALC861VD_3ST_DIG] = "3stack-digout", | |
8827 | [ALC861VD_6ST_DIG] = "6stack-digout", | |
8828 | [ALC861VD_AUTO] = "auto", | |
8829 | }; | |
8830 | ||
8831 | static struct snd_pci_quirk alc861vd_cfg_tbl[] = { | |
07e038b3 | 8832 | SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST), |
f32610ed JS |
8833 | SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST), |
8834 | SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST), | |
8835 | SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST), | |
8836 | ||
8837 | SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_3ST), | |
8838 | {} | |
8839 | }; | |
8840 | ||
8841 | static struct alc_config_preset alc861vd_presets[] = { | |
8842 | [ALC660VD_3ST] = { | |
8843 | .mixers = { alc861vd_3st_mixer }, | |
8844 | .init_verbs = { alc861vd_volume_init_verbs, | |
8845 | alc861vd_3stack_init_verbs }, | |
8846 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
8847 | .dac_nids = alc660vd_dac_nids, | |
8848 | .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids), | |
8849 | .adc_nids = alc861vd_adc_nids, | |
8850 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
8851 | .channel_mode = alc861vd_3stack_2ch_modes, | |
8852 | .input_mux = &alc861vd_capture_source, | |
8853 | }, | |
8854 | [ALC861VD_3ST] = { | |
8855 | .mixers = { alc861vd_3st_mixer }, | |
8856 | .init_verbs = { alc861vd_volume_init_verbs, | |
8857 | alc861vd_3stack_init_verbs }, | |
8858 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
8859 | .dac_nids = alc861vd_dac_nids, | |
8860 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
8861 | .channel_mode = alc861vd_3stack_2ch_modes, | |
8862 | .input_mux = &alc861vd_capture_source, | |
8863 | }, | |
8864 | [ALC861VD_3ST_DIG] = { | |
8865 | .mixers = { alc861vd_3st_mixer }, | |
8866 | .init_verbs = { alc861vd_volume_init_verbs, | |
8867 | alc861vd_3stack_init_verbs }, | |
8868 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
8869 | .dac_nids = alc861vd_dac_nids, | |
8870 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
8871 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
8872 | .channel_mode = alc861vd_3stack_2ch_modes, | |
8873 | .input_mux = &alc861vd_capture_source, | |
8874 | }, | |
8875 | [ALC861VD_6ST_DIG] = { | |
8876 | .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer }, | |
8877 | .init_verbs = { alc861vd_volume_init_verbs, | |
8878 | alc861vd_6stack_init_verbs }, | |
8879 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
8880 | .dac_nids = alc861vd_dac_nids, | |
8881 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
8882 | .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes), | |
8883 | .channel_mode = alc861vd_6stack_modes, | |
8884 | .input_mux = &alc861vd_capture_source, | |
8885 | }, | |
8886 | }; | |
8887 | ||
8888 | /* | |
8889 | * BIOS auto configuration | |
8890 | */ | |
8891 | static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec, | |
8892 | hda_nid_t nid, int pin_type, int dac_idx) | |
8893 | { | |
8894 | /* set as output */ | |
8895 | snd_hda_codec_write(codec, nid, 0, | |
8896 | AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); | |
8897 | snd_hda_codec_write(codec, nid, 0, | |
8898 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); | |
8899 | } | |
8900 | ||
8901 | static void alc861vd_auto_init_multi_out(struct hda_codec *codec) | |
8902 | { | |
8903 | struct alc_spec *spec = codec->spec; | |
8904 | int i; | |
8905 | ||
bc9f98a9 | 8906 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
f32610ed JS |
8907 | for (i = 0; i <= HDA_SIDE; i++) { |
8908 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 8909 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
f32610ed JS |
8910 | if (nid) |
8911 | alc861vd_auto_set_output_and_unmute(codec, nid, | |
baba8ee9 | 8912 | pin_type, i); |
f32610ed JS |
8913 | } |
8914 | } | |
8915 | ||
8916 | ||
8917 | static void alc861vd_auto_init_hp_out(struct hda_codec *codec) | |
8918 | { | |
8919 | struct alc_spec *spec = codec->spec; | |
8920 | hda_nid_t pin; | |
8921 | ||
8922 | pin = spec->autocfg.hp_pins[0]; | |
8923 | if (pin) /* connect to front and use dac 0 */ | |
8924 | alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
8925 | } | |
8926 | ||
8927 | #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid) | |
8928 | #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID | |
8929 | ||
8930 | static void alc861vd_auto_init_analog_input(struct hda_codec *codec) | |
8931 | { | |
8932 | struct alc_spec *spec = codec->spec; | |
8933 | int i; | |
8934 | ||
8935 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
8936 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
8937 | if (alc861vd_is_input_pin(nid)) { | |
8938 | snd_hda_codec_write(codec, nid, 0, | |
8939 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8940 | i <= AUTO_PIN_FRONT_MIC ? | |
8941 | PIN_VREF80 : PIN_IN); | |
8942 | if (nid != ALC861VD_PIN_CD_NID) | |
8943 | snd_hda_codec_write(codec, nid, 0, | |
8944 | AC_VERB_SET_AMP_GAIN_MUTE, | |
8945 | AMP_OUT_MUTE); | |
8946 | } | |
8947 | } | |
8948 | } | |
8949 | ||
8950 | #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02) | |
8951 | #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c) | |
8952 | ||
8953 | /* add playback controls from the parsed DAC table */ | |
8954 | /* Based on ALC880 version. But ALC861VD has separate, | |
8955 | * different NIDs for mute/unmute switch and volume control */ | |
8956 | static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec, | |
8957 | const struct auto_pin_cfg *cfg) | |
8958 | { | |
8959 | char name[32]; | |
8960 | static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"}; | |
8961 | hda_nid_t nid_v, nid_s; | |
8962 | int i, err; | |
8963 | ||
8964 | for (i = 0; i < cfg->line_outs; i++) { | |
f12ab1e0 | 8965 | if (!spec->multiout.dac_nids[i]) |
f32610ed JS |
8966 | continue; |
8967 | nid_v = alc861vd_idx_to_mixer_vol( | |
8968 | alc880_dac_to_idx( | |
8969 | spec->multiout.dac_nids[i])); | |
8970 | nid_s = alc861vd_idx_to_mixer_switch( | |
8971 | alc880_dac_to_idx( | |
8972 | spec->multiout.dac_nids[i])); | |
8973 | ||
8974 | if (i == 2) { | |
8975 | /* Center/LFE */ | |
f12ab1e0 TI |
8976 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
8977 | "Center Playback Volume", | |
8978 | HDA_COMPOSE_AMP_VAL(nid_v, 1, 0, | |
8979 | HDA_OUTPUT)); | |
8980 | if (err < 0) | |
f32610ed | 8981 | return err; |
f12ab1e0 TI |
8982 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
8983 | "LFE Playback Volume", | |
8984 | HDA_COMPOSE_AMP_VAL(nid_v, 2, 0, | |
8985 | HDA_OUTPUT)); | |
8986 | if (err < 0) | |
f32610ed | 8987 | return err; |
f12ab1e0 TI |
8988 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
8989 | "Center Playback Switch", | |
8990 | HDA_COMPOSE_AMP_VAL(nid_s, 1, 2, | |
8991 | HDA_INPUT)); | |
8992 | if (err < 0) | |
f32610ed | 8993 | return err; |
f12ab1e0 TI |
8994 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
8995 | "LFE Playback Switch", | |
8996 | HDA_COMPOSE_AMP_VAL(nid_s, 2, 2, | |
8997 | HDA_INPUT)); | |
8998 | if (err < 0) | |
f32610ed JS |
8999 | return err; |
9000 | } else { | |
9001 | sprintf(name, "%s Playback Volume", chname[i]); | |
f12ab1e0 TI |
9002 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
9003 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, | |
9004 | HDA_OUTPUT)); | |
9005 | if (err < 0) | |
f32610ed JS |
9006 | return err; |
9007 | sprintf(name, "%s Playback Switch", chname[i]); | |
f12ab1e0 TI |
9008 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
9009 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 2, | |
9010 | HDA_INPUT)); | |
9011 | if (err < 0) | |
f32610ed JS |
9012 | return err; |
9013 | } | |
9014 | } | |
9015 | return 0; | |
9016 | } | |
9017 | ||
9018 | /* add playback controls for speaker and HP outputs */ | |
9019 | /* Based on ALC880 version. But ALC861VD has separate, | |
9020 | * different NIDs for mute/unmute switch and volume control */ | |
9021 | static int alc861vd_auto_create_extra_out(struct alc_spec *spec, | |
9022 | hda_nid_t pin, const char *pfx) | |
9023 | { | |
9024 | hda_nid_t nid_v, nid_s; | |
9025 | int err; | |
9026 | char name[32]; | |
9027 | ||
f12ab1e0 | 9028 | if (!pin) |
f32610ed JS |
9029 | return 0; |
9030 | ||
9031 | if (alc880_is_fixed_pin(pin)) { | |
9032 | nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
9033 | /* specify the DAC as the extra output */ | |
f12ab1e0 | 9034 | if (!spec->multiout.hp_nid) |
f32610ed JS |
9035 | spec->multiout.hp_nid = nid_v; |
9036 | else | |
9037 | spec->multiout.extra_out_nid[0] = nid_v; | |
9038 | /* control HP volume/switch on the output mixer amp */ | |
9039 | nid_v = alc861vd_idx_to_mixer_vol( | |
9040 | alc880_fixed_pin_idx(pin)); | |
9041 | nid_s = alc861vd_idx_to_mixer_switch( | |
9042 | alc880_fixed_pin_idx(pin)); | |
9043 | ||
9044 | sprintf(name, "%s Playback Volume", pfx); | |
f12ab1e0 TI |
9045 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
9046 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT)); | |
9047 | if (err < 0) | |
f32610ed JS |
9048 | return err; |
9049 | sprintf(name, "%s Playback Switch", pfx); | |
f12ab1e0 TI |
9050 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
9051 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT)); | |
9052 | if (err < 0) | |
f32610ed JS |
9053 | return err; |
9054 | } else if (alc880_is_multi_pin(pin)) { | |
9055 | /* set manual connection */ | |
9056 | /* we have only a switch on HP-out PIN */ | |
9057 | sprintf(name, "%s Playback Switch", pfx); | |
f12ab1e0 TI |
9058 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
9059 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
9060 | if (err < 0) | |
f32610ed JS |
9061 | return err; |
9062 | } | |
9063 | return 0; | |
9064 | } | |
9065 | ||
9066 | /* parse the BIOS configuration and set up the alc_spec | |
9067 | * return 1 if successful, 0 if the proper config is not found, | |
9068 | * or a negative error code | |
9069 | * Based on ALC880 version - had to change it to override | |
9070 | * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */ | |
9071 | static int alc861vd_parse_auto_config(struct hda_codec *codec) | |
9072 | { | |
9073 | struct alc_spec *spec = codec->spec; | |
9074 | int err; | |
9075 | static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; | |
9076 | ||
f12ab1e0 TI |
9077 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
9078 | alc861vd_ignore); | |
9079 | if (err < 0) | |
f32610ed | 9080 | return err; |
f12ab1e0 | 9081 | if (!spec->autocfg.line_outs) |
f32610ed JS |
9082 | return 0; /* can't find valid BIOS pin config */ |
9083 | ||
f12ab1e0 TI |
9084 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
9085 | if (err < 0) | |
9086 | return err; | |
9087 | err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
9088 | if (err < 0) | |
9089 | return err; | |
9090 | err = alc861vd_auto_create_extra_out(spec, | |
9091 | spec->autocfg.speaker_pins[0], | |
9092 | "Speaker"); | |
9093 | if (err < 0) | |
9094 | return err; | |
9095 | err = alc861vd_auto_create_extra_out(spec, | |
9096 | spec->autocfg.hp_pins[0], | |
9097 | "Headphone"); | |
9098 | if (err < 0) | |
9099 | return err; | |
9100 | err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
9101 | if (err < 0) | |
f32610ed JS |
9102 | return err; |
9103 | ||
9104 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
9105 | ||
9106 | if (spec->autocfg.dig_out_pin) | |
9107 | spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID; | |
9108 | ||
9109 | if (spec->kctl_alloc) | |
9110 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
9111 | ||
9112 | spec->init_verbs[spec->num_init_verbs++] | |
9113 | = alc861vd_volume_init_verbs; | |
9114 | ||
9115 | spec->num_mux_defs = 1; | |
9116 | spec->input_mux = &spec->private_imux; | |
9117 | ||
9118 | return 1; | |
9119 | } | |
9120 | ||
9121 | /* additional initialization for auto-configuration model */ | |
9122 | static void alc861vd_auto_init(struct hda_codec *codec) | |
9123 | { | |
9124 | alc861vd_auto_init_multi_out(codec); | |
9125 | alc861vd_auto_init_hp_out(codec); | |
9126 | alc861vd_auto_init_analog_input(codec); | |
9127 | } | |
9128 | ||
9129 | static int patch_alc861vd(struct hda_codec *codec) | |
9130 | { | |
9131 | struct alc_spec *spec; | |
9132 | int err, board_config; | |
9133 | ||
9134 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
9135 | if (spec == NULL) | |
9136 | return -ENOMEM; | |
9137 | ||
9138 | codec->spec = spec; | |
9139 | ||
9140 | board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST, | |
9141 | alc861vd_models, | |
9142 | alc861vd_cfg_tbl); | |
9143 | ||
9144 | if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) { | |
9145 | printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/" | |
9146 | "ALC861VD, trying auto-probe from BIOS...\n"); | |
9147 | board_config = ALC861VD_AUTO; | |
9148 | } | |
9149 | ||
9150 | if (board_config == ALC861VD_AUTO) { | |
9151 | /* automatic parse from the BIOS config */ | |
9152 | err = alc861vd_parse_auto_config(codec); | |
9153 | if (err < 0) { | |
9154 | alc_free(codec); | |
9155 | return err; | |
f12ab1e0 | 9156 | } else if (!err) { |
f32610ed JS |
9157 | printk(KERN_INFO |
9158 | "hda_codec: Cannot set up configuration " | |
9159 | "from BIOS. Using base mode...\n"); | |
9160 | board_config = ALC861VD_3ST; | |
9161 | } | |
9162 | } | |
9163 | ||
9164 | if (board_config != ALC861VD_AUTO) | |
9165 | setup_preset(spec, &alc861vd_presets[board_config]); | |
9166 | ||
9167 | spec->stream_name_analog = "ALC861VD Analog"; | |
9168 | spec->stream_analog_playback = &alc861vd_pcm_analog_playback; | |
9169 | spec->stream_analog_capture = &alc861vd_pcm_analog_capture; | |
9170 | ||
9171 | spec->stream_name_digital = "ALC861VD Digital"; | |
9172 | spec->stream_digital_playback = &alc861vd_pcm_digital_playback; | |
9173 | spec->stream_digital_capture = &alc861vd_pcm_digital_capture; | |
9174 | ||
9175 | spec->adc_nids = alc861vd_adc_nids; | |
9176 | spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids); | |
9177 | ||
9178 | spec->mixers[spec->num_mixers] = alc861vd_capture_mixer; | |
9179 | spec->num_mixers++; | |
9180 | ||
9181 | codec->patch_ops = alc_patch_ops; | |
9182 | ||
9183 | if (board_config == ALC861VD_AUTO) | |
9184 | spec->init_hook = alc861vd_auto_init; | |
9185 | ||
9186 | return 0; | |
9187 | } | |
9188 | ||
bc9f98a9 KY |
9189 | /* |
9190 | * ALC662 support | |
9191 | * | |
9192 | * ALC662 is almost identical with ALC880 but has cleaner and more flexible | |
9193 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
9194 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
9195 | * 6-channel independent captures. | |
9196 | * | |
9197 | * In addition, an independent DAC for the multi-playback (not used in this | |
9198 | * driver yet). | |
9199 | */ | |
9200 | #define ALC662_DIGOUT_NID 0x06 | |
9201 | #define ALC662_DIGIN_NID 0x0a | |
9202 | ||
9203 | static hda_nid_t alc662_dac_nids[4] = { | |
9204 | /* front, rear, clfe, rear_surr */ | |
9205 | 0x02, 0x03, 0x04 | |
9206 | }; | |
9207 | ||
9208 | static hda_nid_t alc662_adc_nids[1] = { | |
9209 | /* ADC1-2 */ | |
9210 | 0x09, | |
9211 | }; | |
9212 | /* input MUX */ | |
9213 | /* FIXME: should be a matrix-type input source selection */ | |
9214 | ||
9215 | static struct hda_input_mux alc662_capture_source = { | |
9216 | .num_items = 4, | |
9217 | .items = { | |
9218 | { "Mic", 0x0 }, | |
9219 | { "Front Mic", 0x1 }, | |
9220 | { "Line", 0x2 }, | |
9221 | { "CD", 0x4 }, | |
9222 | }, | |
9223 | }; | |
9224 | ||
9225 | static struct hda_input_mux alc662_lenovo_101e_capture_source = { | |
9226 | .num_items = 2, | |
9227 | .items = { | |
9228 | { "Mic", 0x1 }, | |
9229 | { "Line", 0x2 }, | |
9230 | }, | |
9231 | }; | |
9232 | #define alc662_mux_enum_info alc_mux_enum_info | |
9233 | #define alc662_mux_enum_get alc_mux_enum_get | |
9234 | ||
9235 | static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol, | |
9236 | struct snd_ctl_elem_value *ucontrol) | |
9237 | { | |
9238 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
9239 | struct alc_spec *spec = codec->spec; | |
9240 | const struct hda_input_mux *imux = spec->input_mux; | |
9241 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
9242 | static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 }; | |
9243 | hda_nid_t nid = capture_mixers[adc_idx]; | |
9244 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; | |
9245 | unsigned int i, idx; | |
9246 | ||
9247 | idx = ucontrol->value.enumerated.item[0]; | |
9248 | if (idx >= imux->num_items) | |
9249 | idx = imux->num_items - 1; | |
f12ab1e0 | 9250 | if (*cur_val == idx && !codec->in_resume) |
bc9f98a9 KY |
9251 | return 0; |
9252 | for (i = 0; i < imux->num_items; i++) { | |
9253 | unsigned int v = (i == idx) ? 0x7000 : 0x7080; | |
9254 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
9255 | v | (imux->items[i].index << 8)); | |
9256 | } | |
9257 | *cur_val = idx; | |
9258 | return 1; | |
9259 | } | |
9260 | /* | |
9261 | * 2ch mode | |
9262 | */ | |
9263 | static struct hda_channel_mode alc662_3ST_2ch_modes[1] = { | |
9264 | { 2, NULL } | |
9265 | }; | |
9266 | ||
9267 | /* | |
9268 | * 2ch mode | |
9269 | */ | |
9270 | static struct hda_verb alc662_3ST_ch2_init[] = { | |
9271 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
9272 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
9273 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
9274 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
9275 | { } /* end */ | |
9276 | }; | |
9277 | ||
9278 | /* | |
9279 | * 6ch mode | |
9280 | */ | |
9281 | static struct hda_verb alc662_3ST_ch6_init[] = { | |
9282 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
9283 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
9284 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
9285 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
9286 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
9287 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
9288 | { } /* end */ | |
9289 | }; | |
9290 | ||
9291 | static struct hda_channel_mode alc662_3ST_6ch_modes[2] = { | |
9292 | { 2, alc662_3ST_ch2_init }, | |
9293 | { 6, alc662_3ST_ch6_init }, | |
9294 | }; | |
9295 | ||
9296 | /* | |
9297 | * 2ch mode | |
9298 | */ | |
9299 | static struct hda_verb alc662_sixstack_ch6_init[] = { | |
9300 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
9301 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
9302 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
9303 | { } /* end */ | |
9304 | }; | |
9305 | ||
9306 | /* | |
9307 | * 6ch mode | |
9308 | */ | |
9309 | static struct hda_verb alc662_sixstack_ch8_init[] = { | |
9310 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
9311 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
9312 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
9313 | { } /* end */ | |
9314 | }; | |
9315 | ||
9316 | static struct hda_channel_mode alc662_5stack_modes[2] = { | |
9317 | { 2, alc662_sixstack_ch6_init }, | |
9318 | { 6, alc662_sixstack_ch8_init }, | |
9319 | }; | |
9320 | ||
9321 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 | |
9322 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
9323 | */ | |
9324 | ||
9325 | static struct snd_kcontrol_new alc662_base_mixer[] = { | |
9326 | /* output mixer control */ | |
9327 | HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT), | |
9328 | HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT), | |
9329 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT), | |
9330 | HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
9331 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), | |
9332 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), | |
9333 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT), | |
9334 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT), | |
9335 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
9336 | ||
9337 | /*Input mixer control */ | |
9338 | HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT), | |
9339 | HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT), | |
9340 | HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT), | |
9341 | HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT), | |
9342 | HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT), | |
9343 | HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT), | |
9344 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT), | |
9345 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT), | |
9346 | ||
9347 | /* Capture mixer control */ | |
9348 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
9349 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
9350 | { | |
9351 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9352 | .name = "Capture Source", | |
9353 | .count = 1, | |
9354 | .info = alc_mux_enum_info, | |
9355 | .get = alc_mux_enum_get, | |
9356 | .put = alc_mux_enum_put, | |
9357 | }, | |
9358 | { } /* end */ | |
9359 | }; | |
9360 | ||
9361 | static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = { | |
9362 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
9363 | HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT), | |
9364 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
9365 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
9366 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
9367 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
9368 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
9369 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9370 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9371 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
9372 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
9373 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
9374 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
9375 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
9376 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
9377 | { | |
9378 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9379 | /* .name = "Capture Source", */ | |
9380 | .name = "Input Source", | |
9381 | .count = 1, | |
9382 | .info = alc662_mux_enum_info, | |
9383 | .get = alc662_mux_enum_get, | |
9384 | .put = alc662_mux_enum_put, | |
9385 | }, | |
9386 | { } /* end */ | |
9387 | }; | |
9388 | ||
9389 | static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = { | |
9390 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
9391 | HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT), | |
9392 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
9393 | HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT), | |
9394 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), | |
9395 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), | |
9396 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT), | |
9397 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT), | |
9398 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
9399 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
9400 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
9401 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
9402 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
9403 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9404 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9405 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
9406 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
9407 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
9408 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
9409 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
9410 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
9411 | { | |
9412 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9413 | /* .name = "Capture Source", */ | |
9414 | .name = "Input Source", | |
9415 | .count = 1, | |
9416 | .info = alc662_mux_enum_info, | |
9417 | .get = alc662_mux_enum_get, | |
9418 | .put = alc662_mux_enum_put, | |
9419 | }, | |
9420 | { } /* end */ | |
9421 | }; | |
9422 | ||
9423 | static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = { | |
9424 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
9425 | HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT), | |
9426 | HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
9427 | HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT), | |
9428 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
9429 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
9430 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
9431 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
9432 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
9433 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
9434 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
9435 | { | |
9436 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9437 | /* .name = "Capture Source", */ | |
9438 | .name = "Input Source", | |
9439 | .count = 1, | |
9440 | .info = alc662_mux_enum_info, | |
9441 | .get = alc662_mux_enum_get, | |
9442 | .put = alc662_mux_enum_put, | |
9443 | }, | |
9444 | { } /* end */ | |
9445 | }; | |
9446 | ||
9447 | static struct snd_kcontrol_new alc662_chmode_mixer[] = { | |
9448 | { | |
9449 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9450 | .name = "Channel Mode", | |
9451 | .info = alc_ch_mode_info, | |
9452 | .get = alc_ch_mode_get, | |
9453 | .put = alc_ch_mode_put, | |
9454 | }, | |
9455 | { } /* end */ | |
9456 | }; | |
9457 | ||
9458 | static struct hda_verb alc662_init_verbs[] = { | |
9459 | /* ADC: mute amp left and right */ | |
9460 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
9461 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9462 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
9463 | ||
9464 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9465 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9466 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
9467 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
9468 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
9469 | ||
9470 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9471 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9472 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9473 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9474 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9475 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9476 | ||
9477 | /* Front Pin: output 0 (0x0c) */ | |
9478 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9479 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9480 | ||
9481 | /* Rear Pin: output 1 (0x0d) */ | |
9482 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9483 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9484 | ||
9485 | /* CLFE Pin: output 2 (0x0e) */ | |
9486 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9487 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9488 | ||
9489 | /* Mic (rear) pin: input vref at 80% */ | |
9490 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
9491 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9492 | /* Front Mic pin: input vref at 80% */ | |
9493 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
9494 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9495 | /* Line In pin: input */ | |
9496 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
9497 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9498 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
9499 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
9500 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9501 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9502 | /* CD pin widget for input */ | |
9503 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
9504 | ||
9505 | /* FIXME: use matrix-type input source selection */ | |
9506 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
9507 | /* Input mixer */ | |
9508 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9509 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9510 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
9511 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
9512 | { } | |
9513 | }; | |
9514 | ||
9515 | static struct hda_verb alc662_sue_init_verbs[] = { | |
9516 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT}, | |
9517 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT}, | |
9518 | {} | |
9519 | }; | |
9520 | ||
9521 | /* | |
9522 | * generic initialization of ADC, input mixers and output mixers | |
9523 | */ | |
9524 | static struct hda_verb alc662_auto_init_verbs[] = { | |
9525 | /* | |
9526 | * Unmute ADC and set the default input to mic-in | |
9527 | */ | |
9528 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9529 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9530 | ||
9531 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | |
9532 | * mixer widget | |
9533 | * Note: PASD motherboards uses the Line In 2 as the input for front | |
9534 | * panel mic (mic 2) | |
9535 | */ | |
9536 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
9537 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9538 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9539 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
9540 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
9541 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
9542 | ||
9543 | /* | |
9544 | * Set up output mixers (0x0c - 0x0f) | |
9545 | */ | |
9546 | /* set vol=0 to output mixers */ | |
9547 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9548 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9549 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9550 | ||
9551 | /* set up input amps for analog loopback */ | |
9552 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
9553 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9554 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9555 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9556 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9557 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9558 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9559 | ||
9560 | ||
9561 | /* FIXME: use matrix-type input source selection */ | |
9562 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
9563 | /* Input mixer */ | |
9564 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9565 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9566 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
9567 | /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/ | |
9568 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
9569 | ||
9570 | { } | |
9571 | }; | |
9572 | ||
9573 | /* capture mixer elements */ | |
9574 | static struct snd_kcontrol_new alc662_capture_mixer[] = { | |
9575 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
9576 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
9577 | { | |
9578 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9579 | /* The multiple "Capture Source" controls confuse alsamixer | |
9580 | * So call somewhat different.. | |
9581 | * FIXME: the controls appear in the "playback" view! | |
9582 | */ | |
9583 | /* .name = "Capture Source", */ | |
9584 | .name = "Input Source", | |
9585 | .count = 1, | |
9586 | .info = alc882_mux_enum_info, | |
9587 | .get = alc882_mux_enum_get, | |
9588 | .put = alc882_mux_enum_put, | |
9589 | }, | |
9590 | { } /* end */ | |
9591 | }; | |
9592 | ||
9593 | static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec) | |
9594 | { | |
9595 | unsigned int present; | |
f12ab1e0 | 9596 | unsigned char bits; |
bc9f98a9 KY |
9597 | |
9598 | present = snd_hda_codec_read(codec, 0x14, 0, | |
9599 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
f12ab1e0 | 9600 | bits = present ? 0x80 : 0; |
bc9f98a9 | 9601 | snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, |
f12ab1e0 | 9602 | 0x80, bits); |
bc9f98a9 | 9603 | snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, |
f12ab1e0 | 9604 | 0x80, bits); |
bc9f98a9 KY |
9605 | } |
9606 | ||
9607 | static void alc662_lenovo_101e_all_automute(struct hda_codec *codec) | |
9608 | { | |
9609 | unsigned int present; | |
f12ab1e0 | 9610 | unsigned char bits; |
bc9f98a9 KY |
9611 | |
9612 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
9613 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
f12ab1e0 | 9614 | bits = present ? 0x80 : 0; |
bc9f98a9 | 9615 | snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, |
f12ab1e0 | 9616 | 0x80, bits); |
bc9f98a9 | 9617 | snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, |
f12ab1e0 | 9618 | 0x80, bits); |
bc9f98a9 | 9619 | snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, |
f12ab1e0 | 9620 | 0x80, bits); |
bc9f98a9 | 9621 | snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, |
f12ab1e0 | 9622 | 0x80, bits); |
bc9f98a9 KY |
9623 | } |
9624 | ||
9625 | static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec, | |
9626 | unsigned int res) | |
9627 | { | |
9628 | if ((res >> 26) == ALC880_HP_EVENT) | |
9629 | alc662_lenovo_101e_all_automute(codec); | |
9630 | if ((res >> 26) == ALC880_FRONT_EVENT) | |
9631 | alc662_lenovo_101e_ispeaker_automute(codec); | |
9632 | } | |
9633 | ||
9634 | ||
9635 | /* pcm configuration: identiacal with ALC880 */ | |
9636 | #define alc662_pcm_analog_playback alc880_pcm_analog_playback | |
9637 | #define alc662_pcm_analog_capture alc880_pcm_analog_capture | |
9638 | #define alc662_pcm_digital_playback alc880_pcm_digital_playback | |
9639 | #define alc662_pcm_digital_capture alc880_pcm_digital_capture | |
9640 | ||
9641 | /* | |
9642 | * configuration and preset | |
9643 | */ | |
9644 | static const char *alc662_models[ALC662_MODEL_LAST] = { | |
9645 | [ALC662_3ST_2ch_DIG] = "3stack-dig", | |
9646 | [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig", | |
9647 | [ALC662_3ST_6ch] = "3stack-6ch", | |
9648 | [ALC662_5ST_DIG] = "6stack-dig", | |
9649 | [ALC662_LENOVO_101E] = "lenovo-101e", | |
9650 | [ALC662_AUTO] = "auto", | |
9651 | }; | |
9652 | ||
9653 | static struct snd_pci_quirk alc662_cfg_tbl[] = { | |
9654 | SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E), | |
9655 | {} | |
9656 | }; | |
9657 | ||
9658 | static struct alc_config_preset alc662_presets[] = { | |
9659 | [ALC662_3ST_2ch_DIG] = { | |
9660 | .mixers = { alc662_3ST_2ch_mixer }, | |
9661 | .init_verbs = { alc662_init_verbs }, | |
9662 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
9663 | .dac_nids = alc662_dac_nids, | |
9664 | .dig_out_nid = ALC662_DIGOUT_NID, | |
9665 | .num_adc_nids = ARRAY_SIZE(alc662_adc_nids), | |
9666 | .adc_nids = alc662_adc_nids, | |
9667 | .dig_in_nid = ALC662_DIGIN_NID, | |
9668 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
9669 | .channel_mode = alc662_3ST_2ch_modes, | |
9670 | .input_mux = &alc662_capture_source, | |
9671 | }, | |
9672 | [ALC662_3ST_6ch_DIG] = { | |
9673 | .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer }, | |
9674 | .init_verbs = { alc662_init_verbs }, | |
9675 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
9676 | .dac_nids = alc662_dac_nids, | |
9677 | .dig_out_nid = ALC662_DIGOUT_NID, | |
9678 | .num_adc_nids = ARRAY_SIZE(alc662_adc_nids), | |
9679 | .adc_nids = alc662_adc_nids, | |
9680 | .dig_in_nid = ALC662_DIGIN_NID, | |
9681 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), | |
9682 | .channel_mode = alc662_3ST_6ch_modes, | |
9683 | .need_dac_fix = 1, | |
9684 | .input_mux = &alc662_capture_source, | |
f12ab1e0 | 9685 | }, |
bc9f98a9 KY |
9686 | [ALC662_3ST_6ch] = { |
9687 | .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer }, | |
9688 | .init_verbs = { alc662_init_verbs }, | |
9689 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
9690 | .dac_nids = alc662_dac_nids, | |
9691 | .num_adc_nids = ARRAY_SIZE(alc662_adc_nids), | |
9692 | .adc_nids = alc662_adc_nids, | |
9693 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), | |
9694 | .channel_mode = alc662_3ST_6ch_modes, | |
9695 | .need_dac_fix = 1, | |
9696 | .input_mux = &alc662_capture_source, | |
f12ab1e0 | 9697 | }, |
bc9f98a9 KY |
9698 | [ALC662_5ST_DIG] = { |
9699 | .mixers = { alc662_base_mixer, alc662_chmode_mixer }, | |
9700 | .init_verbs = { alc662_init_verbs }, | |
9701 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
9702 | .dac_nids = alc662_dac_nids, | |
9703 | .dig_out_nid = ALC662_DIGOUT_NID, | |
9704 | .num_adc_nids = ARRAY_SIZE(alc662_adc_nids), | |
9705 | .adc_nids = alc662_adc_nids, | |
9706 | .dig_in_nid = ALC662_DIGIN_NID, | |
9707 | .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes), | |
9708 | .channel_mode = alc662_5stack_modes, | |
9709 | .input_mux = &alc662_capture_source, | |
9710 | }, | |
9711 | [ALC662_LENOVO_101E] = { | |
9712 | .mixers = { alc662_lenovo_101e_mixer }, | |
9713 | .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs }, | |
9714 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
9715 | .dac_nids = alc662_dac_nids, | |
9716 | .num_adc_nids = ARRAY_SIZE(alc662_adc_nids), | |
9717 | .adc_nids = alc662_adc_nids, | |
9718 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
9719 | .channel_mode = alc662_3ST_2ch_modes, | |
9720 | .input_mux = &alc662_lenovo_101e_capture_source, | |
9721 | .unsol_event = alc662_lenovo_101e_unsol_event, | |
9722 | .init_hook = alc662_lenovo_101e_all_automute, | |
9723 | }, | |
9724 | ||
9725 | }; | |
9726 | ||
9727 | ||
9728 | /* | |
9729 | * BIOS auto configuration | |
9730 | */ | |
9731 | ||
9732 | /* add playback controls from the parsed DAC table */ | |
9733 | static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec, | |
9734 | const struct auto_pin_cfg *cfg) | |
9735 | { | |
9736 | char name[32]; | |
9737 | static const char *chname[4] = { | |
9738 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
9739 | }; | |
9740 | hda_nid_t nid; | |
9741 | int i, err; | |
9742 | ||
9743 | for (i = 0; i < cfg->line_outs; i++) { | |
9744 | if (!spec->multiout.dac_nids[i]) | |
9745 | continue; | |
9746 | nid = alc880_idx_to_dac(i); | |
9747 | if (i == 2) { | |
9748 | /* Center/LFE */ | |
9749 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
9750 | "Center Playback Volume", | |
f12ab1e0 TI |
9751 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, |
9752 | HDA_OUTPUT)); | |
bc9f98a9 KY |
9753 | if (err < 0) |
9754 | return err; | |
9755 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
9756 | "LFE Playback Volume", | |
f12ab1e0 TI |
9757 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, |
9758 | HDA_OUTPUT)); | |
bc9f98a9 KY |
9759 | if (err < 0) |
9760 | return err; | |
9761 | err = add_control(spec, ALC_CTL_BIND_MUTE, | |
9762 | "Center Playback Switch", | |
f12ab1e0 TI |
9763 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, |
9764 | HDA_INPUT)); | |
bc9f98a9 KY |
9765 | if (err < 0) |
9766 | return err; | |
9767 | err = add_control(spec, ALC_CTL_BIND_MUTE, | |
9768 | "LFE Playback Switch", | |
f12ab1e0 TI |
9769 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, |
9770 | HDA_INPUT)); | |
bc9f98a9 KY |
9771 | if (err < 0) |
9772 | return err; | |
9773 | } else { | |
9774 | sprintf(name, "%s Playback Volume", chname[i]); | |
9775 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
f12ab1e0 TI |
9776 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, |
9777 | HDA_OUTPUT)); | |
bc9f98a9 KY |
9778 | if (err < 0) |
9779 | return err; | |
9780 | sprintf(name, "%s Playback Switch", chname[i]); | |
9781 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | |
f12ab1e0 TI |
9782 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, |
9783 | HDA_INPUT)); | |
bc9f98a9 KY |
9784 | if (err < 0) |
9785 | return err; | |
9786 | } | |
9787 | } | |
9788 | return 0; | |
9789 | } | |
9790 | ||
9791 | /* add playback controls for speaker and HP outputs */ | |
9792 | static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, | |
9793 | const char *pfx) | |
9794 | { | |
9795 | hda_nid_t nid; | |
9796 | int err; | |
9797 | char name[32]; | |
9798 | ||
9799 | if (!pin) | |
9800 | return 0; | |
9801 | ||
9802 | if (alc880_is_fixed_pin(pin)) { | |
9803 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
9804 | /* printk("DAC nid=%x\n",nid); */ | |
9805 | /* specify the DAC as the extra output */ | |
9806 | if (!spec->multiout.hp_nid) | |
9807 | spec->multiout.hp_nid = nid; | |
9808 | else | |
9809 | spec->multiout.extra_out_nid[0] = nid; | |
9810 | /* control HP volume/switch on the output mixer amp */ | |
9811 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
9812 | sprintf(name, "%s Playback Volume", pfx); | |
9813 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
9814 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
9815 | if (err < 0) | |
9816 | return err; | |
9817 | sprintf(name, "%s Playback Switch", pfx); | |
9818 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | |
9819 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); | |
9820 | if (err < 0) | |
9821 | return err; | |
9822 | } else if (alc880_is_multi_pin(pin)) { | |
9823 | /* set manual connection */ | |
9824 | /* we have only a switch on HP-out PIN */ | |
9825 | sprintf(name, "%s Playback Switch", pfx); | |
9826 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | |
9827 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
9828 | if (err < 0) | |
9829 | return err; | |
9830 | } | |
9831 | return 0; | |
9832 | } | |
9833 | ||
9834 | /* create playback/capture controls for input pins */ | |
9835 | static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec, | |
9836 | const struct auto_pin_cfg *cfg) | |
9837 | { | |
9838 | struct hda_input_mux *imux = &spec->private_imux; | |
9839 | int i, err, idx; | |
9840 | ||
9841 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
9842 | if (alc880_is_input_pin(cfg->input_pins[i])) { | |
9843 | idx = alc880_input_pin_idx(cfg->input_pins[i]); | |
9844 | err = new_analog_input(spec, cfg->input_pins[i], | |
9845 | auto_pin_cfg_labels[i], | |
9846 | idx, 0x0b); | |
9847 | if (err < 0) | |
9848 | return err; | |
9849 | imux->items[imux->num_items].label = | |
9850 | auto_pin_cfg_labels[i]; | |
9851 | imux->items[imux->num_items].index = | |
9852 | alc880_input_pin_idx(cfg->input_pins[i]); | |
9853 | imux->num_items++; | |
9854 | } | |
9855 | } | |
9856 | return 0; | |
9857 | } | |
9858 | ||
9859 | static void alc662_auto_set_output_and_unmute(struct hda_codec *codec, | |
9860 | hda_nid_t nid, int pin_type, | |
9861 | int dac_idx) | |
9862 | { | |
9863 | /* set as output */ | |
9864 | snd_hda_codec_write(codec, nid, 0, | |
9865 | AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); | |
9866 | snd_hda_codec_write(codec, nid, 0, | |
9867 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); | |
9868 | /* need the manual connection? */ | |
9869 | if (alc880_is_multi_pin(nid)) { | |
9870 | struct alc_spec *spec = codec->spec; | |
9871 | int idx = alc880_multi_pin_idx(nid); | |
9872 | snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, | |
9873 | AC_VERB_SET_CONNECT_SEL, | |
9874 | alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); | |
9875 | } | |
9876 | } | |
9877 | ||
9878 | static void alc662_auto_init_multi_out(struct hda_codec *codec) | |
9879 | { | |
9880 | struct alc_spec *spec = codec->spec; | |
9881 | int i; | |
9882 | ||
9883 | for (i = 0; i <= HDA_SIDE; i++) { | |
9884 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 9885 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
bc9f98a9 | 9886 | if (nid) |
baba8ee9 | 9887 | alc662_auto_set_output_and_unmute(codec, nid, pin_type, |
bc9f98a9 KY |
9888 | i); |
9889 | } | |
9890 | } | |
9891 | ||
9892 | static void alc662_auto_init_hp_out(struct hda_codec *codec) | |
9893 | { | |
9894 | struct alc_spec *spec = codec->spec; | |
9895 | hda_nid_t pin; | |
9896 | ||
9897 | pin = spec->autocfg.hp_pins[0]; | |
9898 | if (pin) /* connect to front */ | |
9899 | /* use dac 0 */ | |
9900 | alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
9901 | } | |
9902 | ||
9903 | #define alc662_is_input_pin(nid) alc880_is_input_pin(nid) | |
9904 | #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID | |
9905 | ||
9906 | static void alc662_auto_init_analog_input(struct hda_codec *codec) | |
9907 | { | |
9908 | struct alc_spec *spec = codec->spec; | |
9909 | int i; | |
9910 | ||
9911 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
9912 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
9913 | if (alc662_is_input_pin(nid)) { | |
9914 | snd_hda_codec_write(codec, nid, 0, | |
9915 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
9916 | (i <= AUTO_PIN_FRONT_MIC ? | |
9917 | PIN_VREF80 : PIN_IN)); | |
9918 | if (nid != ALC662_PIN_CD_NID) | |
9919 | snd_hda_codec_write(codec, nid, 0, | |
9920 | AC_VERB_SET_AMP_GAIN_MUTE, | |
9921 | AMP_OUT_MUTE); | |
9922 | } | |
9923 | } | |
9924 | } | |
9925 | ||
9926 | static int alc662_parse_auto_config(struct hda_codec *codec) | |
9927 | { | |
9928 | struct alc_spec *spec = codec->spec; | |
9929 | int err; | |
9930 | static hda_nid_t alc662_ignore[] = { 0x1d, 0 }; | |
9931 | ||
9932 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | |
9933 | alc662_ignore); | |
9934 | if (err < 0) | |
9935 | return err; | |
9936 | if (!spec->autocfg.line_outs) | |
9937 | return 0; /* can't find valid BIOS pin config */ | |
9938 | ||
f12ab1e0 TI |
9939 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
9940 | if (err < 0) | |
9941 | return err; | |
9942 | err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
9943 | if (err < 0) | |
9944 | return err; | |
9945 | err = alc662_auto_create_extra_out(spec, | |
9946 | spec->autocfg.speaker_pins[0], | |
9947 | "Speaker"); | |
9948 | if (err < 0) | |
9949 | return err; | |
9950 | err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], | |
9951 | "Headphone"); | |
9952 | if (err < 0) | |
9953 | return err; | |
9954 | err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
9955 | if (err < 0) | |
bc9f98a9 KY |
9956 | return err; |
9957 | ||
9958 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
9959 | ||
9960 | if (spec->autocfg.dig_out_pin) | |
9961 | spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; | |
9962 | ||
9963 | if (spec->kctl_alloc) | |
9964 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
9965 | ||
9966 | spec->num_mux_defs = 1; | |
9967 | spec->input_mux = &spec->private_imux; | |
9968 | ||
9969 | if (err < 0) | |
9970 | return err; | |
9971 | else if (err > 0) | |
9972 | /* hack - override the init verbs */ | |
9973 | spec->init_verbs[0] = alc662_auto_init_verbs; | |
9974 | spec->mixers[spec->num_mixers] = alc662_capture_mixer; | |
9975 | spec->num_mixers++; | |
9976 | return err; | |
9977 | } | |
9978 | ||
9979 | /* additional initialization for auto-configuration model */ | |
9980 | static void alc662_auto_init(struct hda_codec *codec) | |
9981 | { | |
9982 | alc662_auto_init_multi_out(codec); | |
9983 | alc662_auto_init_hp_out(codec); | |
9984 | alc662_auto_init_analog_input(codec); | |
9985 | } | |
9986 | ||
9987 | static int patch_alc662(struct hda_codec *codec) | |
9988 | { | |
9989 | struct alc_spec *spec; | |
9990 | int err, board_config; | |
9991 | ||
9992 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
9993 | if (!spec) | |
9994 | return -ENOMEM; | |
9995 | ||
9996 | codec->spec = spec; | |
9997 | ||
9998 | board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST, | |
9999 | alc662_models, | |
10000 | alc662_cfg_tbl); | |
10001 | if (board_config < 0) { | |
10002 | printk(KERN_INFO "hda_codec: Unknown model for ALC662, " | |
10003 | "trying auto-probe from BIOS...\n"); | |
10004 | board_config = ALC662_AUTO; | |
10005 | } | |
10006 | ||
10007 | if (board_config == ALC662_AUTO) { | |
10008 | /* automatic parse from the BIOS config */ | |
10009 | err = alc662_parse_auto_config(codec); | |
10010 | if (err < 0) { | |
10011 | alc_free(codec); | |
10012 | return err; | |
10013 | } else if (err) { | |
10014 | printk(KERN_INFO | |
10015 | "hda_codec: Cannot set up configuration " | |
10016 | "from BIOS. Using base mode...\n"); | |
10017 | board_config = ALC662_3ST_2ch_DIG; | |
10018 | } | |
10019 | } | |
10020 | ||
10021 | if (board_config != ALC662_AUTO) | |
10022 | setup_preset(spec, &alc662_presets[board_config]); | |
10023 | ||
10024 | spec->stream_name_analog = "ALC662 Analog"; | |
10025 | spec->stream_analog_playback = &alc662_pcm_analog_playback; | |
10026 | spec->stream_analog_capture = &alc662_pcm_analog_capture; | |
10027 | ||
10028 | spec->stream_name_digital = "ALC662 Digital"; | |
10029 | spec->stream_digital_playback = &alc662_pcm_digital_playback; | |
10030 | spec->stream_digital_capture = &alc662_pcm_digital_capture; | |
10031 | ||
10032 | if (!spec->adc_nids && spec->input_mux) { | |
10033 | spec->adc_nids = alc662_adc_nids; | |
10034 | spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids); | |
10035 | } | |
10036 | ||
10037 | codec->patch_ops = alc_patch_ops; | |
10038 | if (board_config == ALC662_AUTO) | |
10039 | spec->init_hook = alc662_auto_init; | |
10040 | ||
10041 | return 0; | |
10042 | } | |
10043 | ||
1da177e4 LT |
10044 | /* |
10045 | * patch entries | |
10046 | */ | |
10047 | struct hda_codec_preset snd_hda_preset_realtek[] = { | |
10048 | { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, | |
df694daa | 10049 | { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, |
f32610ed | 10050 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", |
bc9f98a9 | 10051 | .patch = patch_alc861 }, |
f32610ed JS |
10052 | { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, |
10053 | { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, | |
10054 | { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, | |
bc9f98a9 KY |
10055 | { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", |
10056 | .patch = patch_alc883 }, | |
10057 | { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", | |
10058 | .patch = patch_alc662 }, | |
f32610ed | 10059 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
1da177e4 | 10060 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, |
9c7f852e | 10061 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 }, |
df694daa | 10062 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, |
9c7f852e | 10063 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 }, |
1da177e4 LT |
10064 | {} /* terminator */ |
10065 | }; |