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 | ||
35 | ||
36 | /* ALC880 board config type */ | |
37 | enum { | |
1da177e4 LT |
38 | ALC880_3ST, |
39 | ALC880_3ST_DIG, | |
40 | ALC880_5ST, | |
41 | ALC880_5ST_DIG, | |
42 | ALC880_W810, | |
dfc0ff62 | 43 | ALC880_Z71V, |
b6482d48 | 44 | ALC880_6ST, |
16ded525 TI |
45 | ALC880_6ST_DIG, |
46 | ALC880_F1734, | |
47 | ALC880_ASUS, | |
48 | ALC880_ASUS_DIG, | |
49 | ALC880_ASUS_W1V, | |
df694daa | 50 | ALC880_ASUS_DIG2, |
16ded525 | 51 | ALC880_UNIWILL_DIG, |
df694daa KY |
52 | ALC880_CLEVO, |
53 | ALC880_TCL_S700, | |
ae6b813a | 54 | ALC880_LG, |
d681518a | 55 | ALC880_LG_LW, |
e9edcee0 TI |
56 | #ifdef CONFIG_SND_DEBUG |
57 | ALC880_TEST, | |
58 | #endif | |
df694daa | 59 | ALC880_AUTO, |
16ded525 TI |
60 | ALC880_MODEL_LAST /* last tag */ |
61 | }; | |
62 | ||
63 | /* ALC260 models */ | |
64 | enum { | |
65 | ALC260_BASIC, | |
66 | ALC260_HP, | |
df694daa KY |
67 | ALC260_HP_3013, |
68 | ALC260_FUJITSU_S702X, | |
0bfc90e9 | 69 | ALC260_ACER, |
7cf51e48 JW |
70 | #ifdef CONFIG_SND_DEBUG |
71 | ALC260_TEST, | |
72 | #endif | |
df694daa | 73 | ALC260_AUTO, |
16ded525 | 74 | ALC260_MODEL_LAST /* last tag */ |
1da177e4 LT |
75 | }; |
76 | ||
df694daa KY |
77 | /* ALC262 models */ |
78 | enum { | |
79 | ALC262_BASIC, | |
834be88d | 80 | ALC262_FUJITSU, |
df694daa KY |
81 | ALC262_AUTO, |
82 | ALC262_MODEL_LAST /* last tag */ | |
83 | }; | |
84 | ||
85 | /* ALC861 models */ | |
86 | enum { | |
87 | ALC861_3ST, | |
88 | ALC861_3ST_DIG, | |
89 | ALC861_6ST_DIG, | |
90 | ALC861_AUTO, | |
91 | ALC861_MODEL_LAST, | |
92 | }; | |
93 | ||
94 | /* ALC882 models */ | |
95 | enum { | |
96 | ALC882_3ST_DIG, | |
97 | ALC882_6ST_DIG, | |
98 | ALC882_AUTO, | |
99 | ALC882_MODEL_LAST, | |
100 | }; | |
101 | ||
102 | /* for GPIO Poll */ | |
103 | #define GPIO_MASK 0x03 | |
104 | ||
1da177e4 LT |
105 | struct alc_spec { |
106 | /* codec parameterization */ | |
df694daa | 107 | struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ |
1da177e4 LT |
108 | unsigned int num_mixers; |
109 | ||
df694daa | 110 | const struct hda_verb *init_verbs[5]; /* initialization verbs |
e9edcee0 TI |
111 | * don't forget NULL termination! |
112 | */ | |
113 | unsigned int num_init_verbs; | |
1da177e4 | 114 | |
16ded525 | 115 | char *stream_name_analog; /* analog PCM stream */ |
1da177e4 LT |
116 | struct hda_pcm_stream *stream_analog_playback; |
117 | struct hda_pcm_stream *stream_analog_capture; | |
118 | ||
16ded525 | 119 | char *stream_name_digital; /* digital PCM stream */ |
1da177e4 LT |
120 | struct hda_pcm_stream *stream_digital_playback; |
121 | struct hda_pcm_stream *stream_digital_capture; | |
122 | ||
123 | /* playback */ | |
16ded525 TI |
124 | struct hda_multi_out multiout; /* playback set-up |
125 | * max_channels, dacs must be set | |
126 | * dig_out_nid and hp_nid are optional | |
127 | */ | |
1da177e4 LT |
128 | |
129 | /* capture */ | |
130 | unsigned int num_adc_nids; | |
131 | hda_nid_t *adc_nids; | |
16ded525 | 132 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
1da177e4 LT |
133 | |
134 | /* capture source */ | |
135 | const struct hda_input_mux *input_mux; | |
136 | unsigned int cur_mux[3]; | |
137 | ||
138 | /* channel model */ | |
d2a6d7dc | 139 | const struct hda_channel_mode *channel_mode; |
1da177e4 LT |
140 | int num_channel_mode; |
141 | ||
142 | /* PCM information */ | |
4c5186ed | 143 | struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ |
41e41f1f | 144 | |
e9edcee0 TI |
145 | /* dynamic controls, init_verbs and input_mux */ |
146 | struct auto_pin_cfg autocfg; | |
147 | unsigned int num_kctl_alloc, num_kctl_used; | |
c8b6bf9b | 148 | struct snd_kcontrol_new *kctl_alloc; |
e9edcee0 | 149 | struct hda_input_mux private_imux; |
df694daa | 150 | hda_nid_t private_dac_nids[5]; |
834be88d | 151 | |
ae6b813a TI |
152 | /* hooks */ |
153 | void (*init_hook)(struct hda_codec *codec); | |
154 | void (*unsol_event)(struct hda_codec *codec, unsigned int res); | |
155 | ||
834be88d TI |
156 | /* for pin sensing */ |
157 | unsigned int sense_updated: 1; | |
158 | unsigned int jack_present: 1; | |
df694daa KY |
159 | }; |
160 | ||
161 | /* | |
162 | * configuration template - to be copied to the spec instance | |
163 | */ | |
164 | struct alc_config_preset { | |
165 | struct snd_kcontrol_new *mixers[5]; /* should be identical size with spec */ | |
166 | const struct hda_verb *init_verbs[5]; | |
167 | unsigned int num_dacs; | |
168 | hda_nid_t *dac_nids; | |
169 | hda_nid_t dig_out_nid; /* optional */ | |
170 | hda_nid_t hp_nid; /* optional */ | |
171 | unsigned int num_adc_nids; | |
172 | hda_nid_t *adc_nids; | |
173 | hda_nid_t dig_in_nid; | |
174 | unsigned int num_channel_mode; | |
175 | const struct hda_channel_mode *channel_mode; | |
176 | const struct hda_input_mux *input_mux; | |
ae6b813a TI |
177 | void (*unsol_event)(struct hda_codec *, unsigned int); |
178 | void (*init_hook)(struct hda_codec *); | |
1da177e4 LT |
179 | }; |
180 | ||
1da177e4 LT |
181 | |
182 | /* | |
183 | * input MUX handling | |
184 | */ | |
c8b6bf9b | 185 | static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
1da177e4 LT |
186 | { |
187 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
188 | struct alc_spec *spec = codec->spec; | |
189 | return snd_hda_input_mux_info(spec->input_mux, uinfo); | |
190 | } | |
191 | ||
c8b6bf9b | 192 | static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1da177e4 LT |
193 | { |
194 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
195 | struct alc_spec *spec = codec->spec; | |
196 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
197 | ||
198 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; | |
199 | return 0; | |
200 | } | |
201 | ||
c8b6bf9b | 202 | static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1da177e4 LT |
203 | { |
204 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
205 | struct alc_spec *spec = codec->spec; | |
206 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
207 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, | |
208 | spec->adc_nids[adc_idx], &spec->cur_mux[adc_idx]); | |
209 | } | |
210 | ||
e9edcee0 | 211 | |
1da177e4 LT |
212 | /* |
213 | * channel mode setting | |
214 | */ | |
df694daa | 215 | static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
1da177e4 LT |
216 | { |
217 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
218 | struct alc_spec *spec = codec->spec; | |
d2a6d7dc TI |
219 | return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, |
220 | spec->num_channel_mode); | |
1da177e4 LT |
221 | } |
222 | ||
df694daa | 223 | static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1da177e4 LT |
224 | { |
225 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
226 | struct alc_spec *spec = codec->spec; | |
d2a6d7dc TI |
227 | return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, |
228 | spec->num_channel_mode, spec->multiout.max_channels); | |
1da177e4 LT |
229 | } |
230 | ||
df694daa | 231 | static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1da177e4 LT |
232 | { |
233 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
234 | struct alc_spec *spec = codec->spec; | |
d2a6d7dc TI |
235 | return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, |
236 | spec->num_channel_mode, &spec->multiout.max_channels); | |
1da177e4 LT |
237 | } |
238 | ||
a9430dd8 | 239 | /* |
4c5186ed JW |
240 | * Control the mode of pin widget settings via the mixer. "pc" is used |
241 | * instead of "%" to avoid consequences of accidently treating the % as | |
242 | * being part of a format specifier. Maximum allowed length of a value is | |
243 | * 63 characters plus NULL terminator. | |
7cf51e48 JW |
244 | * |
245 | * Note: some retasking pin complexes seem to ignore requests for input | |
246 | * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these | |
247 | * are requested. Therefore order this list so that this behaviour will not | |
248 | * cause problems when mixer clients move through the enum sequentially. | |
249 | * NIDs 0x0f and 0x10 have been observed to have this behaviour. | |
4c5186ed JW |
250 | */ |
251 | static char *alc_pin_mode_names[] = { | |
7cf51e48 JW |
252 | "Mic 50pc bias", "Mic 80pc bias", |
253 | "Line in", "Line out", "Headphone out", | |
4c5186ed JW |
254 | }; |
255 | static unsigned char alc_pin_mode_values[] = { | |
7cf51e48 | 256 | PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP, |
4c5186ed JW |
257 | }; |
258 | /* The control can present all 5 options, or it can limit the options based | |
259 | * in the pin being assumed to be exclusively an input or an output pin. | |
a9430dd8 | 260 | */ |
4c5186ed JW |
261 | #define ALC_PIN_DIR_IN 0x00 |
262 | #define ALC_PIN_DIR_OUT 0x01 | |
263 | #define ALC_PIN_DIR_INOUT 0x02 | |
264 | ||
265 | /* Info about the pin modes supported by the three different pin directions. | |
266 | * For each direction the minimum and maximum values are given. | |
267 | */ | |
268 | static signed char alc_pin_mode_dir_info[3][2] = { | |
269 | { 0, 2 }, /* ALC_PIN_DIR_IN */ | |
270 | { 3, 4 }, /* ALC_PIN_DIR_OUT */ | |
271 | { 0, 4 }, /* ALC_PIN_DIR_INOUT */ | |
272 | }; | |
273 | #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0]) | |
274 | #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1]) | |
275 | #define alc_pin_mode_n_items(_dir) \ | |
276 | (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1) | |
277 | ||
278 | static int alc_pin_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) | |
a9430dd8 | 279 | { |
4c5186ed JW |
280 | unsigned int item_num = uinfo->value.enumerated.item; |
281 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; | |
282 | ||
283 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
a9430dd8 | 284 | uinfo->count = 1; |
4c5186ed JW |
285 | uinfo->value.enumerated.items = alc_pin_mode_n_items(dir); |
286 | ||
287 | if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir)) | |
288 | item_num = alc_pin_mode_min(dir); | |
289 | strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]); | |
a9430dd8 JW |
290 | return 0; |
291 | } | |
292 | ||
4c5186ed | 293 | static int alc_pin_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
a9430dd8 | 294 | { |
4c5186ed | 295 | unsigned int i; |
a9430dd8 JW |
296 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
297 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
4c5186ed | 298 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
a9430dd8 | 299 | long *valp = ucontrol->value.integer.value; |
4c5186ed | 300 | unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00); |
a9430dd8 | 301 | |
4c5186ed JW |
302 | /* Find enumerated value for current pinctl setting */ |
303 | i = alc_pin_mode_min(dir); | |
304 | while (alc_pin_mode_values[i]!=pinctl && i<=alc_pin_mode_max(dir)) | |
305 | i++; | |
306 | *valp = i<=alc_pin_mode_max(dir)?i:alc_pin_mode_min(dir); | |
a9430dd8 JW |
307 | return 0; |
308 | } | |
309 | ||
4c5186ed | 310 | static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
a9430dd8 | 311 | { |
4c5186ed | 312 | signed int change; |
a9430dd8 JW |
313 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
314 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
4c5186ed JW |
315 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
316 | long val = *ucontrol->value.integer.value; | |
a9430dd8 | 317 | unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00); |
a9430dd8 | 318 | |
4c5186ed JW |
319 | if (val<alc_pin_mode_min(dir) || val>alc_pin_mode_max(dir)) |
320 | val = alc_pin_mode_min(dir); | |
321 | ||
322 | change = pinctl != alc_pin_mode_values[val]; | |
cdcd9268 JW |
323 | if (change) { |
324 | /* Set pin mode to that requested */ | |
a9430dd8 | 325 | snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL, |
4c5186ed | 326 | alc_pin_mode_values[val]); |
cdcd9268 JW |
327 | |
328 | /* Also enable the retasking pin's input/output as required | |
329 | * for the requested pin mode. Enum values of 2 or less are | |
330 | * input modes. | |
331 | * | |
332 | * Dynamically switching the input/output buffers probably | |
333 | * reduces noise slightly, particularly on input. However, | |
334 | * havingboth input and output buffers enabled | |
335 | * simultaneously doesn't seem to be problematic. | |
336 | */ | |
337 | if (val <= 2) { | |
338 | snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE, | |
339 | AMP_OUT_MUTE); | |
340 | snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE, | |
341 | AMP_IN_UNMUTE(0)); | |
342 | } else { | |
343 | snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE, | |
344 | AMP_IN_MUTE(0)); | |
345 | snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE, | |
346 | AMP_OUT_UNMUTE); | |
347 | } | |
348 | } | |
a9430dd8 JW |
349 | return change; |
350 | } | |
351 | ||
4c5186ed | 352 | #define ALC_PIN_MODE(xname, nid, dir) \ |
a9430dd8 | 353 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ |
4c5186ed JW |
354 | .info = alc_pin_mode_info, \ |
355 | .get = alc_pin_mode_get, \ | |
356 | .put = alc_pin_mode_put, \ | |
357 | .private_value = nid | (dir<<16) } | |
df694daa | 358 | |
5c8f858d JW |
359 | /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged |
360 | * together using a mask with more than one bit set. This control is | |
361 | * currently used only by the ALC260 test model. At this stage they are not | |
362 | * needed for any "production" models. | |
363 | */ | |
364 | #ifdef CONFIG_SND_DEBUG | |
365 | static int alc_gpio_data_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) | |
366 | { | |
367 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | |
368 | uinfo->count = 1; | |
369 | uinfo->value.integer.min = 0; | |
370 | uinfo->value.integer.max = 1; | |
371 | return 0; | |
372 | } | |
373 | static int alc_gpio_data_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | |
374 | { | |
375 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
376 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
377 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
378 | long *valp = ucontrol->value.integer.value; | |
379 | unsigned int val = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_GPIO_DATA,0x00); | |
380 | ||
381 | *valp = (val & mask) != 0; | |
382 | return 0; | |
383 | } | |
384 | static int alc_gpio_data_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | |
385 | { | |
386 | signed int change; | |
387 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
388 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
389 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
390 | long val = *ucontrol->value.integer.value; | |
391 | unsigned int gpio_data = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_GPIO_DATA,0x00); | |
392 | ||
393 | /* Set/unset the masked GPIO bit(s) as needed */ | |
394 | change = (val==0?0:mask) != (gpio_data & mask); | |
395 | if (val==0) | |
396 | gpio_data &= ~mask; | |
397 | else | |
398 | gpio_data |= mask; | |
399 | snd_hda_codec_write(codec,nid,0,AC_VERB_SET_GPIO_DATA,gpio_data); | |
400 | ||
401 | return change; | |
402 | } | |
403 | #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \ | |
404 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
405 | .info = alc_gpio_data_info, \ | |
406 | .get = alc_gpio_data_get, \ | |
407 | .put = alc_gpio_data_put, \ | |
408 | .private_value = nid | (mask<<16) } | |
409 | #endif /* CONFIG_SND_DEBUG */ | |
410 | ||
92621f13 JW |
411 | /* A switch control to allow the enabling of the digital IO pins on the |
412 | * ALC260. This is incredibly simplistic; the intention of this control is | |
413 | * to provide something in the test model allowing digital outputs to be | |
414 | * identified if present. If models are found which can utilise these | |
415 | * outputs a more complete mixer control can be devised for those models if | |
416 | * necessary. | |
417 | */ | |
418 | #ifdef CONFIG_SND_DEBUG | |
419 | static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) | |
420 | { | |
421 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | |
422 | uinfo->count = 1; | |
423 | uinfo->value.integer.min = 0; | |
424 | uinfo->value.integer.max = 1; | |
425 | return 0; | |
426 | } | |
427 | static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | |
428 | { | |
429 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
430 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
431 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
432 | long *valp = ucontrol->value.integer.value; | |
433 | unsigned int val = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_DIGI_CONVERT,0x00); | |
434 | ||
435 | *valp = (val & mask) != 0; | |
436 | return 0; | |
437 | } | |
438 | static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | |
439 | { | |
440 | signed int change; | |
441 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
442 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
443 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
444 | long val = *ucontrol->value.integer.value; | |
445 | unsigned int ctrl_data = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_DIGI_CONVERT,0x00); | |
446 | ||
447 | /* Set/unset the masked control bit(s) as needed */ | |
448 | change = (val==0?0:mask) != (ctrl_data & mask); | |
449 | if (val==0) | |
450 | ctrl_data &= ~mask; | |
451 | else | |
452 | ctrl_data |= mask; | |
453 | snd_hda_codec_write(codec,nid,0,AC_VERB_SET_DIGI_CONVERT_1,ctrl_data); | |
454 | ||
455 | return change; | |
456 | } | |
457 | #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \ | |
458 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
459 | .info = alc_spdif_ctrl_info, \ | |
460 | .get = alc_spdif_ctrl_get, \ | |
461 | .put = alc_spdif_ctrl_put, \ | |
462 | .private_value = nid | (mask<<16) } | |
463 | #endif /* CONFIG_SND_DEBUG */ | |
464 | ||
df694daa KY |
465 | /* |
466 | * set up from the preset table | |
467 | */ | |
468 | static void setup_preset(struct alc_spec *spec, const struct alc_config_preset *preset) | |
469 | { | |
470 | int i; | |
471 | ||
472 | for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++) | |
473 | spec->mixers[spec->num_mixers++] = preset->mixers[i]; | |
474 | for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; i++) | |
475 | spec->init_verbs[spec->num_init_verbs++] = preset->init_verbs[i]; | |
476 | ||
477 | spec->channel_mode = preset->channel_mode; | |
478 | spec->num_channel_mode = preset->num_channel_mode; | |
479 | ||
480 | spec->multiout.max_channels = spec->channel_mode[0].channels; | |
481 | ||
482 | spec->multiout.num_dacs = preset->num_dacs; | |
483 | spec->multiout.dac_nids = preset->dac_nids; | |
484 | spec->multiout.dig_out_nid = preset->dig_out_nid; | |
485 | spec->multiout.hp_nid = preset->hp_nid; | |
486 | ||
487 | spec->input_mux = preset->input_mux; | |
488 | ||
489 | spec->num_adc_nids = preset->num_adc_nids; | |
490 | spec->adc_nids = preset->adc_nids; | |
491 | spec->dig_in_nid = preset->dig_in_nid; | |
ae6b813a TI |
492 | |
493 | spec->unsol_event = preset->unsol_event; | |
494 | spec->init_hook = preset->init_hook; | |
df694daa KY |
495 | } |
496 | ||
1da177e4 | 497 | /* |
e9edcee0 TI |
498 | * ALC880 3-stack model |
499 | * | |
500 | * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e) | |
501 | * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, F-Mic = 0x1b | |
502 | * HP = 0x19 | |
1da177e4 LT |
503 | */ |
504 | ||
e9edcee0 TI |
505 | static hda_nid_t alc880_dac_nids[4] = { |
506 | /* front, rear, clfe, rear_surr */ | |
507 | 0x02, 0x05, 0x04, 0x03 | |
508 | }; | |
509 | ||
510 | static hda_nid_t alc880_adc_nids[3] = { | |
511 | /* ADC0-2 */ | |
512 | 0x07, 0x08, 0x09, | |
513 | }; | |
514 | ||
515 | /* The datasheet says the node 0x07 is connected from inputs, | |
516 | * but it shows zero connection in the real implementation on some devices. | |
df694daa | 517 | * Note: this is a 915GAV bug, fixed on 915GLV |
1da177e4 | 518 | */ |
e9edcee0 TI |
519 | static hda_nid_t alc880_adc_nids_alt[2] = { |
520 | /* ADC1-2 */ | |
521 | 0x08, 0x09, | |
522 | }; | |
523 | ||
524 | #define ALC880_DIGOUT_NID 0x06 | |
525 | #define ALC880_DIGIN_NID 0x0a | |
526 | ||
527 | static struct hda_input_mux alc880_capture_source = { | |
528 | .num_items = 4, | |
529 | .items = { | |
530 | { "Mic", 0x0 }, | |
531 | { "Front Mic", 0x3 }, | |
532 | { "Line", 0x2 }, | |
533 | { "CD", 0x4 }, | |
534 | }, | |
535 | }; | |
536 | ||
537 | /* channel source setting (2/6 channel selection for 3-stack) */ | |
538 | /* 2ch mode */ | |
539 | static struct hda_verb alc880_threestack_ch2_init[] = { | |
540 | /* set line-in to input, mute it */ | |
541 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
542 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
543 | /* set mic-in to input vref 80%, mute it */ | |
544 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
545 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
546 | { } /* end */ | |
547 | }; | |
548 | ||
549 | /* 6ch mode */ | |
550 | static struct hda_verb alc880_threestack_ch6_init[] = { | |
551 | /* set line-in to output, unmute it */ | |
552 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
553 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
554 | /* set mic-in to output, unmute it */ | |
555 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
556 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
557 | { } /* end */ | |
558 | }; | |
559 | ||
d2a6d7dc | 560 | static struct hda_channel_mode alc880_threestack_modes[2] = { |
e9edcee0 TI |
561 | { 2, alc880_threestack_ch2_init }, |
562 | { 6, alc880_threestack_ch6_init }, | |
563 | }; | |
564 | ||
c8b6bf9b | 565 | static struct snd_kcontrol_new alc880_three_stack_mixer[] = { |
05acb863 | 566 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 567 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
05acb863 | 568 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 569 | HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT), |
05acb863 TI |
570 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
571 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
572 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
573 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
1da177e4 LT |
574 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
575 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
576 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
577 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
578 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
579 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
580 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT), | |
581 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT), | |
582 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
583 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
e9edcee0 TI |
584 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT), |
585 | { | |
586 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
587 | .name = "Channel Mode", | |
df694daa KY |
588 | .info = alc_ch_mode_info, |
589 | .get = alc_ch_mode_get, | |
590 | .put = alc_ch_mode_put, | |
e9edcee0 TI |
591 | }, |
592 | { } /* end */ | |
593 | }; | |
594 | ||
595 | /* capture mixer elements */ | |
c8b6bf9b | 596 | static struct snd_kcontrol_new alc880_capture_mixer[] = { |
e9edcee0 TI |
597 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), |
598 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), | |
599 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), | |
600 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), | |
601 | HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), | |
602 | HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), | |
1da177e4 LT |
603 | { |
604 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
605 | /* The multiple "Capture Source" controls confuse alsamixer | |
606 | * So call somewhat different.. | |
607 | * FIXME: the controls appear in the "playback" view! | |
608 | */ | |
609 | /* .name = "Capture Source", */ | |
610 | .name = "Input Source", | |
e9edcee0 | 611 | .count = 3, |
1da177e4 LT |
612 | .info = alc_mux_enum_info, |
613 | .get = alc_mux_enum_get, | |
614 | .put = alc_mux_enum_put, | |
615 | }, | |
1da177e4 LT |
616 | { } /* end */ |
617 | }; | |
618 | ||
e9edcee0 | 619 | /* capture mixer elements (in case NID 0x07 not available) */ |
c8b6bf9b | 620 | static struct snd_kcontrol_new alc880_capture_alt_mixer[] = { |
71fe7b82 TI |
621 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
622 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
623 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
624 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
1da177e4 LT |
625 | { |
626 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
627 | /* The multiple "Capture Source" controls confuse alsamixer | |
628 | * So call somewhat different.. | |
629 | * FIXME: the controls appear in the "playback" view! | |
630 | */ | |
631 | /* .name = "Capture Source", */ | |
632 | .name = "Input Source", | |
633 | .count = 2, | |
634 | .info = alc_mux_enum_info, | |
635 | .get = alc_mux_enum_get, | |
636 | .put = alc_mux_enum_put, | |
637 | }, | |
1da177e4 LT |
638 | { } /* end */ |
639 | }; | |
640 | ||
e9edcee0 TI |
641 | |
642 | ||
643 | /* | |
644 | * ALC880 5-stack model | |
645 | * | |
646 | * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), Side = 0x02 (0xd) | |
647 | * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16 | |
648 | * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19 | |
649 | */ | |
650 | ||
651 | /* additional mixers to alc880_three_stack_mixer */ | |
c8b6bf9b | 652 | static struct snd_kcontrol_new alc880_five_stack_mixer[] = { |
e9edcee0 | 653 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 654 | HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT), |
1da177e4 LT |
655 | { } /* end */ |
656 | }; | |
657 | ||
e9edcee0 TI |
658 | /* channel source setting (6/8 channel selection for 5-stack) */ |
659 | /* 6ch mode */ | |
660 | static struct hda_verb alc880_fivestack_ch6_init[] = { | |
661 | /* set line-in to input, mute it */ | |
662 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
663 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
dfc0ff62 TI |
664 | { } /* end */ |
665 | }; | |
666 | ||
e9edcee0 TI |
667 | /* 8ch mode */ |
668 | static struct hda_verb alc880_fivestack_ch8_init[] = { | |
669 | /* set line-in to output, unmute it */ | |
670 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
671 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
672 | { } /* end */ | |
673 | }; | |
674 | ||
d2a6d7dc | 675 | static struct hda_channel_mode alc880_fivestack_modes[2] = { |
e9edcee0 TI |
676 | { 6, alc880_fivestack_ch6_init }, |
677 | { 8, alc880_fivestack_ch8_init }, | |
678 | }; | |
679 | ||
680 | ||
681 | /* | |
682 | * ALC880 6-stack model | |
683 | * | |
684 | * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), Side = 0x05 (0x0f) | |
685 | * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17, | |
686 | * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b | |
687 | */ | |
688 | ||
689 | static hda_nid_t alc880_6st_dac_nids[4] = { | |
690 | /* front, rear, clfe, rear_surr */ | |
691 | 0x02, 0x03, 0x04, 0x05 | |
692 | }; | |
693 | ||
694 | static struct hda_input_mux alc880_6stack_capture_source = { | |
695 | .num_items = 4, | |
696 | .items = { | |
697 | { "Mic", 0x0 }, | |
698 | { "Front Mic", 0x1 }, | |
699 | { "Line", 0x2 }, | |
700 | { "CD", 0x4 }, | |
701 | }, | |
702 | }; | |
703 | ||
704 | /* fixed 8-channels */ | |
d2a6d7dc | 705 | static struct hda_channel_mode alc880_sixstack_modes[1] = { |
e9edcee0 TI |
706 | { 8, NULL }, |
707 | }; | |
708 | ||
c8b6bf9b | 709 | static struct snd_kcontrol_new alc880_six_stack_mixer[] = { |
16ded525 | 710 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 711 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 712 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 713 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
714 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
715 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
716 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
717 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
16ded525 | 718 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 719 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
16ded525 TI |
720 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
721 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
722 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
723 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
724 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
725 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
726 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
727 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
728 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
729 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
16ded525 TI |
730 | { |
731 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
732 | .name = "Channel Mode", | |
df694daa KY |
733 | .info = alc_ch_mode_info, |
734 | .get = alc_ch_mode_get, | |
735 | .put = alc_ch_mode_put, | |
16ded525 TI |
736 | }, |
737 | { } /* end */ | |
738 | }; | |
739 | ||
e9edcee0 TI |
740 | |
741 | /* | |
742 | * ALC880 W810 model | |
743 | * | |
744 | * W810 has rear IO for: | |
745 | * Front (DAC 02) | |
746 | * Surround (DAC 03) | |
747 | * Center/LFE (DAC 04) | |
748 | * Digital out (06) | |
749 | * | |
750 | * The system also has a pair of internal speakers, and a headphone jack. | |
751 | * These are both connected to Line2 on the codec, hence to DAC 02. | |
752 | * | |
753 | * There is a variable resistor to control the speaker or headphone | |
754 | * volume. This is a hardware-only device without a software API. | |
755 | * | |
756 | * Plugging headphones in will disable the internal speakers. This is | |
757 | * implemented in hardware, not via the driver using jack sense. In | |
758 | * a similar fashion, plugging into the rear socket marked "front" will | |
759 | * disable both the speakers and headphones. | |
760 | * | |
761 | * For input, there's a microphone jack, and an "audio in" jack. | |
762 | * These may not do anything useful with this driver yet, because I | |
763 | * haven't setup any initialization verbs for these yet... | |
764 | */ | |
765 | ||
766 | static hda_nid_t alc880_w810_dac_nids[3] = { | |
767 | /* front, rear/surround, clfe */ | |
768 | 0x02, 0x03, 0x04 | |
16ded525 TI |
769 | }; |
770 | ||
e9edcee0 | 771 | /* fixed 6 channels */ |
d2a6d7dc | 772 | static struct hda_channel_mode alc880_w810_modes[1] = { |
e9edcee0 TI |
773 | { 6, NULL } |
774 | }; | |
775 | ||
776 | /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */ | |
c8b6bf9b | 777 | static struct snd_kcontrol_new alc880_w810_base_mixer[] = { |
16ded525 | 778 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 779 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 780 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 781 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
782 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
783 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
784 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
785 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
e9edcee0 TI |
786 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
787 | { } /* end */ | |
788 | }; | |
789 | ||
790 | ||
791 | /* | |
792 | * Z710V model | |
793 | * | |
794 | * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d) | |
795 | * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), Line = 0x1a | |
796 | */ | |
797 | ||
798 | static hda_nid_t alc880_z71v_dac_nids[1] = { | |
799 | 0x02 | |
800 | }; | |
801 | #define ALC880_Z71V_HP_DAC 0x03 | |
802 | ||
803 | /* fixed 2 channels */ | |
d2a6d7dc | 804 | static struct hda_channel_mode alc880_2_jack_modes[1] = { |
e9edcee0 TI |
805 | { 2, NULL } |
806 | }; | |
807 | ||
c8b6bf9b | 808 | static struct snd_kcontrol_new alc880_z71v_mixer[] = { |
e9edcee0 | 809 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 810 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
e9edcee0 | 811 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 812 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
813 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
814 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
16ded525 TI |
815 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
816 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
16ded525 TI |
817 | { } /* end */ |
818 | }; | |
819 | ||
e9edcee0 TI |
820 | |
821 | /* FIXME! */ | |
822 | /* | |
823 | * ALC880 F1734 model | |
824 | * | |
825 | * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d) | |
826 | * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18 | |
827 | */ | |
828 | ||
829 | static hda_nid_t alc880_f1734_dac_nids[1] = { | |
830 | 0x03 | |
831 | }; | |
832 | #define ALC880_F1734_HP_DAC 0x02 | |
833 | ||
c8b6bf9b | 834 | static struct snd_kcontrol_new alc880_f1734_mixer[] = { |
e9edcee0 | 835 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 836 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), |
e9edcee0 | 837 | HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 838 | HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT), |
e9edcee0 TI |
839 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
840 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
841 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
842 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
843 | { } /* end */ | |
844 | }; | |
845 | ||
846 | ||
847 | /* FIXME! */ | |
848 | /* | |
849 | * ALC880 ASUS model | |
850 | * | |
851 | * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) | |
852 | * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, | |
853 | * Mic = 0x18, Line = 0x1a | |
854 | */ | |
855 | ||
856 | #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */ | |
857 | #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */ | |
858 | ||
c8b6bf9b | 859 | static struct snd_kcontrol_new alc880_asus_mixer[] = { |
16ded525 | 860 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 861 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 862 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 863 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
864 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
865 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
866 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
867 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
16ded525 TI |
868 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
869 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
870 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
871 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
16ded525 TI |
872 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
873 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
16ded525 TI |
874 | { |
875 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
876 | .name = "Channel Mode", | |
df694daa KY |
877 | .info = alc_ch_mode_info, |
878 | .get = alc_ch_mode_get, | |
879 | .put = alc_ch_mode_put, | |
16ded525 TI |
880 | }, |
881 | { } /* end */ | |
882 | }; | |
e9edcee0 TI |
883 | |
884 | /* FIXME! */ | |
885 | /* | |
886 | * ALC880 ASUS W1V model | |
887 | * | |
888 | * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) | |
889 | * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, | |
890 | * Mic = 0x18, Line = 0x1a, Line2 = 0x1b | |
891 | */ | |
892 | ||
893 | /* additional mixers to alc880_asus_mixer */ | |
c8b6bf9b | 894 | static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = { |
e9edcee0 TI |
895 | HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT), |
896 | HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT), | |
897 | { } /* end */ | |
898 | }; | |
899 | ||
3c10a9d9 | 900 | /* additional mixers to alc880_asus_mixer */ |
c8b6bf9b | 901 | static struct snd_kcontrol_new alc880_pcbeep_mixer[] = { |
3c10a9d9 TI |
902 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), |
903 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
904 | { } /* end */ | |
905 | }; | |
e9edcee0 | 906 | |
df694daa KY |
907 | /* TCL S700 */ |
908 | static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = { | |
909 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
910 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
911 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
912 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT), | |
913 | HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT), | |
914 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT), | |
915 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT), | |
916 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
917 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
918 | { | |
919 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
920 | /* The multiple "Capture Source" controls confuse alsamixer | |
921 | * So call somewhat different.. | |
922 | * FIXME: the controls appear in the "playback" view! | |
923 | */ | |
924 | /* .name = "Capture Source", */ | |
925 | .name = "Input Source", | |
926 | .count = 1, | |
927 | .info = alc_mux_enum_info, | |
928 | .get = alc_mux_enum_get, | |
929 | .put = alc_mux_enum_put, | |
930 | }, | |
931 | { } /* end */ | |
932 | }; | |
933 | ||
1da177e4 | 934 | /* |
e9edcee0 | 935 | * build control elements |
1da177e4 LT |
936 | */ |
937 | static int alc_build_controls(struct hda_codec *codec) | |
938 | { | |
939 | struct alc_spec *spec = codec->spec; | |
940 | int err; | |
941 | int i; | |
942 | ||
943 | for (i = 0; i < spec->num_mixers; i++) { | |
944 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); | |
945 | if (err < 0) | |
946 | return err; | |
947 | } | |
948 | ||
949 | if (spec->multiout.dig_out_nid) { | |
950 | err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); | |
951 | if (err < 0) | |
952 | return err; | |
953 | } | |
954 | if (spec->dig_in_nid) { | |
955 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); | |
956 | if (err < 0) | |
957 | return err; | |
958 | } | |
959 | return 0; | |
960 | } | |
961 | ||
e9edcee0 | 962 | |
1da177e4 LT |
963 | /* |
964 | * initialize the codec volumes, etc | |
965 | */ | |
966 | ||
e9edcee0 TI |
967 | /* |
968 | * generic initialization of ADC, input mixers and output mixers | |
969 | */ | |
970 | static struct hda_verb alc880_volume_init_verbs[] = { | |
971 | /* | |
972 | * Unmute ADC0-2 and set the default input to mic-in | |
973 | */ | |
71fe7b82 | 974 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 975 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
71fe7b82 | 976 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 977 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
71fe7b82 | 978 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 979 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1da177e4 | 980 | |
e9edcee0 TI |
981 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
982 | * mixer widget | |
1da177e4 LT |
983 | * Note: PASD motherboards uses the Line In 2 as the input for front panel |
984 | * mic (mic 2) | |
985 | */ | |
e9edcee0 | 986 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ |
16ded525 | 987 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
e9edcee0 TI |
988 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
989 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
990 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
991 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
1da177e4 | 992 | |
e9edcee0 TI |
993 | /* |
994 | * Set up output mixers (0x0c - 0x0f) | |
1da177e4 | 995 | */ |
e9edcee0 TI |
996 | /* set vol=0 to output mixers */ |
997 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
998 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
999 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1000 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1001 | /* set up input amps for analog loopback */ | |
1002 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
05acb863 TI |
1003 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1004 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
1005 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1006 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
1007 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1008 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
1009 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1010 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 LT |
1011 | |
1012 | { } | |
1013 | }; | |
1014 | ||
e9edcee0 TI |
1015 | /* |
1016 | * 3-stack pin configuration: | |
1017 | * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b | |
1018 | */ | |
1019 | static struct hda_verb alc880_pin_3stack_init_verbs[] = { | |
1020 | /* | |
1021 | * preset connection lists of input pins | |
1022 | * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround | |
1023 | */ | |
1024 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
1025 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
1026 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */ | |
1027 | ||
1028 | /* | |
1029 | * Set pin mode and muting | |
1030 | */ | |
1031 | /* set front pin widgets 0x14 for output */ | |
05acb863 | 1032 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
1033 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1034 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
1035 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1036 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1037 | /* Mic2 (as headphone out) for HP output */ | |
1038 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1039 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1da177e4 | 1040 | /* Line In pin widget for input */ |
05acb863 | 1041 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 TI |
1042 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
1043 | /* Line2 (as front mic) pin widget for input and vref at 80% */ | |
1044 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1045 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1da177e4 | 1046 | /* CD pin widget for input */ |
05acb863 | 1047 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 1048 | |
e9edcee0 TI |
1049 | { } |
1050 | }; | |
1da177e4 | 1051 | |
e9edcee0 TI |
1052 | /* |
1053 | * 5-stack pin configuration: | |
1054 | * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19, | |
1055 | * line-in/side = 0x1a, f-mic = 0x1b | |
1056 | */ | |
1057 | static struct hda_verb alc880_pin_5stack_init_verbs[] = { | |
1058 | /* | |
1059 | * preset connection lists of input pins | |
1060 | * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround | |
1da177e4 | 1061 | */ |
e9edcee0 TI |
1062 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
1063 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */ | |
1da177e4 | 1064 | |
e9edcee0 TI |
1065 | /* |
1066 | * Set pin mode and muting | |
1da177e4 | 1067 | */ |
e9edcee0 TI |
1068 | /* set pin widgets 0x14-0x17 for output */ |
1069 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1070 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1071 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1072 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1073 | /* unmute pins for output (no gain on this amp) */ | |
1074 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1075 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1076 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1077 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1078 | ||
1079 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
1080 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1081 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1082 | /* Mic2 (as headphone out) for HP output */ | |
1083 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1084 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1085 | /* Line In pin widget for input */ | |
1086 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1087 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1088 | /* Line2 (as front mic) pin widget for input and vref at 80% */ | |
1089 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1090 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1091 | /* CD pin widget for input */ | |
1092 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1da177e4 LT |
1093 | |
1094 | { } | |
1095 | }; | |
1096 | ||
e9edcee0 TI |
1097 | /* |
1098 | * W810 pin configuration: | |
1099 | * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b | |
1100 | */ | |
1101 | static struct hda_verb alc880_pin_w810_init_verbs[] = { | |
1102 | /* hphone/speaker input selector: front DAC */ | |
1103 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
1da177e4 | 1104 | |
05acb863 | 1105 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1106 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 1107 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1108 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 1109 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1110 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 1111 | |
e9edcee0 | 1112 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
05acb863 | 1113 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
1da177e4 | 1114 | |
1da177e4 LT |
1115 | { } |
1116 | }; | |
1117 | ||
e9edcee0 TI |
1118 | /* |
1119 | * Z71V pin configuration: | |
1120 | * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?) | |
1121 | */ | |
1122 | static struct hda_verb alc880_pin_z71v_init_verbs[] = { | |
05acb863 | 1123 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1124 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 1125 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
e9edcee0 | 1126 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
dfc0ff62 | 1127 | |
16ded525 | 1128 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1129 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
16ded525 | 1130 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1131 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
16ded525 TI |
1132 | |
1133 | { } | |
1134 | }; | |
1135 | ||
e9edcee0 TI |
1136 | /* |
1137 | * 6-stack pin configuration: | |
1138 | * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, f-mic = 0x19, | |
1139 | * line = 0x1a, HP = 0x1b | |
1140 | */ | |
1141 | static struct hda_verb alc880_pin_6stack_init_verbs[] = { | |
1142 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
1143 | ||
16ded525 | 1144 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1145 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1146 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1147 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1148 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1149 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1150 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
1151 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1152 | ||
16ded525 | 1153 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1154 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 1155 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1156 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 1157 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 | 1158 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 1159 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
e9edcee0 | 1160 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 TI |
1161 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1162 | ||
e9edcee0 TI |
1163 | { } |
1164 | }; | |
1165 | ||
1166 | /* FIXME! */ | |
1167 | /* | |
1168 | * F1734 pin configuration: | |
1169 | * HP = 0x14, speaker-out = 0x15, mic = 0x18 | |
1170 | */ | |
1171 | static struct hda_verb alc880_pin_f1734_init_verbs[] = { | |
16ded525 TI |
1172 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, |
1173 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1174 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
1175 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1176 | ||
e9edcee0 | 1177 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
16ded525 | 1178 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
e9edcee0 | 1179 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
16ded525 | 1180 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1181 | |
e9edcee0 TI |
1182 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1183 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
16ded525 | 1184 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1185 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 1186 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1187 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1188 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1189 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1190 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
dfc0ff62 TI |
1191 | |
1192 | { } | |
1193 | }; | |
1194 | ||
e9edcee0 TI |
1195 | /* FIXME! */ |
1196 | /* | |
1197 | * ASUS pin configuration: | |
1198 | * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a | |
1199 | */ | |
1200 | static struct hda_verb alc880_pin_asus_init_verbs[] = { | |
16ded525 TI |
1201 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, |
1202 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1203 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
1204 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1205 | ||
1206 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
e9edcee0 | 1207 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1208 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1209 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1210 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1211 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1212 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
1213 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1214 | ||
1215 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1216 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1217 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1218 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1219 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1220 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
16ded525 | 1221 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1222 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 TI |
1223 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1224 | ||
e9edcee0 TI |
1225 | { } |
1226 | }; | |
16ded525 | 1227 | |
e9edcee0 TI |
1228 | /* Enable GPIO mask and set output */ |
1229 | static struct hda_verb alc880_gpio1_init_verbs[] = { | |
1230 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
1231 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
1232 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, | |
df694daa KY |
1233 | |
1234 | { } | |
e9edcee0 | 1235 | }; |
16ded525 | 1236 | |
e9edcee0 TI |
1237 | /* Enable GPIO mask and set output */ |
1238 | static struct hda_verb alc880_gpio2_init_verbs[] = { | |
1239 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, | |
1240 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, | |
1241 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, | |
df694daa KY |
1242 | |
1243 | { } | |
1244 | }; | |
1245 | ||
1246 | /* Clevo m520g init */ | |
1247 | static struct hda_verb alc880_pin_clevo_init_verbs[] = { | |
1248 | /* headphone output */ | |
1249 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
1250 | /* line-out */ | |
1251 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1252 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1253 | /* Line-in */ | |
1254 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1255 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1256 | /* CD */ | |
1257 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1258 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1259 | /* Mic1 (rear panel) */ | |
1260 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1261 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1262 | /* Mic2 (front panel) */ | |
1263 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1264 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1265 | /* headphone */ | |
1266 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1267 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1268 | /* change to EAPD mode */ | |
1269 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
1270 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, | |
1271 | ||
1272 | { } | |
16ded525 TI |
1273 | }; |
1274 | ||
df694daa KY |
1275 | static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = { |
1276 | /* Headphone output */ | |
1277 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1278 | /* Front output*/ | |
1279 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1280 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1281 | ||
1282 | /* Line In pin widget for input */ | |
1283 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1284 | /* CD pin widget for input */ | |
1285 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1286 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
1287 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1288 | ||
1289 | /* change to EAPD mode */ | |
1290 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
1291 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
1292 | ||
1293 | { } | |
1294 | }; | |
16ded525 | 1295 | |
e9edcee0 | 1296 | /* |
ae6b813a TI |
1297 | * LG m1 express dual |
1298 | * | |
1299 | * Pin assignment: | |
1300 | * Rear Line-In/Out (blue): 0x14 | |
1301 | * Build-in Mic-In: 0x15 | |
1302 | * Speaker-out: 0x17 | |
1303 | * HP-Out (green): 0x1b | |
1304 | * Mic-In/Out (red): 0x19 | |
1305 | * SPDIF-Out: 0x1e | |
1306 | */ | |
1307 | ||
1308 | /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */ | |
1309 | static hda_nid_t alc880_lg_dac_nids[3] = { | |
1310 | 0x05, 0x02, 0x03 | |
1311 | }; | |
1312 | ||
1313 | /* seems analog CD is not working */ | |
1314 | static struct hda_input_mux alc880_lg_capture_source = { | |
1315 | .num_items = 3, | |
1316 | .items = { | |
1317 | { "Mic", 0x1 }, | |
1318 | { "Line", 0x5 }, | |
1319 | { "Internal Mic", 0x6 }, | |
1320 | }, | |
1321 | }; | |
1322 | ||
1323 | /* 2,4,6 channel modes */ | |
1324 | static struct hda_verb alc880_lg_ch2_init[] = { | |
1325 | /* set line-in and mic-in to input */ | |
1326 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
1327 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
1328 | { } | |
1329 | }; | |
1330 | ||
1331 | static struct hda_verb alc880_lg_ch4_init[] = { | |
1332 | /* set line-in to out and mic-in to input */ | |
1333 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
1334 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
1335 | { } | |
1336 | }; | |
1337 | ||
1338 | static struct hda_verb alc880_lg_ch6_init[] = { | |
1339 | /* set line-in and mic-in to output */ | |
1340 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
1341 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
1342 | { } | |
1343 | }; | |
1344 | ||
1345 | static struct hda_channel_mode alc880_lg_ch_modes[3] = { | |
1346 | { 2, alc880_lg_ch2_init }, | |
1347 | { 4, alc880_lg_ch4_init }, | |
1348 | { 6, alc880_lg_ch6_init }, | |
1349 | }; | |
1350 | ||
1351 | static struct snd_kcontrol_new alc880_lg_mixer[] = { | |
1352 | /* FIXME: it's not really "master" but front channels */ | |
1353 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
1354 | HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT), | |
1355 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1356 | HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT), | |
1357 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), | |
1358 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT), | |
1359 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT), | |
1360 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), | |
1361 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1362 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1363 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT), | |
1364 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT), | |
1365 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT), | |
1366 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT), | |
1367 | { | |
1368 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1369 | .name = "Channel Mode", | |
1370 | .info = alc_ch_mode_info, | |
1371 | .get = alc_ch_mode_get, | |
1372 | .put = alc_ch_mode_put, | |
1373 | }, | |
1374 | { } /* end */ | |
1375 | }; | |
1376 | ||
1377 | static struct hda_verb alc880_lg_init_verbs[] = { | |
1378 | /* set capture source to mic-in */ | |
1379 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
1380 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
1381 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
1382 | /* mute all amp mixer inputs */ | |
1383 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)}, | |
1384 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)}, | |
1385 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)}, | |
1386 | /* line-in to input */ | |
1387 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1388 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1389 | /* built-in mic */ | |
1390 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1391 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1392 | /* speaker-out */ | |
1393 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1394 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1395 | /* mic-in to input */ | |
1396 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
1397 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1398 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1399 | /* HP-out */ | |
1400 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
1401 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1402 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1403 | /* jack sense */ | |
1404 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, | |
1405 | { } | |
1406 | }; | |
1407 | ||
1408 | /* toggle speaker-output according to the hp-jack state */ | |
1409 | static void alc880_lg_automute(struct hda_codec *codec) | |
1410 | { | |
1411 | unsigned int present; | |
1412 | ||
1413 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
1414 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
1415 | snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0, | |
1416 | 0x80, present ? 0x80 : 0); | |
1417 | snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0, | |
1418 | 0x80, present ? 0x80 : 0); | |
1419 | } | |
1420 | ||
1421 | static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res) | |
1422 | { | |
1423 | /* Looks like the unsol event is incompatible with the standard | |
1424 | * definition. 4bit tag is placed at 28 bit! | |
1425 | */ | |
1426 | if ((res >> 28) == 0x01) | |
1427 | alc880_lg_automute(codec); | |
1428 | } | |
1429 | ||
d681518a TI |
1430 | /* |
1431 | * LG LW20 | |
1432 | * | |
1433 | * Pin assignment: | |
1434 | * Speaker-out: 0x14 | |
1435 | * Mic-In: 0x18 | |
1436 | * Built-in Mic-In: 0x19 (?) | |
1437 | * HP-Out: 0x1b | |
1438 | * SPDIF-Out: 0x1e | |
1439 | */ | |
1440 | ||
1441 | /* seems analog CD is not working */ | |
1442 | static struct hda_input_mux alc880_lg_lw_capture_source = { | |
1443 | .num_items = 2, | |
1444 | .items = { | |
1445 | { "Mic", 0x0 }, | |
1446 | { "Internal Mic", 0x1 }, | |
1447 | }, | |
1448 | }; | |
1449 | ||
1450 | static struct snd_kcontrol_new alc880_lg_lw_mixer[] = { | |
1451 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1452 | HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT), | |
1453 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1454 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1455 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
1456 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
1457 | { } /* end */ | |
1458 | }; | |
1459 | ||
1460 | static struct hda_verb alc880_lg_lw_init_verbs[] = { | |
1461 | /* set capture source to mic-in */ | |
1462 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
1463 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
1464 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
1465 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)}, | |
1466 | /* speaker-out */ | |
1467 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1468 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1469 | /* HP-out */ | |
1470 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1471 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1472 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1473 | /* mic-in to input */ | |
1474 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1475 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1476 | /* built-in mic */ | |
1477 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1478 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1479 | /* jack sense */ | |
1480 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, | |
1481 | { } | |
1482 | }; | |
1483 | ||
1484 | /* toggle speaker-output according to the hp-jack state */ | |
1485 | static void alc880_lg_lw_automute(struct hda_codec *codec) | |
1486 | { | |
1487 | unsigned int present; | |
1488 | ||
1489 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
1490 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
1491 | snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, | |
1492 | 0x80, present ? 0x80 : 0); | |
1493 | snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, | |
1494 | 0x80, present ? 0x80 : 0); | |
1495 | } | |
1496 | ||
1497 | static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res) | |
1498 | { | |
1499 | /* Looks like the unsol event is incompatible with the standard | |
1500 | * definition. 4bit tag is placed at 28 bit! | |
1501 | */ | |
1502 | if ((res >> 28) == 0x01) | |
1503 | alc880_lg_lw_automute(codec); | |
1504 | } | |
1505 | ||
ae6b813a TI |
1506 | /* |
1507 | * Common callbacks | |
e9edcee0 TI |
1508 | */ |
1509 | ||
1da177e4 LT |
1510 | static int alc_init(struct hda_codec *codec) |
1511 | { | |
1512 | struct alc_spec *spec = codec->spec; | |
e9edcee0 TI |
1513 | unsigned int i; |
1514 | ||
1515 | for (i = 0; i < spec->num_init_verbs; i++) | |
1516 | snd_hda_sequence_write(codec, spec->init_verbs[i]); | |
ae6b813a TI |
1517 | |
1518 | if (spec->init_hook) | |
1519 | spec->init_hook(codec); | |
1520 | ||
1da177e4 LT |
1521 | return 0; |
1522 | } | |
1523 | ||
ae6b813a TI |
1524 | static void alc_unsol_event(struct hda_codec *codec, unsigned int res) |
1525 | { | |
1526 | struct alc_spec *spec = codec->spec; | |
1527 | ||
1528 | if (spec->unsol_event) | |
1529 | spec->unsol_event(codec, res); | |
1530 | } | |
1531 | ||
1da177e4 LT |
1532 | #ifdef CONFIG_PM |
1533 | /* | |
1534 | * resume | |
1535 | */ | |
1536 | static int alc_resume(struct hda_codec *codec) | |
1537 | { | |
1538 | struct alc_spec *spec = codec->spec; | |
1539 | int i; | |
1540 | ||
1541 | alc_init(codec); | |
e9edcee0 | 1542 | for (i = 0; i < spec->num_mixers; i++) |
1da177e4 | 1543 | snd_hda_resume_ctls(codec, spec->mixers[i]); |
1da177e4 LT |
1544 | if (spec->multiout.dig_out_nid) |
1545 | snd_hda_resume_spdif_out(codec); | |
1546 | if (spec->dig_in_nid) | |
1547 | snd_hda_resume_spdif_in(codec); | |
1548 | ||
1549 | return 0; | |
1550 | } | |
1551 | #endif | |
1552 | ||
1553 | /* | |
1554 | * Analog playback callbacks | |
1555 | */ | |
1556 | static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo, | |
1557 | struct hda_codec *codec, | |
c8b6bf9b | 1558 | struct snd_pcm_substream *substream) |
1da177e4 LT |
1559 | { |
1560 | struct alc_spec *spec = codec->spec; | |
1561 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); | |
1562 | } | |
1563 | ||
1564 | static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | |
1565 | struct hda_codec *codec, | |
1566 | unsigned int stream_tag, | |
1567 | unsigned int format, | |
c8b6bf9b | 1568 | struct snd_pcm_substream *substream) |
1da177e4 LT |
1569 | { |
1570 | struct alc_spec *spec = codec->spec; | |
1571 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, | |
1572 | format, substream); | |
1573 | } | |
1574 | ||
1575 | static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, | |
1576 | struct hda_codec *codec, | |
c8b6bf9b | 1577 | struct snd_pcm_substream *substream) |
1da177e4 LT |
1578 | { |
1579 | struct alc_spec *spec = codec->spec; | |
1580 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); | |
1581 | } | |
1582 | ||
1583 | /* | |
1584 | * Digital out | |
1585 | */ | |
1586 | static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, | |
1587 | struct hda_codec *codec, | |
c8b6bf9b | 1588 | struct snd_pcm_substream *substream) |
1da177e4 LT |
1589 | { |
1590 | struct alc_spec *spec = codec->spec; | |
1591 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); | |
1592 | } | |
1593 | ||
1594 | static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, | |
1595 | struct hda_codec *codec, | |
c8b6bf9b | 1596 | struct snd_pcm_substream *substream) |
1da177e4 LT |
1597 | { |
1598 | struct alc_spec *spec = codec->spec; | |
1599 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); | |
1600 | } | |
1601 | ||
1602 | /* | |
1603 | * Analog capture | |
1604 | */ | |
1605 | static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo, | |
1606 | struct hda_codec *codec, | |
1607 | unsigned int stream_tag, | |
1608 | unsigned int format, | |
c8b6bf9b | 1609 | struct snd_pcm_substream *substream) |
1da177e4 LT |
1610 | { |
1611 | struct alc_spec *spec = codec->spec; | |
1612 | ||
1613 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], | |
1614 | stream_tag, 0, format); | |
1615 | return 0; | |
1616 | } | |
1617 | ||
1618 | static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, | |
1619 | struct hda_codec *codec, | |
c8b6bf9b | 1620 | struct snd_pcm_substream *substream) |
1da177e4 LT |
1621 | { |
1622 | struct alc_spec *spec = codec->spec; | |
1623 | ||
1624 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0); | |
1625 | return 0; | |
1626 | } | |
1627 | ||
1628 | ||
1629 | /* | |
1630 | */ | |
1631 | static struct hda_pcm_stream alc880_pcm_analog_playback = { | |
1632 | .substreams = 1, | |
1633 | .channels_min = 2, | |
1634 | .channels_max = 8, | |
e9edcee0 | 1635 | /* NID is set in alc_build_pcms */ |
1da177e4 LT |
1636 | .ops = { |
1637 | .open = alc880_playback_pcm_open, | |
1638 | .prepare = alc880_playback_pcm_prepare, | |
1639 | .cleanup = alc880_playback_pcm_cleanup | |
1640 | }, | |
1641 | }; | |
1642 | ||
1643 | static struct hda_pcm_stream alc880_pcm_analog_capture = { | |
1644 | .substreams = 2, | |
1645 | .channels_min = 2, | |
1646 | .channels_max = 2, | |
e9edcee0 | 1647 | /* NID is set in alc_build_pcms */ |
1da177e4 LT |
1648 | .ops = { |
1649 | .prepare = alc880_capture_pcm_prepare, | |
1650 | .cleanup = alc880_capture_pcm_cleanup | |
1651 | }, | |
1652 | }; | |
1653 | ||
1654 | static struct hda_pcm_stream alc880_pcm_digital_playback = { | |
1655 | .substreams = 1, | |
1656 | .channels_min = 2, | |
1657 | .channels_max = 2, | |
1658 | /* NID is set in alc_build_pcms */ | |
1659 | .ops = { | |
1660 | .open = alc880_dig_playback_pcm_open, | |
1661 | .close = alc880_dig_playback_pcm_close | |
1662 | }, | |
1663 | }; | |
1664 | ||
1665 | static struct hda_pcm_stream alc880_pcm_digital_capture = { | |
1666 | .substreams = 1, | |
1667 | .channels_min = 2, | |
1668 | .channels_max = 2, | |
1669 | /* NID is set in alc_build_pcms */ | |
1670 | }; | |
1671 | ||
4c5186ed JW |
1672 | /* Used by alc_build_pcms to flag that a PCM has no playback stream */ |
1673 | static struct hda_pcm_stream alc_pcm_null_playback = { | |
1674 | .substreams = 0, | |
1675 | .channels_min = 0, | |
1676 | .channels_max = 0, | |
1677 | }; | |
1678 | ||
1da177e4 LT |
1679 | static int alc_build_pcms(struct hda_codec *codec) |
1680 | { | |
1681 | struct alc_spec *spec = codec->spec; | |
1682 | struct hda_pcm *info = spec->pcm_rec; | |
1683 | int i; | |
1684 | ||
1685 | codec->num_pcms = 1; | |
1686 | codec->pcm_info = info; | |
1687 | ||
1688 | info->name = spec->stream_name_analog; | |
4a471b7d TI |
1689 | if (spec->stream_analog_playback) { |
1690 | snd_assert(spec->multiout.dac_nids, return -EINVAL); | |
1691 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback); | |
1692 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; | |
1693 | } | |
1694 | if (spec->stream_analog_capture) { | |
1695 | snd_assert(spec->adc_nids, return -EINVAL); | |
1696 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); | |
1697 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; | |
1698 | } | |
1699 | ||
1700 | if (spec->channel_mode) { | |
1701 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; | |
1702 | for (i = 0; i < spec->num_channel_mode; i++) { | |
1703 | if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { | |
1704 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; | |
1705 | } | |
1da177e4 LT |
1706 | } |
1707 | } | |
1708 | ||
4c5186ed JW |
1709 | /* If the use of more than one ADC is requested for the current |
1710 | * model, configure a second analog capture-only PCM. | |
1711 | */ | |
1712 | if (spec->num_adc_nids > 1) { | |
1713 | codec->num_pcms++; | |
1714 | info++; | |
1715 | info->name = spec->stream_name_analog; | |
1716 | /* No playback stream for second PCM */ | |
1717 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback; | |
1718 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; | |
1719 | if (spec->stream_analog_capture) { | |
1720 | snd_assert(spec->adc_nids, return -EINVAL); | |
1721 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); | |
1722 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1]; | |
1723 | } | |
1724 | } | |
1725 | ||
1da177e4 LT |
1726 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
1727 | codec->num_pcms++; | |
1728 | info++; | |
1729 | info->name = spec->stream_name_digital; | |
4a471b7d TI |
1730 | if (spec->multiout.dig_out_nid && |
1731 | spec->stream_digital_playback) { | |
1da177e4 LT |
1732 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback); |
1733 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; | |
1734 | } | |
4a471b7d TI |
1735 | if (spec->dig_in_nid && |
1736 | spec->stream_digital_capture) { | |
1da177e4 LT |
1737 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture); |
1738 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; | |
1739 | } | |
1740 | } | |
1741 | ||
1742 | return 0; | |
1743 | } | |
1744 | ||
1745 | static void alc_free(struct hda_codec *codec) | |
1746 | { | |
e9edcee0 TI |
1747 | struct alc_spec *spec = codec->spec; |
1748 | unsigned int i; | |
1749 | ||
1750 | if (! spec) | |
1751 | return; | |
1752 | ||
1753 | if (spec->kctl_alloc) { | |
1754 | for (i = 0; i < spec->num_kctl_used; i++) | |
1755 | kfree(spec->kctl_alloc[i].name); | |
1756 | kfree(spec->kctl_alloc); | |
1757 | } | |
1758 | kfree(spec); | |
1da177e4 LT |
1759 | } |
1760 | ||
1761 | /* | |
1762 | */ | |
1763 | static struct hda_codec_ops alc_patch_ops = { | |
1764 | .build_controls = alc_build_controls, | |
1765 | .build_pcms = alc_build_pcms, | |
1766 | .init = alc_init, | |
1767 | .free = alc_free, | |
ae6b813a | 1768 | .unsol_event = alc_unsol_event, |
1da177e4 LT |
1769 | #ifdef CONFIG_PM |
1770 | .resume = alc_resume, | |
1771 | #endif | |
1772 | }; | |
1773 | ||
2fa522be TI |
1774 | |
1775 | /* | |
1776 | * Test configuration for debugging | |
1777 | * | |
1778 | * Almost all inputs/outputs are enabled. I/O pins can be configured via | |
1779 | * enum controls. | |
1780 | */ | |
1781 | #ifdef CONFIG_SND_DEBUG | |
1782 | static hda_nid_t alc880_test_dac_nids[4] = { | |
1783 | 0x02, 0x03, 0x04, 0x05 | |
1784 | }; | |
1785 | ||
1786 | static struct hda_input_mux alc880_test_capture_source = { | |
ae6b813a | 1787 | .num_items = 7, |
2fa522be TI |
1788 | .items = { |
1789 | { "In-1", 0x0 }, | |
1790 | { "In-2", 0x1 }, | |
1791 | { "In-3", 0x2 }, | |
1792 | { "In-4", 0x3 }, | |
1793 | { "CD", 0x4 }, | |
ae6b813a TI |
1794 | { "Front", 0x5 }, |
1795 | { "Surround", 0x6 }, | |
2fa522be TI |
1796 | }, |
1797 | }; | |
1798 | ||
d2a6d7dc | 1799 | static struct hda_channel_mode alc880_test_modes[4] = { |
2fa522be | 1800 | { 2, NULL }, |
fd2c326d | 1801 | { 4, NULL }, |
2fa522be | 1802 | { 6, NULL }, |
fd2c326d | 1803 | { 8, NULL }, |
2fa522be TI |
1804 | }; |
1805 | ||
c8b6bf9b | 1806 | static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
2fa522be TI |
1807 | { |
1808 | static char *texts[] = { | |
1809 | "N/A", "Line Out", "HP Out", | |
1810 | "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%" | |
1811 | }; | |
1812 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
1813 | uinfo->count = 1; | |
1814 | uinfo->value.enumerated.items = 8; | |
1815 | if (uinfo->value.enumerated.item >= 8) | |
1816 | uinfo->value.enumerated.item = 7; | |
1817 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | |
1818 | return 0; | |
1819 | } | |
1820 | ||
c8b6bf9b | 1821 | static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
2fa522be TI |
1822 | { |
1823 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
1824 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
1825 | unsigned int pin_ctl, item = 0; | |
1826 | ||
1827 | pin_ctl = snd_hda_codec_read(codec, nid, 0, | |
1828 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | |
1829 | if (pin_ctl & AC_PINCTL_OUT_EN) { | |
1830 | if (pin_ctl & AC_PINCTL_HP_EN) | |
1831 | item = 2; | |
1832 | else | |
1833 | item = 1; | |
1834 | } else if (pin_ctl & AC_PINCTL_IN_EN) { | |
1835 | switch (pin_ctl & AC_PINCTL_VREFEN) { | |
1836 | case AC_PINCTL_VREF_HIZ: item = 3; break; | |
1837 | case AC_PINCTL_VREF_50: item = 4; break; | |
1838 | case AC_PINCTL_VREF_GRD: item = 5; break; | |
1839 | case AC_PINCTL_VREF_80: item = 6; break; | |
1840 | case AC_PINCTL_VREF_100: item = 7; break; | |
1841 | } | |
1842 | } | |
1843 | ucontrol->value.enumerated.item[0] = item; | |
1844 | return 0; | |
1845 | } | |
1846 | ||
c8b6bf9b | 1847 | static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
2fa522be TI |
1848 | { |
1849 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
1850 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
1851 | static unsigned int ctls[] = { | |
1852 | 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN, | |
1853 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ, | |
1854 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_50, | |
1855 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD, | |
1856 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_80, | |
1857 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_100, | |
1858 | }; | |
1859 | unsigned int old_ctl, new_ctl; | |
1860 | ||
1861 | old_ctl = snd_hda_codec_read(codec, nid, 0, | |
1862 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | |
1863 | new_ctl = ctls[ucontrol->value.enumerated.item[0]]; | |
1864 | if (old_ctl != new_ctl) { | |
1865 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl); | |
1866 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
1867 | ucontrol->value.enumerated.item[0] >= 3 ? 0xb080 : 0xb000); | |
1868 | return 1; | |
1869 | } | |
1870 | return 0; | |
1871 | } | |
1872 | ||
c8b6bf9b | 1873 | static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
2fa522be TI |
1874 | { |
1875 | static char *texts[] = { | |
1876 | "Front", "Surround", "CLFE", "Side" | |
1877 | }; | |
1878 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
1879 | uinfo->count = 1; | |
1880 | uinfo->value.enumerated.items = 4; | |
1881 | if (uinfo->value.enumerated.item >= 4) | |
1882 | uinfo->value.enumerated.item = 3; | |
1883 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | |
1884 | return 0; | |
1885 | } | |
1886 | ||
c8b6bf9b | 1887 | static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
2fa522be TI |
1888 | { |
1889 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
1890 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
1891 | unsigned int sel; | |
1892 | ||
1893 | sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0); | |
1894 | ucontrol->value.enumerated.item[0] = sel & 3; | |
1895 | return 0; | |
1896 | } | |
1897 | ||
c8b6bf9b | 1898 | static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
2fa522be TI |
1899 | { |
1900 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
1901 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
1902 | unsigned int sel; | |
1903 | ||
1904 | sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3; | |
1905 | if (ucontrol->value.enumerated.item[0] != sel) { | |
1906 | sel = ucontrol->value.enumerated.item[0] & 3; | |
1907 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel); | |
1908 | return 1; | |
1909 | } | |
1910 | return 0; | |
1911 | } | |
1912 | ||
1913 | #define PIN_CTL_TEST(xname,nid) { \ | |
1914 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
1915 | .name = xname, \ | |
1916 | .info = alc_test_pin_ctl_info, \ | |
1917 | .get = alc_test_pin_ctl_get, \ | |
1918 | .put = alc_test_pin_ctl_put, \ | |
1919 | .private_value = nid \ | |
1920 | } | |
1921 | ||
1922 | #define PIN_SRC_TEST(xname,nid) { \ | |
1923 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
1924 | .name = xname, \ | |
1925 | .info = alc_test_pin_src_info, \ | |
1926 | .get = alc_test_pin_src_get, \ | |
1927 | .put = alc_test_pin_src_put, \ | |
1928 | .private_value = nid \ | |
1929 | } | |
1930 | ||
c8b6bf9b | 1931 | static struct snd_kcontrol_new alc880_test_mixer[] = { |
05acb863 TI |
1932 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
1933 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1934 | HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT), | |
1935 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
985be54b TI |
1936 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
1937 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
1938 | HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT), | |
1939 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
2fa522be TI |
1940 | PIN_CTL_TEST("Front Pin Mode", 0x14), |
1941 | PIN_CTL_TEST("Surround Pin Mode", 0x15), | |
1942 | PIN_CTL_TEST("CLFE Pin Mode", 0x16), | |
1943 | PIN_CTL_TEST("Side Pin Mode", 0x17), | |
1944 | PIN_CTL_TEST("In-1 Pin Mode", 0x18), | |
1945 | PIN_CTL_TEST("In-2 Pin Mode", 0x19), | |
1946 | PIN_CTL_TEST("In-3 Pin Mode", 0x1a), | |
1947 | PIN_CTL_TEST("In-4 Pin Mode", 0x1b), | |
1948 | PIN_SRC_TEST("In-1 Pin Source", 0x18), | |
1949 | PIN_SRC_TEST("In-2 Pin Source", 0x19), | |
1950 | PIN_SRC_TEST("In-3 Pin Source", 0x1a), | |
1951 | PIN_SRC_TEST("In-4 Pin Source", 0x1b), | |
1952 | HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1953 | HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1954 | HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1955 | HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1956 | HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT), | |
1957 | HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT), | |
1958 | HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT), | |
1959 | HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT), | |
1960 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT), | |
1961 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT), | |
2fa522be TI |
1962 | { |
1963 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1964 | .name = "Channel Mode", | |
df694daa KY |
1965 | .info = alc_ch_mode_info, |
1966 | .get = alc_ch_mode_get, | |
1967 | .put = alc_ch_mode_put, | |
2fa522be TI |
1968 | }, |
1969 | { } /* end */ | |
1970 | }; | |
1971 | ||
1972 | static struct hda_verb alc880_test_init_verbs[] = { | |
1973 | /* Unmute inputs of 0x0c - 0x0f */ | |
05acb863 TI |
1974 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1975 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
1976 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
1977 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
1978 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
1979 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
1980 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
1981 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2fa522be | 1982 | /* Vol output for 0x0c-0x0f */ |
05acb863 TI |
1983 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
1984 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1985 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1986 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2fa522be | 1987 | /* Set output pins 0x14-0x17 */ |
05acb863 TI |
1988 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1989 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1990 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1991 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2fa522be | 1992 | /* Unmute output pins 0x14-0x17 */ |
05acb863 TI |
1993 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1994 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1995 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1996 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2fa522be | 1997 | /* Set input pins 0x18-0x1c */ |
16ded525 TI |
1998 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1999 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
05acb863 TI |
2000 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
2001 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2002 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2fa522be | 2003 | /* Mute input pins 0x18-0x1b */ |
05acb863 TI |
2004 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
2005 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2006 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2007 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
71fe7b82 | 2008 | /* ADC set up */ |
05acb863 | 2009 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 2010 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 | 2011 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 2012 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 | 2013 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 2014 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
2015 | /* Analog input/passthru */ |
2016 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
2017 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2018 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
2019 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
2020 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
2fa522be TI |
2021 | { } |
2022 | }; | |
2023 | #endif | |
2024 | ||
1da177e4 LT |
2025 | /* |
2026 | */ | |
2027 | ||
2028 | static struct hda_board_config alc880_cfg_tbl[] = { | |
2029 | /* Back 3 jack, front 2 jack */ | |
2030 | { .modelname = "3stack", .config = ALC880_3ST }, | |
7291548d TI |
2031 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST }, |
2032 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST }, | |
2033 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST }, | |
2034 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST }, | |
2035 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST }, | |
2036 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST }, | |
2037 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST }, | |
2038 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST }, | |
2039 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST }, | |
2040 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST }, | |
2041 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST }, | |
2042 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST }, | |
2043 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST }, | |
2044 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST }, | |
2045 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST }, | |
2046 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST }, | |
2047 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST }, | |
2048 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST }, | |
2049 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST }, | |
2050 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST }, | |
2051 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST }, | |
2052 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST }, | |
2053 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST }, | |
2054 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST }, | |
2055 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST }, | |
2056 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST }, | |
2057 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST }, | |
2058 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST }, | |
2059 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST }, | |
2060 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST }, | |
2061 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST }, | |
2062 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST }, | |
df694daa KY |
2063 | /* TCL S700 */ |
2064 | { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 }, | |
1da177e4 LT |
2065 | |
2066 | /* Back 3 jack, front 2 jack (Internal add Aux-In) */ | |
7291548d | 2067 | { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST }, |
16ded525 | 2068 | { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST }, |
0ca21611 | 2069 | { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST }, |
1da177e4 LT |
2070 | |
2071 | /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */ | |
2072 | { .modelname = "3stack-digout", .config = ALC880_3ST_DIG }, | |
7291548d | 2073 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG }, |
5a47fe3c | 2074 | { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG }, |
df694daa KY |
2075 | /* Clevo m520G NB */ |
2076 | { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520, .config = ALC880_CLEVO }, | |
1da177e4 LT |
2077 | |
2078 | /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/ | |
7291548d TI |
2079 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG }, |
2080 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG }, | |
2081 | { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG }, | |
1da177e4 LT |
2082 | |
2083 | /* Back 5 jack, front 2 jack */ | |
2084 | { .modelname = "5stack", .config = ALC880_5ST }, | |
7291548d TI |
2085 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST }, |
2086 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST }, | |
2087 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST }, | |
2088 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST }, | |
16ded525 | 2089 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST }, |
1da177e4 LT |
2090 | |
2091 | /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */ | |
2092 | { .modelname = "5stack-digout", .config = ALC880_5ST_DIG }, | |
7291548d TI |
2093 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG }, |
2094 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG }, | |
2095 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG }, | |
2096 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG }, | |
2097 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG }, | |
2098 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG }, | |
2099 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG }, | |
2100 | { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG }, | |
16ded525 | 2101 | { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG }, |
ede3531e TI |
2102 | { .pci_subvendor = 0xa0a0, .pci_subdevice = 0x0560, |
2103 | .config = ALC880_5ST_DIG }, /* Aopen i915GMm-HFS */ | |
7a318a70 | 2104 | /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */ |
16ded525 | 2105 | { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG }, |
b0af0de5 TI |
2106 | /* note subvendor = 0 below */ |
2107 | /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */ | |
1da177e4 LT |
2108 | |
2109 | { .modelname = "w810", .config = ALC880_W810 }, | |
7291548d | 2110 | { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 }, |
1da177e4 | 2111 | |
dfc0ff62 | 2112 | { .modelname = "z71v", .config = ALC880_Z71V }, |
7291548d | 2113 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V }, |
dfc0ff62 | 2114 | |
b6482d48 | 2115 | { .modelname = "6stack", .config = ALC880_6ST }, |
7632c7b4 | 2116 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */ |
df694daa | 2117 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST }, |
7a318a70 | 2118 | { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */ |
bae2bdb3 | 2119 | { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */ |
b6482d48 TI |
2120 | |
2121 | { .modelname = "6stack-digout", .config = ALC880_6ST_DIG }, | |
16ded525 TI |
2122 | { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG }, |
2123 | { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG }, | |
2124 | { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG }, | |
2125 | { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG }, | |
df694daa KY |
2126 | { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG }, |
2127 | { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG }, | |
2128 | { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG }, | |
2129 | { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG }, | |
041dec01 | 2130 | { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */ |
a12606cf | 2131 | { .pci_subvendor = 0x1509, .pci_subdevice = 0x925d, .config = ALC880_6ST_DIG }, /* FIC P4M-915GD1 */ |
16ded525 | 2132 | |
e9edcee0 | 2133 | { .modelname = "asus", .config = ALC880_ASUS }, |
16ded525 TI |
2134 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG }, |
2135 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG }, | |
2136 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG }, | |
2137 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG }, | |
8648811f | 2138 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG }, |
16ded525 TI |
2139 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS }, |
2140 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG }, | |
2141 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS }, | |
2142 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG }, | |
2143 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS }, | |
2144 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V }, | |
84f3430c | 2145 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x8181, .config = ALC880_ASUS_DIG }, /* ASUS P4GPL-X */ |
df694daa | 2146 | { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 }, |
16ded525 TI |
2147 | |
2148 | { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG }, | |
2149 | { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG }, | |
2150 | ||
2151 | { .modelname = "F1734", .config = ALC880_F1734 }, | |
2152 | { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 }, | |
df694daa | 2153 | { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 }, |
16ded525 | 2154 | |
ae6b813a TI |
2155 | { .modelname = "lg", .config = ALC880_LG }, |
2156 | { .pci_subvendor = 0x1854, .pci_subdevice = 0x003b, .config = ALC880_LG }, | |
2157 | ||
d681518a TI |
2158 | { .modelname = "lg-lw", .config = ALC880_LG_LW }, |
2159 | { .pci_subvendor = 0x1854, .pci_subdevice = 0x0018, .config = ALC880_LG_LW }, | |
2160 | ||
2fa522be TI |
2161 | #ifdef CONFIG_SND_DEBUG |
2162 | { .modelname = "test", .config = ALC880_TEST }, | |
2163 | #endif | |
df694daa | 2164 | { .modelname = "auto", .config = ALC880_AUTO }, |
2fa522be | 2165 | |
1da177e4 LT |
2166 | {} |
2167 | }; | |
2168 | ||
16ded525 | 2169 | /* |
df694daa | 2170 | * ALC880 codec presets |
16ded525 | 2171 | */ |
16ded525 TI |
2172 | static struct alc_config_preset alc880_presets[] = { |
2173 | [ALC880_3ST] = { | |
e9edcee0 TI |
2174 | .mixers = { alc880_three_stack_mixer }, |
2175 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs }, | |
16ded525 | 2176 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
16ded525 | 2177 | .dac_nids = alc880_dac_nids, |
16ded525 TI |
2178 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
2179 | .channel_mode = alc880_threestack_modes, | |
2180 | .input_mux = &alc880_capture_source, | |
2181 | }, | |
2182 | [ALC880_3ST_DIG] = { | |
e9edcee0 TI |
2183 | .mixers = { alc880_three_stack_mixer }, |
2184 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs }, | |
16ded525 | 2185 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
16ded525 TI |
2186 | .dac_nids = alc880_dac_nids, |
2187 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
2188 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
2189 | .channel_mode = alc880_threestack_modes, | |
2190 | .input_mux = &alc880_capture_source, | |
2191 | }, | |
df694daa KY |
2192 | [ALC880_TCL_S700] = { |
2193 | .mixers = { alc880_tcl_s700_mixer }, | |
2194 | .init_verbs = { alc880_volume_init_verbs, | |
2195 | alc880_pin_tcl_S700_init_verbs, | |
2196 | alc880_gpio2_init_verbs }, | |
2197 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
2198 | .dac_nids = alc880_dac_nids, | |
2199 | .hp_nid = 0x03, | |
2200 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
2201 | .channel_mode = alc880_2_jack_modes, | |
2202 | .input_mux = &alc880_capture_source, | |
2203 | }, | |
16ded525 | 2204 | [ALC880_5ST] = { |
e9edcee0 TI |
2205 | .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer}, |
2206 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs }, | |
16ded525 TI |
2207 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
2208 | .dac_nids = alc880_dac_nids, | |
16ded525 TI |
2209 | .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), |
2210 | .channel_mode = alc880_fivestack_modes, | |
2211 | .input_mux = &alc880_capture_source, | |
2212 | }, | |
2213 | [ALC880_5ST_DIG] = { | |
e9edcee0 TI |
2214 | .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer }, |
2215 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs }, | |
16ded525 TI |
2216 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
2217 | .dac_nids = alc880_dac_nids, | |
2218 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
2219 | .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), |
2220 | .channel_mode = alc880_fivestack_modes, | |
2221 | .input_mux = &alc880_capture_source, | |
2222 | }, | |
b6482d48 TI |
2223 | [ALC880_6ST] = { |
2224 | .mixers = { alc880_six_stack_mixer }, | |
2225 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs }, | |
2226 | .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), | |
2227 | .dac_nids = alc880_6st_dac_nids, | |
2228 | .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), | |
2229 | .channel_mode = alc880_sixstack_modes, | |
2230 | .input_mux = &alc880_6stack_capture_source, | |
2231 | }, | |
16ded525 | 2232 | [ALC880_6ST_DIG] = { |
e9edcee0 TI |
2233 | .mixers = { alc880_six_stack_mixer }, |
2234 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs }, | |
16ded525 TI |
2235 | .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), |
2236 | .dac_nids = alc880_6st_dac_nids, | |
2237 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
2238 | .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), |
2239 | .channel_mode = alc880_sixstack_modes, | |
2240 | .input_mux = &alc880_6stack_capture_source, | |
2241 | }, | |
2242 | [ALC880_W810] = { | |
e9edcee0 | 2243 | .mixers = { alc880_w810_base_mixer }, |
b0af0de5 TI |
2244 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs, |
2245 | alc880_gpio2_init_verbs }, | |
16ded525 TI |
2246 | .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids), |
2247 | .dac_nids = alc880_w810_dac_nids, | |
2248 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
2249 | .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), |
2250 | .channel_mode = alc880_w810_modes, | |
2251 | .input_mux = &alc880_capture_source, | |
2252 | }, | |
2253 | [ALC880_Z71V] = { | |
e9edcee0 | 2254 | .mixers = { alc880_z71v_mixer }, |
b0af0de5 | 2255 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs }, |
16ded525 TI |
2256 | .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids), |
2257 | .dac_nids = alc880_z71v_dac_nids, | |
2258 | .dig_out_nid = ALC880_DIGOUT_NID, | |
2259 | .hp_nid = 0x03, | |
e9edcee0 TI |
2260 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), |
2261 | .channel_mode = alc880_2_jack_modes, | |
16ded525 TI |
2262 | .input_mux = &alc880_capture_source, |
2263 | }, | |
2264 | [ALC880_F1734] = { | |
e9edcee0 TI |
2265 | .mixers = { alc880_f1734_mixer }, |
2266 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs }, | |
2267 | .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids), | |
2268 | .dac_nids = alc880_f1734_dac_nids, | |
2269 | .hp_nid = 0x02, | |
2270 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
2271 | .channel_mode = alc880_2_jack_modes, | |
16ded525 TI |
2272 | .input_mux = &alc880_capture_source, |
2273 | }, | |
2274 | [ALC880_ASUS] = { | |
e9edcee0 TI |
2275 | .mixers = { alc880_asus_mixer }, |
2276 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, | |
2277 | alc880_gpio1_init_verbs }, | |
2278 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
2279 | .dac_nids = alc880_asus_dac_nids, | |
2280 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), | |
2281 | .channel_mode = alc880_asus_modes, | |
16ded525 TI |
2282 | .input_mux = &alc880_capture_source, |
2283 | }, | |
2284 | [ALC880_ASUS_DIG] = { | |
e9edcee0 TI |
2285 | .mixers = { alc880_asus_mixer }, |
2286 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, | |
2287 | alc880_gpio1_init_verbs }, | |
2288 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
2289 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 2290 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
2291 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
2292 | .channel_mode = alc880_asus_modes, | |
16ded525 TI |
2293 | .input_mux = &alc880_capture_source, |
2294 | }, | |
df694daa KY |
2295 | [ALC880_ASUS_DIG2] = { |
2296 | .mixers = { alc880_asus_mixer }, | |
2297 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, | |
2298 | alc880_gpio2_init_verbs }, /* use GPIO2 */ | |
2299 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
2300 | .dac_nids = alc880_asus_dac_nids, | |
2301 | .dig_out_nid = ALC880_DIGOUT_NID, | |
2302 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), | |
2303 | .channel_mode = alc880_asus_modes, | |
2304 | .input_mux = &alc880_capture_source, | |
2305 | }, | |
16ded525 | 2306 | [ALC880_ASUS_W1V] = { |
e9edcee0 TI |
2307 | .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer }, |
2308 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, | |
2309 | alc880_gpio1_init_verbs }, | |
2310 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
2311 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 2312 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
2313 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
2314 | .channel_mode = alc880_asus_modes, | |
16ded525 TI |
2315 | .input_mux = &alc880_capture_source, |
2316 | }, | |
2317 | [ALC880_UNIWILL_DIG] = { | |
3c10a9d9 | 2318 | .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer }, |
e9edcee0 TI |
2319 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs }, |
2320 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
2321 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 2322 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
2323 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
2324 | .channel_mode = alc880_asus_modes, | |
16ded525 TI |
2325 | .input_mux = &alc880_capture_source, |
2326 | }, | |
df694daa KY |
2327 | [ALC880_CLEVO] = { |
2328 | .mixers = { alc880_three_stack_mixer }, | |
2329 | .init_verbs = { alc880_volume_init_verbs, | |
2330 | alc880_pin_clevo_init_verbs }, | |
2331 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
2332 | .dac_nids = alc880_dac_nids, | |
2333 | .hp_nid = 0x03, | |
2334 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
2335 | .channel_mode = alc880_threestack_modes, | |
2336 | .input_mux = &alc880_capture_source, | |
2337 | }, | |
ae6b813a TI |
2338 | [ALC880_LG] = { |
2339 | .mixers = { alc880_lg_mixer }, | |
2340 | .init_verbs = { alc880_volume_init_verbs, | |
2341 | alc880_lg_init_verbs }, | |
2342 | .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids), | |
2343 | .dac_nids = alc880_lg_dac_nids, | |
2344 | .dig_out_nid = ALC880_DIGOUT_NID, | |
2345 | .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes), | |
2346 | .channel_mode = alc880_lg_ch_modes, | |
2347 | .input_mux = &alc880_lg_capture_source, | |
2348 | .unsol_event = alc880_lg_unsol_event, | |
2349 | .init_hook = alc880_lg_automute, | |
2350 | }, | |
d681518a TI |
2351 | [ALC880_LG_LW] = { |
2352 | .mixers = { alc880_lg_lw_mixer }, | |
2353 | .init_verbs = { alc880_volume_init_verbs, | |
2354 | alc880_lg_lw_init_verbs }, | |
2355 | .num_dacs = 1, | |
2356 | .dac_nids = alc880_dac_nids, | |
2357 | .dig_out_nid = ALC880_DIGOUT_NID, | |
2358 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
2359 | .channel_mode = alc880_2_jack_modes, | |
2360 | .input_mux = &alc880_lg_lw_capture_source, | |
2361 | .unsol_event = alc880_lg_lw_unsol_event, | |
2362 | .init_hook = alc880_lg_lw_automute, | |
2363 | }, | |
16ded525 TI |
2364 | #ifdef CONFIG_SND_DEBUG |
2365 | [ALC880_TEST] = { | |
e9edcee0 TI |
2366 | .mixers = { alc880_test_mixer }, |
2367 | .init_verbs = { alc880_test_init_verbs }, | |
16ded525 TI |
2368 | .num_dacs = ARRAY_SIZE(alc880_test_dac_nids), |
2369 | .dac_nids = alc880_test_dac_nids, | |
2370 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
2371 | .num_channel_mode = ARRAY_SIZE(alc880_test_modes), |
2372 | .channel_mode = alc880_test_modes, | |
2373 | .input_mux = &alc880_test_capture_source, | |
2374 | }, | |
2375 | #endif | |
2376 | }; | |
2377 | ||
e9edcee0 TI |
2378 | /* |
2379 | * Automatic parse of I/O pins from the BIOS configuration | |
2380 | */ | |
2381 | ||
2382 | #define NUM_CONTROL_ALLOC 32 | |
2383 | #define NUM_VERB_ALLOC 32 | |
2384 | ||
2385 | enum { | |
2386 | ALC_CTL_WIDGET_VOL, | |
2387 | ALC_CTL_WIDGET_MUTE, | |
2388 | ALC_CTL_BIND_MUTE, | |
2389 | }; | |
c8b6bf9b | 2390 | static struct snd_kcontrol_new alc880_control_templates[] = { |
e9edcee0 TI |
2391 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
2392 | HDA_CODEC_MUTE(NULL, 0, 0, 0), | |
985be54b | 2393 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
e9edcee0 TI |
2394 | }; |
2395 | ||
2396 | /* add dynamic controls */ | |
2397 | static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val) | |
2398 | { | |
c8b6bf9b | 2399 | struct snd_kcontrol_new *knew; |
e9edcee0 TI |
2400 | |
2401 | if (spec->num_kctl_used >= spec->num_kctl_alloc) { | |
2402 | int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; | |
2403 | ||
2404 | knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */ | |
2405 | if (! knew) | |
2406 | return -ENOMEM; | |
2407 | if (spec->kctl_alloc) { | |
2408 | memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc); | |
2409 | kfree(spec->kctl_alloc); | |
2410 | } | |
2411 | spec->kctl_alloc = knew; | |
2412 | spec->num_kctl_alloc = num; | |
2413 | } | |
2414 | ||
2415 | knew = &spec->kctl_alloc[spec->num_kctl_used]; | |
2416 | *knew = alc880_control_templates[type]; | |
543537bd | 2417 | knew->name = kstrdup(name, GFP_KERNEL); |
e9edcee0 TI |
2418 | if (! knew->name) |
2419 | return -ENOMEM; | |
2420 | knew->private_value = val; | |
2421 | spec->num_kctl_used++; | |
2422 | return 0; | |
2423 | } | |
2424 | ||
2425 | #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17) | |
2426 | #define alc880_fixed_pin_idx(nid) ((nid) - 0x14) | |
2427 | #define alc880_is_multi_pin(nid) ((nid) >= 0x18) | |
2428 | #define alc880_multi_pin_idx(nid) ((nid) - 0x18) | |
2429 | #define alc880_is_input_pin(nid) ((nid) >= 0x18) | |
2430 | #define alc880_input_pin_idx(nid) ((nid) - 0x18) | |
2431 | #define alc880_idx_to_dac(nid) ((nid) + 0x02) | |
2432 | #define alc880_dac_to_idx(nid) ((nid) - 0x02) | |
2433 | #define alc880_idx_to_mixer(nid) ((nid) + 0x0c) | |
2434 | #define alc880_idx_to_selector(nid) ((nid) + 0x10) | |
2435 | #define ALC880_PIN_CD_NID 0x1c | |
2436 | ||
2437 | /* fill in the dac_nids table from the parsed pin configuration */ | |
2438 | static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg) | |
2439 | { | |
2440 | hda_nid_t nid; | |
2441 | int assigned[4]; | |
2442 | int i, j; | |
2443 | ||
2444 | memset(assigned, 0, sizeof(assigned)); | |
b0af0de5 | 2445 | spec->multiout.dac_nids = spec->private_dac_nids; |
e9edcee0 TI |
2446 | |
2447 | /* check the pins hardwired to audio widget */ | |
2448 | for (i = 0; i < cfg->line_outs; i++) { | |
2449 | nid = cfg->line_out_pins[i]; | |
2450 | if (alc880_is_fixed_pin(nid)) { | |
2451 | int idx = alc880_fixed_pin_idx(nid); | |
5014f193 | 2452 | spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx); |
e9edcee0 TI |
2453 | assigned[idx] = 1; |
2454 | } | |
2455 | } | |
2456 | /* left pins can be connect to any audio widget */ | |
2457 | for (i = 0; i < cfg->line_outs; i++) { | |
2458 | nid = cfg->line_out_pins[i]; | |
2459 | if (alc880_is_fixed_pin(nid)) | |
2460 | continue; | |
2461 | /* search for an empty channel */ | |
2462 | for (j = 0; j < cfg->line_outs; j++) { | |
2463 | if (! assigned[j]) { | |
2464 | spec->multiout.dac_nids[i] = alc880_idx_to_dac(j); | |
2465 | assigned[j] = 1; | |
2466 | break; | |
2467 | } | |
2468 | } | |
2469 | } | |
2470 | spec->multiout.num_dacs = cfg->line_outs; | |
2471 | return 0; | |
2472 | } | |
2473 | ||
2474 | /* add playback controls from the parsed DAC table */ | |
df694daa KY |
2475 | static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, |
2476 | const struct auto_pin_cfg *cfg) | |
e9edcee0 TI |
2477 | { |
2478 | char name[32]; | |
2479 | static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; | |
2480 | hda_nid_t nid; | |
2481 | int i, err; | |
2482 | ||
2483 | for (i = 0; i < cfg->line_outs; i++) { | |
2484 | if (! spec->multiout.dac_nids[i]) | |
2485 | continue; | |
2486 | nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i])); | |
2487 | if (i == 2) { | |
2488 | /* Center/LFE */ | |
2489 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume", | |
2490 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0) | |
2491 | return err; | |
2492 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume", | |
2493 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) | |
2494 | return err; | |
2495 | if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch", | |
2496 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0) | |
2497 | return err; | |
2498 | if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch", | |
2499 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0) | |
2500 | return err; | |
2501 | } else { | |
2502 | sprintf(name, "%s Playback Volume", chname[i]); | |
2503 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
2504 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) | |
2505 | return err; | |
2506 | sprintf(name, "%s Playback Switch", chname[i]); | |
2507 | if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, | |
2508 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0) | |
2509 | return err; | |
2510 | } | |
2511 | } | |
e9edcee0 TI |
2512 | return 0; |
2513 | } | |
2514 | ||
8d88bc3d TI |
2515 | /* add playback controls for speaker and HP outputs */ |
2516 | static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, | |
2517 | const char *pfx) | |
e9edcee0 TI |
2518 | { |
2519 | hda_nid_t nid; | |
2520 | int err; | |
8d88bc3d | 2521 | char name[32]; |
e9edcee0 TI |
2522 | |
2523 | if (! pin) | |
2524 | return 0; | |
2525 | ||
2526 | if (alc880_is_fixed_pin(pin)) { | |
2527 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
82bc955f TI |
2528 | /* specify the DAC as the extra output */ |
2529 | if (! spec->multiout.hp_nid) | |
e9edcee0 | 2530 | spec->multiout.hp_nid = nid; |
82bc955f TI |
2531 | else |
2532 | spec->multiout.extra_out_nid[0] = nid; | |
e9edcee0 TI |
2533 | /* control HP volume/switch on the output mixer amp */ |
2534 | nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin)); | |
8d88bc3d TI |
2535 | sprintf(name, "%s Playback Volume", pfx); |
2536 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
e9edcee0 TI |
2537 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
2538 | return err; | |
8d88bc3d TI |
2539 | sprintf(name, "%s Playback Switch", pfx); |
2540 | if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, | |
e9edcee0 TI |
2541 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0) |
2542 | return err; | |
2543 | } else if (alc880_is_multi_pin(pin)) { | |
2544 | /* set manual connection */ | |
e9edcee0 | 2545 | /* we have only a switch on HP-out PIN */ |
8d88bc3d TI |
2546 | sprintf(name, "%s Playback Switch", pfx); |
2547 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | |
e9edcee0 TI |
2548 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0) |
2549 | return err; | |
2550 | } | |
2551 | return 0; | |
2552 | } | |
2553 | ||
2554 | /* create input playback/capture controls for the given pin */ | |
df694daa KY |
2555 | static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname, |
2556 | int idx, hda_nid_t mix_nid) | |
e9edcee0 TI |
2557 | { |
2558 | char name[32]; | |
df694daa | 2559 | int err; |
e9edcee0 TI |
2560 | |
2561 | sprintf(name, "%s Playback Volume", ctlname); | |
e9edcee0 | 2562 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
df694daa | 2563 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0) |
e9edcee0 TI |
2564 | return err; |
2565 | sprintf(name, "%s Playback Switch", ctlname); | |
2566 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | |
df694daa | 2567 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0) |
e9edcee0 TI |
2568 | return err; |
2569 | return 0; | |
2570 | } | |
2571 | ||
2572 | /* create playback/capture controls for input pins */ | |
df694daa KY |
2573 | static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, |
2574 | const struct auto_pin_cfg *cfg) | |
e9edcee0 | 2575 | { |
e9edcee0 | 2576 | struct hda_input_mux *imux = &spec->private_imux; |
df694daa | 2577 | int i, err, idx; |
e9edcee0 TI |
2578 | |
2579 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
2580 | if (alc880_is_input_pin(cfg->input_pins[i])) { | |
df694daa | 2581 | idx = alc880_input_pin_idx(cfg->input_pins[i]); |
4a471b7d TI |
2582 | err = new_analog_input(spec, cfg->input_pins[i], |
2583 | auto_pin_cfg_labels[i], | |
df694daa | 2584 | idx, 0x0b); |
e9edcee0 TI |
2585 | if (err < 0) |
2586 | return err; | |
4a471b7d | 2587 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
e9edcee0 TI |
2588 | imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]); |
2589 | imux->num_items++; | |
2590 | } | |
2591 | } | |
2592 | return 0; | |
2593 | } | |
2594 | ||
df694daa KY |
2595 | static void alc880_auto_set_output_and_unmute(struct hda_codec *codec, |
2596 | hda_nid_t nid, int pin_type, | |
e9edcee0 TI |
2597 | int dac_idx) |
2598 | { | |
2599 | /* set as output */ | |
2600 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); | |
2601 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); | |
2602 | /* need the manual connection? */ | |
2603 | if (alc880_is_multi_pin(nid)) { | |
2604 | struct alc_spec *spec = codec->spec; | |
2605 | int idx = alc880_multi_pin_idx(nid); | |
2606 | snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, | |
2607 | AC_VERB_SET_CONNECT_SEL, | |
2608 | alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); | |
2609 | } | |
2610 | } | |
2611 | ||
2612 | static void alc880_auto_init_multi_out(struct hda_codec *codec) | |
2613 | { | |
2614 | struct alc_spec *spec = codec->spec; | |
2615 | int i; | |
2616 | ||
2617 | for (i = 0; i < spec->autocfg.line_outs; i++) { | |
2618 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
2619 | alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); | |
2620 | } | |
2621 | } | |
2622 | ||
8d88bc3d | 2623 | static void alc880_auto_init_extra_out(struct hda_codec *codec) |
e9edcee0 TI |
2624 | { |
2625 | struct alc_spec *spec = codec->spec; | |
2626 | hda_nid_t pin; | |
2627 | ||
82bc955f | 2628 | pin = spec->autocfg.speaker_pins[0]; |
8d88bc3d TI |
2629 | if (pin) /* connect to front */ |
2630 | alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
e9edcee0 TI |
2631 | pin = spec->autocfg.hp_pin; |
2632 | if (pin) /* connect to front */ | |
2633 | alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
2634 | } | |
2635 | ||
2636 | static void alc880_auto_init_analog_input(struct hda_codec *codec) | |
2637 | { | |
2638 | struct alc_spec *spec = codec->spec; | |
2639 | int i; | |
2640 | ||
2641 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
2642 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
2643 | if (alc880_is_input_pin(nid)) { | |
2644 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
2645 | i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); | |
2646 | if (nid != ALC880_PIN_CD_NID) | |
2647 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
2648 | AMP_OUT_MUTE); | |
2649 | } | |
2650 | } | |
2651 | } | |
2652 | ||
2653 | /* parse the BIOS configuration and set up the alc_spec */ | |
2654 | /* return 1 if successful, 0 if the proper config is not found, or a negative error code */ | |
2655 | static int alc880_parse_auto_config(struct hda_codec *codec) | |
2656 | { | |
2657 | struct alc_spec *spec = codec->spec; | |
2658 | int err; | |
df694daa | 2659 | static hda_nid_t alc880_ignore[] = { 0x1d, 0 }; |
e9edcee0 | 2660 | |
df694daa KY |
2661 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
2662 | alc880_ignore)) < 0) | |
e9edcee0 | 2663 | return err; |
82bc955f | 2664 | if (! spec->autocfg.line_outs) |
e9edcee0 | 2665 | return 0; /* can't find valid BIOS pin config */ |
df694daa KY |
2666 | |
2667 | if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 || | |
2668 | (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || | |
82bc955f TI |
2669 | (err = alc880_auto_create_extra_out(spec, |
2670 | spec->autocfg.speaker_pins[0], | |
8d88bc3d | 2671 | "Speaker")) < 0 || |
82bc955f | 2672 | (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pin, |
8d88bc3d | 2673 | "Headphone")) < 0 || |
e9edcee0 TI |
2674 | (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) |
2675 | return err; | |
2676 | ||
2677 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
2678 | ||
2679 | if (spec->autocfg.dig_out_pin) | |
2680 | spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; | |
2681 | if (spec->autocfg.dig_in_pin) | |
2682 | spec->dig_in_nid = ALC880_DIGIN_NID; | |
2683 | ||
2684 | if (spec->kctl_alloc) | |
2685 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
2686 | ||
2687 | spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs; | |
2688 | ||
2689 | spec->input_mux = &spec->private_imux; | |
2690 | ||
2691 | return 1; | |
2692 | } | |
2693 | ||
ae6b813a TI |
2694 | /* additional initialization for auto-configuration model */ |
2695 | static void alc880_auto_init(struct hda_codec *codec) | |
e9edcee0 | 2696 | { |
e9edcee0 | 2697 | alc880_auto_init_multi_out(codec); |
8d88bc3d | 2698 | alc880_auto_init_extra_out(codec); |
e9edcee0 | 2699 | alc880_auto_init_analog_input(codec); |
e9edcee0 TI |
2700 | } |
2701 | ||
2702 | /* | |
2703 | * OK, here we have finally the patch for ALC880 | |
2704 | */ | |
2705 | ||
1da177e4 LT |
2706 | static int patch_alc880(struct hda_codec *codec) |
2707 | { | |
2708 | struct alc_spec *spec; | |
2709 | int board_config; | |
df694daa | 2710 | int err; |
1da177e4 | 2711 | |
e560d8d8 | 2712 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
1da177e4 LT |
2713 | if (spec == NULL) |
2714 | return -ENOMEM; | |
2715 | ||
2716 | codec->spec = spec; | |
2717 | ||
2718 | board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl); | |
16ded525 | 2719 | if (board_config < 0 || board_config >= ALC880_MODEL_LAST) { |
e9edcee0 TI |
2720 | printk(KERN_INFO "hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n"); |
2721 | board_config = ALC880_AUTO; | |
1da177e4 | 2722 | } |
1da177e4 | 2723 | |
e9edcee0 TI |
2724 | if (board_config == ALC880_AUTO) { |
2725 | /* automatic parse from the BIOS config */ | |
2726 | err = alc880_parse_auto_config(codec); | |
2727 | if (err < 0) { | |
2728 | alc_free(codec); | |
2729 | return err; | |
2730 | } else if (! err) { | |
2731 | printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 3-stack mode...\n"); | |
2732 | board_config = ALC880_3ST; | |
2733 | } | |
1da177e4 LT |
2734 | } |
2735 | ||
df694daa KY |
2736 | if (board_config != ALC880_AUTO) |
2737 | setup_preset(spec, &alc880_presets[board_config]); | |
1da177e4 LT |
2738 | |
2739 | spec->stream_name_analog = "ALC880 Analog"; | |
2740 | spec->stream_analog_playback = &alc880_pcm_analog_playback; | |
2741 | spec->stream_analog_capture = &alc880_pcm_analog_capture; | |
2742 | ||
2743 | spec->stream_name_digital = "ALC880 Digital"; | |
2744 | spec->stream_digital_playback = &alc880_pcm_digital_playback; | |
2745 | spec->stream_digital_capture = &alc880_pcm_digital_capture; | |
2746 | ||
e9edcee0 TI |
2747 | if (! spec->adc_nids && spec->input_mux) { |
2748 | /* check whether NID 0x07 is valid */ | |
54d17403 | 2749 | unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); |
e9edcee0 TI |
2750 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ |
2751 | if (wcap != AC_WID_AUD_IN) { | |
2752 | spec->adc_nids = alc880_adc_nids_alt; | |
2753 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); | |
2754 | spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer; | |
2755 | spec->num_mixers++; | |
2756 | } else { | |
2757 | spec->adc_nids = alc880_adc_nids; | |
2758 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids); | |
2759 | spec->mixers[spec->num_mixers] = alc880_capture_mixer; | |
2760 | spec->num_mixers++; | |
2761 | } | |
2762 | } | |
1da177e4 LT |
2763 | |
2764 | codec->patch_ops = alc_patch_ops; | |
e9edcee0 | 2765 | if (board_config == ALC880_AUTO) |
ae6b813a | 2766 | spec->init_hook = alc880_auto_init; |
1da177e4 LT |
2767 | |
2768 | return 0; | |
2769 | } | |
2770 | ||
e9edcee0 | 2771 | |
1da177e4 LT |
2772 | /* |
2773 | * ALC260 support | |
2774 | */ | |
2775 | ||
e9edcee0 TI |
2776 | static hda_nid_t alc260_dac_nids[1] = { |
2777 | /* front */ | |
2778 | 0x02, | |
2779 | }; | |
2780 | ||
2781 | static hda_nid_t alc260_adc_nids[1] = { | |
2782 | /* ADC0 */ | |
2783 | 0x04, | |
2784 | }; | |
2785 | ||
df694daa | 2786 | static hda_nid_t alc260_adc_nids_alt[1] = { |
e9edcee0 TI |
2787 | /* ADC1 */ |
2788 | 0x05, | |
2789 | }; | |
2790 | ||
df694daa KY |
2791 | static hda_nid_t alc260_hp_adc_nids[2] = { |
2792 | /* ADC1, 0 */ | |
2793 | 0x05, 0x04 | |
2794 | }; | |
2795 | ||
d57fdac0 JW |
2796 | /* NIDs used when simultaneous access to both ADCs makes sense. Note that |
2797 | * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC. | |
2798 | */ | |
2799 | static hda_nid_t alc260_dual_adc_nids[2] = { | |
4c5186ed JW |
2800 | /* ADC0, ADC1 */ |
2801 | 0x04, 0x05 | |
2802 | }; | |
2803 | ||
e9edcee0 TI |
2804 | #define ALC260_DIGOUT_NID 0x03 |
2805 | #define ALC260_DIGIN_NID 0x06 | |
2806 | ||
2807 | static struct hda_input_mux alc260_capture_source = { | |
2808 | .num_items = 4, | |
2809 | .items = { | |
2810 | { "Mic", 0x0 }, | |
2811 | { "Front Mic", 0x1 }, | |
2812 | { "Line", 0x2 }, | |
2813 | { "CD", 0x4 }, | |
2814 | }, | |
2815 | }; | |
2816 | ||
17e7aec6 JW |
2817 | /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack, |
2818 | * headphone jack and the internal CD lines. | |
a9430dd8 JW |
2819 | */ |
2820 | static struct hda_input_mux alc260_fujitsu_capture_source = { | |
4c5186ed | 2821 | .num_items = 3, |
a9430dd8 JW |
2822 | .items = { |
2823 | { "Mic/Line", 0x0 }, | |
2824 | { "CD", 0x4 }, | |
4c5186ed | 2825 | { "Headphone", 0x2 }, |
a9430dd8 JW |
2826 | }, |
2827 | }; | |
2828 | ||
0bfc90e9 JW |
2829 | /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configutation to |
2830 | * the Fujitsu S702x, but jacks are marked differently. We won't allow | |
2831 | * retasking the Headphone jack, so it won't be available here. | |
2832 | */ | |
2833 | static struct hda_input_mux alc260_acer_capture_source = { | |
2834 | .num_items = 3, | |
2835 | .items = { | |
2836 | { "Mic", 0x0 }, | |
2837 | { "Line", 0x2 }, | |
2838 | { "CD", 0x4 }, | |
2839 | }, | |
2840 | }; | |
2841 | ||
1da177e4 LT |
2842 | /* |
2843 | * This is just place-holder, so there's something for alc_build_pcms to look | |
2844 | * at when it calculates the maximum number of channels. ALC260 has no mixer | |
2845 | * element which allows changing the channel mode, so the verb list is | |
2846 | * never used. | |
2847 | */ | |
d2a6d7dc | 2848 | static struct hda_channel_mode alc260_modes[1] = { |
1da177e4 LT |
2849 | { 2, NULL }, |
2850 | }; | |
2851 | ||
df694daa KY |
2852 | |
2853 | /* Mixer combinations | |
2854 | * | |
2855 | * basic: base_output + input + pc_beep + capture | |
2856 | * HP: base_output + input + capture_alt | |
2857 | * HP_3013: hp_3013 + input + capture | |
2858 | * fujitsu: fujitsu + capture | |
0bfc90e9 | 2859 | * acer: acer + capture |
df694daa KY |
2860 | */ |
2861 | ||
2862 | static struct snd_kcontrol_new alc260_base_output_mixer[] = { | |
05acb863 | 2863 | HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
985be54b | 2864 | HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), |
05acb863 | 2865 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
985be54b | 2866 | HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), |
05acb863 | 2867 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
985be54b | 2868 | HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), |
1da177e4 | 2869 | { } /* end */ |
df694daa | 2870 | }; |
1da177e4 | 2871 | |
df694daa | 2872 | static struct snd_kcontrol_new alc260_input_mixer[] = { |
16ded525 TI |
2873 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
2874 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
2875 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
2876 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
2877 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
2878 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
2879 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT), | |
2880 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT), | |
df694daa KY |
2881 | { } /* end */ |
2882 | }; | |
2883 | ||
2884 | static struct snd_kcontrol_new alc260_pc_beep_mixer[] = { | |
2885 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT), | |
2886 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT), | |
2887 | { } /* end */ | |
2888 | }; | |
2889 | ||
2890 | static struct snd_kcontrol_new alc260_hp_3013_mixer[] = { | |
2891 | HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT), | |
2892 | HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT), | |
2893 | HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT), | |
2894 | HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT), | |
2895 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
2896 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
2897 | HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), | |
2898 | HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT), | |
16ded525 TI |
2899 | { } /* end */ |
2900 | }; | |
2901 | ||
c8b6bf9b | 2902 | static struct snd_kcontrol_new alc260_fujitsu_mixer[] = { |
a9430dd8 | 2903 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
985be54b | 2904 | HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT), |
4c5186ed | 2905 | ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT), |
a9430dd8 JW |
2906 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
2907 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
2908 | HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT), | |
2909 | HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4c5186ed | 2910 | ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN), |
a9430dd8 JW |
2911 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), |
2912 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
2913 | HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT), | |
985be54b | 2914 | HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT), |
df694daa KY |
2915 | { } /* end */ |
2916 | }; | |
2917 | ||
0bfc90e9 JW |
2918 | static struct snd_kcontrol_new alc260_acer_mixer[] = { |
2919 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
2920 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT), | |
2921 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), | |
2922 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
2923 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
2924 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
2925 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
2926 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
2927 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
2928 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
2929 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), | |
2930 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
2931 | { } /* end */ | |
2932 | }; | |
2933 | ||
df694daa KY |
2934 | /* capture mixer elements */ |
2935 | static struct snd_kcontrol_new alc260_capture_mixer[] = { | |
a9430dd8 JW |
2936 | HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT), |
2937 | HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT), | |
df694daa KY |
2938 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT), |
2939 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT), | |
a9430dd8 JW |
2940 | { |
2941 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
df694daa KY |
2942 | /* The multiple "Capture Source" controls confuse alsamixer |
2943 | * So call somewhat different.. | |
2944 | * FIXME: the controls appear in the "playback" view! | |
2945 | */ | |
2946 | /* .name = "Capture Source", */ | |
2947 | .name = "Input Source", | |
2948 | .count = 2, | |
2949 | .info = alc_mux_enum_info, | |
2950 | .get = alc_mux_enum_get, | |
2951 | .put = alc_mux_enum_put, | |
2952 | }, | |
2953 | { } /* end */ | |
2954 | }; | |
2955 | ||
2956 | static struct snd_kcontrol_new alc260_capture_alt_mixer[] = { | |
2957 | HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT), | |
2958 | HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT), | |
2959 | { | |
2960 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2961 | /* The multiple "Capture Source" controls confuse alsamixer | |
2962 | * So call somewhat different.. | |
2963 | * FIXME: the controls appear in the "playback" view! | |
2964 | */ | |
2965 | /* .name = "Capture Source", */ | |
2966 | .name = "Input Source", | |
2967 | .count = 1, | |
a9430dd8 JW |
2968 | .info = alc_mux_enum_info, |
2969 | .get = alc_mux_enum_get, | |
2970 | .put = alc_mux_enum_put, | |
2971 | }, | |
2972 | { } /* end */ | |
2973 | }; | |
2974 | ||
df694daa KY |
2975 | /* |
2976 | * initialization verbs | |
2977 | */ | |
1da177e4 LT |
2978 | static struct hda_verb alc260_init_verbs[] = { |
2979 | /* Line In pin widget for input */ | |
05acb863 | 2980 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 2981 | /* CD pin widget for input */ |
05acb863 | 2982 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 2983 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
16ded525 | 2984 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1da177e4 | 2985 | /* Mic2 (front panel) pin widget for input and vref at 80% */ |
16ded525 | 2986 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1da177e4 | 2987 | /* LINE-2 is used for line-out in rear */ |
05acb863 | 2988 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1da177e4 | 2989 | /* select line-out */ |
fd56f2db | 2990 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00}, |
1da177e4 | 2991 | /* LINE-OUT pin */ |
05acb863 | 2992 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1da177e4 | 2993 | /* enable HP */ |
05acb863 | 2994 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
1da177e4 | 2995 | /* enable Mono */ |
05acb863 TI |
2996 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
2997 | /* mute capture amp left and right */ | |
16ded525 | 2998 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1da177e4 LT |
2999 | /* set connection select to line in (default select for this ADC) */ |
3000 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
16ded525 TI |
3001 | /* mute capture amp left and right */ |
3002 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
3003 | /* set connection select to line in (default select for this ADC) */ | |
3004 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
05acb863 TI |
3005 | /* set vol=0 Line-Out mixer amp left and right */ |
3006 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3007 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
3008 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3009 | /* set vol=0 HP mixer amp left and right */ | |
3010 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3011 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
3012 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3013 | /* set vol=0 Mono mixer amp left and right */ | |
3014 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3015 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
3016 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3017 | /* unmute LINE-2 out pin */ | |
3018 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1da177e4 | 3019 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ |
05acb863 | 3020 | /* mute CD */ |
16ded525 | 3021 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
05acb863 | 3022 | /* mute Line In */ |
16ded525 | 3023 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
05acb863 | 3024 | /* mute Mic */ |
16ded525 | 3025 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1da177e4 | 3026 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
05acb863 TI |
3027 | /* mute Front out path */ |
3028 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3029 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3030 | /* mute Headphone out path */ | |
3031 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3032 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3033 | /* mute Mono out path */ | |
3034 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3035 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 LT |
3036 | { } |
3037 | }; | |
3038 | ||
df694daa KY |
3039 | static struct hda_verb alc260_hp_init_verbs[] = { |
3040 | /* Headphone and output */ | |
3041 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
3042 | /* mono output */ | |
3043 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
3044 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
3045 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
3046 | /* Mic2 (front panel) pin widget for input and vref at 80% */ | |
3047 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
3048 | /* Line In pin widget for input */ | |
3049 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
3050 | /* Line-2 pin widget for output */ | |
3051 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
3052 | /* CD pin widget for input */ | |
3053 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
3054 | /* unmute amp left and right */ | |
3055 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | |
3056 | /* set connection select to line in (default select for this ADC) */ | |
3057 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
3058 | /* unmute Line-Out mixer amp left and right (volume = 0) */ | |
3059 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
3060 | /* mute pin widget amp left and right (no gain on this amp) */ | |
3061 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
3062 | /* unmute HP mixer amp left and right (volume = 0) */ | |
3063 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
3064 | /* mute pin widget amp left and right (no gain on this amp) */ | |
3065 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
3066 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ | |
3067 | /* unmute CD */ | |
3068 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
3069 | /* unmute Line In */ | |
3070 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
3071 | /* unmute Mic */ | |
3072 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3073 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ | |
3074 | /* Unmute Front out path */ | |
3075 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3076 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
3077 | /* Unmute Headphone out path */ | |
3078 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3079 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
3080 | /* Unmute Mono out path */ | |
3081 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3082 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
3083 | { } | |
3084 | }; | |
3085 | ||
3086 | static struct hda_verb alc260_hp_3013_init_verbs[] = { | |
3087 | /* Line out and output */ | |
3088 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
3089 | /* mono output */ | |
3090 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
3091 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
3092 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
3093 | /* Mic2 (front panel) pin widget for input and vref at 80% */ | |
3094 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
3095 | /* Line In pin widget for input */ | |
3096 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
3097 | /* Headphone pin widget for output */ | |
3098 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
3099 | /* CD pin widget for input */ | |
3100 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
3101 | /* unmute amp left and right */ | |
3102 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | |
3103 | /* set connection select to line in (default select for this ADC) */ | |
3104 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
3105 | /* unmute Line-Out mixer amp left and right (volume = 0) */ | |
3106 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
3107 | /* mute pin widget amp left and right (no gain on this amp) */ | |
3108 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
3109 | /* unmute HP mixer amp left and right (volume = 0) */ | |
3110 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
3111 | /* mute pin widget amp left and right (no gain on this amp) */ | |
3112 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
3113 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ | |
3114 | /* unmute CD */ | |
3115 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
3116 | /* unmute Line In */ | |
3117 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
3118 | /* unmute Mic */ | |
3119 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3120 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ | |
3121 | /* Unmute Front out path */ | |
3122 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3123 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
3124 | /* Unmute Headphone out path */ | |
3125 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3126 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
3127 | /* Unmute Mono out path */ | |
3128 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
3129 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
3130 | { } | |
3131 | }; | |
3132 | ||
a9430dd8 JW |
3133 | /* Initialisation sequence for ALC260 as configured in Fujitsu S702x |
3134 | * laptops. | |
3135 | */ | |
3136 | static struct hda_verb alc260_fujitsu_init_verbs[] = { | |
3137 | /* Disable all GPIOs */ | |
3138 | {0x01, AC_VERB_SET_GPIO_MASK, 0}, | |
3139 | /* Internal speaker is connected to headphone pin */ | |
3140 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
3141 | /* Headphone/Line-out jack connects to Line1 pin; make it an output */ | |
3142 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
f7ace40d JW |
3143 | /* Mic/Line-in jack is connected to mic1 pin, so make it an input */ |
3144 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
3145 | /* Ensure all other unused pins are disabled and muted. */ | |
3146 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
3147 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
a9430dd8 | 3148 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
f7ace40d | 3149 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
a9430dd8 | 3150 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
f7ace40d JW |
3151 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
3152 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
3153 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3154 | ||
3155 | /* Disable digital (SPDIF) pins */ | |
3156 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
3157 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
a9430dd8 | 3158 | |
f7ace40d JW |
3159 | /* Ensure Line1 pin widget takes its input from the OUT1 sum bus |
3160 | * when acting as an output. | |
3161 | */ | |
3162 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
4c5186ed | 3163 | |
f7ace40d | 3164 | /* Start with output sum widgets muted and their output gains at min */ |
8b33a5aa TI |
3165 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
3166 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3167 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3168 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3169 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3170 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3171 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3172 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3173 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
a9430dd8 | 3174 | |
f7ace40d JW |
3175 | /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */ |
3176 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3177 | /* Unmute Line1 pin widget output buffer since it starts as an output. | |
3178 | * If the pin mode is changed by the user the pin mode control will | |
3179 | * take care of enabling the pin's input/output buffers as needed. | |
3180 | * Therefore there's no need to enable the input buffer at this | |
3181 | * stage. | |
cdcd9268 | 3182 | */ |
f7ace40d | 3183 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
cdcd9268 JW |
3184 | /* Unmute input buffer of pin widget used for Line-in (no equiv |
3185 | * mixer ctrl) | |
3186 | */ | |
f7ace40d JW |
3187 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
3188 | ||
3189 | /* Mute capture amp left and right */ | |
3190 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3191 | /* Set ADC connection select to match default mixer setting - line | |
3192 | * in (on mic1 pin) | |
3193 | */ | |
3194 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
3195 | ||
3196 | /* Do the same for the second ADC: mute capture input amp and | |
3197 | * set ADC connection to line in (on mic1 pin) | |
3198 | */ | |
3199 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3200 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
3201 | ||
3202 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
3203 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
3204 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
3205 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
3206 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
3207 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
3208 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
3209 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
3210 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
4a471b7d TI |
3211 | |
3212 | { } | |
a9430dd8 JW |
3213 | }; |
3214 | ||
0bfc90e9 JW |
3215 | /* Initialisation sequence for ALC260 as configured in Acer TravelMate and |
3216 | * similar laptops (adapted from Fujitsu init verbs). | |
3217 | */ | |
3218 | static struct hda_verb alc260_acer_init_verbs[] = { | |
3219 | /* On TravelMate laptops, GPIO 0 enables the internal speaker and | |
3220 | * the headphone jack. Turn this on and rely on the standard mute | |
3221 | * methods whenever the user wants to turn these outputs off. | |
3222 | */ | |
3223 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
3224 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
3225 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, | |
3226 | /* Internal speaker/Headphone jack is connected to Line-out pin */ | |
3227 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
3228 | /* Internal microphone/Mic jack is connected to Mic1 pin */ | |
3229 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | |
3230 | /* Line In jack is connected to Line1 pin */ | |
3231 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
3232 | /* Ensure all other unused pins are disabled and muted. */ | |
3233 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
3234 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3235 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
3236 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3237 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
3238 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3239 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
3240 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3241 | /* Disable digital (SPDIF) pins */ | |
3242 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
3243 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
3244 | ||
3245 | /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum | |
3246 | * bus when acting as outputs. | |
3247 | */ | |
3248 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, | |
3249 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
3250 | ||
3251 | /* Start with output sum widgets muted and their output gains at min */ | |
3252 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3253 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3254 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3255 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3256 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3257 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3258 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3259 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3260 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3261 | ||
3262 | /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */ | |
3263 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3264 | /* Unmute Mic1 and Line1 pin widget input buffers since they start as | |
3265 | * inputs. If the pin mode is changed by the user the pin mode control | |
3266 | * will take care of enabling the pin's input/output buffers as needed. | |
3267 | * Therefore there's no need to enable the input buffer at this | |
3268 | * stage. | |
3269 | */ | |
3270 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
3271 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
3272 | ||
3273 | /* Mute capture amp left and right */ | |
3274 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3275 | /* Set ADC connection select to match default mixer setting - mic | |
3276 | * (on mic1 pin) | |
3277 | */ | |
3278 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
3279 | ||
3280 | /* Do similar with the second ADC: mute capture input amp and | |
3281 | * set ADC connection to line (on line1 pin) | |
3282 | */ | |
3283 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3284 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
3285 | ||
3286 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
3287 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
3288 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
3289 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
3290 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
3291 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
3292 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
3293 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
3294 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
3295 | ||
3296 | { } | |
3297 | }; | |
3298 | ||
7cf51e48 JW |
3299 | /* Test configuration for debugging, modelled after the ALC880 test |
3300 | * configuration. | |
3301 | */ | |
3302 | #ifdef CONFIG_SND_DEBUG | |
3303 | static hda_nid_t alc260_test_dac_nids[1] = { | |
3304 | 0x02, | |
3305 | }; | |
3306 | static hda_nid_t alc260_test_adc_nids[2] = { | |
3307 | 0x04, 0x05, | |
3308 | }; | |
17e7aec6 JW |
3309 | /* This is a bit messy since the two input muxes in the ALC260 have slight |
3310 | * variations in their signal assignments. The ideal way to deal with this | |
3311 | * is to extend alc_spec.input_mux to allow a different input MUX for each | |
3312 | * ADC. For the purposes of the test model it's sufficient to just list | |
3313 | * both options for affected signal indices. The separate input mux | |
3314 | * functionality only needs to be considered if a model comes along which | |
3315 | * actually uses signals 0x5, 0x6 and 0x7 for something which makes sense to | |
3316 | * record. | |
3317 | */ | |
7cf51e48 | 3318 | static struct hda_input_mux alc260_test_capture_source = { |
17e7aec6 | 3319 | .num_items = 8, |
7cf51e48 JW |
3320 | .items = { |
3321 | { "MIC1 pin", 0x0 }, | |
3322 | { "MIC2 pin", 0x1 }, | |
3323 | { "LINE1 pin", 0x2 }, | |
3324 | { "LINE2 pin", 0x3 }, | |
3325 | { "CD pin", 0x4 }, | |
17e7aec6 JW |
3326 | { "LINE-OUT pin (cap1), Mixer (cap2)", 0x5 }, |
3327 | { "HP-OUT pin (cap1), LINE-OUT pin (cap2)", 0x6 }, | |
3328 | { "HP-OUT pin (cap2 only)", 0x7 }, | |
7cf51e48 JW |
3329 | }, |
3330 | }; | |
3331 | static struct snd_kcontrol_new alc260_test_mixer[] = { | |
3332 | /* Output driver widgets */ | |
3333 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), | |
3334 | HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), | |
3335 | HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT), | |
3336 | HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT), | |
3337 | HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
3338 | HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT), | |
3339 | ||
3340 | /* Modes for retasking pin widgets */ | |
3341 | ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT), | |
3342 | ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT), | |
3343 | ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT), | |
3344 | ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT), | |
3345 | ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT), | |
3346 | ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT), | |
3347 | ||
3348 | /* Loopback mixer controls */ | |
3349 | HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT), | |
3350 | HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT), | |
3351 | HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT), | |
3352 | HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT), | |
3353 | HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT), | |
3354 | HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT), | |
3355 | HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT), | |
3356 | HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT), | |
3357 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), | |
3358 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
3359 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), | |
3360 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
3361 | HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT), | |
3362 | HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT), | |
3363 | HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT), | |
3364 | HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT), | |
5c8f858d JW |
3365 | |
3366 | /* Controls for GPIO pins, assuming they are configured as outputs */ | |
3367 | ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01), | |
3368 | ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02), | |
3369 | ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04), | |
3370 | ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08), | |
3371 | ||
92621f13 JW |
3372 | /* Switches to allow the digital IO pins to be enabled. The datasheet |
3373 | * is ambigious as to which NID is which; testing on laptops which | |
3374 | * make this output available should provide clarification. | |
3375 | */ | |
3376 | ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01), | |
3377 | ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01), | |
3378 | ||
7cf51e48 JW |
3379 | { } /* end */ |
3380 | }; | |
3381 | static struct hda_verb alc260_test_init_verbs[] = { | |
5c8f858d JW |
3382 | /* Enable all GPIOs as outputs with an initial value of 0 */ |
3383 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f}, | |
3384 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, | |
3385 | {0x01, AC_VERB_SET_GPIO_MASK, 0x0f}, | |
3386 | ||
7cf51e48 JW |
3387 | /* Enable retasking pins as output, initially without power amp */ |
3388 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
3389 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
3390 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
3391 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
3392 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
3393 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
3394 | ||
92621f13 JW |
3395 | /* Disable digital (SPDIF) pins initially, but users can enable |
3396 | * them via a mixer switch. In the case of SPDIF-out, this initverb | |
3397 | * payload also sets the generation to 0, output to be in "consumer" | |
3398 | * PCM format, copyright asserted, no pre-emphasis and no validity | |
3399 | * control. | |
3400 | */ | |
7cf51e48 JW |
3401 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, |
3402 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
3403 | ||
f7ace40d | 3404 | /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the |
7cf51e48 JW |
3405 | * OUT1 sum bus when acting as an output. |
3406 | */ | |
3407 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, | |
3408 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0}, | |
3409 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
3410 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0}, | |
3411 | ||
3412 | /* Start with output sum widgets muted and their output gains at min */ | |
3413 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3414 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3415 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3416 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3417 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3418 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3419 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3420 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3421 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3422 | ||
cdcd9268 JW |
3423 | /* Unmute retasking pin widget output buffers since the default |
3424 | * state appears to be output. As the pin mode is changed by the | |
3425 | * user the pin mode control will take care of enabling the pin's | |
3426 | * input/output buffers as needed. | |
3427 | */ | |
7cf51e48 JW |
3428 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
3429 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3430 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3431 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3432 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3433 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3434 | /* Also unmute the mono-out pin widget */ | |
3435 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3436 | ||
7cf51e48 JW |
3437 | /* Mute capture amp left and right */ |
3438 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
f7ace40d JW |
3439 | /* Set ADC connection select to match default mixer setting (mic1 |
3440 | * pin) | |
7cf51e48 JW |
3441 | */ |
3442 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
3443 | ||
3444 | /* Do the same for the second ADC: mute capture input amp and | |
f7ace40d | 3445 | * set ADC connection to mic1 pin |
7cf51e48 JW |
3446 | */ |
3447 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3448 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
3449 | ||
3450 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
3451 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
3452 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
3453 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
3454 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
3455 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
3456 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
3457 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
3458 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
3459 | ||
3460 | { } | |
3461 | }; | |
3462 | #endif | |
3463 | ||
1da177e4 LT |
3464 | static struct hda_pcm_stream alc260_pcm_analog_playback = { |
3465 | .substreams = 1, | |
3466 | .channels_min = 2, | |
3467 | .channels_max = 2, | |
1da177e4 LT |
3468 | }; |
3469 | ||
3470 | static struct hda_pcm_stream alc260_pcm_analog_capture = { | |
3471 | .substreams = 1, | |
3472 | .channels_min = 2, | |
3473 | .channels_max = 2, | |
1da177e4 LT |
3474 | }; |
3475 | ||
a3bcba38 TI |
3476 | #define alc260_pcm_digital_playback alc880_pcm_digital_playback |
3477 | #define alc260_pcm_digital_capture alc880_pcm_digital_capture | |
3478 | ||
df694daa KY |
3479 | /* |
3480 | * for BIOS auto-configuration | |
3481 | */ | |
16ded525 | 3482 | |
df694daa KY |
3483 | static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid, |
3484 | const char *pfx) | |
3485 | { | |
3486 | hda_nid_t nid_vol; | |
3487 | unsigned long vol_val, sw_val; | |
3488 | char name[32]; | |
3489 | int err; | |
3490 | ||
3491 | if (nid >= 0x0f && nid < 0x11) { | |
3492 | nid_vol = nid - 0x7; | |
3493 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); | |
3494 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); | |
3495 | } else if (nid == 0x11) { | |
3496 | nid_vol = nid - 0x7; | |
3497 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT); | |
3498 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT); | |
3499 | } else if (nid >= 0x12 && nid <= 0x15) { | |
3500 | nid_vol = 0x08; | |
3501 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); | |
3502 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); | |
3503 | } else | |
3504 | return 0; /* N/A */ | |
3505 | ||
3506 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); | |
3507 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0) | |
3508 | return err; | |
3509 | snprintf(name, sizeof(name), "%s Playback Switch", pfx); | |
3510 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0) | |
3511 | return err; | |
3512 | return 1; | |
3513 | } | |
3514 | ||
3515 | /* add playback controls from the parsed DAC table */ | |
3516 | static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec, | |
3517 | const struct auto_pin_cfg *cfg) | |
3518 | { | |
3519 | hda_nid_t nid; | |
3520 | int err; | |
3521 | ||
3522 | spec->multiout.num_dacs = 1; | |
3523 | spec->multiout.dac_nids = spec->private_dac_nids; | |
3524 | spec->multiout.dac_nids[0] = 0x02; | |
3525 | ||
3526 | nid = cfg->line_out_pins[0]; | |
3527 | if (nid) { | |
3528 | err = alc260_add_playback_controls(spec, nid, "Front"); | |
3529 | if (err < 0) | |
3530 | return err; | |
3531 | } | |
3532 | ||
82bc955f | 3533 | nid = cfg->speaker_pins[0]; |
df694daa KY |
3534 | if (nid) { |
3535 | err = alc260_add_playback_controls(spec, nid, "Speaker"); | |
3536 | if (err < 0) | |
3537 | return err; | |
3538 | } | |
3539 | ||
3540 | nid = cfg->hp_pin; | |
3541 | if (nid) { | |
3542 | err = alc260_add_playback_controls(spec, nid, "Headphone"); | |
3543 | if (err < 0) | |
3544 | return err; | |
3545 | } | |
3546 | return 0; | |
3547 | } | |
3548 | ||
3549 | /* create playback/capture controls for input pins */ | |
3550 | static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec, | |
3551 | const struct auto_pin_cfg *cfg) | |
3552 | { | |
df694daa KY |
3553 | struct hda_input_mux *imux = &spec->private_imux; |
3554 | int i, err, idx; | |
3555 | ||
3556 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
3557 | if (cfg->input_pins[i] >= 0x12) { | |
3558 | idx = cfg->input_pins[i] - 0x12; | |
4a471b7d TI |
3559 | err = new_analog_input(spec, cfg->input_pins[i], |
3560 | auto_pin_cfg_labels[i], idx, 0x07); | |
df694daa KY |
3561 | if (err < 0) |
3562 | return err; | |
4a471b7d | 3563 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
df694daa KY |
3564 | imux->items[imux->num_items].index = idx; |
3565 | imux->num_items++; | |
3566 | } | |
3567 | if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){ | |
3568 | idx = cfg->input_pins[i] - 0x09; | |
4a471b7d TI |
3569 | err = new_analog_input(spec, cfg->input_pins[i], |
3570 | auto_pin_cfg_labels[i], idx, 0x07); | |
df694daa KY |
3571 | if (err < 0) |
3572 | return err; | |
4a471b7d | 3573 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
df694daa KY |
3574 | imux->items[imux->num_items].index = idx; |
3575 | imux->num_items++; | |
3576 | } | |
3577 | } | |
3578 | return 0; | |
3579 | } | |
3580 | ||
3581 | static void alc260_auto_set_output_and_unmute(struct hda_codec *codec, | |
3582 | hda_nid_t nid, int pin_type, | |
3583 | int sel_idx) | |
3584 | { | |
3585 | /* set as output */ | |
3586 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); | |
3587 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); | |
3588 | /* need the manual connection? */ | |
3589 | if (nid >= 0x12) { | |
3590 | int idx = nid - 0x12; | |
3591 | snd_hda_codec_write(codec, idx + 0x0b, 0, | |
3592 | AC_VERB_SET_CONNECT_SEL, sel_idx); | |
3593 | ||
3594 | } | |
3595 | } | |
3596 | ||
3597 | static void alc260_auto_init_multi_out(struct hda_codec *codec) | |
3598 | { | |
3599 | struct alc_spec *spec = codec->spec; | |
3600 | hda_nid_t nid; | |
3601 | ||
3602 | nid = spec->autocfg.line_out_pins[0]; | |
3603 | if (nid) | |
3604 | alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); | |
3605 | ||
82bc955f | 3606 | nid = spec->autocfg.speaker_pins[0]; |
df694daa KY |
3607 | if (nid) |
3608 | alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); | |
3609 | ||
3610 | nid = spec->autocfg.hp_pin; | |
3611 | if (nid) | |
3612 | alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); | |
3613 | } | |
3614 | ||
3615 | #define ALC260_PIN_CD_NID 0x16 | |
3616 | static void alc260_auto_init_analog_input(struct hda_codec *codec) | |
3617 | { | |
3618 | struct alc_spec *spec = codec->spec; | |
3619 | int i; | |
3620 | ||
3621 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
3622 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
3623 | if (nid >= 0x12) { | |
3624 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
3625 | i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); | |
3626 | if (nid != ALC260_PIN_CD_NID) | |
3627 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
3628 | AMP_OUT_MUTE); | |
3629 | } | |
3630 | } | |
3631 | } | |
3632 | ||
3633 | /* | |
3634 | * generic initialization of ADC, input mixers and output mixers | |
3635 | */ | |
3636 | static struct hda_verb alc260_volume_init_verbs[] = { | |
3637 | /* | |
3638 | * Unmute ADC0-1 and set the default input to mic-in | |
3639 | */ | |
3640 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
3641 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
3642 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
3643 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
3644 | ||
3645 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | |
3646 | * mixer widget | |
3647 | * Note: PASD motherboards uses the Line In 2 as the input for front panel | |
3648 | * mic (mic 2) | |
3649 | */ | |
3650 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
3651 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
3652 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
3653 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
3654 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
3655 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
3656 | ||
3657 | /* | |
3658 | * Set up output mixers (0x08 - 0x0a) | |
3659 | */ | |
3660 | /* set vol=0 to output mixers */ | |
3661 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3662 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3663 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3664 | /* set up input amps for analog loopback */ | |
3665 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
3666 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
3667 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
3668 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
3669 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
3670 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
3671 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
3672 | ||
3673 | { } | |
3674 | }; | |
3675 | ||
3676 | static int alc260_parse_auto_config(struct hda_codec *codec) | |
3677 | { | |
3678 | struct alc_spec *spec = codec->spec; | |
3679 | unsigned int wcap; | |
3680 | int err; | |
3681 | static hda_nid_t alc260_ignore[] = { 0x17, 0 }; | |
3682 | ||
3683 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | |
3684 | alc260_ignore)) < 0) | |
3685 | return err; | |
4a471b7d TI |
3686 | if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0) |
3687 | return err; | |
3688 | if (! spec->kctl_alloc) | |
df694daa | 3689 | return 0; /* can't find valid BIOS pin config */ |
4a471b7d | 3690 | if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) |
df694daa KY |
3691 | return err; |
3692 | ||
3693 | spec->multiout.max_channels = 2; | |
3694 | ||
3695 | if (spec->autocfg.dig_out_pin) | |
3696 | spec->multiout.dig_out_nid = ALC260_DIGOUT_NID; | |
3697 | if (spec->kctl_alloc) | |
3698 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
3699 | ||
3700 | spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs; | |
3701 | ||
3702 | spec->input_mux = &spec->private_imux; | |
3703 | ||
3704 | /* check whether NID 0x04 is valid */ | |
4a471b7d | 3705 | wcap = get_wcaps(codec, 0x04); |
df694daa KY |
3706 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ |
3707 | if (wcap != AC_WID_AUD_IN) { | |
3708 | spec->adc_nids = alc260_adc_nids_alt; | |
3709 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt); | |
3710 | spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer; | |
df694daa KY |
3711 | } else { |
3712 | spec->adc_nids = alc260_adc_nids; | |
3713 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); | |
3714 | spec->mixers[spec->num_mixers] = alc260_capture_mixer; | |
df694daa | 3715 | } |
4a471b7d | 3716 | spec->num_mixers++; |
df694daa KY |
3717 | |
3718 | return 1; | |
3719 | } | |
3720 | ||
ae6b813a TI |
3721 | /* additional initialization for auto-configuration model */ |
3722 | static void alc260_auto_init(struct hda_codec *codec) | |
df694daa | 3723 | { |
df694daa KY |
3724 | alc260_auto_init_multi_out(codec); |
3725 | alc260_auto_init_analog_input(codec); | |
df694daa KY |
3726 | } |
3727 | ||
3728 | /* | |
3729 | * ALC260 configurations | |
3730 | */ | |
3731 | static struct hda_board_config alc260_cfg_tbl[] = { | |
3732 | { .modelname = "basic", .config = ALC260_BASIC }, | |
b14e77e6 TI |
3733 | { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb, |
3734 | .config = ALC260_BASIC }, /* Sony VAIO */ | |
c1fc8047 TI |
3735 | { .pci_subvendor = 0x152d, .pci_subdevice = 0x0729, |
3736 | .config = ALC260_BASIC }, /* CTL Travel Master U553W */ | |
df694daa KY |
3737 | { .modelname = "hp", .config = ALC260_HP }, |
3738 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP }, | |
3739 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP }, | |
3740 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP }, | |
3741 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 }, | |
3742 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP }, | |
3743 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP }, | |
3744 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP }, | |
3745 | { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X }, | |
3746 | { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X }, | |
0bfc90e9 JW |
3747 | { .modelname = "acer", .config = ALC260_ACER }, |
3748 | { .pci_subvendor = 0x1025, .pci_subdevice = 0x008f, .config = ALC260_ACER }, | |
7cf51e48 JW |
3749 | #ifdef CONFIG_SND_DEBUG |
3750 | { .modelname = "test", .config = ALC260_TEST }, | |
3751 | #endif | |
df694daa KY |
3752 | { .modelname = "auto", .config = ALC260_AUTO }, |
3753 | {} | |
3754 | }; | |
3755 | ||
3756 | static struct alc_config_preset alc260_presets[] = { | |
3757 | [ALC260_BASIC] = { | |
3758 | .mixers = { alc260_base_output_mixer, | |
3759 | alc260_input_mixer, | |
3760 | alc260_pc_beep_mixer, | |
3761 | alc260_capture_mixer }, | |
3762 | .init_verbs = { alc260_init_verbs }, | |
3763 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
3764 | .dac_nids = alc260_dac_nids, | |
3765 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), | |
3766 | .adc_nids = alc260_adc_nids, | |
3767 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
3768 | .channel_mode = alc260_modes, | |
3769 | .input_mux = &alc260_capture_source, | |
3770 | }, | |
3771 | [ALC260_HP] = { | |
3772 | .mixers = { alc260_base_output_mixer, | |
3773 | alc260_input_mixer, | |
3774 | alc260_capture_alt_mixer }, | |
3775 | .init_verbs = { alc260_hp_init_verbs }, | |
3776 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
3777 | .dac_nids = alc260_dac_nids, | |
3778 | .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), | |
3779 | .adc_nids = alc260_hp_adc_nids, | |
3780 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
3781 | .channel_mode = alc260_modes, | |
3782 | .input_mux = &alc260_capture_source, | |
3783 | }, | |
3784 | [ALC260_HP_3013] = { | |
3785 | .mixers = { alc260_hp_3013_mixer, | |
3786 | alc260_input_mixer, | |
3787 | alc260_capture_alt_mixer }, | |
3788 | .init_verbs = { alc260_hp_3013_init_verbs }, | |
3789 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
3790 | .dac_nids = alc260_dac_nids, | |
3791 | .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), | |
3792 | .adc_nids = alc260_hp_adc_nids, | |
3793 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
3794 | .channel_mode = alc260_modes, | |
3795 | .input_mux = &alc260_capture_source, | |
3796 | }, | |
3797 | [ALC260_FUJITSU_S702X] = { | |
3798 | .mixers = { alc260_fujitsu_mixer, | |
3799 | alc260_capture_mixer }, | |
3800 | .init_verbs = { alc260_fujitsu_init_verbs }, | |
3801 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
3802 | .dac_nids = alc260_dac_nids, | |
d57fdac0 JW |
3803 | .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), |
3804 | .adc_nids = alc260_dual_adc_nids, | |
df694daa KY |
3805 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
3806 | .channel_mode = alc260_modes, | |
3807 | .input_mux = &alc260_fujitsu_capture_source, | |
3808 | }, | |
0bfc90e9 JW |
3809 | [ALC260_ACER] = { |
3810 | .mixers = { alc260_acer_mixer, | |
3811 | alc260_capture_mixer }, | |
3812 | .init_verbs = { alc260_acer_init_verbs }, | |
3813 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
3814 | .dac_nids = alc260_dac_nids, | |
3815 | .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), | |
3816 | .adc_nids = alc260_dual_adc_nids, | |
3817 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
3818 | .channel_mode = alc260_modes, | |
3819 | .input_mux = &alc260_acer_capture_source, | |
3820 | }, | |
7cf51e48 JW |
3821 | #ifdef CONFIG_SND_DEBUG |
3822 | [ALC260_TEST] = { | |
3823 | .mixers = { alc260_test_mixer, | |
3824 | alc260_capture_mixer }, | |
3825 | .init_verbs = { alc260_test_init_verbs }, | |
3826 | .num_dacs = ARRAY_SIZE(alc260_test_dac_nids), | |
3827 | .dac_nids = alc260_test_dac_nids, | |
3828 | .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids), | |
3829 | .adc_nids = alc260_test_adc_nids, | |
3830 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
3831 | .channel_mode = alc260_modes, | |
3832 | .input_mux = &alc260_test_capture_source, | |
3833 | }, | |
3834 | #endif | |
df694daa KY |
3835 | }; |
3836 | ||
3837 | static int patch_alc260(struct hda_codec *codec) | |
1da177e4 LT |
3838 | { |
3839 | struct alc_spec *spec; | |
df694daa | 3840 | int err, board_config; |
1da177e4 | 3841 | |
e560d8d8 | 3842 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
1da177e4 LT |
3843 | if (spec == NULL) |
3844 | return -ENOMEM; | |
3845 | ||
3846 | codec->spec = spec; | |
3847 | ||
16ded525 TI |
3848 | board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl); |
3849 | if (board_config < 0 || board_config >= ALC260_MODEL_LAST) { | |
3850 | snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260\n"); | |
df694daa | 3851 | board_config = ALC260_AUTO; |
16ded525 | 3852 | } |
1da177e4 | 3853 | |
df694daa KY |
3854 | if (board_config == ALC260_AUTO) { |
3855 | /* automatic parse from the BIOS config */ | |
3856 | err = alc260_parse_auto_config(codec); | |
3857 | if (err < 0) { | |
3858 | alc_free(codec); | |
3859 | return err; | |
3860 | } else if (! err) { | |
3861 | printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n"); | |
3862 | board_config = ALC260_BASIC; | |
3863 | } | |
a9430dd8 | 3864 | } |
e9edcee0 | 3865 | |
df694daa KY |
3866 | if (board_config != ALC260_AUTO) |
3867 | setup_preset(spec, &alc260_presets[board_config]); | |
1da177e4 LT |
3868 | |
3869 | spec->stream_name_analog = "ALC260 Analog"; | |
3870 | spec->stream_analog_playback = &alc260_pcm_analog_playback; | |
3871 | spec->stream_analog_capture = &alc260_pcm_analog_capture; | |
3872 | ||
a3bcba38 TI |
3873 | spec->stream_name_digital = "ALC260 Digital"; |
3874 | spec->stream_digital_playback = &alc260_pcm_digital_playback; | |
3875 | spec->stream_digital_capture = &alc260_pcm_digital_capture; | |
3876 | ||
1da177e4 | 3877 | codec->patch_ops = alc_patch_ops; |
df694daa | 3878 | if (board_config == ALC260_AUTO) |
ae6b813a | 3879 | spec->init_hook = alc260_auto_init; |
1da177e4 LT |
3880 | |
3881 | return 0; | |
3882 | } | |
3883 | ||
e9edcee0 | 3884 | |
1da177e4 LT |
3885 | /* |
3886 | * ALC882 support | |
3887 | * | |
3888 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible | |
3889 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
3890 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
3891 | * 6-channel independent captures. | |
3892 | * | |
3893 | * In addition, an independent DAC for the multi-playback (not used in this | |
3894 | * driver yet). | |
3895 | */ | |
df694daa KY |
3896 | #define ALC882_DIGOUT_NID 0x06 |
3897 | #define ALC882_DIGIN_NID 0x0a | |
1da177e4 | 3898 | |
d2a6d7dc | 3899 | static struct hda_channel_mode alc882_ch_modes[1] = { |
1da177e4 LT |
3900 | { 8, NULL } |
3901 | }; | |
3902 | ||
3903 | static hda_nid_t alc882_dac_nids[4] = { | |
3904 | /* front, rear, clfe, rear_surr */ | |
3905 | 0x02, 0x03, 0x04, 0x05 | |
3906 | }; | |
3907 | ||
df694daa KY |
3908 | /* identical with ALC880 */ |
3909 | #define alc882_adc_nids alc880_adc_nids | |
3910 | #define alc882_adc_nids_alt alc880_adc_nids_alt | |
1da177e4 LT |
3911 | |
3912 | /* input MUX */ | |
3913 | /* FIXME: should be a matrix-type input source selection */ | |
3914 | ||
3915 | static struct hda_input_mux alc882_capture_source = { | |
3916 | .num_items = 4, | |
3917 | .items = { | |
3918 | { "Mic", 0x0 }, | |
3919 | { "Front Mic", 0x1 }, | |
3920 | { "Line", 0x2 }, | |
3921 | { "CD", 0x4 }, | |
3922 | }, | |
3923 | }; | |
3924 | ||
3925 | #define alc882_mux_enum_info alc_mux_enum_info | |
3926 | #define alc882_mux_enum_get alc_mux_enum_get | |
3927 | ||
c8b6bf9b | 3928 | static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1da177e4 LT |
3929 | { |
3930 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
3931 | struct alc_spec *spec = codec->spec; | |
3932 | const struct hda_input_mux *imux = spec->input_mux; | |
3933 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
3934 | static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 }; | |
3935 | hda_nid_t nid = capture_mixers[adc_idx]; | |
3936 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; | |
3937 | unsigned int i, idx; | |
3938 | ||
3939 | idx = ucontrol->value.enumerated.item[0]; | |
3940 | if (idx >= imux->num_items) | |
3941 | idx = imux->num_items - 1; | |
3942 | if (*cur_val == idx && ! codec->in_resume) | |
3943 | return 0; | |
3944 | for (i = 0; i < imux->num_items; i++) { | |
3945 | unsigned int v = (i == idx) ? 0x7000 : 0x7080; | |
3946 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
3947 | v | (imux->items[i].index << 8)); | |
3948 | } | |
3949 | *cur_val = idx; | |
3950 | return 1; | |
3951 | } | |
3952 | ||
df694daa KY |
3953 | /* |
3954 | * 6ch mode | |
3955 | */ | |
3956 | static struct hda_verb alc882_sixstack_ch6_init[] = { | |
3957 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
3958 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
3959 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
3960 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
3961 | { } /* end */ | |
3962 | }; | |
3963 | ||
3964 | /* | |
3965 | * 8ch mode | |
3966 | */ | |
3967 | static struct hda_verb alc882_sixstack_ch8_init[] = { | |
3968 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
3969 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
3970 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
3971 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
3972 | { } /* end */ | |
3973 | }; | |
3974 | ||
3975 | static struct hda_channel_mode alc882_sixstack_modes[2] = { | |
3976 | { 6, alc882_sixstack_ch6_init }, | |
3977 | { 8, alc882_sixstack_ch8_init }, | |
3978 | }; | |
3979 | ||
1da177e4 LT |
3980 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
3981 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
3982 | */ | |
c8b6bf9b | 3983 | static struct snd_kcontrol_new alc882_base_mixer[] = { |
05acb863 | 3984 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 3985 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
05acb863 | 3986 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 3987 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
05acb863 TI |
3988 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
3989 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
3990 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
3991 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
05acb863 | 3992 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 3993 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
1da177e4 LT |
3994 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
3995 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
3996 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
3997 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
3998 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
3999 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
4000 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
4001 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
4002 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
4003 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
4004 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
4005 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), | |
4006 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), | |
4007 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), | |
4008 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), | |
4009 | HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), | |
4010 | HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), | |
4011 | { | |
4012 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
4013 | /* .name = "Capture Source", */ | |
4014 | .name = "Input Source", | |
4015 | .count = 3, | |
4016 | .info = alc882_mux_enum_info, | |
4017 | .get = alc882_mux_enum_get, | |
4018 | .put = alc882_mux_enum_put, | |
4019 | }, | |
4020 | { } /* end */ | |
4021 | }; | |
4022 | ||
df694daa KY |
4023 | static struct snd_kcontrol_new alc882_chmode_mixer[] = { |
4024 | { | |
4025 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
4026 | .name = "Channel Mode", | |
4027 | .info = alc_ch_mode_info, | |
4028 | .get = alc_ch_mode_get, | |
4029 | .put = alc_ch_mode_put, | |
4030 | }, | |
4031 | { } /* end */ | |
4032 | }; | |
4033 | ||
1da177e4 LT |
4034 | static struct hda_verb alc882_init_verbs[] = { |
4035 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
05acb863 TI |
4036 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
4037 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4038 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 4039 | /* Rear mixer */ |
05acb863 TI |
4040 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
4041 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4042 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 4043 | /* CLFE mixer */ |
05acb863 TI |
4044 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
4045 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4046 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 4047 | /* Side mixer */ |
05acb863 TI |
4048 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
4049 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4050 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 4051 | |
e9edcee0 | 4052 | /* Front Pin: output 0 (0x0c) */ |
05acb863 | 4053 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 4054 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 4055 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 4056 | /* Rear Pin: output 1 (0x0d) */ |
05acb863 | 4057 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 4058 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 4059 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, |
e9edcee0 | 4060 | /* CLFE Pin: output 2 (0x0e) */ |
05acb863 | 4061 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 4062 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 4063 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, |
e9edcee0 | 4064 | /* Side Pin: output 3 (0x0f) */ |
05acb863 | 4065 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 4066 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 4067 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, |
e9edcee0 | 4068 | /* Mic (rear) pin: input vref at 80% */ |
16ded525 | 4069 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 TI |
4070 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
4071 | /* Front Mic pin: input vref at 80% */ | |
16ded525 | 4072 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 TI |
4073 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
4074 | /* Line In pin: input */ | |
05acb863 | 4075 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 TI |
4076 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
4077 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
4078 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
4079 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4080 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1da177e4 | 4081 | /* CD pin widget for input */ |
05acb863 | 4082 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 LT |
4083 | |
4084 | /* FIXME: use matrix-type input source selection */ | |
4085 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
4086 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
05acb863 TI |
4087 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
4088 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4089 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4090 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 4091 | /* Input mixer2 */ |
05acb863 TI |
4092 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
4093 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4094 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4095 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 4096 | /* Input mixer3 */ |
05acb863 TI |
4097 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
4098 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4099 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4100 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
4101 | /* ADC1: mute amp left and right */ | |
4102 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 4103 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
4104 | /* ADC2: mute amp left and right */ |
4105 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 4106 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
4107 | /* ADC3: mute amp left and right */ |
4108 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 4109 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
1da177e4 LT |
4110 | |
4111 | { } | |
4112 | }; | |
4113 | ||
df694daa KY |
4114 | /* |
4115 | * generic initialization of ADC, input mixers and output mixers | |
4116 | */ | |
4117 | static struct hda_verb alc882_auto_init_verbs[] = { | |
4118 | /* | |
4119 | * Unmute ADC0-2 and set the default input to mic-in | |
4120 | */ | |
4121 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4122 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4123 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4124 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4125 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4126 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
1da177e4 | 4127 | |
df694daa KY |
4128 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
4129 | * mixer widget | |
4130 | * Note: PASD motherboards uses the Line In 2 as the input for front panel | |
4131 | * mic (mic 2) | |
4132 | */ | |
4133 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
4134 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4135 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4136 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
4137 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
4138 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
e9edcee0 | 4139 | |
df694daa KY |
4140 | /* |
4141 | * Set up output mixers (0x0c - 0x0f) | |
4142 | */ | |
4143 | /* set vol=0 to output mixers */ | |
4144 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4145 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4146 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4147 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4148 | /* set up input amps for analog loopback */ | |
4149 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
4150 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4151 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4152 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4153 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4154 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4155 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4156 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4157 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4158 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4159 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4160 | ||
4161 | /* FIXME: use matrix-type input source selection */ | |
4162 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
4163 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
4164 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4165 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
4166 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
4167 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
4168 | /* Input mixer2 */ | |
4169 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4170 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
4171 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
4172 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
4173 | /* Input mixer3 */ | |
4174 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4175 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
4176 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
4177 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
4178 | ||
4179 | { } | |
4180 | }; | |
4181 | ||
4182 | /* capture mixer elements */ | |
4183 | static struct snd_kcontrol_new alc882_capture_alt_mixer[] = { | |
4184 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
4185 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
4186 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | |
4187 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | |
4188 | { | |
4189 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
4190 | /* The multiple "Capture Source" controls confuse alsamixer | |
4191 | * So call somewhat different.. | |
4192 | * FIXME: the controls appear in the "playback" view! | |
4193 | */ | |
4194 | /* .name = "Capture Source", */ | |
4195 | .name = "Input Source", | |
4196 | .count = 2, | |
4197 | .info = alc882_mux_enum_info, | |
4198 | .get = alc882_mux_enum_get, | |
4199 | .put = alc882_mux_enum_put, | |
4200 | }, | |
4201 | { } /* end */ | |
4202 | }; | |
4203 | ||
4204 | static struct snd_kcontrol_new alc882_capture_mixer[] = { | |
4205 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), | |
4206 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), | |
4207 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), | |
4208 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), | |
4209 | HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), | |
4210 | HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), | |
4211 | { | |
4212 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
4213 | /* The multiple "Capture Source" controls confuse alsamixer | |
4214 | * So call somewhat different.. | |
4215 | * FIXME: the controls appear in the "playback" view! | |
4216 | */ | |
4217 | /* .name = "Capture Source", */ | |
4218 | .name = "Input Source", | |
4219 | .count = 3, | |
4220 | .info = alc882_mux_enum_info, | |
4221 | .get = alc882_mux_enum_get, | |
4222 | .put = alc882_mux_enum_put, | |
4223 | }, | |
4224 | { } /* end */ | |
4225 | }; | |
4226 | ||
4227 | /* pcm configuration: identiacal with ALC880 */ | |
4228 | #define alc882_pcm_analog_playback alc880_pcm_analog_playback | |
4229 | #define alc882_pcm_analog_capture alc880_pcm_analog_capture | |
4230 | #define alc882_pcm_digital_playback alc880_pcm_digital_playback | |
4231 | #define alc882_pcm_digital_capture alc880_pcm_digital_capture | |
4232 | ||
4233 | /* | |
4234 | * configuration and preset | |
4235 | */ | |
4236 | static struct hda_board_config alc882_cfg_tbl[] = { | |
1494a92f TI |
4237 | { .modelname = "3stack-dig", .config = ALC882_3ST_DIG }, |
4238 | { .modelname = "6stack-dig", .config = ALC882_6ST_DIG }, | |
df694daa KY |
4239 | { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* MSI */ |
4240 | { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* Foxconn */ | |
4241 | { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* ECS */ | |
1494a92f | 4242 | { .modelname = "auto", .config = ALC882_AUTO }, |
df694daa KY |
4243 | {} |
4244 | }; | |
4245 | ||
4246 | static struct alc_config_preset alc882_presets[] = { | |
4247 | [ALC882_3ST_DIG] = { | |
4248 | .mixers = { alc882_base_mixer }, | |
4249 | .init_verbs = { alc882_init_verbs }, | |
4250 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
4251 | .dac_nids = alc882_dac_nids, | |
4252 | .dig_out_nid = ALC882_DIGOUT_NID, | |
4253 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), | |
4254 | .adc_nids = alc882_adc_nids, | |
4255 | .dig_in_nid = ALC882_DIGIN_NID, | |
4256 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | |
4257 | .channel_mode = alc882_ch_modes, | |
4258 | .input_mux = &alc882_capture_source, | |
4259 | }, | |
4260 | [ALC882_6ST_DIG] = { | |
4261 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, | |
4262 | .init_verbs = { alc882_init_verbs }, | |
4263 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
4264 | .dac_nids = alc882_dac_nids, | |
4265 | .dig_out_nid = ALC882_DIGOUT_NID, | |
4266 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), | |
4267 | .adc_nids = alc882_adc_nids, | |
4268 | .dig_in_nid = ALC882_DIGIN_NID, | |
4269 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), | |
4270 | .channel_mode = alc882_sixstack_modes, | |
4271 | .input_mux = &alc882_capture_source, | |
4272 | }, | |
4273 | }; | |
4274 | ||
4275 | ||
4276 | /* | |
4277 | * BIOS auto configuration | |
4278 | */ | |
4279 | static void alc882_auto_set_output_and_unmute(struct hda_codec *codec, | |
4280 | hda_nid_t nid, int pin_type, | |
4281 | int dac_idx) | |
4282 | { | |
4283 | /* set as output */ | |
4284 | struct alc_spec *spec = codec->spec; | |
4285 | int idx; | |
4286 | ||
4287 | if (spec->multiout.dac_nids[dac_idx] == 0x25) | |
4288 | idx = 4; | |
4289 | else | |
4290 | idx = spec->multiout.dac_nids[dac_idx] - 2; | |
4291 | ||
4292 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); | |
4293 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); | |
4294 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); | |
4295 | ||
4296 | } | |
4297 | ||
4298 | static void alc882_auto_init_multi_out(struct hda_codec *codec) | |
4299 | { | |
4300 | struct alc_spec *spec = codec->spec; | |
4301 | int i; | |
4302 | ||
4303 | for (i = 0; i <= HDA_SIDE; i++) { | |
4304 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
4305 | if (nid) | |
4306 | alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); | |
4307 | } | |
4308 | } | |
4309 | ||
4310 | static void alc882_auto_init_hp_out(struct hda_codec *codec) | |
4311 | { | |
4312 | struct alc_spec *spec = codec->spec; | |
4313 | hda_nid_t pin; | |
4314 | ||
4315 | pin = spec->autocfg.hp_pin; | |
4316 | if (pin) /* connect to front */ | |
4317 | alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */ | |
4318 | } | |
4319 | ||
4320 | #define alc882_is_input_pin(nid) alc880_is_input_pin(nid) | |
4321 | #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID | |
4322 | ||
4323 | static void alc882_auto_init_analog_input(struct hda_codec *codec) | |
4324 | { | |
4325 | struct alc_spec *spec = codec->spec; | |
4326 | int i; | |
4327 | ||
4328 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
4329 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
4330 | if (alc882_is_input_pin(nid)) { | |
4331 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4332 | i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); | |
4333 | if (nid != ALC882_PIN_CD_NID) | |
4334 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
4335 | AMP_OUT_MUTE); | |
4336 | } | |
4337 | } | |
4338 | } | |
4339 | ||
4340 | /* almost identical with ALC880 parser... */ | |
4341 | static int alc882_parse_auto_config(struct hda_codec *codec) | |
4342 | { | |
4343 | struct alc_spec *spec = codec->spec; | |
4344 | int err = alc880_parse_auto_config(codec); | |
4345 | ||
4346 | if (err < 0) | |
4347 | return err; | |
c5f2ea08 TI |
4348 | else if (err > 0) |
4349 | /* hack - override the init verbs */ | |
4350 | spec->init_verbs[0] = alc882_auto_init_verbs; | |
4351 | return err; | |
df694daa KY |
4352 | } |
4353 | ||
ae6b813a TI |
4354 | /* additional initialization for auto-configuration model */ |
4355 | static void alc882_auto_init(struct hda_codec *codec) | |
df694daa | 4356 | { |
df694daa KY |
4357 | alc882_auto_init_multi_out(codec); |
4358 | alc882_auto_init_hp_out(codec); | |
4359 | alc882_auto_init_analog_input(codec); | |
df694daa KY |
4360 | } |
4361 | ||
4362 | /* | |
4363 | * ALC882 Headphone poll in 3.5.1a or 3.5.2 | |
4364 | */ | |
4365 | ||
4366 | static int patch_alc882(struct hda_codec *codec) | |
4367 | { | |
4368 | struct alc_spec *spec; | |
4369 | int err, board_config; | |
4370 | ||
4371 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
4372 | if (spec == NULL) | |
4373 | return -ENOMEM; | |
4374 | ||
4375 | codec->spec = spec; | |
4376 | ||
4377 | board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl); | |
4378 | ||
4379 | if (board_config < 0 || board_config >= ALC882_MODEL_LAST) { | |
4380 | printk(KERN_INFO "hda_codec: Unknown model for ALC882, trying auto-probe from BIOS...\n"); | |
4381 | board_config = ALC882_AUTO; | |
4382 | } | |
4383 | ||
4384 | if (board_config == ALC882_AUTO) { | |
4385 | /* automatic parse from the BIOS config */ | |
4386 | err = alc882_parse_auto_config(codec); | |
4387 | if (err < 0) { | |
4388 | alc_free(codec); | |
4389 | return err; | |
4390 | } else if (! err) { | |
4391 | printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n"); | |
4392 | board_config = ALC882_3ST_DIG; | |
4393 | } | |
4394 | } | |
4395 | ||
4396 | if (board_config != ALC882_AUTO) | |
4397 | setup_preset(spec, &alc882_presets[board_config]); | |
1da177e4 LT |
4398 | |
4399 | spec->stream_name_analog = "ALC882 Analog"; | |
df694daa KY |
4400 | spec->stream_analog_playback = &alc882_pcm_analog_playback; |
4401 | spec->stream_analog_capture = &alc882_pcm_analog_capture; | |
1da177e4 LT |
4402 | |
4403 | spec->stream_name_digital = "ALC882 Digital"; | |
df694daa KY |
4404 | spec->stream_digital_playback = &alc882_pcm_digital_playback; |
4405 | spec->stream_digital_capture = &alc882_pcm_digital_capture; | |
1da177e4 | 4406 | |
df694daa KY |
4407 | if (! spec->adc_nids && spec->input_mux) { |
4408 | /* check whether NID 0x07 is valid */ | |
4a471b7d | 4409 | unsigned int wcap = get_wcaps(codec, 0x07); |
df694daa KY |
4410 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ |
4411 | if (wcap != AC_WID_AUD_IN) { | |
4412 | spec->adc_nids = alc882_adc_nids_alt; | |
4413 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt); | |
4414 | spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer; | |
4415 | spec->num_mixers++; | |
4416 | } else { | |
4417 | spec->adc_nids = alc882_adc_nids; | |
4418 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids); | |
4419 | spec->mixers[spec->num_mixers] = alc882_capture_mixer; | |
4420 | spec->num_mixers++; | |
4421 | } | |
4422 | } | |
1da177e4 LT |
4423 | |
4424 | codec->patch_ops = alc_patch_ops; | |
df694daa | 4425 | if (board_config == ALC882_AUTO) |
ae6b813a | 4426 | spec->init_hook = alc882_auto_init; |
df694daa KY |
4427 | |
4428 | return 0; | |
4429 | } | |
4430 | ||
4431 | /* | |
4432 | * ALC262 support | |
4433 | */ | |
4434 | ||
4435 | #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID | |
4436 | #define ALC262_DIGIN_NID ALC880_DIGIN_NID | |
4437 | ||
4438 | #define alc262_dac_nids alc260_dac_nids | |
4439 | #define alc262_adc_nids alc882_adc_nids | |
4440 | #define alc262_adc_nids_alt alc882_adc_nids_alt | |
4441 | ||
4442 | #define alc262_modes alc260_modes | |
c5f2ea08 | 4443 | #define alc262_capture_source alc882_capture_source |
df694daa KY |
4444 | |
4445 | static struct snd_kcontrol_new alc262_base_mixer[] = { | |
4446 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
4447 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
4448 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
4449 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
4450 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
4451 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
4452 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
4453 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
4454 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
4455 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
4456 | /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
4457 | HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */ | |
4458 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT), | |
4459 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
4460 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
4461 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | |
df694daa | 4462 | { } /* end */ |
834be88d TI |
4463 | }; |
4464 | ||
df694daa KY |
4465 | #define alc262_capture_mixer alc882_capture_mixer |
4466 | #define alc262_capture_alt_mixer alc882_capture_alt_mixer | |
4467 | ||
4468 | /* | |
4469 | * generic initialization of ADC, input mixers and output mixers | |
4470 | */ | |
4471 | static struct hda_verb alc262_init_verbs[] = { | |
4472 | /* | |
4473 | * Unmute ADC0-2 and set the default input to mic-in | |
4474 | */ | |
4475 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4476 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4477 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4478 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4479 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4480 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4481 | ||
4482 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | |
4483 | * mixer widget | |
4484 | * Note: PASD motherboards uses the Line In 2 as the input for front panel | |
4485 | * mic (mic 2) | |
4486 | */ | |
4487 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
4488 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4489 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4490 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
4491 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
4492 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
4493 | ||
4494 | /* | |
4495 | * Set up output mixers (0x0c - 0x0e) | |
4496 | */ | |
4497 | /* set vol=0 to output mixers */ | |
4498 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4499 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4500 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4501 | /* set up input amps for analog loopback */ | |
4502 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
4503 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4504 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4505 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4506 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4507 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4508 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4509 | ||
4510 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
4511 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
4512 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
4513 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
4514 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
4515 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
4516 | ||
4517 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
4518 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
4519 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
4520 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
4521 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
4522 | ||
4523 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4524 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
4525 | ||
4526 | /* FIXME: use matrix-type input source selection */ | |
4527 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
4528 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
4529 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4530 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
4531 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
4532 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
4533 | /* Input mixer2 */ | |
4534 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4535 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
4536 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
4537 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
4538 | /* Input mixer3 */ | |
4539 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4540 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
4541 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
4542 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
4543 | ||
4544 | { } | |
4545 | }; | |
1da177e4 | 4546 | |
834be88d TI |
4547 | /* |
4548 | * fujitsu model | |
4549 | * 0x14 = headphone/spdif-out, 0x15 = internal speaker | |
4550 | */ | |
4551 | ||
4552 | #define ALC_HP_EVENT 0x37 | |
4553 | ||
4554 | static struct hda_verb alc262_fujitsu_unsol_verbs[] = { | |
4555 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, | |
4556 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
4557 | {} | |
4558 | }; | |
4559 | ||
4560 | static struct hda_input_mux alc262_fujitsu_capture_source = { | |
4561 | .num_items = 2, | |
4562 | .items = { | |
4563 | { "Mic", 0x0 }, | |
4564 | { "CD", 0x4 }, | |
4565 | }, | |
4566 | }; | |
4567 | ||
4568 | /* mute/unmute internal speaker according to the hp jack and mute state */ | |
4569 | static void alc262_fujitsu_automute(struct hda_codec *codec, int force) | |
4570 | { | |
4571 | struct alc_spec *spec = codec->spec; | |
4572 | unsigned int mute; | |
4573 | ||
4574 | if (force || ! spec->sense_updated) { | |
4575 | unsigned int present; | |
4576 | /* need to execute and sync at first */ | |
4577 | snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); | |
4578 | present = snd_hda_codec_read(codec, 0x14, 0, | |
4579 | AC_VERB_GET_PIN_SENSE, 0); | |
4580 | spec->jack_present = (present & 0x80000000) != 0; | |
4581 | spec->sense_updated = 1; | |
4582 | } | |
4583 | if (spec->jack_present) { | |
4584 | /* mute internal speaker */ | |
4585 | snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, | |
4586 | 0x80, 0x80); | |
4587 | snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, | |
4588 | 0x80, 0x80); | |
4589 | } else { | |
4590 | /* unmute internal speaker if necessary */ | |
4591 | mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); | |
4592 | snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, | |
4593 | 0x80, mute & 0x80); | |
4594 | mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0); | |
4595 | snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, | |
4596 | 0x80, mute & 0x80); | |
4597 | } | |
4598 | } | |
4599 | ||
4600 | /* unsolicited event for HP jack sensing */ | |
4601 | static void alc262_fujitsu_unsol_event(struct hda_codec *codec, | |
4602 | unsigned int res) | |
4603 | { | |
4604 | if ((res >> 26) != ALC_HP_EVENT) | |
4605 | return; | |
4606 | alc262_fujitsu_automute(codec, 1); | |
4607 | } | |
4608 | ||
4609 | /* bind volumes of both NID 0x0c and 0x0d */ | |
4610 | static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol, | |
4611 | struct snd_ctl_elem_value *ucontrol) | |
4612 | { | |
4613 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
4614 | long *valp = ucontrol->value.integer.value; | |
4615 | int change; | |
4616 | ||
4617 | change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0, | |
4618 | 0x7f, valp[0] & 0x7f); | |
4619 | change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0, | |
4620 | 0x7f, valp[1] & 0x7f); | |
4621 | snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0, | |
4622 | 0x7f, valp[0] & 0x7f); | |
4623 | snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0, | |
4624 | 0x7f, valp[1] & 0x7f); | |
4625 | return change; | |
4626 | } | |
4627 | ||
4628 | /* bind hp and internal speaker mute (with plug check) */ | |
4629 | static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol, | |
4630 | struct snd_ctl_elem_value *ucontrol) | |
4631 | { | |
4632 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
4633 | long *valp = ucontrol->value.integer.value; | |
4634 | int change; | |
4635 | ||
4636 | change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, | |
4637 | 0x80, valp[0] ? 0 : 0x80); | |
4638 | change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, | |
4639 | 0x80, valp[1] ? 0 : 0x80); | |
4640 | if (change || codec->in_resume) | |
4641 | alc262_fujitsu_automute(codec, codec->in_resume); | |
4642 | return change; | |
4643 | } | |
4644 | ||
4645 | static struct snd_kcontrol_new alc262_fujitsu_mixer[] = { | |
4646 | { | |
4647 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
4648 | .name = "Master Playback Volume", | |
4649 | .info = snd_hda_mixer_amp_volume_info, | |
4650 | .get = snd_hda_mixer_amp_volume_get, | |
4651 | .put = alc262_fujitsu_master_vol_put, | |
4652 | .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT), | |
4653 | }, | |
4654 | { | |
4655 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
4656 | .name = "Master Playback Switch", | |
4657 | .info = snd_hda_mixer_amp_switch_info, | |
4658 | .get = snd_hda_mixer_amp_switch_get, | |
4659 | .put = alc262_fujitsu_master_sw_put, | |
4660 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
4661 | }, | |
4662 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
4663 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
4664 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
4665 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
4666 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
4667 | { } /* end */ | |
4668 | }; | |
4669 | ||
df694daa KY |
4670 | /* add playback controls from the parsed DAC table */ |
4671 | static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg) | |
4672 | { | |
4673 | hda_nid_t nid; | |
4674 | int err; | |
4675 | ||
4676 | spec->multiout.num_dacs = 1; /* only use one dac */ | |
4677 | spec->multiout.dac_nids = spec->private_dac_nids; | |
4678 | spec->multiout.dac_nids[0] = 2; | |
4679 | ||
4680 | nid = cfg->line_out_pins[0]; | |
4681 | if (nid) { | |
4682 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume", | |
4683 | HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0) | |
4684 | return err; | |
4685 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch", | |
4686 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) | |
4687 | return err; | |
4688 | } | |
4689 | ||
82bc955f | 4690 | nid = cfg->speaker_pins[0]; |
df694daa KY |
4691 | if (nid) { |
4692 | if (nid == 0x16) { | |
4693 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume", | |
4694 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0) | |
4695 | return err; | |
4696 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch", | |
4697 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) | |
4698 | return err; | |
4699 | } else { | |
df694daa KY |
4700 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch", |
4701 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) | |
4702 | return err; | |
4703 | } | |
4704 | } | |
4705 | nid = cfg->hp_pin; | |
4706 | if (nid) { | |
4707 | /* spec->multiout.hp_nid = 2; */ | |
4708 | if (nid == 0x16) { | |
4709 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume", | |
4710 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0) | |
4711 | return err; | |
4712 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", | |
4713 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) | |
4714 | return err; | |
4715 | } else { | |
df694daa KY |
4716 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", |
4717 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) | |
4718 | return err; | |
4719 | } | |
4720 | } | |
4721 | return 0; | |
4722 | } | |
4723 | ||
4724 | /* identical with ALC880 */ | |
4725 | #define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls | |
4726 | ||
4727 | /* | |
4728 | * generic initialization of ADC, input mixers and output mixers | |
4729 | */ | |
4730 | static struct hda_verb alc262_volume_init_verbs[] = { | |
4731 | /* | |
4732 | * Unmute ADC0-2 and set the default input to mic-in | |
4733 | */ | |
4734 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4735 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4736 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4737 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4738 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4739 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4740 | ||
4741 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | |
4742 | * mixer widget | |
4743 | * Note: PASD motherboards uses the Line In 2 as the input for front panel | |
4744 | * mic (mic 2) | |
4745 | */ | |
4746 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
4747 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4748 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4749 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
4750 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
4751 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
4752 | ||
4753 | /* | |
4754 | * Set up output mixers (0x0c - 0x0f) | |
4755 | */ | |
4756 | /* set vol=0 to output mixers */ | |
4757 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4758 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4759 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4760 | ||
4761 | /* set up input amps for analog loopback */ | |
4762 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
4763 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4764 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4765 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4766 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4767 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4768 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
4769 | ||
4770 | /* FIXME: use matrix-type input source selection */ | |
4771 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
4772 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
4773 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4774 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
4775 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
4776 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
4777 | /* Input mixer2 */ | |
4778 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4779 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
4780 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
4781 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
4782 | /* Input mixer3 */ | |
4783 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4784 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
4785 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
4786 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
4787 | ||
4788 | { } | |
4789 | }; | |
4790 | ||
4791 | /* pcm configuration: identiacal with ALC880 */ | |
4792 | #define alc262_pcm_analog_playback alc880_pcm_analog_playback | |
4793 | #define alc262_pcm_analog_capture alc880_pcm_analog_capture | |
4794 | #define alc262_pcm_digital_playback alc880_pcm_digital_playback | |
4795 | #define alc262_pcm_digital_capture alc880_pcm_digital_capture | |
4796 | ||
4797 | /* | |
4798 | * BIOS auto configuration | |
4799 | */ | |
4800 | static int alc262_parse_auto_config(struct hda_codec *codec) | |
4801 | { | |
4802 | struct alc_spec *spec = codec->spec; | |
4803 | int err; | |
4804 | static hda_nid_t alc262_ignore[] = { 0x1d, 0 }; | |
4805 | ||
4806 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | |
4807 | alc262_ignore)) < 0) | |
4808 | return err; | |
82bc955f | 4809 | if (! spec->autocfg.line_outs) |
df694daa KY |
4810 | return 0; /* can't find valid BIOS pin config */ |
4811 | if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || | |
4812 | (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) | |
4813 | return err; | |
4814 | ||
4815 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
4816 | ||
4817 | if (spec->autocfg.dig_out_pin) | |
4818 | spec->multiout.dig_out_nid = ALC262_DIGOUT_NID; | |
4819 | if (spec->autocfg.dig_in_pin) | |
4820 | spec->dig_in_nid = ALC262_DIGIN_NID; | |
4821 | ||
4822 | if (spec->kctl_alloc) | |
4823 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
4824 | ||
4825 | spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs; | |
4826 | spec->input_mux = &spec->private_imux; | |
4827 | ||
4828 | return 1; | |
4829 | } | |
4830 | ||
4831 | #define alc262_auto_init_multi_out alc882_auto_init_multi_out | |
4832 | #define alc262_auto_init_hp_out alc882_auto_init_hp_out | |
4833 | #define alc262_auto_init_analog_input alc882_auto_init_analog_input | |
4834 | ||
4835 | ||
4836 | /* init callback for auto-configuration model -- overriding the default init */ | |
ae6b813a | 4837 | static void alc262_auto_init(struct hda_codec *codec) |
df694daa | 4838 | { |
df694daa KY |
4839 | alc262_auto_init_multi_out(codec); |
4840 | alc262_auto_init_hp_out(codec); | |
4841 | alc262_auto_init_analog_input(codec); | |
df694daa KY |
4842 | } |
4843 | ||
4844 | /* | |
4845 | * configuration and preset | |
4846 | */ | |
4847 | static struct hda_board_config alc262_cfg_tbl[] = { | |
4848 | { .modelname = "basic", .config = ALC262_BASIC }, | |
834be88d TI |
4849 | { .modelname = "fujitsu", .config = ALC262_FUJITSU }, |
4850 | { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397, .config = ALC262_FUJITSU }, | |
df694daa KY |
4851 | { .modelname = "auto", .config = ALC262_AUTO }, |
4852 | {} | |
4853 | }; | |
4854 | ||
4855 | static struct alc_config_preset alc262_presets[] = { | |
4856 | [ALC262_BASIC] = { | |
4857 | .mixers = { alc262_base_mixer }, | |
4858 | .init_verbs = { alc262_init_verbs }, | |
4859 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
4860 | .dac_nids = alc262_dac_nids, | |
4861 | .hp_nid = 0x03, | |
4862 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
4863 | .channel_mode = alc262_modes, | |
a3bcba38 | 4864 | .input_mux = &alc262_capture_source, |
df694daa | 4865 | }, |
834be88d TI |
4866 | [ALC262_FUJITSU] = { |
4867 | .mixers = { alc262_fujitsu_mixer }, | |
4868 | .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs }, | |
4869 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
4870 | .dac_nids = alc262_dac_nids, | |
4871 | .hp_nid = 0x03, | |
4872 | .dig_out_nid = ALC262_DIGOUT_NID, | |
4873 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
4874 | .channel_mode = alc262_modes, | |
4875 | .input_mux = &alc262_fujitsu_capture_source, | |
ae6b813a | 4876 | .unsol_event = alc262_fujitsu_unsol_event, |
834be88d | 4877 | }, |
df694daa KY |
4878 | }; |
4879 | ||
4880 | static int patch_alc262(struct hda_codec *codec) | |
4881 | { | |
4882 | struct alc_spec *spec; | |
4883 | int board_config; | |
4884 | int err; | |
4885 | ||
4886 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); | |
4887 | if (spec == NULL) | |
4888 | return -ENOMEM; | |
4889 | ||
4890 | codec->spec = spec; | |
4891 | #if 0 | |
4892 | /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */ | |
4893 | { | |
4894 | int tmp; | |
4895 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); | |
4896 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); | |
4897 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); | |
4898 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); | |
4899 | } | |
4900 | #endif | |
4901 | ||
4902 | board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl); | |
4903 | if (board_config < 0 || board_config >= ALC262_MODEL_LAST) { | |
4904 | printk(KERN_INFO "hda_codec: Unknown model for ALC262, trying auto-probe from BIOS...\n"); | |
4905 | board_config = ALC262_AUTO; | |
4906 | } | |
4907 | ||
4908 | if (board_config == ALC262_AUTO) { | |
4909 | /* automatic parse from the BIOS config */ | |
4910 | err = alc262_parse_auto_config(codec); | |
4911 | if (err < 0) { | |
4912 | alc_free(codec); | |
4913 | return err; | |
4914 | } else if (! err) { | |
4915 | printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n"); | |
4916 | board_config = ALC262_BASIC; | |
4917 | } | |
4918 | } | |
4919 | ||
4920 | if (board_config != ALC262_AUTO) | |
4921 | setup_preset(spec, &alc262_presets[board_config]); | |
4922 | ||
4923 | spec->stream_name_analog = "ALC262 Analog"; | |
4924 | spec->stream_analog_playback = &alc262_pcm_analog_playback; | |
4925 | spec->stream_analog_capture = &alc262_pcm_analog_capture; | |
4926 | ||
4927 | spec->stream_name_digital = "ALC262 Digital"; | |
4928 | spec->stream_digital_playback = &alc262_pcm_digital_playback; | |
4929 | spec->stream_digital_capture = &alc262_pcm_digital_capture; | |
4930 | ||
4931 | if (! spec->adc_nids && spec->input_mux) { | |
4932 | /* check whether NID 0x07 is valid */ | |
4a471b7d TI |
4933 | unsigned int wcap = get_wcaps(codec, 0x07); |
4934 | ||
df694daa KY |
4935 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ |
4936 | if (wcap != AC_WID_AUD_IN) { | |
4937 | spec->adc_nids = alc262_adc_nids_alt; | |
4938 | spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt); | |
4939 | spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer; | |
4940 | spec->num_mixers++; | |
4941 | } else { | |
4942 | spec->adc_nids = alc262_adc_nids; | |
4943 | spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids); | |
4944 | spec->mixers[spec->num_mixers] = alc262_capture_mixer; | |
4945 | spec->num_mixers++; | |
4946 | } | |
4947 | } | |
4948 | ||
4949 | codec->patch_ops = alc_patch_ops; | |
4950 | if (board_config == ALC262_AUTO) | |
ae6b813a | 4951 | spec->init_hook = alc262_auto_init; |
834be88d | 4952 | |
df694daa KY |
4953 | return 0; |
4954 | } | |
4955 | ||
4956 | ||
4957 | /* | |
4958 | * ALC861 channel source setting (2/6 channel selection for 3-stack) | |
4959 | */ | |
4960 | ||
4961 | /* | |
4962 | * set the path ways for 2 channel output | |
4963 | * need to set the codec line out and mic 1 pin widgets to inputs | |
4964 | */ | |
4965 | static struct hda_verb alc861_threestack_ch2_init[] = { | |
4966 | /* set pin widget 1Ah (line in) for input */ | |
4967 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
4968 | /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */ | |
4969 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
4970 | ||
4971 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, | |
4972 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, //mic | |
4973 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, //line in | |
4974 | { } /* end */ | |
4975 | }; | |
4976 | /* | |
4977 | * 6ch mode | |
4978 | * need to set the codec line out and mic 1 pin widgets to outputs | |
4979 | */ | |
4980 | static struct hda_verb alc861_threestack_ch6_init[] = { | |
4981 | /* set pin widget 1Ah (line in) for output (Back Surround)*/ | |
4982 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
4983 | /* set pin widget 18h (mic1) for output (CLFE)*/ | |
4984 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
4985 | ||
4986 | { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
4987 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
4988 | ||
4989 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, | |
4990 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, //mic | |
4991 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, //line in | |
4992 | { } /* end */ | |
4993 | }; | |
4994 | ||
4995 | static struct hda_channel_mode alc861_threestack_modes[2] = { | |
4996 | { 2, alc861_threestack_ch2_init }, | |
4997 | { 6, alc861_threestack_ch6_init }, | |
4998 | }; | |
4999 | ||
5000 | /* patch-ALC861 */ | |
5001 | ||
5002 | static struct snd_kcontrol_new alc861_base_mixer[] = { | |
5003 | /* output mixer control */ | |
5004 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
5005 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
5006 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
5007 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
5008 | HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), | |
5009 | ||
5010 | /*Input mixer control */ | |
5011 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
5012 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
5013 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
5014 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
5015 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
5016 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
5017 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
5018 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
5019 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
5020 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
5021 | ||
5022 | /* Capture mixer control */ | |
5023 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
5024 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
5025 | { | |
5026 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5027 | .name = "Capture Source", | |
5028 | .count = 1, | |
5029 | .info = alc_mux_enum_info, | |
5030 | .get = alc_mux_enum_get, | |
5031 | .put = alc_mux_enum_put, | |
5032 | }, | |
5033 | { } /* end */ | |
5034 | }; | |
5035 | ||
5036 | static struct snd_kcontrol_new alc861_3ST_mixer[] = { | |
5037 | /* output mixer control */ | |
5038 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
5039 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
5040 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
5041 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
5042 | /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ | |
5043 | ||
5044 | /* Input mixer control */ | |
5045 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
5046 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
5047 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
5048 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
5049 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
5050 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
5051 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
5052 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
5053 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
5054 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
5055 | ||
5056 | /* Capture mixer control */ | |
5057 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
5058 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
5059 | { | |
5060 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5061 | .name = "Capture Source", | |
5062 | .count = 1, | |
5063 | .info = alc_mux_enum_info, | |
5064 | .get = alc_mux_enum_get, | |
5065 | .put = alc_mux_enum_put, | |
5066 | }, | |
5067 | { | |
5068 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5069 | .name = "Channel Mode", | |
5070 | .info = alc_ch_mode_info, | |
5071 | .get = alc_ch_mode_get, | |
5072 | .put = alc_ch_mode_put, | |
5073 | .private_value = ARRAY_SIZE(alc861_threestack_modes), | |
5074 | }, | |
5075 | { } /* end */ | |
5076 | }; | |
5077 | ||
5078 | /* | |
5079 | * generic initialization of ADC, input mixers and output mixers | |
5080 | */ | |
5081 | static struct hda_verb alc861_base_init_verbs[] = { | |
5082 | /* | |
5083 | * Unmute ADC0 and set the default input to mic-in | |
5084 | */ | |
5085 | /* port-A for surround (rear panel) */ | |
5086 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
5087 | { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
5088 | /* port-B for mic-in (rear panel) with vref */ | |
5089 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
5090 | /* port-C for line-in (rear panel) */ | |
5091 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
5092 | /* port-D for Front */ | |
5093 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
5094 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
5095 | /* port-E for HP out (front panel) */ | |
5096 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | |
5097 | /* route front PCM to HP */ | |
5098 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
5099 | /* port-F for mic-in (front panel) with vref */ | |
5100 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
5101 | /* port-G for CLFE (rear panel) */ | |
5102 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
5103 | { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
5104 | /* port-H for side (rear panel) */ | |
5105 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
5106 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
5107 | /* CD-in */ | |
5108 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
5109 | /* route front mic to ADC1*/ | |
5110 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5111 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5112 | ||
5113 | /* Unmute DAC0~3 & spdif out*/ | |
5114 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5115 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5116 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5117 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5118 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5119 | ||
5120 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
5121 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5122 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5123 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5124 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5125 | ||
5126 | /* Unmute Stereo Mixer 15 */ | |
5127 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5128 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5129 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
5130 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step | |
5131 | ||
5132 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5133 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5134 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5135 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5136 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5137 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5138 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5139 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5140 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front) | |
5141 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
5142 | ||
5143 | { } | |
5144 | }; | |
5145 | ||
5146 | static struct hda_verb alc861_threestack_init_verbs[] = { | |
5147 | /* | |
5148 | * Unmute ADC0 and set the default input to mic-in | |
5149 | */ | |
5150 | /* port-A for surround (rear panel) */ | |
5151 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
5152 | /* port-B for mic-in (rear panel) with vref */ | |
5153 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
5154 | /* port-C for line-in (rear panel) */ | |
5155 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
5156 | /* port-D for Front */ | |
5157 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
5158 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
5159 | /* port-E for HP out (front panel) */ | |
5160 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | |
5161 | /* route front PCM to HP */ | |
5162 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
5163 | /* port-F for mic-in (front panel) with vref */ | |
5164 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
5165 | /* port-G for CLFE (rear panel) */ | |
5166 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
5167 | /* port-H for side (rear panel) */ | |
5168 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
5169 | /* CD-in */ | |
5170 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
5171 | /* route front mic to ADC1*/ | |
5172 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5173 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5174 | /* Unmute DAC0~3 & spdif out*/ | |
5175 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5176 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5177 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5178 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5179 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5180 | ||
5181 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
5182 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5183 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5184 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5185 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5186 | ||
5187 | /* Unmute Stereo Mixer 15 */ | |
5188 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5189 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5190 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
5191 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step | |
5192 | ||
5193 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5194 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5195 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5196 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5197 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5198 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5199 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5200 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5201 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front) | |
5202 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
5203 | { } | |
5204 | }; | |
5205 | /* | |
5206 | * generic initialization of ADC, input mixers and output mixers | |
5207 | */ | |
5208 | static struct hda_verb alc861_auto_init_verbs[] = { | |
5209 | /* | |
5210 | * Unmute ADC0 and set the default input to mic-in | |
5211 | */ | |
5212 | // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5213 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5214 | ||
5215 | /* Unmute DAC0~3 & spdif out*/ | |
5216 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5217 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5218 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5219 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5220 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5221 | ||
5222 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
5223 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5224 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5225 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5226 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5227 | ||
5228 | /* Unmute Stereo Mixer 15 */ | |
5229 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5230 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5231 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
5232 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, | |
5233 | ||
5234 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5235 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5236 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5237 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5238 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5239 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5240 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5241 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5242 | ||
5243 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5244 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5245 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
5246 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
5247 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5248 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5249 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
5250 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
5251 | ||
5252 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1 | |
5253 | ||
5254 | { } | |
5255 | }; | |
5256 | ||
5257 | /* pcm configuration: identiacal with ALC880 */ | |
5258 | #define alc861_pcm_analog_playback alc880_pcm_analog_playback | |
5259 | #define alc861_pcm_analog_capture alc880_pcm_analog_capture | |
5260 | #define alc861_pcm_digital_playback alc880_pcm_digital_playback | |
5261 | #define alc861_pcm_digital_capture alc880_pcm_digital_capture | |
5262 | ||
5263 | ||
5264 | #define ALC861_DIGOUT_NID 0x07 | |
5265 | ||
5266 | static struct hda_channel_mode alc861_8ch_modes[1] = { | |
5267 | { 8, NULL } | |
5268 | }; | |
5269 | ||
5270 | static hda_nid_t alc861_dac_nids[4] = { | |
5271 | /* front, surround, clfe, side */ | |
5272 | 0x03, 0x06, 0x05, 0x04 | |
5273 | }; | |
5274 | ||
5275 | static hda_nid_t alc861_adc_nids[1] = { | |
5276 | /* ADC0-2 */ | |
5277 | 0x08, | |
5278 | }; | |
5279 | ||
5280 | static struct hda_input_mux alc861_capture_source = { | |
5281 | .num_items = 5, | |
5282 | .items = { | |
5283 | { "Mic", 0x0 }, | |
5284 | { "Front Mic", 0x3 }, | |
5285 | { "Line", 0x1 }, | |
5286 | { "CD", 0x4 }, | |
5287 | { "Mixer", 0x5 }, | |
5288 | }, | |
5289 | }; | |
5290 | ||
5291 | /* fill in the dac_nids table from the parsed pin configuration */ | |
5292 | static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg) | |
5293 | { | |
5294 | int i; | |
5295 | hda_nid_t nid; | |
5296 | ||
5297 | spec->multiout.dac_nids = spec->private_dac_nids; | |
5298 | for (i = 0; i < cfg->line_outs; i++) { | |
5299 | nid = cfg->line_out_pins[i]; | |
5300 | if (nid) { | |
5301 | if (i >= ARRAY_SIZE(alc861_dac_nids)) | |
5302 | continue; | |
5303 | spec->multiout.dac_nids[i] = alc861_dac_nids[i]; | |
5304 | } | |
5305 | } | |
5306 | spec->multiout.num_dacs = cfg->line_outs; | |
5307 | return 0; | |
5308 | } | |
5309 | ||
5310 | /* add playback controls from the parsed DAC table */ | |
5311 | static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec, | |
5312 | const struct auto_pin_cfg *cfg) | |
5313 | { | |
5314 | char name[32]; | |
5315 | static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; | |
5316 | hda_nid_t nid; | |
5317 | int i, idx, err; | |
5318 | ||
5319 | for (i = 0; i < cfg->line_outs; i++) { | |
5320 | nid = spec->multiout.dac_nids[i]; | |
5321 | if (! nid) | |
5322 | continue; | |
5323 | if (nid == 0x05) { | |
5324 | /* Center/LFE */ | |
5325 | if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch", | |
5326 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0) | |
5327 | return err; | |
5328 | if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch", | |
5329 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) | |
5330 | return err; | |
5331 | } else { | |
5332 | for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++) | |
5333 | if (nid == alc861_dac_nids[idx]) | |
5334 | break; | |
5335 | sprintf(name, "%s Playback Switch", chname[idx]); | |
5336 | if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, | |
5337 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) | |
5338 | return err; | |
5339 | } | |
5340 | } | |
5341 | return 0; | |
5342 | } | |
5343 | ||
5344 | static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin) | |
5345 | { | |
5346 | int err; | |
5347 | hda_nid_t nid; | |
5348 | ||
5349 | if (! pin) | |
5350 | return 0; | |
5351 | ||
5352 | if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) { | |
5353 | nid = 0x03; | |
5354 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", | |
5355 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) | |
5356 | return err; | |
5357 | spec->multiout.hp_nid = nid; | |
5358 | } | |
5359 | return 0; | |
5360 | } | |
5361 | ||
5362 | /* create playback/capture controls for input pins */ | |
5363 | static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg) | |
5364 | { | |
df694daa KY |
5365 | struct hda_input_mux *imux = &spec->private_imux; |
5366 | int i, err, idx, idx1; | |
5367 | ||
5368 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
5369 | switch(cfg->input_pins[i]) { | |
5370 | case 0x0c: | |
5371 | idx1 = 1; | |
5372 | idx = 2; // Line In | |
5373 | break; | |
5374 | case 0x0f: | |
5375 | idx1 = 2; | |
5376 | idx = 2; // Line In | |
5377 | break; | |
5378 | case 0x0d: | |
5379 | idx1 = 0; | |
5380 | idx = 1; // Mic In | |
5381 | break; | |
5382 | case 0x10: | |
5383 | idx1 = 3; | |
5384 | idx = 1; // Mic In | |
5385 | break; | |
5386 | case 0x11: | |
5387 | idx1 = 4; | |
5388 | idx = 0; // CD | |
5389 | break; | |
5390 | default: | |
5391 | continue; | |
5392 | } | |
5393 | ||
4a471b7d TI |
5394 | err = new_analog_input(spec, cfg->input_pins[i], |
5395 | auto_pin_cfg_labels[i], idx, 0x15); | |
df694daa KY |
5396 | if (err < 0) |
5397 | return err; | |
5398 | ||
4a471b7d | 5399 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
df694daa KY |
5400 | imux->items[imux->num_items].index = idx1; |
5401 | imux->num_items++; | |
5402 | } | |
5403 | return 0; | |
5404 | } | |
5405 | ||
5406 | static struct snd_kcontrol_new alc861_capture_mixer[] = { | |
5407 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
5408 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
5409 | ||
5410 | { | |
5411 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5412 | /* The multiple "Capture Source" controls confuse alsamixer | |
5413 | * So call somewhat different.. | |
5414 | *FIXME: the controls appear in the "playback" view! | |
5415 | */ | |
5416 | /* .name = "Capture Source", */ | |
5417 | .name = "Input Source", | |
5418 | .count = 1, | |
5419 | .info = alc_mux_enum_info, | |
5420 | .get = alc_mux_enum_get, | |
5421 | .put = alc_mux_enum_put, | |
5422 | }, | |
5423 | { } /* end */ | |
5424 | }; | |
5425 | ||
5426 | static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid, | |
5427 | int pin_type, int dac_idx) | |
5428 | { | |
5429 | /* set as output */ | |
5430 | ||
5431 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); | |
5432 | snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); | |
5433 | ||
5434 | } | |
5435 | ||
5436 | static void alc861_auto_init_multi_out(struct hda_codec *codec) | |
5437 | { | |
5438 | struct alc_spec *spec = codec->spec; | |
5439 | int i; | |
5440 | ||
5441 | for (i = 0; i < spec->autocfg.line_outs; i++) { | |
5442 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
5443 | if (nid) | |
5444 | alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]); | |
5445 | } | |
5446 | } | |
5447 | ||
5448 | static void alc861_auto_init_hp_out(struct hda_codec *codec) | |
5449 | { | |
5450 | struct alc_spec *spec = codec->spec; | |
5451 | hda_nid_t pin; | |
5452 | ||
5453 | pin = spec->autocfg.hp_pin; | |
5454 | if (pin) /* connect to front */ | |
5455 | alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]); | |
5456 | } | |
5457 | ||
5458 | static void alc861_auto_init_analog_input(struct hda_codec *codec) | |
5459 | { | |
5460 | struct alc_spec *spec = codec->spec; | |
5461 | int i; | |
5462 | ||
5463 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
5464 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
5465 | if ((nid>=0x0c) && (nid <=0x11)) { | |
5466 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
5467 | i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); | |
5468 | } | |
5469 | } | |
5470 | } | |
5471 | ||
5472 | /* parse the BIOS configuration and set up the alc_spec */ | |
5473 | /* return 1 if successful, 0 if the proper config is not found, or a negative error code */ | |
5474 | static int alc861_parse_auto_config(struct hda_codec *codec) | |
5475 | { | |
5476 | struct alc_spec *spec = codec->spec; | |
5477 | int err; | |
5478 | static hda_nid_t alc861_ignore[] = { 0x1d, 0 }; | |
5479 | ||
5480 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | |
5481 | alc861_ignore)) < 0) | |
5482 | return err; | |
82bc955f | 5483 | if (! spec->autocfg.line_outs) |
df694daa KY |
5484 | return 0; /* can't find valid BIOS pin config */ |
5485 | ||
5486 | if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 || | |
5487 | (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || | |
5488 | (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 || | |
5489 | (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) | |
5490 | return err; | |
5491 | ||
5492 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
5493 | ||
5494 | if (spec->autocfg.dig_out_pin) | |
5495 | spec->multiout.dig_out_nid = ALC861_DIGOUT_NID; | |
5496 | ||
5497 | if (spec->kctl_alloc) | |
5498 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | |
5499 | ||
5500 | spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs; | |
5501 | ||
5502 | spec->input_mux = &spec->private_imux; | |
5503 | ||
5504 | spec->adc_nids = alc861_adc_nids; | |
5505 | spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); | |
5506 | spec->mixers[spec->num_mixers] = alc861_capture_mixer; | |
5507 | spec->num_mixers++; | |
5508 | ||
5509 | return 1; | |
5510 | } | |
5511 | ||
ae6b813a TI |
5512 | /* additional initialization for auto-configuration model */ |
5513 | static void alc861_auto_init(struct hda_codec *codec) | |
df694daa | 5514 | { |
df694daa KY |
5515 | alc861_auto_init_multi_out(codec); |
5516 | alc861_auto_init_hp_out(codec); | |
5517 | alc861_auto_init_analog_input(codec); | |
df694daa KY |
5518 | } |
5519 | ||
5520 | ||
5521 | /* | |
5522 | * configuration and preset | |
5523 | */ | |
5524 | static struct hda_board_config alc861_cfg_tbl[] = { | |
5525 | { .modelname = "3stack", .config = ALC861_3ST }, | |
5526 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600, .config = ALC861_3ST }, | |
5527 | { .modelname = "3stack-dig", .config = ALC861_3ST_DIG }, | |
5528 | { .modelname = "6stack-dig", .config = ALC861_6ST_DIG }, | |
5529 | { .modelname = "auto", .config = ALC861_AUTO }, | |
5530 | {} | |
5531 | }; | |
5532 | ||
5533 | static struct alc_config_preset alc861_presets[] = { | |
5534 | [ALC861_3ST] = { | |
5535 | .mixers = { alc861_3ST_mixer }, | |
5536 | .init_verbs = { alc861_threestack_init_verbs }, | |
5537 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
5538 | .dac_nids = alc861_dac_nids, | |
5539 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
5540 | .channel_mode = alc861_threestack_modes, | |
5541 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
5542 | .adc_nids = alc861_adc_nids, | |
5543 | .input_mux = &alc861_capture_source, | |
5544 | }, | |
5545 | [ALC861_3ST_DIG] = { | |
5546 | .mixers = { alc861_base_mixer }, | |
5547 | .init_verbs = { alc861_threestack_init_verbs }, | |
5548 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
5549 | .dac_nids = alc861_dac_nids, | |
5550 | .dig_out_nid = ALC861_DIGOUT_NID, | |
5551 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
5552 | .channel_mode = alc861_threestack_modes, | |
5553 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
5554 | .adc_nids = alc861_adc_nids, | |
5555 | .input_mux = &alc861_capture_source, | |
5556 | }, | |
5557 | [ALC861_6ST_DIG] = { | |
5558 | .mixers = { alc861_base_mixer }, | |
5559 | .init_verbs = { alc861_base_init_verbs }, | |
5560 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
5561 | .dac_nids = alc861_dac_nids, | |
5562 | .dig_out_nid = ALC861_DIGOUT_NID, | |
5563 | .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes), | |
5564 | .channel_mode = alc861_8ch_modes, | |
5565 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
5566 | .adc_nids = alc861_adc_nids, | |
5567 | .input_mux = &alc861_capture_source, | |
5568 | }, | |
5569 | }; | |
5570 | ||
5571 | ||
5572 | static int patch_alc861(struct hda_codec *codec) | |
5573 | { | |
5574 | struct alc_spec *spec; | |
5575 | int board_config; | |
5576 | int err; | |
5577 | ||
5578 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); | |
5579 | if (spec == NULL) | |
5580 | return -ENOMEM; | |
5581 | ||
5582 | codec->spec = spec; | |
5583 | ||
5584 | board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl); | |
5585 | if (board_config < 0 || board_config >= ALC861_MODEL_LAST) { | |
5586 | printk(KERN_INFO "hda_codec: Unknown model for ALC861, trying auto-probe from BIOS...\n"); | |
5587 | board_config = ALC861_AUTO; | |
5588 | } | |
5589 | ||
5590 | if (board_config == ALC861_AUTO) { | |
5591 | /* automatic parse from the BIOS config */ | |
5592 | err = alc861_parse_auto_config(codec); | |
5593 | if (err < 0) { | |
5594 | alc_free(codec); | |
5595 | return err; | |
5596 | } else if (! err) { | |
5597 | printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n"); | |
5598 | board_config = ALC861_3ST_DIG; | |
5599 | } | |
5600 | } | |
5601 | ||
5602 | if (board_config != ALC861_AUTO) | |
5603 | setup_preset(spec, &alc861_presets[board_config]); | |
5604 | ||
5605 | spec->stream_name_analog = "ALC861 Analog"; | |
5606 | spec->stream_analog_playback = &alc861_pcm_analog_playback; | |
5607 | spec->stream_analog_capture = &alc861_pcm_analog_capture; | |
5608 | ||
5609 | spec->stream_name_digital = "ALC861 Digital"; | |
5610 | spec->stream_digital_playback = &alc861_pcm_digital_playback; | |
5611 | spec->stream_digital_capture = &alc861_pcm_digital_capture; | |
5612 | ||
5613 | codec->patch_ops = alc_patch_ops; | |
5614 | if (board_config == ALC861_AUTO) | |
ae6b813a | 5615 | spec->init_hook = alc861_auto_init; |
df694daa | 5616 | |
1da177e4 LT |
5617 | return 0; |
5618 | } | |
5619 | ||
5620 | /* | |
5621 | * patch entries | |
5622 | */ | |
5623 | struct hda_codec_preset snd_hda_preset_realtek[] = { | |
5624 | { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, | |
df694daa | 5625 | { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, |
1da177e4 LT |
5626 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
5627 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, | |
df694daa KY |
5628 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 }, |
5629 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, | |
5630 | { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, | |
1da177e4 LT |
5631 | {} /* terminator */ |
5632 | }; |