]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * Universal Interface for Intel High Definition Audio Codec | |
3 | * | |
4 | * HD audio interface patch for ALC 260/880/882 codecs | |
5 | * | |
df694daa KY |
6 | * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw> |
7 | * PeiSen Hou <pshou@realtek.com.tw> | |
1da177e4 | 8 | * Takashi Iwai <tiwai@suse.de> |
7cf51e48 | 9 | * Jonathan Woithe <jwoithe@physics.adelaide.edu.au> |
1da177e4 LT |
10 | * |
11 | * This driver is free software; you can redistribute it and/or modify | |
12 | * it under the terms of the GNU General Public License as published by | |
13 | * the Free Software Foundation; either version 2 of the License, or | |
14 | * (at your option) any later version. | |
15 | * | |
16 | * This driver is distributed in the hope that it will be useful, | |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | * GNU General Public License for more details. | |
20 | * | |
21 | * You should have received a copy of the GNU General Public License | |
22 | * along with this program; if not, write to the Free Software | |
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 | */ | |
25 | ||
26 | #include <sound/driver.h> | |
27 | #include <linux/init.h> | |
28 | #include <linux/delay.h> | |
29 | #include <linux/slab.h> | |
30 | #include <linux/pci.h> | |
31 | #include <sound/core.h> | |
32 | #include "hda_codec.h" | |
33 | #include "hda_local.h" | |
34 | ||
ccc656ce KY |
35 | #define ALC880_FRONT_EVENT 0x01 |
36 | #define ALC880_DCVOL_EVENT 0x02 | |
37 | #define ALC880_HP_EVENT 0x04 | |
38 | #define ALC880_MIC_EVENT 0x08 | |
1da177e4 LT |
39 | |
40 | /* ALC880 board config type */ | |
41 | enum { | |
1da177e4 LT |
42 | ALC880_3ST, |
43 | ALC880_3ST_DIG, | |
44 | ALC880_5ST, | |
45 | ALC880_5ST_DIG, | |
46 | ALC880_W810, | |
dfc0ff62 | 47 | ALC880_Z71V, |
b6482d48 | 48 | ALC880_6ST, |
16ded525 TI |
49 | ALC880_6ST_DIG, |
50 | ALC880_F1734, | |
51 | ALC880_ASUS, | |
52 | ALC880_ASUS_DIG, | |
53 | ALC880_ASUS_W1V, | |
df694daa | 54 | ALC880_ASUS_DIG2, |
2cf9f0fc | 55 | ALC880_FUJITSU, |
16ded525 | 56 | ALC880_UNIWILL_DIG, |
ccc656ce KY |
57 | ALC880_UNIWILL, |
58 | ALC880_UNIWILL_P53, | |
df694daa KY |
59 | ALC880_CLEVO, |
60 | ALC880_TCL_S700, | |
ae6b813a | 61 | ALC880_LG, |
d681518a | 62 | ALC880_LG_LW, |
e9edcee0 TI |
63 | #ifdef CONFIG_SND_DEBUG |
64 | ALC880_TEST, | |
65 | #endif | |
df694daa | 66 | ALC880_AUTO, |
16ded525 TI |
67 | ALC880_MODEL_LAST /* last tag */ |
68 | }; | |
69 | ||
70 | /* ALC260 models */ | |
71 | enum { | |
72 | ALC260_BASIC, | |
73 | ALC260_HP, | |
df694daa KY |
74 | ALC260_HP_3013, |
75 | ALC260_FUJITSU_S702X, | |
0bfc90e9 | 76 | ALC260_ACER, |
bc9f98a9 KY |
77 | ALC260_WILL, |
78 | ALC260_REPLACER_672V, | |
7cf51e48 JW |
79 | #ifdef CONFIG_SND_DEBUG |
80 | ALC260_TEST, | |
81 | #endif | |
df694daa | 82 | ALC260_AUTO, |
16ded525 | 83 | ALC260_MODEL_LAST /* last tag */ |
1da177e4 LT |
84 | }; |
85 | ||
df694daa KY |
86 | /* ALC262 models */ |
87 | enum { | |
88 | ALC262_BASIC, | |
ccc656ce KY |
89 | ALC262_HIPPO, |
90 | ALC262_HIPPO_1, | |
834be88d | 91 | ALC262_FUJITSU, |
9c7f852e | 92 | ALC262_HP_BPC, |
cd7509a4 KY |
93 | ALC262_HP_BPC_D7000_WL, |
94 | ALC262_HP_BPC_D7000_WF, | |
304dcaac | 95 | ALC262_BENQ_ED8, |
272a527c | 96 | ALC262_SONY_ASSAMD, |
83c34218 | 97 | ALC262_BENQ_T31, |
df694daa KY |
98 | ALC262_AUTO, |
99 | ALC262_MODEL_LAST /* last tag */ | |
100 | }; | |
101 | ||
a361d84b KY |
102 | /* ALC268 models */ |
103 | enum { | |
104 | ALC268_3ST, | |
d1a991a6 | 105 | ALC268_TOSHIBA, |
d273809e | 106 | ALC268_ACER, |
a361d84b KY |
107 | ALC268_AUTO, |
108 | ALC268_MODEL_LAST /* last tag */ | |
109 | }; | |
110 | ||
df694daa KY |
111 | /* ALC861 models */ |
112 | enum { | |
113 | ALC861_3ST, | |
9c7f852e | 114 | ALC660_3ST, |
df694daa KY |
115 | ALC861_3ST_DIG, |
116 | ALC861_6ST_DIG, | |
22309c3e | 117 | ALC861_UNIWILL_M31, |
a53d1aec | 118 | ALC861_TOSHIBA, |
7cdbff94 | 119 | ALC861_ASUS, |
56bb0cab | 120 | ALC861_ASUS_LAPTOP, |
df694daa KY |
121 | ALC861_AUTO, |
122 | ALC861_MODEL_LAST, | |
123 | }; | |
124 | ||
f32610ed JS |
125 | /* ALC861-VD models */ |
126 | enum { | |
127 | ALC660VD_3ST, | |
6963f84c | 128 | ALC660VD_3ST_DIG, |
f32610ed JS |
129 | ALC861VD_3ST, |
130 | ALC861VD_3ST_DIG, | |
131 | ALC861VD_6ST_DIG, | |
bdd148a3 | 132 | ALC861VD_LENOVO, |
272a527c | 133 | ALC861VD_DALLAS, |
d1a991a6 | 134 | ALC861VD_HP, |
f32610ed JS |
135 | ALC861VD_AUTO, |
136 | ALC861VD_MODEL_LAST, | |
137 | }; | |
138 | ||
bc9f98a9 KY |
139 | /* ALC662 models */ |
140 | enum { | |
141 | ALC662_3ST_2ch_DIG, | |
142 | ALC662_3ST_6ch_DIG, | |
143 | ALC662_3ST_6ch, | |
144 | ALC662_5ST_DIG, | |
145 | ALC662_LENOVO_101E, | |
146 | ALC662_AUTO, | |
147 | ALC662_MODEL_LAST, | |
148 | }; | |
149 | ||
df694daa KY |
150 | /* ALC882 models */ |
151 | enum { | |
152 | ALC882_3ST_DIG, | |
153 | ALC882_6ST_DIG, | |
4b146cb0 | 154 | ALC882_ARIMA, |
bdd148a3 | 155 | ALC882_W2JC, |
272a527c KY |
156 | ALC882_TARGA, |
157 | ALC882_ASUS_A7J, | |
9102cd1c | 158 | ALC885_MACPRO, |
87350ad0 | 159 | ALC885_MBP3, |
c54728d8 | 160 | ALC885_IMAC24, |
272a527c | 161 | ALC882_AUTO, |
df694daa KY |
162 | ALC882_MODEL_LAST, |
163 | }; | |
164 | ||
9c7f852e TI |
165 | /* ALC883 models */ |
166 | enum { | |
167 | ALC883_3ST_2ch_DIG, | |
168 | ALC883_3ST_6ch_DIG, | |
169 | ALC883_3ST_6ch, | |
170 | ALC883_6ST_DIG, | |
ccc656ce KY |
171 | ALC883_TARGA_DIG, |
172 | ALC883_TARGA_2ch_DIG, | |
bab282b9 | 173 | ALC883_ACER, |
2880a867 | 174 | ALC883_ACER_ASPIRE, |
c07584c8 | 175 | ALC883_MEDION, |
272a527c | 176 | ALC883_MEDION_MD2, |
b373bdeb | 177 | ALC883_LAPTOP_EAPD, |
bc9f98a9 | 178 | ALC883_LENOVO_101E_2ch, |
272a527c | 179 | ALC883_LENOVO_NB0763, |
189609ae KY |
180 | ALC888_LENOVO_MS7195_DIG, |
181 | ALC883_HAIER_W66, | |
4723c022 CM |
182 | ALC888_6ST_HP, |
183 | ALC888_3ST_HP, | |
9c7f852e TI |
184 | ALC883_AUTO, |
185 | ALC883_MODEL_LAST, | |
186 | }; | |
187 | ||
df694daa KY |
188 | /* for GPIO Poll */ |
189 | #define GPIO_MASK 0x03 | |
190 | ||
1da177e4 LT |
191 | struct alc_spec { |
192 | /* codec parameterization */ | |
df694daa | 193 | struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ |
1da177e4 LT |
194 | unsigned int num_mixers; |
195 | ||
df694daa | 196 | const struct hda_verb *init_verbs[5]; /* initialization verbs |
9c7f852e TI |
197 | * don't forget NULL |
198 | * termination! | |
e9edcee0 TI |
199 | */ |
200 | unsigned int num_init_verbs; | |
1da177e4 | 201 | |
16ded525 | 202 | char *stream_name_analog; /* analog PCM stream */ |
1da177e4 LT |
203 | struct hda_pcm_stream *stream_analog_playback; |
204 | struct hda_pcm_stream *stream_analog_capture; | |
205 | ||
f12ab1e0 | 206 | char *stream_name_digital; /* digital PCM stream */ |
1da177e4 LT |
207 | struct hda_pcm_stream *stream_digital_playback; |
208 | struct hda_pcm_stream *stream_digital_capture; | |
209 | ||
210 | /* playback */ | |
16ded525 TI |
211 | struct hda_multi_out multiout; /* playback set-up |
212 | * max_channels, dacs must be set | |
213 | * dig_out_nid and hp_nid are optional | |
214 | */ | |
1da177e4 LT |
215 | |
216 | /* capture */ | |
217 | unsigned int num_adc_nids; | |
218 | hda_nid_t *adc_nids; | |
16ded525 | 219 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
1da177e4 LT |
220 | |
221 | /* capture source */ | |
a1e8d2da | 222 | unsigned int num_mux_defs; |
1da177e4 LT |
223 | const struct hda_input_mux *input_mux; |
224 | unsigned int cur_mux[3]; | |
225 | ||
226 | /* channel model */ | |
d2a6d7dc | 227 | const struct hda_channel_mode *channel_mode; |
1da177e4 | 228 | int num_channel_mode; |
4e195a7b | 229 | int need_dac_fix; |
1da177e4 LT |
230 | |
231 | /* PCM information */ | |
4c5186ed | 232 | struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ |
41e41f1f | 233 | |
e9edcee0 TI |
234 | /* dynamic controls, init_verbs and input_mux */ |
235 | struct auto_pin_cfg autocfg; | |
236 | unsigned int num_kctl_alloc, num_kctl_used; | |
c8b6bf9b | 237 | struct snd_kcontrol_new *kctl_alloc; |
e9edcee0 | 238 | struct hda_input_mux private_imux; |
df694daa | 239 | hda_nid_t private_dac_nids[5]; |
834be88d | 240 | |
ae6b813a TI |
241 | /* hooks */ |
242 | void (*init_hook)(struct hda_codec *codec); | |
243 | void (*unsol_event)(struct hda_codec *codec, unsigned int res); | |
244 | ||
834be88d TI |
245 | /* for pin sensing */ |
246 | unsigned int sense_updated: 1; | |
247 | unsigned int jack_present: 1; | |
cb53c626 TI |
248 | |
249 | #ifdef CONFIG_SND_HDA_POWER_SAVE | |
250 | struct hda_loopback_check loopback; | |
251 | #endif | |
df694daa KY |
252 | }; |
253 | ||
254 | /* | |
255 | * configuration template - to be copied to the spec instance | |
256 | */ | |
257 | struct alc_config_preset { | |
9c7f852e TI |
258 | struct snd_kcontrol_new *mixers[5]; /* should be identical size |
259 | * with spec | |
260 | */ | |
df694daa KY |
261 | const struct hda_verb *init_verbs[5]; |
262 | unsigned int num_dacs; | |
263 | hda_nid_t *dac_nids; | |
264 | hda_nid_t dig_out_nid; /* optional */ | |
265 | hda_nid_t hp_nid; /* optional */ | |
266 | unsigned int num_adc_nids; | |
267 | hda_nid_t *adc_nids; | |
268 | hda_nid_t dig_in_nid; | |
269 | unsigned int num_channel_mode; | |
270 | const struct hda_channel_mode *channel_mode; | |
4e195a7b | 271 | int need_dac_fix; |
a1e8d2da | 272 | unsigned int num_mux_defs; |
df694daa | 273 | const struct hda_input_mux *input_mux; |
ae6b813a TI |
274 | void (*unsol_event)(struct hda_codec *, unsigned int); |
275 | void (*init_hook)(struct hda_codec *); | |
cb53c626 TI |
276 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
277 | struct hda_amp_list *loopbacks; | |
278 | #endif | |
1da177e4 LT |
279 | }; |
280 | ||
1da177e4 LT |
281 | |
282 | /* | |
283 | * input MUX handling | |
284 | */ | |
9c7f852e TI |
285 | static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, |
286 | struct snd_ctl_elem_info *uinfo) | |
1da177e4 LT |
287 | { |
288 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
289 | struct alc_spec *spec = codec->spec; | |
a1e8d2da JW |
290 | unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id); |
291 | if (mux_idx >= spec->num_mux_defs) | |
292 | mux_idx = 0; | |
293 | return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo); | |
1da177e4 LT |
294 | } |
295 | ||
9c7f852e TI |
296 | static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, |
297 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
298 | { |
299 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
300 | struct alc_spec *spec = codec->spec; | |
301 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
302 | ||
303 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; | |
304 | return 0; | |
305 | } | |
306 | ||
9c7f852e TI |
307 | static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, |
308 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
309 | { |
310 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
311 | struct alc_spec *spec = codec->spec; | |
312 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
a1e8d2da JW |
313 | unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; |
314 | return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol, | |
9c7f852e TI |
315 | spec->adc_nids[adc_idx], |
316 | &spec->cur_mux[adc_idx]); | |
1da177e4 LT |
317 | } |
318 | ||
e9edcee0 | 319 | |
1da177e4 LT |
320 | /* |
321 | * channel mode setting | |
322 | */ | |
9c7f852e TI |
323 | static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, |
324 | struct snd_ctl_elem_info *uinfo) | |
1da177e4 LT |
325 | { |
326 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
327 | struct alc_spec *spec = codec->spec; | |
d2a6d7dc TI |
328 | return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, |
329 | spec->num_channel_mode); | |
1da177e4 LT |
330 | } |
331 | ||
9c7f852e TI |
332 | static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, |
333 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
334 | { |
335 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
336 | struct alc_spec *spec = codec->spec; | |
d2a6d7dc | 337 | return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, |
9c7f852e TI |
338 | spec->num_channel_mode, |
339 | spec->multiout.max_channels); | |
1da177e4 LT |
340 | } |
341 | ||
9c7f852e TI |
342 | static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, |
343 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
344 | { |
345 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
346 | struct alc_spec *spec = codec->spec; | |
4e195a7b TI |
347 | int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, |
348 | spec->num_channel_mode, | |
349 | &spec->multiout.max_channels); | |
bd2033f2 | 350 | if (err >= 0 && spec->need_dac_fix) |
4e195a7b TI |
351 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; |
352 | return err; | |
1da177e4 LT |
353 | } |
354 | ||
a9430dd8 | 355 | /* |
4c5186ed JW |
356 | * Control the mode of pin widget settings via the mixer. "pc" is used |
357 | * instead of "%" to avoid consequences of accidently treating the % as | |
358 | * being part of a format specifier. Maximum allowed length of a value is | |
359 | * 63 characters plus NULL terminator. | |
7cf51e48 JW |
360 | * |
361 | * Note: some retasking pin complexes seem to ignore requests for input | |
362 | * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these | |
363 | * are requested. Therefore order this list so that this behaviour will not | |
364 | * cause problems when mixer clients move through the enum sequentially. | |
a1e8d2da JW |
365 | * NIDs 0x0f and 0x10 have been observed to have this behaviour as of |
366 | * March 2006. | |
4c5186ed JW |
367 | */ |
368 | static char *alc_pin_mode_names[] = { | |
7cf51e48 JW |
369 | "Mic 50pc bias", "Mic 80pc bias", |
370 | "Line in", "Line out", "Headphone out", | |
4c5186ed JW |
371 | }; |
372 | static unsigned char alc_pin_mode_values[] = { | |
7cf51e48 | 373 | PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP, |
4c5186ed JW |
374 | }; |
375 | /* The control can present all 5 options, or it can limit the options based | |
a1e8d2da JW |
376 | * in the pin being assumed to be exclusively an input or an output pin. In |
377 | * addition, "input" pins may or may not process the mic bias option | |
378 | * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to | |
379 | * accept requests for bias as of chip versions up to March 2006) and/or | |
380 | * wiring in the computer. | |
a9430dd8 | 381 | */ |
a1e8d2da JW |
382 | #define ALC_PIN_DIR_IN 0x00 |
383 | #define ALC_PIN_DIR_OUT 0x01 | |
384 | #define ALC_PIN_DIR_INOUT 0x02 | |
385 | #define ALC_PIN_DIR_IN_NOMICBIAS 0x03 | |
386 | #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04 | |
4c5186ed | 387 | |
a1e8d2da | 388 | /* Info about the pin modes supported by the different pin direction modes. |
4c5186ed JW |
389 | * For each direction the minimum and maximum values are given. |
390 | */ | |
a1e8d2da | 391 | static signed char alc_pin_mode_dir_info[5][2] = { |
4c5186ed JW |
392 | { 0, 2 }, /* ALC_PIN_DIR_IN */ |
393 | { 3, 4 }, /* ALC_PIN_DIR_OUT */ | |
394 | { 0, 4 }, /* ALC_PIN_DIR_INOUT */ | |
a1e8d2da JW |
395 | { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */ |
396 | { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */ | |
4c5186ed JW |
397 | }; |
398 | #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0]) | |
399 | #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1]) | |
400 | #define alc_pin_mode_n_items(_dir) \ | |
401 | (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1) | |
402 | ||
9c7f852e TI |
403 | static int alc_pin_mode_info(struct snd_kcontrol *kcontrol, |
404 | struct snd_ctl_elem_info *uinfo) | |
a9430dd8 | 405 | { |
4c5186ed JW |
406 | unsigned int item_num = uinfo->value.enumerated.item; |
407 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; | |
408 | ||
409 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
a9430dd8 | 410 | uinfo->count = 1; |
4c5186ed JW |
411 | uinfo->value.enumerated.items = alc_pin_mode_n_items(dir); |
412 | ||
413 | if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir)) | |
414 | item_num = alc_pin_mode_min(dir); | |
415 | strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]); | |
a9430dd8 JW |
416 | return 0; |
417 | } | |
418 | ||
9c7f852e TI |
419 | static int alc_pin_mode_get(struct snd_kcontrol *kcontrol, |
420 | struct snd_ctl_elem_value *ucontrol) | |
a9430dd8 | 421 | { |
4c5186ed | 422 | unsigned int i; |
a9430dd8 JW |
423 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
424 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
4c5186ed | 425 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
a9430dd8 | 426 | long *valp = ucontrol->value.integer.value; |
9c7f852e TI |
427 | unsigned int pinctl = snd_hda_codec_read(codec, nid, 0, |
428 | AC_VERB_GET_PIN_WIDGET_CONTROL, | |
429 | 0x00); | |
a9430dd8 | 430 | |
4c5186ed JW |
431 | /* Find enumerated value for current pinctl setting */ |
432 | i = alc_pin_mode_min(dir); | |
9c7f852e | 433 | while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir)) |
4c5186ed | 434 | i++; |
9c7f852e | 435 | *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir); |
a9430dd8 JW |
436 | return 0; |
437 | } | |
438 | ||
9c7f852e TI |
439 | static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, |
440 | struct snd_ctl_elem_value *ucontrol) | |
a9430dd8 | 441 | { |
4c5186ed | 442 | signed int change; |
a9430dd8 JW |
443 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
444 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
4c5186ed JW |
445 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
446 | long val = *ucontrol->value.integer.value; | |
9c7f852e TI |
447 | unsigned int pinctl = snd_hda_codec_read(codec, nid, 0, |
448 | AC_VERB_GET_PIN_WIDGET_CONTROL, | |
449 | 0x00); | |
a9430dd8 | 450 | |
f12ab1e0 | 451 | if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir)) |
4c5186ed JW |
452 | val = alc_pin_mode_min(dir); |
453 | ||
454 | change = pinctl != alc_pin_mode_values[val]; | |
cdcd9268 JW |
455 | if (change) { |
456 | /* Set pin mode to that requested */ | |
82beb8fd TI |
457 | snd_hda_codec_write_cache(codec, nid, 0, |
458 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
459 | alc_pin_mode_values[val]); | |
cdcd9268 JW |
460 | |
461 | /* Also enable the retasking pin's input/output as required | |
462 | * for the requested pin mode. Enum values of 2 or less are | |
463 | * input modes. | |
464 | * | |
465 | * Dynamically switching the input/output buffers probably | |
a1e8d2da JW |
466 | * reduces noise slightly (particularly on input) so we'll |
467 | * do it. However, having both input and output buffers | |
468 | * enabled simultaneously doesn't seem to be problematic if | |
469 | * this turns out to be necessary in the future. | |
cdcd9268 JW |
470 | */ |
471 | if (val <= 2) { | |
47fd830a TI |
472 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
473 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
474 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0, | |
475 | HDA_AMP_MUTE, 0); | |
cdcd9268 | 476 | } else { |
47fd830a TI |
477 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0, |
478 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
479 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, | |
480 | HDA_AMP_MUTE, 0); | |
cdcd9268 JW |
481 | } |
482 | } | |
a9430dd8 JW |
483 | return change; |
484 | } | |
485 | ||
4c5186ed | 486 | #define ALC_PIN_MODE(xname, nid, dir) \ |
a9430dd8 | 487 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ |
4c5186ed JW |
488 | .info = alc_pin_mode_info, \ |
489 | .get = alc_pin_mode_get, \ | |
490 | .put = alc_pin_mode_put, \ | |
491 | .private_value = nid | (dir<<16) } | |
df694daa | 492 | |
5c8f858d JW |
493 | /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged |
494 | * together using a mask with more than one bit set. This control is | |
495 | * currently used only by the ALC260 test model. At this stage they are not | |
496 | * needed for any "production" models. | |
497 | */ | |
498 | #ifdef CONFIG_SND_DEBUG | |
a5ce8890 | 499 | #define alc_gpio_data_info snd_ctl_boolean_mono_info |
f12ab1e0 | 500 | |
9c7f852e TI |
501 | static int alc_gpio_data_get(struct snd_kcontrol *kcontrol, |
502 | struct snd_ctl_elem_value *ucontrol) | |
5c8f858d JW |
503 | { |
504 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
505 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
506 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
507 | long *valp = ucontrol->value.integer.value; | |
9c7f852e TI |
508 | unsigned int val = snd_hda_codec_read(codec, nid, 0, |
509 | AC_VERB_GET_GPIO_DATA, 0x00); | |
5c8f858d JW |
510 | |
511 | *valp = (val & mask) != 0; | |
512 | return 0; | |
513 | } | |
9c7f852e TI |
514 | static int alc_gpio_data_put(struct snd_kcontrol *kcontrol, |
515 | struct snd_ctl_elem_value *ucontrol) | |
5c8f858d JW |
516 | { |
517 | signed int change; | |
518 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
519 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
520 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
521 | long val = *ucontrol->value.integer.value; | |
9c7f852e TI |
522 | unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0, |
523 | AC_VERB_GET_GPIO_DATA, | |
524 | 0x00); | |
5c8f858d JW |
525 | |
526 | /* Set/unset the masked GPIO bit(s) as needed */ | |
9c7f852e TI |
527 | change = (val == 0 ? 0 : mask) != (gpio_data & mask); |
528 | if (val == 0) | |
5c8f858d JW |
529 | gpio_data &= ~mask; |
530 | else | |
531 | gpio_data |= mask; | |
82beb8fd TI |
532 | snd_hda_codec_write_cache(codec, nid, 0, |
533 | AC_VERB_SET_GPIO_DATA, gpio_data); | |
5c8f858d JW |
534 | |
535 | return change; | |
536 | } | |
537 | #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \ | |
538 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
539 | .info = alc_gpio_data_info, \ | |
540 | .get = alc_gpio_data_get, \ | |
541 | .put = alc_gpio_data_put, \ | |
542 | .private_value = nid | (mask<<16) } | |
543 | #endif /* CONFIG_SND_DEBUG */ | |
544 | ||
92621f13 JW |
545 | /* A switch control to allow the enabling of the digital IO pins on the |
546 | * ALC260. This is incredibly simplistic; the intention of this control is | |
547 | * to provide something in the test model allowing digital outputs to be | |
548 | * identified if present. If models are found which can utilise these | |
549 | * outputs a more complete mixer control can be devised for those models if | |
550 | * necessary. | |
551 | */ | |
552 | #ifdef CONFIG_SND_DEBUG | |
a5ce8890 | 553 | #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info |
f12ab1e0 | 554 | |
9c7f852e TI |
555 | static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol, |
556 | struct snd_ctl_elem_value *ucontrol) | |
92621f13 JW |
557 | { |
558 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
559 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
560 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
561 | long *valp = ucontrol->value.integer.value; | |
9c7f852e TI |
562 | unsigned int val = snd_hda_codec_read(codec, nid, 0, |
563 | AC_VERB_GET_DIGI_CONVERT, 0x00); | |
92621f13 JW |
564 | |
565 | *valp = (val & mask) != 0; | |
566 | return 0; | |
567 | } | |
9c7f852e TI |
568 | static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol, |
569 | struct snd_ctl_elem_value *ucontrol) | |
92621f13 JW |
570 | { |
571 | signed int change; | |
572 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
573 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
574 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
575 | long val = *ucontrol->value.integer.value; | |
9c7f852e TI |
576 | unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0, |
577 | AC_VERB_GET_DIGI_CONVERT, | |
578 | 0x00); | |
92621f13 JW |
579 | |
580 | /* Set/unset the masked control bit(s) as needed */ | |
9c7f852e | 581 | change = (val == 0 ? 0 : mask) != (ctrl_data & mask); |
92621f13 JW |
582 | if (val==0) |
583 | ctrl_data &= ~mask; | |
584 | else | |
585 | ctrl_data |= mask; | |
82beb8fd TI |
586 | snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, |
587 | ctrl_data); | |
92621f13 JW |
588 | |
589 | return change; | |
590 | } | |
591 | #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \ | |
592 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
593 | .info = alc_spdif_ctrl_info, \ | |
594 | .get = alc_spdif_ctrl_get, \ | |
595 | .put = alc_spdif_ctrl_put, \ | |
596 | .private_value = nid | (mask<<16) } | |
597 | #endif /* CONFIG_SND_DEBUG */ | |
598 | ||
df694daa KY |
599 | /* |
600 | * set up from the preset table | |
601 | */ | |
9c7f852e TI |
602 | static void setup_preset(struct alc_spec *spec, |
603 | const struct alc_config_preset *preset) | |
df694daa KY |
604 | { |
605 | int i; | |
606 | ||
607 | for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++) | |
608 | spec->mixers[spec->num_mixers++] = preset->mixers[i]; | |
9c7f852e TI |
609 | for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; |
610 | i++) | |
611 | spec->init_verbs[spec->num_init_verbs++] = | |
612 | preset->init_verbs[i]; | |
df694daa KY |
613 | |
614 | spec->channel_mode = preset->channel_mode; | |
615 | spec->num_channel_mode = preset->num_channel_mode; | |
4e195a7b | 616 | spec->need_dac_fix = preset->need_dac_fix; |
df694daa KY |
617 | |
618 | spec->multiout.max_channels = spec->channel_mode[0].channels; | |
619 | ||
620 | spec->multiout.num_dacs = preset->num_dacs; | |
621 | spec->multiout.dac_nids = preset->dac_nids; | |
622 | spec->multiout.dig_out_nid = preset->dig_out_nid; | |
623 | spec->multiout.hp_nid = preset->hp_nid; | |
624 | ||
a1e8d2da | 625 | spec->num_mux_defs = preset->num_mux_defs; |
f12ab1e0 | 626 | if (!spec->num_mux_defs) |
a1e8d2da | 627 | spec->num_mux_defs = 1; |
df694daa KY |
628 | spec->input_mux = preset->input_mux; |
629 | ||
630 | spec->num_adc_nids = preset->num_adc_nids; | |
631 | spec->adc_nids = preset->adc_nids; | |
632 | spec->dig_in_nid = preset->dig_in_nid; | |
ae6b813a TI |
633 | |
634 | spec->unsol_event = preset->unsol_event; | |
635 | spec->init_hook = preset->init_hook; | |
cb53c626 TI |
636 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
637 | spec->loopback.amplist = preset->loopbacks; | |
638 | #endif | |
df694daa KY |
639 | } |
640 | ||
bc9f98a9 KY |
641 | /* Enable GPIO mask and set output */ |
642 | static struct hda_verb alc_gpio1_init_verbs[] = { | |
643 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
644 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
645 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, | |
646 | { } | |
647 | }; | |
648 | ||
649 | static struct hda_verb alc_gpio2_init_verbs[] = { | |
650 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, | |
651 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, | |
652 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, | |
653 | { } | |
654 | }; | |
655 | ||
bdd148a3 KY |
656 | static struct hda_verb alc_gpio3_init_verbs[] = { |
657 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, | |
658 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | |
659 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | |
660 | { } | |
661 | }; | |
662 | ||
bc9f98a9 KY |
663 | /* 32-bit subsystem ID for BIOS loading in HD Audio codec. |
664 | * 31 ~ 16 : Manufacture ID | |
665 | * 15 ~ 8 : SKU ID | |
666 | * 7 ~ 0 : Assembly ID | |
667 | * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36 | |
668 | */ | |
669 | static void alc_subsystem_id(struct hda_codec *codec, | |
670 | unsigned int porta, unsigned int porte, | |
671 | unsigned int portd) | |
672 | { | |
673 | unsigned int ass, tmp; | |
674 | ||
675 | ass = codec->subsystem_id; | |
676 | if (!(ass & 1)) | |
677 | return; | |
678 | ||
679 | /* Override */ | |
680 | tmp = (ass & 0x38) >> 3; /* external Amp control */ | |
681 | switch (tmp) { | |
682 | case 1: | |
683 | snd_hda_sequence_write(codec, alc_gpio1_init_verbs); | |
684 | break; | |
685 | case 3: | |
686 | snd_hda_sequence_write(codec, alc_gpio2_init_verbs); | |
687 | break; | |
bdd148a3 KY |
688 | case 7: |
689 | snd_hda_sequence_write(codec, alc_gpio3_init_verbs); | |
690 | break; | |
bc9f98a9 | 691 | case 5: |
bdd148a3 KY |
692 | switch (codec->vendor_id) { |
693 | case 0x10ec0862: | |
694 | case 0x10ec0660: | |
695 | case 0x10ec0662: | |
696 | case 0x10ec0267: | |
697 | case 0x10ec0268: | |
698 | snd_hda_codec_write(codec, 0x14, 0, | |
699 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
700 | snd_hda_codec_write(codec, 0x15, 0, | |
701 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
702 | return; | |
703 | } | |
bc9f98a9 KY |
704 | case 6: |
705 | if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */ | |
706 | hda_nid_t port = 0; | |
707 | tmp = (ass & 0x1800) >> 11; | |
708 | switch (tmp) { | |
709 | case 0: port = porta; break; | |
710 | case 1: port = porte; break; | |
711 | case 2: port = portd; break; | |
712 | } | |
713 | if (port) | |
714 | snd_hda_codec_write(codec, port, 0, | |
715 | AC_VERB_SET_EAPD_BTLENABLE, | |
716 | 2); | |
717 | } | |
718 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); | |
719 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, | |
720 | (tmp == 5 ? 0x3040 : 0x3050)); | |
721 | break; | |
722 | } | |
723 | } | |
724 | ||
f95474ec TI |
725 | /* |
726 | * Fix-up pin default configurations | |
727 | */ | |
728 | ||
729 | struct alc_pincfg { | |
730 | hda_nid_t nid; | |
731 | u32 val; | |
732 | }; | |
733 | ||
734 | static void alc_fix_pincfg(struct hda_codec *codec, | |
735 | const struct snd_pci_quirk *quirk, | |
736 | const struct alc_pincfg **pinfix) | |
737 | { | |
738 | const struct alc_pincfg *cfg; | |
739 | ||
740 | quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk); | |
741 | if (!quirk) | |
742 | return; | |
743 | ||
744 | cfg = pinfix[quirk->value]; | |
745 | for (; cfg->nid; cfg++) { | |
746 | int i; | |
747 | u32 val = cfg->val; | |
748 | for (i = 0; i < 4; i++) { | |
749 | snd_hda_codec_write(codec, cfg->nid, 0, | |
750 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i, | |
751 | val & 0xff); | |
752 | val >>= 8; | |
753 | } | |
754 | } | |
755 | } | |
756 | ||
1da177e4 | 757 | /* |
e9edcee0 TI |
758 | * ALC880 3-stack model |
759 | * | |
760 | * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e) | |
9c7f852e TI |
761 | * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, |
762 | * F-Mic = 0x1b, HP = 0x19 | |
1da177e4 LT |
763 | */ |
764 | ||
e9edcee0 TI |
765 | static hda_nid_t alc880_dac_nids[4] = { |
766 | /* front, rear, clfe, rear_surr */ | |
767 | 0x02, 0x05, 0x04, 0x03 | |
768 | }; | |
769 | ||
770 | static hda_nid_t alc880_adc_nids[3] = { | |
771 | /* ADC0-2 */ | |
772 | 0x07, 0x08, 0x09, | |
773 | }; | |
774 | ||
775 | /* The datasheet says the node 0x07 is connected from inputs, | |
776 | * but it shows zero connection in the real implementation on some devices. | |
df694daa | 777 | * Note: this is a 915GAV bug, fixed on 915GLV |
1da177e4 | 778 | */ |
e9edcee0 TI |
779 | static hda_nid_t alc880_adc_nids_alt[2] = { |
780 | /* ADC1-2 */ | |
781 | 0x08, 0x09, | |
782 | }; | |
783 | ||
784 | #define ALC880_DIGOUT_NID 0x06 | |
785 | #define ALC880_DIGIN_NID 0x0a | |
786 | ||
787 | static struct hda_input_mux alc880_capture_source = { | |
788 | .num_items = 4, | |
789 | .items = { | |
790 | { "Mic", 0x0 }, | |
791 | { "Front Mic", 0x3 }, | |
792 | { "Line", 0x2 }, | |
793 | { "CD", 0x4 }, | |
794 | }, | |
795 | }; | |
796 | ||
797 | /* channel source setting (2/6 channel selection for 3-stack) */ | |
798 | /* 2ch mode */ | |
799 | static struct hda_verb alc880_threestack_ch2_init[] = { | |
800 | /* set line-in to input, mute it */ | |
801 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
802 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
803 | /* set mic-in to input vref 80%, mute it */ | |
804 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
805 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
806 | { } /* end */ | |
807 | }; | |
808 | ||
809 | /* 6ch mode */ | |
810 | static struct hda_verb alc880_threestack_ch6_init[] = { | |
811 | /* set line-in to output, unmute it */ | |
812 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
813 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
814 | /* set mic-in to output, unmute it */ | |
815 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
816 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
817 | { } /* end */ | |
818 | }; | |
819 | ||
d2a6d7dc | 820 | static struct hda_channel_mode alc880_threestack_modes[2] = { |
e9edcee0 TI |
821 | { 2, alc880_threestack_ch2_init }, |
822 | { 6, alc880_threestack_ch6_init }, | |
823 | }; | |
824 | ||
c8b6bf9b | 825 | static struct snd_kcontrol_new alc880_three_stack_mixer[] = { |
05acb863 | 826 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 827 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
05acb863 | 828 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 829 | HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT), |
05acb863 TI |
830 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
831 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
832 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
833 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
1da177e4 LT |
834 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
835 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
836 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
837 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
838 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
839 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
840 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT), | |
841 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT), | |
842 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
843 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
e9edcee0 TI |
844 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT), |
845 | { | |
846 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
847 | .name = "Channel Mode", | |
df694daa KY |
848 | .info = alc_ch_mode_info, |
849 | .get = alc_ch_mode_get, | |
850 | .put = alc_ch_mode_put, | |
e9edcee0 TI |
851 | }, |
852 | { } /* end */ | |
853 | }; | |
854 | ||
855 | /* capture mixer elements */ | |
c8b6bf9b | 856 | static struct snd_kcontrol_new alc880_capture_mixer[] = { |
e9edcee0 TI |
857 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), |
858 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), | |
859 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), | |
860 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), | |
861 | HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), | |
862 | HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), | |
1da177e4 LT |
863 | { |
864 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
865 | /* The multiple "Capture Source" controls confuse alsamixer | |
866 | * So call somewhat different.. | |
867 | * FIXME: the controls appear in the "playback" view! | |
868 | */ | |
869 | /* .name = "Capture Source", */ | |
870 | .name = "Input Source", | |
e9edcee0 | 871 | .count = 3, |
1da177e4 LT |
872 | .info = alc_mux_enum_info, |
873 | .get = alc_mux_enum_get, | |
874 | .put = alc_mux_enum_put, | |
875 | }, | |
1da177e4 LT |
876 | { } /* end */ |
877 | }; | |
878 | ||
e9edcee0 | 879 | /* capture mixer elements (in case NID 0x07 not available) */ |
c8b6bf9b | 880 | static struct snd_kcontrol_new alc880_capture_alt_mixer[] = { |
71fe7b82 TI |
881 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
882 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
883 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
884 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
1da177e4 LT |
885 | { |
886 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
887 | /* The multiple "Capture Source" controls confuse alsamixer | |
888 | * So call somewhat different.. | |
889 | * FIXME: the controls appear in the "playback" view! | |
890 | */ | |
891 | /* .name = "Capture Source", */ | |
892 | .name = "Input Source", | |
893 | .count = 2, | |
894 | .info = alc_mux_enum_info, | |
895 | .get = alc_mux_enum_get, | |
896 | .put = alc_mux_enum_put, | |
897 | }, | |
1da177e4 LT |
898 | { } /* end */ |
899 | }; | |
900 | ||
e9edcee0 TI |
901 | |
902 | ||
903 | /* | |
904 | * ALC880 5-stack model | |
905 | * | |
9c7f852e TI |
906 | * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), |
907 | * Side = 0x02 (0xd) | |
e9edcee0 TI |
908 | * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16 |
909 | * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19 | |
910 | */ | |
911 | ||
912 | /* additional mixers to alc880_three_stack_mixer */ | |
c8b6bf9b | 913 | static struct snd_kcontrol_new alc880_five_stack_mixer[] = { |
e9edcee0 | 914 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 915 | HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT), |
1da177e4 LT |
916 | { } /* end */ |
917 | }; | |
918 | ||
e9edcee0 TI |
919 | /* channel source setting (6/8 channel selection for 5-stack) */ |
920 | /* 6ch mode */ | |
921 | static struct hda_verb alc880_fivestack_ch6_init[] = { | |
922 | /* set line-in to input, mute it */ | |
923 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
924 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
dfc0ff62 TI |
925 | { } /* end */ |
926 | }; | |
927 | ||
e9edcee0 TI |
928 | /* 8ch mode */ |
929 | static struct hda_verb alc880_fivestack_ch8_init[] = { | |
930 | /* set line-in to output, unmute it */ | |
931 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
932 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
933 | { } /* end */ | |
934 | }; | |
935 | ||
d2a6d7dc | 936 | static struct hda_channel_mode alc880_fivestack_modes[2] = { |
e9edcee0 TI |
937 | { 6, alc880_fivestack_ch6_init }, |
938 | { 8, alc880_fivestack_ch8_init }, | |
939 | }; | |
940 | ||
941 | ||
942 | /* | |
943 | * ALC880 6-stack model | |
944 | * | |
9c7f852e TI |
945 | * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), |
946 | * Side = 0x05 (0x0f) | |
e9edcee0 TI |
947 | * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17, |
948 | * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b | |
949 | */ | |
950 | ||
951 | static hda_nid_t alc880_6st_dac_nids[4] = { | |
952 | /* front, rear, clfe, rear_surr */ | |
953 | 0x02, 0x03, 0x04, 0x05 | |
f12ab1e0 | 954 | }; |
e9edcee0 TI |
955 | |
956 | static struct hda_input_mux alc880_6stack_capture_source = { | |
957 | .num_items = 4, | |
958 | .items = { | |
959 | { "Mic", 0x0 }, | |
960 | { "Front Mic", 0x1 }, | |
961 | { "Line", 0x2 }, | |
962 | { "CD", 0x4 }, | |
963 | }, | |
964 | }; | |
965 | ||
966 | /* fixed 8-channels */ | |
d2a6d7dc | 967 | static struct hda_channel_mode alc880_sixstack_modes[1] = { |
e9edcee0 TI |
968 | { 8, NULL }, |
969 | }; | |
970 | ||
c8b6bf9b | 971 | static struct snd_kcontrol_new alc880_six_stack_mixer[] = { |
16ded525 | 972 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 973 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 974 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 975 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
976 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
977 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
978 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
979 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
16ded525 | 980 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 981 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
16ded525 TI |
982 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
983 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
984 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
985 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
986 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
987 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
988 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
989 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
990 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
991 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
16ded525 TI |
992 | { |
993 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
994 | .name = "Channel Mode", | |
df694daa KY |
995 | .info = alc_ch_mode_info, |
996 | .get = alc_ch_mode_get, | |
997 | .put = alc_ch_mode_put, | |
16ded525 TI |
998 | }, |
999 | { } /* end */ | |
1000 | }; | |
1001 | ||
e9edcee0 TI |
1002 | |
1003 | /* | |
1004 | * ALC880 W810 model | |
1005 | * | |
1006 | * W810 has rear IO for: | |
1007 | * Front (DAC 02) | |
1008 | * Surround (DAC 03) | |
1009 | * Center/LFE (DAC 04) | |
1010 | * Digital out (06) | |
1011 | * | |
1012 | * The system also has a pair of internal speakers, and a headphone jack. | |
1013 | * These are both connected to Line2 on the codec, hence to DAC 02. | |
1014 | * | |
1015 | * There is a variable resistor to control the speaker or headphone | |
1016 | * volume. This is a hardware-only device without a software API. | |
1017 | * | |
1018 | * Plugging headphones in will disable the internal speakers. This is | |
1019 | * implemented in hardware, not via the driver using jack sense. In | |
1020 | * a similar fashion, plugging into the rear socket marked "front" will | |
1021 | * disable both the speakers and headphones. | |
1022 | * | |
1023 | * For input, there's a microphone jack, and an "audio in" jack. | |
1024 | * These may not do anything useful with this driver yet, because I | |
1025 | * haven't setup any initialization verbs for these yet... | |
1026 | */ | |
1027 | ||
1028 | static hda_nid_t alc880_w810_dac_nids[3] = { | |
1029 | /* front, rear/surround, clfe */ | |
1030 | 0x02, 0x03, 0x04 | |
16ded525 TI |
1031 | }; |
1032 | ||
e9edcee0 | 1033 | /* fixed 6 channels */ |
d2a6d7dc | 1034 | static struct hda_channel_mode alc880_w810_modes[1] = { |
e9edcee0 TI |
1035 | { 6, NULL } |
1036 | }; | |
1037 | ||
1038 | /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */ | |
c8b6bf9b | 1039 | static struct snd_kcontrol_new alc880_w810_base_mixer[] = { |
16ded525 | 1040 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1041 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 1042 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1043 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1044 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1045 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1046 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1047 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
e9edcee0 TI |
1048 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
1049 | { } /* end */ | |
1050 | }; | |
1051 | ||
1052 | ||
1053 | /* | |
1054 | * Z710V model | |
1055 | * | |
1056 | * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d) | |
9c7f852e TI |
1057 | * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), |
1058 | * Line = 0x1a | |
e9edcee0 TI |
1059 | */ |
1060 | ||
1061 | static hda_nid_t alc880_z71v_dac_nids[1] = { | |
1062 | 0x02 | |
1063 | }; | |
1064 | #define ALC880_Z71V_HP_DAC 0x03 | |
1065 | ||
1066 | /* fixed 2 channels */ | |
d2a6d7dc | 1067 | static struct hda_channel_mode alc880_2_jack_modes[1] = { |
e9edcee0 TI |
1068 | { 2, NULL } |
1069 | }; | |
1070 | ||
c8b6bf9b | 1071 | static struct snd_kcontrol_new alc880_z71v_mixer[] = { |
e9edcee0 | 1072 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1073 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
e9edcee0 | 1074 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1075 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1076 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1077 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
16ded525 TI |
1078 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
1079 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
16ded525 TI |
1080 | { } /* end */ |
1081 | }; | |
1082 | ||
e9edcee0 TI |
1083 | |
1084 | /* FIXME! */ | |
1085 | /* | |
1086 | * ALC880 F1734 model | |
1087 | * | |
1088 | * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d) | |
1089 | * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18 | |
1090 | */ | |
1091 | ||
1092 | static hda_nid_t alc880_f1734_dac_nids[1] = { | |
1093 | 0x03 | |
1094 | }; | |
1095 | #define ALC880_F1734_HP_DAC 0x02 | |
1096 | ||
c8b6bf9b | 1097 | static struct snd_kcontrol_new alc880_f1734_mixer[] = { |
e9edcee0 | 1098 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1099 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), |
e9edcee0 | 1100 | HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1101 | HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT), |
e9edcee0 TI |
1102 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1103 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1104 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1105 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1106 | { } /* end */ | |
1107 | }; | |
1108 | ||
1109 | ||
1110 | /* FIXME! */ | |
1111 | /* | |
1112 | * ALC880 ASUS model | |
1113 | * | |
1114 | * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) | |
1115 | * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, | |
1116 | * Mic = 0x18, Line = 0x1a | |
1117 | */ | |
1118 | ||
1119 | #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */ | |
1120 | #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */ | |
1121 | ||
c8b6bf9b | 1122 | static struct snd_kcontrol_new alc880_asus_mixer[] = { |
16ded525 | 1123 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1124 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 1125 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1126 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1127 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1128 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1129 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1130 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
16ded525 TI |
1131 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1132 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1133 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1134 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
16ded525 TI |
1135 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
1136 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
16ded525 TI |
1137 | { |
1138 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1139 | .name = "Channel Mode", | |
df694daa KY |
1140 | .info = alc_ch_mode_info, |
1141 | .get = alc_ch_mode_get, | |
1142 | .put = alc_ch_mode_put, | |
16ded525 TI |
1143 | }, |
1144 | { } /* end */ | |
1145 | }; | |
e9edcee0 TI |
1146 | |
1147 | /* FIXME! */ | |
1148 | /* | |
1149 | * ALC880 ASUS W1V model | |
1150 | * | |
1151 | * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) | |
1152 | * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, | |
1153 | * Mic = 0x18, Line = 0x1a, Line2 = 0x1b | |
1154 | */ | |
1155 | ||
1156 | /* additional mixers to alc880_asus_mixer */ | |
c8b6bf9b | 1157 | static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = { |
e9edcee0 TI |
1158 | HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT), |
1159 | HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT), | |
1160 | { } /* end */ | |
1161 | }; | |
1162 | ||
3c10a9d9 | 1163 | /* additional mixers to alc880_asus_mixer */ |
c8b6bf9b | 1164 | static struct snd_kcontrol_new alc880_pcbeep_mixer[] = { |
3c10a9d9 TI |
1165 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), |
1166 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
1167 | { } /* end */ | |
1168 | }; | |
e9edcee0 | 1169 | |
df694daa KY |
1170 | /* TCL S700 */ |
1171 | static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = { | |
1172 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1173 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
1174 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
1175 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT), | |
1176 | HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT), | |
1177 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT), | |
1178 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT), | |
1179 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
1180 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
1181 | { | |
1182 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1183 | /* The multiple "Capture Source" controls confuse alsamixer | |
1184 | * So call somewhat different.. | |
1185 | * FIXME: the controls appear in the "playback" view! | |
1186 | */ | |
1187 | /* .name = "Capture Source", */ | |
1188 | .name = "Input Source", | |
1189 | .count = 1, | |
1190 | .info = alc_mux_enum_info, | |
1191 | .get = alc_mux_enum_get, | |
1192 | .put = alc_mux_enum_put, | |
1193 | }, | |
1194 | { } /* end */ | |
1195 | }; | |
1196 | ||
ccc656ce KY |
1197 | /* Uniwill */ |
1198 | static struct snd_kcontrol_new alc880_uniwill_mixer[] = { | |
1199 | HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1200 | HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1201 | HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1202 | HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
1203 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
1204 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
1205 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
1206 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
1207 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
1208 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1209 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1210 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
1211 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1212 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1213 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1214 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1215 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
1216 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
1217 | { | |
1218 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1219 | .name = "Channel Mode", | |
1220 | .info = alc_ch_mode_info, | |
1221 | .get = alc_ch_mode_get, | |
1222 | .put = alc_ch_mode_put, | |
1223 | }, | |
1224 | { } /* end */ | |
1225 | }; | |
1226 | ||
2cf9f0fc TD |
1227 | static struct snd_kcontrol_new alc880_fujitsu_mixer[] = { |
1228 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1229 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1230 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1231 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
1232 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
1233 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1234 | HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1235 | HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1236 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1237 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1238 | { } /* end */ | |
1239 | }; | |
1240 | ||
ccc656ce KY |
1241 | static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = { |
1242 | HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1243 | HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1244 | HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1245 | HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
1246 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1247 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1248 | { } /* end */ | |
1249 | }; | |
1250 | ||
1da177e4 | 1251 | /* |
e9edcee0 | 1252 | * build control elements |
1da177e4 LT |
1253 | */ |
1254 | static int alc_build_controls(struct hda_codec *codec) | |
1255 | { | |
1256 | struct alc_spec *spec = codec->spec; | |
1257 | int err; | |
1258 | int i; | |
1259 | ||
1260 | for (i = 0; i < spec->num_mixers; i++) { | |
1261 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); | |
1262 | if (err < 0) | |
1263 | return err; | |
1264 | } | |
1265 | ||
1266 | if (spec->multiout.dig_out_nid) { | |
9c7f852e TI |
1267 | err = snd_hda_create_spdif_out_ctls(codec, |
1268 | spec->multiout.dig_out_nid); | |
1da177e4 LT |
1269 | if (err < 0) |
1270 | return err; | |
1271 | } | |
1272 | if (spec->dig_in_nid) { | |
1273 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); | |
1274 | if (err < 0) | |
1275 | return err; | |
1276 | } | |
1277 | return 0; | |
1278 | } | |
1279 | ||
e9edcee0 | 1280 | |
1da177e4 LT |
1281 | /* |
1282 | * initialize the codec volumes, etc | |
1283 | */ | |
1284 | ||
e9edcee0 TI |
1285 | /* |
1286 | * generic initialization of ADC, input mixers and output mixers | |
1287 | */ | |
1288 | static struct hda_verb alc880_volume_init_verbs[] = { | |
1289 | /* | |
1290 | * Unmute ADC0-2 and set the default input to mic-in | |
1291 | */ | |
71fe7b82 | 1292 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 1293 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
71fe7b82 | 1294 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 1295 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
71fe7b82 | 1296 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 1297 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1da177e4 | 1298 | |
e9edcee0 TI |
1299 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
1300 | * mixer widget | |
9c7f852e TI |
1301 | * Note: PASD motherboards uses the Line In 2 as the input for front |
1302 | * panel mic (mic 2) | |
1da177e4 | 1303 | */ |
e9edcee0 | 1304 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ |
cb53c626 TI |
1305 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1306 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1307 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
1308 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
1309 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1310 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
1311 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
1da177e4 | 1312 | |
e9edcee0 TI |
1313 | /* |
1314 | * Set up output mixers (0x0c - 0x0f) | |
1da177e4 | 1315 | */ |
e9edcee0 TI |
1316 | /* set vol=0 to output mixers */ |
1317 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1318 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1319 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1320 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1321 | /* set up input amps for analog loopback */ | |
1322 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
05acb863 TI |
1323 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1324 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
1325 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1326 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
1327 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1328 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
1329 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1330 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 LT |
1331 | |
1332 | { } | |
1333 | }; | |
1334 | ||
e9edcee0 TI |
1335 | /* |
1336 | * 3-stack pin configuration: | |
1337 | * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b | |
1338 | */ | |
1339 | static struct hda_verb alc880_pin_3stack_init_verbs[] = { | |
1340 | /* | |
1341 | * preset connection lists of input pins | |
1342 | * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround | |
1343 | */ | |
1344 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
1345 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
1346 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */ | |
1347 | ||
1348 | /* | |
1349 | * Set pin mode and muting | |
1350 | */ | |
1351 | /* set front pin widgets 0x14 for output */ | |
05acb863 | 1352 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
1353 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1354 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
1355 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1356 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1357 | /* Mic2 (as headphone out) for HP output */ | |
1358 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1359 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1da177e4 | 1360 | /* Line In pin widget for input */ |
05acb863 | 1361 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 TI |
1362 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
1363 | /* Line2 (as front mic) pin widget for input and vref at 80% */ | |
1364 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1365 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1da177e4 | 1366 | /* CD pin widget for input */ |
05acb863 | 1367 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 1368 | |
e9edcee0 TI |
1369 | { } |
1370 | }; | |
1da177e4 | 1371 | |
e9edcee0 TI |
1372 | /* |
1373 | * 5-stack pin configuration: | |
1374 | * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19, | |
1375 | * line-in/side = 0x1a, f-mic = 0x1b | |
1376 | */ | |
1377 | static struct hda_verb alc880_pin_5stack_init_verbs[] = { | |
1378 | /* | |
1379 | * preset connection lists of input pins | |
1380 | * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround | |
1da177e4 | 1381 | */ |
e9edcee0 TI |
1382 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
1383 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */ | |
1da177e4 | 1384 | |
e9edcee0 TI |
1385 | /* |
1386 | * Set pin mode and muting | |
1da177e4 | 1387 | */ |
e9edcee0 TI |
1388 | /* set pin widgets 0x14-0x17 for output */ |
1389 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1390 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1391 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1392 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1393 | /* unmute pins for output (no gain on this amp) */ | |
1394 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1395 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1396 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1397 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1398 | ||
1399 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
1400 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1401 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1402 | /* Mic2 (as headphone out) for HP output */ | |
1403 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1404 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1405 | /* Line In pin widget for input */ | |
1406 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1407 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1408 | /* Line2 (as front mic) pin widget for input and vref at 80% */ | |
1409 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1410 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1411 | /* CD pin widget for input */ | |
1412 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1da177e4 LT |
1413 | |
1414 | { } | |
1415 | }; | |
1416 | ||
e9edcee0 TI |
1417 | /* |
1418 | * W810 pin configuration: | |
1419 | * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b | |
1420 | */ | |
1421 | static struct hda_verb alc880_pin_w810_init_verbs[] = { | |
1422 | /* hphone/speaker input selector: front DAC */ | |
1423 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
1da177e4 | 1424 | |
05acb863 | 1425 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1426 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 1427 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1428 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 1429 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1430 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 1431 | |
e9edcee0 | 1432 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
05acb863 | 1433 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
1da177e4 | 1434 | |
1da177e4 LT |
1435 | { } |
1436 | }; | |
1437 | ||
e9edcee0 TI |
1438 | /* |
1439 | * Z71V pin configuration: | |
1440 | * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?) | |
1441 | */ | |
1442 | static struct hda_verb alc880_pin_z71v_init_verbs[] = { | |
05acb863 | 1443 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1444 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 1445 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
e9edcee0 | 1446 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
dfc0ff62 | 1447 | |
16ded525 | 1448 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1449 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
16ded525 | 1450 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1451 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
16ded525 TI |
1452 | |
1453 | { } | |
1454 | }; | |
1455 | ||
e9edcee0 TI |
1456 | /* |
1457 | * 6-stack pin configuration: | |
9c7f852e TI |
1458 | * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, |
1459 | * f-mic = 0x19, line = 0x1a, HP = 0x1b | |
e9edcee0 TI |
1460 | */ |
1461 | static struct hda_verb alc880_pin_6stack_init_verbs[] = { | |
1462 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
1463 | ||
16ded525 | 1464 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1465 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1466 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1467 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1468 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1469 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1470 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
1471 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1472 | ||
16ded525 | 1473 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1474 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 1475 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1476 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 1477 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 | 1478 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 1479 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
e9edcee0 | 1480 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 TI |
1481 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1482 | ||
e9edcee0 TI |
1483 | { } |
1484 | }; | |
1485 | ||
ccc656ce KY |
1486 | /* |
1487 | * Uniwill pin configuration: | |
1488 | * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19, | |
1489 | * line = 0x1a | |
1490 | */ | |
1491 | static struct hda_verb alc880_uniwill_init_verbs[] = { | |
1492 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
1493 | ||
1494 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1495 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1496 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1497 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1498 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1499 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1500 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1501 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1502 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1503 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1504 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1505 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1506 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1507 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1508 | ||
1509 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1510 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1511 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1512 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1513 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1514 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1515 | /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */ | |
1516 | /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */ | |
1517 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1518 | ||
1519 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
1520 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
1521 | ||
1522 | { } | |
1523 | }; | |
1524 | ||
1525 | /* | |
1526 | * Uniwill P53 | |
1527 | * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19, | |
1528 | */ | |
1529 | static struct hda_verb alc880_uniwill_p53_init_verbs[] = { | |
1530 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
1531 | ||
1532 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1533 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1534 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1535 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1536 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1537 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1538 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1539 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1540 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1541 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1542 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1543 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1544 | ||
1545 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1546 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1547 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1548 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1549 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1550 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1551 | ||
1552 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
1553 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT}, | |
1554 | ||
1555 | { } | |
1556 | }; | |
1557 | ||
2cf9f0fc TD |
1558 | static struct hda_verb alc880_beep_init_verbs[] = { |
1559 | { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) }, | |
1560 | { } | |
1561 | }; | |
1562 | ||
ccc656ce | 1563 | /* toggle speaker-output according to the hp-jack state */ |
458a4fab | 1564 | static void alc880_uniwill_hp_automute(struct hda_codec *codec) |
ccc656ce KY |
1565 | { |
1566 | unsigned int present; | |
f12ab1e0 | 1567 | unsigned char bits; |
ccc656ce KY |
1568 | |
1569 | present = snd_hda_codec_read(codec, 0x14, 0, | |
1570 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
1571 | bits = present ? HDA_AMP_MUTE : 0; |
1572 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
1573 | HDA_AMP_MUTE, bits); | |
1574 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
1575 | HDA_AMP_MUTE, bits); | |
458a4fab TI |
1576 | } |
1577 | ||
1578 | /* auto-toggle front mic */ | |
1579 | static void alc880_uniwill_mic_automute(struct hda_codec *codec) | |
1580 | { | |
1581 | unsigned int present; | |
1582 | unsigned char bits; | |
ccc656ce KY |
1583 | |
1584 | present = snd_hda_codec_read(codec, 0x18, 0, | |
1585 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
1586 | bits = present ? HDA_AMP_MUTE : 0; |
1587 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); | |
458a4fab TI |
1588 | } |
1589 | ||
1590 | static void alc880_uniwill_automute(struct hda_codec *codec) | |
1591 | { | |
1592 | alc880_uniwill_hp_automute(codec); | |
1593 | alc880_uniwill_mic_automute(codec); | |
ccc656ce KY |
1594 | } |
1595 | ||
1596 | static void alc880_uniwill_unsol_event(struct hda_codec *codec, | |
1597 | unsigned int res) | |
1598 | { | |
1599 | /* Looks like the unsol event is incompatible with the standard | |
1600 | * definition. 4bit tag is placed at 28 bit! | |
1601 | */ | |
458a4fab TI |
1602 | switch (res >> 28) { |
1603 | case ALC880_HP_EVENT: | |
1604 | alc880_uniwill_hp_automute(codec); | |
1605 | break; | |
1606 | case ALC880_MIC_EVENT: | |
1607 | alc880_uniwill_mic_automute(codec); | |
1608 | break; | |
1609 | } | |
ccc656ce KY |
1610 | } |
1611 | ||
1612 | static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec) | |
1613 | { | |
1614 | unsigned int present; | |
f12ab1e0 | 1615 | unsigned char bits; |
ccc656ce KY |
1616 | |
1617 | present = snd_hda_codec_read(codec, 0x14, 0, | |
1618 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
1619 | bits = present ? HDA_AMP_MUTE : 0; |
1620 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits); | |
ccc656ce KY |
1621 | } |
1622 | ||
1623 | static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) | |
1624 | { | |
1625 | unsigned int present; | |
1626 | ||
1627 | present = snd_hda_codec_read(codec, 0x21, 0, | |
47fd830a TI |
1628 | AC_VERB_GET_VOLUME_KNOB_CONTROL, 0); |
1629 | present &= HDA_AMP_VOLMASK; | |
1630 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, | |
1631 | HDA_AMP_VOLMASK, present); | |
1632 | snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0, | |
1633 | HDA_AMP_VOLMASK, present); | |
ccc656ce | 1634 | } |
47fd830a | 1635 | |
ccc656ce KY |
1636 | static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec, |
1637 | unsigned int res) | |
1638 | { | |
1639 | /* Looks like the unsol event is incompatible with the standard | |
1640 | * definition. 4bit tag is placed at 28 bit! | |
1641 | */ | |
1642 | if ((res >> 28) == ALC880_HP_EVENT) | |
1643 | alc880_uniwill_p53_hp_automute(codec); | |
f12ab1e0 | 1644 | if ((res >> 28) == ALC880_DCVOL_EVENT) |
ccc656ce KY |
1645 | alc880_uniwill_p53_dcvol_automute(codec); |
1646 | } | |
1647 | ||
e9edcee0 TI |
1648 | /* FIXME! */ |
1649 | /* | |
1650 | * F1734 pin configuration: | |
1651 | * HP = 0x14, speaker-out = 0x15, mic = 0x18 | |
1652 | */ | |
1653 | static struct hda_verb alc880_pin_f1734_init_verbs[] = { | |
16ded525 TI |
1654 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, |
1655 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1656 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
1657 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1658 | ||
e9edcee0 | 1659 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
16ded525 | 1660 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
e9edcee0 | 1661 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
16ded525 | 1662 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1663 | |
e9edcee0 TI |
1664 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1665 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
16ded525 | 1666 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1667 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 1668 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1669 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1670 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1671 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1672 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
dfc0ff62 TI |
1673 | |
1674 | { } | |
1675 | }; | |
1676 | ||
e9edcee0 TI |
1677 | /* FIXME! */ |
1678 | /* | |
1679 | * ASUS pin configuration: | |
1680 | * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a | |
1681 | */ | |
1682 | static struct hda_verb alc880_pin_asus_init_verbs[] = { | |
16ded525 TI |
1683 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, |
1684 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1685 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
1686 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1687 | ||
1688 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
e9edcee0 | 1689 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1690 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1691 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1692 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1693 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1694 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
1695 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1696 | ||
1697 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1698 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1699 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1700 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1701 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1702 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
16ded525 | 1703 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1704 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 TI |
1705 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1706 | ||
e9edcee0 TI |
1707 | { } |
1708 | }; | |
16ded525 | 1709 | |
e9edcee0 | 1710 | /* Enable GPIO mask and set output */ |
bc9f98a9 KY |
1711 | #define alc880_gpio1_init_verbs alc_gpio1_init_verbs |
1712 | #define alc880_gpio2_init_verbs alc_gpio2_init_verbs | |
df694daa KY |
1713 | |
1714 | /* Clevo m520g init */ | |
1715 | static struct hda_verb alc880_pin_clevo_init_verbs[] = { | |
1716 | /* headphone output */ | |
1717 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
1718 | /* line-out */ | |
1719 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1720 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1721 | /* Line-in */ | |
1722 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1723 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1724 | /* CD */ | |
1725 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1726 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1727 | /* Mic1 (rear panel) */ | |
1728 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1729 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1730 | /* Mic2 (front panel) */ | |
1731 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1732 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1733 | /* headphone */ | |
1734 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1735 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1736 | /* change to EAPD mode */ | |
1737 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
1738 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, | |
1739 | ||
1740 | { } | |
16ded525 TI |
1741 | }; |
1742 | ||
df694daa | 1743 | static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = { |
4b146cb0 TI |
1744 | /* change to EAPD mode */ |
1745 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
1746 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, | |
1747 | ||
df694daa KY |
1748 | /* Headphone output */ |
1749 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1750 | /* Front output*/ | |
1751 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1752 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1753 | ||
1754 | /* Line In pin widget for input */ | |
1755 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1756 | /* CD pin widget for input */ | |
1757 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1758 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
1759 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1760 | ||
1761 | /* change to EAPD mode */ | |
1762 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
1763 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
1764 | ||
1765 | { } | |
1766 | }; | |
16ded525 | 1767 | |
e9edcee0 | 1768 | /* |
ae6b813a TI |
1769 | * LG m1 express dual |
1770 | * | |
1771 | * Pin assignment: | |
1772 | * Rear Line-In/Out (blue): 0x14 | |
1773 | * Build-in Mic-In: 0x15 | |
1774 | * Speaker-out: 0x17 | |
1775 | * HP-Out (green): 0x1b | |
1776 | * Mic-In/Out (red): 0x19 | |
1777 | * SPDIF-Out: 0x1e | |
1778 | */ | |
1779 | ||
1780 | /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */ | |
1781 | static hda_nid_t alc880_lg_dac_nids[3] = { | |
1782 | 0x05, 0x02, 0x03 | |
1783 | }; | |
1784 | ||
1785 | /* seems analog CD is not working */ | |
1786 | static struct hda_input_mux alc880_lg_capture_source = { | |
1787 | .num_items = 3, | |
1788 | .items = { | |
1789 | { "Mic", 0x1 }, | |
1790 | { "Line", 0x5 }, | |
1791 | { "Internal Mic", 0x6 }, | |
1792 | }, | |
1793 | }; | |
1794 | ||
1795 | /* 2,4,6 channel modes */ | |
1796 | static struct hda_verb alc880_lg_ch2_init[] = { | |
1797 | /* set line-in and mic-in to input */ | |
1798 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
1799 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
1800 | { } | |
1801 | }; | |
1802 | ||
1803 | static struct hda_verb alc880_lg_ch4_init[] = { | |
1804 | /* set line-in to out and mic-in to input */ | |
1805 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
1806 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
1807 | { } | |
1808 | }; | |
1809 | ||
1810 | static struct hda_verb alc880_lg_ch6_init[] = { | |
1811 | /* set line-in and mic-in to output */ | |
1812 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
1813 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
1814 | { } | |
1815 | }; | |
1816 | ||
1817 | static struct hda_channel_mode alc880_lg_ch_modes[3] = { | |
1818 | { 2, alc880_lg_ch2_init }, | |
1819 | { 4, alc880_lg_ch4_init }, | |
1820 | { 6, alc880_lg_ch6_init }, | |
1821 | }; | |
1822 | ||
1823 | static struct snd_kcontrol_new alc880_lg_mixer[] = { | |
1824 | /* FIXME: it's not really "master" but front channels */ | |
1825 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
1826 | HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT), | |
1827 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1828 | HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT), | |
1829 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), | |
1830 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT), | |
1831 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT), | |
1832 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), | |
1833 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1834 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1835 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT), | |
1836 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT), | |
1837 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT), | |
1838 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT), | |
1839 | { | |
1840 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1841 | .name = "Channel Mode", | |
1842 | .info = alc_ch_mode_info, | |
1843 | .get = alc_ch_mode_get, | |
1844 | .put = alc_ch_mode_put, | |
1845 | }, | |
1846 | { } /* end */ | |
1847 | }; | |
1848 | ||
1849 | static struct hda_verb alc880_lg_init_verbs[] = { | |
1850 | /* set capture source to mic-in */ | |
1851 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
1852 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
1853 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
1854 | /* mute all amp mixer inputs */ | |
1855 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)}, | |
cb53c626 TI |
1856 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, |
1857 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
ae6b813a TI |
1858 | /* line-in to input */ |
1859 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1860 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1861 | /* built-in mic */ | |
1862 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1863 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1864 | /* speaker-out */ | |
1865 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1866 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1867 | /* mic-in to input */ | |
1868 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
1869 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1870 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1871 | /* HP-out */ | |
1872 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
1873 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1874 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1875 | /* jack sense */ | |
1876 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, | |
1877 | { } | |
1878 | }; | |
1879 | ||
1880 | /* toggle speaker-output according to the hp-jack state */ | |
1881 | static void alc880_lg_automute(struct hda_codec *codec) | |
1882 | { | |
1883 | unsigned int present; | |
f12ab1e0 | 1884 | unsigned char bits; |
ae6b813a TI |
1885 | |
1886 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
1887 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
1888 | bits = present ? HDA_AMP_MUTE : 0; |
1889 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
1890 | HDA_AMP_MUTE, bits); | |
ae6b813a TI |
1891 | } |
1892 | ||
1893 | static void alc880_lg_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_automute(codec); | |
1900 | } | |
1901 | ||
d681518a TI |
1902 | /* |
1903 | * LG LW20 | |
1904 | * | |
1905 | * Pin assignment: | |
1906 | * Speaker-out: 0x14 | |
1907 | * Mic-In: 0x18 | |
e4f41da9 CM |
1908 | * Built-in Mic-In: 0x19 |
1909 | * Line-In: 0x1b | |
1910 | * HP-Out: 0x1a | |
d681518a TI |
1911 | * SPDIF-Out: 0x1e |
1912 | */ | |
1913 | ||
d681518a | 1914 | static struct hda_input_mux alc880_lg_lw_capture_source = { |
e4f41da9 | 1915 | .num_items = 3, |
d681518a TI |
1916 | .items = { |
1917 | { "Mic", 0x0 }, | |
1918 | { "Internal Mic", 0x1 }, | |
e4f41da9 | 1919 | { "Line In", 0x2 }, |
d681518a TI |
1920 | }, |
1921 | }; | |
1922 | ||
0a8c5da3 CM |
1923 | #define alc880_lg_lw_modes alc880_threestack_modes |
1924 | ||
d681518a | 1925 | static struct snd_kcontrol_new alc880_lg_lw_mixer[] = { |
0a8c5da3 CM |
1926 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
1927 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
1928 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
1929 | HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT), | |
1930 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
1931 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
1932 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
1933 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
1934 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1935 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
d681518a TI |
1936 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
1937 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1938 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
1939 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
0a8c5da3 CM |
1940 | { |
1941 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1942 | .name = "Channel Mode", | |
1943 | .info = alc_ch_mode_info, | |
1944 | .get = alc_ch_mode_get, | |
1945 | .put = alc_ch_mode_put, | |
1946 | }, | |
d681518a TI |
1947 | { } /* end */ |
1948 | }; | |
1949 | ||
1950 | static struct hda_verb alc880_lg_lw_init_verbs[] = { | |
0a8c5da3 CM |
1951 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
1952 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
1953 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */ | |
1954 | ||
d681518a TI |
1955 | /* set capture source to mic-in */ |
1956 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
1957 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
1958 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
cb53c626 | 1959 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, |
d681518a TI |
1960 | /* speaker-out */ |
1961 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1962 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1963 | /* HP-out */ | |
d681518a TI |
1964 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
1965 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1966 | /* mic-in to input */ | |
1967 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1968 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1969 | /* built-in mic */ | |
1970 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1971 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1972 | /* jack sense */ | |
1973 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, | |
1974 | { } | |
1975 | }; | |
1976 | ||
1977 | /* toggle speaker-output according to the hp-jack state */ | |
1978 | static void alc880_lg_lw_automute(struct hda_codec *codec) | |
1979 | { | |
1980 | unsigned int present; | |
f12ab1e0 | 1981 | unsigned char bits; |
d681518a TI |
1982 | |
1983 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
1984 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
1985 | bits = present ? HDA_AMP_MUTE : 0; |
1986 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
1987 | HDA_AMP_MUTE, bits); | |
d681518a TI |
1988 | } |
1989 | ||
1990 | static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res) | |
1991 | { | |
1992 | /* Looks like the unsol event is incompatible with the standard | |
1993 | * definition. 4bit tag is placed at 28 bit! | |
1994 | */ | |
1995 | if ((res >> 28) == 0x01) | |
1996 | alc880_lg_lw_automute(codec); | |
1997 | } | |
1998 | ||
cb53c626 TI |
1999 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
2000 | static struct hda_amp_list alc880_loopbacks[] = { | |
2001 | { 0x0b, HDA_INPUT, 0 }, | |
2002 | { 0x0b, HDA_INPUT, 1 }, | |
2003 | { 0x0b, HDA_INPUT, 2 }, | |
2004 | { 0x0b, HDA_INPUT, 3 }, | |
2005 | { 0x0b, HDA_INPUT, 4 }, | |
2006 | { } /* end */ | |
2007 | }; | |
2008 | ||
2009 | static struct hda_amp_list alc880_lg_loopbacks[] = { | |
2010 | { 0x0b, HDA_INPUT, 1 }, | |
2011 | { 0x0b, HDA_INPUT, 6 }, | |
2012 | { 0x0b, HDA_INPUT, 7 }, | |
2013 | { } /* end */ | |
2014 | }; | |
2015 | #endif | |
2016 | ||
ae6b813a TI |
2017 | /* |
2018 | * Common callbacks | |
e9edcee0 TI |
2019 | */ |
2020 | ||
1da177e4 LT |
2021 | static int alc_init(struct hda_codec *codec) |
2022 | { | |
2023 | struct alc_spec *spec = codec->spec; | |
e9edcee0 TI |
2024 | unsigned int i; |
2025 | ||
2026 | for (i = 0; i < spec->num_init_verbs; i++) | |
2027 | snd_hda_sequence_write(codec, spec->init_verbs[i]); | |
ae6b813a TI |
2028 | |
2029 | if (spec->init_hook) | |
2030 | spec->init_hook(codec); | |
2031 | ||
1da177e4 LT |
2032 | return 0; |
2033 | } | |
2034 | ||
ae6b813a TI |
2035 | static void alc_unsol_event(struct hda_codec *codec, unsigned int res) |
2036 | { | |
2037 | struct alc_spec *spec = codec->spec; | |
2038 | ||
2039 | if (spec->unsol_event) | |
2040 | spec->unsol_event(codec, res); | |
2041 | } | |
2042 | ||
cb53c626 TI |
2043 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
2044 | static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid) | |
2045 | { | |
2046 | struct alc_spec *spec = codec->spec; | |
2047 | return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); | |
2048 | } | |
2049 | #endif | |
2050 | ||
1da177e4 LT |
2051 | /* |
2052 | * Analog playback callbacks | |
2053 | */ | |
2054 | static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo, | |
2055 | struct hda_codec *codec, | |
c8b6bf9b | 2056 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2057 | { |
2058 | struct alc_spec *spec = codec->spec; | |
2059 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); | |
2060 | } | |
2061 | ||
2062 | static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | |
2063 | struct hda_codec *codec, | |
2064 | unsigned int stream_tag, | |
2065 | unsigned int format, | |
c8b6bf9b | 2066 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2067 | { |
2068 | struct alc_spec *spec = codec->spec; | |
9c7f852e TI |
2069 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, |
2070 | stream_tag, format, substream); | |
1da177e4 LT |
2071 | } |
2072 | ||
2073 | static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, | |
2074 | struct hda_codec *codec, | |
c8b6bf9b | 2075 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2076 | { |
2077 | struct alc_spec *spec = codec->spec; | |
2078 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); | |
2079 | } | |
2080 | ||
2081 | /* | |
2082 | * Digital out | |
2083 | */ | |
2084 | static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, | |
2085 | struct hda_codec *codec, | |
c8b6bf9b | 2086 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2087 | { |
2088 | struct alc_spec *spec = codec->spec; | |
2089 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); | |
2090 | } | |
2091 | ||
6b97eb45 TI |
2092 | static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
2093 | struct hda_codec *codec, | |
2094 | unsigned int stream_tag, | |
2095 | unsigned int format, | |
2096 | struct snd_pcm_substream *substream) | |
2097 | { | |
2098 | struct alc_spec *spec = codec->spec; | |
2099 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, | |
2100 | stream_tag, format, substream); | |
2101 | } | |
2102 | ||
1da177e4 LT |
2103 | static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
2104 | struct hda_codec *codec, | |
c8b6bf9b | 2105 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2106 | { |
2107 | struct alc_spec *spec = codec->spec; | |
2108 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); | |
2109 | } | |
2110 | ||
2111 | /* | |
2112 | * Analog capture | |
2113 | */ | |
2114 | static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo, | |
2115 | struct hda_codec *codec, | |
2116 | unsigned int stream_tag, | |
2117 | unsigned int format, | |
c8b6bf9b | 2118 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2119 | { |
2120 | struct alc_spec *spec = codec->spec; | |
2121 | ||
2122 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], | |
2123 | stream_tag, 0, format); | |
2124 | return 0; | |
2125 | } | |
2126 | ||
2127 | static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, | |
2128 | struct hda_codec *codec, | |
c8b6bf9b | 2129 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2130 | { |
2131 | struct alc_spec *spec = codec->spec; | |
2132 | ||
9c7f852e TI |
2133 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], |
2134 | 0, 0, 0); | |
1da177e4 LT |
2135 | return 0; |
2136 | } | |
2137 | ||
2138 | ||
2139 | /* | |
2140 | */ | |
2141 | static struct hda_pcm_stream alc880_pcm_analog_playback = { | |
2142 | .substreams = 1, | |
2143 | .channels_min = 2, | |
2144 | .channels_max = 8, | |
e9edcee0 | 2145 | /* NID is set in alc_build_pcms */ |
1da177e4 LT |
2146 | .ops = { |
2147 | .open = alc880_playback_pcm_open, | |
2148 | .prepare = alc880_playback_pcm_prepare, | |
2149 | .cleanup = alc880_playback_pcm_cleanup | |
2150 | }, | |
2151 | }; | |
2152 | ||
2153 | static struct hda_pcm_stream alc880_pcm_analog_capture = { | |
2154 | .substreams = 2, | |
2155 | .channels_min = 2, | |
2156 | .channels_max = 2, | |
e9edcee0 | 2157 | /* NID is set in alc_build_pcms */ |
1da177e4 LT |
2158 | .ops = { |
2159 | .prepare = alc880_capture_pcm_prepare, | |
2160 | .cleanup = alc880_capture_pcm_cleanup | |
2161 | }, | |
2162 | }; | |
2163 | ||
2164 | static struct hda_pcm_stream alc880_pcm_digital_playback = { | |
2165 | .substreams = 1, | |
2166 | .channels_min = 2, | |
2167 | .channels_max = 2, | |
2168 | /* NID is set in alc_build_pcms */ | |
2169 | .ops = { | |
2170 | .open = alc880_dig_playback_pcm_open, | |
6b97eb45 TI |
2171 | .close = alc880_dig_playback_pcm_close, |
2172 | .prepare = alc880_dig_playback_pcm_prepare | |
1da177e4 LT |
2173 | }, |
2174 | }; | |
2175 | ||
2176 | static struct hda_pcm_stream alc880_pcm_digital_capture = { | |
2177 | .substreams = 1, | |
2178 | .channels_min = 2, | |
2179 | .channels_max = 2, | |
2180 | /* NID is set in alc_build_pcms */ | |
2181 | }; | |
2182 | ||
4c5186ed JW |
2183 | /* Used by alc_build_pcms to flag that a PCM has no playback stream */ |
2184 | static struct hda_pcm_stream alc_pcm_null_playback = { | |
2185 | .substreams = 0, | |
2186 | .channels_min = 0, | |
2187 | .channels_max = 0, | |
2188 | }; | |
2189 | ||
1da177e4 LT |
2190 | static int alc_build_pcms(struct hda_codec *codec) |
2191 | { | |
2192 | struct alc_spec *spec = codec->spec; | |
2193 | struct hda_pcm *info = spec->pcm_rec; | |
2194 | int i; | |
2195 | ||
2196 | codec->num_pcms = 1; | |
2197 | codec->pcm_info = info; | |
2198 | ||
2199 | info->name = spec->stream_name_analog; | |
4a471b7d TI |
2200 | if (spec->stream_analog_playback) { |
2201 | snd_assert(spec->multiout.dac_nids, return -EINVAL); | |
2202 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback); | |
2203 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; | |
2204 | } | |
2205 | if (spec->stream_analog_capture) { | |
2206 | snd_assert(spec->adc_nids, return -EINVAL); | |
2207 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); | |
2208 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; | |
2209 | } | |
2210 | ||
2211 | if (spec->channel_mode) { | |
2212 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; | |
2213 | for (i = 0; i < spec->num_channel_mode; i++) { | |
2214 | if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { | |
2215 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; | |
2216 | } | |
1da177e4 LT |
2217 | } |
2218 | } | |
2219 | ||
e08a007d | 2220 | /* SPDIF for stream index #1 */ |
1da177e4 | 2221 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
e08a007d | 2222 | codec->num_pcms = 2; |
c06134d7 | 2223 | info = spec->pcm_rec + 1; |
1da177e4 | 2224 | info->name = spec->stream_name_digital; |
4a471b7d TI |
2225 | if (spec->multiout.dig_out_nid && |
2226 | spec->stream_digital_playback) { | |
1da177e4 LT |
2227 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback); |
2228 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; | |
2229 | } | |
4a471b7d TI |
2230 | if (spec->dig_in_nid && |
2231 | spec->stream_digital_capture) { | |
1da177e4 LT |
2232 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture); |
2233 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; | |
2234 | } | |
2235 | } | |
2236 | ||
e08a007d TI |
2237 | /* If the use of more than one ADC is requested for the current |
2238 | * model, configure a second analog capture-only PCM. | |
2239 | */ | |
2240 | /* Additional Analaog capture for index #2 */ | |
2241 | if (spec->num_adc_nids > 1 && spec->stream_analog_capture && | |
2242 | spec->adc_nids) { | |
2243 | codec->num_pcms = 3; | |
c06134d7 | 2244 | info = spec->pcm_rec + 2; |
e08a007d TI |
2245 | info->name = spec->stream_name_analog; |
2246 | /* No playback stream for second PCM */ | |
2247 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback; | |
2248 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; | |
2249 | if (spec->stream_analog_capture) { | |
2250 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); | |
2251 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1]; | |
2252 | } | |
2253 | } | |
2254 | ||
1da177e4 LT |
2255 | return 0; |
2256 | } | |
2257 | ||
2258 | static void alc_free(struct hda_codec *codec) | |
2259 | { | |
e9edcee0 TI |
2260 | struct alc_spec *spec = codec->spec; |
2261 | unsigned int i; | |
2262 | ||
f12ab1e0 | 2263 | if (!spec) |
e9edcee0 TI |
2264 | return; |
2265 | ||
2266 | if (spec->kctl_alloc) { | |
2267 | for (i = 0; i < spec->num_kctl_used; i++) | |
2268 | kfree(spec->kctl_alloc[i].name); | |
2269 | kfree(spec->kctl_alloc); | |
2270 | } | |
2271 | kfree(spec); | |
1da177e4 LT |
2272 | } |
2273 | ||
2274 | /* | |
2275 | */ | |
2276 | static struct hda_codec_ops alc_patch_ops = { | |
2277 | .build_controls = alc_build_controls, | |
2278 | .build_pcms = alc_build_pcms, | |
2279 | .init = alc_init, | |
2280 | .free = alc_free, | |
ae6b813a | 2281 | .unsol_event = alc_unsol_event, |
cb53c626 TI |
2282 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
2283 | .check_power_status = alc_check_power_status, | |
2284 | #endif | |
1da177e4 LT |
2285 | }; |
2286 | ||
2fa522be TI |
2287 | |
2288 | /* | |
2289 | * Test configuration for debugging | |
2290 | * | |
2291 | * Almost all inputs/outputs are enabled. I/O pins can be configured via | |
2292 | * enum controls. | |
2293 | */ | |
2294 | #ifdef CONFIG_SND_DEBUG | |
2295 | static hda_nid_t alc880_test_dac_nids[4] = { | |
2296 | 0x02, 0x03, 0x04, 0x05 | |
2297 | }; | |
2298 | ||
2299 | static struct hda_input_mux alc880_test_capture_source = { | |
ae6b813a | 2300 | .num_items = 7, |
2fa522be TI |
2301 | .items = { |
2302 | { "In-1", 0x0 }, | |
2303 | { "In-2", 0x1 }, | |
2304 | { "In-3", 0x2 }, | |
2305 | { "In-4", 0x3 }, | |
2306 | { "CD", 0x4 }, | |
ae6b813a TI |
2307 | { "Front", 0x5 }, |
2308 | { "Surround", 0x6 }, | |
2fa522be TI |
2309 | }, |
2310 | }; | |
2311 | ||
d2a6d7dc | 2312 | static struct hda_channel_mode alc880_test_modes[4] = { |
2fa522be | 2313 | { 2, NULL }, |
fd2c326d | 2314 | { 4, NULL }, |
2fa522be | 2315 | { 6, NULL }, |
fd2c326d | 2316 | { 8, NULL }, |
2fa522be TI |
2317 | }; |
2318 | ||
9c7f852e TI |
2319 | static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, |
2320 | struct snd_ctl_elem_info *uinfo) | |
2fa522be TI |
2321 | { |
2322 | static char *texts[] = { | |
2323 | "N/A", "Line Out", "HP Out", | |
2324 | "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%" | |
2325 | }; | |
2326 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
2327 | uinfo->count = 1; | |
2328 | uinfo->value.enumerated.items = 8; | |
2329 | if (uinfo->value.enumerated.item >= 8) | |
2330 | uinfo->value.enumerated.item = 7; | |
2331 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | |
2332 | return 0; | |
2333 | } | |
2334 | ||
9c7f852e TI |
2335 | static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, |
2336 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
2337 | { |
2338 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2339 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
2340 | unsigned int pin_ctl, item = 0; | |
2341 | ||
2342 | pin_ctl = snd_hda_codec_read(codec, nid, 0, | |
2343 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | |
2344 | if (pin_ctl & AC_PINCTL_OUT_EN) { | |
2345 | if (pin_ctl & AC_PINCTL_HP_EN) | |
2346 | item = 2; | |
2347 | else | |
2348 | item = 1; | |
2349 | } else if (pin_ctl & AC_PINCTL_IN_EN) { | |
2350 | switch (pin_ctl & AC_PINCTL_VREFEN) { | |
2351 | case AC_PINCTL_VREF_HIZ: item = 3; break; | |
2352 | case AC_PINCTL_VREF_50: item = 4; break; | |
2353 | case AC_PINCTL_VREF_GRD: item = 5; break; | |
2354 | case AC_PINCTL_VREF_80: item = 6; break; | |
2355 | case AC_PINCTL_VREF_100: item = 7; break; | |
2356 | } | |
2357 | } | |
2358 | ucontrol->value.enumerated.item[0] = item; | |
2359 | return 0; | |
2360 | } | |
2361 | ||
9c7f852e TI |
2362 | static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, |
2363 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
2364 | { |
2365 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2366 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
2367 | static unsigned int ctls[] = { | |
2368 | 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN, | |
2369 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ, | |
2370 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_50, | |
2371 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD, | |
2372 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_80, | |
2373 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_100, | |
2374 | }; | |
2375 | unsigned int old_ctl, new_ctl; | |
2376 | ||
2377 | old_ctl = snd_hda_codec_read(codec, nid, 0, | |
2378 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | |
2379 | new_ctl = ctls[ucontrol->value.enumerated.item[0]]; | |
2380 | if (old_ctl != new_ctl) { | |
82beb8fd TI |
2381 | int val; |
2382 | snd_hda_codec_write_cache(codec, nid, 0, | |
2383 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
2384 | new_ctl); | |
47fd830a TI |
2385 | val = ucontrol->value.enumerated.item[0] >= 3 ? |
2386 | HDA_AMP_MUTE : 0; | |
2387 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, | |
2388 | HDA_AMP_MUTE, val); | |
2fa522be TI |
2389 | return 1; |
2390 | } | |
2391 | return 0; | |
2392 | } | |
2393 | ||
9c7f852e TI |
2394 | static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, |
2395 | struct snd_ctl_elem_info *uinfo) | |
2fa522be TI |
2396 | { |
2397 | static char *texts[] = { | |
2398 | "Front", "Surround", "CLFE", "Side" | |
2399 | }; | |
2400 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
2401 | uinfo->count = 1; | |
2402 | uinfo->value.enumerated.items = 4; | |
2403 | if (uinfo->value.enumerated.item >= 4) | |
2404 | uinfo->value.enumerated.item = 3; | |
2405 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | |
2406 | return 0; | |
2407 | } | |
2408 | ||
9c7f852e TI |
2409 | static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, |
2410 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
2411 | { |
2412 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2413 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
2414 | unsigned int sel; | |
2415 | ||
2416 | sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0); | |
2417 | ucontrol->value.enumerated.item[0] = sel & 3; | |
2418 | return 0; | |
2419 | } | |
2420 | ||
9c7f852e TI |
2421 | static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, |
2422 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
2423 | { |
2424 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2425 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
2426 | unsigned int sel; | |
2427 | ||
2428 | sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3; | |
2429 | if (ucontrol->value.enumerated.item[0] != sel) { | |
2430 | sel = ucontrol->value.enumerated.item[0] & 3; | |
82beb8fd TI |
2431 | snd_hda_codec_write_cache(codec, nid, 0, |
2432 | AC_VERB_SET_CONNECT_SEL, sel); | |
2fa522be TI |
2433 | return 1; |
2434 | } | |
2435 | return 0; | |
2436 | } | |
2437 | ||
2438 | #define PIN_CTL_TEST(xname,nid) { \ | |
2439 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
2440 | .name = xname, \ | |
2441 | .info = alc_test_pin_ctl_info, \ | |
2442 | .get = alc_test_pin_ctl_get, \ | |
2443 | .put = alc_test_pin_ctl_put, \ | |
2444 | .private_value = nid \ | |
2445 | } | |
2446 | ||
2447 | #define PIN_SRC_TEST(xname,nid) { \ | |
2448 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
2449 | .name = xname, \ | |
2450 | .info = alc_test_pin_src_info, \ | |
2451 | .get = alc_test_pin_src_get, \ | |
2452 | .put = alc_test_pin_src_put, \ | |
2453 | .private_value = nid \ | |
2454 | } | |
2455 | ||
c8b6bf9b | 2456 | static struct snd_kcontrol_new alc880_test_mixer[] = { |
05acb863 TI |
2457 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
2458 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
2459 | HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT), | |
2460 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
985be54b TI |
2461 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
2462 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
2463 | HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT), | |
2464 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
2fa522be TI |
2465 | PIN_CTL_TEST("Front Pin Mode", 0x14), |
2466 | PIN_CTL_TEST("Surround Pin Mode", 0x15), | |
2467 | PIN_CTL_TEST("CLFE Pin Mode", 0x16), | |
2468 | PIN_CTL_TEST("Side Pin Mode", 0x17), | |
2469 | PIN_CTL_TEST("In-1 Pin Mode", 0x18), | |
2470 | PIN_CTL_TEST("In-2 Pin Mode", 0x19), | |
2471 | PIN_CTL_TEST("In-3 Pin Mode", 0x1a), | |
2472 | PIN_CTL_TEST("In-4 Pin Mode", 0x1b), | |
2473 | PIN_SRC_TEST("In-1 Pin Source", 0x18), | |
2474 | PIN_SRC_TEST("In-2 Pin Source", 0x19), | |
2475 | PIN_SRC_TEST("In-3 Pin Source", 0x1a), | |
2476 | PIN_SRC_TEST("In-4 Pin Source", 0x1b), | |
2477 | HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
2478 | HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2479 | HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
2480 | HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
2481 | HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT), | |
2482 | HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT), | |
2483 | HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT), | |
2484 | HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT), | |
2485 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT), | |
2486 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT), | |
2fa522be TI |
2487 | { |
2488 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2489 | .name = "Channel Mode", | |
df694daa KY |
2490 | .info = alc_ch_mode_info, |
2491 | .get = alc_ch_mode_get, | |
2492 | .put = alc_ch_mode_put, | |
2fa522be TI |
2493 | }, |
2494 | { } /* end */ | |
2495 | }; | |
2496 | ||
2497 | static struct hda_verb alc880_test_init_verbs[] = { | |
2498 | /* Unmute inputs of 0x0c - 0x0f */ | |
05acb863 TI |
2499 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
2500 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2501 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2502 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2503 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2504 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2505 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2506 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2fa522be | 2507 | /* Vol output for 0x0c-0x0f */ |
05acb863 TI |
2508 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
2509 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2510 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2511 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2fa522be | 2512 | /* Set output pins 0x14-0x17 */ |
05acb863 TI |
2513 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
2514 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2515 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2516 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2fa522be | 2517 | /* Unmute output pins 0x14-0x17 */ |
05acb863 TI |
2518 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
2519 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2520 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2521 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2fa522be | 2522 | /* Set input pins 0x18-0x1c */ |
16ded525 TI |
2523 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
2524 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
05acb863 TI |
2525 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
2526 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2527 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2fa522be | 2528 | /* Mute input pins 0x18-0x1b */ |
05acb863 TI |
2529 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
2530 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2531 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2532 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
71fe7b82 | 2533 | /* ADC set up */ |
05acb863 | 2534 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 2535 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 | 2536 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 2537 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 | 2538 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 2539 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
2540 | /* Analog input/passthru */ |
2541 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
2542 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2543 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
2544 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
2545 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
2fa522be TI |
2546 | { } |
2547 | }; | |
2548 | #endif | |
2549 | ||
1da177e4 LT |
2550 | /* |
2551 | */ | |
2552 | ||
f5fcc13c TI |
2553 | static const char *alc880_models[ALC880_MODEL_LAST] = { |
2554 | [ALC880_3ST] = "3stack", | |
2555 | [ALC880_TCL_S700] = "tcl", | |
2556 | [ALC880_3ST_DIG] = "3stack-digout", | |
2557 | [ALC880_CLEVO] = "clevo", | |
2558 | [ALC880_5ST] = "5stack", | |
2559 | [ALC880_5ST_DIG] = "5stack-digout", | |
2560 | [ALC880_W810] = "w810", | |
2561 | [ALC880_Z71V] = "z71v", | |
2562 | [ALC880_6ST] = "6stack", | |
2563 | [ALC880_6ST_DIG] = "6stack-digout", | |
2564 | [ALC880_ASUS] = "asus", | |
2565 | [ALC880_ASUS_W1V] = "asus-w1v", | |
2566 | [ALC880_ASUS_DIG] = "asus-dig", | |
2567 | [ALC880_ASUS_DIG2] = "asus-dig2", | |
2568 | [ALC880_UNIWILL_DIG] = "uniwill", | |
2cf9f0fc TD |
2569 | [ALC880_UNIWILL_P53] = "uniwill-p53", |
2570 | [ALC880_FUJITSU] = "fujitsu", | |
f5fcc13c TI |
2571 | [ALC880_F1734] = "F1734", |
2572 | [ALC880_LG] = "lg", | |
2573 | [ALC880_LG_LW] = "lg-lw", | |
2fa522be | 2574 | #ifdef CONFIG_SND_DEBUG |
f5fcc13c | 2575 | [ALC880_TEST] = "test", |
2fa522be | 2576 | #endif |
f5fcc13c TI |
2577 | [ALC880_AUTO] = "auto", |
2578 | }; | |
2579 | ||
2580 | static struct snd_pci_quirk alc880_cfg_tbl[] = { | |
2581 | /* Broken BIOS configuration */ | |
2582 | SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), | |
2583 | SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG), | |
2584 | ||
2585 | SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG), | |
2586 | SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST), | |
4dc53e28 | 2587 | SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810), |
f5fcc13c TI |
2588 | SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG), |
2589 | SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG), | |
2590 | SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG), | |
2591 | SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG), | |
2592 | SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG), | |
2593 | SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST), | |
2594 | ||
2595 | SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG), | |
2596 | SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST), | |
2597 | ||
2598 | SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V), | |
2599 | SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG), | |
2600 | SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG), | |
2601 | SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG), | |
2602 | SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG), | |
2603 | SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG), | |
2604 | SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V), | |
2605 | /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */ | |
2606 | SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG), | |
2607 | SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG), | |
0e4ceb75 | 2608 | SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS), |
f5fcc13c TI |
2609 | SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG), |
2610 | SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST), | |
2611 | SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST), | |
2612 | SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), | |
2613 | ||
2614 | SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST), | |
2615 | SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST), | |
2616 | SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST), | |
2617 | SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST), | |
2618 | SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST), | |
2619 | SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO), | |
2620 | SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO), | |
2621 | SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG), | |
2622 | SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810), | |
2623 | SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG), | |
2624 | SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700), | |
2625 | SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG), | |
2626 | SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG), | |
2627 | SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG), | |
2628 | SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG), | |
2629 | SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG), | |
2630 | SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG), | |
2631 | SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2), | |
2632 | ||
2633 | SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG), | |
2634 | SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL), | |
2635 | SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53), | |
2636 | SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734), | |
2637 | ||
2638 | SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG), | |
2639 | SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL), | |
2640 | SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734), | |
2cf9f0fc | 2641 | SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU), |
f5fcc13c TI |
2642 | |
2643 | SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG), | |
2644 | SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG), | |
2645 | SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW), | |
2646 | SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW), | |
2647 | ||
2648 | SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG), | |
2649 | SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG), | |
2650 | SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG), | |
2651 | SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG), | |
2652 | SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG), | |
2653 | SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG), | |
2654 | SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG), | |
2655 | SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG), | |
2656 | SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG), | |
2657 | SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG), | |
2658 | SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), | |
2fa522be | 2659 | |
1da177e4 LT |
2660 | {} |
2661 | }; | |
2662 | ||
16ded525 | 2663 | /* |
df694daa | 2664 | * ALC880 codec presets |
16ded525 | 2665 | */ |
16ded525 TI |
2666 | static struct alc_config_preset alc880_presets[] = { |
2667 | [ALC880_3ST] = { | |
e9edcee0 | 2668 | .mixers = { alc880_three_stack_mixer }, |
f12ab1e0 TI |
2669 | .init_verbs = { alc880_volume_init_verbs, |
2670 | alc880_pin_3stack_init_verbs }, | |
16ded525 | 2671 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
16ded525 | 2672 | .dac_nids = alc880_dac_nids, |
16ded525 TI |
2673 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
2674 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 2675 | .need_dac_fix = 1, |
16ded525 TI |
2676 | .input_mux = &alc880_capture_source, |
2677 | }, | |
2678 | [ALC880_3ST_DIG] = { | |
e9edcee0 | 2679 | .mixers = { alc880_three_stack_mixer }, |
f12ab1e0 TI |
2680 | .init_verbs = { alc880_volume_init_verbs, |
2681 | alc880_pin_3stack_init_verbs }, | |
16ded525 | 2682 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
16ded525 TI |
2683 | .dac_nids = alc880_dac_nids, |
2684 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
2685 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
2686 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 2687 | .need_dac_fix = 1, |
16ded525 TI |
2688 | .input_mux = &alc880_capture_source, |
2689 | }, | |
df694daa KY |
2690 | [ALC880_TCL_S700] = { |
2691 | .mixers = { alc880_tcl_s700_mixer }, | |
2692 | .init_verbs = { alc880_volume_init_verbs, | |
2693 | alc880_pin_tcl_S700_init_verbs, | |
2694 | alc880_gpio2_init_verbs }, | |
2695 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
2696 | .dac_nids = alc880_dac_nids, | |
2697 | .hp_nid = 0x03, | |
2698 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
2699 | .channel_mode = alc880_2_jack_modes, | |
2700 | .input_mux = &alc880_capture_source, | |
2701 | }, | |
16ded525 | 2702 | [ALC880_5ST] = { |
f12ab1e0 TI |
2703 | .mixers = { alc880_three_stack_mixer, |
2704 | alc880_five_stack_mixer}, | |
2705 | .init_verbs = { alc880_volume_init_verbs, | |
2706 | alc880_pin_5stack_init_verbs }, | |
16ded525 TI |
2707 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
2708 | .dac_nids = alc880_dac_nids, | |
16ded525 TI |
2709 | .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), |
2710 | .channel_mode = alc880_fivestack_modes, | |
2711 | .input_mux = &alc880_capture_source, | |
2712 | }, | |
2713 | [ALC880_5ST_DIG] = { | |
f12ab1e0 TI |
2714 | .mixers = { alc880_three_stack_mixer, |
2715 | alc880_five_stack_mixer }, | |
2716 | .init_verbs = { alc880_volume_init_verbs, | |
2717 | alc880_pin_5stack_init_verbs }, | |
16ded525 TI |
2718 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
2719 | .dac_nids = alc880_dac_nids, | |
2720 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
2721 | .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), |
2722 | .channel_mode = alc880_fivestack_modes, | |
2723 | .input_mux = &alc880_capture_source, | |
2724 | }, | |
b6482d48 TI |
2725 | [ALC880_6ST] = { |
2726 | .mixers = { alc880_six_stack_mixer }, | |
f12ab1e0 TI |
2727 | .init_verbs = { alc880_volume_init_verbs, |
2728 | alc880_pin_6stack_init_verbs }, | |
b6482d48 TI |
2729 | .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), |
2730 | .dac_nids = alc880_6st_dac_nids, | |
2731 | .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), | |
2732 | .channel_mode = alc880_sixstack_modes, | |
2733 | .input_mux = &alc880_6stack_capture_source, | |
2734 | }, | |
16ded525 | 2735 | [ALC880_6ST_DIG] = { |
e9edcee0 | 2736 | .mixers = { alc880_six_stack_mixer }, |
f12ab1e0 TI |
2737 | .init_verbs = { alc880_volume_init_verbs, |
2738 | alc880_pin_6stack_init_verbs }, | |
16ded525 TI |
2739 | .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), |
2740 | .dac_nids = alc880_6st_dac_nids, | |
2741 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
2742 | .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), |
2743 | .channel_mode = alc880_sixstack_modes, | |
2744 | .input_mux = &alc880_6stack_capture_source, | |
2745 | }, | |
2746 | [ALC880_W810] = { | |
e9edcee0 | 2747 | .mixers = { alc880_w810_base_mixer }, |
f12ab1e0 TI |
2748 | .init_verbs = { alc880_volume_init_verbs, |
2749 | alc880_pin_w810_init_verbs, | |
b0af0de5 | 2750 | alc880_gpio2_init_verbs }, |
16ded525 TI |
2751 | .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids), |
2752 | .dac_nids = alc880_w810_dac_nids, | |
2753 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
2754 | .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), |
2755 | .channel_mode = alc880_w810_modes, | |
2756 | .input_mux = &alc880_capture_source, | |
2757 | }, | |
2758 | [ALC880_Z71V] = { | |
e9edcee0 | 2759 | .mixers = { alc880_z71v_mixer }, |
f12ab1e0 TI |
2760 | .init_verbs = { alc880_volume_init_verbs, |
2761 | alc880_pin_z71v_init_verbs }, | |
16ded525 TI |
2762 | .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids), |
2763 | .dac_nids = alc880_z71v_dac_nids, | |
2764 | .dig_out_nid = ALC880_DIGOUT_NID, | |
2765 | .hp_nid = 0x03, | |
e9edcee0 TI |
2766 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), |
2767 | .channel_mode = alc880_2_jack_modes, | |
16ded525 TI |
2768 | .input_mux = &alc880_capture_source, |
2769 | }, | |
2770 | [ALC880_F1734] = { | |
e9edcee0 | 2771 | .mixers = { alc880_f1734_mixer }, |
f12ab1e0 TI |
2772 | .init_verbs = { alc880_volume_init_verbs, |
2773 | alc880_pin_f1734_init_verbs }, | |
e9edcee0 TI |
2774 | .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids), |
2775 | .dac_nids = alc880_f1734_dac_nids, | |
2776 | .hp_nid = 0x02, | |
2777 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
2778 | .channel_mode = alc880_2_jack_modes, | |
16ded525 TI |
2779 | .input_mux = &alc880_capture_source, |
2780 | }, | |
2781 | [ALC880_ASUS] = { | |
e9edcee0 | 2782 | .mixers = { alc880_asus_mixer }, |
f12ab1e0 TI |
2783 | .init_verbs = { alc880_volume_init_verbs, |
2784 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
2785 | alc880_gpio1_init_verbs }, |
2786 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
2787 | .dac_nids = alc880_asus_dac_nids, | |
2788 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), | |
2789 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 2790 | .need_dac_fix = 1, |
16ded525 TI |
2791 | .input_mux = &alc880_capture_source, |
2792 | }, | |
2793 | [ALC880_ASUS_DIG] = { | |
e9edcee0 | 2794 | .mixers = { alc880_asus_mixer }, |
f12ab1e0 TI |
2795 | .init_verbs = { alc880_volume_init_verbs, |
2796 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
2797 | alc880_gpio1_init_verbs }, |
2798 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
2799 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 2800 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
2801 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
2802 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 2803 | .need_dac_fix = 1, |
16ded525 TI |
2804 | .input_mux = &alc880_capture_source, |
2805 | }, | |
df694daa KY |
2806 | [ALC880_ASUS_DIG2] = { |
2807 | .mixers = { alc880_asus_mixer }, | |
f12ab1e0 TI |
2808 | .init_verbs = { alc880_volume_init_verbs, |
2809 | alc880_pin_asus_init_verbs, | |
df694daa KY |
2810 | alc880_gpio2_init_verbs }, /* use GPIO2 */ |
2811 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
2812 | .dac_nids = alc880_asus_dac_nids, | |
2813 | .dig_out_nid = ALC880_DIGOUT_NID, | |
2814 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), | |
2815 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 2816 | .need_dac_fix = 1, |
df694daa KY |
2817 | .input_mux = &alc880_capture_source, |
2818 | }, | |
16ded525 | 2819 | [ALC880_ASUS_W1V] = { |
e9edcee0 | 2820 | .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer }, |
f12ab1e0 TI |
2821 | .init_verbs = { alc880_volume_init_verbs, |
2822 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
2823 | alc880_gpio1_init_verbs }, |
2824 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
2825 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 2826 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
2827 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
2828 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 2829 | .need_dac_fix = 1, |
16ded525 TI |
2830 | .input_mux = &alc880_capture_source, |
2831 | }, | |
2832 | [ALC880_UNIWILL_DIG] = { | |
3c10a9d9 | 2833 | .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer }, |
ccc656ce KY |
2834 | .init_verbs = { alc880_volume_init_verbs, |
2835 | alc880_pin_asus_init_verbs }, | |
e9edcee0 TI |
2836 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), |
2837 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 2838 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
2839 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
2840 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 2841 | .need_dac_fix = 1, |
16ded525 TI |
2842 | .input_mux = &alc880_capture_source, |
2843 | }, | |
ccc656ce KY |
2844 | [ALC880_UNIWILL] = { |
2845 | .mixers = { alc880_uniwill_mixer }, | |
2846 | .init_verbs = { alc880_volume_init_verbs, | |
2847 | alc880_uniwill_init_verbs }, | |
2848 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
2849 | .dac_nids = alc880_asus_dac_nids, | |
2850 | .dig_out_nid = ALC880_DIGOUT_NID, | |
2851 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
2852 | .channel_mode = alc880_threestack_modes, | |
2853 | .need_dac_fix = 1, | |
2854 | .input_mux = &alc880_capture_source, | |
2855 | .unsol_event = alc880_uniwill_unsol_event, | |
2856 | .init_hook = alc880_uniwill_automute, | |
2857 | }, | |
2858 | [ALC880_UNIWILL_P53] = { | |
2859 | .mixers = { alc880_uniwill_p53_mixer }, | |
2860 | .init_verbs = { alc880_volume_init_verbs, | |
2861 | alc880_uniwill_p53_init_verbs }, | |
2862 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
2863 | .dac_nids = alc880_asus_dac_nids, | |
2864 | .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), | |
2cf9f0fc TD |
2865 | .channel_mode = alc880_threestack_modes, |
2866 | .input_mux = &alc880_capture_source, | |
2867 | .unsol_event = alc880_uniwill_p53_unsol_event, | |
2868 | .init_hook = alc880_uniwill_p53_hp_automute, | |
2869 | }, | |
2870 | [ALC880_FUJITSU] = { | |
f12ab1e0 | 2871 | .mixers = { alc880_fujitsu_mixer, |
2cf9f0fc TD |
2872 | alc880_pcbeep_mixer, }, |
2873 | .init_verbs = { alc880_volume_init_verbs, | |
2874 | alc880_uniwill_p53_init_verbs, | |
2875 | alc880_beep_init_verbs }, | |
2876 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
2877 | .dac_nids = alc880_dac_nids, | |
d53d7d9e | 2878 | .dig_out_nid = ALC880_DIGOUT_NID, |
2cf9f0fc TD |
2879 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), |
2880 | .channel_mode = alc880_2_jack_modes, | |
ccc656ce KY |
2881 | .input_mux = &alc880_capture_source, |
2882 | .unsol_event = alc880_uniwill_p53_unsol_event, | |
2883 | .init_hook = alc880_uniwill_p53_hp_automute, | |
2884 | }, | |
df694daa KY |
2885 | [ALC880_CLEVO] = { |
2886 | .mixers = { alc880_three_stack_mixer }, | |
2887 | .init_verbs = { alc880_volume_init_verbs, | |
2888 | alc880_pin_clevo_init_verbs }, | |
2889 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
2890 | .dac_nids = alc880_dac_nids, | |
2891 | .hp_nid = 0x03, | |
2892 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
2893 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 2894 | .need_dac_fix = 1, |
df694daa KY |
2895 | .input_mux = &alc880_capture_source, |
2896 | }, | |
ae6b813a TI |
2897 | [ALC880_LG] = { |
2898 | .mixers = { alc880_lg_mixer }, | |
2899 | .init_verbs = { alc880_volume_init_verbs, | |
2900 | alc880_lg_init_verbs }, | |
2901 | .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids), | |
2902 | .dac_nids = alc880_lg_dac_nids, | |
2903 | .dig_out_nid = ALC880_DIGOUT_NID, | |
2904 | .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes), | |
2905 | .channel_mode = alc880_lg_ch_modes, | |
4e195a7b | 2906 | .need_dac_fix = 1, |
ae6b813a TI |
2907 | .input_mux = &alc880_lg_capture_source, |
2908 | .unsol_event = alc880_lg_unsol_event, | |
2909 | .init_hook = alc880_lg_automute, | |
cb53c626 TI |
2910 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
2911 | .loopbacks = alc880_lg_loopbacks, | |
2912 | #endif | |
ae6b813a | 2913 | }, |
d681518a TI |
2914 | [ALC880_LG_LW] = { |
2915 | .mixers = { alc880_lg_lw_mixer }, | |
2916 | .init_verbs = { alc880_volume_init_verbs, | |
2917 | alc880_lg_lw_init_verbs }, | |
0a8c5da3 | 2918 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
d681518a TI |
2919 | .dac_nids = alc880_dac_nids, |
2920 | .dig_out_nid = ALC880_DIGOUT_NID, | |
0a8c5da3 CM |
2921 | .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes), |
2922 | .channel_mode = alc880_lg_lw_modes, | |
d681518a TI |
2923 | .input_mux = &alc880_lg_lw_capture_source, |
2924 | .unsol_event = alc880_lg_lw_unsol_event, | |
2925 | .init_hook = alc880_lg_lw_automute, | |
2926 | }, | |
16ded525 TI |
2927 | #ifdef CONFIG_SND_DEBUG |
2928 | [ALC880_TEST] = { | |
e9edcee0 TI |
2929 | .mixers = { alc880_test_mixer }, |
2930 | .init_verbs = { alc880_test_init_verbs }, | |
16ded525 TI |
2931 | .num_dacs = ARRAY_SIZE(alc880_test_dac_nids), |
2932 | .dac_nids = alc880_test_dac_nids, | |
2933 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
2934 | .num_channel_mode = ARRAY_SIZE(alc880_test_modes), |
2935 | .channel_mode = alc880_test_modes, | |
2936 | .input_mux = &alc880_test_capture_source, | |
2937 | }, | |
2938 | #endif | |
2939 | }; | |
2940 | ||
e9edcee0 TI |
2941 | /* |
2942 | * Automatic parse of I/O pins from the BIOS configuration | |
2943 | */ | |
2944 | ||
2945 | #define NUM_CONTROL_ALLOC 32 | |
2946 | #define NUM_VERB_ALLOC 32 | |
2947 | ||
2948 | enum { | |
2949 | ALC_CTL_WIDGET_VOL, | |
2950 | ALC_CTL_WIDGET_MUTE, | |
2951 | ALC_CTL_BIND_MUTE, | |
2952 | }; | |
c8b6bf9b | 2953 | static struct snd_kcontrol_new alc880_control_templates[] = { |
e9edcee0 TI |
2954 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
2955 | HDA_CODEC_MUTE(NULL, 0, 0, 0), | |
985be54b | 2956 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
e9edcee0 TI |
2957 | }; |
2958 | ||
2959 | /* add dynamic controls */ | |
f12ab1e0 TI |
2960 | static int add_control(struct alc_spec *spec, int type, const char *name, |
2961 | unsigned long val) | |
e9edcee0 | 2962 | { |
c8b6bf9b | 2963 | struct snd_kcontrol_new *knew; |
e9edcee0 TI |
2964 | |
2965 | if (spec->num_kctl_used >= spec->num_kctl_alloc) { | |
2966 | int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; | |
2967 | ||
f12ab1e0 TI |
2968 | /* array + terminator */ |
2969 | knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); | |
2970 | if (!knew) | |
e9edcee0 TI |
2971 | return -ENOMEM; |
2972 | if (spec->kctl_alloc) { | |
f12ab1e0 TI |
2973 | memcpy(knew, spec->kctl_alloc, |
2974 | sizeof(*knew) * spec->num_kctl_alloc); | |
e9edcee0 TI |
2975 | kfree(spec->kctl_alloc); |
2976 | } | |
2977 | spec->kctl_alloc = knew; | |
2978 | spec->num_kctl_alloc = num; | |
2979 | } | |
2980 | ||
2981 | knew = &spec->kctl_alloc[spec->num_kctl_used]; | |
2982 | *knew = alc880_control_templates[type]; | |
543537bd | 2983 | knew->name = kstrdup(name, GFP_KERNEL); |
f12ab1e0 | 2984 | if (!knew->name) |
e9edcee0 TI |
2985 | return -ENOMEM; |
2986 | knew->private_value = val; | |
2987 | spec->num_kctl_used++; | |
2988 | return 0; | |
2989 | } | |
2990 | ||
2991 | #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17) | |
2992 | #define alc880_fixed_pin_idx(nid) ((nid) - 0x14) | |
2993 | #define alc880_is_multi_pin(nid) ((nid) >= 0x18) | |
2994 | #define alc880_multi_pin_idx(nid) ((nid) - 0x18) | |
2995 | #define alc880_is_input_pin(nid) ((nid) >= 0x18) | |
2996 | #define alc880_input_pin_idx(nid) ((nid) - 0x18) | |
2997 | #define alc880_idx_to_dac(nid) ((nid) + 0x02) | |
2998 | #define alc880_dac_to_idx(nid) ((nid) - 0x02) | |
2999 | #define alc880_idx_to_mixer(nid) ((nid) + 0x0c) | |
3000 | #define alc880_idx_to_selector(nid) ((nid) + 0x10) | |
3001 | #define ALC880_PIN_CD_NID 0x1c | |
3002 | ||
3003 | /* fill in the dac_nids table from the parsed pin configuration */ | |
f12ab1e0 TI |
3004 | static int alc880_auto_fill_dac_nids(struct alc_spec *spec, |
3005 | const struct auto_pin_cfg *cfg) | |
e9edcee0 TI |
3006 | { |
3007 | hda_nid_t nid; | |
3008 | int assigned[4]; | |
3009 | int i, j; | |
3010 | ||
3011 | memset(assigned, 0, sizeof(assigned)); | |
b0af0de5 | 3012 | spec->multiout.dac_nids = spec->private_dac_nids; |
e9edcee0 TI |
3013 | |
3014 | /* check the pins hardwired to audio widget */ | |
3015 | for (i = 0; i < cfg->line_outs; i++) { | |
3016 | nid = cfg->line_out_pins[i]; | |
3017 | if (alc880_is_fixed_pin(nid)) { | |
3018 | int idx = alc880_fixed_pin_idx(nid); | |
5014f193 | 3019 | spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx); |
e9edcee0 TI |
3020 | assigned[idx] = 1; |
3021 | } | |
3022 | } | |
3023 | /* left pins can be connect to any audio widget */ | |
3024 | for (i = 0; i < cfg->line_outs; i++) { | |
3025 | nid = cfg->line_out_pins[i]; | |
3026 | if (alc880_is_fixed_pin(nid)) | |
3027 | continue; | |
3028 | /* search for an empty channel */ | |
3029 | for (j = 0; j < cfg->line_outs; j++) { | |
f12ab1e0 TI |
3030 | if (!assigned[j]) { |
3031 | spec->multiout.dac_nids[i] = | |
3032 | alc880_idx_to_dac(j); | |
e9edcee0 TI |
3033 | assigned[j] = 1; |
3034 | break; | |
3035 | } | |
3036 | } | |
3037 | } | |
3038 | spec->multiout.num_dacs = cfg->line_outs; | |
3039 | return 0; | |
3040 | } | |
3041 | ||
3042 | /* add playback controls from the parsed DAC table */ | |
df694daa KY |
3043 | static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, |
3044 | const struct auto_pin_cfg *cfg) | |
e9edcee0 TI |
3045 | { |
3046 | char name[32]; | |
f12ab1e0 TI |
3047 | static const char *chname[4] = { |
3048 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
3049 | }; | |
e9edcee0 TI |
3050 | hda_nid_t nid; |
3051 | int i, err; | |
3052 | ||
3053 | for (i = 0; i < cfg->line_outs; i++) { | |
f12ab1e0 | 3054 | if (!spec->multiout.dac_nids[i]) |
e9edcee0 TI |
3055 | continue; |
3056 | nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i])); | |
3057 | if (i == 2) { | |
3058 | /* Center/LFE */ | |
f12ab1e0 TI |
3059 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
3060 | "Center Playback Volume", | |
3061 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, | |
3062 | HDA_OUTPUT)); | |
3063 | if (err < 0) | |
e9edcee0 | 3064 | return err; |
f12ab1e0 TI |
3065 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
3066 | "LFE Playback Volume", | |
3067 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
3068 | HDA_OUTPUT)); | |
3069 | if (err < 0) | |
e9edcee0 | 3070 | return err; |
f12ab1e0 TI |
3071 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
3072 | "Center Playback Switch", | |
3073 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, | |
3074 | HDA_INPUT)); | |
3075 | if (err < 0) | |
e9edcee0 | 3076 | return err; |
f12ab1e0 TI |
3077 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
3078 | "LFE Playback Switch", | |
3079 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, | |
3080 | HDA_INPUT)); | |
3081 | if (err < 0) | |
e9edcee0 TI |
3082 | return err; |
3083 | } else { | |
3084 | sprintf(name, "%s Playback Volume", chname[i]); | |
f12ab1e0 TI |
3085 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
3086 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
3087 | HDA_OUTPUT)); | |
3088 | if (err < 0) | |
e9edcee0 TI |
3089 | return err; |
3090 | sprintf(name, "%s Playback Switch", chname[i]); | |
f12ab1e0 TI |
3091 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
3092 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, | |
3093 | HDA_INPUT)); | |
3094 | if (err < 0) | |
e9edcee0 TI |
3095 | return err; |
3096 | } | |
3097 | } | |
e9edcee0 TI |
3098 | return 0; |
3099 | } | |
3100 | ||
8d88bc3d TI |
3101 | /* add playback controls for speaker and HP outputs */ |
3102 | static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, | |
3103 | const char *pfx) | |
e9edcee0 TI |
3104 | { |
3105 | hda_nid_t nid; | |
3106 | int err; | |
8d88bc3d | 3107 | char name[32]; |
e9edcee0 | 3108 | |
f12ab1e0 | 3109 | if (!pin) |
e9edcee0 TI |
3110 | return 0; |
3111 | ||
3112 | if (alc880_is_fixed_pin(pin)) { | |
3113 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
82bc955f | 3114 | /* specify the DAC as the extra output */ |
f12ab1e0 | 3115 | if (!spec->multiout.hp_nid) |
e9edcee0 | 3116 | spec->multiout.hp_nid = nid; |
82bc955f TI |
3117 | else |
3118 | spec->multiout.extra_out_nid[0] = nid; | |
e9edcee0 TI |
3119 | /* control HP volume/switch on the output mixer amp */ |
3120 | nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin)); | |
8d88bc3d | 3121 | sprintf(name, "%s Playback Volume", pfx); |
f12ab1e0 TI |
3122 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
3123 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
3124 | if (err < 0) | |
e9edcee0 | 3125 | return err; |
8d88bc3d | 3126 | sprintf(name, "%s Playback Switch", pfx); |
f12ab1e0 TI |
3127 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
3128 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); | |
3129 | if (err < 0) | |
e9edcee0 TI |
3130 | return err; |
3131 | } else if (alc880_is_multi_pin(pin)) { | |
3132 | /* set manual connection */ | |
e9edcee0 | 3133 | /* we have only a switch on HP-out PIN */ |
8d88bc3d | 3134 | sprintf(name, "%s Playback Switch", pfx); |
f12ab1e0 TI |
3135 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
3136 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
3137 | if (err < 0) | |
e9edcee0 TI |
3138 | return err; |
3139 | } | |
3140 | return 0; | |
3141 | } | |
3142 | ||
3143 | /* create input playback/capture controls for the given pin */ | |
f12ab1e0 TI |
3144 | static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, |
3145 | const char *ctlname, | |
df694daa | 3146 | int idx, hda_nid_t mix_nid) |
e9edcee0 TI |
3147 | { |
3148 | char name[32]; | |
df694daa | 3149 | int err; |
e9edcee0 TI |
3150 | |
3151 | sprintf(name, "%s Playback Volume", ctlname); | |
f12ab1e0 TI |
3152 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
3153 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); | |
3154 | if (err < 0) | |
e9edcee0 TI |
3155 | return err; |
3156 | sprintf(name, "%s Playback Switch", ctlname); | |
f12ab1e0 TI |
3157 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
3158 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); | |
3159 | if (err < 0) | |
e9edcee0 TI |
3160 | return err; |
3161 | return 0; | |
3162 | } | |
3163 | ||
3164 | /* create playback/capture controls for input pins */ | |
df694daa KY |
3165 | static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, |
3166 | const struct auto_pin_cfg *cfg) | |
e9edcee0 | 3167 | { |
e9edcee0 | 3168 | struct hda_input_mux *imux = &spec->private_imux; |
df694daa | 3169 | int i, err, idx; |
e9edcee0 TI |
3170 | |
3171 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
3172 | if (alc880_is_input_pin(cfg->input_pins[i])) { | |
df694daa | 3173 | idx = alc880_input_pin_idx(cfg->input_pins[i]); |
4a471b7d TI |
3174 | err = new_analog_input(spec, cfg->input_pins[i], |
3175 | auto_pin_cfg_labels[i], | |
df694daa | 3176 | idx, 0x0b); |
e9edcee0 TI |
3177 | if (err < 0) |
3178 | return err; | |
f12ab1e0 TI |
3179 | imux->items[imux->num_items].label = |
3180 | auto_pin_cfg_labels[i]; | |
3181 | imux->items[imux->num_items].index = | |
3182 | alc880_input_pin_idx(cfg->input_pins[i]); | |
e9edcee0 TI |
3183 | imux->num_items++; |
3184 | } | |
3185 | } | |
3186 | return 0; | |
3187 | } | |
3188 | ||
df694daa KY |
3189 | static void alc880_auto_set_output_and_unmute(struct hda_codec *codec, |
3190 | hda_nid_t nid, int pin_type, | |
e9edcee0 TI |
3191 | int dac_idx) |
3192 | { | |
3193 | /* set as output */ | |
f12ab1e0 TI |
3194 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
3195 | pin_type); | |
3196 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
3197 | AMP_OUT_UNMUTE); | |
e9edcee0 TI |
3198 | /* need the manual connection? */ |
3199 | if (alc880_is_multi_pin(nid)) { | |
3200 | struct alc_spec *spec = codec->spec; | |
3201 | int idx = alc880_multi_pin_idx(nid); | |
3202 | snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, | |
3203 | AC_VERB_SET_CONNECT_SEL, | |
3204 | alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); | |
3205 | } | |
3206 | } | |
3207 | ||
baba8ee9 TI |
3208 | static int get_pin_type(int line_out_type) |
3209 | { | |
3210 | if (line_out_type == AUTO_PIN_HP_OUT) | |
3211 | return PIN_HP; | |
3212 | else | |
3213 | return PIN_OUT; | |
3214 | } | |
3215 | ||
e9edcee0 TI |
3216 | static void alc880_auto_init_multi_out(struct hda_codec *codec) |
3217 | { | |
3218 | struct alc_spec *spec = codec->spec; | |
3219 | int i; | |
bc9f98a9 KY |
3220 | |
3221 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); | |
e9edcee0 TI |
3222 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
3223 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 TI |
3224 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
3225 | alc880_auto_set_output_and_unmute(codec, nid, pin_type, i); | |
e9edcee0 TI |
3226 | } |
3227 | } | |
3228 | ||
8d88bc3d | 3229 | static void alc880_auto_init_extra_out(struct hda_codec *codec) |
e9edcee0 TI |
3230 | { |
3231 | struct alc_spec *spec = codec->spec; | |
3232 | hda_nid_t pin; | |
3233 | ||
82bc955f | 3234 | pin = spec->autocfg.speaker_pins[0]; |
8d88bc3d TI |
3235 | if (pin) /* connect to front */ |
3236 | alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
eb06ed8f | 3237 | pin = spec->autocfg.hp_pins[0]; |
e9edcee0 TI |
3238 | if (pin) /* connect to front */ |
3239 | alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
3240 | } | |
3241 | ||
3242 | static void alc880_auto_init_analog_input(struct hda_codec *codec) | |
3243 | { | |
3244 | struct alc_spec *spec = codec->spec; | |
3245 | int i; | |
3246 | ||
3247 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
3248 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
3249 | if (alc880_is_input_pin(nid)) { | |
f12ab1e0 TI |
3250 | snd_hda_codec_write(codec, nid, 0, |
3251 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
3252 | i <= AUTO_PIN_FRONT_MIC ? | |
3253 | PIN_VREF80 : PIN_IN); | |
e9edcee0 | 3254 | if (nid != ALC880_PIN_CD_NID) |
f12ab1e0 TI |
3255 | snd_hda_codec_write(codec, nid, 0, |
3256 | AC_VERB_SET_AMP_GAIN_MUTE, | |
e9edcee0 TI |
3257 | AMP_OUT_MUTE); |
3258 | } | |
3259 | } | |
3260 | } | |
3261 | ||
3262 | /* parse the BIOS configuration and set up the alc_spec */ | |
f12ab1e0 TI |
3263 | /* return 1 if successful, 0 if the proper config is not found, |
3264 | * or a negative error code | |
3265 | */ | |
e9edcee0 TI |
3266 | static int alc880_parse_auto_config(struct hda_codec *codec) |
3267 | { | |
3268 | struct alc_spec *spec = codec->spec; | |
3269 | int err; | |
df694daa | 3270 | static hda_nid_t alc880_ignore[] = { 0x1d, 0 }; |
e9edcee0 | 3271 | |
f12ab1e0 TI |
3272 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
3273 | alc880_ignore); | |
3274 | if (err < 0) | |
e9edcee0 | 3275 | return err; |
f12ab1e0 | 3276 | if (!spec->autocfg.line_outs) |
e9edcee0 | 3277 | return 0; /* can't find valid BIOS pin config */ |
df694daa | 3278 | |
f12ab1e0 TI |
3279 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
3280 | if (err < 0) | |
3281 | return err; | |
3282 | err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
3283 | if (err < 0) | |
3284 | return err; | |
3285 | err = alc880_auto_create_extra_out(spec, | |
3286 | spec->autocfg.speaker_pins[0], | |
3287 | "Speaker"); | |
3288 | if (err < 0) | |
3289 | return err; | |
3290 | err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], | |
3291 | "Headphone"); | |
3292 | if (err < 0) | |
3293 | return err; | |
3294 | err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
3295 | if (err < 0) | |
e9edcee0 TI |
3296 | return err; |
3297 | ||
3298 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
3299 | ||
3300 | if (spec->autocfg.dig_out_pin) | |
3301 | spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; | |
3302 | if (spec->autocfg.dig_in_pin) | |
3303 | spec->dig_in_nid = ALC880_DIGIN_NID; | |
3304 | ||
3305 | if (spec->kctl_alloc) | |
3306 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
3307 | ||
3308 | spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs; | |
3309 | ||
a1e8d2da | 3310 | spec->num_mux_defs = 1; |
e9edcee0 TI |
3311 | spec->input_mux = &spec->private_imux; |
3312 | ||
3313 | return 1; | |
3314 | } | |
3315 | ||
ae6b813a TI |
3316 | /* additional initialization for auto-configuration model */ |
3317 | static void alc880_auto_init(struct hda_codec *codec) | |
e9edcee0 | 3318 | { |
e9edcee0 | 3319 | alc880_auto_init_multi_out(codec); |
8d88bc3d | 3320 | alc880_auto_init_extra_out(codec); |
e9edcee0 | 3321 | alc880_auto_init_analog_input(codec); |
e9edcee0 TI |
3322 | } |
3323 | ||
3324 | /* | |
3325 | * OK, here we have finally the patch for ALC880 | |
3326 | */ | |
3327 | ||
1da177e4 LT |
3328 | static int patch_alc880(struct hda_codec *codec) |
3329 | { | |
3330 | struct alc_spec *spec; | |
3331 | int board_config; | |
df694daa | 3332 | int err; |
1da177e4 | 3333 | |
e560d8d8 | 3334 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
1da177e4 LT |
3335 | if (spec == NULL) |
3336 | return -ENOMEM; | |
3337 | ||
3338 | codec->spec = spec; | |
3339 | ||
f5fcc13c TI |
3340 | board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST, |
3341 | alc880_models, | |
3342 | alc880_cfg_tbl); | |
3343 | if (board_config < 0) { | |
9c7f852e TI |
3344 | printk(KERN_INFO "hda_codec: Unknown model for ALC880, " |
3345 | "trying auto-probe from BIOS...\n"); | |
e9edcee0 | 3346 | board_config = ALC880_AUTO; |
1da177e4 | 3347 | } |
1da177e4 | 3348 | |
e9edcee0 TI |
3349 | if (board_config == ALC880_AUTO) { |
3350 | /* automatic parse from the BIOS config */ | |
3351 | err = alc880_parse_auto_config(codec); | |
3352 | if (err < 0) { | |
3353 | alc_free(codec); | |
3354 | return err; | |
f12ab1e0 | 3355 | } else if (!err) { |
9c7f852e TI |
3356 | printk(KERN_INFO |
3357 | "hda_codec: Cannot set up configuration " | |
3358 | "from BIOS. Using 3-stack mode...\n"); | |
e9edcee0 TI |
3359 | board_config = ALC880_3ST; |
3360 | } | |
1da177e4 LT |
3361 | } |
3362 | ||
df694daa KY |
3363 | if (board_config != ALC880_AUTO) |
3364 | setup_preset(spec, &alc880_presets[board_config]); | |
1da177e4 LT |
3365 | |
3366 | spec->stream_name_analog = "ALC880 Analog"; | |
3367 | spec->stream_analog_playback = &alc880_pcm_analog_playback; | |
3368 | spec->stream_analog_capture = &alc880_pcm_analog_capture; | |
3369 | ||
3370 | spec->stream_name_digital = "ALC880 Digital"; | |
3371 | spec->stream_digital_playback = &alc880_pcm_digital_playback; | |
3372 | spec->stream_digital_capture = &alc880_pcm_digital_capture; | |
3373 | ||
f12ab1e0 | 3374 | if (!spec->adc_nids && spec->input_mux) { |
e9edcee0 | 3375 | /* check whether NID 0x07 is valid */ |
54d17403 | 3376 | unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); |
f12ab1e0 TI |
3377 | /* get type */ |
3378 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
e9edcee0 TI |
3379 | if (wcap != AC_WID_AUD_IN) { |
3380 | spec->adc_nids = alc880_adc_nids_alt; | |
3381 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); | |
f12ab1e0 TI |
3382 | spec->mixers[spec->num_mixers] = |
3383 | alc880_capture_alt_mixer; | |
e9edcee0 TI |
3384 | spec->num_mixers++; |
3385 | } else { | |
3386 | spec->adc_nids = alc880_adc_nids; | |
3387 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids); | |
3388 | spec->mixers[spec->num_mixers] = alc880_capture_mixer; | |
3389 | spec->num_mixers++; | |
3390 | } | |
3391 | } | |
1da177e4 LT |
3392 | |
3393 | codec->patch_ops = alc_patch_ops; | |
e9edcee0 | 3394 | if (board_config == ALC880_AUTO) |
ae6b813a | 3395 | spec->init_hook = alc880_auto_init; |
cb53c626 TI |
3396 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
3397 | if (!spec->loopback.amplist) | |
3398 | spec->loopback.amplist = alc880_loopbacks; | |
3399 | #endif | |
1da177e4 LT |
3400 | |
3401 | return 0; | |
3402 | } | |
3403 | ||
e9edcee0 | 3404 | |
1da177e4 LT |
3405 | /* |
3406 | * ALC260 support | |
3407 | */ | |
3408 | ||
e9edcee0 TI |
3409 | static hda_nid_t alc260_dac_nids[1] = { |
3410 | /* front */ | |
3411 | 0x02, | |
3412 | }; | |
3413 | ||
3414 | static hda_nid_t alc260_adc_nids[1] = { | |
3415 | /* ADC0 */ | |
3416 | 0x04, | |
3417 | }; | |
3418 | ||
df694daa | 3419 | static hda_nid_t alc260_adc_nids_alt[1] = { |
e9edcee0 TI |
3420 | /* ADC1 */ |
3421 | 0x05, | |
3422 | }; | |
3423 | ||
df694daa KY |
3424 | static hda_nid_t alc260_hp_adc_nids[2] = { |
3425 | /* ADC1, 0 */ | |
3426 | 0x05, 0x04 | |
3427 | }; | |
3428 | ||
d57fdac0 JW |
3429 | /* NIDs used when simultaneous access to both ADCs makes sense. Note that |
3430 | * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC. | |
3431 | */ | |
3432 | static hda_nid_t alc260_dual_adc_nids[2] = { | |
4c5186ed JW |
3433 | /* ADC0, ADC1 */ |
3434 | 0x04, 0x05 | |
3435 | }; | |
3436 | ||
e9edcee0 TI |
3437 | #define ALC260_DIGOUT_NID 0x03 |
3438 | #define ALC260_DIGIN_NID 0x06 | |
3439 | ||
3440 | static struct hda_input_mux alc260_capture_source = { | |
3441 | .num_items = 4, | |
3442 | .items = { | |
3443 | { "Mic", 0x0 }, | |
3444 | { "Front Mic", 0x1 }, | |
3445 | { "Line", 0x2 }, | |
3446 | { "CD", 0x4 }, | |
3447 | }, | |
3448 | }; | |
3449 | ||
17e7aec6 | 3450 | /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack, |
a1e8d2da JW |
3451 | * headphone jack and the internal CD lines since these are the only pins at |
3452 | * which audio can appear. For flexibility, also allow the option of | |
3453 | * recording the mixer output on the second ADC (ADC0 doesn't have a | |
3454 | * connection to the mixer output). | |
a9430dd8 | 3455 | */ |
a1e8d2da JW |
3456 | static struct hda_input_mux alc260_fujitsu_capture_sources[2] = { |
3457 | { | |
3458 | .num_items = 3, | |
3459 | .items = { | |
3460 | { "Mic/Line", 0x0 }, | |
3461 | { "CD", 0x4 }, | |
3462 | { "Headphone", 0x2 }, | |
3463 | }, | |
a9430dd8 | 3464 | }, |
a1e8d2da JW |
3465 | { |
3466 | .num_items = 4, | |
3467 | .items = { | |
3468 | { "Mic/Line", 0x0 }, | |
3469 | { "CD", 0x4 }, | |
3470 | { "Headphone", 0x2 }, | |
3471 | { "Mixer", 0x5 }, | |
3472 | }, | |
3473 | }, | |
3474 | ||
a9430dd8 JW |
3475 | }; |
3476 | ||
a1e8d2da JW |
3477 | /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to |
3478 | * the Fujitsu S702x, but jacks are marked differently. | |
0bfc90e9 | 3479 | */ |
a1e8d2da JW |
3480 | static struct hda_input_mux alc260_acer_capture_sources[2] = { |
3481 | { | |
3482 | .num_items = 4, | |
3483 | .items = { | |
3484 | { "Mic", 0x0 }, | |
3485 | { "Line", 0x2 }, | |
3486 | { "CD", 0x4 }, | |
3487 | { "Headphone", 0x5 }, | |
3488 | }, | |
3489 | }, | |
3490 | { | |
3491 | .num_items = 5, | |
3492 | .items = { | |
3493 | { "Mic", 0x0 }, | |
3494 | { "Line", 0x2 }, | |
3495 | { "CD", 0x4 }, | |
3496 | { "Headphone", 0x6 }, | |
3497 | { "Mixer", 0x5 }, | |
3498 | }, | |
0bfc90e9 JW |
3499 | }, |
3500 | }; | |
1da177e4 LT |
3501 | /* |
3502 | * This is just place-holder, so there's something for alc_build_pcms to look | |
3503 | * at when it calculates the maximum number of channels. ALC260 has no mixer | |
3504 | * element which allows changing the channel mode, so the verb list is | |
3505 | * never used. | |
3506 | */ | |
d2a6d7dc | 3507 | static struct hda_channel_mode alc260_modes[1] = { |
1da177e4 LT |
3508 | { 2, NULL }, |
3509 | }; | |
3510 | ||
df694daa KY |
3511 | |
3512 | /* Mixer combinations | |
3513 | * | |
3514 | * basic: base_output + input + pc_beep + capture | |
3515 | * HP: base_output + input + capture_alt | |
3516 | * HP_3013: hp_3013 + input + capture | |
3517 | * fujitsu: fujitsu + capture | |
0bfc90e9 | 3518 | * acer: acer + capture |
df694daa KY |
3519 | */ |
3520 | ||
3521 | static struct snd_kcontrol_new alc260_base_output_mixer[] = { | |
05acb863 | 3522 | HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
985be54b | 3523 | HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), |
05acb863 | 3524 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
985be54b | 3525 | HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), |
05acb863 | 3526 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
985be54b | 3527 | HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), |
1da177e4 | 3528 | { } /* end */ |
f12ab1e0 | 3529 | }; |
1da177e4 | 3530 | |
df694daa | 3531 | static struct snd_kcontrol_new alc260_input_mixer[] = { |
16ded525 TI |
3532 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
3533 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
3534 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
3535 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
3536 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
3537 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
3538 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT), | |
3539 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT), | |
df694daa KY |
3540 | { } /* end */ |
3541 | }; | |
3542 | ||
3543 | static struct snd_kcontrol_new alc260_pc_beep_mixer[] = { | |
3544 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT), | |
3545 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT), | |
3546 | { } /* end */ | |
3547 | }; | |
3548 | ||
3549 | static struct snd_kcontrol_new alc260_hp_3013_mixer[] = { | |
3550 | HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT), | |
3551 | HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT), | |
3552 | HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT), | |
3553 | HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT), | |
3554 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
3555 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
3556 | HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), | |
3557 | HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT), | |
16ded525 TI |
3558 | { } /* end */ |
3559 | }; | |
3560 | ||
a1e8d2da JW |
3561 | /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12, |
3562 | * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10. | |
3563 | */ | |
c8b6bf9b | 3564 | static struct snd_kcontrol_new alc260_fujitsu_mixer[] = { |
a9430dd8 | 3565 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
985be54b | 3566 | HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT), |
4c5186ed | 3567 | ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT), |
a9430dd8 JW |
3568 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
3569 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
3570 | HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT), | |
3571 | HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4c5186ed | 3572 | ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN), |
a9430dd8 JW |
3573 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), |
3574 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
3575 | HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT), | |
985be54b | 3576 | HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT), |
df694daa KY |
3577 | { } /* end */ |
3578 | }; | |
3579 | ||
a1e8d2da JW |
3580 | /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current |
3581 | * versions of the ALC260 don't act on requests to enable mic bias from NID | |
3582 | * 0x0f (used to drive the headphone jack in these laptops). The ALC260 | |
3583 | * datasheet doesn't mention this restriction. At this stage it's not clear | |
3584 | * whether this behaviour is intentional or is a hardware bug in chip | |
3585 | * revisions available in early 2006. Therefore for now allow the | |
3586 | * "Headphone Jack Mode" control to span all choices, but if it turns out | |
3587 | * that the lack of mic bias for this NID is intentional we could change the | |
3588 | * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
3589 | * | |
3590 | * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006 | |
3591 | * don't appear to make the mic bias available from the "line" jack, even | |
3592 | * though the NID used for this jack (0x14) can supply it. The theory is | |
3593 | * that perhaps Acer have included blocking capacitors between the ALC260 | |
3594 | * and the output jack. If this turns out to be the case for all such | |
3595 | * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT | |
3596 | * to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
bd869485 JW |
3597 | * |
3598 | * The C20x Tablet series have a mono internal speaker which is controlled | |
3599 | * via the chip's Mono sum widget and pin complex, so include the necessary | |
3600 | * controls for such models. On models without a "mono speaker" the control | |
3601 | * won't do anything. | |
a1e8d2da | 3602 | */ |
0bfc90e9 JW |
3603 | static struct snd_kcontrol_new alc260_acer_mixer[] = { |
3604 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
3605 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT), | |
a1e8d2da | 3606 | ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT), |
bd869485 JW |
3607 | HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0, |
3608 | HDA_OUTPUT), | |
3609 | HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2, | |
3610 | HDA_INPUT), | |
0bfc90e9 JW |
3611 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
3612 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
3613 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
3614 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
3615 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
3616 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
3617 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
3618 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
3619 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), | |
3620 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
3621 | { } /* end */ | |
3622 | }; | |
3623 | ||
bc9f98a9 KY |
3624 | /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12, |
3625 | * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17. | |
3626 | */ | |
3627 | static struct snd_kcontrol_new alc260_will_mixer[] = { | |
3628 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
3629 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT), | |
3630 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
3631 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
3632 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
3633 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
3634 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
3635 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
3636 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), | |
3637 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
3638 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), | |
3639 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
3640 | { } /* end */ | |
3641 | }; | |
3642 | ||
3643 | /* Replacer 672V ALC260 pin usage: Mic jack = 0x12, | |
3644 | * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f. | |
3645 | */ | |
3646 | static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = { | |
3647 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
3648 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT), | |
3649 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
3650 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
3651 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
3652 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT), | |
3653 | HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT), | |
3654 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
3655 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
3656 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
3657 | { } /* end */ | |
3658 | }; | |
3659 | ||
df694daa KY |
3660 | /* capture mixer elements */ |
3661 | static struct snd_kcontrol_new alc260_capture_mixer[] = { | |
a9430dd8 JW |
3662 | HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT), |
3663 | HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT), | |
df694daa KY |
3664 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT), |
3665 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT), | |
a9430dd8 JW |
3666 | { |
3667 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
df694daa KY |
3668 | /* The multiple "Capture Source" controls confuse alsamixer |
3669 | * So call somewhat different.. | |
3670 | * FIXME: the controls appear in the "playback" view! | |
3671 | */ | |
3672 | /* .name = "Capture Source", */ | |
3673 | .name = "Input Source", | |
3674 | .count = 2, | |
3675 | .info = alc_mux_enum_info, | |
3676 | .get = alc_mux_enum_get, | |
3677 | .put = alc_mux_enum_put, | |
3678 | }, | |
3679 | { } /* end */ | |
3680 | }; | |
3681 | ||
3682 | static struct snd_kcontrol_new alc260_capture_alt_mixer[] = { | |
3683 | HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT), | |
3684 | HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT), | |
3685 | { | |
3686 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
3687 | /* The multiple "Capture Source" controls confuse alsamixer | |
3688 | * So call somewhat different.. | |
3689 | * FIXME: the controls appear in the "playback" view! | |
3690 | */ | |
3691 | /* .name = "Capture Source", */ | |
3692 | .name = "Input Source", | |
3693 | .count = 1, | |
a9430dd8 JW |
3694 | .info = alc_mux_enum_info, |
3695 | .get = alc_mux_enum_get, | |
3696 | .put = alc_mux_enum_put, | |
3697 | }, | |
3698 | { } /* end */ | |
3699 | }; | |
3700 | ||
df694daa KY |
3701 | /* |
3702 | * initialization verbs | |
3703 | */ | |
1da177e4 LT |
3704 | static struct hda_verb alc260_init_verbs[] = { |
3705 | /* Line In pin widget for input */ | |
05acb863 | 3706 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 3707 | /* CD pin widget for input */ |
05acb863 | 3708 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 3709 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
16ded525 | 3710 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1da177e4 | 3711 | /* Mic2 (front panel) pin widget for input and vref at 80% */ |
16ded525 | 3712 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1da177e4 | 3713 | /* LINE-2 is used for line-out in rear */ |
05acb863 | 3714 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1da177e4 | 3715 | /* select line-out */ |
fd56f2db | 3716 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00}, |
1da177e4 | 3717 | /* LINE-OUT pin */ |
05acb863 | 3718 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1da177e4 | 3719 | /* enable HP */ |
05acb863 | 3720 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
1da177e4 | 3721 | /* enable Mono */ |
05acb863 TI |
3722 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
3723 | /* mute capture amp left and right */ | |
16ded525 | 3724 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1da177e4 LT |
3725 | /* set connection select to line in (default select for this ADC) */ |
3726 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
16ded525 TI |
3727 | /* mute capture amp left and right */ |
3728 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
3729 | /* set connection select to line in (default select for this ADC) */ | |
3730 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
05acb863 TI |
3731 | /* set vol=0 Line-Out mixer amp left and right */ |
3732 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3733 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
3734 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3735 | /* set vol=0 HP mixer amp left and right */ | |
3736 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3737 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
3738 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3739 | /* set vol=0 Mono mixer amp left and right */ | |
3740 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3741 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
3742 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3743 | /* unmute LINE-2 out pin */ | |
3744 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
f12ab1e0 TI |
3745 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
3746 | * Line In 2 = 0x03 | |
3747 | */ | |
cb53c626 TI |
3748 | /* mute analog inputs */ |
3749 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3750 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3751 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
3752 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
3753 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 3754 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
05acb863 TI |
3755 | /* mute Front out path */ |
3756 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3757 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3758 | /* mute Headphone out path */ | |
3759 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3760 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3761 | /* mute Mono out path */ | |
3762 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3763 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 LT |
3764 | { } |
3765 | }; | |
3766 | ||
474167d6 | 3767 | #if 0 /* should be identical with alc260_init_verbs? */ |
df694daa KY |
3768 | static struct hda_verb alc260_hp_init_verbs[] = { |
3769 | /* Headphone and output */ | |
3770 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
3771 | /* mono output */ | |
3772 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
3773 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
3774 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
3775 | /* Mic2 (front panel) pin widget for input and vref at 80% */ | |
3776 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
3777 | /* Line In pin widget for input */ | |
3778 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
3779 | /* Line-2 pin widget for output */ | |
3780 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
3781 | /* CD pin widget for input */ | |
3782 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
3783 | /* unmute amp left and right */ | |
3784 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | |
3785 | /* set connection select to line in (default select for this ADC) */ | |
3786 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
3787 | /* unmute Line-Out mixer amp left and right (volume = 0) */ | |
3788 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
3789 | /* mute pin widget amp left and right (no gain on this amp) */ | |
3790 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
3791 | /* unmute HP mixer amp left and right (volume = 0) */ | |
3792 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
3793 | /* mute pin widget amp left and right (no gain on this amp) */ | |
3794 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
f12ab1e0 TI |
3795 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
3796 | * Line In 2 = 0x03 | |
3797 | */ | |
cb53c626 TI |
3798 | /* mute analog inputs */ |
3799 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3800 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3801 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
3802 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
3803 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
3804 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
3805 | /* Unmute Front out path */ | |
3806 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3807 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
3808 | /* Unmute Headphone out path */ | |
3809 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3810 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
3811 | /* Unmute Mono out path */ | |
3812 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3813 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
3814 | { } | |
3815 | }; | |
474167d6 | 3816 | #endif |
df694daa KY |
3817 | |
3818 | static struct hda_verb alc260_hp_3013_init_verbs[] = { | |
3819 | /* Line out and output */ | |
3820 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
3821 | /* mono output */ | |
3822 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
3823 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
3824 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
3825 | /* Mic2 (front panel) pin widget for input and vref at 80% */ | |
3826 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
3827 | /* Line In pin widget for input */ | |
3828 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
3829 | /* Headphone pin widget for output */ | |
3830 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
3831 | /* CD pin widget for input */ | |
3832 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
3833 | /* unmute amp left and right */ | |
3834 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | |
3835 | /* set connection select to line in (default select for this ADC) */ | |
3836 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
3837 | /* unmute Line-Out mixer amp left and right (volume = 0) */ | |
3838 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
3839 | /* mute pin widget amp left and right (no gain on this amp) */ | |
3840 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
3841 | /* unmute HP mixer amp left and right (volume = 0) */ | |
3842 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
3843 | /* mute pin widget amp left and right (no gain on this amp) */ | |
3844 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
f12ab1e0 TI |
3845 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
3846 | * Line In 2 = 0x03 | |
3847 | */ | |
cb53c626 TI |
3848 | /* mute analog inputs */ |
3849 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3850 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3851 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
3852 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
3853 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
3854 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
3855 | /* Unmute Front out path */ | |
3856 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3857 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
3858 | /* Unmute Headphone out path */ | |
3859 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3860 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
3861 | /* Unmute Mono out path */ | |
3862 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3863 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
3864 | { } | |
3865 | }; | |
3866 | ||
a9430dd8 | 3867 | /* Initialisation sequence for ALC260 as configured in Fujitsu S702x |
a1e8d2da JW |
3868 | * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD |
3869 | * audio = 0x16, internal speaker = 0x10. | |
a9430dd8 JW |
3870 | */ |
3871 | static struct hda_verb alc260_fujitsu_init_verbs[] = { | |
3872 | /* Disable all GPIOs */ | |
3873 | {0x01, AC_VERB_SET_GPIO_MASK, 0}, | |
3874 | /* Internal speaker is connected to headphone pin */ | |
3875 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
3876 | /* Headphone/Line-out jack connects to Line1 pin; make it an output */ | |
3877 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
f7ace40d JW |
3878 | /* Mic/Line-in jack is connected to mic1 pin, so make it an input */ |
3879 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
3880 | /* Ensure all other unused pins are disabled and muted. */ | |
3881 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
3882 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
a9430dd8 | 3883 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
f7ace40d | 3884 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
a9430dd8 | 3885 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
f7ace40d JW |
3886 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
3887 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
3888 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3889 | ||
3890 | /* Disable digital (SPDIF) pins */ | |
3891 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
3892 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
a9430dd8 | 3893 | |
f7ace40d JW |
3894 | /* Ensure Line1 pin widget takes its input from the OUT1 sum bus |
3895 | * when acting as an output. | |
3896 | */ | |
3897 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
4c5186ed | 3898 | |
f7ace40d | 3899 | /* Start with output sum widgets muted and their output gains at min */ |
8b33a5aa TI |
3900 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
3901 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3902 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3903 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3904 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3905 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3906 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3907 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3908 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
a9430dd8 | 3909 | |
f7ace40d JW |
3910 | /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */ |
3911 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3912 | /* Unmute Line1 pin widget output buffer since it starts as an output. | |
3913 | * If the pin mode is changed by the user the pin mode control will | |
3914 | * take care of enabling the pin's input/output buffers as needed. | |
3915 | * Therefore there's no need to enable the input buffer at this | |
3916 | * stage. | |
cdcd9268 | 3917 | */ |
f7ace40d | 3918 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
cdcd9268 JW |
3919 | /* Unmute input buffer of pin widget used for Line-in (no equiv |
3920 | * mixer ctrl) | |
3921 | */ | |
f7ace40d JW |
3922 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
3923 | ||
3924 | /* Mute capture amp left and right */ | |
3925 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3926 | /* Set ADC connection select to match default mixer setting - line | |
3927 | * in (on mic1 pin) | |
3928 | */ | |
3929 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
3930 | ||
3931 | /* Do the same for the second ADC: mute capture input amp and | |
3932 | * set ADC connection to line in (on mic1 pin) | |
3933 | */ | |
3934 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3935 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
3936 | ||
3937 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
3938 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
3939 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
3940 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
3941 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
3942 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
3943 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
3944 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
3945 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
4a471b7d TI |
3946 | |
3947 | { } | |
a9430dd8 JW |
3948 | }; |
3949 | ||
0bfc90e9 JW |
3950 | /* Initialisation sequence for ALC260 as configured in Acer TravelMate and |
3951 | * similar laptops (adapted from Fujitsu init verbs). | |
3952 | */ | |
3953 | static struct hda_verb alc260_acer_init_verbs[] = { | |
3954 | /* On TravelMate laptops, GPIO 0 enables the internal speaker and | |
3955 | * the headphone jack. Turn this on and rely on the standard mute | |
3956 | * methods whenever the user wants to turn these outputs off. | |
3957 | */ | |
3958 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
3959 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
3960 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, | |
3961 | /* Internal speaker/Headphone jack is connected to Line-out pin */ | |
3962 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
3963 | /* Internal microphone/Mic jack is connected to Mic1 pin */ | |
3964 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | |
3965 | /* Line In jack is connected to Line1 pin */ | |
3966 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
bd869485 JW |
3967 | /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */ |
3968 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
0bfc90e9 JW |
3969 | /* Ensure all other unused pins are disabled and muted. */ |
3970 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
3971 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
0bfc90e9 JW |
3972 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
3973 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3974 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
3975 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3976 | /* Disable digital (SPDIF) pins */ | |
3977 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
3978 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
3979 | ||
3980 | /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum | |
3981 | * bus when acting as outputs. | |
3982 | */ | |
3983 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, | |
3984 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
3985 | ||
3986 | /* Start with output sum widgets muted and their output gains at min */ | |
3987 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3988 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3989 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3990 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3991 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3992 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3993 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3994 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3995 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3996 | ||
f12ab1e0 TI |
3997 | /* Unmute Line-out pin widget amp left and right |
3998 | * (no equiv mixer ctrl) | |
3999 | */ | |
0bfc90e9 | 4000 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
bd869485 JW |
4001 | /* Unmute mono pin widget amp output (no equiv mixer ctrl) */ |
4002 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
0bfc90e9 JW |
4003 | /* Unmute Mic1 and Line1 pin widget input buffers since they start as |
4004 | * inputs. If the pin mode is changed by the user the pin mode control | |
4005 | * will take care of enabling the pin's input/output buffers as needed. | |
4006 | * Therefore there's no need to enable the input buffer at this | |
4007 | * stage. | |
4008 | */ | |
4009 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4010 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4011 | ||
4012 | /* Mute capture amp left and right */ | |
4013 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4014 | /* Set ADC connection select to match default mixer setting - mic | |
4015 | * (on mic1 pin) | |
4016 | */ | |
4017 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4018 | ||
4019 | /* Do similar with the second ADC: mute capture input amp and | |
a1e8d2da | 4020 | * set ADC connection to mic to match ALSA's default state. |
0bfc90e9 JW |
4021 | */ |
4022 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
a1e8d2da | 4023 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, |
0bfc90e9 JW |
4024 | |
4025 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
4026 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
4027 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
4028 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
4029 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
4030 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
4031 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
4032 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
4033 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
4034 | ||
4035 | { } | |
4036 | }; | |
4037 | ||
bc9f98a9 KY |
4038 | static struct hda_verb alc260_will_verbs[] = { |
4039 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
4040 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4041 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4042 | {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, | |
4043 | {0x1a, AC_VERB_SET_COEF_INDEX, 0x07}, | |
4044 | {0x1a, AC_VERB_SET_PROC_COEF, 0x3040}, | |
4045 | {} | |
4046 | }; | |
4047 | ||
4048 | static struct hda_verb alc260_replacer_672v_verbs[] = { | |
4049 | {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, | |
4050 | {0x1a, AC_VERB_SET_COEF_INDEX, 0x07}, | |
4051 | {0x1a, AC_VERB_SET_PROC_COEF, 0x3050}, | |
4052 | ||
4053 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
4054 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
4055 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, | |
4056 | ||
4057 | {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
4058 | {} | |
4059 | }; | |
4060 | ||
4061 | /* toggle speaker-output according to the hp-jack state */ | |
4062 | static void alc260_replacer_672v_automute(struct hda_codec *codec) | |
4063 | { | |
4064 | unsigned int present; | |
4065 | ||
4066 | /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */ | |
4067 | present = snd_hda_codec_read(codec, 0x0f, 0, | |
4068 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
4069 | if (present) { | |
82beb8fd TI |
4070 | snd_hda_codec_write_cache(codec, 0x01, 0, |
4071 | AC_VERB_SET_GPIO_DATA, 1); | |
4072 | snd_hda_codec_write_cache(codec, 0x0f, 0, | |
4073 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4074 | PIN_HP); | |
bc9f98a9 | 4075 | } else { |
82beb8fd TI |
4076 | snd_hda_codec_write_cache(codec, 0x01, 0, |
4077 | AC_VERB_SET_GPIO_DATA, 0); | |
4078 | snd_hda_codec_write_cache(codec, 0x0f, 0, | |
4079 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4080 | PIN_OUT); | |
bc9f98a9 KY |
4081 | } |
4082 | } | |
4083 | ||
4084 | static void alc260_replacer_672v_unsol_event(struct hda_codec *codec, | |
4085 | unsigned int res) | |
4086 | { | |
4087 | if ((res >> 26) == ALC880_HP_EVENT) | |
4088 | alc260_replacer_672v_automute(codec); | |
4089 | } | |
4090 | ||
7cf51e48 JW |
4091 | /* Test configuration for debugging, modelled after the ALC880 test |
4092 | * configuration. | |
4093 | */ | |
4094 | #ifdef CONFIG_SND_DEBUG | |
4095 | static hda_nid_t alc260_test_dac_nids[1] = { | |
4096 | 0x02, | |
4097 | }; | |
4098 | static hda_nid_t alc260_test_adc_nids[2] = { | |
4099 | 0x04, 0x05, | |
4100 | }; | |
a1e8d2da JW |
4101 | /* For testing the ALC260, each input MUX needs its own definition since |
4102 | * the signal assignments are different. This assumes that the first ADC | |
4103 | * is NID 0x04. | |
17e7aec6 | 4104 | */ |
a1e8d2da JW |
4105 | static struct hda_input_mux alc260_test_capture_sources[2] = { |
4106 | { | |
4107 | .num_items = 7, | |
4108 | .items = { | |
4109 | { "MIC1 pin", 0x0 }, | |
4110 | { "MIC2 pin", 0x1 }, | |
4111 | { "LINE1 pin", 0x2 }, | |
4112 | { "LINE2 pin", 0x3 }, | |
4113 | { "CD pin", 0x4 }, | |
4114 | { "LINE-OUT pin", 0x5 }, | |
4115 | { "HP-OUT pin", 0x6 }, | |
4116 | }, | |
4117 | }, | |
4118 | { | |
4119 | .num_items = 8, | |
4120 | .items = { | |
4121 | { "MIC1 pin", 0x0 }, | |
4122 | { "MIC2 pin", 0x1 }, | |
4123 | { "LINE1 pin", 0x2 }, | |
4124 | { "LINE2 pin", 0x3 }, | |
4125 | { "CD pin", 0x4 }, | |
4126 | { "Mixer", 0x5 }, | |
4127 | { "LINE-OUT pin", 0x6 }, | |
4128 | { "HP-OUT pin", 0x7 }, | |
4129 | }, | |
7cf51e48 JW |
4130 | }, |
4131 | }; | |
4132 | static struct snd_kcontrol_new alc260_test_mixer[] = { | |
4133 | /* Output driver widgets */ | |
4134 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), | |
4135 | HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), | |
4136 | HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT), | |
4137 | HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT), | |
4138 | HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4139 | HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT), | |
4140 | ||
a1e8d2da JW |
4141 | /* Modes for retasking pin widgets |
4142 | * Note: the ALC260 doesn't seem to act on requests to enable mic | |
4143 | * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't | |
4144 | * mention this restriction. At this stage it's not clear whether | |
4145 | * this behaviour is intentional or is a hardware bug in chip | |
4146 | * revisions available at least up until early 2006. Therefore for | |
4147 | * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all | |
4148 | * choices, but if it turns out that the lack of mic bias for these | |
4149 | * NIDs is intentional we could change their modes from | |
4150 | * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
4151 | */ | |
7cf51e48 JW |
4152 | ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT), |
4153 | ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT), | |
4154 | ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT), | |
4155 | ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT), | |
4156 | ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT), | |
4157 | ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT), | |
4158 | ||
4159 | /* Loopback mixer controls */ | |
4160 | HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT), | |
4161 | HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT), | |
4162 | HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT), | |
4163 | HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT), | |
4164 | HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4165 | HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4166 | HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT), | |
4167 | HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT), | |
4168 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), | |
4169 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
4170 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), | |
4171 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
4172 | HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT), | |
4173 | HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT), | |
4174 | HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT), | |
4175 | HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT), | |
5c8f858d JW |
4176 | |
4177 | /* Controls for GPIO pins, assuming they are configured as outputs */ | |
4178 | ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01), | |
4179 | ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02), | |
4180 | ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04), | |
4181 | ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08), | |
4182 | ||
92621f13 JW |
4183 | /* Switches to allow the digital IO pins to be enabled. The datasheet |
4184 | * is ambigious as to which NID is which; testing on laptops which | |
4185 | * make this output available should provide clarification. | |
4186 | */ | |
4187 | ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01), | |
4188 | ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01), | |
4189 | ||
7cf51e48 JW |
4190 | { } /* end */ |
4191 | }; | |
4192 | static struct hda_verb alc260_test_init_verbs[] = { | |
5c8f858d JW |
4193 | /* Enable all GPIOs as outputs with an initial value of 0 */ |
4194 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f}, | |
4195 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, | |
4196 | {0x01, AC_VERB_SET_GPIO_MASK, 0x0f}, | |
4197 | ||
7cf51e48 JW |
4198 | /* Enable retasking pins as output, initially without power amp */ |
4199 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4200 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4201 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4202 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4203 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4204 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4205 | ||
92621f13 JW |
4206 | /* Disable digital (SPDIF) pins initially, but users can enable |
4207 | * them via a mixer switch. In the case of SPDIF-out, this initverb | |
4208 | * payload also sets the generation to 0, output to be in "consumer" | |
4209 | * PCM format, copyright asserted, no pre-emphasis and no validity | |
4210 | * control. | |
4211 | */ | |
7cf51e48 JW |
4212 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, |
4213 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
4214 | ||
f7ace40d | 4215 | /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the |
7cf51e48 JW |
4216 | * OUT1 sum bus when acting as an output. |
4217 | */ | |
4218 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, | |
4219 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0}, | |
4220 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
4221 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0}, | |
4222 | ||
4223 | /* Start with output sum widgets muted and their output gains at min */ | |
4224 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4225 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4226 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4227 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4228 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4229 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4230 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4231 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4232 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4233 | ||
cdcd9268 JW |
4234 | /* Unmute retasking pin widget output buffers since the default |
4235 | * state appears to be output. As the pin mode is changed by the | |
4236 | * user the pin mode control will take care of enabling the pin's | |
4237 | * input/output buffers as needed. | |
4238 | */ | |
7cf51e48 JW |
4239 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
4240 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4241 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4242 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4243 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4244 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4245 | /* Also unmute the mono-out pin widget */ | |
4246 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4247 | ||
7cf51e48 JW |
4248 | /* Mute capture amp left and right */ |
4249 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
f7ace40d JW |
4250 | /* Set ADC connection select to match default mixer setting (mic1 |
4251 | * pin) | |
7cf51e48 JW |
4252 | */ |
4253 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4254 | ||
4255 | /* Do the same for the second ADC: mute capture input amp and | |
f7ace40d | 4256 | * set ADC connection to mic1 pin |
7cf51e48 JW |
4257 | */ |
4258 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4259 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4260 | ||
4261 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
4262 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
4263 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
4264 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
4265 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
4266 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
4267 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
4268 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
4269 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
4270 | ||
4271 | { } | |
4272 | }; | |
4273 | #endif | |
4274 | ||
1da177e4 LT |
4275 | static struct hda_pcm_stream alc260_pcm_analog_playback = { |
4276 | .substreams = 1, | |
4277 | .channels_min = 2, | |
4278 | .channels_max = 2, | |
1da177e4 LT |
4279 | }; |
4280 | ||
4281 | static struct hda_pcm_stream alc260_pcm_analog_capture = { | |
4282 | .substreams = 1, | |
4283 | .channels_min = 2, | |
4284 | .channels_max = 2, | |
1da177e4 LT |
4285 | }; |
4286 | ||
a3bcba38 TI |
4287 | #define alc260_pcm_digital_playback alc880_pcm_digital_playback |
4288 | #define alc260_pcm_digital_capture alc880_pcm_digital_capture | |
4289 | ||
df694daa KY |
4290 | /* |
4291 | * for BIOS auto-configuration | |
4292 | */ | |
16ded525 | 4293 | |
df694daa KY |
4294 | static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid, |
4295 | const char *pfx) | |
4296 | { | |
4297 | hda_nid_t nid_vol; | |
4298 | unsigned long vol_val, sw_val; | |
4299 | char name[32]; | |
4300 | int err; | |
4301 | ||
4302 | if (nid >= 0x0f && nid < 0x11) { | |
4303 | nid_vol = nid - 0x7; | |
4304 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); | |
4305 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); | |
4306 | } else if (nid == 0x11) { | |
4307 | nid_vol = nid - 0x7; | |
4308 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT); | |
4309 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT); | |
4310 | } else if (nid >= 0x12 && nid <= 0x15) { | |
4311 | nid_vol = 0x08; | |
4312 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); | |
4313 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); | |
4314 | } else | |
4315 | return 0; /* N/A */ | |
4316 | ||
4317 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); | |
f12ab1e0 TI |
4318 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val); |
4319 | if (err < 0) | |
df694daa KY |
4320 | return err; |
4321 | snprintf(name, sizeof(name), "%s Playback Switch", pfx); | |
f12ab1e0 TI |
4322 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val); |
4323 | if (err < 0) | |
df694daa KY |
4324 | return err; |
4325 | return 1; | |
4326 | } | |
4327 | ||
4328 | /* add playback controls from the parsed DAC table */ | |
4329 | static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec, | |
4330 | const struct auto_pin_cfg *cfg) | |
4331 | { | |
4332 | hda_nid_t nid; | |
4333 | int err; | |
4334 | ||
4335 | spec->multiout.num_dacs = 1; | |
4336 | spec->multiout.dac_nids = spec->private_dac_nids; | |
4337 | spec->multiout.dac_nids[0] = 0x02; | |
4338 | ||
4339 | nid = cfg->line_out_pins[0]; | |
4340 | if (nid) { | |
4341 | err = alc260_add_playback_controls(spec, nid, "Front"); | |
4342 | if (err < 0) | |
4343 | return err; | |
4344 | } | |
4345 | ||
82bc955f | 4346 | nid = cfg->speaker_pins[0]; |
df694daa KY |
4347 | if (nid) { |
4348 | err = alc260_add_playback_controls(spec, nid, "Speaker"); | |
4349 | if (err < 0) | |
4350 | return err; | |
4351 | } | |
4352 | ||
eb06ed8f | 4353 | nid = cfg->hp_pins[0]; |
df694daa KY |
4354 | if (nid) { |
4355 | err = alc260_add_playback_controls(spec, nid, "Headphone"); | |
4356 | if (err < 0) | |
4357 | return err; | |
4358 | } | |
f12ab1e0 | 4359 | return 0; |
df694daa KY |
4360 | } |
4361 | ||
4362 | /* create playback/capture controls for input pins */ | |
4363 | static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec, | |
4364 | const struct auto_pin_cfg *cfg) | |
4365 | { | |
df694daa KY |
4366 | struct hda_input_mux *imux = &spec->private_imux; |
4367 | int i, err, idx; | |
4368 | ||
4369 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
4370 | if (cfg->input_pins[i] >= 0x12) { | |
4371 | idx = cfg->input_pins[i] - 0x12; | |
4a471b7d | 4372 | err = new_analog_input(spec, cfg->input_pins[i], |
f12ab1e0 TI |
4373 | auto_pin_cfg_labels[i], idx, |
4374 | 0x07); | |
df694daa KY |
4375 | if (err < 0) |
4376 | return err; | |
f12ab1e0 TI |
4377 | imux->items[imux->num_items].label = |
4378 | auto_pin_cfg_labels[i]; | |
df694daa KY |
4379 | imux->items[imux->num_items].index = idx; |
4380 | imux->num_items++; | |
4381 | } | |
f12ab1e0 | 4382 | if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){ |
df694daa | 4383 | idx = cfg->input_pins[i] - 0x09; |
4a471b7d | 4384 | err = new_analog_input(spec, cfg->input_pins[i], |
f12ab1e0 TI |
4385 | auto_pin_cfg_labels[i], idx, |
4386 | 0x07); | |
df694daa KY |
4387 | if (err < 0) |
4388 | return err; | |
f12ab1e0 TI |
4389 | imux->items[imux->num_items].label = |
4390 | auto_pin_cfg_labels[i]; | |
df694daa KY |
4391 | imux->items[imux->num_items].index = idx; |
4392 | imux->num_items++; | |
4393 | } | |
4394 | } | |
4395 | return 0; | |
4396 | } | |
4397 | ||
4398 | static void alc260_auto_set_output_and_unmute(struct hda_codec *codec, | |
4399 | hda_nid_t nid, int pin_type, | |
4400 | int sel_idx) | |
4401 | { | |
4402 | /* set as output */ | |
f12ab1e0 TI |
4403 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
4404 | pin_type); | |
4405 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
4406 | AMP_OUT_UNMUTE); | |
df694daa KY |
4407 | /* need the manual connection? */ |
4408 | if (nid >= 0x12) { | |
4409 | int idx = nid - 0x12; | |
4410 | snd_hda_codec_write(codec, idx + 0x0b, 0, | |
4411 | AC_VERB_SET_CONNECT_SEL, sel_idx); | |
df694daa KY |
4412 | } |
4413 | } | |
4414 | ||
4415 | static void alc260_auto_init_multi_out(struct hda_codec *codec) | |
4416 | { | |
4417 | struct alc_spec *spec = codec->spec; | |
4418 | hda_nid_t nid; | |
4419 | ||
bc9f98a9 | 4420 | alc_subsystem_id(codec, 0x10, 0x15, 0x0f); |
f12ab1e0 | 4421 | nid = spec->autocfg.line_out_pins[0]; |
baba8ee9 TI |
4422 | if (nid) { |
4423 | int pin_type = get_pin_type(spec->autocfg.line_out_type); | |
4424 | alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0); | |
4425 | } | |
df694daa | 4426 | |
82bc955f | 4427 | nid = spec->autocfg.speaker_pins[0]; |
df694daa KY |
4428 | if (nid) |
4429 | alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); | |
4430 | ||
eb06ed8f | 4431 | nid = spec->autocfg.hp_pins[0]; |
df694daa | 4432 | if (nid) |
baba8ee9 | 4433 | alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0); |
f12ab1e0 | 4434 | } |
df694daa KY |
4435 | |
4436 | #define ALC260_PIN_CD_NID 0x16 | |
4437 | static void alc260_auto_init_analog_input(struct hda_codec *codec) | |
4438 | { | |
4439 | struct alc_spec *spec = codec->spec; | |
4440 | int i; | |
4441 | ||
4442 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
4443 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
4444 | if (nid >= 0x12) { | |
f12ab1e0 TI |
4445 | snd_hda_codec_write(codec, nid, 0, |
4446 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4447 | i <= AUTO_PIN_FRONT_MIC ? | |
4448 | PIN_VREF80 : PIN_IN); | |
df694daa | 4449 | if (nid != ALC260_PIN_CD_NID) |
f12ab1e0 TI |
4450 | snd_hda_codec_write(codec, nid, 0, |
4451 | AC_VERB_SET_AMP_GAIN_MUTE, | |
df694daa KY |
4452 | AMP_OUT_MUTE); |
4453 | } | |
4454 | } | |
4455 | } | |
4456 | ||
4457 | /* | |
4458 | * generic initialization of ADC, input mixers and output mixers | |
4459 | */ | |
4460 | static struct hda_verb alc260_volume_init_verbs[] = { | |
4461 | /* | |
4462 | * Unmute ADC0-1 and set the default input to mic-in | |
4463 | */ | |
4464 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4465 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4466 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4467 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4468 | ||
4469 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | |
4470 | * mixer widget | |
f12ab1e0 TI |
4471 | * Note: PASD motherboards uses the Line In 2 as the input for |
4472 | * front panel mic (mic 2) | |
df694daa KY |
4473 | */ |
4474 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
4475 | /* mute analog inputs */ |
4476 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4477 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4478 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4479 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4480 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
4481 | |
4482 | /* | |
4483 | * Set up output mixers (0x08 - 0x0a) | |
4484 | */ | |
4485 | /* set vol=0 to output mixers */ | |
4486 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4487 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4488 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4489 | /* set up input amps for analog loopback */ | |
4490 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
4491 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4492 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4493 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4494 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4495 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4496 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4497 | ||
4498 | { } | |
4499 | }; | |
4500 | ||
4501 | static int alc260_parse_auto_config(struct hda_codec *codec) | |
4502 | { | |
4503 | struct alc_spec *spec = codec->spec; | |
4504 | unsigned int wcap; | |
4505 | int err; | |
4506 | static hda_nid_t alc260_ignore[] = { 0x17, 0 }; | |
4507 | ||
f12ab1e0 TI |
4508 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
4509 | alc260_ignore); | |
4510 | if (err < 0) | |
df694daa | 4511 | return err; |
f12ab1e0 TI |
4512 | err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg); |
4513 | if (err < 0) | |
4a471b7d | 4514 | return err; |
f12ab1e0 | 4515 | if (!spec->kctl_alloc) |
df694daa | 4516 | return 0; /* can't find valid BIOS pin config */ |
f12ab1e0 TI |
4517 | err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg); |
4518 | if (err < 0) | |
df694daa KY |
4519 | return err; |
4520 | ||
4521 | spec->multiout.max_channels = 2; | |
4522 | ||
4523 | if (spec->autocfg.dig_out_pin) | |
4524 | spec->multiout.dig_out_nid = ALC260_DIGOUT_NID; | |
4525 | if (spec->kctl_alloc) | |
4526 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
4527 | ||
4528 | spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs; | |
4529 | ||
a1e8d2da | 4530 | spec->num_mux_defs = 1; |
df694daa KY |
4531 | spec->input_mux = &spec->private_imux; |
4532 | ||
4533 | /* check whether NID 0x04 is valid */ | |
4a471b7d | 4534 | wcap = get_wcaps(codec, 0x04); |
df694daa KY |
4535 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ |
4536 | if (wcap != AC_WID_AUD_IN) { | |
4537 | spec->adc_nids = alc260_adc_nids_alt; | |
4538 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt); | |
4539 | spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer; | |
df694daa KY |
4540 | } else { |
4541 | spec->adc_nids = alc260_adc_nids; | |
4542 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); | |
4543 | spec->mixers[spec->num_mixers] = alc260_capture_mixer; | |
df694daa | 4544 | } |
4a471b7d | 4545 | spec->num_mixers++; |
df694daa KY |
4546 | |
4547 | return 1; | |
4548 | } | |
4549 | ||
ae6b813a TI |
4550 | /* additional initialization for auto-configuration model */ |
4551 | static void alc260_auto_init(struct hda_codec *codec) | |
df694daa | 4552 | { |
df694daa KY |
4553 | alc260_auto_init_multi_out(codec); |
4554 | alc260_auto_init_analog_input(codec); | |
df694daa KY |
4555 | } |
4556 | ||
cb53c626 TI |
4557 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
4558 | static struct hda_amp_list alc260_loopbacks[] = { | |
4559 | { 0x07, HDA_INPUT, 0 }, | |
4560 | { 0x07, HDA_INPUT, 1 }, | |
4561 | { 0x07, HDA_INPUT, 2 }, | |
4562 | { 0x07, HDA_INPUT, 3 }, | |
4563 | { 0x07, HDA_INPUT, 4 }, | |
4564 | { } /* end */ | |
4565 | }; | |
4566 | #endif | |
4567 | ||
df694daa KY |
4568 | /* |
4569 | * ALC260 configurations | |
4570 | */ | |
f5fcc13c TI |
4571 | static const char *alc260_models[ALC260_MODEL_LAST] = { |
4572 | [ALC260_BASIC] = "basic", | |
4573 | [ALC260_HP] = "hp", | |
4574 | [ALC260_HP_3013] = "hp-3013", | |
4575 | [ALC260_FUJITSU_S702X] = "fujitsu", | |
4576 | [ALC260_ACER] = "acer", | |
bc9f98a9 KY |
4577 | [ALC260_WILL] = "will", |
4578 | [ALC260_REPLACER_672V] = "replacer", | |
7cf51e48 | 4579 | #ifdef CONFIG_SND_DEBUG |
f5fcc13c | 4580 | [ALC260_TEST] = "test", |
7cf51e48 | 4581 | #endif |
f5fcc13c TI |
4582 | [ALC260_AUTO] = "auto", |
4583 | }; | |
4584 | ||
4585 | static struct snd_pci_quirk alc260_cfg_tbl[] = { | |
bd869485 | 4586 | SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER), |
f5fcc13c | 4587 | SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER), |
9720b718 | 4588 | SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013), |
a8a5d067 | 4589 | SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013), |
f5fcc13c TI |
4590 | SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013), |
4591 | SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP), | |
4592 | SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013), | |
4593 | SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013), | |
4594 | SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP), | |
4595 | SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP), | |
4596 | SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP), | |
4597 | SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC), | |
4598 | SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC), | |
4599 | SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC), | |
4600 | SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X), | |
4601 | SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC), | |
bc9f98a9 KY |
4602 | SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL), |
4603 | SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V), | |
df694daa KY |
4604 | {} |
4605 | }; | |
4606 | ||
4607 | static struct alc_config_preset alc260_presets[] = { | |
4608 | [ALC260_BASIC] = { | |
4609 | .mixers = { alc260_base_output_mixer, | |
4610 | alc260_input_mixer, | |
4611 | alc260_pc_beep_mixer, | |
4612 | alc260_capture_mixer }, | |
4613 | .init_verbs = { alc260_init_verbs }, | |
4614 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
4615 | .dac_nids = alc260_dac_nids, | |
4616 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), | |
4617 | .adc_nids = alc260_adc_nids, | |
4618 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
4619 | .channel_mode = alc260_modes, | |
4620 | .input_mux = &alc260_capture_source, | |
4621 | }, | |
4622 | [ALC260_HP] = { | |
4623 | .mixers = { alc260_base_output_mixer, | |
4624 | alc260_input_mixer, | |
4625 | alc260_capture_alt_mixer }, | |
474167d6 | 4626 | .init_verbs = { alc260_init_verbs }, |
df694daa KY |
4627 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), |
4628 | .dac_nids = alc260_dac_nids, | |
4629 | .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), | |
4630 | .adc_nids = alc260_hp_adc_nids, | |
4631 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
4632 | .channel_mode = alc260_modes, | |
4633 | .input_mux = &alc260_capture_source, | |
4634 | }, | |
4635 | [ALC260_HP_3013] = { | |
4636 | .mixers = { alc260_hp_3013_mixer, | |
4637 | alc260_input_mixer, | |
4638 | alc260_capture_alt_mixer }, | |
4639 | .init_verbs = { alc260_hp_3013_init_verbs }, | |
4640 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
4641 | .dac_nids = alc260_dac_nids, | |
4642 | .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), | |
4643 | .adc_nids = alc260_hp_adc_nids, | |
4644 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
4645 | .channel_mode = alc260_modes, | |
4646 | .input_mux = &alc260_capture_source, | |
4647 | }, | |
4648 | [ALC260_FUJITSU_S702X] = { | |
4649 | .mixers = { alc260_fujitsu_mixer, | |
4650 | alc260_capture_mixer }, | |
4651 | .init_verbs = { alc260_fujitsu_init_verbs }, | |
4652 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
4653 | .dac_nids = alc260_dac_nids, | |
d57fdac0 JW |
4654 | .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), |
4655 | .adc_nids = alc260_dual_adc_nids, | |
df694daa KY |
4656 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
4657 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
4658 | .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources), |
4659 | .input_mux = alc260_fujitsu_capture_sources, | |
df694daa | 4660 | }, |
0bfc90e9 JW |
4661 | [ALC260_ACER] = { |
4662 | .mixers = { alc260_acer_mixer, | |
4663 | alc260_capture_mixer }, | |
4664 | .init_verbs = { alc260_acer_init_verbs }, | |
4665 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
4666 | .dac_nids = alc260_dac_nids, | |
4667 | .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), | |
4668 | .adc_nids = alc260_dual_adc_nids, | |
4669 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
4670 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
4671 | .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources), |
4672 | .input_mux = alc260_acer_capture_sources, | |
0bfc90e9 | 4673 | }, |
bc9f98a9 KY |
4674 | [ALC260_WILL] = { |
4675 | .mixers = { alc260_will_mixer, | |
4676 | alc260_capture_mixer }, | |
4677 | .init_verbs = { alc260_init_verbs, alc260_will_verbs }, | |
4678 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
4679 | .dac_nids = alc260_dac_nids, | |
4680 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), | |
4681 | .adc_nids = alc260_adc_nids, | |
4682 | .dig_out_nid = ALC260_DIGOUT_NID, | |
4683 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
4684 | .channel_mode = alc260_modes, | |
4685 | .input_mux = &alc260_capture_source, | |
4686 | }, | |
4687 | [ALC260_REPLACER_672V] = { | |
4688 | .mixers = { alc260_replacer_672v_mixer, | |
4689 | alc260_capture_mixer }, | |
4690 | .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs }, | |
4691 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
4692 | .dac_nids = alc260_dac_nids, | |
4693 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), | |
4694 | .adc_nids = alc260_adc_nids, | |
4695 | .dig_out_nid = ALC260_DIGOUT_NID, | |
4696 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
4697 | .channel_mode = alc260_modes, | |
4698 | .input_mux = &alc260_capture_source, | |
4699 | .unsol_event = alc260_replacer_672v_unsol_event, | |
4700 | .init_hook = alc260_replacer_672v_automute, | |
4701 | }, | |
7cf51e48 JW |
4702 | #ifdef CONFIG_SND_DEBUG |
4703 | [ALC260_TEST] = { | |
4704 | .mixers = { alc260_test_mixer, | |
4705 | alc260_capture_mixer }, | |
4706 | .init_verbs = { alc260_test_init_verbs }, | |
4707 | .num_dacs = ARRAY_SIZE(alc260_test_dac_nids), | |
4708 | .dac_nids = alc260_test_dac_nids, | |
4709 | .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids), | |
4710 | .adc_nids = alc260_test_adc_nids, | |
4711 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
4712 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
4713 | .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources), |
4714 | .input_mux = alc260_test_capture_sources, | |
7cf51e48 JW |
4715 | }, |
4716 | #endif | |
df694daa KY |
4717 | }; |
4718 | ||
4719 | static int patch_alc260(struct hda_codec *codec) | |
1da177e4 LT |
4720 | { |
4721 | struct alc_spec *spec; | |
df694daa | 4722 | int err, board_config; |
1da177e4 | 4723 | |
e560d8d8 | 4724 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
1da177e4 LT |
4725 | if (spec == NULL) |
4726 | return -ENOMEM; | |
4727 | ||
4728 | codec->spec = spec; | |
4729 | ||
f5fcc13c TI |
4730 | board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST, |
4731 | alc260_models, | |
4732 | alc260_cfg_tbl); | |
4733 | if (board_config < 0) { | |
9c7f852e TI |
4734 | snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, " |
4735 | "trying auto-probe from BIOS...\n"); | |
df694daa | 4736 | board_config = ALC260_AUTO; |
16ded525 | 4737 | } |
1da177e4 | 4738 | |
df694daa KY |
4739 | if (board_config == ALC260_AUTO) { |
4740 | /* automatic parse from the BIOS config */ | |
4741 | err = alc260_parse_auto_config(codec); | |
4742 | if (err < 0) { | |
4743 | alc_free(codec); | |
4744 | return err; | |
f12ab1e0 | 4745 | } else if (!err) { |
9c7f852e TI |
4746 | printk(KERN_INFO |
4747 | "hda_codec: Cannot set up configuration " | |
4748 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
4749 | board_config = ALC260_BASIC; |
4750 | } | |
a9430dd8 | 4751 | } |
e9edcee0 | 4752 | |
df694daa KY |
4753 | if (board_config != ALC260_AUTO) |
4754 | setup_preset(spec, &alc260_presets[board_config]); | |
1da177e4 LT |
4755 | |
4756 | spec->stream_name_analog = "ALC260 Analog"; | |
4757 | spec->stream_analog_playback = &alc260_pcm_analog_playback; | |
4758 | spec->stream_analog_capture = &alc260_pcm_analog_capture; | |
4759 | ||
a3bcba38 TI |
4760 | spec->stream_name_digital = "ALC260 Digital"; |
4761 | spec->stream_digital_playback = &alc260_pcm_digital_playback; | |
4762 | spec->stream_digital_capture = &alc260_pcm_digital_capture; | |
4763 | ||
1da177e4 | 4764 | codec->patch_ops = alc_patch_ops; |
df694daa | 4765 | if (board_config == ALC260_AUTO) |
ae6b813a | 4766 | spec->init_hook = alc260_auto_init; |
cb53c626 TI |
4767 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
4768 | if (!spec->loopback.amplist) | |
4769 | spec->loopback.amplist = alc260_loopbacks; | |
4770 | #endif | |
1da177e4 LT |
4771 | |
4772 | return 0; | |
4773 | } | |
4774 | ||
e9edcee0 | 4775 | |
1da177e4 LT |
4776 | /* |
4777 | * ALC882 support | |
4778 | * | |
4779 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible | |
4780 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
4781 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
4782 | * 6-channel independent captures. | |
4783 | * | |
4784 | * In addition, an independent DAC for the multi-playback (not used in this | |
4785 | * driver yet). | |
4786 | */ | |
df694daa KY |
4787 | #define ALC882_DIGOUT_NID 0x06 |
4788 | #define ALC882_DIGIN_NID 0x0a | |
1da177e4 | 4789 | |
d2a6d7dc | 4790 | static struct hda_channel_mode alc882_ch_modes[1] = { |
1da177e4 LT |
4791 | { 8, NULL } |
4792 | }; | |
4793 | ||
4794 | static hda_nid_t alc882_dac_nids[4] = { | |
4795 | /* front, rear, clfe, rear_surr */ | |
4796 | 0x02, 0x03, 0x04, 0x05 | |
4797 | }; | |
4798 | ||
df694daa KY |
4799 | /* identical with ALC880 */ |
4800 | #define alc882_adc_nids alc880_adc_nids | |
4801 | #define alc882_adc_nids_alt alc880_adc_nids_alt | |
1da177e4 LT |
4802 | |
4803 | /* input MUX */ | |
4804 | /* FIXME: should be a matrix-type input source selection */ | |
4805 | ||
4806 | static struct hda_input_mux alc882_capture_source = { | |
4807 | .num_items = 4, | |
4808 | .items = { | |
4809 | { "Mic", 0x0 }, | |
4810 | { "Front Mic", 0x1 }, | |
4811 | { "Line", 0x2 }, | |
4812 | { "CD", 0x4 }, | |
4813 | }, | |
4814 | }; | |
1da177e4 LT |
4815 | #define alc882_mux_enum_info alc_mux_enum_info |
4816 | #define alc882_mux_enum_get alc_mux_enum_get | |
4817 | ||
f12ab1e0 TI |
4818 | static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, |
4819 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
4820 | { |
4821 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
4822 | struct alc_spec *spec = codec->spec; | |
4823 | const struct hda_input_mux *imux = spec->input_mux; | |
4824 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
4825 | static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 }; | |
4826 | hda_nid_t nid = capture_mixers[adc_idx]; | |
4827 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; | |
4828 | unsigned int i, idx; | |
4829 | ||
4830 | idx = ucontrol->value.enumerated.item[0]; | |
4831 | if (idx >= imux->num_items) | |
4832 | idx = imux->num_items - 1; | |
82beb8fd | 4833 | if (*cur_val == idx) |
1da177e4 LT |
4834 | return 0; |
4835 | for (i = 0; i < imux->num_items; i++) { | |
47fd830a TI |
4836 | unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE; |
4837 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, | |
82beb8fd | 4838 | imux->items[i].index, |
47fd830a | 4839 | HDA_AMP_MUTE, v); |
1da177e4 LT |
4840 | } |
4841 | *cur_val = idx; | |
4842 | return 1; | |
4843 | } | |
4844 | ||
272a527c KY |
4845 | /* |
4846 | * 2ch mode | |
4847 | */ | |
4848 | static struct hda_verb alc882_3ST_ch2_init[] = { | |
4849 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
4850 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
4851 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
4852 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
4853 | { } /* end */ | |
4854 | }; | |
4855 | ||
4856 | /* | |
4857 | * 6ch mode | |
4858 | */ | |
4859 | static struct hda_verb alc882_3ST_ch6_init[] = { | |
4860 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
4861 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
4862 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
4863 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
4864 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
4865 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
4866 | { } /* end */ | |
4867 | }; | |
4868 | ||
4869 | static struct hda_channel_mode alc882_3ST_6ch_modes[2] = { | |
4870 | { 2, alc882_3ST_ch2_init }, | |
4871 | { 6, alc882_3ST_ch6_init }, | |
4872 | }; | |
4873 | ||
df694daa KY |
4874 | /* |
4875 | * 6ch mode | |
4876 | */ | |
4877 | static struct hda_verb alc882_sixstack_ch6_init[] = { | |
4878 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
4879 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
4880 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
4881 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
4882 | { } /* end */ | |
4883 | }; | |
4884 | ||
4885 | /* | |
4886 | * 8ch mode | |
4887 | */ | |
4888 | static struct hda_verb alc882_sixstack_ch8_init[] = { | |
4889 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
4890 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
4891 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
4892 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
4893 | { } /* end */ | |
4894 | }; | |
4895 | ||
4896 | static struct hda_channel_mode alc882_sixstack_modes[2] = { | |
4897 | { 6, alc882_sixstack_ch6_init }, | |
4898 | { 8, alc882_sixstack_ch8_init }, | |
4899 | }; | |
4900 | ||
87350ad0 TI |
4901 | /* |
4902 | * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic | |
4903 | */ | |
4904 | ||
4905 | /* | |
4906 | * 2ch mode | |
4907 | */ | |
4908 | static struct hda_verb alc885_mbp_ch2_init[] = { | |
4909 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
4910 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4911 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4912 | { } /* end */ | |
4913 | }; | |
4914 | ||
4915 | /* | |
4916 | * 6ch mode | |
4917 | */ | |
4918 | static struct hda_verb alc885_mbp_ch6_init[] = { | |
4919 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
4920 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4921 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
4922 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4923 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4924 | { } /* end */ | |
4925 | }; | |
4926 | ||
4927 | static struct hda_channel_mode alc885_mbp_6ch_modes[2] = { | |
4928 | { 2, alc885_mbp_ch2_init }, | |
4929 | { 6, alc885_mbp_ch6_init }, | |
4930 | }; | |
4931 | ||
4932 | ||
1da177e4 LT |
4933 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
4934 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
4935 | */ | |
c8b6bf9b | 4936 | static struct snd_kcontrol_new alc882_base_mixer[] = { |
05acb863 | 4937 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 4938 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
05acb863 | 4939 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 4940 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
05acb863 TI |
4941 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
4942 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
4943 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
4944 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
05acb863 | 4945 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 4946 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
1da177e4 LT |
4947 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
4948 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
4949 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
4950 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
4951 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
4952 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 4953 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
1da177e4 LT |
4954 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
4955 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 4956 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
1da177e4 LT |
4957 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
4958 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
4959 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
1da177e4 LT |
4960 | { } /* end */ |
4961 | }; | |
4962 | ||
87350ad0 TI |
4963 | static struct snd_kcontrol_new alc885_mbp3_mixer[] = { |
4964 | HDA_CODEC_VOLUME("Master Volume", 0x0c, 0x00, HDA_OUTPUT), | |
4965 | HDA_BIND_MUTE ("Master Switch", 0x0c, 0x02, HDA_INPUT), | |
4966 | HDA_CODEC_MUTE ("Speaker Switch", 0x14, 0x00, HDA_OUTPUT), | |
4967 | HDA_CODEC_VOLUME("Line Out Volume", 0x0d,0x00, HDA_OUTPUT), | |
4968 | HDA_CODEC_VOLUME("Line In Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
4969 | HDA_CODEC_MUTE ("Line In Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
4970 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT), | |
4971 | HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT), | |
4972 | HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0x00, HDA_INPUT), | |
4973 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT), | |
4974 | { } /* end */ | |
4975 | }; | |
bdd148a3 KY |
4976 | static struct snd_kcontrol_new alc882_w2jc_mixer[] = { |
4977 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
4978 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
4979 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
4980 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
4981 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
4982 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
4983 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
4984 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
4985 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
4986 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
4987 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
4988 | { } /* end */ | |
4989 | }; | |
4990 | ||
272a527c KY |
4991 | static struct snd_kcontrol_new alc882_targa_mixer[] = { |
4992 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
4993 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
4994 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
4995 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
4996 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
4997 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
4998 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
4999 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
5000 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
5001 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
5002 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
5003 | { } /* end */ | |
5004 | }; | |
5005 | ||
5006 | /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ??? | |
5007 | * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c | |
5008 | */ | |
5009 | static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = { | |
5010 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5011 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
5012 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
5013 | HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT), | |
5014 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5015 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5016 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5017 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5018 | HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT), | |
5019 | HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT), | |
5020 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
5021 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
5022 | { } /* end */ | |
5023 | }; | |
5024 | ||
df694daa KY |
5025 | static struct snd_kcontrol_new alc882_chmode_mixer[] = { |
5026 | { | |
5027 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5028 | .name = "Channel Mode", | |
5029 | .info = alc_ch_mode_info, | |
5030 | .get = alc_ch_mode_get, | |
5031 | .put = alc_ch_mode_put, | |
5032 | }, | |
5033 | { } /* end */ | |
5034 | }; | |
5035 | ||
1da177e4 LT |
5036 | static struct hda_verb alc882_init_verbs[] = { |
5037 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
05acb863 TI |
5038 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
5039 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5040 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 5041 | /* Rear mixer */ |
05acb863 TI |
5042 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
5043 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5044 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 5045 | /* CLFE mixer */ |
05acb863 TI |
5046 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
5047 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5048 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 5049 | /* Side mixer */ |
05acb863 TI |
5050 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
5051 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5052 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 5053 | |
e9edcee0 | 5054 | /* Front Pin: output 0 (0x0c) */ |
05acb863 | 5055 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 5056 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 5057 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 5058 | /* Rear Pin: output 1 (0x0d) */ |
05acb863 | 5059 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 5060 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 5061 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, |
e9edcee0 | 5062 | /* CLFE Pin: output 2 (0x0e) */ |
05acb863 | 5063 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 5064 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 5065 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, |
e9edcee0 | 5066 | /* Side Pin: output 3 (0x0f) */ |
05acb863 | 5067 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 5068 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 5069 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, |
e9edcee0 | 5070 | /* Mic (rear) pin: input vref at 80% */ |
16ded525 | 5071 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 TI |
5072 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
5073 | /* Front Mic pin: input vref at 80% */ | |
16ded525 | 5074 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 TI |
5075 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
5076 | /* Line In pin: input */ | |
05acb863 | 5077 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 TI |
5078 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
5079 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
5080 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5081 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5082 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1da177e4 | 5083 | /* CD pin widget for input */ |
05acb863 | 5084 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 LT |
5085 | |
5086 | /* FIXME: use matrix-type input source selection */ | |
5087 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
5088 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
05acb863 TI |
5089 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
5090 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5091 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5092 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 5093 | /* Input mixer2 */ |
05acb863 TI |
5094 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
5095 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5096 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5097 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 5098 | /* Input mixer3 */ |
05acb863 TI |
5099 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
5100 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5101 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5102 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5103 | /* ADC1: mute amp left and right */ | |
5104 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 5105 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
5106 | /* ADC2: mute amp left and right */ |
5107 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 5108 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
5109 | /* ADC3: mute amp left and right */ |
5110 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 5111 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
1da177e4 LT |
5112 | |
5113 | { } | |
5114 | }; | |
5115 | ||
4b146cb0 TI |
5116 | static struct hda_verb alc882_eapd_verbs[] = { |
5117 | /* change to EAPD mode */ | |
5118 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
b373bdeb | 5119 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, |
f12ab1e0 | 5120 | { } |
4b146cb0 TI |
5121 | }; |
5122 | ||
9102cd1c TD |
5123 | /* Mac Pro test */ |
5124 | static struct snd_kcontrol_new alc882_macpro_mixer[] = { | |
5125 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5126 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
5127 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT), | |
5128 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
5129 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
5130 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5131 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5132 | { } /* end */ | |
5133 | }; | |
5134 | ||
5135 | static struct hda_verb alc882_macpro_init_verbs[] = { | |
5136 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
5137 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5138 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5139 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5140 | /* Front Pin: output 0 (0x0c) */ | |
5141 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5142 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5143 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5144 | /* Front Mic pin: input vref at 80% */ | |
5145 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
5146 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5147 | /* Speaker: output */ | |
5148 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5149 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5150 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04}, | |
5151 | /* Headphone output (output 0 - 0x0c) */ | |
5152 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5153 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5154 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5155 | ||
5156 | /* FIXME: use matrix-type input source selection */ | |
5157 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
5158 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
5159 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5160 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5161 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5162 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5163 | /* Input mixer2 */ | |
5164 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5165 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5166 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5167 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5168 | /* Input mixer3 */ | |
5169 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5170 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5171 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5172 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5173 | /* ADC1: mute amp left and right */ | |
5174 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5175 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5176 | /* ADC2: mute amp left and right */ | |
5177 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5178 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5179 | /* ADC3: mute amp left and right */ | |
5180 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5181 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5182 | ||
5183 | { } | |
5184 | }; | |
f12ab1e0 | 5185 | |
87350ad0 TI |
5186 | /* Macbook Pro rev3 */ |
5187 | static struct hda_verb alc885_mbp3_init_verbs[] = { | |
5188 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
5189 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5190 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5191 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5192 | /* Rear mixer */ | |
5193 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5194 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5195 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5196 | /* Front Pin: output 0 (0x0c) */ | |
5197 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5198 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5199 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5200 | /* HP Pin: output 0 (0x0d) */ | |
5201 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, | |
5202 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5203 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5204 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
5205 | /* Mic (rear) pin: input vref at 80% */ | |
5206 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
5207 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5208 | /* Front Mic pin: input vref at 80% */ | |
5209 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
5210 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5211 | /* Line In pin: use output 1 when in LineOut mode */ | |
5212 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
5213 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5214 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
5215 | ||
5216 | /* FIXME: use matrix-type input source selection */ | |
5217 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
5218 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
5219 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5220 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5221 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5222 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5223 | /* Input mixer2 */ | |
5224 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5225 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5226 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5227 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5228 | /* Input mixer3 */ | |
5229 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5230 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5231 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5232 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5233 | /* ADC1: mute amp left and right */ | |
5234 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5235 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5236 | /* ADC2: mute amp left and right */ | |
5237 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5238 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5239 | /* ADC3: mute amp left and right */ | |
5240 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5241 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5242 | ||
5243 | { } | |
5244 | }; | |
5245 | ||
c54728d8 NF |
5246 | /* iMac 24 mixer. */ |
5247 | static struct snd_kcontrol_new alc885_imac24_mixer[] = { | |
5248 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT), | |
5249 | HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT), | |
5250 | { } /* end */ | |
5251 | }; | |
5252 | ||
5253 | /* iMac 24 init verbs. */ | |
5254 | static struct hda_verb alc885_imac24_init_verbs[] = { | |
5255 | /* Internal speakers: output 0 (0x0c) */ | |
5256 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5257 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5258 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5259 | /* Internal speakers: output 0 (0x0c) */ | |
5260 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5261 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5262 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5263 | /* Headphone: output 0 (0x0c) */ | |
5264 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5265 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5266 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5267 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
5268 | /* Front Mic: input vref at 80% */ | |
5269 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
5270 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5271 | { } | |
5272 | }; | |
5273 | ||
5274 | /* Toggle speaker-output according to the hp-jack state */ | |
5275 | static void alc885_imac24_automute(struct hda_codec *codec) | |
5276 | { | |
5277 | unsigned int present; | |
5278 | ||
5279 | present = snd_hda_codec_read(codec, 0x14, 0, | |
5280 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
5281 | snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0, |
5282 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
5283 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, | |
5284 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
c54728d8 NF |
5285 | } |
5286 | ||
5287 | /* Processes unsolicited events. */ | |
5288 | static void alc885_imac24_unsol_event(struct hda_codec *codec, | |
5289 | unsigned int res) | |
5290 | { | |
5291 | /* Headphone insertion or removal. */ | |
5292 | if ((res >> 26) == ALC880_HP_EVENT) | |
5293 | alc885_imac24_automute(codec); | |
5294 | } | |
5295 | ||
87350ad0 TI |
5296 | static void alc885_mbp3_automute(struct hda_codec *codec) |
5297 | { | |
5298 | unsigned int present; | |
5299 | ||
5300 | present = snd_hda_codec_read(codec, 0x15, 0, | |
5301 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
5302 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
5303 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
5304 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
5305 | HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE); | |
5306 | ||
5307 | } | |
5308 | static void alc885_mbp3_unsol_event(struct hda_codec *codec, | |
5309 | unsigned int res) | |
5310 | { | |
5311 | /* Headphone insertion or removal. */ | |
5312 | if ((res >> 26) == ALC880_HP_EVENT) | |
5313 | alc885_mbp3_automute(codec); | |
5314 | } | |
5315 | ||
5316 | ||
272a527c KY |
5317 | static struct hda_verb alc882_targa_verbs[] = { |
5318 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5319 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5320 | ||
5321 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5322 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5323 | ||
5324 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
5325 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
5326 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
5327 | ||
5328 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
5329 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, | |
5330 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | |
5331 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | |
5332 | { } /* end */ | |
5333 | }; | |
5334 | ||
5335 | /* toggle speaker-output according to the hp-jack state */ | |
5336 | static void alc882_targa_automute(struct hda_codec *codec) | |
5337 | { | |
5338 | unsigned int present; | |
5339 | ||
5340 | present = snd_hda_codec_read(codec, 0x14, 0, | |
5341 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
5342 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, |
5343 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
82beb8fd TI |
5344 | snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA, |
5345 | present ? 1 : 3); | |
272a527c KY |
5346 | } |
5347 | ||
5348 | static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res) | |
5349 | { | |
5350 | /* Looks like the unsol event is incompatible with the standard | |
5351 | * definition. 4bit tag is placed at 26 bit! | |
5352 | */ | |
5353 | if (((res >> 26) == ALC880_HP_EVENT)) { | |
5354 | alc882_targa_automute(codec); | |
5355 | } | |
5356 | } | |
5357 | ||
5358 | static struct hda_verb alc882_asus_a7j_verbs[] = { | |
5359 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5360 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5361 | ||
5362 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5363 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5364 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5365 | ||
5366 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ | |
5367 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
5368 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ | |
5369 | ||
5370 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
5371 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
5372 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
5373 | { } /* end */ | |
5374 | }; | |
5375 | ||
9102cd1c TD |
5376 | static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) |
5377 | { | |
5378 | unsigned int gpiostate, gpiomask, gpiodir; | |
5379 | ||
5380 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, | |
5381 | AC_VERB_GET_GPIO_DATA, 0); | |
5382 | ||
5383 | if (!muted) | |
5384 | gpiostate |= (1 << pin); | |
5385 | else | |
5386 | gpiostate &= ~(1 << pin); | |
5387 | ||
5388 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, | |
5389 | AC_VERB_GET_GPIO_MASK, 0); | |
5390 | gpiomask |= (1 << pin); | |
5391 | ||
5392 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, | |
5393 | AC_VERB_GET_GPIO_DIRECTION, 0); | |
5394 | gpiodir |= (1 << pin); | |
5395 | ||
5396 | ||
5397 | snd_hda_codec_write(codec, codec->afg, 0, | |
5398 | AC_VERB_SET_GPIO_MASK, gpiomask); | |
5399 | snd_hda_codec_write(codec, codec->afg, 0, | |
5400 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); | |
5401 | ||
5402 | msleep(1); | |
5403 | ||
5404 | snd_hda_codec_write(codec, codec->afg, 0, | |
5405 | AC_VERB_SET_GPIO_DATA, gpiostate); | |
5406 | } | |
5407 | ||
7debbe51 TI |
5408 | /* set up GPIO at initialization */ |
5409 | static void alc885_macpro_init_hook(struct hda_codec *codec) | |
5410 | { | |
5411 | alc882_gpio_mute(codec, 0, 0); | |
5412 | alc882_gpio_mute(codec, 1, 0); | |
5413 | } | |
5414 | ||
5415 | /* set up GPIO and update auto-muting at initialization */ | |
5416 | static void alc885_imac24_init_hook(struct hda_codec *codec) | |
5417 | { | |
5418 | alc885_macpro_init_hook(codec); | |
5419 | alc885_imac24_automute(codec); | |
5420 | } | |
5421 | ||
df694daa KY |
5422 | /* |
5423 | * generic initialization of ADC, input mixers and output mixers | |
5424 | */ | |
5425 | static struct hda_verb alc882_auto_init_verbs[] = { | |
5426 | /* | |
5427 | * Unmute ADC0-2 and set the default input to mic-in | |
5428 | */ | |
5429 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5430 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5431 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5432 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5433 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5434 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
1da177e4 | 5435 | |
cb53c626 | 5436 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
df694daa | 5437 | * mixer widget |
f12ab1e0 TI |
5438 | * Note: PASD motherboards uses the Line In 2 as the input for |
5439 | * front panel mic (mic 2) | |
df694daa KY |
5440 | */ |
5441 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
5442 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
5443 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5444 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5445 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5446 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
e9edcee0 | 5447 | |
df694daa KY |
5448 | /* |
5449 | * Set up output mixers (0x0c - 0x0f) | |
5450 | */ | |
5451 | /* set vol=0 to output mixers */ | |
5452 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5453 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5454 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5455 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5456 | /* set up input amps for analog loopback */ | |
5457 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
5458 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5459 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5460 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5461 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5462 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5463 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5464 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5465 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5466 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5467 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5468 | ||
5469 | /* FIXME: use matrix-type input source selection */ | |
5470 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
5471 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
5472 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
5473 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
5474 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
5475 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
5476 | /* Input mixer2 */ | |
5477 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
5478 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
5479 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
5480 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
5481 | /* Input mixer3 */ | |
5482 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
5483 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
5484 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
5485 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
5486 | ||
5487 | { } | |
5488 | }; | |
5489 | ||
5490 | /* capture mixer elements */ | |
5491 | static struct snd_kcontrol_new alc882_capture_alt_mixer[] = { | |
5492 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
5493 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
5494 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
5495 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
5496 | { | |
5497 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5498 | /* The multiple "Capture Source" controls confuse alsamixer | |
5499 | * So call somewhat different.. | |
5500 | * FIXME: the controls appear in the "playback" view! | |
5501 | */ | |
5502 | /* .name = "Capture Source", */ | |
5503 | .name = "Input Source", | |
5504 | .count = 2, | |
5505 | .info = alc882_mux_enum_info, | |
5506 | .get = alc882_mux_enum_get, | |
5507 | .put = alc882_mux_enum_put, | |
5508 | }, | |
5509 | { } /* end */ | |
5510 | }; | |
5511 | ||
5512 | static struct snd_kcontrol_new alc882_capture_mixer[] = { | |
5513 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), | |
5514 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), | |
5515 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), | |
5516 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), | |
5517 | HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), | |
5518 | HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), | |
5519 | { | |
5520 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5521 | /* The multiple "Capture Source" controls confuse alsamixer | |
5522 | * So call somewhat different.. | |
5523 | * FIXME: the controls appear in the "playback" view! | |
5524 | */ | |
5525 | /* .name = "Capture Source", */ | |
5526 | .name = "Input Source", | |
5527 | .count = 3, | |
5528 | .info = alc882_mux_enum_info, | |
5529 | .get = alc882_mux_enum_get, | |
5530 | .put = alc882_mux_enum_put, | |
5531 | }, | |
5532 | { } /* end */ | |
5533 | }; | |
5534 | ||
cb53c626 TI |
5535 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
5536 | #define alc882_loopbacks alc880_loopbacks | |
5537 | #endif | |
5538 | ||
df694daa KY |
5539 | /* pcm configuration: identiacal with ALC880 */ |
5540 | #define alc882_pcm_analog_playback alc880_pcm_analog_playback | |
5541 | #define alc882_pcm_analog_capture alc880_pcm_analog_capture | |
5542 | #define alc882_pcm_digital_playback alc880_pcm_digital_playback | |
5543 | #define alc882_pcm_digital_capture alc880_pcm_digital_capture | |
5544 | ||
5545 | /* | |
5546 | * configuration and preset | |
5547 | */ | |
f5fcc13c TI |
5548 | static const char *alc882_models[ALC882_MODEL_LAST] = { |
5549 | [ALC882_3ST_DIG] = "3stack-dig", | |
5550 | [ALC882_6ST_DIG] = "6stack-dig", | |
5551 | [ALC882_ARIMA] = "arima", | |
bdd148a3 | 5552 | [ALC882_W2JC] = "w2jc", |
9102cd1c | 5553 | [ALC885_MACPRO] = "macpro", |
87350ad0 | 5554 | [ALC885_MBP3] = "mbp3", |
c54728d8 | 5555 | [ALC885_IMAC24] = "imac24", |
f5fcc13c TI |
5556 | [ALC882_AUTO] = "auto", |
5557 | }; | |
5558 | ||
5559 | static struct snd_pci_quirk alc882_cfg_tbl[] = { | |
5560 | SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG), | |
5561 | SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG), | |
5562 | SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG), | |
272a527c | 5563 | SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */ |
f5fcc13c | 5564 | SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), |
272a527c | 5565 | SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J), |
c5d9f1cd | 5566 | SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG), |
7b9470d8 | 5567 | SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG), |
bdd148a3 | 5568 | SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC), |
df694daa KY |
5569 | {} |
5570 | }; | |
5571 | ||
5572 | static struct alc_config_preset alc882_presets[] = { | |
5573 | [ALC882_3ST_DIG] = { | |
5574 | .mixers = { alc882_base_mixer }, | |
5575 | .init_verbs = { alc882_init_verbs }, | |
5576 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
5577 | .dac_nids = alc882_dac_nids, | |
5578 | .dig_out_nid = ALC882_DIGOUT_NID, | |
df694daa KY |
5579 | .dig_in_nid = ALC882_DIGIN_NID, |
5580 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | |
5581 | .channel_mode = alc882_ch_modes, | |
4e195a7b | 5582 | .need_dac_fix = 1, |
df694daa KY |
5583 | .input_mux = &alc882_capture_source, |
5584 | }, | |
5585 | [ALC882_6ST_DIG] = { | |
5586 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, | |
5587 | .init_verbs = { alc882_init_verbs }, | |
5588 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
5589 | .dac_nids = alc882_dac_nids, | |
5590 | .dig_out_nid = ALC882_DIGOUT_NID, | |
df694daa KY |
5591 | .dig_in_nid = ALC882_DIGIN_NID, |
5592 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), | |
5593 | .channel_mode = alc882_sixstack_modes, | |
5594 | .input_mux = &alc882_capture_source, | |
5595 | }, | |
4b146cb0 TI |
5596 | [ALC882_ARIMA] = { |
5597 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, | |
5598 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs }, | |
5599 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
5600 | .dac_nids = alc882_dac_nids, | |
5601 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), | |
5602 | .channel_mode = alc882_sixstack_modes, | |
5603 | .input_mux = &alc882_capture_source, | |
5604 | }, | |
bdd148a3 KY |
5605 | [ALC882_W2JC] = { |
5606 | .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer }, | |
5607 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs, | |
5608 | alc880_gpio1_init_verbs }, | |
5609 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
5610 | .dac_nids = alc882_dac_nids, | |
5611 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
5612 | .channel_mode = alc880_threestack_modes, | |
5613 | .need_dac_fix = 1, | |
5614 | .input_mux = &alc882_capture_source, | |
5615 | .dig_out_nid = ALC882_DIGOUT_NID, | |
5616 | }, | |
87350ad0 TI |
5617 | [ALC885_MBP3] = { |
5618 | .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer }, | |
5619 | .init_verbs = { alc885_mbp3_init_verbs, | |
5620 | alc880_gpio1_init_verbs }, | |
5621 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
5622 | .dac_nids = alc882_dac_nids, | |
5623 | .channel_mode = alc885_mbp_6ch_modes, | |
5624 | .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes), | |
5625 | .input_mux = &alc882_capture_source, | |
5626 | .dig_out_nid = ALC882_DIGOUT_NID, | |
5627 | .dig_in_nid = ALC882_DIGIN_NID, | |
5628 | .unsol_event = alc885_mbp3_unsol_event, | |
5629 | .init_hook = alc885_mbp3_automute, | |
5630 | }, | |
9102cd1c TD |
5631 | [ALC885_MACPRO] = { |
5632 | .mixers = { alc882_macpro_mixer }, | |
5633 | .init_verbs = { alc882_macpro_init_verbs }, | |
5634 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
5635 | .dac_nids = alc882_dac_nids, | |
5636 | .dig_out_nid = ALC882_DIGOUT_NID, | |
5637 | .dig_in_nid = ALC882_DIGIN_NID, | |
5638 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | |
5639 | .channel_mode = alc882_ch_modes, | |
5640 | .input_mux = &alc882_capture_source, | |
7debbe51 | 5641 | .init_hook = alc885_macpro_init_hook, |
9102cd1c | 5642 | }, |
c54728d8 NF |
5643 | [ALC885_IMAC24] = { |
5644 | .mixers = { alc885_imac24_mixer }, | |
5645 | .init_verbs = { alc885_imac24_init_verbs }, | |
5646 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
5647 | .dac_nids = alc882_dac_nids, | |
5648 | .dig_out_nid = ALC882_DIGOUT_NID, | |
5649 | .dig_in_nid = ALC882_DIGIN_NID, | |
5650 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | |
5651 | .channel_mode = alc882_ch_modes, | |
5652 | .input_mux = &alc882_capture_source, | |
5653 | .unsol_event = alc885_imac24_unsol_event, | |
7debbe51 | 5654 | .init_hook = alc885_imac24_init_hook, |
c54728d8 | 5655 | }, |
272a527c KY |
5656 | [ALC882_TARGA] = { |
5657 | .mixers = { alc882_targa_mixer, alc882_chmode_mixer, | |
5658 | alc882_capture_mixer }, | |
5659 | .init_verbs = { alc882_init_verbs, alc882_targa_verbs}, | |
5660 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
5661 | .dac_nids = alc882_dac_nids, | |
5662 | .dig_out_nid = ALC882_DIGOUT_NID, | |
5663 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), | |
5664 | .adc_nids = alc882_adc_nids, | |
5665 | .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), | |
5666 | .channel_mode = alc882_3ST_6ch_modes, | |
5667 | .need_dac_fix = 1, | |
5668 | .input_mux = &alc882_capture_source, | |
5669 | .unsol_event = alc882_targa_unsol_event, | |
5670 | .init_hook = alc882_targa_automute, | |
5671 | }, | |
5672 | [ALC882_ASUS_A7J] = { | |
5673 | .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer, | |
5674 | alc882_capture_mixer }, | |
5675 | .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs}, | |
5676 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
5677 | .dac_nids = alc882_dac_nids, | |
5678 | .dig_out_nid = ALC882_DIGOUT_NID, | |
5679 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), | |
5680 | .adc_nids = alc882_adc_nids, | |
5681 | .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), | |
5682 | .channel_mode = alc882_3ST_6ch_modes, | |
5683 | .need_dac_fix = 1, | |
5684 | .input_mux = &alc882_capture_source, | |
5685 | }, | |
df694daa KY |
5686 | }; |
5687 | ||
5688 | ||
f95474ec TI |
5689 | /* |
5690 | * Pin config fixes | |
5691 | */ | |
5692 | enum { | |
5693 | PINFIX_ABIT_AW9D_MAX | |
5694 | }; | |
5695 | ||
5696 | static struct alc_pincfg alc882_abit_aw9d_pinfix[] = { | |
5697 | { 0x15, 0x01080104 }, /* side */ | |
5698 | { 0x16, 0x01011012 }, /* rear */ | |
5699 | { 0x17, 0x01016011 }, /* clfe */ | |
5700 | { } | |
5701 | }; | |
5702 | ||
5703 | static const struct alc_pincfg *alc882_pin_fixes[] = { | |
5704 | [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix, | |
5705 | }; | |
5706 | ||
5707 | static struct snd_pci_quirk alc882_pinfix_tbl[] = { | |
5708 | SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX), | |
5709 | {} | |
5710 | }; | |
5711 | ||
df694daa KY |
5712 | /* |
5713 | * BIOS auto configuration | |
5714 | */ | |
5715 | static void alc882_auto_set_output_and_unmute(struct hda_codec *codec, | |
5716 | hda_nid_t nid, int pin_type, | |
5717 | int dac_idx) | |
5718 | { | |
5719 | /* set as output */ | |
5720 | struct alc_spec *spec = codec->spec; | |
f12ab1e0 TI |
5721 | int idx; |
5722 | ||
df694daa KY |
5723 | if (spec->multiout.dac_nids[dac_idx] == 0x25) |
5724 | idx = 4; | |
5725 | else | |
5726 | idx = spec->multiout.dac_nids[dac_idx] - 2; | |
5727 | ||
f12ab1e0 TI |
5728 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
5729 | pin_type); | |
5730 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
5731 | AMP_OUT_UNMUTE); | |
df694daa KY |
5732 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); |
5733 | ||
5734 | } | |
5735 | ||
5736 | static void alc882_auto_init_multi_out(struct hda_codec *codec) | |
5737 | { | |
5738 | struct alc_spec *spec = codec->spec; | |
5739 | int i; | |
5740 | ||
bc9f98a9 | 5741 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
df694daa | 5742 | for (i = 0; i <= HDA_SIDE; i++) { |
f12ab1e0 | 5743 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
baba8ee9 | 5744 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
df694daa | 5745 | if (nid) |
baba8ee9 | 5746 | alc882_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 5747 | i); |
df694daa KY |
5748 | } |
5749 | } | |
5750 | ||
5751 | static void alc882_auto_init_hp_out(struct hda_codec *codec) | |
5752 | { | |
5753 | struct alc_spec *spec = codec->spec; | |
5754 | hda_nid_t pin; | |
5755 | ||
eb06ed8f | 5756 | pin = spec->autocfg.hp_pins[0]; |
df694daa | 5757 | if (pin) /* connect to front */ |
f12ab1e0 TI |
5758 | /* use dac 0 */ |
5759 | alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
df694daa KY |
5760 | } |
5761 | ||
5762 | #define alc882_is_input_pin(nid) alc880_is_input_pin(nid) | |
5763 | #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID | |
5764 | ||
5765 | static void alc882_auto_init_analog_input(struct hda_codec *codec) | |
5766 | { | |
5767 | struct alc_spec *spec = codec->spec; | |
5768 | int i; | |
5769 | ||
5770 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
5771 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
5772 | if (alc882_is_input_pin(nid)) { | |
f12ab1e0 TI |
5773 | snd_hda_codec_write(codec, nid, 0, |
5774 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
5775 | i <= AUTO_PIN_FRONT_MIC ? | |
5776 | PIN_VREF80 : PIN_IN); | |
df694daa | 5777 | if (nid != ALC882_PIN_CD_NID) |
f12ab1e0 TI |
5778 | snd_hda_codec_write(codec, nid, 0, |
5779 | AC_VERB_SET_AMP_GAIN_MUTE, | |
df694daa KY |
5780 | AMP_OUT_MUTE); |
5781 | } | |
5782 | } | |
5783 | } | |
5784 | ||
5785 | /* almost identical with ALC880 parser... */ | |
5786 | static int alc882_parse_auto_config(struct hda_codec *codec) | |
5787 | { | |
5788 | struct alc_spec *spec = codec->spec; | |
5789 | int err = alc880_parse_auto_config(codec); | |
5790 | ||
5791 | if (err < 0) | |
5792 | return err; | |
c5f2ea08 TI |
5793 | else if (err > 0) |
5794 | /* hack - override the init verbs */ | |
5795 | spec->init_verbs[0] = alc882_auto_init_verbs; | |
5796 | return err; | |
df694daa KY |
5797 | } |
5798 | ||
ae6b813a TI |
5799 | /* additional initialization for auto-configuration model */ |
5800 | static void alc882_auto_init(struct hda_codec *codec) | |
df694daa | 5801 | { |
df694daa KY |
5802 | alc882_auto_init_multi_out(codec); |
5803 | alc882_auto_init_hp_out(codec); | |
5804 | alc882_auto_init_analog_input(codec); | |
df694daa KY |
5805 | } |
5806 | ||
df694daa KY |
5807 | static int patch_alc882(struct hda_codec *codec) |
5808 | { | |
5809 | struct alc_spec *spec; | |
5810 | int err, board_config; | |
5811 | ||
5812 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
5813 | if (spec == NULL) | |
5814 | return -ENOMEM; | |
5815 | ||
5816 | codec->spec = spec; | |
5817 | ||
f5fcc13c TI |
5818 | board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST, |
5819 | alc882_models, | |
5820 | alc882_cfg_tbl); | |
df694daa KY |
5821 | |
5822 | if (board_config < 0 || board_config >= ALC882_MODEL_LAST) { | |
081d17c4 TD |
5823 | /* Pick up systems that don't supply PCI SSID */ |
5824 | switch (codec->subsystem_id) { | |
5825 | case 0x106b0c00: /* Mac Pro */ | |
5826 | board_config = ALC885_MACPRO; | |
5827 | break; | |
c54728d8 NF |
5828 | case 0x106b1000: /* iMac 24 */ |
5829 | board_config = ALC885_IMAC24; | |
5830 | break; | |
87350ad0 TI |
5831 | case 0x106b2c00: /* Macbook Pro rev3 */ |
5832 | board_config = ALC885_MBP3; | |
5833 | break; | |
081d17c4 TD |
5834 | default: |
5835 | printk(KERN_INFO "hda_codec: Unknown model for ALC882, " | |
5836 | "trying auto-probe from BIOS...\n"); | |
5837 | board_config = ALC882_AUTO; | |
5838 | } | |
df694daa KY |
5839 | } |
5840 | ||
f95474ec TI |
5841 | alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes); |
5842 | ||
df694daa KY |
5843 | if (board_config == ALC882_AUTO) { |
5844 | /* automatic parse from the BIOS config */ | |
5845 | err = alc882_parse_auto_config(codec); | |
5846 | if (err < 0) { | |
5847 | alc_free(codec); | |
5848 | return err; | |
f12ab1e0 | 5849 | } else if (!err) { |
9c7f852e TI |
5850 | printk(KERN_INFO |
5851 | "hda_codec: Cannot set up configuration " | |
5852 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
5853 | board_config = ALC882_3ST_DIG; |
5854 | } | |
5855 | } | |
5856 | ||
5857 | if (board_config != ALC882_AUTO) | |
5858 | setup_preset(spec, &alc882_presets[board_config]); | |
1da177e4 LT |
5859 | |
5860 | spec->stream_name_analog = "ALC882 Analog"; | |
df694daa KY |
5861 | spec->stream_analog_playback = &alc882_pcm_analog_playback; |
5862 | spec->stream_analog_capture = &alc882_pcm_analog_capture; | |
1da177e4 LT |
5863 | |
5864 | spec->stream_name_digital = "ALC882 Digital"; | |
df694daa KY |
5865 | spec->stream_digital_playback = &alc882_pcm_digital_playback; |
5866 | spec->stream_digital_capture = &alc882_pcm_digital_capture; | |
1da177e4 | 5867 | |
f12ab1e0 | 5868 | if (!spec->adc_nids && spec->input_mux) { |
df694daa | 5869 | /* check whether NID 0x07 is valid */ |
4a471b7d | 5870 | unsigned int wcap = get_wcaps(codec, 0x07); |
f12ab1e0 TI |
5871 | /* get type */ |
5872 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
df694daa KY |
5873 | if (wcap != AC_WID_AUD_IN) { |
5874 | spec->adc_nids = alc882_adc_nids_alt; | |
5875 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt); | |
f12ab1e0 TI |
5876 | spec->mixers[spec->num_mixers] = |
5877 | alc882_capture_alt_mixer; | |
df694daa KY |
5878 | spec->num_mixers++; |
5879 | } else { | |
5880 | spec->adc_nids = alc882_adc_nids; | |
5881 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids); | |
5882 | spec->mixers[spec->num_mixers] = alc882_capture_mixer; | |
5883 | spec->num_mixers++; | |
5884 | } | |
5885 | } | |
1da177e4 LT |
5886 | |
5887 | codec->patch_ops = alc_patch_ops; | |
df694daa | 5888 | if (board_config == ALC882_AUTO) |
ae6b813a | 5889 | spec->init_hook = alc882_auto_init; |
cb53c626 TI |
5890 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
5891 | if (!spec->loopback.amplist) | |
5892 | spec->loopback.amplist = alc882_loopbacks; | |
5893 | #endif | |
df694daa KY |
5894 | |
5895 | return 0; | |
5896 | } | |
5897 | ||
5898 | /* | |
9c7f852e TI |
5899 | * ALC883 support |
5900 | * | |
5901 | * ALC883 is almost identical with ALC880 but has cleaner and more flexible | |
5902 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
5903 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
5904 | * 6-channel independent captures. | |
5905 | * | |
5906 | * In addition, an independent DAC for the multi-playback (not used in this | |
5907 | * driver yet). | |
df694daa | 5908 | */ |
9c7f852e TI |
5909 | #define ALC883_DIGOUT_NID 0x06 |
5910 | #define ALC883_DIGIN_NID 0x0a | |
df694daa | 5911 | |
9c7f852e TI |
5912 | static hda_nid_t alc883_dac_nids[4] = { |
5913 | /* front, rear, clfe, rear_surr */ | |
5914 | 0x02, 0x04, 0x03, 0x05 | |
5915 | }; | |
df694daa | 5916 | |
9c7f852e TI |
5917 | static hda_nid_t alc883_adc_nids[2] = { |
5918 | /* ADC1-2 */ | |
5919 | 0x08, 0x09, | |
5920 | }; | |
f12ab1e0 | 5921 | |
9c7f852e TI |
5922 | /* input MUX */ |
5923 | /* FIXME: should be a matrix-type input source selection */ | |
df694daa | 5924 | |
9c7f852e TI |
5925 | static struct hda_input_mux alc883_capture_source = { |
5926 | .num_items = 4, | |
5927 | .items = { | |
5928 | { "Mic", 0x0 }, | |
5929 | { "Front Mic", 0x1 }, | |
5930 | { "Line", 0x2 }, | |
5931 | { "CD", 0x4 }, | |
5932 | }, | |
5933 | }; | |
bc9f98a9 KY |
5934 | |
5935 | static struct hda_input_mux alc883_lenovo_101e_capture_source = { | |
5936 | .num_items = 2, | |
5937 | .items = { | |
5938 | { "Mic", 0x1 }, | |
5939 | { "Line", 0x2 }, | |
5940 | }, | |
5941 | }; | |
5942 | ||
272a527c KY |
5943 | static struct hda_input_mux alc883_lenovo_nb0763_capture_source = { |
5944 | .num_items = 4, | |
5945 | .items = { | |
5946 | { "Mic", 0x0 }, | |
5947 | { "iMic", 0x1 }, | |
5948 | { "Line", 0x2 }, | |
5949 | { "CD", 0x4 }, | |
5950 | }, | |
5951 | }; | |
5952 | ||
9c7f852e TI |
5953 | #define alc883_mux_enum_info alc_mux_enum_info |
5954 | #define alc883_mux_enum_get alc_mux_enum_get | |
df694daa | 5955 | |
9c7f852e TI |
5956 | static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol, |
5957 | struct snd_ctl_elem_value *ucontrol) | |
5958 | { | |
5959 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
5960 | struct alc_spec *spec = codec->spec; | |
5961 | const struct hda_input_mux *imux = spec->input_mux; | |
5962 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
5963 | static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 }; | |
5964 | hda_nid_t nid = capture_mixers[adc_idx]; | |
5965 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; | |
5966 | unsigned int i, idx; | |
5967 | ||
5968 | idx = ucontrol->value.enumerated.item[0]; | |
5969 | if (idx >= imux->num_items) | |
5970 | idx = imux->num_items - 1; | |
82beb8fd | 5971 | if (*cur_val == idx) |
9c7f852e TI |
5972 | return 0; |
5973 | for (i = 0; i < imux->num_items; i++) { | |
47fd830a TI |
5974 | unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE; |
5975 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, | |
82beb8fd | 5976 | imux->items[i].index, |
47fd830a | 5977 | HDA_AMP_MUTE, v); |
9c7f852e TI |
5978 | } |
5979 | *cur_val = idx; | |
5980 | return 1; | |
5981 | } | |
f12ab1e0 | 5982 | |
9c7f852e TI |
5983 | /* |
5984 | * 2ch mode | |
5985 | */ | |
5986 | static struct hda_channel_mode alc883_3ST_2ch_modes[1] = { | |
5987 | { 2, NULL } | |
5988 | }; | |
5989 | ||
5990 | /* | |
5991 | * 2ch mode | |
5992 | */ | |
5993 | static struct hda_verb alc883_3ST_ch2_init[] = { | |
5994 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
5995 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
5996 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
5997 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
5998 | { } /* end */ | |
5999 | }; | |
6000 | ||
6001 | /* | |
6002 | * 6ch mode | |
6003 | */ | |
6004 | static struct hda_verb alc883_3ST_ch6_init[] = { | |
6005 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6006 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
6007 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
6008 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6009 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
6010 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
6011 | { } /* end */ | |
6012 | }; | |
6013 | ||
6014 | static struct hda_channel_mode alc883_3ST_6ch_modes[2] = { | |
6015 | { 2, alc883_3ST_ch2_init }, | |
6016 | { 6, alc883_3ST_ch6_init }, | |
6017 | }; | |
6018 | ||
6019 | /* | |
6020 | * 6ch mode | |
6021 | */ | |
6022 | static struct hda_verb alc883_sixstack_ch6_init[] = { | |
6023 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
6024 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6025 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6026 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6027 | { } /* end */ | |
6028 | }; | |
6029 | ||
6030 | /* | |
6031 | * 8ch mode | |
6032 | */ | |
6033 | static struct hda_verb alc883_sixstack_ch8_init[] = { | |
6034 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6035 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6036 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6037 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6038 | { } /* end */ | |
6039 | }; | |
6040 | ||
6041 | static struct hda_channel_mode alc883_sixstack_modes[2] = { | |
6042 | { 6, alc883_sixstack_ch6_init }, | |
6043 | { 8, alc883_sixstack_ch8_init }, | |
6044 | }; | |
6045 | ||
b373bdeb AN |
6046 | static struct hda_verb alc883_medion_eapd_verbs[] = { |
6047 | /* eanable EAPD on medion laptop */ | |
6048 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
6049 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
6050 | { } | |
6051 | }; | |
6052 | ||
9c7f852e TI |
6053 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
6054 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
6055 | */ | |
6056 | ||
6057 | static struct snd_kcontrol_new alc883_base_mixer[] = { | |
df694daa | 6058 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9c7f852e TI |
6059 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
6060 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
6061 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
6062 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
6063 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
6064 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
6065 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
6066 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
6067 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
6068 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
df694daa KY |
6069 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
6070 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6071 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6072 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6073 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 6074 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
df694daa | 6075 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
9c7f852e | 6076 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
32360416 | 6077 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
6078 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
6079 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
6080 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
6081 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6082 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6083 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6084 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6085 | { | |
6086 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6087 | /* .name = "Capture Source", */ | |
6088 | .name = "Input Source", | |
6089 | .count = 2, | |
6090 | .info = alc883_mux_enum_info, | |
6091 | .get = alc883_mux_enum_get, | |
6092 | .put = alc883_mux_enum_put, | |
6093 | }, | |
df694daa | 6094 | { } /* end */ |
834be88d TI |
6095 | }; |
6096 | ||
9c7f852e TI |
6097 | static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = { |
6098 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6099 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
6100 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6101 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6102 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6103 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6104 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6105 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 6106 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
6107 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
6108 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 6109 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
6110 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
6111 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
6112 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
6113 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6114 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6115 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6116 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6117 | { | |
6118 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6119 | /* .name = "Capture Source", */ | |
6120 | .name = "Input Source", | |
6121 | .count = 2, | |
6122 | .info = alc883_mux_enum_info, | |
6123 | .get = alc883_mux_enum_get, | |
6124 | .put = alc883_mux_enum_put, | |
6125 | }, | |
6126 | { } /* end */ | |
6127 | }; | |
df694daa | 6128 | |
9c7f852e TI |
6129 | static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = { |
6130 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6131 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
6132 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
6133 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
6134 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
6135 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
6136 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
6137 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
6138 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6139 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6140 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6141 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6142 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6143 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 6144 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
6145 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
6146 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 6147 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
6148 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
6149 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
6150 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
6151 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6152 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6153 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6154 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6155 | { | |
6156 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6157 | /* .name = "Capture Source", */ | |
6158 | .name = "Input Source", | |
6159 | .count = 2, | |
6160 | .info = alc883_mux_enum_info, | |
6161 | .get = alc883_mux_enum_get, | |
6162 | .put = alc883_mux_enum_put, | |
6163 | }, | |
6164 | { } /* end */ | |
6165 | }; | |
6166 | ||
d1d985f0 | 6167 | static struct snd_kcontrol_new alc883_fivestack_mixer[] = { |
c07584c8 TD |
6168 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
6169 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
6170 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
6171 | HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
6172 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
6173 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
6174 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT), | |
6175 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | |
6176 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6177 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6178 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6179 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6180 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6181 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 6182 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
c07584c8 TD |
6183 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
6184 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 6185 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
c07584c8 TD |
6186 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
6187 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
6188 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
6189 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6190 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6191 | ||
6192 | { | |
6193 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6194 | /* .name = "Capture Source", */ | |
6195 | .name = "Input Source", | |
6196 | .count = 1, | |
6197 | .info = alc883_mux_enum_info, | |
6198 | .get = alc883_mux_enum_get, | |
6199 | .put = alc883_mux_enum_put, | |
6200 | }, | |
6201 | { } /* end */ | |
6202 | }; | |
6203 | ||
ccc656ce KY |
6204 | static struct snd_kcontrol_new alc883_tagra_mixer[] = { |
6205 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6206 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
6207 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6208 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
6209 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
6210 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
6211 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
6212 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
6213 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
6214 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6215 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6216 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6217 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6218 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 6219 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce KY |
6220 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
6221 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6222 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6223 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6224 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6225 | { | |
6226 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6227 | /* .name = "Capture Source", */ | |
6228 | .name = "Input Source", | |
6229 | .count = 2, | |
6230 | .info = alc883_mux_enum_info, | |
6231 | .get = alc883_mux_enum_get, | |
6232 | .put = alc883_mux_enum_put, | |
6233 | }, | |
6234 | { } /* end */ | |
f12ab1e0 | 6235 | }; |
ccc656ce KY |
6236 | |
6237 | static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = { | |
6238 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6239 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
6240 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6241 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6242 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6243 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 6244 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce KY |
6245 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
6246 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6247 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6248 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6249 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6250 | { | |
6251 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6252 | /* .name = "Capture Source", */ | |
6253 | .name = "Input Source", | |
6254 | .count = 2, | |
6255 | .info = alc883_mux_enum_info, | |
6256 | .get = alc883_mux_enum_get, | |
6257 | .put = alc883_mux_enum_put, | |
6258 | }, | |
6259 | { } /* end */ | |
f12ab1e0 | 6260 | }; |
ccc656ce | 6261 | |
bc9f98a9 KY |
6262 | static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = { |
6263 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6264 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
6265 | HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
6266 | HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
6267 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6268 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
6269 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
6270 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
6271 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6272 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6273 | { | |
6274 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6275 | /* .name = "Capture Source", */ | |
6276 | .name = "Input Source", | |
6277 | .count = 1, | |
6278 | .info = alc883_mux_enum_info, | |
6279 | .get = alc883_mux_enum_get, | |
6280 | .put = alc883_mux_enum_put, | |
6281 | }, | |
6282 | { } /* end */ | |
f12ab1e0 | 6283 | }; |
bc9f98a9 | 6284 | |
272a527c KY |
6285 | static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = { |
6286 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6287 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT), | |
6288 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
6289 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6290 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6291 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6292 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
6293 | HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
6294 | HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
6295 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6296 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6297 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6298 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6299 | { | |
6300 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6301 | /* .name = "Capture Source", */ | |
6302 | .name = "Input Source", | |
6303 | .count = 2, | |
6304 | .info = alc883_mux_enum_info, | |
6305 | .get = alc883_mux_enum_get, | |
6306 | .put = alc883_mux_enum_put, | |
6307 | }, | |
6308 | { } /* end */ | |
6309 | }; | |
6310 | ||
6311 | static struct snd_kcontrol_new alc883_medion_md2_mixer[] = { | |
6312 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6313 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
6314 | HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
6315 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6316 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6317 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6318 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
6319 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6320 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6321 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6322 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6323 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6324 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6325 | { | |
6326 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6327 | /* .name = "Capture Source", */ | |
6328 | .name = "Input Source", | |
6329 | .count = 2, | |
6330 | .info = alc883_mux_enum_info, | |
6331 | .get = alc883_mux_enum_get, | |
6332 | .put = alc883_mux_enum_put, | |
6333 | }, | |
6334 | { } /* end */ | |
6335 | }; | |
6336 | ||
4723c022 | 6337 | static struct snd_kcontrol_new alc888_6st_hp_mixer[] = { |
cd1e3b40 CM |
6338 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
6339 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
6340 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT), | |
6341 | HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT), | |
6342 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), | |
6343 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT), | |
6344 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT), | |
6345 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), | |
6346 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
6347 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
6348 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6349 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6350 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6351 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6352 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6353 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6354 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
6355 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
6356 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
6357 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
6358 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
6359 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
6360 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
6361 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6362 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6363 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6364 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6365 | { | |
6366 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6367 | /* .name = "Capture Source", */ | |
6368 | .name = "Input Source", | |
6369 | .count = 2, | |
6370 | .info = alc883_mux_enum_info, | |
6371 | .get = alc883_mux_enum_get, | |
6372 | .put = alc883_mux_enum_put, | |
6373 | }, | |
6374 | { } /* end */ | |
6375 | }; | |
6376 | ||
4723c022 | 6377 | static struct snd_kcontrol_new alc888_3st_hp_mixer[] = { |
8341de60 CM |
6378 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
6379 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
6380 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT), | |
6381 | HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT), | |
6382 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), | |
6383 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT), | |
6384 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT), | |
6385 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), | |
6386 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6387 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6388 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6389 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6390 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6391 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6392 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
6393 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
6394 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
6395 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
6396 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
6397 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
6398 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
6399 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6400 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6401 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6402 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6403 | { | |
6404 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6405 | /* .name = "Capture Source", */ | |
6406 | .name = "Input Source", | |
6407 | .count = 2, | |
6408 | .info = alc883_mux_enum_info, | |
6409 | .get = alc883_mux_enum_get, | |
6410 | .put = alc883_mux_enum_put, | |
6411 | }, | |
6412 | { } /* end */ | |
6413 | }; | |
6414 | ||
2880a867 | 6415 | static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = { |
d1a991a6 KY |
6416 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
6417 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
2880a867 | 6418 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), |
2880a867 TD |
6419 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
6420 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
d1a991a6 KY |
6421 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
6422 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
6423 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2880a867 TD |
6424 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
6425 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6426 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6427 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6428 | { | |
6429 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6430 | /* .name = "Capture Source", */ | |
6431 | .name = "Input Source", | |
6432 | .count = 2, | |
6433 | .info = alc883_mux_enum_info, | |
6434 | .get = alc883_mux_enum_get, | |
6435 | .put = alc883_mux_enum_put, | |
6436 | }, | |
6437 | { } /* end */ | |
d1a991a6 | 6438 | }; |
2880a867 | 6439 | |
9c7f852e TI |
6440 | static struct snd_kcontrol_new alc883_chmode_mixer[] = { |
6441 | { | |
6442 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6443 | .name = "Channel Mode", | |
6444 | .info = alc_ch_mode_info, | |
6445 | .get = alc_ch_mode_get, | |
6446 | .put = alc_ch_mode_put, | |
6447 | }, | |
6448 | { } /* end */ | |
6449 | }; | |
6450 | ||
6451 | static struct hda_verb alc883_init_verbs[] = { | |
6452 | /* ADC1: mute amp left and right */ | |
6453 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
df694daa | 6454 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
9c7f852e TI |
6455 | /* ADC2: mute amp left and right */ |
6456 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
df694daa | 6457 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
9c7f852e TI |
6458 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ |
6459 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6460 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6461 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
6462 | /* Rear mixer */ | |
6463 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6464 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6465 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
6466 | /* CLFE mixer */ | |
6467 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6468 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6469 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
6470 | /* Side mixer */ | |
6471 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6472 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6473 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
df694daa | 6474 | |
cb53c626 TI |
6475 | /* mute analog input loopbacks */ |
6476 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6477 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
6478 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6479 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6480 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa | 6481 | |
9c7f852e TI |
6482 | /* Front Pin: output 0 (0x0c) */ |
6483 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6484 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6485 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6486 | /* Rear Pin: output 1 (0x0d) */ | |
6487 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6488 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6489 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
6490 | /* CLFE Pin: output 2 (0x0e) */ | |
6491 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6492 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6493 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
6494 | /* Side Pin: output 3 (0x0f) */ | |
6495 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6496 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6497 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
6498 | /* Mic (rear) pin: input vref at 80% */ | |
6499 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
6500 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
6501 | /* Front Mic pin: input vref at 80% */ | |
6502 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
6503 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
6504 | /* Line In pin: input */ | |
6505 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
6506 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
6507 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
6508 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6509 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6510 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6511 | /* CD pin widget for input */ | |
6512 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
6513 | ||
6514 | /* FIXME: use matrix-type input source selection */ | |
6515 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
6516 | /* Input mixer2 */ | |
6517 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6518 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6519 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
6520 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
6521 | /* Input mixer3 */ | |
6522 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6523 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6524 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
6525 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
6526 | { } | |
6527 | }; | |
6528 | ||
ccc656ce KY |
6529 | static struct hda_verb alc883_tagra_verbs[] = { |
6530 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6531 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6532 | ||
6533 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6534 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6535 | ||
6536 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
6537 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
6538 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
6539 | ||
6540 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
f12ab1e0 TI |
6541 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
6542 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | |
6543 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | |
ccc656ce KY |
6544 | |
6545 | { } /* end */ | |
6546 | }; | |
6547 | ||
bc9f98a9 KY |
6548 | static struct hda_verb alc883_lenovo_101e_verbs[] = { |
6549 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6550 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN}, | |
6551 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN}, | |
6552 | { } /* end */ | |
6553 | }; | |
6554 | ||
272a527c KY |
6555 | static struct hda_verb alc883_lenovo_nb0763_verbs[] = { |
6556 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6557 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6558 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
6559 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6560 | { } /* end */ | |
6561 | }; | |
6562 | ||
6563 | static struct hda_verb alc888_lenovo_ms7195_verbs[] = { | |
6564 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6565 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6566 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6567 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN}, | |
6568 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
6569 | { } /* end */ | |
6570 | }; | |
6571 | ||
189609ae KY |
6572 | static struct hda_verb alc883_haier_w66_verbs[] = { |
6573 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6574 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6575 | ||
6576 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6577 | ||
6578 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6579 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6580 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
6581 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6582 | { } /* end */ | |
6583 | }; | |
6584 | ||
4723c022 | 6585 | static struct hda_verb alc888_6st_hp_verbs[] = { |
cd1e3b40 CM |
6586 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */ |
6587 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */ | |
6588 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */ | |
6589 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */ | |
6590 | { } | |
6591 | }; | |
6592 | ||
4723c022 | 6593 | static struct hda_verb alc888_3st_hp_verbs[] = { |
8341de60 CM |
6594 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */ |
6595 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */ | |
6596 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */ | |
6597 | { } | |
6598 | }; | |
6599 | ||
4723c022 | 6600 | static struct hda_verb alc888_3st_hp_2ch_init[] = { |
8341de60 CM |
6601 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
6602 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
6603 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
6604 | { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
6605 | { } | |
6606 | }; | |
6607 | ||
4723c022 | 6608 | static struct hda_verb alc888_3st_hp_6ch_init[] = { |
8341de60 CM |
6609 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
6610 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
6611 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6612 | { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
6613 | { } | |
6614 | }; | |
6615 | ||
4723c022 CM |
6616 | static struct hda_channel_mode alc888_3st_hp_modes[2] = { |
6617 | { 2, alc888_3st_hp_2ch_init }, | |
6618 | { 6, alc888_3st_hp_6ch_init }, | |
8341de60 CM |
6619 | }; |
6620 | ||
272a527c KY |
6621 | /* toggle front-jack and RCA according to the hp-jack state */ |
6622 | static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec) | |
6623 | { | |
6624 | unsigned int present; | |
6625 | ||
6626 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
6627 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
6628 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
6629 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
6630 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
6631 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c KY |
6632 | } |
6633 | ||
6634 | /* toggle RCA according to the front-jack state */ | |
6635 | static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec) | |
6636 | { | |
6637 | unsigned int present; | |
6638 | ||
6639 | present = snd_hda_codec_read(codec, 0x14, 0, | |
6640 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
6641 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
6642 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c | 6643 | } |
47fd830a | 6644 | |
272a527c KY |
6645 | static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec, |
6646 | unsigned int res) | |
6647 | { | |
6648 | if ((res >> 26) == ALC880_HP_EVENT) | |
6649 | alc888_lenovo_ms7195_front_automute(codec); | |
6650 | if ((res >> 26) == ALC880_FRONT_EVENT) | |
6651 | alc888_lenovo_ms7195_rca_automute(codec); | |
6652 | } | |
6653 | ||
6654 | static struct hda_verb alc883_medion_md2_verbs[] = { | |
6655 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6656 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6657 | ||
6658 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6659 | ||
6660 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
6661 | { } /* end */ | |
6662 | }; | |
6663 | ||
6664 | /* toggle speaker-output according to the hp-jack state */ | |
6665 | static void alc883_medion_md2_automute(struct hda_codec *codec) | |
6666 | { | |
6667 | unsigned int present; | |
6668 | ||
6669 | present = snd_hda_codec_read(codec, 0x14, 0, | |
6670 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
6671 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
6672 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c KY |
6673 | } |
6674 | ||
6675 | static void alc883_medion_md2_unsol_event(struct hda_codec *codec, | |
6676 | unsigned int res) | |
6677 | { | |
6678 | if ((res >> 26) == ALC880_HP_EVENT) | |
6679 | alc883_medion_md2_automute(codec); | |
6680 | } | |
6681 | ||
ccc656ce KY |
6682 | /* toggle speaker-output according to the hp-jack state */ |
6683 | static void alc883_tagra_automute(struct hda_codec *codec) | |
6684 | { | |
6685 | unsigned int present; | |
f12ab1e0 | 6686 | unsigned char bits; |
ccc656ce KY |
6687 | |
6688 | present = snd_hda_codec_read(codec, 0x14, 0, | |
6689 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
6690 | bits = present ? HDA_AMP_MUTE : 0; |
6691 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
6692 | HDA_AMP_MUTE, bits); | |
82beb8fd TI |
6693 | snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA, |
6694 | present ? 1 : 3); | |
ccc656ce KY |
6695 | } |
6696 | ||
6697 | static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res) | |
6698 | { | |
6699 | if ((res >> 26) == ALC880_HP_EVENT) | |
6700 | alc883_tagra_automute(codec); | |
6701 | } | |
6702 | ||
189609ae KY |
6703 | static void alc883_haier_w66_automute(struct hda_codec *codec) |
6704 | { | |
6705 | unsigned int present; | |
6706 | unsigned char bits; | |
6707 | ||
6708 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
6709 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
6710 | bits = present ? 0x80 : 0; | |
6711 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
6712 | 0x80, bits); | |
6713 | } | |
6714 | ||
6715 | static void alc883_haier_w66_unsol_event(struct hda_codec *codec, | |
6716 | unsigned int res) | |
6717 | { | |
6718 | if ((res >> 26) == ALC880_HP_EVENT) | |
6719 | alc883_haier_w66_automute(codec); | |
6720 | } | |
6721 | ||
bc9f98a9 KY |
6722 | static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec) |
6723 | { | |
6724 | unsigned int present; | |
f12ab1e0 | 6725 | unsigned char bits; |
bc9f98a9 KY |
6726 | |
6727 | present = snd_hda_codec_read(codec, 0x14, 0, | |
6728 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
6729 | bits = present ? HDA_AMP_MUTE : 0; |
6730 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
6731 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
6732 | } |
6733 | ||
6734 | static void alc883_lenovo_101e_all_automute(struct hda_codec *codec) | |
6735 | { | |
6736 | unsigned int present; | |
f12ab1e0 | 6737 | unsigned char bits; |
bc9f98a9 KY |
6738 | |
6739 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
6740 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
6741 | bits = present ? HDA_AMP_MUTE : 0; |
6742 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
6743 | HDA_AMP_MUTE, bits); | |
6744 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
6745 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
6746 | } |
6747 | ||
6748 | static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec, | |
6749 | unsigned int res) | |
6750 | { | |
6751 | if ((res >> 26) == ALC880_HP_EVENT) | |
6752 | alc883_lenovo_101e_all_automute(codec); | |
6753 | if ((res >> 26) == ALC880_FRONT_EVENT) | |
6754 | alc883_lenovo_101e_ispeaker_automute(codec); | |
6755 | } | |
6756 | ||
676a9b53 TI |
6757 | /* toggle speaker-output according to the hp-jack state */ |
6758 | static void alc883_acer_aspire_automute(struct hda_codec *codec) | |
6759 | { | |
6760 | unsigned int present; | |
6761 | ||
6762 | present = snd_hda_codec_read(codec, 0x14, 0, | |
6763 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
6764 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
6765 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
6766 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
6767 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
6768 | } | |
6769 | ||
6770 | static void alc883_acer_aspire_unsol_event(struct hda_codec *codec, | |
6771 | unsigned int res) | |
6772 | { | |
6773 | if ((res >> 26) == ALC880_HP_EVENT) | |
6774 | alc883_acer_aspire_automute(codec); | |
6775 | } | |
6776 | ||
d1a991a6 KY |
6777 | static struct hda_verb alc883_acer_eapd_verbs[] = { |
6778 | /* HP Pin: output 0 (0x0c) */ | |
6779 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6780 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6781 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6782 | /* Front Pin: output 0 (0x0c) */ | |
676a9b53 TI |
6783 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
6784 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
d1a991a6 | 6785 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
d1a991a6 KY |
6786 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, |
6787 | /* eanable EAPD on medion laptop */ | |
6788 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
6789 | {0x20, AC_VERB_SET_PROC_COEF, 0x3050}, | |
676a9b53 TI |
6790 | /* enable unsolicited event */ |
6791 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
d1a991a6 KY |
6792 | { } |
6793 | }; | |
6794 | ||
9c7f852e TI |
6795 | /* |
6796 | * generic initialization of ADC, input mixers and output mixers | |
6797 | */ | |
6798 | static struct hda_verb alc883_auto_init_verbs[] = { | |
6799 | /* | |
6800 | * Unmute ADC0-2 and set the default input to mic-in | |
6801 | */ | |
6802 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6803 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6804 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6805 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6806 | ||
cb53c626 | 6807 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
9c7f852e | 6808 | * mixer widget |
f12ab1e0 TI |
6809 | * Note: PASD motherboards uses the Line In 2 as the input for |
6810 | * front panel mic (mic 2) | |
9c7f852e TI |
6811 | */ |
6812 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
6813 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
6814 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
6815 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6816 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6817 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9c7f852e TI |
6818 | |
6819 | /* | |
6820 | * Set up output mixers (0x0c - 0x0f) | |
6821 | */ | |
6822 | /* set vol=0 to output mixers */ | |
6823 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6824 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6825 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6826 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6827 | /* set up input amps for analog loopback */ | |
6828 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
6829 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6830 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6831 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6832 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6833 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6834 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6835 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6836 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6837 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6838 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6839 | ||
6840 | /* FIXME: use matrix-type input source selection */ | |
6841 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
6842 | /* Input mixer1 */ | |
6843 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6844 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6845 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 6846 | /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */ |
9c7f852e TI |
6847 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
6848 | /* Input mixer2 */ | |
6849 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6850 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6851 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 6852 | /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */ |
9c7f852e TI |
6853 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
6854 | ||
6855 | { } | |
6856 | }; | |
6857 | ||
6858 | /* capture mixer elements */ | |
6859 | static struct snd_kcontrol_new alc883_capture_mixer[] = { | |
6860 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6861 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6862 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6863 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6864 | { | |
6865 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6866 | /* The multiple "Capture Source" controls confuse alsamixer | |
6867 | * So call somewhat different.. | |
6868 | * FIXME: the controls appear in the "playback" view! | |
6869 | */ | |
6870 | /* .name = "Capture Source", */ | |
6871 | .name = "Input Source", | |
6872 | .count = 2, | |
6873 | .info = alc882_mux_enum_info, | |
6874 | .get = alc882_mux_enum_get, | |
6875 | .put = alc882_mux_enum_put, | |
6876 | }, | |
6877 | { } /* end */ | |
6878 | }; | |
6879 | ||
cb53c626 TI |
6880 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
6881 | #define alc883_loopbacks alc880_loopbacks | |
6882 | #endif | |
6883 | ||
9c7f852e TI |
6884 | /* pcm configuration: identiacal with ALC880 */ |
6885 | #define alc883_pcm_analog_playback alc880_pcm_analog_playback | |
6886 | #define alc883_pcm_analog_capture alc880_pcm_analog_capture | |
6887 | #define alc883_pcm_digital_playback alc880_pcm_digital_playback | |
6888 | #define alc883_pcm_digital_capture alc880_pcm_digital_capture | |
6889 | ||
6890 | /* | |
6891 | * configuration and preset | |
6892 | */ | |
f5fcc13c TI |
6893 | static const char *alc883_models[ALC883_MODEL_LAST] = { |
6894 | [ALC883_3ST_2ch_DIG] = "3stack-dig", | |
6895 | [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig", | |
6896 | [ALC883_3ST_6ch] = "3stack-6ch", | |
6897 | [ALC883_6ST_DIG] = "6stack-dig", | |
6898 | [ALC883_TARGA_DIG] = "targa-dig", | |
6899 | [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig", | |
f5fcc13c | 6900 | [ALC883_ACER] = "acer", |
2880a867 | 6901 | [ALC883_ACER_ASPIRE] = "acer-aspire", |
f5fcc13c | 6902 | [ALC883_MEDION] = "medion", |
272a527c | 6903 | [ALC883_MEDION_MD2] = "medion-md2", |
f5fcc13c | 6904 | [ALC883_LAPTOP_EAPD] = "laptop-eapd", |
bc9f98a9 | 6905 | [ALC883_LENOVO_101E_2ch] = "lenovo-101e", |
272a527c KY |
6906 | [ALC883_LENOVO_NB0763] = "lenovo-nb0763", |
6907 | [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig", | |
189609ae | 6908 | [ALC883_HAIER_W66] = "haier-w66", |
4723c022 CM |
6909 | [ALC888_6ST_HP] = "6stack-hp", |
6910 | [ALC888_3ST_HP] = "3stack-hp", | |
f5fcc13c TI |
6911 | [ALC883_AUTO] = "auto", |
6912 | }; | |
6913 | ||
6914 | static struct snd_pci_quirk alc883_cfg_tbl[] = { | |
6915 | SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG), | |
febe3375 | 6916 | SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG), |
f5fcc13c TI |
6917 | SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch), |
6918 | SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD), | |
6919 | SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG), | |
57b14f24 | 6920 | SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG), |
f5fcc13c TI |
6921 | SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG), |
6922 | SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG), | |
799f88a3 | 6923 | SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG), |
2a296cb6 | 6924 | SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG), |
2dcd522f | 6925 | SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG), |
6f3bf657 | 6926 | SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG), |
f5fcc13c | 6927 | SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG), |
dd146a60 | 6928 | SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG), |
f5fcc13c TI |
6929 | SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG), |
6930 | SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG), | |
6931 | SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG), | |
6932 | SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG), | |
6933 | SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG), | |
64ca1c29 | 6934 | SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG), |
f5fcc13c TI |
6935 | SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG), |
6936 | SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG), | |
6937 | SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG), | |
6938 | SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG), | |
d1a991a6 | 6939 | SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE), |
2880a867 | 6940 | SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE), |
f5fcc13c | 6941 | SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), |
e60623b4 | 6942 | SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch), |
f5fcc13c TI |
6943 | SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), |
6944 | SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD), | |
6945 | SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), | |
272a527c KY |
6946 | SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch), |
6947 | SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763), | |
6948 | SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763), | |
4723c022 CM |
6949 | SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP), |
6950 | SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP), | |
6951 | SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP), | |
272a527c | 6952 | SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2), |
189609ae KY |
6953 | SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66), |
6954 | SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763), | |
9c7f852e TI |
6955 | {} |
6956 | }; | |
6957 | ||
6958 | static struct alc_config_preset alc883_presets[] = { | |
6959 | [ALC883_3ST_2ch_DIG] = { | |
6960 | .mixers = { alc883_3ST_2ch_mixer }, | |
6961 | .init_verbs = { alc883_init_verbs }, | |
6962 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
6963 | .dac_nids = alc883_dac_nids, | |
6964 | .dig_out_nid = ALC883_DIGOUT_NID, | |
6965 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
6966 | .adc_nids = alc883_adc_nids, | |
6967 | .dig_in_nid = ALC883_DIGIN_NID, | |
6968 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
6969 | .channel_mode = alc883_3ST_2ch_modes, | |
6970 | .input_mux = &alc883_capture_source, | |
6971 | }, | |
6972 | [ALC883_3ST_6ch_DIG] = { | |
6973 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
6974 | .init_verbs = { alc883_init_verbs }, | |
6975 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
6976 | .dac_nids = alc883_dac_nids, | |
6977 | .dig_out_nid = ALC883_DIGOUT_NID, | |
6978 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
6979 | .adc_nids = alc883_adc_nids, | |
6980 | .dig_in_nid = ALC883_DIGIN_NID, | |
6981 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
6982 | .channel_mode = alc883_3ST_6ch_modes, | |
4e195a7b | 6983 | .need_dac_fix = 1, |
9c7f852e | 6984 | .input_mux = &alc883_capture_source, |
f12ab1e0 | 6985 | }, |
9c7f852e TI |
6986 | [ALC883_3ST_6ch] = { |
6987 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
6988 | .init_verbs = { alc883_init_verbs }, | |
6989 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
6990 | .dac_nids = alc883_dac_nids, | |
6991 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
6992 | .adc_nids = alc883_adc_nids, | |
6993 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
6994 | .channel_mode = alc883_3ST_6ch_modes, | |
4e195a7b | 6995 | .need_dac_fix = 1, |
9c7f852e | 6996 | .input_mux = &alc883_capture_source, |
f12ab1e0 | 6997 | }, |
9c7f852e TI |
6998 | [ALC883_6ST_DIG] = { |
6999 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, | |
7000 | .init_verbs = { alc883_init_verbs }, | |
7001 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7002 | .dac_nids = alc883_dac_nids, | |
7003 | .dig_out_nid = ALC883_DIGOUT_NID, | |
7004 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7005 | .adc_nids = alc883_adc_nids, | |
7006 | .dig_in_nid = ALC883_DIGIN_NID, | |
7007 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | |
7008 | .channel_mode = alc883_sixstack_modes, | |
7009 | .input_mux = &alc883_capture_source, | |
7010 | }, | |
ccc656ce KY |
7011 | [ALC883_TARGA_DIG] = { |
7012 | .mixers = { alc883_tagra_mixer, alc883_chmode_mixer }, | |
7013 | .init_verbs = { alc883_init_verbs, alc883_tagra_verbs}, | |
7014 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7015 | .dac_nids = alc883_dac_nids, | |
7016 | .dig_out_nid = ALC883_DIGOUT_NID, | |
7017 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7018 | .adc_nids = alc883_adc_nids, | |
7019 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
7020 | .channel_mode = alc883_3ST_6ch_modes, | |
7021 | .need_dac_fix = 1, | |
7022 | .input_mux = &alc883_capture_source, | |
7023 | .unsol_event = alc883_tagra_unsol_event, | |
7024 | .init_hook = alc883_tagra_automute, | |
7025 | }, | |
7026 | [ALC883_TARGA_2ch_DIG] = { | |
7027 | .mixers = { alc883_tagra_2ch_mixer}, | |
7028 | .init_verbs = { alc883_init_verbs, alc883_tagra_verbs}, | |
7029 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7030 | .dac_nids = alc883_dac_nids, | |
7031 | .dig_out_nid = ALC883_DIGOUT_NID, | |
7032 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7033 | .adc_nids = alc883_adc_nids, | |
7034 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
7035 | .channel_mode = alc883_3ST_2ch_modes, | |
7036 | .input_mux = &alc883_capture_source, | |
7037 | .unsol_event = alc883_tagra_unsol_event, | |
7038 | .init_hook = alc883_tagra_automute, | |
7039 | }, | |
bab282b9 | 7040 | [ALC883_ACER] = { |
676a9b53 | 7041 | .mixers = { alc883_base_mixer }, |
bab282b9 VA |
7042 | /* On TravelMate laptops, GPIO 0 enables the internal speaker |
7043 | * and the headphone jack. Turn this on and rely on the | |
7044 | * standard mute methods whenever the user wants to turn | |
7045 | * these outputs off. | |
7046 | */ | |
7047 | .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs }, | |
7048 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7049 | .dac_nids = alc883_dac_nids, | |
7050 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7051 | .adc_nids = alc883_adc_nids, | |
7052 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
7053 | .channel_mode = alc883_3ST_2ch_modes, | |
7054 | .input_mux = &alc883_capture_source, | |
7055 | }, | |
2880a867 | 7056 | [ALC883_ACER_ASPIRE] = { |
676a9b53 | 7057 | .mixers = { alc883_acer_aspire_mixer }, |
d1a991a6 | 7058 | .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs }, |
2880a867 TD |
7059 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
7060 | .dac_nids = alc883_dac_nids, | |
7061 | .dig_out_nid = ALC883_DIGOUT_NID, | |
7062 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7063 | .adc_nids = alc883_adc_nids, | |
7064 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
7065 | .channel_mode = alc883_3ST_2ch_modes, | |
7066 | .input_mux = &alc883_capture_source, | |
676a9b53 TI |
7067 | .unsol_event = alc883_acer_aspire_unsol_event, |
7068 | .init_hook = alc883_acer_aspire_automute, | |
d1a991a6 | 7069 | }, |
c07584c8 TD |
7070 | [ALC883_MEDION] = { |
7071 | .mixers = { alc883_fivestack_mixer, | |
7072 | alc883_chmode_mixer }, | |
7073 | .init_verbs = { alc883_init_verbs, | |
b373bdeb | 7074 | alc883_medion_eapd_verbs }, |
c07584c8 TD |
7075 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
7076 | .dac_nids = alc883_dac_nids, | |
7077 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7078 | .adc_nids = alc883_adc_nids, | |
7079 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | |
7080 | .channel_mode = alc883_sixstack_modes, | |
7081 | .input_mux = &alc883_capture_source, | |
b373bdeb | 7082 | }, |
272a527c KY |
7083 | [ALC883_MEDION_MD2] = { |
7084 | .mixers = { alc883_medion_md2_mixer}, | |
7085 | .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs}, | |
7086 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7087 | .dac_nids = alc883_dac_nids, | |
7088 | .dig_out_nid = ALC883_DIGOUT_NID, | |
7089 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7090 | .adc_nids = alc883_adc_nids, | |
7091 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
7092 | .channel_mode = alc883_3ST_2ch_modes, | |
7093 | .input_mux = &alc883_capture_source, | |
7094 | .unsol_event = alc883_medion_md2_unsol_event, | |
7095 | .init_hook = alc883_medion_md2_automute, | |
7096 | }, | |
b373bdeb | 7097 | [ALC883_LAPTOP_EAPD] = { |
676a9b53 | 7098 | .mixers = { alc883_base_mixer }, |
b373bdeb AN |
7099 | .init_verbs = { alc883_init_verbs, alc882_eapd_verbs }, |
7100 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7101 | .dac_nids = alc883_dac_nids, | |
7102 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7103 | .adc_nids = alc883_adc_nids, | |
7104 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
7105 | .channel_mode = alc883_3ST_2ch_modes, | |
7106 | .input_mux = &alc883_capture_source, | |
7107 | }, | |
bc9f98a9 KY |
7108 | [ALC883_LENOVO_101E_2ch] = { |
7109 | .mixers = { alc883_lenovo_101e_2ch_mixer}, | |
7110 | .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs}, | |
7111 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7112 | .dac_nids = alc883_dac_nids, | |
7113 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7114 | .adc_nids = alc883_adc_nids, | |
7115 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
7116 | .channel_mode = alc883_3ST_2ch_modes, | |
7117 | .input_mux = &alc883_lenovo_101e_capture_source, | |
7118 | .unsol_event = alc883_lenovo_101e_unsol_event, | |
7119 | .init_hook = alc883_lenovo_101e_all_automute, | |
7120 | }, | |
272a527c KY |
7121 | [ALC883_LENOVO_NB0763] = { |
7122 | .mixers = { alc883_lenovo_nb0763_mixer }, | |
7123 | .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs}, | |
7124 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7125 | .dac_nids = alc883_dac_nids, | |
7126 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7127 | .adc_nids = alc883_adc_nids, | |
7128 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
7129 | .channel_mode = alc883_3ST_2ch_modes, | |
7130 | .need_dac_fix = 1, | |
7131 | .input_mux = &alc883_lenovo_nb0763_capture_source, | |
7132 | .unsol_event = alc883_medion_md2_unsol_event, | |
7133 | .init_hook = alc883_medion_md2_automute, | |
7134 | }, | |
7135 | [ALC888_LENOVO_MS7195_DIG] = { | |
7136 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
7137 | .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs}, | |
7138 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7139 | .dac_nids = alc883_dac_nids, | |
7140 | .dig_out_nid = ALC883_DIGOUT_NID, | |
7141 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7142 | .adc_nids = alc883_adc_nids, | |
7143 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
7144 | .channel_mode = alc883_3ST_6ch_modes, | |
7145 | .need_dac_fix = 1, | |
7146 | .input_mux = &alc883_capture_source, | |
7147 | .unsol_event = alc883_lenovo_ms7195_unsol_event, | |
7148 | .init_hook = alc888_lenovo_ms7195_front_automute, | |
189609ae KY |
7149 | }, |
7150 | [ALC883_HAIER_W66] = { | |
7151 | .mixers = { alc883_tagra_2ch_mixer}, | |
7152 | .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs}, | |
7153 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7154 | .dac_nids = alc883_dac_nids, | |
7155 | .dig_out_nid = ALC883_DIGOUT_NID, | |
7156 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7157 | .adc_nids = alc883_adc_nids, | |
7158 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
7159 | .channel_mode = alc883_3ST_2ch_modes, | |
7160 | .input_mux = &alc883_capture_source, | |
7161 | .unsol_event = alc883_haier_w66_unsol_event, | |
7162 | .init_hook = alc883_haier_w66_automute, | |
272a527c | 7163 | }, |
4723c022 CM |
7164 | [ALC888_6ST_HP] = { |
7165 | .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer }, | |
7166 | .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs }, | |
cd1e3b40 CM |
7167 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
7168 | .dac_nids = alc883_dac_nids, | |
7169 | .dig_out_nid = ALC883_DIGOUT_NID, | |
7170 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7171 | .adc_nids = alc883_adc_nids, | |
7172 | .dig_in_nid = ALC883_DIGIN_NID, | |
7173 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | |
7174 | .channel_mode = alc883_sixstack_modes, | |
7175 | .input_mux = &alc883_capture_source, | |
7176 | }, | |
4723c022 CM |
7177 | [ALC888_3ST_HP] = { |
7178 | .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer }, | |
7179 | .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs }, | |
8341de60 CM |
7180 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
7181 | .dac_nids = alc883_dac_nids, | |
7182 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7183 | .adc_nids = alc883_adc_nids, | |
4723c022 CM |
7184 | .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes), |
7185 | .channel_mode = alc888_3st_hp_modes, | |
8341de60 CM |
7186 | .need_dac_fix = 1, |
7187 | .input_mux = &alc883_capture_source, | |
7188 | }, | |
9c7f852e TI |
7189 | }; |
7190 | ||
7191 | ||
7192 | /* | |
7193 | * BIOS auto configuration | |
7194 | */ | |
7195 | static void alc883_auto_set_output_and_unmute(struct hda_codec *codec, | |
7196 | hda_nid_t nid, int pin_type, | |
7197 | int dac_idx) | |
7198 | { | |
7199 | /* set as output */ | |
7200 | struct alc_spec *spec = codec->spec; | |
f12ab1e0 TI |
7201 | int idx; |
7202 | ||
9c7f852e TI |
7203 | if (spec->multiout.dac_nids[dac_idx] == 0x25) |
7204 | idx = 4; | |
7205 | else | |
7206 | idx = spec->multiout.dac_nids[dac_idx] - 2; | |
7207 | ||
7208 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
7209 | pin_type); | |
7210 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
7211 | AMP_OUT_UNMUTE); | |
7212 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); | |
7213 | ||
7214 | } | |
7215 | ||
7216 | static void alc883_auto_init_multi_out(struct hda_codec *codec) | |
7217 | { | |
7218 | struct alc_spec *spec = codec->spec; | |
7219 | int i; | |
7220 | ||
bc9f98a9 | 7221 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
9c7f852e | 7222 | for (i = 0; i <= HDA_SIDE; i++) { |
f12ab1e0 | 7223 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
baba8ee9 | 7224 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
9c7f852e | 7225 | if (nid) |
baba8ee9 | 7226 | alc883_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 7227 | i); |
9c7f852e TI |
7228 | } |
7229 | } | |
7230 | ||
7231 | static void alc883_auto_init_hp_out(struct hda_codec *codec) | |
7232 | { | |
7233 | struct alc_spec *spec = codec->spec; | |
7234 | hda_nid_t pin; | |
7235 | ||
eb06ed8f | 7236 | pin = spec->autocfg.hp_pins[0]; |
9c7f852e TI |
7237 | if (pin) /* connect to front */ |
7238 | /* use dac 0 */ | |
7239 | alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
7240 | } | |
7241 | ||
7242 | #define alc883_is_input_pin(nid) alc880_is_input_pin(nid) | |
7243 | #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID | |
7244 | ||
7245 | static void alc883_auto_init_analog_input(struct hda_codec *codec) | |
7246 | { | |
7247 | struct alc_spec *spec = codec->spec; | |
7248 | int i; | |
7249 | ||
7250 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
7251 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
7252 | if (alc883_is_input_pin(nid)) { | |
7253 | snd_hda_codec_write(codec, nid, 0, | |
7254 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
7255 | (i <= AUTO_PIN_FRONT_MIC ? | |
7256 | PIN_VREF80 : PIN_IN)); | |
7257 | if (nid != ALC883_PIN_CD_NID) | |
7258 | snd_hda_codec_write(codec, nid, 0, | |
7259 | AC_VERB_SET_AMP_GAIN_MUTE, | |
7260 | AMP_OUT_MUTE); | |
7261 | } | |
7262 | } | |
7263 | } | |
7264 | ||
7265 | /* almost identical with ALC880 parser... */ | |
7266 | static int alc883_parse_auto_config(struct hda_codec *codec) | |
7267 | { | |
7268 | struct alc_spec *spec = codec->spec; | |
7269 | int err = alc880_parse_auto_config(codec); | |
7270 | ||
7271 | if (err < 0) | |
7272 | return err; | |
7273 | else if (err > 0) | |
7274 | /* hack - override the init verbs */ | |
7275 | spec->init_verbs[0] = alc883_auto_init_verbs; | |
bc9f98a9 KY |
7276 | spec->mixers[spec->num_mixers] = alc883_capture_mixer; |
7277 | spec->num_mixers++; | |
9c7f852e TI |
7278 | return err; |
7279 | } | |
7280 | ||
7281 | /* additional initialization for auto-configuration model */ | |
7282 | static void alc883_auto_init(struct hda_codec *codec) | |
7283 | { | |
7284 | alc883_auto_init_multi_out(codec); | |
7285 | alc883_auto_init_hp_out(codec); | |
7286 | alc883_auto_init_analog_input(codec); | |
7287 | } | |
7288 | ||
7289 | static int patch_alc883(struct hda_codec *codec) | |
7290 | { | |
7291 | struct alc_spec *spec; | |
7292 | int err, board_config; | |
7293 | ||
7294 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
7295 | if (spec == NULL) | |
7296 | return -ENOMEM; | |
7297 | ||
7298 | codec->spec = spec; | |
7299 | ||
f5fcc13c TI |
7300 | board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST, |
7301 | alc883_models, | |
7302 | alc883_cfg_tbl); | |
7303 | if (board_config < 0) { | |
9c7f852e TI |
7304 | printk(KERN_INFO "hda_codec: Unknown model for ALC883, " |
7305 | "trying auto-probe from BIOS...\n"); | |
7306 | board_config = ALC883_AUTO; | |
7307 | } | |
7308 | ||
7309 | if (board_config == ALC883_AUTO) { | |
7310 | /* automatic parse from the BIOS config */ | |
7311 | err = alc883_parse_auto_config(codec); | |
7312 | if (err < 0) { | |
7313 | alc_free(codec); | |
7314 | return err; | |
f12ab1e0 | 7315 | } else if (!err) { |
9c7f852e TI |
7316 | printk(KERN_INFO |
7317 | "hda_codec: Cannot set up configuration " | |
7318 | "from BIOS. Using base mode...\n"); | |
7319 | board_config = ALC883_3ST_2ch_DIG; | |
7320 | } | |
7321 | } | |
7322 | ||
7323 | if (board_config != ALC883_AUTO) | |
7324 | setup_preset(spec, &alc883_presets[board_config]); | |
7325 | ||
7326 | spec->stream_name_analog = "ALC883 Analog"; | |
7327 | spec->stream_analog_playback = &alc883_pcm_analog_playback; | |
7328 | spec->stream_analog_capture = &alc883_pcm_analog_capture; | |
7329 | ||
7330 | spec->stream_name_digital = "ALC883 Digital"; | |
7331 | spec->stream_digital_playback = &alc883_pcm_digital_playback; | |
7332 | spec->stream_digital_capture = &alc883_pcm_digital_capture; | |
7333 | ||
f12ab1e0 | 7334 | if (!spec->adc_nids && spec->input_mux) { |
4b146cb0 TI |
7335 | spec->adc_nids = alc883_adc_nids; |
7336 | spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); | |
7337 | } | |
9c7f852e TI |
7338 | |
7339 | codec->patch_ops = alc_patch_ops; | |
7340 | if (board_config == ALC883_AUTO) | |
7341 | spec->init_hook = alc883_auto_init; | |
cb53c626 TI |
7342 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
7343 | if (!spec->loopback.amplist) | |
7344 | spec->loopback.amplist = alc883_loopbacks; | |
7345 | #endif | |
9c7f852e TI |
7346 | |
7347 | return 0; | |
7348 | } | |
7349 | ||
7350 | /* | |
7351 | * ALC262 support | |
7352 | */ | |
7353 | ||
7354 | #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID | |
7355 | #define ALC262_DIGIN_NID ALC880_DIGIN_NID | |
7356 | ||
7357 | #define alc262_dac_nids alc260_dac_nids | |
7358 | #define alc262_adc_nids alc882_adc_nids | |
7359 | #define alc262_adc_nids_alt alc882_adc_nids_alt | |
7360 | ||
7361 | #define alc262_modes alc260_modes | |
7362 | #define alc262_capture_source alc882_capture_source | |
7363 | ||
7364 | static struct snd_kcontrol_new alc262_base_mixer[] = { | |
7365 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7366 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7367 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7368 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7369 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7370 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7371 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7372 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 7373 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
7374 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
7375 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 7376 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
7377 | /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), |
7378 | HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */ | |
7379 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT), | |
7380 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
7381 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
7382 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | |
7383 | { } /* end */ | |
7384 | }; | |
7385 | ||
ccc656ce KY |
7386 | static struct snd_kcontrol_new alc262_hippo1_mixer[] = { |
7387 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7388 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7389 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7390 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7391 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7392 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7393 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7394 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 7395 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce KY |
7396 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
7397 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 7398 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
ccc656ce KY |
7399 | /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), |
7400 | HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */ | |
7401 | /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/ | |
7402 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7403 | { } /* end */ | |
7404 | }; | |
7405 | ||
9c7f852e TI |
7406 | static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = { |
7407 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7408 | HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
7409 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7410 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
7411 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | |
7412 | ||
7413 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7414 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 7415 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
7416 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
7417 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 7418 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
7419 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
7420 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7421 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7422 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7423 | HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
7424 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
7425 | HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT), | |
7426 | HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT), | |
7427 | { } /* end */ | |
7428 | }; | |
7429 | ||
cd7509a4 KY |
7430 | static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = { |
7431 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7432 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7433 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7434 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
7435 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
7436 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | |
7437 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7438 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
cc69d12d | 7439 | HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT), |
cd7509a4 KY |
7440 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), |
7441 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
7442 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7443 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7444 | HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
7445 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
7446 | { } /* end */ | |
7447 | }; | |
7448 | ||
7449 | static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = { | |
7450 | HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7451 | HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 7452 | HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT), |
cd7509a4 KY |
7453 | { } /* end */ |
7454 | }; | |
7455 | ||
532d5381 TI |
7456 | static struct hda_bind_ctls alc262_sony_bind_sw = { |
7457 | .ops = &snd_hda_bind_sw, | |
7458 | .values = { | |
7459 | HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | |
7460 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
7461 | 0, | |
7462 | }, | |
7463 | }; | |
5b31954e | 7464 | |
272a527c KY |
7465 | static struct snd_kcontrol_new alc262_sony_mixer[] = { |
7466 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
532d5381 | 7467 | HDA_BIND_SW("Front Playback Switch", &alc262_sony_bind_sw), |
272a527c KY |
7468 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
7469 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7470 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
7471 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
7472 | { } /* end */ | |
7473 | }; | |
7474 | ||
83c34218 KY |
7475 | static struct snd_kcontrol_new alc262_benq_t31_mixer[] = { |
7476 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7477 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7478 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
7479 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7480 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7481 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
7482 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
7483 | { } /* end */ | |
7484 | }; | |
272a527c | 7485 | |
9c7f852e TI |
7486 | #define alc262_capture_mixer alc882_capture_mixer |
7487 | #define alc262_capture_alt_mixer alc882_capture_alt_mixer | |
7488 | ||
7489 | /* | |
7490 | * generic initialization of ADC, input mixers and output mixers | |
7491 | */ | |
7492 | static struct hda_verb alc262_init_verbs[] = { | |
7493 | /* | |
7494 | * Unmute ADC0-2 and set the default input to mic-in | |
7495 | */ | |
7496 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7497 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7498 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7499 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7500 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7501 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7502 | ||
cb53c626 | 7503 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
9c7f852e | 7504 | * mixer widget |
f12ab1e0 TI |
7505 | * Note: PASD motherboards uses the Line In 2 as the input for |
7506 | * front panel mic (mic 2) | |
9c7f852e TI |
7507 | */ |
7508 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
7509 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
7510 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7511 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
7512 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
7513 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9c7f852e TI |
7514 | |
7515 | /* | |
df694daa KY |
7516 | * Set up output mixers (0x0c - 0x0e) |
7517 | */ | |
7518 | /* set vol=0 to output mixers */ | |
7519 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7520 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7521 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7522 | /* set up input amps for analog loopback */ | |
7523 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
7524 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7525 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7526 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7527 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7528 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7529 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7530 | ||
7531 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
7532 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
7533 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
7534 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
7535 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
7536 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
7537 | ||
7538 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
7539 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
7540 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
7541 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
7542 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
7543 | ||
7544 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7545 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
7546 | ||
7547 | /* FIXME: use matrix-type input source selection */ | |
7548 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
7549 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
7550 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
7551 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
7552 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
7553 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
7554 | /* Input mixer2 */ | |
7555 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
7556 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
7557 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
7558 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
7559 | /* Input mixer3 */ | |
7560 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
7561 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
7562 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
f12ab1e0 | 7563 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
df694daa KY |
7564 | |
7565 | { } | |
7566 | }; | |
1da177e4 | 7567 | |
ccc656ce KY |
7568 | static struct hda_verb alc262_hippo_unsol_verbs[] = { |
7569 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
7570 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7571 | {} | |
7572 | }; | |
7573 | ||
7574 | static struct hda_verb alc262_hippo1_unsol_verbs[] = { | |
7575 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
7576 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7577 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
7578 | ||
7579 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
7580 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7581 | {} | |
7582 | }; | |
7583 | ||
272a527c KY |
7584 | static struct hda_verb alc262_sony_unsol_verbs[] = { |
7585 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
7586 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7587 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic | |
7588 | ||
7589 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
7590 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7591 | }; | |
7592 | ||
ccc656ce | 7593 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
5b31954e | 7594 | static void alc262_hippo_automute(struct hda_codec *codec) |
ccc656ce KY |
7595 | { |
7596 | struct alc_spec *spec = codec->spec; | |
7597 | unsigned int mute; | |
5b31954e | 7598 | unsigned int present; |
ccc656ce | 7599 | |
5b31954e TI |
7600 | /* need to execute and sync at first */ |
7601 | snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); | |
7602 | present = snd_hda_codec_read(codec, 0x15, 0, | |
7603 | AC_VERB_GET_PIN_SENSE, 0); | |
7604 | spec->jack_present = (present & 0x80000000) != 0; | |
ccc656ce KY |
7605 | if (spec->jack_present) { |
7606 | /* mute internal speaker */ | |
47fd830a TI |
7607 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
7608 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
ccc656ce KY |
7609 | } else { |
7610 | /* unmute internal speaker if necessary */ | |
7611 | mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0); | |
47fd830a TI |
7612 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
7613 | HDA_AMP_MUTE, mute); | |
ccc656ce KY |
7614 | } |
7615 | } | |
7616 | ||
7617 | /* unsolicited event for HP jack sensing */ | |
7618 | static void alc262_hippo_unsol_event(struct hda_codec *codec, | |
7619 | unsigned int res) | |
7620 | { | |
7621 | if ((res >> 26) != ALC880_HP_EVENT) | |
7622 | return; | |
5b31954e | 7623 | alc262_hippo_automute(codec); |
ccc656ce KY |
7624 | } |
7625 | ||
5b31954e | 7626 | static void alc262_hippo1_automute(struct hda_codec *codec) |
ccc656ce | 7627 | { |
ccc656ce | 7628 | unsigned int mute; |
5b31954e | 7629 | unsigned int present; |
ccc656ce | 7630 | |
5b31954e TI |
7631 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); |
7632 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
7633 | AC_VERB_GET_PIN_SENSE, 0); | |
7634 | present = (present & 0x80000000) != 0; | |
7635 | if (present) { | |
ccc656ce | 7636 | /* mute internal speaker */ |
47fd830a TI |
7637 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
7638 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
ccc656ce KY |
7639 | } else { |
7640 | /* unmute internal speaker if necessary */ | |
7641 | mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); | |
47fd830a TI |
7642 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
7643 | HDA_AMP_MUTE, mute); | |
ccc656ce KY |
7644 | } |
7645 | } | |
7646 | ||
7647 | /* unsolicited event for HP jack sensing */ | |
7648 | static void alc262_hippo1_unsol_event(struct hda_codec *codec, | |
7649 | unsigned int res) | |
7650 | { | |
7651 | if ((res >> 26) != ALC880_HP_EVENT) | |
7652 | return; | |
5b31954e | 7653 | alc262_hippo1_automute(codec); |
ccc656ce KY |
7654 | } |
7655 | ||
834be88d TI |
7656 | /* |
7657 | * fujitsu model | |
7658 | * 0x14 = headphone/spdif-out, 0x15 = internal speaker | |
7659 | */ | |
7660 | ||
7661 | #define ALC_HP_EVENT 0x37 | |
7662 | ||
7663 | static struct hda_verb alc262_fujitsu_unsol_verbs[] = { | |
7664 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, | |
7665 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7666 | {} | |
7667 | }; | |
7668 | ||
7669 | static struct hda_input_mux alc262_fujitsu_capture_source = { | |
7670 | .num_items = 2, | |
7671 | .items = { | |
7672 | { "Mic", 0x0 }, | |
7673 | { "CD", 0x4 }, | |
7674 | }, | |
7675 | }; | |
7676 | ||
9c7f852e TI |
7677 | static struct hda_input_mux alc262_HP_capture_source = { |
7678 | .num_items = 5, | |
7679 | .items = { | |
7680 | { "Mic", 0x0 }, | |
7681 | { "Front Mic", 0x3 }, | |
7682 | { "Line", 0x2 }, | |
7683 | { "CD", 0x4 }, | |
7684 | { "AUX IN", 0x6 }, | |
7685 | }, | |
7686 | }; | |
7687 | ||
834be88d TI |
7688 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
7689 | static void alc262_fujitsu_automute(struct hda_codec *codec, int force) | |
7690 | { | |
7691 | struct alc_spec *spec = codec->spec; | |
7692 | unsigned int mute; | |
7693 | ||
f12ab1e0 | 7694 | if (force || !spec->sense_updated) { |
834be88d TI |
7695 | unsigned int present; |
7696 | /* need to execute and sync at first */ | |
7697 | snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); | |
7698 | present = snd_hda_codec_read(codec, 0x14, 0, | |
7699 | AC_VERB_GET_PIN_SENSE, 0); | |
7700 | spec->jack_present = (present & 0x80000000) != 0; | |
7701 | spec->sense_updated = 1; | |
7702 | } | |
7703 | if (spec->jack_present) { | |
7704 | /* mute internal speaker */ | |
47fd830a TI |
7705 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
7706 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
834be88d TI |
7707 | } else { |
7708 | /* unmute internal speaker if necessary */ | |
7709 | mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); | |
47fd830a TI |
7710 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
7711 | HDA_AMP_MUTE, mute); | |
834be88d TI |
7712 | } |
7713 | } | |
7714 | ||
7715 | /* unsolicited event for HP jack sensing */ | |
7716 | static void alc262_fujitsu_unsol_event(struct hda_codec *codec, | |
7717 | unsigned int res) | |
7718 | { | |
7719 | if ((res >> 26) != ALC_HP_EVENT) | |
7720 | return; | |
7721 | alc262_fujitsu_automute(codec, 1); | |
7722 | } | |
7723 | ||
7724 | /* bind volumes of both NID 0x0c and 0x0d */ | |
cca3b371 TI |
7725 | static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = { |
7726 | .ops = &snd_hda_bind_vol, | |
7727 | .values = { | |
7728 | HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT), | |
7729 | HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT), | |
7730 | 0 | |
7731 | }, | |
7732 | }; | |
834be88d TI |
7733 | |
7734 | /* bind hp and internal speaker mute (with plug check) */ | |
7735 | static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol, | |
7736 | struct snd_ctl_elem_value *ucontrol) | |
7737 | { | |
7738 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
7739 | long *valp = ucontrol->value.integer.value; | |
7740 | int change; | |
7741 | ||
7742 | change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, | |
47fd830a TI |
7743 | HDA_AMP_MUTE, |
7744 | valp[0] ? 0 : HDA_AMP_MUTE); | |
834be88d | 7745 | change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, |
47fd830a TI |
7746 | HDA_AMP_MUTE, |
7747 | valp[1] ? 0 : HDA_AMP_MUTE); | |
82beb8fd TI |
7748 | if (change) |
7749 | alc262_fujitsu_automute(codec, 0); | |
834be88d TI |
7750 | return change; |
7751 | } | |
7752 | ||
7753 | static struct snd_kcontrol_new alc262_fujitsu_mixer[] = { | |
cca3b371 | 7754 | HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol), |
834be88d TI |
7755 | { |
7756 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7757 | .name = "Master Playback Switch", | |
7758 | .info = snd_hda_mixer_amp_switch_info, | |
7759 | .get = snd_hda_mixer_amp_switch_get, | |
7760 | .put = alc262_fujitsu_master_sw_put, | |
7761 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
7762 | }, | |
7763 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7764 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7765 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7766 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7767 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7768 | { } /* end */ | |
7769 | }; | |
7770 | ||
304dcaac TI |
7771 | /* additional init verbs for Benq laptops */ |
7772 | static struct hda_verb alc262_EAPD_verbs[] = { | |
7773 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
7774 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
7775 | {} | |
7776 | }; | |
7777 | ||
83c34218 KY |
7778 | static struct hda_verb alc262_benq_t31_EAPD_verbs[] = { |
7779 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7780 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
7781 | ||
7782 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
7783 | {0x20, AC_VERB_SET_PROC_COEF, 0x3050}, | |
7784 | {} | |
7785 | }; | |
7786 | ||
df694daa | 7787 | /* add playback controls from the parsed DAC table */ |
f12ab1e0 TI |
7788 | static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, |
7789 | const struct auto_pin_cfg *cfg) | |
df694daa KY |
7790 | { |
7791 | hda_nid_t nid; | |
7792 | int err; | |
7793 | ||
7794 | spec->multiout.num_dacs = 1; /* only use one dac */ | |
7795 | spec->multiout.dac_nids = spec->private_dac_nids; | |
7796 | spec->multiout.dac_nids[0] = 2; | |
7797 | ||
7798 | nid = cfg->line_out_pins[0]; | |
7799 | if (nid) { | |
f12ab1e0 TI |
7800 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
7801 | "Front Playback Volume", | |
7802 | HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT)); | |
7803 | if (err < 0) | |
df694daa | 7804 | return err; |
f12ab1e0 TI |
7805 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
7806 | "Front Playback Switch", | |
7807 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
7808 | if (err < 0) | |
df694daa KY |
7809 | return err; |
7810 | } | |
7811 | ||
82bc955f | 7812 | nid = cfg->speaker_pins[0]; |
df694daa KY |
7813 | if (nid) { |
7814 | if (nid == 0x16) { | |
f12ab1e0 TI |
7815 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
7816 | "Speaker Playback Volume", | |
7817 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, | |
7818 | HDA_OUTPUT)); | |
7819 | if (err < 0) | |
df694daa | 7820 | return err; |
f12ab1e0 TI |
7821 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
7822 | "Speaker Playback Switch", | |
7823 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
7824 | HDA_OUTPUT)); | |
7825 | if (err < 0) | |
df694daa KY |
7826 | return err; |
7827 | } else { | |
f12ab1e0 TI |
7828 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
7829 | "Speaker Playback Switch", | |
7830 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
7831 | HDA_OUTPUT)); | |
7832 | if (err < 0) | |
df694daa KY |
7833 | return err; |
7834 | } | |
7835 | } | |
eb06ed8f | 7836 | nid = cfg->hp_pins[0]; |
df694daa KY |
7837 | if (nid) { |
7838 | /* spec->multiout.hp_nid = 2; */ | |
7839 | if (nid == 0x16) { | |
f12ab1e0 TI |
7840 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
7841 | "Headphone Playback Volume", | |
7842 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, | |
7843 | HDA_OUTPUT)); | |
7844 | if (err < 0) | |
df694daa | 7845 | return err; |
f12ab1e0 TI |
7846 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
7847 | "Headphone Playback Switch", | |
7848 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
7849 | HDA_OUTPUT)); | |
7850 | if (err < 0) | |
df694daa KY |
7851 | return err; |
7852 | } else { | |
f12ab1e0 TI |
7853 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
7854 | "Headphone Playback Switch", | |
7855 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
7856 | HDA_OUTPUT)); | |
7857 | if (err < 0) | |
df694daa KY |
7858 | return err; |
7859 | } | |
7860 | } | |
f12ab1e0 | 7861 | return 0; |
df694daa KY |
7862 | } |
7863 | ||
7864 | /* identical with ALC880 */ | |
f12ab1e0 TI |
7865 | #define alc262_auto_create_analog_input_ctls \ |
7866 | alc880_auto_create_analog_input_ctls | |
df694daa KY |
7867 | |
7868 | /* | |
7869 | * generic initialization of ADC, input mixers and output mixers | |
7870 | */ | |
7871 | static struct hda_verb alc262_volume_init_verbs[] = { | |
7872 | /* | |
7873 | * Unmute ADC0-2 and set the default input to mic-in | |
7874 | */ | |
7875 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7876 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7877 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7878 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7879 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7880 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7881 | ||
cb53c626 | 7882 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
df694daa | 7883 | * mixer widget |
f12ab1e0 TI |
7884 | * Note: PASD motherboards uses the Line In 2 as the input for |
7885 | * front panel mic (mic 2) | |
df694daa KY |
7886 | */ |
7887 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
7888 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
7889 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7890 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
7891 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
7892 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
7893 | |
7894 | /* | |
7895 | * Set up output mixers (0x0c - 0x0f) | |
7896 | */ | |
7897 | /* set vol=0 to output mixers */ | |
7898 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7899 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7900 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7901 | ||
7902 | /* set up input amps for analog loopback */ | |
7903 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
7904 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7905 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7906 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7907 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7908 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7909 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7910 | ||
7911 | /* FIXME: use matrix-type input source selection */ | |
7912 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
7913 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
7914 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
7915 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
7916 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
7917 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
7918 | /* Input mixer2 */ | |
7919 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
7920 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
7921 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
7922 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
7923 | /* Input mixer3 */ | |
7924 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
7925 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
7926 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
7927 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
7928 | ||
7929 | { } | |
7930 | }; | |
7931 | ||
9c7f852e TI |
7932 | static struct hda_verb alc262_HP_BPC_init_verbs[] = { |
7933 | /* | |
7934 | * Unmute ADC0-2 and set the default input to mic-in | |
7935 | */ | |
7936 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7937 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7938 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7939 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7940 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7941 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7942 | ||
cb53c626 | 7943 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
9c7f852e | 7944 | * mixer widget |
f12ab1e0 TI |
7945 | * Note: PASD motherboards uses the Line In 2 as the input for |
7946 | * front panel mic (mic 2) | |
9c7f852e TI |
7947 | */ |
7948 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
7949 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
7950 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7951 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
7952 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
7953 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
7954 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
7955 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
9c7f852e TI |
7956 | |
7957 | /* | |
7958 | * Set up output mixers (0x0c - 0x0e) | |
7959 | */ | |
7960 | /* set vol=0 to output mixers */ | |
7961 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7962 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7963 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7964 | ||
7965 | /* set up input amps for analog loopback */ | |
7966 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
7967 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7968 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7969 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7970 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7971 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7972 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7973 | ||
7974 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
7975 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7976 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7977 | ||
7978 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7979 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7980 | ||
7981 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7982 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7983 | ||
7984 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
7985 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
7986 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
7987 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
7988 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
7989 | ||
7990 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
7991 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
7992 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
7993 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
7994 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
7995 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
7996 | ||
7997 | ||
7998 | /* FIXME: use matrix-type input source selection */ | |
7999 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
8000 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
8001 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
8002 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
8003 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
8004 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
8005 | /* Input mixer2 */ | |
8006 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
8007 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
8008 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
8009 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
8010 | /* Input mixer3 */ | |
8011 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
8012 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
8013 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
8014 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
8015 | ||
8016 | { } | |
8017 | }; | |
8018 | ||
cd7509a4 KY |
8019 | static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = { |
8020 | /* | |
8021 | * Unmute ADC0-2 and set the default input to mic-in | |
8022 | */ | |
8023 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8024 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8025 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8026 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8027 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8028 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8029 | ||
cb53c626 | 8030 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
cd7509a4 KY |
8031 | * mixer widget |
8032 | * Note: PASD motherboards uses the Line In 2 as the input for front | |
8033 | * panel mic (mic 2) | |
8034 | */ | |
8035 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
8036 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
8037 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
8038 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
8039 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
8040 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
8041 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
8042 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
8043 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
cd7509a4 KY |
8044 | /* |
8045 | * Set up output mixers (0x0c - 0x0e) | |
8046 | */ | |
8047 | /* set vol=0 to output mixers */ | |
8048 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8049 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8050 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8051 | ||
8052 | /* set up input amps for analog loopback */ | |
8053 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
8054 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8055 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8056 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8057 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8058 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8059 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8060 | ||
8061 | ||
8062 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */ | |
8063 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */ | |
8064 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */ | |
8065 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */ | |
8066 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */ | |
8067 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */ | |
8068 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */ | |
8069 | ||
8070 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
8071 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
8072 | ||
8073 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8074 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
8075 | ||
8076 | /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */ | |
8077 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
8078 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
8079 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
8080 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
8081 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
8082 | ||
8083 | /* FIXME: use matrix-type input source selection */ | |
8084 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
8085 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
8086 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/ | |
8087 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/ | |
8088 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/ | |
8089 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/ | |
8090 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/ | |
8091 | /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
8092 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/ | |
8093 | /* Input mixer2 */ | |
8094 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
8095 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
8096 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
8097 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
8098 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
8099 | /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
8100 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, | |
8101 | /* Input mixer3 */ | |
8102 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
8103 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
8104 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
8105 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
8106 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
8107 | /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
8108 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, | |
8109 | ||
8110 | { } | |
8111 | }; | |
8112 | ||
cb53c626 TI |
8113 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
8114 | #define alc262_loopbacks alc880_loopbacks | |
8115 | #endif | |
8116 | ||
df694daa KY |
8117 | /* pcm configuration: identiacal with ALC880 */ |
8118 | #define alc262_pcm_analog_playback alc880_pcm_analog_playback | |
8119 | #define alc262_pcm_analog_capture alc880_pcm_analog_capture | |
8120 | #define alc262_pcm_digital_playback alc880_pcm_digital_playback | |
8121 | #define alc262_pcm_digital_capture alc880_pcm_digital_capture | |
8122 | ||
8123 | /* | |
8124 | * BIOS auto configuration | |
8125 | */ | |
8126 | static int alc262_parse_auto_config(struct hda_codec *codec) | |
8127 | { | |
8128 | struct alc_spec *spec = codec->spec; | |
8129 | int err; | |
8130 | static hda_nid_t alc262_ignore[] = { 0x1d, 0 }; | |
8131 | ||
f12ab1e0 TI |
8132 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
8133 | alc262_ignore); | |
8134 | if (err < 0) | |
df694daa | 8135 | return err; |
f12ab1e0 | 8136 | if (!spec->autocfg.line_outs) |
df694daa | 8137 | return 0; /* can't find valid BIOS pin config */ |
f12ab1e0 TI |
8138 | err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg); |
8139 | if (err < 0) | |
8140 | return err; | |
8141 | err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
8142 | if (err < 0) | |
df694daa KY |
8143 | return err; |
8144 | ||
8145 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
8146 | ||
8147 | if (spec->autocfg.dig_out_pin) | |
8148 | spec->multiout.dig_out_nid = ALC262_DIGOUT_NID; | |
8149 | if (spec->autocfg.dig_in_pin) | |
8150 | spec->dig_in_nid = ALC262_DIGIN_NID; | |
8151 | ||
8152 | if (spec->kctl_alloc) | |
8153 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
8154 | ||
8155 | spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs; | |
a1e8d2da | 8156 | spec->num_mux_defs = 1; |
df694daa KY |
8157 | spec->input_mux = &spec->private_imux; |
8158 | ||
8159 | return 1; | |
8160 | } | |
8161 | ||
8162 | #define alc262_auto_init_multi_out alc882_auto_init_multi_out | |
8163 | #define alc262_auto_init_hp_out alc882_auto_init_hp_out | |
8164 | #define alc262_auto_init_analog_input alc882_auto_init_analog_input | |
8165 | ||
8166 | ||
8167 | /* init callback for auto-configuration model -- overriding the default init */ | |
ae6b813a | 8168 | static void alc262_auto_init(struct hda_codec *codec) |
df694daa | 8169 | { |
df694daa KY |
8170 | alc262_auto_init_multi_out(codec); |
8171 | alc262_auto_init_hp_out(codec); | |
8172 | alc262_auto_init_analog_input(codec); | |
df694daa KY |
8173 | } |
8174 | ||
8175 | /* | |
8176 | * configuration and preset | |
8177 | */ | |
f5fcc13c TI |
8178 | static const char *alc262_models[ALC262_MODEL_LAST] = { |
8179 | [ALC262_BASIC] = "basic", | |
8180 | [ALC262_HIPPO] = "hippo", | |
8181 | [ALC262_HIPPO_1] = "hippo_1", | |
8182 | [ALC262_FUJITSU] = "fujitsu", | |
8183 | [ALC262_HP_BPC] = "hp-bpc", | |
cd7509a4 | 8184 | [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000", |
f5fcc13c | 8185 | [ALC262_BENQ_ED8] = "benq", |
0f40502e TI |
8186 | [ALC262_BENQ_T31] = "benq-t31", |
8187 | [ALC262_SONY_ASSAMD] = "sony-assamd", | |
f5fcc13c TI |
8188 | [ALC262_AUTO] = "auto", |
8189 | }; | |
8190 | ||
8191 | static struct snd_pci_quirk alc262_cfg_tbl[] = { | |
8192 | SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO), | |
8193 | SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC), | |
8194 | SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC), | |
7d87de2d KY |
8195 | SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC), |
8196 | SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC), | |
f5fcc13c | 8197 | SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC), |
7d87de2d | 8198 | SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC), |
f5fcc13c | 8199 | SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC), |
7d87de2d | 8200 | SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC), |
cd7509a4 KY |
8201 | SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL), |
8202 | SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL), | |
8203 | SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL), | |
8204 | SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL), | |
8205 | SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF), | |
8206 | SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF), | |
8207 | SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF), | |
8208 | SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF), | |
f5fcc13c TI |
8209 | SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO), |
8210 | SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU), | |
8211 | SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1), | |
8212 | SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8), | |
83c34218 | 8213 | SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31), |
5b31954e | 8214 | SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD), |
272a527c KY |
8215 | SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD), |
8216 | SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD), | |
8217 | SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD), | |
df694daa KY |
8218 | {} |
8219 | }; | |
8220 | ||
8221 | static struct alc_config_preset alc262_presets[] = { | |
8222 | [ALC262_BASIC] = { | |
8223 | .mixers = { alc262_base_mixer }, | |
8224 | .init_verbs = { alc262_init_verbs }, | |
8225 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
8226 | .dac_nids = alc262_dac_nids, | |
8227 | .hp_nid = 0x03, | |
8228 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
8229 | .channel_mode = alc262_modes, | |
a3bcba38 | 8230 | .input_mux = &alc262_capture_source, |
df694daa | 8231 | }, |
ccc656ce KY |
8232 | [ALC262_HIPPO] = { |
8233 | .mixers = { alc262_base_mixer }, | |
8234 | .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs}, | |
8235 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
8236 | .dac_nids = alc262_dac_nids, | |
8237 | .hp_nid = 0x03, | |
8238 | .dig_out_nid = ALC262_DIGOUT_NID, | |
8239 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
8240 | .channel_mode = alc262_modes, | |
8241 | .input_mux = &alc262_capture_source, | |
8242 | .unsol_event = alc262_hippo_unsol_event, | |
5b31954e | 8243 | .init_hook = alc262_hippo_automute, |
ccc656ce KY |
8244 | }, |
8245 | [ALC262_HIPPO_1] = { | |
8246 | .mixers = { alc262_hippo1_mixer }, | |
8247 | .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs}, | |
8248 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
8249 | .dac_nids = alc262_dac_nids, | |
8250 | .hp_nid = 0x02, | |
8251 | .dig_out_nid = ALC262_DIGOUT_NID, | |
8252 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
8253 | .channel_mode = alc262_modes, | |
8254 | .input_mux = &alc262_capture_source, | |
8255 | .unsol_event = alc262_hippo1_unsol_event, | |
5b31954e | 8256 | .init_hook = alc262_hippo1_automute, |
ccc656ce | 8257 | }, |
834be88d TI |
8258 | [ALC262_FUJITSU] = { |
8259 | .mixers = { alc262_fujitsu_mixer }, | |
8260 | .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs }, | |
8261 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
8262 | .dac_nids = alc262_dac_nids, | |
8263 | .hp_nid = 0x03, | |
8264 | .dig_out_nid = ALC262_DIGOUT_NID, | |
8265 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
8266 | .channel_mode = alc262_modes, | |
8267 | .input_mux = &alc262_fujitsu_capture_source, | |
ae6b813a | 8268 | .unsol_event = alc262_fujitsu_unsol_event, |
834be88d | 8269 | }, |
9c7f852e TI |
8270 | [ALC262_HP_BPC] = { |
8271 | .mixers = { alc262_HP_BPC_mixer }, | |
8272 | .init_verbs = { alc262_HP_BPC_init_verbs }, | |
8273 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
8274 | .dac_nids = alc262_dac_nids, | |
8275 | .hp_nid = 0x03, | |
8276 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
8277 | .channel_mode = alc262_modes, | |
8278 | .input_mux = &alc262_HP_capture_source, | |
f12ab1e0 | 8279 | }, |
cd7509a4 KY |
8280 | [ALC262_HP_BPC_D7000_WF] = { |
8281 | .mixers = { alc262_HP_BPC_WildWest_mixer }, | |
8282 | .init_verbs = { alc262_HP_BPC_WildWest_init_verbs }, | |
8283 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
8284 | .dac_nids = alc262_dac_nids, | |
8285 | .hp_nid = 0x03, | |
8286 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
8287 | .channel_mode = alc262_modes, | |
8288 | .input_mux = &alc262_HP_capture_source, | |
f12ab1e0 | 8289 | }, |
cd7509a4 KY |
8290 | [ALC262_HP_BPC_D7000_WL] = { |
8291 | .mixers = { alc262_HP_BPC_WildWest_mixer, | |
8292 | alc262_HP_BPC_WildWest_option_mixer }, | |
8293 | .init_verbs = { alc262_HP_BPC_WildWest_init_verbs }, | |
8294 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
8295 | .dac_nids = alc262_dac_nids, | |
8296 | .hp_nid = 0x03, | |
8297 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
8298 | .channel_mode = alc262_modes, | |
8299 | .input_mux = &alc262_HP_capture_source, | |
f12ab1e0 | 8300 | }, |
304dcaac TI |
8301 | [ALC262_BENQ_ED8] = { |
8302 | .mixers = { alc262_base_mixer }, | |
8303 | .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs }, | |
8304 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
8305 | .dac_nids = alc262_dac_nids, | |
8306 | .hp_nid = 0x03, | |
8307 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
8308 | .channel_mode = alc262_modes, | |
8309 | .input_mux = &alc262_capture_source, | |
f12ab1e0 | 8310 | }, |
272a527c KY |
8311 | [ALC262_SONY_ASSAMD] = { |
8312 | .mixers = { alc262_sony_mixer }, | |
8313 | .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs}, | |
8314 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
8315 | .dac_nids = alc262_dac_nids, | |
8316 | .hp_nid = 0x02, | |
8317 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
8318 | .channel_mode = alc262_modes, | |
8319 | .input_mux = &alc262_capture_source, | |
8320 | .unsol_event = alc262_hippo_unsol_event, | |
5b31954e | 8321 | .init_hook = alc262_hippo_automute, |
83c34218 KY |
8322 | }, |
8323 | [ALC262_BENQ_T31] = { | |
8324 | .mixers = { alc262_benq_t31_mixer }, | |
8325 | .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs }, | |
8326 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
8327 | .dac_nids = alc262_dac_nids, | |
8328 | .hp_nid = 0x03, | |
8329 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
8330 | .channel_mode = alc262_modes, | |
8331 | .input_mux = &alc262_capture_source, | |
8332 | .unsol_event = alc262_hippo_unsol_event, | |
5b31954e | 8333 | .init_hook = alc262_hippo_automute, |
272a527c | 8334 | }, |
df694daa KY |
8335 | }; |
8336 | ||
8337 | static int patch_alc262(struct hda_codec *codec) | |
8338 | { | |
8339 | struct alc_spec *spec; | |
8340 | int board_config; | |
8341 | int err; | |
8342 | ||
dc041e0b | 8343 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
df694daa KY |
8344 | if (spec == NULL) |
8345 | return -ENOMEM; | |
8346 | ||
8347 | codec->spec = spec; | |
8348 | #if 0 | |
f12ab1e0 TI |
8349 | /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is |
8350 | * under-run | |
8351 | */ | |
df694daa KY |
8352 | { |
8353 | int tmp; | |
8354 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); | |
8355 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); | |
8356 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); | |
8357 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); | |
8358 | } | |
8359 | #endif | |
8360 | ||
f5fcc13c TI |
8361 | board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST, |
8362 | alc262_models, | |
8363 | alc262_cfg_tbl); | |
cd7509a4 | 8364 | |
f5fcc13c | 8365 | if (board_config < 0) { |
9c7f852e TI |
8366 | printk(KERN_INFO "hda_codec: Unknown model for ALC262, " |
8367 | "trying auto-probe from BIOS...\n"); | |
df694daa KY |
8368 | board_config = ALC262_AUTO; |
8369 | } | |
8370 | ||
8371 | if (board_config == ALC262_AUTO) { | |
8372 | /* automatic parse from the BIOS config */ | |
8373 | err = alc262_parse_auto_config(codec); | |
8374 | if (err < 0) { | |
8375 | alc_free(codec); | |
8376 | return err; | |
f12ab1e0 | 8377 | } else if (!err) { |
9c7f852e TI |
8378 | printk(KERN_INFO |
8379 | "hda_codec: Cannot set up configuration " | |
8380 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
8381 | board_config = ALC262_BASIC; |
8382 | } | |
8383 | } | |
8384 | ||
8385 | if (board_config != ALC262_AUTO) | |
8386 | setup_preset(spec, &alc262_presets[board_config]); | |
8387 | ||
8388 | spec->stream_name_analog = "ALC262 Analog"; | |
8389 | spec->stream_analog_playback = &alc262_pcm_analog_playback; | |
8390 | spec->stream_analog_capture = &alc262_pcm_analog_capture; | |
8391 | ||
8392 | spec->stream_name_digital = "ALC262 Digital"; | |
8393 | spec->stream_digital_playback = &alc262_pcm_digital_playback; | |
8394 | spec->stream_digital_capture = &alc262_pcm_digital_capture; | |
8395 | ||
f12ab1e0 | 8396 | if (!spec->adc_nids && spec->input_mux) { |
df694daa | 8397 | /* check whether NID 0x07 is valid */ |
4a471b7d TI |
8398 | unsigned int wcap = get_wcaps(codec, 0x07); |
8399 | ||
f12ab1e0 TI |
8400 | /* get type */ |
8401 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
df694daa KY |
8402 | if (wcap != AC_WID_AUD_IN) { |
8403 | spec->adc_nids = alc262_adc_nids_alt; | |
8404 | spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt); | |
f12ab1e0 TI |
8405 | spec->mixers[spec->num_mixers] = |
8406 | alc262_capture_alt_mixer; | |
df694daa KY |
8407 | spec->num_mixers++; |
8408 | } else { | |
8409 | spec->adc_nids = alc262_adc_nids; | |
8410 | spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids); | |
8411 | spec->mixers[spec->num_mixers] = alc262_capture_mixer; | |
8412 | spec->num_mixers++; | |
8413 | } | |
8414 | } | |
8415 | ||
8416 | codec->patch_ops = alc_patch_ops; | |
8417 | if (board_config == ALC262_AUTO) | |
ae6b813a | 8418 | spec->init_hook = alc262_auto_init; |
cb53c626 TI |
8419 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
8420 | if (!spec->loopback.amplist) | |
8421 | spec->loopback.amplist = alc262_loopbacks; | |
8422 | #endif | |
834be88d | 8423 | |
df694daa KY |
8424 | return 0; |
8425 | } | |
8426 | ||
a361d84b KY |
8427 | /* |
8428 | * ALC268 channel source setting (2 channel) | |
8429 | */ | |
8430 | #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID | |
8431 | #define alc268_modes alc260_modes | |
8432 | ||
8433 | static hda_nid_t alc268_dac_nids[2] = { | |
8434 | /* front, hp */ | |
8435 | 0x02, 0x03 | |
8436 | }; | |
8437 | ||
8438 | static hda_nid_t alc268_adc_nids[2] = { | |
8439 | /* ADC0-1 */ | |
8440 | 0x08, 0x07 | |
8441 | }; | |
8442 | ||
8443 | static hda_nid_t alc268_adc_nids_alt[1] = { | |
8444 | /* ADC0 */ | |
8445 | 0x08 | |
8446 | }; | |
8447 | ||
8448 | static struct snd_kcontrol_new alc268_base_mixer[] = { | |
8449 | /* output mixer control */ | |
8450 | HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT), | |
8451 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
8452 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT), | |
8453 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
33bf17ab TI |
8454 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
8455 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
8456 | HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT), | |
a361d84b KY |
8457 | { } |
8458 | }; | |
8459 | ||
d1a991a6 KY |
8460 | static struct hda_verb alc268_eapd_verbs[] = { |
8461 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
8462 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
8463 | { } | |
8464 | }; | |
8465 | ||
d273809e TI |
8466 | /* Toshiba specific */ |
8467 | #define alc268_toshiba_automute alc262_hippo_automute | |
8468 | ||
8469 | static struct hda_verb alc268_toshiba_verbs[] = { | |
8470 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
8471 | { } /* end */ | |
8472 | }; | |
8473 | ||
8474 | /* Acer specific */ | |
6bc96857 TI |
8475 | /* bind volumes of both NID 0x0c and 0x0d */ |
8476 | static struct hda_bind_ctls alc268_acer_bind_master_vol = { | |
8477 | .ops = &snd_hda_bind_vol, | |
8478 | .values = { | |
8479 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), | |
8480 | HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT), | |
8481 | 0 | |
8482 | }, | |
8483 | }; | |
8484 | ||
d273809e TI |
8485 | #define alc268_acer_master_sw_put alc262_fujitsu_master_sw_put |
8486 | #define alc268_acer_automute alc262_fujitsu_automute | |
8487 | ||
8488 | static struct snd_kcontrol_new alc268_acer_mixer[] = { | |
8489 | /* output mixer control */ | |
8490 | HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol), | |
8491 | { | |
8492 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
8493 | .name = "Master Playback Switch", | |
8494 | .info = snd_hda_mixer_amp_switch_info, | |
8495 | .get = snd_hda_mixer_amp_switch_get, | |
8496 | .put = alc268_acer_master_sw_put, | |
8497 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
8498 | }, | |
33bf17ab TI |
8499 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
8500 | HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT), | |
8501 | HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT), | |
d273809e TI |
8502 | { } |
8503 | }; | |
8504 | ||
8505 | static struct hda_verb alc268_acer_verbs[] = { | |
8506 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
8507 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
8508 | ||
8509 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
8510 | { } | |
8511 | }; | |
8512 | ||
8513 | /* unsolicited event for HP jack sensing */ | |
8514 | static void alc268_toshiba_unsol_event(struct hda_codec *codec, | |
8515 | unsigned int res) | |
8516 | { | |
8517 | if ((res >> 28) != ALC880_HP_EVENT) | |
8518 | return; | |
8519 | alc268_toshiba_automute(codec); | |
8520 | } | |
8521 | ||
8522 | static void alc268_acer_unsol_event(struct hda_codec *codec, | |
8523 | unsigned int res) | |
8524 | { | |
8525 | if ((res >> 28) != ALC880_HP_EVENT) | |
8526 | return; | |
8527 | alc268_acer_automute(codec, 1); | |
8528 | } | |
8529 | ||
a361d84b KY |
8530 | /* |
8531 | * generic initialization of ADC, input mixers and output mixers | |
8532 | */ | |
8533 | static struct hda_verb alc268_base_init_verbs[] = { | |
8534 | /* Unmute DAC0-1 and set vol = 0 */ | |
8535 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8536 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8537 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8538 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8539 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8540 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8541 | ||
8542 | /* | |
8543 | * Set up output mixers (0x0c - 0x0e) | |
8544 | */ | |
8545 | /* set vol=0 to output mixers */ | |
8546 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8547 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8548 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8549 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8550 | ||
8551 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8552 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8553 | ||
8554 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
8555 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
8556 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
8557 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
8558 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
8559 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
8560 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
8561 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
8562 | ||
8563 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
8564 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
8565 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
8566 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
8567 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
8568 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
8569 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
8570 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
8571 | ||
8572 | /* FIXME: use matrix-type input source selection */ | |
8573 | /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */ | |
8574 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
8575 | /* Input mixer2 */ | |
8576 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
8577 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
8578 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
8579 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
8580 | ||
8581 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
8582 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
8583 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
8584 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
8585 | { } | |
8586 | }; | |
8587 | ||
8588 | /* | |
8589 | * generic initialization of ADC, input mixers and output mixers | |
8590 | */ | |
8591 | static struct hda_verb alc268_volume_init_verbs[] = { | |
8592 | /* set output DAC */ | |
8593 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8594 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8595 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8596 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8597 | ||
8598 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
8599 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
8600 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
8601 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
8602 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
8603 | ||
8604 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8605 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8606 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8607 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8608 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8609 | ||
8610 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
8611 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
8612 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
8613 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
8614 | ||
8615 | /* set PCBEEP vol = 0 */ | |
8616 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))}, | |
8617 | ||
8618 | { } | |
8619 | }; | |
8620 | ||
8621 | #define alc268_mux_enum_info alc_mux_enum_info | |
8622 | #define alc268_mux_enum_get alc_mux_enum_get | |
8623 | ||
8624 | static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol, | |
8625 | struct snd_ctl_elem_value *ucontrol) | |
8626 | { | |
8627 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
8628 | struct alc_spec *spec = codec->spec; | |
8629 | const struct hda_input_mux *imux = spec->input_mux; | |
8630 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
8631 | static hda_nid_t capture_mixers[3] = { 0x23, 0x24 }; | |
8632 | hda_nid_t nid = capture_mixers[adc_idx]; | |
8633 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; | |
8634 | unsigned int i, idx; | |
8635 | ||
8636 | idx = ucontrol->value.enumerated.item[0]; | |
8637 | if (idx >= imux->num_items) | |
8638 | idx = imux->num_items - 1; | |
82beb8fd | 8639 | if (*cur_val == idx) |
a361d84b KY |
8640 | return 0; |
8641 | for (i = 0; i < imux->num_items; i++) { | |
47fd830a TI |
8642 | unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE; |
8643 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, | |
8644 | imux->items[i].index, | |
8645 | HDA_AMP_MUTE, v); | |
82beb8fd TI |
8646 | snd_hda_codec_write_cache(codec, nid, 0, |
8647 | AC_VERB_SET_CONNECT_SEL, | |
8648 | idx ); | |
a361d84b KY |
8649 | } |
8650 | *cur_val = idx; | |
8651 | return 1; | |
8652 | } | |
8653 | ||
8654 | static struct snd_kcontrol_new alc268_capture_alt_mixer[] = { | |
8655 | HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), | |
8656 | HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), | |
8657 | { | |
8658 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
8659 | /* The multiple "Capture Source" controls confuse alsamixer | |
8660 | * So call somewhat different.. | |
8661 | * FIXME: the controls appear in the "playback" view! | |
8662 | */ | |
8663 | /* .name = "Capture Source", */ | |
8664 | .name = "Input Source", | |
8665 | .count = 1, | |
8666 | .info = alc268_mux_enum_info, | |
8667 | .get = alc268_mux_enum_get, | |
8668 | .put = alc268_mux_enum_put, | |
8669 | }, | |
8670 | { } /* end */ | |
8671 | }; | |
8672 | ||
8673 | static struct snd_kcontrol_new alc268_capture_mixer[] = { | |
8674 | HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), | |
8675 | HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), | |
8676 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT), | |
8677 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT), | |
8678 | { | |
8679 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
8680 | /* The multiple "Capture Source" controls confuse alsamixer | |
8681 | * So call somewhat different.. | |
8682 | * FIXME: the controls appear in the "playback" view! | |
8683 | */ | |
8684 | /* .name = "Capture Source", */ | |
8685 | .name = "Input Source", | |
8686 | .count = 2, | |
8687 | .info = alc268_mux_enum_info, | |
8688 | .get = alc268_mux_enum_get, | |
8689 | .put = alc268_mux_enum_put, | |
8690 | }, | |
8691 | { } /* end */ | |
8692 | }; | |
8693 | ||
8694 | static struct hda_input_mux alc268_capture_source = { | |
8695 | .num_items = 4, | |
8696 | .items = { | |
8697 | { "Mic", 0x0 }, | |
8698 | { "Front Mic", 0x1 }, | |
8699 | { "Line", 0x2 }, | |
8700 | { "CD", 0x3 }, | |
8701 | }, | |
8702 | }; | |
8703 | ||
8704 | /* create input playback/capture controls for the given pin */ | |
8705 | static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid, | |
8706 | const char *ctlname, int idx) | |
8707 | { | |
8708 | char name[32]; | |
8709 | int err; | |
8710 | ||
8711 | sprintf(name, "%s Playback Volume", ctlname); | |
8712 | if (nid == 0x14) { | |
8713 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
8714 | HDA_COMPOSE_AMP_VAL(0x02, 3, idx, | |
8715 | HDA_OUTPUT)); | |
8716 | if (err < 0) | |
8717 | return err; | |
8718 | } else if (nid == 0x15) { | |
8719 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
8720 | HDA_COMPOSE_AMP_VAL(0x03, 3, idx, | |
8721 | HDA_OUTPUT)); | |
8722 | if (err < 0) | |
8723 | return err; | |
8724 | } else | |
8725 | return -1; | |
8726 | sprintf(name, "%s Playback Switch", ctlname); | |
8727 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | |
8728 | HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT)); | |
8729 | if (err < 0) | |
8730 | return err; | |
8731 | return 0; | |
8732 | } | |
8733 | ||
8734 | /* add playback controls from the parsed DAC table */ | |
8735 | static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec, | |
8736 | const struct auto_pin_cfg *cfg) | |
8737 | { | |
8738 | hda_nid_t nid; | |
8739 | int err; | |
8740 | ||
8741 | spec->multiout.num_dacs = 2; /* only use one dac */ | |
8742 | spec->multiout.dac_nids = spec->private_dac_nids; | |
8743 | spec->multiout.dac_nids[0] = 2; | |
8744 | spec->multiout.dac_nids[1] = 3; | |
8745 | ||
8746 | nid = cfg->line_out_pins[0]; | |
8747 | if (nid) | |
8748 | alc268_new_analog_output(spec, nid, "Front", 0); | |
8749 | ||
8750 | nid = cfg->speaker_pins[0]; | |
8751 | if (nid == 0x1d) { | |
8752 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
8753 | "Speaker Playback Volume", | |
8754 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | |
8755 | if (err < 0) | |
8756 | return err; | |
8757 | } | |
8758 | nid = cfg->hp_pins[0]; | |
8759 | if (nid) | |
8760 | alc268_new_analog_output(spec, nid, "Headphone", 0); | |
8761 | ||
8762 | nid = cfg->line_out_pins[1] | cfg->line_out_pins[2]; | |
8763 | if (nid == 0x16) { | |
8764 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
8765 | "Mono Playback Switch", | |
8766 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT)); | |
8767 | if (err < 0) | |
8768 | return err; | |
8769 | } | |
8770 | return 0; | |
8771 | } | |
8772 | ||
8773 | /* create playback/capture controls for input pins */ | |
8774 | static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec, | |
8775 | const struct auto_pin_cfg *cfg) | |
8776 | { | |
8777 | struct hda_input_mux *imux = &spec->private_imux; | |
8778 | int i, idx1; | |
8779 | ||
8780 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
8781 | switch(cfg->input_pins[i]) { | |
8782 | case 0x18: | |
8783 | idx1 = 0; /* Mic 1 */ | |
8784 | break; | |
8785 | case 0x19: | |
8786 | idx1 = 1; /* Mic 2 */ | |
8787 | break; | |
8788 | case 0x1a: | |
8789 | idx1 = 2; /* Line In */ | |
8790 | break; | |
8791 | case 0x1c: | |
8792 | idx1 = 3; /* CD */ | |
8793 | break; | |
8794 | default: | |
8795 | continue; | |
8796 | } | |
8797 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; | |
8798 | imux->items[imux->num_items].index = idx1; | |
8799 | imux->num_items++; | |
8800 | } | |
8801 | return 0; | |
8802 | } | |
8803 | ||
8804 | static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec) | |
8805 | { | |
8806 | struct alc_spec *spec = codec->spec; | |
8807 | hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0]; | |
8808 | hda_nid_t hp_nid = spec->autocfg.hp_pins[0]; | |
8809 | hda_nid_t line_nid = spec->autocfg.line_out_pins[0]; | |
8810 | unsigned int dac_vol1, dac_vol2; | |
8811 | ||
8812 | if (speaker_nid) { | |
8813 | snd_hda_codec_write(codec, speaker_nid, 0, | |
8814 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | |
8815 | snd_hda_codec_write(codec, 0x0f, 0, | |
8816 | AC_VERB_SET_AMP_GAIN_MUTE, | |
8817 | AMP_IN_UNMUTE(1)); | |
8818 | snd_hda_codec_write(codec, 0x10, 0, | |
8819 | AC_VERB_SET_AMP_GAIN_MUTE, | |
8820 | AMP_IN_UNMUTE(1)); | |
8821 | } else { | |
8822 | snd_hda_codec_write(codec, 0x0f, 0, | |
8823 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)); | |
8824 | snd_hda_codec_write(codec, 0x10, 0, | |
8825 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)); | |
8826 | } | |
8827 | ||
8828 | dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */ | |
8829 | if (line_nid == 0x14) | |
8830 | dac_vol2 = AMP_OUT_ZERO; | |
8831 | else if (line_nid == 0x15) | |
8832 | dac_vol1 = AMP_OUT_ZERO; | |
8833 | if (hp_nid == 0x14) | |
8834 | dac_vol2 = AMP_OUT_ZERO; | |
8835 | else if (hp_nid == 0x15) | |
8836 | dac_vol1 = AMP_OUT_ZERO; | |
8837 | if (line_nid != 0x16 || hp_nid != 0x16 || | |
8838 | spec->autocfg.line_out_pins[1] != 0x16 || | |
8839 | spec->autocfg.line_out_pins[2] != 0x16) | |
8840 | dac_vol1 = dac_vol2 = AMP_OUT_ZERO; | |
8841 | ||
8842 | snd_hda_codec_write(codec, 0x02, 0, | |
8843 | AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1); | |
8844 | snd_hda_codec_write(codec, 0x03, 0, | |
8845 | AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2); | |
8846 | } | |
8847 | ||
8848 | /* pcm configuration: identiacal with ALC880 */ | |
8849 | #define alc268_pcm_analog_playback alc880_pcm_analog_playback | |
8850 | #define alc268_pcm_analog_capture alc880_pcm_analog_capture | |
8851 | #define alc268_pcm_digital_playback alc880_pcm_digital_playback | |
8852 | ||
8853 | /* | |
8854 | * BIOS auto configuration | |
8855 | */ | |
8856 | static int alc268_parse_auto_config(struct hda_codec *codec) | |
8857 | { | |
8858 | struct alc_spec *spec = codec->spec; | |
8859 | int err; | |
8860 | static hda_nid_t alc268_ignore[] = { 0 }; | |
8861 | ||
8862 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | |
8863 | alc268_ignore); | |
8864 | if (err < 0) | |
8865 | return err; | |
8866 | if (!spec->autocfg.line_outs) | |
8867 | return 0; /* can't find valid BIOS pin config */ | |
8868 | ||
8869 | err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
8870 | if (err < 0) | |
8871 | return err; | |
8872 | err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
8873 | if (err < 0) | |
8874 | return err; | |
8875 | ||
8876 | spec->multiout.max_channels = 2; | |
8877 | ||
8878 | /* digital only support output */ | |
8879 | if (spec->autocfg.dig_out_pin) | |
8880 | spec->multiout.dig_out_nid = ALC268_DIGOUT_NID; | |
8881 | ||
8882 | if (spec->kctl_alloc) | |
8883 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
8884 | ||
8885 | spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs; | |
8886 | spec->num_mux_defs = 1; | |
8887 | spec->input_mux = &spec->private_imux; | |
8888 | ||
8889 | return 1; | |
8890 | } | |
8891 | ||
8892 | #define alc268_auto_init_multi_out alc882_auto_init_multi_out | |
8893 | #define alc268_auto_init_hp_out alc882_auto_init_hp_out | |
8894 | #define alc268_auto_init_analog_input alc882_auto_init_analog_input | |
8895 | ||
8896 | /* init callback for auto-configuration model -- overriding the default init */ | |
8897 | static void alc268_auto_init(struct hda_codec *codec) | |
8898 | { | |
8899 | alc268_auto_init_multi_out(codec); | |
8900 | alc268_auto_init_hp_out(codec); | |
8901 | alc268_auto_init_mono_speaker_out(codec); | |
8902 | alc268_auto_init_analog_input(codec); | |
8903 | } | |
8904 | ||
8905 | /* | |
8906 | * configuration and preset | |
8907 | */ | |
8908 | static const char *alc268_models[ALC268_MODEL_LAST] = { | |
8909 | [ALC268_3ST] = "3stack", | |
983f8ae4 | 8910 | [ALC268_TOSHIBA] = "toshiba", |
d273809e | 8911 | [ALC268_ACER] = "acer", |
a361d84b KY |
8912 | [ALC268_AUTO] = "auto", |
8913 | }; | |
8914 | ||
8915 | static struct snd_pci_quirk alc268_cfg_tbl[] = { | |
8916 | SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST), | |
d1a991a6 | 8917 | SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA), |
d273809e TI |
8918 | SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA), |
8919 | SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER), | |
a361d84b KY |
8920 | {} |
8921 | }; | |
8922 | ||
8923 | static struct alc_config_preset alc268_presets[] = { | |
8924 | [ALC268_3ST] = { | |
8925 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer }, | |
8926 | .init_verbs = { alc268_base_init_verbs }, | |
8927 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
8928 | .dac_nids = alc268_dac_nids, | |
8929 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
8930 | .adc_nids = alc268_adc_nids_alt, | |
8931 | .hp_nid = 0x03, | |
8932 | .dig_out_nid = ALC268_DIGOUT_NID, | |
8933 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
8934 | .channel_mode = alc268_modes, | |
8935 | .input_mux = &alc268_capture_source, | |
8936 | }, | |
d1a991a6 KY |
8937 | [ALC268_TOSHIBA] = { |
8938 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer }, | |
d273809e TI |
8939 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
8940 | alc268_toshiba_verbs }, | |
d1a991a6 KY |
8941 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), |
8942 | .dac_nids = alc268_dac_nids, | |
8943 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
8944 | .adc_nids = alc268_adc_nids_alt, | |
8945 | .hp_nid = 0x03, | |
8946 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
8947 | .channel_mode = alc268_modes, | |
8948 | .input_mux = &alc268_capture_source, | |
d273809e TI |
8949 | .input_mux = &alc268_capture_source, |
8950 | .unsol_event = alc268_toshiba_unsol_event, | |
8951 | .init_hook = alc268_toshiba_automute, | |
8952 | }, | |
8953 | [ALC268_ACER] = { | |
8954 | .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer }, | |
8955 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, | |
8956 | alc268_acer_verbs }, | |
8957 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
8958 | .dac_nids = alc268_dac_nids, | |
8959 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
8960 | .adc_nids = alc268_adc_nids_alt, | |
8961 | .hp_nid = 0x02, | |
8962 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
8963 | .channel_mode = alc268_modes, | |
8964 | .input_mux = &alc268_capture_source, | |
8965 | .unsol_event = alc268_acer_unsol_event, | |
d1a991a6 | 8966 | }, |
a361d84b KY |
8967 | }; |
8968 | ||
8969 | static int patch_alc268(struct hda_codec *codec) | |
8970 | { | |
8971 | struct alc_spec *spec; | |
8972 | int board_config; | |
8973 | int err; | |
8974 | ||
8975 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); | |
8976 | if (spec == NULL) | |
8977 | return -ENOMEM; | |
8978 | ||
8979 | codec->spec = spec; | |
8980 | ||
8981 | board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST, | |
8982 | alc268_models, | |
8983 | alc268_cfg_tbl); | |
8984 | ||
8985 | if (board_config < 0 || board_config >= ALC268_MODEL_LAST) { | |
8986 | printk(KERN_INFO "hda_codec: Unknown model for ALC268, " | |
8987 | "trying auto-probe from BIOS...\n"); | |
8988 | board_config = ALC268_AUTO; | |
8989 | } | |
8990 | ||
8991 | if (board_config == ALC268_AUTO) { | |
8992 | /* automatic parse from the BIOS config */ | |
8993 | err = alc268_parse_auto_config(codec); | |
8994 | if (err < 0) { | |
8995 | alc_free(codec); | |
8996 | return err; | |
8997 | } else if (!err) { | |
8998 | printk(KERN_INFO | |
8999 | "hda_codec: Cannot set up configuration " | |
9000 | "from BIOS. Using base mode...\n"); | |
9001 | board_config = ALC268_3ST; | |
9002 | } | |
9003 | } | |
9004 | ||
9005 | if (board_config != ALC268_AUTO) | |
9006 | setup_preset(spec, &alc268_presets[board_config]); | |
9007 | ||
9008 | spec->stream_name_analog = "ALC268 Analog"; | |
9009 | spec->stream_analog_playback = &alc268_pcm_analog_playback; | |
9010 | spec->stream_analog_capture = &alc268_pcm_analog_capture; | |
9011 | ||
9012 | spec->stream_name_digital = "ALC268 Digital"; | |
9013 | spec->stream_digital_playback = &alc268_pcm_digital_playback; | |
9014 | ||
9015 | if (board_config == ALC268_AUTO) { | |
9016 | if (!spec->adc_nids && spec->input_mux) { | |
9017 | /* check whether NID 0x07 is valid */ | |
9018 | unsigned int wcap = get_wcaps(codec, 0x07); | |
9019 | ||
9020 | /* get type */ | |
9021 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
9022 | if (wcap != AC_WID_AUD_IN) { | |
9023 | spec->adc_nids = alc268_adc_nids_alt; | |
9024 | spec->num_adc_nids = | |
9025 | ARRAY_SIZE(alc268_adc_nids_alt); | |
9026 | spec->mixers[spec->num_mixers] = | |
9027 | alc268_capture_alt_mixer; | |
9028 | spec->num_mixers++; | |
9029 | } else { | |
9030 | spec->adc_nids = alc268_adc_nids; | |
9031 | spec->num_adc_nids = | |
9032 | ARRAY_SIZE(alc268_adc_nids); | |
9033 | spec->mixers[spec->num_mixers] = | |
9034 | alc268_capture_mixer; | |
9035 | spec->num_mixers++; | |
9036 | } | |
9037 | } | |
9038 | } | |
9039 | codec->patch_ops = alc_patch_ops; | |
9040 | if (board_config == ALC268_AUTO) | |
9041 | spec->init_hook = alc268_auto_init; | |
9042 | ||
9043 | return 0; | |
9044 | } | |
9045 | ||
df694daa KY |
9046 | /* |
9047 | * ALC861 channel source setting (2/6 channel selection for 3-stack) | |
9048 | */ | |
9049 | ||
9050 | /* | |
9051 | * set the path ways for 2 channel output | |
9052 | * need to set the codec line out and mic 1 pin widgets to inputs | |
9053 | */ | |
9054 | static struct hda_verb alc861_threestack_ch2_init[] = { | |
9055 | /* set pin widget 1Ah (line in) for input */ | |
9056 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
f12ab1e0 TI |
9057 | /* set pin widget 18h (mic1/2) for input, for mic also enable |
9058 | * the vref | |
9059 | */ | |
df694daa KY |
9060 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
9061 | ||
9c7f852e TI |
9062 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, |
9063 | #if 0 | |
9064 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
9065 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/ | |
9066 | #endif | |
df694daa KY |
9067 | { } /* end */ |
9068 | }; | |
9069 | /* | |
9070 | * 6ch mode | |
9071 | * need to set the codec line out and mic 1 pin widgets to outputs | |
9072 | */ | |
9073 | static struct hda_verb alc861_threestack_ch6_init[] = { | |
9074 | /* set pin widget 1Ah (line in) for output (Back Surround)*/ | |
9075 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
9076 | /* set pin widget 18h (mic1) for output (CLFE)*/ | |
9077 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
9078 | ||
9079 | { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
9c7f852e | 9080 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa | 9081 | |
9c7f852e TI |
9082 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, |
9083 | #if 0 | |
9084 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
9085 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/ | |
9086 | #endif | |
df694daa KY |
9087 | { } /* end */ |
9088 | }; | |
9089 | ||
9090 | static struct hda_channel_mode alc861_threestack_modes[2] = { | |
9091 | { 2, alc861_threestack_ch2_init }, | |
9092 | { 6, alc861_threestack_ch6_init }, | |
9093 | }; | |
22309c3e TI |
9094 | /* Set mic1 as input and unmute the mixer */ |
9095 | static struct hda_verb alc861_uniwill_m31_ch2_init[] = { | |
9096 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
9097 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
9098 | { } /* end */ | |
9099 | }; | |
9100 | /* Set mic1 as output and mute mixer */ | |
9101 | static struct hda_verb alc861_uniwill_m31_ch4_init[] = { | |
9102 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
9103 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
9104 | { } /* end */ | |
9105 | }; | |
9106 | ||
9107 | static struct hda_channel_mode alc861_uniwill_m31_modes[2] = { | |
9108 | { 2, alc861_uniwill_m31_ch2_init }, | |
9109 | { 4, alc861_uniwill_m31_ch4_init }, | |
9110 | }; | |
df694daa | 9111 | |
7cdbff94 MD |
9112 | /* Set mic1 and line-in as input and unmute the mixer */ |
9113 | static struct hda_verb alc861_asus_ch2_init[] = { | |
9114 | /* set pin widget 1Ah (line in) for input */ | |
9115 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
f12ab1e0 TI |
9116 | /* set pin widget 18h (mic1/2) for input, for mic also enable |
9117 | * the vref | |
9118 | */ | |
7cdbff94 MD |
9119 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
9120 | ||
9121 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, | |
9122 | #if 0 | |
9123 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
9124 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/ | |
9125 | #endif | |
9126 | { } /* end */ | |
9127 | }; | |
9128 | /* Set mic1 nad line-in as output and mute mixer */ | |
9129 | static struct hda_verb alc861_asus_ch6_init[] = { | |
9130 | /* set pin widget 1Ah (line in) for output (Back Surround)*/ | |
9131 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
9132 | /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */ | |
9133 | /* set pin widget 18h (mic1) for output (CLFE)*/ | |
9134 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
9135 | /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */ | |
9136 | { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
9137 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
9138 | ||
9139 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, | |
9140 | #if 0 | |
9141 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
9142 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/ | |
9143 | #endif | |
9144 | { } /* end */ | |
9145 | }; | |
9146 | ||
9147 | static struct hda_channel_mode alc861_asus_modes[2] = { | |
9148 | { 2, alc861_asus_ch2_init }, | |
9149 | { 6, alc861_asus_ch6_init }, | |
9150 | }; | |
9151 | ||
df694daa KY |
9152 | /* patch-ALC861 */ |
9153 | ||
9154 | static struct snd_kcontrol_new alc861_base_mixer[] = { | |
9155 | /* output mixer control */ | |
9156 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
9157 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
9158 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
9159 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
9160 | HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), | |
9161 | ||
9162 | /*Input mixer control */ | |
9163 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
9164 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
9165 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
9166 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
9167 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
9168 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
9169 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
9170 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
9171 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
9172 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 9173 | |
df694daa KY |
9174 | /* Capture mixer control */ |
9175 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
9176 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
9177 | { | |
9178 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9179 | .name = "Capture Source", | |
9180 | .count = 1, | |
9181 | .info = alc_mux_enum_info, | |
9182 | .get = alc_mux_enum_get, | |
9183 | .put = alc_mux_enum_put, | |
9184 | }, | |
9185 | { } /* end */ | |
9186 | }; | |
9187 | ||
9188 | static struct snd_kcontrol_new alc861_3ST_mixer[] = { | |
9189 | /* output mixer control */ | |
9190 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
9191 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
9192 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
9193 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
9194 | /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ | |
9195 | ||
9196 | /* Input mixer control */ | |
9197 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
9198 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
9199 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
9200 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
9201 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
9202 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
9203 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
9204 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
9205 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
9206 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 9207 | |
df694daa KY |
9208 | /* Capture mixer control */ |
9209 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
9210 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
9211 | { | |
9212 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9213 | .name = "Capture Source", | |
9214 | .count = 1, | |
9215 | .info = alc_mux_enum_info, | |
9216 | .get = alc_mux_enum_get, | |
9217 | .put = alc_mux_enum_put, | |
9218 | }, | |
9219 | { | |
9220 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9221 | .name = "Channel Mode", | |
9222 | .info = alc_ch_mode_info, | |
9223 | .get = alc_ch_mode_get, | |
9224 | .put = alc_ch_mode_put, | |
9225 | .private_value = ARRAY_SIZE(alc861_threestack_modes), | |
9226 | }, | |
9227 | { } /* end */ | |
a53d1aec TD |
9228 | }; |
9229 | ||
d1d985f0 | 9230 | static struct snd_kcontrol_new alc861_toshiba_mixer[] = { |
a53d1aec TD |
9231 | /* output mixer control */ |
9232 | HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
9233 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
9234 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
9235 | ||
9236 | /*Capture mixer control */ | |
9237 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
9238 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
9239 | { | |
9240 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9241 | .name = "Capture Source", | |
9242 | .count = 1, | |
9243 | .info = alc_mux_enum_info, | |
9244 | .get = alc_mux_enum_get, | |
9245 | .put = alc_mux_enum_put, | |
9246 | }, | |
9247 | ||
9248 | { } /* end */ | |
f12ab1e0 | 9249 | }; |
a53d1aec | 9250 | |
22309c3e TI |
9251 | static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = { |
9252 | /* output mixer control */ | |
9253 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
9254 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
9255 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
9256 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
9257 | /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ | |
9258 | ||
9259 | /* Input mixer control */ | |
9260 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
9261 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
9262 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
9263 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
9264 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
9265 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
9266 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
9267 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
9268 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
9269 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 9270 | |
22309c3e TI |
9271 | /* Capture mixer control */ |
9272 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
9273 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
9274 | { | |
9275 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9276 | .name = "Capture Source", | |
9277 | .count = 1, | |
9278 | .info = alc_mux_enum_info, | |
9279 | .get = alc_mux_enum_get, | |
9280 | .put = alc_mux_enum_put, | |
9281 | }, | |
9282 | { | |
9283 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9284 | .name = "Channel Mode", | |
9285 | .info = alc_ch_mode_info, | |
9286 | .get = alc_ch_mode_get, | |
9287 | .put = alc_ch_mode_put, | |
9288 | .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes), | |
9289 | }, | |
9290 | { } /* end */ | |
f12ab1e0 | 9291 | }; |
7cdbff94 MD |
9292 | |
9293 | static struct snd_kcontrol_new alc861_asus_mixer[] = { | |
9294 | /* output mixer control */ | |
9295 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
9296 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
9297 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
9298 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
9299 | HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), | |
9300 | ||
9301 | /* Input mixer control */ | |
9302 | HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
9303 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
9304 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
9305 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
9306 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
9307 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
9308 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
9309 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
9310 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
f12ab1e0 TI |
9311 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), |
9312 | ||
7cdbff94 MD |
9313 | /* Capture mixer control */ |
9314 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
9315 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
9316 | { | |
9317 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9318 | .name = "Capture Source", | |
9319 | .count = 1, | |
9320 | .info = alc_mux_enum_info, | |
9321 | .get = alc_mux_enum_get, | |
9322 | .put = alc_mux_enum_put, | |
9323 | }, | |
9324 | { | |
9325 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9326 | .name = "Channel Mode", | |
9327 | .info = alc_ch_mode_info, | |
9328 | .get = alc_ch_mode_get, | |
9329 | .put = alc_ch_mode_put, | |
9330 | .private_value = ARRAY_SIZE(alc861_asus_modes), | |
9331 | }, | |
9332 | { } | |
56bb0cab TI |
9333 | }; |
9334 | ||
9335 | /* additional mixer */ | |
d1d985f0 | 9336 | static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = { |
56bb0cab TI |
9337 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), |
9338 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
9339 | HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT), | |
9340 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT), | |
9341 | { } | |
9342 | }; | |
7cdbff94 | 9343 | |
df694daa KY |
9344 | /* |
9345 | * generic initialization of ADC, input mixers and output mixers | |
9346 | */ | |
9347 | static struct hda_verb alc861_base_init_verbs[] = { | |
9348 | /* | |
9349 | * Unmute ADC0 and set the default input to mic-in | |
9350 | */ | |
9351 | /* port-A for surround (rear panel) */ | |
9352 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
9353 | { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
9354 | /* port-B for mic-in (rear panel) with vref */ | |
9355 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
9356 | /* port-C for line-in (rear panel) */ | |
9357 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
9358 | /* port-D for Front */ | |
9359 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
9360 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
9361 | /* port-E for HP out (front panel) */ | |
9362 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | |
9363 | /* route front PCM to HP */ | |
9dece1d7 | 9364 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa KY |
9365 | /* port-F for mic-in (front panel) with vref */ |
9366 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
9367 | /* port-G for CLFE (rear panel) */ | |
9368 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
9369 | { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
9370 | /* port-H for side (rear panel) */ | |
9371 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
9372 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
9373 | /* CD-in */ | |
9374 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
9375 | /* route front mic to ADC1*/ | |
9376 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9377 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9378 | ||
9379 | /* Unmute DAC0~3 & spdif out*/ | |
9380 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9381 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9382 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9383 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9384 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9385 | ||
9386 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
9387 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9388 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9389 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9390 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9391 | ||
9392 | /* Unmute Stereo Mixer 15 */ | |
9393 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9394 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9395 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 9396 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
df694daa KY |
9397 | |
9398 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9399 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9400 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9401 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9402 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9403 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9404 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9405 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
9406 | /* hp used DAC 3 (Front) */ |
9407 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
9408 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
9409 | ||
9410 | { } | |
9411 | }; | |
9412 | ||
9413 | static struct hda_verb alc861_threestack_init_verbs[] = { | |
9414 | /* | |
9415 | * Unmute ADC0 and set the default input to mic-in | |
9416 | */ | |
9417 | /* port-A for surround (rear panel) */ | |
9418 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
9419 | /* port-B for mic-in (rear panel) with vref */ | |
9420 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
9421 | /* port-C for line-in (rear panel) */ | |
9422 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
9423 | /* port-D for Front */ | |
9424 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
9425 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
9426 | /* port-E for HP out (front panel) */ | |
9427 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | |
9428 | /* route front PCM to HP */ | |
9dece1d7 | 9429 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa KY |
9430 | /* port-F for mic-in (front panel) with vref */ |
9431 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
9432 | /* port-G for CLFE (rear panel) */ | |
9433 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
9434 | /* port-H for side (rear panel) */ | |
9435 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
9436 | /* CD-in */ | |
9437 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
9438 | /* route front mic to ADC1*/ | |
9439 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9440 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9441 | /* Unmute DAC0~3 & spdif out*/ | |
9442 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9443 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9444 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9445 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9446 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9447 | ||
9448 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
9449 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9450 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9451 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9452 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9453 | ||
9454 | /* Unmute Stereo Mixer 15 */ | |
9455 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9456 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9457 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 9458 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
df694daa KY |
9459 | |
9460 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9461 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9462 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9463 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9464 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9465 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9466 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9467 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
9468 | /* hp used DAC 3 (Front) */ |
9469 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
9470 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
9471 | { } | |
9472 | }; | |
22309c3e TI |
9473 | |
9474 | static struct hda_verb alc861_uniwill_m31_init_verbs[] = { | |
9475 | /* | |
9476 | * Unmute ADC0 and set the default input to mic-in | |
9477 | */ | |
9478 | /* port-A for surround (rear panel) */ | |
9479 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
9480 | /* port-B for mic-in (rear panel) with vref */ | |
9481 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
9482 | /* port-C for line-in (rear panel) */ | |
9483 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
9484 | /* port-D for Front */ | |
9485 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
9486 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
9487 | /* port-E for HP out (front panel) */ | |
f12ab1e0 TI |
9488 | /* this has to be set to VREF80 */ |
9489 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
22309c3e | 9490 | /* route front PCM to HP */ |
9dece1d7 | 9491 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
22309c3e TI |
9492 | /* port-F for mic-in (front panel) with vref */ |
9493 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
9494 | /* port-G for CLFE (rear panel) */ | |
9495 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
9496 | /* port-H for side (rear panel) */ | |
9497 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
9498 | /* CD-in */ | |
9499 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
9500 | /* route front mic to ADC1*/ | |
9501 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9502 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9503 | /* Unmute DAC0~3 & spdif out*/ | |
9504 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9505 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9506 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9507 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9508 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9509 | ||
9510 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
9511 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9512 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9513 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9514 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9515 | ||
9516 | /* Unmute Stereo Mixer 15 */ | |
9517 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9518 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9519 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 9520 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
22309c3e TI |
9521 | |
9522 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9523 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9524 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9525 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9526 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9527 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9528 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9529 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
9530 | /* hp used DAC 3 (Front) */ |
9531 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
22309c3e TI |
9532 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
9533 | { } | |
9534 | }; | |
9535 | ||
7cdbff94 MD |
9536 | static struct hda_verb alc861_asus_init_verbs[] = { |
9537 | /* | |
9538 | * Unmute ADC0 and set the default input to mic-in | |
9539 | */ | |
f12ab1e0 TI |
9540 | /* port-A for surround (rear panel) |
9541 | * according to codec#0 this is the HP jack | |
9542 | */ | |
7cdbff94 MD |
9543 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */ |
9544 | /* route front PCM to HP */ | |
9545 | { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
9546 | /* port-B for mic-in (rear panel) with vref */ | |
9547 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
9548 | /* port-C for line-in (rear panel) */ | |
9549 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
9550 | /* port-D for Front */ | |
9551 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
9552 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
9553 | /* port-E for HP out (front panel) */ | |
f12ab1e0 TI |
9554 | /* this has to be set to VREF80 */ |
9555 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
7cdbff94 | 9556 | /* route front PCM to HP */ |
9dece1d7 | 9557 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
7cdbff94 MD |
9558 | /* port-F for mic-in (front panel) with vref */ |
9559 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
9560 | /* port-G for CLFE (rear panel) */ | |
9561 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
9562 | /* port-H for side (rear panel) */ | |
9563 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
9564 | /* CD-in */ | |
9565 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
9566 | /* route front mic to ADC1*/ | |
9567 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9568 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9569 | /* Unmute DAC0~3 & spdif out*/ | |
9570 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9571 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9572 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9573 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9574 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9575 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
9576 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9577 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9578 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9579 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9580 | ||
9581 | /* Unmute Stereo Mixer 15 */ | |
9582 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9583 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9584 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 9585 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
7cdbff94 MD |
9586 | |
9587 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9588 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9589 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9590 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9591 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9592 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9593 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9594 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
9595 | /* hp used DAC 3 (Front) */ |
9596 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
7cdbff94 MD |
9597 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
9598 | { } | |
9599 | }; | |
9600 | ||
56bb0cab TI |
9601 | /* additional init verbs for ASUS laptops */ |
9602 | static struct hda_verb alc861_asus_laptop_init_verbs[] = { | |
9603 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */ | |
9604 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */ | |
9605 | { } | |
9606 | }; | |
7cdbff94 | 9607 | |
df694daa KY |
9608 | /* |
9609 | * generic initialization of ADC, input mixers and output mixers | |
9610 | */ | |
9611 | static struct hda_verb alc861_auto_init_verbs[] = { | |
9612 | /* | |
9613 | * Unmute ADC0 and set the default input to mic-in | |
9614 | */ | |
f12ab1e0 | 9615 | /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */ |
df694daa KY |
9616 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
9617 | ||
9618 | /* Unmute DAC0~3 & spdif out*/ | |
9619 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9620 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9621 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9622 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9623 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9624 | ||
9625 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
9626 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9627 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9628 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9629 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9630 | ||
9631 | /* Unmute Stereo Mixer 15 */ | |
9632 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9633 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9634 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
9635 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, | |
9636 | ||
9637 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9638 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9639 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9640 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9641 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9642 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9643 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9644 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9645 | ||
9646 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
9647 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
f12ab1e0 TI |
9648 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
9649 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
9650 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
9651 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
f12ab1e0 TI |
9652 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
9653 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa | 9654 | |
f12ab1e0 | 9655 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */ |
df694daa KY |
9656 | |
9657 | { } | |
9658 | }; | |
9659 | ||
a53d1aec TD |
9660 | static struct hda_verb alc861_toshiba_init_verbs[] = { |
9661 | {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
f12ab1e0 | 9662 | |
a53d1aec TD |
9663 | { } |
9664 | }; | |
9665 | ||
9666 | /* toggle speaker-output according to the hp-jack state */ | |
9667 | static void alc861_toshiba_automute(struct hda_codec *codec) | |
9668 | { | |
9669 | unsigned int present; | |
9670 | ||
9671 | present = snd_hda_codec_read(codec, 0x0f, 0, | |
9672 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
9673 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0, |
9674 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
9675 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3, | |
9676 | HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE); | |
a53d1aec TD |
9677 | } |
9678 | ||
9679 | static void alc861_toshiba_unsol_event(struct hda_codec *codec, | |
9680 | unsigned int res) | |
9681 | { | |
a53d1aec TD |
9682 | if ((res >> 26) == ALC880_HP_EVENT) |
9683 | alc861_toshiba_automute(codec); | |
9684 | } | |
9685 | ||
df694daa KY |
9686 | /* pcm configuration: identiacal with ALC880 */ |
9687 | #define alc861_pcm_analog_playback alc880_pcm_analog_playback | |
9688 | #define alc861_pcm_analog_capture alc880_pcm_analog_capture | |
9689 | #define alc861_pcm_digital_playback alc880_pcm_digital_playback | |
9690 | #define alc861_pcm_digital_capture alc880_pcm_digital_capture | |
9691 | ||
9692 | ||
9693 | #define ALC861_DIGOUT_NID 0x07 | |
9694 | ||
9695 | static struct hda_channel_mode alc861_8ch_modes[1] = { | |
9696 | { 8, NULL } | |
9697 | }; | |
9698 | ||
9699 | static hda_nid_t alc861_dac_nids[4] = { | |
9700 | /* front, surround, clfe, side */ | |
9701 | 0x03, 0x06, 0x05, 0x04 | |
9702 | }; | |
9703 | ||
9c7f852e TI |
9704 | static hda_nid_t alc660_dac_nids[3] = { |
9705 | /* front, clfe, surround */ | |
9706 | 0x03, 0x05, 0x06 | |
9707 | }; | |
9708 | ||
df694daa KY |
9709 | static hda_nid_t alc861_adc_nids[1] = { |
9710 | /* ADC0-2 */ | |
9711 | 0x08, | |
9712 | }; | |
9713 | ||
9714 | static struct hda_input_mux alc861_capture_source = { | |
9715 | .num_items = 5, | |
9716 | .items = { | |
9717 | { "Mic", 0x0 }, | |
9718 | { "Front Mic", 0x3 }, | |
9719 | { "Line", 0x1 }, | |
9720 | { "CD", 0x4 }, | |
9721 | { "Mixer", 0x5 }, | |
9722 | }, | |
9723 | }; | |
9724 | ||
9725 | /* fill in the dac_nids table from the parsed pin configuration */ | |
f12ab1e0 TI |
9726 | static int alc861_auto_fill_dac_nids(struct alc_spec *spec, |
9727 | const struct auto_pin_cfg *cfg) | |
df694daa KY |
9728 | { |
9729 | int i; | |
9730 | hda_nid_t nid; | |
9731 | ||
9732 | spec->multiout.dac_nids = spec->private_dac_nids; | |
9733 | for (i = 0; i < cfg->line_outs; i++) { | |
9734 | nid = cfg->line_out_pins[i]; | |
9735 | if (nid) { | |
9736 | if (i >= ARRAY_SIZE(alc861_dac_nids)) | |
9737 | continue; | |
9738 | spec->multiout.dac_nids[i] = alc861_dac_nids[i]; | |
9739 | } | |
9740 | } | |
9741 | spec->multiout.num_dacs = cfg->line_outs; | |
9742 | return 0; | |
9743 | } | |
9744 | ||
9745 | /* add playback controls from the parsed DAC table */ | |
9746 | static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec, | |
9747 | const struct auto_pin_cfg *cfg) | |
9748 | { | |
9749 | char name[32]; | |
f12ab1e0 TI |
9750 | static const char *chname[4] = { |
9751 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
9752 | }; | |
df694daa KY |
9753 | hda_nid_t nid; |
9754 | int i, idx, err; | |
9755 | ||
9756 | for (i = 0; i < cfg->line_outs; i++) { | |
9757 | nid = spec->multiout.dac_nids[i]; | |
f12ab1e0 | 9758 | if (!nid) |
df694daa KY |
9759 | continue; |
9760 | if (nid == 0x05) { | |
9761 | /* Center/LFE */ | |
f12ab1e0 TI |
9762 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
9763 | "Center Playback Switch", | |
9764 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, | |
9765 | HDA_OUTPUT)); | |
9766 | if (err < 0) | |
df694daa | 9767 | return err; |
f12ab1e0 TI |
9768 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
9769 | "LFE Playback Switch", | |
9770 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
9771 | HDA_OUTPUT)); | |
9772 | if (err < 0) | |
df694daa KY |
9773 | return err; |
9774 | } else { | |
f12ab1e0 TI |
9775 | for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; |
9776 | idx++) | |
df694daa KY |
9777 | if (nid == alc861_dac_nids[idx]) |
9778 | break; | |
9779 | sprintf(name, "%s Playback Switch", chname[idx]); | |
f12ab1e0 TI |
9780 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
9781 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
9782 | HDA_OUTPUT)); | |
9783 | if (err < 0) | |
df694daa KY |
9784 | return err; |
9785 | } | |
9786 | } | |
9787 | return 0; | |
9788 | } | |
9789 | ||
9790 | static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin) | |
9791 | { | |
9792 | int err; | |
9793 | hda_nid_t nid; | |
9794 | ||
f12ab1e0 | 9795 | if (!pin) |
df694daa KY |
9796 | return 0; |
9797 | ||
9798 | if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) { | |
9799 | nid = 0x03; | |
f12ab1e0 TI |
9800 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
9801 | "Headphone Playback Switch", | |
9802 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
9803 | if (err < 0) | |
df694daa KY |
9804 | return err; |
9805 | spec->multiout.hp_nid = nid; | |
9806 | } | |
9807 | return 0; | |
9808 | } | |
9809 | ||
9810 | /* create playback/capture controls for input pins */ | |
f12ab1e0 TI |
9811 | static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, |
9812 | const struct auto_pin_cfg *cfg) | |
df694daa | 9813 | { |
df694daa KY |
9814 | struct hda_input_mux *imux = &spec->private_imux; |
9815 | int i, err, idx, idx1; | |
9816 | ||
9817 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
f12ab1e0 | 9818 | switch (cfg->input_pins[i]) { |
df694daa KY |
9819 | case 0x0c: |
9820 | idx1 = 1; | |
f12ab1e0 | 9821 | idx = 2; /* Line In */ |
df694daa KY |
9822 | break; |
9823 | case 0x0f: | |
9824 | idx1 = 2; | |
f12ab1e0 | 9825 | idx = 2; /* Line In */ |
df694daa KY |
9826 | break; |
9827 | case 0x0d: | |
9828 | idx1 = 0; | |
f12ab1e0 | 9829 | idx = 1; /* Mic In */ |
df694daa | 9830 | break; |
f12ab1e0 | 9831 | case 0x10: |
df694daa | 9832 | idx1 = 3; |
f12ab1e0 | 9833 | idx = 1; /* Mic In */ |
df694daa KY |
9834 | break; |
9835 | case 0x11: | |
9836 | idx1 = 4; | |
f12ab1e0 | 9837 | idx = 0; /* CD */ |
df694daa KY |
9838 | break; |
9839 | default: | |
9840 | continue; | |
9841 | } | |
9842 | ||
4a471b7d TI |
9843 | err = new_analog_input(spec, cfg->input_pins[i], |
9844 | auto_pin_cfg_labels[i], idx, 0x15); | |
df694daa KY |
9845 | if (err < 0) |
9846 | return err; | |
9847 | ||
4a471b7d | 9848 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
df694daa | 9849 | imux->items[imux->num_items].index = idx1; |
f12ab1e0 | 9850 | imux->num_items++; |
df694daa KY |
9851 | } |
9852 | return 0; | |
9853 | } | |
9854 | ||
9855 | static struct snd_kcontrol_new alc861_capture_mixer[] = { | |
9856 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
9857 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
9858 | ||
9859 | { | |
9860 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9861 | /* The multiple "Capture Source" controls confuse alsamixer | |
9862 | * So call somewhat different.. | |
9863 | *FIXME: the controls appear in the "playback" view! | |
9864 | */ | |
9865 | /* .name = "Capture Source", */ | |
9866 | .name = "Input Source", | |
9867 | .count = 1, | |
9868 | .info = alc_mux_enum_info, | |
9869 | .get = alc_mux_enum_get, | |
9870 | .put = alc_mux_enum_put, | |
9871 | }, | |
9872 | { } /* end */ | |
9873 | }; | |
9874 | ||
f12ab1e0 TI |
9875 | static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, |
9876 | hda_nid_t nid, | |
df694daa KY |
9877 | int pin_type, int dac_idx) |
9878 | { | |
9879 | /* set as output */ | |
9880 | ||
f12ab1e0 TI |
9881 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
9882 | pin_type); | |
9883 | snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
9884 | AMP_OUT_UNMUTE); | |
df694daa KY |
9885 | |
9886 | } | |
9887 | ||
9888 | static void alc861_auto_init_multi_out(struct hda_codec *codec) | |
9889 | { | |
9890 | struct alc_spec *spec = codec->spec; | |
9891 | int i; | |
9892 | ||
bc9f98a9 | 9893 | alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b); |
df694daa KY |
9894 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
9895 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 9896 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
df694daa | 9897 | if (nid) |
baba8ee9 | 9898 | alc861_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 9899 | spec->multiout.dac_nids[i]); |
df694daa KY |
9900 | } |
9901 | } | |
9902 | ||
9903 | static void alc861_auto_init_hp_out(struct hda_codec *codec) | |
9904 | { | |
9905 | struct alc_spec *spec = codec->spec; | |
9906 | hda_nid_t pin; | |
9907 | ||
eb06ed8f | 9908 | pin = spec->autocfg.hp_pins[0]; |
df694daa | 9909 | if (pin) /* connect to front */ |
f12ab1e0 TI |
9910 | alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, |
9911 | spec->multiout.dac_nids[0]); | |
df694daa KY |
9912 | } |
9913 | ||
9914 | static void alc861_auto_init_analog_input(struct hda_codec *codec) | |
9915 | { | |
9916 | struct alc_spec *spec = codec->spec; | |
9917 | int i; | |
9918 | ||
9919 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
9920 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
f12ab1e0 TI |
9921 | if (nid >= 0x0c && nid <= 0x11) { |
9922 | snd_hda_codec_write(codec, nid, 0, | |
9923 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
9924 | i <= AUTO_PIN_FRONT_MIC ? | |
9925 | PIN_VREF80 : PIN_IN); | |
df694daa KY |
9926 | } |
9927 | } | |
9928 | } | |
9929 | ||
9930 | /* parse the BIOS configuration and set up the alc_spec */ | |
f12ab1e0 TI |
9931 | /* return 1 if successful, 0 if the proper config is not found, |
9932 | * or a negative error code | |
9933 | */ | |
df694daa KY |
9934 | static int alc861_parse_auto_config(struct hda_codec *codec) |
9935 | { | |
9936 | struct alc_spec *spec = codec->spec; | |
9937 | int err; | |
9938 | static hda_nid_t alc861_ignore[] = { 0x1d, 0 }; | |
9939 | ||
f12ab1e0 TI |
9940 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
9941 | alc861_ignore); | |
9942 | if (err < 0) | |
df694daa | 9943 | return err; |
f12ab1e0 | 9944 | if (!spec->autocfg.line_outs) |
df694daa KY |
9945 | return 0; /* can't find valid BIOS pin config */ |
9946 | ||
f12ab1e0 TI |
9947 | err = alc861_auto_fill_dac_nids(spec, &spec->autocfg); |
9948 | if (err < 0) | |
9949 | return err; | |
9950 | err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
9951 | if (err < 0) | |
9952 | return err; | |
9953 | err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); | |
9954 | if (err < 0) | |
9955 | return err; | |
9956 | err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
9957 | if (err < 0) | |
df694daa KY |
9958 | return err; |
9959 | ||
9960 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
9961 | ||
9962 | if (spec->autocfg.dig_out_pin) | |
9963 | spec->multiout.dig_out_nid = ALC861_DIGOUT_NID; | |
9964 | ||
9965 | if (spec->kctl_alloc) | |
9966 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
9967 | ||
9968 | spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs; | |
9969 | ||
a1e8d2da | 9970 | spec->num_mux_defs = 1; |
df694daa KY |
9971 | spec->input_mux = &spec->private_imux; |
9972 | ||
9973 | spec->adc_nids = alc861_adc_nids; | |
9974 | spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); | |
9975 | spec->mixers[spec->num_mixers] = alc861_capture_mixer; | |
9976 | spec->num_mixers++; | |
9977 | ||
9978 | return 1; | |
9979 | } | |
9980 | ||
ae6b813a TI |
9981 | /* additional initialization for auto-configuration model */ |
9982 | static void alc861_auto_init(struct hda_codec *codec) | |
df694daa | 9983 | { |
df694daa KY |
9984 | alc861_auto_init_multi_out(codec); |
9985 | alc861_auto_init_hp_out(codec); | |
9986 | alc861_auto_init_analog_input(codec); | |
df694daa KY |
9987 | } |
9988 | ||
cb53c626 TI |
9989 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
9990 | static struct hda_amp_list alc861_loopbacks[] = { | |
9991 | { 0x15, HDA_INPUT, 0 }, | |
9992 | { 0x15, HDA_INPUT, 1 }, | |
9993 | { 0x15, HDA_INPUT, 2 }, | |
9994 | { 0x15, HDA_INPUT, 3 }, | |
9995 | { } /* end */ | |
9996 | }; | |
9997 | #endif | |
9998 | ||
df694daa KY |
9999 | |
10000 | /* | |
10001 | * configuration and preset | |
10002 | */ | |
f5fcc13c TI |
10003 | static const char *alc861_models[ALC861_MODEL_LAST] = { |
10004 | [ALC861_3ST] = "3stack", | |
10005 | [ALC660_3ST] = "3stack-660", | |
10006 | [ALC861_3ST_DIG] = "3stack-dig", | |
10007 | [ALC861_6ST_DIG] = "6stack-dig", | |
10008 | [ALC861_UNIWILL_M31] = "uniwill-m31", | |
10009 | [ALC861_TOSHIBA] = "toshiba", | |
10010 | [ALC861_ASUS] = "asus", | |
10011 | [ALC861_ASUS_LAPTOP] = "asus-laptop", | |
10012 | [ALC861_AUTO] = "auto", | |
10013 | }; | |
10014 | ||
10015 | static struct snd_pci_quirk alc861_cfg_tbl[] = { | |
687a47bd | 10016 | SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST), |
f5fcc13c TI |
10017 | SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP), |
10018 | SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP), | |
f223a9fc | 10019 | SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP), |
83c34218 | 10020 | SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP), |
f5fcc13c | 10021 | SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS), |
83c34218 | 10022 | SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG), |
ad5e7737 | 10023 | SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA), |
341d4eb0 TI |
10024 | /* FIXME: the entry below breaks Toshiba A100 (model=auto works!) |
10025 | * Any other models that need this preset? | |
10026 | */ | |
10027 | /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */ | |
f5fcc13c | 10028 | SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31), |
35739bb1 | 10029 | SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), |
4147dab6 | 10030 | SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31), |
07e038b3 | 10031 | SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST), |
f5fcc13c | 10032 | SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST), |
ef64adbb CM |
10033 | SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST), |
10034 | SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST), | |
df694daa KY |
10035 | {} |
10036 | }; | |
10037 | ||
10038 | static struct alc_config_preset alc861_presets[] = { | |
10039 | [ALC861_3ST] = { | |
10040 | .mixers = { alc861_3ST_mixer }, | |
10041 | .init_verbs = { alc861_threestack_init_verbs }, | |
10042 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
10043 | .dac_nids = alc861_dac_nids, | |
10044 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
10045 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 10046 | .need_dac_fix = 1, |
df694daa KY |
10047 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
10048 | .adc_nids = alc861_adc_nids, | |
10049 | .input_mux = &alc861_capture_source, | |
10050 | }, | |
10051 | [ALC861_3ST_DIG] = { | |
10052 | .mixers = { alc861_base_mixer }, | |
10053 | .init_verbs = { alc861_threestack_init_verbs }, | |
10054 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
10055 | .dac_nids = alc861_dac_nids, | |
10056 | .dig_out_nid = ALC861_DIGOUT_NID, | |
10057 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
10058 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 10059 | .need_dac_fix = 1, |
df694daa KY |
10060 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
10061 | .adc_nids = alc861_adc_nids, | |
10062 | .input_mux = &alc861_capture_source, | |
10063 | }, | |
10064 | [ALC861_6ST_DIG] = { | |
10065 | .mixers = { alc861_base_mixer }, | |
10066 | .init_verbs = { alc861_base_init_verbs }, | |
10067 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
10068 | .dac_nids = alc861_dac_nids, | |
10069 | .dig_out_nid = ALC861_DIGOUT_NID, | |
10070 | .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes), | |
10071 | .channel_mode = alc861_8ch_modes, | |
10072 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
10073 | .adc_nids = alc861_adc_nids, | |
10074 | .input_mux = &alc861_capture_source, | |
10075 | }, | |
9c7f852e TI |
10076 | [ALC660_3ST] = { |
10077 | .mixers = { alc861_3ST_mixer }, | |
10078 | .init_verbs = { alc861_threestack_init_verbs }, | |
10079 | .num_dacs = ARRAY_SIZE(alc660_dac_nids), | |
10080 | .dac_nids = alc660_dac_nids, | |
10081 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
10082 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 10083 | .need_dac_fix = 1, |
9c7f852e TI |
10084 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
10085 | .adc_nids = alc861_adc_nids, | |
10086 | .input_mux = &alc861_capture_source, | |
10087 | }, | |
22309c3e TI |
10088 | [ALC861_UNIWILL_M31] = { |
10089 | .mixers = { alc861_uniwill_m31_mixer }, | |
10090 | .init_verbs = { alc861_uniwill_m31_init_verbs }, | |
10091 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
10092 | .dac_nids = alc861_dac_nids, | |
10093 | .dig_out_nid = ALC861_DIGOUT_NID, | |
10094 | .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes), | |
10095 | .channel_mode = alc861_uniwill_m31_modes, | |
10096 | .need_dac_fix = 1, | |
10097 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
10098 | .adc_nids = alc861_adc_nids, | |
10099 | .input_mux = &alc861_capture_source, | |
10100 | }, | |
a53d1aec TD |
10101 | [ALC861_TOSHIBA] = { |
10102 | .mixers = { alc861_toshiba_mixer }, | |
f12ab1e0 TI |
10103 | .init_verbs = { alc861_base_init_verbs, |
10104 | alc861_toshiba_init_verbs }, | |
a53d1aec TD |
10105 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), |
10106 | .dac_nids = alc861_dac_nids, | |
10107 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
10108 | .channel_mode = alc883_3ST_2ch_modes, | |
10109 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
10110 | .adc_nids = alc861_adc_nids, | |
10111 | .input_mux = &alc861_capture_source, | |
10112 | .unsol_event = alc861_toshiba_unsol_event, | |
10113 | .init_hook = alc861_toshiba_automute, | |
10114 | }, | |
7cdbff94 MD |
10115 | [ALC861_ASUS] = { |
10116 | .mixers = { alc861_asus_mixer }, | |
10117 | .init_verbs = { alc861_asus_init_verbs }, | |
10118 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
10119 | .dac_nids = alc861_dac_nids, | |
10120 | .dig_out_nid = ALC861_DIGOUT_NID, | |
10121 | .num_channel_mode = ARRAY_SIZE(alc861_asus_modes), | |
10122 | .channel_mode = alc861_asus_modes, | |
10123 | .need_dac_fix = 1, | |
10124 | .hp_nid = 0x06, | |
10125 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
10126 | .adc_nids = alc861_adc_nids, | |
10127 | .input_mux = &alc861_capture_source, | |
10128 | }, | |
56bb0cab TI |
10129 | [ALC861_ASUS_LAPTOP] = { |
10130 | .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer }, | |
10131 | .init_verbs = { alc861_asus_init_verbs, | |
10132 | alc861_asus_laptop_init_verbs }, | |
10133 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
10134 | .dac_nids = alc861_dac_nids, | |
10135 | .dig_out_nid = ALC861_DIGOUT_NID, | |
10136 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
10137 | .channel_mode = alc883_3ST_2ch_modes, | |
10138 | .need_dac_fix = 1, | |
10139 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
10140 | .adc_nids = alc861_adc_nids, | |
10141 | .input_mux = &alc861_capture_source, | |
10142 | }, | |
10143 | }; | |
df694daa KY |
10144 | |
10145 | ||
10146 | static int patch_alc861(struct hda_codec *codec) | |
10147 | { | |
10148 | struct alc_spec *spec; | |
10149 | int board_config; | |
10150 | int err; | |
10151 | ||
dc041e0b | 10152 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
df694daa KY |
10153 | if (spec == NULL) |
10154 | return -ENOMEM; | |
10155 | ||
f12ab1e0 | 10156 | codec->spec = spec; |
df694daa | 10157 | |
f5fcc13c TI |
10158 | board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST, |
10159 | alc861_models, | |
10160 | alc861_cfg_tbl); | |
9c7f852e | 10161 | |
f5fcc13c | 10162 | if (board_config < 0) { |
9c7f852e TI |
10163 | printk(KERN_INFO "hda_codec: Unknown model for ALC861, " |
10164 | "trying auto-probe from BIOS...\n"); | |
df694daa KY |
10165 | board_config = ALC861_AUTO; |
10166 | } | |
10167 | ||
10168 | if (board_config == ALC861_AUTO) { | |
10169 | /* automatic parse from the BIOS config */ | |
10170 | err = alc861_parse_auto_config(codec); | |
10171 | if (err < 0) { | |
10172 | alc_free(codec); | |
10173 | return err; | |
f12ab1e0 | 10174 | } else if (!err) { |
9c7f852e TI |
10175 | printk(KERN_INFO |
10176 | "hda_codec: Cannot set up configuration " | |
10177 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
10178 | board_config = ALC861_3ST_DIG; |
10179 | } | |
10180 | } | |
10181 | ||
10182 | if (board_config != ALC861_AUTO) | |
10183 | setup_preset(spec, &alc861_presets[board_config]); | |
10184 | ||
10185 | spec->stream_name_analog = "ALC861 Analog"; | |
10186 | spec->stream_analog_playback = &alc861_pcm_analog_playback; | |
10187 | spec->stream_analog_capture = &alc861_pcm_analog_capture; | |
10188 | ||
10189 | spec->stream_name_digital = "ALC861 Digital"; | |
10190 | spec->stream_digital_playback = &alc861_pcm_digital_playback; | |
10191 | spec->stream_digital_capture = &alc861_pcm_digital_capture; | |
10192 | ||
10193 | codec->patch_ops = alc_patch_ops; | |
10194 | if (board_config == ALC861_AUTO) | |
ae6b813a | 10195 | spec->init_hook = alc861_auto_init; |
cb53c626 TI |
10196 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
10197 | if (!spec->loopback.amplist) | |
10198 | spec->loopback.amplist = alc861_loopbacks; | |
10199 | #endif | |
df694daa | 10200 | |
1da177e4 LT |
10201 | return 0; |
10202 | } | |
10203 | ||
f32610ed JS |
10204 | /* |
10205 | * ALC861-VD support | |
10206 | * | |
10207 | * Based on ALC882 | |
10208 | * | |
10209 | * In addition, an independent DAC | |
10210 | */ | |
10211 | #define ALC861VD_DIGOUT_NID 0x06 | |
10212 | ||
10213 | static hda_nid_t alc861vd_dac_nids[4] = { | |
10214 | /* front, surr, clfe, side surr */ | |
10215 | 0x02, 0x03, 0x04, 0x05 | |
10216 | }; | |
10217 | ||
10218 | /* dac_nids for ALC660vd are in a different order - according to | |
10219 | * Realtek's driver. | |
10220 | * This should probably tesult in a different mixer for 6stack models | |
10221 | * of ALC660vd codecs, but for now there is only 3stack mixer | |
10222 | * - and it is the same as in 861vd. | |
10223 | * adc_nids in ALC660vd are (is) the same as in 861vd | |
10224 | */ | |
10225 | static hda_nid_t alc660vd_dac_nids[3] = { | |
10226 | /* front, rear, clfe, rear_surr */ | |
10227 | 0x02, 0x04, 0x03 | |
10228 | }; | |
10229 | ||
10230 | static hda_nid_t alc861vd_adc_nids[1] = { | |
10231 | /* ADC0 */ | |
10232 | 0x09, | |
10233 | }; | |
10234 | ||
10235 | /* input MUX */ | |
10236 | /* FIXME: should be a matrix-type input source selection */ | |
10237 | static struct hda_input_mux alc861vd_capture_source = { | |
10238 | .num_items = 4, | |
10239 | .items = { | |
10240 | { "Mic", 0x0 }, | |
10241 | { "Front Mic", 0x1 }, | |
10242 | { "Line", 0x2 }, | |
10243 | { "CD", 0x4 }, | |
10244 | }, | |
10245 | }; | |
10246 | ||
272a527c KY |
10247 | static struct hda_input_mux alc861vd_dallas_capture_source = { |
10248 | .num_items = 3, | |
10249 | .items = { | |
10250 | { "Front Mic", 0x0 }, | |
10251 | { "ATAPI Mic", 0x1 }, | |
10252 | { "Line In", 0x5 }, | |
10253 | }, | |
10254 | }; | |
10255 | ||
d1a991a6 KY |
10256 | static struct hda_input_mux alc861vd_hp_capture_source = { |
10257 | .num_items = 2, | |
10258 | .items = { | |
10259 | { "Front Mic", 0x0 }, | |
10260 | { "ATAPI Mic", 0x1 }, | |
10261 | }, | |
10262 | }; | |
10263 | ||
f32610ed JS |
10264 | #define alc861vd_mux_enum_info alc_mux_enum_info |
10265 | #define alc861vd_mux_enum_get alc_mux_enum_get | |
10266 | ||
10267 | static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol, | |
10268 | struct snd_ctl_elem_value *ucontrol) | |
10269 | { | |
10270 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
10271 | struct alc_spec *spec = codec->spec; | |
10272 | const struct hda_input_mux *imux = spec->input_mux; | |
10273 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
10274 | static hda_nid_t capture_mixers[1] = { 0x22 }; | |
10275 | hda_nid_t nid = capture_mixers[adc_idx]; | |
10276 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; | |
10277 | unsigned int i, idx; | |
10278 | ||
10279 | idx = ucontrol->value.enumerated.item[0]; | |
10280 | if (idx >= imux->num_items) | |
10281 | idx = imux->num_items - 1; | |
82beb8fd | 10282 | if (*cur_val == idx) |
f32610ed JS |
10283 | return 0; |
10284 | for (i = 0; i < imux->num_items; i++) { | |
47fd830a TI |
10285 | unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE; |
10286 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, | |
10287 | imux->items[i].index, | |
10288 | HDA_AMP_MUTE, v); | |
f32610ed JS |
10289 | } |
10290 | *cur_val = idx; | |
10291 | return 1; | |
10292 | } | |
10293 | ||
10294 | /* | |
10295 | * 2ch mode | |
10296 | */ | |
10297 | static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = { | |
10298 | { 2, NULL } | |
10299 | }; | |
10300 | ||
10301 | /* | |
10302 | * 6ch mode | |
10303 | */ | |
10304 | static struct hda_verb alc861vd_6stack_ch6_init[] = { | |
10305 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
10306 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
10307 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
10308 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
10309 | { } /* end */ | |
10310 | }; | |
10311 | ||
10312 | /* | |
10313 | * 8ch mode | |
10314 | */ | |
10315 | static struct hda_verb alc861vd_6stack_ch8_init[] = { | |
10316 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
10317 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
10318 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
10319 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
10320 | { } /* end */ | |
10321 | }; | |
10322 | ||
10323 | static struct hda_channel_mode alc861vd_6stack_modes[2] = { | |
10324 | { 6, alc861vd_6stack_ch6_init }, | |
10325 | { 8, alc861vd_6stack_ch8_init }, | |
10326 | }; | |
10327 | ||
10328 | static struct snd_kcontrol_new alc861vd_chmode_mixer[] = { | |
10329 | { | |
10330 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10331 | .name = "Channel Mode", | |
10332 | .info = alc_ch_mode_info, | |
10333 | .get = alc_ch_mode_get, | |
10334 | .put = alc_ch_mode_put, | |
10335 | }, | |
10336 | { } /* end */ | |
10337 | }; | |
10338 | ||
10339 | static struct snd_kcontrol_new alc861vd_capture_mixer[] = { | |
10340 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
10341 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
10342 | ||
10343 | { | |
10344 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10345 | /* The multiple "Capture Source" controls confuse alsamixer | |
10346 | * So call somewhat different.. | |
10347 | *FIXME: the controls appear in the "playback" view! | |
10348 | */ | |
10349 | /* .name = "Capture Source", */ | |
10350 | .name = "Input Source", | |
10351 | .count = 1, | |
10352 | .info = alc861vd_mux_enum_info, | |
10353 | .get = alc861vd_mux_enum_get, | |
10354 | .put = alc861vd_mux_enum_put, | |
10355 | }, | |
10356 | { } /* end */ | |
10357 | }; | |
10358 | ||
10359 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 | |
10360 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
10361 | */ | |
10362 | static struct snd_kcontrol_new alc861vd_6st_mixer[] = { | |
10363 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
10364 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
10365 | ||
10366 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
10367 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
10368 | ||
10369 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, | |
10370 | HDA_OUTPUT), | |
10371 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, | |
10372 | HDA_OUTPUT), | |
10373 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
10374 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
10375 | ||
10376 | HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT), | |
10377 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
10378 | ||
10379 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
10380 | ||
10381 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
10382 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
10383 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
10384 | ||
10385 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
10386 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
10387 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
10388 | ||
10389 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
10390 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
10391 | ||
10392 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
10393 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
10394 | ||
10395 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
10396 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
10397 | ||
10398 | { } /* end */ | |
10399 | }; | |
10400 | ||
10401 | static struct snd_kcontrol_new alc861vd_3st_mixer[] = { | |
10402 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
10403 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
10404 | ||
10405 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
10406 | ||
10407 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
10408 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
10409 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
10410 | ||
10411 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
10412 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
10413 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
10414 | ||
10415 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
10416 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
10417 | ||
10418 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
10419 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
10420 | ||
10421 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
10422 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
10423 | ||
10424 | { } /* end */ | |
10425 | }; | |
10426 | ||
bdd148a3 KY |
10427 | static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = { |
10428 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
10429 | /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/ | |
10430 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
10431 | ||
10432 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
10433 | ||
10434 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
10435 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
10436 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
10437 | ||
10438 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
10439 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
10440 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
10441 | ||
10442 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
10443 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
10444 | ||
10445 | { } /* end */ | |
10446 | }; | |
10447 | ||
272a527c KY |
10448 | /* Pin assignment: Front=0x14, HP = 0x15, |
10449 | * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d | |
10450 | */ | |
10451 | static struct snd_kcontrol_new alc861vd_dallas_mixer[] = { | |
10452 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
10453 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
10454 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
10455 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), | |
10456 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
10457 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
10458 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
10459 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
10460 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
10461 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
272a527c KY |
10462 | { } /* end */ |
10463 | }; | |
10464 | ||
d1a991a6 KY |
10465 | /* Pin assignment: Speaker=0x14, Line-out = 0x15, |
10466 | * Front Mic=0x18, ATAPI Mic = 0x19, | |
10467 | */ | |
10468 | static struct snd_kcontrol_new alc861vd_hp_mixer[] = { | |
10469 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
10470 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
10471 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
10472 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), | |
10473 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
10474 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
10475 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
10476 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
10477 | ||
10478 | { } /* end */ | |
10479 | }; | |
10480 | ||
f32610ed JS |
10481 | /* |
10482 | * generic initialization of ADC, input mixers and output mixers | |
10483 | */ | |
10484 | static struct hda_verb alc861vd_volume_init_verbs[] = { | |
10485 | /* | |
10486 | * Unmute ADC0 and set the default input to mic-in | |
10487 | */ | |
10488 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10489 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10490 | ||
10491 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of | |
10492 | * the analog-loopback mixer widget | |
10493 | */ | |
10494 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
10495 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
10496 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10497 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
10498 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
10499 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
f32610ed JS |
10500 | |
10501 | /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */ | |
bdd148a3 KY |
10502 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
10503 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10504 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f32610ed | 10505 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
f32610ed JS |
10506 | |
10507 | /* | |
10508 | * Set up output mixers (0x02 - 0x05) | |
10509 | */ | |
10510 | /* set vol=0 to output mixers */ | |
10511 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10512 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10513 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10514 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10515 | ||
10516 | /* set up input amps for analog loopback */ | |
10517 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
10518 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
10519 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10520 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
10521 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10522 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
10523 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10524 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
10525 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10526 | ||
10527 | { } | |
10528 | }; | |
10529 | ||
10530 | /* | |
10531 | * 3-stack pin configuration: | |
10532 | * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b | |
10533 | */ | |
10534 | static struct hda_verb alc861vd_3stack_init_verbs[] = { | |
10535 | /* | |
10536 | * Set pin mode and muting | |
10537 | */ | |
10538 | /* set front pin widgets 0x14 for output */ | |
10539 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
10540 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10541 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10542 | ||
10543 | /* Mic (rear) pin: input vref at 80% */ | |
10544 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
10545 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10546 | /* Front Mic pin: input vref at 80% */ | |
10547 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
10548 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10549 | /* Line In pin: input */ | |
10550 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
10551 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10552 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
10553 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
10554 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10555 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10556 | /* CD pin widget for input */ | |
10557 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
10558 | ||
10559 | { } | |
10560 | }; | |
10561 | ||
10562 | /* | |
10563 | * 6-stack pin configuration: | |
10564 | */ | |
10565 | static struct hda_verb alc861vd_6stack_init_verbs[] = { | |
10566 | /* | |
10567 | * Set pin mode and muting | |
10568 | */ | |
10569 | /* set front pin widgets 0x14 for output */ | |
10570 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
10571 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10572 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10573 | ||
10574 | /* Rear Pin: output 1 (0x0d) */ | |
10575 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
10576 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10577 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
10578 | /* CLFE Pin: output 2 (0x0e) */ | |
10579 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
10580 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10581 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
10582 | /* Side Pin: output 3 (0x0f) */ | |
10583 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
10584 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10585 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
10586 | ||
10587 | /* Mic (rear) pin: input vref at 80% */ | |
10588 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
10589 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10590 | /* Front Mic pin: input vref at 80% */ | |
10591 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
10592 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10593 | /* Line In pin: input */ | |
10594 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
10595 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10596 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
10597 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
10598 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10599 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10600 | /* CD pin widget for input */ | |
10601 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
10602 | ||
10603 | { } | |
10604 | }; | |
10605 | ||
bdd148a3 KY |
10606 | static struct hda_verb alc861vd_eapd_verbs[] = { |
10607 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
10608 | { } | |
10609 | }; | |
10610 | ||
10611 | static struct hda_verb alc861vd_lenovo_unsol_verbs[] = { | |
10612 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10613 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10614 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
10615 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
10616 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
10617 | {} | |
10618 | }; | |
10619 | ||
10620 | /* toggle speaker-output according to the hp-jack state */ | |
10621 | static void alc861vd_lenovo_hp_automute(struct hda_codec *codec) | |
10622 | { | |
10623 | unsigned int present; | |
10624 | unsigned char bits; | |
10625 | ||
10626 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
10627 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
10628 | bits = present ? HDA_AMP_MUTE : 0; |
10629 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
10630 | HDA_AMP_MUTE, bits); | |
bdd148a3 KY |
10631 | } |
10632 | ||
10633 | static void alc861vd_lenovo_mic_automute(struct hda_codec *codec) | |
10634 | { | |
10635 | unsigned int present; | |
10636 | unsigned char bits; | |
10637 | ||
10638 | present = snd_hda_codec_read(codec, 0x18, 0, | |
10639 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
10640 | bits = present ? HDA_AMP_MUTE : 0; |
10641 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, | |
10642 | HDA_AMP_MUTE, bits); | |
bdd148a3 KY |
10643 | } |
10644 | ||
10645 | static void alc861vd_lenovo_automute(struct hda_codec *codec) | |
10646 | { | |
10647 | alc861vd_lenovo_hp_automute(codec); | |
10648 | alc861vd_lenovo_mic_automute(codec); | |
10649 | } | |
10650 | ||
10651 | static void alc861vd_lenovo_unsol_event(struct hda_codec *codec, | |
10652 | unsigned int res) | |
10653 | { | |
10654 | switch (res >> 26) { | |
10655 | case ALC880_HP_EVENT: | |
10656 | alc861vd_lenovo_hp_automute(codec); | |
10657 | break; | |
10658 | case ALC880_MIC_EVENT: | |
10659 | alc861vd_lenovo_mic_automute(codec); | |
10660 | break; | |
10661 | } | |
10662 | } | |
10663 | ||
272a527c KY |
10664 | static struct hda_verb alc861vd_dallas_verbs[] = { |
10665 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10666 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10667 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10668 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10669 | ||
10670 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10671 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10672 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
10673 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10674 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
10675 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10676 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
10677 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10678 | ||
10679 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
10680 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10681 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
10682 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10683 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
10684 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10685 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
10686 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10687 | ||
10688 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | |
10689 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10690 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | |
10691 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10692 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
10693 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
10694 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
10695 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
10696 | ||
10697 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10698 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
10699 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
10700 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
10701 | ||
10702 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
10703 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10704 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
10705 | ||
10706 | { } /* end */ | |
10707 | }; | |
10708 | ||
10709 | /* toggle speaker-output according to the hp-jack state */ | |
10710 | static void alc861vd_dallas_automute(struct hda_codec *codec) | |
10711 | { | |
10712 | unsigned int present; | |
10713 | ||
10714 | present = snd_hda_codec_read(codec, 0x15, 0, | |
10715 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
10716 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
10717 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c KY |
10718 | } |
10719 | ||
10720 | static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res) | |
10721 | { | |
10722 | if ((res >> 26) == ALC880_HP_EVENT) | |
10723 | alc861vd_dallas_automute(codec); | |
10724 | } | |
10725 | ||
cb53c626 TI |
10726 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
10727 | #define alc861vd_loopbacks alc880_loopbacks | |
10728 | #endif | |
10729 | ||
f32610ed JS |
10730 | /* pcm configuration: identiacal with ALC880 */ |
10731 | #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback | |
10732 | #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture | |
10733 | #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback | |
10734 | #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture | |
10735 | ||
10736 | /* | |
10737 | * configuration and preset | |
10738 | */ | |
10739 | static const char *alc861vd_models[ALC861VD_MODEL_LAST] = { | |
10740 | [ALC660VD_3ST] = "3stack-660", | |
983f8ae4 | 10741 | [ALC660VD_3ST_DIG] = "3stack-660-digout", |
f32610ed JS |
10742 | [ALC861VD_3ST] = "3stack", |
10743 | [ALC861VD_3ST_DIG] = "3stack-digout", | |
10744 | [ALC861VD_6ST_DIG] = "6stack-digout", | |
bdd148a3 | 10745 | [ALC861VD_LENOVO] = "lenovo", |
272a527c | 10746 | [ALC861VD_DALLAS] = "dallas", |
983f8ae4 | 10747 | [ALC861VD_HP] = "hp", |
f32610ed JS |
10748 | [ALC861VD_AUTO] = "auto", |
10749 | }; | |
10750 | ||
10751 | static struct snd_pci_quirk alc861vd_cfg_tbl[] = { | |
07e038b3 | 10752 | SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST), |
f32610ed | 10753 | SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST), |
6963f84c | 10754 | SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG), |
f32610ed JS |
10755 | SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST), |
10756 | SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST), | |
10757 | ||
38baf5ad | 10758 | /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/ |
272a527c | 10759 | SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS), |
bdd148a3 KY |
10760 | SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO), |
10761 | SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO), | |
a18519e1 | 10762 | SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO), |
542d7c66 | 10763 | SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO), |
39c5d41f | 10764 | SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG), |
625dc0bf | 10765 | SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG), |
d1a991a6 | 10766 | SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP), |
f32610ed JS |
10767 | {} |
10768 | }; | |
10769 | ||
10770 | static struct alc_config_preset alc861vd_presets[] = { | |
10771 | [ALC660VD_3ST] = { | |
10772 | .mixers = { alc861vd_3st_mixer }, | |
10773 | .init_verbs = { alc861vd_volume_init_verbs, | |
10774 | alc861vd_3stack_init_verbs }, | |
10775 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
10776 | .dac_nids = alc660vd_dac_nids, | |
10777 | .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids), | |
10778 | .adc_nids = alc861vd_adc_nids, | |
10779 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
10780 | .channel_mode = alc861vd_3stack_2ch_modes, | |
10781 | .input_mux = &alc861vd_capture_source, | |
10782 | }, | |
6963f84c MC |
10783 | [ALC660VD_3ST_DIG] = { |
10784 | .mixers = { alc861vd_3st_mixer }, | |
10785 | .init_verbs = { alc861vd_volume_init_verbs, | |
10786 | alc861vd_3stack_init_verbs }, | |
10787 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
10788 | .dac_nids = alc660vd_dac_nids, | |
10789 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
10790 | .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids), | |
10791 | .adc_nids = alc861vd_adc_nids, | |
10792 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
10793 | .channel_mode = alc861vd_3stack_2ch_modes, | |
10794 | .input_mux = &alc861vd_capture_source, | |
10795 | }, | |
f32610ed JS |
10796 | [ALC861VD_3ST] = { |
10797 | .mixers = { alc861vd_3st_mixer }, | |
10798 | .init_verbs = { alc861vd_volume_init_verbs, | |
10799 | alc861vd_3stack_init_verbs }, | |
10800 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
10801 | .dac_nids = alc861vd_dac_nids, | |
10802 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
10803 | .channel_mode = alc861vd_3stack_2ch_modes, | |
10804 | .input_mux = &alc861vd_capture_source, | |
10805 | }, | |
10806 | [ALC861VD_3ST_DIG] = { | |
10807 | .mixers = { alc861vd_3st_mixer }, | |
10808 | .init_verbs = { alc861vd_volume_init_verbs, | |
10809 | alc861vd_3stack_init_verbs }, | |
10810 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
10811 | .dac_nids = alc861vd_dac_nids, | |
10812 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
10813 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
10814 | .channel_mode = alc861vd_3stack_2ch_modes, | |
10815 | .input_mux = &alc861vd_capture_source, | |
10816 | }, | |
10817 | [ALC861VD_6ST_DIG] = { | |
10818 | .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer }, | |
10819 | .init_verbs = { alc861vd_volume_init_verbs, | |
10820 | alc861vd_6stack_init_verbs }, | |
10821 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
10822 | .dac_nids = alc861vd_dac_nids, | |
10823 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
10824 | .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes), | |
10825 | .channel_mode = alc861vd_6stack_modes, | |
10826 | .input_mux = &alc861vd_capture_source, | |
10827 | }, | |
bdd148a3 KY |
10828 | [ALC861VD_LENOVO] = { |
10829 | .mixers = { alc861vd_lenovo_mixer }, | |
10830 | .init_verbs = { alc861vd_volume_init_verbs, | |
10831 | alc861vd_3stack_init_verbs, | |
10832 | alc861vd_eapd_verbs, | |
10833 | alc861vd_lenovo_unsol_verbs }, | |
10834 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
10835 | .dac_nids = alc660vd_dac_nids, | |
10836 | .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids), | |
10837 | .adc_nids = alc861vd_adc_nids, | |
10838 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
10839 | .channel_mode = alc861vd_3stack_2ch_modes, | |
10840 | .input_mux = &alc861vd_capture_source, | |
10841 | .unsol_event = alc861vd_lenovo_unsol_event, | |
10842 | .init_hook = alc861vd_lenovo_automute, | |
10843 | }, | |
272a527c KY |
10844 | [ALC861VD_DALLAS] = { |
10845 | .mixers = { alc861vd_dallas_mixer }, | |
10846 | .init_verbs = { alc861vd_dallas_verbs }, | |
10847 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
10848 | .dac_nids = alc861vd_dac_nids, | |
10849 | .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids), | |
10850 | .adc_nids = alc861vd_adc_nids, | |
10851 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
10852 | .channel_mode = alc861vd_3stack_2ch_modes, | |
10853 | .input_mux = &alc861vd_dallas_capture_source, | |
10854 | .unsol_event = alc861vd_dallas_unsol_event, | |
10855 | .init_hook = alc861vd_dallas_automute, | |
d1a991a6 KY |
10856 | }, |
10857 | [ALC861VD_HP] = { | |
10858 | .mixers = { alc861vd_hp_mixer }, | |
10859 | .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs }, | |
10860 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
10861 | .dac_nids = alc861vd_dac_nids, | |
10862 | .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids), | |
10863 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
10864 | .adc_nids = alc861vd_adc_nids, | |
10865 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
10866 | .channel_mode = alc861vd_3stack_2ch_modes, | |
10867 | .input_mux = &alc861vd_hp_capture_source, | |
10868 | .unsol_event = alc861vd_dallas_unsol_event, | |
10869 | .init_hook = alc861vd_dallas_automute, | |
10870 | }, | |
f32610ed JS |
10871 | }; |
10872 | ||
10873 | /* | |
10874 | * BIOS auto configuration | |
10875 | */ | |
10876 | static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec, | |
10877 | hda_nid_t nid, int pin_type, int dac_idx) | |
10878 | { | |
10879 | /* set as output */ | |
10880 | snd_hda_codec_write(codec, nid, 0, | |
10881 | AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); | |
10882 | snd_hda_codec_write(codec, nid, 0, | |
10883 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); | |
10884 | } | |
10885 | ||
10886 | static void alc861vd_auto_init_multi_out(struct hda_codec *codec) | |
10887 | { | |
10888 | struct alc_spec *spec = codec->spec; | |
10889 | int i; | |
10890 | ||
bc9f98a9 | 10891 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
f32610ed JS |
10892 | for (i = 0; i <= HDA_SIDE; i++) { |
10893 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 10894 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
f32610ed JS |
10895 | if (nid) |
10896 | alc861vd_auto_set_output_and_unmute(codec, nid, | |
baba8ee9 | 10897 | pin_type, i); |
f32610ed JS |
10898 | } |
10899 | } | |
10900 | ||
10901 | ||
10902 | static void alc861vd_auto_init_hp_out(struct hda_codec *codec) | |
10903 | { | |
10904 | struct alc_spec *spec = codec->spec; | |
10905 | hda_nid_t pin; | |
10906 | ||
10907 | pin = spec->autocfg.hp_pins[0]; | |
10908 | if (pin) /* connect to front and use dac 0 */ | |
10909 | alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
10910 | } | |
10911 | ||
10912 | #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid) | |
10913 | #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID | |
10914 | ||
10915 | static void alc861vd_auto_init_analog_input(struct hda_codec *codec) | |
10916 | { | |
10917 | struct alc_spec *spec = codec->spec; | |
10918 | int i; | |
10919 | ||
10920 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
10921 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
10922 | if (alc861vd_is_input_pin(nid)) { | |
10923 | snd_hda_codec_write(codec, nid, 0, | |
10924 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
10925 | i <= AUTO_PIN_FRONT_MIC ? | |
10926 | PIN_VREF80 : PIN_IN); | |
10927 | if (nid != ALC861VD_PIN_CD_NID) | |
10928 | snd_hda_codec_write(codec, nid, 0, | |
10929 | AC_VERB_SET_AMP_GAIN_MUTE, | |
10930 | AMP_OUT_MUTE); | |
10931 | } | |
10932 | } | |
10933 | } | |
10934 | ||
10935 | #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02) | |
10936 | #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c) | |
10937 | ||
10938 | /* add playback controls from the parsed DAC table */ | |
10939 | /* Based on ALC880 version. But ALC861VD has separate, | |
10940 | * different NIDs for mute/unmute switch and volume control */ | |
10941 | static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec, | |
10942 | const struct auto_pin_cfg *cfg) | |
10943 | { | |
10944 | char name[32]; | |
10945 | static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"}; | |
10946 | hda_nid_t nid_v, nid_s; | |
10947 | int i, err; | |
10948 | ||
10949 | for (i = 0; i < cfg->line_outs; i++) { | |
f12ab1e0 | 10950 | if (!spec->multiout.dac_nids[i]) |
f32610ed JS |
10951 | continue; |
10952 | nid_v = alc861vd_idx_to_mixer_vol( | |
10953 | alc880_dac_to_idx( | |
10954 | spec->multiout.dac_nids[i])); | |
10955 | nid_s = alc861vd_idx_to_mixer_switch( | |
10956 | alc880_dac_to_idx( | |
10957 | spec->multiout.dac_nids[i])); | |
10958 | ||
10959 | if (i == 2) { | |
10960 | /* Center/LFE */ | |
f12ab1e0 TI |
10961 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
10962 | "Center Playback Volume", | |
10963 | HDA_COMPOSE_AMP_VAL(nid_v, 1, 0, | |
10964 | HDA_OUTPUT)); | |
10965 | if (err < 0) | |
f32610ed | 10966 | return err; |
f12ab1e0 TI |
10967 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
10968 | "LFE Playback Volume", | |
10969 | HDA_COMPOSE_AMP_VAL(nid_v, 2, 0, | |
10970 | HDA_OUTPUT)); | |
10971 | if (err < 0) | |
f32610ed | 10972 | return err; |
f12ab1e0 TI |
10973 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
10974 | "Center Playback Switch", | |
10975 | HDA_COMPOSE_AMP_VAL(nid_s, 1, 2, | |
10976 | HDA_INPUT)); | |
10977 | if (err < 0) | |
f32610ed | 10978 | return err; |
f12ab1e0 TI |
10979 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
10980 | "LFE Playback Switch", | |
10981 | HDA_COMPOSE_AMP_VAL(nid_s, 2, 2, | |
10982 | HDA_INPUT)); | |
10983 | if (err < 0) | |
f32610ed JS |
10984 | return err; |
10985 | } else { | |
10986 | sprintf(name, "%s Playback Volume", chname[i]); | |
f12ab1e0 TI |
10987 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
10988 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, | |
10989 | HDA_OUTPUT)); | |
10990 | if (err < 0) | |
f32610ed JS |
10991 | return err; |
10992 | sprintf(name, "%s Playback Switch", chname[i]); | |
f12ab1e0 | 10993 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
bdd148a3 | 10994 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, |
f12ab1e0 TI |
10995 | HDA_INPUT)); |
10996 | if (err < 0) | |
f32610ed JS |
10997 | return err; |
10998 | } | |
10999 | } | |
11000 | return 0; | |
11001 | } | |
11002 | ||
11003 | /* add playback controls for speaker and HP outputs */ | |
11004 | /* Based on ALC880 version. But ALC861VD has separate, | |
11005 | * different NIDs for mute/unmute switch and volume control */ | |
11006 | static int alc861vd_auto_create_extra_out(struct alc_spec *spec, | |
11007 | hda_nid_t pin, const char *pfx) | |
11008 | { | |
11009 | hda_nid_t nid_v, nid_s; | |
11010 | int err; | |
11011 | char name[32]; | |
11012 | ||
f12ab1e0 | 11013 | if (!pin) |
f32610ed JS |
11014 | return 0; |
11015 | ||
11016 | if (alc880_is_fixed_pin(pin)) { | |
11017 | nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
11018 | /* specify the DAC as the extra output */ | |
f12ab1e0 | 11019 | if (!spec->multiout.hp_nid) |
f32610ed JS |
11020 | spec->multiout.hp_nid = nid_v; |
11021 | else | |
11022 | spec->multiout.extra_out_nid[0] = nid_v; | |
11023 | /* control HP volume/switch on the output mixer amp */ | |
11024 | nid_v = alc861vd_idx_to_mixer_vol( | |
11025 | alc880_fixed_pin_idx(pin)); | |
11026 | nid_s = alc861vd_idx_to_mixer_switch( | |
11027 | alc880_fixed_pin_idx(pin)); | |
11028 | ||
11029 | sprintf(name, "%s Playback Volume", pfx); | |
f12ab1e0 TI |
11030 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
11031 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT)); | |
11032 | if (err < 0) | |
f32610ed JS |
11033 | return err; |
11034 | sprintf(name, "%s Playback Switch", pfx); | |
f12ab1e0 TI |
11035 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
11036 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT)); | |
11037 | if (err < 0) | |
f32610ed JS |
11038 | return err; |
11039 | } else if (alc880_is_multi_pin(pin)) { | |
11040 | /* set manual connection */ | |
11041 | /* we have only a switch on HP-out PIN */ | |
11042 | sprintf(name, "%s Playback Switch", pfx); | |
f12ab1e0 TI |
11043 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
11044 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
11045 | if (err < 0) | |
f32610ed JS |
11046 | return err; |
11047 | } | |
11048 | return 0; | |
11049 | } | |
11050 | ||
11051 | /* parse the BIOS configuration and set up the alc_spec | |
11052 | * return 1 if successful, 0 if the proper config is not found, | |
11053 | * or a negative error code | |
11054 | * Based on ALC880 version - had to change it to override | |
11055 | * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */ | |
11056 | static int alc861vd_parse_auto_config(struct hda_codec *codec) | |
11057 | { | |
11058 | struct alc_spec *spec = codec->spec; | |
11059 | int err; | |
11060 | static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; | |
11061 | ||
f12ab1e0 TI |
11062 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
11063 | alc861vd_ignore); | |
11064 | if (err < 0) | |
f32610ed | 11065 | return err; |
f12ab1e0 | 11066 | if (!spec->autocfg.line_outs) |
f32610ed JS |
11067 | return 0; /* can't find valid BIOS pin config */ |
11068 | ||
f12ab1e0 TI |
11069 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
11070 | if (err < 0) | |
11071 | return err; | |
11072 | err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
11073 | if (err < 0) | |
11074 | return err; | |
11075 | err = alc861vd_auto_create_extra_out(spec, | |
11076 | spec->autocfg.speaker_pins[0], | |
11077 | "Speaker"); | |
11078 | if (err < 0) | |
11079 | return err; | |
11080 | err = alc861vd_auto_create_extra_out(spec, | |
11081 | spec->autocfg.hp_pins[0], | |
11082 | "Headphone"); | |
11083 | if (err < 0) | |
11084 | return err; | |
11085 | err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
11086 | if (err < 0) | |
f32610ed JS |
11087 | return err; |
11088 | ||
11089 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
11090 | ||
11091 | if (spec->autocfg.dig_out_pin) | |
11092 | spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID; | |
11093 | ||
11094 | if (spec->kctl_alloc) | |
11095 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
11096 | ||
11097 | spec->init_verbs[spec->num_init_verbs++] | |
11098 | = alc861vd_volume_init_verbs; | |
11099 | ||
11100 | spec->num_mux_defs = 1; | |
11101 | spec->input_mux = &spec->private_imux; | |
11102 | ||
11103 | return 1; | |
11104 | } | |
11105 | ||
11106 | /* additional initialization for auto-configuration model */ | |
11107 | static void alc861vd_auto_init(struct hda_codec *codec) | |
11108 | { | |
11109 | alc861vd_auto_init_multi_out(codec); | |
11110 | alc861vd_auto_init_hp_out(codec); | |
11111 | alc861vd_auto_init_analog_input(codec); | |
11112 | } | |
11113 | ||
11114 | static int patch_alc861vd(struct hda_codec *codec) | |
11115 | { | |
11116 | struct alc_spec *spec; | |
11117 | int err, board_config; | |
11118 | ||
11119 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
11120 | if (spec == NULL) | |
11121 | return -ENOMEM; | |
11122 | ||
11123 | codec->spec = spec; | |
11124 | ||
11125 | board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST, | |
11126 | alc861vd_models, | |
11127 | alc861vd_cfg_tbl); | |
11128 | ||
11129 | if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) { | |
11130 | printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/" | |
11131 | "ALC861VD, trying auto-probe from BIOS...\n"); | |
11132 | board_config = ALC861VD_AUTO; | |
11133 | } | |
11134 | ||
11135 | if (board_config == ALC861VD_AUTO) { | |
11136 | /* automatic parse from the BIOS config */ | |
11137 | err = alc861vd_parse_auto_config(codec); | |
11138 | if (err < 0) { | |
11139 | alc_free(codec); | |
11140 | return err; | |
f12ab1e0 | 11141 | } else if (!err) { |
f32610ed JS |
11142 | printk(KERN_INFO |
11143 | "hda_codec: Cannot set up configuration " | |
11144 | "from BIOS. Using base mode...\n"); | |
11145 | board_config = ALC861VD_3ST; | |
11146 | } | |
11147 | } | |
11148 | ||
11149 | if (board_config != ALC861VD_AUTO) | |
11150 | setup_preset(spec, &alc861vd_presets[board_config]); | |
11151 | ||
11152 | spec->stream_name_analog = "ALC861VD Analog"; | |
11153 | spec->stream_analog_playback = &alc861vd_pcm_analog_playback; | |
11154 | spec->stream_analog_capture = &alc861vd_pcm_analog_capture; | |
11155 | ||
11156 | spec->stream_name_digital = "ALC861VD Digital"; | |
11157 | spec->stream_digital_playback = &alc861vd_pcm_digital_playback; | |
11158 | spec->stream_digital_capture = &alc861vd_pcm_digital_capture; | |
11159 | ||
11160 | spec->adc_nids = alc861vd_adc_nids; | |
11161 | spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids); | |
11162 | ||
11163 | spec->mixers[spec->num_mixers] = alc861vd_capture_mixer; | |
11164 | spec->num_mixers++; | |
11165 | ||
11166 | codec->patch_ops = alc_patch_ops; | |
11167 | ||
11168 | if (board_config == ALC861VD_AUTO) | |
11169 | spec->init_hook = alc861vd_auto_init; | |
cb53c626 TI |
11170 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
11171 | if (!spec->loopback.amplist) | |
11172 | spec->loopback.amplist = alc861vd_loopbacks; | |
11173 | #endif | |
f32610ed JS |
11174 | |
11175 | return 0; | |
11176 | } | |
11177 | ||
bc9f98a9 KY |
11178 | /* |
11179 | * ALC662 support | |
11180 | * | |
11181 | * ALC662 is almost identical with ALC880 but has cleaner and more flexible | |
11182 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
11183 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
11184 | * 6-channel independent captures. | |
11185 | * | |
11186 | * In addition, an independent DAC for the multi-playback (not used in this | |
11187 | * driver yet). | |
11188 | */ | |
11189 | #define ALC662_DIGOUT_NID 0x06 | |
11190 | #define ALC662_DIGIN_NID 0x0a | |
11191 | ||
11192 | static hda_nid_t alc662_dac_nids[4] = { | |
11193 | /* front, rear, clfe, rear_surr */ | |
11194 | 0x02, 0x03, 0x04 | |
11195 | }; | |
11196 | ||
11197 | static hda_nid_t alc662_adc_nids[1] = { | |
11198 | /* ADC1-2 */ | |
11199 | 0x09, | |
11200 | }; | |
11201 | /* input MUX */ | |
11202 | /* FIXME: should be a matrix-type input source selection */ | |
11203 | ||
11204 | static struct hda_input_mux alc662_capture_source = { | |
11205 | .num_items = 4, | |
11206 | .items = { | |
11207 | { "Mic", 0x0 }, | |
11208 | { "Front Mic", 0x1 }, | |
11209 | { "Line", 0x2 }, | |
11210 | { "CD", 0x4 }, | |
11211 | }, | |
11212 | }; | |
11213 | ||
11214 | static struct hda_input_mux alc662_lenovo_101e_capture_source = { | |
11215 | .num_items = 2, | |
11216 | .items = { | |
11217 | { "Mic", 0x1 }, | |
11218 | { "Line", 0x2 }, | |
11219 | }, | |
11220 | }; | |
11221 | #define alc662_mux_enum_info alc_mux_enum_info | |
11222 | #define alc662_mux_enum_get alc_mux_enum_get | |
11223 | ||
11224 | static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol, | |
11225 | struct snd_ctl_elem_value *ucontrol) | |
11226 | { | |
11227 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
11228 | struct alc_spec *spec = codec->spec; | |
11229 | const struct hda_input_mux *imux = spec->input_mux; | |
11230 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
d1a991a6 | 11231 | static hda_nid_t capture_mixers[2] = { 0x23, 0x22 }; |
bc9f98a9 KY |
11232 | hda_nid_t nid = capture_mixers[adc_idx]; |
11233 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; | |
11234 | unsigned int i, idx; | |
11235 | ||
11236 | idx = ucontrol->value.enumerated.item[0]; | |
11237 | if (idx >= imux->num_items) | |
11238 | idx = imux->num_items - 1; | |
82beb8fd | 11239 | if (*cur_val == idx) |
bc9f98a9 KY |
11240 | return 0; |
11241 | for (i = 0; i < imux->num_items; i++) { | |
47fd830a TI |
11242 | unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE; |
11243 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, | |
11244 | imux->items[i].index, | |
11245 | HDA_AMP_MUTE, v); | |
bc9f98a9 KY |
11246 | } |
11247 | *cur_val = idx; | |
11248 | return 1; | |
11249 | } | |
11250 | /* | |
11251 | * 2ch mode | |
11252 | */ | |
11253 | static struct hda_channel_mode alc662_3ST_2ch_modes[1] = { | |
11254 | { 2, NULL } | |
11255 | }; | |
11256 | ||
11257 | /* | |
11258 | * 2ch mode | |
11259 | */ | |
11260 | static struct hda_verb alc662_3ST_ch2_init[] = { | |
11261 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
11262 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
11263 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
11264 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
11265 | { } /* end */ | |
11266 | }; | |
11267 | ||
11268 | /* | |
11269 | * 6ch mode | |
11270 | */ | |
11271 | static struct hda_verb alc662_3ST_ch6_init[] = { | |
11272 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
11273 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
11274 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
11275 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
11276 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
11277 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
11278 | { } /* end */ | |
11279 | }; | |
11280 | ||
11281 | static struct hda_channel_mode alc662_3ST_6ch_modes[2] = { | |
11282 | { 2, alc662_3ST_ch2_init }, | |
11283 | { 6, alc662_3ST_ch6_init }, | |
11284 | }; | |
11285 | ||
11286 | /* | |
11287 | * 2ch mode | |
11288 | */ | |
11289 | static struct hda_verb alc662_sixstack_ch6_init[] = { | |
11290 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
11291 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
11292 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
11293 | { } /* end */ | |
11294 | }; | |
11295 | ||
11296 | /* | |
11297 | * 6ch mode | |
11298 | */ | |
11299 | static struct hda_verb alc662_sixstack_ch8_init[] = { | |
11300 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
11301 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
11302 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
11303 | { } /* end */ | |
11304 | }; | |
11305 | ||
11306 | static struct hda_channel_mode alc662_5stack_modes[2] = { | |
11307 | { 2, alc662_sixstack_ch6_init }, | |
11308 | { 6, alc662_sixstack_ch8_init }, | |
11309 | }; | |
11310 | ||
11311 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 | |
11312 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
11313 | */ | |
11314 | ||
11315 | static struct snd_kcontrol_new alc662_base_mixer[] = { | |
11316 | /* output mixer control */ | |
11317 | HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT), | |
11318 | HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT), | |
11319 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT), | |
11320 | HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
11321 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), | |
11322 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), | |
11323 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT), | |
11324 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT), | |
11325 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
11326 | ||
11327 | /*Input mixer control */ | |
11328 | HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT), | |
11329 | HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT), | |
11330 | HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT), | |
11331 | HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT), | |
11332 | HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT), | |
11333 | HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT), | |
11334 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT), | |
11335 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT), | |
11336 | ||
11337 | /* Capture mixer control */ | |
11338 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
11339 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
11340 | { | |
11341 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11342 | .name = "Capture Source", | |
11343 | .count = 1, | |
11344 | .info = alc_mux_enum_info, | |
11345 | .get = alc_mux_enum_get, | |
11346 | .put = alc_mux_enum_put, | |
11347 | }, | |
11348 | { } /* end */ | |
11349 | }; | |
11350 | ||
11351 | static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = { | |
11352 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
11353 | HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT), | |
11354 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
11355 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
11356 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
11357 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
11358 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
11359 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
11360 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
11361 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
11362 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
11363 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
11364 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
11365 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
11366 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
11367 | { | |
11368 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11369 | /* .name = "Capture Source", */ | |
11370 | .name = "Input Source", | |
11371 | .count = 1, | |
11372 | .info = alc662_mux_enum_info, | |
11373 | .get = alc662_mux_enum_get, | |
11374 | .put = alc662_mux_enum_put, | |
11375 | }, | |
11376 | { } /* end */ | |
11377 | }; | |
11378 | ||
11379 | static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = { | |
11380 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
11381 | HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT), | |
11382 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
11383 | HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT), | |
11384 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), | |
11385 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), | |
11386 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT), | |
11387 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT), | |
11388 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
11389 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
11390 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
11391 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
11392 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
11393 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
11394 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
11395 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
11396 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
11397 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
11398 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
11399 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
11400 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
11401 | { | |
11402 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11403 | /* .name = "Capture Source", */ | |
11404 | .name = "Input Source", | |
11405 | .count = 1, | |
11406 | .info = alc662_mux_enum_info, | |
11407 | .get = alc662_mux_enum_get, | |
11408 | .put = alc662_mux_enum_put, | |
11409 | }, | |
11410 | { } /* end */ | |
11411 | }; | |
11412 | ||
11413 | static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = { | |
11414 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
11415 | HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT), | |
11416 | HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
11417 | HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT), | |
11418 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
11419 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
11420 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
11421 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
11422 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
11423 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
11424 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
11425 | { | |
11426 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11427 | /* .name = "Capture Source", */ | |
11428 | .name = "Input Source", | |
11429 | .count = 1, | |
11430 | .info = alc662_mux_enum_info, | |
11431 | .get = alc662_mux_enum_get, | |
11432 | .put = alc662_mux_enum_put, | |
11433 | }, | |
11434 | { } /* end */ | |
11435 | }; | |
11436 | ||
11437 | static struct snd_kcontrol_new alc662_chmode_mixer[] = { | |
11438 | { | |
11439 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11440 | .name = "Channel Mode", | |
11441 | .info = alc_ch_mode_info, | |
11442 | .get = alc_ch_mode_get, | |
11443 | .put = alc_ch_mode_put, | |
11444 | }, | |
11445 | { } /* end */ | |
11446 | }; | |
11447 | ||
11448 | static struct hda_verb alc662_init_verbs[] = { | |
11449 | /* ADC: mute amp left and right */ | |
11450 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
11451 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
11452 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
11453 | ||
cb53c626 TI |
11454 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
11455 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
11456 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
11457 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
11458 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
bc9f98a9 KY |
11459 | |
11460 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11461 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11462 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11463 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11464 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11465 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11466 | ||
11467 | /* Front Pin: output 0 (0x0c) */ | |
11468 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
11469 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11470 | ||
11471 | /* Rear Pin: output 1 (0x0d) */ | |
11472 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
11473 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11474 | ||
11475 | /* CLFE Pin: output 2 (0x0e) */ | |
11476 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
11477 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11478 | ||
11479 | /* Mic (rear) pin: input vref at 80% */ | |
11480 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
11481 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11482 | /* Front Mic pin: input vref at 80% */ | |
11483 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
11484 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11485 | /* Line In pin: input */ | |
11486 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
11487 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11488 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
11489 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
11490 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11491 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
11492 | /* CD pin widget for input */ | |
11493 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
11494 | ||
11495 | /* FIXME: use matrix-type input source selection */ | |
11496 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
11497 | /* Input mixer */ | |
11498 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11499 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11500 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
11501 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
11502 | { } | |
11503 | }; | |
11504 | ||
11505 | static struct hda_verb alc662_sue_init_verbs[] = { | |
11506 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT}, | |
11507 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT}, | |
11508 | {} | |
11509 | }; | |
11510 | ||
11511 | /* | |
11512 | * generic initialization of ADC, input mixers and output mixers | |
11513 | */ | |
11514 | static struct hda_verb alc662_auto_init_verbs[] = { | |
11515 | /* | |
11516 | * Unmute ADC and set the default input to mic-in | |
11517 | */ | |
11518 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
11519 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11520 | ||
11521 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | |
11522 | * mixer widget | |
11523 | * Note: PASD motherboards uses the Line In 2 as the input for front | |
11524 | * panel mic (mic 2) | |
11525 | */ | |
11526 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
11527 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
11528 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
11529 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
11530 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
11531 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
bc9f98a9 KY |
11532 | |
11533 | /* | |
11534 | * Set up output mixers (0x0c - 0x0f) | |
11535 | */ | |
11536 | /* set vol=0 to output mixers */ | |
11537 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
11538 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
11539 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
11540 | ||
11541 | /* set up input amps for analog loopback */ | |
11542 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
11543 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11544 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11545 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11546 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11547 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11548 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11549 | ||
11550 | ||
11551 | /* FIXME: use matrix-type input source selection */ | |
11552 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
11553 | /* Input mixer */ | |
11554 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
d1a991a6 | 11555 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
bc9f98a9 KY |
11556 | { } |
11557 | }; | |
11558 | ||
11559 | /* capture mixer elements */ | |
11560 | static struct snd_kcontrol_new alc662_capture_mixer[] = { | |
11561 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
11562 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
11563 | { | |
11564 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11565 | /* The multiple "Capture Source" controls confuse alsamixer | |
11566 | * So call somewhat different.. | |
11567 | * FIXME: the controls appear in the "playback" view! | |
11568 | */ | |
11569 | /* .name = "Capture Source", */ | |
11570 | .name = "Input Source", | |
11571 | .count = 1, | |
11572 | .info = alc882_mux_enum_info, | |
11573 | .get = alc882_mux_enum_get, | |
11574 | .put = alc882_mux_enum_put, | |
11575 | }, | |
11576 | { } /* end */ | |
11577 | }; | |
11578 | ||
11579 | static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec) | |
11580 | { | |
11581 | unsigned int present; | |
f12ab1e0 | 11582 | unsigned char bits; |
bc9f98a9 KY |
11583 | |
11584 | present = snd_hda_codec_read(codec, 0x14, 0, | |
11585 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
11586 | bits = present ? HDA_AMP_MUTE : 0; |
11587 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
11588 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
11589 | } |
11590 | ||
11591 | static void alc662_lenovo_101e_all_automute(struct hda_codec *codec) | |
11592 | { | |
11593 | unsigned int present; | |
f12ab1e0 | 11594 | unsigned char bits; |
bc9f98a9 KY |
11595 | |
11596 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
11597 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
11598 | bits = present ? HDA_AMP_MUTE : 0; |
11599 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
11600 | HDA_AMP_MUTE, bits); | |
11601 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
11602 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
11603 | } |
11604 | ||
11605 | static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec, | |
11606 | unsigned int res) | |
11607 | { | |
11608 | if ((res >> 26) == ALC880_HP_EVENT) | |
11609 | alc662_lenovo_101e_all_automute(codec); | |
11610 | if ((res >> 26) == ALC880_FRONT_EVENT) | |
11611 | alc662_lenovo_101e_ispeaker_automute(codec); | |
11612 | } | |
11613 | ||
cb53c626 TI |
11614 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
11615 | #define alc662_loopbacks alc880_loopbacks | |
11616 | #endif | |
11617 | ||
bc9f98a9 KY |
11618 | |
11619 | /* pcm configuration: identiacal with ALC880 */ | |
11620 | #define alc662_pcm_analog_playback alc880_pcm_analog_playback | |
11621 | #define alc662_pcm_analog_capture alc880_pcm_analog_capture | |
11622 | #define alc662_pcm_digital_playback alc880_pcm_digital_playback | |
11623 | #define alc662_pcm_digital_capture alc880_pcm_digital_capture | |
11624 | ||
11625 | /* | |
11626 | * configuration and preset | |
11627 | */ | |
11628 | static const char *alc662_models[ALC662_MODEL_LAST] = { | |
11629 | [ALC662_3ST_2ch_DIG] = "3stack-dig", | |
11630 | [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig", | |
11631 | [ALC662_3ST_6ch] = "3stack-6ch", | |
11632 | [ALC662_5ST_DIG] = "6stack-dig", | |
11633 | [ALC662_LENOVO_101E] = "lenovo-101e", | |
11634 | [ALC662_AUTO] = "auto", | |
11635 | }; | |
11636 | ||
11637 | static struct snd_pci_quirk alc662_cfg_tbl[] = { | |
11638 | SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E), | |
11639 | {} | |
11640 | }; | |
11641 | ||
11642 | static struct alc_config_preset alc662_presets[] = { | |
11643 | [ALC662_3ST_2ch_DIG] = { | |
11644 | .mixers = { alc662_3ST_2ch_mixer }, | |
11645 | .init_verbs = { alc662_init_verbs }, | |
11646 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
11647 | .dac_nids = alc662_dac_nids, | |
11648 | .dig_out_nid = ALC662_DIGOUT_NID, | |
11649 | .num_adc_nids = ARRAY_SIZE(alc662_adc_nids), | |
11650 | .adc_nids = alc662_adc_nids, | |
11651 | .dig_in_nid = ALC662_DIGIN_NID, | |
11652 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
11653 | .channel_mode = alc662_3ST_2ch_modes, | |
11654 | .input_mux = &alc662_capture_source, | |
11655 | }, | |
11656 | [ALC662_3ST_6ch_DIG] = { | |
11657 | .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer }, | |
11658 | .init_verbs = { alc662_init_verbs }, | |
11659 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
11660 | .dac_nids = alc662_dac_nids, | |
11661 | .dig_out_nid = ALC662_DIGOUT_NID, | |
11662 | .num_adc_nids = ARRAY_SIZE(alc662_adc_nids), | |
11663 | .adc_nids = alc662_adc_nids, | |
11664 | .dig_in_nid = ALC662_DIGIN_NID, | |
11665 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), | |
11666 | .channel_mode = alc662_3ST_6ch_modes, | |
11667 | .need_dac_fix = 1, | |
11668 | .input_mux = &alc662_capture_source, | |
f12ab1e0 | 11669 | }, |
bc9f98a9 KY |
11670 | [ALC662_3ST_6ch] = { |
11671 | .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer }, | |
11672 | .init_verbs = { alc662_init_verbs }, | |
11673 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
11674 | .dac_nids = alc662_dac_nids, | |
11675 | .num_adc_nids = ARRAY_SIZE(alc662_adc_nids), | |
11676 | .adc_nids = alc662_adc_nids, | |
11677 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), | |
11678 | .channel_mode = alc662_3ST_6ch_modes, | |
11679 | .need_dac_fix = 1, | |
11680 | .input_mux = &alc662_capture_source, | |
f12ab1e0 | 11681 | }, |
bc9f98a9 KY |
11682 | [ALC662_5ST_DIG] = { |
11683 | .mixers = { alc662_base_mixer, alc662_chmode_mixer }, | |
11684 | .init_verbs = { alc662_init_verbs }, | |
11685 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
11686 | .dac_nids = alc662_dac_nids, | |
11687 | .dig_out_nid = ALC662_DIGOUT_NID, | |
11688 | .num_adc_nids = ARRAY_SIZE(alc662_adc_nids), | |
11689 | .adc_nids = alc662_adc_nids, | |
11690 | .dig_in_nid = ALC662_DIGIN_NID, | |
11691 | .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes), | |
11692 | .channel_mode = alc662_5stack_modes, | |
11693 | .input_mux = &alc662_capture_source, | |
11694 | }, | |
11695 | [ALC662_LENOVO_101E] = { | |
11696 | .mixers = { alc662_lenovo_101e_mixer }, | |
11697 | .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs }, | |
11698 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
11699 | .dac_nids = alc662_dac_nids, | |
11700 | .num_adc_nids = ARRAY_SIZE(alc662_adc_nids), | |
11701 | .adc_nids = alc662_adc_nids, | |
11702 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
11703 | .channel_mode = alc662_3ST_2ch_modes, | |
11704 | .input_mux = &alc662_lenovo_101e_capture_source, | |
11705 | .unsol_event = alc662_lenovo_101e_unsol_event, | |
11706 | .init_hook = alc662_lenovo_101e_all_automute, | |
11707 | }, | |
11708 | ||
11709 | }; | |
11710 | ||
11711 | ||
11712 | /* | |
11713 | * BIOS auto configuration | |
11714 | */ | |
11715 | ||
11716 | /* add playback controls from the parsed DAC table */ | |
11717 | static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec, | |
11718 | const struct auto_pin_cfg *cfg) | |
11719 | { | |
11720 | char name[32]; | |
11721 | static const char *chname[4] = { | |
11722 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
11723 | }; | |
11724 | hda_nid_t nid; | |
11725 | int i, err; | |
11726 | ||
11727 | for (i = 0; i < cfg->line_outs; i++) { | |
11728 | if (!spec->multiout.dac_nids[i]) | |
11729 | continue; | |
067b5a84 | 11730 | nid = alc880_idx_to_mixer(i); |
bc9f98a9 KY |
11731 | if (i == 2) { |
11732 | /* Center/LFE */ | |
11733 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
11734 | "Center Playback Volume", | |
f12ab1e0 TI |
11735 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, |
11736 | HDA_OUTPUT)); | |
bc9f98a9 KY |
11737 | if (err < 0) |
11738 | return err; | |
11739 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
11740 | "LFE Playback Volume", | |
f12ab1e0 TI |
11741 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, |
11742 | HDA_OUTPUT)); | |
bc9f98a9 KY |
11743 | if (err < 0) |
11744 | return err; | |
11745 | err = add_control(spec, ALC_CTL_BIND_MUTE, | |
11746 | "Center Playback Switch", | |
f12ab1e0 TI |
11747 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, |
11748 | HDA_INPUT)); | |
bc9f98a9 KY |
11749 | if (err < 0) |
11750 | return err; | |
11751 | err = add_control(spec, ALC_CTL_BIND_MUTE, | |
11752 | "LFE Playback Switch", | |
f12ab1e0 TI |
11753 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, |
11754 | HDA_INPUT)); | |
bc9f98a9 KY |
11755 | if (err < 0) |
11756 | return err; | |
11757 | } else { | |
11758 | sprintf(name, "%s Playback Volume", chname[i]); | |
11759 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
f12ab1e0 TI |
11760 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, |
11761 | HDA_OUTPUT)); | |
bc9f98a9 KY |
11762 | if (err < 0) |
11763 | return err; | |
11764 | sprintf(name, "%s Playback Switch", chname[i]); | |
11765 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | |
f12ab1e0 TI |
11766 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, |
11767 | HDA_INPUT)); | |
bc9f98a9 KY |
11768 | if (err < 0) |
11769 | return err; | |
11770 | } | |
11771 | } | |
11772 | return 0; | |
11773 | } | |
11774 | ||
11775 | /* add playback controls for speaker and HP outputs */ | |
11776 | static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, | |
11777 | const char *pfx) | |
11778 | { | |
11779 | hda_nid_t nid; | |
11780 | int err; | |
11781 | char name[32]; | |
11782 | ||
11783 | if (!pin) | |
11784 | return 0; | |
11785 | ||
11786 | if (alc880_is_fixed_pin(pin)) { | |
11787 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
11788 | /* printk("DAC nid=%x\n",nid); */ | |
11789 | /* specify the DAC as the extra output */ | |
11790 | if (!spec->multiout.hp_nid) | |
11791 | spec->multiout.hp_nid = nid; | |
11792 | else | |
11793 | spec->multiout.extra_out_nid[0] = nid; | |
11794 | /* control HP volume/switch on the output mixer amp */ | |
11795 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
11796 | sprintf(name, "%s Playback Volume", pfx); | |
11797 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
11798 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
11799 | if (err < 0) | |
11800 | return err; | |
11801 | sprintf(name, "%s Playback Switch", pfx); | |
11802 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | |
11803 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); | |
11804 | if (err < 0) | |
11805 | return err; | |
11806 | } else if (alc880_is_multi_pin(pin)) { | |
11807 | /* set manual connection */ | |
11808 | /* we have only a switch on HP-out PIN */ | |
11809 | sprintf(name, "%s Playback Switch", pfx); | |
11810 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | |
11811 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
11812 | if (err < 0) | |
11813 | return err; | |
11814 | } | |
11815 | return 0; | |
11816 | } | |
11817 | ||
11818 | /* create playback/capture controls for input pins */ | |
11819 | static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec, | |
11820 | const struct auto_pin_cfg *cfg) | |
11821 | { | |
11822 | struct hda_input_mux *imux = &spec->private_imux; | |
11823 | int i, err, idx; | |
11824 | ||
11825 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
11826 | if (alc880_is_input_pin(cfg->input_pins[i])) { | |
11827 | idx = alc880_input_pin_idx(cfg->input_pins[i]); | |
11828 | err = new_analog_input(spec, cfg->input_pins[i], | |
11829 | auto_pin_cfg_labels[i], | |
11830 | idx, 0x0b); | |
11831 | if (err < 0) | |
11832 | return err; | |
11833 | imux->items[imux->num_items].label = | |
11834 | auto_pin_cfg_labels[i]; | |
11835 | imux->items[imux->num_items].index = | |
11836 | alc880_input_pin_idx(cfg->input_pins[i]); | |
11837 | imux->num_items++; | |
11838 | } | |
11839 | } | |
11840 | return 0; | |
11841 | } | |
11842 | ||
11843 | static void alc662_auto_set_output_and_unmute(struct hda_codec *codec, | |
11844 | hda_nid_t nid, int pin_type, | |
11845 | int dac_idx) | |
11846 | { | |
11847 | /* set as output */ | |
11848 | snd_hda_codec_write(codec, nid, 0, | |
11849 | AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); | |
11850 | snd_hda_codec_write(codec, nid, 0, | |
11851 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); | |
11852 | /* need the manual connection? */ | |
11853 | if (alc880_is_multi_pin(nid)) { | |
11854 | struct alc_spec *spec = codec->spec; | |
11855 | int idx = alc880_multi_pin_idx(nid); | |
11856 | snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, | |
11857 | AC_VERB_SET_CONNECT_SEL, | |
11858 | alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); | |
11859 | } | |
11860 | } | |
11861 | ||
11862 | static void alc662_auto_init_multi_out(struct hda_codec *codec) | |
11863 | { | |
11864 | struct alc_spec *spec = codec->spec; | |
11865 | int i; | |
11866 | ||
11867 | for (i = 0; i <= HDA_SIDE; i++) { | |
11868 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 11869 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
bc9f98a9 | 11870 | if (nid) |
baba8ee9 | 11871 | alc662_auto_set_output_and_unmute(codec, nid, pin_type, |
bc9f98a9 KY |
11872 | i); |
11873 | } | |
11874 | } | |
11875 | ||
11876 | static void alc662_auto_init_hp_out(struct hda_codec *codec) | |
11877 | { | |
11878 | struct alc_spec *spec = codec->spec; | |
11879 | hda_nid_t pin; | |
11880 | ||
11881 | pin = spec->autocfg.hp_pins[0]; | |
11882 | if (pin) /* connect to front */ | |
11883 | /* use dac 0 */ | |
11884 | alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
11885 | } | |
11886 | ||
11887 | #define alc662_is_input_pin(nid) alc880_is_input_pin(nid) | |
11888 | #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID | |
11889 | ||
11890 | static void alc662_auto_init_analog_input(struct hda_codec *codec) | |
11891 | { | |
11892 | struct alc_spec *spec = codec->spec; | |
11893 | int i; | |
11894 | ||
11895 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
11896 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
11897 | if (alc662_is_input_pin(nid)) { | |
11898 | snd_hda_codec_write(codec, nid, 0, | |
11899 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
11900 | (i <= AUTO_PIN_FRONT_MIC ? | |
11901 | PIN_VREF80 : PIN_IN)); | |
11902 | if (nid != ALC662_PIN_CD_NID) | |
11903 | snd_hda_codec_write(codec, nid, 0, | |
11904 | AC_VERB_SET_AMP_GAIN_MUTE, | |
11905 | AMP_OUT_MUTE); | |
11906 | } | |
11907 | } | |
11908 | } | |
11909 | ||
11910 | static int alc662_parse_auto_config(struct hda_codec *codec) | |
11911 | { | |
11912 | struct alc_spec *spec = codec->spec; | |
11913 | int err; | |
11914 | static hda_nid_t alc662_ignore[] = { 0x1d, 0 }; | |
11915 | ||
11916 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | |
11917 | alc662_ignore); | |
11918 | if (err < 0) | |
11919 | return err; | |
11920 | if (!spec->autocfg.line_outs) | |
11921 | return 0; /* can't find valid BIOS pin config */ | |
11922 | ||
f12ab1e0 TI |
11923 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
11924 | if (err < 0) | |
11925 | return err; | |
11926 | err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
11927 | if (err < 0) | |
11928 | return err; | |
11929 | err = alc662_auto_create_extra_out(spec, | |
11930 | spec->autocfg.speaker_pins[0], | |
11931 | "Speaker"); | |
11932 | if (err < 0) | |
11933 | return err; | |
11934 | err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], | |
11935 | "Headphone"); | |
11936 | if (err < 0) | |
11937 | return err; | |
11938 | err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
11939 | if (err < 0) | |
bc9f98a9 KY |
11940 | return err; |
11941 | ||
11942 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
11943 | ||
11944 | if (spec->autocfg.dig_out_pin) | |
11945 | spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; | |
11946 | ||
11947 | if (spec->kctl_alloc) | |
11948 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
11949 | ||
11950 | spec->num_mux_defs = 1; | |
11951 | spec->input_mux = &spec->private_imux; | |
11952 | ||
8c87286f | 11953 | spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs; |
bc9f98a9 KY |
11954 | spec->mixers[spec->num_mixers] = alc662_capture_mixer; |
11955 | spec->num_mixers++; | |
8c87286f | 11956 | return 1; |
bc9f98a9 KY |
11957 | } |
11958 | ||
11959 | /* additional initialization for auto-configuration model */ | |
11960 | static void alc662_auto_init(struct hda_codec *codec) | |
11961 | { | |
11962 | alc662_auto_init_multi_out(codec); | |
11963 | alc662_auto_init_hp_out(codec); | |
11964 | alc662_auto_init_analog_input(codec); | |
11965 | } | |
11966 | ||
11967 | static int patch_alc662(struct hda_codec *codec) | |
11968 | { | |
11969 | struct alc_spec *spec; | |
11970 | int err, board_config; | |
11971 | ||
11972 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
11973 | if (!spec) | |
11974 | return -ENOMEM; | |
11975 | ||
11976 | codec->spec = spec; | |
11977 | ||
11978 | board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST, | |
11979 | alc662_models, | |
11980 | alc662_cfg_tbl); | |
11981 | if (board_config < 0) { | |
11982 | printk(KERN_INFO "hda_codec: Unknown model for ALC662, " | |
11983 | "trying auto-probe from BIOS...\n"); | |
11984 | board_config = ALC662_AUTO; | |
11985 | } | |
11986 | ||
11987 | if (board_config == ALC662_AUTO) { | |
11988 | /* automatic parse from the BIOS config */ | |
11989 | err = alc662_parse_auto_config(codec); | |
11990 | if (err < 0) { | |
11991 | alc_free(codec); | |
11992 | return err; | |
8c87286f | 11993 | } else if (!err) { |
bc9f98a9 KY |
11994 | printk(KERN_INFO |
11995 | "hda_codec: Cannot set up configuration " | |
11996 | "from BIOS. Using base mode...\n"); | |
11997 | board_config = ALC662_3ST_2ch_DIG; | |
11998 | } | |
11999 | } | |
12000 | ||
12001 | if (board_config != ALC662_AUTO) | |
12002 | setup_preset(spec, &alc662_presets[board_config]); | |
12003 | ||
12004 | spec->stream_name_analog = "ALC662 Analog"; | |
12005 | spec->stream_analog_playback = &alc662_pcm_analog_playback; | |
12006 | spec->stream_analog_capture = &alc662_pcm_analog_capture; | |
12007 | ||
12008 | spec->stream_name_digital = "ALC662 Digital"; | |
12009 | spec->stream_digital_playback = &alc662_pcm_digital_playback; | |
12010 | spec->stream_digital_capture = &alc662_pcm_digital_capture; | |
12011 | ||
12012 | if (!spec->adc_nids && spec->input_mux) { | |
12013 | spec->adc_nids = alc662_adc_nids; | |
12014 | spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids); | |
12015 | } | |
12016 | ||
12017 | codec->patch_ops = alc_patch_ops; | |
12018 | if (board_config == ALC662_AUTO) | |
12019 | spec->init_hook = alc662_auto_init; | |
cb53c626 TI |
12020 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
12021 | if (!spec->loopback.amplist) | |
12022 | spec->loopback.amplist = alc662_loopbacks; | |
12023 | #endif | |
bc9f98a9 KY |
12024 | |
12025 | return 0; | |
12026 | } | |
12027 | ||
1da177e4 LT |
12028 | /* |
12029 | * patch entries | |
12030 | */ | |
12031 | struct hda_codec_preset snd_hda_preset_realtek[] = { | |
12032 | { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, | |
df694daa | 12033 | { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, |
a361d84b | 12034 | { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, |
f32610ed | 12035 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", |
bc9f98a9 | 12036 | .patch = patch_alc861 }, |
f32610ed JS |
12037 | { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, |
12038 | { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, | |
12039 | { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, | |
bc9f98a9 KY |
12040 | { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", |
12041 | .patch = patch_alc883 }, | |
12042 | { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", | |
12043 | .patch = patch_alc662 }, | |
f32610ed | 12044 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
1da177e4 | 12045 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, |
9c7f852e | 12046 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 }, |
df694daa | 12047 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, |
9c7f852e | 12048 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 }, |
1da177e4 LT |
12049 | {} /* terminator */ |
12050 | }; |