[ALSA] hda-codec - Add the support of ALC262,ALC883,ALC885,ALC861
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / sound / pci / hda / patch_realtek.c
bloba98c0e4da0acbf909d0d37eb2b4abd26e57ef179
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>
10 * This driver is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This driver is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include <sound/driver.h>
26 #include <linux/init.h>
27 #include <linux/delay.h>
28 #include <linux/slab.h>
29 #include <linux/pci.h>
30 #include <sound/core.h>
31 #include "hda_codec.h"
32 #include "hda_local.h"
35 /* ALC880 board config type */
36 enum {
37 ALC880_3ST,
38 ALC880_3ST_DIG,
39 ALC880_5ST,
40 ALC880_5ST_DIG,
41 ALC880_W810,
42 ALC880_Z71V,
43 ALC880_6ST,
44 ALC880_6ST_DIG,
45 ALC880_F1734,
46 ALC880_ASUS,
47 ALC880_ASUS_DIG,
48 ALC880_ASUS_W1V,
49 ALC880_ASUS_DIG2,
50 ALC880_UNIWILL_DIG,
51 ALC880_CLEVO,
52 ALC880_TCL_S700,
53 #ifdef CONFIG_SND_DEBUG
54 ALC880_TEST,
55 #endif
56 ALC880_AUTO,
57 ALC880_MODEL_LAST /* last tag */
60 /* ALC260 models */
61 enum {
62 ALC260_BASIC,
63 ALC260_HP,
64 ALC260_HP_3013,
65 ALC260_FUJITSU_S702X,
66 ALC260_AUTO,
67 ALC260_MODEL_LAST /* last tag */
70 /* ALC262 models */
71 enum {
72 ALC262_BASIC,
73 ALC262_AUTO,
74 ALC262_MODEL_LAST /* last tag */
77 /* ALC861 models */
78 enum {
79 ALC861_3ST,
80 ALC861_3ST_DIG,
81 ALC861_6ST_DIG,
82 ALC861_AUTO,
83 ALC861_MODEL_LAST,
86 /* ALC882 models */
87 enum {
88 ALC882_3ST_DIG,
89 ALC882_6ST_DIG,
90 ALC882_AUTO,
91 ALC882_MODEL_LAST,
94 /* for GPIO Poll */
95 #define GPIO_MASK 0x03
97 struct alc_spec {
98 /* codec parameterization */
99 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
100 unsigned int num_mixers;
102 const struct hda_verb *init_verbs[5]; /* initialization verbs
103 * don't forget NULL termination!
105 unsigned int num_init_verbs;
107 char *stream_name_analog; /* analog PCM stream */
108 struct hda_pcm_stream *stream_analog_playback;
109 struct hda_pcm_stream *stream_analog_capture;
111 char *stream_name_digital; /* digital PCM stream */
112 struct hda_pcm_stream *stream_digital_playback;
113 struct hda_pcm_stream *stream_digital_capture;
115 /* playback */
116 struct hda_multi_out multiout; /* playback set-up
117 * max_channels, dacs must be set
118 * dig_out_nid and hp_nid are optional
121 /* capture */
122 unsigned int num_adc_nids;
123 hda_nid_t *adc_nids;
124 hda_nid_t dig_in_nid; /* digital-in NID; optional */
126 /* capture source */
127 const struct hda_input_mux *input_mux;
128 unsigned int cur_mux[3];
130 /* channel model */
131 const struct hda_channel_mode *channel_mode;
132 int num_channel_mode;
134 /* PCM information */
135 struct hda_pcm pcm_rec[2]; /* used in alc_build_pcms() */
137 /* dynamic controls, init_verbs and input_mux */
138 struct auto_pin_cfg autocfg;
139 unsigned int num_kctl_alloc, num_kctl_used;
140 struct snd_kcontrol_new *kctl_alloc;
141 struct hda_input_mux private_imux;
142 hda_nid_t private_dac_nids[5];
146 * configuration template - to be copied to the spec instance
148 struct alc_config_preset {
149 struct snd_kcontrol_new *mixers[5]; /* should be identical size with spec */
150 const struct hda_verb *init_verbs[5];
151 unsigned int num_dacs;
152 hda_nid_t *dac_nids;
153 hda_nid_t dig_out_nid; /* optional */
154 hda_nid_t hp_nid; /* optional */
155 unsigned int num_adc_nids;
156 hda_nid_t *adc_nids;
157 hda_nid_t dig_in_nid;
158 unsigned int num_channel_mode;
159 const struct hda_channel_mode *channel_mode;
160 const struct hda_input_mux *input_mux;
165 * input MUX handling
167 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
169 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
170 struct alc_spec *spec = codec->spec;
171 return snd_hda_input_mux_info(spec->input_mux, uinfo);
174 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
176 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
177 struct alc_spec *spec = codec->spec;
178 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
180 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
181 return 0;
184 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
186 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
187 struct alc_spec *spec = codec->spec;
188 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
189 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
190 spec->adc_nids[adc_idx], &spec->cur_mux[adc_idx]);
195 * channel mode setting
197 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
199 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
200 struct alc_spec *spec = codec->spec;
201 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
202 spec->num_channel_mode);
205 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
207 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
208 struct alc_spec *spec = codec->spec;
209 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
210 spec->num_channel_mode, spec->multiout.max_channels);
213 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
215 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
216 struct alc_spec *spec = codec->spec;
217 return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
218 spec->num_channel_mode, &spec->multiout.max_channels);
223 * Control of pin widget settings via the mixer. Only boolean settings are
224 * supported, so VrefEn can't be controlled using these functions as they
225 * stand.
227 static int alc_pinctl_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
229 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
230 uinfo->count = 1;
231 uinfo->value.integer.min = 0;
232 uinfo->value.integer.max = 1;
233 return 0;
236 static int alc_pinctl_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
238 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
239 hda_nid_t nid = kcontrol->private_value & 0xffff;
240 long mask = (kcontrol->private_value >> 16) & 0xff;
241 long *valp = ucontrol->value.integer.value;
243 *valp = 0;
244 if (snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00) & mask)
245 *valp = 1;
246 return 0;
249 static int alc_pinctl_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
251 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
252 hda_nid_t nid = kcontrol->private_value & 0xffff;
253 long mask = (kcontrol->private_value >> 16) & 0xff;
254 long *valp = ucontrol->value.integer.value;
255 unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00);
256 int change = ((pinctl & mask)!=0) != *valp;
258 if (change)
259 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
260 *valp?(pinctl|mask):(pinctl&~mask));
261 return change;
264 #define ALC_PINCTL_SWITCH(xname, nid, mask) \
265 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
266 .info = alc_pinctl_switch_info, \
267 .get = alc_pinctl_switch_get, \
268 .put = alc_pinctl_switch_put, \
269 .private_value = (nid) | (mask<<16) }
273 * set up from the preset table
275 static void setup_preset(struct alc_spec *spec, const struct alc_config_preset *preset)
277 int i;
279 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
280 spec->mixers[spec->num_mixers++] = preset->mixers[i];
281 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; i++)
282 spec->init_verbs[spec->num_init_verbs++] = preset->init_verbs[i];
284 spec->channel_mode = preset->channel_mode;
285 spec->num_channel_mode = preset->num_channel_mode;
287 spec->multiout.max_channels = spec->channel_mode[0].channels;
289 spec->multiout.num_dacs = preset->num_dacs;
290 spec->multiout.dac_nids = preset->dac_nids;
291 spec->multiout.dig_out_nid = preset->dig_out_nid;
292 spec->multiout.hp_nid = preset->hp_nid;
294 spec->input_mux = preset->input_mux;
296 spec->num_adc_nids = preset->num_adc_nids;
297 spec->adc_nids = preset->adc_nids;
298 spec->dig_in_nid = preset->dig_in_nid;
302 * ALC880 3-stack model
304 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
305 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, F-Mic = 0x1b
306 * HP = 0x19
309 static hda_nid_t alc880_dac_nids[4] = {
310 /* front, rear, clfe, rear_surr */
311 0x02, 0x05, 0x04, 0x03
314 static hda_nid_t alc880_adc_nids[3] = {
315 /* ADC0-2 */
316 0x07, 0x08, 0x09,
319 /* The datasheet says the node 0x07 is connected from inputs,
320 * but it shows zero connection in the real implementation on some devices.
321 * Note: this is a 915GAV bug, fixed on 915GLV
323 static hda_nid_t alc880_adc_nids_alt[2] = {
324 /* ADC1-2 */
325 0x08, 0x09,
328 #define ALC880_DIGOUT_NID 0x06
329 #define ALC880_DIGIN_NID 0x0a
331 static struct hda_input_mux alc880_capture_source = {
332 .num_items = 4,
333 .items = {
334 { "Mic", 0x0 },
335 { "Front Mic", 0x3 },
336 { "Line", 0x2 },
337 { "CD", 0x4 },
341 /* channel source setting (2/6 channel selection for 3-stack) */
342 /* 2ch mode */
343 static struct hda_verb alc880_threestack_ch2_init[] = {
344 /* set line-in to input, mute it */
345 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
346 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
347 /* set mic-in to input vref 80%, mute it */
348 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
349 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
350 { } /* end */
353 /* 6ch mode */
354 static struct hda_verb alc880_threestack_ch6_init[] = {
355 /* set line-in to output, unmute it */
356 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
357 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
358 /* set mic-in to output, unmute it */
359 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
360 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
361 { } /* end */
364 static struct hda_channel_mode alc880_threestack_modes[2] = {
365 { 2, alc880_threestack_ch2_init },
366 { 6, alc880_threestack_ch6_init },
369 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
370 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
371 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
372 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
373 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
374 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
375 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
376 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
377 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
378 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
379 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
380 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
381 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
382 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
383 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
384 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
385 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
386 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
387 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
388 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
390 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
391 .name = "Channel Mode",
392 .info = alc_ch_mode_info,
393 .get = alc_ch_mode_get,
394 .put = alc_ch_mode_put,
396 { } /* end */
399 /* capture mixer elements */
400 static struct snd_kcontrol_new alc880_capture_mixer[] = {
401 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
402 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
403 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
404 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
405 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
406 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
408 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
409 /* The multiple "Capture Source" controls confuse alsamixer
410 * So call somewhat different..
411 * FIXME: the controls appear in the "playback" view!
413 /* .name = "Capture Source", */
414 .name = "Input Source",
415 .count = 3,
416 .info = alc_mux_enum_info,
417 .get = alc_mux_enum_get,
418 .put = alc_mux_enum_put,
420 { } /* end */
423 /* capture mixer elements (in case NID 0x07 not available) */
424 static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
425 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
426 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
427 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
428 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
430 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
431 /* The multiple "Capture Source" controls confuse alsamixer
432 * So call somewhat different..
433 * FIXME: the controls appear in the "playback" view!
435 /* .name = "Capture Source", */
436 .name = "Input Source",
437 .count = 2,
438 .info = alc_mux_enum_info,
439 .get = alc_mux_enum_get,
440 .put = alc_mux_enum_put,
442 { } /* end */
448 * ALC880 5-stack model
450 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), Side = 0x02 (0xd)
451 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
452 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
455 /* additional mixers to alc880_three_stack_mixer */
456 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
457 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
458 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
459 { } /* end */
462 /* channel source setting (6/8 channel selection for 5-stack) */
463 /* 6ch mode */
464 static struct hda_verb alc880_fivestack_ch6_init[] = {
465 /* set line-in to input, mute it */
466 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
467 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
468 { } /* end */
471 /* 8ch mode */
472 static struct hda_verb alc880_fivestack_ch8_init[] = {
473 /* set line-in to output, unmute it */
474 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
475 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
476 { } /* end */
479 static struct hda_channel_mode alc880_fivestack_modes[2] = {
480 { 6, alc880_fivestack_ch6_init },
481 { 8, alc880_fivestack_ch8_init },
486 * ALC880 6-stack model
488 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), Side = 0x05 (0x0f)
489 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
490 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
493 static hda_nid_t alc880_6st_dac_nids[4] = {
494 /* front, rear, clfe, rear_surr */
495 0x02, 0x03, 0x04, 0x05
498 static struct hda_input_mux alc880_6stack_capture_source = {
499 .num_items = 4,
500 .items = {
501 { "Mic", 0x0 },
502 { "Front Mic", 0x1 },
503 { "Line", 0x2 },
504 { "CD", 0x4 },
508 /* fixed 8-channels */
509 static struct hda_channel_mode alc880_sixstack_modes[1] = {
510 { 8, NULL },
513 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
514 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
515 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
516 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
517 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
518 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
519 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
520 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
521 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
522 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
523 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
524 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
525 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
526 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
527 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
528 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
529 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
530 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
531 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
532 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
533 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
535 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
536 .name = "Channel Mode",
537 .info = alc_ch_mode_info,
538 .get = alc_ch_mode_get,
539 .put = alc_ch_mode_put,
541 { } /* end */
546 * ALC880 W810 model
548 * W810 has rear IO for:
549 * Front (DAC 02)
550 * Surround (DAC 03)
551 * Center/LFE (DAC 04)
552 * Digital out (06)
554 * The system also has a pair of internal speakers, and a headphone jack.
555 * These are both connected to Line2 on the codec, hence to DAC 02.
557 * There is a variable resistor to control the speaker or headphone
558 * volume. This is a hardware-only device without a software API.
560 * Plugging headphones in will disable the internal speakers. This is
561 * implemented in hardware, not via the driver using jack sense. In
562 * a similar fashion, plugging into the rear socket marked "front" will
563 * disable both the speakers and headphones.
565 * For input, there's a microphone jack, and an "audio in" jack.
566 * These may not do anything useful with this driver yet, because I
567 * haven't setup any initialization verbs for these yet...
570 static hda_nid_t alc880_w810_dac_nids[3] = {
571 /* front, rear/surround, clfe */
572 0x02, 0x03, 0x04
575 /* fixed 6 channels */
576 static struct hda_channel_mode alc880_w810_modes[1] = {
577 { 6, NULL }
580 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
581 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
582 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
583 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
584 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
585 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
586 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
587 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
588 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
589 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
590 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
591 { } /* end */
596 * Z710V model
598 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
599 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), Line = 0x1a
602 static hda_nid_t alc880_z71v_dac_nids[1] = {
603 0x02
605 #define ALC880_Z71V_HP_DAC 0x03
607 /* fixed 2 channels */
608 static struct hda_channel_mode alc880_2_jack_modes[1] = {
609 { 2, NULL }
612 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
613 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
614 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
615 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
616 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
617 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
618 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
619 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
620 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
621 { } /* end */
625 /* FIXME! */
627 * ALC880 F1734 model
629 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
630 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
633 static hda_nid_t alc880_f1734_dac_nids[1] = {
634 0x03
636 #define ALC880_F1734_HP_DAC 0x02
638 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
639 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
640 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
641 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
642 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
643 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
644 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
645 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
646 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
647 { } /* end */
651 /* FIXME! */
653 * ALC880 ASUS model
655 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
656 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
657 * Mic = 0x18, Line = 0x1a
660 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
661 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
663 static struct snd_kcontrol_new alc880_asus_mixer[] = {
664 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
665 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
666 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
667 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
668 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
669 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
670 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
671 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
672 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
673 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
674 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
675 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
676 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
677 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
679 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
680 .name = "Channel Mode",
681 .info = alc_ch_mode_info,
682 .get = alc_ch_mode_get,
683 .put = alc_ch_mode_put,
685 { } /* end */
688 /* FIXME! */
690 * ALC880 ASUS W1V model
692 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
693 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
694 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
697 /* additional mixers to alc880_asus_mixer */
698 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
699 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
700 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
701 { } /* end */
704 /* additional mixers to alc880_asus_mixer */
705 static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
706 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
707 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
708 { } /* end */
711 /* TCL S700 */
712 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
713 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
714 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
715 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
716 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
717 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
718 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
719 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
720 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
721 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
723 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
724 /* The multiple "Capture Source" controls confuse alsamixer
725 * So call somewhat different..
726 * FIXME: the controls appear in the "playback" view!
728 /* .name = "Capture Source", */
729 .name = "Input Source",
730 .count = 1,
731 .info = alc_mux_enum_info,
732 .get = alc_mux_enum_get,
733 .put = alc_mux_enum_put,
735 { } /* end */
739 * build control elements
741 static int alc_build_controls(struct hda_codec *codec)
743 struct alc_spec *spec = codec->spec;
744 int err;
745 int i;
747 for (i = 0; i < spec->num_mixers; i++) {
748 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
749 if (err < 0)
750 return err;
753 if (spec->multiout.dig_out_nid) {
754 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
755 if (err < 0)
756 return err;
758 if (spec->dig_in_nid) {
759 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
760 if (err < 0)
761 return err;
763 return 0;
768 * initialize the codec volumes, etc
772 * generic initialization of ADC, input mixers and output mixers
774 static struct hda_verb alc880_volume_init_verbs[] = {
776 * Unmute ADC0-2 and set the default input to mic-in
778 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
779 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
780 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
781 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
782 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
783 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
785 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
786 * mixer widget
787 * Note: PASD motherboards uses the Line In 2 as the input for front panel
788 * mic (mic 2)
790 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
791 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
792 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
793 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
794 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
795 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
798 * Set up output mixers (0x0c - 0x0f)
800 /* set vol=0 to output mixers */
801 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
802 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
803 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
804 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
805 /* set up input amps for analog loopback */
806 /* Amp Indices: DAC = 0, mixer = 1 */
807 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
808 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
809 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
810 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
811 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
812 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
813 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
814 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
820 * 3-stack pin configuration:
821 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
823 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
825 * preset connection lists of input pins
826 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
828 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
829 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
830 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
833 * Set pin mode and muting
835 /* set front pin widgets 0x14 for output */
836 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
837 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
838 /* Mic1 (rear panel) pin widget for input and vref at 80% */
839 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
840 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
841 /* Mic2 (as headphone out) for HP output */
842 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
843 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
844 /* Line In pin widget for input */
845 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
846 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
847 /* Line2 (as front mic) pin widget for input and vref at 80% */
848 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
849 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
850 /* CD pin widget for input */
851 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
857 * 5-stack pin configuration:
858 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
859 * line-in/side = 0x1a, f-mic = 0x1b
861 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
863 * preset connection lists of input pins
864 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
866 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
867 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
870 * Set pin mode and muting
872 /* set pin widgets 0x14-0x17 for output */
873 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
874 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
875 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
876 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
877 /* unmute pins for output (no gain on this amp) */
878 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
879 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
880 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
881 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
883 /* Mic1 (rear panel) pin widget for input and vref at 80% */
884 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
885 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
886 /* Mic2 (as headphone out) for HP output */
887 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
888 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
889 /* Line In pin widget for input */
890 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
891 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
892 /* Line2 (as front mic) pin widget for input and vref at 80% */
893 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
894 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
895 /* CD pin widget for input */
896 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
902 * W810 pin configuration:
903 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
905 static struct hda_verb alc880_pin_w810_init_verbs[] = {
906 /* hphone/speaker input selector: front DAC */
907 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
909 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
910 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
911 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
912 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
913 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
914 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
916 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
917 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
923 * Z71V pin configuration:
924 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
926 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
927 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
928 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
929 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
930 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
932 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
933 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
934 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
935 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
941 * 6-stack pin configuration:
942 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, f-mic = 0x19,
943 * line = 0x1a, HP = 0x1b
945 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
946 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
948 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
949 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
950 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
951 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
952 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
953 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
954 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
955 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
957 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
958 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
959 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
960 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
961 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
962 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
963 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
964 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
965 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
970 /* FIXME! */
972 * F1734 pin configuration:
973 * HP = 0x14, speaker-out = 0x15, mic = 0x18
975 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
976 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
977 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
978 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
979 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
981 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
982 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
983 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
984 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
986 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
987 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
988 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
989 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
990 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
991 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
992 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
993 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
994 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
999 /* FIXME! */
1001 * ASUS pin configuration:
1002 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1004 static struct hda_verb alc880_pin_asus_init_verbs[] = {
1005 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1006 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1007 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1008 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1010 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1011 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1012 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1013 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1014 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1015 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1016 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1017 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1019 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1020 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1021 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1022 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1023 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1024 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1025 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1026 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1027 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1032 /* Enable GPIO mask and set output */
1033 static struct hda_verb alc880_gpio1_init_verbs[] = {
1034 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
1035 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
1036 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
1041 /* Enable GPIO mask and set output */
1042 static struct hda_verb alc880_gpio2_init_verbs[] = {
1043 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1044 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1045 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
1050 /* Clevo m520g init */
1051 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1052 /* headphone output */
1053 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1054 /* line-out */
1055 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1056 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1057 /* Line-in */
1058 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1059 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1060 /* CD */
1061 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1062 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1063 /* Mic1 (rear panel) */
1064 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1065 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1066 /* Mic2 (front panel) */
1067 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1068 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1069 /* headphone */
1070 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1071 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1072 /* change to EAPD mode */
1073 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1074 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1079 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
1080 /* Headphone output */
1081 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1082 /* Front output*/
1083 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1084 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1086 /* Line In pin widget for input */
1087 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1088 /* CD pin widget for input */
1089 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1090 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1091 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1093 /* change to EAPD mode */
1094 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1095 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1103 static int alc_init(struct hda_codec *codec)
1105 struct alc_spec *spec = codec->spec;
1106 unsigned int i;
1108 for (i = 0; i < spec->num_init_verbs; i++)
1109 snd_hda_sequence_write(codec, spec->init_verbs[i]);
1110 return 0;
1113 #ifdef CONFIG_PM
1115 * resume
1117 static int alc_resume(struct hda_codec *codec)
1119 struct alc_spec *spec = codec->spec;
1120 int i;
1122 alc_init(codec);
1123 for (i = 0; i < spec->num_mixers; i++)
1124 snd_hda_resume_ctls(codec, spec->mixers[i]);
1125 if (spec->multiout.dig_out_nid)
1126 snd_hda_resume_spdif_out(codec);
1127 if (spec->dig_in_nid)
1128 snd_hda_resume_spdif_in(codec);
1130 return 0;
1132 #endif
1135 * Analog playback callbacks
1137 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
1138 struct hda_codec *codec,
1139 struct snd_pcm_substream *substream)
1141 struct alc_spec *spec = codec->spec;
1142 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1145 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1146 struct hda_codec *codec,
1147 unsigned int stream_tag,
1148 unsigned int format,
1149 struct snd_pcm_substream *substream)
1151 struct alc_spec *spec = codec->spec;
1152 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
1153 format, substream);
1156 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1157 struct hda_codec *codec,
1158 struct snd_pcm_substream *substream)
1160 struct alc_spec *spec = codec->spec;
1161 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1165 * Digital out
1167 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1168 struct hda_codec *codec,
1169 struct snd_pcm_substream *substream)
1171 struct alc_spec *spec = codec->spec;
1172 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1175 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1176 struct hda_codec *codec,
1177 struct snd_pcm_substream *substream)
1179 struct alc_spec *spec = codec->spec;
1180 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1184 * Analog capture
1186 static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1187 struct hda_codec *codec,
1188 unsigned int stream_tag,
1189 unsigned int format,
1190 struct snd_pcm_substream *substream)
1192 struct alc_spec *spec = codec->spec;
1194 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1195 stream_tag, 0, format);
1196 return 0;
1199 static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1200 struct hda_codec *codec,
1201 struct snd_pcm_substream *substream)
1203 struct alc_spec *spec = codec->spec;
1205 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
1206 return 0;
1212 static struct hda_pcm_stream alc880_pcm_analog_playback = {
1213 .substreams = 1,
1214 .channels_min = 2,
1215 .channels_max = 8,
1216 /* NID is set in alc_build_pcms */
1217 .ops = {
1218 .open = alc880_playback_pcm_open,
1219 .prepare = alc880_playback_pcm_prepare,
1220 .cleanup = alc880_playback_pcm_cleanup
1224 static struct hda_pcm_stream alc880_pcm_analog_capture = {
1225 .substreams = 2,
1226 .channels_min = 2,
1227 .channels_max = 2,
1228 /* NID is set in alc_build_pcms */
1229 .ops = {
1230 .prepare = alc880_capture_pcm_prepare,
1231 .cleanup = alc880_capture_pcm_cleanup
1235 static struct hda_pcm_stream alc880_pcm_digital_playback = {
1236 .substreams = 1,
1237 .channels_min = 2,
1238 .channels_max = 2,
1239 /* NID is set in alc_build_pcms */
1240 .ops = {
1241 .open = alc880_dig_playback_pcm_open,
1242 .close = alc880_dig_playback_pcm_close
1246 static struct hda_pcm_stream alc880_pcm_digital_capture = {
1247 .substreams = 1,
1248 .channels_min = 2,
1249 .channels_max = 2,
1250 /* NID is set in alc_build_pcms */
1253 static int alc_build_pcms(struct hda_codec *codec)
1255 struct alc_spec *spec = codec->spec;
1256 struct hda_pcm *info = spec->pcm_rec;
1257 int i;
1259 codec->num_pcms = 1;
1260 codec->pcm_info = info;
1262 info->name = spec->stream_name_analog;
1263 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
1264 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
1265 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1266 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1268 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
1269 for (i = 0; i < spec->num_channel_mode; i++) {
1270 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
1271 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
1275 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
1276 codec->num_pcms++;
1277 info++;
1278 info->name = spec->stream_name_digital;
1279 if (spec->multiout.dig_out_nid) {
1280 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
1281 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
1283 if (spec->dig_in_nid) {
1284 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
1285 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
1289 return 0;
1292 static void alc_free(struct hda_codec *codec)
1294 struct alc_spec *spec = codec->spec;
1295 unsigned int i;
1297 if (! spec)
1298 return;
1300 if (spec->kctl_alloc) {
1301 for (i = 0; i < spec->num_kctl_used; i++)
1302 kfree(spec->kctl_alloc[i].name);
1303 kfree(spec->kctl_alloc);
1305 kfree(spec);
1310 static struct hda_codec_ops alc_patch_ops = {
1311 .build_controls = alc_build_controls,
1312 .build_pcms = alc_build_pcms,
1313 .init = alc_init,
1314 .free = alc_free,
1315 #ifdef CONFIG_PM
1316 .resume = alc_resume,
1317 #endif
1322 * Test configuration for debugging
1324 * Almost all inputs/outputs are enabled. I/O pins can be configured via
1325 * enum controls.
1327 #ifdef CONFIG_SND_DEBUG
1328 static hda_nid_t alc880_test_dac_nids[4] = {
1329 0x02, 0x03, 0x04, 0x05
1332 static struct hda_input_mux alc880_test_capture_source = {
1333 .num_items = 5,
1334 .items = {
1335 { "In-1", 0x0 },
1336 { "In-2", 0x1 },
1337 { "In-3", 0x2 },
1338 { "In-4", 0x3 },
1339 { "CD", 0x4 },
1343 static struct hda_channel_mode alc880_test_modes[4] = {
1344 { 2, NULL },
1345 { 4, NULL },
1346 { 6, NULL },
1347 { 8, NULL },
1350 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1352 static char *texts[] = {
1353 "N/A", "Line Out", "HP Out",
1354 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
1356 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1357 uinfo->count = 1;
1358 uinfo->value.enumerated.items = 8;
1359 if (uinfo->value.enumerated.item >= 8)
1360 uinfo->value.enumerated.item = 7;
1361 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1362 return 0;
1365 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1367 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1368 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1369 unsigned int pin_ctl, item = 0;
1371 pin_ctl = snd_hda_codec_read(codec, nid, 0,
1372 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1373 if (pin_ctl & AC_PINCTL_OUT_EN) {
1374 if (pin_ctl & AC_PINCTL_HP_EN)
1375 item = 2;
1376 else
1377 item = 1;
1378 } else if (pin_ctl & AC_PINCTL_IN_EN) {
1379 switch (pin_ctl & AC_PINCTL_VREFEN) {
1380 case AC_PINCTL_VREF_HIZ: item = 3; break;
1381 case AC_PINCTL_VREF_50: item = 4; break;
1382 case AC_PINCTL_VREF_GRD: item = 5; break;
1383 case AC_PINCTL_VREF_80: item = 6; break;
1384 case AC_PINCTL_VREF_100: item = 7; break;
1387 ucontrol->value.enumerated.item[0] = item;
1388 return 0;
1391 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1393 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1394 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1395 static unsigned int ctls[] = {
1396 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
1397 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
1398 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
1399 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
1400 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
1401 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
1403 unsigned int old_ctl, new_ctl;
1405 old_ctl = snd_hda_codec_read(codec, nid, 0,
1406 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1407 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
1408 if (old_ctl != new_ctl) {
1409 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
1410 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
1411 ucontrol->value.enumerated.item[0] >= 3 ? 0xb080 : 0xb000);
1412 return 1;
1414 return 0;
1417 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1419 static char *texts[] = {
1420 "Front", "Surround", "CLFE", "Side"
1422 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1423 uinfo->count = 1;
1424 uinfo->value.enumerated.items = 4;
1425 if (uinfo->value.enumerated.item >= 4)
1426 uinfo->value.enumerated.item = 3;
1427 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1428 return 0;
1431 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1433 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1434 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1435 unsigned int sel;
1437 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
1438 ucontrol->value.enumerated.item[0] = sel & 3;
1439 return 0;
1442 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1444 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1445 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1446 unsigned int sel;
1448 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
1449 if (ucontrol->value.enumerated.item[0] != sel) {
1450 sel = ucontrol->value.enumerated.item[0] & 3;
1451 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
1452 return 1;
1454 return 0;
1457 #define PIN_CTL_TEST(xname,nid) { \
1458 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1459 .name = xname, \
1460 .info = alc_test_pin_ctl_info, \
1461 .get = alc_test_pin_ctl_get, \
1462 .put = alc_test_pin_ctl_put, \
1463 .private_value = nid \
1466 #define PIN_SRC_TEST(xname,nid) { \
1467 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1468 .name = xname, \
1469 .info = alc_test_pin_src_info, \
1470 .get = alc_test_pin_src_get, \
1471 .put = alc_test_pin_src_put, \
1472 .private_value = nid \
1475 static struct snd_kcontrol_new alc880_test_mixer[] = {
1476 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1477 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1478 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
1479 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1480 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1481 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1482 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
1483 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1484 PIN_CTL_TEST("Front Pin Mode", 0x14),
1485 PIN_CTL_TEST("Surround Pin Mode", 0x15),
1486 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
1487 PIN_CTL_TEST("Side Pin Mode", 0x17),
1488 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
1489 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
1490 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
1491 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
1492 PIN_SRC_TEST("In-1 Pin Source", 0x18),
1493 PIN_SRC_TEST("In-2 Pin Source", 0x19),
1494 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
1495 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
1496 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
1497 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
1498 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
1499 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
1500 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
1501 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
1502 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
1503 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
1504 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
1505 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
1507 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1508 .name = "Channel Mode",
1509 .info = alc_ch_mode_info,
1510 .get = alc_ch_mode_get,
1511 .put = alc_ch_mode_put,
1513 { } /* end */
1516 static struct hda_verb alc880_test_init_verbs[] = {
1517 /* Unmute inputs of 0x0c - 0x0f */
1518 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1519 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1520 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1521 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1522 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1523 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1524 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1525 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1526 /* Vol output for 0x0c-0x0f */
1527 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1528 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1529 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1530 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1531 /* Set output pins 0x14-0x17 */
1532 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1533 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1534 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1535 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1536 /* Unmute output pins 0x14-0x17 */
1537 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1538 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1539 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1540 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1541 /* Set input pins 0x18-0x1c */
1542 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1543 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1544 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1545 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1546 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1547 /* Mute input pins 0x18-0x1b */
1548 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1549 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1550 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1551 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1552 /* ADC set up */
1553 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1554 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1555 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1556 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1557 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1558 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1559 /* Analog input/passthru */
1560 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1561 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1562 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1563 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1564 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1567 #endif
1572 static struct hda_board_config alc880_cfg_tbl[] = {
1573 /* Back 3 jack, front 2 jack */
1574 { .modelname = "3stack", .config = ALC880_3ST },
1575 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
1576 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
1577 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
1578 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
1579 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
1580 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
1581 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
1582 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
1583 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
1584 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
1585 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
1586 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
1587 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
1588 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
1589 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
1590 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
1591 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
1592 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
1593 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
1594 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
1595 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
1596 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
1597 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
1598 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
1599 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
1600 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
1601 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
1602 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
1603 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
1604 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
1605 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
1606 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
1607 /* TCL S700 */
1608 { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
1610 /* Back 3 jack, front 2 jack (Internal add Aux-In) */
1611 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
1612 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
1613 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
1615 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
1616 { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
1617 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
1618 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
1619 /* Clevo m520G NB */
1620 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520, .config = ALC880_CLEVO },
1622 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
1623 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
1624 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
1625 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
1627 /* Back 5 jack, front 2 jack */
1628 { .modelname = "5stack", .config = ALC880_5ST },
1629 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
1630 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
1631 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
1632 { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
1633 { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
1635 /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
1636 { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
1637 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
1638 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
1639 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
1640 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
1641 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
1642 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
1643 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
1644 { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
1645 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
1646 /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
1647 { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
1648 /* note subvendor = 0 below */
1649 /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
1651 { .modelname = "w810", .config = ALC880_W810 },
1652 { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
1654 { .modelname = "z71v", .config = ALC880_Z71V },
1655 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
1657 { .modelname = "6stack", .config = ALC880_6ST },
1658 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
1659 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
1661 { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
1662 { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
1663 { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
1664 { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
1665 { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
1666 { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
1667 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
1668 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
1669 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
1671 { .modelname = "asus", .config = ALC880_ASUS },
1672 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
1673 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
1674 { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
1675 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
1676 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
1677 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
1678 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
1679 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
1680 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
1681 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
1682 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
1683 { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
1685 { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
1686 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
1688 { .modelname = "F1734", .config = ALC880_F1734 },
1689 { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
1690 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
1692 #ifdef CONFIG_SND_DEBUG
1693 { .modelname = "test", .config = ALC880_TEST },
1694 #endif
1695 { .modelname = "auto", .config = ALC880_AUTO },
1701 * ALC880 codec presets
1703 static struct alc_config_preset alc880_presets[] = {
1704 [ALC880_3ST] = {
1705 .mixers = { alc880_three_stack_mixer },
1706 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
1707 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1708 .dac_nids = alc880_dac_nids,
1709 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
1710 .channel_mode = alc880_threestack_modes,
1711 .input_mux = &alc880_capture_source,
1713 [ALC880_3ST_DIG] = {
1714 .mixers = { alc880_three_stack_mixer },
1715 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
1716 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1717 .dac_nids = alc880_dac_nids,
1718 .dig_out_nid = ALC880_DIGOUT_NID,
1719 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
1720 .channel_mode = alc880_threestack_modes,
1721 .input_mux = &alc880_capture_source,
1723 [ALC880_TCL_S700] = {
1724 .mixers = { alc880_tcl_s700_mixer },
1725 .init_verbs = { alc880_volume_init_verbs,
1726 alc880_pin_tcl_S700_init_verbs,
1727 alc880_gpio2_init_verbs },
1728 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1729 .dac_nids = alc880_dac_nids,
1730 .hp_nid = 0x03,
1731 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
1732 .channel_mode = alc880_2_jack_modes,
1733 .input_mux = &alc880_capture_source,
1735 [ALC880_5ST] = {
1736 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
1737 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
1738 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1739 .dac_nids = alc880_dac_nids,
1740 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
1741 .channel_mode = alc880_fivestack_modes,
1742 .input_mux = &alc880_capture_source,
1744 [ALC880_5ST_DIG] = {
1745 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
1746 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
1747 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1748 .dac_nids = alc880_dac_nids,
1749 .dig_out_nid = ALC880_DIGOUT_NID,
1750 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
1751 .channel_mode = alc880_fivestack_modes,
1752 .input_mux = &alc880_capture_source,
1754 [ALC880_6ST] = {
1755 .mixers = { alc880_six_stack_mixer },
1756 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
1757 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
1758 .dac_nids = alc880_6st_dac_nids,
1759 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
1760 .channel_mode = alc880_sixstack_modes,
1761 .input_mux = &alc880_6stack_capture_source,
1763 [ALC880_6ST_DIG] = {
1764 .mixers = { alc880_six_stack_mixer },
1765 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
1766 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
1767 .dac_nids = alc880_6st_dac_nids,
1768 .dig_out_nid = ALC880_DIGOUT_NID,
1769 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
1770 .channel_mode = alc880_sixstack_modes,
1771 .input_mux = &alc880_6stack_capture_source,
1773 [ALC880_W810] = {
1774 .mixers = { alc880_w810_base_mixer },
1775 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
1776 alc880_gpio2_init_verbs },
1777 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
1778 .dac_nids = alc880_w810_dac_nids,
1779 .dig_out_nid = ALC880_DIGOUT_NID,
1780 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
1781 .channel_mode = alc880_w810_modes,
1782 .input_mux = &alc880_capture_source,
1784 [ALC880_Z71V] = {
1785 .mixers = { alc880_z71v_mixer },
1786 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
1787 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
1788 .dac_nids = alc880_z71v_dac_nids,
1789 .dig_out_nid = ALC880_DIGOUT_NID,
1790 .hp_nid = 0x03,
1791 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
1792 .channel_mode = alc880_2_jack_modes,
1793 .input_mux = &alc880_capture_source,
1795 [ALC880_F1734] = {
1796 .mixers = { alc880_f1734_mixer },
1797 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
1798 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
1799 .dac_nids = alc880_f1734_dac_nids,
1800 .hp_nid = 0x02,
1801 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
1802 .channel_mode = alc880_2_jack_modes,
1803 .input_mux = &alc880_capture_source,
1805 [ALC880_ASUS] = {
1806 .mixers = { alc880_asus_mixer },
1807 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1808 alc880_gpio1_init_verbs },
1809 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1810 .dac_nids = alc880_asus_dac_nids,
1811 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1812 .channel_mode = alc880_asus_modes,
1813 .input_mux = &alc880_capture_source,
1815 [ALC880_ASUS_DIG] = {
1816 .mixers = { alc880_asus_mixer },
1817 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1818 alc880_gpio1_init_verbs },
1819 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1820 .dac_nids = alc880_asus_dac_nids,
1821 .dig_out_nid = ALC880_DIGOUT_NID,
1822 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1823 .channel_mode = alc880_asus_modes,
1824 .input_mux = &alc880_capture_source,
1826 [ALC880_ASUS_DIG2] = {
1827 .mixers = { alc880_asus_mixer },
1828 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1829 alc880_gpio2_init_verbs }, /* use GPIO2 */
1830 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1831 .dac_nids = alc880_asus_dac_nids,
1832 .dig_out_nid = ALC880_DIGOUT_NID,
1833 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1834 .channel_mode = alc880_asus_modes,
1835 .input_mux = &alc880_capture_source,
1837 [ALC880_ASUS_W1V] = {
1838 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
1839 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1840 alc880_gpio1_init_verbs },
1841 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1842 .dac_nids = alc880_asus_dac_nids,
1843 .dig_out_nid = ALC880_DIGOUT_NID,
1844 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1845 .channel_mode = alc880_asus_modes,
1846 .input_mux = &alc880_capture_source,
1848 [ALC880_UNIWILL_DIG] = {
1849 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
1850 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
1851 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1852 .dac_nids = alc880_asus_dac_nids,
1853 .dig_out_nid = ALC880_DIGOUT_NID,
1854 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1855 .channel_mode = alc880_asus_modes,
1856 .input_mux = &alc880_capture_source,
1858 [ALC880_CLEVO] = {
1859 .mixers = { alc880_three_stack_mixer },
1860 .init_verbs = { alc880_volume_init_verbs,
1861 alc880_pin_clevo_init_verbs },
1862 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1863 .dac_nids = alc880_dac_nids,
1864 .hp_nid = 0x03,
1865 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
1866 .channel_mode = alc880_threestack_modes,
1867 .input_mux = &alc880_capture_source,
1869 #ifdef CONFIG_SND_DEBUG
1870 [ALC880_TEST] = {
1871 .mixers = { alc880_test_mixer },
1872 .init_verbs = { alc880_test_init_verbs },
1873 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
1874 .dac_nids = alc880_test_dac_nids,
1875 .dig_out_nid = ALC880_DIGOUT_NID,
1876 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
1877 .channel_mode = alc880_test_modes,
1878 .input_mux = &alc880_test_capture_source,
1880 #endif
1884 * Automatic parse of I/O pins from the BIOS configuration
1887 #define NUM_CONTROL_ALLOC 32
1888 #define NUM_VERB_ALLOC 32
1890 enum {
1891 ALC_CTL_WIDGET_VOL,
1892 ALC_CTL_WIDGET_MUTE,
1893 ALC_CTL_BIND_MUTE,
1895 static struct snd_kcontrol_new alc880_control_templates[] = {
1896 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
1897 HDA_CODEC_MUTE(NULL, 0, 0, 0),
1898 HDA_BIND_MUTE(NULL, 0, 0, 0),
1901 /* add dynamic controls */
1902 static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
1904 struct snd_kcontrol_new *knew;
1906 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
1907 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
1909 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
1910 if (! knew)
1911 return -ENOMEM;
1912 if (spec->kctl_alloc) {
1913 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
1914 kfree(spec->kctl_alloc);
1916 spec->kctl_alloc = knew;
1917 spec->num_kctl_alloc = num;
1920 knew = &spec->kctl_alloc[spec->num_kctl_used];
1921 *knew = alc880_control_templates[type];
1922 knew->name = kstrdup(name, GFP_KERNEL);
1923 if (! knew->name)
1924 return -ENOMEM;
1925 knew->private_value = val;
1926 spec->num_kctl_used++;
1927 return 0;
1930 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
1931 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
1932 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
1933 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
1934 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
1935 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
1936 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
1937 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
1938 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
1939 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
1940 #define ALC880_PIN_CD_NID 0x1c
1942 /* fill in the dac_nids table from the parsed pin configuration */
1943 static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
1945 hda_nid_t nid;
1946 int assigned[4];
1947 int i, j;
1949 memset(assigned, 0, sizeof(assigned));
1950 spec->multiout.dac_nids = spec->private_dac_nids;
1952 /* check the pins hardwired to audio widget */
1953 for (i = 0; i < cfg->line_outs; i++) {
1954 nid = cfg->line_out_pins[i];
1955 if (alc880_is_fixed_pin(nid)) {
1956 int idx = alc880_fixed_pin_idx(nid);
1957 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
1958 assigned[idx] = 1;
1961 /* left pins can be connect to any audio widget */
1962 for (i = 0; i < cfg->line_outs; i++) {
1963 nid = cfg->line_out_pins[i];
1964 if (alc880_is_fixed_pin(nid))
1965 continue;
1966 /* search for an empty channel */
1967 for (j = 0; j < cfg->line_outs; j++) {
1968 if (! assigned[j]) {
1969 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
1970 assigned[j] = 1;
1971 break;
1975 spec->multiout.num_dacs = cfg->line_outs;
1976 return 0;
1979 /* add playback controls from the parsed DAC table */
1980 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
1981 const struct auto_pin_cfg *cfg)
1983 char name[32];
1984 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
1985 hda_nid_t nid;
1986 int i, err;
1988 for (i = 0; i < cfg->line_outs; i++) {
1989 if (! spec->multiout.dac_nids[i])
1990 continue;
1991 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
1992 if (i == 2) {
1993 /* Center/LFE */
1994 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
1995 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
1996 return err;
1997 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
1998 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
1999 return err;
2000 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
2001 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
2002 return err;
2003 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
2004 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
2005 return err;
2006 } else {
2007 sprintf(name, "%s Playback Volume", chname[i]);
2008 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2009 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2010 return err;
2011 sprintf(name, "%s Playback Switch", chname[i]);
2012 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2013 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2014 return err;
2017 return 0;
2020 /* add playback controls for speaker and HP outputs */
2021 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
2022 const char *pfx)
2024 hda_nid_t nid;
2025 int err;
2026 char name[32];
2028 if (! pin)
2029 return 0;
2031 if (alc880_is_fixed_pin(pin)) {
2032 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
2033 if (! spec->multiout.dac_nids[0]) {
2034 /* use this as the primary output */
2035 spec->multiout.dac_nids[0] = nid;
2036 if (! spec->multiout.num_dacs)
2037 spec->multiout.num_dacs = 1;
2038 } else
2039 /* specify the DAC as the extra output */
2040 spec->multiout.hp_nid = nid;
2041 /* control HP volume/switch on the output mixer amp */
2042 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
2043 sprintf(name, "%s Playback Volume", pfx);
2044 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2045 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2046 return err;
2047 sprintf(name, "%s Playback Switch", pfx);
2048 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2049 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2050 return err;
2051 } else if (alc880_is_multi_pin(pin)) {
2052 /* set manual connection */
2053 if (! spec->multiout.dac_nids[0]) {
2054 /* use this as the primary output */
2055 spec->multiout.dac_nids[0] = alc880_idx_to_dac(alc880_multi_pin_idx(pin));
2056 if (! spec->multiout.num_dacs)
2057 spec->multiout.num_dacs = 1;
2059 /* we have only a switch on HP-out PIN */
2060 sprintf(name, "%s Playback Switch", pfx);
2061 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2062 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
2063 return err;
2065 return 0;
2068 /* create input playback/capture controls for the given pin */
2069 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
2070 int idx, hda_nid_t mix_nid)
2072 char name[32];
2073 int err;
2075 sprintf(name, "%s Playback Volume", ctlname);
2076 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2077 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
2078 return err;
2079 sprintf(name, "%s Playback Switch", ctlname);
2080 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2081 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
2082 return err;
2083 return 0;
2086 /* create playback/capture controls for input pins */
2087 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
2088 const struct auto_pin_cfg *cfg)
2090 static char *labels[AUTO_PIN_LAST] = {
2091 "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux"
2093 struct hda_input_mux *imux = &spec->private_imux;
2094 int i, err, idx;
2096 for (i = 0; i < AUTO_PIN_LAST; i++) {
2097 if (alc880_is_input_pin(cfg->input_pins[i])) {
2098 idx = alc880_input_pin_idx(cfg->input_pins[i]);
2099 err = new_analog_input(spec, cfg->input_pins[i], labels[i],
2100 idx, 0x0b);
2101 if (err < 0)
2102 return err;
2103 imux->items[imux->num_items].label = labels[i];
2104 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
2105 imux->num_items++;
2108 return 0;
2111 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2112 hda_nid_t nid, int pin_type,
2113 int dac_idx)
2115 /* set as output */
2116 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2117 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2118 /* need the manual connection? */
2119 if (alc880_is_multi_pin(nid)) {
2120 struct alc_spec *spec = codec->spec;
2121 int idx = alc880_multi_pin_idx(nid);
2122 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
2123 AC_VERB_SET_CONNECT_SEL,
2124 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
2128 static void alc880_auto_init_multi_out(struct hda_codec *codec)
2130 struct alc_spec *spec = codec->spec;
2131 int i;
2133 for (i = 0; i < spec->autocfg.line_outs; i++) {
2134 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2135 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2139 static void alc880_auto_init_extra_out(struct hda_codec *codec)
2141 struct alc_spec *spec = codec->spec;
2142 hda_nid_t pin;
2144 pin = spec->autocfg.speaker_pin;
2145 if (pin) /* connect to front */
2146 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
2147 pin = spec->autocfg.hp_pin;
2148 if (pin) /* connect to front */
2149 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2152 static void alc880_auto_init_analog_input(struct hda_codec *codec)
2154 struct alc_spec *spec = codec->spec;
2155 int i;
2157 for (i = 0; i < AUTO_PIN_LAST; i++) {
2158 hda_nid_t nid = spec->autocfg.input_pins[i];
2159 if (alc880_is_input_pin(nid)) {
2160 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2161 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2162 if (nid != ALC880_PIN_CD_NID)
2163 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2164 AMP_OUT_MUTE);
2169 /* parse the BIOS configuration and set up the alc_spec */
2170 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2171 static int alc880_parse_auto_config(struct hda_codec *codec)
2173 struct alc_spec *spec = codec->spec;
2174 int err;
2175 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
2177 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
2178 alc880_ignore)) < 0)
2179 return err;
2180 if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
2181 ! spec->autocfg.hp_pin)
2182 return 0; /* can't find valid BIOS pin config */
2184 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
2185 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
2186 (err = alc880_auto_create_extra_out(spec, spec->autocfg.speaker_pin,
2187 "Speaker")) < 0 ||
2188 (err = alc880_auto_create_extra_out(spec, spec->autocfg.speaker_pin,
2189 "Headphone")) < 0 ||
2190 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2191 return err;
2193 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2195 if (spec->autocfg.dig_out_pin)
2196 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
2197 if (spec->autocfg.dig_in_pin)
2198 spec->dig_in_nid = ALC880_DIGIN_NID;
2200 if (spec->kctl_alloc)
2201 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2203 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
2205 spec->input_mux = &spec->private_imux;
2207 return 1;
2210 /* init callback for auto-configuration model -- overriding the default init */
2211 static int alc880_auto_init(struct hda_codec *codec)
2213 alc_init(codec);
2214 alc880_auto_init_multi_out(codec);
2215 alc880_auto_init_extra_out(codec);
2216 alc880_auto_init_analog_input(codec);
2217 return 0;
2221 * OK, here we have finally the patch for ALC880
2224 static int patch_alc880(struct hda_codec *codec)
2226 struct alc_spec *spec;
2227 int board_config;
2228 int err;
2230 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2231 if (spec == NULL)
2232 return -ENOMEM;
2234 codec->spec = spec;
2236 board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
2237 if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
2238 printk(KERN_INFO "hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n");
2239 board_config = ALC880_AUTO;
2242 if (board_config == ALC880_AUTO) {
2243 /* automatic parse from the BIOS config */
2244 err = alc880_parse_auto_config(codec);
2245 if (err < 0) {
2246 alc_free(codec);
2247 return err;
2248 } else if (! err) {
2249 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 3-stack mode...\n");
2250 board_config = ALC880_3ST;
2254 if (board_config != ALC880_AUTO)
2255 setup_preset(spec, &alc880_presets[board_config]);
2257 spec->stream_name_analog = "ALC880 Analog";
2258 spec->stream_analog_playback = &alc880_pcm_analog_playback;
2259 spec->stream_analog_capture = &alc880_pcm_analog_capture;
2261 spec->stream_name_digital = "ALC880 Digital";
2262 spec->stream_digital_playback = &alc880_pcm_digital_playback;
2263 spec->stream_digital_capture = &alc880_pcm_digital_capture;
2265 if (! spec->adc_nids && spec->input_mux) {
2266 /* check whether NID 0x07 is valid */
2267 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
2268 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
2269 if (wcap != AC_WID_AUD_IN) {
2270 spec->adc_nids = alc880_adc_nids_alt;
2271 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
2272 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
2273 spec->num_mixers++;
2274 } else {
2275 spec->adc_nids = alc880_adc_nids;
2276 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
2277 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
2278 spec->num_mixers++;
2282 codec->patch_ops = alc_patch_ops;
2283 if (board_config == ALC880_AUTO)
2284 codec->patch_ops.init = alc880_auto_init;
2286 return 0;
2291 * ALC260 support
2294 static hda_nid_t alc260_dac_nids[1] = {
2295 /* front */
2296 0x02,
2299 static hda_nid_t alc260_adc_nids[1] = {
2300 /* ADC0 */
2301 0x04,
2304 static hda_nid_t alc260_adc_nids_alt[1] = {
2305 /* ADC1 */
2306 0x05,
2309 static hda_nid_t alc260_hp_adc_nids[2] = {
2310 /* ADC1, 0 */
2311 0x05, 0x04
2314 #define ALC260_DIGOUT_NID 0x03
2315 #define ALC260_DIGIN_NID 0x06
2317 static struct hda_input_mux alc260_capture_source = {
2318 .num_items = 4,
2319 .items = {
2320 { "Mic", 0x0 },
2321 { "Front Mic", 0x1 },
2322 { "Line", 0x2 },
2323 { "CD", 0x4 },
2327 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack
2328 * and the internal CD lines.
2330 static struct hda_input_mux alc260_fujitsu_capture_source = {
2331 .num_items = 2,
2332 .items = {
2333 { "Mic/Line", 0x0 },
2334 { "CD", 0x4 },
2339 * This is just place-holder, so there's something for alc_build_pcms to look
2340 * at when it calculates the maximum number of channels. ALC260 has no mixer
2341 * element which allows changing the channel mode, so the verb list is
2342 * never used.
2344 static struct hda_channel_mode alc260_modes[1] = {
2345 { 2, NULL },
2349 /* Mixer combinations
2351 * basic: base_output + input + pc_beep + capture
2352 * HP: base_output + input + capture_alt
2353 * HP_3013: hp_3013 + input + capture
2354 * fujitsu: fujitsu + capture
2357 static struct snd_kcontrol_new alc260_base_output_mixer[] = {
2358 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2359 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
2360 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2361 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
2362 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2363 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
2364 { } /* end */
2367 static struct snd_kcontrol_new alc260_input_mixer[] = {
2368 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2369 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2370 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
2371 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
2372 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
2373 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
2374 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
2375 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
2376 { } /* end */
2379 static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
2380 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
2381 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
2382 { } /* end */
2385 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
2386 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2387 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
2388 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
2389 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
2390 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2391 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
2392 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2393 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
2394 { } /* end */
2397 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
2398 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2399 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
2400 ALC_PINCTL_SWITCH("Headphone Amp Switch", 0x14, PIN_HP_AMP),
2401 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2402 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2403 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
2404 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
2405 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
2406 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
2407 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2408 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
2409 { } /* end */
2412 /* capture mixer elements */
2413 static struct snd_kcontrol_new alc260_capture_mixer[] = {
2414 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
2415 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
2416 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
2417 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
2419 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2420 /* The multiple "Capture Source" controls confuse alsamixer
2421 * So call somewhat different..
2422 * FIXME: the controls appear in the "playback" view!
2424 /* .name = "Capture Source", */
2425 .name = "Input Source",
2426 .count = 2,
2427 .info = alc_mux_enum_info,
2428 .get = alc_mux_enum_get,
2429 .put = alc_mux_enum_put,
2431 { } /* end */
2434 static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
2435 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
2436 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
2438 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2439 /* The multiple "Capture Source" controls confuse alsamixer
2440 * So call somewhat different..
2441 * FIXME: the controls appear in the "playback" view!
2443 /* .name = "Capture Source", */
2444 .name = "Input Source",
2445 .count = 1,
2446 .info = alc_mux_enum_info,
2447 .get = alc_mux_enum_get,
2448 .put = alc_mux_enum_put,
2450 { } /* end */
2454 * initialization verbs
2456 static struct hda_verb alc260_init_verbs[] = {
2457 /* Line In pin widget for input */
2458 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2459 /* CD pin widget for input */
2460 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2461 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2462 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2463 /* Mic2 (front panel) pin widget for input and vref at 80% */
2464 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2465 /* LINE-2 is used for line-out in rear */
2466 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2467 /* select line-out */
2468 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2469 /* LINE-OUT pin */
2470 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2471 /* enable HP */
2472 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2473 /* enable Mono */
2474 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2475 /* mute capture amp left and right */
2476 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2477 /* set connection select to line in (default select for this ADC) */
2478 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
2479 /* mute capture amp left and right */
2480 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2481 /* set connection select to line in (default select for this ADC) */
2482 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
2483 /* set vol=0 Line-Out mixer amp left and right */
2484 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2485 /* unmute pin widget amp left and right (no gain on this amp) */
2486 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2487 /* set vol=0 HP mixer amp left and right */
2488 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2489 /* unmute pin widget amp left and right (no gain on this amp) */
2490 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2491 /* set vol=0 Mono mixer amp left and right */
2492 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2493 /* unmute pin widget amp left and right (no gain on this amp) */
2494 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2495 /* unmute LINE-2 out pin */
2496 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2497 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
2498 /* mute CD */
2499 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
2500 /* mute Line In */
2501 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
2502 /* mute Mic */
2503 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2504 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
2505 /* mute Front out path */
2506 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2507 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2508 /* mute Headphone out path */
2509 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2510 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2511 /* mute Mono out path */
2512 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2513 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2517 static struct hda_verb alc260_hp_init_verbs[] = {
2518 /* Headphone and output */
2519 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
2520 /* mono output */
2521 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
2522 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2523 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
2524 /* Mic2 (front panel) pin widget for input and vref at 80% */
2525 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
2526 /* Line In pin widget for input */
2527 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
2528 /* Line-2 pin widget for output */
2529 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
2530 /* CD pin widget for input */
2531 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
2532 /* unmute amp left and right */
2533 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
2534 /* set connection select to line in (default select for this ADC) */
2535 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
2536 /* unmute Line-Out mixer amp left and right (volume = 0) */
2537 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
2538 /* mute pin widget amp left and right (no gain on this amp) */
2539 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
2540 /* unmute HP mixer amp left and right (volume = 0) */
2541 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
2542 /* mute pin widget amp left and right (no gain on this amp) */
2543 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
2544 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
2545 /* unmute CD */
2546 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
2547 /* unmute Line In */
2548 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
2549 /* unmute Mic */
2550 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2551 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
2552 /* Unmute Front out path */
2553 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2554 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2555 /* Unmute Headphone out path */
2556 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2557 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2558 /* Unmute Mono out path */
2559 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2560 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2564 static struct hda_verb alc260_hp_3013_init_verbs[] = {
2565 /* Line out and output */
2566 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
2567 /* mono output */
2568 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
2569 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2570 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
2571 /* Mic2 (front panel) pin widget for input and vref at 80% */
2572 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
2573 /* Line In pin widget for input */
2574 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
2575 /* Headphone pin widget for output */
2576 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
2577 /* CD pin widget for input */
2578 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
2579 /* unmute amp left and right */
2580 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
2581 /* set connection select to line in (default select for this ADC) */
2582 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
2583 /* unmute Line-Out mixer amp left and right (volume = 0) */
2584 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
2585 /* mute pin widget amp left and right (no gain on this amp) */
2586 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
2587 /* unmute HP mixer amp left and right (volume = 0) */
2588 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
2589 /* mute pin widget amp left and right (no gain on this amp) */
2590 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
2591 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
2592 /* unmute CD */
2593 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
2594 /* unmute Line In */
2595 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
2596 /* unmute Mic */
2597 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2598 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
2599 /* Unmute Front out path */
2600 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2601 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2602 /* Unmute Headphone out path */
2603 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2604 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2605 /* Unmute Mono out path */
2606 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2607 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2611 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
2612 * laptops.
2614 static struct hda_verb alc260_fujitsu_init_verbs[] = {
2615 /* Disable all GPIOs */
2616 {0x01, AC_VERB_SET_GPIO_MASK, 0},
2617 /* Internal speaker is connected to headphone pin */
2618 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2619 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
2620 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2621 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
2622 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2623 /* Ensure all other unused pins are disabled and muted.
2624 * Note: trying to set widget 0x15 to anything blocks all audio
2625 * output for some reason, so just leave that at the default.
2627 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2628 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2629 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2630 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2631 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2632 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2633 /* Disable digital (SPDIF) pins */
2634 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
2635 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
2637 /* Start with mixer outputs muted */
2638 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2639 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2640 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2642 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
2643 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2644 /* Unmute Line1 pin widget amp left and right (no equiv mixer ctrl) */
2645 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2646 /* Unmute pin widget used for Line-in (no equiv mixer ctrl) */
2647 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2649 /* Mute capture amp left and right */
2650 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2651 /* Set ADC connection select to line in (on mic1 pin) */
2652 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
2654 /* Mute all inputs to mixer widget (even unconnected ones) */
2655 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
2656 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
2657 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
2658 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
2659 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
2660 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
2661 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
2662 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
2665 static struct hda_pcm_stream alc260_pcm_analog_playback = {
2666 .substreams = 1,
2667 .channels_min = 2,
2668 .channels_max = 2,
2671 static struct hda_pcm_stream alc260_pcm_analog_capture = {
2672 .substreams = 1,
2673 .channels_min = 2,
2674 .channels_max = 2,
2678 * for BIOS auto-configuration
2681 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
2682 const char *pfx)
2684 hda_nid_t nid_vol;
2685 unsigned long vol_val, sw_val;
2686 char name[32];
2687 int err;
2689 if (nid >= 0x0f && nid < 0x11) {
2690 nid_vol = nid - 0x7;
2691 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
2692 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
2693 } else if (nid == 0x11) {
2694 nid_vol = nid - 0x7;
2695 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
2696 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
2697 } else if (nid >= 0x12 && nid <= 0x15) {
2698 nid_vol = 0x08;
2699 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
2700 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
2701 } else
2702 return 0; /* N/A */
2704 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
2705 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
2706 return err;
2707 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
2708 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
2709 return err;
2710 return 1;
2713 /* add playback controls from the parsed DAC table */
2714 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
2715 const struct auto_pin_cfg *cfg)
2717 hda_nid_t nid;
2718 int err;
2720 spec->multiout.num_dacs = 1;
2721 spec->multiout.dac_nids = spec->private_dac_nids;
2722 spec->multiout.dac_nids[0] = 0x02;
2724 nid = cfg->line_out_pins[0];
2725 if (nid) {
2726 err = alc260_add_playback_controls(spec, nid, "Front");
2727 if (err < 0)
2728 return err;
2731 nid = cfg->speaker_pin;
2732 if (nid) {
2733 err = alc260_add_playback_controls(spec, nid, "Speaker");
2734 if (err < 0)
2735 return err;
2738 nid = cfg->hp_pin;
2739 if (nid) {
2740 err = alc260_add_playback_controls(spec, nid, "Headphone");
2741 if (err < 0)
2742 return err;
2744 return 0;
2747 /* create playback/capture controls for input pins */
2748 static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
2749 const struct auto_pin_cfg *cfg)
2751 static char *labels[AUTO_PIN_LAST] = {
2752 "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux"
2754 struct hda_input_mux *imux = &spec->private_imux;
2755 int i, err, idx;
2757 for (i = 0; i < AUTO_PIN_LAST; i++) {
2758 if (cfg->input_pins[i] >= 0x12) {
2759 idx = cfg->input_pins[i] - 0x12;
2760 err = new_analog_input(spec, cfg->input_pins[i], labels[i], idx, 0x07);
2761 if (err < 0)
2762 return err;
2763 imux->items[imux->num_items].label = labels[i];
2764 imux->items[imux->num_items].index = idx;
2765 imux->num_items++;
2767 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
2768 idx = cfg->input_pins[i] - 0x09;
2769 err = new_analog_input(spec, cfg->input_pins[i], labels[i], idx, 0x07);
2770 if (err < 0)
2771 return err;
2772 imux->items[imux->num_items].label = labels[i];
2773 imux->items[imux->num_items].index = idx;
2774 imux->num_items++;
2777 return 0;
2780 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
2781 hda_nid_t nid, int pin_type,
2782 int sel_idx)
2784 /* set as output */
2785 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2786 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2787 /* need the manual connection? */
2788 if (nid >= 0x12) {
2789 int idx = nid - 0x12;
2790 snd_hda_codec_write(codec, idx + 0x0b, 0,
2791 AC_VERB_SET_CONNECT_SEL, sel_idx);
2796 static void alc260_auto_init_multi_out(struct hda_codec *codec)
2798 struct alc_spec *spec = codec->spec;
2799 hda_nid_t nid;
2801 nid = spec->autocfg.line_out_pins[0];
2802 if (nid)
2803 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
2805 nid = spec->autocfg.speaker_pin;
2806 if (nid)
2807 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
2809 nid = spec->autocfg.hp_pin;
2810 if (nid)
2811 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
2814 #define ALC260_PIN_CD_NID 0x16
2815 static void alc260_auto_init_analog_input(struct hda_codec *codec)
2817 struct alc_spec *spec = codec->spec;
2818 int i;
2820 for (i = 0; i < AUTO_PIN_LAST; i++) {
2821 hda_nid_t nid = spec->autocfg.input_pins[i];
2822 if (nid >= 0x12) {
2823 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2824 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2825 if (nid != ALC260_PIN_CD_NID)
2826 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2827 AMP_OUT_MUTE);
2833 * generic initialization of ADC, input mixers and output mixers
2835 static struct hda_verb alc260_volume_init_verbs[] = {
2837 * Unmute ADC0-1 and set the default input to mic-in
2839 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
2840 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2841 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
2842 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2844 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2845 * mixer widget
2846 * Note: PASD motherboards uses the Line In 2 as the input for front panel
2847 * mic (mic 2)
2849 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
2850 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2851 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2852 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
2853 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
2854 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
2857 * Set up output mixers (0x08 - 0x0a)
2859 /* set vol=0 to output mixers */
2860 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2861 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2862 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2863 /* set up input amps for analog loopback */
2864 /* Amp Indices: DAC = 0, mixer = 1 */
2865 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2866 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2867 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2868 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2869 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2870 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2875 static int alc260_parse_auto_config(struct hda_codec *codec)
2877 struct alc_spec *spec = codec->spec;
2878 unsigned int wcap;
2879 int err;
2880 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
2882 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
2883 alc260_ignore)) < 0)
2884 return err;
2885 if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
2886 ! spec->autocfg.hp_pin)
2887 return 0; /* can't find valid BIOS pin config */
2888 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
2889 (err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2890 return err;
2892 spec->multiout.max_channels = 2;
2894 if (spec->autocfg.dig_out_pin)
2895 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
2896 if (spec->kctl_alloc)
2897 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2899 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
2901 spec->input_mux = &spec->private_imux;
2903 /* check whether NID 0x04 is valid */
2904 wcap = snd_hda_param_read(codec, alc260_adc_nids[0], AC_PAR_AUDIO_WIDGET_CAP);
2905 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
2906 if (wcap != AC_WID_AUD_IN) {
2907 spec->adc_nids = alc260_adc_nids_alt;
2908 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
2909 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
2910 spec->num_mixers++;
2911 } else {
2912 spec->adc_nids = alc260_adc_nids;
2913 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
2914 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
2915 spec->num_mixers++;
2918 return 1;
2921 /* init callback for auto-configuration model -- overriding the default init */
2922 static int alc260_auto_init(struct hda_codec *codec)
2924 alc_init(codec);
2925 alc260_auto_init_multi_out(codec);
2926 alc260_auto_init_analog_input(codec);
2927 return 0;
2931 * ALC260 configurations
2933 static struct hda_board_config alc260_cfg_tbl[] = {
2934 { .modelname = "basic", .config = ALC260_BASIC },
2935 { .modelname = "hp", .config = ALC260_HP },
2936 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP },
2937 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
2938 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP },
2939 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
2940 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
2941 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
2942 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
2943 { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
2944 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
2945 { .modelname = "auto", .config = ALC260_AUTO },
2949 static struct alc_config_preset alc260_presets[] = {
2950 [ALC260_BASIC] = {
2951 .mixers = { alc260_base_output_mixer,
2952 alc260_input_mixer,
2953 alc260_pc_beep_mixer,
2954 alc260_capture_mixer },
2955 .init_verbs = { alc260_init_verbs },
2956 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
2957 .dac_nids = alc260_dac_nids,
2958 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
2959 .adc_nids = alc260_adc_nids,
2960 .num_channel_mode = ARRAY_SIZE(alc260_modes),
2961 .channel_mode = alc260_modes,
2962 .input_mux = &alc260_capture_source,
2964 [ALC260_HP] = {
2965 .mixers = { alc260_base_output_mixer,
2966 alc260_input_mixer,
2967 alc260_capture_alt_mixer },
2968 .init_verbs = { alc260_hp_init_verbs },
2969 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
2970 .dac_nids = alc260_dac_nids,
2971 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
2972 .adc_nids = alc260_hp_adc_nids,
2973 .num_channel_mode = ARRAY_SIZE(alc260_modes),
2974 .channel_mode = alc260_modes,
2975 .input_mux = &alc260_capture_source,
2977 [ALC260_HP_3013] = {
2978 .mixers = { alc260_hp_3013_mixer,
2979 alc260_input_mixer,
2980 alc260_capture_alt_mixer },
2981 .init_verbs = { alc260_hp_3013_init_verbs },
2982 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
2983 .dac_nids = alc260_dac_nids,
2984 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
2985 .adc_nids = alc260_hp_adc_nids,
2986 .num_channel_mode = ARRAY_SIZE(alc260_modes),
2987 .channel_mode = alc260_modes,
2988 .input_mux = &alc260_capture_source,
2990 [ALC260_FUJITSU_S702X] = {
2991 .mixers = { alc260_fujitsu_mixer,
2992 alc260_capture_mixer },
2993 .init_verbs = { alc260_fujitsu_init_verbs },
2994 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
2995 .dac_nids = alc260_dac_nids,
2996 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
2997 .adc_nids = alc260_adc_nids,
2998 .num_channel_mode = ARRAY_SIZE(alc260_modes),
2999 .channel_mode = alc260_modes,
3000 .input_mux = &alc260_fujitsu_capture_source,
3004 static int patch_alc260(struct hda_codec *codec)
3006 struct alc_spec *spec;
3007 int err, board_config;
3009 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3010 if (spec == NULL)
3011 return -ENOMEM;
3013 codec->spec = spec;
3015 board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
3016 if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
3017 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260\n");
3018 board_config = ALC260_AUTO;
3021 if (board_config == ALC260_AUTO) {
3022 /* automatic parse from the BIOS config */
3023 err = alc260_parse_auto_config(codec);
3024 if (err < 0) {
3025 alc_free(codec);
3026 return err;
3027 } else if (! err) {
3028 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
3029 board_config = ALC260_BASIC;
3033 if (board_config != ALC260_AUTO)
3034 setup_preset(spec, &alc260_presets[board_config]);
3036 spec->stream_name_analog = "ALC260 Analog";
3037 spec->stream_analog_playback = &alc260_pcm_analog_playback;
3038 spec->stream_analog_capture = &alc260_pcm_analog_capture;
3040 codec->patch_ops = alc_patch_ops;
3041 if (board_config == ALC260_AUTO)
3042 codec->patch_ops.init = alc260_auto_init;
3044 return 0;
3049 * ALC882 support
3051 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
3052 * configuration. Each pin widget can choose any input DACs and a mixer.
3053 * Each ADC is connected from a mixer of all inputs. This makes possible
3054 * 6-channel independent captures.
3056 * In addition, an independent DAC for the multi-playback (not used in this
3057 * driver yet).
3059 #define ALC882_DIGOUT_NID 0x06
3060 #define ALC882_DIGIN_NID 0x0a
3062 static struct hda_channel_mode alc882_ch_modes[1] = {
3063 { 8, NULL }
3066 static hda_nid_t alc882_dac_nids[4] = {
3067 /* front, rear, clfe, rear_surr */
3068 0x02, 0x03, 0x04, 0x05
3071 /* identical with ALC880 */
3072 #define alc882_adc_nids alc880_adc_nids
3073 #define alc882_adc_nids_alt alc880_adc_nids_alt
3075 /* input MUX */
3076 /* FIXME: should be a matrix-type input source selection */
3078 static struct hda_input_mux alc882_capture_source = {
3079 .num_items = 4,
3080 .items = {
3081 { "Mic", 0x0 },
3082 { "Front Mic", 0x1 },
3083 { "Line", 0x2 },
3084 { "CD", 0x4 },
3088 #define alc882_mux_enum_info alc_mux_enum_info
3089 #define alc882_mux_enum_get alc_mux_enum_get
3091 static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
3093 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3094 struct alc_spec *spec = codec->spec;
3095 const struct hda_input_mux *imux = spec->input_mux;
3096 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
3097 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
3098 hda_nid_t nid = capture_mixers[adc_idx];
3099 unsigned int *cur_val = &spec->cur_mux[adc_idx];
3100 unsigned int i, idx;
3102 idx = ucontrol->value.enumerated.item[0];
3103 if (idx >= imux->num_items)
3104 idx = imux->num_items - 1;
3105 if (*cur_val == idx && ! codec->in_resume)
3106 return 0;
3107 for (i = 0; i < imux->num_items; i++) {
3108 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
3109 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3110 v | (imux->items[i].index << 8));
3112 *cur_val = idx;
3113 return 1;
3117 * 6ch mode
3119 static struct hda_verb alc882_sixstack_ch6_init[] = {
3120 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
3121 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3122 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3123 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3124 { } /* end */
3128 * 8ch mode
3130 static struct hda_verb alc882_sixstack_ch8_init[] = {
3131 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3132 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3133 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3134 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3135 { } /* end */
3138 static struct hda_channel_mode alc882_sixstack_modes[2] = {
3139 { 6, alc882_sixstack_ch6_init },
3140 { 8, alc882_sixstack_ch8_init },
3143 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
3144 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
3146 static struct snd_kcontrol_new alc882_base_mixer[] = {
3147 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3148 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3149 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3150 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3151 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3152 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3153 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3154 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3155 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3156 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
3157 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
3158 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
3159 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
3160 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3161 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
3162 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3163 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3164 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3165 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3166 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
3167 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
3168 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
3169 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
3170 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
3171 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
3172 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
3173 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
3175 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3176 /* .name = "Capture Source", */
3177 .name = "Input Source",
3178 .count = 3,
3179 .info = alc882_mux_enum_info,
3180 .get = alc882_mux_enum_get,
3181 .put = alc882_mux_enum_put,
3183 { } /* end */
3186 static struct snd_kcontrol_new alc882_chmode_mixer[] = {
3188 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3189 .name = "Channel Mode",
3190 .info = alc_ch_mode_info,
3191 .get = alc_ch_mode_get,
3192 .put = alc_ch_mode_put,
3194 { } /* end */
3197 static struct hda_verb alc882_init_verbs[] = {
3198 /* Front mixer: unmute input/output amp left and right (volume = 0) */
3199 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3200 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3201 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3202 /* Rear mixer */
3203 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3204 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3205 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3206 /* CLFE mixer */
3207 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3208 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3209 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3210 /* Side mixer */
3211 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3212 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3213 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3215 /* Front Pin: output 0 (0x0c) */
3216 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3217 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3218 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
3219 /* Rear Pin: output 1 (0x0d) */
3220 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3221 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3222 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
3223 /* CLFE Pin: output 2 (0x0e) */
3224 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3225 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3226 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
3227 /* Side Pin: output 3 (0x0f) */
3228 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3229 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3230 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
3231 /* Mic (rear) pin: input vref at 80% */
3232 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3233 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3234 /* Front Mic pin: input vref at 80% */
3235 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3236 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3237 /* Line In pin: input */
3238 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3239 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3240 /* Line-2 In: Headphone output (output 0 - 0x0c) */
3241 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3242 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3243 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3244 /* CD pin widget for input */
3245 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3247 /* FIXME: use matrix-type input source selection */
3248 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
3249 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
3250 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3251 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3252 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3253 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3254 /* Input mixer2 */
3255 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3256 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3257 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3258 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3259 /* Input mixer3 */
3260 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3261 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3262 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3263 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3264 /* ADC1: mute amp left and right */
3265 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3266 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
3267 /* ADC2: mute amp left and right */
3268 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3269 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
3270 /* ADC3: mute amp left and right */
3271 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3272 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
3278 * generic initialization of ADC, input mixers and output mixers
3280 static struct hda_verb alc882_auto_init_verbs[] = {
3282 * Unmute ADC0-2 and set the default input to mic-in
3284 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
3285 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3286 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
3287 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3288 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
3289 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3291 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3292 * mixer widget
3293 * Note: PASD motherboards uses the Line In 2 as the input for front panel
3294 * mic (mic 2)
3296 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
3297 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3298 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3299 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3300 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
3301 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3304 * Set up output mixers (0x0c - 0x0f)
3306 /* set vol=0 to output mixers */
3307 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3308 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3309 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3310 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3311 /* set up input amps for analog loopback */
3312 /* Amp Indices: DAC = 0, mixer = 1 */
3313 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3314 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3315 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3316 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3317 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3318 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3319 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3320 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3321 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3322 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3324 /* FIXME: use matrix-type input source selection */
3325 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
3326 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
3327 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3328 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3329 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3330 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3331 /* Input mixer2 */
3332 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3333 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3334 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3335 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3336 /* Input mixer3 */
3337 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3338 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3339 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3340 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3345 /* capture mixer elements */
3346 static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
3347 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
3348 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
3349 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
3350 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
3352 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3353 /* The multiple "Capture Source" controls confuse alsamixer
3354 * So call somewhat different..
3355 * FIXME: the controls appear in the "playback" view!
3357 /* .name = "Capture Source", */
3358 .name = "Input Source",
3359 .count = 2,
3360 .info = alc882_mux_enum_info,
3361 .get = alc882_mux_enum_get,
3362 .put = alc882_mux_enum_put,
3364 { } /* end */
3367 static struct snd_kcontrol_new alc882_capture_mixer[] = {
3368 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
3369 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
3370 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
3371 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
3372 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
3373 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
3375 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3376 /* The multiple "Capture Source" controls confuse alsamixer
3377 * So call somewhat different..
3378 * FIXME: the controls appear in the "playback" view!
3380 /* .name = "Capture Source", */
3381 .name = "Input Source",
3382 .count = 3,
3383 .info = alc882_mux_enum_info,
3384 .get = alc882_mux_enum_get,
3385 .put = alc882_mux_enum_put,
3387 { } /* end */
3390 /* pcm configuration: identiacal with ALC880 */
3391 #define alc882_pcm_analog_playback alc880_pcm_analog_playback
3392 #define alc882_pcm_analog_capture alc880_pcm_analog_capture
3393 #define alc882_pcm_digital_playback alc880_pcm_digital_playback
3394 #define alc882_pcm_digital_capture alc880_pcm_digital_capture
3397 * configuration and preset
3399 static struct hda_board_config alc882_cfg_tbl[] = {
3400 { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
3401 { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
3402 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* MSI */
3403 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* Foxconn */
3404 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* ECS */
3405 { .modelname = "auto", .config = ALC861_AUTO },
3409 static struct alc_config_preset alc882_presets[] = {
3410 [ALC882_3ST_DIG] = {
3411 .mixers = { alc882_base_mixer },
3412 .init_verbs = { alc882_init_verbs },
3413 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
3414 .dac_nids = alc882_dac_nids,
3415 .dig_out_nid = ALC882_DIGOUT_NID,
3416 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
3417 .adc_nids = alc882_adc_nids,
3418 .dig_in_nid = ALC882_DIGIN_NID,
3419 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
3420 .channel_mode = alc882_ch_modes,
3421 .input_mux = &alc882_capture_source,
3423 [ALC882_6ST_DIG] = {
3424 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
3425 .init_verbs = { alc882_init_verbs },
3426 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
3427 .dac_nids = alc882_dac_nids,
3428 .dig_out_nid = ALC882_DIGOUT_NID,
3429 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
3430 .adc_nids = alc882_adc_nids,
3431 .dig_in_nid = ALC882_DIGIN_NID,
3432 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
3433 .channel_mode = alc882_sixstack_modes,
3434 .input_mux = &alc882_capture_source,
3440 * BIOS auto configuration
3442 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
3443 hda_nid_t nid, int pin_type,
3444 int dac_idx)
3446 /* set as output */
3447 struct alc_spec *spec = codec->spec;
3448 int idx;
3450 if (spec->multiout.dac_nids[dac_idx] == 0x25)
3451 idx = 4;
3452 else
3453 idx = spec->multiout.dac_nids[dac_idx] - 2;
3455 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
3456 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
3457 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
3461 static void alc882_auto_init_multi_out(struct hda_codec *codec)
3463 struct alc_spec *spec = codec->spec;
3464 int i;
3466 for (i = 0; i <= HDA_SIDE; i++) {
3467 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3468 if (nid)
3469 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
3473 static void alc882_auto_init_hp_out(struct hda_codec *codec)
3475 struct alc_spec *spec = codec->spec;
3476 hda_nid_t pin;
3478 pin = spec->autocfg.hp_pin;
3479 if (pin) /* connect to front */
3480 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
3483 #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
3484 #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
3486 static void alc882_auto_init_analog_input(struct hda_codec *codec)
3488 struct alc_spec *spec = codec->spec;
3489 int i;
3491 for (i = 0; i < AUTO_PIN_LAST; i++) {
3492 hda_nid_t nid = spec->autocfg.input_pins[i];
3493 if (alc882_is_input_pin(nid)) {
3494 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3495 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
3496 if (nid != ALC882_PIN_CD_NID)
3497 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3498 AMP_OUT_MUTE);
3503 /* almost identical with ALC880 parser... */
3504 static int alc882_parse_auto_config(struct hda_codec *codec)
3506 struct alc_spec *spec = codec->spec;
3507 int err = alc880_parse_auto_config(codec);
3509 if (err < 0)
3510 return err;
3511 /* hack - override the init verbs */
3512 spec->init_verbs[0] = alc882_auto_init_verbs;
3513 return 0;
3516 /* init callback for auto-configuration model -- overriding the default init */
3517 static int alc882_auto_init(struct hda_codec *codec)
3519 alc_init(codec);
3520 alc882_auto_init_multi_out(codec);
3521 alc882_auto_init_hp_out(codec);
3522 alc882_auto_init_analog_input(codec);
3523 return 0;
3527 * ALC882 Headphone poll in 3.5.1a or 3.5.2
3530 static int patch_alc882(struct hda_codec *codec)
3532 struct alc_spec *spec;
3533 int err, board_config;
3535 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3536 if (spec == NULL)
3537 return -ENOMEM;
3539 codec->spec = spec;
3541 board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
3543 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
3544 printk(KERN_INFO "hda_codec: Unknown model for ALC882, trying auto-probe from BIOS...\n");
3545 board_config = ALC882_AUTO;
3548 if (board_config == ALC882_AUTO) {
3549 /* automatic parse from the BIOS config */
3550 err = alc882_parse_auto_config(codec);
3551 if (err < 0) {
3552 alc_free(codec);
3553 return err;
3554 } else if (! err) {
3555 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
3556 board_config = ALC882_3ST_DIG;
3560 if (board_config != ALC882_AUTO)
3561 setup_preset(spec, &alc882_presets[board_config]);
3563 spec->stream_name_analog = "ALC882 Analog";
3564 spec->stream_analog_playback = &alc882_pcm_analog_playback;
3565 spec->stream_analog_capture = &alc882_pcm_analog_capture;
3567 spec->stream_name_digital = "ALC882 Digital";
3568 spec->stream_digital_playback = &alc882_pcm_digital_playback;
3569 spec->stream_digital_capture = &alc882_pcm_digital_capture;
3571 if (! spec->adc_nids && spec->input_mux) {
3572 /* check whether NID 0x07 is valid */
3573 unsigned int wcap = snd_hda_param_read(codec, 0x07,
3574 AC_PAR_AUDIO_WIDGET_CAP);
3575 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
3576 if (wcap != AC_WID_AUD_IN) {
3577 spec->adc_nids = alc882_adc_nids_alt;
3578 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
3579 spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
3580 spec->num_mixers++;
3581 } else {
3582 spec->adc_nids = alc882_adc_nids;
3583 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
3584 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
3585 spec->num_mixers++;
3589 codec->patch_ops = alc_patch_ops;
3590 if (board_config == ALC882_AUTO)
3591 codec->patch_ops.init = alc882_auto_init;
3593 return 0;
3597 * ALC262 support
3600 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
3601 #define ALC262_DIGIN_NID ALC880_DIGIN_NID
3603 #define alc262_dac_nids alc260_dac_nids
3604 #define alc262_adc_nids alc882_adc_nids
3605 #define alc262_adc_nids_alt alc882_adc_nids_alt
3607 #define alc262_modes alc260_modes
3609 static struct snd_kcontrol_new alc262_base_mixer[] = {
3610 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3611 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
3612 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
3613 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
3614 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3615 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
3616 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3617 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3618 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3619 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
3620 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
3621 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
3622 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
3623 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3624 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3625 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
3626 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
3627 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
3629 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3630 .name = "Capture Source",
3631 .count = 1,
3632 .info = alc882_mux_enum_info,
3633 .get = alc882_mux_enum_get,
3634 .put = alc882_mux_enum_put,
3636 { } /* end */
3639 #define alc262_capture_mixer alc882_capture_mixer
3640 #define alc262_capture_alt_mixer alc882_capture_alt_mixer
3643 * generic initialization of ADC, input mixers and output mixers
3645 static struct hda_verb alc262_init_verbs[] = {
3647 * Unmute ADC0-2 and set the default input to mic-in
3649 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
3650 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3651 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
3652 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3653 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
3654 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3656 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3657 * mixer widget
3658 * Note: PASD motherboards uses the Line In 2 as the input for front panel
3659 * mic (mic 2)
3661 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
3662 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3663 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3664 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3665 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
3666 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3669 * Set up output mixers (0x0c - 0x0e)
3671 /* set vol=0 to output mixers */
3672 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3673 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3674 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3675 /* set up input amps for analog loopback */
3676 /* Amp Indices: DAC = 0, mixer = 1 */
3677 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3678 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3679 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3680 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3681 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3682 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3684 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3685 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3686 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3687 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3688 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3689 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3691 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3692 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3693 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3694 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3695 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3697 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
3698 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
3700 /* FIXME: use matrix-type input source selection */
3701 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
3702 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
3703 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3704 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3705 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3706 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3707 /* Input mixer2 */
3708 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3709 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3710 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3711 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3712 /* Input mixer3 */
3713 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3714 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3715 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3716 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3721 /* add playback controls from the parsed DAC table */
3722 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
3724 hda_nid_t nid;
3725 int err;
3727 spec->multiout.num_dacs = 1; /* only use one dac */
3728 spec->multiout.dac_nids = spec->private_dac_nids;
3729 spec->multiout.dac_nids[0] = 2;
3731 nid = cfg->line_out_pins[0];
3732 if (nid) {
3733 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
3734 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
3735 return err;
3736 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
3737 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
3738 return err;
3741 nid = cfg->speaker_pin;
3742 if (nid) {
3743 if (nid == 0x16) {
3744 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
3745 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
3746 return err;
3747 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
3748 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
3749 return err;
3750 } else {
3751 if (! cfg->line_out_pins[0])
3752 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
3753 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
3754 return err;
3755 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
3756 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
3757 return err;
3760 nid = cfg->hp_pin;
3761 if (nid) {
3762 /* spec->multiout.hp_nid = 2; */
3763 if (nid == 0x16) {
3764 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
3765 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
3766 return err;
3767 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
3768 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
3769 return err;
3770 } else {
3771 if (! cfg->line_out_pins[0])
3772 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
3773 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
3774 return err;
3775 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
3776 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
3777 return err;
3780 return 0;
3783 /* identical with ALC880 */
3784 #define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
3787 * generic initialization of ADC, input mixers and output mixers
3789 static struct hda_verb alc262_volume_init_verbs[] = {
3791 * Unmute ADC0-2 and set the default input to mic-in
3793 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
3794 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3795 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
3796 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3797 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
3798 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3800 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3801 * mixer widget
3802 * Note: PASD motherboards uses the Line In 2 as the input for front panel
3803 * mic (mic 2)
3805 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
3806 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3807 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3808 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3809 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
3810 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3813 * Set up output mixers (0x0c - 0x0f)
3815 /* set vol=0 to output mixers */
3816 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3817 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3818 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3820 /* set up input amps for analog loopback */
3821 /* Amp Indices: DAC = 0, mixer = 1 */
3822 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3823 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3824 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3825 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3826 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3827 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3829 /* FIXME: use matrix-type input source selection */
3830 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
3831 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
3832 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3833 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3834 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3835 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3836 /* Input mixer2 */
3837 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3838 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3839 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3840 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3841 /* Input mixer3 */
3842 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3843 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3844 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3845 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3850 /* pcm configuration: identiacal with ALC880 */
3851 #define alc262_pcm_analog_playback alc880_pcm_analog_playback
3852 #define alc262_pcm_analog_capture alc880_pcm_analog_capture
3853 #define alc262_pcm_digital_playback alc880_pcm_digital_playback
3854 #define alc262_pcm_digital_capture alc880_pcm_digital_capture
3857 * BIOS auto configuration
3859 static int alc262_parse_auto_config(struct hda_codec *codec)
3861 struct alc_spec *spec = codec->spec;
3862 int err;
3863 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
3865 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3866 alc262_ignore)) < 0)
3867 return err;
3868 if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
3869 ! spec->autocfg.hp_pin)
3870 return 0; /* can't find valid BIOS pin config */
3871 if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
3872 (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
3873 return err;
3875 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3877 if (spec->autocfg.dig_out_pin)
3878 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
3879 if (spec->autocfg.dig_in_pin)
3880 spec->dig_in_nid = ALC262_DIGIN_NID;
3882 if (spec->kctl_alloc)
3883 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3885 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
3886 spec->input_mux = &spec->private_imux;
3888 return 1;
3891 #define alc262_auto_init_multi_out alc882_auto_init_multi_out
3892 #define alc262_auto_init_hp_out alc882_auto_init_hp_out
3893 #define alc262_auto_init_analog_input alc882_auto_init_analog_input
3896 /* init callback for auto-configuration model -- overriding the default init */
3897 static int alc262_auto_init(struct hda_codec *codec)
3899 alc_init(codec);
3900 alc262_auto_init_multi_out(codec);
3901 alc262_auto_init_hp_out(codec);
3902 alc262_auto_init_analog_input(codec);
3903 return 0;
3907 * configuration and preset
3909 static struct hda_board_config alc262_cfg_tbl[] = {
3910 { .modelname = "basic", .config = ALC262_BASIC },
3911 { .modelname = "auto", .config = ALC262_AUTO },
3915 static struct alc_config_preset alc262_presets[] = {
3916 [ALC262_BASIC] = {
3917 .mixers = { alc262_base_mixer },
3918 .init_verbs = { alc262_init_verbs },
3919 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
3920 .dac_nids = alc262_dac_nids,
3921 .hp_nid = 0x03,
3922 .num_channel_mode = ARRAY_SIZE(alc262_modes),
3923 .channel_mode = alc262_modes,
3927 static int patch_alc262(struct hda_codec *codec)
3929 struct alc_spec *spec;
3930 int board_config;
3931 int err;
3933 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
3934 if (spec == NULL)
3935 return -ENOMEM;
3937 codec->spec = spec;
3938 #if 0
3939 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
3941 int tmp;
3942 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
3943 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
3944 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
3945 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
3947 #endif
3949 board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
3950 if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
3951 printk(KERN_INFO "hda_codec: Unknown model for ALC262, trying auto-probe from BIOS...\n");
3952 board_config = ALC262_AUTO;
3955 if (board_config == ALC262_AUTO) {
3956 /* automatic parse from the BIOS config */
3957 err = alc262_parse_auto_config(codec);
3958 if (err < 0) {
3959 alc_free(codec);
3960 return err;
3961 } else if (! err) {
3962 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
3963 board_config = ALC262_BASIC;
3967 if (board_config != ALC262_AUTO)
3968 setup_preset(spec, &alc262_presets[board_config]);
3970 spec->stream_name_analog = "ALC262 Analog";
3971 spec->stream_analog_playback = &alc262_pcm_analog_playback;
3972 spec->stream_analog_capture = &alc262_pcm_analog_capture;
3974 spec->stream_name_digital = "ALC262 Digital";
3975 spec->stream_digital_playback = &alc262_pcm_digital_playback;
3976 spec->stream_digital_capture = &alc262_pcm_digital_capture;
3978 if (! spec->adc_nids && spec->input_mux) {
3979 /* check whether NID 0x07 is valid */
3980 unsigned int wcap = snd_hda_param_read(codec, 0x07,
3981 AC_PAR_AUDIO_WIDGET_CAP);
3982 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
3983 if (wcap != AC_WID_AUD_IN) {
3984 spec->adc_nids = alc262_adc_nids_alt;
3985 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
3986 spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
3987 spec->num_mixers++;
3988 } else {
3989 spec->adc_nids = alc262_adc_nids;
3990 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
3991 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
3992 spec->num_mixers++;
3996 codec->patch_ops = alc_patch_ops;
3997 if (board_config == ALC262_AUTO)
3998 codec->patch_ops.init = alc262_auto_init;
4000 return 0;
4005 * ALC861 channel source setting (2/6 channel selection for 3-stack)
4009 * set the path ways for 2 channel output
4010 * need to set the codec line out and mic 1 pin widgets to inputs
4012 static struct hda_verb alc861_threestack_ch2_init[] = {
4013 /* set pin widget 1Ah (line in) for input */
4014 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
4015 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
4016 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
4018 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
4019 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, //mic
4020 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, //line in
4021 { } /* end */
4024 * 6ch mode
4025 * need to set the codec line out and mic 1 pin widgets to outputs
4027 static struct hda_verb alc861_threestack_ch6_init[] = {
4028 /* set pin widget 1Ah (line in) for output (Back Surround)*/
4029 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4030 /* set pin widget 18h (mic1) for output (CLFE)*/
4031 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4033 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
4034 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
4036 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
4037 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, //mic
4038 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, //line in
4039 { } /* end */
4042 static struct hda_channel_mode alc861_threestack_modes[2] = {
4043 { 2, alc861_threestack_ch2_init },
4044 { 6, alc861_threestack_ch6_init },
4047 /* patch-ALC861 */
4049 static struct snd_kcontrol_new alc861_base_mixer[] = {
4050 /* output mixer control */
4051 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
4052 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
4053 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
4054 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
4055 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
4057 /*Input mixer control */
4058 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
4059 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
4060 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
4061 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
4062 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
4063 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
4064 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
4065 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
4066 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
4067 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
4069 /* Capture mixer control */
4070 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4071 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4073 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4074 .name = "Capture Source",
4075 .count = 1,
4076 .info = alc_mux_enum_info,
4077 .get = alc_mux_enum_get,
4078 .put = alc_mux_enum_put,
4080 { } /* end */
4083 static struct snd_kcontrol_new alc861_3ST_mixer[] = {
4084 /* output mixer control */
4085 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
4086 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
4087 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
4088 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
4089 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
4091 /* Input mixer control */
4092 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
4093 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
4094 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
4095 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
4096 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
4097 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
4098 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
4099 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
4100 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
4101 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
4103 /* Capture mixer control */
4104 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4105 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4107 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4108 .name = "Capture Source",
4109 .count = 1,
4110 .info = alc_mux_enum_info,
4111 .get = alc_mux_enum_get,
4112 .put = alc_mux_enum_put,
4115 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4116 .name = "Channel Mode",
4117 .info = alc_ch_mode_info,
4118 .get = alc_ch_mode_get,
4119 .put = alc_ch_mode_put,
4120 .private_value = ARRAY_SIZE(alc861_threestack_modes),
4122 { } /* end */
4126 * generic initialization of ADC, input mixers and output mixers
4128 static struct hda_verb alc861_base_init_verbs[] = {
4130 * Unmute ADC0 and set the default input to mic-in
4132 /* port-A for surround (rear panel) */
4133 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4134 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
4135 /* port-B for mic-in (rear panel) with vref */
4136 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
4137 /* port-C for line-in (rear panel) */
4138 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
4139 /* port-D for Front */
4140 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4141 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
4142 /* port-E for HP out (front panel) */
4143 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
4144 /* route front PCM to HP */
4145 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
4146 /* port-F for mic-in (front panel) with vref */
4147 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
4148 /* port-G for CLFE (rear panel) */
4149 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4150 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
4151 /* port-H for side (rear panel) */
4152 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4153 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
4154 /* CD-in */
4155 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
4156 /* route front mic to ADC1*/
4157 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4158 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4160 /* Unmute DAC0~3 & spdif out*/
4161 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4162 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4163 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4164 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4165 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4167 /* Unmute Mixer 14 (mic) 1c (Line in)*/
4168 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4169 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4170 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4171 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4173 /* Unmute Stereo Mixer 15 */
4174 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4175 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4176 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4177 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
4179 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4180 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4181 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4182 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4183 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4184 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4185 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4186 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4187 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
4188 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4193 static struct hda_verb alc861_threestack_init_verbs[] = {
4195 * Unmute ADC0 and set the default input to mic-in
4197 /* port-A for surround (rear panel) */
4198 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4199 /* port-B for mic-in (rear panel) with vref */
4200 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
4201 /* port-C for line-in (rear panel) */
4202 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
4203 /* port-D for Front */
4204 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4205 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
4206 /* port-E for HP out (front panel) */
4207 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
4208 /* route front PCM to HP */
4209 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
4210 /* port-F for mic-in (front panel) with vref */
4211 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
4212 /* port-G for CLFE (rear panel) */
4213 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4214 /* port-H for side (rear panel) */
4215 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4216 /* CD-in */
4217 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
4218 /* route front mic to ADC1*/
4219 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4220 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4221 /* Unmute DAC0~3 & spdif out*/
4222 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4223 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4224 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4225 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4226 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4228 /* Unmute Mixer 14 (mic) 1c (Line in)*/
4229 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4230 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4231 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4232 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4234 /* Unmute Stereo Mixer 15 */
4235 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4236 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4237 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4238 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
4240 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4241 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4242 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4243 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4244 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4245 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4246 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4247 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4248 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
4249 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4253 * generic initialization of ADC, input mixers and output mixers
4255 static struct hda_verb alc861_auto_init_verbs[] = {
4257 * Unmute ADC0 and set the default input to mic-in
4259 // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4260 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4262 /* Unmute DAC0~3 & spdif out*/
4263 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4264 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4265 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4266 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4267 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4269 /* Unmute Mixer 14 (mic) 1c (Line in)*/
4270 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4271 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4272 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4273 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4275 /* Unmute Stereo Mixer 15 */
4276 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4277 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4278 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4279 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
4281 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4282 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4283 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4284 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4285 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4286 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4287 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4288 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4290 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4291 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4292 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4293 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4294 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4295 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4296 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4297 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4299 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
4304 /* pcm configuration: identiacal with ALC880 */
4305 #define alc861_pcm_analog_playback alc880_pcm_analog_playback
4306 #define alc861_pcm_analog_capture alc880_pcm_analog_capture
4307 #define alc861_pcm_digital_playback alc880_pcm_digital_playback
4308 #define alc861_pcm_digital_capture alc880_pcm_digital_capture
4311 #define ALC861_DIGOUT_NID 0x07
4313 static struct hda_channel_mode alc861_8ch_modes[1] = {
4314 { 8, NULL }
4317 static hda_nid_t alc861_dac_nids[4] = {
4318 /* front, surround, clfe, side */
4319 0x03, 0x06, 0x05, 0x04
4322 static hda_nid_t alc861_adc_nids[1] = {
4323 /* ADC0-2 */
4324 0x08,
4327 static struct hda_input_mux alc861_capture_source = {
4328 .num_items = 5,
4329 .items = {
4330 { "Mic", 0x0 },
4331 { "Front Mic", 0x3 },
4332 { "Line", 0x1 },
4333 { "CD", 0x4 },
4334 { "Mixer", 0x5 },
4338 /* fill in the dac_nids table from the parsed pin configuration */
4339 static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
4341 int i;
4342 hda_nid_t nid;
4344 spec->multiout.dac_nids = spec->private_dac_nids;
4345 for (i = 0; i < cfg->line_outs; i++) {
4346 nid = cfg->line_out_pins[i];
4347 if (nid) {
4348 if (i >= ARRAY_SIZE(alc861_dac_nids))
4349 continue;
4350 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
4353 spec->multiout.num_dacs = cfg->line_outs;
4354 return 0;
4357 /* add playback controls from the parsed DAC table */
4358 static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
4359 const struct auto_pin_cfg *cfg)
4361 char name[32];
4362 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
4363 hda_nid_t nid;
4364 int i, idx, err;
4366 for (i = 0; i < cfg->line_outs; i++) {
4367 nid = spec->multiout.dac_nids[i];
4368 if (! nid)
4369 continue;
4370 if (nid == 0x05) {
4371 /* Center/LFE */
4372 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
4373 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
4374 return err;
4375 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
4376 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
4377 return err;
4378 } else {
4379 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
4380 if (nid == alc861_dac_nids[idx])
4381 break;
4382 sprintf(name, "%s Playback Switch", chname[idx]);
4383 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4384 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
4385 return err;
4388 return 0;
4391 static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
4393 int err;
4394 hda_nid_t nid;
4396 if (! pin)
4397 return 0;
4399 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
4400 nid = 0x03;
4401 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
4402 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
4403 return err;
4404 spec->multiout.hp_nid = nid;
4406 return 0;
4409 /* create playback/capture controls for input pins */
4410 static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
4412 static char *labels[AUTO_PIN_LAST] = {
4413 "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux"
4415 struct hda_input_mux *imux = &spec->private_imux;
4416 int i, err, idx, idx1;
4418 for (i = 0; i < AUTO_PIN_LAST; i++) {
4419 switch(cfg->input_pins[i]) {
4420 case 0x0c:
4421 idx1 = 1;
4422 idx = 2; // Line In
4423 break;
4424 case 0x0f:
4425 idx1 = 2;
4426 idx = 2; // Line In
4427 break;
4428 case 0x0d:
4429 idx1 = 0;
4430 idx = 1; // Mic In
4431 break;
4432 case 0x10:
4433 idx1 = 3;
4434 idx = 1; // Mic In
4435 break;
4436 case 0x11:
4437 idx1 = 4;
4438 idx = 0; // CD
4439 break;
4440 default:
4441 continue;
4444 err = new_analog_input(spec, cfg->input_pins[i], labels[i], idx, 0x15);
4445 if (err < 0)
4446 return err;
4448 imux->items[imux->num_items].label = labels[i];
4449 imux->items[imux->num_items].index = idx1;
4450 imux->num_items++;
4452 return 0;
4455 static struct snd_kcontrol_new alc861_capture_mixer[] = {
4456 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4457 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4460 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4461 /* The multiple "Capture Source" controls confuse alsamixer
4462 * So call somewhat different..
4463 *FIXME: the controls appear in the "playback" view!
4465 /* .name = "Capture Source", */
4466 .name = "Input Source",
4467 .count = 1,
4468 .info = alc_mux_enum_info,
4469 .get = alc_mux_enum_get,
4470 .put = alc_mux_enum_put,
4472 { } /* end */
4475 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
4476 int pin_type, int dac_idx)
4478 /* set as output */
4480 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
4481 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4485 static void alc861_auto_init_multi_out(struct hda_codec *codec)
4487 struct alc_spec *spec = codec->spec;
4488 int i;
4490 for (i = 0; i < spec->autocfg.line_outs; i++) {
4491 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4492 if (nid)
4493 alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
4497 static void alc861_auto_init_hp_out(struct hda_codec *codec)
4499 struct alc_spec *spec = codec->spec;
4500 hda_nid_t pin;
4502 pin = spec->autocfg.hp_pin;
4503 if (pin) /* connect to front */
4504 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
4507 static void alc861_auto_init_analog_input(struct hda_codec *codec)
4509 struct alc_spec *spec = codec->spec;
4510 int i;
4512 for (i = 0; i < AUTO_PIN_LAST; i++) {
4513 hda_nid_t nid = spec->autocfg.input_pins[i];
4514 if ((nid>=0x0c) && (nid <=0x11)) {
4515 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4516 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
4521 /* parse the BIOS configuration and set up the alc_spec */
4522 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
4523 static int alc861_parse_auto_config(struct hda_codec *codec)
4525 struct alc_spec *spec = codec->spec;
4526 int err;
4527 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
4529 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4530 alc861_ignore)) < 0)
4531 return err;
4532 if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
4533 ! spec->autocfg.hp_pin)
4534 return 0; /* can't find valid BIOS pin config */
4536 if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
4537 (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
4538 (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 ||
4539 (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
4540 return err;
4542 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4544 if (spec->autocfg.dig_out_pin)
4545 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
4547 if (spec->kctl_alloc)
4548 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4550 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
4552 spec->input_mux = &spec->private_imux;
4554 spec->adc_nids = alc861_adc_nids;
4555 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
4556 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
4557 spec->num_mixers++;
4559 return 1;
4562 /* init callback for auto-configuration model -- overriding the default init */
4563 static int alc861_auto_init(struct hda_codec *codec)
4565 alc_init(codec);
4566 alc861_auto_init_multi_out(codec);
4567 alc861_auto_init_hp_out(codec);
4568 alc861_auto_init_analog_input(codec);
4570 return 0;
4575 * configuration and preset
4577 static struct hda_board_config alc861_cfg_tbl[] = {
4578 { .modelname = "3stack", .config = ALC861_3ST },
4579 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600, .config = ALC861_3ST },
4580 { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
4581 { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
4582 { .modelname = "auto", .config = ALC861_AUTO },
4586 static struct alc_config_preset alc861_presets[] = {
4587 [ALC861_3ST] = {
4588 .mixers = { alc861_3ST_mixer },
4589 .init_verbs = { alc861_threestack_init_verbs },
4590 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
4591 .dac_nids = alc861_dac_nids,
4592 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
4593 .channel_mode = alc861_threestack_modes,
4594 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
4595 .adc_nids = alc861_adc_nids,
4596 .input_mux = &alc861_capture_source,
4598 [ALC861_3ST_DIG] = {
4599 .mixers = { alc861_base_mixer },
4600 .init_verbs = { alc861_threestack_init_verbs },
4601 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
4602 .dac_nids = alc861_dac_nids,
4603 .dig_out_nid = ALC861_DIGOUT_NID,
4604 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
4605 .channel_mode = alc861_threestack_modes,
4606 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
4607 .adc_nids = alc861_adc_nids,
4608 .input_mux = &alc861_capture_source,
4610 [ALC861_6ST_DIG] = {
4611 .mixers = { alc861_base_mixer },
4612 .init_verbs = { alc861_base_init_verbs },
4613 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
4614 .dac_nids = alc861_dac_nids,
4615 .dig_out_nid = ALC861_DIGOUT_NID,
4616 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
4617 .channel_mode = alc861_8ch_modes,
4618 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
4619 .adc_nids = alc861_adc_nids,
4620 .input_mux = &alc861_capture_source,
4625 static int patch_alc861(struct hda_codec *codec)
4627 struct alc_spec *spec;
4628 int board_config;
4629 int err;
4631 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
4632 if (spec == NULL)
4633 return -ENOMEM;
4635 codec->spec = spec;
4637 board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
4638 if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
4639 printk(KERN_INFO "hda_codec: Unknown model for ALC861, trying auto-probe from BIOS...\n");
4640 board_config = ALC861_AUTO;
4643 if (board_config == ALC861_AUTO) {
4644 /* automatic parse from the BIOS config */
4645 err = alc861_parse_auto_config(codec);
4646 if (err < 0) {
4647 alc_free(codec);
4648 return err;
4649 } else if (! err) {
4650 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
4651 board_config = ALC861_3ST_DIG;
4655 if (board_config != ALC861_AUTO)
4656 setup_preset(spec, &alc861_presets[board_config]);
4658 spec->stream_name_analog = "ALC861 Analog";
4659 spec->stream_analog_playback = &alc861_pcm_analog_playback;
4660 spec->stream_analog_capture = &alc861_pcm_analog_capture;
4662 spec->stream_name_digital = "ALC861 Digital";
4663 spec->stream_digital_playback = &alc861_pcm_digital_playback;
4664 spec->stream_digital_capture = &alc861_pcm_digital_capture;
4666 codec->patch_ops = alc_patch_ops;
4667 if (board_config == ALC861_AUTO)
4668 codec->patch_ops.init = alc861_auto_init;
4670 return 0;
4674 * patch entries
4676 struct hda_codec_preset snd_hda_preset_realtek[] = {
4677 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
4678 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
4679 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
4680 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
4681 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
4682 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
4683 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
4684 {} /* terminator */