]>
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, | |
66d2a9d6 | 95 | ALC262_HP_TC_T5735, |
304dcaac | 96 | ALC262_BENQ_ED8, |
272a527c | 97 | ALC262_SONY_ASSAMD, |
83c34218 | 98 | ALC262_BENQ_T31, |
f651b50b | 99 | ALC262_ULTRA, |
df694daa KY |
100 | ALC262_AUTO, |
101 | ALC262_MODEL_LAST /* last tag */ | |
102 | }; | |
103 | ||
a361d84b KY |
104 | /* ALC268 models */ |
105 | enum { | |
106 | ALC268_3ST, | |
d1a991a6 | 107 | ALC268_TOSHIBA, |
d273809e | 108 | ALC268_ACER, |
a361d84b KY |
109 | ALC268_AUTO, |
110 | ALC268_MODEL_LAST /* last tag */ | |
111 | }; | |
112 | ||
df694daa KY |
113 | /* ALC861 models */ |
114 | enum { | |
115 | ALC861_3ST, | |
9c7f852e | 116 | ALC660_3ST, |
df694daa KY |
117 | ALC861_3ST_DIG, |
118 | ALC861_6ST_DIG, | |
22309c3e | 119 | ALC861_UNIWILL_M31, |
a53d1aec | 120 | ALC861_TOSHIBA, |
7cdbff94 | 121 | ALC861_ASUS, |
56bb0cab | 122 | ALC861_ASUS_LAPTOP, |
df694daa KY |
123 | ALC861_AUTO, |
124 | ALC861_MODEL_LAST, | |
125 | }; | |
126 | ||
f32610ed JS |
127 | /* ALC861-VD models */ |
128 | enum { | |
129 | ALC660VD_3ST, | |
6963f84c | 130 | ALC660VD_3ST_DIG, |
f32610ed JS |
131 | ALC861VD_3ST, |
132 | ALC861VD_3ST_DIG, | |
133 | ALC861VD_6ST_DIG, | |
bdd148a3 | 134 | ALC861VD_LENOVO, |
272a527c | 135 | ALC861VD_DALLAS, |
d1a991a6 | 136 | ALC861VD_HP, |
f32610ed JS |
137 | ALC861VD_AUTO, |
138 | ALC861VD_MODEL_LAST, | |
139 | }; | |
140 | ||
bc9f98a9 KY |
141 | /* ALC662 models */ |
142 | enum { | |
143 | ALC662_3ST_2ch_DIG, | |
144 | ALC662_3ST_6ch_DIG, | |
145 | ALC662_3ST_6ch, | |
146 | ALC662_5ST_DIG, | |
147 | ALC662_LENOVO_101E, | |
291702f0 | 148 | ALC662_ASUS_EEEPC_P701, |
bc9f98a9 KY |
149 | ALC662_AUTO, |
150 | ALC662_MODEL_LAST, | |
151 | }; | |
152 | ||
df694daa KY |
153 | /* ALC882 models */ |
154 | enum { | |
155 | ALC882_3ST_DIG, | |
156 | ALC882_6ST_DIG, | |
4b146cb0 | 157 | ALC882_ARIMA, |
bdd148a3 | 158 | ALC882_W2JC, |
272a527c KY |
159 | ALC882_TARGA, |
160 | ALC882_ASUS_A7J, | |
914759b7 | 161 | ALC882_ASUS_A7M, |
9102cd1c | 162 | ALC885_MACPRO, |
87350ad0 | 163 | ALC885_MBP3, |
c54728d8 | 164 | ALC885_IMAC24, |
272a527c | 165 | ALC882_AUTO, |
df694daa KY |
166 | ALC882_MODEL_LAST, |
167 | }; | |
168 | ||
9c7f852e TI |
169 | /* ALC883 models */ |
170 | enum { | |
171 | ALC883_3ST_2ch_DIG, | |
172 | ALC883_3ST_6ch_DIG, | |
173 | ALC883_3ST_6ch, | |
174 | ALC883_6ST_DIG, | |
ccc656ce KY |
175 | ALC883_TARGA_DIG, |
176 | ALC883_TARGA_2ch_DIG, | |
bab282b9 | 177 | ALC883_ACER, |
2880a867 | 178 | ALC883_ACER_ASPIRE, |
c07584c8 | 179 | ALC883_MEDION, |
272a527c | 180 | ALC883_MEDION_MD2, |
b373bdeb | 181 | ALC883_LAPTOP_EAPD, |
bc9f98a9 | 182 | ALC883_LENOVO_101E_2ch, |
272a527c | 183 | ALC883_LENOVO_NB0763, |
189609ae KY |
184 | ALC888_LENOVO_MS7195_DIG, |
185 | ALC883_HAIER_W66, | |
4723c022 CM |
186 | ALC888_6ST_HP, |
187 | ALC888_3ST_HP, | |
9c7f852e TI |
188 | ALC883_AUTO, |
189 | ALC883_MODEL_LAST, | |
190 | }; | |
191 | ||
df694daa KY |
192 | /* for GPIO Poll */ |
193 | #define GPIO_MASK 0x03 | |
194 | ||
1da177e4 LT |
195 | struct alc_spec { |
196 | /* codec parameterization */ | |
df694daa | 197 | struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ |
1da177e4 LT |
198 | unsigned int num_mixers; |
199 | ||
df694daa | 200 | const struct hda_verb *init_verbs[5]; /* initialization verbs |
9c7f852e TI |
201 | * don't forget NULL |
202 | * termination! | |
e9edcee0 TI |
203 | */ |
204 | unsigned int num_init_verbs; | |
1da177e4 | 205 | |
16ded525 | 206 | char *stream_name_analog; /* analog PCM stream */ |
1da177e4 LT |
207 | struct hda_pcm_stream *stream_analog_playback; |
208 | struct hda_pcm_stream *stream_analog_capture; | |
209 | ||
f12ab1e0 | 210 | char *stream_name_digital; /* digital PCM stream */ |
1da177e4 LT |
211 | struct hda_pcm_stream *stream_digital_playback; |
212 | struct hda_pcm_stream *stream_digital_capture; | |
213 | ||
214 | /* playback */ | |
16ded525 TI |
215 | struct hda_multi_out multiout; /* playback set-up |
216 | * max_channels, dacs must be set | |
217 | * dig_out_nid and hp_nid are optional | |
218 | */ | |
1da177e4 LT |
219 | |
220 | /* capture */ | |
221 | unsigned int num_adc_nids; | |
222 | hda_nid_t *adc_nids; | |
16ded525 | 223 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
1da177e4 LT |
224 | |
225 | /* capture source */ | |
a1e8d2da | 226 | unsigned int num_mux_defs; |
1da177e4 LT |
227 | const struct hda_input_mux *input_mux; |
228 | unsigned int cur_mux[3]; | |
229 | ||
230 | /* channel model */ | |
d2a6d7dc | 231 | const struct hda_channel_mode *channel_mode; |
1da177e4 | 232 | int num_channel_mode; |
4e195a7b | 233 | int need_dac_fix; |
1da177e4 LT |
234 | |
235 | /* PCM information */ | |
4c5186ed | 236 | struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ |
41e41f1f | 237 | |
e9edcee0 TI |
238 | /* dynamic controls, init_verbs and input_mux */ |
239 | struct auto_pin_cfg autocfg; | |
240 | unsigned int num_kctl_alloc, num_kctl_used; | |
c8b6bf9b | 241 | struct snd_kcontrol_new *kctl_alloc; |
e9edcee0 | 242 | struct hda_input_mux private_imux; |
41923e44 | 243 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
834be88d | 244 | |
ae6b813a TI |
245 | /* hooks */ |
246 | void (*init_hook)(struct hda_codec *codec); | |
247 | void (*unsol_event)(struct hda_codec *codec, unsigned int res); | |
248 | ||
834be88d TI |
249 | /* for pin sensing */ |
250 | unsigned int sense_updated: 1; | |
251 | unsigned int jack_present: 1; | |
cb53c626 TI |
252 | |
253 | #ifdef CONFIG_SND_HDA_POWER_SAVE | |
254 | struct hda_loopback_check loopback; | |
255 | #endif | |
df694daa KY |
256 | }; |
257 | ||
258 | /* | |
259 | * configuration template - to be copied to the spec instance | |
260 | */ | |
261 | struct alc_config_preset { | |
9c7f852e TI |
262 | struct snd_kcontrol_new *mixers[5]; /* should be identical size |
263 | * with spec | |
264 | */ | |
df694daa KY |
265 | const struct hda_verb *init_verbs[5]; |
266 | unsigned int num_dacs; | |
267 | hda_nid_t *dac_nids; | |
268 | hda_nid_t dig_out_nid; /* optional */ | |
269 | hda_nid_t hp_nid; /* optional */ | |
270 | unsigned int num_adc_nids; | |
271 | hda_nid_t *adc_nids; | |
272 | hda_nid_t dig_in_nid; | |
273 | unsigned int num_channel_mode; | |
274 | const struct hda_channel_mode *channel_mode; | |
4e195a7b | 275 | int need_dac_fix; |
a1e8d2da | 276 | unsigned int num_mux_defs; |
df694daa | 277 | const struct hda_input_mux *input_mux; |
ae6b813a TI |
278 | void (*unsol_event)(struct hda_codec *, unsigned int); |
279 | void (*init_hook)(struct hda_codec *); | |
cb53c626 TI |
280 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
281 | struct hda_amp_list *loopbacks; | |
282 | #endif | |
1da177e4 LT |
283 | }; |
284 | ||
1da177e4 LT |
285 | |
286 | /* | |
287 | * input MUX handling | |
288 | */ | |
9c7f852e TI |
289 | static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, |
290 | struct snd_ctl_elem_info *uinfo) | |
1da177e4 LT |
291 | { |
292 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
293 | struct alc_spec *spec = codec->spec; | |
a1e8d2da JW |
294 | unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id); |
295 | if (mux_idx >= spec->num_mux_defs) | |
296 | mux_idx = 0; | |
297 | return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo); | |
1da177e4 LT |
298 | } |
299 | ||
9c7f852e TI |
300 | static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, |
301 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
302 | { |
303 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
304 | struct alc_spec *spec = codec->spec; | |
305 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
306 | ||
307 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; | |
308 | return 0; | |
309 | } | |
310 | ||
9c7f852e TI |
311 | static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, |
312 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
313 | { |
314 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
315 | struct alc_spec *spec = codec->spec; | |
316 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
a1e8d2da JW |
317 | unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; |
318 | return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol, | |
9c7f852e TI |
319 | spec->adc_nids[adc_idx], |
320 | &spec->cur_mux[adc_idx]); | |
1da177e4 LT |
321 | } |
322 | ||
e9edcee0 | 323 | |
1da177e4 LT |
324 | /* |
325 | * channel mode setting | |
326 | */ | |
9c7f852e TI |
327 | static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, |
328 | struct snd_ctl_elem_info *uinfo) | |
1da177e4 LT |
329 | { |
330 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
331 | struct alc_spec *spec = codec->spec; | |
d2a6d7dc TI |
332 | return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, |
333 | spec->num_channel_mode); | |
1da177e4 LT |
334 | } |
335 | ||
9c7f852e TI |
336 | static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, |
337 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
338 | { |
339 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
340 | struct alc_spec *spec = codec->spec; | |
d2a6d7dc | 341 | return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, |
9c7f852e TI |
342 | spec->num_channel_mode, |
343 | spec->multiout.max_channels); | |
1da177e4 LT |
344 | } |
345 | ||
9c7f852e TI |
346 | static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, |
347 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
348 | { |
349 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
350 | struct alc_spec *spec = codec->spec; | |
4e195a7b TI |
351 | int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, |
352 | spec->num_channel_mode, | |
353 | &spec->multiout.max_channels); | |
bd2033f2 | 354 | if (err >= 0 && spec->need_dac_fix) |
4e195a7b TI |
355 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; |
356 | return err; | |
1da177e4 LT |
357 | } |
358 | ||
a9430dd8 | 359 | /* |
4c5186ed JW |
360 | * Control the mode of pin widget settings via the mixer. "pc" is used |
361 | * instead of "%" to avoid consequences of accidently treating the % as | |
362 | * being part of a format specifier. Maximum allowed length of a value is | |
363 | * 63 characters plus NULL terminator. | |
7cf51e48 JW |
364 | * |
365 | * Note: some retasking pin complexes seem to ignore requests for input | |
366 | * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these | |
367 | * are requested. Therefore order this list so that this behaviour will not | |
368 | * cause problems when mixer clients move through the enum sequentially. | |
a1e8d2da JW |
369 | * NIDs 0x0f and 0x10 have been observed to have this behaviour as of |
370 | * March 2006. | |
4c5186ed JW |
371 | */ |
372 | static char *alc_pin_mode_names[] = { | |
7cf51e48 JW |
373 | "Mic 50pc bias", "Mic 80pc bias", |
374 | "Line in", "Line out", "Headphone out", | |
4c5186ed JW |
375 | }; |
376 | static unsigned char alc_pin_mode_values[] = { | |
7cf51e48 | 377 | PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP, |
4c5186ed JW |
378 | }; |
379 | /* The control can present all 5 options, or it can limit the options based | |
a1e8d2da JW |
380 | * in the pin being assumed to be exclusively an input or an output pin. In |
381 | * addition, "input" pins may or may not process the mic bias option | |
382 | * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to | |
383 | * accept requests for bias as of chip versions up to March 2006) and/or | |
384 | * wiring in the computer. | |
a9430dd8 | 385 | */ |
a1e8d2da JW |
386 | #define ALC_PIN_DIR_IN 0x00 |
387 | #define ALC_PIN_DIR_OUT 0x01 | |
388 | #define ALC_PIN_DIR_INOUT 0x02 | |
389 | #define ALC_PIN_DIR_IN_NOMICBIAS 0x03 | |
390 | #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04 | |
4c5186ed | 391 | |
a1e8d2da | 392 | /* Info about the pin modes supported by the different pin direction modes. |
4c5186ed JW |
393 | * For each direction the minimum and maximum values are given. |
394 | */ | |
a1e8d2da | 395 | static signed char alc_pin_mode_dir_info[5][2] = { |
4c5186ed JW |
396 | { 0, 2 }, /* ALC_PIN_DIR_IN */ |
397 | { 3, 4 }, /* ALC_PIN_DIR_OUT */ | |
398 | { 0, 4 }, /* ALC_PIN_DIR_INOUT */ | |
a1e8d2da JW |
399 | { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */ |
400 | { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */ | |
4c5186ed JW |
401 | }; |
402 | #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0]) | |
403 | #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1]) | |
404 | #define alc_pin_mode_n_items(_dir) \ | |
405 | (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1) | |
406 | ||
9c7f852e TI |
407 | static int alc_pin_mode_info(struct snd_kcontrol *kcontrol, |
408 | struct snd_ctl_elem_info *uinfo) | |
a9430dd8 | 409 | { |
4c5186ed JW |
410 | unsigned int item_num = uinfo->value.enumerated.item; |
411 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; | |
412 | ||
413 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
a9430dd8 | 414 | uinfo->count = 1; |
4c5186ed JW |
415 | uinfo->value.enumerated.items = alc_pin_mode_n_items(dir); |
416 | ||
417 | if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir)) | |
418 | item_num = alc_pin_mode_min(dir); | |
419 | strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]); | |
a9430dd8 JW |
420 | return 0; |
421 | } | |
422 | ||
9c7f852e TI |
423 | static int alc_pin_mode_get(struct snd_kcontrol *kcontrol, |
424 | struct snd_ctl_elem_value *ucontrol) | |
a9430dd8 | 425 | { |
4c5186ed | 426 | unsigned int i; |
a9430dd8 JW |
427 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
428 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
4c5186ed | 429 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
a9430dd8 | 430 | long *valp = ucontrol->value.integer.value; |
9c7f852e TI |
431 | unsigned int pinctl = snd_hda_codec_read(codec, nid, 0, |
432 | AC_VERB_GET_PIN_WIDGET_CONTROL, | |
433 | 0x00); | |
a9430dd8 | 434 | |
4c5186ed JW |
435 | /* Find enumerated value for current pinctl setting */ |
436 | i = alc_pin_mode_min(dir); | |
9c7f852e | 437 | while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir)) |
4c5186ed | 438 | i++; |
9c7f852e | 439 | *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir); |
a9430dd8 JW |
440 | return 0; |
441 | } | |
442 | ||
9c7f852e TI |
443 | static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, |
444 | struct snd_ctl_elem_value *ucontrol) | |
a9430dd8 | 445 | { |
4c5186ed | 446 | signed int change; |
a9430dd8 JW |
447 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
448 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
4c5186ed JW |
449 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
450 | long val = *ucontrol->value.integer.value; | |
9c7f852e TI |
451 | unsigned int pinctl = snd_hda_codec_read(codec, nid, 0, |
452 | AC_VERB_GET_PIN_WIDGET_CONTROL, | |
453 | 0x00); | |
a9430dd8 | 454 | |
f12ab1e0 | 455 | if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir)) |
4c5186ed JW |
456 | val = alc_pin_mode_min(dir); |
457 | ||
458 | change = pinctl != alc_pin_mode_values[val]; | |
cdcd9268 JW |
459 | if (change) { |
460 | /* Set pin mode to that requested */ | |
82beb8fd TI |
461 | snd_hda_codec_write_cache(codec, nid, 0, |
462 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
463 | alc_pin_mode_values[val]); | |
cdcd9268 JW |
464 | |
465 | /* Also enable the retasking pin's input/output as required | |
466 | * for the requested pin mode. Enum values of 2 or less are | |
467 | * input modes. | |
468 | * | |
469 | * Dynamically switching the input/output buffers probably | |
a1e8d2da JW |
470 | * reduces noise slightly (particularly on input) so we'll |
471 | * do it. However, having both input and output buffers | |
472 | * enabled simultaneously doesn't seem to be problematic if | |
473 | * this turns out to be necessary in the future. | |
cdcd9268 JW |
474 | */ |
475 | if (val <= 2) { | |
47fd830a TI |
476 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
477 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
478 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0, | |
479 | HDA_AMP_MUTE, 0); | |
cdcd9268 | 480 | } else { |
47fd830a TI |
481 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0, |
482 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
483 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, | |
484 | HDA_AMP_MUTE, 0); | |
cdcd9268 JW |
485 | } |
486 | } | |
a9430dd8 JW |
487 | return change; |
488 | } | |
489 | ||
4c5186ed | 490 | #define ALC_PIN_MODE(xname, nid, dir) \ |
a9430dd8 | 491 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ |
4c5186ed JW |
492 | .info = alc_pin_mode_info, \ |
493 | .get = alc_pin_mode_get, \ | |
494 | .put = alc_pin_mode_put, \ | |
495 | .private_value = nid | (dir<<16) } | |
df694daa | 496 | |
5c8f858d JW |
497 | /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged |
498 | * together using a mask with more than one bit set. This control is | |
499 | * currently used only by the ALC260 test model. At this stage they are not | |
500 | * needed for any "production" models. | |
501 | */ | |
502 | #ifdef CONFIG_SND_DEBUG | |
a5ce8890 | 503 | #define alc_gpio_data_info snd_ctl_boolean_mono_info |
f12ab1e0 | 504 | |
9c7f852e TI |
505 | static int alc_gpio_data_get(struct snd_kcontrol *kcontrol, |
506 | struct snd_ctl_elem_value *ucontrol) | |
5c8f858d JW |
507 | { |
508 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
509 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
510 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
511 | long *valp = ucontrol->value.integer.value; | |
9c7f852e TI |
512 | unsigned int val = snd_hda_codec_read(codec, nid, 0, |
513 | AC_VERB_GET_GPIO_DATA, 0x00); | |
5c8f858d JW |
514 | |
515 | *valp = (val & mask) != 0; | |
516 | return 0; | |
517 | } | |
9c7f852e TI |
518 | static int alc_gpio_data_put(struct snd_kcontrol *kcontrol, |
519 | struct snd_ctl_elem_value *ucontrol) | |
5c8f858d JW |
520 | { |
521 | signed int change; | |
522 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
523 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
524 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
525 | long val = *ucontrol->value.integer.value; | |
9c7f852e TI |
526 | unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0, |
527 | AC_VERB_GET_GPIO_DATA, | |
528 | 0x00); | |
5c8f858d JW |
529 | |
530 | /* Set/unset the masked GPIO bit(s) as needed */ | |
9c7f852e TI |
531 | change = (val == 0 ? 0 : mask) != (gpio_data & mask); |
532 | if (val == 0) | |
5c8f858d JW |
533 | gpio_data &= ~mask; |
534 | else | |
535 | gpio_data |= mask; | |
82beb8fd TI |
536 | snd_hda_codec_write_cache(codec, nid, 0, |
537 | AC_VERB_SET_GPIO_DATA, gpio_data); | |
5c8f858d JW |
538 | |
539 | return change; | |
540 | } | |
541 | #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \ | |
542 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
543 | .info = alc_gpio_data_info, \ | |
544 | .get = alc_gpio_data_get, \ | |
545 | .put = alc_gpio_data_put, \ | |
546 | .private_value = nid | (mask<<16) } | |
547 | #endif /* CONFIG_SND_DEBUG */ | |
548 | ||
92621f13 JW |
549 | /* A switch control to allow the enabling of the digital IO pins on the |
550 | * ALC260. This is incredibly simplistic; the intention of this control is | |
551 | * to provide something in the test model allowing digital outputs to be | |
552 | * identified if present. If models are found which can utilise these | |
553 | * outputs a more complete mixer control can be devised for those models if | |
554 | * necessary. | |
555 | */ | |
556 | #ifdef CONFIG_SND_DEBUG | |
a5ce8890 | 557 | #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info |
f12ab1e0 | 558 | |
9c7f852e TI |
559 | static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol, |
560 | struct snd_ctl_elem_value *ucontrol) | |
92621f13 JW |
561 | { |
562 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
563 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
564 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
565 | long *valp = ucontrol->value.integer.value; | |
9c7f852e TI |
566 | unsigned int val = snd_hda_codec_read(codec, nid, 0, |
567 | AC_VERB_GET_DIGI_CONVERT, 0x00); | |
92621f13 JW |
568 | |
569 | *valp = (val & mask) != 0; | |
570 | return 0; | |
571 | } | |
9c7f852e TI |
572 | static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol, |
573 | struct snd_ctl_elem_value *ucontrol) | |
92621f13 JW |
574 | { |
575 | signed int change; | |
576 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
577 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
578 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
579 | long val = *ucontrol->value.integer.value; | |
9c7f852e TI |
580 | unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0, |
581 | AC_VERB_GET_DIGI_CONVERT, | |
582 | 0x00); | |
92621f13 JW |
583 | |
584 | /* Set/unset the masked control bit(s) as needed */ | |
9c7f852e | 585 | change = (val == 0 ? 0 : mask) != (ctrl_data & mask); |
92621f13 JW |
586 | if (val==0) |
587 | ctrl_data &= ~mask; | |
588 | else | |
589 | ctrl_data |= mask; | |
82beb8fd TI |
590 | snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, |
591 | ctrl_data); | |
92621f13 JW |
592 | |
593 | return change; | |
594 | } | |
595 | #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \ | |
596 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
597 | .info = alc_spdif_ctrl_info, \ | |
598 | .get = alc_spdif_ctrl_get, \ | |
599 | .put = alc_spdif_ctrl_put, \ | |
600 | .private_value = nid | (mask<<16) } | |
601 | #endif /* CONFIG_SND_DEBUG */ | |
602 | ||
df694daa KY |
603 | /* |
604 | * set up from the preset table | |
605 | */ | |
9c7f852e TI |
606 | static void setup_preset(struct alc_spec *spec, |
607 | const struct alc_config_preset *preset) | |
df694daa KY |
608 | { |
609 | int i; | |
610 | ||
611 | for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++) | |
612 | spec->mixers[spec->num_mixers++] = preset->mixers[i]; | |
9c7f852e TI |
613 | for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; |
614 | i++) | |
615 | spec->init_verbs[spec->num_init_verbs++] = | |
616 | preset->init_verbs[i]; | |
df694daa KY |
617 | |
618 | spec->channel_mode = preset->channel_mode; | |
619 | spec->num_channel_mode = preset->num_channel_mode; | |
4e195a7b | 620 | spec->need_dac_fix = preset->need_dac_fix; |
df694daa KY |
621 | |
622 | spec->multiout.max_channels = spec->channel_mode[0].channels; | |
623 | ||
624 | spec->multiout.num_dacs = preset->num_dacs; | |
625 | spec->multiout.dac_nids = preset->dac_nids; | |
626 | spec->multiout.dig_out_nid = preset->dig_out_nid; | |
627 | spec->multiout.hp_nid = preset->hp_nid; | |
628 | ||
a1e8d2da | 629 | spec->num_mux_defs = preset->num_mux_defs; |
f12ab1e0 | 630 | if (!spec->num_mux_defs) |
a1e8d2da | 631 | spec->num_mux_defs = 1; |
df694daa KY |
632 | spec->input_mux = preset->input_mux; |
633 | ||
634 | spec->num_adc_nids = preset->num_adc_nids; | |
635 | spec->adc_nids = preset->adc_nids; | |
636 | spec->dig_in_nid = preset->dig_in_nid; | |
ae6b813a TI |
637 | |
638 | spec->unsol_event = preset->unsol_event; | |
639 | spec->init_hook = preset->init_hook; | |
cb53c626 TI |
640 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
641 | spec->loopback.amplist = preset->loopbacks; | |
642 | #endif | |
df694daa KY |
643 | } |
644 | ||
bc9f98a9 KY |
645 | /* Enable GPIO mask and set output */ |
646 | static struct hda_verb alc_gpio1_init_verbs[] = { | |
647 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
648 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
649 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, | |
650 | { } | |
651 | }; | |
652 | ||
653 | static struct hda_verb alc_gpio2_init_verbs[] = { | |
654 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, | |
655 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, | |
656 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, | |
657 | { } | |
658 | }; | |
659 | ||
bdd148a3 KY |
660 | static struct hda_verb alc_gpio3_init_verbs[] = { |
661 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, | |
662 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | |
663 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | |
664 | { } | |
665 | }; | |
666 | ||
c9b58006 KY |
667 | static void alc_sku_automute(struct hda_codec *codec) |
668 | { | |
669 | struct alc_spec *spec = codec->spec; | |
670 | unsigned int mute; | |
671 | unsigned int present; | |
672 | unsigned int hp_nid = spec->autocfg.hp_pins[0]; | |
673 | unsigned int sp_nid = spec->autocfg.speaker_pins[0]; | |
674 | ||
675 | /* need to execute and sync at first */ | |
676 | snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0); | |
677 | present = snd_hda_codec_read(codec, hp_nid, 0, | |
678 | AC_VERB_GET_PIN_SENSE, 0); | |
679 | spec->jack_present = (present & 0x80000000) != 0; | |
680 | if (spec->jack_present) { | |
681 | /* mute internal speaker */ | |
682 | snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0, | |
683 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
684 | } else { | |
685 | /* unmute internal speaker if necessary */ | |
686 | mute = snd_hda_codec_amp_read(codec, hp_nid, 0, HDA_OUTPUT, 0); | |
687 | snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0, | |
688 | HDA_AMP_MUTE, mute); | |
689 | } | |
690 | } | |
691 | ||
692 | /* unsolicited event for HP jack sensing */ | |
693 | static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) | |
694 | { | |
695 | if (codec->vendor_id == 0x10ec0880) | |
696 | res >>= 28; | |
697 | else | |
698 | res >>= 26; | |
699 | if (res != ALC880_HP_EVENT) | |
700 | return; | |
701 | ||
702 | alc_sku_automute(codec); | |
703 | } | |
704 | ||
bc9f98a9 KY |
705 | /* 32-bit subsystem ID for BIOS loading in HD Audio codec. |
706 | * 31 ~ 16 : Manufacture ID | |
707 | * 15 ~ 8 : SKU ID | |
708 | * 7 ~ 0 : Assembly ID | |
709 | * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36 | |
710 | */ | |
711 | static void alc_subsystem_id(struct hda_codec *codec, | |
712 | unsigned int porta, unsigned int porte, | |
713 | unsigned int portd) | |
714 | { | |
c9b58006 KY |
715 | unsigned int ass, tmp, i; |
716 | unsigned nid; | |
717 | struct alc_spec *spec = codec->spec; | |
bc9f98a9 | 718 | |
c9b58006 KY |
719 | ass = codec->subsystem_id & 0xffff; |
720 | if ((ass != codec->bus->pci->subsystem_device) && (ass & 1)) | |
721 | goto do_sku; | |
722 | ||
723 | /* | |
724 | * 31~30 : port conetcivity | |
725 | * 29~21 : reserve | |
726 | * 20 : PCBEEP input | |
727 | * 19~16 : Check sum (15:1) | |
728 | * 15~1 : Custom | |
729 | * 0 : override | |
730 | */ | |
731 | nid = 0x1d; | |
732 | if (codec->vendor_id == 0x10ec0260) | |
733 | nid = 0x17; | |
734 | ass = snd_hda_codec_read(codec, nid, 0, | |
735 | AC_VERB_GET_CONFIG_DEFAULT, 0); | |
736 | if (!(ass & 1) && !(ass & 0x100000)) | |
737 | return; | |
738 | if ((ass >> 30) != 1) /* no physical connection */ | |
bc9f98a9 KY |
739 | return; |
740 | ||
c9b58006 KY |
741 | /* check sum */ |
742 | tmp = 0; | |
743 | for (i = 1; i < 16; i++) { | |
744 | if ((ass >> i) && 1) | |
745 | tmp++; | |
746 | } | |
747 | if (((ass >> 16) & 0xf) != tmp) | |
748 | return; | |
749 | do_sku: | |
750 | /* | |
751 | * 0 : override | |
752 | * 1 : Swap Jack | |
753 | * 2 : 0 --> Desktop, 1 --> Laptop | |
754 | * 3~5 : External Amplifier control | |
755 | * 7~6 : Reserved | |
756 | */ | |
bc9f98a9 KY |
757 | tmp = (ass & 0x38) >> 3; /* external Amp control */ |
758 | switch (tmp) { | |
759 | case 1: | |
760 | snd_hda_sequence_write(codec, alc_gpio1_init_verbs); | |
761 | break; | |
762 | case 3: | |
763 | snd_hda_sequence_write(codec, alc_gpio2_init_verbs); | |
764 | break; | |
bdd148a3 KY |
765 | case 7: |
766 | snd_hda_sequence_write(codec, alc_gpio3_init_verbs); | |
767 | break; | |
c9b58006 | 768 | case 5: /* set EAPD output high */ |
bdd148a3 | 769 | switch (codec->vendor_id) { |
c9b58006 KY |
770 | case 0x10ec0260: |
771 | snd_hda_codec_write(codec, 0x0f, 0, | |
772 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
773 | snd_hda_codec_write(codec, 0x10, 0, | |
774 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
775 | break; | |
776 | case 0x10ec0262: | |
bdd148a3 KY |
777 | case 0x10ec0267: |
778 | case 0x10ec0268: | |
c9b58006 KY |
779 | case 0x10ec0269: |
780 | case 0x10ec0862: | |
781 | case 0x10ec0662: | |
bdd148a3 KY |
782 | snd_hda_codec_write(codec, 0x14, 0, |
783 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
784 | snd_hda_codec_write(codec, 0x15, 0, | |
785 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
c9b58006 | 786 | break; |
bdd148a3 | 787 | } |
c9b58006 KY |
788 | switch (codec->vendor_id) { |
789 | case 0x10ec0260: | |
790 | snd_hda_codec_write(codec, 0x1a, 0, | |
791 | AC_VERB_SET_COEF_INDEX, 7); | |
792 | tmp = snd_hda_codec_read(codec, 0x1a, 0, | |
793 | AC_VERB_GET_PROC_COEF, 0); | |
794 | snd_hda_codec_write(codec, 0x1a, 0, | |
795 | AC_VERB_SET_COEF_INDEX, 7); | |
796 | snd_hda_codec_write(codec, 0x1a, 0, | |
797 | AC_VERB_SET_PROC_COEF, | |
798 | tmp | 0x2010); | |
799 | break; | |
800 | case 0x10ec0262: | |
801 | case 0x10ec0880: | |
802 | case 0x10ec0882: | |
803 | case 0x10ec0883: | |
804 | case 0x10ec0885: | |
805 | case 0x10ec0888: | |
806 | snd_hda_codec_write(codec, 0x20, 0, | |
807 | AC_VERB_SET_COEF_INDEX, 7); | |
808 | tmp = snd_hda_codec_read(codec, 0x20, 0, | |
809 | AC_VERB_GET_PROC_COEF, 0); | |
810 | snd_hda_codec_write(codec, 0x20, 0, | |
811 | AC_VERB_SET_COEF_INDEX, 7); | |
812 | snd_hda_codec_write(codec, 0x20, 0, | |
813 | AC_VERB_SET_PROC_COEF, | |
814 | tmp | 0x2010); | |
815 | break; | |
816 | case 0x10ec0267: | |
817 | case 0x10ec0268: | |
818 | snd_hda_codec_write(codec, 0x20, 0, | |
819 | AC_VERB_SET_COEF_INDEX, 7); | |
820 | tmp = snd_hda_codec_read(codec, 0x20, 0, | |
821 | AC_VERB_GET_PROC_COEF, 0); | |
822 | snd_hda_codec_write(codec, 0x20, 0, | |
823 | AC_VERB_SET_COEF_INDEX, 7); | |
824 | snd_hda_codec_write(codec, 0x20, 0, | |
825 | AC_VERB_SET_PROC_COEF, | |
826 | tmp | 0x3000); | |
827 | break; | |
bc9f98a9 | 828 | } |
c9b58006 | 829 | default: |
bc9f98a9 KY |
830 | break; |
831 | } | |
c9b58006 KY |
832 | |
833 | /* is laptop and enable the function "Mute internal speaker | |
834 | * when the external headphone out jack is plugged" | |
835 | */ | |
836 | if (!(ass & 0x4) || !(ass & 0x8000)) | |
837 | return; | |
838 | /* | |
839 | * 10~8 : Jack location | |
840 | * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered | |
841 | * 14~13: Resvered | |
842 | * 15 : 1 --> enable the function "Mute internal speaker | |
843 | * when the external headphone out jack is plugged" | |
844 | */ | |
845 | if (!spec->autocfg.speaker_pins[0]) { | |
846 | if (spec->multiout.dac_nids[0]) | |
847 | spec->autocfg.speaker_pins[0] = | |
848 | spec->multiout.dac_nids[0]; | |
849 | else | |
850 | return; | |
851 | } | |
852 | ||
853 | if (!spec->autocfg.hp_pins[0]) { | |
854 | tmp = (ass >> 11) & 0x3; /* HP to chassis */ | |
855 | if (tmp == 0) | |
856 | spec->autocfg.hp_pins[0] = porta; | |
857 | else if (tmp == 1) | |
858 | spec->autocfg.hp_pins[0] = porte; | |
859 | else if (tmp == 2) | |
860 | spec->autocfg.hp_pins[0] = portd; | |
861 | else | |
862 | return; | |
863 | } | |
864 | ||
865 | snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0, | |
866 | AC_VERB_SET_UNSOLICITED_ENABLE, | |
867 | AC_USRSP_EN | ALC880_HP_EVENT); | |
868 | spec->unsol_event = alc_sku_unsol_event; | |
869 | spec->init_hook = alc_sku_automute; | |
bc9f98a9 KY |
870 | } |
871 | ||
f95474ec TI |
872 | /* |
873 | * Fix-up pin default configurations | |
874 | */ | |
875 | ||
876 | struct alc_pincfg { | |
877 | hda_nid_t nid; | |
878 | u32 val; | |
879 | }; | |
880 | ||
881 | static void alc_fix_pincfg(struct hda_codec *codec, | |
882 | const struct snd_pci_quirk *quirk, | |
883 | const struct alc_pincfg **pinfix) | |
884 | { | |
885 | const struct alc_pincfg *cfg; | |
886 | ||
887 | quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk); | |
888 | if (!quirk) | |
889 | return; | |
890 | ||
891 | cfg = pinfix[quirk->value]; | |
892 | for (; cfg->nid; cfg++) { | |
893 | int i; | |
894 | u32 val = cfg->val; | |
895 | for (i = 0; i < 4; i++) { | |
896 | snd_hda_codec_write(codec, cfg->nid, 0, | |
897 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i, | |
898 | val & 0xff); | |
899 | val >>= 8; | |
900 | } | |
901 | } | |
902 | } | |
903 | ||
1da177e4 | 904 | /* |
e9edcee0 TI |
905 | * ALC880 3-stack model |
906 | * | |
907 | * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e) | |
9c7f852e TI |
908 | * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, |
909 | * F-Mic = 0x1b, HP = 0x19 | |
1da177e4 LT |
910 | */ |
911 | ||
e9edcee0 TI |
912 | static hda_nid_t alc880_dac_nids[4] = { |
913 | /* front, rear, clfe, rear_surr */ | |
914 | 0x02, 0x05, 0x04, 0x03 | |
915 | }; | |
916 | ||
917 | static hda_nid_t alc880_adc_nids[3] = { | |
918 | /* ADC0-2 */ | |
919 | 0x07, 0x08, 0x09, | |
920 | }; | |
921 | ||
922 | /* The datasheet says the node 0x07 is connected from inputs, | |
923 | * but it shows zero connection in the real implementation on some devices. | |
df694daa | 924 | * Note: this is a 915GAV bug, fixed on 915GLV |
1da177e4 | 925 | */ |
e9edcee0 TI |
926 | static hda_nid_t alc880_adc_nids_alt[2] = { |
927 | /* ADC1-2 */ | |
928 | 0x08, 0x09, | |
929 | }; | |
930 | ||
931 | #define ALC880_DIGOUT_NID 0x06 | |
932 | #define ALC880_DIGIN_NID 0x0a | |
933 | ||
934 | static struct hda_input_mux alc880_capture_source = { | |
935 | .num_items = 4, | |
936 | .items = { | |
937 | { "Mic", 0x0 }, | |
938 | { "Front Mic", 0x3 }, | |
939 | { "Line", 0x2 }, | |
940 | { "CD", 0x4 }, | |
941 | }, | |
942 | }; | |
943 | ||
944 | /* channel source setting (2/6 channel selection for 3-stack) */ | |
945 | /* 2ch mode */ | |
946 | static struct hda_verb alc880_threestack_ch2_init[] = { | |
947 | /* set line-in to input, mute it */ | |
948 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
949 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
950 | /* set mic-in to input vref 80%, mute it */ | |
951 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
952 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
953 | { } /* end */ | |
954 | }; | |
955 | ||
956 | /* 6ch mode */ | |
957 | static struct hda_verb alc880_threestack_ch6_init[] = { | |
958 | /* set line-in to output, unmute it */ | |
959 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
960 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
961 | /* set mic-in to output, unmute it */ | |
962 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
963 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
964 | { } /* end */ | |
965 | }; | |
966 | ||
d2a6d7dc | 967 | static struct hda_channel_mode alc880_threestack_modes[2] = { |
e9edcee0 TI |
968 | { 2, alc880_threestack_ch2_init }, |
969 | { 6, alc880_threestack_ch6_init }, | |
970 | }; | |
971 | ||
c8b6bf9b | 972 | static struct snd_kcontrol_new alc880_three_stack_mixer[] = { |
05acb863 | 973 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 974 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
05acb863 | 975 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 976 | HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT), |
05acb863 TI |
977 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
978 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
979 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
980 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
1da177e4 LT |
981 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
982 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
983 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
984 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
985 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
986 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
987 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT), | |
988 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT), | |
989 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
990 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
e9edcee0 TI |
991 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT), |
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, | |
e9edcee0 TI |
998 | }, |
999 | { } /* end */ | |
1000 | }; | |
1001 | ||
1002 | /* capture mixer elements */ | |
c8b6bf9b | 1003 | static struct snd_kcontrol_new alc880_capture_mixer[] = { |
e9edcee0 TI |
1004 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), |
1005 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), | |
1006 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), | |
1007 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), | |
1008 | HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), | |
1009 | HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), | |
1da177e4 LT |
1010 | { |
1011 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1012 | /* The multiple "Capture Source" controls confuse alsamixer | |
1013 | * So call somewhat different.. | |
1014 | * FIXME: the controls appear in the "playback" view! | |
1015 | */ | |
1016 | /* .name = "Capture Source", */ | |
1017 | .name = "Input Source", | |
e9edcee0 | 1018 | .count = 3, |
1da177e4 LT |
1019 | .info = alc_mux_enum_info, |
1020 | .get = alc_mux_enum_get, | |
1021 | .put = alc_mux_enum_put, | |
1022 | }, | |
1da177e4 LT |
1023 | { } /* end */ |
1024 | }; | |
1025 | ||
e9edcee0 | 1026 | /* capture mixer elements (in case NID 0x07 not available) */ |
c8b6bf9b | 1027 | static struct snd_kcontrol_new alc880_capture_alt_mixer[] = { |
71fe7b82 TI |
1028 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
1029 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
1030 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
1031 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
1da177e4 LT |
1032 | { |
1033 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1034 | /* The multiple "Capture Source" controls confuse alsamixer | |
1035 | * So call somewhat different.. | |
1036 | * FIXME: the controls appear in the "playback" view! | |
1037 | */ | |
1038 | /* .name = "Capture Source", */ | |
1039 | .name = "Input Source", | |
1040 | .count = 2, | |
1041 | .info = alc_mux_enum_info, | |
1042 | .get = alc_mux_enum_get, | |
1043 | .put = alc_mux_enum_put, | |
1044 | }, | |
1da177e4 LT |
1045 | { } /* end */ |
1046 | }; | |
1047 | ||
e9edcee0 TI |
1048 | |
1049 | ||
1050 | /* | |
1051 | * ALC880 5-stack model | |
1052 | * | |
9c7f852e TI |
1053 | * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), |
1054 | * Side = 0x02 (0xd) | |
e9edcee0 TI |
1055 | * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16 |
1056 | * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19 | |
1057 | */ | |
1058 | ||
1059 | /* additional mixers to alc880_three_stack_mixer */ | |
c8b6bf9b | 1060 | static struct snd_kcontrol_new alc880_five_stack_mixer[] = { |
e9edcee0 | 1061 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1062 | HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT), |
1da177e4 LT |
1063 | { } /* end */ |
1064 | }; | |
1065 | ||
e9edcee0 TI |
1066 | /* channel source setting (6/8 channel selection for 5-stack) */ |
1067 | /* 6ch mode */ | |
1068 | static struct hda_verb alc880_fivestack_ch6_init[] = { | |
1069 | /* set line-in to input, mute it */ | |
1070 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
1071 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
dfc0ff62 TI |
1072 | { } /* end */ |
1073 | }; | |
1074 | ||
e9edcee0 TI |
1075 | /* 8ch mode */ |
1076 | static struct hda_verb alc880_fivestack_ch8_init[] = { | |
1077 | /* set line-in to output, unmute it */ | |
1078 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1079 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1080 | { } /* end */ | |
1081 | }; | |
1082 | ||
d2a6d7dc | 1083 | static struct hda_channel_mode alc880_fivestack_modes[2] = { |
e9edcee0 TI |
1084 | { 6, alc880_fivestack_ch6_init }, |
1085 | { 8, alc880_fivestack_ch8_init }, | |
1086 | }; | |
1087 | ||
1088 | ||
1089 | /* | |
1090 | * ALC880 6-stack model | |
1091 | * | |
9c7f852e TI |
1092 | * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), |
1093 | * Side = 0x05 (0x0f) | |
e9edcee0 TI |
1094 | * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17, |
1095 | * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b | |
1096 | */ | |
1097 | ||
1098 | static hda_nid_t alc880_6st_dac_nids[4] = { | |
1099 | /* front, rear, clfe, rear_surr */ | |
1100 | 0x02, 0x03, 0x04, 0x05 | |
f12ab1e0 | 1101 | }; |
e9edcee0 TI |
1102 | |
1103 | static struct hda_input_mux alc880_6stack_capture_source = { | |
1104 | .num_items = 4, | |
1105 | .items = { | |
1106 | { "Mic", 0x0 }, | |
1107 | { "Front Mic", 0x1 }, | |
1108 | { "Line", 0x2 }, | |
1109 | { "CD", 0x4 }, | |
1110 | }, | |
1111 | }; | |
1112 | ||
1113 | /* fixed 8-channels */ | |
d2a6d7dc | 1114 | static struct hda_channel_mode alc880_sixstack_modes[1] = { |
e9edcee0 TI |
1115 | { 8, NULL }, |
1116 | }; | |
1117 | ||
c8b6bf9b | 1118 | static struct snd_kcontrol_new alc880_six_stack_mixer[] = { |
16ded525 | 1119 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1120 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 1121 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1122 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1123 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1124 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1125 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1126 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
16ded525 | 1127 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 1128 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
16ded525 TI |
1129 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1130 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1131 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1132 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
1133 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1134 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1135 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1136 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1137 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
1138 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
16ded525 TI |
1139 | { |
1140 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1141 | .name = "Channel Mode", | |
df694daa KY |
1142 | .info = alc_ch_mode_info, |
1143 | .get = alc_ch_mode_get, | |
1144 | .put = alc_ch_mode_put, | |
16ded525 TI |
1145 | }, |
1146 | { } /* end */ | |
1147 | }; | |
1148 | ||
e9edcee0 TI |
1149 | |
1150 | /* | |
1151 | * ALC880 W810 model | |
1152 | * | |
1153 | * W810 has rear IO for: | |
1154 | * Front (DAC 02) | |
1155 | * Surround (DAC 03) | |
1156 | * Center/LFE (DAC 04) | |
1157 | * Digital out (06) | |
1158 | * | |
1159 | * The system also has a pair of internal speakers, and a headphone jack. | |
1160 | * These are both connected to Line2 on the codec, hence to DAC 02. | |
1161 | * | |
1162 | * There is a variable resistor to control the speaker or headphone | |
1163 | * volume. This is a hardware-only device without a software API. | |
1164 | * | |
1165 | * Plugging headphones in will disable the internal speakers. This is | |
1166 | * implemented in hardware, not via the driver using jack sense. In | |
1167 | * a similar fashion, plugging into the rear socket marked "front" will | |
1168 | * disable both the speakers and headphones. | |
1169 | * | |
1170 | * For input, there's a microphone jack, and an "audio in" jack. | |
1171 | * These may not do anything useful with this driver yet, because I | |
1172 | * haven't setup any initialization verbs for these yet... | |
1173 | */ | |
1174 | ||
1175 | static hda_nid_t alc880_w810_dac_nids[3] = { | |
1176 | /* front, rear/surround, clfe */ | |
1177 | 0x02, 0x03, 0x04 | |
16ded525 TI |
1178 | }; |
1179 | ||
e9edcee0 | 1180 | /* fixed 6 channels */ |
d2a6d7dc | 1181 | static struct hda_channel_mode alc880_w810_modes[1] = { |
e9edcee0 TI |
1182 | { 6, NULL } |
1183 | }; | |
1184 | ||
1185 | /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */ | |
c8b6bf9b | 1186 | static struct snd_kcontrol_new alc880_w810_base_mixer[] = { |
16ded525 | 1187 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1188 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 1189 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1190 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1191 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1192 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1193 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1194 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
e9edcee0 TI |
1195 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
1196 | { } /* end */ | |
1197 | }; | |
1198 | ||
1199 | ||
1200 | /* | |
1201 | * Z710V model | |
1202 | * | |
1203 | * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d) | |
9c7f852e TI |
1204 | * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), |
1205 | * Line = 0x1a | |
e9edcee0 TI |
1206 | */ |
1207 | ||
1208 | static hda_nid_t alc880_z71v_dac_nids[1] = { | |
1209 | 0x02 | |
1210 | }; | |
1211 | #define ALC880_Z71V_HP_DAC 0x03 | |
1212 | ||
1213 | /* fixed 2 channels */ | |
d2a6d7dc | 1214 | static struct hda_channel_mode alc880_2_jack_modes[1] = { |
e9edcee0 TI |
1215 | { 2, NULL } |
1216 | }; | |
1217 | ||
c8b6bf9b | 1218 | static struct snd_kcontrol_new alc880_z71v_mixer[] = { |
e9edcee0 | 1219 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1220 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
e9edcee0 | 1221 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1222 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1223 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1224 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
16ded525 TI |
1225 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
1226 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
16ded525 TI |
1227 | { } /* end */ |
1228 | }; | |
1229 | ||
e9edcee0 TI |
1230 | |
1231 | /* FIXME! */ | |
1232 | /* | |
1233 | * ALC880 F1734 model | |
1234 | * | |
1235 | * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d) | |
1236 | * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18 | |
1237 | */ | |
1238 | ||
1239 | static hda_nid_t alc880_f1734_dac_nids[1] = { | |
1240 | 0x03 | |
1241 | }; | |
1242 | #define ALC880_F1734_HP_DAC 0x02 | |
1243 | ||
c8b6bf9b | 1244 | static struct snd_kcontrol_new alc880_f1734_mixer[] = { |
e9edcee0 | 1245 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1246 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), |
e9edcee0 | 1247 | HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1248 | HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT), |
e9edcee0 TI |
1249 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1250 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1251 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1252 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1253 | { } /* end */ | |
1254 | }; | |
1255 | ||
1256 | ||
1257 | /* FIXME! */ | |
1258 | /* | |
1259 | * ALC880 ASUS model | |
1260 | * | |
1261 | * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) | |
1262 | * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, | |
1263 | * Mic = 0x18, Line = 0x1a | |
1264 | */ | |
1265 | ||
1266 | #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */ | |
1267 | #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */ | |
1268 | ||
c8b6bf9b | 1269 | static struct snd_kcontrol_new alc880_asus_mixer[] = { |
16ded525 | 1270 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1271 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 1272 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1273 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1274 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1275 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1276 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1277 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
16ded525 TI |
1278 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1279 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1280 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1281 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
16ded525 TI |
1282 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
1283 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
16ded525 TI |
1284 | { |
1285 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1286 | .name = "Channel Mode", | |
df694daa KY |
1287 | .info = alc_ch_mode_info, |
1288 | .get = alc_ch_mode_get, | |
1289 | .put = alc_ch_mode_put, | |
16ded525 TI |
1290 | }, |
1291 | { } /* end */ | |
1292 | }; | |
e9edcee0 TI |
1293 | |
1294 | /* FIXME! */ | |
1295 | /* | |
1296 | * ALC880 ASUS W1V model | |
1297 | * | |
1298 | * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) | |
1299 | * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, | |
1300 | * Mic = 0x18, Line = 0x1a, Line2 = 0x1b | |
1301 | */ | |
1302 | ||
1303 | /* additional mixers to alc880_asus_mixer */ | |
c8b6bf9b | 1304 | static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = { |
e9edcee0 TI |
1305 | HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT), |
1306 | HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT), | |
1307 | { } /* end */ | |
1308 | }; | |
1309 | ||
3c10a9d9 | 1310 | /* additional mixers to alc880_asus_mixer */ |
c8b6bf9b | 1311 | static struct snd_kcontrol_new alc880_pcbeep_mixer[] = { |
3c10a9d9 TI |
1312 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), |
1313 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
1314 | { } /* end */ | |
1315 | }; | |
e9edcee0 | 1316 | |
df694daa KY |
1317 | /* TCL S700 */ |
1318 | static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = { | |
1319 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1320 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
1321 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
1322 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT), | |
1323 | HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT), | |
1324 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT), | |
1325 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT), | |
1326 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
1327 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
1328 | { | |
1329 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1330 | /* The multiple "Capture Source" controls confuse alsamixer | |
1331 | * So call somewhat different.. | |
1332 | * FIXME: the controls appear in the "playback" view! | |
1333 | */ | |
1334 | /* .name = "Capture Source", */ | |
1335 | .name = "Input Source", | |
1336 | .count = 1, | |
1337 | .info = alc_mux_enum_info, | |
1338 | .get = alc_mux_enum_get, | |
1339 | .put = alc_mux_enum_put, | |
1340 | }, | |
1341 | { } /* end */ | |
1342 | }; | |
1343 | ||
ccc656ce KY |
1344 | /* Uniwill */ |
1345 | static struct snd_kcontrol_new alc880_uniwill_mixer[] = { | |
1346 | HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1347 | HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1348 | HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1349 | HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
1350 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
1351 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
1352 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
1353 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
1354 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
1355 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1356 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1357 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
1358 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1359 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1360 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1361 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1362 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
1363 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
1364 | { | |
1365 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1366 | .name = "Channel Mode", | |
1367 | .info = alc_ch_mode_info, | |
1368 | .get = alc_ch_mode_get, | |
1369 | .put = alc_ch_mode_put, | |
1370 | }, | |
1371 | { } /* end */ | |
1372 | }; | |
1373 | ||
2cf9f0fc TD |
1374 | static struct snd_kcontrol_new alc880_fujitsu_mixer[] = { |
1375 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1376 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1377 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1378 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
1379 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
1380 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1381 | HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1382 | HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1383 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1384 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1385 | { } /* end */ | |
1386 | }; | |
1387 | ||
ccc656ce KY |
1388 | static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = { |
1389 | HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1390 | HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1391 | HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1392 | HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
1393 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1394 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1395 | { } /* end */ | |
1396 | }; | |
1397 | ||
1da177e4 | 1398 | /* |
e9edcee0 | 1399 | * build control elements |
1da177e4 LT |
1400 | */ |
1401 | static int alc_build_controls(struct hda_codec *codec) | |
1402 | { | |
1403 | struct alc_spec *spec = codec->spec; | |
1404 | int err; | |
1405 | int i; | |
1406 | ||
1407 | for (i = 0; i < spec->num_mixers; i++) { | |
1408 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); | |
1409 | if (err < 0) | |
1410 | return err; | |
1411 | } | |
1412 | ||
1413 | if (spec->multiout.dig_out_nid) { | |
9c7f852e TI |
1414 | err = snd_hda_create_spdif_out_ctls(codec, |
1415 | spec->multiout.dig_out_nid); | |
1da177e4 LT |
1416 | if (err < 0) |
1417 | return err; | |
1418 | } | |
1419 | if (spec->dig_in_nid) { | |
1420 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); | |
1421 | if (err < 0) | |
1422 | return err; | |
1423 | } | |
1424 | return 0; | |
1425 | } | |
1426 | ||
e9edcee0 | 1427 | |
1da177e4 LT |
1428 | /* |
1429 | * initialize the codec volumes, etc | |
1430 | */ | |
1431 | ||
e9edcee0 TI |
1432 | /* |
1433 | * generic initialization of ADC, input mixers and output mixers | |
1434 | */ | |
1435 | static struct hda_verb alc880_volume_init_verbs[] = { | |
1436 | /* | |
1437 | * Unmute ADC0-2 and set the default input to mic-in | |
1438 | */ | |
71fe7b82 | 1439 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 1440 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
71fe7b82 | 1441 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 1442 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
71fe7b82 | 1443 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 1444 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1da177e4 | 1445 | |
e9edcee0 TI |
1446 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
1447 | * mixer widget | |
9c7f852e TI |
1448 | * Note: PASD motherboards uses the Line In 2 as the input for front |
1449 | * panel mic (mic 2) | |
1da177e4 | 1450 | */ |
e9edcee0 | 1451 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ |
cb53c626 TI |
1452 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1453 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1454 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
1455 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
1456 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1457 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
1458 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
1da177e4 | 1459 | |
e9edcee0 TI |
1460 | /* |
1461 | * Set up output mixers (0x0c - 0x0f) | |
1da177e4 | 1462 | */ |
e9edcee0 TI |
1463 | /* set vol=0 to output mixers */ |
1464 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1465 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1466 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1467 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1468 | /* set up input amps for analog loopback */ | |
1469 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
05acb863 TI |
1470 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1471 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
1472 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1473 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
1474 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1475 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
1476 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1477 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 LT |
1478 | |
1479 | { } | |
1480 | }; | |
1481 | ||
e9edcee0 TI |
1482 | /* |
1483 | * 3-stack pin configuration: | |
1484 | * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b | |
1485 | */ | |
1486 | static struct hda_verb alc880_pin_3stack_init_verbs[] = { | |
1487 | /* | |
1488 | * preset connection lists of input pins | |
1489 | * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround | |
1490 | */ | |
1491 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
1492 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
1493 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */ | |
1494 | ||
1495 | /* | |
1496 | * Set pin mode and muting | |
1497 | */ | |
1498 | /* set front pin widgets 0x14 for output */ | |
05acb863 | 1499 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
1500 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1501 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
1502 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1503 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1504 | /* Mic2 (as headphone out) for HP output */ | |
1505 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1506 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1da177e4 | 1507 | /* Line In pin widget for input */ |
05acb863 | 1508 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 TI |
1509 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
1510 | /* Line2 (as front mic) pin widget for input and vref at 80% */ | |
1511 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1512 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1da177e4 | 1513 | /* CD pin widget for input */ |
05acb863 | 1514 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 1515 | |
e9edcee0 TI |
1516 | { } |
1517 | }; | |
1da177e4 | 1518 | |
e9edcee0 TI |
1519 | /* |
1520 | * 5-stack pin configuration: | |
1521 | * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19, | |
1522 | * line-in/side = 0x1a, f-mic = 0x1b | |
1523 | */ | |
1524 | static struct hda_verb alc880_pin_5stack_init_verbs[] = { | |
1525 | /* | |
1526 | * preset connection lists of input pins | |
1527 | * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround | |
1da177e4 | 1528 | */ |
e9edcee0 TI |
1529 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
1530 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */ | |
1da177e4 | 1531 | |
e9edcee0 TI |
1532 | /* |
1533 | * Set pin mode and muting | |
1da177e4 | 1534 | */ |
e9edcee0 TI |
1535 | /* set pin widgets 0x14-0x17 for output */ |
1536 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1537 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1538 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1539 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1540 | /* unmute pins for output (no gain on this amp) */ | |
1541 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1542 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1543 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1544 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1545 | ||
1546 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
1547 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1548 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1549 | /* Mic2 (as headphone out) for HP output */ | |
1550 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1551 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1552 | /* Line In pin widget for input */ | |
1553 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1554 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1555 | /* Line2 (as front mic) pin widget for input and vref at 80% */ | |
1556 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1557 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1558 | /* CD pin widget for input */ | |
1559 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1da177e4 LT |
1560 | |
1561 | { } | |
1562 | }; | |
1563 | ||
e9edcee0 TI |
1564 | /* |
1565 | * W810 pin configuration: | |
1566 | * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b | |
1567 | */ | |
1568 | static struct hda_verb alc880_pin_w810_init_verbs[] = { | |
1569 | /* hphone/speaker input selector: front DAC */ | |
1570 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
1da177e4 | 1571 | |
05acb863 | 1572 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1573 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 1574 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1575 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 1576 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1577 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 1578 | |
e9edcee0 | 1579 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
05acb863 | 1580 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
1da177e4 | 1581 | |
1da177e4 LT |
1582 | { } |
1583 | }; | |
1584 | ||
e9edcee0 TI |
1585 | /* |
1586 | * Z71V pin configuration: | |
1587 | * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?) | |
1588 | */ | |
1589 | static struct hda_verb alc880_pin_z71v_init_verbs[] = { | |
05acb863 | 1590 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1591 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 1592 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
e9edcee0 | 1593 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
dfc0ff62 | 1594 | |
16ded525 | 1595 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1596 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
16ded525 | 1597 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1598 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
16ded525 TI |
1599 | |
1600 | { } | |
1601 | }; | |
1602 | ||
e9edcee0 TI |
1603 | /* |
1604 | * 6-stack pin configuration: | |
9c7f852e TI |
1605 | * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, |
1606 | * f-mic = 0x19, line = 0x1a, HP = 0x1b | |
e9edcee0 TI |
1607 | */ |
1608 | static struct hda_verb alc880_pin_6stack_init_verbs[] = { | |
1609 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
1610 | ||
16ded525 | 1611 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1612 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1613 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1614 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1615 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1616 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1617 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
1618 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1619 | ||
16ded525 | 1620 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1621 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 1622 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1623 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 1624 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 | 1625 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 1626 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
e9edcee0 | 1627 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 TI |
1628 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1629 | ||
e9edcee0 TI |
1630 | { } |
1631 | }; | |
1632 | ||
ccc656ce KY |
1633 | /* |
1634 | * Uniwill pin configuration: | |
1635 | * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19, | |
1636 | * line = 0x1a | |
1637 | */ | |
1638 | static struct hda_verb alc880_uniwill_init_verbs[] = { | |
1639 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
1640 | ||
1641 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1642 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1643 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1644 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1645 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1646 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1647 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1648 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1649 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1650 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1651 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1652 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1653 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1654 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1655 | ||
1656 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1657 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1658 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1659 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1660 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1661 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1662 | /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */ | |
1663 | /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */ | |
1664 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1665 | ||
1666 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
1667 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
1668 | ||
1669 | { } | |
1670 | }; | |
1671 | ||
1672 | /* | |
1673 | * Uniwill P53 | |
1674 | * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19, | |
1675 | */ | |
1676 | static struct hda_verb alc880_uniwill_p53_init_verbs[] = { | |
1677 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
1678 | ||
1679 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1680 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1681 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1682 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1683 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1684 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1685 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1686 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1687 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1688 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1689 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
1690 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
1691 | ||
1692 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1693 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1694 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1695 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1696 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1697 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1698 | ||
1699 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
1700 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT}, | |
1701 | ||
1702 | { } | |
1703 | }; | |
1704 | ||
2cf9f0fc TD |
1705 | static struct hda_verb alc880_beep_init_verbs[] = { |
1706 | { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) }, | |
1707 | { } | |
1708 | }; | |
1709 | ||
ccc656ce | 1710 | /* toggle speaker-output according to the hp-jack state */ |
458a4fab | 1711 | static void alc880_uniwill_hp_automute(struct hda_codec *codec) |
ccc656ce KY |
1712 | { |
1713 | unsigned int present; | |
f12ab1e0 | 1714 | unsigned char bits; |
ccc656ce KY |
1715 | |
1716 | present = snd_hda_codec_read(codec, 0x14, 0, | |
1717 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
1718 | bits = present ? HDA_AMP_MUTE : 0; |
1719 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
1720 | HDA_AMP_MUTE, bits); | |
1721 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
1722 | HDA_AMP_MUTE, bits); | |
458a4fab TI |
1723 | } |
1724 | ||
1725 | /* auto-toggle front mic */ | |
1726 | static void alc880_uniwill_mic_automute(struct hda_codec *codec) | |
1727 | { | |
1728 | unsigned int present; | |
1729 | unsigned char bits; | |
ccc656ce KY |
1730 | |
1731 | present = snd_hda_codec_read(codec, 0x18, 0, | |
1732 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
1733 | bits = present ? HDA_AMP_MUTE : 0; |
1734 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); | |
458a4fab TI |
1735 | } |
1736 | ||
1737 | static void alc880_uniwill_automute(struct hda_codec *codec) | |
1738 | { | |
1739 | alc880_uniwill_hp_automute(codec); | |
1740 | alc880_uniwill_mic_automute(codec); | |
ccc656ce KY |
1741 | } |
1742 | ||
1743 | static void alc880_uniwill_unsol_event(struct hda_codec *codec, | |
1744 | unsigned int res) | |
1745 | { | |
1746 | /* Looks like the unsol event is incompatible with the standard | |
1747 | * definition. 4bit tag is placed at 28 bit! | |
1748 | */ | |
458a4fab TI |
1749 | switch (res >> 28) { |
1750 | case ALC880_HP_EVENT: | |
1751 | alc880_uniwill_hp_automute(codec); | |
1752 | break; | |
1753 | case ALC880_MIC_EVENT: | |
1754 | alc880_uniwill_mic_automute(codec); | |
1755 | break; | |
1756 | } | |
ccc656ce KY |
1757 | } |
1758 | ||
1759 | static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec) | |
1760 | { | |
1761 | unsigned int present; | |
f12ab1e0 | 1762 | unsigned char bits; |
ccc656ce KY |
1763 | |
1764 | present = snd_hda_codec_read(codec, 0x14, 0, | |
1765 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
1766 | bits = present ? HDA_AMP_MUTE : 0; |
1767 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits); | |
ccc656ce KY |
1768 | } |
1769 | ||
1770 | static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) | |
1771 | { | |
1772 | unsigned int present; | |
1773 | ||
1774 | present = snd_hda_codec_read(codec, 0x21, 0, | |
47fd830a TI |
1775 | AC_VERB_GET_VOLUME_KNOB_CONTROL, 0); |
1776 | present &= HDA_AMP_VOLMASK; | |
1777 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, | |
1778 | HDA_AMP_VOLMASK, present); | |
1779 | snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0, | |
1780 | HDA_AMP_VOLMASK, present); | |
ccc656ce | 1781 | } |
47fd830a | 1782 | |
ccc656ce KY |
1783 | static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec, |
1784 | unsigned int res) | |
1785 | { | |
1786 | /* Looks like the unsol event is incompatible with the standard | |
1787 | * definition. 4bit tag is placed at 28 bit! | |
1788 | */ | |
1789 | if ((res >> 28) == ALC880_HP_EVENT) | |
1790 | alc880_uniwill_p53_hp_automute(codec); | |
f12ab1e0 | 1791 | if ((res >> 28) == ALC880_DCVOL_EVENT) |
ccc656ce KY |
1792 | alc880_uniwill_p53_dcvol_automute(codec); |
1793 | } | |
1794 | ||
e9edcee0 TI |
1795 | /* FIXME! */ |
1796 | /* | |
1797 | * F1734 pin configuration: | |
1798 | * HP = 0x14, speaker-out = 0x15, mic = 0x18 | |
1799 | */ | |
1800 | static struct hda_verb alc880_pin_f1734_init_verbs[] = { | |
16ded525 TI |
1801 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, |
1802 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1803 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
1804 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1805 | ||
e9edcee0 | 1806 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
16ded525 | 1807 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
e9edcee0 | 1808 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
16ded525 | 1809 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1810 | |
e9edcee0 TI |
1811 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1812 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
16ded525 | 1813 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1814 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 1815 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1816 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1817 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1818 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1819 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
dfc0ff62 TI |
1820 | |
1821 | { } | |
1822 | }; | |
1823 | ||
e9edcee0 TI |
1824 | /* FIXME! */ |
1825 | /* | |
1826 | * ASUS pin configuration: | |
1827 | * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a | |
1828 | */ | |
1829 | static struct hda_verb alc880_pin_asus_init_verbs[] = { | |
16ded525 TI |
1830 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, |
1831 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1832 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
1833 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1834 | ||
1835 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
e9edcee0 | 1836 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1837 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1838 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1839 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1840 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1841 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
1842 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1843 | ||
1844 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1845 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1846 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1847 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1848 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1849 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
16ded525 | 1850 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1851 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 TI |
1852 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1853 | ||
e9edcee0 TI |
1854 | { } |
1855 | }; | |
16ded525 | 1856 | |
e9edcee0 | 1857 | /* Enable GPIO mask and set output */ |
bc9f98a9 KY |
1858 | #define alc880_gpio1_init_verbs alc_gpio1_init_verbs |
1859 | #define alc880_gpio2_init_verbs alc_gpio2_init_verbs | |
df694daa KY |
1860 | |
1861 | /* Clevo m520g init */ | |
1862 | static struct hda_verb alc880_pin_clevo_init_verbs[] = { | |
1863 | /* headphone output */ | |
1864 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
1865 | /* line-out */ | |
1866 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1867 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1868 | /* Line-in */ | |
1869 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1870 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1871 | /* CD */ | |
1872 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1873 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1874 | /* Mic1 (rear panel) */ | |
1875 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1876 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1877 | /* Mic2 (front panel) */ | |
1878 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1879 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1880 | /* headphone */ | |
1881 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1882 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1883 | /* change to EAPD mode */ | |
1884 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
1885 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, | |
1886 | ||
1887 | { } | |
16ded525 TI |
1888 | }; |
1889 | ||
df694daa | 1890 | static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = { |
4b146cb0 TI |
1891 | /* change to EAPD mode */ |
1892 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
1893 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, | |
1894 | ||
df694daa KY |
1895 | /* Headphone output */ |
1896 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1897 | /* Front output*/ | |
1898 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1899 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1900 | ||
1901 | /* Line In pin widget for input */ | |
1902 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1903 | /* CD pin widget for input */ | |
1904 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1905 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
1906 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1907 | ||
1908 | /* change to EAPD mode */ | |
1909 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
1910 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
1911 | ||
1912 | { } | |
1913 | }; | |
16ded525 | 1914 | |
e9edcee0 | 1915 | /* |
ae6b813a TI |
1916 | * LG m1 express dual |
1917 | * | |
1918 | * Pin assignment: | |
1919 | * Rear Line-In/Out (blue): 0x14 | |
1920 | * Build-in Mic-In: 0x15 | |
1921 | * Speaker-out: 0x17 | |
1922 | * HP-Out (green): 0x1b | |
1923 | * Mic-In/Out (red): 0x19 | |
1924 | * SPDIF-Out: 0x1e | |
1925 | */ | |
1926 | ||
1927 | /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */ | |
1928 | static hda_nid_t alc880_lg_dac_nids[3] = { | |
1929 | 0x05, 0x02, 0x03 | |
1930 | }; | |
1931 | ||
1932 | /* seems analog CD is not working */ | |
1933 | static struct hda_input_mux alc880_lg_capture_source = { | |
1934 | .num_items = 3, | |
1935 | .items = { | |
1936 | { "Mic", 0x1 }, | |
1937 | { "Line", 0x5 }, | |
1938 | { "Internal Mic", 0x6 }, | |
1939 | }, | |
1940 | }; | |
1941 | ||
1942 | /* 2,4,6 channel modes */ | |
1943 | static struct hda_verb alc880_lg_ch2_init[] = { | |
1944 | /* set line-in and mic-in to input */ | |
1945 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
1946 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
1947 | { } | |
1948 | }; | |
1949 | ||
1950 | static struct hda_verb alc880_lg_ch4_init[] = { | |
1951 | /* set line-in to out and mic-in to input */ | |
1952 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
1953 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
1954 | { } | |
1955 | }; | |
1956 | ||
1957 | static struct hda_verb alc880_lg_ch6_init[] = { | |
1958 | /* set line-in and mic-in to output */ | |
1959 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
1960 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
1961 | { } | |
1962 | }; | |
1963 | ||
1964 | static struct hda_channel_mode alc880_lg_ch_modes[3] = { | |
1965 | { 2, alc880_lg_ch2_init }, | |
1966 | { 4, alc880_lg_ch4_init }, | |
1967 | { 6, alc880_lg_ch6_init }, | |
1968 | }; | |
1969 | ||
1970 | static struct snd_kcontrol_new alc880_lg_mixer[] = { | |
1971 | /* FIXME: it's not really "master" but front channels */ | |
1972 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
1973 | HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT), | |
1974 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1975 | HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT), | |
1976 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), | |
1977 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT), | |
1978 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT), | |
1979 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), | |
1980 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1981 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1982 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT), | |
1983 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT), | |
1984 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT), | |
1985 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT), | |
1986 | { | |
1987 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1988 | .name = "Channel Mode", | |
1989 | .info = alc_ch_mode_info, | |
1990 | .get = alc_ch_mode_get, | |
1991 | .put = alc_ch_mode_put, | |
1992 | }, | |
1993 | { } /* end */ | |
1994 | }; | |
1995 | ||
1996 | static struct hda_verb alc880_lg_init_verbs[] = { | |
1997 | /* set capture source to mic-in */ | |
1998 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
1999 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2000 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2001 | /* mute all amp mixer inputs */ | |
2002 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)}, | |
cb53c626 TI |
2003 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, |
2004 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
ae6b813a TI |
2005 | /* line-in to input */ |
2006 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2007 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2008 | /* built-in mic */ | |
2009 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2010 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2011 | /* speaker-out */ | |
2012 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2013 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2014 | /* mic-in to input */ | |
2015 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
2016 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2017 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2018 | /* HP-out */ | |
2019 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
2020 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2021 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2022 | /* jack sense */ | |
2023 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, | |
2024 | { } | |
2025 | }; | |
2026 | ||
2027 | /* toggle speaker-output according to the hp-jack state */ | |
2028 | static void alc880_lg_automute(struct hda_codec *codec) | |
2029 | { | |
2030 | unsigned int present; | |
f12ab1e0 | 2031 | unsigned char bits; |
ae6b813a TI |
2032 | |
2033 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
2034 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
2035 | bits = present ? HDA_AMP_MUTE : 0; |
2036 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
2037 | HDA_AMP_MUTE, bits); | |
ae6b813a TI |
2038 | } |
2039 | ||
2040 | static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res) | |
2041 | { | |
2042 | /* Looks like the unsol event is incompatible with the standard | |
2043 | * definition. 4bit tag is placed at 28 bit! | |
2044 | */ | |
2045 | if ((res >> 28) == 0x01) | |
2046 | alc880_lg_automute(codec); | |
2047 | } | |
2048 | ||
d681518a TI |
2049 | /* |
2050 | * LG LW20 | |
2051 | * | |
2052 | * Pin assignment: | |
2053 | * Speaker-out: 0x14 | |
2054 | * Mic-In: 0x18 | |
e4f41da9 CM |
2055 | * Built-in Mic-In: 0x19 |
2056 | * Line-In: 0x1b | |
2057 | * HP-Out: 0x1a | |
d681518a TI |
2058 | * SPDIF-Out: 0x1e |
2059 | */ | |
2060 | ||
d681518a | 2061 | static struct hda_input_mux alc880_lg_lw_capture_source = { |
e4f41da9 | 2062 | .num_items = 3, |
d681518a TI |
2063 | .items = { |
2064 | { "Mic", 0x0 }, | |
2065 | { "Internal Mic", 0x1 }, | |
e4f41da9 | 2066 | { "Line In", 0x2 }, |
d681518a TI |
2067 | }, |
2068 | }; | |
2069 | ||
0a8c5da3 CM |
2070 | #define alc880_lg_lw_modes alc880_threestack_modes |
2071 | ||
d681518a | 2072 | static struct snd_kcontrol_new alc880_lg_lw_mixer[] = { |
0a8c5da3 CM |
2073 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
2074 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
2075 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
2076 | HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT), | |
2077 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
2078 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
2079 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
2080 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
2081 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
2082 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
d681518a TI |
2083 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
2084 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2085 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
2086 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
0a8c5da3 CM |
2087 | { |
2088 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2089 | .name = "Channel Mode", | |
2090 | .info = alc_ch_mode_info, | |
2091 | .get = alc_ch_mode_get, | |
2092 | .put = alc_ch_mode_put, | |
2093 | }, | |
d681518a TI |
2094 | { } /* end */ |
2095 | }; | |
2096 | ||
2097 | static struct hda_verb alc880_lg_lw_init_verbs[] = { | |
0a8c5da3 CM |
2098 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
2099 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
2100 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */ | |
2101 | ||
d681518a TI |
2102 | /* set capture source to mic-in */ |
2103 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2104 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2105 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
cb53c626 | 2106 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, |
d681518a TI |
2107 | /* speaker-out */ |
2108 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2109 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2110 | /* HP-out */ | |
d681518a TI |
2111 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
2112 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2113 | /* mic-in to input */ | |
2114 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2115 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2116 | /* built-in mic */ | |
2117 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2118 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2119 | /* jack sense */ | |
2120 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, | |
2121 | { } | |
2122 | }; | |
2123 | ||
2124 | /* toggle speaker-output according to the hp-jack state */ | |
2125 | static void alc880_lg_lw_automute(struct hda_codec *codec) | |
2126 | { | |
2127 | unsigned int present; | |
f12ab1e0 | 2128 | unsigned char bits; |
d681518a TI |
2129 | |
2130 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
2131 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
2132 | bits = present ? HDA_AMP_MUTE : 0; |
2133 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
2134 | HDA_AMP_MUTE, bits); | |
d681518a TI |
2135 | } |
2136 | ||
2137 | static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res) | |
2138 | { | |
2139 | /* Looks like the unsol event is incompatible with the standard | |
2140 | * definition. 4bit tag is placed at 28 bit! | |
2141 | */ | |
2142 | if ((res >> 28) == 0x01) | |
2143 | alc880_lg_lw_automute(codec); | |
2144 | } | |
2145 | ||
cb53c626 TI |
2146 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
2147 | static struct hda_amp_list alc880_loopbacks[] = { | |
2148 | { 0x0b, HDA_INPUT, 0 }, | |
2149 | { 0x0b, HDA_INPUT, 1 }, | |
2150 | { 0x0b, HDA_INPUT, 2 }, | |
2151 | { 0x0b, HDA_INPUT, 3 }, | |
2152 | { 0x0b, HDA_INPUT, 4 }, | |
2153 | { } /* end */ | |
2154 | }; | |
2155 | ||
2156 | static struct hda_amp_list alc880_lg_loopbacks[] = { | |
2157 | { 0x0b, HDA_INPUT, 1 }, | |
2158 | { 0x0b, HDA_INPUT, 6 }, | |
2159 | { 0x0b, HDA_INPUT, 7 }, | |
2160 | { } /* end */ | |
2161 | }; | |
2162 | #endif | |
2163 | ||
ae6b813a TI |
2164 | /* |
2165 | * Common callbacks | |
e9edcee0 TI |
2166 | */ |
2167 | ||
1da177e4 LT |
2168 | static int alc_init(struct hda_codec *codec) |
2169 | { | |
2170 | struct alc_spec *spec = codec->spec; | |
e9edcee0 TI |
2171 | unsigned int i; |
2172 | ||
2173 | for (i = 0; i < spec->num_init_verbs; i++) | |
2174 | snd_hda_sequence_write(codec, spec->init_verbs[i]); | |
ae6b813a TI |
2175 | |
2176 | if (spec->init_hook) | |
2177 | spec->init_hook(codec); | |
2178 | ||
1da177e4 LT |
2179 | return 0; |
2180 | } | |
2181 | ||
ae6b813a TI |
2182 | static void alc_unsol_event(struct hda_codec *codec, unsigned int res) |
2183 | { | |
2184 | struct alc_spec *spec = codec->spec; | |
2185 | ||
2186 | if (spec->unsol_event) | |
2187 | spec->unsol_event(codec, res); | |
2188 | } | |
2189 | ||
cb53c626 TI |
2190 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
2191 | static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid) | |
2192 | { | |
2193 | struct alc_spec *spec = codec->spec; | |
2194 | return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); | |
2195 | } | |
2196 | #endif | |
2197 | ||
1da177e4 LT |
2198 | /* |
2199 | * Analog playback callbacks | |
2200 | */ | |
2201 | static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo, | |
2202 | struct hda_codec *codec, | |
c8b6bf9b | 2203 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2204 | { |
2205 | struct alc_spec *spec = codec->spec; | |
2206 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); | |
2207 | } | |
2208 | ||
2209 | static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | |
2210 | struct hda_codec *codec, | |
2211 | unsigned int stream_tag, | |
2212 | unsigned int format, | |
c8b6bf9b | 2213 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2214 | { |
2215 | struct alc_spec *spec = codec->spec; | |
9c7f852e TI |
2216 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, |
2217 | stream_tag, format, substream); | |
1da177e4 LT |
2218 | } |
2219 | ||
2220 | static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, | |
2221 | struct hda_codec *codec, | |
c8b6bf9b | 2222 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2223 | { |
2224 | struct alc_spec *spec = codec->spec; | |
2225 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); | |
2226 | } | |
2227 | ||
2228 | /* | |
2229 | * Digital out | |
2230 | */ | |
2231 | static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, | |
2232 | struct hda_codec *codec, | |
c8b6bf9b | 2233 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2234 | { |
2235 | struct alc_spec *spec = codec->spec; | |
2236 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); | |
2237 | } | |
2238 | ||
6b97eb45 TI |
2239 | static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
2240 | struct hda_codec *codec, | |
2241 | unsigned int stream_tag, | |
2242 | unsigned int format, | |
2243 | struct snd_pcm_substream *substream) | |
2244 | { | |
2245 | struct alc_spec *spec = codec->spec; | |
2246 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, | |
2247 | stream_tag, format, substream); | |
2248 | } | |
2249 | ||
1da177e4 LT |
2250 | static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
2251 | struct hda_codec *codec, | |
c8b6bf9b | 2252 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2253 | { |
2254 | struct alc_spec *spec = codec->spec; | |
2255 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); | |
2256 | } | |
2257 | ||
2258 | /* | |
2259 | * Analog capture | |
2260 | */ | |
2261 | static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo, | |
2262 | struct hda_codec *codec, | |
2263 | unsigned int stream_tag, | |
2264 | unsigned int format, | |
c8b6bf9b | 2265 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2266 | { |
2267 | struct alc_spec *spec = codec->spec; | |
2268 | ||
2269 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], | |
2270 | stream_tag, 0, format); | |
2271 | return 0; | |
2272 | } | |
2273 | ||
2274 | static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, | |
2275 | struct hda_codec *codec, | |
c8b6bf9b | 2276 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2277 | { |
2278 | struct alc_spec *spec = codec->spec; | |
2279 | ||
9c7f852e TI |
2280 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], |
2281 | 0, 0, 0); | |
1da177e4 LT |
2282 | return 0; |
2283 | } | |
2284 | ||
2285 | ||
2286 | /* | |
2287 | */ | |
2288 | static struct hda_pcm_stream alc880_pcm_analog_playback = { | |
2289 | .substreams = 1, | |
2290 | .channels_min = 2, | |
2291 | .channels_max = 8, | |
e9edcee0 | 2292 | /* NID is set in alc_build_pcms */ |
1da177e4 LT |
2293 | .ops = { |
2294 | .open = alc880_playback_pcm_open, | |
2295 | .prepare = alc880_playback_pcm_prepare, | |
2296 | .cleanup = alc880_playback_pcm_cleanup | |
2297 | }, | |
2298 | }; | |
2299 | ||
2300 | static struct hda_pcm_stream alc880_pcm_analog_capture = { | |
2301 | .substreams = 2, | |
2302 | .channels_min = 2, | |
2303 | .channels_max = 2, | |
e9edcee0 | 2304 | /* NID is set in alc_build_pcms */ |
1da177e4 LT |
2305 | .ops = { |
2306 | .prepare = alc880_capture_pcm_prepare, | |
2307 | .cleanup = alc880_capture_pcm_cleanup | |
2308 | }, | |
2309 | }; | |
2310 | ||
2311 | static struct hda_pcm_stream alc880_pcm_digital_playback = { | |
2312 | .substreams = 1, | |
2313 | .channels_min = 2, | |
2314 | .channels_max = 2, | |
2315 | /* NID is set in alc_build_pcms */ | |
2316 | .ops = { | |
2317 | .open = alc880_dig_playback_pcm_open, | |
6b97eb45 TI |
2318 | .close = alc880_dig_playback_pcm_close, |
2319 | .prepare = alc880_dig_playback_pcm_prepare | |
1da177e4 LT |
2320 | }, |
2321 | }; | |
2322 | ||
2323 | static struct hda_pcm_stream alc880_pcm_digital_capture = { | |
2324 | .substreams = 1, | |
2325 | .channels_min = 2, | |
2326 | .channels_max = 2, | |
2327 | /* NID is set in alc_build_pcms */ | |
2328 | }; | |
2329 | ||
4c5186ed JW |
2330 | /* Used by alc_build_pcms to flag that a PCM has no playback stream */ |
2331 | static struct hda_pcm_stream alc_pcm_null_playback = { | |
2332 | .substreams = 0, | |
2333 | .channels_min = 0, | |
2334 | .channels_max = 0, | |
2335 | }; | |
2336 | ||
1da177e4 LT |
2337 | static int alc_build_pcms(struct hda_codec *codec) |
2338 | { | |
2339 | struct alc_spec *spec = codec->spec; | |
2340 | struct hda_pcm *info = spec->pcm_rec; | |
2341 | int i; | |
2342 | ||
2343 | codec->num_pcms = 1; | |
2344 | codec->pcm_info = info; | |
2345 | ||
2346 | info->name = spec->stream_name_analog; | |
4a471b7d TI |
2347 | if (spec->stream_analog_playback) { |
2348 | snd_assert(spec->multiout.dac_nids, return -EINVAL); | |
2349 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback); | |
2350 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; | |
2351 | } | |
2352 | if (spec->stream_analog_capture) { | |
2353 | snd_assert(spec->adc_nids, return -EINVAL); | |
2354 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); | |
2355 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; | |
2356 | } | |
2357 | ||
2358 | if (spec->channel_mode) { | |
2359 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; | |
2360 | for (i = 0; i < spec->num_channel_mode; i++) { | |
2361 | if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { | |
2362 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; | |
2363 | } | |
1da177e4 LT |
2364 | } |
2365 | } | |
2366 | ||
e08a007d | 2367 | /* SPDIF for stream index #1 */ |
1da177e4 | 2368 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
e08a007d | 2369 | codec->num_pcms = 2; |
c06134d7 | 2370 | info = spec->pcm_rec + 1; |
1da177e4 | 2371 | info->name = spec->stream_name_digital; |
4a471b7d TI |
2372 | if (spec->multiout.dig_out_nid && |
2373 | spec->stream_digital_playback) { | |
1da177e4 LT |
2374 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback); |
2375 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; | |
2376 | } | |
4a471b7d TI |
2377 | if (spec->dig_in_nid && |
2378 | spec->stream_digital_capture) { | |
1da177e4 LT |
2379 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture); |
2380 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; | |
2381 | } | |
2382 | } | |
2383 | ||
e08a007d TI |
2384 | /* If the use of more than one ADC is requested for the current |
2385 | * model, configure a second analog capture-only PCM. | |
2386 | */ | |
2387 | /* Additional Analaog capture for index #2 */ | |
2388 | if (spec->num_adc_nids > 1 && spec->stream_analog_capture && | |
2389 | spec->adc_nids) { | |
2390 | codec->num_pcms = 3; | |
c06134d7 | 2391 | info = spec->pcm_rec + 2; |
e08a007d TI |
2392 | info->name = spec->stream_name_analog; |
2393 | /* No playback stream for second PCM */ | |
2394 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback; | |
2395 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; | |
2396 | if (spec->stream_analog_capture) { | |
2397 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); | |
2398 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1]; | |
2399 | } | |
2400 | } | |
2401 | ||
1da177e4 LT |
2402 | return 0; |
2403 | } | |
2404 | ||
2405 | static void alc_free(struct hda_codec *codec) | |
2406 | { | |
e9edcee0 TI |
2407 | struct alc_spec *spec = codec->spec; |
2408 | unsigned int i; | |
2409 | ||
f12ab1e0 | 2410 | if (!spec) |
e9edcee0 TI |
2411 | return; |
2412 | ||
2413 | if (spec->kctl_alloc) { | |
2414 | for (i = 0; i < spec->num_kctl_used; i++) | |
2415 | kfree(spec->kctl_alloc[i].name); | |
2416 | kfree(spec->kctl_alloc); | |
2417 | } | |
2418 | kfree(spec); | |
1da177e4 LT |
2419 | } |
2420 | ||
2421 | /* | |
2422 | */ | |
2423 | static struct hda_codec_ops alc_patch_ops = { | |
2424 | .build_controls = alc_build_controls, | |
2425 | .build_pcms = alc_build_pcms, | |
2426 | .init = alc_init, | |
2427 | .free = alc_free, | |
ae6b813a | 2428 | .unsol_event = alc_unsol_event, |
cb53c626 TI |
2429 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
2430 | .check_power_status = alc_check_power_status, | |
2431 | #endif | |
1da177e4 LT |
2432 | }; |
2433 | ||
2fa522be TI |
2434 | |
2435 | /* | |
2436 | * Test configuration for debugging | |
2437 | * | |
2438 | * Almost all inputs/outputs are enabled. I/O pins can be configured via | |
2439 | * enum controls. | |
2440 | */ | |
2441 | #ifdef CONFIG_SND_DEBUG | |
2442 | static hda_nid_t alc880_test_dac_nids[4] = { | |
2443 | 0x02, 0x03, 0x04, 0x05 | |
2444 | }; | |
2445 | ||
2446 | static struct hda_input_mux alc880_test_capture_source = { | |
ae6b813a | 2447 | .num_items = 7, |
2fa522be TI |
2448 | .items = { |
2449 | { "In-1", 0x0 }, | |
2450 | { "In-2", 0x1 }, | |
2451 | { "In-3", 0x2 }, | |
2452 | { "In-4", 0x3 }, | |
2453 | { "CD", 0x4 }, | |
ae6b813a TI |
2454 | { "Front", 0x5 }, |
2455 | { "Surround", 0x6 }, | |
2fa522be TI |
2456 | }, |
2457 | }; | |
2458 | ||
d2a6d7dc | 2459 | static struct hda_channel_mode alc880_test_modes[4] = { |
2fa522be | 2460 | { 2, NULL }, |
fd2c326d | 2461 | { 4, NULL }, |
2fa522be | 2462 | { 6, NULL }, |
fd2c326d | 2463 | { 8, NULL }, |
2fa522be TI |
2464 | }; |
2465 | ||
9c7f852e TI |
2466 | static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, |
2467 | struct snd_ctl_elem_info *uinfo) | |
2fa522be TI |
2468 | { |
2469 | static char *texts[] = { | |
2470 | "N/A", "Line Out", "HP Out", | |
2471 | "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%" | |
2472 | }; | |
2473 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
2474 | uinfo->count = 1; | |
2475 | uinfo->value.enumerated.items = 8; | |
2476 | if (uinfo->value.enumerated.item >= 8) | |
2477 | uinfo->value.enumerated.item = 7; | |
2478 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | |
2479 | return 0; | |
2480 | } | |
2481 | ||
9c7f852e TI |
2482 | static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, |
2483 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
2484 | { |
2485 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2486 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
2487 | unsigned int pin_ctl, item = 0; | |
2488 | ||
2489 | pin_ctl = snd_hda_codec_read(codec, nid, 0, | |
2490 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | |
2491 | if (pin_ctl & AC_PINCTL_OUT_EN) { | |
2492 | if (pin_ctl & AC_PINCTL_HP_EN) | |
2493 | item = 2; | |
2494 | else | |
2495 | item = 1; | |
2496 | } else if (pin_ctl & AC_PINCTL_IN_EN) { | |
2497 | switch (pin_ctl & AC_PINCTL_VREFEN) { | |
2498 | case AC_PINCTL_VREF_HIZ: item = 3; break; | |
2499 | case AC_PINCTL_VREF_50: item = 4; break; | |
2500 | case AC_PINCTL_VREF_GRD: item = 5; break; | |
2501 | case AC_PINCTL_VREF_80: item = 6; break; | |
2502 | case AC_PINCTL_VREF_100: item = 7; break; | |
2503 | } | |
2504 | } | |
2505 | ucontrol->value.enumerated.item[0] = item; | |
2506 | return 0; | |
2507 | } | |
2508 | ||
9c7f852e TI |
2509 | static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, |
2510 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
2511 | { |
2512 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2513 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
2514 | static unsigned int ctls[] = { | |
2515 | 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN, | |
2516 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ, | |
2517 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_50, | |
2518 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD, | |
2519 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_80, | |
2520 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_100, | |
2521 | }; | |
2522 | unsigned int old_ctl, new_ctl; | |
2523 | ||
2524 | old_ctl = snd_hda_codec_read(codec, nid, 0, | |
2525 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | |
2526 | new_ctl = ctls[ucontrol->value.enumerated.item[0]]; | |
2527 | if (old_ctl != new_ctl) { | |
82beb8fd TI |
2528 | int val; |
2529 | snd_hda_codec_write_cache(codec, nid, 0, | |
2530 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
2531 | new_ctl); | |
47fd830a TI |
2532 | val = ucontrol->value.enumerated.item[0] >= 3 ? |
2533 | HDA_AMP_MUTE : 0; | |
2534 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, | |
2535 | HDA_AMP_MUTE, val); | |
2fa522be TI |
2536 | return 1; |
2537 | } | |
2538 | return 0; | |
2539 | } | |
2540 | ||
9c7f852e TI |
2541 | static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, |
2542 | struct snd_ctl_elem_info *uinfo) | |
2fa522be TI |
2543 | { |
2544 | static char *texts[] = { | |
2545 | "Front", "Surround", "CLFE", "Side" | |
2546 | }; | |
2547 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
2548 | uinfo->count = 1; | |
2549 | uinfo->value.enumerated.items = 4; | |
2550 | if (uinfo->value.enumerated.item >= 4) | |
2551 | uinfo->value.enumerated.item = 3; | |
2552 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | |
2553 | return 0; | |
2554 | } | |
2555 | ||
9c7f852e TI |
2556 | static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, |
2557 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
2558 | { |
2559 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2560 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
2561 | unsigned int sel; | |
2562 | ||
2563 | sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0); | |
2564 | ucontrol->value.enumerated.item[0] = sel & 3; | |
2565 | return 0; | |
2566 | } | |
2567 | ||
9c7f852e TI |
2568 | static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, |
2569 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
2570 | { |
2571 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2572 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
2573 | unsigned int sel; | |
2574 | ||
2575 | sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3; | |
2576 | if (ucontrol->value.enumerated.item[0] != sel) { | |
2577 | sel = ucontrol->value.enumerated.item[0] & 3; | |
82beb8fd TI |
2578 | snd_hda_codec_write_cache(codec, nid, 0, |
2579 | AC_VERB_SET_CONNECT_SEL, sel); | |
2fa522be TI |
2580 | return 1; |
2581 | } | |
2582 | return 0; | |
2583 | } | |
2584 | ||
2585 | #define PIN_CTL_TEST(xname,nid) { \ | |
2586 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
2587 | .name = xname, \ | |
2588 | .info = alc_test_pin_ctl_info, \ | |
2589 | .get = alc_test_pin_ctl_get, \ | |
2590 | .put = alc_test_pin_ctl_put, \ | |
2591 | .private_value = nid \ | |
2592 | } | |
2593 | ||
2594 | #define PIN_SRC_TEST(xname,nid) { \ | |
2595 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
2596 | .name = xname, \ | |
2597 | .info = alc_test_pin_src_info, \ | |
2598 | .get = alc_test_pin_src_get, \ | |
2599 | .put = alc_test_pin_src_put, \ | |
2600 | .private_value = nid \ | |
2601 | } | |
2602 | ||
c8b6bf9b | 2603 | static struct snd_kcontrol_new alc880_test_mixer[] = { |
05acb863 TI |
2604 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
2605 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
2606 | HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT), | |
2607 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
985be54b TI |
2608 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
2609 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
2610 | HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT), | |
2611 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
2fa522be TI |
2612 | PIN_CTL_TEST("Front Pin Mode", 0x14), |
2613 | PIN_CTL_TEST("Surround Pin Mode", 0x15), | |
2614 | PIN_CTL_TEST("CLFE Pin Mode", 0x16), | |
2615 | PIN_CTL_TEST("Side Pin Mode", 0x17), | |
2616 | PIN_CTL_TEST("In-1 Pin Mode", 0x18), | |
2617 | PIN_CTL_TEST("In-2 Pin Mode", 0x19), | |
2618 | PIN_CTL_TEST("In-3 Pin Mode", 0x1a), | |
2619 | PIN_CTL_TEST("In-4 Pin Mode", 0x1b), | |
2620 | PIN_SRC_TEST("In-1 Pin Source", 0x18), | |
2621 | PIN_SRC_TEST("In-2 Pin Source", 0x19), | |
2622 | PIN_SRC_TEST("In-3 Pin Source", 0x1a), | |
2623 | PIN_SRC_TEST("In-4 Pin Source", 0x1b), | |
2624 | HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
2625 | HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2626 | HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
2627 | HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
2628 | HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT), | |
2629 | HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT), | |
2630 | HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT), | |
2631 | HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT), | |
2632 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT), | |
2633 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT), | |
2fa522be TI |
2634 | { |
2635 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2636 | .name = "Channel Mode", | |
df694daa KY |
2637 | .info = alc_ch_mode_info, |
2638 | .get = alc_ch_mode_get, | |
2639 | .put = alc_ch_mode_put, | |
2fa522be TI |
2640 | }, |
2641 | { } /* end */ | |
2642 | }; | |
2643 | ||
2644 | static struct hda_verb alc880_test_init_verbs[] = { | |
2645 | /* Unmute inputs of 0x0c - 0x0f */ | |
05acb863 TI |
2646 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
2647 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2648 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2649 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2650 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2651 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2652 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2653 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2fa522be | 2654 | /* Vol output for 0x0c-0x0f */ |
05acb863 TI |
2655 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
2656 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2657 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2658 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2fa522be | 2659 | /* Set output pins 0x14-0x17 */ |
05acb863 TI |
2660 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
2661 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2662 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2663 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2fa522be | 2664 | /* Unmute output pins 0x14-0x17 */ |
05acb863 TI |
2665 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
2666 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2667 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2668 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2fa522be | 2669 | /* Set input pins 0x18-0x1c */ |
16ded525 TI |
2670 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
2671 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
05acb863 TI |
2672 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
2673 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2674 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2fa522be | 2675 | /* Mute input pins 0x18-0x1b */ |
05acb863 TI |
2676 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
2677 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2678 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2679 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
71fe7b82 | 2680 | /* ADC set up */ |
05acb863 | 2681 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 2682 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 | 2683 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 2684 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 | 2685 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 2686 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
2687 | /* Analog input/passthru */ |
2688 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
2689 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2690 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
2691 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
2692 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
2fa522be TI |
2693 | { } |
2694 | }; | |
2695 | #endif | |
2696 | ||
1da177e4 LT |
2697 | /* |
2698 | */ | |
2699 | ||
f5fcc13c TI |
2700 | static const char *alc880_models[ALC880_MODEL_LAST] = { |
2701 | [ALC880_3ST] = "3stack", | |
2702 | [ALC880_TCL_S700] = "tcl", | |
2703 | [ALC880_3ST_DIG] = "3stack-digout", | |
2704 | [ALC880_CLEVO] = "clevo", | |
2705 | [ALC880_5ST] = "5stack", | |
2706 | [ALC880_5ST_DIG] = "5stack-digout", | |
2707 | [ALC880_W810] = "w810", | |
2708 | [ALC880_Z71V] = "z71v", | |
2709 | [ALC880_6ST] = "6stack", | |
2710 | [ALC880_6ST_DIG] = "6stack-digout", | |
2711 | [ALC880_ASUS] = "asus", | |
2712 | [ALC880_ASUS_W1V] = "asus-w1v", | |
2713 | [ALC880_ASUS_DIG] = "asus-dig", | |
2714 | [ALC880_ASUS_DIG2] = "asus-dig2", | |
2715 | [ALC880_UNIWILL_DIG] = "uniwill", | |
2cf9f0fc TD |
2716 | [ALC880_UNIWILL_P53] = "uniwill-p53", |
2717 | [ALC880_FUJITSU] = "fujitsu", | |
f5fcc13c TI |
2718 | [ALC880_F1734] = "F1734", |
2719 | [ALC880_LG] = "lg", | |
2720 | [ALC880_LG_LW] = "lg-lw", | |
2fa522be | 2721 | #ifdef CONFIG_SND_DEBUG |
f5fcc13c | 2722 | [ALC880_TEST] = "test", |
2fa522be | 2723 | #endif |
f5fcc13c TI |
2724 | [ALC880_AUTO] = "auto", |
2725 | }; | |
2726 | ||
2727 | static struct snd_pci_quirk alc880_cfg_tbl[] = { | |
2728 | /* Broken BIOS configuration */ | |
2729 | SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), | |
2730 | SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG), | |
2731 | ||
2732 | SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG), | |
2733 | SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST), | |
4dc53e28 | 2734 | SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810), |
f5fcc13c TI |
2735 | SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG), |
2736 | SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG), | |
2737 | SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG), | |
2738 | SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG), | |
2739 | SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG), | |
2740 | SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST), | |
2741 | ||
2742 | SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG), | |
2743 | SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST), | |
2744 | ||
2745 | SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V), | |
2746 | SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG), | |
2747 | SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG), | |
2748 | SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG), | |
2749 | SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG), | |
2750 | SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG), | |
2751 | SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V), | |
2752 | /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */ | |
2753 | SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG), | |
2754 | SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG), | |
0e4ceb75 | 2755 | SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS), |
f5fcc13c TI |
2756 | SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG), |
2757 | SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST), | |
2758 | SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST), | |
2759 | SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), | |
2760 | ||
2761 | SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST), | |
2762 | SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST), | |
2763 | SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST), | |
2764 | SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST), | |
2765 | SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST), | |
2766 | SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO), | |
2767 | SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO), | |
2768 | SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG), | |
2769 | SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810), | |
2770 | SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG), | |
2771 | SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700), | |
2772 | SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG), | |
2773 | SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG), | |
2774 | SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG), | |
2775 | SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG), | |
2776 | SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG), | |
2777 | SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG), | |
2778 | SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2), | |
2779 | ||
2780 | SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG), | |
2781 | SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL), | |
2782 | SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53), | |
2783 | SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734), | |
2784 | ||
2785 | SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG), | |
2786 | SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL), | |
2787 | SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734), | |
2cf9f0fc | 2788 | SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU), |
f5fcc13c TI |
2789 | |
2790 | SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG), | |
2791 | SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG), | |
2792 | SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW), | |
2793 | SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW), | |
2794 | ||
2795 | SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG), | |
2796 | SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG), | |
2797 | SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG), | |
2798 | SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG), | |
2799 | SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG), | |
2800 | SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG), | |
2801 | SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG), | |
2802 | SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG), | |
2803 | SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG), | |
2804 | SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG), | |
2805 | SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), | |
2fa522be | 2806 | |
1da177e4 LT |
2807 | {} |
2808 | }; | |
2809 | ||
16ded525 | 2810 | /* |
df694daa | 2811 | * ALC880 codec presets |
16ded525 | 2812 | */ |
16ded525 TI |
2813 | static struct alc_config_preset alc880_presets[] = { |
2814 | [ALC880_3ST] = { | |
e9edcee0 | 2815 | .mixers = { alc880_three_stack_mixer }, |
f12ab1e0 TI |
2816 | .init_verbs = { alc880_volume_init_verbs, |
2817 | alc880_pin_3stack_init_verbs }, | |
16ded525 | 2818 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
16ded525 | 2819 | .dac_nids = alc880_dac_nids, |
16ded525 TI |
2820 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
2821 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 2822 | .need_dac_fix = 1, |
16ded525 TI |
2823 | .input_mux = &alc880_capture_source, |
2824 | }, | |
2825 | [ALC880_3ST_DIG] = { | |
e9edcee0 | 2826 | .mixers = { alc880_three_stack_mixer }, |
f12ab1e0 TI |
2827 | .init_verbs = { alc880_volume_init_verbs, |
2828 | alc880_pin_3stack_init_verbs }, | |
16ded525 | 2829 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
16ded525 TI |
2830 | .dac_nids = alc880_dac_nids, |
2831 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
2832 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
2833 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 2834 | .need_dac_fix = 1, |
16ded525 TI |
2835 | .input_mux = &alc880_capture_source, |
2836 | }, | |
df694daa KY |
2837 | [ALC880_TCL_S700] = { |
2838 | .mixers = { alc880_tcl_s700_mixer }, | |
2839 | .init_verbs = { alc880_volume_init_verbs, | |
2840 | alc880_pin_tcl_S700_init_verbs, | |
2841 | alc880_gpio2_init_verbs }, | |
2842 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
2843 | .dac_nids = alc880_dac_nids, | |
2844 | .hp_nid = 0x03, | |
2845 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
2846 | .channel_mode = alc880_2_jack_modes, | |
2847 | .input_mux = &alc880_capture_source, | |
2848 | }, | |
16ded525 | 2849 | [ALC880_5ST] = { |
f12ab1e0 TI |
2850 | .mixers = { alc880_three_stack_mixer, |
2851 | alc880_five_stack_mixer}, | |
2852 | .init_verbs = { alc880_volume_init_verbs, | |
2853 | alc880_pin_5stack_init_verbs }, | |
16ded525 TI |
2854 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
2855 | .dac_nids = alc880_dac_nids, | |
16ded525 TI |
2856 | .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), |
2857 | .channel_mode = alc880_fivestack_modes, | |
2858 | .input_mux = &alc880_capture_source, | |
2859 | }, | |
2860 | [ALC880_5ST_DIG] = { | |
f12ab1e0 TI |
2861 | .mixers = { alc880_three_stack_mixer, |
2862 | alc880_five_stack_mixer }, | |
2863 | .init_verbs = { alc880_volume_init_verbs, | |
2864 | alc880_pin_5stack_init_verbs }, | |
16ded525 TI |
2865 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
2866 | .dac_nids = alc880_dac_nids, | |
2867 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
2868 | .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), |
2869 | .channel_mode = alc880_fivestack_modes, | |
2870 | .input_mux = &alc880_capture_source, | |
2871 | }, | |
b6482d48 TI |
2872 | [ALC880_6ST] = { |
2873 | .mixers = { alc880_six_stack_mixer }, | |
f12ab1e0 TI |
2874 | .init_verbs = { alc880_volume_init_verbs, |
2875 | alc880_pin_6stack_init_verbs }, | |
b6482d48 TI |
2876 | .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), |
2877 | .dac_nids = alc880_6st_dac_nids, | |
2878 | .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), | |
2879 | .channel_mode = alc880_sixstack_modes, | |
2880 | .input_mux = &alc880_6stack_capture_source, | |
2881 | }, | |
16ded525 | 2882 | [ALC880_6ST_DIG] = { |
e9edcee0 | 2883 | .mixers = { alc880_six_stack_mixer }, |
f12ab1e0 TI |
2884 | .init_verbs = { alc880_volume_init_verbs, |
2885 | alc880_pin_6stack_init_verbs }, | |
16ded525 TI |
2886 | .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), |
2887 | .dac_nids = alc880_6st_dac_nids, | |
2888 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
2889 | .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), |
2890 | .channel_mode = alc880_sixstack_modes, | |
2891 | .input_mux = &alc880_6stack_capture_source, | |
2892 | }, | |
2893 | [ALC880_W810] = { | |
e9edcee0 | 2894 | .mixers = { alc880_w810_base_mixer }, |
f12ab1e0 TI |
2895 | .init_verbs = { alc880_volume_init_verbs, |
2896 | alc880_pin_w810_init_verbs, | |
b0af0de5 | 2897 | alc880_gpio2_init_verbs }, |
16ded525 TI |
2898 | .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids), |
2899 | .dac_nids = alc880_w810_dac_nids, | |
2900 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
2901 | .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), |
2902 | .channel_mode = alc880_w810_modes, | |
2903 | .input_mux = &alc880_capture_source, | |
2904 | }, | |
2905 | [ALC880_Z71V] = { | |
e9edcee0 | 2906 | .mixers = { alc880_z71v_mixer }, |
f12ab1e0 TI |
2907 | .init_verbs = { alc880_volume_init_verbs, |
2908 | alc880_pin_z71v_init_verbs }, | |
16ded525 TI |
2909 | .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids), |
2910 | .dac_nids = alc880_z71v_dac_nids, | |
2911 | .dig_out_nid = ALC880_DIGOUT_NID, | |
2912 | .hp_nid = 0x03, | |
e9edcee0 TI |
2913 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), |
2914 | .channel_mode = alc880_2_jack_modes, | |
16ded525 TI |
2915 | .input_mux = &alc880_capture_source, |
2916 | }, | |
2917 | [ALC880_F1734] = { | |
e9edcee0 | 2918 | .mixers = { alc880_f1734_mixer }, |
f12ab1e0 TI |
2919 | .init_verbs = { alc880_volume_init_verbs, |
2920 | alc880_pin_f1734_init_verbs }, | |
e9edcee0 TI |
2921 | .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids), |
2922 | .dac_nids = alc880_f1734_dac_nids, | |
2923 | .hp_nid = 0x02, | |
2924 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
2925 | .channel_mode = alc880_2_jack_modes, | |
16ded525 TI |
2926 | .input_mux = &alc880_capture_source, |
2927 | }, | |
2928 | [ALC880_ASUS] = { | |
e9edcee0 | 2929 | .mixers = { alc880_asus_mixer }, |
f12ab1e0 TI |
2930 | .init_verbs = { alc880_volume_init_verbs, |
2931 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
2932 | alc880_gpio1_init_verbs }, |
2933 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
2934 | .dac_nids = alc880_asus_dac_nids, | |
2935 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), | |
2936 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 2937 | .need_dac_fix = 1, |
16ded525 TI |
2938 | .input_mux = &alc880_capture_source, |
2939 | }, | |
2940 | [ALC880_ASUS_DIG] = { | |
e9edcee0 | 2941 | .mixers = { alc880_asus_mixer }, |
f12ab1e0 TI |
2942 | .init_verbs = { alc880_volume_init_verbs, |
2943 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
2944 | alc880_gpio1_init_verbs }, |
2945 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
2946 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 2947 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
2948 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
2949 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 2950 | .need_dac_fix = 1, |
16ded525 TI |
2951 | .input_mux = &alc880_capture_source, |
2952 | }, | |
df694daa KY |
2953 | [ALC880_ASUS_DIG2] = { |
2954 | .mixers = { alc880_asus_mixer }, | |
f12ab1e0 TI |
2955 | .init_verbs = { alc880_volume_init_verbs, |
2956 | alc880_pin_asus_init_verbs, | |
df694daa KY |
2957 | alc880_gpio2_init_verbs }, /* use GPIO2 */ |
2958 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
2959 | .dac_nids = alc880_asus_dac_nids, | |
2960 | .dig_out_nid = ALC880_DIGOUT_NID, | |
2961 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), | |
2962 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 2963 | .need_dac_fix = 1, |
df694daa KY |
2964 | .input_mux = &alc880_capture_source, |
2965 | }, | |
16ded525 | 2966 | [ALC880_ASUS_W1V] = { |
e9edcee0 | 2967 | .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer }, |
f12ab1e0 TI |
2968 | .init_verbs = { alc880_volume_init_verbs, |
2969 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
2970 | alc880_gpio1_init_verbs }, |
2971 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
2972 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 2973 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
2974 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
2975 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 2976 | .need_dac_fix = 1, |
16ded525 TI |
2977 | .input_mux = &alc880_capture_source, |
2978 | }, | |
2979 | [ALC880_UNIWILL_DIG] = { | |
3c10a9d9 | 2980 | .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer }, |
ccc656ce KY |
2981 | .init_verbs = { alc880_volume_init_verbs, |
2982 | alc880_pin_asus_init_verbs }, | |
e9edcee0 TI |
2983 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), |
2984 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 2985 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
2986 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
2987 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 2988 | .need_dac_fix = 1, |
16ded525 TI |
2989 | .input_mux = &alc880_capture_source, |
2990 | }, | |
ccc656ce KY |
2991 | [ALC880_UNIWILL] = { |
2992 | .mixers = { alc880_uniwill_mixer }, | |
2993 | .init_verbs = { alc880_volume_init_verbs, | |
2994 | alc880_uniwill_init_verbs }, | |
2995 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
2996 | .dac_nids = alc880_asus_dac_nids, | |
2997 | .dig_out_nid = ALC880_DIGOUT_NID, | |
2998 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
2999 | .channel_mode = alc880_threestack_modes, | |
3000 | .need_dac_fix = 1, | |
3001 | .input_mux = &alc880_capture_source, | |
3002 | .unsol_event = alc880_uniwill_unsol_event, | |
3003 | .init_hook = alc880_uniwill_automute, | |
3004 | }, | |
3005 | [ALC880_UNIWILL_P53] = { | |
3006 | .mixers = { alc880_uniwill_p53_mixer }, | |
3007 | .init_verbs = { alc880_volume_init_verbs, | |
3008 | alc880_uniwill_p53_init_verbs }, | |
3009 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3010 | .dac_nids = alc880_asus_dac_nids, | |
3011 | .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), | |
2cf9f0fc TD |
3012 | .channel_mode = alc880_threestack_modes, |
3013 | .input_mux = &alc880_capture_source, | |
3014 | .unsol_event = alc880_uniwill_p53_unsol_event, | |
3015 | .init_hook = alc880_uniwill_p53_hp_automute, | |
3016 | }, | |
3017 | [ALC880_FUJITSU] = { | |
f12ab1e0 | 3018 | .mixers = { alc880_fujitsu_mixer, |
2cf9f0fc TD |
3019 | alc880_pcbeep_mixer, }, |
3020 | .init_verbs = { alc880_volume_init_verbs, | |
3021 | alc880_uniwill_p53_init_verbs, | |
3022 | alc880_beep_init_verbs }, | |
3023 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
3024 | .dac_nids = alc880_dac_nids, | |
d53d7d9e | 3025 | .dig_out_nid = ALC880_DIGOUT_NID, |
2cf9f0fc TD |
3026 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), |
3027 | .channel_mode = alc880_2_jack_modes, | |
ccc656ce KY |
3028 | .input_mux = &alc880_capture_source, |
3029 | .unsol_event = alc880_uniwill_p53_unsol_event, | |
3030 | .init_hook = alc880_uniwill_p53_hp_automute, | |
3031 | }, | |
df694daa KY |
3032 | [ALC880_CLEVO] = { |
3033 | .mixers = { alc880_three_stack_mixer }, | |
3034 | .init_verbs = { alc880_volume_init_verbs, | |
3035 | alc880_pin_clevo_init_verbs }, | |
3036 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
3037 | .dac_nids = alc880_dac_nids, | |
3038 | .hp_nid = 0x03, | |
3039 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
3040 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 3041 | .need_dac_fix = 1, |
df694daa KY |
3042 | .input_mux = &alc880_capture_source, |
3043 | }, | |
ae6b813a TI |
3044 | [ALC880_LG] = { |
3045 | .mixers = { alc880_lg_mixer }, | |
3046 | .init_verbs = { alc880_volume_init_verbs, | |
3047 | alc880_lg_init_verbs }, | |
3048 | .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids), | |
3049 | .dac_nids = alc880_lg_dac_nids, | |
3050 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3051 | .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes), | |
3052 | .channel_mode = alc880_lg_ch_modes, | |
4e195a7b | 3053 | .need_dac_fix = 1, |
ae6b813a TI |
3054 | .input_mux = &alc880_lg_capture_source, |
3055 | .unsol_event = alc880_lg_unsol_event, | |
3056 | .init_hook = alc880_lg_automute, | |
cb53c626 TI |
3057 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
3058 | .loopbacks = alc880_lg_loopbacks, | |
3059 | #endif | |
ae6b813a | 3060 | }, |
d681518a TI |
3061 | [ALC880_LG_LW] = { |
3062 | .mixers = { alc880_lg_lw_mixer }, | |
3063 | .init_verbs = { alc880_volume_init_verbs, | |
3064 | alc880_lg_lw_init_verbs }, | |
0a8c5da3 | 3065 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
d681518a TI |
3066 | .dac_nids = alc880_dac_nids, |
3067 | .dig_out_nid = ALC880_DIGOUT_NID, | |
0a8c5da3 CM |
3068 | .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes), |
3069 | .channel_mode = alc880_lg_lw_modes, | |
d681518a TI |
3070 | .input_mux = &alc880_lg_lw_capture_source, |
3071 | .unsol_event = alc880_lg_lw_unsol_event, | |
3072 | .init_hook = alc880_lg_lw_automute, | |
3073 | }, | |
16ded525 TI |
3074 | #ifdef CONFIG_SND_DEBUG |
3075 | [ALC880_TEST] = { | |
e9edcee0 TI |
3076 | .mixers = { alc880_test_mixer }, |
3077 | .init_verbs = { alc880_test_init_verbs }, | |
16ded525 TI |
3078 | .num_dacs = ARRAY_SIZE(alc880_test_dac_nids), |
3079 | .dac_nids = alc880_test_dac_nids, | |
3080 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3081 | .num_channel_mode = ARRAY_SIZE(alc880_test_modes), |
3082 | .channel_mode = alc880_test_modes, | |
3083 | .input_mux = &alc880_test_capture_source, | |
3084 | }, | |
3085 | #endif | |
3086 | }; | |
3087 | ||
e9edcee0 TI |
3088 | /* |
3089 | * Automatic parse of I/O pins from the BIOS configuration | |
3090 | */ | |
3091 | ||
3092 | #define NUM_CONTROL_ALLOC 32 | |
3093 | #define NUM_VERB_ALLOC 32 | |
3094 | ||
3095 | enum { | |
3096 | ALC_CTL_WIDGET_VOL, | |
3097 | ALC_CTL_WIDGET_MUTE, | |
3098 | ALC_CTL_BIND_MUTE, | |
3099 | }; | |
c8b6bf9b | 3100 | static struct snd_kcontrol_new alc880_control_templates[] = { |
e9edcee0 TI |
3101 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
3102 | HDA_CODEC_MUTE(NULL, 0, 0, 0), | |
985be54b | 3103 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
e9edcee0 TI |
3104 | }; |
3105 | ||
3106 | /* add dynamic controls */ | |
f12ab1e0 TI |
3107 | static int add_control(struct alc_spec *spec, int type, const char *name, |
3108 | unsigned long val) | |
e9edcee0 | 3109 | { |
c8b6bf9b | 3110 | struct snd_kcontrol_new *knew; |
e9edcee0 TI |
3111 | |
3112 | if (spec->num_kctl_used >= spec->num_kctl_alloc) { | |
3113 | int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; | |
3114 | ||
f12ab1e0 TI |
3115 | /* array + terminator */ |
3116 | knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); | |
3117 | if (!knew) | |
e9edcee0 TI |
3118 | return -ENOMEM; |
3119 | if (spec->kctl_alloc) { | |
f12ab1e0 TI |
3120 | memcpy(knew, spec->kctl_alloc, |
3121 | sizeof(*knew) * spec->num_kctl_alloc); | |
e9edcee0 TI |
3122 | kfree(spec->kctl_alloc); |
3123 | } | |
3124 | spec->kctl_alloc = knew; | |
3125 | spec->num_kctl_alloc = num; | |
3126 | } | |
3127 | ||
3128 | knew = &spec->kctl_alloc[spec->num_kctl_used]; | |
3129 | *knew = alc880_control_templates[type]; | |
543537bd | 3130 | knew->name = kstrdup(name, GFP_KERNEL); |
f12ab1e0 | 3131 | if (!knew->name) |
e9edcee0 TI |
3132 | return -ENOMEM; |
3133 | knew->private_value = val; | |
3134 | spec->num_kctl_used++; | |
3135 | return 0; | |
3136 | } | |
3137 | ||
3138 | #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17) | |
3139 | #define alc880_fixed_pin_idx(nid) ((nid) - 0x14) | |
3140 | #define alc880_is_multi_pin(nid) ((nid) >= 0x18) | |
3141 | #define alc880_multi_pin_idx(nid) ((nid) - 0x18) | |
3142 | #define alc880_is_input_pin(nid) ((nid) >= 0x18) | |
3143 | #define alc880_input_pin_idx(nid) ((nid) - 0x18) | |
3144 | #define alc880_idx_to_dac(nid) ((nid) + 0x02) | |
3145 | #define alc880_dac_to_idx(nid) ((nid) - 0x02) | |
3146 | #define alc880_idx_to_mixer(nid) ((nid) + 0x0c) | |
3147 | #define alc880_idx_to_selector(nid) ((nid) + 0x10) | |
3148 | #define ALC880_PIN_CD_NID 0x1c | |
3149 | ||
3150 | /* fill in the dac_nids table from the parsed pin configuration */ | |
f12ab1e0 TI |
3151 | static int alc880_auto_fill_dac_nids(struct alc_spec *spec, |
3152 | const struct auto_pin_cfg *cfg) | |
e9edcee0 TI |
3153 | { |
3154 | hda_nid_t nid; | |
3155 | int assigned[4]; | |
3156 | int i, j; | |
3157 | ||
3158 | memset(assigned, 0, sizeof(assigned)); | |
b0af0de5 | 3159 | spec->multiout.dac_nids = spec->private_dac_nids; |
e9edcee0 TI |
3160 | |
3161 | /* check the pins hardwired to audio widget */ | |
3162 | for (i = 0; i < cfg->line_outs; i++) { | |
3163 | nid = cfg->line_out_pins[i]; | |
3164 | if (alc880_is_fixed_pin(nid)) { | |
3165 | int idx = alc880_fixed_pin_idx(nid); | |
5014f193 | 3166 | spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx); |
e9edcee0 TI |
3167 | assigned[idx] = 1; |
3168 | } | |
3169 | } | |
3170 | /* left pins can be connect to any audio widget */ | |
3171 | for (i = 0; i < cfg->line_outs; i++) { | |
3172 | nid = cfg->line_out_pins[i]; | |
3173 | if (alc880_is_fixed_pin(nid)) | |
3174 | continue; | |
3175 | /* search for an empty channel */ | |
3176 | for (j = 0; j < cfg->line_outs; j++) { | |
f12ab1e0 TI |
3177 | if (!assigned[j]) { |
3178 | spec->multiout.dac_nids[i] = | |
3179 | alc880_idx_to_dac(j); | |
e9edcee0 TI |
3180 | assigned[j] = 1; |
3181 | break; | |
3182 | } | |
3183 | } | |
3184 | } | |
3185 | spec->multiout.num_dacs = cfg->line_outs; | |
3186 | return 0; | |
3187 | } | |
3188 | ||
3189 | /* add playback controls from the parsed DAC table */ | |
df694daa KY |
3190 | static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, |
3191 | const struct auto_pin_cfg *cfg) | |
e9edcee0 TI |
3192 | { |
3193 | char name[32]; | |
f12ab1e0 TI |
3194 | static const char *chname[4] = { |
3195 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
3196 | }; | |
e9edcee0 TI |
3197 | hda_nid_t nid; |
3198 | int i, err; | |
3199 | ||
3200 | for (i = 0; i < cfg->line_outs; i++) { | |
f12ab1e0 | 3201 | if (!spec->multiout.dac_nids[i]) |
e9edcee0 TI |
3202 | continue; |
3203 | nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i])); | |
3204 | if (i == 2) { | |
3205 | /* Center/LFE */ | |
f12ab1e0 TI |
3206 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
3207 | "Center Playback Volume", | |
3208 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, | |
3209 | HDA_OUTPUT)); | |
3210 | if (err < 0) | |
e9edcee0 | 3211 | return err; |
f12ab1e0 TI |
3212 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
3213 | "LFE Playback Volume", | |
3214 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
3215 | HDA_OUTPUT)); | |
3216 | if (err < 0) | |
e9edcee0 | 3217 | return err; |
f12ab1e0 TI |
3218 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
3219 | "Center Playback Switch", | |
3220 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, | |
3221 | HDA_INPUT)); | |
3222 | if (err < 0) | |
e9edcee0 | 3223 | return err; |
f12ab1e0 TI |
3224 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
3225 | "LFE Playback Switch", | |
3226 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, | |
3227 | HDA_INPUT)); | |
3228 | if (err < 0) | |
e9edcee0 TI |
3229 | return err; |
3230 | } else { | |
3231 | sprintf(name, "%s Playback Volume", chname[i]); | |
f12ab1e0 TI |
3232 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
3233 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
3234 | HDA_OUTPUT)); | |
3235 | if (err < 0) | |
e9edcee0 TI |
3236 | return err; |
3237 | sprintf(name, "%s Playback Switch", chname[i]); | |
f12ab1e0 TI |
3238 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
3239 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, | |
3240 | HDA_INPUT)); | |
3241 | if (err < 0) | |
e9edcee0 TI |
3242 | return err; |
3243 | } | |
3244 | } | |
e9edcee0 TI |
3245 | return 0; |
3246 | } | |
3247 | ||
8d88bc3d TI |
3248 | /* add playback controls for speaker and HP outputs */ |
3249 | static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, | |
3250 | const char *pfx) | |
e9edcee0 TI |
3251 | { |
3252 | hda_nid_t nid; | |
3253 | int err; | |
8d88bc3d | 3254 | char name[32]; |
e9edcee0 | 3255 | |
f12ab1e0 | 3256 | if (!pin) |
e9edcee0 TI |
3257 | return 0; |
3258 | ||
3259 | if (alc880_is_fixed_pin(pin)) { | |
3260 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
82bc955f | 3261 | /* specify the DAC as the extra output */ |
f12ab1e0 | 3262 | if (!spec->multiout.hp_nid) |
e9edcee0 | 3263 | spec->multiout.hp_nid = nid; |
82bc955f TI |
3264 | else |
3265 | spec->multiout.extra_out_nid[0] = nid; | |
e9edcee0 TI |
3266 | /* control HP volume/switch on the output mixer amp */ |
3267 | nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin)); | |
8d88bc3d | 3268 | sprintf(name, "%s Playback Volume", pfx); |
f12ab1e0 TI |
3269 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
3270 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
3271 | if (err < 0) | |
e9edcee0 | 3272 | return err; |
8d88bc3d | 3273 | sprintf(name, "%s Playback Switch", pfx); |
f12ab1e0 TI |
3274 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
3275 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); | |
3276 | if (err < 0) | |
e9edcee0 TI |
3277 | return err; |
3278 | } else if (alc880_is_multi_pin(pin)) { | |
3279 | /* set manual connection */ | |
e9edcee0 | 3280 | /* we have only a switch on HP-out PIN */ |
8d88bc3d | 3281 | sprintf(name, "%s Playback Switch", pfx); |
f12ab1e0 TI |
3282 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
3283 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
3284 | if (err < 0) | |
e9edcee0 TI |
3285 | return err; |
3286 | } | |
3287 | return 0; | |
3288 | } | |
3289 | ||
3290 | /* create input playback/capture controls for the given pin */ | |
f12ab1e0 TI |
3291 | static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, |
3292 | const char *ctlname, | |
df694daa | 3293 | int idx, hda_nid_t mix_nid) |
e9edcee0 TI |
3294 | { |
3295 | char name[32]; | |
df694daa | 3296 | int err; |
e9edcee0 TI |
3297 | |
3298 | sprintf(name, "%s Playback Volume", ctlname); | |
f12ab1e0 TI |
3299 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
3300 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); | |
3301 | if (err < 0) | |
e9edcee0 TI |
3302 | return err; |
3303 | sprintf(name, "%s Playback Switch", ctlname); | |
f12ab1e0 TI |
3304 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
3305 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); | |
3306 | if (err < 0) | |
e9edcee0 TI |
3307 | return err; |
3308 | return 0; | |
3309 | } | |
3310 | ||
3311 | /* create playback/capture controls for input pins */ | |
df694daa KY |
3312 | static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, |
3313 | const struct auto_pin_cfg *cfg) | |
e9edcee0 | 3314 | { |
e9edcee0 | 3315 | struct hda_input_mux *imux = &spec->private_imux; |
df694daa | 3316 | int i, err, idx; |
e9edcee0 TI |
3317 | |
3318 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
3319 | if (alc880_is_input_pin(cfg->input_pins[i])) { | |
df694daa | 3320 | idx = alc880_input_pin_idx(cfg->input_pins[i]); |
4a471b7d TI |
3321 | err = new_analog_input(spec, cfg->input_pins[i], |
3322 | auto_pin_cfg_labels[i], | |
df694daa | 3323 | idx, 0x0b); |
e9edcee0 TI |
3324 | if (err < 0) |
3325 | return err; | |
f12ab1e0 TI |
3326 | imux->items[imux->num_items].label = |
3327 | auto_pin_cfg_labels[i]; | |
3328 | imux->items[imux->num_items].index = | |
3329 | alc880_input_pin_idx(cfg->input_pins[i]); | |
e9edcee0 TI |
3330 | imux->num_items++; |
3331 | } | |
3332 | } | |
3333 | return 0; | |
3334 | } | |
3335 | ||
df694daa KY |
3336 | static void alc880_auto_set_output_and_unmute(struct hda_codec *codec, |
3337 | hda_nid_t nid, int pin_type, | |
e9edcee0 TI |
3338 | int dac_idx) |
3339 | { | |
3340 | /* set as output */ | |
f12ab1e0 TI |
3341 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
3342 | pin_type); | |
3343 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
3344 | AMP_OUT_UNMUTE); | |
e9edcee0 TI |
3345 | /* need the manual connection? */ |
3346 | if (alc880_is_multi_pin(nid)) { | |
3347 | struct alc_spec *spec = codec->spec; | |
3348 | int idx = alc880_multi_pin_idx(nid); | |
3349 | snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, | |
3350 | AC_VERB_SET_CONNECT_SEL, | |
3351 | alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); | |
3352 | } | |
3353 | } | |
3354 | ||
baba8ee9 TI |
3355 | static int get_pin_type(int line_out_type) |
3356 | { | |
3357 | if (line_out_type == AUTO_PIN_HP_OUT) | |
3358 | return PIN_HP; | |
3359 | else | |
3360 | return PIN_OUT; | |
3361 | } | |
3362 | ||
e9edcee0 TI |
3363 | static void alc880_auto_init_multi_out(struct hda_codec *codec) |
3364 | { | |
3365 | struct alc_spec *spec = codec->spec; | |
3366 | int i; | |
bc9f98a9 KY |
3367 | |
3368 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); | |
e9edcee0 TI |
3369 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
3370 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 TI |
3371 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
3372 | alc880_auto_set_output_and_unmute(codec, nid, pin_type, i); | |
e9edcee0 TI |
3373 | } |
3374 | } | |
3375 | ||
8d88bc3d | 3376 | static void alc880_auto_init_extra_out(struct hda_codec *codec) |
e9edcee0 TI |
3377 | { |
3378 | struct alc_spec *spec = codec->spec; | |
3379 | hda_nid_t pin; | |
3380 | ||
82bc955f | 3381 | pin = spec->autocfg.speaker_pins[0]; |
8d88bc3d TI |
3382 | if (pin) /* connect to front */ |
3383 | alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
eb06ed8f | 3384 | pin = spec->autocfg.hp_pins[0]; |
e9edcee0 TI |
3385 | if (pin) /* connect to front */ |
3386 | alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
3387 | } | |
3388 | ||
3389 | static void alc880_auto_init_analog_input(struct hda_codec *codec) | |
3390 | { | |
3391 | struct alc_spec *spec = codec->spec; | |
3392 | int i; | |
3393 | ||
3394 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
3395 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
3396 | if (alc880_is_input_pin(nid)) { | |
f12ab1e0 TI |
3397 | snd_hda_codec_write(codec, nid, 0, |
3398 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
3399 | i <= AUTO_PIN_FRONT_MIC ? | |
3400 | PIN_VREF80 : PIN_IN); | |
e9edcee0 | 3401 | if (nid != ALC880_PIN_CD_NID) |
f12ab1e0 TI |
3402 | snd_hda_codec_write(codec, nid, 0, |
3403 | AC_VERB_SET_AMP_GAIN_MUTE, | |
e9edcee0 TI |
3404 | AMP_OUT_MUTE); |
3405 | } | |
3406 | } | |
3407 | } | |
3408 | ||
3409 | /* parse the BIOS configuration and set up the alc_spec */ | |
f12ab1e0 TI |
3410 | /* return 1 if successful, 0 if the proper config is not found, |
3411 | * or a negative error code | |
3412 | */ | |
e9edcee0 TI |
3413 | static int alc880_parse_auto_config(struct hda_codec *codec) |
3414 | { | |
3415 | struct alc_spec *spec = codec->spec; | |
3416 | int err; | |
df694daa | 3417 | static hda_nid_t alc880_ignore[] = { 0x1d, 0 }; |
e9edcee0 | 3418 | |
f12ab1e0 TI |
3419 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
3420 | alc880_ignore); | |
3421 | if (err < 0) | |
e9edcee0 | 3422 | return err; |
f12ab1e0 | 3423 | if (!spec->autocfg.line_outs) |
e9edcee0 | 3424 | return 0; /* can't find valid BIOS pin config */ |
df694daa | 3425 | |
f12ab1e0 TI |
3426 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
3427 | if (err < 0) | |
3428 | return err; | |
3429 | err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
3430 | if (err < 0) | |
3431 | return err; | |
3432 | err = alc880_auto_create_extra_out(spec, | |
3433 | spec->autocfg.speaker_pins[0], | |
3434 | "Speaker"); | |
3435 | if (err < 0) | |
3436 | return err; | |
3437 | err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], | |
3438 | "Headphone"); | |
3439 | if (err < 0) | |
3440 | return err; | |
3441 | err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
3442 | if (err < 0) | |
e9edcee0 TI |
3443 | return err; |
3444 | ||
3445 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
3446 | ||
3447 | if (spec->autocfg.dig_out_pin) | |
3448 | spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; | |
3449 | if (spec->autocfg.dig_in_pin) | |
3450 | spec->dig_in_nid = ALC880_DIGIN_NID; | |
3451 | ||
3452 | if (spec->kctl_alloc) | |
3453 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
3454 | ||
3455 | spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs; | |
3456 | ||
a1e8d2da | 3457 | spec->num_mux_defs = 1; |
e9edcee0 TI |
3458 | spec->input_mux = &spec->private_imux; |
3459 | ||
3460 | return 1; | |
3461 | } | |
3462 | ||
ae6b813a TI |
3463 | /* additional initialization for auto-configuration model */ |
3464 | static void alc880_auto_init(struct hda_codec *codec) | |
e9edcee0 | 3465 | { |
e9edcee0 | 3466 | alc880_auto_init_multi_out(codec); |
8d88bc3d | 3467 | alc880_auto_init_extra_out(codec); |
e9edcee0 | 3468 | alc880_auto_init_analog_input(codec); |
e9edcee0 TI |
3469 | } |
3470 | ||
3471 | /* | |
3472 | * OK, here we have finally the patch for ALC880 | |
3473 | */ | |
3474 | ||
1da177e4 LT |
3475 | static int patch_alc880(struct hda_codec *codec) |
3476 | { | |
3477 | struct alc_spec *spec; | |
3478 | int board_config; | |
df694daa | 3479 | int err; |
1da177e4 | 3480 | |
e560d8d8 | 3481 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
1da177e4 LT |
3482 | if (spec == NULL) |
3483 | return -ENOMEM; | |
3484 | ||
3485 | codec->spec = spec; | |
3486 | ||
f5fcc13c TI |
3487 | board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST, |
3488 | alc880_models, | |
3489 | alc880_cfg_tbl); | |
3490 | if (board_config < 0) { | |
9c7f852e TI |
3491 | printk(KERN_INFO "hda_codec: Unknown model for ALC880, " |
3492 | "trying auto-probe from BIOS...\n"); | |
e9edcee0 | 3493 | board_config = ALC880_AUTO; |
1da177e4 | 3494 | } |
1da177e4 | 3495 | |
e9edcee0 TI |
3496 | if (board_config == ALC880_AUTO) { |
3497 | /* automatic parse from the BIOS config */ | |
3498 | err = alc880_parse_auto_config(codec); | |
3499 | if (err < 0) { | |
3500 | alc_free(codec); | |
3501 | return err; | |
f12ab1e0 | 3502 | } else if (!err) { |
9c7f852e TI |
3503 | printk(KERN_INFO |
3504 | "hda_codec: Cannot set up configuration " | |
3505 | "from BIOS. Using 3-stack mode...\n"); | |
e9edcee0 TI |
3506 | board_config = ALC880_3ST; |
3507 | } | |
1da177e4 LT |
3508 | } |
3509 | ||
df694daa KY |
3510 | if (board_config != ALC880_AUTO) |
3511 | setup_preset(spec, &alc880_presets[board_config]); | |
1da177e4 LT |
3512 | |
3513 | spec->stream_name_analog = "ALC880 Analog"; | |
3514 | spec->stream_analog_playback = &alc880_pcm_analog_playback; | |
3515 | spec->stream_analog_capture = &alc880_pcm_analog_capture; | |
3516 | ||
3517 | spec->stream_name_digital = "ALC880 Digital"; | |
3518 | spec->stream_digital_playback = &alc880_pcm_digital_playback; | |
3519 | spec->stream_digital_capture = &alc880_pcm_digital_capture; | |
3520 | ||
f12ab1e0 | 3521 | if (!spec->adc_nids && spec->input_mux) { |
e9edcee0 | 3522 | /* check whether NID 0x07 is valid */ |
54d17403 | 3523 | unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); |
f12ab1e0 TI |
3524 | /* get type */ |
3525 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
e9edcee0 TI |
3526 | if (wcap != AC_WID_AUD_IN) { |
3527 | spec->adc_nids = alc880_adc_nids_alt; | |
3528 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); | |
f12ab1e0 TI |
3529 | spec->mixers[spec->num_mixers] = |
3530 | alc880_capture_alt_mixer; | |
e9edcee0 TI |
3531 | spec->num_mixers++; |
3532 | } else { | |
3533 | spec->adc_nids = alc880_adc_nids; | |
3534 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids); | |
3535 | spec->mixers[spec->num_mixers] = alc880_capture_mixer; | |
3536 | spec->num_mixers++; | |
3537 | } | |
3538 | } | |
1da177e4 LT |
3539 | |
3540 | codec->patch_ops = alc_patch_ops; | |
e9edcee0 | 3541 | if (board_config == ALC880_AUTO) |
ae6b813a | 3542 | spec->init_hook = alc880_auto_init; |
cb53c626 TI |
3543 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
3544 | if (!spec->loopback.amplist) | |
3545 | spec->loopback.amplist = alc880_loopbacks; | |
3546 | #endif | |
1da177e4 LT |
3547 | |
3548 | return 0; | |
3549 | } | |
3550 | ||
e9edcee0 | 3551 | |
1da177e4 LT |
3552 | /* |
3553 | * ALC260 support | |
3554 | */ | |
3555 | ||
e9edcee0 TI |
3556 | static hda_nid_t alc260_dac_nids[1] = { |
3557 | /* front */ | |
3558 | 0x02, | |
3559 | }; | |
3560 | ||
3561 | static hda_nid_t alc260_adc_nids[1] = { | |
3562 | /* ADC0 */ | |
3563 | 0x04, | |
3564 | }; | |
3565 | ||
df694daa | 3566 | static hda_nid_t alc260_adc_nids_alt[1] = { |
e9edcee0 TI |
3567 | /* ADC1 */ |
3568 | 0x05, | |
3569 | }; | |
3570 | ||
df694daa KY |
3571 | static hda_nid_t alc260_hp_adc_nids[2] = { |
3572 | /* ADC1, 0 */ | |
3573 | 0x05, 0x04 | |
3574 | }; | |
3575 | ||
d57fdac0 JW |
3576 | /* NIDs used when simultaneous access to both ADCs makes sense. Note that |
3577 | * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC. | |
3578 | */ | |
3579 | static hda_nid_t alc260_dual_adc_nids[2] = { | |
4c5186ed JW |
3580 | /* ADC0, ADC1 */ |
3581 | 0x04, 0x05 | |
3582 | }; | |
3583 | ||
e9edcee0 TI |
3584 | #define ALC260_DIGOUT_NID 0x03 |
3585 | #define ALC260_DIGIN_NID 0x06 | |
3586 | ||
3587 | static struct hda_input_mux alc260_capture_source = { | |
3588 | .num_items = 4, | |
3589 | .items = { | |
3590 | { "Mic", 0x0 }, | |
3591 | { "Front Mic", 0x1 }, | |
3592 | { "Line", 0x2 }, | |
3593 | { "CD", 0x4 }, | |
3594 | }, | |
3595 | }; | |
3596 | ||
17e7aec6 | 3597 | /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack, |
a1e8d2da JW |
3598 | * headphone jack and the internal CD lines since these are the only pins at |
3599 | * which audio can appear. For flexibility, also allow the option of | |
3600 | * recording the mixer output on the second ADC (ADC0 doesn't have a | |
3601 | * connection to the mixer output). | |
a9430dd8 | 3602 | */ |
a1e8d2da JW |
3603 | static struct hda_input_mux alc260_fujitsu_capture_sources[2] = { |
3604 | { | |
3605 | .num_items = 3, | |
3606 | .items = { | |
3607 | { "Mic/Line", 0x0 }, | |
3608 | { "CD", 0x4 }, | |
3609 | { "Headphone", 0x2 }, | |
3610 | }, | |
a9430dd8 | 3611 | }, |
a1e8d2da JW |
3612 | { |
3613 | .num_items = 4, | |
3614 | .items = { | |
3615 | { "Mic/Line", 0x0 }, | |
3616 | { "CD", 0x4 }, | |
3617 | { "Headphone", 0x2 }, | |
3618 | { "Mixer", 0x5 }, | |
3619 | }, | |
3620 | }, | |
3621 | ||
a9430dd8 JW |
3622 | }; |
3623 | ||
a1e8d2da JW |
3624 | /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to |
3625 | * the Fujitsu S702x, but jacks are marked differently. | |
0bfc90e9 | 3626 | */ |
a1e8d2da JW |
3627 | static struct hda_input_mux alc260_acer_capture_sources[2] = { |
3628 | { | |
3629 | .num_items = 4, | |
3630 | .items = { | |
3631 | { "Mic", 0x0 }, | |
3632 | { "Line", 0x2 }, | |
3633 | { "CD", 0x4 }, | |
3634 | { "Headphone", 0x5 }, | |
3635 | }, | |
3636 | }, | |
3637 | { | |
3638 | .num_items = 5, | |
3639 | .items = { | |
3640 | { "Mic", 0x0 }, | |
3641 | { "Line", 0x2 }, | |
3642 | { "CD", 0x4 }, | |
3643 | { "Headphone", 0x6 }, | |
3644 | { "Mixer", 0x5 }, | |
3645 | }, | |
0bfc90e9 JW |
3646 | }, |
3647 | }; | |
1da177e4 LT |
3648 | /* |
3649 | * This is just place-holder, so there's something for alc_build_pcms to look | |
3650 | * at when it calculates the maximum number of channels. ALC260 has no mixer | |
3651 | * element which allows changing the channel mode, so the verb list is | |
3652 | * never used. | |
3653 | */ | |
d2a6d7dc | 3654 | static struct hda_channel_mode alc260_modes[1] = { |
1da177e4 LT |
3655 | { 2, NULL }, |
3656 | }; | |
3657 | ||
df694daa KY |
3658 | |
3659 | /* Mixer combinations | |
3660 | * | |
3661 | * basic: base_output + input + pc_beep + capture | |
3662 | * HP: base_output + input + capture_alt | |
3663 | * HP_3013: hp_3013 + input + capture | |
3664 | * fujitsu: fujitsu + capture | |
0bfc90e9 | 3665 | * acer: acer + capture |
df694daa KY |
3666 | */ |
3667 | ||
3668 | static struct snd_kcontrol_new alc260_base_output_mixer[] = { | |
05acb863 | 3669 | HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
985be54b | 3670 | HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), |
05acb863 | 3671 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
985be54b | 3672 | HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), |
05acb863 | 3673 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
985be54b | 3674 | HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), |
1da177e4 | 3675 | { } /* end */ |
f12ab1e0 | 3676 | }; |
1da177e4 | 3677 | |
df694daa | 3678 | static struct snd_kcontrol_new alc260_input_mixer[] = { |
16ded525 TI |
3679 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
3680 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
3681 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
3682 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
3683 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
3684 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
3685 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT), | |
3686 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT), | |
df694daa KY |
3687 | { } /* end */ |
3688 | }; | |
3689 | ||
3690 | static struct snd_kcontrol_new alc260_pc_beep_mixer[] = { | |
3691 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT), | |
3692 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT), | |
3693 | { } /* end */ | |
3694 | }; | |
3695 | ||
3696 | static struct snd_kcontrol_new alc260_hp_3013_mixer[] = { | |
3697 | HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT), | |
3698 | HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT), | |
3699 | HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT), | |
3700 | HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT), | |
3701 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
3702 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
3703 | HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), | |
3704 | HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT), | |
16ded525 TI |
3705 | { } /* end */ |
3706 | }; | |
3707 | ||
a1e8d2da JW |
3708 | /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12, |
3709 | * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10. | |
3710 | */ | |
c8b6bf9b | 3711 | static struct snd_kcontrol_new alc260_fujitsu_mixer[] = { |
a9430dd8 | 3712 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
985be54b | 3713 | HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT), |
4c5186ed | 3714 | ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT), |
a9430dd8 JW |
3715 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
3716 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
3717 | HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT), | |
3718 | HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4c5186ed | 3719 | ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN), |
a9430dd8 JW |
3720 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), |
3721 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
3722 | HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT), | |
985be54b | 3723 | HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT), |
df694daa KY |
3724 | { } /* end */ |
3725 | }; | |
3726 | ||
a1e8d2da JW |
3727 | /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current |
3728 | * versions of the ALC260 don't act on requests to enable mic bias from NID | |
3729 | * 0x0f (used to drive the headphone jack in these laptops). The ALC260 | |
3730 | * datasheet doesn't mention this restriction. At this stage it's not clear | |
3731 | * whether this behaviour is intentional or is a hardware bug in chip | |
3732 | * revisions available in early 2006. Therefore for now allow the | |
3733 | * "Headphone Jack Mode" control to span all choices, but if it turns out | |
3734 | * that the lack of mic bias for this NID is intentional we could change the | |
3735 | * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
3736 | * | |
3737 | * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006 | |
3738 | * don't appear to make the mic bias available from the "line" jack, even | |
3739 | * though the NID used for this jack (0x14) can supply it. The theory is | |
3740 | * that perhaps Acer have included blocking capacitors between the ALC260 | |
3741 | * and the output jack. If this turns out to be the case for all such | |
3742 | * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT | |
3743 | * to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
bd869485 JW |
3744 | * |
3745 | * The C20x Tablet series have a mono internal speaker which is controlled | |
3746 | * via the chip's Mono sum widget and pin complex, so include the necessary | |
3747 | * controls for such models. On models without a "mono speaker" the control | |
3748 | * won't do anything. | |
a1e8d2da | 3749 | */ |
0bfc90e9 JW |
3750 | static struct snd_kcontrol_new alc260_acer_mixer[] = { |
3751 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
3752 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT), | |
a1e8d2da | 3753 | ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT), |
bd869485 JW |
3754 | HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0, |
3755 | HDA_OUTPUT), | |
3756 | HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2, | |
3757 | HDA_INPUT), | |
0bfc90e9 JW |
3758 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
3759 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
3760 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
3761 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
3762 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
3763 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
3764 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
3765 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
3766 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), | |
3767 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
3768 | { } /* end */ | |
3769 | }; | |
3770 | ||
bc9f98a9 KY |
3771 | /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12, |
3772 | * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17. | |
3773 | */ | |
3774 | static struct snd_kcontrol_new alc260_will_mixer[] = { | |
3775 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
3776 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT), | |
3777 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
3778 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
3779 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
3780 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
3781 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
3782 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
3783 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), | |
3784 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
3785 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), | |
3786 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
3787 | { } /* end */ | |
3788 | }; | |
3789 | ||
3790 | /* Replacer 672V ALC260 pin usage: Mic jack = 0x12, | |
3791 | * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f. | |
3792 | */ | |
3793 | static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = { | |
3794 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
3795 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT), | |
3796 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
3797 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
3798 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
3799 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT), | |
3800 | HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT), | |
3801 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
3802 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
3803 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
3804 | { } /* end */ | |
3805 | }; | |
3806 | ||
df694daa KY |
3807 | /* capture mixer elements */ |
3808 | static struct snd_kcontrol_new alc260_capture_mixer[] = { | |
a9430dd8 JW |
3809 | HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT), |
3810 | HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT), | |
df694daa KY |
3811 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT), |
3812 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT), | |
a9430dd8 JW |
3813 | { |
3814 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
df694daa KY |
3815 | /* The multiple "Capture Source" controls confuse alsamixer |
3816 | * So call somewhat different.. | |
3817 | * FIXME: the controls appear in the "playback" view! | |
3818 | */ | |
3819 | /* .name = "Capture Source", */ | |
3820 | .name = "Input Source", | |
3821 | .count = 2, | |
3822 | .info = alc_mux_enum_info, | |
3823 | .get = alc_mux_enum_get, | |
3824 | .put = alc_mux_enum_put, | |
3825 | }, | |
3826 | { } /* end */ | |
3827 | }; | |
3828 | ||
3829 | static struct snd_kcontrol_new alc260_capture_alt_mixer[] = { | |
3830 | HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT), | |
3831 | HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT), | |
3832 | { | |
3833 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
3834 | /* The multiple "Capture Source" controls confuse alsamixer | |
3835 | * So call somewhat different.. | |
3836 | * FIXME: the controls appear in the "playback" view! | |
3837 | */ | |
3838 | /* .name = "Capture Source", */ | |
3839 | .name = "Input Source", | |
3840 | .count = 1, | |
a9430dd8 JW |
3841 | .info = alc_mux_enum_info, |
3842 | .get = alc_mux_enum_get, | |
3843 | .put = alc_mux_enum_put, | |
3844 | }, | |
3845 | { } /* end */ | |
3846 | }; | |
3847 | ||
df694daa KY |
3848 | /* |
3849 | * initialization verbs | |
3850 | */ | |
1da177e4 LT |
3851 | static struct hda_verb alc260_init_verbs[] = { |
3852 | /* Line In pin widget for input */ | |
05acb863 | 3853 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 3854 | /* CD pin widget for input */ |
05acb863 | 3855 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 3856 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
16ded525 | 3857 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1da177e4 | 3858 | /* Mic2 (front panel) pin widget for input and vref at 80% */ |
16ded525 | 3859 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1da177e4 | 3860 | /* LINE-2 is used for line-out in rear */ |
05acb863 | 3861 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1da177e4 | 3862 | /* select line-out */ |
fd56f2db | 3863 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00}, |
1da177e4 | 3864 | /* LINE-OUT pin */ |
05acb863 | 3865 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1da177e4 | 3866 | /* enable HP */ |
05acb863 | 3867 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
1da177e4 | 3868 | /* enable Mono */ |
05acb863 TI |
3869 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
3870 | /* mute capture amp left and right */ | |
16ded525 | 3871 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1da177e4 LT |
3872 | /* set connection select to line in (default select for this ADC) */ |
3873 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
16ded525 TI |
3874 | /* mute capture amp left and right */ |
3875 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
3876 | /* set connection select to line in (default select for this ADC) */ | |
3877 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
05acb863 TI |
3878 | /* set vol=0 Line-Out mixer amp left and right */ |
3879 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3880 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
3881 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3882 | /* set vol=0 HP mixer amp left and right */ | |
3883 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3884 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
3885 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3886 | /* set vol=0 Mono mixer amp left and right */ | |
3887 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3888 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
3889 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3890 | /* unmute LINE-2 out pin */ | |
3891 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
f12ab1e0 TI |
3892 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
3893 | * Line In 2 = 0x03 | |
3894 | */ | |
cb53c626 TI |
3895 | /* mute analog inputs */ |
3896 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3897 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3898 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
3899 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
3900 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 3901 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
05acb863 TI |
3902 | /* mute Front out path */ |
3903 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3904 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3905 | /* mute Headphone out path */ | |
3906 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3907 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3908 | /* mute Mono out path */ | |
3909 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3910 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 LT |
3911 | { } |
3912 | }; | |
3913 | ||
474167d6 | 3914 | #if 0 /* should be identical with alc260_init_verbs? */ |
df694daa KY |
3915 | static struct hda_verb alc260_hp_init_verbs[] = { |
3916 | /* Headphone and output */ | |
3917 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
3918 | /* mono output */ | |
3919 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
3920 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
3921 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
3922 | /* Mic2 (front panel) pin widget for input and vref at 80% */ | |
3923 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
3924 | /* Line In pin widget for input */ | |
3925 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
3926 | /* Line-2 pin widget for output */ | |
3927 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
3928 | /* CD pin widget for input */ | |
3929 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
3930 | /* unmute amp left and right */ | |
3931 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | |
3932 | /* set connection select to line in (default select for this ADC) */ | |
3933 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
3934 | /* unmute Line-Out mixer amp left and right (volume = 0) */ | |
3935 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
3936 | /* mute pin widget amp left and right (no gain on this amp) */ | |
3937 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
3938 | /* unmute HP mixer amp left and right (volume = 0) */ | |
3939 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
3940 | /* mute pin widget amp left and right (no gain on this amp) */ | |
3941 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
f12ab1e0 TI |
3942 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
3943 | * Line In 2 = 0x03 | |
3944 | */ | |
cb53c626 TI |
3945 | /* mute analog inputs */ |
3946 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3947 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3948 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
3949 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
3950 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
3951 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
3952 | /* Unmute Front out path */ | |
3953 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3954 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
3955 | /* Unmute Headphone out path */ | |
3956 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3957 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
3958 | /* Unmute Mono out path */ | |
3959 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3960 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
3961 | { } | |
3962 | }; | |
474167d6 | 3963 | #endif |
df694daa KY |
3964 | |
3965 | static struct hda_verb alc260_hp_3013_init_verbs[] = { | |
3966 | /* Line out and output */ | |
3967 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
3968 | /* mono output */ | |
3969 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
3970 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
3971 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
3972 | /* Mic2 (front panel) pin widget for input and vref at 80% */ | |
3973 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
3974 | /* Line In pin widget for input */ | |
3975 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
3976 | /* Headphone pin widget for output */ | |
3977 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
3978 | /* CD pin widget for input */ | |
3979 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
3980 | /* unmute amp left and right */ | |
3981 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | |
3982 | /* set connection select to line in (default select for this ADC) */ | |
3983 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
3984 | /* unmute Line-Out mixer amp left and right (volume = 0) */ | |
3985 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
3986 | /* mute pin widget amp left and right (no gain on this amp) */ | |
3987 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
3988 | /* unmute HP mixer amp left and right (volume = 0) */ | |
3989 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
3990 | /* mute pin widget amp left and right (no gain on this amp) */ | |
3991 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
f12ab1e0 TI |
3992 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
3993 | * Line In 2 = 0x03 | |
3994 | */ | |
cb53c626 TI |
3995 | /* mute analog inputs */ |
3996 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3997 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3998 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
3999 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4000 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
4001 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
4002 | /* Unmute Front out path */ | |
4003 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4004 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4005 | /* Unmute Headphone out path */ | |
4006 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4007 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4008 | /* Unmute Mono out path */ | |
4009 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4010 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4011 | { } | |
4012 | }; | |
4013 | ||
a9430dd8 | 4014 | /* Initialisation sequence for ALC260 as configured in Fujitsu S702x |
a1e8d2da JW |
4015 | * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD |
4016 | * audio = 0x16, internal speaker = 0x10. | |
a9430dd8 JW |
4017 | */ |
4018 | static struct hda_verb alc260_fujitsu_init_verbs[] = { | |
4019 | /* Disable all GPIOs */ | |
4020 | {0x01, AC_VERB_SET_GPIO_MASK, 0}, | |
4021 | /* Internal speaker is connected to headphone pin */ | |
4022 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
4023 | /* Headphone/Line-out jack connects to Line1 pin; make it an output */ | |
4024 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
f7ace40d JW |
4025 | /* Mic/Line-in jack is connected to mic1 pin, so make it an input */ |
4026 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
4027 | /* Ensure all other unused pins are disabled and muted. */ | |
4028 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
4029 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
a9430dd8 | 4030 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
f7ace40d | 4031 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
a9430dd8 | 4032 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
f7ace40d JW |
4033 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
4034 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
4035 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4036 | ||
4037 | /* Disable digital (SPDIF) pins */ | |
4038 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
4039 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
a9430dd8 | 4040 | |
f7ace40d JW |
4041 | /* Ensure Line1 pin widget takes its input from the OUT1 sum bus |
4042 | * when acting as an output. | |
4043 | */ | |
4044 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
4c5186ed | 4045 | |
f7ace40d | 4046 | /* Start with output sum widgets muted and their output gains at min */ |
8b33a5aa TI |
4047 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
4048 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4049 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4050 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4051 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4052 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4053 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4054 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4055 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
a9430dd8 | 4056 | |
f7ace40d JW |
4057 | /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */ |
4058 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4059 | /* Unmute Line1 pin widget output buffer since it starts as an output. | |
4060 | * If the pin mode is changed by the user the pin mode control will | |
4061 | * take care of enabling the pin's input/output buffers as needed. | |
4062 | * Therefore there's no need to enable the input buffer at this | |
4063 | * stage. | |
cdcd9268 | 4064 | */ |
f7ace40d | 4065 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
cdcd9268 JW |
4066 | /* Unmute input buffer of pin widget used for Line-in (no equiv |
4067 | * mixer ctrl) | |
4068 | */ | |
f7ace40d JW |
4069 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
4070 | ||
4071 | /* Mute capture amp left and right */ | |
4072 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4073 | /* Set ADC connection select to match default mixer setting - line | |
4074 | * in (on mic1 pin) | |
4075 | */ | |
4076 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4077 | ||
4078 | /* Do the same for the second ADC: mute capture input amp and | |
4079 | * set ADC connection to line in (on mic1 pin) | |
4080 | */ | |
4081 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4082 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4083 | ||
4084 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
4085 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
4086 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
4087 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
4088 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
4089 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
4090 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
4091 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
4092 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
4a471b7d TI |
4093 | |
4094 | { } | |
a9430dd8 JW |
4095 | }; |
4096 | ||
0bfc90e9 JW |
4097 | /* Initialisation sequence for ALC260 as configured in Acer TravelMate and |
4098 | * similar laptops (adapted from Fujitsu init verbs). | |
4099 | */ | |
4100 | static struct hda_verb alc260_acer_init_verbs[] = { | |
4101 | /* On TravelMate laptops, GPIO 0 enables the internal speaker and | |
4102 | * the headphone jack. Turn this on and rely on the standard mute | |
4103 | * methods whenever the user wants to turn these outputs off. | |
4104 | */ | |
4105 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
4106 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
4107 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, | |
4108 | /* Internal speaker/Headphone jack is connected to Line-out pin */ | |
4109 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
4110 | /* Internal microphone/Mic jack is connected to Mic1 pin */ | |
4111 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | |
4112 | /* Line In jack is connected to Line1 pin */ | |
4113 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
bd869485 JW |
4114 | /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */ |
4115 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
0bfc90e9 JW |
4116 | /* Ensure all other unused pins are disabled and muted. */ |
4117 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
4118 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
0bfc90e9 JW |
4119 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
4120 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4121 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
4122 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4123 | /* Disable digital (SPDIF) pins */ | |
4124 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
4125 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
4126 | ||
4127 | /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum | |
4128 | * bus when acting as outputs. | |
4129 | */ | |
4130 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, | |
4131 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
4132 | ||
4133 | /* Start with output sum widgets muted and their output gains at min */ | |
4134 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4135 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4136 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4137 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4138 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4139 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4140 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4141 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4142 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4143 | ||
f12ab1e0 TI |
4144 | /* Unmute Line-out pin widget amp left and right |
4145 | * (no equiv mixer ctrl) | |
4146 | */ | |
0bfc90e9 | 4147 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
bd869485 JW |
4148 | /* Unmute mono pin widget amp output (no equiv mixer ctrl) */ |
4149 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
0bfc90e9 JW |
4150 | /* Unmute Mic1 and Line1 pin widget input buffers since they start as |
4151 | * inputs. If the pin mode is changed by the user the pin mode control | |
4152 | * will take care of enabling the pin's input/output buffers as needed. | |
4153 | * Therefore there's no need to enable the input buffer at this | |
4154 | * stage. | |
4155 | */ | |
4156 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4157 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4158 | ||
4159 | /* Mute capture amp left and right */ | |
4160 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4161 | /* Set ADC connection select to match default mixer setting - mic | |
4162 | * (on mic1 pin) | |
4163 | */ | |
4164 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4165 | ||
4166 | /* Do similar with the second ADC: mute capture input amp and | |
a1e8d2da | 4167 | * set ADC connection to mic to match ALSA's default state. |
0bfc90e9 JW |
4168 | */ |
4169 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
a1e8d2da | 4170 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, |
0bfc90e9 JW |
4171 | |
4172 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
4173 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
4174 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
4175 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
4176 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
4177 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
4178 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
4179 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
4180 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
4181 | ||
4182 | { } | |
4183 | }; | |
4184 | ||
bc9f98a9 KY |
4185 | static struct hda_verb alc260_will_verbs[] = { |
4186 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
4187 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4188 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4189 | {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, | |
4190 | {0x1a, AC_VERB_SET_COEF_INDEX, 0x07}, | |
4191 | {0x1a, AC_VERB_SET_PROC_COEF, 0x3040}, | |
4192 | {} | |
4193 | }; | |
4194 | ||
4195 | static struct hda_verb alc260_replacer_672v_verbs[] = { | |
4196 | {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, | |
4197 | {0x1a, AC_VERB_SET_COEF_INDEX, 0x07}, | |
4198 | {0x1a, AC_VERB_SET_PROC_COEF, 0x3050}, | |
4199 | ||
4200 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
4201 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
4202 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, | |
4203 | ||
4204 | {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
4205 | {} | |
4206 | }; | |
4207 | ||
4208 | /* toggle speaker-output according to the hp-jack state */ | |
4209 | static void alc260_replacer_672v_automute(struct hda_codec *codec) | |
4210 | { | |
4211 | unsigned int present; | |
4212 | ||
4213 | /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */ | |
4214 | present = snd_hda_codec_read(codec, 0x0f, 0, | |
4215 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
4216 | if (present) { | |
82beb8fd TI |
4217 | snd_hda_codec_write_cache(codec, 0x01, 0, |
4218 | AC_VERB_SET_GPIO_DATA, 1); | |
4219 | snd_hda_codec_write_cache(codec, 0x0f, 0, | |
4220 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4221 | PIN_HP); | |
bc9f98a9 | 4222 | } else { |
82beb8fd TI |
4223 | snd_hda_codec_write_cache(codec, 0x01, 0, |
4224 | AC_VERB_SET_GPIO_DATA, 0); | |
4225 | snd_hda_codec_write_cache(codec, 0x0f, 0, | |
4226 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4227 | PIN_OUT); | |
bc9f98a9 KY |
4228 | } |
4229 | } | |
4230 | ||
4231 | static void alc260_replacer_672v_unsol_event(struct hda_codec *codec, | |
4232 | unsigned int res) | |
4233 | { | |
4234 | if ((res >> 26) == ALC880_HP_EVENT) | |
4235 | alc260_replacer_672v_automute(codec); | |
4236 | } | |
4237 | ||
7cf51e48 JW |
4238 | /* Test configuration for debugging, modelled after the ALC880 test |
4239 | * configuration. | |
4240 | */ | |
4241 | #ifdef CONFIG_SND_DEBUG | |
4242 | static hda_nid_t alc260_test_dac_nids[1] = { | |
4243 | 0x02, | |
4244 | }; | |
4245 | static hda_nid_t alc260_test_adc_nids[2] = { | |
4246 | 0x04, 0x05, | |
4247 | }; | |
a1e8d2da JW |
4248 | /* For testing the ALC260, each input MUX needs its own definition since |
4249 | * the signal assignments are different. This assumes that the first ADC | |
4250 | * is NID 0x04. | |
17e7aec6 | 4251 | */ |
a1e8d2da JW |
4252 | static struct hda_input_mux alc260_test_capture_sources[2] = { |
4253 | { | |
4254 | .num_items = 7, | |
4255 | .items = { | |
4256 | { "MIC1 pin", 0x0 }, | |
4257 | { "MIC2 pin", 0x1 }, | |
4258 | { "LINE1 pin", 0x2 }, | |
4259 | { "LINE2 pin", 0x3 }, | |
4260 | { "CD pin", 0x4 }, | |
4261 | { "LINE-OUT pin", 0x5 }, | |
4262 | { "HP-OUT pin", 0x6 }, | |
4263 | }, | |
4264 | }, | |
4265 | { | |
4266 | .num_items = 8, | |
4267 | .items = { | |
4268 | { "MIC1 pin", 0x0 }, | |
4269 | { "MIC2 pin", 0x1 }, | |
4270 | { "LINE1 pin", 0x2 }, | |
4271 | { "LINE2 pin", 0x3 }, | |
4272 | { "CD pin", 0x4 }, | |
4273 | { "Mixer", 0x5 }, | |
4274 | { "LINE-OUT pin", 0x6 }, | |
4275 | { "HP-OUT pin", 0x7 }, | |
4276 | }, | |
7cf51e48 JW |
4277 | }, |
4278 | }; | |
4279 | static struct snd_kcontrol_new alc260_test_mixer[] = { | |
4280 | /* Output driver widgets */ | |
4281 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), | |
4282 | HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), | |
4283 | HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT), | |
4284 | HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT), | |
4285 | HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4286 | HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT), | |
4287 | ||
a1e8d2da JW |
4288 | /* Modes for retasking pin widgets |
4289 | * Note: the ALC260 doesn't seem to act on requests to enable mic | |
4290 | * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't | |
4291 | * mention this restriction. At this stage it's not clear whether | |
4292 | * this behaviour is intentional or is a hardware bug in chip | |
4293 | * revisions available at least up until early 2006. Therefore for | |
4294 | * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all | |
4295 | * choices, but if it turns out that the lack of mic bias for these | |
4296 | * NIDs is intentional we could change their modes from | |
4297 | * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
4298 | */ | |
7cf51e48 JW |
4299 | ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT), |
4300 | ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT), | |
4301 | ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT), | |
4302 | ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT), | |
4303 | ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT), | |
4304 | ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT), | |
4305 | ||
4306 | /* Loopback mixer controls */ | |
4307 | HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT), | |
4308 | HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT), | |
4309 | HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT), | |
4310 | HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT), | |
4311 | HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4312 | HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4313 | HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT), | |
4314 | HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT), | |
4315 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), | |
4316 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
4317 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), | |
4318 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
4319 | HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT), | |
4320 | HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT), | |
4321 | HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT), | |
4322 | HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT), | |
5c8f858d JW |
4323 | |
4324 | /* Controls for GPIO pins, assuming they are configured as outputs */ | |
4325 | ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01), | |
4326 | ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02), | |
4327 | ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04), | |
4328 | ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08), | |
4329 | ||
92621f13 JW |
4330 | /* Switches to allow the digital IO pins to be enabled. The datasheet |
4331 | * is ambigious as to which NID is which; testing on laptops which | |
4332 | * make this output available should provide clarification. | |
4333 | */ | |
4334 | ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01), | |
4335 | ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01), | |
4336 | ||
7cf51e48 JW |
4337 | { } /* end */ |
4338 | }; | |
4339 | static struct hda_verb alc260_test_init_verbs[] = { | |
5c8f858d JW |
4340 | /* Enable all GPIOs as outputs with an initial value of 0 */ |
4341 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f}, | |
4342 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, | |
4343 | {0x01, AC_VERB_SET_GPIO_MASK, 0x0f}, | |
4344 | ||
7cf51e48 JW |
4345 | /* Enable retasking pins as output, initially without power amp */ |
4346 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4347 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4348 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4349 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4350 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4351 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4352 | ||
92621f13 JW |
4353 | /* Disable digital (SPDIF) pins initially, but users can enable |
4354 | * them via a mixer switch. In the case of SPDIF-out, this initverb | |
4355 | * payload also sets the generation to 0, output to be in "consumer" | |
4356 | * PCM format, copyright asserted, no pre-emphasis and no validity | |
4357 | * control. | |
4358 | */ | |
7cf51e48 JW |
4359 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, |
4360 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
4361 | ||
f7ace40d | 4362 | /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the |
7cf51e48 JW |
4363 | * OUT1 sum bus when acting as an output. |
4364 | */ | |
4365 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, | |
4366 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0}, | |
4367 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
4368 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0}, | |
4369 | ||
4370 | /* Start with output sum widgets muted and their output gains at min */ | |
4371 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4372 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4373 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4374 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4375 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4376 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4377 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4378 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4379 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4380 | ||
cdcd9268 JW |
4381 | /* Unmute retasking pin widget output buffers since the default |
4382 | * state appears to be output. As the pin mode is changed by the | |
4383 | * user the pin mode control will take care of enabling the pin's | |
4384 | * input/output buffers as needed. | |
4385 | */ | |
7cf51e48 JW |
4386 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
4387 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4388 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4389 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4390 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4391 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4392 | /* Also unmute the mono-out pin widget */ | |
4393 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4394 | ||
7cf51e48 JW |
4395 | /* Mute capture amp left and right */ |
4396 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
f7ace40d JW |
4397 | /* Set ADC connection select to match default mixer setting (mic1 |
4398 | * pin) | |
7cf51e48 JW |
4399 | */ |
4400 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4401 | ||
4402 | /* Do the same for the second ADC: mute capture input amp and | |
f7ace40d | 4403 | * set ADC connection to mic1 pin |
7cf51e48 JW |
4404 | */ |
4405 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4406 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4407 | ||
4408 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
4409 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
4410 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
4411 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
4412 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
4413 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
4414 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
4415 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
4416 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
4417 | ||
4418 | { } | |
4419 | }; | |
4420 | #endif | |
4421 | ||
1da177e4 LT |
4422 | static struct hda_pcm_stream alc260_pcm_analog_playback = { |
4423 | .substreams = 1, | |
4424 | .channels_min = 2, | |
4425 | .channels_max = 2, | |
1da177e4 LT |
4426 | }; |
4427 | ||
4428 | static struct hda_pcm_stream alc260_pcm_analog_capture = { | |
4429 | .substreams = 1, | |
4430 | .channels_min = 2, | |
4431 | .channels_max = 2, | |
1da177e4 LT |
4432 | }; |
4433 | ||
a3bcba38 TI |
4434 | #define alc260_pcm_digital_playback alc880_pcm_digital_playback |
4435 | #define alc260_pcm_digital_capture alc880_pcm_digital_capture | |
4436 | ||
df694daa KY |
4437 | /* |
4438 | * for BIOS auto-configuration | |
4439 | */ | |
16ded525 | 4440 | |
df694daa KY |
4441 | static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid, |
4442 | const char *pfx) | |
4443 | { | |
4444 | hda_nid_t nid_vol; | |
4445 | unsigned long vol_val, sw_val; | |
4446 | char name[32]; | |
4447 | int err; | |
4448 | ||
4449 | if (nid >= 0x0f && nid < 0x11) { | |
4450 | nid_vol = nid - 0x7; | |
4451 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); | |
4452 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); | |
4453 | } else if (nid == 0x11) { | |
4454 | nid_vol = nid - 0x7; | |
4455 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT); | |
4456 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT); | |
4457 | } else if (nid >= 0x12 && nid <= 0x15) { | |
4458 | nid_vol = 0x08; | |
4459 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); | |
4460 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); | |
4461 | } else | |
4462 | return 0; /* N/A */ | |
4463 | ||
4464 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); | |
f12ab1e0 TI |
4465 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val); |
4466 | if (err < 0) | |
df694daa KY |
4467 | return err; |
4468 | snprintf(name, sizeof(name), "%s Playback Switch", pfx); | |
f12ab1e0 TI |
4469 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val); |
4470 | if (err < 0) | |
df694daa KY |
4471 | return err; |
4472 | return 1; | |
4473 | } | |
4474 | ||
4475 | /* add playback controls from the parsed DAC table */ | |
4476 | static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec, | |
4477 | const struct auto_pin_cfg *cfg) | |
4478 | { | |
4479 | hda_nid_t nid; | |
4480 | int err; | |
4481 | ||
4482 | spec->multiout.num_dacs = 1; | |
4483 | spec->multiout.dac_nids = spec->private_dac_nids; | |
4484 | spec->multiout.dac_nids[0] = 0x02; | |
4485 | ||
4486 | nid = cfg->line_out_pins[0]; | |
4487 | if (nid) { | |
4488 | err = alc260_add_playback_controls(spec, nid, "Front"); | |
4489 | if (err < 0) | |
4490 | return err; | |
4491 | } | |
4492 | ||
82bc955f | 4493 | nid = cfg->speaker_pins[0]; |
df694daa KY |
4494 | if (nid) { |
4495 | err = alc260_add_playback_controls(spec, nid, "Speaker"); | |
4496 | if (err < 0) | |
4497 | return err; | |
4498 | } | |
4499 | ||
eb06ed8f | 4500 | nid = cfg->hp_pins[0]; |
df694daa KY |
4501 | if (nid) { |
4502 | err = alc260_add_playback_controls(spec, nid, "Headphone"); | |
4503 | if (err < 0) | |
4504 | return err; | |
4505 | } | |
f12ab1e0 | 4506 | return 0; |
df694daa KY |
4507 | } |
4508 | ||
4509 | /* create playback/capture controls for input pins */ | |
4510 | static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec, | |
4511 | const struct auto_pin_cfg *cfg) | |
4512 | { | |
df694daa KY |
4513 | struct hda_input_mux *imux = &spec->private_imux; |
4514 | int i, err, idx; | |
4515 | ||
4516 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
4517 | if (cfg->input_pins[i] >= 0x12) { | |
4518 | idx = cfg->input_pins[i] - 0x12; | |
4a471b7d | 4519 | err = new_analog_input(spec, cfg->input_pins[i], |
f12ab1e0 TI |
4520 | auto_pin_cfg_labels[i], idx, |
4521 | 0x07); | |
df694daa KY |
4522 | if (err < 0) |
4523 | return err; | |
f12ab1e0 TI |
4524 | imux->items[imux->num_items].label = |
4525 | auto_pin_cfg_labels[i]; | |
df694daa KY |
4526 | imux->items[imux->num_items].index = idx; |
4527 | imux->num_items++; | |
4528 | } | |
f12ab1e0 | 4529 | if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){ |
df694daa | 4530 | idx = cfg->input_pins[i] - 0x09; |
4a471b7d | 4531 | err = new_analog_input(spec, cfg->input_pins[i], |
f12ab1e0 TI |
4532 | auto_pin_cfg_labels[i], idx, |
4533 | 0x07); | |
df694daa KY |
4534 | if (err < 0) |
4535 | return err; | |
f12ab1e0 TI |
4536 | imux->items[imux->num_items].label = |
4537 | auto_pin_cfg_labels[i]; | |
df694daa KY |
4538 | imux->items[imux->num_items].index = idx; |
4539 | imux->num_items++; | |
4540 | } | |
4541 | } | |
4542 | return 0; | |
4543 | } | |
4544 | ||
4545 | static void alc260_auto_set_output_and_unmute(struct hda_codec *codec, | |
4546 | hda_nid_t nid, int pin_type, | |
4547 | int sel_idx) | |
4548 | { | |
4549 | /* set as output */ | |
f12ab1e0 TI |
4550 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
4551 | pin_type); | |
4552 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
4553 | AMP_OUT_UNMUTE); | |
df694daa KY |
4554 | /* need the manual connection? */ |
4555 | if (nid >= 0x12) { | |
4556 | int idx = nid - 0x12; | |
4557 | snd_hda_codec_write(codec, idx + 0x0b, 0, | |
4558 | AC_VERB_SET_CONNECT_SEL, sel_idx); | |
df694daa KY |
4559 | } |
4560 | } | |
4561 | ||
4562 | static void alc260_auto_init_multi_out(struct hda_codec *codec) | |
4563 | { | |
4564 | struct alc_spec *spec = codec->spec; | |
4565 | hda_nid_t nid; | |
4566 | ||
bc9f98a9 | 4567 | alc_subsystem_id(codec, 0x10, 0x15, 0x0f); |
f12ab1e0 | 4568 | nid = spec->autocfg.line_out_pins[0]; |
baba8ee9 TI |
4569 | if (nid) { |
4570 | int pin_type = get_pin_type(spec->autocfg.line_out_type); | |
4571 | alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0); | |
4572 | } | |
df694daa | 4573 | |
82bc955f | 4574 | nid = spec->autocfg.speaker_pins[0]; |
df694daa KY |
4575 | if (nid) |
4576 | alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); | |
4577 | ||
eb06ed8f | 4578 | nid = spec->autocfg.hp_pins[0]; |
df694daa | 4579 | if (nid) |
baba8ee9 | 4580 | alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0); |
f12ab1e0 | 4581 | } |
df694daa KY |
4582 | |
4583 | #define ALC260_PIN_CD_NID 0x16 | |
4584 | static void alc260_auto_init_analog_input(struct hda_codec *codec) | |
4585 | { | |
4586 | struct alc_spec *spec = codec->spec; | |
4587 | int i; | |
4588 | ||
4589 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
4590 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
4591 | if (nid >= 0x12) { | |
f12ab1e0 TI |
4592 | snd_hda_codec_write(codec, nid, 0, |
4593 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4594 | i <= AUTO_PIN_FRONT_MIC ? | |
4595 | PIN_VREF80 : PIN_IN); | |
df694daa | 4596 | if (nid != ALC260_PIN_CD_NID) |
f12ab1e0 TI |
4597 | snd_hda_codec_write(codec, nid, 0, |
4598 | AC_VERB_SET_AMP_GAIN_MUTE, | |
df694daa KY |
4599 | AMP_OUT_MUTE); |
4600 | } | |
4601 | } | |
4602 | } | |
4603 | ||
4604 | /* | |
4605 | * generic initialization of ADC, input mixers and output mixers | |
4606 | */ | |
4607 | static struct hda_verb alc260_volume_init_verbs[] = { | |
4608 | /* | |
4609 | * Unmute ADC0-1 and set the default input to mic-in | |
4610 | */ | |
4611 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4612 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4613 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4614 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4615 | ||
4616 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | |
4617 | * mixer widget | |
f12ab1e0 TI |
4618 | * Note: PASD motherboards uses the Line In 2 as the input for |
4619 | * front panel mic (mic 2) | |
df694daa KY |
4620 | */ |
4621 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
4622 | /* mute analog inputs */ |
4623 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4624 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4625 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4626 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4627 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
4628 | |
4629 | /* | |
4630 | * Set up output mixers (0x08 - 0x0a) | |
4631 | */ | |
4632 | /* set vol=0 to output mixers */ | |
4633 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4634 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4635 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4636 | /* set up input amps for analog loopback */ | |
4637 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
4638 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4639 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4640 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4641 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4642 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4643 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4644 | ||
4645 | { } | |
4646 | }; | |
4647 | ||
4648 | static int alc260_parse_auto_config(struct hda_codec *codec) | |
4649 | { | |
4650 | struct alc_spec *spec = codec->spec; | |
4651 | unsigned int wcap; | |
4652 | int err; | |
4653 | static hda_nid_t alc260_ignore[] = { 0x17, 0 }; | |
4654 | ||
f12ab1e0 TI |
4655 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
4656 | alc260_ignore); | |
4657 | if (err < 0) | |
df694daa | 4658 | return err; |
f12ab1e0 TI |
4659 | err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg); |
4660 | if (err < 0) | |
4a471b7d | 4661 | return err; |
f12ab1e0 | 4662 | if (!spec->kctl_alloc) |
df694daa | 4663 | return 0; /* can't find valid BIOS pin config */ |
f12ab1e0 TI |
4664 | err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg); |
4665 | if (err < 0) | |
df694daa KY |
4666 | return err; |
4667 | ||
4668 | spec->multiout.max_channels = 2; | |
4669 | ||
4670 | if (spec->autocfg.dig_out_pin) | |
4671 | spec->multiout.dig_out_nid = ALC260_DIGOUT_NID; | |
4672 | if (spec->kctl_alloc) | |
4673 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
4674 | ||
4675 | spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs; | |
4676 | ||
a1e8d2da | 4677 | spec->num_mux_defs = 1; |
df694daa KY |
4678 | spec->input_mux = &spec->private_imux; |
4679 | ||
4680 | /* check whether NID 0x04 is valid */ | |
4a471b7d | 4681 | wcap = get_wcaps(codec, 0x04); |
df694daa KY |
4682 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ |
4683 | if (wcap != AC_WID_AUD_IN) { | |
4684 | spec->adc_nids = alc260_adc_nids_alt; | |
4685 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt); | |
4686 | spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer; | |
df694daa KY |
4687 | } else { |
4688 | spec->adc_nids = alc260_adc_nids; | |
4689 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); | |
4690 | spec->mixers[spec->num_mixers] = alc260_capture_mixer; | |
df694daa | 4691 | } |
4a471b7d | 4692 | spec->num_mixers++; |
df694daa KY |
4693 | |
4694 | return 1; | |
4695 | } | |
4696 | ||
ae6b813a TI |
4697 | /* additional initialization for auto-configuration model */ |
4698 | static void alc260_auto_init(struct hda_codec *codec) | |
df694daa | 4699 | { |
df694daa KY |
4700 | alc260_auto_init_multi_out(codec); |
4701 | alc260_auto_init_analog_input(codec); | |
df694daa KY |
4702 | } |
4703 | ||
cb53c626 TI |
4704 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
4705 | static struct hda_amp_list alc260_loopbacks[] = { | |
4706 | { 0x07, HDA_INPUT, 0 }, | |
4707 | { 0x07, HDA_INPUT, 1 }, | |
4708 | { 0x07, HDA_INPUT, 2 }, | |
4709 | { 0x07, HDA_INPUT, 3 }, | |
4710 | { 0x07, HDA_INPUT, 4 }, | |
4711 | { } /* end */ | |
4712 | }; | |
4713 | #endif | |
4714 | ||
df694daa KY |
4715 | /* |
4716 | * ALC260 configurations | |
4717 | */ | |
f5fcc13c TI |
4718 | static const char *alc260_models[ALC260_MODEL_LAST] = { |
4719 | [ALC260_BASIC] = "basic", | |
4720 | [ALC260_HP] = "hp", | |
4721 | [ALC260_HP_3013] = "hp-3013", | |
4722 | [ALC260_FUJITSU_S702X] = "fujitsu", | |
4723 | [ALC260_ACER] = "acer", | |
bc9f98a9 KY |
4724 | [ALC260_WILL] = "will", |
4725 | [ALC260_REPLACER_672V] = "replacer", | |
7cf51e48 | 4726 | #ifdef CONFIG_SND_DEBUG |
f5fcc13c | 4727 | [ALC260_TEST] = "test", |
7cf51e48 | 4728 | #endif |
f5fcc13c TI |
4729 | [ALC260_AUTO] = "auto", |
4730 | }; | |
4731 | ||
4732 | static struct snd_pci_quirk alc260_cfg_tbl[] = { | |
bd869485 | 4733 | SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER), |
f5fcc13c | 4734 | SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER), |
9720b718 | 4735 | SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013), |
a8a5d067 | 4736 | SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013), |
f5fcc13c TI |
4737 | SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013), |
4738 | SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP), | |
4739 | SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013), | |
4740 | SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013), | |
4741 | SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP), | |
4742 | SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP), | |
4743 | SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP), | |
4744 | SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC), | |
4745 | SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC), | |
4746 | SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC), | |
4747 | SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X), | |
4748 | SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC), | |
bc9f98a9 KY |
4749 | SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL), |
4750 | SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V), | |
df694daa KY |
4751 | {} |
4752 | }; | |
4753 | ||
4754 | static struct alc_config_preset alc260_presets[] = { | |
4755 | [ALC260_BASIC] = { | |
4756 | .mixers = { alc260_base_output_mixer, | |
4757 | alc260_input_mixer, | |
4758 | alc260_pc_beep_mixer, | |
4759 | alc260_capture_mixer }, | |
4760 | .init_verbs = { alc260_init_verbs }, | |
4761 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
4762 | .dac_nids = alc260_dac_nids, | |
4763 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), | |
4764 | .adc_nids = alc260_adc_nids, | |
4765 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
4766 | .channel_mode = alc260_modes, | |
4767 | .input_mux = &alc260_capture_source, | |
4768 | }, | |
4769 | [ALC260_HP] = { | |
4770 | .mixers = { alc260_base_output_mixer, | |
4771 | alc260_input_mixer, | |
4772 | alc260_capture_alt_mixer }, | |
474167d6 | 4773 | .init_verbs = { alc260_init_verbs }, |
df694daa KY |
4774 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), |
4775 | .dac_nids = alc260_dac_nids, | |
4776 | .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), | |
4777 | .adc_nids = alc260_hp_adc_nids, | |
4778 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
4779 | .channel_mode = alc260_modes, | |
4780 | .input_mux = &alc260_capture_source, | |
4781 | }, | |
4782 | [ALC260_HP_3013] = { | |
4783 | .mixers = { alc260_hp_3013_mixer, | |
4784 | alc260_input_mixer, | |
4785 | alc260_capture_alt_mixer }, | |
4786 | .init_verbs = { alc260_hp_3013_init_verbs }, | |
4787 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
4788 | .dac_nids = alc260_dac_nids, | |
4789 | .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), | |
4790 | .adc_nids = alc260_hp_adc_nids, | |
4791 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
4792 | .channel_mode = alc260_modes, | |
4793 | .input_mux = &alc260_capture_source, | |
4794 | }, | |
4795 | [ALC260_FUJITSU_S702X] = { | |
4796 | .mixers = { alc260_fujitsu_mixer, | |
4797 | alc260_capture_mixer }, | |
4798 | .init_verbs = { alc260_fujitsu_init_verbs }, | |
4799 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
4800 | .dac_nids = alc260_dac_nids, | |
d57fdac0 JW |
4801 | .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), |
4802 | .adc_nids = alc260_dual_adc_nids, | |
df694daa KY |
4803 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
4804 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
4805 | .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources), |
4806 | .input_mux = alc260_fujitsu_capture_sources, | |
df694daa | 4807 | }, |
0bfc90e9 JW |
4808 | [ALC260_ACER] = { |
4809 | .mixers = { alc260_acer_mixer, | |
4810 | alc260_capture_mixer }, | |
4811 | .init_verbs = { alc260_acer_init_verbs }, | |
4812 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
4813 | .dac_nids = alc260_dac_nids, | |
4814 | .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), | |
4815 | .adc_nids = alc260_dual_adc_nids, | |
4816 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
4817 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
4818 | .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources), |
4819 | .input_mux = alc260_acer_capture_sources, | |
0bfc90e9 | 4820 | }, |
bc9f98a9 KY |
4821 | [ALC260_WILL] = { |
4822 | .mixers = { alc260_will_mixer, | |
4823 | alc260_capture_mixer }, | |
4824 | .init_verbs = { alc260_init_verbs, alc260_will_verbs }, | |
4825 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
4826 | .dac_nids = alc260_dac_nids, | |
4827 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), | |
4828 | .adc_nids = alc260_adc_nids, | |
4829 | .dig_out_nid = ALC260_DIGOUT_NID, | |
4830 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
4831 | .channel_mode = alc260_modes, | |
4832 | .input_mux = &alc260_capture_source, | |
4833 | }, | |
4834 | [ALC260_REPLACER_672V] = { | |
4835 | .mixers = { alc260_replacer_672v_mixer, | |
4836 | alc260_capture_mixer }, | |
4837 | .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs }, | |
4838 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
4839 | .dac_nids = alc260_dac_nids, | |
4840 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), | |
4841 | .adc_nids = alc260_adc_nids, | |
4842 | .dig_out_nid = ALC260_DIGOUT_NID, | |
4843 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
4844 | .channel_mode = alc260_modes, | |
4845 | .input_mux = &alc260_capture_source, | |
4846 | .unsol_event = alc260_replacer_672v_unsol_event, | |
4847 | .init_hook = alc260_replacer_672v_automute, | |
4848 | }, | |
7cf51e48 JW |
4849 | #ifdef CONFIG_SND_DEBUG |
4850 | [ALC260_TEST] = { | |
4851 | .mixers = { alc260_test_mixer, | |
4852 | alc260_capture_mixer }, | |
4853 | .init_verbs = { alc260_test_init_verbs }, | |
4854 | .num_dacs = ARRAY_SIZE(alc260_test_dac_nids), | |
4855 | .dac_nids = alc260_test_dac_nids, | |
4856 | .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids), | |
4857 | .adc_nids = alc260_test_adc_nids, | |
4858 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
4859 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
4860 | .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources), |
4861 | .input_mux = alc260_test_capture_sources, | |
7cf51e48 JW |
4862 | }, |
4863 | #endif | |
df694daa KY |
4864 | }; |
4865 | ||
4866 | static int patch_alc260(struct hda_codec *codec) | |
1da177e4 LT |
4867 | { |
4868 | struct alc_spec *spec; | |
df694daa | 4869 | int err, board_config; |
1da177e4 | 4870 | |
e560d8d8 | 4871 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
1da177e4 LT |
4872 | if (spec == NULL) |
4873 | return -ENOMEM; | |
4874 | ||
4875 | codec->spec = spec; | |
4876 | ||
f5fcc13c TI |
4877 | board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST, |
4878 | alc260_models, | |
4879 | alc260_cfg_tbl); | |
4880 | if (board_config < 0) { | |
9c7f852e TI |
4881 | snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, " |
4882 | "trying auto-probe from BIOS...\n"); | |
df694daa | 4883 | board_config = ALC260_AUTO; |
16ded525 | 4884 | } |
1da177e4 | 4885 | |
df694daa KY |
4886 | if (board_config == ALC260_AUTO) { |
4887 | /* automatic parse from the BIOS config */ | |
4888 | err = alc260_parse_auto_config(codec); | |
4889 | if (err < 0) { | |
4890 | alc_free(codec); | |
4891 | return err; | |
f12ab1e0 | 4892 | } else if (!err) { |
9c7f852e TI |
4893 | printk(KERN_INFO |
4894 | "hda_codec: Cannot set up configuration " | |
4895 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
4896 | board_config = ALC260_BASIC; |
4897 | } | |
a9430dd8 | 4898 | } |
e9edcee0 | 4899 | |
df694daa KY |
4900 | if (board_config != ALC260_AUTO) |
4901 | setup_preset(spec, &alc260_presets[board_config]); | |
1da177e4 LT |
4902 | |
4903 | spec->stream_name_analog = "ALC260 Analog"; | |
4904 | spec->stream_analog_playback = &alc260_pcm_analog_playback; | |
4905 | spec->stream_analog_capture = &alc260_pcm_analog_capture; | |
4906 | ||
a3bcba38 TI |
4907 | spec->stream_name_digital = "ALC260 Digital"; |
4908 | spec->stream_digital_playback = &alc260_pcm_digital_playback; | |
4909 | spec->stream_digital_capture = &alc260_pcm_digital_capture; | |
4910 | ||
1da177e4 | 4911 | codec->patch_ops = alc_patch_ops; |
df694daa | 4912 | if (board_config == ALC260_AUTO) |
ae6b813a | 4913 | spec->init_hook = alc260_auto_init; |
cb53c626 TI |
4914 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
4915 | if (!spec->loopback.amplist) | |
4916 | spec->loopback.amplist = alc260_loopbacks; | |
4917 | #endif | |
1da177e4 LT |
4918 | |
4919 | return 0; | |
4920 | } | |
4921 | ||
e9edcee0 | 4922 | |
1da177e4 LT |
4923 | /* |
4924 | * ALC882 support | |
4925 | * | |
4926 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible | |
4927 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
4928 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
4929 | * 6-channel independent captures. | |
4930 | * | |
4931 | * In addition, an independent DAC for the multi-playback (not used in this | |
4932 | * driver yet). | |
4933 | */ | |
df694daa KY |
4934 | #define ALC882_DIGOUT_NID 0x06 |
4935 | #define ALC882_DIGIN_NID 0x0a | |
1da177e4 | 4936 | |
d2a6d7dc | 4937 | static struct hda_channel_mode alc882_ch_modes[1] = { |
1da177e4 LT |
4938 | { 8, NULL } |
4939 | }; | |
4940 | ||
4941 | static hda_nid_t alc882_dac_nids[4] = { | |
4942 | /* front, rear, clfe, rear_surr */ | |
4943 | 0x02, 0x03, 0x04, 0x05 | |
4944 | }; | |
4945 | ||
df694daa KY |
4946 | /* identical with ALC880 */ |
4947 | #define alc882_adc_nids alc880_adc_nids | |
4948 | #define alc882_adc_nids_alt alc880_adc_nids_alt | |
1da177e4 LT |
4949 | |
4950 | /* input MUX */ | |
4951 | /* FIXME: should be a matrix-type input source selection */ | |
4952 | ||
4953 | static struct hda_input_mux alc882_capture_source = { | |
4954 | .num_items = 4, | |
4955 | .items = { | |
4956 | { "Mic", 0x0 }, | |
4957 | { "Front Mic", 0x1 }, | |
4958 | { "Line", 0x2 }, | |
4959 | { "CD", 0x4 }, | |
4960 | }, | |
4961 | }; | |
1da177e4 LT |
4962 | #define alc882_mux_enum_info alc_mux_enum_info |
4963 | #define alc882_mux_enum_get alc_mux_enum_get | |
4964 | ||
f12ab1e0 TI |
4965 | static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, |
4966 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
4967 | { |
4968 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
4969 | struct alc_spec *spec = codec->spec; | |
4970 | const struct hda_input_mux *imux = spec->input_mux; | |
4971 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
4972 | static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 }; | |
4973 | hda_nid_t nid = capture_mixers[adc_idx]; | |
4974 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; | |
4975 | unsigned int i, idx; | |
4976 | ||
4977 | idx = ucontrol->value.enumerated.item[0]; | |
4978 | if (idx >= imux->num_items) | |
4979 | idx = imux->num_items - 1; | |
82beb8fd | 4980 | if (*cur_val == idx) |
1da177e4 LT |
4981 | return 0; |
4982 | for (i = 0; i < imux->num_items; i++) { | |
47fd830a TI |
4983 | unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE; |
4984 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, | |
82beb8fd | 4985 | imux->items[i].index, |
47fd830a | 4986 | HDA_AMP_MUTE, v); |
1da177e4 LT |
4987 | } |
4988 | *cur_val = idx; | |
4989 | return 1; | |
4990 | } | |
4991 | ||
272a527c KY |
4992 | /* |
4993 | * 2ch mode | |
4994 | */ | |
4995 | static struct hda_verb alc882_3ST_ch2_init[] = { | |
4996 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
4997 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
4998 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
4999 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
5000 | { } /* end */ | |
5001 | }; | |
5002 | ||
5003 | /* | |
5004 | * 6ch mode | |
5005 | */ | |
5006 | static struct hda_verb alc882_3ST_ch6_init[] = { | |
5007 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5008 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
5009 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
5010 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5011 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
5012 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
5013 | { } /* end */ | |
5014 | }; | |
5015 | ||
5016 | static struct hda_channel_mode alc882_3ST_6ch_modes[2] = { | |
5017 | { 2, alc882_3ST_ch2_init }, | |
5018 | { 6, alc882_3ST_ch6_init }, | |
5019 | }; | |
5020 | ||
df694daa KY |
5021 | /* |
5022 | * 6ch mode | |
5023 | */ | |
5024 | static struct hda_verb alc882_sixstack_ch6_init[] = { | |
5025 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
5026 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5027 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5028 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5029 | { } /* end */ | |
5030 | }; | |
5031 | ||
5032 | /* | |
5033 | * 8ch mode | |
5034 | */ | |
5035 | static struct hda_verb alc882_sixstack_ch8_init[] = { | |
5036 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5037 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5038 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5039 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5040 | { } /* end */ | |
5041 | }; | |
5042 | ||
5043 | static struct hda_channel_mode alc882_sixstack_modes[2] = { | |
5044 | { 6, alc882_sixstack_ch6_init }, | |
5045 | { 8, alc882_sixstack_ch8_init }, | |
5046 | }; | |
5047 | ||
87350ad0 TI |
5048 | /* |
5049 | * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic | |
5050 | */ | |
5051 | ||
5052 | /* | |
5053 | * 2ch mode | |
5054 | */ | |
5055 | static struct hda_verb alc885_mbp_ch2_init[] = { | |
5056 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
5057 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5058 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5059 | { } /* end */ | |
5060 | }; | |
5061 | ||
5062 | /* | |
5063 | * 6ch mode | |
5064 | */ | |
5065 | static struct hda_verb alc885_mbp_ch6_init[] = { | |
5066 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5067 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5068 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
5069 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5070 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5071 | { } /* end */ | |
5072 | }; | |
5073 | ||
5074 | static struct hda_channel_mode alc885_mbp_6ch_modes[2] = { | |
5075 | { 2, alc885_mbp_ch2_init }, | |
5076 | { 6, alc885_mbp_ch6_init }, | |
5077 | }; | |
5078 | ||
5079 | ||
1da177e4 LT |
5080 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
5081 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
5082 | */ | |
c8b6bf9b | 5083 | static struct snd_kcontrol_new alc882_base_mixer[] = { |
05acb863 | 5084 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 5085 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
05acb863 | 5086 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 5087 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
05acb863 TI |
5088 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
5089 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
5090 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
5091 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
05acb863 | 5092 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 5093 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
1da177e4 LT |
5094 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
5095 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5096 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5097 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5098 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5099 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 5100 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
1da177e4 LT |
5101 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
5102 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 5103 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
1da177e4 LT |
5104 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
5105 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
5106 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
1da177e4 LT |
5107 | { } /* end */ |
5108 | }; | |
5109 | ||
87350ad0 TI |
5110 | static struct snd_kcontrol_new alc885_mbp3_mixer[] = { |
5111 | HDA_CODEC_VOLUME("Master Volume", 0x0c, 0x00, HDA_OUTPUT), | |
5112 | HDA_BIND_MUTE ("Master Switch", 0x0c, 0x02, HDA_INPUT), | |
5113 | HDA_CODEC_MUTE ("Speaker Switch", 0x14, 0x00, HDA_OUTPUT), | |
5114 | HDA_CODEC_VOLUME("Line Out Volume", 0x0d,0x00, HDA_OUTPUT), | |
5115 | HDA_CODEC_VOLUME("Line In Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5116 | HDA_CODEC_MUTE ("Line In Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5117 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT), | |
5118 | HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT), | |
5119 | HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0x00, HDA_INPUT), | |
5120 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT), | |
5121 | { } /* end */ | |
5122 | }; | |
bdd148a3 KY |
5123 | static struct snd_kcontrol_new alc882_w2jc_mixer[] = { |
5124 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5125 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
5126 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5127 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5128 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5129 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5130 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
5131 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
5132 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
5133 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
5134 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
5135 | { } /* end */ | |
5136 | }; | |
5137 | ||
272a527c KY |
5138 | static struct snd_kcontrol_new alc882_targa_mixer[] = { |
5139 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5140 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
5141 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
5142 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5143 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5144 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5145 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5146 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
5147 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
96fe7cc8 | 5148 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
272a527c KY |
5149 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
5150 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
96fe7cc8 | 5151 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
272a527c KY |
5152 | { } /* end */ |
5153 | }; | |
5154 | ||
5155 | /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ??? | |
5156 | * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c | |
5157 | */ | |
5158 | static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = { | |
5159 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5160 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
5161 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
5162 | HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT), | |
5163 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5164 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5165 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5166 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5167 | HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT), | |
5168 | HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT), | |
5169 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
5170 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
96fe7cc8 | 5171 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
272a527c KY |
5172 | { } /* end */ |
5173 | }; | |
5174 | ||
914759b7 TI |
5175 | static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = { |
5176 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5177 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
5178 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
5179 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5180 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5181 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5182 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5183 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
5184 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
5185 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
5186 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
5187 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
5188 | { } /* end */ | |
5189 | }; | |
5190 | ||
df694daa KY |
5191 | static struct snd_kcontrol_new alc882_chmode_mixer[] = { |
5192 | { | |
5193 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5194 | .name = "Channel Mode", | |
5195 | .info = alc_ch_mode_info, | |
5196 | .get = alc_ch_mode_get, | |
5197 | .put = alc_ch_mode_put, | |
5198 | }, | |
5199 | { } /* end */ | |
5200 | }; | |
5201 | ||
1da177e4 LT |
5202 | static struct hda_verb alc882_init_verbs[] = { |
5203 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
05acb863 TI |
5204 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
5205 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5206 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 5207 | /* Rear mixer */ |
05acb863 TI |
5208 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
5209 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5210 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 5211 | /* CLFE mixer */ |
05acb863 TI |
5212 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
5213 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5214 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 5215 | /* Side mixer */ |
05acb863 TI |
5216 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
5217 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5218 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 5219 | |
e9edcee0 | 5220 | /* Front Pin: output 0 (0x0c) */ |
05acb863 | 5221 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 5222 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 5223 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 5224 | /* Rear Pin: output 1 (0x0d) */ |
05acb863 | 5225 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 5226 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 5227 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, |
e9edcee0 | 5228 | /* CLFE Pin: output 2 (0x0e) */ |
05acb863 | 5229 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 5230 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 5231 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, |
e9edcee0 | 5232 | /* Side Pin: output 3 (0x0f) */ |
05acb863 | 5233 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 5234 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 5235 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, |
e9edcee0 | 5236 | /* Mic (rear) pin: input vref at 80% */ |
16ded525 | 5237 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 TI |
5238 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
5239 | /* Front Mic pin: input vref at 80% */ | |
16ded525 | 5240 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 TI |
5241 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
5242 | /* Line In pin: input */ | |
05acb863 | 5243 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 TI |
5244 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
5245 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
5246 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5247 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5248 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1da177e4 | 5249 | /* CD pin widget for input */ |
05acb863 | 5250 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 LT |
5251 | |
5252 | /* FIXME: use matrix-type input source selection */ | |
5253 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
5254 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
05acb863 TI |
5255 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
5256 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5257 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5258 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 5259 | /* Input mixer2 */ |
05acb863 TI |
5260 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
5261 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5262 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5263 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 5264 | /* Input mixer3 */ |
05acb863 TI |
5265 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
5266 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5267 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5268 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5269 | /* ADC1: mute amp left and right */ | |
5270 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 5271 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
5272 | /* ADC2: mute amp left and right */ |
5273 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 5274 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
5275 | /* ADC3: mute amp left and right */ |
5276 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 5277 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
1da177e4 LT |
5278 | |
5279 | { } | |
5280 | }; | |
5281 | ||
4b146cb0 TI |
5282 | static struct hda_verb alc882_eapd_verbs[] = { |
5283 | /* change to EAPD mode */ | |
5284 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
b373bdeb | 5285 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, |
f12ab1e0 | 5286 | { } |
4b146cb0 TI |
5287 | }; |
5288 | ||
9102cd1c TD |
5289 | /* Mac Pro test */ |
5290 | static struct snd_kcontrol_new alc882_macpro_mixer[] = { | |
5291 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5292 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
5293 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT), | |
5294 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
5295 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
5296 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5297 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5298 | { } /* end */ | |
5299 | }; | |
5300 | ||
5301 | static struct hda_verb alc882_macpro_init_verbs[] = { | |
5302 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
5303 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5304 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5305 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5306 | /* Front Pin: output 0 (0x0c) */ | |
5307 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5308 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5309 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5310 | /* Front Mic pin: input vref at 80% */ | |
5311 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
5312 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5313 | /* Speaker: output */ | |
5314 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5315 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5316 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04}, | |
5317 | /* Headphone output (output 0 - 0x0c) */ | |
5318 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5319 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5320 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5321 | ||
5322 | /* FIXME: use matrix-type input source selection */ | |
5323 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
5324 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
5325 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5326 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5327 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5328 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5329 | /* Input mixer2 */ | |
5330 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5331 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5332 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5333 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5334 | /* Input mixer3 */ | |
5335 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5336 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5337 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5338 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5339 | /* ADC1: mute amp left and right */ | |
5340 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5341 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5342 | /* ADC2: mute amp left and right */ | |
5343 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5344 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5345 | /* ADC3: mute amp left and right */ | |
5346 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5347 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5348 | ||
5349 | { } | |
5350 | }; | |
f12ab1e0 | 5351 | |
87350ad0 TI |
5352 | /* Macbook Pro rev3 */ |
5353 | static struct hda_verb alc885_mbp3_init_verbs[] = { | |
5354 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
5355 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5356 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5357 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5358 | /* Rear mixer */ | |
5359 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5360 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5361 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5362 | /* Front Pin: output 0 (0x0c) */ | |
5363 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5364 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5365 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5366 | /* HP Pin: output 0 (0x0d) */ | |
5367 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, | |
5368 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5369 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5370 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
5371 | /* Mic (rear) pin: input vref at 80% */ | |
5372 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
5373 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5374 | /* Front Mic pin: input vref at 80% */ | |
5375 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
5376 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5377 | /* Line In pin: use output 1 when in LineOut mode */ | |
5378 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
5379 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5380 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
5381 | ||
5382 | /* FIXME: use matrix-type input source selection */ | |
5383 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
5384 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
5385 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5386 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5387 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5388 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5389 | /* Input mixer2 */ | |
5390 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5391 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5392 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5393 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5394 | /* Input mixer3 */ | |
5395 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5396 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5397 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5398 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5399 | /* ADC1: mute amp left and right */ | |
5400 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5401 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5402 | /* ADC2: mute amp left and right */ | |
5403 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5404 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5405 | /* ADC3: mute amp left and right */ | |
5406 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5407 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5408 | ||
5409 | { } | |
5410 | }; | |
5411 | ||
c54728d8 NF |
5412 | /* iMac 24 mixer. */ |
5413 | static struct snd_kcontrol_new alc885_imac24_mixer[] = { | |
5414 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT), | |
5415 | HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT), | |
5416 | { } /* end */ | |
5417 | }; | |
5418 | ||
5419 | /* iMac 24 init verbs. */ | |
5420 | static struct hda_verb alc885_imac24_init_verbs[] = { | |
5421 | /* Internal speakers: output 0 (0x0c) */ | |
5422 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5423 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5424 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5425 | /* Internal speakers: output 0 (0x0c) */ | |
5426 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5427 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5428 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5429 | /* Headphone: output 0 (0x0c) */ | |
5430 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5431 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5432 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5433 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
5434 | /* Front Mic: input vref at 80% */ | |
5435 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
5436 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5437 | { } | |
5438 | }; | |
5439 | ||
5440 | /* Toggle speaker-output according to the hp-jack state */ | |
5441 | static void alc885_imac24_automute(struct hda_codec *codec) | |
5442 | { | |
5443 | unsigned int present; | |
5444 | ||
5445 | present = snd_hda_codec_read(codec, 0x14, 0, | |
5446 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
5447 | snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0, |
5448 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
5449 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, | |
5450 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
c54728d8 NF |
5451 | } |
5452 | ||
5453 | /* Processes unsolicited events. */ | |
5454 | static void alc885_imac24_unsol_event(struct hda_codec *codec, | |
5455 | unsigned int res) | |
5456 | { | |
5457 | /* Headphone insertion or removal. */ | |
5458 | if ((res >> 26) == ALC880_HP_EVENT) | |
5459 | alc885_imac24_automute(codec); | |
5460 | } | |
5461 | ||
87350ad0 TI |
5462 | static void alc885_mbp3_automute(struct hda_codec *codec) |
5463 | { | |
5464 | unsigned int present; | |
5465 | ||
5466 | present = snd_hda_codec_read(codec, 0x15, 0, | |
5467 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
5468 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
5469 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
5470 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
5471 | HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE); | |
5472 | ||
5473 | } | |
5474 | static void alc885_mbp3_unsol_event(struct hda_codec *codec, | |
5475 | unsigned int res) | |
5476 | { | |
5477 | /* Headphone insertion or removal. */ | |
5478 | if ((res >> 26) == ALC880_HP_EVENT) | |
5479 | alc885_mbp3_automute(codec); | |
5480 | } | |
5481 | ||
5482 | ||
272a527c KY |
5483 | static struct hda_verb alc882_targa_verbs[] = { |
5484 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5485 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5486 | ||
5487 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5488 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5489 | ||
5490 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
5491 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
5492 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
5493 | ||
5494 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
5495 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, | |
5496 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | |
5497 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | |
5498 | { } /* end */ | |
5499 | }; | |
5500 | ||
5501 | /* toggle speaker-output according to the hp-jack state */ | |
5502 | static void alc882_targa_automute(struct hda_codec *codec) | |
5503 | { | |
5504 | unsigned int present; | |
5505 | ||
5506 | present = snd_hda_codec_read(codec, 0x14, 0, | |
5507 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
5508 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, |
5509 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
82beb8fd TI |
5510 | snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA, |
5511 | present ? 1 : 3); | |
272a527c KY |
5512 | } |
5513 | ||
5514 | static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res) | |
5515 | { | |
5516 | /* Looks like the unsol event is incompatible with the standard | |
5517 | * definition. 4bit tag is placed at 26 bit! | |
5518 | */ | |
5519 | if (((res >> 26) == ALC880_HP_EVENT)) { | |
5520 | alc882_targa_automute(codec); | |
5521 | } | |
5522 | } | |
5523 | ||
5524 | static struct hda_verb alc882_asus_a7j_verbs[] = { | |
5525 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5526 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5527 | ||
5528 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5529 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5530 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5531 | ||
5532 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ | |
5533 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
5534 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ | |
5535 | ||
5536 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
5537 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
5538 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
5539 | { } /* end */ | |
5540 | }; | |
5541 | ||
914759b7 TI |
5542 | static struct hda_verb alc882_asus_a7m_verbs[] = { |
5543 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5544 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5545 | ||
5546 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5547 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5548 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5549 | ||
5550 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ | |
5551 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
5552 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ | |
5553 | ||
5554 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
5555 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
5556 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
5557 | { } /* end */ | |
5558 | }; | |
5559 | ||
9102cd1c TD |
5560 | static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) |
5561 | { | |
5562 | unsigned int gpiostate, gpiomask, gpiodir; | |
5563 | ||
5564 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, | |
5565 | AC_VERB_GET_GPIO_DATA, 0); | |
5566 | ||
5567 | if (!muted) | |
5568 | gpiostate |= (1 << pin); | |
5569 | else | |
5570 | gpiostate &= ~(1 << pin); | |
5571 | ||
5572 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, | |
5573 | AC_VERB_GET_GPIO_MASK, 0); | |
5574 | gpiomask |= (1 << pin); | |
5575 | ||
5576 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, | |
5577 | AC_VERB_GET_GPIO_DIRECTION, 0); | |
5578 | gpiodir |= (1 << pin); | |
5579 | ||
5580 | ||
5581 | snd_hda_codec_write(codec, codec->afg, 0, | |
5582 | AC_VERB_SET_GPIO_MASK, gpiomask); | |
5583 | snd_hda_codec_write(codec, codec->afg, 0, | |
5584 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); | |
5585 | ||
5586 | msleep(1); | |
5587 | ||
5588 | snd_hda_codec_write(codec, codec->afg, 0, | |
5589 | AC_VERB_SET_GPIO_DATA, gpiostate); | |
5590 | } | |
5591 | ||
7debbe51 TI |
5592 | /* set up GPIO at initialization */ |
5593 | static void alc885_macpro_init_hook(struct hda_codec *codec) | |
5594 | { | |
5595 | alc882_gpio_mute(codec, 0, 0); | |
5596 | alc882_gpio_mute(codec, 1, 0); | |
5597 | } | |
5598 | ||
5599 | /* set up GPIO and update auto-muting at initialization */ | |
5600 | static void alc885_imac24_init_hook(struct hda_codec *codec) | |
5601 | { | |
5602 | alc885_macpro_init_hook(codec); | |
5603 | alc885_imac24_automute(codec); | |
5604 | } | |
5605 | ||
df694daa KY |
5606 | /* |
5607 | * generic initialization of ADC, input mixers and output mixers | |
5608 | */ | |
5609 | static struct hda_verb alc882_auto_init_verbs[] = { | |
5610 | /* | |
5611 | * Unmute ADC0-2 and set the default input to mic-in | |
5612 | */ | |
5613 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5614 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5615 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5616 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5617 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5618 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
1da177e4 | 5619 | |
cb53c626 | 5620 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
df694daa | 5621 | * mixer widget |
f12ab1e0 TI |
5622 | * Note: PASD motherboards uses the Line In 2 as the input for |
5623 | * front panel mic (mic 2) | |
df694daa KY |
5624 | */ |
5625 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
5626 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
5627 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5628 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5629 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5630 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
e9edcee0 | 5631 | |
df694daa KY |
5632 | /* |
5633 | * Set up output mixers (0x0c - 0x0f) | |
5634 | */ | |
5635 | /* set vol=0 to output mixers */ | |
5636 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5637 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5638 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5639 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5640 | /* set up input amps for analog loopback */ | |
5641 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
5642 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5643 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5644 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5645 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5646 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5647 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5648 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5649 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5650 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5651 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5652 | ||
5653 | /* FIXME: use matrix-type input source selection */ | |
5654 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
5655 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
5656 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
5657 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
5658 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
5659 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
5660 | /* Input mixer2 */ | |
5661 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
5662 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
5663 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
5664 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
5665 | /* Input mixer3 */ | |
5666 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
5667 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
5668 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
5669 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
5670 | ||
5671 | { } | |
5672 | }; | |
5673 | ||
5674 | /* capture mixer elements */ | |
5675 | static struct snd_kcontrol_new alc882_capture_alt_mixer[] = { | |
5676 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
5677 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
5678 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
5679 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
5680 | { | |
5681 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5682 | /* The multiple "Capture Source" controls confuse alsamixer | |
5683 | * So call somewhat different.. | |
5684 | * FIXME: the controls appear in the "playback" view! | |
5685 | */ | |
5686 | /* .name = "Capture Source", */ | |
5687 | .name = "Input Source", | |
5688 | .count = 2, | |
5689 | .info = alc882_mux_enum_info, | |
5690 | .get = alc882_mux_enum_get, | |
5691 | .put = alc882_mux_enum_put, | |
5692 | }, | |
5693 | { } /* end */ | |
5694 | }; | |
5695 | ||
5696 | static struct snd_kcontrol_new alc882_capture_mixer[] = { | |
5697 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), | |
5698 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), | |
5699 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), | |
5700 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), | |
5701 | HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), | |
5702 | HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), | |
5703 | { | |
5704 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5705 | /* The multiple "Capture Source" controls confuse alsamixer | |
5706 | * So call somewhat different.. | |
5707 | * FIXME: the controls appear in the "playback" view! | |
5708 | */ | |
5709 | /* .name = "Capture Source", */ | |
5710 | .name = "Input Source", | |
5711 | .count = 3, | |
5712 | .info = alc882_mux_enum_info, | |
5713 | .get = alc882_mux_enum_get, | |
5714 | .put = alc882_mux_enum_put, | |
5715 | }, | |
5716 | { } /* end */ | |
5717 | }; | |
5718 | ||
cb53c626 TI |
5719 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
5720 | #define alc882_loopbacks alc880_loopbacks | |
5721 | #endif | |
5722 | ||
df694daa KY |
5723 | /* pcm configuration: identiacal with ALC880 */ |
5724 | #define alc882_pcm_analog_playback alc880_pcm_analog_playback | |
5725 | #define alc882_pcm_analog_capture alc880_pcm_analog_capture | |
5726 | #define alc882_pcm_digital_playback alc880_pcm_digital_playback | |
5727 | #define alc882_pcm_digital_capture alc880_pcm_digital_capture | |
5728 | ||
5729 | /* | |
5730 | * configuration and preset | |
5731 | */ | |
f5fcc13c TI |
5732 | static const char *alc882_models[ALC882_MODEL_LAST] = { |
5733 | [ALC882_3ST_DIG] = "3stack-dig", | |
5734 | [ALC882_6ST_DIG] = "6stack-dig", | |
5735 | [ALC882_ARIMA] = "arima", | |
bdd148a3 | 5736 | [ALC882_W2JC] = "w2jc", |
0438a00e TI |
5737 | [ALC882_TARGA] = "targa", |
5738 | [ALC882_ASUS_A7J] = "asus-a7j", | |
5739 | [ALC882_ASUS_A7M] = "asus-a7m", | |
9102cd1c | 5740 | [ALC885_MACPRO] = "macpro", |
87350ad0 | 5741 | [ALC885_MBP3] = "mbp3", |
c54728d8 | 5742 | [ALC885_IMAC24] = "imac24", |
f5fcc13c TI |
5743 | [ALC882_AUTO] = "auto", |
5744 | }; | |
5745 | ||
5746 | static struct snd_pci_quirk alc882_cfg_tbl[] = { | |
5747 | SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG), | |
5748 | SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG), | |
5749 | SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG), | |
272a527c | 5750 | SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */ |
f5fcc13c | 5751 | SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), |
272a527c | 5752 | SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J), |
ac8842a0 | 5753 | SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J), |
914759b7 | 5754 | SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M), |
c5d9f1cd | 5755 | SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG), |
7b9470d8 | 5756 | SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG), |
bdd148a3 | 5757 | SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC), |
df694daa KY |
5758 | {} |
5759 | }; | |
5760 | ||
5761 | static struct alc_config_preset alc882_presets[] = { | |
5762 | [ALC882_3ST_DIG] = { | |
5763 | .mixers = { alc882_base_mixer }, | |
5764 | .init_verbs = { alc882_init_verbs }, | |
5765 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
5766 | .dac_nids = alc882_dac_nids, | |
5767 | .dig_out_nid = ALC882_DIGOUT_NID, | |
df694daa KY |
5768 | .dig_in_nid = ALC882_DIGIN_NID, |
5769 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | |
5770 | .channel_mode = alc882_ch_modes, | |
4e195a7b | 5771 | .need_dac_fix = 1, |
df694daa KY |
5772 | .input_mux = &alc882_capture_source, |
5773 | }, | |
5774 | [ALC882_6ST_DIG] = { | |
5775 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, | |
5776 | .init_verbs = { alc882_init_verbs }, | |
5777 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
5778 | .dac_nids = alc882_dac_nids, | |
5779 | .dig_out_nid = ALC882_DIGOUT_NID, | |
df694daa KY |
5780 | .dig_in_nid = ALC882_DIGIN_NID, |
5781 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), | |
5782 | .channel_mode = alc882_sixstack_modes, | |
5783 | .input_mux = &alc882_capture_source, | |
5784 | }, | |
4b146cb0 TI |
5785 | [ALC882_ARIMA] = { |
5786 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, | |
5787 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs }, | |
5788 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
5789 | .dac_nids = alc882_dac_nids, | |
5790 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), | |
5791 | .channel_mode = alc882_sixstack_modes, | |
5792 | .input_mux = &alc882_capture_source, | |
5793 | }, | |
bdd148a3 KY |
5794 | [ALC882_W2JC] = { |
5795 | .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer }, | |
5796 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs, | |
5797 | alc880_gpio1_init_verbs }, | |
5798 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
5799 | .dac_nids = alc882_dac_nids, | |
5800 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
5801 | .channel_mode = alc880_threestack_modes, | |
5802 | .need_dac_fix = 1, | |
5803 | .input_mux = &alc882_capture_source, | |
5804 | .dig_out_nid = ALC882_DIGOUT_NID, | |
5805 | }, | |
87350ad0 TI |
5806 | [ALC885_MBP3] = { |
5807 | .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer }, | |
5808 | .init_verbs = { alc885_mbp3_init_verbs, | |
5809 | alc880_gpio1_init_verbs }, | |
5810 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
5811 | .dac_nids = alc882_dac_nids, | |
5812 | .channel_mode = alc885_mbp_6ch_modes, | |
5813 | .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes), | |
5814 | .input_mux = &alc882_capture_source, | |
5815 | .dig_out_nid = ALC882_DIGOUT_NID, | |
5816 | .dig_in_nid = ALC882_DIGIN_NID, | |
5817 | .unsol_event = alc885_mbp3_unsol_event, | |
5818 | .init_hook = alc885_mbp3_automute, | |
5819 | }, | |
9102cd1c TD |
5820 | [ALC885_MACPRO] = { |
5821 | .mixers = { alc882_macpro_mixer }, | |
5822 | .init_verbs = { alc882_macpro_init_verbs }, | |
5823 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
5824 | .dac_nids = alc882_dac_nids, | |
5825 | .dig_out_nid = ALC882_DIGOUT_NID, | |
5826 | .dig_in_nid = ALC882_DIGIN_NID, | |
5827 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | |
5828 | .channel_mode = alc882_ch_modes, | |
5829 | .input_mux = &alc882_capture_source, | |
7debbe51 | 5830 | .init_hook = alc885_macpro_init_hook, |
9102cd1c | 5831 | }, |
c54728d8 NF |
5832 | [ALC885_IMAC24] = { |
5833 | .mixers = { alc885_imac24_mixer }, | |
5834 | .init_verbs = { alc885_imac24_init_verbs }, | |
5835 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
5836 | .dac_nids = alc882_dac_nids, | |
5837 | .dig_out_nid = ALC882_DIGOUT_NID, | |
5838 | .dig_in_nid = ALC882_DIGIN_NID, | |
5839 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | |
5840 | .channel_mode = alc882_ch_modes, | |
5841 | .input_mux = &alc882_capture_source, | |
5842 | .unsol_event = alc885_imac24_unsol_event, | |
7debbe51 | 5843 | .init_hook = alc885_imac24_init_hook, |
c54728d8 | 5844 | }, |
272a527c KY |
5845 | [ALC882_TARGA] = { |
5846 | .mixers = { alc882_targa_mixer, alc882_chmode_mixer, | |
5847 | alc882_capture_mixer }, | |
5848 | .init_verbs = { alc882_init_verbs, alc882_targa_verbs}, | |
5849 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
5850 | .dac_nids = alc882_dac_nids, | |
5851 | .dig_out_nid = ALC882_DIGOUT_NID, | |
5852 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), | |
5853 | .adc_nids = alc882_adc_nids, | |
5854 | .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), | |
5855 | .channel_mode = alc882_3ST_6ch_modes, | |
5856 | .need_dac_fix = 1, | |
5857 | .input_mux = &alc882_capture_source, | |
5858 | .unsol_event = alc882_targa_unsol_event, | |
5859 | .init_hook = alc882_targa_automute, | |
5860 | }, | |
5861 | [ALC882_ASUS_A7J] = { | |
5862 | .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer, | |
5863 | alc882_capture_mixer }, | |
5864 | .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs}, | |
5865 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
5866 | .dac_nids = alc882_dac_nids, | |
5867 | .dig_out_nid = ALC882_DIGOUT_NID, | |
5868 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), | |
5869 | .adc_nids = alc882_adc_nids, | |
5870 | .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), | |
5871 | .channel_mode = alc882_3ST_6ch_modes, | |
5872 | .need_dac_fix = 1, | |
5873 | .input_mux = &alc882_capture_source, | |
5874 | }, | |
914759b7 TI |
5875 | [ALC882_ASUS_A7M] = { |
5876 | .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer }, | |
5877 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs, | |
5878 | alc880_gpio1_init_verbs, | |
5879 | alc882_asus_a7m_verbs }, | |
5880 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
5881 | .dac_nids = alc882_dac_nids, | |
5882 | .dig_out_nid = ALC882_DIGOUT_NID, | |
5883 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
5884 | .channel_mode = alc880_threestack_modes, | |
5885 | .need_dac_fix = 1, | |
5886 | .input_mux = &alc882_capture_source, | |
5887 | }, | |
df694daa KY |
5888 | }; |
5889 | ||
5890 | ||
f95474ec TI |
5891 | /* |
5892 | * Pin config fixes | |
5893 | */ | |
5894 | enum { | |
5895 | PINFIX_ABIT_AW9D_MAX | |
5896 | }; | |
5897 | ||
5898 | static struct alc_pincfg alc882_abit_aw9d_pinfix[] = { | |
5899 | { 0x15, 0x01080104 }, /* side */ | |
5900 | { 0x16, 0x01011012 }, /* rear */ | |
5901 | { 0x17, 0x01016011 }, /* clfe */ | |
5902 | { } | |
5903 | }; | |
5904 | ||
5905 | static const struct alc_pincfg *alc882_pin_fixes[] = { | |
5906 | [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix, | |
5907 | }; | |
5908 | ||
5909 | static struct snd_pci_quirk alc882_pinfix_tbl[] = { | |
5910 | SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX), | |
5911 | {} | |
5912 | }; | |
5913 | ||
df694daa KY |
5914 | /* |
5915 | * BIOS auto configuration | |
5916 | */ | |
5917 | static void alc882_auto_set_output_and_unmute(struct hda_codec *codec, | |
5918 | hda_nid_t nid, int pin_type, | |
5919 | int dac_idx) | |
5920 | { | |
5921 | /* set as output */ | |
5922 | struct alc_spec *spec = codec->spec; | |
f12ab1e0 TI |
5923 | int idx; |
5924 | ||
df694daa KY |
5925 | if (spec->multiout.dac_nids[dac_idx] == 0x25) |
5926 | idx = 4; | |
5927 | else | |
5928 | idx = spec->multiout.dac_nids[dac_idx] - 2; | |
5929 | ||
f12ab1e0 TI |
5930 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
5931 | pin_type); | |
5932 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
5933 | AMP_OUT_UNMUTE); | |
df694daa KY |
5934 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); |
5935 | ||
5936 | } | |
5937 | ||
5938 | static void alc882_auto_init_multi_out(struct hda_codec *codec) | |
5939 | { | |
5940 | struct alc_spec *spec = codec->spec; | |
5941 | int i; | |
5942 | ||
bc9f98a9 | 5943 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
df694daa | 5944 | for (i = 0; i <= HDA_SIDE; i++) { |
f12ab1e0 | 5945 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
baba8ee9 | 5946 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
df694daa | 5947 | if (nid) |
baba8ee9 | 5948 | alc882_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 5949 | i); |
df694daa KY |
5950 | } |
5951 | } | |
5952 | ||
5953 | static void alc882_auto_init_hp_out(struct hda_codec *codec) | |
5954 | { | |
5955 | struct alc_spec *spec = codec->spec; | |
5956 | hda_nid_t pin; | |
5957 | ||
eb06ed8f | 5958 | pin = spec->autocfg.hp_pins[0]; |
df694daa | 5959 | if (pin) /* connect to front */ |
f12ab1e0 TI |
5960 | /* use dac 0 */ |
5961 | alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
df694daa KY |
5962 | } |
5963 | ||
5964 | #define alc882_is_input_pin(nid) alc880_is_input_pin(nid) | |
5965 | #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID | |
5966 | ||
5967 | static void alc882_auto_init_analog_input(struct hda_codec *codec) | |
5968 | { | |
5969 | struct alc_spec *spec = codec->spec; | |
5970 | int i; | |
5971 | ||
5972 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
5973 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
5974 | if (alc882_is_input_pin(nid)) { | |
f12ab1e0 TI |
5975 | snd_hda_codec_write(codec, nid, 0, |
5976 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
5977 | i <= AUTO_PIN_FRONT_MIC ? | |
5978 | PIN_VREF80 : PIN_IN); | |
df694daa | 5979 | if (nid != ALC882_PIN_CD_NID) |
f12ab1e0 TI |
5980 | snd_hda_codec_write(codec, nid, 0, |
5981 | AC_VERB_SET_AMP_GAIN_MUTE, | |
df694daa KY |
5982 | AMP_OUT_MUTE); |
5983 | } | |
5984 | } | |
5985 | } | |
5986 | ||
776e184e TI |
5987 | /* add mic boosts if needed */ |
5988 | static int alc_auto_add_mic_boost(struct hda_codec *codec) | |
5989 | { | |
5990 | struct alc_spec *spec = codec->spec; | |
5991 | int err; | |
5992 | hda_nid_t nid; | |
5993 | ||
5994 | nid = spec->autocfg.input_pins[AUTO_PIN_MIC]; | |
5995 | if (nid) { | |
5996 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
5997 | "Mic Boost", | |
5998 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | |
5999 | if (err < 0) | |
6000 | return err; | |
6001 | } | |
6002 | nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]; | |
6003 | if (nid) { | |
6004 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
6005 | "Front Mic Boost", | |
6006 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | |
6007 | if (err < 0) | |
6008 | return err; | |
6009 | } | |
6010 | return 0; | |
6011 | } | |
6012 | ||
df694daa KY |
6013 | /* almost identical with ALC880 parser... */ |
6014 | static int alc882_parse_auto_config(struct hda_codec *codec) | |
6015 | { | |
6016 | struct alc_spec *spec = codec->spec; | |
6017 | int err = alc880_parse_auto_config(codec); | |
6018 | ||
6019 | if (err < 0) | |
6020 | return err; | |
776e184e TI |
6021 | else if (!err) |
6022 | return 0; /* no config found */ | |
6023 | ||
6024 | err = alc_auto_add_mic_boost(codec); | |
6025 | if (err < 0) | |
6026 | return err; | |
6027 | ||
6028 | /* hack - override the init verbs */ | |
6029 | spec->init_verbs[0] = alc882_auto_init_verbs; | |
6030 | ||
6031 | return 1; /* config found */ | |
df694daa KY |
6032 | } |
6033 | ||
ae6b813a TI |
6034 | /* additional initialization for auto-configuration model */ |
6035 | static void alc882_auto_init(struct hda_codec *codec) | |
df694daa | 6036 | { |
df694daa KY |
6037 | alc882_auto_init_multi_out(codec); |
6038 | alc882_auto_init_hp_out(codec); | |
6039 | alc882_auto_init_analog_input(codec); | |
df694daa KY |
6040 | } |
6041 | ||
df694daa KY |
6042 | static int patch_alc882(struct hda_codec *codec) |
6043 | { | |
6044 | struct alc_spec *spec; | |
6045 | int err, board_config; | |
6046 | ||
6047 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
6048 | if (spec == NULL) | |
6049 | return -ENOMEM; | |
6050 | ||
6051 | codec->spec = spec; | |
6052 | ||
f5fcc13c TI |
6053 | board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST, |
6054 | alc882_models, | |
6055 | alc882_cfg_tbl); | |
df694daa KY |
6056 | |
6057 | if (board_config < 0 || board_config >= ALC882_MODEL_LAST) { | |
081d17c4 TD |
6058 | /* Pick up systems that don't supply PCI SSID */ |
6059 | switch (codec->subsystem_id) { | |
6060 | case 0x106b0c00: /* Mac Pro */ | |
6061 | board_config = ALC885_MACPRO; | |
6062 | break; | |
c54728d8 NF |
6063 | case 0x106b1000: /* iMac 24 */ |
6064 | board_config = ALC885_IMAC24; | |
6065 | break; | |
87350ad0 TI |
6066 | case 0x106b2c00: /* Macbook Pro rev3 */ |
6067 | board_config = ALC885_MBP3; | |
6068 | break; | |
081d17c4 TD |
6069 | default: |
6070 | printk(KERN_INFO "hda_codec: Unknown model for ALC882, " | |
6071 | "trying auto-probe from BIOS...\n"); | |
6072 | board_config = ALC882_AUTO; | |
6073 | } | |
df694daa KY |
6074 | } |
6075 | ||
f95474ec TI |
6076 | alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes); |
6077 | ||
df694daa KY |
6078 | if (board_config == ALC882_AUTO) { |
6079 | /* automatic parse from the BIOS config */ | |
6080 | err = alc882_parse_auto_config(codec); | |
6081 | if (err < 0) { | |
6082 | alc_free(codec); | |
6083 | return err; | |
f12ab1e0 | 6084 | } else if (!err) { |
9c7f852e TI |
6085 | printk(KERN_INFO |
6086 | "hda_codec: Cannot set up configuration " | |
6087 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
6088 | board_config = ALC882_3ST_DIG; |
6089 | } | |
6090 | } | |
6091 | ||
6092 | if (board_config != ALC882_AUTO) | |
6093 | setup_preset(spec, &alc882_presets[board_config]); | |
1da177e4 LT |
6094 | |
6095 | spec->stream_name_analog = "ALC882 Analog"; | |
df694daa KY |
6096 | spec->stream_analog_playback = &alc882_pcm_analog_playback; |
6097 | spec->stream_analog_capture = &alc882_pcm_analog_capture; | |
1da177e4 LT |
6098 | |
6099 | spec->stream_name_digital = "ALC882 Digital"; | |
df694daa KY |
6100 | spec->stream_digital_playback = &alc882_pcm_digital_playback; |
6101 | spec->stream_digital_capture = &alc882_pcm_digital_capture; | |
1da177e4 | 6102 | |
f12ab1e0 | 6103 | if (!spec->adc_nids && spec->input_mux) { |
df694daa | 6104 | /* check whether NID 0x07 is valid */ |
4a471b7d | 6105 | unsigned int wcap = get_wcaps(codec, 0x07); |
f12ab1e0 TI |
6106 | /* get type */ |
6107 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
df694daa KY |
6108 | if (wcap != AC_WID_AUD_IN) { |
6109 | spec->adc_nids = alc882_adc_nids_alt; | |
6110 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt); | |
f12ab1e0 TI |
6111 | spec->mixers[spec->num_mixers] = |
6112 | alc882_capture_alt_mixer; | |
df694daa KY |
6113 | spec->num_mixers++; |
6114 | } else { | |
6115 | spec->adc_nids = alc882_adc_nids; | |
6116 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids); | |
6117 | spec->mixers[spec->num_mixers] = alc882_capture_mixer; | |
6118 | spec->num_mixers++; | |
6119 | } | |
6120 | } | |
1da177e4 LT |
6121 | |
6122 | codec->patch_ops = alc_patch_ops; | |
df694daa | 6123 | if (board_config == ALC882_AUTO) |
ae6b813a | 6124 | spec->init_hook = alc882_auto_init; |
cb53c626 TI |
6125 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
6126 | if (!spec->loopback.amplist) | |
6127 | spec->loopback.amplist = alc882_loopbacks; | |
6128 | #endif | |
df694daa KY |
6129 | |
6130 | return 0; | |
6131 | } | |
6132 | ||
6133 | /* | |
9c7f852e TI |
6134 | * ALC883 support |
6135 | * | |
6136 | * ALC883 is almost identical with ALC880 but has cleaner and more flexible | |
6137 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
6138 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
6139 | * 6-channel independent captures. | |
6140 | * | |
6141 | * In addition, an independent DAC for the multi-playback (not used in this | |
6142 | * driver yet). | |
df694daa | 6143 | */ |
9c7f852e TI |
6144 | #define ALC883_DIGOUT_NID 0x06 |
6145 | #define ALC883_DIGIN_NID 0x0a | |
df694daa | 6146 | |
9c7f852e TI |
6147 | static hda_nid_t alc883_dac_nids[4] = { |
6148 | /* front, rear, clfe, rear_surr */ | |
6149 | 0x02, 0x04, 0x03, 0x05 | |
6150 | }; | |
df694daa | 6151 | |
9c7f852e TI |
6152 | static hda_nid_t alc883_adc_nids[2] = { |
6153 | /* ADC1-2 */ | |
6154 | 0x08, 0x09, | |
6155 | }; | |
f12ab1e0 | 6156 | |
9c7f852e TI |
6157 | /* input MUX */ |
6158 | /* FIXME: should be a matrix-type input source selection */ | |
df694daa | 6159 | |
9c7f852e TI |
6160 | static struct hda_input_mux alc883_capture_source = { |
6161 | .num_items = 4, | |
6162 | .items = { | |
6163 | { "Mic", 0x0 }, | |
6164 | { "Front Mic", 0x1 }, | |
6165 | { "Line", 0x2 }, | |
6166 | { "CD", 0x4 }, | |
6167 | }, | |
6168 | }; | |
bc9f98a9 KY |
6169 | |
6170 | static struct hda_input_mux alc883_lenovo_101e_capture_source = { | |
6171 | .num_items = 2, | |
6172 | .items = { | |
6173 | { "Mic", 0x1 }, | |
6174 | { "Line", 0x2 }, | |
6175 | }, | |
6176 | }; | |
6177 | ||
272a527c KY |
6178 | static struct hda_input_mux alc883_lenovo_nb0763_capture_source = { |
6179 | .num_items = 4, | |
6180 | .items = { | |
6181 | { "Mic", 0x0 }, | |
6182 | { "iMic", 0x1 }, | |
6183 | { "Line", 0x2 }, | |
6184 | { "CD", 0x4 }, | |
6185 | }, | |
6186 | }; | |
6187 | ||
9c7f852e TI |
6188 | #define alc883_mux_enum_info alc_mux_enum_info |
6189 | #define alc883_mux_enum_get alc_mux_enum_get | |
df694daa | 6190 | |
9c7f852e TI |
6191 | static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol, |
6192 | struct snd_ctl_elem_value *ucontrol) | |
6193 | { | |
6194 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
6195 | struct alc_spec *spec = codec->spec; | |
6196 | const struct hda_input_mux *imux = spec->input_mux; | |
6197 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
6198 | static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 }; | |
6199 | hda_nid_t nid = capture_mixers[adc_idx]; | |
6200 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; | |
6201 | unsigned int i, idx; | |
6202 | ||
6203 | idx = ucontrol->value.enumerated.item[0]; | |
6204 | if (idx >= imux->num_items) | |
6205 | idx = imux->num_items - 1; | |
82beb8fd | 6206 | if (*cur_val == idx) |
9c7f852e TI |
6207 | return 0; |
6208 | for (i = 0; i < imux->num_items; i++) { | |
47fd830a TI |
6209 | unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE; |
6210 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, | |
82beb8fd | 6211 | imux->items[i].index, |
47fd830a | 6212 | HDA_AMP_MUTE, v); |
9c7f852e TI |
6213 | } |
6214 | *cur_val = idx; | |
6215 | return 1; | |
6216 | } | |
f12ab1e0 | 6217 | |
9c7f852e TI |
6218 | /* |
6219 | * 2ch mode | |
6220 | */ | |
6221 | static struct hda_channel_mode alc883_3ST_2ch_modes[1] = { | |
6222 | { 2, NULL } | |
6223 | }; | |
6224 | ||
6225 | /* | |
6226 | * 2ch mode | |
6227 | */ | |
6228 | static struct hda_verb alc883_3ST_ch2_init[] = { | |
6229 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
6230 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
6231 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
6232 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
6233 | { } /* end */ | |
6234 | }; | |
6235 | ||
b201131c TD |
6236 | /* |
6237 | * 4ch mode | |
6238 | */ | |
6239 | static struct hda_verb alc883_3ST_ch4_init[] = { | |
6240 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
6241 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
6242 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6243 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
6244 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
6245 | { } /* end */ | |
6246 | }; | |
6247 | ||
9c7f852e TI |
6248 | /* |
6249 | * 6ch mode | |
6250 | */ | |
6251 | static struct hda_verb alc883_3ST_ch6_init[] = { | |
6252 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6253 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
6254 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
6255 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6256 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
6257 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
6258 | { } /* end */ | |
6259 | }; | |
6260 | ||
b201131c | 6261 | static struct hda_channel_mode alc883_3ST_6ch_modes[3] = { |
9c7f852e | 6262 | { 2, alc883_3ST_ch2_init }, |
b201131c | 6263 | { 4, alc883_3ST_ch4_init }, |
9c7f852e TI |
6264 | { 6, alc883_3ST_ch6_init }, |
6265 | }; | |
6266 | ||
6267 | /* | |
6268 | * 6ch mode | |
6269 | */ | |
6270 | static struct hda_verb alc883_sixstack_ch6_init[] = { | |
6271 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
6272 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6273 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6274 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6275 | { } /* end */ | |
6276 | }; | |
6277 | ||
6278 | /* | |
6279 | * 8ch mode | |
6280 | */ | |
6281 | static struct hda_verb alc883_sixstack_ch8_init[] = { | |
6282 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6283 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6284 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6285 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6286 | { } /* end */ | |
6287 | }; | |
6288 | ||
6289 | static struct hda_channel_mode alc883_sixstack_modes[2] = { | |
6290 | { 6, alc883_sixstack_ch6_init }, | |
6291 | { 8, alc883_sixstack_ch8_init }, | |
6292 | }; | |
6293 | ||
b373bdeb AN |
6294 | static struct hda_verb alc883_medion_eapd_verbs[] = { |
6295 | /* eanable EAPD on medion laptop */ | |
6296 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
6297 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
6298 | { } | |
6299 | }; | |
6300 | ||
9c7f852e TI |
6301 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
6302 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
6303 | */ | |
6304 | ||
6305 | static struct snd_kcontrol_new alc883_base_mixer[] = { | |
df694daa | 6306 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9c7f852e TI |
6307 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
6308 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
6309 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
6310 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
6311 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
6312 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
6313 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
6314 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
6315 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
6316 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
df694daa KY |
6317 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
6318 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, 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("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 6322 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
df694daa | 6323 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
9c7f852e | 6324 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
32360416 | 6325 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
6326 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
6327 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
6328 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
6329 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6330 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6331 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6332 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6333 | { | |
6334 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6335 | /* .name = "Capture Source", */ | |
6336 | .name = "Input Source", | |
6337 | .count = 2, | |
6338 | .info = alc883_mux_enum_info, | |
6339 | .get = alc883_mux_enum_get, | |
6340 | .put = alc883_mux_enum_put, | |
6341 | }, | |
df694daa | 6342 | { } /* end */ |
834be88d TI |
6343 | }; |
6344 | ||
9c7f852e TI |
6345 | static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = { |
6346 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6347 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 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), | |
32360416 | 6354 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
6355 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
6356 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 6357 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
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 | }; | |
df694daa | 6376 | |
9c7f852e TI |
6377 | static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = { |
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", 0x0d, 0x0, HDA_OUTPUT), | |
6381 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
6382 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
6383 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
6384 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
6385 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 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), | |
32360416 | 6392 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
6393 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
6394 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 6395 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
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 | ||
d1d985f0 | 6415 | static struct snd_kcontrol_new alc883_fivestack_mixer[] = { |
c07584c8 TD |
6416 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
6417 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
6418 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
6419 | HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
6420 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
6421 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
6422 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT), | |
6423 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | |
6424 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6425 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6426 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6427 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6428 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6429 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 6430 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
c07584c8 TD |
6431 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
6432 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 6433 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
c07584c8 TD |
6434 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
6435 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
6436 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
6437 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6438 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6439 | ||
6440 | { | |
6441 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6442 | /* .name = "Capture Source", */ | |
6443 | .name = "Input Source", | |
6444 | .count = 1, | |
6445 | .info = alc883_mux_enum_info, | |
6446 | .get = alc883_mux_enum_get, | |
6447 | .put = alc883_mux_enum_put, | |
6448 | }, | |
6449 | { } /* end */ | |
6450 | }; | |
6451 | ||
ccc656ce KY |
6452 | static struct snd_kcontrol_new alc883_tagra_mixer[] = { |
6453 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6454 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
6455 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6456 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
6457 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
6458 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
6459 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
6460 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
6461 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
6462 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6463 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6464 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6465 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6466 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 6467 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce KY |
6468 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
6469 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6470 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6471 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6472 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6473 | { | |
6474 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6475 | /* .name = "Capture Source", */ | |
6476 | .name = "Input Source", | |
6477 | .count = 2, | |
6478 | .info = alc883_mux_enum_info, | |
6479 | .get = alc883_mux_enum_get, | |
6480 | .put = alc883_mux_enum_put, | |
6481 | }, | |
6482 | { } /* end */ | |
f12ab1e0 | 6483 | }; |
ccc656ce KY |
6484 | |
6485 | static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = { | |
6486 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6487 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
6488 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6489 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6490 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6491 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 6492 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce KY |
6493 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
6494 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6495 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6496 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6497 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6498 | { | |
6499 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6500 | /* .name = "Capture Source", */ | |
6501 | .name = "Input Source", | |
6502 | .count = 2, | |
6503 | .info = alc883_mux_enum_info, | |
6504 | .get = alc883_mux_enum_get, | |
6505 | .put = alc883_mux_enum_put, | |
6506 | }, | |
6507 | { } /* end */ | |
f12ab1e0 | 6508 | }; |
ccc656ce | 6509 | |
bc9f98a9 KY |
6510 | static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = { |
6511 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6512 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
6513 | HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
6514 | HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
6515 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6516 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
6517 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
6518 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
6519 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6520 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6521 | { | |
6522 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6523 | /* .name = "Capture Source", */ | |
6524 | .name = "Input Source", | |
6525 | .count = 1, | |
6526 | .info = alc883_mux_enum_info, | |
6527 | .get = alc883_mux_enum_get, | |
6528 | .put = alc883_mux_enum_put, | |
6529 | }, | |
6530 | { } /* end */ | |
f12ab1e0 | 6531 | }; |
bc9f98a9 | 6532 | |
272a527c KY |
6533 | static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = { |
6534 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6535 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT), | |
6536 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
6537 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6538 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6539 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6540 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
6541 | HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
6542 | HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
6543 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6544 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6545 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6546 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6547 | { | |
6548 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6549 | /* .name = "Capture Source", */ | |
6550 | .name = "Input Source", | |
6551 | .count = 2, | |
6552 | .info = alc883_mux_enum_info, | |
6553 | .get = alc883_mux_enum_get, | |
6554 | .put = alc883_mux_enum_put, | |
6555 | }, | |
6556 | { } /* end */ | |
6557 | }; | |
6558 | ||
6559 | static struct snd_kcontrol_new alc883_medion_md2_mixer[] = { | |
6560 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
6561 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
6562 | HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
6563 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6564 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6565 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6566 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
6567 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6568 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6569 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6570 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6571 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6572 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6573 | { | |
6574 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6575 | /* .name = "Capture Source", */ | |
6576 | .name = "Input Source", | |
6577 | .count = 2, | |
6578 | .info = alc883_mux_enum_info, | |
6579 | .get = alc883_mux_enum_get, | |
6580 | .put = alc883_mux_enum_put, | |
6581 | }, | |
6582 | { } /* end */ | |
6583 | }; | |
6584 | ||
4723c022 | 6585 | static struct snd_kcontrol_new alc888_6st_hp_mixer[] = { |
cd1e3b40 CM |
6586 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
6587 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
6588 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT), | |
6589 | HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT), | |
6590 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), | |
6591 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT), | |
6592 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT), | |
6593 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), | |
6594 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
6595 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
6596 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6597 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6598 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6599 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6600 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6601 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6602 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
6603 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
6604 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
6605 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
6606 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
6607 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
6608 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
6609 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6610 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6611 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6612 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6613 | { | |
6614 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6615 | /* .name = "Capture Source", */ | |
6616 | .name = "Input Source", | |
6617 | .count = 2, | |
6618 | .info = alc883_mux_enum_info, | |
6619 | .get = alc883_mux_enum_get, | |
6620 | .put = alc883_mux_enum_put, | |
6621 | }, | |
6622 | { } /* end */ | |
6623 | }; | |
6624 | ||
4723c022 | 6625 | static struct snd_kcontrol_new alc888_3st_hp_mixer[] = { |
8341de60 CM |
6626 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
6627 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
6628 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT), | |
6629 | HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT), | |
6630 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), | |
6631 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT), | |
6632 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT), | |
6633 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), | |
6634 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
6635 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
6636 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
6637 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
6638 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
6639 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
6640 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
6641 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
6642 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
6643 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
6644 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
6645 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
6646 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
6647 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
6648 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6649 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6650 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6651 | { | |
6652 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6653 | /* .name = "Capture Source", */ | |
6654 | .name = "Input Source", | |
6655 | .count = 2, | |
6656 | .info = alc883_mux_enum_info, | |
6657 | .get = alc883_mux_enum_get, | |
6658 | .put = alc883_mux_enum_put, | |
6659 | }, | |
6660 | { } /* end */ | |
6661 | }; | |
6662 | ||
2880a867 | 6663 | static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = { |
d1a991a6 KY |
6664 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
6665 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
2880a867 | 6666 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), |
2880a867 TD |
6667 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
6668 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
d1a991a6 KY |
6669 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
6670 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
6671 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2880a867 TD |
6672 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
6673 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
6674 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
6675 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
6676 | { | |
6677 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6678 | /* .name = "Capture Source", */ | |
6679 | .name = "Input Source", | |
6680 | .count = 2, | |
6681 | .info = alc883_mux_enum_info, | |
6682 | .get = alc883_mux_enum_get, | |
6683 | .put = alc883_mux_enum_put, | |
6684 | }, | |
6685 | { } /* end */ | |
d1a991a6 | 6686 | }; |
2880a867 | 6687 | |
9c7f852e TI |
6688 | static struct snd_kcontrol_new alc883_chmode_mixer[] = { |
6689 | { | |
6690 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
6691 | .name = "Channel Mode", | |
6692 | .info = alc_ch_mode_info, | |
6693 | .get = alc_ch_mode_get, | |
6694 | .put = alc_ch_mode_put, | |
6695 | }, | |
6696 | { } /* end */ | |
6697 | }; | |
6698 | ||
6699 | static struct hda_verb alc883_init_verbs[] = { | |
6700 | /* ADC1: mute amp left and right */ | |
6701 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
df694daa | 6702 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
9c7f852e TI |
6703 | /* ADC2: mute amp left and right */ |
6704 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
df694daa | 6705 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
9c7f852e TI |
6706 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ |
6707 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6708 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6709 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
6710 | /* Rear mixer */ | |
6711 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6712 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6713 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
6714 | /* CLFE mixer */ | |
6715 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6716 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6717 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
6718 | /* Side mixer */ | |
6719 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6720 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6721 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
df694daa | 6722 | |
cb53c626 TI |
6723 | /* mute analog input loopbacks */ |
6724 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6725 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
6726 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6727 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6728 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa | 6729 | |
9c7f852e TI |
6730 | /* Front Pin: output 0 (0x0c) */ |
6731 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6732 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6733 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6734 | /* Rear Pin: output 1 (0x0d) */ | |
6735 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6736 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6737 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
6738 | /* CLFE Pin: output 2 (0x0e) */ | |
6739 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6740 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6741 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
6742 | /* Side Pin: output 3 (0x0f) */ | |
6743 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6744 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6745 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
6746 | /* Mic (rear) pin: input vref at 80% */ | |
6747 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
6748 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
6749 | /* Front Mic pin: input vref at 80% */ | |
6750 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
6751 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
6752 | /* Line In pin: input */ | |
6753 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
6754 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
6755 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
6756 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6757 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6758 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6759 | /* CD pin widget for input */ | |
6760 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
6761 | ||
6762 | /* FIXME: use matrix-type input source selection */ | |
6763 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
6764 | /* Input mixer2 */ | |
6765 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6766 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6767 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
6768 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
6769 | /* Input mixer3 */ | |
6770 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6771 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6772 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
6773 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
6774 | { } | |
6775 | }; | |
6776 | ||
ccc656ce KY |
6777 | static struct hda_verb alc883_tagra_verbs[] = { |
6778 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6779 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6780 | ||
6781 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6782 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6783 | ||
6784 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
6785 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
6786 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
6787 | ||
6788 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
f12ab1e0 TI |
6789 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
6790 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | |
6791 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | |
ccc656ce KY |
6792 | |
6793 | { } /* end */ | |
6794 | }; | |
6795 | ||
bc9f98a9 KY |
6796 | static struct hda_verb alc883_lenovo_101e_verbs[] = { |
6797 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6798 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN}, | |
6799 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN}, | |
6800 | { } /* end */ | |
6801 | }; | |
6802 | ||
272a527c KY |
6803 | static struct hda_verb alc883_lenovo_nb0763_verbs[] = { |
6804 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6805 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6806 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
6807 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6808 | { } /* end */ | |
6809 | }; | |
6810 | ||
6811 | static struct hda_verb alc888_lenovo_ms7195_verbs[] = { | |
6812 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6813 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6814 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6815 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN}, | |
6816 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
6817 | { } /* end */ | |
6818 | }; | |
6819 | ||
189609ae KY |
6820 | static struct hda_verb alc883_haier_w66_verbs[] = { |
6821 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6822 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6823 | ||
6824 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6825 | ||
6826 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6827 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6828 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
6829 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6830 | { } /* end */ | |
6831 | }; | |
6832 | ||
4723c022 | 6833 | static struct hda_verb alc888_6st_hp_verbs[] = { |
cd1e3b40 CM |
6834 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */ |
6835 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */ | |
6836 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */ | |
6837 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */ | |
6838 | { } | |
6839 | }; | |
6840 | ||
4723c022 | 6841 | static struct hda_verb alc888_3st_hp_verbs[] = { |
8341de60 CM |
6842 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */ |
6843 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */ | |
6844 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */ | |
6845 | { } | |
6846 | }; | |
6847 | ||
4723c022 | 6848 | static struct hda_verb alc888_3st_hp_2ch_init[] = { |
8341de60 CM |
6849 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
6850 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
6851 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
6852 | { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
6853 | { } | |
6854 | }; | |
6855 | ||
4723c022 | 6856 | static struct hda_verb alc888_3st_hp_6ch_init[] = { |
8341de60 CM |
6857 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
6858 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
6859 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6860 | { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
6861 | { } | |
6862 | }; | |
6863 | ||
4723c022 CM |
6864 | static struct hda_channel_mode alc888_3st_hp_modes[2] = { |
6865 | { 2, alc888_3st_hp_2ch_init }, | |
6866 | { 6, alc888_3st_hp_6ch_init }, | |
8341de60 CM |
6867 | }; |
6868 | ||
272a527c KY |
6869 | /* toggle front-jack and RCA according to the hp-jack state */ |
6870 | static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec) | |
6871 | { | |
6872 | unsigned int present; | |
6873 | ||
6874 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
6875 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
6876 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
6877 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
6878 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
6879 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c KY |
6880 | } |
6881 | ||
6882 | /* toggle RCA according to the front-jack state */ | |
6883 | static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec) | |
6884 | { | |
6885 | unsigned int present; | |
6886 | ||
6887 | present = snd_hda_codec_read(codec, 0x14, 0, | |
6888 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
6889 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
6890 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c | 6891 | } |
47fd830a | 6892 | |
272a527c KY |
6893 | static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec, |
6894 | unsigned int res) | |
6895 | { | |
6896 | if ((res >> 26) == ALC880_HP_EVENT) | |
6897 | alc888_lenovo_ms7195_front_automute(codec); | |
6898 | if ((res >> 26) == ALC880_FRONT_EVENT) | |
6899 | alc888_lenovo_ms7195_rca_automute(codec); | |
6900 | } | |
6901 | ||
6902 | static struct hda_verb alc883_medion_md2_verbs[] = { | |
6903 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6904 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6905 | ||
6906 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6907 | ||
6908 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
6909 | { } /* end */ | |
6910 | }; | |
6911 | ||
6912 | /* toggle speaker-output according to the hp-jack state */ | |
6913 | static void alc883_medion_md2_automute(struct hda_codec *codec) | |
6914 | { | |
6915 | unsigned int present; | |
6916 | ||
6917 | present = snd_hda_codec_read(codec, 0x14, 0, | |
6918 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
6919 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
6920 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c KY |
6921 | } |
6922 | ||
6923 | static void alc883_medion_md2_unsol_event(struct hda_codec *codec, | |
6924 | unsigned int res) | |
6925 | { | |
6926 | if ((res >> 26) == ALC880_HP_EVENT) | |
6927 | alc883_medion_md2_automute(codec); | |
6928 | } | |
6929 | ||
ccc656ce KY |
6930 | /* toggle speaker-output according to the hp-jack state */ |
6931 | static void alc883_tagra_automute(struct hda_codec *codec) | |
6932 | { | |
6933 | unsigned int present; | |
f12ab1e0 | 6934 | unsigned char bits; |
ccc656ce KY |
6935 | |
6936 | present = snd_hda_codec_read(codec, 0x14, 0, | |
6937 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
6938 | bits = present ? HDA_AMP_MUTE : 0; |
6939 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
6940 | HDA_AMP_MUTE, bits); | |
82beb8fd TI |
6941 | snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA, |
6942 | present ? 1 : 3); | |
ccc656ce KY |
6943 | } |
6944 | ||
6945 | static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res) | |
6946 | { | |
6947 | if ((res >> 26) == ALC880_HP_EVENT) | |
6948 | alc883_tagra_automute(codec); | |
6949 | } | |
6950 | ||
189609ae KY |
6951 | static void alc883_haier_w66_automute(struct hda_codec *codec) |
6952 | { | |
6953 | unsigned int present; | |
6954 | unsigned char bits; | |
6955 | ||
6956 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
6957 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
6958 | bits = present ? 0x80 : 0; | |
6959 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
6960 | 0x80, bits); | |
6961 | } | |
6962 | ||
6963 | static void alc883_haier_w66_unsol_event(struct hda_codec *codec, | |
6964 | unsigned int res) | |
6965 | { | |
6966 | if ((res >> 26) == ALC880_HP_EVENT) | |
6967 | alc883_haier_w66_automute(codec); | |
6968 | } | |
6969 | ||
bc9f98a9 KY |
6970 | static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec) |
6971 | { | |
6972 | unsigned int present; | |
f12ab1e0 | 6973 | unsigned char bits; |
bc9f98a9 KY |
6974 | |
6975 | present = snd_hda_codec_read(codec, 0x14, 0, | |
6976 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
6977 | bits = present ? HDA_AMP_MUTE : 0; |
6978 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
6979 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
6980 | } |
6981 | ||
6982 | static void alc883_lenovo_101e_all_automute(struct hda_codec *codec) | |
6983 | { | |
6984 | unsigned int present; | |
f12ab1e0 | 6985 | unsigned char bits; |
bc9f98a9 KY |
6986 | |
6987 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
6988 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
6989 | bits = present ? HDA_AMP_MUTE : 0; |
6990 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
6991 | HDA_AMP_MUTE, bits); | |
6992 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
6993 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
6994 | } |
6995 | ||
6996 | static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec, | |
6997 | unsigned int res) | |
6998 | { | |
6999 | if ((res >> 26) == ALC880_HP_EVENT) | |
7000 | alc883_lenovo_101e_all_automute(codec); | |
7001 | if ((res >> 26) == ALC880_FRONT_EVENT) | |
7002 | alc883_lenovo_101e_ispeaker_automute(codec); | |
7003 | } | |
7004 | ||
676a9b53 TI |
7005 | /* toggle speaker-output according to the hp-jack state */ |
7006 | static void alc883_acer_aspire_automute(struct hda_codec *codec) | |
7007 | { | |
7008 | unsigned int present; | |
7009 | ||
7010 | present = snd_hda_codec_read(codec, 0x14, 0, | |
7011 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
7012 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
7013 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7014 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
7015 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7016 | } | |
7017 | ||
7018 | static void alc883_acer_aspire_unsol_event(struct hda_codec *codec, | |
7019 | unsigned int res) | |
7020 | { | |
7021 | if ((res >> 26) == ALC880_HP_EVENT) | |
7022 | alc883_acer_aspire_automute(codec); | |
7023 | } | |
7024 | ||
d1a991a6 KY |
7025 | static struct hda_verb alc883_acer_eapd_verbs[] = { |
7026 | /* HP Pin: output 0 (0x0c) */ | |
7027 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7028 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7029 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7030 | /* Front Pin: output 0 (0x0c) */ | |
676a9b53 TI |
7031 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
7032 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
d1a991a6 | 7033 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
d1a991a6 KY |
7034 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, |
7035 | /* eanable EAPD on medion laptop */ | |
7036 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
7037 | {0x20, AC_VERB_SET_PROC_COEF, 0x3050}, | |
676a9b53 TI |
7038 | /* enable unsolicited event */ |
7039 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
d1a991a6 KY |
7040 | { } |
7041 | }; | |
7042 | ||
9c7f852e TI |
7043 | /* |
7044 | * generic initialization of ADC, input mixers and output mixers | |
7045 | */ | |
7046 | static struct hda_verb alc883_auto_init_verbs[] = { | |
7047 | /* | |
7048 | * Unmute ADC0-2 and set the default input to mic-in | |
7049 | */ | |
7050 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7051 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7052 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7053 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7054 | ||
cb53c626 | 7055 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
9c7f852e | 7056 | * mixer widget |
f12ab1e0 TI |
7057 | * Note: PASD motherboards uses the Line In 2 as the input for |
7058 | * front panel mic (mic 2) | |
9c7f852e TI |
7059 | */ |
7060 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
7061 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
7062 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7063 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
7064 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
7065 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9c7f852e TI |
7066 | |
7067 | /* | |
7068 | * Set up output mixers (0x0c - 0x0f) | |
7069 | */ | |
7070 | /* set vol=0 to output mixers */ | |
7071 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7072 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7073 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7074 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7075 | /* set up input amps for analog loopback */ | |
7076 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
7077 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7078 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7079 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7080 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7081 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7082 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7083 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7084 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7085 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7086 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7087 | ||
7088 | /* FIXME: use matrix-type input source selection */ | |
7089 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
7090 | /* Input mixer1 */ | |
7091 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7092 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7093 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 7094 | /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */ |
9c7f852e TI |
7095 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
7096 | /* Input mixer2 */ | |
7097 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7098 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7099 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 7100 | /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */ |
9c7f852e TI |
7101 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
7102 | ||
7103 | { } | |
7104 | }; | |
7105 | ||
7106 | /* capture mixer elements */ | |
7107 | static struct snd_kcontrol_new alc883_capture_mixer[] = { | |
7108 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
7109 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
7110 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
7111 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
7112 | { | |
7113 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7114 | /* The multiple "Capture Source" controls confuse alsamixer | |
7115 | * So call somewhat different.. | |
7116 | * FIXME: the controls appear in the "playback" view! | |
7117 | */ | |
7118 | /* .name = "Capture Source", */ | |
7119 | .name = "Input Source", | |
7120 | .count = 2, | |
7121 | .info = alc882_mux_enum_info, | |
7122 | .get = alc882_mux_enum_get, | |
7123 | .put = alc882_mux_enum_put, | |
7124 | }, | |
7125 | { } /* end */ | |
7126 | }; | |
7127 | ||
cb53c626 TI |
7128 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
7129 | #define alc883_loopbacks alc880_loopbacks | |
7130 | #endif | |
7131 | ||
9c7f852e TI |
7132 | /* pcm configuration: identiacal with ALC880 */ |
7133 | #define alc883_pcm_analog_playback alc880_pcm_analog_playback | |
7134 | #define alc883_pcm_analog_capture alc880_pcm_analog_capture | |
7135 | #define alc883_pcm_digital_playback alc880_pcm_digital_playback | |
7136 | #define alc883_pcm_digital_capture alc880_pcm_digital_capture | |
7137 | ||
7138 | /* | |
7139 | * configuration and preset | |
7140 | */ | |
f5fcc13c TI |
7141 | static const char *alc883_models[ALC883_MODEL_LAST] = { |
7142 | [ALC883_3ST_2ch_DIG] = "3stack-dig", | |
7143 | [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig", | |
7144 | [ALC883_3ST_6ch] = "3stack-6ch", | |
7145 | [ALC883_6ST_DIG] = "6stack-dig", | |
7146 | [ALC883_TARGA_DIG] = "targa-dig", | |
7147 | [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig", | |
f5fcc13c | 7148 | [ALC883_ACER] = "acer", |
2880a867 | 7149 | [ALC883_ACER_ASPIRE] = "acer-aspire", |
f5fcc13c | 7150 | [ALC883_MEDION] = "medion", |
272a527c | 7151 | [ALC883_MEDION_MD2] = "medion-md2", |
f5fcc13c | 7152 | [ALC883_LAPTOP_EAPD] = "laptop-eapd", |
bc9f98a9 | 7153 | [ALC883_LENOVO_101E_2ch] = "lenovo-101e", |
272a527c KY |
7154 | [ALC883_LENOVO_NB0763] = "lenovo-nb0763", |
7155 | [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig", | |
189609ae | 7156 | [ALC883_HAIER_W66] = "haier-w66", |
4723c022 CM |
7157 | [ALC888_6ST_HP] = "6stack-hp", |
7158 | [ALC888_3ST_HP] = "3stack-hp", | |
f5fcc13c TI |
7159 | [ALC883_AUTO] = "auto", |
7160 | }; | |
7161 | ||
7162 | static struct snd_pci_quirk alc883_cfg_tbl[] = { | |
7163 | SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG), | |
febe3375 | 7164 | SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG), |
f5fcc13c TI |
7165 | SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch), |
7166 | SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD), | |
7167 | SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG), | |
57b14f24 | 7168 | SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG), |
f5fcc13c TI |
7169 | SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG), |
7170 | SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG), | |
799f88a3 | 7171 | SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG), |
2a296cb6 | 7172 | SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG), |
2dcd522f | 7173 | SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG), |
6f3bf657 | 7174 | SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG), |
f5fcc13c | 7175 | SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG), |
dd146a60 | 7176 | SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG), |
f5fcc13c TI |
7177 | SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG), |
7178 | SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG), | |
7179 | SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG), | |
7180 | SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG), | |
7181 | SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG), | |
64ca1c29 | 7182 | SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG), |
f5fcc13c TI |
7183 | SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG), |
7184 | SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG), | |
7185 | SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG), | |
7186 | SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG), | |
d1a991a6 | 7187 | SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE), |
2880a867 | 7188 | SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE), |
8da6470e | 7189 | SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE), |
f5fcc13c | 7190 | SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), |
e60623b4 | 7191 | SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch), |
f5fcc13c TI |
7192 | SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), |
7193 | SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD), | |
7194 | SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), | |
272a527c KY |
7195 | SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch), |
7196 | SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763), | |
7197 | SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763), | |
4723c022 CM |
7198 | SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP), |
7199 | SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP), | |
7200 | SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP), | |
272a527c | 7201 | SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2), |
189609ae KY |
7202 | SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66), |
7203 | SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763), | |
11370ee2 TD |
7204 | SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG), |
7205 | SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG), | |
9c7f852e TI |
7206 | {} |
7207 | }; | |
7208 | ||
7209 | static struct alc_config_preset alc883_presets[] = { | |
7210 | [ALC883_3ST_2ch_DIG] = { | |
7211 | .mixers = { alc883_3ST_2ch_mixer }, | |
7212 | .init_verbs = { alc883_init_verbs }, | |
7213 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7214 | .dac_nids = alc883_dac_nids, | |
7215 | .dig_out_nid = ALC883_DIGOUT_NID, | |
7216 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7217 | .adc_nids = alc883_adc_nids, | |
7218 | .dig_in_nid = ALC883_DIGIN_NID, | |
7219 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
7220 | .channel_mode = alc883_3ST_2ch_modes, | |
7221 | .input_mux = &alc883_capture_source, | |
7222 | }, | |
7223 | [ALC883_3ST_6ch_DIG] = { | |
7224 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
7225 | .init_verbs = { alc883_init_verbs }, | |
7226 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7227 | .dac_nids = alc883_dac_nids, | |
7228 | .dig_out_nid = ALC883_DIGOUT_NID, | |
7229 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7230 | .adc_nids = alc883_adc_nids, | |
7231 | .dig_in_nid = ALC883_DIGIN_NID, | |
7232 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
7233 | .channel_mode = alc883_3ST_6ch_modes, | |
4e195a7b | 7234 | .need_dac_fix = 1, |
9c7f852e | 7235 | .input_mux = &alc883_capture_source, |
f12ab1e0 | 7236 | }, |
9c7f852e TI |
7237 | [ALC883_3ST_6ch] = { |
7238 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
7239 | .init_verbs = { alc883_init_verbs }, | |
7240 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7241 | .dac_nids = alc883_dac_nids, | |
7242 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7243 | .adc_nids = alc883_adc_nids, | |
7244 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
7245 | .channel_mode = alc883_3ST_6ch_modes, | |
4e195a7b | 7246 | .need_dac_fix = 1, |
9c7f852e | 7247 | .input_mux = &alc883_capture_source, |
f12ab1e0 | 7248 | }, |
9c7f852e TI |
7249 | [ALC883_6ST_DIG] = { |
7250 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, | |
7251 | .init_verbs = { alc883_init_verbs }, | |
7252 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7253 | .dac_nids = alc883_dac_nids, | |
7254 | .dig_out_nid = ALC883_DIGOUT_NID, | |
7255 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7256 | .adc_nids = alc883_adc_nids, | |
7257 | .dig_in_nid = ALC883_DIGIN_NID, | |
7258 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | |
7259 | .channel_mode = alc883_sixstack_modes, | |
7260 | .input_mux = &alc883_capture_source, | |
7261 | }, | |
ccc656ce KY |
7262 | [ALC883_TARGA_DIG] = { |
7263 | .mixers = { alc883_tagra_mixer, alc883_chmode_mixer }, | |
7264 | .init_verbs = { alc883_init_verbs, alc883_tagra_verbs}, | |
7265 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7266 | .dac_nids = alc883_dac_nids, | |
7267 | .dig_out_nid = ALC883_DIGOUT_NID, | |
7268 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7269 | .adc_nids = alc883_adc_nids, | |
7270 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
7271 | .channel_mode = alc883_3ST_6ch_modes, | |
7272 | .need_dac_fix = 1, | |
7273 | .input_mux = &alc883_capture_source, | |
7274 | .unsol_event = alc883_tagra_unsol_event, | |
7275 | .init_hook = alc883_tagra_automute, | |
7276 | }, | |
7277 | [ALC883_TARGA_2ch_DIG] = { | |
7278 | .mixers = { alc883_tagra_2ch_mixer}, | |
7279 | .init_verbs = { alc883_init_verbs, alc883_tagra_verbs}, | |
7280 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7281 | .dac_nids = alc883_dac_nids, | |
7282 | .dig_out_nid = ALC883_DIGOUT_NID, | |
7283 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7284 | .adc_nids = alc883_adc_nids, | |
7285 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
7286 | .channel_mode = alc883_3ST_2ch_modes, | |
7287 | .input_mux = &alc883_capture_source, | |
7288 | .unsol_event = alc883_tagra_unsol_event, | |
7289 | .init_hook = alc883_tagra_automute, | |
7290 | }, | |
bab282b9 | 7291 | [ALC883_ACER] = { |
676a9b53 | 7292 | .mixers = { alc883_base_mixer }, |
bab282b9 VA |
7293 | /* On TravelMate laptops, GPIO 0 enables the internal speaker |
7294 | * and the headphone jack. Turn this on and rely on the | |
7295 | * standard mute methods whenever the user wants to turn | |
7296 | * these outputs off. | |
7297 | */ | |
7298 | .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs }, | |
7299 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7300 | .dac_nids = alc883_dac_nids, | |
7301 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7302 | .adc_nids = alc883_adc_nids, | |
7303 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
7304 | .channel_mode = alc883_3ST_2ch_modes, | |
7305 | .input_mux = &alc883_capture_source, | |
7306 | }, | |
2880a867 | 7307 | [ALC883_ACER_ASPIRE] = { |
676a9b53 | 7308 | .mixers = { alc883_acer_aspire_mixer }, |
d1a991a6 | 7309 | .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs }, |
2880a867 TD |
7310 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
7311 | .dac_nids = alc883_dac_nids, | |
7312 | .dig_out_nid = ALC883_DIGOUT_NID, | |
7313 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7314 | .adc_nids = alc883_adc_nids, | |
7315 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
7316 | .channel_mode = alc883_3ST_2ch_modes, | |
7317 | .input_mux = &alc883_capture_source, | |
676a9b53 TI |
7318 | .unsol_event = alc883_acer_aspire_unsol_event, |
7319 | .init_hook = alc883_acer_aspire_automute, | |
d1a991a6 | 7320 | }, |
c07584c8 TD |
7321 | [ALC883_MEDION] = { |
7322 | .mixers = { alc883_fivestack_mixer, | |
7323 | alc883_chmode_mixer }, | |
7324 | .init_verbs = { alc883_init_verbs, | |
b373bdeb | 7325 | alc883_medion_eapd_verbs }, |
c07584c8 TD |
7326 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
7327 | .dac_nids = alc883_dac_nids, | |
7328 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7329 | .adc_nids = alc883_adc_nids, | |
7330 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | |
7331 | .channel_mode = alc883_sixstack_modes, | |
7332 | .input_mux = &alc883_capture_source, | |
b373bdeb | 7333 | }, |
272a527c KY |
7334 | [ALC883_MEDION_MD2] = { |
7335 | .mixers = { alc883_medion_md2_mixer}, | |
7336 | .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs}, | |
7337 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7338 | .dac_nids = alc883_dac_nids, | |
7339 | .dig_out_nid = ALC883_DIGOUT_NID, | |
7340 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7341 | .adc_nids = alc883_adc_nids, | |
7342 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
7343 | .channel_mode = alc883_3ST_2ch_modes, | |
7344 | .input_mux = &alc883_capture_source, | |
7345 | .unsol_event = alc883_medion_md2_unsol_event, | |
7346 | .init_hook = alc883_medion_md2_automute, | |
7347 | }, | |
b373bdeb | 7348 | [ALC883_LAPTOP_EAPD] = { |
676a9b53 | 7349 | .mixers = { alc883_base_mixer }, |
b373bdeb AN |
7350 | .init_verbs = { alc883_init_verbs, alc882_eapd_verbs }, |
7351 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7352 | .dac_nids = alc883_dac_nids, | |
7353 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7354 | .adc_nids = alc883_adc_nids, | |
7355 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
7356 | .channel_mode = alc883_3ST_2ch_modes, | |
7357 | .input_mux = &alc883_capture_source, | |
7358 | }, | |
bc9f98a9 KY |
7359 | [ALC883_LENOVO_101E_2ch] = { |
7360 | .mixers = { alc883_lenovo_101e_2ch_mixer}, | |
7361 | .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs}, | |
7362 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7363 | .dac_nids = alc883_dac_nids, | |
7364 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7365 | .adc_nids = alc883_adc_nids, | |
7366 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
7367 | .channel_mode = alc883_3ST_2ch_modes, | |
7368 | .input_mux = &alc883_lenovo_101e_capture_source, | |
7369 | .unsol_event = alc883_lenovo_101e_unsol_event, | |
7370 | .init_hook = alc883_lenovo_101e_all_automute, | |
7371 | }, | |
272a527c KY |
7372 | [ALC883_LENOVO_NB0763] = { |
7373 | .mixers = { alc883_lenovo_nb0763_mixer }, | |
7374 | .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs}, | |
7375 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7376 | .dac_nids = alc883_dac_nids, | |
7377 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7378 | .adc_nids = alc883_adc_nids, | |
7379 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
7380 | .channel_mode = alc883_3ST_2ch_modes, | |
7381 | .need_dac_fix = 1, | |
7382 | .input_mux = &alc883_lenovo_nb0763_capture_source, | |
7383 | .unsol_event = alc883_medion_md2_unsol_event, | |
7384 | .init_hook = alc883_medion_md2_automute, | |
7385 | }, | |
7386 | [ALC888_LENOVO_MS7195_DIG] = { | |
7387 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
7388 | .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs}, | |
7389 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7390 | .dac_nids = alc883_dac_nids, | |
7391 | .dig_out_nid = ALC883_DIGOUT_NID, | |
7392 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7393 | .adc_nids = alc883_adc_nids, | |
7394 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
7395 | .channel_mode = alc883_3ST_6ch_modes, | |
7396 | .need_dac_fix = 1, | |
7397 | .input_mux = &alc883_capture_source, | |
7398 | .unsol_event = alc883_lenovo_ms7195_unsol_event, | |
7399 | .init_hook = alc888_lenovo_ms7195_front_automute, | |
189609ae KY |
7400 | }, |
7401 | [ALC883_HAIER_W66] = { | |
7402 | .mixers = { alc883_tagra_2ch_mixer}, | |
7403 | .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs}, | |
7404 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
7405 | .dac_nids = alc883_dac_nids, | |
7406 | .dig_out_nid = ALC883_DIGOUT_NID, | |
7407 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7408 | .adc_nids = alc883_adc_nids, | |
7409 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
7410 | .channel_mode = alc883_3ST_2ch_modes, | |
7411 | .input_mux = &alc883_capture_source, | |
7412 | .unsol_event = alc883_haier_w66_unsol_event, | |
7413 | .init_hook = alc883_haier_w66_automute, | |
272a527c | 7414 | }, |
4723c022 CM |
7415 | [ALC888_6ST_HP] = { |
7416 | .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer }, | |
7417 | .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs }, | |
cd1e3b40 CM |
7418 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
7419 | .dac_nids = alc883_dac_nids, | |
7420 | .dig_out_nid = ALC883_DIGOUT_NID, | |
7421 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7422 | .adc_nids = alc883_adc_nids, | |
7423 | .dig_in_nid = ALC883_DIGIN_NID, | |
7424 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | |
7425 | .channel_mode = alc883_sixstack_modes, | |
7426 | .input_mux = &alc883_capture_source, | |
7427 | }, | |
4723c022 CM |
7428 | [ALC888_3ST_HP] = { |
7429 | .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer }, | |
7430 | .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs }, | |
8341de60 CM |
7431 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
7432 | .dac_nids = alc883_dac_nids, | |
7433 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | |
7434 | .adc_nids = alc883_adc_nids, | |
4723c022 CM |
7435 | .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes), |
7436 | .channel_mode = alc888_3st_hp_modes, | |
8341de60 CM |
7437 | .need_dac_fix = 1, |
7438 | .input_mux = &alc883_capture_source, | |
7439 | }, | |
9c7f852e TI |
7440 | }; |
7441 | ||
7442 | ||
7443 | /* | |
7444 | * BIOS auto configuration | |
7445 | */ | |
7446 | static void alc883_auto_set_output_and_unmute(struct hda_codec *codec, | |
7447 | hda_nid_t nid, int pin_type, | |
7448 | int dac_idx) | |
7449 | { | |
7450 | /* set as output */ | |
7451 | struct alc_spec *spec = codec->spec; | |
f12ab1e0 TI |
7452 | int idx; |
7453 | ||
9c7f852e TI |
7454 | if (spec->multiout.dac_nids[dac_idx] == 0x25) |
7455 | idx = 4; | |
7456 | else | |
7457 | idx = spec->multiout.dac_nids[dac_idx] - 2; | |
7458 | ||
7459 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
7460 | pin_type); | |
7461 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
7462 | AMP_OUT_UNMUTE); | |
7463 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); | |
7464 | ||
7465 | } | |
7466 | ||
7467 | static void alc883_auto_init_multi_out(struct hda_codec *codec) | |
7468 | { | |
7469 | struct alc_spec *spec = codec->spec; | |
7470 | int i; | |
7471 | ||
bc9f98a9 | 7472 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
9c7f852e | 7473 | for (i = 0; i <= HDA_SIDE; i++) { |
f12ab1e0 | 7474 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
baba8ee9 | 7475 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
9c7f852e | 7476 | if (nid) |
baba8ee9 | 7477 | alc883_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 7478 | i); |
9c7f852e TI |
7479 | } |
7480 | } | |
7481 | ||
7482 | static void alc883_auto_init_hp_out(struct hda_codec *codec) | |
7483 | { | |
7484 | struct alc_spec *spec = codec->spec; | |
7485 | hda_nid_t pin; | |
7486 | ||
eb06ed8f | 7487 | pin = spec->autocfg.hp_pins[0]; |
9c7f852e TI |
7488 | if (pin) /* connect to front */ |
7489 | /* use dac 0 */ | |
7490 | alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
7491 | } | |
7492 | ||
7493 | #define alc883_is_input_pin(nid) alc880_is_input_pin(nid) | |
7494 | #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID | |
7495 | ||
7496 | static void alc883_auto_init_analog_input(struct hda_codec *codec) | |
7497 | { | |
7498 | struct alc_spec *spec = codec->spec; | |
7499 | int i; | |
7500 | ||
7501 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
7502 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
7503 | if (alc883_is_input_pin(nid)) { | |
7504 | snd_hda_codec_write(codec, nid, 0, | |
7505 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
7506 | (i <= AUTO_PIN_FRONT_MIC ? | |
7507 | PIN_VREF80 : PIN_IN)); | |
7508 | if (nid != ALC883_PIN_CD_NID) | |
7509 | snd_hda_codec_write(codec, nid, 0, | |
7510 | AC_VERB_SET_AMP_GAIN_MUTE, | |
7511 | AMP_OUT_MUTE); | |
7512 | } | |
7513 | } | |
7514 | } | |
7515 | ||
7516 | /* almost identical with ALC880 parser... */ | |
7517 | static int alc883_parse_auto_config(struct hda_codec *codec) | |
7518 | { | |
7519 | struct alc_spec *spec = codec->spec; | |
7520 | int err = alc880_parse_auto_config(codec); | |
7521 | ||
7522 | if (err < 0) | |
7523 | return err; | |
776e184e TI |
7524 | else if (!err) |
7525 | return 0; /* no config found */ | |
7526 | ||
7527 | err = alc_auto_add_mic_boost(codec); | |
7528 | if (err < 0) | |
7529 | return err; | |
7530 | ||
7531 | /* hack - override the init verbs */ | |
7532 | spec->init_verbs[0] = alc883_auto_init_verbs; | |
bc9f98a9 KY |
7533 | spec->mixers[spec->num_mixers] = alc883_capture_mixer; |
7534 | spec->num_mixers++; | |
776e184e TI |
7535 | |
7536 | return 1; /* config found */ | |
9c7f852e TI |
7537 | } |
7538 | ||
7539 | /* additional initialization for auto-configuration model */ | |
7540 | static void alc883_auto_init(struct hda_codec *codec) | |
7541 | { | |
7542 | alc883_auto_init_multi_out(codec); | |
7543 | alc883_auto_init_hp_out(codec); | |
7544 | alc883_auto_init_analog_input(codec); | |
7545 | } | |
7546 | ||
7547 | static int patch_alc883(struct hda_codec *codec) | |
7548 | { | |
7549 | struct alc_spec *spec; | |
7550 | int err, board_config; | |
7551 | ||
7552 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
7553 | if (spec == NULL) | |
7554 | return -ENOMEM; | |
7555 | ||
7556 | codec->spec = spec; | |
7557 | ||
f5fcc13c TI |
7558 | board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST, |
7559 | alc883_models, | |
7560 | alc883_cfg_tbl); | |
7561 | if (board_config < 0) { | |
9c7f852e TI |
7562 | printk(KERN_INFO "hda_codec: Unknown model for ALC883, " |
7563 | "trying auto-probe from BIOS...\n"); | |
7564 | board_config = ALC883_AUTO; | |
7565 | } | |
7566 | ||
7567 | if (board_config == ALC883_AUTO) { | |
7568 | /* automatic parse from the BIOS config */ | |
7569 | err = alc883_parse_auto_config(codec); | |
7570 | if (err < 0) { | |
7571 | alc_free(codec); | |
7572 | return err; | |
f12ab1e0 | 7573 | } else if (!err) { |
9c7f852e TI |
7574 | printk(KERN_INFO |
7575 | "hda_codec: Cannot set up configuration " | |
7576 | "from BIOS. Using base mode...\n"); | |
7577 | board_config = ALC883_3ST_2ch_DIG; | |
7578 | } | |
7579 | } | |
7580 | ||
7581 | if (board_config != ALC883_AUTO) | |
7582 | setup_preset(spec, &alc883_presets[board_config]); | |
7583 | ||
7584 | spec->stream_name_analog = "ALC883 Analog"; | |
7585 | spec->stream_analog_playback = &alc883_pcm_analog_playback; | |
7586 | spec->stream_analog_capture = &alc883_pcm_analog_capture; | |
7587 | ||
7588 | spec->stream_name_digital = "ALC883 Digital"; | |
7589 | spec->stream_digital_playback = &alc883_pcm_digital_playback; | |
7590 | spec->stream_digital_capture = &alc883_pcm_digital_capture; | |
7591 | ||
f12ab1e0 | 7592 | if (!spec->adc_nids && spec->input_mux) { |
4b146cb0 TI |
7593 | spec->adc_nids = alc883_adc_nids; |
7594 | spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); | |
7595 | } | |
9c7f852e TI |
7596 | |
7597 | codec->patch_ops = alc_patch_ops; | |
7598 | if (board_config == ALC883_AUTO) | |
7599 | spec->init_hook = alc883_auto_init; | |
cb53c626 TI |
7600 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
7601 | if (!spec->loopback.amplist) | |
7602 | spec->loopback.amplist = alc883_loopbacks; | |
7603 | #endif | |
9c7f852e TI |
7604 | |
7605 | return 0; | |
7606 | } | |
7607 | ||
7608 | /* | |
7609 | * ALC262 support | |
7610 | */ | |
7611 | ||
7612 | #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID | |
7613 | #define ALC262_DIGIN_NID ALC880_DIGIN_NID | |
7614 | ||
7615 | #define alc262_dac_nids alc260_dac_nids | |
7616 | #define alc262_adc_nids alc882_adc_nids | |
7617 | #define alc262_adc_nids_alt alc882_adc_nids_alt | |
7618 | ||
7619 | #define alc262_modes alc260_modes | |
7620 | #define alc262_capture_source alc882_capture_source | |
7621 | ||
7622 | static struct snd_kcontrol_new alc262_base_mixer[] = { | |
7623 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7624 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7625 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7626 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7627 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7628 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7629 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7630 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 7631 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
7632 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
7633 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 7634 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
7635 | /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), |
7636 | HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */ | |
7637 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT), | |
7638 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
7639 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
7640 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | |
7641 | { } /* end */ | |
7642 | }; | |
7643 | ||
ccc656ce KY |
7644 | static struct snd_kcontrol_new alc262_hippo1_mixer[] = { |
7645 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7646 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7647 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7648 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7649 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7650 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7651 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7652 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 7653 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce KY |
7654 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
7655 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 7656 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
ccc656ce KY |
7657 | /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), |
7658 | HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */ | |
7659 | /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/ | |
7660 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7661 | { } /* end */ | |
7662 | }; | |
7663 | ||
9c7f852e TI |
7664 | static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = { |
7665 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7666 | HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
7667 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7668 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
7669 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | |
7670 | ||
7671 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7672 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 7673 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
7674 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
7675 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 7676 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
7677 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
7678 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7679 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7680 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7681 | HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
7682 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
7683 | HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT), | |
7684 | HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT), | |
7685 | { } /* end */ | |
7686 | }; | |
7687 | ||
cd7509a4 KY |
7688 | static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = { |
7689 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7690 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7691 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7692 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
7693 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
7694 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | |
7695 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7696 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
cc69d12d | 7697 | HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT), |
cd7509a4 KY |
7698 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), |
7699 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
7700 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7701 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7702 | HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
7703 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
7704 | { } /* end */ | |
7705 | }; | |
7706 | ||
7707 | static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = { | |
7708 | HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7709 | HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 7710 | HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT), |
cd7509a4 KY |
7711 | { } /* end */ |
7712 | }; | |
7713 | ||
66d2a9d6 KY |
7714 | static struct hda_bind_ctls alc262_hp_t5735_bind_front_vol = { |
7715 | .ops = &snd_hda_bind_vol, | |
7716 | .values = { | |
7717 | HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT), | |
7718 | HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT), | |
7719 | 0 | |
7720 | }, | |
7721 | }; | |
7722 | ||
7723 | static struct hda_bind_ctls alc262_hp_t5735_bind_front_sw = { | |
7724 | .ops = &snd_hda_bind_sw, | |
7725 | .values = { | |
7726 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
7727 | HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | |
7728 | 0 | |
7729 | }, | |
7730 | }; | |
7731 | ||
7732 | /* mute/unmute internal speaker according to the hp jack and mute state */ | |
7733 | static void alc262_hp_t5735_automute(struct hda_codec *codec, int force) | |
7734 | { | |
7735 | struct alc_spec *spec = codec->spec; | |
7736 | unsigned int mute; | |
7737 | ||
7738 | if (force || !spec->sense_updated) { | |
7739 | unsigned int present; | |
7740 | present = snd_hda_codec_read(codec, 0x15, 0, | |
7741 | AC_VERB_GET_PIN_SENSE, 0); | |
7742 | spec->jack_present = (present & 0x80000000) != 0; | |
7743 | spec->sense_updated = 1; | |
7744 | } | |
7745 | if (spec->jack_present) | |
7746 | mute = (0x7080 | ((0)<<8)); /* mute internal speaker */ | |
7747 | else /* unmute internal speaker if necessary */ | |
7748 | mute = (0x7000 | ((0)<<8)); | |
7749 | snd_hda_codec_write(codec, 0x0c, 0, | |
7750 | AC_VERB_SET_AMP_GAIN_MUTE, mute ); | |
7751 | } | |
7752 | ||
7753 | static void alc262_hp_t5735_unsol_event(struct hda_codec *codec, | |
7754 | unsigned int res) | |
7755 | { | |
7756 | if ((res >> 26) != ALC880_HP_EVENT) | |
7757 | return; | |
7758 | alc262_hp_t5735_automute(codec, 1); | |
7759 | } | |
7760 | ||
7761 | static void alc262_hp_t5735_init_hook(struct hda_codec *codec) | |
7762 | { | |
7763 | alc262_hp_t5735_automute(codec, 1); | |
7764 | } | |
7765 | ||
7766 | static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = { | |
7767 | HDA_BIND_VOL("PCM Playback Volume", &alc262_hp_t5735_bind_front_vol), | |
7768 | HDA_BIND_SW("PCM Playback Switch",&alc262_hp_t5735_bind_front_sw), | |
7769 | HDA_CODEC_VOLUME("LineOut Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7770 | HDA_CODEC_MUTE("LineOut Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7771 | HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7772 | HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7773 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7774 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
7775 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7776 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7777 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7778 | { } /* end */ | |
7779 | }; | |
7780 | ||
7781 | static struct hda_verb alc262_hp_t5735_verbs[] = { | |
7782 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7783 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7784 | ||
7785 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7786 | { } | |
7787 | }; | |
7788 | ||
0724ea2a TI |
7789 | /* bind hp and internal speaker mute (with plug check) */ |
7790 | static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol, | |
7791 | struct snd_ctl_elem_value *ucontrol) | |
7792 | { | |
7793 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
7794 | long *valp = ucontrol->value.integer.value; | |
7795 | int change; | |
7796 | ||
7797 | /* change hp mute */ | |
7798 | change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, | |
7799 | HDA_AMP_MUTE, | |
7800 | valp[0] ? 0 : HDA_AMP_MUTE); | |
7801 | change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, | |
7802 | HDA_AMP_MUTE, | |
7803 | valp[1] ? 0 : HDA_AMP_MUTE); | |
7804 | if (change) { | |
7805 | /* change speaker according to HP jack state */ | |
7806 | struct alc_spec *spec = codec->spec; | |
7807 | unsigned int mute; | |
7808 | if (spec->jack_present) | |
7809 | mute = HDA_AMP_MUTE; | |
7810 | else | |
7811 | mute = snd_hda_codec_amp_read(codec, 0x15, 0, | |
7812 | HDA_OUTPUT, 0); | |
7813 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
7814 | HDA_AMP_MUTE, mute); | |
7815 | } | |
7816 | return change; | |
7817 | } | |
5b31954e | 7818 | |
272a527c | 7819 | static struct snd_kcontrol_new alc262_sony_mixer[] = { |
0724ea2a TI |
7820 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
7821 | { | |
7822 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7823 | .name = "Master Playback Switch", | |
7824 | .info = snd_hda_mixer_amp_switch_info, | |
7825 | .get = snd_hda_mixer_amp_switch_get, | |
7826 | .put = alc262_sony_master_sw_put, | |
7827 | .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | |
7828 | }, | |
272a527c KY |
7829 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
7830 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7831 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
7832 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
7833 | { } /* end */ | |
7834 | }; | |
7835 | ||
83c34218 KY |
7836 | static struct snd_kcontrol_new alc262_benq_t31_mixer[] = { |
7837 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7838 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7839 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
7840 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7841 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7842 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
7843 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
7844 | { } /* end */ | |
7845 | }; | |
272a527c | 7846 | |
9c7f852e TI |
7847 | #define alc262_capture_mixer alc882_capture_mixer |
7848 | #define alc262_capture_alt_mixer alc882_capture_alt_mixer | |
7849 | ||
7850 | /* | |
7851 | * generic initialization of ADC, input mixers and output mixers | |
7852 | */ | |
7853 | static struct hda_verb alc262_init_verbs[] = { | |
7854 | /* | |
7855 | * Unmute ADC0-2 and set the default input to mic-in | |
7856 | */ | |
7857 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7858 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7859 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7860 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7861 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7862 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7863 | ||
cb53c626 | 7864 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
9c7f852e | 7865 | * mixer widget |
f12ab1e0 TI |
7866 | * Note: PASD motherboards uses the Line In 2 as the input for |
7867 | * front panel mic (mic 2) | |
9c7f852e TI |
7868 | */ |
7869 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
7870 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
7871 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7872 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
7873 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
7874 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9c7f852e TI |
7875 | |
7876 | /* | |
df694daa KY |
7877 | * Set up output mixers (0x0c - 0x0e) |
7878 | */ | |
7879 | /* set vol=0 to output mixers */ | |
7880 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7881 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7882 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7883 | /* set up input amps for analog loopback */ | |
7884 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
7885 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7886 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7887 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7888 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7889 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7890 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7891 | ||
7892 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
7893 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
7894 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
7895 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
7896 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
7897 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
7898 | ||
7899 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
7900 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
7901 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
7902 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
7903 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
7904 | ||
7905 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7906 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
7907 | ||
7908 | /* FIXME: use matrix-type input source selection */ | |
7909 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
7910 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
7911 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
7912 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
7913 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
7914 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
7915 | /* Input mixer2 */ | |
7916 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
7917 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
7918 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
7919 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
7920 | /* Input mixer3 */ | |
7921 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
7922 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
7923 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
f12ab1e0 | 7924 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
df694daa KY |
7925 | |
7926 | { } | |
7927 | }; | |
1da177e4 | 7928 | |
ccc656ce KY |
7929 | static struct hda_verb alc262_hippo_unsol_verbs[] = { |
7930 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
7931 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7932 | {} | |
7933 | }; | |
7934 | ||
7935 | static struct hda_verb alc262_hippo1_unsol_verbs[] = { | |
7936 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
7937 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7938 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
7939 | ||
7940 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
7941 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7942 | {} | |
7943 | }; | |
7944 | ||
272a527c KY |
7945 | static struct hda_verb alc262_sony_unsol_verbs[] = { |
7946 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
7947 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7948 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic | |
7949 | ||
7950 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
7951 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7952 | }; | |
7953 | ||
ccc656ce | 7954 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
5b31954e | 7955 | static void alc262_hippo_automute(struct hda_codec *codec) |
ccc656ce KY |
7956 | { |
7957 | struct alc_spec *spec = codec->spec; | |
7958 | unsigned int mute; | |
5b31954e | 7959 | unsigned int present; |
ccc656ce | 7960 | |
5b31954e TI |
7961 | /* need to execute and sync at first */ |
7962 | snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); | |
7963 | present = snd_hda_codec_read(codec, 0x15, 0, | |
7964 | AC_VERB_GET_PIN_SENSE, 0); | |
7965 | spec->jack_present = (present & 0x80000000) != 0; | |
ccc656ce KY |
7966 | if (spec->jack_present) { |
7967 | /* mute internal speaker */ | |
47fd830a TI |
7968 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
7969 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
ccc656ce KY |
7970 | } else { |
7971 | /* unmute internal speaker if necessary */ | |
7972 | mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0); | |
47fd830a TI |
7973 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
7974 | HDA_AMP_MUTE, mute); | |
ccc656ce KY |
7975 | } |
7976 | } | |
7977 | ||
7978 | /* unsolicited event for HP jack sensing */ | |
7979 | static void alc262_hippo_unsol_event(struct hda_codec *codec, | |
7980 | unsigned int res) | |
7981 | { | |
7982 | if ((res >> 26) != ALC880_HP_EVENT) | |
7983 | return; | |
5b31954e | 7984 | alc262_hippo_automute(codec); |
ccc656ce KY |
7985 | } |
7986 | ||
5b31954e | 7987 | static void alc262_hippo1_automute(struct hda_codec *codec) |
ccc656ce | 7988 | { |
ccc656ce | 7989 | unsigned int mute; |
5b31954e | 7990 | unsigned int present; |
ccc656ce | 7991 | |
5b31954e TI |
7992 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); |
7993 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
7994 | AC_VERB_GET_PIN_SENSE, 0); | |
7995 | present = (present & 0x80000000) != 0; | |
7996 | if (present) { | |
ccc656ce | 7997 | /* mute internal speaker */ |
47fd830a TI |
7998 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
7999 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
ccc656ce KY |
8000 | } else { |
8001 | /* unmute internal speaker if necessary */ | |
8002 | mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); | |
47fd830a TI |
8003 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
8004 | HDA_AMP_MUTE, mute); | |
ccc656ce KY |
8005 | } |
8006 | } | |
8007 | ||
8008 | /* unsolicited event for HP jack sensing */ | |
8009 | static void alc262_hippo1_unsol_event(struct hda_codec *codec, | |
8010 | unsigned int res) | |
8011 | { | |
8012 | if ((res >> 26) != ALC880_HP_EVENT) | |
8013 | return; | |
5b31954e | 8014 | alc262_hippo1_automute(codec); |
ccc656ce KY |
8015 | } |
8016 | ||
834be88d TI |
8017 | /* |
8018 | * fujitsu model | |
8019 | * 0x14 = headphone/spdif-out, 0x15 = internal speaker | |
8020 | */ | |
8021 | ||
8022 | #define ALC_HP_EVENT 0x37 | |
8023 | ||
8024 | static struct hda_verb alc262_fujitsu_unsol_verbs[] = { | |
8025 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, | |
8026 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
8027 | {} | |
8028 | }; | |
8029 | ||
8030 | static struct hda_input_mux alc262_fujitsu_capture_source = { | |
39d3ed38 | 8031 | .num_items = 3, |
834be88d TI |
8032 | .items = { |
8033 | { "Mic", 0x0 }, | |
39d3ed38 | 8034 | { "Int Mic", 0x1 }, |
834be88d TI |
8035 | { "CD", 0x4 }, |
8036 | }, | |
8037 | }; | |
8038 | ||
9c7f852e TI |
8039 | static struct hda_input_mux alc262_HP_capture_source = { |
8040 | .num_items = 5, | |
8041 | .items = { | |
8042 | { "Mic", 0x0 }, | |
accbe498 | 8043 | { "Front Mic", 0x1 }, |
9c7f852e TI |
8044 | { "Line", 0x2 }, |
8045 | { "CD", 0x4 }, | |
8046 | { "AUX IN", 0x6 }, | |
8047 | }, | |
8048 | }; | |
8049 | ||
accbe498 | 8050 | static struct hda_input_mux alc262_HP_D7000_capture_source = { |
8051 | .num_items = 4, | |
8052 | .items = { | |
8053 | { "Mic", 0x0 }, | |
8054 | { "Front Mic", 0x2 }, | |
8055 | { "Line", 0x1 }, | |
8056 | { "CD", 0x4 }, | |
8057 | }, | |
8058 | }; | |
8059 | ||
834be88d TI |
8060 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
8061 | static void alc262_fujitsu_automute(struct hda_codec *codec, int force) | |
8062 | { | |
8063 | struct alc_spec *spec = codec->spec; | |
8064 | unsigned int mute; | |
8065 | ||
f12ab1e0 | 8066 | if (force || !spec->sense_updated) { |
834be88d TI |
8067 | unsigned int present; |
8068 | /* need to execute and sync at first */ | |
8069 | snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); | |
8070 | present = snd_hda_codec_read(codec, 0x14, 0, | |
8071 | AC_VERB_GET_PIN_SENSE, 0); | |
8072 | spec->jack_present = (present & 0x80000000) != 0; | |
8073 | spec->sense_updated = 1; | |
8074 | } | |
8075 | if (spec->jack_present) { | |
8076 | /* mute internal speaker */ | |
47fd830a TI |
8077 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
8078 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
834be88d TI |
8079 | } else { |
8080 | /* unmute internal speaker if necessary */ | |
8081 | mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); | |
47fd830a TI |
8082 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
8083 | HDA_AMP_MUTE, mute); | |
834be88d TI |
8084 | } |
8085 | } | |
8086 | ||
8087 | /* unsolicited event for HP jack sensing */ | |
8088 | static void alc262_fujitsu_unsol_event(struct hda_codec *codec, | |
8089 | unsigned int res) | |
8090 | { | |
8091 | if ((res >> 26) != ALC_HP_EVENT) | |
8092 | return; | |
8093 | alc262_fujitsu_automute(codec, 1); | |
8094 | } | |
8095 | ||
8096 | /* bind volumes of both NID 0x0c and 0x0d */ | |
cca3b371 TI |
8097 | static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = { |
8098 | .ops = &snd_hda_bind_vol, | |
8099 | .values = { | |
8100 | HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT), | |
8101 | HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT), | |
8102 | 0 | |
8103 | }, | |
8104 | }; | |
834be88d TI |
8105 | |
8106 | /* bind hp and internal speaker mute (with plug check) */ | |
8107 | static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol, | |
8108 | struct snd_ctl_elem_value *ucontrol) | |
8109 | { | |
8110 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
8111 | long *valp = ucontrol->value.integer.value; | |
8112 | int change; | |
8113 | ||
8114 | change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, | |
47fd830a TI |
8115 | HDA_AMP_MUTE, |
8116 | valp[0] ? 0 : HDA_AMP_MUTE); | |
834be88d | 8117 | change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, |
47fd830a TI |
8118 | HDA_AMP_MUTE, |
8119 | valp[1] ? 0 : HDA_AMP_MUTE); | |
82beb8fd TI |
8120 | if (change) |
8121 | alc262_fujitsu_automute(codec, 0); | |
834be88d TI |
8122 | return change; |
8123 | } | |
8124 | ||
8125 | static struct snd_kcontrol_new alc262_fujitsu_mixer[] = { | |
cca3b371 | 8126 | HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol), |
834be88d TI |
8127 | { |
8128 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
8129 | .name = "Master Playback Switch", | |
8130 | .info = snd_hda_mixer_amp_switch_info, | |
8131 | .get = snd_hda_mixer_amp_switch_get, | |
8132 | .put = alc262_fujitsu_master_sw_put, | |
8133 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
8134 | }, | |
8135 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
8136 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
8137 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
8138 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
8139 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
39d3ed38 TI |
8140 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), |
8141 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
8142 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
834be88d TI |
8143 | { } /* end */ |
8144 | }; | |
8145 | ||
304dcaac TI |
8146 | /* additional init verbs for Benq laptops */ |
8147 | static struct hda_verb alc262_EAPD_verbs[] = { | |
8148 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
8149 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
8150 | {} | |
8151 | }; | |
8152 | ||
83c34218 KY |
8153 | static struct hda_verb alc262_benq_t31_EAPD_verbs[] = { |
8154 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8155 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
8156 | ||
8157 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
8158 | {0x20, AC_VERB_SET_PROC_COEF, 0x3050}, | |
8159 | {} | |
8160 | }; | |
8161 | ||
f651b50b TD |
8162 | /* Samsung Q1 Ultra Vista model setup */ |
8163 | static struct snd_kcontrol_new alc262_ultra_mixer[] = { | |
8164 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
8165 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
8166 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
8167 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
8168 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
8169 | HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT), | |
8170 | { } /* end */ | |
8171 | }; | |
8172 | ||
8173 | static struct hda_verb alc262_ultra_verbs[] = { | |
8174 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
8175 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
8176 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
8177 | /* Mic is on Node 0x19 */ | |
8178 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
8179 | {0x22, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
8180 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
8181 | {0x23, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
8182 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
8183 | {0x24, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
8184 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
8185 | {} | |
8186 | }; | |
8187 | ||
8188 | static struct hda_input_mux alc262_ultra_capture_source = { | |
8189 | .num_items = 1, | |
8190 | .items = { | |
8191 | { "Mic", 0x1 }, | |
8192 | }, | |
8193 | }; | |
8194 | ||
8195 | /* mute/unmute internal speaker according to the hp jack and mute state */ | |
8196 | static void alc262_ultra_automute(struct hda_codec *codec) | |
8197 | { | |
8198 | struct alc_spec *spec = codec->spec; | |
8199 | unsigned int mute; | |
8200 | unsigned int present; | |
8201 | ||
8202 | /* need to execute and sync at first */ | |
8203 | snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); | |
8204 | present = snd_hda_codec_read(codec, 0x15, 0, | |
8205 | AC_VERB_GET_PIN_SENSE, 0); | |
8206 | spec->jack_present = (present & 0x80000000) != 0; | |
8207 | if (spec->jack_present) { | |
8208 | /* mute internal speaker */ | |
8209 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
8210 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
8211 | } else { | |
8212 | /* unmute internal speaker if necessary */ | |
8213 | mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0); | |
8214 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
8215 | HDA_AMP_MUTE, mute); | |
8216 | } | |
8217 | } | |
8218 | ||
8219 | /* unsolicited event for HP jack sensing */ | |
8220 | static void alc262_ultra_unsol_event(struct hda_codec *codec, | |
8221 | unsigned int res) | |
8222 | { | |
8223 | if ((res >> 26) != ALC880_HP_EVENT) | |
8224 | return; | |
8225 | alc262_ultra_automute(codec); | |
8226 | } | |
8227 | ||
df694daa | 8228 | /* add playback controls from the parsed DAC table */ |
f12ab1e0 TI |
8229 | static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, |
8230 | const struct auto_pin_cfg *cfg) | |
df694daa KY |
8231 | { |
8232 | hda_nid_t nid; | |
8233 | int err; | |
8234 | ||
8235 | spec->multiout.num_dacs = 1; /* only use one dac */ | |
8236 | spec->multiout.dac_nids = spec->private_dac_nids; | |
8237 | spec->multiout.dac_nids[0] = 2; | |
8238 | ||
8239 | nid = cfg->line_out_pins[0]; | |
8240 | if (nid) { | |
f12ab1e0 TI |
8241 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
8242 | "Front Playback Volume", | |
8243 | HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT)); | |
8244 | if (err < 0) | |
df694daa | 8245 | return err; |
f12ab1e0 TI |
8246 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
8247 | "Front Playback Switch", | |
8248 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
8249 | if (err < 0) | |
df694daa KY |
8250 | return err; |
8251 | } | |
8252 | ||
82bc955f | 8253 | nid = cfg->speaker_pins[0]; |
df694daa KY |
8254 | if (nid) { |
8255 | if (nid == 0x16) { | |
f12ab1e0 TI |
8256 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
8257 | "Speaker Playback Volume", | |
8258 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, | |
8259 | HDA_OUTPUT)); | |
8260 | if (err < 0) | |
df694daa | 8261 | return err; |
f12ab1e0 TI |
8262 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
8263 | "Speaker Playback Switch", | |
8264 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
8265 | HDA_OUTPUT)); | |
8266 | if (err < 0) | |
df694daa KY |
8267 | return err; |
8268 | } else { | |
f12ab1e0 TI |
8269 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
8270 | "Speaker Playback Switch", | |
8271 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
8272 | HDA_OUTPUT)); | |
8273 | if (err < 0) | |
df694daa KY |
8274 | return err; |
8275 | } | |
8276 | } | |
eb06ed8f | 8277 | nid = cfg->hp_pins[0]; |
df694daa KY |
8278 | if (nid) { |
8279 | /* spec->multiout.hp_nid = 2; */ | |
8280 | if (nid == 0x16) { | |
f12ab1e0 TI |
8281 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
8282 | "Headphone Playback Volume", | |
8283 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, | |
8284 | HDA_OUTPUT)); | |
8285 | if (err < 0) | |
df694daa | 8286 | return err; |
f12ab1e0 TI |
8287 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
8288 | "Headphone Playback Switch", | |
8289 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
8290 | HDA_OUTPUT)); | |
8291 | if (err < 0) | |
df694daa KY |
8292 | return err; |
8293 | } else { | |
f12ab1e0 TI |
8294 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
8295 | "Headphone Playback Switch", | |
8296 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
8297 | HDA_OUTPUT)); | |
8298 | if (err < 0) | |
df694daa KY |
8299 | return err; |
8300 | } | |
8301 | } | |
f12ab1e0 | 8302 | return 0; |
df694daa KY |
8303 | } |
8304 | ||
8305 | /* identical with ALC880 */ | |
f12ab1e0 TI |
8306 | #define alc262_auto_create_analog_input_ctls \ |
8307 | alc880_auto_create_analog_input_ctls | |
df694daa KY |
8308 | |
8309 | /* | |
8310 | * generic initialization of ADC, input mixers and output mixers | |
8311 | */ | |
8312 | static struct hda_verb alc262_volume_init_verbs[] = { | |
8313 | /* | |
8314 | * Unmute ADC0-2 and set the default input to mic-in | |
8315 | */ | |
8316 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8317 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8318 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8319 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8320 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8321 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8322 | ||
cb53c626 | 8323 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
df694daa | 8324 | * mixer widget |
f12ab1e0 TI |
8325 | * Note: PASD motherboards uses the Line In 2 as the input for |
8326 | * front panel mic (mic 2) | |
df694daa KY |
8327 | */ |
8328 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
8329 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
8330 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
8331 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
8332 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
8333 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
8334 | |
8335 | /* | |
8336 | * Set up output mixers (0x0c - 0x0f) | |
8337 | */ | |
8338 | /* set vol=0 to output mixers */ | |
8339 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8340 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8341 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8342 | ||
8343 | /* set up input amps for analog loopback */ | |
8344 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
8345 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8346 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8347 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8348 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8349 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8350 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8351 | ||
8352 | /* FIXME: use matrix-type input source selection */ | |
8353 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
8354 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
8355 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
8356 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
8357 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
8358 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
8359 | /* Input mixer2 */ | |
8360 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
8361 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
8362 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
8363 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
8364 | /* Input mixer3 */ | |
8365 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
8366 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
8367 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
8368 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
8369 | ||
8370 | { } | |
8371 | }; | |
8372 | ||
9c7f852e TI |
8373 | static struct hda_verb alc262_HP_BPC_init_verbs[] = { |
8374 | /* | |
8375 | * Unmute ADC0-2 and set the default input to mic-in | |
8376 | */ | |
8377 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8378 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8379 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8380 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8381 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8382 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8383 | ||
cb53c626 | 8384 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
9c7f852e | 8385 | * mixer widget |
f12ab1e0 TI |
8386 | * Note: PASD motherboards uses the Line In 2 as the input for |
8387 | * front panel mic (mic 2) | |
9c7f852e TI |
8388 | */ |
8389 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
8390 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
8391 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
8392 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
8393 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
8394 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
8395 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
8396 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
9c7f852e TI |
8397 | |
8398 | /* | |
8399 | * Set up output mixers (0x0c - 0x0e) | |
8400 | */ | |
8401 | /* set vol=0 to output mixers */ | |
8402 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8403 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8404 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8405 | ||
8406 | /* set up input amps for analog loopback */ | |
8407 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
8408 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8409 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8410 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8411 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8412 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8413 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8414 | ||
8415 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
8416 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
8417 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
8418 | ||
8419 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
8420 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
8421 | ||
8422 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8423 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8424 | ||
8425 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
8426 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
8427 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
8428 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
8429 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
8430 | ||
8431 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
8432 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
8433 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
8434 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
8435 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
8436 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
8437 | ||
8438 | ||
8439 | /* FIXME: use matrix-type input source selection */ | |
8440 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
8441 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
8442 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
8443 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
8444 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
8445 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
8446 | /* Input mixer2 */ | |
8447 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
8448 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
8449 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
8450 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
8451 | /* Input mixer3 */ | |
8452 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
8453 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
8454 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
8455 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
8456 | ||
8457 | { } | |
8458 | }; | |
8459 | ||
cd7509a4 KY |
8460 | static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = { |
8461 | /* | |
8462 | * Unmute ADC0-2 and set the default input to mic-in | |
8463 | */ | |
8464 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8465 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8466 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8467 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8468 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8469 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8470 | ||
cb53c626 | 8471 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
cd7509a4 KY |
8472 | * mixer widget |
8473 | * Note: PASD motherboards uses the Line In 2 as the input for front | |
8474 | * panel mic (mic 2) | |
8475 | */ | |
8476 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
8477 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
8478 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
8479 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
8480 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
8481 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
8482 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
8483 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
8484 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
cd7509a4 KY |
8485 | /* |
8486 | * Set up output mixers (0x0c - 0x0e) | |
8487 | */ | |
8488 | /* set vol=0 to output mixers */ | |
8489 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8490 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8491 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8492 | ||
8493 | /* set up input amps for analog loopback */ | |
8494 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
8495 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8496 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8497 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8498 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8499 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8500 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8501 | ||
8502 | ||
8503 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */ | |
8504 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */ | |
8505 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */ | |
8506 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */ | |
8507 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */ | |
8508 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */ | |
8509 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */ | |
8510 | ||
8511 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
8512 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
8513 | ||
8514 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
8515 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
8516 | ||
8517 | /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */ | |
8518 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
8519 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
8520 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
8521 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
8522 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
8523 | ||
8524 | /* FIXME: use matrix-type input source selection */ | |
8525 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
8526 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
8527 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/ | |
8528 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/ | |
8529 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/ | |
8530 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/ | |
8531 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/ | |
8532 | /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
8533 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/ | |
8534 | /* Input mixer2 */ | |
8535 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
8536 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
8537 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
8538 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
8539 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
8540 | /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
8541 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, | |
8542 | /* Input mixer3 */ | |
8543 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
8544 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
8545 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
8546 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
8547 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
8548 | /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
8549 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, | |
8550 | ||
8551 | { } | |
8552 | }; | |
8553 | ||
cb53c626 TI |
8554 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
8555 | #define alc262_loopbacks alc880_loopbacks | |
8556 | #endif | |
8557 | ||
df694daa KY |
8558 | /* pcm configuration: identiacal with ALC880 */ |
8559 | #define alc262_pcm_analog_playback alc880_pcm_analog_playback | |
8560 | #define alc262_pcm_analog_capture alc880_pcm_analog_capture | |
8561 | #define alc262_pcm_digital_playback alc880_pcm_digital_playback | |
8562 | #define alc262_pcm_digital_capture alc880_pcm_digital_capture | |
8563 | ||
8564 | /* | |
8565 | * BIOS auto configuration | |
8566 | */ | |
8567 | static int alc262_parse_auto_config(struct hda_codec *codec) | |
8568 | { | |
8569 | struct alc_spec *spec = codec->spec; | |
8570 | int err; | |
8571 | static hda_nid_t alc262_ignore[] = { 0x1d, 0 }; | |
8572 | ||
f12ab1e0 TI |
8573 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
8574 | alc262_ignore); | |
8575 | if (err < 0) | |
df694daa | 8576 | return err; |
f12ab1e0 | 8577 | if (!spec->autocfg.line_outs) |
df694daa | 8578 | return 0; /* can't find valid BIOS pin config */ |
f12ab1e0 TI |
8579 | err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg); |
8580 | if (err < 0) | |
8581 | return err; | |
8582 | err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
8583 | if (err < 0) | |
df694daa KY |
8584 | return err; |
8585 | ||
8586 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
8587 | ||
8588 | if (spec->autocfg.dig_out_pin) | |
8589 | spec->multiout.dig_out_nid = ALC262_DIGOUT_NID; | |
8590 | if (spec->autocfg.dig_in_pin) | |
8591 | spec->dig_in_nid = ALC262_DIGIN_NID; | |
8592 | ||
8593 | if (spec->kctl_alloc) | |
8594 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
8595 | ||
8596 | spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs; | |
a1e8d2da | 8597 | spec->num_mux_defs = 1; |
df694daa KY |
8598 | spec->input_mux = &spec->private_imux; |
8599 | ||
776e184e TI |
8600 | err = alc_auto_add_mic_boost(codec); |
8601 | if (err < 0) | |
8602 | return err; | |
8603 | ||
df694daa KY |
8604 | return 1; |
8605 | } | |
8606 | ||
8607 | #define alc262_auto_init_multi_out alc882_auto_init_multi_out | |
8608 | #define alc262_auto_init_hp_out alc882_auto_init_hp_out | |
8609 | #define alc262_auto_init_analog_input alc882_auto_init_analog_input | |
8610 | ||
8611 | ||
8612 | /* init callback for auto-configuration model -- overriding the default init */ | |
ae6b813a | 8613 | static void alc262_auto_init(struct hda_codec *codec) |
df694daa | 8614 | { |
df694daa KY |
8615 | alc262_auto_init_multi_out(codec); |
8616 | alc262_auto_init_hp_out(codec); | |
8617 | alc262_auto_init_analog_input(codec); | |
df694daa KY |
8618 | } |
8619 | ||
8620 | /* | |
8621 | * configuration and preset | |
8622 | */ | |
f5fcc13c TI |
8623 | static const char *alc262_models[ALC262_MODEL_LAST] = { |
8624 | [ALC262_BASIC] = "basic", | |
8625 | [ALC262_HIPPO] = "hippo", | |
8626 | [ALC262_HIPPO_1] = "hippo_1", | |
8627 | [ALC262_FUJITSU] = "fujitsu", | |
8628 | [ALC262_HP_BPC] = "hp-bpc", | |
cd7509a4 | 8629 | [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000", |
f5fcc13c | 8630 | [ALC262_BENQ_ED8] = "benq", |
0f40502e TI |
8631 | [ALC262_BENQ_T31] = "benq-t31", |
8632 | [ALC262_SONY_ASSAMD] = "sony-assamd", | |
f651b50b | 8633 | [ALC262_ULTRA] = "ultra", |
f5fcc13c TI |
8634 | [ALC262_AUTO] = "auto", |
8635 | }; | |
8636 | ||
8637 | static struct snd_pci_quirk alc262_cfg_tbl[] = { | |
8638 | SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO), | |
8639 | SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC), | |
8640 | SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC), | |
7d87de2d KY |
8641 | SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC), |
8642 | SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC), | |
b98f9334 | 8643 | SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC), |
f5fcc13c | 8644 | SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC), |
7d87de2d | 8645 | SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC), |
b98f9334 | 8646 | SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC), |
f5fcc13c | 8647 | SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC), |
7d87de2d | 8648 | SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC), |
b98f9334 | 8649 | SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC), |
cd7509a4 KY |
8650 | SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL), |
8651 | SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL), | |
8652 | SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL), | |
8653 | SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL), | |
8654 | SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF), | |
8655 | SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF), | |
8656 | SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF), | |
8657 | SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF), | |
66d2a9d6 KY |
8658 | SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735", |
8659 | ALC262_HP_TC_T5735), | |
f5fcc13c TI |
8660 | SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO), |
8661 | SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU), | |
8662 | SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1), | |
8663 | SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8), | |
83c34218 | 8664 | SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31), |
5b31954e | 8665 | SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD), |
272a527c KY |
8666 | SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD), |
8667 | SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD), | |
8668 | SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD), | |
f651b50b | 8669 | SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA), |
df694daa KY |
8670 | {} |
8671 | }; | |
8672 | ||
8673 | static struct alc_config_preset alc262_presets[] = { | |
8674 | [ALC262_BASIC] = { | |
8675 | .mixers = { alc262_base_mixer }, | |
8676 | .init_verbs = { alc262_init_verbs }, | |
8677 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
8678 | .dac_nids = alc262_dac_nids, | |
8679 | .hp_nid = 0x03, | |
8680 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
8681 | .channel_mode = alc262_modes, | |
a3bcba38 | 8682 | .input_mux = &alc262_capture_source, |
df694daa | 8683 | }, |
ccc656ce KY |
8684 | [ALC262_HIPPO] = { |
8685 | .mixers = { alc262_base_mixer }, | |
8686 | .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs}, | |
8687 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
8688 | .dac_nids = alc262_dac_nids, | |
8689 | .hp_nid = 0x03, | |
8690 | .dig_out_nid = ALC262_DIGOUT_NID, | |
8691 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
8692 | .channel_mode = alc262_modes, | |
8693 | .input_mux = &alc262_capture_source, | |
8694 | .unsol_event = alc262_hippo_unsol_event, | |
5b31954e | 8695 | .init_hook = alc262_hippo_automute, |
ccc656ce KY |
8696 | }, |
8697 | [ALC262_HIPPO_1] = { | |
8698 | .mixers = { alc262_hippo1_mixer }, | |
8699 | .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs}, | |
8700 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
8701 | .dac_nids = alc262_dac_nids, | |
8702 | .hp_nid = 0x02, | |
8703 | .dig_out_nid = ALC262_DIGOUT_NID, | |
8704 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
8705 | .channel_mode = alc262_modes, | |
8706 | .input_mux = &alc262_capture_source, | |
8707 | .unsol_event = alc262_hippo1_unsol_event, | |
5b31954e | 8708 | .init_hook = alc262_hippo1_automute, |
ccc656ce | 8709 | }, |
834be88d TI |
8710 | [ALC262_FUJITSU] = { |
8711 | .mixers = { alc262_fujitsu_mixer }, | |
39d3ed38 TI |
8712 | .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs, |
8713 | alc262_fujitsu_unsol_verbs }, | |
834be88d TI |
8714 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), |
8715 | .dac_nids = alc262_dac_nids, | |
8716 | .hp_nid = 0x03, | |
8717 | .dig_out_nid = ALC262_DIGOUT_NID, | |
8718 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
8719 | .channel_mode = alc262_modes, | |
8720 | .input_mux = &alc262_fujitsu_capture_source, | |
ae6b813a | 8721 | .unsol_event = alc262_fujitsu_unsol_event, |
834be88d | 8722 | }, |
9c7f852e TI |
8723 | [ALC262_HP_BPC] = { |
8724 | .mixers = { alc262_HP_BPC_mixer }, | |
8725 | .init_verbs = { alc262_HP_BPC_init_verbs }, | |
8726 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
8727 | .dac_nids = alc262_dac_nids, | |
8728 | .hp_nid = 0x03, | |
8729 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
8730 | .channel_mode = alc262_modes, | |
8731 | .input_mux = &alc262_HP_capture_source, | |
f12ab1e0 | 8732 | }, |
cd7509a4 KY |
8733 | [ALC262_HP_BPC_D7000_WF] = { |
8734 | .mixers = { alc262_HP_BPC_WildWest_mixer }, | |
8735 | .init_verbs = { alc262_HP_BPC_WildWest_init_verbs }, | |
8736 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
8737 | .dac_nids = alc262_dac_nids, | |
8738 | .hp_nid = 0x03, | |
8739 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
8740 | .channel_mode = alc262_modes, | |
accbe498 | 8741 | .input_mux = &alc262_HP_D7000_capture_source, |
f12ab1e0 | 8742 | }, |
cd7509a4 KY |
8743 | [ALC262_HP_BPC_D7000_WL] = { |
8744 | .mixers = { alc262_HP_BPC_WildWest_mixer, | |
8745 | alc262_HP_BPC_WildWest_option_mixer }, | |
8746 | .init_verbs = { alc262_HP_BPC_WildWest_init_verbs }, | |
8747 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
8748 | .dac_nids = alc262_dac_nids, | |
8749 | .hp_nid = 0x03, | |
8750 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
8751 | .channel_mode = alc262_modes, | |
accbe498 | 8752 | .input_mux = &alc262_HP_D7000_capture_source, |
f12ab1e0 | 8753 | }, |
66d2a9d6 KY |
8754 | [ALC262_HP_TC_T5735] = { |
8755 | .mixers = { alc262_hp_t5735_mixer }, | |
8756 | .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs }, | |
8757 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
8758 | .dac_nids = alc262_dac_nids, | |
8759 | .hp_nid = 0x03, | |
8760 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
8761 | .channel_mode = alc262_modes, | |
8762 | .input_mux = &alc262_capture_source, | |
8763 | .unsol_event = alc262_hp_t5735_unsol_event, | |
8764 | .init_hook = alc262_hp_t5735_init_hook, | |
8765 | }, | |
304dcaac TI |
8766 | [ALC262_BENQ_ED8] = { |
8767 | .mixers = { alc262_base_mixer }, | |
8768 | .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs }, | |
8769 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
8770 | .dac_nids = alc262_dac_nids, | |
8771 | .hp_nid = 0x03, | |
8772 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
8773 | .channel_mode = alc262_modes, | |
8774 | .input_mux = &alc262_capture_source, | |
f12ab1e0 | 8775 | }, |
272a527c KY |
8776 | [ALC262_SONY_ASSAMD] = { |
8777 | .mixers = { alc262_sony_mixer }, | |
8778 | .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs}, | |
8779 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
8780 | .dac_nids = alc262_dac_nids, | |
8781 | .hp_nid = 0x02, | |
8782 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
8783 | .channel_mode = alc262_modes, | |
8784 | .input_mux = &alc262_capture_source, | |
8785 | .unsol_event = alc262_hippo_unsol_event, | |
5b31954e | 8786 | .init_hook = alc262_hippo_automute, |
83c34218 KY |
8787 | }, |
8788 | [ALC262_BENQ_T31] = { | |
8789 | .mixers = { alc262_benq_t31_mixer }, | |
8790 | .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs }, | |
8791 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
8792 | .dac_nids = alc262_dac_nids, | |
8793 | .hp_nid = 0x03, | |
8794 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
8795 | .channel_mode = alc262_modes, | |
8796 | .input_mux = &alc262_capture_source, | |
8797 | .unsol_event = alc262_hippo_unsol_event, | |
5b31954e | 8798 | .init_hook = alc262_hippo_automute, |
272a527c | 8799 | }, |
f651b50b TD |
8800 | [ALC262_ULTRA] = { |
8801 | .mixers = { alc262_ultra_mixer }, | |
8802 | .init_verbs = { alc262_init_verbs, alc262_ultra_verbs }, | |
8803 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
8804 | .dac_nids = alc262_dac_nids, | |
8805 | .hp_nid = 0x03, | |
8806 | .dig_out_nid = ALC262_DIGOUT_NID, | |
8807 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
8808 | .channel_mode = alc262_modes, | |
8809 | .input_mux = &alc262_ultra_capture_source, | |
8810 | .unsol_event = alc262_ultra_unsol_event, | |
8811 | .init_hook = alc262_ultra_automute, | |
8812 | }, | |
df694daa KY |
8813 | }; |
8814 | ||
8815 | static int patch_alc262(struct hda_codec *codec) | |
8816 | { | |
8817 | struct alc_spec *spec; | |
8818 | int board_config; | |
8819 | int err; | |
8820 | ||
dc041e0b | 8821 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
df694daa KY |
8822 | if (spec == NULL) |
8823 | return -ENOMEM; | |
8824 | ||
8825 | codec->spec = spec; | |
8826 | #if 0 | |
f12ab1e0 TI |
8827 | /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is |
8828 | * under-run | |
8829 | */ | |
df694daa KY |
8830 | { |
8831 | int tmp; | |
8832 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); | |
8833 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); | |
8834 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); | |
8835 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); | |
8836 | } | |
8837 | #endif | |
8838 | ||
f5fcc13c TI |
8839 | board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST, |
8840 | alc262_models, | |
8841 | alc262_cfg_tbl); | |
cd7509a4 | 8842 | |
f5fcc13c | 8843 | if (board_config < 0) { |
9c7f852e TI |
8844 | printk(KERN_INFO "hda_codec: Unknown model for ALC262, " |
8845 | "trying auto-probe from BIOS...\n"); | |
df694daa KY |
8846 | board_config = ALC262_AUTO; |
8847 | } | |
8848 | ||
8849 | if (board_config == ALC262_AUTO) { | |
8850 | /* automatic parse from the BIOS config */ | |
8851 | err = alc262_parse_auto_config(codec); | |
8852 | if (err < 0) { | |
8853 | alc_free(codec); | |
8854 | return err; | |
f12ab1e0 | 8855 | } else if (!err) { |
9c7f852e TI |
8856 | printk(KERN_INFO |
8857 | "hda_codec: Cannot set up configuration " | |
8858 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
8859 | board_config = ALC262_BASIC; |
8860 | } | |
8861 | } | |
8862 | ||
8863 | if (board_config != ALC262_AUTO) | |
8864 | setup_preset(spec, &alc262_presets[board_config]); | |
8865 | ||
8866 | spec->stream_name_analog = "ALC262 Analog"; | |
8867 | spec->stream_analog_playback = &alc262_pcm_analog_playback; | |
8868 | spec->stream_analog_capture = &alc262_pcm_analog_capture; | |
8869 | ||
8870 | spec->stream_name_digital = "ALC262 Digital"; | |
8871 | spec->stream_digital_playback = &alc262_pcm_digital_playback; | |
8872 | spec->stream_digital_capture = &alc262_pcm_digital_capture; | |
8873 | ||
f12ab1e0 | 8874 | if (!spec->adc_nids && spec->input_mux) { |
df694daa | 8875 | /* check whether NID 0x07 is valid */ |
4a471b7d TI |
8876 | unsigned int wcap = get_wcaps(codec, 0x07); |
8877 | ||
f12ab1e0 TI |
8878 | /* get type */ |
8879 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
df694daa KY |
8880 | if (wcap != AC_WID_AUD_IN) { |
8881 | spec->adc_nids = alc262_adc_nids_alt; | |
8882 | spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt); | |
f12ab1e0 TI |
8883 | spec->mixers[spec->num_mixers] = |
8884 | alc262_capture_alt_mixer; | |
df694daa KY |
8885 | spec->num_mixers++; |
8886 | } else { | |
8887 | spec->adc_nids = alc262_adc_nids; | |
8888 | spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids); | |
8889 | spec->mixers[spec->num_mixers] = alc262_capture_mixer; | |
8890 | spec->num_mixers++; | |
8891 | } | |
8892 | } | |
8893 | ||
8894 | codec->patch_ops = alc_patch_ops; | |
8895 | if (board_config == ALC262_AUTO) | |
ae6b813a | 8896 | spec->init_hook = alc262_auto_init; |
cb53c626 TI |
8897 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
8898 | if (!spec->loopback.amplist) | |
8899 | spec->loopback.amplist = alc262_loopbacks; | |
8900 | #endif | |
834be88d | 8901 | |
df694daa KY |
8902 | return 0; |
8903 | } | |
8904 | ||
a361d84b KY |
8905 | /* |
8906 | * ALC268 channel source setting (2 channel) | |
8907 | */ | |
8908 | #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID | |
8909 | #define alc268_modes alc260_modes | |
8910 | ||
8911 | static hda_nid_t alc268_dac_nids[2] = { | |
8912 | /* front, hp */ | |
8913 | 0x02, 0x03 | |
8914 | }; | |
8915 | ||
8916 | static hda_nid_t alc268_adc_nids[2] = { | |
8917 | /* ADC0-1 */ | |
8918 | 0x08, 0x07 | |
8919 | }; | |
8920 | ||
8921 | static hda_nid_t alc268_adc_nids_alt[1] = { | |
8922 | /* ADC0 */ | |
8923 | 0x08 | |
8924 | }; | |
8925 | ||
8926 | static struct snd_kcontrol_new alc268_base_mixer[] = { | |
8927 | /* output mixer control */ | |
8928 | HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT), | |
8929 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
8930 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT), | |
8931 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
33bf17ab TI |
8932 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
8933 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
8934 | HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT), | |
a361d84b KY |
8935 | { } |
8936 | }; | |
8937 | ||
d1a991a6 KY |
8938 | static struct hda_verb alc268_eapd_verbs[] = { |
8939 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
8940 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
8941 | { } | |
8942 | }; | |
8943 | ||
d273809e TI |
8944 | /* Toshiba specific */ |
8945 | #define alc268_toshiba_automute alc262_hippo_automute | |
8946 | ||
8947 | static struct hda_verb alc268_toshiba_verbs[] = { | |
8948 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
8949 | { } /* end */ | |
8950 | }; | |
8951 | ||
8952 | /* Acer specific */ | |
889c4395 | 8953 | /* bind volumes of both NID 0x02 and 0x03 */ |
6bc96857 TI |
8954 | static struct hda_bind_ctls alc268_acer_bind_master_vol = { |
8955 | .ops = &snd_hda_bind_vol, | |
8956 | .values = { | |
8957 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), | |
8958 | HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT), | |
8959 | 0 | |
8960 | }, | |
8961 | }; | |
8962 | ||
889c4395 TI |
8963 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
8964 | static void alc268_acer_automute(struct hda_codec *codec, int force) | |
8965 | { | |
8966 | struct alc_spec *spec = codec->spec; | |
8967 | unsigned int mute; | |
8968 | ||
8969 | if (force || !spec->sense_updated) { | |
8970 | unsigned int present; | |
8971 | present = snd_hda_codec_read(codec, 0x14, 0, | |
8972 | AC_VERB_GET_PIN_SENSE, 0); | |
8973 | spec->jack_present = (present & 0x80000000) != 0; | |
8974 | spec->sense_updated = 1; | |
8975 | } | |
8976 | if (spec->jack_present) | |
8977 | mute = HDA_AMP_MUTE; /* mute internal speaker */ | |
8978 | else /* unmute internal speaker if necessary */ | |
8979 | mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); | |
8980 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
8981 | HDA_AMP_MUTE, mute); | |
8982 | } | |
8983 | ||
8984 | ||
8985 | /* bind hp and internal speaker mute (with plug check) */ | |
8986 | static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol, | |
8987 | struct snd_ctl_elem_value *ucontrol) | |
8988 | { | |
8989 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
8990 | long *valp = ucontrol->value.integer.value; | |
8991 | int change; | |
8992 | ||
8993 | change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, | |
8994 | HDA_AMP_MUTE, | |
8995 | valp[0] ? 0 : HDA_AMP_MUTE); | |
8996 | change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, | |
8997 | HDA_AMP_MUTE, | |
8998 | valp[1] ? 0 : HDA_AMP_MUTE); | |
8999 | if (change) | |
9000 | alc268_acer_automute(codec, 0); | |
9001 | return change; | |
9002 | } | |
d273809e TI |
9003 | |
9004 | static struct snd_kcontrol_new alc268_acer_mixer[] = { | |
9005 | /* output mixer control */ | |
9006 | HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol), | |
9007 | { | |
9008 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9009 | .name = "Master Playback Switch", | |
9010 | .info = snd_hda_mixer_amp_switch_info, | |
9011 | .get = snd_hda_mixer_amp_switch_get, | |
9012 | .put = alc268_acer_master_sw_put, | |
9013 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
9014 | }, | |
33bf17ab TI |
9015 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9016 | HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT), | |
9017 | HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT), | |
d273809e TI |
9018 | { } |
9019 | }; | |
9020 | ||
9021 | static struct hda_verb alc268_acer_verbs[] = { | |
9022 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
9023 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9024 | ||
9025 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
9026 | { } | |
9027 | }; | |
9028 | ||
9029 | /* unsolicited event for HP jack sensing */ | |
9030 | static void alc268_toshiba_unsol_event(struct hda_codec *codec, | |
9031 | unsigned int res) | |
9032 | { | |
889c4395 | 9033 | if ((res >> 26) != ALC880_HP_EVENT) |
d273809e TI |
9034 | return; |
9035 | alc268_toshiba_automute(codec); | |
9036 | } | |
9037 | ||
9038 | static void alc268_acer_unsol_event(struct hda_codec *codec, | |
9039 | unsigned int res) | |
9040 | { | |
889c4395 | 9041 | if ((res >> 26) != ALC880_HP_EVENT) |
d273809e TI |
9042 | return; |
9043 | alc268_acer_automute(codec, 1); | |
9044 | } | |
9045 | ||
889c4395 TI |
9046 | static void alc268_acer_init_hook(struct hda_codec *codec) |
9047 | { | |
9048 | alc268_acer_automute(codec, 1); | |
9049 | } | |
9050 | ||
a361d84b KY |
9051 | /* |
9052 | * generic initialization of ADC, input mixers and output mixers | |
9053 | */ | |
9054 | static struct hda_verb alc268_base_init_verbs[] = { | |
9055 | /* Unmute DAC0-1 and set vol = 0 */ | |
9056 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9057 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9058 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9059 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9060 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9061 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9062 | ||
9063 | /* | |
9064 | * Set up output mixers (0x0c - 0x0e) | |
9065 | */ | |
9066 | /* set vol=0 to output mixers */ | |
9067 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9068 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9069 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9070 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9071 | ||
9072 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9073 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9074 | ||
9075 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
9076 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
9077 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
9078 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
9079 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
9080 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
9081 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
9082 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
9083 | ||
9084 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9085 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9086 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9087 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9088 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9089 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9090 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9091 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9092 | ||
9093 | /* FIXME: use matrix-type input source selection */ | |
9094 | /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */ | |
9095 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
9096 | /* Input mixer2 */ | |
9097 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9098 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
9099 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
9100 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
9101 | ||
9102 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9103 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
9104 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
9105 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
9106 | { } | |
9107 | }; | |
9108 | ||
9109 | /* | |
9110 | * generic initialization of ADC, input mixers and output mixers | |
9111 | */ | |
9112 | static struct hda_verb alc268_volume_init_verbs[] = { | |
9113 | /* set output DAC */ | |
9114 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9115 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9116 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9117 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9118 | ||
9119 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
9120 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
9121 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
9122 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
9123 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
9124 | ||
9125 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9126 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9127 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9128 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9129 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9130 | ||
9131 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9132 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9133 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9134 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9135 | ||
9136 | /* set PCBEEP vol = 0 */ | |
9137 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))}, | |
9138 | ||
9139 | { } | |
9140 | }; | |
9141 | ||
9142 | #define alc268_mux_enum_info alc_mux_enum_info | |
9143 | #define alc268_mux_enum_get alc_mux_enum_get | |
9144 | ||
9145 | static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol, | |
9146 | struct snd_ctl_elem_value *ucontrol) | |
9147 | { | |
9148 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
9149 | struct alc_spec *spec = codec->spec; | |
9150 | const struct hda_input_mux *imux = spec->input_mux; | |
9151 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
9152 | static hda_nid_t capture_mixers[3] = { 0x23, 0x24 }; | |
9153 | hda_nid_t nid = capture_mixers[adc_idx]; | |
9154 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; | |
9155 | unsigned int i, idx; | |
9156 | ||
9157 | idx = ucontrol->value.enumerated.item[0]; | |
9158 | if (idx >= imux->num_items) | |
9159 | idx = imux->num_items - 1; | |
82beb8fd | 9160 | if (*cur_val == idx) |
a361d84b KY |
9161 | return 0; |
9162 | for (i = 0; i < imux->num_items; i++) { | |
47fd830a TI |
9163 | unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE; |
9164 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, | |
9165 | imux->items[i].index, | |
9166 | HDA_AMP_MUTE, v); | |
82beb8fd TI |
9167 | snd_hda_codec_write_cache(codec, nid, 0, |
9168 | AC_VERB_SET_CONNECT_SEL, | |
9169 | idx ); | |
a361d84b KY |
9170 | } |
9171 | *cur_val = idx; | |
9172 | return 1; | |
9173 | } | |
9174 | ||
9175 | static struct snd_kcontrol_new alc268_capture_alt_mixer[] = { | |
9176 | HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), | |
9177 | HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), | |
9178 | { | |
9179 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9180 | /* The multiple "Capture Source" controls confuse alsamixer | |
9181 | * So call somewhat different.. | |
9182 | * FIXME: the controls appear in the "playback" view! | |
9183 | */ | |
9184 | /* .name = "Capture Source", */ | |
9185 | .name = "Input Source", | |
9186 | .count = 1, | |
9187 | .info = alc268_mux_enum_info, | |
9188 | .get = alc268_mux_enum_get, | |
9189 | .put = alc268_mux_enum_put, | |
9190 | }, | |
9191 | { } /* end */ | |
9192 | }; | |
9193 | ||
9194 | static struct snd_kcontrol_new alc268_capture_mixer[] = { | |
9195 | HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), | |
9196 | HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), | |
9197 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT), | |
9198 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT), | |
9199 | { | |
9200 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9201 | /* The multiple "Capture Source" controls confuse alsamixer | |
9202 | * So call somewhat different.. | |
9203 | * FIXME: the controls appear in the "playback" view! | |
9204 | */ | |
9205 | /* .name = "Capture Source", */ | |
9206 | .name = "Input Source", | |
9207 | .count = 2, | |
9208 | .info = alc268_mux_enum_info, | |
9209 | .get = alc268_mux_enum_get, | |
9210 | .put = alc268_mux_enum_put, | |
9211 | }, | |
9212 | { } /* end */ | |
9213 | }; | |
9214 | ||
9215 | static struct hda_input_mux alc268_capture_source = { | |
9216 | .num_items = 4, | |
9217 | .items = { | |
9218 | { "Mic", 0x0 }, | |
9219 | { "Front Mic", 0x1 }, | |
9220 | { "Line", 0x2 }, | |
9221 | { "CD", 0x3 }, | |
9222 | }, | |
9223 | }; | |
9224 | ||
9225 | /* create input playback/capture controls for the given pin */ | |
9226 | static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid, | |
9227 | const char *ctlname, int idx) | |
9228 | { | |
9229 | char name[32]; | |
9230 | int err; | |
9231 | ||
9232 | sprintf(name, "%s Playback Volume", ctlname); | |
9233 | if (nid == 0x14) { | |
9234 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
9235 | HDA_COMPOSE_AMP_VAL(0x02, 3, idx, | |
9236 | HDA_OUTPUT)); | |
9237 | if (err < 0) | |
9238 | return err; | |
9239 | } else if (nid == 0x15) { | |
9240 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
9241 | HDA_COMPOSE_AMP_VAL(0x03, 3, idx, | |
9242 | HDA_OUTPUT)); | |
9243 | if (err < 0) | |
9244 | return err; | |
9245 | } else | |
9246 | return -1; | |
9247 | sprintf(name, "%s Playback Switch", ctlname); | |
9248 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | |
9249 | HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT)); | |
9250 | if (err < 0) | |
9251 | return err; | |
9252 | return 0; | |
9253 | } | |
9254 | ||
9255 | /* add playback controls from the parsed DAC table */ | |
9256 | static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec, | |
9257 | const struct auto_pin_cfg *cfg) | |
9258 | { | |
9259 | hda_nid_t nid; | |
9260 | int err; | |
9261 | ||
9262 | spec->multiout.num_dacs = 2; /* only use one dac */ | |
9263 | spec->multiout.dac_nids = spec->private_dac_nids; | |
9264 | spec->multiout.dac_nids[0] = 2; | |
9265 | spec->multiout.dac_nids[1] = 3; | |
9266 | ||
9267 | nid = cfg->line_out_pins[0]; | |
9268 | if (nid) | |
9269 | alc268_new_analog_output(spec, nid, "Front", 0); | |
9270 | ||
9271 | nid = cfg->speaker_pins[0]; | |
9272 | if (nid == 0x1d) { | |
9273 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
9274 | "Speaker Playback Volume", | |
9275 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | |
9276 | if (err < 0) | |
9277 | return err; | |
9278 | } | |
9279 | nid = cfg->hp_pins[0]; | |
9280 | if (nid) | |
9281 | alc268_new_analog_output(spec, nid, "Headphone", 0); | |
9282 | ||
9283 | nid = cfg->line_out_pins[1] | cfg->line_out_pins[2]; | |
9284 | if (nid == 0x16) { | |
9285 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
9286 | "Mono Playback Switch", | |
9287 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT)); | |
9288 | if (err < 0) | |
9289 | return err; | |
9290 | } | |
9291 | return 0; | |
9292 | } | |
9293 | ||
9294 | /* create playback/capture controls for input pins */ | |
9295 | static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec, | |
9296 | const struct auto_pin_cfg *cfg) | |
9297 | { | |
9298 | struct hda_input_mux *imux = &spec->private_imux; | |
9299 | int i, idx1; | |
9300 | ||
9301 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
9302 | switch(cfg->input_pins[i]) { | |
9303 | case 0x18: | |
9304 | idx1 = 0; /* Mic 1 */ | |
9305 | break; | |
9306 | case 0x19: | |
9307 | idx1 = 1; /* Mic 2 */ | |
9308 | break; | |
9309 | case 0x1a: | |
9310 | idx1 = 2; /* Line In */ | |
9311 | break; | |
9312 | case 0x1c: | |
9313 | idx1 = 3; /* CD */ | |
9314 | break; | |
9315 | default: | |
9316 | continue; | |
9317 | } | |
9318 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; | |
9319 | imux->items[imux->num_items].index = idx1; | |
9320 | imux->num_items++; | |
9321 | } | |
9322 | return 0; | |
9323 | } | |
9324 | ||
9325 | static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec) | |
9326 | { | |
9327 | struct alc_spec *spec = codec->spec; | |
9328 | hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0]; | |
9329 | hda_nid_t hp_nid = spec->autocfg.hp_pins[0]; | |
9330 | hda_nid_t line_nid = spec->autocfg.line_out_pins[0]; | |
9331 | unsigned int dac_vol1, dac_vol2; | |
9332 | ||
9333 | if (speaker_nid) { | |
9334 | snd_hda_codec_write(codec, speaker_nid, 0, | |
9335 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | |
9336 | snd_hda_codec_write(codec, 0x0f, 0, | |
9337 | AC_VERB_SET_AMP_GAIN_MUTE, | |
9338 | AMP_IN_UNMUTE(1)); | |
9339 | snd_hda_codec_write(codec, 0x10, 0, | |
9340 | AC_VERB_SET_AMP_GAIN_MUTE, | |
9341 | AMP_IN_UNMUTE(1)); | |
9342 | } else { | |
9343 | snd_hda_codec_write(codec, 0x0f, 0, | |
9344 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)); | |
9345 | snd_hda_codec_write(codec, 0x10, 0, | |
9346 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)); | |
9347 | } | |
9348 | ||
9349 | dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */ | |
9350 | if (line_nid == 0x14) | |
9351 | dac_vol2 = AMP_OUT_ZERO; | |
9352 | else if (line_nid == 0x15) | |
9353 | dac_vol1 = AMP_OUT_ZERO; | |
9354 | if (hp_nid == 0x14) | |
9355 | dac_vol2 = AMP_OUT_ZERO; | |
9356 | else if (hp_nid == 0x15) | |
9357 | dac_vol1 = AMP_OUT_ZERO; | |
9358 | if (line_nid != 0x16 || hp_nid != 0x16 || | |
9359 | spec->autocfg.line_out_pins[1] != 0x16 || | |
9360 | spec->autocfg.line_out_pins[2] != 0x16) | |
9361 | dac_vol1 = dac_vol2 = AMP_OUT_ZERO; | |
9362 | ||
9363 | snd_hda_codec_write(codec, 0x02, 0, | |
9364 | AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1); | |
9365 | snd_hda_codec_write(codec, 0x03, 0, | |
9366 | AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2); | |
9367 | } | |
9368 | ||
9369 | /* pcm configuration: identiacal with ALC880 */ | |
9370 | #define alc268_pcm_analog_playback alc880_pcm_analog_playback | |
9371 | #define alc268_pcm_analog_capture alc880_pcm_analog_capture | |
9372 | #define alc268_pcm_digital_playback alc880_pcm_digital_playback | |
9373 | ||
9374 | /* | |
9375 | * BIOS auto configuration | |
9376 | */ | |
9377 | static int alc268_parse_auto_config(struct hda_codec *codec) | |
9378 | { | |
9379 | struct alc_spec *spec = codec->spec; | |
9380 | int err; | |
9381 | static hda_nid_t alc268_ignore[] = { 0 }; | |
9382 | ||
9383 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | |
9384 | alc268_ignore); | |
9385 | if (err < 0) | |
9386 | return err; | |
9387 | if (!spec->autocfg.line_outs) | |
9388 | return 0; /* can't find valid BIOS pin config */ | |
9389 | ||
9390 | err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
9391 | if (err < 0) | |
9392 | return err; | |
9393 | err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
9394 | if (err < 0) | |
9395 | return err; | |
9396 | ||
9397 | spec->multiout.max_channels = 2; | |
9398 | ||
9399 | /* digital only support output */ | |
9400 | if (spec->autocfg.dig_out_pin) | |
9401 | spec->multiout.dig_out_nid = ALC268_DIGOUT_NID; | |
9402 | ||
9403 | if (spec->kctl_alloc) | |
9404 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
9405 | ||
9406 | spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs; | |
9407 | spec->num_mux_defs = 1; | |
9408 | spec->input_mux = &spec->private_imux; | |
9409 | ||
776e184e TI |
9410 | err = alc_auto_add_mic_boost(codec); |
9411 | if (err < 0) | |
9412 | return err; | |
9413 | ||
a361d84b KY |
9414 | return 1; |
9415 | } | |
9416 | ||
9417 | #define alc268_auto_init_multi_out alc882_auto_init_multi_out | |
9418 | #define alc268_auto_init_hp_out alc882_auto_init_hp_out | |
9419 | #define alc268_auto_init_analog_input alc882_auto_init_analog_input | |
9420 | ||
9421 | /* init callback for auto-configuration model -- overriding the default init */ | |
9422 | static void alc268_auto_init(struct hda_codec *codec) | |
9423 | { | |
9424 | alc268_auto_init_multi_out(codec); | |
9425 | alc268_auto_init_hp_out(codec); | |
9426 | alc268_auto_init_mono_speaker_out(codec); | |
9427 | alc268_auto_init_analog_input(codec); | |
9428 | } | |
9429 | ||
9430 | /* | |
9431 | * configuration and preset | |
9432 | */ | |
9433 | static const char *alc268_models[ALC268_MODEL_LAST] = { | |
9434 | [ALC268_3ST] = "3stack", | |
983f8ae4 | 9435 | [ALC268_TOSHIBA] = "toshiba", |
d273809e | 9436 | [ALC268_ACER] = "acer", |
a361d84b KY |
9437 | [ALC268_AUTO] = "auto", |
9438 | }; | |
9439 | ||
9440 | static struct snd_pci_quirk alc268_cfg_tbl[] = { | |
9441 | SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST), | |
d1a991a6 | 9442 | SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA), |
8e7f00f9 | 9443 | SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA), |
d273809e TI |
9444 | SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA), |
9445 | SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER), | |
889c4395 | 9446 | SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER), |
b875bf3a | 9447 | SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER), |
a361d84b KY |
9448 | {} |
9449 | }; | |
9450 | ||
9451 | static struct alc_config_preset alc268_presets[] = { | |
9452 | [ALC268_3ST] = { | |
9453 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer }, | |
9454 | .init_verbs = { alc268_base_init_verbs }, | |
9455 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
9456 | .dac_nids = alc268_dac_nids, | |
9457 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
9458 | .adc_nids = alc268_adc_nids_alt, | |
9459 | .hp_nid = 0x03, | |
9460 | .dig_out_nid = ALC268_DIGOUT_NID, | |
9461 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
9462 | .channel_mode = alc268_modes, | |
9463 | .input_mux = &alc268_capture_source, | |
9464 | }, | |
d1a991a6 KY |
9465 | [ALC268_TOSHIBA] = { |
9466 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer }, | |
d273809e TI |
9467 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
9468 | alc268_toshiba_verbs }, | |
d1a991a6 KY |
9469 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), |
9470 | .dac_nids = alc268_dac_nids, | |
9471 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
9472 | .adc_nids = alc268_adc_nids_alt, | |
9473 | .hp_nid = 0x03, | |
9474 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
9475 | .channel_mode = alc268_modes, | |
9476 | .input_mux = &alc268_capture_source, | |
d273809e TI |
9477 | .unsol_event = alc268_toshiba_unsol_event, |
9478 | .init_hook = alc268_toshiba_automute, | |
9479 | }, | |
9480 | [ALC268_ACER] = { | |
9481 | .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer }, | |
9482 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, | |
9483 | alc268_acer_verbs }, | |
9484 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
9485 | .dac_nids = alc268_dac_nids, | |
9486 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
9487 | .adc_nids = alc268_adc_nids_alt, | |
9488 | .hp_nid = 0x02, | |
9489 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
9490 | .channel_mode = alc268_modes, | |
9491 | .input_mux = &alc268_capture_source, | |
9492 | .unsol_event = alc268_acer_unsol_event, | |
889c4395 | 9493 | .init_hook = alc268_acer_init_hook, |
d1a991a6 | 9494 | }, |
a361d84b KY |
9495 | }; |
9496 | ||
9497 | static int patch_alc268(struct hda_codec *codec) | |
9498 | { | |
9499 | struct alc_spec *spec; | |
9500 | int board_config; | |
9501 | int err; | |
9502 | ||
9503 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); | |
9504 | if (spec == NULL) | |
9505 | return -ENOMEM; | |
9506 | ||
9507 | codec->spec = spec; | |
9508 | ||
9509 | board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST, | |
9510 | alc268_models, | |
9511 | alc268_cfg_tbl); | |
9512 | ||
9513 | if (board_config < 0 || board_config >= ALC268_MODEL_LAST) { | |
9514 | printk(KERN_INFO "hda_codec: Unknown model for ALC268, " | |
9515 | "trying auto-probe from BIOS...\n"); | |
9516 | board_config = ALC268_AUTO; | |
9517 | } | |
9518 | ||
9519 | if (board_config == ALC268_AUTO) { | |
9520 | /* automatic parse from the BIOS config */ | |
9521 | err = alc268_parse_auto_config(codec); | |
9522 | if (err < 0) { | |
9523 | alc_free(codec); | |
9524 | return err; | |
9525 | } else if (!err) { | |
9526 | printk(KERN_INFO | |
9527 | "hda_codec: Cannot set up configuration " | |
9528 | "from BIOS. Using base mode...\n"); | |
9529 | board_config = ALC268_3ST; | |
9530 | } | |
9531 | } | |
9532 | ||
9533 | if (board_config != ALC268_AUTO) | |
9534 | setup_preset(spec, &alc268_presets[board_config]); | |
9535 | ||
9536 | spec->stream_name_analog = "ALC268 Analog"; | |
9537 | spec->stream_analog_playback = &alc268_pcm_analog_playback; | |
9538 | spec->stream_analog_capture = &alc268_pcm_analog_capture; | |
9539 | ||
9540 | spec->stream_name_digital = "ALC268 Digital"; | |
9541 | spec->stream_digital_playback = &alc268_pcm_digital_playback; | |
9542 | ||
9543 | if (board_config == ALC268_AUTO) { | |
9544 | if (!spec->adc_nids && spec->input_mux) { | |
9545 | /* check whether NID 0x07 is valid */ | |
9546 | unsigned int wcap = get_wcaps(codec, 0x07); | |
9547 | ||
9548 | /* get type */ | |
9549 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
9550 | if (wcap != AC_WID_AUD_IN) { | |
9551 | spec->adc_nids = alc268_adc_nids_alt; | |
9552 | spec->num_adc_nids = | |
9553 | ARRAY_SIZE(alc268_adc_nids_alt); | |
9554 | spec->mixers[spec->num_mixers] = | |
9555 | alc268_capture_alt_mixer; | |
9556 | spec->num_mixers++; | |
9557 | } else { | |
9558 | spec->adc_nids = alc268_adc_nids; | |
9559 | spec->num_adc_nids = | |
9560 | ARRAY_SIZE(alc268_adc_nids); | |
9561 | spec->mixers[spec->num_mixers] = | |
9562 | alc268_capture_mixer; | |
9563 | spec->num_mixers++; | |
9564 | } | |
9565 | } | |
9566 | } | |
9567 | codec->patch_ops = alc_patch_ops; | |
9568 | if (board_config == ALC268_AUTO) | |
9569 | spec->init_hook = alc268_auto_init; | |
9570 | ||
9571 | return 0; | |
9572 | } | |
9573 | ||
df694daa KY |
9574 | /* |
9575 | * ALC861 channel source setting (2/6 channel selection for 3-stack) | |
9576 | */ | |
9577 | ||
9578 | /* | |
9579 | * set the path ways for 2 channel output | |
9580 | * need to set the codec line out and mic 1 pin widgets to inputs | |
9581 | */ | |
9582 | static struct hda_verb alc861_threestack_ch2_init[] = { | |
9583 | /* set pin widget 1Ah (line in) for input */ | |
9584 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
f12ab1e0 TI |
9585 | /* set pin widget 18h (mic1/2) for input, for mic also enable |
9586 | * the vref | |
9587 | */ | |
df694daa KY |
9588 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
9589 | ||
9c7f852e TI |
9590 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, |
9591 | #if 0 | |
9592 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
9593 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/ | |
9594 | #endif | |
df694daa KY |
9595 | { } /* end */ |
9596 | }; | |
9597 | /* | |
9598 | * 6ch mode | |
9599 | * need to set the codec line out and mic 1 pin widgets to outputs | |
9600 | */ | |
9601 | static struct hda_verb alc861_threestack_ch6_init[] = { | |
9602 | /* set pin widget 1Ah (line in) for output (Back Surround)*/ | |
9603 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
9604 | /* set pin widget 18h (mic1) for output (CLFE)*/ | |
9605 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
9606 | ||
9607 | { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
9c7f852e | 9608 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa | 9609 | |
9c7f852e TI |
9610 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, |
9611 | #if 0 | |
9612 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
9613 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/ | |
9614 | #endif | |
df694daa KY |
9615 | { } /* end */ |
9616 | }; | |
9617 | ||
9618 | static struct hda_channel_mode alc861_threestack_modes[2] = { | |
9619 | { 2, alc861_threestack_ch2_init }, | |
9620 | { 6, alc861_threestack_ch6_init }, | |
9621 | }; | |
22309c3e TI |
9622 | /* Set mic1 as input and unmute the mixer */ |
9623 | static struct hda_verb alc861_uniwill_m31_ch2_init[] = { | |
9624 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
9625 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
9626 | { } /* end */ | |
9627 | }; | |
9628 | /* Set mic1 as output and mute mixer */ | |
9629 | static struct hda_verb alc861_uniwill_m31_ch4_init[] = { | |
9630 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
9631 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
9632 | { } /* end */ | |
9633 | }; | |
9634 | ||
9635 | static struct hda_channel_mode alc861_uniwill_m31_modes[2] = { | |
9636 | { 2, alc861_uniwill_m31_ch2_init }, | |
9637 | { 4, alc861_uniwill_m31_ch4_init }, | |
9638 | }; | |
df694daa | 9639 | |
7cdbff94 MD |
9640 | /* Set mic1 and line-in as input and unmute the mixer */ |
9641 | static struct hda_verb alc861_asus_ch2_init[] = { | |
9642 | /* set pin widget 1Ah (line in) for input */ | |
9643 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
f12ab1e0 TI |
9644 | /* set pin widget 18h (mic1/2) for input, for mic also enable |
9645 | * the vref | |
9646 | */ | |
7cdbff94 MD |
9647 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
9648 | ||
9649 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, | |
9650 | #if 0 | |
9651 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
9652 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/ | |
9653 | #endif | |
9654 | { } /* end */ | |
9655 | }; | |
9656 | /* Set mic1 nad line-in as output and mute mixer */ | |
9657 | static struct hda_verb alc861_asus_ch6_init[] = { | |
9658 | /* set pin widget 1Ah (line in) for output (Back Surround)*/ | |
9659 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
9660 | /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */ | |
9661 | /* set pin widget 18h (mic1) for output (CLFE)*/ | |
9662 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
9663 | /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */ | |
9664 | { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
9665 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
9666 | ||
9667 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, | |
9668 | #if 0 | |
9669 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
9670 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/ | |
9671 | #endif | |
9672 | { } /* end */ | |
9673 | }; | |
9674 | ||
9675 | static struct hda_channel_mode alc861_asus_modes[2] = { | |
9676 | { 2, alc861_asus_ch2_init }, | |
9677 | { 6, alc861_asus_ch6_init }, | |
9678 | }; | |
9679 | ||
df694daa KY |
9680 | /* patch-ALC861 */ |
9681 | ||
9682 | static struct snd_kcontrol_new alc861_base_mixer[] = { | |
9683 | /* output mixer control */ | |
9684 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
9685 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
9686 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
9687 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
9688 | HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), | |
9689 | ||
9690 | /*Input mixer control */ | |
9691 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
9692 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
9693 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
9694 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
9695 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
9696 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
9697 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
9698 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
9699 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
9700 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 9701 | |
df694daa KY |
9702 | /* Capture mixer control */ |
9703 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
9704 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
9705 | { | |
9706 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9707 | .name = "Capture Source", | |
9708 | .count = 1, | |
9709 | .info = alc_mux_enum_info, | |
9710 | .get = alc_mux_enum_get, | |
9711 | .put = alc_mux_enum_put, | |
9712 | }, | |
9713 | { } /* end */ | |
9714 | }; | |
9715 | ||
9716 | static struct snd_kcontrol_new alc861_3ST_mixer[] = { | |
9717 | /* output mixer control */ | |
9718 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
9719 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
9720 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
9721 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
9722 | /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ | |
9723 | ||
9724 | /* Input mixer control */ | |
9725 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
9726 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
9727 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
9728 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
9729 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
9730 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
9731 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
9732 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
9733 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
9734 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 9735 | |
df694daa KY |
9736 | /* Capture mixer control */ |
9737 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
9738 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
9739 | { | |
9740 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9741 | .name = "Capture Source", | |
9742 | .count = 1, | |
9743 | .info = alc_mux_enum_info, | |
9744 | .get = alc_mux_enum_get, | |
9745 | .put = alc_mux_enum_put, | |
9746 | }, | |
9747 | { | |
9748 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9749 | .name = "Channel Mode", | |
9750 | .info = alc_ch_mode_info, | |
9751 | .get = alc_ch_mode_get, | |
9752 | .put = alc_ch_mode_put, | |
9753 | .private_value = ARRAY_SIZE(alc861_threestack_modes), | |
9754 | }, | |
9755 | { } /* end */ | |
a53d1aec TD |
9756 | }; |
9757 | ||
d1d985f0 | 9758 | static struct snd_kcontrol_new alc861_toshiba_mixer[] = { |
a53d1aec TD |
9759 | /* output mixer control */ |
9760 | HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
9761 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
9762 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
9763 | ||
9764 | /*Capture mixer control */ | |
9765 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
9766 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
9767 | { | |
9768 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9769 | .name = "Capture Source", | |
9770 | .count = 1, | |
9771 | .info = alc_mux_enum_info, | |
9772 | .get = alc_mux_enum_get, | |
9773 | .put = alc_mux_enum_put, | |
9774 | }, | |
9775 | ||
9776 | { } /* end */ | |
f12ab1e0 | 9777 | }; |
a53d1aec | 9778 | |
22309c3e TI |
9779 | static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = { |
9780 | /* output mixer control */ | |
9781 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
9782 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
9783 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
9784 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
9785 | /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ | |
9786 | ||
9787 | /* Input mixer control */ | |
9788 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
9789 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
9790 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
9791 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
9792 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
9793 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
9794 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
9795 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
9796 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
9797 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 9798 | |
22309c3e TI |
9799 | /* Capture mixer control */ |
9800 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
9801 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
9802 | { | |
9803 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9804 | .name = "Capture Source", | |
9805 | .count = 1, | |
9806 | .info = alc_mux_enum_info, | |
9807 | .get = alc_mux_enum_get, | |
9808 | .put = alc_mux_enum_put, | |
9809 | }, | |
9810 | { | |
9811 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9812 | .name = "Channel Mode", | |
9813 | .info = alc_ch_mode_info, | |
9814 | .get = alc_ch_mode_get, | |
9815 | .put = alc_ch_mode_put, | |
9816 | .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes), | |
9817 | }, | |
9818 | { } /* end */ | |
f12ab1e0 | 9819 | }; |
7cdbff94 MD |
9820 | |
9821 | static struct snd_kcontrol_new alc861_asus_mixer[] = { | |
9822 | /* output mixer control */ | |
9823 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
9824 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
9825 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
9826 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
9827 | HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), | |
9828 | ||
9829 | /* Input mixer control */ | |
9830 | HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
9831 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
9832 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
9833 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
9834 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
9835 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
9836 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
9837 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
9838 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
f12ab1e0 TI |
9839 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), |
9840 | ||
7cdbff94 MD |
9841 | /* Capture mixer control */ |
9842 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
9843 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
9844 | { | |
9845 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9846 | .name = "Capture Source", | |
9847 | .count = 1, | |
9848 | .info = alc_mux_enum_info, | |
9849 | .get = alc_mux_enum_get, | |
9850 | .put = alc_mux_enum_put, | |
9851 | }, | |
9852 | { | |
9853 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9854 | .name = "Channel Mode", | |
9855 | .info = alc_ch_mode_info, | |
9856 | .get = alc_ch_mode_get, | |
9857 | .put = alc_ch_mode_put, | |
9858 | .private_value = ARRAY_SIZE(alc861_asus_modes), | |
9859 | }, | |
9860 | { } | |
56bb0cab TI |
9861 | }; |
9862 | ||
9863 | /* additional mixer */ | |
d1d985f0 | 9864 | static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = { |
56bb0cab TI |
9865 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), |
9866 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
9867 | HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT), | |
9868 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT), | |
9869 | { } | |
9870 | }; | |
7cdbff94 | 9871 | |
df694daa KY |
9872 | /* |
9873 | * generic initialization of ADC, input mixers and output mixers | |
9874 | */ | |
9875 | static struct hda_verb alc861_base_init_verbs[] = { | |
9876 | /* | |
9877 | * Unmute ADC0 and set the default input to mic-in | |
9878 | */ | |
9879 | /* port-A for surround (rear panel) */ | |
9880 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
9881 | { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
9882 | /* port-B for mic-in (rear panel) with vref */ | |
9883 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
9884 | /* port-C for line-in (rear panel) */ | |
9885 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
9886 | /* port-D for Front */ | |
9887 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
9888 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
9889 | /* port-E for HP out (front panel) */ | |
9890 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | |
9891 | /* route front PCM to HP */ | |
9dece1d7 | 9892 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa KY |
9893 | /* port-F for mic-in (front panel) with vref */ |
9894 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
9895 | /* port-G for CLFE (rear panel) */ | |
9896 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
9897 | { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
9898 | /* port-H for side (rear panel) */ | |
9899 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
9900 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
9901 | /* CD-in */ | |
9902 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
9903 | /* route front mic to ADC1*/ | |
9904 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9905 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9906 | ||
9907 | /* Unmute DAC0~3 & spdif out*/ | |
9908 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9909 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9910 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9911 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9912 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9913 | ||
9914 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
9915 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9916 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9917 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9918 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9919 | ||
9920 | /* Unmute Stereo Mixer 15 */ | |
9921 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9922 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9923 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 9924 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
df694daa KY |
9925 | |
9926 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9927 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9928 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9929 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9930 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9931 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9932 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9933 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
9934 | /* hp used DAC 3 (Front) */ |
9935 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
9936 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
9937 | ||
9938 | { } | |
9939 | }; | |
9940 | ||
9941 | static struct hda_verb alc861_threestack_init_verbs[] = { | |
9942 | /* | |
9943 | * Unmute ADC0 and set the default input to mic-in | |
9944 | */ | |
9945 | /* port-A for surround (rear panel) */ | |
9946 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
9947 | /* port-B for mic-in (rear panel) with vref */ | |
9948 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
9949 | /* port-C for line-in (rear panel) */ | |
9950 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
9951 | /* port-D for Front */ | |
9952 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
9953 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
9954 | /* port-E for HP out (front panel) */ | |
9955 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | |
9956 | /* route front PCM to HP */ | |
9dece1d7 | 9957 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa KY |
9958 | /* port-F for mic-in (front panel) with vref */ |
9959 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
9960 | /* port-G for CLFE (rear panel) */ | |
9961 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
9962 | /* port-H for side (rear panel) */ | |
9963 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
9964 | /* CD-in */ | |
9965 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
9966 | /* route front mic to ADC1*/ | |
9967 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9968 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9969 | /* Unmute DAC0~3 & spdif out*/ | |
9970 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9971 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9972 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9973 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9974 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9975 | ||
9976 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
9977 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9978 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9979 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9980 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9981 | ||
9982 | /* Unmute Stereo Mixer 15 */ | |
9983 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9984 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9985 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 9986 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
df694daa KY |
9987 | |
9988 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9989 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9990 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9991 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9992 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9993 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9994 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9995 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
9996 | /* hp used DAC 3 (Front) */ |
9997 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
9998 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
9999 | { } | |
10000 | }; | |
22309c3e TI |
10001 | |
10002 | static struct hda_verb alc861_uniwill_m31_init_verbs[] = { | |
10003 | /* | |
10004 | * Unmute ADC0 and set the default input to mic-in | |
10005 | */ | |
10006 | /* port-A for surround (rear panel) */ | |
10007 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
10008 | /* port-B for mic-in (rear panel) with vref */ | |
10009 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
10010 | /* port-C for line-in (rear panel) */ | |
10011 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
10012 | /* port-D for Front */ | |
10013 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
10014 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
10015 | /* port-E for HP out (front panel) */ | |
f12ab1e0 TI |
10016 | /* this has to be set to VREF80 */ |
10017 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
22309c3e | 10018 | /* route front PCM to HP */ |
9dece1d7 | 10019 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
22309c3e TI |
10020 | /* port-F for mic-in (front panel) with vref */ |
10021 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
10022 | /* port-G for CLFE (rear panel) */ | |
10023 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
10024 | /* port-H for side (rear panel) */ | |
10025 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
10026 | /* CD-in */ | |
10027 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
10028 | /* route front mic to ADC1*/ | |
10029 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10030 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10031 | /* Unmute DAC0~3 & spdif out*/ | |
10032 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10033 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10034 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10035 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10036 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10037 | ||
10038 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
10039 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10040 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10041 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10042 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10043 | ||
10044 | /* Unmute Stereo Mixer 15 */ | |
10045 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10046 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10047 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 10048 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
22309c3e TI |
10049 | |
10050 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10051 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10052 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10053 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10054 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10055 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10056 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10057 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
10058 | /* hp used DAC 3 (Front) */ |
10059 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
22309c3e TI |
10060 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
10061 | { } | |
10062 | }; | |
10063 | ||
7cdbff94 MD |
10064 | static struct hda_verb alc861_asus_init_verbs[] = { |
10065 | /* | |
10066 | * Unmute ADC0 and set the default input to mic-in | |
10067 | */ | |
f12ab1e0 TI |
10068 | /* port-A for surround (rear panel) |
10069 | * according to codec#0 this is the HP jack | |
10070 | */ | |
7cdbff94 MD |
10071 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */ |
10072 | /* route front PCM to HP */ | |
10073 | { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
10074 | /* port-B for mic-in (rear panel) with vref */ | |
10075 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
10076 | /* port-C for line-in (rear panel) */ | |
10077 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
10078 | /* port-D for Front */ | |
10079 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
10080 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
10081 | /* port-E for HP out (front panel) */ | |
f12ab1e0 TI |
10082 | /* this has to be set to VREF80 */ |
10083 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
7cdbff94 | 10084 | /* route front PCM to HP */ |
9dece1d7 | 10085 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
7cdbff94 MD |
10086 | /* port-F for mic-in (front panel) with vref */ |
10087 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
10088 | /* port-G for CLFE (rear panel) */ | |
10089 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
10090 | /* port-H for side (rear panel) */ | |
10091 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
10092 | /* CD-in */ | |
10093 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
10094 | /* route front mic to ADC1*/ | |
10095 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10096 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10097 | /* Unmute DAC0~3 & spdif out*/ | |
10098 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10099 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10100 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10101 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10102 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10103 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
10104 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10105 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10106 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10107 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10108 | ||
10109 | /* Unmute Stereo Mixer 15 */ | |
10110 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10111 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10112 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 10113 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
7cdbff94 MD |
10114 | |
10115 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10116 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10117 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10118 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10119 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10120 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10121 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10122 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
10123 | /* hp used DAC 3 (Front) */ |
10124 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
7cdbff94 MD |
10125 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
10126 | { } | |
10127 | }; | |
10128 | ||
56bb0cab TI |
10129 | /* additional init verbs for ASUS laptops */ |
10130 | static struct hda_verb alc861_asus_laptop_init_verbs[] = { | |
10131 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */ | |
10132 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */ | |
10133 | { } | |
10134 | }; | |
7cdbff94 | 10135 | |
df694daa KY |
10136 | /* |
10137 | * generic initialization of ADC, input mixers and output mixers | |
10138 | */ | |
10139 | static struct hda_verb alc861_auto_init_verbs[] = { | |
10140 | /* | |
10141 | * Unmute ADC0 and set the default input to mic-in | |
10142 | */ | |
f12ab1e0 | 10143 | /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */ |
df694daa KY |
10144 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
10145 | ||
10146 | /* Unmute DAC0~3 & spdif out*/ | |
10147 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10148 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10149 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10150 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10151 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10152 | ||
10153 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
10154 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10155 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10156 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10157 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10158 | ||
10159 | /* Unmute Stereo Mixer 15 */ | |
10160 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10161 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10162 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
10163 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, | |
10164 | ||
10165 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10166 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10167 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10168 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10169 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10170 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10171 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10172 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10173 | ||
10174 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
10175 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
f12ab1e0 TI |
10176 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
10177 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
10178 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
10179 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
f12ab1e0 TI |
10180 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
10181 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa | 10182 | |
f12ab1e0 | 10183 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */ |
df694daa KY |
10184 | |
10185 | { } | |
10186 | }; | |
10187 | ||
a53d1aec TD |
10188 | static struct hda_verb alc861_toshiba_init_verbs[] = { |
10189 | {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
f12ab1e0 | 10190 | |
a53d1aec TD |
10191 | { } |
10192 | }; | |
10193 | ||
10194 | /* toggle speaker-output according to the hp-jack state */ | |
10195 | static void alc861_toshiba_automute(struct hda_codec *codec) | |
10196 | { | |
10197 | unsigned int present; | |
10198 | ||
10199 | present = snd_hda_codec_read(codec, 0x0f, 0, | |
10200 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
10201 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0, |
10202 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
10203 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3, | |
10204 | HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE); | |
a53d1aec TD |
10205 | } |
10206 | ||
10207 | static void alc861_toshiba_unsol_event(struct hda_codec *codec, | |
10208 | unsigned int res) | |
10209 | { | |
a53d1aec TD |
10210 | if ((res >> 26) == ALC880_HP_EVENT) |
10211 | alc861_toshiba_automute(codec); | |
10212 | } | |
10213 | ||
df694daa KY |
10214 | /* pcm configuration: identiacal with ALC880 */ |
10215 | #define alc861_pcm_analog_playback alc880_pcm_analog_playback | |
10216 | #define alc861_pcm_analog_capture alc880_pcm_analog_capture | |
10217 | #define alc861_pcm_digital_playback alc880_pcm_digital_playback | |
10218 | #define alc861_pcm_digital_capture alc880_pcm_digital_capture | |
10219 | ||
10220 | ||
10221 | #define ALC861_DIGOUT_NID 0x07 | |
10222 | ||
10223 | static struct hda_channel_mode alc861_8ch_modes[1] = { | |
10224 | { 8, NULL } | |
10225 | }; | |
10226 | ||
10227 | static hda_nid_t alc861_dac_nids[4] = { | |
10228 | /* front, surround, clfe, side */ | |
10229 | 0x03, 0x06, 0x05, 0x04 | |
10230 | }; | |
10231 | ||
9c7f852e TI |
10232 | static hda_nid_t alc660_dac_nids[3] = { |
10233 | /* front, clfe, surround */ | |
10234 | 0x03, 0x05, 0x06 | |
10235 | }; | |
10236 | ||
df694daa KY |
10237 | static hda_nid_t alc861_adc_nids[1] = { |
10238 | /* ADC0-2 */ | |
10239 | 0x08, | |
10240 | }; | |
10241 | ||
10242 | static struct hda_input_mux alc861_capture_source = { | |
10243 | .num_items = 5, | |
10244 | .items = { | |
10245 | { "Mic", 0x0 }, | |
10246 | { "Front Mic", 0x3 }, | |
10247 | { "Line", 0x1 }, | |
10248 | { "CD", 0x4 }, | |
10249 | { "Mixer", 0x5 }, | |
10250 | }, | |
10251 | }; | |
10252 | ||
10253 | /* fill in the dac_nids table from the parsed pin configuration */ | |
f12ab1e0 TI |
10254 | static int alc861_auto_fill_dac_nids(struct alc_spec *spec, |
10255 | const struct auto_pin_cfg *cfg) | |
df694daa KY |
10256 | { |
10257 | int i; | |
10258 | hda_nid_t nid; | |
10259 | ||
10260 | spec->multiout.dac_nids = spec->private_dac_nids; | |
10261 | for (i = 0; i < cfg->line_outs; i++) { | |
10262 | nid = cfg->line_out_pins[i]; | |
10263 | if (nid) { | |
10264 | if (i >= ARRAY_SIZE(alc861_dac_nids)) | |
10265 | continue; | |
10266 | spec->multiout.dac_nids[i] = alc861_dac_nids[i]; | |
10267 | } | |
10268 | } | |
10269 | spec->multiout.num_dacs = cfg->line_outs; | |
10270 | return 0; | |
10271 | } | |
10272 | ||
10273 | /* add playback controls from the parsed DAC table */ | |
10274 | static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec, | |
10275 | const struct auto_pin_cfg *cfg) | |
10276 | { | |
10277 | char name[32]; | |
f12ab1e0 TI |
10278 | static const char *chname[4] = { |
10279 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
10280 | }; | |
df694daa KY |
10281 | hda_nid_t nid; |
10282 | int i, idx, err; | |
10283 | ||
10284 | for (i = 0; i < cfg->line_outs; i++) { | |
10285 | nid = spec->multiout.dac_nids[i]; | |
f12ab1e0 | 10286 | if (!nid) |
df694daa KY |
10287 | continue; |
10288 | if (nid == 0x05) { | |
10289 | /* Center/LFE */ | |
f12ab1e0 TI |
10290 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
10291 | "Center Playback Switch", | |
10292 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, | |
10293 | HDA_OUTPUT)); | |
10294 | if (err < 0) | |
df694daa | 10295 | return err; |
f12ab1e0 TI |
10296 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
10297 | "LFE Playback Switch", | |
10298 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
10299 | HDA_OUTPUT)); | |
10300 | if (err < 0) | |
df694daa KY |
10301 | return err; |
10302 | } else { | |
f12ab1e0 TI |
10303 | for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; |
10304 | idx++) | |
df694daa KY |
10305 | if (nid == alc861_dac_nids[idx]) |
10306 | break; | |
10307 | sprintf(name, "%s Playback Switch", chname[idx]); | |
f12ab1e0 TI |
10308 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
10309 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
10310 | HDA_OUTPUT)); | |
10311 | if (err < 0) | |
df694daa KY |
10312 | return err; |
10313 | } | |
10314 | } | |
10315 | return 0; | |
10316 | } | |
10317 | ||
10318 | static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin) | |
10319 | { | |
10320 | int err; | |
10321 | hda_nid_t nid; | |
10322 | ||
f12ab1e0 | 10323 | if (!pin) |
df694daa KY |
10324 | return 0; |
10325 | ||
10326 | if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) { | |
10327 | nid = 0x03; | |
f12ab1e0 TI |
10328 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
10329 | "Headphone Playback Switch", | |
10330 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
10331 | if (err < 0) | |
df694daa KY |
10332 | return err; |
10333 | spec->multiout.hp_nid = nid; | |
10334 | } | |
10335 | return 0; | |
10336 | } | |
10337 | ||
10338 | /* create playback/capture controls for input pins */ | |
f12ab1e0 TI |
10339 | static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, |
10340 | const struct auto_pin_cfg *cfg) | |
df694daa | 10341 | { |
df694daa KY |
10342 | struct hda_input_mux *imux = &spec->private_imux; |
10343 | int i, err, idx, idx1; | |
10344 | ||
10345 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
f12ab1e0 | 10346 | switch (cfg->input_pins[i]) { |
df694daa KY |
10347 | case 0x0c: |
10348 | idx1 = 1; | |
f12ab1e0 | 10349 | idx = 2; /* Line In */ |
df694daa KY |
10350 | break; |
10351 | case 0x0f: | |
10352 | idx1 = 2; | |
f12ab1e0 | 10353 | idx = 2; /* Line In */ |
df694daa KY |
10354 | break; |
10355 | case 0x0d: | |
10356 | idx1 = 0; | |
f12ab1e0 | 10357 | idx = 1; /* Mic In */ |
df694daa | 10358 | break; |
f12ab1e0 | 10359 | case 0x10: |
df694daa | 10360 | idx1 = 3; |
f12ab1e0 | 10361 | idx = 1; /* Mic In */ |
df694daa KY |
10362 | break; |
10363 | case 0x11: | |
10364 | idx1 = 4; | |
f12ab1e0 | 10365 | idx = 0; /* CD */ |
df694daa KY |
10366 | break; |
10367 | default: | |
10368 | continue; | |
10369 | } | |
10370 | ||
4a471b7d TI |
10371 | err = new_analog_input(spec, cfg->input_pins[i], |
10372 | auto_pin_cfg_labels[i], idx, 0x15); | |
df694daa KY |
10373 | if (err < 0) |
10374 | return err; | |
10375 | ||
4a471b7d | 10376 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
df694daa | 10377 | imux->items[imux->num_items].index = idx1; |
f12ab1e0 | 10378 | imux->num_items++; |
df694daa KY |
10379 | } |
10380 | return 0; | |
10381 | } | |
10382 | ||
10383 | static struct snd_kcontrol_new alc861_capture_mixer[] = { | |
10384 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
10385 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
10386 | ||
10387 | { | |
10388 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10389 | /* The multiple "Capture Source" controls confuse alsamixer | |
10390 | * So call somewhat different.. | |
10391 | *FIXME: the controls appear in the "playback" view! | |
10392 | */ | |
10393 | /* .name = "Capture Source", */ | |
10394 | .name = "Input Source", | |
10395 | .count = 1, | |
10396 | .info = alc_mux_enum_info, | |
10397 | .get = alc_mux_enum_get, | |
10398 | .put = alc_mux_enum_put, | |
10399 | }, | |
10400 | { } /* end */ | |
10401 | }; | |
10402 | ||
f12ab1e0 TI |
10403 | static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, |
10404 | hda_nid_t nid, | |
df694daa KY |
10405 | int pin_type, int dac_idx) |
10406 | { | |
10407 | /* set as output */ | |
10408 | ||
f12ab1e0 TI |
10409 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
10410 | pin_type); | |
10411 | snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
10412 | AMP_OUT_UNMUTE); | |
df694daa KY |
10413 | |
10414 | } | |
10415 | ||
10416 | static void alc861_auto_init_multi_out(struct hda_codec *codec) | |
10417 | { | |
10418 | struct alc_spec *spec = codec->spec; | |
10419 | int i; | |
10420 | ||
bc9f98a9 | 10421 | alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b); |
df694daa KY |
10422 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
10423 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 10424 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
df694daa | 10425 | if (nid) |
baba8ee9 | 10426 | alc861_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 10427 | spec->multiout.dac_nids[i]); |
df694daa KY |
10428 | } |
10429 | } | |
10430 | ||
10431 | static void alc861_auto_init_hp_out(struct hda_codec *codec) | |
10432 | { | |
10433 | struct alc_spec *spec = codec->spec; | |
10434 | hda_nid_t pin; | |
10435 | ||
eb06ed8f | 10436 | pin = spec->autocfg.hp_pins[0]; |
df694daa | 10437 | if (pin) /* connect to front */ |
f12ab1e0 TI |
10438 | alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, |
10439 | spec->multiout.dac_nids[0]); | |
df694daa KY |
10440 | } |
10441 | ||
10442 | static void alc861_auto_init_analog_input(struct hda_codec *codec) | |
10443 | { | |
10444 | struct alc_spec *spec = codec->spec; | |
10445 | int i; | |
10446 | ||
10447 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
10448 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
f12ab1e0 TI |
10449 | if (nid >= 0x0c && nid <= 0x11) { |
10450 | snd_hda_codec_write(codec, nid, 0, | |
10451 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
10452 | i <= AUTO_PIN_FRONT_MIC ? | |
10453 | PIN_VREF80 : PIN_IN); | |
df694daa KY |
10454 | } |
10455 | } | |
10456 | } | |
10457 | ||
10458 | /* parse the BIOS configuration and set up the alc_spec */ | |
f12ab1e0 TI |
10459 | /* return 1 if successful, 0 if the proper config is not found, |
10460 | * or a negative error code | |
10461 | */ | |
df694daa KY |
10462 | static int alc861_parse_auto_config(struct hda_codec *codec) |
10463 | { | |
10464 | struct alc_spec *spec = codec->spec; | |
10465 | int err; | |
10466 | static hda_nid_t alc861_ignore[] = { 0x1d, 0 }; | |
10467 | ||
f12ab1e0 TI |
10468 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
10469 | alc861_ignore); | |
10470 | if (err < 0) | |
df694daa | 10471 | return err; |
f12ab1e0 | 10472 | if (!spec->autocfg.line_outs) |
df694daa KY |
10473 | return 0; /* can't find valid BIOS pin config */ |
10474 | ||
f12ab1e0 TI |
10475 | err = alc861_auto_fill_dac_nids(spec, &spec->autocfg); |
10476 | if (err < 0) | |
10477 | return err; | |
10478 | err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
10479 | if (err < 0) | |
10480 | return err; | |
10481 | err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); | |
10482 | if (err < 0) | |
10483 | return err; | |
10484 | err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
10485 | if (err < 0) | |
df694daa KY |
10486 | return err; |
10487 | ||
10488 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
10489 | ||
10490 | if (spec->autocfg.dig_out_pin) | |
10491 | spec->multiout.dig_out_nid = ALC861_DIGOUT_NID; | |
10492 | ||
10493 | if (spec->kctl_alloc) | |
10494 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
10495 | ||
10496 | spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs; | |
10497 | ||
a1e8d2da | 10498 | spec->num_mux_defs = 1; |
df694daa KY |
10499 | spec->input_mux = &spec->private_imux; |
10500 | ||
10501 | spec->adc_nids = alc861_adc_nids; | |
10502 | spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); | |
10503 | spec->mixers[spec->num_mixers] = alc861_capture_mixer; | |
10504 | spec->num_mixers++; | |
10505 | ||
10506 | return 1; | |
10507 | } | |
10508 | ||
ae6b813a TI |
10509 | /* additional initialization for auto-configuration model */ |
10510 | static void alc861_auto_init(struct hda_codec *codec) | |
df694daa | 10511 | { |
df694daa KY |
10512 | alc861_auto_init_multi_out(codec); |
10513 | alc861_auto_init_hp_out(codec); | |
10514 | alc861_auto_init_analog_input(codec); | |
df694daa KY |
10515 | } |
10516 | ||
cb53c626 TI |
10517 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
10518 | static struct hda_amp_list alc861_loopbacks[] = { | |
10519 | { 0x15, HDA_INPUT, 0 }, | |
10520 | { 0x15, HDA_INPUT, 1 }, | |
10521 | { 0x15, HDA_INPUT, 2 }, | |
10522 | { 0x15, HDA_INPUT, 3 }, | |
10523 | { } /* end */ | |
10524 | }; | |
10525 | #endif | |
10526 | ||
df694daa KY |
10527 | |
10528 | /* | |
10529 | * configuration and preset | |
10530 | */ | |
f5fcc13c TI |
10531 | static const char *alc861_models[ALC861_MODEL_LAST] = { |
10532 | [ALC861_3ST] = "3stack", | |
10533 | [ALC660_3ST] = "3stack-660", | |
10534 | [ALC861_3ST_DIG] = "3stack-dig", | |
10535 | [ALC861_6ST_DIG] = "6stack-dig", | |
10536 | [ALC861_UNIWILL_M31] = "uniwill-m31", | |
10537 | [ALC861_TOSHIBA] = "toshiba", | |
10538 | [ALC861_ASUS] = "asus", | |
10539 | [ALC861_ASUS_LAPTOP] = "asus-laptop", | |
10540 | [ALC861_AUTO] = "auto", | |
10541 | }; | |
10542 | ||
10543 | static struct snd_pci_quirk alc861_cfg_tbl[] = { | |
687a47bd | 10544 | SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST), |
f5fcc13c TI |
10545 | SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP), |
10546 | SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP), | |
f223a9fc | 10547 | SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP), |
83c34218 | 10548 | SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP), |
f5fcc13c | 10549 | SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS), |
83c34218 | 10550 | SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG), |
ad5e7737 | 10551 | SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA), |
341d4eb0 TI |
10552 | /* FIXME: the entry below breaks Toshiba A100 (model=auto works!) |
10553 | * Any other models that need this preset? | |
10554 | */ | |
10555 | /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */ | |
f5fcc13c | 10556 | SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31), |
35739bb1 | 10557 | SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), |
4147dab6 | 10558 | SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31), |
07e038b3 | 10559 | SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST), |
f5fcc13c | 10560 | SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST), |
ef64adbb CM |
10561 | SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST), |
10562 | SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST), | |
df694daa KY |
10563 | {} |
10564 | }; | |
10565 | ||
10566 | static struct alc_config_preset alc861_presets[] = { | |
10567 | [ALC861_3ST] = { | |
10568 | .mixers = { alc861_3ST_mixer }, | |
10569 | .init_verbs = { alc861_threestack_init_verbs }, | |
10570 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
10571 | .dac_nids = alc861_dac_nids, | |
10572 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
10573 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 10574 | .need_dac_fix = 1, |
df694daa KY |
10575 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
10576 | .adc_nids = alc861_adc_nids, | |
10577 | .input_mux = &alc861_capture_source, | |
10578 | }, | |
10579 | [ALC861_3ST_DIG] = { | |
10580 | .mixers = { alc861_base_mixer }, | |
10581 | .init_verbs = { alc861_threestack_init_verbs }, | |
10582 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
10583 | .dac_nids = alc861_dac_nids, | |
10584 | .dig_out_nid = ALC861_DIGOUT_NID, | |
10585 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
10586 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 10587 | .need_dac_fix = 1, |
df694daa KY |
10588 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
10589 | .adc_nids = alc861_adc_nids, | |
10590 | .input_mux = &alc861_capture_source, | |
10591 | }, | |
10592 | [ALC861_6ST_DIG] = { | |
10593 | .mixers = { alc861_base_mixer }, | |
10594 | .init_verbs = { alc861_base_init_verbs }, | |
10595 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
10596 | .dac_nids = alc861_dac_nids, | |
10597 | .dig_out_nid = ALC861_DIGOUT_NID, | |
10598 | .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes), | |
10599 | .channel_mode = alc861_8ch_modes, | |
10600 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
10601 | .adc_nids = alc861_adc_nids, | |
10602 | .input_mux = &alc861_capture_source, | |
10603 | }, | |
9c7f852e TI |
10604 | [ALC660_3ST] = { |
10605 | .mixers = { alc861_3ST_mixer }, | |
10606 | .init_verbs = { alc861_threestack_init_verbs }, | |
10607 | .num_dacs = ARRAY_SIZE(alc660_dac_nids), | |
10608 | .dac_nids = alc660_dac_nids, | |
10609 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
10610 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 10611 | .need_dac_fix = 1, |
9c7f852e TI |
10612 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
10613 | .adc_nids = alc861_adc_nids, | |
10614 | .input_mux = &alc861_capture_source, | |
10615 | }, | |
22309c3e TI |
10616 | [ALC861_UNIWILL_M31] = { |
10617 | .mixers = { alc861_uniwill_m31_mixer }, | |
10618 | .init_verbs = { alc861_uniwill_m31_init_verbs }, | |
10619 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
10620 | .dac_nids = alc861_dac_nids, | |
10621 | .dig_out_nid = ALC861_DIGOUT_NID, | |
10622 | .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes), | |
10623 | .channel_mode = alc861_uniwill_m31_modes, | |
10624 | .need_dac_fix = 1, | |
10625 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
10626 | .adc_nids = alc861_adc_nids, | |
10627 | .input_mux = &alc861_capture_source, | |
10628 | }, | |
a53d1aec TD |
10629 | [ALC861_TOSHIBA] = { |
10630 | .mixers = { alc861_toshiba_mixer }, | |
f12ab1e0 TI |
10631 | .init_verbs = { alc861_base_init_verbs, |
10632 | alc861_toshiba_init_verbs }, | |
a53d1aec TD |
10633 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), |
10634 | .dac_nids = alc861_dac_nids, | |
10635 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
10636 | .channel_mode = alc883_3ST_2ch_modes, | |
10637 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
10638 | .adc_nids = alc861_adc_nids, | |
10639 | .input_mux = &alc861_capture_source, | |
10640 | .unsol_event = alc861_toshiba_unsol_event, | |
10641 | .init_hook = alc861_toshiba_automute, | |
10642 | }, | |
7cdbff94 MD |
10643 | [ALC861_ASUS] = { |
10644 | .mixers = { alc861_asus_mixer }, | |
10645 | .init_verbs = { alc861_asus_init_verbs }, | |
10646 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
10647 | .dac_nids = alc861_dac_nids, | |
10648 | .dig_out_nid = ALC861_DIGOUT_NID, | |
10649 | .num_channel_mode = ARRAY_SIZE(alc861_asus_modes), | |
10650 | .channel_mode = alc861_asus_modes, | |
10651 | .need_dac_fix = 1, | |
10652 | .hp_nid = 0x06, | |
10653 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
10654 | .adc_nids = alc861_adc_nids, | |
10655 | .input_mux = &alc861_capture_source, | |
10656 | }, | |
56bb0cab TI |
10657 | [ALC861_ASUS_LAPTOP] = { |
10658 | .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer }, | |
10659 | .init_verbs = { alc861_asus_init_verbs, | |
10660 | alc861_asus_laptop_init_verbs }, | |
10661 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
10662 | .dac_nids = alc861_dac_nids, | |
10663 | .dig_out_nid = ALC861_DIGOUT_NID, | |
10664 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
10665 | .channel_mode = alc883_3ST_2ch_modes, | |
10666 | .need_dac_fix = 1, | |
10667 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
10668 | .adc_nids = alc861_adc_nids, | |
10669 | .input_mux = &alc861_capture_source, | |
10670 | }, | |
10671 | }; | |
df694daa KY |
10672 | |
10673 | ||
10674 | static int patch_alc861(struct hda_codec *codec) | |
10675 | { | |
10676 | struct alc_spec *spec; | |
10677 | int board_config; | |
10678 | int err; | |
10679 | ||
dc041e0b | 10680 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
df694daa KY |
10681 | if (spec == NULL) |
10682 | return -ENOMEM; | |
10683 | ||
f12ab1e0 | 10684 | codec->spec = spec; |
df694daa | 10685 | |
f5fcc13c TI |
10686 | board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST, |
10687 | alc861_models, | |
10688 | alc861_cfg_tbl); | |
9c7f852e | 10689 | |
f5fcc13c | 10690 | if (board_config < 0) { |
9c7f852e TI |
10691 | printk(KERN_INFO "hda_codec: Unknown model for ALC861, " |
10692 | "trying auto-probe from BIOS...\n"); | |
df694daa KY |
10693 | board_config = ALC861_AUTO; |
10694 | } | |
10695 | ||
10696 | if (board_config == ALC861_AUTO) { | |
10697 | /* automatic parse from the BIOS config */ | |
10698 | err = alc861_parse_auto_config(codec); | |
10699 | if (err < 0) { | |
10700 | alc_free(codec); | |
10701 | return err; | |
f12ab1e0 | 10702 | } else if (!err) { |
9c7f852e TI |
10703 | printk(KERN_INFO |
10704 | "hda_codec: Cannot set up configuration " | |
10705 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
10706 | board_config = ALC861_3ST_DIG; |
10707 | } | |
10708 | } | |
10709 | ||
10710 | if (board_config != ALC861_AUTO) | |
10711 | setup_preset(spec, &alc861_presets[board_config]); | |
10712 | ||
10713 | spec->stream_name_analog = "ALC861 Analog"; | |
10714 | spec->stream_analog_playback = &alc861_pcm_analog_playback; | |
10715 | spec->stream_analog_capture = &alc861_pcm_analog_capture; | |
10716 | ||
10717 | spec->stream_name_digital = "ALC861 Digital"; | |
10718 | spec->stream_digital_playback = &alc861_pcm_digital_playback; | |
10719 | spec->stream_digital_capture = &alc861_pcm_digital_capture; | |
10720 | ||
10721 | codec->patch_ops = alc_patch_ops; | |
10722 | if (board_config == ALC861_AUTO) | |
ae6b813a | 10723 | spec->init_hook = alc861_auto_init; |
cb53c626 TI |
10724 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
10725 | if (!spec->loopback.amplist) | |
10726 | spec->loopback.amplist = alc861_loopbacks; | |
10727 | #endif | |
df694daa | 10728 | |
1da177e4 LT |
10729 | return 0; |
10730 | } | |
10731 | ||
f32610ed JS |
10732 | /* |
10733 | * ALC861-VD support | |
10734 | * | |
10735 | * Based on ALC882 | |
10736 | * | |
10737 | * In addition, an independent DAC | |
10738 | */ | |
10739 | #define ALC861VD_DIGOUT_NID 0x06 | |
10740 | ||
10741 | static hda_nid_t alc861vd_dac_nids[4] = { | |
10742 | /* front, surr, clfe, side surr */ | |
10743 | 0x02, 0x03, 0x04, 0x05 | |
10744 | }; | |
10745 | ||
10746 | /* dac_nids for ALC660vd are in a different order - according to | |
10747 | * Realtek's driver. | |
10748 | * This should probably tesult in a different mixer for 6stack models | |
10749 | * of ALC660vd codecs, but for now there is only 3stack mixer | |
10750 | * - and it is the same as in 861vd. | |
10751 | * adc_nids in ALC660vd are (is) the same as in 861vd | |
10752 | */ | |
10753 | static hda_nid_t alc660vd_dac_nids[3] = { | |
10754 | /* front, rear, clfe, rear_surr */ | |
10755 | 0x02, 0x04, 0x03 | |
10756 | }; | |
10757 | ||
10758 | static hda_nid_t alc861vd_adc_nids[1] = { | |
10759 | /* ADC0 */ | |
10760 | 0x09, | |
10761 | }; | |
10762 | ||
10763 | /* input MUX */ | |
10764 | /* FIXME: should be a matrix-type input source selection */ | |
10765 | static struct hda_input_mux alc861vd_capture_source = { | |
10766 | .num_items = 4, | |
10767 | .items = { | |
10768 | { "Mic", 0x0 }, | |
10769 | { "Front Mic", 0x1 }, | |
10770 | { "Line", 0x2 }, | |
10771 | { "CD", 0x4 }, | |
10772 | }, | |
10773 | }; | |
10774 | ||
272a527c KY |
10775 | static struct hda_input_mux alc861vd_dallas_capture_source = { |
10776 | .num_items = 3, | |
10777 | .items = { | |
10778 | { "Front Mic", 0x0 }, | |
10779 | { "ATAPI Mic", 0x1 }, | |
10780 | { "Line In", 0x5 }, | |
10781 | }, | |
10782 | }; | |
10783 | ||
d1a991a6 KY |
10784 | static struct hda_input_mux alc861vd_hp_capture_source = { |
10785 | .num_items = 2, | |
10786 | .items = { | |
10787 | { "Front Mic", 0x0 }, | |
10788 | { "ATAPI Mic", 0x1 }, | |
10789 | }, | |
10790 | }; | |
10791 | ||
f32610ed JS |
10792 | #define alc861vd_mux_enum_info alc_mux_enum_info |
10793 | #define alc861vd_mux_enum_get alc_mux_enum_get | |
10794 | ||
10795 | static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol, | |
10796 | struct snd_ctl_elem_value *ucontrol) | |
10797 | { | |
10798 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
10799 | struct alc_spec *spec = codec->spec; | |
10800 | const struct hda_input_mux *imux = spec->input_mux; | |
10801 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
10802 | static hda_nid_t capture_mixers[1] = { 0x22 }; | |
10803 | hda_nid_t nid = capture_mixers[adc_idx]; | |
10804 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; | |
10805 | unsigned int i, idx; | |
10806 | ||
10807 | idx = ucontrol->value.enumerated.item[0]; | |
10808 | if (idx >= imux->num_items) | |
10809 | idx = imux->num_items - 1; | |
82beb8fd | 10810 | if (*cur_val == idx) |
f32610ed JS |
10811 | return 0; |
10812 | for (i = 0; i < imux->num_items; i++) { | |
47fd830a TI |
10813 | unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE; |
10814 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, | |
10815 | imux->items[i].index, | |
10816 | HDA_AMP_MUTE, v); | |
f32610ed JS |
10817 | } |
10818 | *cur_val = idx; | |
10819 | return 1; | |
10820 | } | |
10821 | ||
10822 | /* | |
10823 | * 2ch mode | |
10824 | */ | |
10825 | static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = { | |
10826 | { 2, NULL } | |
10827 | }; | |
10828 | ||
10829 | /* | |
10830 | * 6ch mode | |
10831 | */ | |
10832 | static struct hda_verb alc861vd_6stack_ch6_init[] = { | |
10833 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
10834 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
10835 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
10836 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
10837 | { } /* end */ | |
10838 | }; | |
10839 | ||
10840 | /* | |
10841 | * 8ch mode | |
10842 | */ | |
10843 | static struct hda_verb alc861vd_6stack_ch8_init[] = { | |
10844 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
10845 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
10846 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
10847 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
10848 | { } /* end */ | |
10849 | }; | |
10850 | ||
10851 | static struct hda_channel_mode alc861vd_6stack_modes[2] = { | |
10852 | { 6, alc861vd_6stack_ch6_init }, | |
10853 | { 8, alc861vd_6stack_ch8_init }, | |
10854 | }; | |
10855 | ||
10856 | static struct snd_kcontrol_new alc861vd_chmode_mixer[] = { | |
10857 | { | |
10858 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10859 | .name = "Channel Mode", | |
10860 | .info = alc_ch_mode_info, | |
10861 | .get = alc_ch_mode_get, | |
10862 | .put = alc_ch_mode_put, | |
10863 | }, | |
10864 | { } /* end */ | |
10865 | }; | |
10866 | ||
10867 | static struct snd_kcontrol_new alc861vd_capture_mixer[] = { | |
10868 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
10869 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
10870 | ||
10871 | { | |
10872 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10873 | /* The multiple "Capture Source" controls confuse alsamixer | |
10874 | * So call somewhat different.. | |
10875 | *FIXME: the controls appear in the "playback" view! | |
10876 | */ | |
10877 | /* .name = "Capture Source", */ | |
10878 | .name = "Input Source", | |
10879 | .count = 1, | |
10880 | .info = alc861vd_mux_enum_info, | |
10881 | .get = alc861vd_mux_enum_get, | |
10882 | .put = alc861vd_mux_enum_put, | |
10883 | }, | |
10884 | { } /* end */ | |
10885 | }; | |
10886 | ||
10887 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 | |
10888 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
10889 | */ | |
10890 | static struct snd_kcontrol_new alc861vd_6st_mixer[] = { | |
10891 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
10892 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
10893 | ||
10894 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
10895 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
10896 | ||
10897 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, | |
10898 | HDA_OUTPUT), | |
10899 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, | |
10900 | HDA_OUTPUT), | |
10901 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
10902 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
10903 | ||
10904 | HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT), | |
10905 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
10906 | ||
10907 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
10908 | ||
10909 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
10910 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
10911 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
10912 | ||
10913 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
10914 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
10915 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
10916 | ||
10917 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
10918 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
10919 | ||
10920 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
10921 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
10922 | ||
10923 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
10924 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
10925 | ||
10926 | { } /* end */ | |
10927 | }; | |
10928 | ||
10929 | static struct snd_kcontrol_new alc861vd_3st_mixer[] = { | |
10930 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
10931 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
10932 | ||
10933 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
10934 | ||
10935 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
10936 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
10937 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
10938 | ||
10939 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
10940 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
10941 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
10942 | ||
10943 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
10944 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
10945 | ||
10946 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
10947 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
10948 | ||
10949 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
10950 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
10951 | ||
10952 | { } /* end */ | |
10953 | }; | |
10954 | ||
bdd148a3 KY |
10955 | static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = { |
10956 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
10957 | /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/ | |
10958 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
10959 | ||
10960 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
10961 | ||
10962 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
10963 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
10964 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
10965 | ||
10966 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
10967 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
10968 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
10969 | ||
10970 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
10971 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
10972 | ||
10973 | { } /* end */ | |
10974 | }; | |
10975 | ||
272a527c KY |
10976 | /* Pin assignment: Front=0x14, HP = 0x15, |
10977 | * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d | |
10978 | */ | |
10979 | static struct snd_kcontrol_new alc861vd_dallas_mixer[] = { | |
10980 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
10981 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
10982 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
10983 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), | |
10984 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
10985 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
10986 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
10987 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
10988 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
10989 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
272a527c KY |
10990 | { } /* end */ |
10991 | }; | |
10992 | ||
d1a991a6 KY |
10993 | /* Pin assignment: Speaker=0x14, Line-out = 0x15, |
10994 | * Front Mic=0x18, ATAPI Mic = 0x19, | |
10995 | */ | |
10996 | static struct snd_kcontrol_new alc861vd_hp_mixer[] = { | |
10997 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
10998 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
10999 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
11000 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), | |
11001 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
11002 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
11003 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
11004 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
11005 | ||
11006 | { } /* end */ | |
11007 | }; | |
11008 | ||
f32610ed JS |
11009 | /* |
11010 | * generic initialization of ADC, input mixers and output mixers | |
11011 | */ | |
11012 | static struct hda_verb alc861vd_volume_init_verbs[] = { | |
11013 | /* | |
11014 | * Unmute ADC0 and set the default input to mic-in | |
11015 | */ | |
11016 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
11017 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11018 | ||
11019 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of | |
11020 | * the analog-loopback mixer widget | |
11021 | */ | |
11022 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
11023 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
11024 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
11025 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
11026 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
11027 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
f32610ed JS |
11028 | |
11029 | /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */ | |
bdd148a3 KY |
11030 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
11031 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11032 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f32610ed | 11033 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
f32610ed JS |
11034 | |
11035 | /* | |
11036 | * Set up output mixers (0x02 - 0x05) | |
11037 | */ | |
11038 | /* set vol=0 to output mixers */ | |
11039 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
11040 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
11041 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
11042 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
11043 | ||
11044 | /* set up input amps for analog loopback */ | |
11045 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
11046 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
11047 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
11048 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
11049 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
11050 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
11051 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
11052 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
11053 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
11054 | ||
11055 | { } | |
11056 | }; | |
11057 | ||
11058 | /* | |
11059 | * 3-stack pin configuration: | |
11060 | * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b | |
11061 | */ | |
11062 | static struct hda_verb alc861vd_3stack_init_verbs[] = { | |
11063 | /* | |
11064 | * Set pin mode and muting | |
11065 | */ | |
11066 | /* set front pin widgets 0x14 for output */ | |
11067 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
11068 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11069 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
11070 | ||
11071 | /* Mic (rear) pin: input vref at 80% */ | |
11072 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
11073 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11074 | /* Front Mic pin: input vref at 80% */ | |
11075 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
11076 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11077 | /* Line In pin: input */ | |
11078 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
11079 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11080 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
11081 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
11082 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11083 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
11084 | /* CD pin widget for input */ | |
11085 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
11086 | ||
11087 | { } | |
11088 | }; | |
11089 | ||
11090 | /* | |
11091 | * 6-stack pin configuration: | |
11092 | */ | |
11093 | static struct hda_verb alc861vd_6stack_init_verbs[] = { | |
11094 | /* | |
11095 | * Set pin mode and muting | |
11096 | */ | |
11097 | /* set front pin widgets 0x14 for output */ | |
11098 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
11099 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11100 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
11101 | ||
11102 | /* Rear Pin: output 1 (0x0d) */ | |
11103 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
11104 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11105 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
11106 | /* CLFE Pin: output 2 (0x0e) */ | |
11107 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
11108 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11109 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
11110 | /* Side Pin: output 3 (0x0f) */ | |
11111 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
11112 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11113 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
11114 | ||
11115 | /* Mic (rear) pin: input vref at 80% */ | |
11116 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
11117 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11118 | /* Front Mic pin: input vref at 80% */ | |
11119 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
11120 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11121 | /* Line In pin: input */ | |
11122 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
11123 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11124 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
11125 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
11126 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11127 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
11128 | /* CD pin widget for input */ | |
11129 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
11130 | ||
11131 | { } | |
11132 | }; | |
11133 | ||
bdd148a3 KY |
11134 | static struct hda_verb alc861vd_eapd_verbs[] = { |
11135 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
11136 | { } | |
11137 | }; | |
11138 | ||
11139 | static struct hda_verb alc861vd_lenovo_unsol_verbs[] = { | |
11140 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11141 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11142 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
11143 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
11144 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
11145 | {} | |
11146 | }; | |
11147 | ||
11148 | /* toggle speaker-output according to the hp-jack state */ | |
11149 | static void alc861vd_lenovo_hp_automute(struct hda_codec *codec) | |
11150 | { | |
11151 | unsigned int present; | |
11152 | unsigned char bits; | |
11153 | ||
11154 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
11155 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
11156 | bits = present ? HDA_AMP_MUTE : 0; |
11157 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
11158 | HDA_AMP_MUTE, bits); | |
bdd148a3 KY |
11159 | } |
11160 | ||
11161 | static void alc861vd_lenovo_mic_automute(struct hda_codec *codec) | |
11162 | { | |
11163 | unsigned int present; | |
11164 | unsigned char bits; | |
11165 | ||
11166 | present = snd_hda_codec_read(codec, 0x18, 0, | |
11167 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
11168 | bits = present ? HDA_AMP_MUTE : 0; |
11169 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, | |
11170 | HDA_AMP_MUTE, bits); | |
bdd148a3 KY |
11171 | } |
11172 | ||
11173 | static void alc861vd_lenovo_automute(struct hda_codec *codec) | |
11174 | { | |
11175 | alc861vd_lenovo_hp_automute(codec); | |
11176 | alc861vd_lenovo_mic_automute(codec); | |
11177 | } | |
11178 | ||
11179 | static void alc861vd_lenovo_unsol_event(struct hda_codec *codec, | |
11180 | unsigned int res) | |
11181 | { | |
11182 | switch (res >> 26) { | |
11183 | case ALC880_HP_EVENT: | |
11184 | alc861vd_lenovo_hp_automute(codec); | |
11185 | break; | |
11186 | case ALC880_MIC_EVENT: | |
11187 | alc861vd_lenovo_mic_automute(codec); | |
11188 | break; | |
11189 | } | |
11190 | } | |
11191 | ||
272a527c KY |
11192 | static struct hda_verb alc861vd_dallas_verbs[] = { |
11193 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
11194 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
11195 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
11196 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
11197 | ||
11198 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11199 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11200 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
11201 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
11202 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
11203 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
11204 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
11205 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
11206 | ||
11207 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
11208 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11209 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
11210 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11211 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
11212 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11213 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
11214 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11215 | ||
11216 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | |
11217 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11218 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | |
11219 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11220 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
11221 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
11222 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
11223 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
11224 | ||
11225 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11226 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
11227 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
11228 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
11229 | ||
11230 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
11231 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
11232 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
11233 | ||
11234 | { } /* end */ | |
11235 | }; | |
11236 | ||
11237 | /* toggle speaker-output according to the hp-jack state */ | |
11238 | static void alc861vd_dallas_automute(struct hda_codec *codec) | |
11239 | { | |
11240 | unsigned int present; | |
11241 | ||
11242 | present = snd_hda_codec_read(codec, 0x15, 0, | |
11243 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
11244 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
11245 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c KY |
11246 | } |
11247 | ||
11248 | static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res) | |
11249 | { | |
11250 | if ((res >> 26) == ALC880_HP_EVENT) | |
11251 | alc861vd_dallas_automute(codec); | |
11252 | } | |
11253 | ||
cb53c626 TI |
11254 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
11255 | #define alc861vd_loopbacks alc880_loopbacks | |
11256 | #endif | |
11257 | ||
f32610ed JS |
11258 | /* pcm configuration: identiacal with ALC880 */ |
11259 | #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback | |
11260 | #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture | |
11261 | #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback | |
11262 | #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture | |
11263 | ||
11264 | /* | |
11265 | * configuration and preset | |
11266 | */ | |
11267 | static const char *alc861vd_models[ALC861VD_MODEL_LAST] = { | |
11268 | [ALC660VD_3ST] = "3stack-660", | |
983f8ae4 | 11269 | [ALC660VD_3ST_DIG] = "3stack-660-digout", |
f32610ed JS |
11270 | [ALC861VD_3ST] = "3stack", |
11271 | [ALC861VD_3ST_DIG] = "3stack-digout", | |
11272 | [ALC861VD_6ST_DIG] = "6stack-digout", | |
bdd148a3 | 11273 | [ALC861VD_LENOVO] = "lenovo", |
272a527c | 11274 | [ALC861VD_DALLAS] = "dallas", |
983f8ae4 | 11275 | [ALC861VD_HP] = "hp", |
f32610ed JS |
11276 | [ALC861VD_AUTO] = "auto", |
11277 | }; | |
11278 | ||
11279 | static struct snd_pci_quirk alc861vd_cfg_tbl[] = { | |
07e038b3 | 11280 | SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST), |
f32610ed | 11281 | SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST), |
6963f84c | 11282 | SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG), |
f32610ed JS |
11283 | SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST), |
11284 | SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST), | |
11285 | ||
38baf5ad | 11286 | /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/ |
272a527c | 11287 | SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS), |
bdd148a3 KY |
11288 | SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO), |
11289 | SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO), | |
a18519e1 | 11290 | SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO), |
542d7c66 | 11291 | SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO), |
39c5d41f | 11292 | SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG), |
625dc0bf | 11293 | SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG), |
d1a991a6 | 11294 | SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP), |
f32610ed JS |
11295 | {} |
11296 | }; | |
11297 | ||
11298 | static struct alc_config_preset alc861vd_presets[] = { | |
11299 | [ALC660VD_3ST] = { | |
11300 | .mixers = { alc861vd_3st_mixer }, | |
11301 | .init_verbs = { alc861vd_volume_init_verbs, | |
11302 | alc861vd_3stack_init_verbs }, | |
11303 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
11304 | .dac_nids = alc660vd_dac_nids, | |
11305 | .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids), | |
11306 | .adc_nids = alc861vd_adc_nids, | |
11307 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
11308 | .channel_mode = alc861vd_3stack_2ch_modes, | |
11309 | .input_mux = &alc861vd_capture_source, | |
11310 | }, | |
6963f84c MC |
11311 | [ALC660VD_3ST_DIG] = { |
11312 | .mixers = { alc861vd_3st_mixer }, | |
11313 | .init_verbs = { alc861vd_volume_init_verbs, | |
11314 | alc861vd_3stack_init_verbs }, | |
11315 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
11316 | .dac_nids = alc660vd_dac_nids, | |
11317 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
11318 | .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids), | |
11319 | .adc_nids = alc861vd_adc_nids, | |
11320 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
11321 | .channel_mode = alc861vd_3stack_2ch_modes, | |
11322 | .input_mux = &alc861vd_capture_source, | |
11323 | }, | |
f32610ed JS |
11324 | [ALC861VD_3ST] = { |
11325 | .mixers = { alc861vd_3st_mixer }, | |
11326 | .init_verbs = { alc861vd_volume_init_verbs, | |
11327 | alc861vd_3stack_init_verbs }, | |
11328 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
11329 | .dac_nids = alc861vd_dac_nids, | |
11330 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
11331 | .channel_mode = alc861vd_3stack_2ch_modes, | |
11332 | .input_mux = &alc861vd_capture_source, | |
11333 | }, | |
11334 | [ALC861VD_3ST_DIG] = { | |
11335 | .mixers = { alc861vd_3st_mixer }, | |
11336 | .init_verbs = { alc861vd_volume_init_verbs, | |
11337 | alc861vd_3stack_init_verbs }, | |
11338 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
11339 | .dac_nids = alc861vd_dac_nids, | |
11340 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
11341 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
11342 | .channel_mode = alc861vd_3stack_2ch_modes, | |
11343 | .input_mux = &alc861vd_capture_source, | |
11344 | }, | |
11345 | [ALC861VD_6ST_DIG] = { | |
11346 | .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer }, | |
11347 | .init_verbs = { alc861vd_volume_init_verbs, | |
11348 | alc861vd_6stack_init_verbs }, | |
11349 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
11350 | .dac_nids = alc861vd_dac_nids, | |
11351 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
11352 | .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes), | |
11353 | .channel_mode = alc861vd_6stack_modes, | |
11354 | .input_mux = &alc861vd_capture_source, | |
11355 | }, | |
bdd148a3 KY |
11356 | [ALC861VD_LENOVO] = { |
11357 | .mixers = { alc861vd_lenovo_mixer }, | |
11358 | .init_verbs = { alc861vd_volume_init_verbs, | |
11359 | alc861vd_3stack_init_verbs, | |
11360 | alc861vd_eapd_verbs, | |
11361 | alc861vd_lenovo_unsol_verbs }, | |
11362 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
11363 | .dac_nids = alc660vd_dac_nids, | |
11364 | .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids), | |
11365 | .adc_nids = alc861vd_adc_nids, | |
11366 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
11367 | .channel_mode = alc861vd_3stack_2ch_modes, | |
11368 | .input_mux = &alc861vd_capture_source, | |
11369 | .unsol_event = alc861vd_lenovo_unsol_event, | |
11370 | .init_hook = alc861vd_lenovo_automute, | |
11371 | }, | |
272a527c KY |
11372 | [ALC861VD_DALLAS] = { |
11373 | .mixers = { alc861vd_dallas_mixer }, | |
11374 | .init_verbs = { alc861vd_dallas_verbs }, | |
11375 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
11376 | .dac_nids = alc861vd_dac_nids, | |
11377 | .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids), | |
11378 | .adc_nids = alc861vd_adc_nids, | |
11379 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
11380 | .channel_mode = alc861vd_3stack_2ch_modes, | |
11381 | .input_mux = &alc861vd_dallas_capture_source, | |
11382 | .unsol_event = alc861vd_dallas_unsol_event, | |
11383 | .init_hook = alc861vd_dallas_automute, | |
d1a991a6 KY |
11384 | }, |
11385 | [ALC861VD_HP] = { | |
11386 | .mixers = { alc861vd_hp_mixer }, | |
11387 | .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs }, | |
11388 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
11389 | .dac_nids = alc861vd_dac_nids, | |
11390 | .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids), | |
11391 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
11392 | .adc_nids = alc861vd_adc_nids, | |
11393 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
11394 | .channel_mode = alc861vd_3stack_2ch_modes, | |
11395 | .input_mux = &alc861vd_hp_capture_source, | |
11396 | .unsol_event = alc861vd_dallas_unsol_event, | |
11397 | .init_hook = alc861vd_dallas_automute, | |
11398 | }, | |
f32610ed JS |
11399 | }; |
11400 | ||
11401 | /* | |
11402 | * BIOS auto configuration | |
11403 | */ | |
11404 | static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec, | |
11405 | hda_nid_t nid, int pin_type, int dac_idx) | |
11406 | { | |
11407 | /* set as output */ | |
11408 | snd_hda_codec_write(codec, nid, 0, | |
11409 | AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); | |
11410 | snd_hda_codec_write(codec, nid, 0, | |
11411 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); | |
11412 | } | |
11413 | ||
11414 | static void alc861vd_auto_init_multi_out(struct hda_codec *codec) | |
11415 | { | |
11416 | struct alc_spec *spec = codec->spec; | |
11417 | int i; | |
11418 | ||
bc9f98a9 | 11419 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
f32610ed JS |
11420 | for (i = 0; i <= HDA_SIDE; i++) { |
11421 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 11422 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
f32610ed JS |
11423 | if (nid) |
11424 | alc861vd_auto_set_output_and_unmute(codec, nid, | |
baba8ee9 | 11425 | pin_type, i); |
f32610ed JS |
11426 | } |
11427 | } | |
11428 | ||
11429 | ||
11430 | static void alc861vd_auto_init_hp_out(struct hda_codec *codec) | |
11431 | { | |
11432 | struct alc_spec *spec = codec->spec; | |
11433 | hda_nid_t pin; | |
11434 | ||
11435 | pin = spec->autocfg.hp_pins[0]; | |
11436 | if (pin) /* connect to front and use dac 0 */ | |
11437 | alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
11438 | } | |
11439 | ||
11440 | #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid) | |
11441 | #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID | |
11442 | ||
11443 | static void alc861vd_auto_init_analog_input(struct hda_codec *codec) | |
11444 | { | |
11445 | struct alc_spec *spec = codec->spec; | |
11446 | int i; | |
11447 | ||
11448 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
11449 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
11450 | if (alc861vd_is_input_pin(nid)) { | |
11451 | snd_hda_codec_write(codec, nid, 0, | |
11452 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
11453 | i <= AUTO_PIN_FRONT_MIC ? | |
11454 | PIN_VREF80 : PIN_IN); | |
11455 | if (nid != ALC861VD_PIN_CD_NID) | |
11456 | snd_hda_codec_write(codec, nid, 0, | |
11457 | AC_VERB_SET_AMP_GAIN_MUTE, | |
11458 | AMP_OUT_MUTE); | |
11459 | } | |
11460 | } | |
11461 | } | |
11462 | ||
11463 | #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02) | |
11464 | #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c) | |
11465 | ||
11466 | /* add playback controls from the parsed DAC table */ | |
11467 | /* Based on ALC880 version. But ALC861VD has separate, | |
11468 | * different NIDs for mute/unmute switch and volume control */ | |
11469 | static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec, | |
11470 | const struct auto_pin_cfg *cfg) | |
11471 | { | |
11472 | char name[32]; | |
11473 | static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"}; | |
11474 | hda_nid_t nid_v, nid_s; | |
11475 | int i, err; | |
11476 | ||
11477 | for (i = 0; i < cfg->line_outs; i++) { | |
f12ab1e0 | 11478 | if (!spec->multiout.dac_nids[i]) |
f32610ed JS |
11479 | continue; |
11480 | nid_v = alc861vd_idx_to_mixer_vol( | |
11481 | alc880_dac_to_idx( | |
11482 | spec->multiout.dac_nids[i])); | |
11483 | nid_s = alc861vd_idx_to_mixer_switch( | |
11484 | alc880_dac_to_idx( | |
11485 | spec->multiout.dac_nids[i])); | |
11486 | ||
11487 | if (i == 2) { | |
11488 | /* Center/LFE */ | |
f12ab1e0 TI |
11489 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
11490 | "Center Playback Volume", | |
11491 | HDA_COMPOSE_AMP_VAL(nid_v, 1, 0, | |
11492 | HDA_OUTPUT)); | |
11493 | if (err < 0) | |
f32610ed | 11494 | return err; |
f12ab1e0 TI |
11495 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
11496 | "LFE Playback Volume", | |
11497 | HDA_COMPOSE_AMP_VAL(nid_v, 2, 0, | |
11498 | HDA_OUTPUT)); | |
11499 | if (err < 0) | |
f32610ed | 11500 | return err; |
f12ab1e0 TI |
11501 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
11502 | "Center Playback Switch", | |
11503 | HDA_COMPOSE_AMP_VAL(nid_s, 1, 2, | |
11504 | HDA_INPUT)); | |
11505 | if (err < 0) | |
f32610ed | 11506 | return err; |
f12ab1e0 TI |
11507 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
11508 | "LFE Playback Switch", | |
11509 | HDA_COMPOSE_AMP_VAL(nid_s, 2, 2, | |
11510 | HDA_INPUT)); | |
11511 | if (err < 0) | |
f32610ed JS |
11512 | return err; |
11513 | } else { | |
11514 | sprintf(name, "%s Playback Volume", chname[i]); | |
f12ab1e0 TI |
11515 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
11516 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, | |
11517 | HDA_OUTPUT)); | |
11518 | if (err < 0) | |
f32610ed JS |
11519 | return err; |
11520 | sprintf(name, "%s Playback Switch", chname[i]); | |
f12ab1e0 | 11521 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
bdd148a3 | 11522 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, |
f12ab1e0 TI |
11523 | HDA_INPUT)); |
11524 | if (err < 0) | |
f32610ed JS |
11525 | return err; |
11526 | } | |
11527 | } | |
11528 | return 0; | |
11529 | } | |
11530 | ||
11531 | /* add playback controls for speaker and HP outputs */ | |
11532 | /* Based on ALC880 version. But ALC861VD has separate, | |
11533 | * different NIDs for mute/unmute switch and volume control */ | |
11534 | static int alc861vd_auto_create_extra_out(struct alc_spec *spec, | |
11535 | hda_nid_t pin, const char *pfx) | |
11536 | { | |
11537 | hda_nid_t nid_v, nid_s; | |
11538 | int err; | |
11539 | char name[32]; | |
11540 | ||
f12ab1e0 | 11541 | if (!pin) |
f32610ed JS |
11542 | return 0; |
11543 | ||
11544 | if (alc880_is_fixed_pin(pin)) { | |
11545 | nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
11546 | /* specify the DAC as the extra output */ | |
f12ab1e0 | 11547 | if (!spec->multiout.hp_nid) |
f32610ed JS |
11548 | spec->multiout.hp_nid = nid_v; |
11549 | else | |
11550 | spec->multiout.extra_out_nid[0] = nid_v; | |
11551 | /* control HP volume/switch on the output mixer amp */ | |
11552 | nid_v = alc861vd_idx_to_mixer_vol( | |
11553 | alc880_fixed_pin_idx(pin)); | |
11554 | nid_s = alc861vd_idx_to_mixer_switch( | |
11555 | alc880_fixed_pin_idx(pin)); | |
11556 | ||
11557 | sprintf(name, "%s Playback Volume", pfx); | |
f12ab1e0 TI |
11558 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
11559 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT)); | |
11560 | if (err < 0) | |
f32610ed JS |
11561 | return err; |
11562 | sprintf(name, "%s Playback Switch", pfx); | |
f12ab1e0 TI |
11563 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
11564 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT)); | |
11565 | if (err < 0) | |
f32610ed JS |
11566 | return err; |
11567 | } else if (alc880_is_multi_pin(pin)) { | |
11568 | /* set manual connection */ | |
11569 | /* we have only a switch on HP-out PIN */ | |
11570 | sprintf(name, "%s Playback Switch", pfx); | |
f12ab1e0 TI |
11571 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
11572 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
11573 | if (err < 0) | |
f32610ed JS |
11574 | return err; |
11575 | } | |
11576 | return 0; | |
11577 | } | |
11578 | ||
11579 | /* parse the BIOS configuration and set up the alc_spec | |
11580 | * return 1 if successful, 0 if the proper config is not found, | |
11581 | * or a negative error code | |
11582 | * Based on ALC880 version - had to change it to override | |
11583 | * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */ | |
11584 | static int alc861vd_parse_auto_config(struct hda_codec *codec) | |
11585 | { | |
11586 | struct alc_spec *spec = codec->spec; | |
11587 | int err; | |
11588 | static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; | |
11589 | ||
f12ab1e0 TI |
11590 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
11591 | alc861vd_ignore); | |
11592 | if (err < 0) | |
f32610ed | 11593 | return err; |
f12ab1e0 | 11594 | if (!spec->autocfg.line_outs) |
f32610ed JS |
11595 | return 0; /* can't find valid BIOS pin config */ |
11596 | ||
f12ab1e0 TI |
11597 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
11598 | if (err < 0) | |
11599 | return err; | |
11600 | err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
11601 | if (err < 0) | |
11602 | return err; | |
11603 | err = alc861vd_auto_create_extra_out(spec, | |
11604 | spec->autocfg.speaker_pins[0], | |
11605 | "Speaker"); | |
11606 | if (err < 0) | |
11607 | return err; | |
11608 | err = alc861vd_auto_create_extra_out(spec, | |
11609 | spec->autocfg.hp_pins[0], | |
11610 | "Headphone"); | |
11611 | if (err < 0) | |
11612 | return err; | |
11613 | err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
11614 | if (err < 0) | |
f32610ed JS |
11615 | return err; |
11616 | ||
11617 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
11618 | ||
11619 | if (spec->autocfg.dig_out_pin) | |
11620 | spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID; | |
11621 | ||
11622 | if (spec->kctl_alloc) | |
11623 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
11624 | ||
11625 | spec->init_verbs[spec->num_init_verbs++] | |
11626 | = alc861vd_volume_init_verbs; | |
11627 | ||
11628 | spec->num_mux_defs = 1; | |
11629 | spec->input_mux = &spec->private_imux; | |
11630 | ||
776e184e TI |
11631 | err = alc_auto_add_mic_boost(codec); |
11632 | if (err < 0) | |
11633 | return err; | |
11634 | ||
f32610ed JS |
11635 | return 1; |
11636 | } | |
11637 | ||
11638 | /* additional initialization for auto-configuration model */ | |
11639 | static void alc861vd_auto_init(struct hda_codec *codec) | |
11640 | { | |
11641 | alc861vd_auto_init_multi_out(codec); | |
11642 | alc861vd_auto_init_hp_out(codec); | |
11643 | alc861vd_auto_init_analog_input(codec); | |
11644 | } | |
11645 | ||
11646 | static int patch_alc861vd(struct hda_codec *codec) | |
11647 | { | |
11648 | struct alc_spec *spec; | |
11649 | int err, board_config; | |
11650 | ||
11651 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
11652 | if (spec == NULL) | |
11653 | return -ENOMEM; | |
11654 | ||
11655 | codec->spec = spec; | |
11656 | ||
11657 | board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST, | |
11658 | alc861vd_models, | |
11659 | alc861vd_cfg_tbl); | |
11660 | ||
11661 | if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) { | |
11662 | printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/" | |
11663 | "ALC861VD, trying auto-probe from BIOS...\n"); | |
11664 | board_config = ALC861VD_AUTO; | |
11665 | } | |
11666 | ||
11667 | if (board_config == ALC861VD_AUTO) { | |
11668 | /* automatic parse from the BIOS config */ | |
11669 | err = alc861vd_parse_auto_config(codec); | |
11670 | if (err < 0) { | |
11671 | alc_free(codec); | |
11672 | return err; | |
f12ab1e0 | 11673 | } else if (!err) { |
f32610ed JS |
11674 | printk(KERN_INFO |
11675 | "hda_codec: Cannot set up configuration " | |
11676 | "from BIOS. Using base mode...\n"); | |
11677 | board_config = ALC861VD_3ST; | |
11678 | } | |
11679 | } | |
11680 | ||
11681 | if (board_config != ALC861VD_AUTO) | |
11682 | setup_preset(spec, &alc861vd_presets[board_config]); | |
11683 | ||
11684 | spec->stream_name_analog = "ALC861VD Analog"; | |
11685 | spec->stream_analog_playback = &alc861vd_pcm_analog_playback; | |
11686 | spec->stream_analog_capture = &alc861vd_pcm_analog_capture; | |
11687 | ||
11688 | spec->stream_name_digital = "ALC861VD Digital"; | |
11689 | spec->stream_digital_playback = &alc861vd_pcm_digital_playback; | |
11690 | spec->stream_digital_capture = &alc861vd_pcm_digital_capture; | |
11691 | ||
11692 | spec->adc_nids = alc861vd_adc_nids; | |
11693 | spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids); | |
11694 | ||
11695 | spec->mixers[spec->num_mixers] = alc861vd_capture_mixer; | |
11696 | spec->num_mixers++; | |
11697 | ||
11698 | codec->patch_ops = alc_patch_ops; | |
11699 | ||
11700 | if (board_config == ALC861VD_AUTO) | |
11701 | spec->init_hook = alc861vd_auto_init; | |
cb53c626 TI |
11702 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
11703 | if (!spec->loopback.amplist) | |
11704 | spec->loopback.amplist = alc861vd_loopbacks; | |
11705 | #endif | |
f32610ed JS |
11706 | |
11707 | return 0; | |
11708 | } | |
11709 | ||
bc9f98a9 KY |
11710 | /* |
11711 | * ALC662 support | |
11712 | * | |
11713 | * ALC662 is almost identical with ALC880 but has cleaner and more flexible | |
11714 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
11715 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
11716 | * 6-channel independent captures. | |
11717 | * | |
11718 | * In addition, an independent DAC for the multi-playback (not used in this | |
11719 | * driver yet). | |
11720 | */ | |
11721 | #define ALC662_DIGOUT_NID 0x06 | |
11722 | #define ALC662_DIGIN_NID 0x0a | |
11723 | ||
11724 | static hda_nid_t alc662_dac_nids[4] = { | |
11725 | /* front, rear, clfe, rear_surr */ | |
11726 | 0x02, 0x03, 0x04 | |
11727 | }; | |
11728 | ||
11729 | static hda_nid_t alc662_adc_nids[1] = { | |
11730 | /* ADC1-2 */ | |
11731 | 0x09, | |
11732 | }; | |
11733 | /* input MUX */ | |
11734 | /* FIXME: should be a matrix-type input source selection */ | |
11735 | ||
11736 | static struct hda_input_mux alc662_capture_source = { | |
11737 | .num_items = 4, | |
11738 | .items = { | |
11739 | { "Mic", 0x0 }, | |
11740 | { "Front Mic", 0x1 }, | |
11741 | { "Line", 0x2 }, | |
11742 | { "CD", 0x4 }, | |
11743 | }, | |
11744 | }; | |
11745 | ||
11746 | static struct hda_input_mux alc662_lenovo_101e_capture_source = { | |
11747 | .num_items = 2, | |
11748 | .items = { | |
11749 | { "Mic", 0x1 }, | |
11750 | { "Line", 0x2 }, | |
11751 | }, | |
11752 | }; | |
291702f0 KY |
11753 | |
11754 | static struct hda_input_mux alc662_eeepc_capture_source = { | |
11755 | .num_items = 2, | |
11756 | .items = { | |
11757 | { "i-Mic", 0x1 }, | |
11758 | { "e-Mic", 0x0 }, | |
11759 | }, | |
11760 | }; | |
11761 | ||
bc9f98a9 KY |
11762 | #define alc662_mux_enum_info alc_mux_enum_info |
11763 | #define alc662_mux_enum_get alc_mux_enum_get | |
11764 | ||
11765 | static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol, | |
11766 | struct snd_ctl_elem_value *ucontrol) | |
11767 | { | |
11768 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
11769 | struct alc_spec *spec = codec->spec; | |
11770 | const struct hda_input_mux *imux = spec->input_mux; | |
11771 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
d1a991a6 | 11772 | static hda_nid_t capture_mixers[2] = { 0x23, 0x22 }; |
bc9f98a9 KY |
11773 | hda_nid_t nid = capture_mixers[adc_idx]; |
11774 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; | |
11775 | unsigned int i, idx; | |
11776 | ||
11777 | idx = ucontrol->value.enumerated.item[0]; | |
11778 | if (idx >= imux->num_items) | |
11779 | idx = imux->num_items - 1; | |
82beb8fd | 11780 | if (*cur_val == idx) |
bc9f98a9 KY |
11781 | return 0; |
11782 | for (i = 0; i < imux->num_items; i++) { | |
47fd830a TI |
11783 | unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE; |
11784 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, | |
11785 | imux->items[i].index, | |
11786 | HDA_AMP_MUTE, v); | |
bc9f98a9 KY |
11787 | } |
11788 | *cur_val = idx; | |
11789 | return 1; | |
11790 | } | |
11791 | /* | |
11792 | * 2ch mode | |
11793 | */ | |
11794 | static struct hda_channel_mode alc662_3ST_2ch_modes[1] = { | |
11795 | { 2, NULL } | |
11796 | }; | |
11797 | ||
11798 | /* | |
11799 | * 2ch mode | |
11800 | */ | |
11801 | static struct hda_verb alc662_3ST_ch2_init[] = { | |
11802 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
11803 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
11804 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
11805 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
11806 | { } /* end */ | |
11807 | }; | |
11808 | ||
11809 | /* | |
11810 | * 6ch mode | |
11811 | */ | |
11812 | static struct hda_verb alc662_3ST_ch6_init[] = { | |
11813 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
11814 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
11815 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
11816 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
11817 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
11818 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
11819 | { } /* end */ | |
11820 | }; | |
11821 | ||
11822 | static struct hda_channel_mode alc662_3ST_6ch_modes[2] = { | |
11823 | { 2, alc662_3ST_ch2_init }, | |
11824 | { 6, alc662_3ST_ch6_init }, | |
11825 | }; | |
11826 | ||
11827 | /* | |
11828 | * 2ch mode | |
11829 | */ | |
11830 | static struct hda_verb alc662_sixstack_ch6_init[] = { | |
11831 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
11832 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
11833 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
11834 | { } /* end */ | |
11835 | }; | |
11836 | ||
11837 | /* | |
11838 | * 6ch mode | |
11839 | */ | |
11840 | static struct hda_verb alc662_sixstack_ch8_init[] = { | |
11841 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
11842 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
11843 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
11844 | { } /* end */ | |
11845 | }; | |
11846 | ||
11847 | static struct hda_channel_mode alc662_5stack_modes[2] = { | |
11848 | { 2, alc662_sixstack_ch6_init }, | |
11849 | { 6, alc662_sixstack_ch8_init }, | |
11850 | }; | |
11851 | ||
11852 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 | |
11853 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
11854 | */ | |
11855 | ||
11856 | static struct snd_kcontrol_new alc662_base_mixer[] = { | |
11857 | /* output mixer control */ | |
11858 | HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT), | |
11859 | HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT), | |
11860 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT), | |
11861 | HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
11862 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), | |
11863 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), | |
11864 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT), | |
11865 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT), | |
11866 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
11867 | ||
11868 | /*Input mixer control */ | |
11869 | HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT), | |
11870 | HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT), | |
11871 | HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT), | |
11872 | HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT), | |
11873 | HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT), | |
11874 | HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT), | |
11875 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT), | |
11876 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT), | |
11877 | ||
11878 | /* Capture mixer control */ | |
11879 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
11880 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
11881 | { | |
11882 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11883 | .name = "Capture Source", | |
11884 | .count = 1, | |
11885 | .info = alc_mux_enum_info, | |
11886 | .get = alc_mux_enum_get, | |
11887 | .put = alc_mux_enum_put, | |
11888 | }, | |
11889 | { } /* end */ | |
11890 | }; | |
11891 | ||
11892 | static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = { | |
11893 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
11894 | HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT), | |
11895 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
11896 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
11897 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
11898 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
11899 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
11900 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
11901 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
11902 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
11903 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
11904 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
11905 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
11906 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
11907 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
11908 | { | |
11909 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11910 | /* .name = "Capture Source", */ | |
11911 | .name = "Input Source", | |
11912 | .count = 1, | |
11913 | .info = alc662_mux_enum_info, | |
11914 | .get = alc662_mux_enum_get, | |
11915 | .put = alc662_mux_enum_put, | |
11916 | }, | |
11917 | { } /* end */ | |
11918 | }; | |
11919 | ||
11920 | static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = { | |
11921 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
11922 | HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT), | |
11923 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
11924 | HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT), | |
11925 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), | |
11926 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), | |
11927 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT), | |
11928 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT), | |
11929 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
11930 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
11931 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
11932 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
11933 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
11934 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
11935 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
11936 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
11937 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
11938 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
11939 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
11940 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
11941 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
11942 | { | |
11943 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11944 | /* .name = "Capture Source", */ | |
11945 | .name = "Input Source", | |
11946 | .count = 1, | |
11947 | .info = alc662_mux_enum_info, | |
11948 | .get = alc662_mux_enum_get, | |
11949 | .put = alc662_mux_enum_put, | |
11950 | }, | |
11951 | { } /* end */ | |
11952 | }; | |
11953 | ||
11954 | static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = { | |
11955 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
11956 | HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT), | |
11957 | HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
11958 | HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT), | |
11959 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
11960 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
11961 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
11962 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
11963 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
11964 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
11965 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
11966 | { | |
11967 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11968 | /* .name = "Capture Source", */ | |
11969 | .name = "Input Source", | |
11970 | .count = 1, | |
11971 | .info = alc662_mux_enum_info, | |
11972 | .get = alc662_mux_enum_get, | |
11973 | .put = alc662_mux_enum_put, | |
11974 | }, | |
11975 | { } /* end */ | |
11976 | }; | |
11977 | ||
291702f0 KY |
11978 | static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = { |
11979 | HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
11980 | ||
11981 | HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
11982 | HDA_CODEC_MUTE("LineOut Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
11983 | ||
11984 | HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT), | |
11985 | HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
11986 | HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
11987 | ||
11988 | HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT), | |
11989 | HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
11990 | HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
11991 | { } /* end */ | |
11992 | }; | |
11993 | ||
bc9f98a9 KY |
11994 | static struct snd_kcontrol_new alc662_chmode_mixer[] = { |
11995 | { | |
11996 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11997 | .name = "Channel Mode", | |
11998 | .info = alc_ch_mode_info, | |
11999 | .get = alc_ch_mode_get, | |
12000 | .put = alc_ch_mode_put, | |
12001 | }, | |
12002 | { } /* end */ | |
12003 | }; | |
12004 | ||
12005 | static struct hda_verb alc662_init_verbs[] = { | |
12006 | /* ADC: mute amp left and right */ | |
12007 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
12008 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
12009 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
12010 | ||
cb53c626 TI |
12011 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
12012 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
12013 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
12014 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
12015 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
bc9f98a9 | 12016 | |
b60dd394 KY |
12017 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
12018 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12019 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12020 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12021 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12022 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
bc9f98a9 KY |
12023 | |
12024 | /* Front Pin: output 0 (0x0c) */ | |
12025 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
12026 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12027 | ||
12028 | /* Rear Pin: output 1 (0x0d) */ | |
12029 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
12030 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12031 | ||
12032 | /* CLFE Pin: output 2 (0x0e) */ | |
12033 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
12034 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12035 | ||
12036 | /* Mic (rear) pin: input vref at 80% */ | |
12037 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
12038 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12039 | /* Front Mic pin: input vref at 80% */ | |
12040 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
12041 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12042 | /* Line In pin: input */ | |
12043 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12044 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12045 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
12046 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
12047 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12048 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
12049 | /* CD pin widget for input */ | |
12050 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
12051 | ||
12052 | /* FIXME: use matrix-type input source selection */ | |
12053 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
12054 | /* Input mixer */ | |
12055 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12056 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12057 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
12058 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
291702f0 KY |
12059 | |
12060 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12061 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12062 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
12063 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
bc9f98a9 KY |
12064 | { } |
12065 | }; | |
12066 | ||
12067 | static struct hda_verb alc662_sue_init_verbs[] = { | |
12068 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT}, | |
12069 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT}, | |
291702f0 KY |
12070 | {} |
12071 | }; | |
12072 | ||
12073 | static struct hda_verb alc662_eeepc_sue_init_verbs[] = { | |
12074 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
12075 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
12076 | {} | |
bc9f98a9 KY |
12077 | }; |
12078 | ||
12079 | /* | |
12080 | * generic initialization of ADC, input mixers and output mixers | |
12081 | */ | |
12082 | static struct hda_verb alc662_auto_init_verbs[] = { | |
12083 | /* | |
12084 | * Unmute ADC and set the default input to mic-in | |
12085 | */ | |
12086 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
12087 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12088 | ||
12089 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | |
12090 | * mixer widget | |
12091 | * Note: PASD motherboards uses the Line In 2 as the input for front | |
12092 | * panel mic (mic 2) | |
12093 | */ | |
12094 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
12095 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
12096 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
12097 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
12098 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
12099 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
bc9f98a9 KY |
12100 | |
12101 | /* | |
12102 | * Set up output mixers (0x0c - 0x0f) | |
12103 | */ | |
12104 | /* set vol=0 to output mixers */ | |
12105 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
12106 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
12107 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
12108 | ||
12109 | /* set up input amps for analog loopback */ | |
12110 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
b60dd394 KY |
12111 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
12112 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12113 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12114 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12115 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12116 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
bc9f98a9 KY |
12117 | |
12118 | ||
12119 | /* FIXME: use matrix-type input source selection */ | |
12120 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
12121 | /* Input mixer */ | |
12122 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
d1a991a6 | 12123 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
bc9f98a9 KY |
12124 | { } |
12125 | }; | |
12126 | ||
12127 | /* capture mixer elements */ | |
12128 | static struct snd_kcontrol_new alc662_capture_mixer[] = { | |
12129 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
12130 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
12131 | { | |
12132 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
12133 | /* The multiple "Capture Source" controls confuse alsamixer | |
12134 | * So call somewhat different.. | |
12135 | * FIXME: the controls appear in the "playback" view! | |
12136 | */ | |
12137 | /* .name = "Capture Source", */ | |
12138 | .name = "Input Source", | |
12139 | .count = 1, | |
12140 | .info = alc882_mux_enum_info, | |
12141 | .get = alc882_mux_enum_get, | |
12142 | .put = alc882_mux_enum_put, | |
12143 | }, | |
12144 | { } /* end */ | |
12145 | }; | |
12146 | ||
12147 | static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec) | |
12148 | { | |
12149 | unsigned int present; | |
f12ab1e0 | 12150 | unsigned char bits; |
bc9f98a9 KY |
12151 | |
12152 | present = snd_hda_codec_read(codec, 0x14, 0, | |
12153 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
12154 | bits = present ? HDA_AMP_MUTE : 0; |
12155 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
12156 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
12157 | } |
12158 | ||
12159 | static void alc662_lenovo_101e_all_automute(struct hda_codec *codec) | |
12160 | { | |
12161 | unsigned int present; | |
f12ab1e0 | 12162 | unsigned char bits; |
bc9f98a9 KY |
12163 | |
12164 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
12165 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
12166 | bits = present ? HDA_AMP_MUTE : 0; |
12167 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
12168 | HDA_AMP_MUTE, bits); | |
12169 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
12170 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
12171 | } |
12172 | ||
12173 | static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec, | |
12174 | unsigned int res) | |
12175 | { | |
12176 | if ((res >> 26) == ALC880_HP_EVENT) | |
12177 | alc662_lenovo_101e_all_automute(codec); | |
12178 | if ((res >> 26) == ALC880_FRONT_EVENT) | |
12179 | alc662_lenovo_101e_ispeaker_automute(codec); | |
12180 | } | |
12181 | ||
291702f0 KY |
12182 | static void alc662_eeepc_mic_automute(struct hda_codec *codec) |
12183 | { | |
12184 | unsigned int present; | |
12185 | ||
12186 | present = snd_hda_codec_read(codec, 0x18, 0, | |
12187 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
12188 | snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
12189 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | |
12190 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
12191 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | |
12192 | snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
12193 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); | |
12194 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
12195 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); | |
12196 | } | |
12197 | ||
12198 | /* unsolicited event for HP jack sensing */ | |
12199 | static void alc662_eeepc_unsol_event(struct hda_codec *codec, | |
12200 | unsigned int res) | |
12201 | { | |
12202 | if ((res >> 26) == ALC880_HP_EVENT) | |
12203 | alc262_hippo1_automute( codec ); | |
12204 | ||
12205 | if ((res >> 26) == ALC880_MIC_EVENT) | |
12206 | alc662_eeepc_mic_automute(codec); | |
12207 | } | |
12208 | ||
12209 | static void alc662_eeepc_inithook(struct hda_codec *codec) | |
12210 | { | |
12211 | alc262_hippo1_automute( codec ); | |
12212 | alc662_eeepc_mic_automute(codec); | |
12213 | } | |
12214 | ||
cb53c626 TI |
12215 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
12216 | #define alc662_loopbacks alc880_loopbacks | |
12217 | #endif | |
12218 | ||
bc9f98a9 KY |
12219 | |
12220 | /* pcm configuration: identiacal with ALC880 */ | |
12221 | #define alc662_pcm_analog_playback alc880_pcm_analog_playback | |
12222 | #define alc662_pcm_analog_capture alc880_pcm_analog_capture | |
12223 | #define alc662_pcm_digital_playback alc880_pcm_digital_playback | |
12224 | #define alc662_pcm_digital_capture alc880_pcm_digital_capture | |
12225 | ||
12226 | /* | |
12227 | * configuration and preset | |
12228 | */ | |
12229 | static const char *alc662_models[ALC662_MODEL_LAST] = { | |
12230 | [ALC662_3ST_2ch_DIG] = "3stack-dig", | |
12231 | [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig", | |
12232 | [ALC662_3ST_6ch] = "3stack-6ch", | |
12233 | [ALC662_5ST_DIG] = "6stack-dig", | |
12234 | [ALC662_LENOVO_101E] = "lenovo-101e", | |
b995d76d | 12235 | [ALC662_ASUS_EEEPC_P701] = "eeepc-p701", |
bc9f98a9 KY |
12236 | [ALC662_AUTO] = "auto", |
12237 | }; | |
12238 | ||
12239 | static struct snd_pci_quirk alc662_cfg_tbl[] = { | |
12240 | SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E), | |
291702f0 | 12241 | SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701), |
bc9f98a9 KY |
12242 | {} |
12243 | }; | |
12244 | ||
12245 | static struct alc_config_preset alc662_presets[] = { | |
12246 | [ALC662_3ST_2ch_DIG] = { | |
291702f0 | 12247 | .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer }, |
bc9f98a9 KY |
12248 | .init_verbs = { alc662_init_verbs }, |
12249 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
12250 | .dac_nids = alc662_dac_nids, | |
12251 | .dig_out_nid = ALC662_DIGOUT_NID, | |
12252 | .num_adc_nids = ARRAY_SIZE(alc662_adc_nids), | |
12253 | .adc_nids = alc662_adc_nids, | |
12254 | .dig_in_nid = ALC662_DIGIN_NID, | |
12255 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
12256 | .channel_mode = alc662_3ST_2ch_modes, | |
12257 | .input_mux = &alc662_capture_source, | |
12258 | }, | |
12259 | [ALC662_3ST_6ch_DIG] = { | |
291702f0 KY |
12260 | .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer, |
12261 | alc662_capture_mixer }, | |
bc9f98a9 KY |
12262 | .init_verbs = { alc662_init_verbs }, |
12263 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
12264 | .dac_nids = alc662_dac_nids, | |
12265 | .dig_out_nid = ALC662_DIGOUT_NID, | |
12266 | .num_adc_nids = ARRAY_SIZE(alc662_adc_nids), | |
12267 | .adc_nids = alc662_adc_nids, | |
12268 | .dig_in_nid = ALC662_DIGIN_NID, | |
12269 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), | |
12270 | .channel_mode = alc662_3ST_6ch_modes, | |
12271 | .need_dac_fix = 1, | |
12272 | .input_mux = &alc662_capture_source, | |
f12ab1e0 | 12273 | }, |
bc9f98a9 | 12274 | [ALC662_3ST_6ch] = { |
291702f0 KY |
12275 | .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer, |
12276 | alc662_capture_mixer }, | |
bc9f98a9 KY |
12277 | .init_verbs = { alc662_init_verbs }, |
12278 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
12279 | .dac_nids = alc662_dac_nids, | |
12280 | .num_adc_nids = ARRAY_SIZE(alc662_adc_nids), | |
12281 | .adc_nids = alc662_adc_nids, | |
12282 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), | |
12283 | .channel_mode = alc662_3ST_6ch_modes, | |
12284 | .need_dac_fix = 1, | |
12285 | .input_mux = &alc662_capture_source, | |
f12ab1e0 | 12286 | }, |
bc9f98a9 | 12287 | [ALC662_5ST_DIG] = { |
291702f0 KY |
12288 | .mixers = { alc662_base_mixer, alc662_chmode_mixer, |
12289 | alc662_capture_mixer }, | |
bc9f98a9 KY |
12290 | .init_verbs = { alc662_init_verbs }, |
12291 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
12292 | .dac_nids = alc662_dac_nids, | |
12293 | .dig_out_nid = ALC662_DIGOUT_NID, | |
12294 | .num_adc_nids = ARRAY_SIZE(alc662_adc_nids), | |
12295 | .adc_nids = alc662_adc_nids, | |
12296 | .dig_in_nid = ALC662_DIGIN_NID, | |
12297 | .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes), | |
12298 | .channel_mode = alc662_5stack_modes, | |
12299 | .input_mux = &alc662_capture_source, | |
12300 | }, | |
12301 | [ALC662_LENOVO_101E] = { | |
291702f0 | 12302 | .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer }, |
bc9f98a9 KY |
12303 | .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs }, |
12304 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
12305 | .dac_nids = alc662_dac_nids, | |
12306 | .num_adc_nids = ARRAY_SIZE(alc662_adc_nids), | |
12307 | .adc_nids = alc662_adc_nids, | |
12308 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
12309 | .channel_mode = alc662_3ST_2ch_modes, | |
12310 | .input_mux = &alc662_lenovo_101e_capture_source, | |
12311 | .unsol_event = alc662_lenovo_101e_unsol_event, | |
12312 | .init_hook = alc662_lenovo_101e_all_automute, | |
12313 | }, | |
291702f0 KY |
12314 | [ALC662_ASUS_EEEPC_P701] = { |
12315 | .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer }, | |
12316 | .init_verbs = { alc662_init_verbs, | |
12317 | alc662_eeepc_sue_init_verbs }, | |
12318 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
12319 | .dac_nids = alc662_dac_nids, | |
12320 | .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids), | |
12321 | .adc_nids = alc662_adc_nids, | |
12322 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
12323 | .channel_mode = alc662_3ST_2ch_modes, | |
12324 | .input_mux = &alc662_eeepc_capture_source, | |
12325 | .unsol_event = alc662_eeepc_unsol_event, | |
12326 | .init_hook = alc662_eeepc_inithook, | |
12327 | }, | |
bc9f98a9 KY |
12328 | |
12329 | }; | |
12330 | ||
12331 | ||
12332 | /* | |
12333 | * BIOS auto configuration | |
12334 | */ | |
12335 | ||
12336 | /* add playback controls from the parsed DAC table */ | |
12337 | static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec, | |
12338 | const struct auto_pin_cfg *cfg) | |
12339 | { | |
12340 | char name[32]; | |
12341 | static const char *chname[4] = { | |
12342 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
12343 | }; | |
12344 | hda_nid_t nid; | |
12345 | int i, err; | |
12346 | ||
12347 | for (i = 0; i < cfg->line_outs; i++) { | |
12348 | if (!spec->multiout.dac_nids[i]) | |
12349 | continue; | |
b60dd394 | 12350 | nid = alc880_idx_to_dac(i); |
bc9f98a9 KY |
12351 | if (i == 2) { |
12352 | /* Center/LFE */ | |
12353 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
12354 | "Center Playback Volume", | |
f12ab1e0 TI |
12355 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, |
12356 | HDA_OUTPUT)); | |
bc9f98a9 KY |
12357 | if (err < 0) |
12358 | return err; | |
12359 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
12360 | "LFE Playback Volume", | |
f12ab1e0 TI |
12361 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, |
12362 | HDA_OUTPUT)); | |
bc9f98a9 KY |
12363 | if (err < 0) |
12364 | return err; | |
12365 | err = add_control(spec, ALC_CTL_BIND_MUTE, | |
12366 | "Center Playback Switch", | |
f12ab1e0 TI |
12367 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, |
12368 | HDA_INPUT)); | |
bc9f98a9 KY |
12369 | if (err < 0) |
12370 | return err; | |
12371 | err = add_control(spec, ALC_CTL_BIND_MUTE, | |
12372 | "LFE Playback Switch", | |
f12ab1e0 TI |
12373 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, |
12374 | HDA_INPUT)); | |
bc9f98a9 KY |
12375 | if (err < 0) |
12376 | return err; | |
12377 | } else { | |
12378 | sprintf(name, "%s Playback Volume", chname[i]); | |
12379 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
f12ab1e0 TI |
12380 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, |
12381 | HDA_OUTPUT)); | |
bc9f98a9 KY |
12382 | if (err < 0) |
12383 | return err; | |
12384 | sprintf(name, "%s Playback Switch", chname[i]); | |
12385 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | |
f12ab1e0 TI |
12386 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, |
12387 | HDA_INPUT)); | |
bc9f98a9 KY |
12388 | if (err < 0) |
12389 | return err; | |
12390 | } | |
12391 | } | |
12392 | return 0; | |
12393 | } | |
12394 | ||
12395 | /* add playback controls for speaker and HP outputs */ | |
12396 | static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, | |
12397 | const char *pfx) | |
12398 | { | |
12399 | hda_nid_t nid; | |
12400 | int err; | |
12401 | char name[32]; | |
12402 | ||
12403 | if (!pin) | |
12404 | return 0; | |
12405 | ||
12406 | if (alc880_is_fixed_pin(pin)) { | |
12407 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
12408 | /* printk("DAC nid=%x\n",nid); */ | |
12409 | /* specify the DAC as the extra output */ | |
12410 | if (!spec->multiout.hp_nid) | |
12411 | spec->multiout.hp_nid = nid; | |
12412 | else | |
12413 | spec->multiout.extra_out_nid[0] = nid; | |
12414 | /* control HP volume/switch on the output mixer amp */ | |
12415 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
12416 | sprintf(name, "%s Playback Volume", pfx); | |
12417 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
12418 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
12419 | if (err < 0) | |
12420 | return err; | |
12421 | sprintf(name, "%s Playback Switch", pfx); | |
12422 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | |
12423 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); | |
12424 | if (err < 0) | |
12425 | return err; | |
12426 | } else if (alc880_is_multi_pin(pin)) { | |
12427 | /* set manual connection */ | |
12428 | /* we have only a switch on HP-out PIN */ | |
12429 | sprintf(name, "%s Playback Switch", pfx); | |
12430 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | |
12431 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
12432 | if (err < 0) | |
12433 | return err; | |
12434 | } | |
12435 | return 0; | |
12436 | } | |
12437 | ||
12438 | /* create playback/capture controls for input pins */ | |
12439 | static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec, | |
12440 | const struct auto_pin_cfg *cfg) | |
12441 | { | |
12442 | struct hda_input_mux *imux = &spec->private_imux; | |
12443 | int i, err, idx; | |
12444 | ||
12445 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
12446 | if (alc880_is_input_pin(cfg->input_pins[i])) { | |
12447 | idx = alc880_input_pin_idx(cfg->input_pins[i]); | |
12448 | err = new_analog_input(spec, cfg->input_pins[i], | |
12449 | auto_pin_cfg_labels[i], | |
12450 | idx, 0x0b); | |
12451 | if (err < 0) | |
12452 | return err; | |
12453 | imux->items[imux->num_items].label = | |
12454 | auto_pin_cfg_labels[i]; | |
12455 | imux->items[imux->num_items].index = | |
12456 | alc880_input_pin_idx(cfg->input_pins[i]); | |
12457 | imux->num_items++; | |
12458 | } | |
12459 | } | |
12460 | return 0; | |
12461 | } | |
12462 | ||
12463 | static void alc662_auto_set_output_and_unmute(struct hda_codec *codec, | |
12464 | hda_nid_t nid, int pin_type, | |
12465 | int dac_idx) | |
12466 | { | |
12467 | /* set as output */ | |
12468 | snd_hda_codec_write(codec, nid, 0, | |
12469 | AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); | |
12470 | snd_hda_codec_write(codec, nid, 0, | |
12471 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); | |
12472 | /* need the manual connection? */ | |
12473 | if (alc880_is_multi_pin(nid)) { | |
12474 | struct alc_spec *spec = codec->spec; | |
12475 | int idx = alc880_multi_pin_idx(nid); | |
12476 | snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, | |
12477 | AC_VERB_SET_CONNECT_SEL, | |
12478 | alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); | |
12479 | } | |
12480 | } | |
12481 | ||
12482 | static void alc662_auto_init_multi_out(struct hda_codec *codec) | |
12483 | { | |
12484 | struct alc_spec *spec = codec->spec; | |
12485 | int i; | |
12486 | ||
12487 | for (i = 0; i <= HDA_SIDE; i++) { | |
12488 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 12489 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
bc9f98a9 | 12490 | if (nid) |
baba8ee9 | 12491 | alc662_auto_set_output_and_unmute(codec, nid, pin_type, |
bc9f98a9 KY |
12492 | i); |
12493 | } | |
12494 | } | |
12495 | ||
12496 | static void alc662_auto_init_hp_out(struct hda_codec *codec) | |
12497 | { | |
12498 | struct alc_spec *spec = codec->spec; | |
12499 | hda_nid_t pin; | |
12500 | ||
12501 | pin = spec->autocfg.hp_pins[0]; | |
12502 | if (pin) /* connect to front */ | |
12503 | /* use dac 0 */ | |
12504 | alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
12505 | } | |
12506 | ||
12507 | #define alc662_is_input_pin(nid) alc880_is_input_pin(nid) | |
12508 | #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID | |
12509 | ||
12510 | static void alc662_auto_init_analog_input(struct hda_codec *codec) | |
12511 | { | |
12512 | struct alc_spec *spec = codec->spec; | |
12513 | int i; | |
12514 | ||
12515 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
12516 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
12517 | if (alc662_is_input_pin(nid)) { | |
12518 | snd_hda_codec_write(codec, nid, 0, | |
12519 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
12520 | (i <= AUTO_PIN_FRONT_MIC ? | |
12521 | PIN_VREF80 : PIN_IN)); | |
12522 | if (nid != ALC662_PIN_CD_NID) | |
12523 | snd_hda_codec_write(codec, nid, 0, | |
12524 | AC_VERB_SET_AMP_GAIN_MUTE, | |
12525 | AMP_OUT_MUTE); | |
12526 | } | |
12527 | } | |
12528 | } | |
12529 | ||
12530 | static int alc662_parse_auto_config(struct hda_codec *codec) | |
12531 | { | |
12532 | struct alc_spec *spec = codec->spec; | |
12533 | int err; | |
12534 | static hda_nid_t alc662_ignore[] = { 0x1d, 0 }; | |
12535 | ||
12536 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | |
12537 | alc662_ignore); | |
12538 | if (err < 0) | |
12539 | return err; | |
12540 | if (!spec->autocfg.line_outs) | |
12541 | return 0; /* can't find valid BIOS pin config */ | |
12542 | ||
f12ab1e0 TI |
12543 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
12544 | if (err < 0) | |
12545 | return err; | |
12546 | err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
12547 | if (err < 0) | |
12548 | return err; | |
12549 | err = alc662_auto_create_extra_out(spec, | |
12550 | spec->autocfg.speaker_pins[0], | |
12551 | "Speaker"); | |
12552 | if (err < 0) | |
12553 | return err; | |
12554 | err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], | |
12555 | "Headphone"); | |
12556 | if (err < 0) | |
12557 | return err; | |
12558 | err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
12559 | if (err < 0) | |
bc9f98a9 KY |
12560 | return err; |
12561 | ||
12562 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
12563 | ||
12564 | if (spec->autocfg.dig_out_pin) | |
12565 | spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; | |
12566 | ||
12567 | if (spec->kctl_alloc) | |
12568 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
12569 | ||
12570 | spec->num_mux_defs = 1; | |
12571 | spec->input_mux = &spec->private_imux; | |
12572 | ||
8c87286f | 12573 | spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs; |
bc9f98a9 KY |
12574 | spec->mixers[spec->num_mixers] = alc662_capture_mixer; |
12575 | spec->num_mixers++; | |
8c87286f | 12576 | return 1; |
bc9f98a9 KY |
12577 | } |
12578 | ||
12579 | /* additional initialization for auto-configuration model */ | |
12580 | static void alc662_auto_init(struct hda_codec *codec) | |
12581 | { | |
12582 | alc662_auto_init_multi_out(codec); | |
12583 | alc662_auto_init_hp_out(codec); | |
12584 | alc662_auto_init_analog_input(codec); | |
12585 | } | |
12586 | ||
12587 | static int patch_alc662(struct hda_codec *codec) | |
12588 | { | |
12589 | struct alc_spec *spec; | |
12590 | int err, board_config; | |
12591 | ||
12592 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
12593 | if (!spec) | |
12594 | return -ENOMEM; | |
12595 | ||
12596 | codec->spec = spec; | |
12597 | ||
12598 | board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST, | |
12599 | alc662_models, | |
12600 | alc662_cfg_tbl); | |
12601 | if (board_config < 0) { | |
12602 | printk(KERN_INFO "hda_codec: Unknown model for ALC662, " | |
12603 | "trying auto-probe from BIOS...\n"); | |
12604 | board_config = ALC662_AUTO; | |
12605 | } | |
12606 | ||
12607 | if (board_config == ALC662_AUTO) { | |
12608 | /* automatic parse from the BIOS config */ | |
12609 | err = alc662_parse_auto_config(codec); | |
12610 | if (err < 0) { | |
12611 | alc_free(codec); | |
12612 | return err; | |
8c87286f | 12613 | } else if (!err) { |
bc9f98a9 KY |
12614 | printk(KERN_INFO |
12615 | "hda_codec: Cannot set up configuration " | |
12616 | "from BIOS. Using base mode...\n"); | |
12617 | board_config = ALC662_3ST_2ch_DIG; | |
12618 | } | |
12619 | } | |
12620 | ||
12621 | if (board_config != ALC662_AUTO) | |
12622 | setup_preset(spec, &alc662_presets[board_config]); | |
12623 | ||
12624 | spec->stream_name_analog = "ALC662 Analog"; | |
12625 | spec->stream_analog_playback = &alc662_pcm_analog_playback; | |
12626 | spec->stream_analog_capture = &alc662_pcm_analog_capture; | |
12627 | ||
12628 | spec->stream_name_digital = "ALC662 Digital"; | |
12629 | spec->stream_digital_playback = &alc662_pcm_digital_playback; | |
12630 | spec->stream_digital_capture = &alc662_pcm_digital_capture; | |
12631 | ||
12632 | if (!spec->adc_nids && spec->input_mux) { | |
12633 | spec->adc_nids = alc662_adc_nids; | |
12634 | spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids); | |
12635 | } | |
12636 | ||
12637 | codec->patch_ops = alc_patch_ops; | |
12638 | if (board_config == ALC662_AUTO) | |
12639 | spec->init_hook = alc662_auto_init; | |
cb53c626 TI |
12640 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
12641 | if (!spec->loopback.amplist) | |
12642 | spec->loopback.amplist = alc662_loopbacks; | |
12643 | #endif | |
bc9f98a9 KY |
12644 | |
12645 | return 0; | |
12646 | } | |
12647 | ||
1da177e4 LT |
12648 | /* |
12649 | * patch entries | |
12650 | */ | |
12651 | struct hda_codec_preset snd_hda_preset_realtek[] = { | |
12652 | { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, | |
df694daa | 12653 | { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, |
a361d84b | 12654 | { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, |
f32610ed | 12655 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", |
bc9f98a9 | 12656 | .patch = patch_alc861 }, |
f32610ed JS |
12657 | { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, |
12658 | { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, | |
12659 | { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, | |
bc9f98a9 KY |
12660 | { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", |
12661 | .patch = patch_alc883 }, | |
12662 | { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", | |
12663 | .patch = patch_alc662 }, | |
f32610ed | 12664 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
1da177e4 | 12665 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, |
9c7f852e | 12666 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 }, |
df694daa | 12667 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, |
9c7f852e | 12668 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 }, |
1da177e4 LT |
12669 | {} /* terminator */ |
12670 | }; |