[ALSA] Added model for Uniwill laptop with ALC861
[linux-2.6/linux-2.6-openrd.git] / sound / pci / hda / patch_realtek.c
blobf857e963ff45266803f7b6d23ac1f518c4aeb1a7
1 /*
2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for ALC 260/880/882 codecs
6 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
8 * Takashi Iwai <tiwai@suse.de>
9 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
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.
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.
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
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"
36 /* ALC880 board config type */
37 enum {
38 ALC880_3ST,
39 ALC880_3ST_DIG,
40 ALC880_5ST,
41 ALC880_5ST_DIG,
42 ALC880_W810,
43 ALC880_Z71V,
44 ALC880_6ST,
45 ALC880_6ST_DIG,
46 ALC880_F1734,
47 ALC880_ASUS,
48 ALC880_ASUS_DIG,
49 ALC880_ASUS_W1V,
50 ALC880_ASUS_DIG2,
51 ALC880_UNIWILL_DIG,
52 ALC880_CLEVO,
53 ALC880_TCL_S700,
54 ALC880_LG,
55 ALC880_LG_LW,
56 #ifdef CONFIG_SND_DEBUG
57 ALC880_TEST,
58 #endif
59 ALC880_AUTO,
60 ALC880_MODEL_LAST /* last tag */
63 /* ALC260 models */
64 enum {
65 ALC260_BASIC,
66 ALC260_HP,
67 ALC260_HP_3013,
68 ALC260_FUJITSU_S702X,
69 ALC260_ACER,
70 #ifdef CONFIG_SND_DEBUG
71 ALC260_TEST,
72 #endif
73 ALC260_AUTO,
74 ALC260_MODEL_LAST /* last tag */
77 /* ALC262 models */
78 enum {
79 ALC262_BASIC,
80 ALC262_FUJITSU,
81 ALC262_HP_BPC,
82 ALC262_BENQ_ED8,
83 ALC262_AUTO,
84 ALC262_MODEL_LAST /* last tag */
87 /* ALC861 models */
88 enum {
89 ALC861_3ST,
90 ALC660_3ST,
91 ALC861_3ST_DIG,
92 ALC861_6ST_DIG,
93 ALC861_UNIWILL_M31,
94 ALC861_AUTO,
95 ALC861_MODEL_LAST,
98 /* ALC882 models */
99 enum {
100 ALC882_3ST_DIG,
101 ALC882_6ST_DIG,
102 ALC882_ARIMA,
103 ALC882_AUTO,
104 ALC882_MODEL_LAST,
107 /* ALC883 models */
108 enum {
109 ALC883_3ST_2ch_DIG,
110 ALC883_3ST_6ch_DIG,
111 ALC883_3ST_6ch,
112 ALC883_6ST_DIG,
113 ALC888_DEMO_BOARD,
114 ALC883_AUTO,
115 ALC883_MODEL_LAST,
118 /* for GPIO Poll */
119 #define GPIO_MASK 0x03
121 struct alc_spec {
122 /* codec parameterization */
123 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
124 unsigned int num_mixers;
126 const struct hda_verb *init_verbs[5]; /* initialization verbs
127 * don't forget NULL
128 * termination!
130 unsigned int num_init_verbs;
132 char *stream_name_analog; /* analog PCM stream */
133 struct hda_pcm_stream *stream_analog_playback;
134 struct hda_pcm_stream *stream_analog_capture;
136 char *stream_name_digital; /* digital PCM stream */
137 struct hda_pcm_stream *stream_digital_playback;
138 struct hda_pcm_stream *stream_digital_capture;
140 /* playback */
141 struct hda_multi_out multiout; /* playback set-up
142 * max_channels, dacs must be set
143 * dig_out_nid and hp_nid are optional
146 /* capture */
147 unsigned int num_adc_nids;
148 hda_nid_t *adc_nids;
149 hda_nid_t dig_in_nid; /* digital-in NID; optional */
151 /* capture source */
152 unsigned int num_mux_defs;
153 const struct hda_input_mux *input_mux;
154 unsigned int cur_mux[3];
156 /* channel model */
157 const struct hda_channel_mode *channel_mode;
158 int num_channel_mode;
159 int need_dac_fix;
161 /* PCM information */
162 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
164 /* dynamic controls, init_verbs and input_mux */
165 struct auto_pin_cfg autocfg;
166 unsigned int num_kctl_alloc, num_kctl_used;
167 struct snd_kcontrol_new *kctl_alloc;
168 struct hda_input_mux private_imux;
169 hda_nid_t private_dac_nids[5];
171 /* hooks */
172 void (*init_hook)(struct hda_codec *codec);
173 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
175 /* for pin sensing */
176 unsigned int sense_updated: 1;
177 unsigned int jack_present: 1;
181 * configuration template - to be copied to the spec instance
183 struct alc_config_preset {
184 struct snd_kcontrol_new *mixers[5]; /* should be identical size
185 * with spec
187 const struct hda_verb *init_verbs[5];
188 unsigned int num_dacs;
189 hda_nid_t *dac_nids;
190 hda_nid_t dig_out_nid; /* optional */
191 hda_nid_t hp_nid; /* optional */
192 unsigned int num_adc_nids;
193 hda_nid_t *adc_nids;
194 hda_nid_t dig_in_nid;
195 unsigned int num_channel_mode;
196 const struct hda_channel_mode *channel_mode;
197 int need_dac_fix;
198 unsigned int num_mux_defs;
199 const struct hda_input_mux *input_mux;
200 void (*unsol_event)(struct hda_codec *, unsigned int);
201 void (*init_hook)(struct hda_codec *);
206 * input MUX handling
208 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
209 struct snd_ctl_elem_info *uinfo)
211 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
212 struct alc_spec *spec = codec->spec;
213 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
214 if (mux_idx >= spec->num_mux_defs)
215 mux_idx = 0;
216 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
219 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
220 struct snd_ctl_elem_value *ucontrol)
222 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
223 struct alc_spec *spec = codec->spec;
224 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
226 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
227 return 0;
230 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
231 struct snd_ctl_elem_value *ucontrol)
233 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
234 struct alc_spec *spec = codec->spec;
235 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
236 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
237 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
238 spec->adc_nids[adc_idx],
239 &spec->cur_mux[adc_idx]);
244 * channel mode setting
246 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
247 struct snd_ctl_elem_info *uinfo)
249 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
250 struct alc_spec *spec = codec->spec;
251 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
252 spec->num_channel_mode);
255 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
256 struct snd_ctl_elem_value *ucontrol)
258 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
259 struct alc_spec *spec = codec->spec;
260 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
261 spec->num_channel_mode,
262 spec->multiout.max_channels);
265 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
266 struct snd_ctl_elem_value *ucontrol)
268 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
269 struct alc_spec *spec = codec->spec;
270 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
271 spec->num_channel_mode,
272 &spec->multiout.max_channels);
273 if (! err && spec->need_dac_fix)
274 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
275 return err;
279 * Control the mode of pin widget settings via the mixer. "pc" is used
280 * instead of "%" to avoid consequences of accidently treating the % as
281 * being part of a format specifier. Maximum allowed length of a value is
282 * 63 characters plus NULL terminator.
284 * Note: some retasking pin complexes seem to ignore requests for input
285 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
286 * are requested. Therefore order this list so that this behaviour will not
287 * cause problems when mixer clients move through the enum sequentially.
288 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
289 * March 2006.
291 static char *alc_pin_mode_names[] = {
292 "Mic 50pc bias", "Mic 80pc bias",
293 "Line in", "Line out", "Headphone out",
295 static unsigned char alc_pin_mode_values[] = {
296 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
298 /* The control can present all 5 options, or it can limit the options based
299 * in the pin being assumed to be exclusively an input or an output pin. In
300 * addition, "input" pins may or may not process the mic bias option
301 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
302 * accept requests for bias as of chip versions up to March 2006) and/or
303 * wiring in the computer.
305 #define ALC_PIN_DIR_IN 0x00
306 #define ALC_PIN_DIR_OUT 0x01
307 #define ALC_PIN_DIR_INOUT 0x02
308 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
309 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
311 /* Info about the pin modes supported by the different pin direction modes.
312 * For each direction the minimum and maximum values are given.
314 static signed char alc_pin_mode_dir_info[5][2] = {
315 { 0, 2 }, /* ALC_PIN_DIR_IN */
316 { 3, 4 }, /* ALC_PIN_DIR_OUT */
317 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
318 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
319 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
321 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
322 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
323 #define alc_pin_mode_n_items(_dir) \
324 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
326 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
327 struct snd_ctl_elem_info *uinfo)
329 unsigned int item_num = uinfo->value.enumerated.item;
330 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
332 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
333 uinfo->count = 1;
334 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
336 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
337 item_num = alc_pin_mode_min(dir);
338 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
339 return 0;
342 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
343 struct snd_ctl_elem_value *ucontrol)
345 unsigned int i;
346 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
347 hda_nid_t nid = kcontrol->private_value & 0xffff;
348 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
349 long *valp = ucontrol->value.integer.value;
350 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
351 AC_VERB_GET_PIN_WIDGET_CONTROL,
352 0x00);
354 /* Find enumerated value for current pinctl setting */
355 i = alc_pin_mode_min(dir);
356 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
357 i++;
358 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
359 return 0;
362 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
363 struct snd_ctl_elem_value *ucontrol)
365 signed int change;
366 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
367 hda_nid_t nid = kcontrol->private_value & 0xffff;
368 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
369 long val = *ucontrol->value.integer.value;
370 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
371 AC_VERB_GET_PIN_WIDGET_CONTROL,
372 0x00);
374 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
375 val = alc_pin_mode_min(dir);
377 change = pinctl != alc_pin_mode_values[val];
378 if (change) {
379 /* Set pin mode to that requested */
380 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
381 alc_pin_mode_values[val]);
383 /* Also enable the retasking pin's input/output as required
384 * for the requested pin mode. Enum values of 2 or less are
385 * input modes.
387 * Dynamically switching the input/output buffers probably
388 * reduces noise slightly (particularly on input) so we'll
389 * do it. However, having both input and output buffers
390 * enabled simultaneously doesn't seem to be problematic if
391 * this turns out to be necessary in the future.
393 if (val <= 2) {
394 snd_hda_codec_write(codec, nid, 0,
395 AC_VERB_SET_AMP_GAIN_MUTE,
396 AMP_OUT_MUTE);
397 snd_hda_codec_write(codec, nid, 0,
398 AC_VERB_SET_AMP_GAIN_MUTE,
399 AMP_IN_UNMUTE(0));
400 } else {
401 snd_hda_codec_write(codec, nid, 0,
402 AC_VERB_SET_AMP_GAIN_MUTE,
403 AMP_IN_MUTE(0));
404 snd_hda_codec_write(codec, nid, 0,
405 AC_VERB_SET_AMP_GAIN_MUTE,
406 AMP_OUT_UNMUTE);
409 return change;
412 #define ALC_PIN_MODE(xname, nid, dir) \
413 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
414 .info = alc_pin_mode_info, \
415 .get = alc_pin_mode_get, \
416 .put = alc_pin_mode_put, \
417 .private_value = nid | (dir<<16) }
419 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
420 * together using a mask with more than one bit set. This control is
421 * currently used only by the ALC260 test model. At this stage they are not
422 * needed for any "production" models.
424 #ifdef CONFIG_SND_DEBUG
425 static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
426 struct snd_ctl_elem_info *uinfo)
428 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
429 uinfo->count = 1;
430 uinfo->value.integer.min = 0;
431 uinfo->value.integer.max = 1;
432 return 0;
434 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
435 struct snd_ctl_elem_value *ucontrol)
437 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
438 hda_nid_t nid = kcontrol->private_value & 0xffff;
439 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
440 long *valp = ucontrol->value.integer.value;
441 unsigned int val = snd_hda_codec_read(codec, nid, 0,
442 AC_VERB_GET_GPIO_DATA, 0x00);
444 *valp = (val & mask) != 0;
445 return 0;
447 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
448 struct snd_ctl_elem_value *ucontrol)
450 signed int change;
451 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
452 hda_nid_t nid = kcontrol->private_value & 0xffff;
453 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
454 long val = *ucontrol->value.integer.value;
455 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
456 AC_VERB_GET_GPIO_DATA,
457 0x00);
459 /* Set/unset the masked GPIO bit(s) as needed */
460 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
461 if (val == 0)
462 gpio_data &= ~mask;
463 else
464 gpio_data |= mask;
465 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
467 return change;
469 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
470 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
471 .info = alc_gpio_data_info, \
472 .get = alc_gpio_data_get, \
473 .put = alc_gpio_data_put, \
474 .private_value = nid | (mask<<16) }
475 #endif /* CONFIG_SND_DEBUG */
477 /* A switch control to allow the enabling of the digital IO pins on the
478 * ALC260. This is incredibly simplistic; the intention of this control is
479 * to provide something in the test model allowing digital outputs to be
480 * identified if present. If models are found which can utilise these
481 * outputs a more complete mixer control can be devised for those models if
482 * necessary.
484 #ifdef CONFIG_SND_DEBUG
485 static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
486 struct snd_ctl_elem_info *uinfo)
488 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
489 uinfo->count = 1;
490 uinfo->value.integer.min = 0;
491 uinfo->value.integer.max = 1;
492 return 0;
494 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
495 struct snd_ctl_elem_value *ucontrol)
497 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
498 hda_nid_t nid = kcontrol->private_value & 0xffff;
499 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
500 long *valp = ucontrol->value.integer.value;
501 unsigned int val = snd_hda_codec_read(codec, nid, 0,
502 AC_VERB_GET_DIGI_CONVERT, 0x00);
504 *valp = (val & mask) != 0;
505 return 0;
507 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
508 struct snd_ctl_elem_value *ucontrol)
510 signed int change;
511 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
512 hda_nid_t nid = kcontrol->private_value & 0xffff;
513 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
514 long val = *ucontrol->value.integer.value;
515 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
516 AC_VERB_GET_DIGI_CONVERT,
517 0x00);
519 /* Set/unset the masked control bit(s) as needed */
520 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
521 if (val==0)
522 ctrl_data &= ~mask;
523 else
524 ctrl_data |= mask;
525 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
526 ctrl_data);
528 return change;
530 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
531 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
532 .info = alc_spdif_ctrl_info, \
533 .get = alc_spdif_ctrl_get, \
534 .put = alc_spdif_ctrl_put, \
535 .private_value = nid | (mask<<16) }
536 #endif /* CONFIG_SND_DEBUG */
539 * set up from the preset table
541 static void setup_preset(struct alc_spec *spec,
542 const struct alc_config_preset *preset)
544 int i;
546 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
547 spec->mixers[spec->num_mixers++] = preset->mixers[i];
548 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
549 i++)
550 spec->init_verbs[spec->num_init_verbs++] =
551 preset->init_verbs[i];
553 spec->channel_mode = preset->channel_mode;
554 spec->num_channel_mode = preset->num_channel_mode;
555 spec->need_dac_fix = preset->need_dac_fix;
557 spec->multiout.max_channels = spec->channel_mode[0].channels;
559 spec->multiout.num_dacs = preset->num_dacs;
560 spec->multiout.dac_nids = preset->dac_nids;
561 spec->multiout.dig_out_nid = preset->dig_out_nid;
562 spec->multiout.hp_nid = preset->hp_nid;
564 spec->num_mux_defs = preset->num_mux_defs;
565 if (! spec->num_mux_defs)
566 spec->num_mux_defs = 1;
567 spec->input_mux = preset->input_mux;
569 spec->num_adc_nids = preset->num_adc_nids;
570 spec->adc_nids = preset->adc_nids;
571 spec->dig_in_nid = preset->dig_in_nid;
573 spec->unsol_event = preset->unsol_event;
574 spec->init_hook = preset->init_hook;
578 * ALC880 3-stack model
580 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
581 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
582 * F-Mic = 0x1b, HP = 0x19
585 static hda_nid_t alc880_dac_nids[4] = {
586 /* front, rear, clfe, rear_surr */
587 0x02, 0x05, 0x04, 0x03
590 static hda_nid_t alc880_adc_nids[3] = {
591 /* ADC0-2 */
592 0x07, 0x08, 0x09,
595 /* The datasheet says the node 0x07 is connected from inputs,
596 * but it shows zero connection in the real implementation on some devices.
597 * Note: this is a 915GAV bug, fixed on 915GLV
599 static hda_nid_t alc880_adc_nids_alt[2] = {
600 /* ADC1-2 */
601 0x08, 0x09,
604 #define ALC880_DIGOUT_NID 0x06
605 #define ALC880_DIGIN_NID 0x0a
607 static struct hda_input_mux alc880_capture_source = {
608 .num_items = 4,
609 .items = {
610 { "Mic", 0x0 },
611 { "Front Mic", 0x3 },
612 { "Line", 0x2 },
613 { "CD", 0x4 },
617 /* channel source setting (2/6 channel selection for 3-stack) */
618 /* 2ch mode */
619 static struct hda_verb alc880_threestack_ch2_init[] = {
620 /* set line-in to input, mute it */
621 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
622 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
623 /* set mic-in to input vref 80%, mute it */
624 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
625 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
626 { } /* end */
629 /* 6ch mode */
630 static struct hda_verb alc880_threestack_ch6_init[] = {
631 /* set line-in to output, unmute it */
632 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
633 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
634 /* set mic-in to output, unmute it */
635 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
636 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
637 { } /* end */
640 static struct hda_channel_mode alc880_threestack_modes[2] = {
641 { 2, alc880_threestack_ch2_init },
642 { 6, alc880_threestack_ch6_init },
645 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
646 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
647 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
648 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
649 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
650 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
651 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
652 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
653 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
654 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
655 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
656 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
657 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
658 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
659 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
660 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
661 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
662 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
663 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
664 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
666 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
667 .name = "Channel Mode",
668 .info = alc_ch_mode_info,
669 .get = alc_ch_mode_get,
670 .put = alc_ch_mode_put,
672 { } /* end */
675 /* capture mixer elements */
676 static struct snd_kcontrol_new alc880_capture_mixer[] = {
677 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
678 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
679 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
680 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
681 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
682 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
684 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
685 /* The multiple "Capture Source" controls confuse alsamixer
686 * So call somewhat different..
687 * FIXME: the controls appear in the "playback" view!
689 /* .name = "Capture Source", */
690 .name = "Input Source",
691 .count = 3,
692 .info = alc_mux_enum_info,
693 .get = alc_mux_enum_get,
694 .put = alc_mux_enum_put,
696 { } /* end */
699 /* capture mixer elements (in case NID 0x07 not available) */
700 static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
701 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
702 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
703 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
704 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
706 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
707 /* The multiple "Capture Source" controls confuse alsamixer
708 * So call somewhat different..
709 * FIXME: the controls appear in the "playback" view!
711 /* .name = "Capture Source", */
712 .name = "Input Source",
713 .count = 2,
714 .info = alc_mux_enum_info,
715 .get = alc_mux_enum_get,
716 .put = alc_mux_enum_put,
718 { } /* end */
724 * ALC880 5-stack model
726 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
727 * Side = 0x02 (0xd)
728 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
729 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
732 /* additional mixers to alc880_three_stack_mixer */
733 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
734 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
735 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
736 { } /* end */
739 /* channel source setting (6/8 channel selection for 5-stack) */
740 /* 6ch mode */
741 static struct hda_verb alc880_fivestack_ch6_init[] = {
742 /* set line-in to input, mute it */
743 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
744 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
745 { } /* end */
748 /* 8ch mode */
749 static struct hda_verb alc880_fivestack_ch8_init[] = {
750 /* set line-in to output, unmute it */
751 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
752 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
753 { } /* end */
756 static struct hda_channel_mode alc880_fivestack_modes[2] = {
757 { 6, alc880_fivestack_ch6_init },
758 { 8, alc880_fivestack_ch8_init },
763 * ALC880 6-stack model
765 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
766 * Side = 0x05 (0x0f)
767 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
768 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
771 static hda_nid_t alc880_6st_dac_nids[4] = {
772 /* front, rear, clfe, rear_surr */
773 0x02, 0x03, 0x04, 0x05
776 static struct hda_input_mux alc880_6stack_capture_source = {
777 .num_items = 4,
778 .items = {
779 { "Mic", 0x0 },
780 { "Front Mic", 0x1 },
781 { "Line", 0x2 },
782 { "CD", 0x4 },
786 /* fixed 8-channels */
787 static struct hda_channel_mode alc880_sixstack_modes[1] = {
788 { 8, NULL },
791 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
792 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
793 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
794 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
795 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
796 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
797 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
798 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
799 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
800 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
801 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
802 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
803 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
804 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
805 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
806 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
807 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
808 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
809 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
810 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
811 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
813 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
814 .name = "Channel Mode",
815 .info = alc_ch_mode_info,
816 .get = alc_ch_mode_get,
817 .put = alc_ch_mode_put,
819 { } /* end */
824 * ALC880 W810 model
826 * W810 has rear IO for:
827 * Front (DAC 02)
828 * Surround (DAC 03)
829 * Center/LFE (DAC 04)
830 * Digital out (06)
832 * The system also has a pair of internal speakers, and a headphone jack.
833 * These are both connected to Line2 on the codec, hence to DAC 02.
835 * There is a variable resistor to control the speaker or headphone
836 * volume. This is a hardware-only device without a software API.
838 * Plugging headphones in will disable the internal speakers. This is
839 * implemented in hardware, not via the driver using jack sense. In
840 * a similar fashion, plugging into the rear socket marked "front" will
841 * disable both the speakers and headphones.
843 * For input, there's a microphone jack, and an "audio in" jack.
844 * These may not do anything useful with this driver yet, because I
845 * haven't setup any initialization verbs for these yet...
848 static hda_nid_t alc880_w810_dac_nids[3] = {
849 /* front, rear/surround, clfe */
850 0x02, 0x03, 0x04
853 /* fixed 6 channels */
854 static struct hda_channel_mode alc880_w810_modes[1] = {
855 { 6, NULL }
858 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
859 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
860 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
861 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
862 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
863 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
864 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
865 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
866 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
867 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
868 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
869 { } /* end */
874 * Z710V model
876 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
877 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
878 * Line = 0x1a
881 static hda_nid_t alc880_z71v_dac_nids[1] = {
882 0x02
884 #define ALC880_Z71V_HP_DAC 0x03
886 /* fixed 2 channels */
887 static struct hda_channel_mode alc880_2_jack_modes[1] = {
888 { 2, NULL }
891 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
892 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
893 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
894 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
895 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
896 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
897 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
898 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
899 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
900 { } /* end */
904 /* FIXME! */
906 * ALC880 F1734 model
908 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
909 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
912 static hda_nid_t alc880_f1734_dac_nids[1] = {
913 0x03
915 #define ALC880_F1734_HP_DAC 0x02
917 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
918 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
919 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
920 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
921 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
922 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
923 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
924 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
925 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
926 { } /* end */
930 /* FIXME! */
932 * ALC880 ASUS model
934 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
935 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
936 * Mic = 0x18, Line = 0x1a
939 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
940 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
942 static struct snd_kcontrol_new alc880_asus_mixer[] = {
943 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
944 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
945 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
946 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
947 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
948 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
949 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
950 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
951 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
952 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
953 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
954 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
955 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
956 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
958 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
959 .name = "Channel Mode",
960 .info = alc_ch_mode_info,
961 .get = alc_ch_mode_get,
962 .put = alc_ch_mode_put,
964 { } /* end */
967 /* FIXME! */
969 * ALC880 ASUS W1V model
971 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
972 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
973 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
976 /* additional mixers to alc880_asus_mixer */
977 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
978 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
979 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
980 { } /* end */
983 /* additional mixers to alc880_asus_mixer */
984 static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
985 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
986 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
987 { } /* end */
990 /* TCL S700 */
991 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
992 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
993 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
994 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
995 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
996 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
997 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
998 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
999 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1000 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1002 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1003 /* The multiple "Capture Source" controls confuse alsamixer
1004 * So call somewhat different..
1005 * FIXME: the controls appear in the "playback" view!
1007 /* .name = "Capture Source", */
1008 .name = "Input Source",
1009 .count = 1,
1010 .info = alc_mux_enum_info,
1011 .get = alc_mux_enum_get,
1012 .put = alc_mux_enum_put,
1014 { } /* end */
1018 * build control elements
1020 static int alc_build_controls(struct hda_codec *codec)
1022 struct alc_spec *spec = codec->spec;
1023 int err;
1024 int i;
1026 for (i = 0; i < spec->num_mixers; i++) {
1027 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1028 if (err < 0)
1029 return err;
1032 if (spec->multiout.dig_out_nid) {
1033 err = snd_hda_create_spdif_out_ctls(codec,
1034 spec->multiout.dig_out_nid);
1035 if (err < 0)
1036 return err;
1038 if (spec->dig_in_nid) {
1039 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1040 if (err < 0)
1041 return err;
1043 return 0;
1048 * initialize the codec volumes, etc
1052 * generic initialization of ADC, input mixers and output mixers
1054 static struct hda_verb alc880_volume_init_verbs[] = {
1056 * Unmute ADC0-2 and set the default input to mic-in
1058 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1059 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1060 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1061 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1062 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1063 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1065 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1066 * mixer widget
1067 * Note: PASD motherboards uses the Line In 2 as the input for front
1068 * panel mic (mic 2)
1070 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
1071 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1072 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1073 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1074 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1075 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
1078 * Set up output mixers (0x0c - 0x0f)
1080 /* set vol=0 to output mixers */
1081 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1082 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1083 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1084 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1085 /* set up input amps for analog loopback */
1086 /* Amp Indices: DAC = 0, mixer = 1 */
1087 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1088 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1089 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1090 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1091 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1092 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1093 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1094 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1100 * 3-stack pin configuration:
1101 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1103 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1105 * preset connection lists of input pins
1106 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1108 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1109 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1110 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1113 * Set pin mode and muting
1115 /* set front pin widgets 0x14 for output */
1116 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1117 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1118 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1119 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1120 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1121 /* Mic2 (as headphone out) for HP output */
1122 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1123 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1124 /* Line In pin widget for input */
1125 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1126 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1127 /* Line2 (as front mic) pin widget for input and vref at 80% */
1128 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1129 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1130 /* CD pin widget for input */
1131 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1137 * 5-stack pin configuration:
1138 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1139 * line-in/side = 0x1a, f-mic = 0x1b
1141 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1143 * preset connection lists of input pins
1144 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1146 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1147 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1150 * Set pin mode and muting
1152 /* set pin widgets 0x14-0x17 for output */
1153 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1154 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1155 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1156 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1157 /* unmute pins for output (no gain on this amp) */
1158 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1159 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1160 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1161 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1163 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1164 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1165 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1166 /* Mic2 (as headphone out) for HP output */
1167 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1168 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1169 /* Line In pin widget for input */
1170 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1171 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1172 /* Line2 (as front mic) pin widget for input and vref at 80% */
1173 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1174 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1175 /* CD pin widget for input */
1176 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1182 * W810 pin configuration:
1183 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1185 static struct hda_verb alc880_pin_w810_init_verbs[] = {
1186 /* hphone/speaker input selector: front DAC */
1187 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1189 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1190 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1191 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1192 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1193 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1194 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1196 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1197 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1203 * Z71V pin configuration:
1204 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1206 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
1207 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1208 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1209 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1210 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1212 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1213 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1214 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1215 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1221 * 6-stack pin configuration:
1222 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1223 * f-mic = 0x19, line = 0x1a, HP = 0x1b
1225 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1226 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1228 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1229 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1230 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1231 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1232 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1233 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1234 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1235 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1237 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1238 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1239 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1240 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1241 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1242 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1243 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1244 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1245 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1250 /* FIXME! */
1252 * F1734 pin configuration:
1253 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1255 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1256 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1257 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1258 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1259 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1261 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1262 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1263 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1264 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1266 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1267 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1268 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1269 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1270 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1271 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1272 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1273 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1274 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1279 /* FIXME! */
1281 * ASUS pin configuration:
1282 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1284 static struct hda_verb alc880_pin_asus_init_verbs[] = {
1285 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1286 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1287 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1288 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1290 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1291 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1292 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1293 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1294 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1295 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1296 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1297 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1299 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1300 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1301 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1302 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1303 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1304 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1305 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1306 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1307 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1312 /* Enable GPIO mask and set output */
1313 static struct hda_verb alc880_gpio1_init_verbs[] = {
1314 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
1315 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
1316 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
1321 /* Enable GPIO mask and set output */
1322 static struct hda_verb alc880_gpio2_init_verbs[] = {
1323 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1324 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1325 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
1330 /* Clevo m520g init */
1331 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1332 /* headphone output */
1333 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1334 /* line-out */
1335 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1336 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1337 /* Line-in */
1338 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1339 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1340 /* CD */
1341 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1342 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1343 /* Mic1 (rear panel) */
1344 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1345 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1346 /* Mic2 (front panel) */
1347 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1348 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1349 /* headphone */
1350 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1351 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1352 /* change to EAPD mode */
1353 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1354 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1359 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
1360 /* change to EAPD mode */
1361 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1362 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1364 /* Headphone output */
1365 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1366 /* Front output*/
1367 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1368 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1370 /* Line In pin widget for input */
1371 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1372 /* CD pin widget for input */
1373 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1374 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1375 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1377 /* change to EAPD mode */
1378 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1379 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1385 * LG m1 express dual
1387 * Pin assignment:
1388 * Rear Line-In/Out (blue): 0x14
1389 * Build-in Mic-In: 0x15
1390 * Speaker-out: 0x17
1391 * HP-Out (green): 0x1b
1392 * Mic-In/Out (red): 0x19
1393 * SPDIF-Out: 0x1e
1396 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1397 static hda_nid_t alc880_lg_dac_nids[3] = {
1398 0x05, 0x02, 0x03
1401 /* seems analog CD is not working */
1402 static struct hda_input_mux alc880_lg_capture_source = {
1403 .num_items = 3,
1404 .items = {
1405 { "Mic", 0x1 },
1406 { "Line", 0x5 },
1407 { "Internal Mic", 0x6 },
1411 /* 2,4,6 channel modes */
1412 static struct hda_verb alc880_lg_ch2_init[] = {
1413 /* set line-in and mic-in to input */
1414 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1415 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1419 static struct hda_verb alc880_lg_ch4_init[] = {
1420 /* set line-in to out and mic-in to input */
1421 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1422 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1426 static struct hda_verb alc880_lg_ch6_init[] = {
1427 /* set line-in and mic-in to output */
1428 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1429 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1433 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1434 { 2, alc880_lg_ch2_init },
1435 { 4, alc880_lg_ch4_init },
1436 { 6, alc880_lg_ch6_init },
1439 static struct snd_kcontrol_new alc880_lg_mixer[] = {
1440 /* FIXME: it's not really "master" but front channels */
1441 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1442 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1443 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1444 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1445 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1446 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1447 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1448 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1449 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1450 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1451 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1452 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1453 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1454 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1456 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1457 .name = "Channel Mode",
1458 .info = alc_ch_mode_info,
1459 .get = alc_ch_mode_get,
1460 .put = alc_ch_mode_put,
1462 { } /* end */
1465 static struct hda_verb alc880_lg_init_verbs[] = {
1466 /* set capture source to mic-in */
1467 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1468 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1469 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1470 /* mute all amp mixer inputs */
1471 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1472 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1473 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1474 /* line-in to input */
1475 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1476 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1477 /* built-in mic */
1478 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1479 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1480 /* speaker-out */
1481 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1482 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1483 /* mic-in to input */
1484 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1485 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1486 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1487 /* HP-out */
1488 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1489 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1490 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1491 /* jack sense */
1492 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1496 /* toggle speaker-output according to the hp-jack state */
1497 static void alc880_lg_automute(struct hda_codec *codec)
1499 unsigned int present;
1501 present = snd_hda_codec_read(codec, 0x1b, 0,
1502 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1503 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
1504 0x80, present ? 0x80 : 0);
1505 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
1506 0x80, present ? 0x80 : 0);
1509 static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1511 /* Looks like the unsol event is incompatible with the standard
1512 * definition. 4bit tag is placed at 28 bit!
1514 if ((res >> 28) == 0x01)
1515 alc880_lg_automute(codec);
1519 * LG LW20
1521 * Pin assignment:
1522 * Speaker-out: 0x14
1523 * Mic-In: 0x18
1524 * Built-in Mic-In: 0x19 (?)
1525 * HP-Out: 0x1b
1526 * SPDIF-Out: 0x1e
1529 /* seems analog CD is not working */
1530 static struct hda_input_mux alc880_lg_lw_capture_source = {
1531 .num_items = 2,
1532 .items = {
1533 { "Mic", 0x0 },
1534 { "Internal Mic", 0x1 },
1538 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1539 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1540 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
1541 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1542 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1543 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1544 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1545 { } /* end */
1548 static struct hda_verb alc880_lg_lw_init_verbs[] = {
1549 /* set capture source to mic-in */
1550 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1551 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1552 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1553 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1554 /* speaker-out */
1555 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1556 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1557 /* HP-out */
1558 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1559 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1560 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1561 /* mic-in to input */
1562 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1563 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1564 /* built-in mic */
1565 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1566 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1567 /* jack sense */
1568 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1572 /* toggle speaker-output according to the hp-jack state */
1573 static void alc880_lg_lw_automute(struct hda_codec *codec)
1575 unsigned int present;
1577 present = snd_hda_codec_read(codec, 0x1b, 0,
1578 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1579 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
1580 0x80, present ? 0x80 : 0);
1581 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
1582 0x80, present ? 0x80 : 0);
1585 static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1587 /* Looks like the unsol event is incompatible with the standard
1588 * definition. 4bit tag is placed at 28 bit!
1590 if ((res >> 28) == 0x01)
1591 alc880_lg_lw_automute(codec);
1595 * Common callbacks
1598 static int alc_init(struct hda_codec *codec)
1600 struct alc_spec *spec = codec->spec;
1601 unsigned int i;
1603 for (i = 0; i < spec->num_init_verbs; i++)
1604 snd_hda_sequence_write(codec, spec->init_verbs[i]);
1606 if (spec->init_hook)
1607 spec->init_hook(codec);
1609 return 0;
1612 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
1614 struct alc_spec *spec = codec->spec;
1616 if (spec->unsol_event)
1617 spec->unsol_event(codec, res);
1620 #ifdef CONFIG_PM
1622 * resume
1624 static int alc_resume(struct hda_codec *codec)
1626 struct alc_spec *spec = codec->spec;
1627 int i;
1629 alc_init(codec);
1630 for (i = 0; i < spec->num_mixers; i++)
1631 snd_hda_resume_ctls(codec, spec->mixers[i]);
1632 if (spec->multiout.dig_out_nid)
1633 snd_hda_resume_spdif_out(codec);
1634 if (spec->dig_in_nid)
1635 snd_hda_resume_spdif_in(codec);
1637 return 0;
1639 #endif
1642 * Analog playback callbacks
1644 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
1645 struct hda_codec *codec,
1646 struct snd_pcm_substream *substream)
1648 struct alc_spec *spec = codec->spec;
1649 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1652 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1653 struct hda_codec *codec,
1654 unsigned int stream_tag,
1655 unsigned int format,
1656 struct snd_pcm_substream *substream)
1658 struct alc_spec *spec = codec->spec;
1659 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
1660 stream_tag, format, substream);
1663 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1664 struct hda_codec *codec,
1665 struct snd_pcm_substream *substream)
1667 struct alc_spec *spec = codec->spec;
1668 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1672 * Digital out
1674 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1675 struct hda_codec *codec,
1676 struct snd_pcm_substream *substream)
1678 struct alc_spec *spec = codec->spec;
1679 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1682 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1683 struct hda_codec *codec,
1684 struct snd_pcm_substream *substream)
1686 struct alc_spec *spec = codec->spec;
1687 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1691 * Analog capture
1693 static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1694 struct hda_codec *codec,
1695 unsigned int stream_tag,
1696 unsigned int format,
1697 struct snd_pcm_substream *substream)
1699 struct alc_spec *spec = codec->spec;
1701 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1702 stream_tag, 0, format);
1703 return 0;
1706 static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1707 struct hda_codec *codec,
1708 struct snd_pcm_substream *substream)
1710 struct alc_spec *spec = codec->spec;
1712 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1713 0, 0, 0);
1714 return 0;
1720 static struct hda_pcm_stream alc880_pcm_analog_playback = {
1721 .substreams = 1,
1722 .channels_min = 2,
1723 .channels_max = 8,
1724 /* NID is set in alc_build_pcms */
1725 .ops = {
1726 .open = alc880_playback_pcm_open,
1727 .prepare = alc880_playback_pcm_prepare,
1728 .cleanup = alc880_playback_pcm_cleanup
1732 static struct hda_pcm_stream alc880_pcm_analog_capture = {
1733 .substreams = 2,
1734 .channels_min = 2,
1735 .channels_max = 2,
1736 /* NID is set in alc_build_pcms */
1737 .ops = {
1738 .prepare = alc880_capture_pcm_prepare,
1739 .cleanup = alc880_capture_pcm_cleanup
1743 static struct hda_pcm_stream alc880_pcm_digital_playback = {
1744 .substreams = 1,
1745 .channels_min = 2,
1746 .channels_max = 2,
1747 /* NID is set in alc_build_pcms */
1748 .ops = {
1749 .open = alc880_dig_playback_pcm_open,
1750 .close = alc880_dig_playback_pcm_close
1754 static struct hda_pcm_stream alc880_pcm_digital_capture = {
1755 .substreams = 1,
1756 .channels_min = 2,
1757 .channels_max = 2,
1758 /* NID is set in alc_build_pcms */
1761 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
1762 static struct hda_pcm_stream alc_pcm_null_playback = {
1763 .substreams = 0,
1764 .channels_min = 0,
1765 .channels_max = 0,
1768 static int alc_build_pcms(struct hda_codec *codec)
1770 struct alc_spec *spec = codec->spec;
1771 struct hda_pcm *info = spec->pcm_rec;
1772 int i;
1774 codec->num_pcms = 1;
1775 codec->pcm_info = info;
1777 info->name = spec->stream_name_analog;
1778 if (spec->stream_analog_playback) {
1779 snd_assert(spec->multiout.dac_nids, return -EINVAL);
1780 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
1781 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
1783 if (spec->stream_analog_capture) {
1784 snd_assert(spec->adc_nids, return -EINVAL);
1785 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1786 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1789 if (spec->channel_mode) {
1790 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
1791 for (i = 0; i < spec->num_channel_mode; i++) {
1792 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
1793 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
1798 /* If the use of more than one ADC is requested for the current
1799 * model, configure a second analog capture-only PCM.
1801 if (spec->num_adc_nids > 1) {
1802 codec->num_pcms++;
1803 info++;
1804 info->name = spec->stream_name_analog;
1805 /* No playback stream for second PCM */
1806 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
1807 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
1808 if (spec->stream_analog_capture) {
1809 snd_assert(spec->adc_nids, return -EINVAL);
1810 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1811 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
1815 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
1816 codec->num_pcms++;
1817 info++;
1818 info->name = spec->stream_name_digital;
1819 if (spec->multiout.dig_out_nid &&
1820 spec->stream_digital_playback) {
1821 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
1822 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
1824 if (spec->dig_in_nid &&
1825 spec->stream_digital_capture) {
1826 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
1827 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
1831 return 0;
1834 static void alc_free(struct hda_codec *codec)
1836 struct alc_spec *spec = codec->spec;
1837 unsigned int i;
1839 if (! spec)
1840 return;
1842 if (spec->kctl_alloc) {
1843 for (i = 0; i < spec->num_kctl_used; i++)
1844 kfree(spec->kctl_alloc[i].name);
1845 kfree(spec->kctl_alloc);
1847 kfree(spec);
1852 static struct hda_codec_ops alc_patch_ops = {
1853 .build_controls = alc_build_controls,
1854 .build_pcms = alc_build_pcms,
1855 .init = alc_init,
1856 .free = alc_free,
1857 .unsol_event = alc_unsol_event,
1858 #ifdef CONFIG_PM
1859 .resume = alc_resume,
1860 #endif
1865 * Test configuration for debugging
1867 * Almost all inputs/outputs are enabled. I/O pins can be configured via
1868 * enum controls.
1870 #ifdef CONFIG_SND_DEBUG
1871 static hda_nid_t alc880_test_dac_nids[4] = {
1872 0x02, 0x03, 0x04, 0x05
1875 static struct hda_input_mux alc880_test_capture_source = {
1876 .num_items = 7,
1877 .items = {
1878 { "In-1", 0x0 },
1879 { "In-2", 0x1 },
1880 { "In-3", 0x2 },
1881 { "In-4", 0x3 },
1882 { "CD", 0x4 },
1883 { "Front", 0x5 },
1884 { "Surround", 0x6 },
1888 static struct hda_channel_mode alc880_test_modes[4] = {
1889 { 2, NULL },
1890 { 4, NULL },
1891 { 6, NULL },
1892 { 8, NULL },
1895 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
1896 struct snd_ctl_elem_info *uinfo)
1898 static char *texts[] = {
1899 "N/A", "Line Out", "HP Out",
1900 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
1902 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1903 uinfo->count = 1;
1904 uinfo->value.enumerated.items = 8;
1905 if (uinfo->value.enumerated.item >= 8)
1906 uinfo->value.enumerated.item = 7;
1907 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1908 return 0;
1911 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
1912 struct snd_ctl_elem_value *ucontrol)
1914 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1915 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1916 unsigned int pin_ctl, item = 0;
1918 pin_ctl = snd_hda_codec_read(codec, nid, 0,
1919 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1920 if (pin_ctl & AC_PINCTL_OUT_EN) {
1921 if (pin_ctl & AC_PINCTL_HP_EN)
1922 item = 2;
1923 else
1924 item = 1;
1925 } else if (pin_ctl & AC_PINCTL_IN_EN) {
1926 switch (pin_ctl & AC_PINCTL_VREFEN) {
1927 case AC_PINCTL_VREF_HIZ: item = 3; break;
1928 case AC_PINCTL_VREF_50: item = 4; break;
1929 case AC_PINCTL_VREF_GRD: item = 5; break;
1930 case AC_PINCTL_VREF_80: item = 6; break;
1931 case AC_PINCTL_VREF_100: item = 7; break;
1934 ucontrol->value.enumerated.item[0] = item;
1935 return 0;
1938 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
1939 struct snd_ctl_elem_value *ucontrol)
1941 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1942 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1943 static unsigned int ctls[] = {
1944 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
1945 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
1946 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
1947 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
1948 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
1949 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
1951 unsigned int old_ctl, new_ctl;
1953 old_ctl = snd_hda_codec_read(codec, nid, 0,
1954 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1955 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
1956 if (old_ctl != new_ctl) {
1957 snd_hda_codec_write(codec, nid, 0,
1958 AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
1959 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
1960 (ucontrol->value.enumerated.item[0] >= 3 ?
1961 0xb080 : 0xb000));
1962 return 1;
1964 return 0;
1967 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
1968 struct snd_ctl_elem_info *uinfo)
1970 static char *texts[] = {
1971 "Front", "Surround", "CLFE", "Side"
1973 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1974 uinfo->count = 1;
1975 uinfo->value.enumerated.items = 4;
1976 if (uinfo->value.enumerated.item >= 4)
1977 uinfo->value.enumerated.item = 3;
1978 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1979 return 0;
1982 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
1983 struct snd_ctl_elem_value *ucontrol)
1985 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1986 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1987 unsigned int sel;
1989 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
1990 ucontrol->value.enumerated.item[0] = sel & 3;
1991 return 0;
1994 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
1995 struct snd_ctl_elem_value *ucontrol)
1997 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1998 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1999 unsigned int sel;
2001 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2002 if (ucontrol->value.enumerated.item[0] != sel) {
2003 sel = ucontrol->value.enumerated.item[0] & 3;
2004 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
2005 return 1;
2007 return 0;
2010 #define PIN_CTL_TEST(xname,nid) { \
2011 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2012 .name = xname, \
2013 .info = alc_test_pin_ctl_info, \
2014 .get = alc_test_pin_ctl_get, \
2015 .put = alc_test_pin_ctl_put, \
2016 .private_value = nid \
2019 #define PIN_SRC_TEST(xname,nid) { \
2020 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2021 .name = xname, \
2022 .info = alc_test_pin_src_info, \
2023 .get = alc_test_pin_src_get, \
2024 .put = alc_test_pin_src_put, \
2025 .private_value = nid \
2028 static struct snd_kcontrol_new alc880_test_mixer[] = {
2029 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2030 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2031 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2032 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2033 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2034 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2035 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2036 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2037 PIN_CTL_TEST("Front Pin Mode", 0x14),
2038 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2039 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2040 PIN_CTL_TEST("Side Pin Mode", 0x17),
2041 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2042 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2043 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2044 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2045 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2046 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2047 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2048 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2049 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2050 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2051 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2052 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2053 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2054 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2055 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2056 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2057 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2058 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
2060 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2061 .name = "Channel Mode",
2062 .info = alc_ch_mode_info,
2063 .get = alc_ch_mode_get,
2064 .put = alc_ch_mode_put,
2066 { } /* end */
2069 static struct hda_verb alc880_test_init_verbs[] = {
2070 /* Unmute inputs of 0x0c - 0x0f */
2071 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2072 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2073 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2074 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2075 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2076 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2077 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2078 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2079 /* Vol output for 0x0c-0x0f */
2080 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2081 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2082 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2083 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2084 /* Set output pins 0x14-0x17 */
2085 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2086 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2087 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2088 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2089 /* Unmute output pins 0x14-0x17 */
2090 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2091 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2092 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2093 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2094 /* Set input pins 0x18-0x1c */
2095 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2096 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2097 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2098 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2099 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2100 /* Mute input pins 0x18-0x1b */
2101 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2102 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2103 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2104 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2105 /* ADC set up */
2106 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2107 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2108 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2109 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2110 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2111 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2112 /* Analog input/passthru */
2113 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2114 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2115 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2116 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2117 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2120 #endif
2125 static struct hda_board_config alc880_cfg_tbl[] = {
2126 /* Back 3 jack, front 2 jack */
2127 { .modelname = "3stack", .config = ALC880_3ST },
2128 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
2129 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
2130 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
2131 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
2132 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
2133 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
2134 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
2135 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
2136 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
2137 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
2138 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
2139 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
2140 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
2141 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
2142 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
2143 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
2144 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
2145 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
2146 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
2147 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
2148 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
2149 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
2150 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
2151 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
2152 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
2153 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
2154 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
2155 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
2156 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
2157 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
2158 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
2159 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
2160 /* TCL S700 */
2161 { .modelname = "tcl", .config = ALC880_TCL_S700 },
2162 { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
2164 /* Back 3 jack, front 2 jack (Internal add Aux-In) */
2165 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
2166 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
2167 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
2169 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
2170 { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
2171 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
2172 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
2174 /* Clevo laptops */
2175 { .modelname = "clevo", .config = ALC880_CLEVO },
2176 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520,
2177 .config = ALC880_CLEVO }, /* Clevo m520G NB */
2178 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0660,
2179 .config = ALC880_CLEVO }, /* Clevo m665n */
2181 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
2182 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
2183 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
2184 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
2186 /* Back 5 jack, front 2 jack */
2187 { .modelname = "5stack", .config = ALC880_5ST },
2188 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
2189 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
2190 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
2191 { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
2192 { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
2194 /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
2195 { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
2196 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
2197 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
2198 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
2199 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
2200 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
2201 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
2202 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
2203 { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
2204 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
2205 { .pci_subvendor = 0xa0a0, .pci_subdevice = 0x0560,
2206 .config = ALC880_5ST_DIG }, /* Aopen i915GMm-HFS */
2207 /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
2208 { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
2209 /* note subvendor = 0 below */
2210 /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
2212 { .modelname = "w810", .config = ALC880_W810 },
2213 { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
2215 { .modelname = "z71v", .config = ALC880_Z71V },
2216 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
2218 { .modelname = "6stack", .config = ALC880_6ST },
2219 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
2220 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
2221 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
2222 { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */
2224 { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
2225 { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
2226 { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
2227 { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
2228 { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
2229 { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
2230 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
2231 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
2232 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
2233 { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */
2234 { .pci_subvendor = 0x1509, .pci_subdevice = 0x925d, .config = ALC880_6ST_DIG }, /* FIC P4M-915GD1 */
2235 { .pci_subvendor = 0x1695, .pci_subdevice = 0x4012, .config = ALC880_5ST_DIG }, /* Epox EP-5LDA+ GLi */
2237 { .modelname = "asus", .config = ALC880_ASUS },
2238 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
2239 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
2240 { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
2241 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
2242 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
2243 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
2244 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c2, .config = ALC880_ASUS_DIG }, /* Asus W6A */
2245 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
2246 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
2247 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
2248 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
2249 { .modelname = "asus-w1v", .config = ALC880_ASUS_W1V },
2250 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
2251 { .modelname = "asus-dig", .config = ALC880_ASUS_DIG },
2252 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8181, .config = ALC880_ASUS_DIG }, /* ASUS P4GPL-X */
2253 { .modelname = "asus-dig2", .config = ALC880_ASUS_DIG2 },
2254 { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
2256 { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
2257 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
2259 { .modelname = "F1734", .config = ALC880_F1734 },
2260 { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
2261 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
2263 { .modelname = "lg", .config = ALC880_LG },
2264 { .pci_subvendor = 0x1854, .pci_subdevice = 0x003b, .config = ALC880_LG },
2265 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0068, .config = ALC880_LG },
2267 { .modelname = "lg-lw", .config = ALC880_LG_LW },
2268 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0018, .config = ALC880_LG_LW },
2270 #ifdef CONFIG_SND_DEBUG
2271 { .modelname = "test", .config = ALC880_TEST },
2272 #endif
2273 { .modelname = "auto", .config = ALC880_AUTO },
2279 * ALC880 codec presets
2281 static struct alc_config_preset alc880_presets[] = {
2282 [ALC880_3ST] = {
2283 .mixers = { alc880_three_stack_mixer },
2284 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
2285 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2286 .dac_nids = alc880_dac_nids,
2287 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2288 .channel_mode = alc880_threestack_modes,
2289 .need_dac_fix = 1,
2290 .input_mux = &alc880_capture_source,
2292 [ALC880_3ST_DIG] = {
2293 .mixers = { alc880_three_stack_mixer },
2294 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
2295 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2296 .dac_nids = alc880_dac_nids,
2297 .dig_out_nid = ALC880_DIGOUT_NID,
2298 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2299 .channel_mode = alc880_threestack_modes,
2300 .need_dac_fix = 1,
2301 .input_mux = &alc880_capture_source,
2303 [ALC880_TCL_S700] = {
2304 .mixers = { alc880_tcl_s700_mixer },
2305 .init_verbs = { alc880_volume_init_verbs,
2306 alc880_pin_tcl_S700_init_verbs,
2307 alc880_gpio2_init_verbs },
2308 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2309 .dac_nids = alc880_dac_nids,
2310 .hp_nid = 0x03,
2311 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2312 .channel_mode = alc880_2_jack_modes,
2313 .input_mux = &alc880_capture_source,
2315 [ALC880_5ST] = {
2316 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
2317 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
2318 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2319 .dac_nids = alc880_dac_nids,
2320 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2321 .channel_mode = alc880_fivestack_modes,
2322 .input_mux = &alc880_capture_source,
2324 [ALC880_5ST_DIG] = {
2325 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
2326 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
2327 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2328 .dac_nids = alc880_dac_nids,
2329 .dig_out_nid = ALC880_DIGOUT_NID,
2330 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2331 .channel_mode = alc880_fivestack_modes,
2332 .input_mux = &alc880_capture_source,
2334 [ALC880_6ST] = {
2335 .mixers = { alc880_six_stack_mixer },
2336 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
2337 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2338 .dac_nids = alc880_6st_dac_nids,
2339 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2340 .channel_mode = alc880_sixstack_modes,
2341 .input_mux = &alc880_6stack_capture_source,
2343 [ALC880_6ST_DIG] = {
2344 .mixers = { alc880_six_stack_mixer },
2345 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
2346 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2347 .dac_nids = alc880_6st_dac_nids,
2348 .dig_out_nid = ALC880_DIGOUT_NID,
2349 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2350 .channel_mode = alc880_sixstack_modes,
2351 .input_mux = &alc880_6stack_capture_source,
2353 [ALC880_W810] = {
2354 .mixers = { alc880_w810_base_mixer },
2355 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
2356 alc880_gpio2_init_verbs },
2357 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2358 .dac_nids = alc880_w810_dac_nids,
2359 .dig_out_nid = ALC880_DIGOUT_NID,
2360 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2361 .channel_mode = alc880_w810_modes,
2362 .input_mux = &alc880_capture_source,
2364 [ALC880_Z71V] = {
2365 .mixers = { alc880_z71v_mixer },
2366 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
2367 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2368 .dac_nids = alc880_z71v_dac_nids,
2369 .dig_out_nid = ALC880_DIGOUT_NID,
2370 .hp_nid = 0x03,
2371 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2372 .channel_mode = alc880_2_jack_modes,
2373 .input_mux = &alc880_capture_source,
2375 [ALC880_F1734] = {
2376 .mixers = { alc880_f1734_mixer },
2377 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
2378 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2379 .dac_nids = alc880_f1734_dac_nids,
2380 .hp_nid = 0x02,
2381 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2382 .channel_mode = alc880_2_jack_modes,
2383 .input_mux = &alc880_capture_source,
2385 [ALC880_ASUS] = {
2386 .mixers = { alc880_asus_mixer },
2387 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2388 alc880_gpio1_init_verbs },
2389 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2390 .dac_nids = alc880_asus_dac_nids,
2391 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2392 .channel_mode = alc880_asus_modes,
2393 .need_dac_fix = 1,
2394 .input_mux = &alc880_capture_source,
2396 [ALC880_ASUS_DIG] = {
2397 .mixers = { alc880_asus_mixer },
2398 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2399 alc880_gpio1_init_verbs },
2400 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2401 .dac_nids = alc880_asus_dac_nids,
2402 .dig_out_nid = ALC880_DIGOUT_NID,
2403 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2404 .channel_mode = alc880_asus_modes,
2405 .need_dac_fix = 1,
2406 .input_mux = &alc880_capture_source,
2408 [ALC880_ASUS_DIG2] = {
2409 .mixers = { alc880_asus_mixer },
2410 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2411 alc880_gpio2_init_verbs }, /* use GPIO2 */
2412 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2413 .dac_nids = alc880_asus_dac_nids,
2414 .dig_out_nid = ALC880_DIGOUT_NID,
2415 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2416 .channel_mode = alc880_asus_modes,
2417 .need_dac_fix = 1,
2418 .input_mux = &alc880_capture_source,
2420 [ALC880_ASUS_W1V] = {
2421 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2422 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2423 alc880_gpio1_init_verbs },
2424 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2425 .dac_nids = alc880_asus_dac_nids,
2426 .dig_out_nid = ALC880_DIGOUT_NID,
2427 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2428 .channel_mode = alc880_asus_modes,
2429 .need_dac_fix = 1,
2430 .input_mux = &alc880_capture_source,
2432 [ALC880_UNIWILL_DIG] = {
2433 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
2434 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
2435 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2436 .dac_nids = alc880_asus_dac_nids,
2437 .dig_out_nid = ALC880_DIGOUT_NID,
2438 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2439 .channel_mode = alc880_asus_modes,
2440 .need_dac_fix = 1,
2441 .input_mux = &alc880_capture_source,
2443 [ALC880_CLEVO] = {
2444 .mixers = { alc880_three_stack_mixer },
2445 .init_verbs = { alc880_volume_init_verbs,
2446 alc880_pin_clevo_init_verbs },
2447 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2448 .dac_nids = alc880_dac_nids,
2449 .hp_nid = 0x03,
2450 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2451 .channel_mode = alc880_threestack_modes,
2452 .need_dac_fix = 1,
2453 .input_mux = &alc880_capture_source,
2455 [ALC880_LG] = {
2456 .mixers = { alc880_lg_mixer },
2457 .init_verbs = { alc880_volume_init_verbs,
2458 alc880_lg_init_verbs },
2459 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2460 .dac_nids = alc880_lg_dac_nids,
2461 .dig_out_nid = ALC880_DIGOUT_NID,
2462 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2463 .channel_mode = alc880_lg_ch_modes,
2464 .need_dac_fix = 1,
2465 .input_mux = &alc880_lg_capture_source,
2466 .unsol_event = alc880_lg_unsol_event,
2467 .init_hook = alc880_lg_automute,
2469 [ALC880_LG_LW] = {
2470 .mixers = { alc880_lg_lw_mixer },
2471 .init_verbs = { alc880_volume_init_verbs,
2472 alc880_lg_lw_init_verbs },
2473 .num_dacs = 1,
2474 .dac_nids = alc880_dac_nids,
2475 .dig_out_nid = ALC880_DIGOUT_NID,
2476 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2477 .channel_mode = alc880_2_jack_modes,
2478 .input_mux = &alc880_lg_lw_capture_source,
2479 .unsol_event = alc880_lg_lw_unsol_event,
2480 .init_hook = alc880_lg_lw_automute,
2482 #ifdef CONFIG_SND_DEBUG
2483 [ALC880_TEST] = {
2484 .mixers = { alc880_test_mixer },
2485 .init_verbs = { alc880_test_init_verbs },
2486 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2487 .dac_nids = alc880_test_dac_nids,
2488 .dig_out_nid = ALC880_DIGOUT_NID,
2489 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2490 .channel_mode = alc880_test_modes,
2491 .input_mux = &alc880_test_capture_source,
2493 #endif
2497 * Automatic parse of I/O pins from the BIOS configuration
2500 #define NUM_CONTROL_ALLOC 32
2501 #define NUM_VERB_ALLOC 32
2503 enum {
2504 ALC_CTL_WIDGET_VOL,
2505 ALC_CTL_WIDGET_MUTE,
2506 ALC_CTL_BIND_MUTE,
2508 static struct snd_kcontrol_new alc880_control_templates[] = {
2509 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2510 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2511 HDA_BIND_MUTE(NULL, 0, 0, 0),
2514 /* add dynamic controls */
2515 static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
2517 struct snd_kcontrol_new *knew;
2519 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2520 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2522 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2523 if (! knew)
2524 return -ENOMEM;
2525 if (spec->kctl_alloc) {
2526 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2527 kfree(spec->kctl_alloc);
2529 spec->kctl_alloc = knew;
2530 spec->num_kctl_alloc = num;
2533 knew = &spec->kctl_alloc[spec->num_kctl_used];
2534 *knew = alc880_control_templates[type];
2535 knew->name = kstrdup(name, GFP_KERNEL);
2536 if (! knew->name)
2537 return -ENOMEM;
2538 knew->private_value = val;
2539 spec->num_kctl_used++;
2540 return 0;
2543 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2544 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2545 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2546 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2547 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
2548 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
2549 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
2550 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
2551 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2552 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
2553 #define ALC880_PIN_CD_NID 0x1c
2555 /* fill in the dac_nids table from the parsed pin configuration */
2556 static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
2558 hda_nid_t nid;
2559 int assigned[4];
2560 int i, j;
2562 memset(assigned, 0, sizeof(assigned));
2563 spec->multiout.dac_nids = spec->private_dac_nids;
2565 /* check the pins hardwired to audio widget */
2566 for (i = 0; i < cfg->line_outs; i++) {
2567 nid = cfg->line_out_pins[i];
2568 if (alc880_is_fixed_pin(nid)) {
2569 int idx = alc880_fixed_pin_idx(nid);
2570 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
2571 assigned[idx] = 1;
2574 /* left pins can be connect to any audio widget */
2575 for (i = 0; i < cfg->line_outs; i++) {
2576 nid = cfg->line_out_pins[i];
2577 if (alc880_is_fixed_pin(nid))
2578 continue;
2579 /* search for an empty channel */
2580 for (j = 0; j < cfg->line_outs; j++) {
2581 if (! assigned[j]) {
2582 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
2583 assigned[j] = 1;
2584 break;
2588 spec->multiout.num_dacs = cfg->line_outs;
2589 return 0;
2592 /* add playback controls from the parsed DAC table */
2593 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2594 const struct auto_pin_cfg *cfg)
2596 char name[32];
2597 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
2598 hda_nid_t nid;
2599 int i, err;
2601 for (i = 0; i < cfg->line_outs; i++) {
2602 if (! spec->multiout.dac_nids[i])
2603 continue;
2604 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
2605 if (i == 2) {
2606 /* Center/LFE */
2607 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
2608 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
2609 return err;
2610 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
2611 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
2612 return err;
2613 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
2614 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
2615 return err;
2616 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
2617 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
2618 return err;
2619 } else {
2620 sprintf(name, "%s Playback Volume", chname[i]);
2621 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2622 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2623 return err;
2624 sprintf(name, "%s Playback Switch", chname[i]);
2625 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2626 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2627 return err;
2630 return 0;
2633 /* add playback controls for speaker and HP outputs */
2634 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
2635 const char *pfx)
2637 hda_nid_t nid;
2638 int err;
2639 char name[32];
2641 if (! pin)
2642 return 0;
2644 if (alc880_is_fixed_pin(pin)) {
2645 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
2646 /* specify the DAC as the extra output */
2647 if (! spec->multiout.hp_nid)
2648 spec->multiout.hp_nid = nid;
2649 else
2650 spec->multiout.extra_out_nid[0] = nid;
2651 /* control HP volume/switch on the output mixer amp */
2652 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
2653 sprintf(name, "%s Playback Volume", pfx);
2654 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2655 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2656 return err;
2657 sprintf(name, "%s Playback Switch", pfx);
2658 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2659 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2660 return err;
2661 } else if (alc880_is_multi_pin(pin)) {
2662 /* set manual connection */
2663 /* we have only a switch on HP-out PIN */
2664 sprintf(name, "%s Playback Switch", pfx);
2665 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2666 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
2667 return err;
2669 return 0;
2672 /* create input playback/capture controls for the given pin */
2673 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
2674 int idx, hda_nid_t mix_nid)
2676 char name[32];
2677 int err;
2679 sprintf(name, "%s Playback Volume", ctlname);
2680 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2681 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
2682 return err;
2683 sprintf(name, "%s Playback Switch", ctlname);
2684 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2685 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
2686 return err;
2687 return 0;
2690 /* create playback/capture controls for input pins */
2691 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
2692 const struct auto_pin_cfg *cfg)
2694 struct hda_input_mux *imux = &spec->private_imux;
2695 int i, err, idx;
2697 for (i = 0; i < AUTO_PIN_LAST; i++) {
2698 if (alc880_is_input_pin(cfg->input_pins[i])) {
2699 idx = alc880_input_pin_idx(cfg->input_pins[i]);
2700 err = new_analog_input(spec, cfg->input_pins[i],
2701 auto_pin_cfg_labels[i],
2702 idx, 0x0b);
2703 if (err < 0)
2704 return err;
2705 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2706 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
2707 imux->num_items++;
2710 return 0;
2713 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2714 hda_nid_t nid, int pin_type,
2715 int dac_idx)
2717 /* set as output */
2718 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2719 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2720 /* need the manual connection? */
2721 if (alc880_is_multi_pin(nid)) {
2722 struct alc_spec *spec = codec->spec;
2723 int idx = alc880_multi_pin_idx(nid);
2724 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
2725 AC_VERB_SET_CONNECT_SEL,
2726 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
2730 static void alc880_auto_init_multi_out(struct hda_codec *codec)
2732 struct alc_spec *spec = codec->spec;
2733 int i;
2735 for (i = 0; i < spec->autocfg.line_outs; i++) {
2736 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2737 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2741 static void alc880_auto_init_extra_out(struct hda_codec *codec)
2743 struct alc_spec *spec = codec->spec;
2744 hda_nid_t pin;
2746 pin = spec->autocfg.speaker_pins[0];
2747 if (pin) /* connect to front */
2748 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
2749 pin = spec->autocfg.hp_pin;
2750 if (pin) /* connect to front */
2751 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2754 static void alc880_auto_init_analog_input(struct hda_codec *codec)
2756 struct alc_spec *spec = codec->spec;
2757 int i;
2759 for (i = 0; i < AUTO_PIN_LAST; i++) {
2760 hda_nid_t nid = spec->autocfg.input_pins[i];
2761 if (alc880_is_input_pin(nid)) {
2762 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2763 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2764 if (nid != ALC880_PIN_CD_NID)
2765 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2766 AMP_OUT_MUTE);
2771 /* parse the BIOS configuration and set up the alc_spec */
2772 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2773 static int alc880_parse_auto_config(struct hda_codec *codec)
2775 struct alc_spec *spec = codec->spec;
2776 int err;
2777 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
2779 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
2780 alc880_ignore)) < 0)
2781 return err;
2782 if (! spec->autocfg.line_outs)
2783 return 0; /* can't find valid BIOS pin config */
2785 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
2786 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
2787 (err = alc880_auto_create_extra_out(spec,
2788 spec->autocfg.speaker_pins[0],
2789 "Speaker")) < 0 ||
2790 (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pin,
2791 "Headphone")) < 0 ||
2792 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2793 return err;
2795 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2797 if (spec->autocfg.dig_out_pin)
2798 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
2799 if (spec->autocfg.dig_in_pin)
2800 spec->dig_in_nid = ALC880_DIGIN_NID;
2802 if (spec->kctl_alloc)
2803 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2805 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
2807 spec->num_mux_defs = 1;
2808 spec->input_mux = &spec->private_imux;
2810 return 1;
2813 /* additional initialization for auto-configuration model */
2814 static void alc880_auto_init(struct hda_codec *codec)
2816 alc880_auto_init_multi_out(codec);
2817 alc880_auto_init_extra_out(codec);
2818 alc880_auto_init_analog_input(codec);
2822 * OK, here we have finally the patch for ALC880
2825 static int patch_alc880(struct hda_codec *codec)
2827 struct alc_spec *spec;
2828 int board_config;
2829 int err;
2831 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2832 if (spec == NULL)
2833 return -ENOMEM;
2835 codec->spec = spec;
2837 board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
2838 if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
2839 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
2840 "trying auto-probe from BIOS...\n");
2841 board_config = ALC880_AUTO;
2844 if (board_config == ALC880_AUTO) {
2845 /* automatic parse from the BIOS config */
2846 err = alc880_parse_auto_config(codec);
2847 if (err < 0) {
2848 alc_free(codec);
2849 return err;
2850 } else if (! err) {
2851 printk(KERN_INFO
2852 "hda_codec: Cannot set up configuration "
2853 "from BIOS. Using 3-stack mode...\n");
2854 board_config = ALC880_3ST;
2858 if (board_config != ALC880_AUTO)
2859 setup_preset(spec, &alc880_presets[board_config]);
2861 spec->stream_name_analog = "ALC880 Analog";
2862 spec->stream_analog_playback = &alc880_pcm_analog_playback;
2863 spec->stream_analog_capture = &alc880_pcm_analog_capture;
2865 spec->stream_name_digital = "ALC880 Digital";
2866 spec->stream_digital_playback = &alc880_pcm_digital_playback;
2867 spec->stream_digital_capture = &alc880_pcm_digital_capture;
2869 if (! spec->adc_nids && spec->input_mux) {
2870 /* check whether NID 0x07 is valid */
2871 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
2872 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
2873 if (wcap != AC_WID_AUD_IN) {
2874 spec->adc_nids = alc880_adc_nids_alt;
2875 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
2876 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
2877 spec->num_mixers++;
2878 } else {
2879 spec->adc_nids = alc880_adc_nids;
2880 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
2881 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
2882 spec->num_mixers++;
2886 codec->patch_ops = alc_patch_ops;
2887 if (board_config == ALC880_AUTO)
2888 spec->init_hook = alc880_auto_init;
2890 return 0;
2895 * ALC260 support
2898 static hda_nid_t alc260_dac_nids[1] = {
2899 /* front */
2900 0x02,
2903 static hda_nid_t alc260_adc_nids[1] = {
2904 /* ADC0 */
2905 0x04,
2908 static hda_nid_t alc260_adc_nids_alt[1] = {
2909 /* ADC1 */
2910 0x05,
2913 static hda_nid_t alc260_hp_adc_nids[2] = {
2914 /* ADC1, 0 */
2915 0x05, 0x04
2918 /* NIDs used when simultaneous access to both ADCs makes sense. Note that
2919 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
2921 static hda_nid_t alc260_dual_adc_nids[2] = {
2922 /* ADC0, ADC1 */
2923 0x04, 0x05
2926 #define ALC260_DIGOUT_NID 0x03
2927 #define ALC260_DIGIN_NID 0x06
2929 static struct hda_input_mux alc260_capture_source = {
2930 .num_items = 4,
2931 .items = {
2932 { "Mic", 0x0 },
2933 { "Front Mic", 0x1 },
2934 { "Line", 0x2 },
2935 { "CD", 0x4 },
2939 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
2940 * headphone jack and the internal CD lines since these are the only pins at
2941 * which audio can appear. For flexibility, also allow the option of
2942 * recording the mixer output on the second ADC (ADC0 doesn't have a
2943 * connection to the mixer output).
2945 static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
2947 .num_items = 3,
2948 .items = {
2949 { "Mic/Line", 0x0 },
2950 { "CD", 0x4 },
2951 { "Headphone", 0x2 },
2955 .num_items = 4,
2956 .items = {
2957 { "Mic/Line", 0x0 },
2958 { "CD", 0x4 },
2959 { "Headphone", 0x2 },
2960 { "Mixer", 0x5 },
2966 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
2967 * the Fujitsu S702x, but jacks are marked differently.
2969 static struct hda_input_mux alc260_acer_capture_sources[2] = {
2971 .num_items = 4,
2972 .items = {
2973 { "Mic", 0x0 },
2974 { "Line", 0x2 },
2975 { "CD", 0x4 },
2976 { "Headphone", 0x5 },
2980 .num_items = 5,
2981 .items = {
2982 { "Mic", 0x0 },
2983 { "Line", 0x2 },
2984 { "CD", 0x4 },
2985 { "Headphone", 0x6 },
2986 { "Mixer", 0x5 },
2991 * This is just place-holder, so there's something for alc_build_pcms to look
2992 * at when it calculates the maximum number of channels. ALC260 has no mixer
2993 * element which allows changing the channel mode, so the verb list is
2994 * never used.
2996 static struct hda_channel_mode alc260_modes[1] = {
2997 { 2, NULL },
3001 /* Mixer combinations
3003 * basic: base_output + input + pc_beep + capture
3004 * HP: base_output + input + capture_alt
3005 * HP_3013: hp_3013 + input + capture
3006 * fujitsu: fujitsu + capture
3007 * acer: acer + capture
3010 static struct snd_kcontrol_new alc260_base_output_mixer[] = {
3011 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3012 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
3013 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3014 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3015 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3016 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3017 { } /* end */
3020 static struct snd_kcontrol_new alc260_input_mixer[] = {
3021 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3022 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3023 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3024 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3025 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3026 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3027 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3028 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
3029 { } /* end */
3032 static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3033 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3034 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3035 { } /* end */
3038 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3039 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3040 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3041 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3042 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3043 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3044 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3045 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3046 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
3047 { } /* end */
3050 /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3051 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3053 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
3054 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3055 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
3056 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3057 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3058 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3059 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3060 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
3061 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
3062 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3063 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3064 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3065 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
3066 { } /* end */
3069 /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3070 * versions of the ALC260 don't act on requests to enable mic bias from NID
3071 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3072 * datasheet doesn't mention this restriction. At this stage it's not clear
3073 * whether this behaviour is intentional or is a hardware bug in chip
3074 * revisions available in early 2006. Therefore for now allow the
3075 * "Headphone Jack Mode" control to span all choices, but if it turns out
3076 * that the lack of mic bias for this NID is intentional we could change the
3077 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3079 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3080 * don't appear to make the mic bias available from the "line" jack, even
3081 * though the NID used for this jack (0x14) can supply it. The theory is
3082 * that perhaps Acer have included blocking capacitors between the ALC260
3083 * and the output jack. If this turns out to be the case for all such
3084 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3085 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
3087 static struct snd_kcontrol_new alc260_acer_mixer[] = {
3088 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3089 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
3090 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
3091 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3092 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3093 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3094 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3095 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3096 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3097 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3098 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3099 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3100 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3101 { } /* end */
3104 /* capture mixer elements */
3105 static struct snd_kcontrol_new alc260_capture_mixer[] = {
3106 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3107 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
3108 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3109 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
3111 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3112 /* The multiple "Capture Source" controls confuse alsamixer
3113 * So call somewhat different..
3114 * FIXME: the controls appear in the "playback" view!
3116 /* .name = "Capture Source", */
3117 .name = "Input Source",
3118 .count = 2,
3119 .info = alc_mux_enum_info,
3120 .get = alc_mux_enum_get,
3121 .put = alc_mux_enum_put,
3123 { } /* end */
3126 static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3127 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3128 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3130 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3131 /* The multiple "Capture Source" controls confuse alsamixer
3132 * So call somewhat different..
3133 * FIXME: the controls appear in the "playback" view!
3135 /* .name = "Capture Source", */
3136 .name = "Input Source",
3137 .count = 1,
3138 .info = alc_mux_enum_info,
3139 .get = alc_mux_enum_get,
3140 .put = alc_mux_enum_put,
3142 { } /* end */
3146 * initialization verbs
3148 static struct hda_verb alc260_init_verbs[] = {
3149 /* Line In pin widget for input */
3150 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3151 /* CD pin widget for input */
3152 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3153 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3154 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3155 /* Mic2 (front panel) pin widget for input and vref at 80% */
3156 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3157 /* LINE-2 is used for line-out in rear */
3158 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3159 /* select line-out */
3160 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
3161 /* LINE-OUT pin */
3162 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3163 /* enable HP */
3164 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3165 /* enable Mono */
3166 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3167 /* mute capture amp left and right */
3168 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3169 /* set connection select to line in (default select for this ADC) */
3170 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3171 /* mute capture amp left and right */
3172 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3173 /* set connection select to line in (default select for this ADC) */
3174 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
3175 /* set vol=0 Line-Out mixer amp left and right */
3176 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3177 /* unmute pin widget amp left and right (no gain on this amp) */
3178 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3179 /* set vol=0 HP mixer amp left and right */
3180 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3181 /* unmute pin widget amp left and right (no gain on this amp) */
3182 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3183 /* set vol=0 Mono mixer amp left and right */
3184 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3185 /* unmute pin widget amp left and right (no gain on this amp) */
3186 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3187 /* unmute LINE-2 out pin */
3188 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3189 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3190 /* mute CD */
3191 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3192 /* mute Line In */
3193 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3194 /* mute Mic */
3195 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3196 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3197 /* mute Front out path */
3198 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3199 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3200 /* mute Headphone out path */
3201 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3202 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3203 /* mute Mono out path */
3204 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3205 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3209 #if 0 /* should be identical with alc260_init_verbs? */
3210 static struct hda_verb alc260_hp_init_verbs[] = {
3211 /* Headphone and output */
3212 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3213 /* mono output */
3214 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3215 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3216 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3217 /* Mic2 (front panel) pin widget for input and vref at 80% */
3218 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3219 /* Line In pin widget for input */
3220 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3221 /* Line-2 pin widget for output */
3222 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3223 /* CD pin widget for input */
3224 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3225 /* unmute amp left and right */
3226 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3227 /* set connection select to line in (default select for this ADC) */
3228 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3229 /* unmute Line-Out mixer amp left and right (volume = 0) */
3230 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3231 /* mute pin widget amp left and right (no gain on this amp) */
3232 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3233 /* unmute HP mixer amp left and right (volume = 0) */
3234 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3235 /* mute pin widget amp left and right (no gain on this amp) */
3236 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3237 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3238 /* unmute CD */
3239 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3240 /* unmute Line In */
3241 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3242 /* unmute Mic */
3243 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3244 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3245 /* Unmute Front out path */
3246 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3247 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3248 /* Unmute Headphone out path */
3249 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3250 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3251 /* Unmute Mono out path */
3252 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3253 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3256 #endif
3258 static struct hda_verb alc260_hp_3013_init_verbs[] = {
3259 /* Line out and output */
3260 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3261 /* mono output */
3262 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3263 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3264 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3265 /* Mic2 (front panel) pin widget for input and vref at 80% */
3266 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3267 /* Line In pin widget for input */
3268 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3269 /* Headphone pin widget for output */
3270 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3271 /* CD pin widget for input */
3272 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3273 /* unmute amp left and right */
3274 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3275 /* set connection select to line in (default select for this ADC) */
3276 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3277 /* unmute Line-Out mixer amp left and right (volume = 0) */
3278 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3279 /* mute pin widget amp left and right (no gain on this amp) */
3280 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3281 /* unmute HP mixer amp left and right (volume = 0) */
3282 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3283 /* mute pin widget amp left and right (no gain on this amp) */
3284 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3285 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3286 /* unmute CD */
3287 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3288 /* unmute Line In */
3289 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3290 /* unmute Mic */
3291 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3292 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3293 /* Unmute Front out path */
3294 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3295 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3296 /* Unmute Headphone out path */
3297 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3298 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3299 /* Unmute Mono out path */
3300 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3301 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3305 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
3306 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3307 * audio = 0x16, internal speaker = 0x10.
3309 static struct hda_verb alc260_fujitsu_init_verbs[] = {
3310 /* Disable all GPIOs */
3311 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3312 /* Internal speaker is connected to headphone pin */
3313 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3314 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3315 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3316 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3317 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3318 /* Ensure all other unused pins are disabled and muted. */
3319 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3320 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3321 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3322 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3323 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3324 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3325 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3326 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3328 /* Disable digital (SPDIF) pins */
3329 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3330 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3332 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3333 * when acting as an output.
3335 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3337 /* Start with output sum widgets muted and their output gains at min */
3338 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3339 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3340 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3341 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3342 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3343 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3344 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3345 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3346 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3348 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3349 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3350 /* Unmute Line1 pin widget output buffer since it starts as an output.
3351 * If the pin mode is changed by the user the pin mode control will
3352 * take care of enabling the pin's input/output buffers as needed.
3353 * Therefore there's no need to enable the input buffer at this
3354 * stage.
3356 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3357 /* Unmute input buffer of pin widget used for Line-in (no equiv
3358 * mixer ctrl)
3360 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3362 /* Mute capture amp left and right */
3363 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3364 /* Set ADC connection select to match default mixer setting - line
3365 * in (on mic1 pin)
3367 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3369 /* Do the same for the second ADC: mute capture input amp and
3370 * set ADC connection to line in (on mic1 pin)
3372 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3373 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3375 /* Mute all inputs to mixer widget (even unconnected ones) */
3376 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3377 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3378 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3379 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3380 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3381 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3382 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3383 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3388 /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3389 * similar laptops (adapted from Fujitsu init verbs).
3391 static struct hda_verb alc260_acer_init_verbs[] = {
3392 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3393 * the headphone jack. Turn this on and rely on the standard mute
3394 * methods whenever the user wants to turn these outputs off.
3396 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3397 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3398 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3399 /* Internal speaker/Headphone jack is connected to Line-out pin */
3400 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3401 /* Internal microphone/Mic jack is connected to Mic1 pin */
3402 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3403 /* Line In jack is connected to Line1 pin */
3404 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3405 /* Ensure all other unused pins are disabled and muted. */
3406 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3407 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3408 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3409 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3410 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3411 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3412 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3413 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3414 /* Disable digital (SPDIF) pins */
3415 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3416 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3418 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3419 * bus when acting as outputs.
3421 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3422 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3424 /* Start with output sum widgets muted and their output gains at min */
3425 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3426 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3427 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3428 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3429 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3430 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3431 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3432 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3433 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3435 /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
3436 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3437 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
3438 * inputs. If the pin mode is changed by the user the pin mode control
3439 * will take care of enabling the pin's input/output buffers as needed.
3440 * Therefore there's no need to enable the input buffer at this
3441 * stage.
3443 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3444 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3446 /* Mute capture amp left and right */
3447 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3448 /* Set ADC connection select to match default mixer setting - mic
3449 * (on mic1 pin)
3451 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3453 /* Do similar with the second ADC: mute capture input amp and
3454 * set ADC connection to mic to match ALSA's default state.
3456 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3457 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3459 /* Mute all inputs to mixer widget (even unconnected ones) */
3460 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3461 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3462 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3463 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3464 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3465 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3466 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3467 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3472 /* Test configuration for debugging, modelled after the ALC880 test
3473 * configuration.
3475 #ifdef CONFIG_SND_DEBUG
3476 static hda_nid_t alc260_test_dac_nids[1] = {
3477 0x02,
3479 static hda_nid_t alc260_test_adc_nids[2] = {
3480 0x04, 0x05,
3482 /* For testing the ALC260, each input MUX needs its own definition since
3483 * the signal assignments are different. This assumes that the first ADC
3484 * is NID 0x04.
3486 static struct hda_input_mux alc260_test_capture_sources[2] = {
3488 .num_items = 7,
3489 .items = {
3490 { "MIC1 pin", 0x0 },
3491 { "MIC2 pin", 0x1 },
3492 { "LINE1 pin", 0x2 },
3493 { "LINE2 pin", 0x3 },
3494 { "CD pin", 0x4 },
3495 { "LINE-OUT pin", 0x5 },
3496 { "HP-OUT pin", 0x6 },
3500 .num_items = 8,
3501 .items = {
3502 { "MIC1 pin", 0x0 },
3503 { "MIC2 pin", 0x1 },
3504 { "LINE1 pin", 0x2 },
3505 { "LINE2 pin", 0x3 },
3506 { "CD pin", 0x4 },
3507 { "Mixer", 0x5 },
3508 { "LINE-OUT pin", 0x6 },
3509 { "HP-OUT pin", 0x7 },
3513 static struct snd_kcontrol_new alc260_test_mixer[] = {
3514 /* Output driver widgets */
3515 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3516 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3517 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3518 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
3519 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3520 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
3522 /* Modes for retasking pin widgets
3523 * Note: the ALC260 doesn't seem to act on requests to enable mic
3524 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
3525 * mention this restriction. At this stage it's not clear whether
3526 * this behaviour is intentional or is a hardware bug in chip
3527 * revisions available at least up until early 2006. Therefore for
3528 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
3529 * choices, but if it turns out that the lack of mic bias for these
3530 * NIDs is intentional we could change their modes from
3531 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3533 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
3534 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
3535 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
3536 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
3537 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
3538 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
3540 /* Loopback mixer controls */
3541 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
3542 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
3543 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
3544 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
3545 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
3546 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
3547 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
3548 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
3549 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3550 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3551 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3552 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3553 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
3554 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
3555 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
3556 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
3558 /* Controls for GPIO pins, assuming they are configured as outputs */
3559 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
3560 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
3561 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
3562 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
3564 /* Switches to allow the digital IO pins to be enabled. The datasheet
3565 * is ambigious as to which NID is which; testing on laptops which
3566 * make this output available should provide clarification.
3568 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
3569 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
3571 { } /* end */
3573 static struct hda_verb alc260_test_init_verbs[] = {
3574 /* Enable all GPIOs as outputs with an initial value of 0 */
3575 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
3576 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
3577 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
3579 /* Enable retasking pins as output, initially without power amp */
3580 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3581 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3582 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3583 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3584 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3585 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3587 /* Disable digital (SPDIF) pins initially, but users can enable
3588 * them via a mixer switch. In the case of SPDIF-out, this initverb
3589 * payload also sets the generation to 0, output to be in "consumer"
3590 * PCM format, copyright asserted, no pre-emphasis and no validity
3591 * control.
3593 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3594 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3596 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
3597 * OUT1 sum bus when acting as an output.
3599 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3600 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
3601 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3602 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
3604 /* Start with output sum widgets muted and their output gains at min */
3605 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3606 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3607 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3608 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3609 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3610 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3611 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3612 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3613 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3615 /* Unmute retasking pin widget output buffers since the default
3616 * state appears to be output. As the pin mode is changed by the
3617 * user the pin mode control will take care of enabling the pin's
3618 * input/output buffers as needed.
3620 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3621 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3622 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3623 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3624 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3625 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3626 /* Also unmute the mono-out pin widget */
3627 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3629 /* Mute capture amp left and right */
3630 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3631 /* Set ADC connection select to match default mixer setting (mic1
3632 * pin)
3634 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3636 /* Do the same for the second ADC: mute capture input amp and
3637 * set ADC connection to mic1 pin
3639 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3640 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3642 /* Mute all inputs to mixer widget (even unconnected ones) */
3643 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3644 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3645 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3646 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3647 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3648 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3649 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3650 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3654 #endif
3656 static struct hda_pcm_stream alc260_pcm_analog_playback = {
3657 .substreams = 1,
3658 .channels_min = 2,
3659 .channels_max = 2,
3662 static struct hda_pcm_stream alc260_pcm_analog_capture = {
3663 .substreams = 1,
3664 .channels_min = 2,
3665 .channels_max = 2,
3668 #define alc260_pcm_digital_playback alc880_pcm_digital_playback
3669 #define alc260_pcm_digital_capture alc880_pcm_digital_capture
3672 * for BIOS auto-configuration
3675 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
3676 const char *pfx)
3678 hda_nid_t nid_vol;
3679 unsigned long vol_val, sw_val;
3680 char name[32];
3681 int err;
3683 if (nid >= 0x0f && nid < 0x11) {
3684 nid_vol = nid - 0x7;
3685 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3686 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3687 } else if (nid == 0x11) {
3688 nid_vol = nid - 0x7;
3689 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
3690 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
3691 } else if (nid >= 0x12 && nid <= 0x15) {
3692 nid_vol = 0x08;
3693 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3694 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3695 } else
3696 return 0; /* N/A */
3698 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
3699 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
3700 return err;
3701 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
3702 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
3703 return err;
3704 return 1;
3707 /* add playback controls from the parsed DAC table */
3708 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
3709 const struct auto_pin_cfg *cfg)
3711 hda_nid_t nid;
3712 int err;
3714 spec->multiout.num_dacs = 1;
3715 spec->multiout.dac_nids = spec->private_dac_nids;
3716 spec->multiout.dac_nids[0] = 0x02;
3718 nid = cfg->line_out_pins[0];
3719 if (nid) {
3720 err = alc260_add_playback_controls(spec, nid, "Front");
3721 if (err < 0)
3722 return err;
3725 nid = cfg->speaker_pins[0];
3726 if (nid) {
3727 err = alc260_add_playback_controls(spec, nid, "Speaker");
3728 if (err < 0)
3729 return err;
3732 nid = cfg->hp_pin;
3733 if (nid) {
3734 err = alc260_add_playback_controls(spec, nid, "Headphone");
3735 if (err < 0)
3736 return err;
3738 return 0;
3741 /* create playback/capture controls for input pins */
3742 static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
3743 const struct auto_pin_cfg *cfg)
3745 struct hda_input_mux *imux = &spec->private_imux;
3746 int i, err, idx;
3748 for (i = 0; i < AUTO_PIN_LAST; i++) {
3749 if (cfg->input_pins[i] >= 0x12) {
3750 idx = cfg->input_pins[i] - 0x12;
3751 err = new_analog_input(spec, cfg->input_pins[i],
3752 auto_pin_cfg_labels[i], idx, 0x07);
3753 if (err < 0)
3754 return err;
3755 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3756 imux->items[imux->num_items].index = idx;
3757 imux->num_items++;
3759 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
3760 idx = cfg->input_pins[i] - 0x09;
3761 err = new_analog_input(spec, cfg->input_pins[i],
3762 auto_pin_cfg_labels[i], idx, 0x07);
3763 if (err < 0)
3764 return err;
3765 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3766 imux->items[imux->num_items].index = idx;
3767 imux->num_items++;
3770 return 0;
3773 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
3774 hda_nid_t nid, int pin_type,
3775 int sel_idx)
3777 /* set as output */
3778 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
3779 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
3780 /* need the manual connection? */
3781 if (nid >= 0x12) {
3782 int idx = nid - 0x12;
3783 snd_hda_codec_write(codec, idx + 0x0b, 0,
3784 AC_VERB_SET_CONNECT_SEL, sel_idx);
3789 static void alc260_auto_init_multi_out(struct hda_codec *codec)
3791 struct alc_spec *spec = codec->spec;
3792 hda_nid_t nid;
3794 nid = spec->autocfg.line_out_pins[0];
3795 if (nid)
3796 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3798 nid = spec->autocfg.speaker_pins[0];
3799 if (nid)
3800 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3802 nid = spec->autocfg.hp_pin;
3803 if (nid)
3804 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3807 #define ALC260_PIN_CD_NID 0x16
3808 static void alc260_auto_init_analog_input(struct hda_codec *codec)
3810 struct alc_spec *spec = codec->spec;
3811 int i;
3813 for (i = 0; i < AUTO_PIN_LAST; i++) {
3814 hda_nid_t nid = spec->autocfg.input_pins[i];
3815 if (nid >= 0x12) {
3816 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3817 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
3818 if (nid != ALC260_PIN_CD_NID)
3819 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3820 AMP_OUT_MUTE);
3826 * generic initialization of ADC, input mixers and output mixers
3828 static struct hda_verb alc260_volume_init_verbs[] = {
3830 * Unmute ADC0-1 and set the default input to mic-in
3832 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3833 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3834 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3835 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3837 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3838 * mixer widget
3839 * Note: PASD motherboards uses the Line In 2 as the input for front panel
3840 * mic (mic 2)
3842 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
3843 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3844 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3845 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3846 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
3847 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3850 * Set up output mixers (0x08 - 0x0a)
3852 /* set vol=0 to output mixers */
3853 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3854 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3855 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3856 /* set up input amps for analog loopback */
3857 /* Amp Indices: DAC = 0, mixer = 1 */
3858 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3859 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3860 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3861 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3862 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3863 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3868 static int alc260_parse_auto_config(struct hda_codec *codec)
3870 struct alc_spec *spec = codec->spec;
3871 unsigned int wcap;
3872 int err;
3873 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
3875 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3876 alc260_ignore)) < 0)
3877 return err;
3878 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
3879 return err;
3880 if (! spec->kctl_alloc)
3881 return 0; /* can't find valid BIOS pin config */
3882 if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
3883 return err;
3885 spec->multiout.max_channels = 2;
3887 if (spec->autocfg.dig_out_pin)
3888 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
3889 if (spec->kctl_alloc)
3890 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3892 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
3894 spec->num_mux_defs = 1;
3895 spec->input_mux = &spec->private_imux;
3897 /* check whether NID 0x04 is valid */
3898 wcap = get_wcaps(codec, 0x04);
3899 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
3900 if (wcap != AC_WID_AUD_IN) {
3901 spec->adc_nids = alc260_adc_nids_alt;
3902 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
3903 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
3904 } else {
3905 spec->adc_nids = alc260_adc_nids;
3906 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
3907 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
3909 spec->num_mixers++;
3911 return 1;
3914 /* additional initialization for auto-configuration model */
3915 static void alc260_auto_init(struct hda_codec *codec)
3917 alc260_auto_init_multi_out(codec);
3918 alc260_auto_init_analog_input(codec);
3922 * ALC260 configurations
3924 static struct hda_board_config alc260_cfg_tbl[] = {
3925 { .modelname = "basic", .config = ALC260_BASIC },
3926 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
3927 .config = ALC260_BASIC }, /* Sony VAIO */
3928 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cc,
3929 .config = ALC260_BASIC }, /* Sony VAIO VGN-S3HP */
3930 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cd,
3931 .config = ALC260_BASIC }, /* Sony VAIO */
3932 { .pci_subvendor = 0x152d, .pci_subdevice = 0x0729,
3933 .config = ALC260_BASIC }, /* CTL Travel Master U553W */
3934 { .modelname = "hp", .config = ALC260_HP },
3935 { .modelname = "hp-3013", .config = ALC260_HP_3013 },
3936 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP_3013 },
3937 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
3938 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP_3013 },
3939 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
3940 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
3941 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
3942 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
3943 { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
3944 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
3945 { .modelname = "acer", .config = ALC260_ACER },
3946 { .pci_subvendor = 0x1025, .pci_subdevice = 0x008f, .config = ALC260_ACER },
3947 #ifdef CONFIG_SND_DEBUG
3948 { .modelname = "test", .config = ALC260_TEST },
3949 #endif
3950 { .modelname = "auto", .config = ALC260_AUTO },
3954 static struct alc_config_preset alc260_presets[] = {
3955 [ALC260_BASIC] = {
3956 .mixers = { alc260_base_output_mixer,
3957 alc260_input_mixer,
3958 alc260_pc_beep_mixer,
3959 alc260_capture_mixer },
3960 .init_verbs = { alc260_init_verbs },
3961 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3962 .dac_nids = alc260_dac_nids,
3963 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
3964 .adc_nids = alc260_adc_nids,
3965 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3966 .channel_mode = alc260_modes,
3967 .input_mux = &alc260_capture_source,
3969 [ALC260_HP] = {
3970 .mixers = { alc260_base_output_mixer,
3971 alc260_input_mixer,
3972 alc260_capture_alt_mixer },
3973 .init_verbs = { alc260_init_verbs },
3974 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3975 .dac_nids = alc260_dac_nids,
3976 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
3977 .adc_nids = alc260_hp_adc_nids,
3978 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3979 .channel_mode = alc260_modes,
3980 .input_mux = &alc260_capture_source,
3982 [ALC260_HP_3013] = {
3983 .mixers = { alc260_hp_3013_mixer,
3984 alc260_input_mixer,
3985 alc260_capture_alt_mixer },
3986 .init_verbs = { alc260_hp_3013_init_verbs },
3987 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3988 .dac_nids = alc260_dac_nids,
3989 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
3990 .adc_nids = alc260_hp_adc_nids,
3991 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3992 .channel_mode = alc260_modes,
3993 .input_mux = &alc260_capture_source,
3995 [ALC260_FUJITSU_S702X] = {
3996 .mixers = { alc260_fujitsu_mixer,
3997 alc260_capture_mixer },
3998 .init_verbs = { alc260_fujitsu_init_verbs },
3999 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4000 .dac_nids = alc260_dac_nids,
4001 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4002 .adc_nids = alc260_dual_adc_nids,
4003 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4004 .channel_mode = alc260_modes,
4005 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4006 .input_mux = alc260_fujitsu_capture_sources,
4008 [ALC260_ACER] = {
4009 .mixers = { alc260_acer_mixer,
4010 alc260_capture_mixer },
4011 .init_verbs = { alc260_acer_init_verbs },
4012 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4013 .dac_nids = alc260_dac_nids,
4014 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4015 .adc_nids = alc260_dual_adc_nids,
4016 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4017 .channel_mode = alc260_modes,
4018 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4019 .input_mux = alc260_acer_capture_sources,
4021 #ifdef CONFIG_SND_DEBUG
4022 [ALC260_TEST] = {
4023 .mixers = { alc260_test_mixer,
4024 alc260_capture_mixer },
4025 .init_verbs = { alc260_test_init_verbs },
4026 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4027 .dac_nids = alc260_test_dac_nids,
4028 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4029 .adc_nids = alc260_test_adc_nids,
4030 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4031 .channel_mode = alc260_modes,
4032 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4033 .input_mux = alc260_test_capture_sources,
4035 #endif
4038 static int patch_alc260(struct hda_codec *codec)
4040 struct alc_spec *spec;
4041 int err, board_config;
4043 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4044 if (spec == NULL)
4045 return -ENOMEM;
4047 codec->spec = spec;
4049 board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
4050 if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
4051 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4052 "trying auto-probe from BIOS...\n");
4053 board_config = ALC260_AUTO;
4056 if (board_config == ALC260_AUTO) {
4057 /* automatic parse from the BIOS config */
4058 err = alc260_parse_auto_config(codec);
4059 if (err < 0) {
4060 alc_free(codec);
4061 return err;
4062 } else if (! err) {
4063 printk(KERN_INFO
4064 "hda_codec: Cannot set up configuration "
4065 "from BIOS. Using base mode...\n");
4066 board_config = ALC260_BASIC;
4070 if (board_config != ALC260_AUTO)
4071 setup_preset(spec, &alc260_presets[board_config]);
4073 spec->stream_name_analog = "ALC260 Analog";
4074 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4075 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4077 spec->stream_name_digital = "ALC260 Digital";
4078 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4079 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4081 codec->patch_ops = alc_patch_ops;
4082 if (board_config == ALC260_AUTO)
4083 spec->init_hook = alc260_auto_init;
4085 return 0;
4090 * ALC882 support
4092 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4093 * configuration. Each pin widget can choose any input DACs and a mixer.
4094 * Each ADC is connected from a mixer of all inputs. This makes possible
4095 * 6-channel independent captures.
4097 * In addition, an independent DAC for the multi-playback (not used in this
4098 * driver yet).
4100 #define ALC882_DIGOUT_NID 0x06
4101 #define ALC882_DIGIN_NID 0x0a
4103 static struct hda_channel_mode alc882_ch_modes[1] = {
4104 { 8, NULL }
4107 static hda_nid_t alc882_dac_nids[4] = {
4108 /* front, rear, clfe, rear_surr */
4109 0x02, 0x03, 0x04, 0x05
4112 /* identical with ALC880 */
4113 #define alc882_adc_nids alc880_adc_nids
4114 #define alc882_adc_nids_alt alc880_adc_nids_alt
4116 /* input MUX */
4117 /* FIXME: should be a matrix-type input source selection */
4119 static struct hda_input_mux alc882_capture_source = {
4120 .num_items = 4,
4121 .items = {
4122 { "Mic", 0x0 },
4123 { "Front Mic", 0x1 },
4124 { "Line", 0x2 },
4125 { "CD", 0x4 },
4128 #define alc882_mux_enum_info alc_mux_enum_info
4129 #define alc882_mux_enum_get alc_mux_enum_get
4131 static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
4133 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4134 struct alc_spec *spec = codec->spec;
4135 const struct hda_input_mux *imux = spec->input_mux;
4136 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4137 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4138 hda_nid_t nid = capture_mixers[adc_idx];
4139 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4140 unsigned int i, idx;
4142 idx = ucontrol->value.enumerated.item[0];
4143 if (idx >= imux->num_items)
4144 idx = imux->num_items - 1;
4145 if (*cur_val == idx && ! codec->in_resume)
4146 return 0;
4147 for (i = 0; i < imux->num_items; i++) {
4148 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4149 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4150 v | (imux->items[i].index << 8));
4152 *cur_val = idx;
4153 return 1;
4157 * 6ch mode
4159 static struct hda_verb alc882_sixstack_ch6_init[] = {
4160 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4161 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4162 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4163 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4164 { } /* end */
4168 * 8ch mode
4170 static struct hda_verb alc882_sixstack_ch8_init[] = {
4171 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4172 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4173 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4174 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4175 { } /* end */
4178 static struct hda_channel_mode alc882_sixstack_modes[2] = {
4179 { 6, alc882_sixstack_ch6_init },
4180 { 8, alc882_sixstack_ch8_init },
4183 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4184 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4186 static struct snd_kcontrol_new alc882_base_mixer[] = {
4187 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4188 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4189 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4190 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4191 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4192 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4193 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4194 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4195 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
4196 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
4197 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4198 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4199 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4200 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4201 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4202 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4203 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4204 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4205 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4206 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4207 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4208 { } /* end */
4211 static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4213 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4214 .name = "Channel Mode",
4215 .info = alc_ch_mode_info,
4216 .get = alc_ch_mode_get,
4217 .put = alc_ch_mode_put,
4219 { } /* end */
4222 static struct hda_verb alc882_init_verbs[] = {
4223 /* Front mixer: unmute input/output amp left and right (volume = 0) */
4224 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4225 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4226 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4227 /* Rear mixer */
4228 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4229 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4230 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4231 /* CLFE mixer */
4232 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4233 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4234 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4235 /* Side mixer */
4236 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4237 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4238 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4240 /* Front Pin: output 0 (0x0c) */
4241 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4242 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4243 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
4244 /* Rear Pin: output 1 (0x0d) */
4245 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4246 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4247 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4248 /* CLFE Pin: output 2 (0x0e) */
4249 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4250 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4251 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
4252 /* Side Pin: output 3 (0x0f) */
4253 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4254 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4255 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
4256 /* Mic (rear) pin: input vref at 80% */
4257 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4258 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4259 /* Front Mic pin: input vref at 80% */
4260 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4261 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4262 /* Line In pin: input */
4263 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4264 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4265 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4266 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4267 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4268 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
4269 /* CD pin widget for input */
4270 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4272 /* FIXME: use matrix-type input source selection */
4273 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4274 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4275 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4276 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4277 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4278 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4279 /* Input mixer2 */
4280 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4281 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4282 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4283 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4284 /* Input mixer3 */
4285 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4286 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4287 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4288 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4289 /* ADC1: mute amp left and right */
4290 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4291 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4292 /* ADC2: mute amp left and right */
4293 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4294 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4295 /* ADC3: mute amp left and right */
4296 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4297 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4302 static struct hda_verb alc882_eapd_verbs[] = {
4303 /* change to EAPD mode */
4304 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
4305 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
4306 { }
4310 * generic initialization of ADC, input mixers and output mixers
4312 static struct hda_verb alc882_auto_init_verbs[] = {
4314 * Unmute ADC0-2 and set the default input to mic-in
4316 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4317 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4318 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4319 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4320 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4321 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4323 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4324 * mixer widget
4325 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4326 * mic (mic 2)
4328 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4329 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4330 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4331 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4332 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4333 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4336 * Set up output mixers (0x0c - 0x0f)
4338 /* set vol=0 to output mixers */
4339 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4340 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4341 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4342 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4343 /* set up input amps for analog loopback */
4344 /* Amp Indices: DAC = 0, mixer = 1 */
4345 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4346 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4347 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4348 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4349 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4350 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4351 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4352 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4353 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4354 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4356 /* FIXME: use matrix-type input source selection */
4357 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4358 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4359 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4360 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4361 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4362 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4363 /* Input mixer2 */
4364 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4365 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4366 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4367 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4368 /* Input mixer3 */
4369 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4370 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4371 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4372 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4377 /* capture mixer elements */
4378 static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
4379 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4380 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4381 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4382 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4384 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4385 /* The multiple "Capture Source" controls confuse alsamixer
4386 * So call somewhat different..
4387 * FIXME: the controls appear in the "playback" view!
4389 /* .name = "Capture Source", */
4390 .name = "Input Source",
4391 .count = 2,
4392 .info = alc882_mux_enum_info,
4393 .get = alc882_mux_enum_get,
4394 .put = alc882_mux_enum_put,
4396 { } /* end */
4399 static struct snd_kcontrol_new alc882_capture_mixer[] = {
4400 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
4401 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
4402 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
4403 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
4404 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
4405 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
4407 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4408 /* The multiple "Capture Source" controls confuse alsamixer
4409 * So call somewhat different..
4410 * FIXME: the controls appear in the "playback" view!
4412 /* .name = "Capture Source", */
4413 .name = "Input Source",
4414 .count = 3,
4415 .info = alc882_mux_enum_info,
4416 .get = alc882_mux_enum_get,
4417 .put = alc882_mux_enum_put,
4419 { } /* end */
4422 /* pcm configuration: identiacal with ALC880 */
4423 #define alc882_pcm_analog_playback alc880_pcm_analog_playback
4424 #define alc882_pcm_analog_capture alc880_pcm_analog_capture
4425 #define alc882_pcm_digital_playback alc880_pcm_digital_playback
4426 #define alc882_pcm_digital_capture alc880_pcm_digital_capture
4429 * configuration and preset
4431 static struct hda_board_config alc882_cfg_tbl[] = {
4432 { .modelname = "3stack-dig", .config = ALC882_3ST_DIG },
4433 { .modelname = "6stack-dig", .config = ALC882_6ST_DIG },
4434 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
4435 .config = ALC882_6ST_DIG }, /* MSI */
4436 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
4437 .config = ALC882_6ST_DIG }, /* Foxconn */
4438 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
4439 .config = ALC882_6ST_DIG }, /* ECS to Intel*/
4440 { .modelname = "arima", .config = ALC882_ARIMA },
4441 { .pci_subvendor = 0x161f, .pci_subdevice = 0x2054,
4442 .config = ALC882_ARIMA }, /* Arima W820Di1 */
4443 { .modelname = "auto", .config = ALC882_AUTO },
4447 static struct alc_config_preset alc882_presets[] = {
4448 [ALC882_3ST_DIG] = {
4449 .mixers = { alc882_base_mixer },
4450 .init_verbs = { alc882_init_verbs },
4451 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4452 .dac_nids = alc882_dac_nids,
4453 .dig_out_nid = ALC882_DIGOUT_NID,
4454 .dig_in_nid = ALC882_DIGIN_NID,
4455 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
4456 .channel_mode = alc882_ch_modes,
4457 .need_dac_fix = 1,
4458 .input_mux = &alc882_capture_source,
4460 [ALC882_6ST_DIG] = {
4461 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4462 .init_verbs = { alc882_init_verbs },
4463 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4464 .dac_nids = alc882_dac_nids,
4465 .dig_out_nid = ALC882_DIGOUT_NID,
4466 .dig_in_nid = ALC882_DIGIN_NID,
4467 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4468 .channel_mode = alc882_sixstack_modes,
4469 .input_mux = &alc882_capture_source,
4471 [ALC882_ARIMA] = {
4472 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4473 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
4474 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4475 .dac_nids = alc882_dac_nids,
4476 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4477 .channel_mode = alc882_sixstack_modes,
4478 .input_mux = &alc882_capture_source,
4484 * BIOS auto configuration
4486 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
4487 hda_nid_t nid, int pin_type,
4488 int dac_idx)
4490 /* set as output */
4491 struct alc_spec *spec = codec->spec;
4492 int idx;
4494 if (spec->multiout.dac_nids[dac_idx] == 0x25)
4495 idx = 4;
4496 else
4497 idx = spec->multiout.dac_nids[dac_idx] - 2;
4499 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
4500 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4501 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
4505 static void alc882_auto_init_multi_out(struct hda_codec *codec)
4507 struct alc_spec *spec = codec->spec;
4508 int i;
4510 for (i = 0; i <= HDA_SIDE; i++) {
4511 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4512 if (nid)
4513 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
4517 static void alc882_auto_init_hp_out(struct hda_codec *codec)
4519 struct alc_spec *spec = codec->spec;
4520 hda_nid_t pin;
4522 pin = spec->autocfg.hp_pin;
4523 if (pin) /* connect to front */
4524 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
4527 #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
4528 #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
4530 static void alc882_auto_init_analog_input(struct hda_codec *codec)
4532 struct alc_spec *spec = codec->spec;
4533 int i;
4535 for (i = 0; i < AUTO_PIN_LAST; i++) {
4536 hda_nid_t nid = spec->autocfg.input_pins[i];
4537 if (alc882_is_input_pin(nid)) {
4538 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4539 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
4540 if (nid != ALC882_PIN_CD_NID)
4541 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4542 AMP_OUT_MUTE);
4547 /* almost identical with ALC880 parser... */
4548 static int alc882_parse_auto_config(struct hda_codec *codec)
4550 struct alc_spec *spec = codec->spec;
4551 int err = alc880_parse_auto_config(codec);
4553 if (err < 0)
4554 return err;
4555 else if (err > 0)
4556 /* hack - override the init verbs */
4557 spec->init_verbs[0] = alc882_auto_init_verbs;
4558 return err;
4561 /* additional initialization for auto-configuration model */
4562 static void alc882_auto_init(struct hda_codec *codec)
4564 alc882_auto_init_multi_out(codec);
4565 alc882_auto_init_hp_out(codec);
4566 alc882_auto_init_analog_input(codec);
4569 static int patch_alc882(struct hda_codec *codec)
4571 struct alc_spec *spec;
4572 int err, board_config;
4574 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4575 if (spec == NULL)
4576 return -ENOMEM;
4578 codec->spec = spec;
4580 board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
4582 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
4583 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
4584 "trying auto-probe from BIOS...\n");
4585 board_config = ALC882_AUTO;
4588 if (board_config == ALC882_AUTO) {
4589 /* automatic parse from the BIOS config */
4590 err = alc882_parse_auto_config(codec);
4591 if (err < 0) {
4592 alc_free(codec);
4593 return err;
4594 } else if (! err) {
4595 printk(KERN_INFO
4596 "hda_codec: Cannot set up configuration "
4597 "from BIOS. Using base mode...\n");
4598 board_config = ALC882_3ST_DIG;
4602 if (board_config != ALC882_AUTO)
4603 setup_preset(spec, &alc882_presets[board_config]);
4605 spec->stream_name_analog = "ALC882 Analog";
4606 spec->stream_analog_playback = &alc882_pcm_analog_playback;
4607 spec->stream_analog_capture = &alc882_pcm_analog_capture;
4609 spec->stream_name_digital = "ALC882 Digital";
4610 spec->stream_digital_playback = &alc882_pcm_digital_playback;
4611 spec->stream_digital_capture = &alc882_pcm_digital_capture;
4613 if (! spec->adc_nids && spec->input_mux) {
4614 /* check whether NID 0x07 is valid */
4615 unsigned int wcap = get_wcaps(codec, 0x07);
4616 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4617 if (wcap != AC_WID_AUD_IN) {
4618 spec->adc_nids = alc882_adc_nids_alt;
4619 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
4620 spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
4621 spec->num_mixers++;
4622 } else {
4623 spec->adc_nids = alc882_adc_nids;
4624 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
4625 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
4626 spec->num_mixers++;
4630 codec->patch_ops = alc_patch_ops;
4631 if (board_config == ALC882_AUTO)
4632 spec->init_hook = alc882_auto_init;
4634 return 0;
4638 * ALC883 support
4640 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
4641 * configuration. Each pin widget can choose any input DACs and a mixer.
4642 * Each ADC is connected from a mixer of all inputs. This makes possible
4643 * 6-channel independent captures.
4645 * In addition, an independent DAC for the multi-playback (not used in this
4646 * driver yet).
4648 #define ALC883_DIGOUT_NID 0x06
4649 #define ALC883_DIGIN_NID 0x0a
4651 static hda_nid_t alc883_dac_nids[4] = {
4652 /* front, rear, clfe, rear_surr */
4653 0x02, 0x04, 0x03, 0x05
4656 static hda_nid_t alc883_adc_nids[2] = {
4657 /* ADC1-2 */
4658 0x08, 0x09,
4660 /* input MUX */
4661 /* FIXME: should be a matrix-type input source selection */
4663 static struct hda_input_mux alc883_capture_source = {
4664 .num_items = 4,
4665 .items = {
4666 { "Mic", 0x0 },
4667 { "Front Mic", 0x1 },
4668 { "Line", 0x2 },
4669 { "CD", 0x4 },
4672 #define alc883_mux_enum_info alc_mux_enum_info
4673 #define alc883_mux_enum_get alc_mux_enum_get
4675 static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
4676 struct snd_ctl_elem_value *ucontrol)
4678 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4679 struct alc_spec *spec = codec->spec;
4680 const struct hda_input_mux *imux = spec->input_mux;
4681 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4682 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4683 hda_nid_t nid = capture_mixers[adc_idx];
4684 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4685 unsigned int i, idx;
4687 idx = ucontrol->value.enumerated.item[0];
4688 if (idx >= imux->num_items)
4689 idx = imux->num_items - 1;
4690 if (*cur_val == idx && ! codec->in_resume)
4691 return 0;
4692 for (i = 0; i < imux->num_items; i++) {
4693 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4694 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4695 v | (imux->items[i].index << 8));
4697 *cur_val = idx;
4698 return 1;
4701 * 2ch mode
4703 static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
4704 { 2, NULL }
4708 * 2ch mode
4710 static struct hda_verb alc883_3ST_ch2_init[] = {
4711 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4712 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4713 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4714 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4715 { } /* end */
4719 * 6ch mode
4721 static struct hda_verb alc883_3ST_ch6_init[] = {
4722 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4723 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4724 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4725 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4726 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4727 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4728 { } /* end */
4731 static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
4732 { 2, alc883_3ST_ch2_init },
4733 { 6, alc883_3ST_ch6_init },
4737 * 6ch mode
4739 static struct hda_verb alc883_sixstack_ch6_init[] = {
4740 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4741 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4742 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4743 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4744 { } /* end */
4748 * 8ch mode
4750 static struct hda_verb alc883_sixstack_ch8_init[] = {
4751 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4752 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4753 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4754 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4755 { } /* end */
4758 static struct hda_channel_mode alc883_sixstack_modes[2] = {
4759 { 6, alc883_sixstack_ch6_init },
4760 { 8, alc883_sixstack_ch8_init },
4763 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4764 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4767 static struct snd_kcontrol_new alc883_base_mixer[] = {
4768 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4769 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4770 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4771 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4772 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4773 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4774 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4775 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4776 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
4777 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
4778 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4779 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4780 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4781 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4782 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4783 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4784 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4785 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4786 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4787 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4788 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4789 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4790 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4791 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4792 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4794 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4795 /* .name = "Capture Source", */
4796 .name = "Input Source",
4797 .count = 2,
4798 .info = alc883_mux_enum_info,
4799 .get = alc883_mux_enum_get,
4800 .put = alc883_mux_enum_put,
4802 { } /* end */
4805 static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
4806 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4807 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4808 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4809 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4810 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4811 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4812 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4813 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4814 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4815 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4816 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4817 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4818 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4819 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4820 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4821 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4822 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4824 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4825 /* .name = "Capture Source", */
4826 .name = "Input Source",
4827 .count = 2,
4828 .info = alc883_mux_enum_info,
4829 .get = alc883_mux_enum_get,
4830 .put = alc883_mux_enum_put,
4832 { } /* end */
4835 static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
4836 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4837 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4838 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4839 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4840 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4841 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4842 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4843 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4844 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4845 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4846 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4847 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4848 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4849 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4850 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4851 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4852 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4853 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4854 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4855 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4856 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4857 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4858 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4860 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4861 /* .name = "Capture Source", */
4862 .name = "Input Source",
4863 .count = 2,
4864 .info = alc883_mux_enum_info,
4865 .get = alc883_mux_enum_get,
4866 .put = alc883_mux_enum_put,
4868 { } /* end */
4871 static struct snd_kcontrol_new alc883_chmode_mixer[] = {
4873 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4874 .name = "Channel Mode",
4875 .info = alc_ch_mode_info,
4876 .get = alc_ch_mode_get,
4877 .put = alc_ch_mode_put,
4879 { } /* end */
4882 static struct hda_verb alc883_init_verbs[] = {
4883 /* ADC1: mute amp left and right */
4884 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4885 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4886 /* ADC2: mute amp left and right */
4887 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4888 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4889 /* Front mixer: unmute input/output amp left and right (volume = 0) */
4890 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4891 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4892 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4893 /* Rear mixer */
4894 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4895 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4896 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4897 /* CLFE mixer */
4898 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4899 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4900 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4901 /* Side mixer */
4902 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4903 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4904 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4906 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4907 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4908 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4909 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4910 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4912 /* Front Pin: output 0 (0x0c) */
4913 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4914 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4915 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
4916 /* Rear Pin: output 1 (0x0d) */
4917 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4918 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4919 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4920 /* CLFE Pin: output 2 (0x0e) */
4921 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4922 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4923 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
4924 /* Side Pin: output 3 (0x0f) */
4925 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4926 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4927 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
4928 /* Mic (rear) pin: input vref at 80% */
4929 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4930 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4931 /* Front Mic pin: input vref at 80% */
4932 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4933 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4934 /* Line In pin: input */
4935 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4936 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4937 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4938 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4939 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4940 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
4941 /* CD pin widget for input */
4942 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4944 /* FIXME: use matrix-type input source selection */
4945 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4946 /* Input mixer2 */
4947 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4948 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4949 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4950 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4951 /* Input mixer3 */
4952 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4953 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4954 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4955 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4960 * generic initialization of ADC, input mixers and output mixers
4962 static struct hda_verb alc883_auto_init_verbs[] = {
4964 * Unmute ADC0-2 and set the default input to mic-in
4966 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4967 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4968 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4969 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4971 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4972 * mixer widget
4973 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4974 * mic (mic 2)
4976 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4977 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4978 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4979 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4980 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4981 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4984 * Set up output mixers (0x0c - 0x0f)
4986 /* set vol=0 to output mixers */
4987 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4988 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4989 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4990 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4991 /* set up input amps for analog loopback */
4992 /* Amp Indices: DAC = 0, mixer = 1 */
4993 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4994 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4995 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4996 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4997 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4998 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4999 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5000 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5001 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5002 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5004 /* FIXME: use matrix-type input source selection */
5005 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5006 /* Input mixer1 */
5007 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5008 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5009 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5010 //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5011 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5012 /* Input mixer2 */
5013 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5014 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5015 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5016 //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5017 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5022 /* capture mixer elements */
5023 static struct snd_kcontrol_new alc883_capture_mixer[] = {
5024 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5025 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5026 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5027 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5029 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5030 /* The multiple "Capture Source" controls confuse alsamixer
5031 * So call somewhat different..
5032 * FIXME: the controls appear in the "playback" view!
5034 /* .name = "Capture Source", */
5035 .name = "Input Source",
5036 .count = 2,
5037 .info = alc882_mux_enum_info,
5038 .get = alc882_mux_enum_get,
5039 .put = alc882_mux_enum_put,
5041 { } /* end */
5044 /* pcm configuration: identiacal with ALC880 */
5045 #define alc883_pcm_analog_playback alc880_pcm_analog_playback
5046 #define alc883_pcm_analog_capture alc880_pcm_analog_capture
5047 #define alc883_pcm_digital_playback alc880_pcm_digital_playback
5048 #define alc883_pcm_digital_capture alc880_pcm_digital_capture
5051 * configuration and preset
5053 static struct hda_board_config alc883_cfg_tbl[] = {
5054 { .modelname = "3stack-dig", .config = ALC883_3ST_2ch_DIG },
5055 { .modelname = "3stack-6ch-dig", .config = ALC883_3ST_6ch_DIG },
5056 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
5057 .config = ALC883_3ST_6ch_DIG }, /* ECS to Intel*/
5058 { .modelname = "3stack-6ch", .config = ALC883_3ST_6ch },
5059 { .pci_subvendor = 0x108e, .pci_subdevice = 0x534d,
5060 .config = ALC883_3ST_6ch },
5061 { .modelname = "6stack-dig", .config = ALC883_6ST_DIG },
5062 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
5063 .config = ALC883_6ST_DIG }, /* MSI */
5064 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
5065 .config = ALC883_6ST_DIG }, /* Foxconn */
5066 { .modelname = "6stack-dig-demo", .config = ALC888_DEMO_BOARD },
5067 { .modelname = "auto", .config = ALC883_AUTO },
5071 static struct alc_config_preset alc883_presets[] = {
5072 [ALC883_3ST_2ch_DIG] = {
5073 .mixers = { alc883_3ST_2ch_mixer },
5074 .init_verbs = { alc883_init_verbs },
5075 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5076 .dac_nids = alc883_dac_nids,
5077 .dig_out_nid = ALC883_DIGOUT_NID,
5078 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5079 .adc_nids = alc883_adc_nids,
5080 .dig_in_nid = ALC883_DIGIN_NID,
5081 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5082 .channel_mode = alc883_3ST_2ch_modes,
5083 .input_mux = &alc883_capture_source,
5085 [ALC883_3ST_6ch_DIG] = {
5086 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5087 .init_verbs = { alc883_init_verbs },
5088 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5089 .dac_nids = alc883_dac_nids,
5090 .dig_out_nid = ALC883_DIGOUT_NID,
5091 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5092 .adc_nids = alc883_adc_nids,
5093 .dig_in_nid = ALC883_DIGIN_NID,
5094 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5095 .channel_mode = alc883_3ST_6ch_modes,
5096 .need_dac_fix = 1,
5097 .input_mux = &alc883_capture_source,
5099 [ALC883_3ST_6ch] = {
5100 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5101 .init_verbs = { alc883_init_verbs },
5102 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5103 .dac_nids = alc883_dac_nids,
5104 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5105 .adc_nids = alc883_adc_nids,
5106 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5107 .channel_mode = alc883_3ST_6ch_modes,
5108 .need_dac_fix = 1,
5109 .input_mux = &alc883_capture_source,
5111 [ALC883_6ST_DIG] = {
5112 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5113 .init_verbs = { alc883_init_verbs },
5114 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5115 .dac_nids = alc883_dac_nids,
5116 .dig_out_nid = ALC883_DIGOUT_NID,
5117 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5118 .adc_nids = alc883_adc_nids,
5119 .dig_in_nid = ALC883_DIGIN_NID,
5120 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5121 .channel_mode = alc883_sixstack_modes,
5122 .input_mux = &alc883_capture_source,
5124 [ALC888_DEMO_BOARD] = {
5125 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5126 .init_verbs = { alc883_init_verbs },
5127 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5128 .dac_nids = alc883_dac_nids,
5129 .dig_out_nid = ALC883_DIGOUT_NID,
5130 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5131 .adc_nids = alc883_adc_nids,
5132 .dig_in_nid = ALC883_DIGIN_NID,
5133 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5134 .channel_mode = alc883_sixstack_modes,
5135 .input_mux = &alc883_capture_source,
5141 * BIOS auto configuration
5143 static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
5144 hda_nid_t nid, int pin_type,
5145 int dac_idx)
5147 /* set as output */
5148 struct alc_spec *spec = codec->spec;
5149 int idx;
5151 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5152 idx = 4;
5153 else
5154 idx = spec->multiout.dac_nids[dac_idx] - 2;
5156 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5157 pin_type);
5158 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5159 AMP_OUT_UNMUTE);
5160 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5164 static void alc883_auto_init_multi_out(struct hda_codec *codec)
5166 struct alc_spec *spec = codec->spec;
5167 int i;
5169 for (i = 0; i <= HDA_SIDE; i++) {
5170 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5171 if (nid)
5172 alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
5176 static void alc883_auto_init_hp_out(struct hda_codec *codec)
5178 struct alc_spec *spec = codec->spec;
5179 hda_nid_t pin;
5181 pin = spec->autocfg.hp_pin;
5182 if (pin) /* connect to front */
5183 /* use dac 0 */
5184 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5187 #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
5188 #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
5190 static void alc883_auto_init_analog_input(struct hda_codec *codec)
5192 struct alc_spec *spec = codec->spec;
5193 int i;
5195 for (i = 0; i < AUTO_PIN_LAST; i++) {
5196 hda_nid_t nid = spec->autocfg.input_pins[i];
5197 if (alc883_is_input_pin(nid)) {
5198 snd_hda_codec_write(codec, nid, 0,
5199 AC_VERB_SET_PIN_WIDGET_CONTROL,
5200 (i <= AUTO_PIN_FRONT_MIC ?
5201 PIN_VREF80 : PIN_IN));
5202 if (nid != ALC883_PIN_CD_NID)
5203 snd_hda_codec_write(codec, nid, 0,
5204 AC_VERB_SET_AMP_GAIN_MUTE,
5205 AMP_OUT_MUTE);
5210 /* almost identical with ALC880 parser... */
5211 static int alc883_parse_auto_config(struct hda_codec *codec)
5213 struct alc_spec *spec = codec->spec;
5214 int err = alc880_parse_auto_config(codec);
5216 if (err < 0)
5217 return err;
5218 else if (err > 0)
5219 /* hack - override the init verbs */
5220 spec->init_verbs[0] = alc883_auto_init_verbs;
5221 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
5222 spec->num_mixers++;
5223 return err;
5226 /* additional initialization for auto-configuration model */
5227 static void alc883_auto_init(struct hda_codec *codec)
5229 alc883_auto_init_multi_out(codec);
5230 alc883_auto_init_hp_out(codec);
5231 alc883_auto_init_analog_input(codec);
5234 static int patch_alc883(struct hda_codec *codec)
5236 struct alc_spec *spec;
5237 int err, board_config;
5239 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5240 if (spec == NULL)
5241 return -ENOMEM;
5243 codec->spec = spec;
5245 board_config = snd_hda_check_board_config(codec, alc883_cfg_tbl);
5246 if (board_config < 0 || board_config >= ALC883_MODEL_LAST) {
5247 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
5248 "trying auto-probe from BIOS...\n");
5249 board_config = ALC883_AUTO;
5252 if (board_config == ALC883_AUTO) {
5253 /* automatic parse from the BIOS config */
5254 err = alc883_parse_auto_config(codec);
5255 if (err < 0) {
5256 alc_free(codec);
5257 return err;
5258 } else if (! err) {
5259 printk(KERN_INFO
5260 "hda_codec: Cannot set up configuration "
5261 "from BIOS. Using base mode...\n");
5262 board_config = ALC883_3ST_2ch_DIG;
5266 if (board_config != ALC883_AUTO)
5267 setup_preset(spec, &alc883_presets[board_config]);
5269 spec->stream_name_analog = "ALC883 Analog";
5270 spec->stream_analog_playback = &alc883_pcm_analog_playback;
5271 spec->stream_analog_capture = &alc883_pcm_analog_capture;
5273 spec->stream_name_digital = "ALC883 Digital";
5274 spec->stream_digital_playback = &alc883_pcm_digital_playback;
5275 spec->stream_digital_capture = &alc883_pcm_digital_capture;
5277 if (! spec->adc_nids && spec->input_mux) {
5278 spec->adc_nids = alc883_adc_nids;
5279 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
5282 codec->patch_ops = alc_patch_ops;
5283 if (board_config == ALC883_AUTO)
5284 spec->init_hook = alc883_auto_init;
5286 return 0;
5290 * ALC262 support
5293 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
5294 #define ALC262_DIGIN_NID ALC880_DIGIN_NID
5296 #define alc262_dac_nids alc260_dac_nids
5297 #define alc262_adc_nids alc882_adc_nids
5298 #define alc262_adc_nids_alt alc882_adc_nids_alt
5300 #define alc262_modes alc260_modes
5301 #define alc262_capture_source alc882_capture_source
5303 static struct snd_kcontrol_new alc262_base_mixer[] = {
5304 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5305 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5306 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5307 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5308 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5309 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5310 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5311 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5312 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5313 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5314 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5315 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
5316 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
5317 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5318 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5319 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5320 { } /* end */
5323 static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
5324 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5325 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5326 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5327 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5328 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5330 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5331 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5332 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5333 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5334 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5335 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5336 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5337 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5338 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5339 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
5340 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
5341 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
5342 { } /* end */
5345 #define alc262_capture_mixer alc882_capture_mixer
5346 #define alc262_capture_alt_mixer alc882_capture_alt_mixer
5349 * generic initialization of ADC, input mixers and output mixers
5351 static struct hda_verb alc262_init_verbs[] = {
5353 * Unmute ADC0-2 and set the default input to mic-in
5355 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5356 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5357 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5358 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5359 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5360 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5362 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5363 * mixer widget
5364 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5365 * mic (mic 2)
5367 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5368 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5369 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5370 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5371 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5372 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5375 * Set up output mixers (0x0c - 0x0e)
5377 /* set vol=0 to output mixers */
5378 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5379 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5380 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5381 /* set up input amps for analog loopback */
5382 /* Amp Indices: DAC = 0, mixer = 1 */
5383 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5384 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5385 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5386 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5387 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5388 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5390 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5391 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5392 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5393 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5394 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5395 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5397 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5398 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5399 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5400 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5401 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5403 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5404 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5406 /* FIXME: use matrix-type input source selection */
5407 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5408 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5409 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5410 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5411 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5412 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5413 /* Input mixer2 */
5414 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5415 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5416 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5417 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5418 /* Input mixer3 */
5419 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5420 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5421 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5422 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5428 * fujitsu model
5429 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
5432 #define ALC_HP_EVENT 0x37
5434 static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
5435 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
5436 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5440 static struct hda_input_mux alc262_fujitsu_capture_source = {
5441 .num_items = 2,
5442 .items = {
5443 { "Mic", 0x0 },
5444 { "CD", 0x4 },
5448 static struct hda_input_mux alc262_HP_capture_source = {
5449 .num_items = 5,
5450 .items = {
5451 { "Mic", 0x0 },
5452 { "Front Mic", 0x3 },
5453 { "Line", 0x2 },
5454 { "CD", 0x4 },
5455 { "AUX IN", 0x6 },
5459 /* mute/unmute internal speaker according to the hp jack and mute state */
5460 static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
5462 struct alc_spec *spec = codec->spec;
5463 unsigned int mute;
5465 if (force || ! spec->sense_updated) {
5466 unsigned int present;
5467 /* need to execute and sync at first */
5468 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
5469 present = snd_hda_codec_read(codec, 0x14, 0,
5470 AC_VERB_GET_PIN_SENSE, 0);
5471 spec->jack_present = (present & 0x80000000) != 0;
5472 spec->sense_updated = 1;
5474 if (spec->jack_present) {
5475 /* mute internal speaker */
5476 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
5477 0x80, 0x80);
5478 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
5479 0x80, 0x80);
5480 } else {
5481 /* unmute internal speaker if necessary */
5482 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
5483 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
5484 0x80, mute & 0x80);
5485 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
5486 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
5487 0x80, mute & 0x80);
5491 /* unsolicited event for HP jack sensing */
5492 static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
5493 unsigned int res)
5495 if ((res >> 26) != ALC_HP_EVENT)
5496 return;
5497 alc262_fujitsu_automute(codec, 1);
5500 /* bind volumes of both NID 0x0c and 0x0d */
5501 static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
5502 struct snd_ctl_elem_value *ucontrol)
5504 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5505 long *valp = ucontrol->value.integer.value;
5506 int change;
5508 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
5509 0x7f, valp[0] & 0x7f);
5510 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
5511 0x7f, valp[1] & 0x7f);
5512 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
5513 0x7f, valp[0] & 0x7f);
5514 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
5515 0x7f, valp[1] & 0x7f);
5516 return change;
5519 /* bind hp and internal speaker mute (with plug check) */
5520 static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
5521 struct snd_ctl_elem_value *ucontrol)
5523 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5524 long *valp = ucontrol->value.integer.value;
5525 int change;
5527 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
5528 0x80, valp[0] ? 0 : 0x80);
5529 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
5530 0x80, valp[1] ? 0 : 0x80);
5531 if (change || codec->in_resume)
5532 alc262_fujitsu_automute(codec, codec->in_resume);
5533 return change;
5536 static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
5538 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5539 .name = "Master Playback Volume",
5540 .info = snd_hda_mixer_amp_volume_info,
5541 .get = snd_hda_mixer_amp_volume_get,
5542 .put = alc262_fujitsu_master_vol_put,
5543 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
5546 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5547 .name = "Master Playback Switch",
5548 .info = snd_hda_mixer_amp_switch_info,
5549 .get = snd_hda_mixer_amp_switch_get,
5550 .put = alc262_fujitsu_master_sw_put,
5551 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
5553 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5554 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5555 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5556 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5557 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5558 { } /* end */
5561 /* additional init verbs for Benq laptops */
5562 static struct hda_verb alc262_EAPD_verbs[] = {
5563 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5564 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
5568 /* add playback controls from the parsed DAC table */
5569 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
5571 hda_nid_t nid;
5572 int err;
5574 spec->multiout.num_dacs = 1; /* only use one dac */
5575 spec->multiout.dac_nids = spec->private_dac_nids;
5576 spec->multiout.dac_nids[0] = 2;
5578 nid = cfg->line_out_pins[0];
5579 if (nid) {
5580 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
5581 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
5582 return err;
5583 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
5584 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5585 return err;
5588 nid = cfg->speaker_pins[0];
5589 if (nid) {
5590 if (nid == 0x16) {
5591 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
5592 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
5593 return err;
5594 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
5595 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
5596 return err;
5597 } else {
5598 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
5599 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5600 return err;
5603 nid = cfg->hp_pin;
5604 if (nid) {
5605 /* spec->multiout.hp_nid = 2; */
5606 if (nid == 0x16) {
5607 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
5608 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
5609 return err;
5610 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
5611 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
5612 return err;
5613 } else {
5614 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
5615 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5616 return err;
5619 return 0;
5622 /* identical with ALC880 */
5623 #define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
5626 * generic initialization of ADC, input mixers and output mixers
5628 static struct hda_verb alc262_volume_init_verbs[] = {
5630 * Unmute ADC0-2 and set the default input to mic-in
5632 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5633 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5634 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5635 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5636 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5637 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5639 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5640 * mixer widget
5641 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5642 * mic (mic 2)
5644 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5645 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5646 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5647 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5648 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5649 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5652 * Set up output mixers (0x0c - 0x0f)
5654 /* set vol=0 to output mixers */
5655 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5656 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5657 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5659 /* set up input amps for analog loopback */
5660 /* Amp Indices: DAC = 0, mixer = 1 */
5661 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5662 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5663 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5664 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5665 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5666 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5668 /* FIXME: use matrix-type input source selection */
5669 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5670 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5671 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5672 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5673 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5674 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5675 /* Input mixer2 */
5676 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5677 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5678 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5679 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5680 /* Input mixer3 */
5681 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5682 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5683 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5684 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5689 static struct hda_verb alc262_HP_BPC_init_verbs[] = {
5691 * Unmute ADC0-2 and set the default input to mic-in
5693 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5694 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5695 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5696 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5697 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5698 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5700 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5701 * mixer widget
5702 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5703 * mic (mic 2)
5705 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5706 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5707 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5708 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5709 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5710 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5711 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
5712 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
5715 * Set up output mixers (0x0c - 0x0e)
5717 /* set vol=0 to output mixers */
5718 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5719 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5720 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5722 /* set up input amps for analog loopback */
5723 /* Amp Indices: DAC = 0, mixer = 1 */
5724 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5725 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5726 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5727 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5728 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5729 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5731 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5732 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5733 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5735 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5736 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5738 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5739 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5741 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5742 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5743 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5744 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5745 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5747 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
5748 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5749 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5750 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
5751 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5752 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5755 /* FIXME: use matrix-type input source selection */
5756 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5757 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5758 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5759 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
5760 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
5761 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
5762 /* Input mixer2 */
5763 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5764 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
5765 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
5766 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
5767 /* Input mixer3 */
5768 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5769 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
5770 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
5771 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
5776 /* pcm configuration: identiacal with ALC880 */
5777 #define alc262_pcm_analog_playback alc880_pcm_analog_playback
5778 #define alc262_pcm_analog_capture alc880_pcm_analog_capture
5779 #define alc262_pcm_digital_playback alc880_pcm_digital_playback
5780 #define alc262_pcm_digital_capture alc880_pcm_digital_capture
5783 * BIOS auto configuration
5785 static int alc262_parse_auto_config(struct hda_codec *codec)
5787 struct alc_spec *spec = codec->spec;
5788 int err;
5789 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
5791 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5792 alc262_ignore)) < 0)
5793 return err;
5794 if (! spec->autocfg.line_outs)
5795 return 0; /* can't find valid BIOS pin config */
5796 if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
5797 (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
5798 return err;
5800 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5802 if (spec->autocfg.dig_out_pin)
5803 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
5804 if (spec->autocfg.dig_in_pin)
5805 spec->dig_in_nid = ALC262_DIGIN_NID;
5807 if (spec->kctl_alloc)
5808 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
5810 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
5811 spec->num_mux_defs = 1;
5812 spec->input_mux = &spec->private_imux;
5814 return 1;
5817 #define alc262_auto_init_multi_out alc882_auto_init_multi_out
5818 #define alc262_auto_init_hp_out alc882_auto_init_hp_out
5819 #define alc262_auto_init_analog_input alc882_auto_init_analog_input
5822 /* init callback for auto-configuration model -- overriding the default init */
5823 static void alc262_auto_init(struct hda_codec *codec)
5825 alc262_auto_init_multi_out(codec);
5826 alc262_auto_init_hp_out(codec);
5827 alc262_auto_init_analog_input(codec);
5831 * configuration and preset
5833 static struct hda_board_config alc262_cfg_tbl[] = {
5834 { .modelname = "basic", .config = ALC262_BASIC },
5835 { .modelname = "fujitsu", .config = ALC262_FUJITSU },
5836 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397,
5837 .config = ALC262_FUJITSU },
5838 { .modelname = "hp-bpc", .config = ALC262_HP_BPC },
5839 { .pci_subvendor = 0x103c, .pci_subdevice = 0x208c,
5840 .config = ALC262_HP_BPC }, /* xw4400 */
5841 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014,
5842 .config = ALC262_HP_BPC }, /* xw6400 */
5843 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015,
5844 .config = ALC262_HP_BPC }, /* xw8400 */
5845 { .pci_subvendor = 0x103c, .pci_subdevice = 0x12fe,
5846 .config = ALC262_HP_BPC }, /* xw9400 */
5847 { .modelname = "benq", .config = ALC262_BENQ_ED8 },
5848 { .pci_subvendor = 0x17ff, .pci_subdevice = 0x0560,
5849 .config = ALC262_BENQ_ED8 },
5850 { .modelname = "auto", .config = ALC262_AUTO },
5854 static struct alc_config_preset alc262_presets[] = {
5855 [ALC262_BASIC] = {
5856 .mixers = { alc262_base_mixer },
5857 .init_verbs = { alc262_init_verbs },
5858 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5859 .dac_nids = alc262_dac_nids,
5860 .hp_nid = 0x03,
5861 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5862 .channel_mode = alc262_modes,
5863 .input_mux = &alc262_capture_source,
5865 [ALC262_FUJITSU] = {
5866 .mixers = { alc262_fujitsu_mixer },
5867 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
5868 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5869 .dac_nids = alc262_dac_nids,
5870 .hp_nid = 0x03,
5871 .dig_out_nid = ALC262_DIGOUT_NID,
5872 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5873 .channel_mode = alc262_modes,
5874 .input_mux = &alc262_fujitsu_capture_source,
5875 .unsol_event = alc262_fujitsu_unsol_event,
5877 [ALC262_HP_BPC] = {
5878 .mixers = { alc262_HP_BPC_mixer },
5879 .init_verbs = { alc262_HP_BPC_init_verbs },
5880 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5881 .dac_nids = alc262_dac_nids,
5882 .hp_nid = 0x03,
5883 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5884 .channel_mode = alc262_modes,
5885 .input_mux = &alc262_HP_capture_source,
5887 [ALC262_BENQ_ED8] = {
5888 .mixers = { alc262_base_mixer },
5889 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
5890 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5891 .dac_nids = alc262_dac_nids,
5892 .hp_nid = 0x03,
5893 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5894 .channel_mode = alc262_modes,
5895 .input_mux = &alc262_capture_source,
5899 static int patch_alc262(struct hda_codec *codec)
5901 struct alc_spec *spec;
5902 int board_config;
5903 int err;
5905 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
5906 if (spec == NULL)
5907 return -ENOMEM;
5909 codec->spec = spec;
5910 #if 0
5911 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
5913 int tmp;
5914 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
5915 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
5916 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
5917 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
5919 #endif
5921 board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
5923 if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
5924 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
5925 "trying auto-probe from BIOS...\n");
5926 board_config = ALC262_AUTO;
5929 if (board_config == ALC262_AUTO) {
5930 /* automatic parse from the BIOS config */
5931 err = alc262_parse_auto_config(codec);
5932 if (err < 0) {
5933 alc_free(codec);
5934 return err;
5935 } else if (! err) {
5936 printk(KERN_INFO
5937 "hda_codec: Cannot set up configuration "
5938 "from BIOS. Using base mode...\n");
5939 board_config = ALC262_BASIC;
5943 if (board_config != ALC262_AUTO)
5944 setup_preset(spec, &alc262_presets[board_config]);
5946 spec->stream_name_analog = "ALC262 Analog";
5947 spec->stream_analog_playback = &alc262_pcm_analog_playback;
5948 spec->stream_analog_capture = &alc262_pcm_analog_capture;
5950 spec->stream_name_digital = "ALC262 Digital";
5951 spec->stream_digital_playback = &alc262_pcm_digital_playback;
5952 spec->stream_digital_capture = &alc262_pcm_digital_capture;
5954 if (! spec->adc_nids && spec->input_mux) {
5955 /* check whether NID 0x07 is valid */
5956 unsigned int wcap = get_wcaps(codec, 0x07);
5958 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
5959 if (wcap != AC_WID_AUD_IN) {
5960 spec->adc_nids = alc262_adc_nids_alt;
5961 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
5962 spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
5963 spec->num_mixers++;
5964 } else {
5965 spec->adc_nids = alc262_adc_nids;
5966 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
5967 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
5968 spec->num_mixers++;
5972 codec->patch_ops = alc_patch_ops;
5973 if (board_config == ALC262_AUTO)
5974 spec->init_hook = alc262_auto_init;
5976 return 0;
5980 * ALC861 channel source setting (2/6 channel selection for 3-stack)
5984 * set the path ways for 2 channel output
5985 * need to set the codec line out and mic 1 pin widgets to inputs
5987 static struct hda_verb alc861_threestack_ch2_init[] = {
5988 /* set pin widget 1Ah (line in) for input */
5989 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
5990 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
5991 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
5993 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
5994 #if 0
5995 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
5996 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
5997 #endif
5998 { } /* end */
6001 * 6ch mode
6002 * need to set the codec line out and mic 1 pin widgets to outputs
6004 static struct hda_verb alc861_threestack_ch6_init[] = {
6005 /* set pin widget 1Ah (line in) for output (Back Surround)*/
6006 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6007 /* set pin widget 18h (mic1) for output (CLFE)*/
6008 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6010 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
6011 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
6013 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
6014 #if 0
6015 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
6016 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
6017 #endif
6018 { } /* end */
6021 static struct hda_channel_mode alc861_threestack_modes[2] = {
6022 { 2, alc861_threestack_ch2_init },
6023 { 6, alc861_threestack_ch6_init },
6025 /* Set mic1 as input and unmute the mixer */
6026 static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
6027 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6028 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
6029 { } /* end */
6031 /* Set mic1 as output and mute mixer */
6032 static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
6033 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6034 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
6035 { } /* end */
6038 static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
6039 { 2, alc861_uniwill_m31_ch2_init },
6040 { 4, alc861_uniwill_m31_ch4_init },
6043 /* patch-ALC861 */
6045 static struct snd_kcontrol_new alc861_base_mixer[] = {
6046 /* output mixer control */
6047 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6048 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6049 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6050 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6051 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
6053 /*Input mixer control */
6054 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6055 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6056 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6057 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6058 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6059 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6060 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6061 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6062 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6063 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6065 /* Capture mixer control */
6066 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6067 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6069 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6070 .name = "Capture Source",
6071 .count = 1,
6072 .info = alc_mux_enum_info,
6073 .get = alc_mux_enum_get,
6074 .put = alc_mux_enum_put,
6076 { } /* end */
6079 static struct snd_kcontrol_new alc861_3ST_mixer[] = {
6080 /* output mixer control */
6081 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6082 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6083 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6084 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6085 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
6087 /* Input mixer control */
6088 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6089 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6090 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6091 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6092 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6093 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6094 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6095 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6096 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6097 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6099 /* Capture mixer control */
6100 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6101 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6103 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6104 .name = "Capture Source",
6105 .count = 1,
6106 .info = alc_mux_enum_info,
6107 .get = alc_mux_enum_get,
6108 .put = alc_mux_enum_put,
6111 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6112 .name = "Channel Mode",
6113 .info = alc_ch_mode_info,
6114 .get = alc_ch_mode_get,
6115 .put = alc_ch_mode_put,
6116 .private_value = ARRAY_SIZE(alc861_threestack_modes),
6118 { } /* end */
6120 static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
6121 /* output mixer control */
6122 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6123 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6124 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6125 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6126 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
6128 /* Input mixer control */
6129 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6130 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6131 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6132 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6133 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6134 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6135 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6136 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6137 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6138 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6140 /* Capture mixer control */
6141 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6142 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6144 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6145 .name = "Capture Source",
6146 .count = 1,
6147 .info = alc_mux_enum_info,
6148 .get = alc_mux_enum_get,
6149 .put = alc_mux_enum_put,
6152 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6153 .name = "Channel Mode",
6154 .info = alc_ch_mode_info,
6155 .get = alc_ch_mode_get,
6156 .put = alc_ch_mode_put,
6157 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
6159 { } /* end */
6163 * generic initialization of ADC, input mixers and output mixers
6165 static struct hda_verb alc861_base_init_verbs[] = {
6167 * Unmute ADC0 and set the default input to mic-in
6169 /* port-A for surround (rear panel) */
6170 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6171 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
6172 /* port-B for mic-in (rear panel) with vref */
6173 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6174 /* port-C for line-in (rear panel) */
6175 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6176 /* port-D for Front */
6177 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6178 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6179 /* port-E for HP out (front panel) */
6180 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
6181 /* route front PCM to HP */
6182 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
6183 /* port-F for mic-in (front panel) with vref */
6184 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6185 /* port-G for CLFE (rear panel) */
6186 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6187 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
6188 /* port-H for side (rear panel) */
6189 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6190 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
6191 /* CD-in */
6192 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6193 /* route front mic to ADC1*/
6194 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6195 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6197 /* Unmute DAC0~3 & spdif out*/
6198 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6199 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6200 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6201 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6202 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6204 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6205 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6206 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6207 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6208 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6210 /* Unmute Stereo Mixer 15 */
6211 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6212 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6213 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6214 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
6216 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6217 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6218 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6219 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6220 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6221 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6222 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6223 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6224 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
6225 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6230 static struct hda_verb alc861_threestack_init_verbs[] = {
6232 * Unmute ADC0 and set the default input to mic-in
6234 /* port-A for surround (rear panel) */
6235 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6236 /* port-B for mic-in (rear panel) with vref */
6237 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6238 /* port-C for line-in (rear panel) */
6239 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6240 /* port-D for Front */
6241 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6242 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6243 /* port-E for HP out (front panel) */
6244 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
6245 /* route front PCM to HP */
6246 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
6247 /* port-F for mic-in (front panel) with vref */
6248 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6249 /* port-G for CLFE (rear panel) */
6250 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6251 /* port-H for side (rear panel) */
6252 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6253 /* CD-in */
6254 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6255 /* route front mic to ADC1*/
6256 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6257 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6258 /* Unmute DAC0~3 & spdif out*/
6259 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6260 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6261 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6262 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6263 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6265 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6266 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6267 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6268 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6269 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6271 /* Unmute Stereo Mixer 15 */
6272 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6273 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6274 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6275 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
6277 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6278 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6279 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6280 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6281 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6282 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6283 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6284 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6285 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
6286 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6290 static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
6292 * Unmute ADC0 and set the default input to mic-in
6294 /* port-A for surround (rear panel) */
6295 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6296 /* port-B for mic-in (rear panel) with vref */
6297 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6298 /* port-C for line-in (rear panel) */
6299 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6300 /* port-D for Front */
6301 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6302 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6303 /* port-E for HP out (front panel) */
6304 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, // this has to be set to VREF80
6305 /* route front PCM to HP */
6306 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
6307 /* port-F for mic-in (front panel) with vref */
6308 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6309 /* port-G for CLFE (rear panel) */
6310 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6311 /* port-H for side (rear panel) */
6312 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6313 /* CD-in */
6314 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6315 /* route front mic to ADC1*/
6316 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6317 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6318 /* Unmute DAC0~3 & spdif out*/
6319 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6320 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6321 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6322 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6323 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6325 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6326 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6327 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6328 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6329 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6331 /* Unmute Stereo Mixer 15 */
6332 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6333 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6334 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6335 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
6337 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6338 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6339 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6340 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6341 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6342 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6343 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6344 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6345 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
6346 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6351 * generic initialization of ADC, input mixers and output mixers
6353 static struct hda_verb alc861_auto_init_verbs[] = {
6355 * Unmute ADC0 and set the default input to mic-in
6357 // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6358 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6360 /* Unmute DAC0~3 & spdif out*/
6361 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6362 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6363 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6364 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6365 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6367 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6368 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6369 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6370 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6371 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6373 /* Unmute Stereo Mixer 15 */
6374 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6375 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6376 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6377 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
6379 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6380 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6381 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6382 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6383 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6384 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6385 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6386 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6388 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6389 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6390 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6391 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6392 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6393 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6394 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6395 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6397 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
6402 /* pcm configuration: identiacal with ALC880 */
6403 #define alc861_pcm_analog_playback alc880_pcm_analog_playback
6404 #define alc861_pcm_analog_capture alc880_pcm_analog_capture
6405 #define alc861_pcm_digital_playback alc880_pcm_digital_playback
6406 #define alc861_pcm_digital_capture alc880_pcm_digital_capture
6409 #define ALC861_DIGOUT_NID 0x07
6411 static struct hda_channel_mode alc861_8ch_modes[1] = {
6412 { 8, NULL }
6415 static hda_nid_t alc861_dac_nids[4] = {
6416 /* front, surround, clfe, side */
6417 0x03, 0x06, 0x05, 0x04
6420 static hda_nid_t alc660_dac_nids[3] = {
6421 /* front, clfe, surround */
6422 0x03, 0x05, 0x06
6425 static hda_nid_t alc861_adc_nids[1] = {
6426 /* ADC0-2 */
6427 0x08,
6430 static struct hda_input_mux alc861_capture_source = {
6431 .num_items = 5,
6432 .items = {
6433 { "Mic", 0x0 },
6434 { "Front Mic", 0x3 },
6435 { "Line", 0x1 },
6436 { "CD", 0x4 },
6437 { "Mixer", 0x5 },
6441 /* fill in the dac_nids table from the parsed pin configuration */
6442 static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
6444 int i;
6445 hda_nid_t nid;
6447 spec->multiout.dac_nids = spec->private_dac_nids;
6448 for (i = 0; i < cfg->line_outs; i++) {
6449 nid = cfg->line_out_pins[i];
6450 if (nid) {
6451 if (i >= ARRAY_SIZE(alc861_dac_nids))
6452 continue;
6453 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
6456 spec->multiout.num_dacs = cfg->line_outs;
6457 return 0;
6460 /* add playback controls from the parsed DAC table */
6461 static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
6462 const struct auto_pin_cfg *cfg)
6464 char name[32];
6465 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
6466 hda_nid_t nid;
6467 int i, idx, err;
6469 for (i = 0; i < cfg->line_outs; i++) {
6470 nid = spec->multiout.dac_nids[i];
6471 if (! nid)
6472 continue;
6473 if (nid == 0x05) {
6474 /* Center/LFE */
6475 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
6476 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
6477 return err;
6478 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
6479 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
6480 return err;
6481 } else {
6482 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
6483 if (nid == alc861_dac_nids[idx])
6484 break;
6485 sprintf(name, "%s Playback Switch", chname[idx]);
6486 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
6487 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6488 return err;
6491 return 0;
6494 static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
6496 int err;
6497 hda_nid_t nid;
6499 if (! pin)
6500 return 0;
6502 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
6503 nid = 0x03;
6504 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
6505 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6506 return err;
6507 spec->multiout.hp_nid = nid;
6509 return 0;
6512 /* create playback/capture controls for input pins */
6513 static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
6515 struct hda_input_mux *imux = &spec->private_imux;
6516 int i, err, idx, idx1;
6518 for (i = 0; i < AUTO_PIN_LAST; i++) {
6519 switch(cfg->input_pins[i]) {
6520 case 0x0c:
6521 idx1 = 1;
6522 idx = 2; // Line In
6523 break;
6524 case 0x0f:
6525 idx1 = 2;
6526 idx = 2; // Line In
6527 break;
6528 case 0x0d:
6529 idx1 = 0;
6530 idx = 1; // Mic In
6531 break;
6532 case 0x10:
6533 idx1 = 3;
6534 idx = 1; // Mic In
6535 break;
6536 case 0x11:
6537 idx1 = 4;
6538 idx = 0; // CD
6539 break;
6540 default:
6541 continue;
6544 err = new_analog_input(spec, cfg->input_pins[i],
6545 auto_pin_cfg_labels[i], idx, 0x15);
6546 if (err < 0)
6547 return err;
6549 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
6550 imux->items[imux->num_items].index = idx1;
6551 imux->num_items++;
6553 return 0;
6556 static struct snd_kcontrol_new alc861_capture_mixer[] = {
6557 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6558 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6561 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6562 /* The multiple "Capture Source" controls confuse alsamixer
6563 * So call somewhat different..
6564 *FIXME: the controls appear in the "playback" view!
6566 /* .name = "Capture Source", */
6567 .name = "Input Source",
6568 .count = 1,
6569 .info = alc_mux_enum_info,
6570 .get = alc_mux_enum_get,
6571 .put = alc_mux_enum_put,
6573 { } /* end */
6576 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
6577 int pin_type, int dac_idx)
6579 /* set as output */
6581 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
6582 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
6586 static void alc861_auto_init_multi_out(struct hda_codec *codec)
6588 struct alc_spec *spec = codec->spec;
6589 int i;
6591 for (i = 0; i < spec->autocfg.line_outs; i++) {
6592 hda_nid_t nid = spec->autocfg.line_out_pins[i];
6593 if (nid)
6594 alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
6598 static void alc861_auto_init_hp_out(struct hda_codec *codec)
6600 struct alc_spec *spec = codec->spec;
6601 hda_nid_t pin;
6603 pin = spec->autocfg.hp_pin;
6604 if (pin) /* connect to front */
6605 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
6608 static void alc861_auto_init_analog_input(struct hda_codec *codec)
6610 struct alc_spec *spec = codec->spec;
6611 int i;
6613 for (i = 0; i < AUTO_PIN_LAST; i++) {
6614 hda_nid_t nid = spec->autocfg.input_pins[i];
6615 if ((nid>=0x0c) && (nid <=0x11)) {
6616 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6617 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
6622 /* parse the BIOS configuration and set up the alc_spec */
6623 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
6624 static int alc861_parse_auto_config(struct hda_codec *codec)
6626 struct alc_spec *spec = codec->spec;
6627 int err;
6628 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
6630 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6631 alc861_ignore)) < 0)
6632 return err;
6633 if (! spec->autocfg.line_outs)
6634 return 0; /* can't find valid BIOS pin config */
6636 if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
6637 (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
6638 (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 ||
6639 (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
6640 return err;
6642 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
6644 if (spec->autocfg.dig_out_pin)
6645 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
6647 if (spec->kctl_alloc)
6648 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
6650 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
6652 spec->num_mux_defs = 1;
6653 spec->input_mux = &spec->private_imux;
6655 spec->adc_nids = alc861_adc_nids;
6656 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
6657 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
6658 spec->num_mixers++;
6660 return 1;
6663 /* additional initialization for auto-configuration model */
6664 static void alc861_auto_init(struct hda_codec *codec)
6666 alc861_auto_init_multi_out(codec);
6667 alc861_auto_init_hp_out(codec);
6668 alc861_auto_init_analog_input(codec);
6673 * configuration and preset
6675 static struct hda_board_config alc861_cfg_tbl[] = {
6676 { .modelname = "3stack", .config = ALC861_3ST },
6677 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600,
6678 .config = ALC861_3ST },
6679 { .modelname = "3stack-660", .config = ALC660_3ST },
6680 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81e7,
6681 .config = ALC660_3ST },
6682 { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
6683 { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
6684 { .modelname = "uniwill-m31", .config = ALC861_UNIWILL_M31},
6685 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9072,
6686 .config = ALC861_UNIWILL_M31 },
6687 { .modelname = "auto", .config = ALC861_AUTO },
6691 static struct alc_config_preset alc861_presets[] = {
6692 [ALC861_3ST] = {
6693 .mixers = { alc861_3ST_mixer },
6694 .init_verbs = { alc861_threestack_init_verbs },
6695 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
6696 .dac_nids = alc861_dac_nids,
6697 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
6698 .channel_mode = alc861_threestack_modes,
6699 .need_dac_fix = 1,
6700 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6701 .adc_nids = alc861_adc_nids,
6702 .input_mux = &alc861_capture_source,
6704 [ALC861_3ST_DIG] = {
6705 .mixers = { alc861_base_mixer },
6706 .init_verbs = { alc861_threestack_init_verbs },
6707 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
6708 .dac_nids = alc861_dac_nids,
6709 .dig_out_nid = ALC861_DIGOUT_NID,
6710 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
6711 .channel_mode = alc861_threestack_modes,
6712 .need_dac_fix = 1,
6713 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6714 .adc_nids = alc861_adc_nids,
6715 .input_mux = &alc861_capture_source,
6717 [ALC861_6ST_DIG] = {
6718 .mixers = { alc861_base_mixer },
6719 .init_verbs = { alc861_base_init_verbs },
6720 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
6721 .dac_nids = alc861_dac_nids,
6722 .dig_out_nid = ALC861_DIGOUT_NID,
6723 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
6724 .channel_mode = alc861_8ch_modes,
6725 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6726 .adc_nids = alc861_adc_nids,
6727 .input_mux = &alc861_capture_source,
6729 [ALC660_3ST] = {
6730 .mixers = { alc861_3ST_mixer },
6731 .init_verbs = { alc861_threestack_init_verbs },
6732 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
6733 .dac_nids = alc660_dac_nids,
6734 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
6735 .channel_mode = alc861_threestack_modes,
6736 .need_dac_fix = 1,
6737 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6738 .adc_nids = alc861_adc_nids,
6739 .input_mux = &alc861_capture_source,
6741 [ALC861_UNIWILL_M31] = {
6742 .mixers = { alc861_uniwill_m31_mixer },
6743 .init_verbs = { alc861_uniwill_m31_init_verbs },
6744 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
6745 .dac_nids = alc861_dac_nids,
6746 .dig_out_nid = ALC861_DIGOUT_NID,
6747 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
6748 .channel_mode = alc861_uniwill_m31_modes,
6749 .need_dac_fix = 1,
6750 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6751 .adc_nids = alc861_adc_nids,
6752 .input_mux = &alc861_capture_source,
6758 static int patch_alc861(struct hda_codec *codec)
6760 struct alc_spec *spec;
6761 int board_config;
6762 int err;
6764 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
6765 if (spec == NULL)
6766 return -ENOMEM;
6768 codec->spec = spec;
6770 board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
6772 if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
6773 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
6774 "trying auto-probe from BIOS...\n");
6775 board_config = ALC861_AUTO;
6778 if (board_config == ALC861_AUTO) {
6779 /* automatic parse from the BIOS config */
6780 err = alc861_parse_auto_config(codec);
6781 if (err < 0) {
6782 alc_free(codec);
6783 return err;
6784 } else if (! err) {
6785 printk(KERN_INFO
6786 "hda_codec: Cannot set up configuration "
6787 "from BIOS. Using base mode...\n");
6788 board_config = ALC861_3ST_DIG;
6792 if (board_config != ALC861_AUTO)
6793 setup_preset(spec, &alc861_presets[board_config]);
6795 spec->stream_name_analog = "ALC861 Analog";
6796 spec->stream_analog_playback = &alc861_pcm_analog_playback;
6797 spec->stream_analog_capture = &alc861_pcm_analog_capture;
6799 spec->stream_name_digital = "ALC861 Digital";
6800 spec->stream_digital_playback = &alc861_pcm_digital_playback;
6801 spec->stream_digital_capture = &alc861_pcm_digital_capture;
6803 codec->patch_ops = alc_patch_ops;
6804 if (board_config == ALC861_AUTO)
6805 spec->init_hook = alc861_auto_init;
6807 return 0;
6811 * patch entries
6813 struct hda_codec_preset snd_hda_preset_realtek[] = {
6814 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
6815 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
6816 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
6817 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
6818 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
6819 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
6820 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
6821 { .id = 0x10ec0861, .rev = 0x100300, .name = "ALC861",
6822 .patch = patch_alc861 },
6823 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
6824 .patch = patch_alc861 },
6825 {} /* terminator */