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