2 * HD audio interface patch for AD1882, AD1884, AD1981HD, AD1983, AD1984,
5 * Copyright (c) 2005-2007 Takashi Iwai <tiwai@suse.de>
7 * This driver is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This driver is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <sound/driver.h>
23 #include <linux/init.h>
24 #include <linux/delay.h>
25 #include <linux/slab.h>
26 #include <linux/pci.h>
27 #include <linux/mutex.h>
29 #include <sound/core.h>
30 #include "hda_codec.h"
31 #include "hda_local.h"
34 struct snd_kcontrol_new *mixers[5];
37 const struct hda_verb *init_verbs[5]; /* initialization verbs
38 * don't forget NULL termination!
40 unsigned int num_init_verbs;
43 struct hda_multi_out multiout; /* playback set-up
44 * max_channels, dacs must be set
45 * dig_out_nid and hp_nid are optional
47 unsigned int cur_eapd;
48 unsigned int need_dac_fix;
51 unsigned int num_adc_nids;
53 hda_nid_t dig_in_nid; /* digital-in NID; optional */
56 const struct hda_input_mux *input_mux;
57 hda_nid_t *capsrc_nids;
58 unsigned int cur_mux[3];
61 const struct hda_channel_mode *channel_mode;
65 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
67 struct mutex amp_mutex; /* PCM volume/mute control mutex */
68 unsigned int spdif_route;
70 /* dynamic controls, init_verbs and input_mux */
71 struct auto_pin_cfg autocfg;
72 unsigned int num_kctl_alloc, num_kctl_used;
73 struct snd_kcontrol_new *kctl_alloc;
74 struct hda_input_mux private_imux;
75 hda_nid_t private_dac_nids[4];
77 #ifdef CONFIG_SND_HDA_POWER_SAVE
78 struct hda_loopback_check loopback;
83 * input MUX handling (common part)
85 static int ad198x_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
87 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
88 struct ad198x_spec *spec = codec->spec;
90 return snd_hda_input_mux_info(spec->input_mux, uinfo);
93 static int ad198x_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
95 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
96 struct ad198x_spec *spec = codec->spec;
97 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
99 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
103 static int ad198x_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
105 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
106 struct ad198x_spec *spec = codec->spec;
107 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
109 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
110 spec->capsrc_nids[adc_idx],
111 &spec->cur_mux[adc_idx]);
115 * initialization (common callbacks)
117 static int ad198x_init(struct hda_codec *codec)
119 struct ad198x_spec *spec = codec->spec;
122 for (i = 0; i < spec->num_init_verbs; i++)
123 snd_hda_sequence_write(codec, spec->init_verbs[i]);
127 static int ad198x_build_controls(struct hda_codec *codec)
129 struct ad198x_spec *spec = codec->spec;
133 for (i = 0; i < spec->num_mixers; i++) {
134 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
138 if (spec->multiout.dig_out_nid) {
139 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
143 if (spec->dig_in_nid) {
144 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
151 #ifdef CONFIG_SND_HDA_POWER_SAVE
152 static int ad198x_check_power_status(struct hda_codec *codec, hda_nid_t nid)
154 struct ad198x_spec *spec = codec->spec;
155 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
160 * Analog playback callbacks
162 static int ad198x_playback_pcm_open(struct hda_pcm_stream *hinfo,
163 struct hda_codec *codec,
164 struct snd_pcm_substream *substream)
166 struct ad198x_spec *spec = codec->spec;
167 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
170 static int ad198x_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
171 struct hda_codec *codec,
172 unsigned int stream_tag,
174 struct snd_pcm_substream *substream)
176 struct ad198x_spec *spec = codec->spec;
177 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
181 static int ad198x_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
182 struct hda_codec *codec,
183 struct snd_pcm_substream *substream)
185 struct ad198x_spec *spec = codec->spec;
186 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
192 static int ad198x_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
193 struct hda_codec *codec,
194 struct snd_pcm_substream *substream)
196 struct ad198x_spec *spec = codec->spec;
197 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
200 static int ad198x_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
201 struct hda_codec *codec,
202 struct snd_pcm_substream *substream)
204 struct ad198x_spec *spec = codec->spec;
205 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
208 static int ad198x_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
209 struct hda_codec *codec,
210 unsigned int stream_tag,
212 struct snd_pcm_substream *substream)
214 struct ad198x_spec *spec = codec->spec;
215 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag,
222 static int ad198x_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
223 struct hda_codec *codec,
224 unsigned int stream_tag,
226 struct snd_pcm_substream *substream)
228 struct ad198x_spec *spec = codec->spec;
229 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
230 stream_tag, 0, format);
234 static int ad198x_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
235 struct hda_codec *codec,
236 struct snd_pcm_substream *substream)
238 struct ad198x_spec *spec = codec->spec;
239 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
247 static struct hda_pcm_stream ad198x_pcm_analog_playback = {
250 .channels_max = 6, /* changed later */
251 .nid = 0, /* fill later */
253 .open = ad198x_playback_pcm_open,
254 .prepare = ad198x_playback_pcm_prepare,
255 .cleanup = ad198x_playback_pcm_cleanup
259 static struct hda_pcm_stream ad198x_pcm_analog_capture = {
263 .nid = 0, /* fill later */
265 .prepare = ad198x_capture_pcm_prepare,
266 .cleanup = ad198x_capture_pcm_cleanup
270 static struct hda_pcm_stream ad198x_pcm_digital_playback = {
274 .nid = 0, /* fill later */
276 .open = ad198x_dig_playback_pcm_open,
277 .close = ad198x_dig_playback_pcm_close,
278 .prepare = ad198x_dig_playback_pcm_prepare
282 static struct hda_pcm_stream ad198x_pcm_digital_capture = {
286 /* NID is set in alc_build_pcms */
289 static int ad198x_build_pcms(struct hda_codec *codec)
291 struct ad198x_spec *spec = codec->spec;
292 struct hda_pcm *info = spec->pcm_rec;
295 codec->pcm_info = info;
297 info->name = "AD198x Analog";
298 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_analog_playback;
299 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->multiout.max_channels;
300 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
301 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_analog_capture;
302 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adc_nids;
303 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
305 if (spec->multiout.dig_out_nid) {
308 info->name = "AD198x Digital";
309 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_digital_playback;
310 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
311 if (spec->dig_in_nid) {
312 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_digital_capture;
313 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
320 static void ad198x_free(struct hda_codec *codec)
322 struct ad198x_spec *spec = codec->spec;
325 if (spec->kctl_alloc) {
326 for (i = 0; i < spec->num_kctl_used; i++)
327 kfree(spec->kctl_alloc[i].name);
328 kfree(spec->kctl_alloc);
333 static struct hda_codec_ops ad198x_patch_ops = {
334 .build_controls = ad198x_build_controls,
335 .build_pcms = ad198x_build_pcms,
338 #ifdef CONFIG_SND_HDA_POWER_SAVE
339 .check_power_status = ad198x_check_power_status,
346 * the private value = nid | (invert << 8)
348 #define ad198x_eapd_info snd_ctl_boolean_mono_info
350 static int ad198x_eapd_get(struct snd_kcontrol *kcontrol,
351 struct snd_ctl_elem_value *ucontrol)
353 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
354 struct ad198x_spec *spec = codec->spec;
355 int invert = (kcontrol->private_value >> 8) & 1;
357 ucontrol->value.integer.value[0] = ! spec->cur_eapd;
359 ucontrol->value.integer.value[0] = spec->cur_eapd;
363 static int ad198x_eapd_put(struct snd_kcontrol *kcontrol,
364 struct snd_ctl_elem_value *ucontrol)
366 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
367 struct ad198x_spec *spec = codec->spec;
368 int invert = (kcontrol->private_value >> 8) & 1;
369 hda_nid_t nid = kcontrol->private_value & 0xff;
371 eapd = ucontrol->value.integer.value[0];
374 if (eapd == spec->cur_eapd)
376 spec->cur_eapd = eapd;
377 snd_hda_codec_write_cache(codec, nid,
378 0, AC_VERB_SET_EAPD_BTLENABLE,
383 static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol,
384 struct snd_ctl_elem_info *uinfo);
385 static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol,
386 struct snd_ctl_elem_value *ucontrol);
387 static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol,
388 struct snd_ctl_elem_value *ucontrol);
395 #define AD1986A_SPDIF_OUT 0x02
396 #define AD1986A_FRONT_DAC 0x03
397 #define AD1986A_SURR_DAC 0x04
398 #define AD1986A_CLFE_DAC 0x05
399 #define AD1986A_ADC 0x06
401 static hda_nid_t ad1986a_dac_nids[3] = {
402 AD1986A_FRONT_DAC, AD1986A_SURR_DAC, AD1986A_CLFE_DAC
404 static hda_nid_t ad1986a_adc_nids[1] = { AD1986A_ADC };
405 static hda_nid_t ad1986a_capsrc_nids[1] = { 0x12 };
407 static struct hda_input_mux ad1986a_capture_source = {
421 static struct hda_bind_ctls ad1986a_bind_pcm_vol = {
422 .ops = &snd_hda_bind_vol,
424 HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT),
425 HDA_COMPOSE_AMP_VAL(AD1986A_SURR_DAC, 3, 0, HDA_OUTPUT),
426 HDA_COMPOSE_AMP_VAL(AD1986A_CLFE_DAC, 3, 0, HDA_OUTPUT),
431 static struct hda_bind_ctls ad1986a_bind_pcm_sw = {
432 .ops = &snd_hda_bind_sw,
434 HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT),
435 HDA_COMPOSE_AMP_VAL(AD1986A_SURR_DAC, 3, 0, HDA_OUTPUT),
436 HDA_COMPOSE_AMP_VAL(AD1986A_CLFE_DAC, 3, 0, HDA_OUTPUT),
444 static struct snd_kcontrol_new ad1986a_mixers[] = {
446 * bind volumes/mutes of 3 DACs as a single PCM control for simplicity
448 HDA_BIND_VOL("PCM Playback Volume", &ad1986a_bind_pcm_vol),
449 HDA_BIND_SW("PCM Playback Switch", &ad1986a_bind_pcm_sw),
450 HDA_CODEC_VOLUME("Front Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
451 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
452 HDA_CODEC_VOLUME("Surround Playback Volume", 0x1c, 0x0, HDA_OUTPUT),
453 HDA_CODEC_MUTE("Surround Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
454 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x1d, 1, 0x0, HDA_OUTPUT),
455 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x1d, 2, 0x0, HDA_OUTPUT),
456 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x1d, 1, 0x0, HDA_OUTPUT),
457 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x1d, 2, 0x0, HDA_OUTPUT),
458 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT),
459 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
460 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT),
461 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT),
462 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT),
463 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT),
464 HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT),
465 HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT),
466 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
467 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
468 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
469 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT),
470 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT),
471 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
472 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT),
473 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
474 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
476 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
477 .name = "Capture Source",
478 .info = ad198x_mux_enum_info,
479 .get = ad198x_mux_enum_get,
480 .put = ad198x_mux_enum_put,
482 HDA_CODEC_MUTE("Stereo Downmix Switch", 0x09, 0x0, HDA_OUTPUT),
486 /* additional mixers for 3stack mode */
487 static struct snd_kcontrol_new ad1986a_3st_mixers[] = {
489 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
490 .name = "Channel Mode",
491 .info = ad198x_ch_mode_info,
492 .get = ad198x_ch_mode_get,
493 .put = ad198x_ch_mode_put,
498 /* laptop model - 2ch only */
499 static hda_nid_t ad1986a_laptop_dac_nids[1] = { AD1986A_FRONT_DAC };
501 /* master controls both pins 0x1a and 0x1b */
502 static struct hda_bind_ctls ad1986a_laptop_master_vol = {
503 .ops = &snd_hda_bind_vol,
505 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT),
506 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
511 static struct hda_bind_ctls ad1986a_laptop_master_sw = {
512 .ops = &snd_hda_bind_sw,
514 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT),
515 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
520 static struct snd_kcontrol_new ad1986a_laptop_mixers[] = {
521 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
522 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
523 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol),
524 HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw),
525 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT),
526 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT),
527 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT),
528 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT),
529 HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT),
530 HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT),
531 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
532 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
533 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
534 /* HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT),
535 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT),
536 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
537 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), */
538 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
539 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
541 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
542 .name = "Capture Source",
543 .info = ad198x_mux_enum_info,
544 .get = ad198x_mux_enum_get,
545 .put = ad198x_mux_enum_put,
550 /* laptop-eapd model - 2ch only */
552 static struct hda_input_mux ad1986a_laptop_eapd_capture_source = {
556 { "Internal Mic", 0x4 },
561 static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = {
562 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol),
563 HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw),
564 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
565 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
566 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x0, HDA_OUTPUT),
567 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x0, HDA_OUTPUT),
568 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
569 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
570 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
571 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
572 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
574 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
575 .name = "Capture Source",
576 .info = ad198x_mux_enum_info,
577 .get = ad198x_mux_enum_get,
578 .put = ad198x_mux_enum_put,
581 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
582 .name = "External Amplifier",
583 .info = ad198x_eapd_info,
584 .get = ad198x_eapd_get,
585 .put = ad198x_eapd_put,
586 .private_value = 0x1b | (1 << 8), /* port-D, inversed */
592 * initialization verbs
594 static struct hda_verb ad1986a_init_verbs[] = {
595 /* Front, Surround, CLFE DAC; mute as default */
596 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
597 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
598 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
600 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
601 /* HP, Line-Out, Surround, CLFE selectors */
602 {0x0a, AC_VERB_SET_CONNECT_SEL, 0x0},
603 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x0},
604 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0},
605 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
607 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x0},
608 /* Mic selector: Mic 1/2 pin */
609 {0x0f, AC_VERB_SET_CONNECT_SEL, 0x0},
610 /* Line-in selector: Line-in */
611 {0x10, AC_VERB_SET_CONNECT_SEL, 0x0},
613 {0x11, AC_VERB_SET_CONNECT_SEL, 0x0},
614 /* Record selector: mic */
615 {0x12, AC_VERB_SET_CONNECT_SEL, 0x0},
616 /* Mic, Phone, CD, Aux, Line-In amp; mute as default */
617 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
618 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
619 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
620 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
621 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
623 {0x18, AC_VERB_SET_CONNECT_SEL, 0x0},
624 /* HP, Line-Out, Surround, CLFE, Mono pins; mute as default */
625 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
626 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
627 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
628 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
629 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
631 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
632 /* Front, Surround, CLFE Pins */
633 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
634 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
635 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
637 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
639 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
640 /* Line, Aux, CD, Beep-In Pin */
641 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
642 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
643 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
644 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
645 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
649 static struct hda_verb ad1986a_ch2_init[] = {
650 /* Surround out -> Line In */
651 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
652 /* Line-in selectors */
653 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x1 },
655 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
656 /* Mic selector, mix C/LFE (backmic) and Mic (frontmic) */
657 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 },
661 static struct hda_verb ad1986a_ch4_init[] = {
662 /* Surround out -> Surround */
663 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
664 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
666 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
667 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 },
671 static struct hda_verb ad1986a_ch6_init[] = {
672 /* Surround out -> Surround out */
673 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
674 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
676 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
677 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x0 },
681 static struct hda_channel_mode ad1986a_modes[3] = {
682 { 2, ad1986a_ch2_init },
683 { 4, ad1986a_ch4_init },
684 { 6, ad1986a_ch6_init },
687 /* eapd initialization */
688 static struct hda_verb ad1986a_eapd_init_verbs[] = {
689 {0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00 },
693 /* Ultra initialization */
694 static struct hda_verb ad1986a_ultra_init[] = {
695 /* eapd initialization */
696 { 0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00 },
698 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2 },
699 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
700 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
714 static const char *ad1986a_models[AD1986A_MODELS] = {
715 [AD1986A_6STACK] = "6stack",
716 [AD1986A_3STACK] = "3stack",
717 [AD1986A_LAPTOP] = "laptop",
718 [AD1986A_LAPTOP_EAPD] = "laptop-eapd",
719 [AD1986A_ULTRA] = "ultra",
722 static struct snd_pci_quirk ad1986a_cfg_tbl[] = {
723 SND_PCI_QUIRK(0x103c, 0x30af, "HP B2800", AD1986A_LAPTOP_EAPD),
724 SND_PCI_QUIRK(0x10de, 0xcb84, "ASUS A8N-VM", AD1986A_3STACK),
725 SND_PCI_QUIRK(0x1043, 0x1153, "ASUS M9", AD1986A_LAPTOP_EAPD),
726 SND_PCI_QUIRK(0x1043, 0x1213, "ASUS A6J", AD1986A_LAPTOP_EAPD),
727 SND_PCI_QUIRK(0x1043, 0x11f7, "ASUS U5A", AD1986A_LAPTOP_EAPD),
728 SND_PCI_QUIRK(0x1043, 0x1263, "ASUS U5F", AD1986A_LAPTOP_EAPD),
729 SND_PCI_QUIRK(0x1043, 0x1297, "ASUS Z62F", AD1986A_LAPTOP_EAPD),
730 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS V1j", AD1986A_LAPTOP_EAPD),
731 SND_PCI_QUIRK(0x1043, 0x1302, "ASUS W3j", AD1986A_LAPTOP_EAPD),
732 SND_PCI_QUIRK(0x1043, 0x1447, "ASUS A8J", AD1986A_3STACK),
733 SND_PCI_QUIRK(0x1043, 0x817f, "ASUS P5", AD1986A_3STACK),
734 SND_PCI_QUIRK(0x1043, 0x818f, "ASUS P5", AD1986A_LAPTOP),
735 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS P5", AD1986A_3STACK),
736 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS M2N", AD1986A_3STACK),
737 SND_PCI_QUIRK(0x1043, 0x8234, "ASUS M2N", AD1986A_3STACK),
738 SND_PCI_QUIRK(0x144d, 0xb03c, "Samsung R55", AD1986A_3STACK),
739 SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP),
740 SND_PCI_QUIRK(0x144d, 0xc023, "Samsung X60", AD1986A_LAPTOP_EAPD),
741 SND_PCI_QUIRK(0x144d, 0xc024, "Samsung R65", AD1986A_LAPTOP_EAPD),
742 SND_PCI_QUIRK(0x144d, 0xc026, "Samsung X11", AD1986A_LAPTOP_EAPD),
743 SND_PCI_QUIRK(0x144d, 0xc504, "Samsung Q35", AD1986A_3STACK),
744 SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_ULTRA),
745 SND_PCI_QUIRK(0x17aa, 0x1011, "Lenovo M55", AD1986A_LAPTOP),
746 SND_PCI_QUIRK(0x17aa, 0x1017, "Lenovo A60", AD1986A_3STACK),
747 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo N100", AD1986A_LAPTOP_EAPD),
748 SND_PCI_QUIRK(0x17c0, 0x2017, "Samsung M50", AD1986A_LAPTOP),
752 #ifdef CONFIG_SND_HDA_POWER_SAVE
753 static struct hda_amp_list ad1986a_loopbacks[] = {
754 { 0x13, HDA_OUTPUT, 0 }, /* Mic */
755 { 0x14, HDA_OUTPUT, 0 }, /* Phone */
756 { 0x15, HDA_OUTPUT, 0 }, /* CD */
757 { 0x16, HDA_OUTPUT, 0 }, /* Aux */
758 { 0x17, HDA_OUTPUT, 0 }, /* Line */
763 static int patch_ad1986a(struct hda_codec *codec)
765 struct ad198x_spec *spec;
768 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
774 spec->multiout.max_channels = 6;
775 spec->multiout.num_dacs = ARRAY_SIZE(ad1986a_dac_nids);
776 spec->multiout.dac_nids = ad1986a_dac_nids;
777 spec->multiout.dig_out_nid = AD1986A_SPDIF_OUT;
778 spec->num_adc_nids = 1;
779 spec->adc_nids = ad1986a_adc_nids;
780 spec->capsrc_nids = ad1986a_capsrc_nids;
781 spec->input_mux = &ad1986a_capture_source;
782 spec->num_mixers = 1;
783 spec->mixers[0] = ad1986a_mixers;
784 spec->num_init_verbs = 1;
785 spec->init_verbs[0] = ad1986a_init_verbs;
786 #ifdef CONFIG_SND_HDA_POWER_SAVE
787 spec->loopback.amplist = ad1986a_loopbacks;
790 codec->patch_ops = ad198x_patch_ops;
792 /* override some parameters */
793 board_config = snd_hda_check_board_config(codec, AD1986A_MODELS,
796 switch (board_config) {
798 spec->num_mixers = 2;
799 spec->mixers[1] = ad1986a_3st_mixers;
800 spec->num_init_verbs = 2;
801 spec->init_verbs[1] = ad1986a_ch2_init;
802 spec->channel_mode = ad1986a_modes;
803 spec->num_channel_mode = ARRAY_SIZE(ad1986a_modes);
804 spec->need_dac_fix = 1;
805 spec->multiout.max_channels = 2;
806 spec->multiout.num_dacs = 1;
809 spec->mixers[0] = ad1986a_laptop_mixers;
810 spec->multiout.max_channels = 2;
811 spec->multiout.num_dacs = 1;
812 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
814 case AD1986A_LAPTOP_EAPD:
815 spec->mixers[0] = ad1986a_laptop_eapd_mixers;
816 spec->num_init_verbs = 2;
817 spec->init_verbs[1] = ad1986a_eapd_init_verbs;
818 spec->multiout.max_channels = 2;
819 spec->multiout.num_dacs = 1;
820 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
821 spec->multiout.dig_out_nid = 0;
822 spec->input_mux = &ad1986a_laptop_eapd_capture_source;
825 spec->mixers[0] = ad1986a_laptop_eapd_mixers;
826 spec->num_init_verbs = 2;
827 spec->init_verbs[1] = ad1986a_ultra_init;
828 spec->multiout.max_channels = 2;
829 spec->multiout.num_dacs = 1;
830 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
831 spec->multiout.dig_out_nid = 0;
842 #define AD1983_SPDIF_OUT 0x02
843 #define AD1983_DAC 0x03
844 #define AD1983_ADC 0x04
846 static hda_nid_t ad1983_dac_nids[1] = { AD1983_DAC };
847 static hda_nid_t ad1983_adc_nids[1] = { AD1983_ADC };
848 static hda_nid_t ad1983_capsrc_nids[1] = { 0x15 };
850 static struct hda_input_mux ad1983_capture_source = {
861 * SPDIF playback route
863 static int ad1983_spdif_route_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
865 static char *texts[] = { "PCM", "ADC" };
867 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
869 uinfo->value.enumerated.items = 2;
870 if (uinfo->value.enumerated.item > 1)
871 uinfo->value.enumerated.item = 1;
872 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
876 static int ad1983_spdif_route_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
878 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
879 struct ad198x_spec *spec = codec->spec;
881 ucontrol->value.enumerated.item[0] = spec->spdif_route;
885 static int ad1983_spdif_route_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
887 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
888 struct ad198x_spec *spec = codec->spec;
890 if (spec->spdif_route != ucontrol->value.enumerated.item[0]) {
891 spec->spdif_route = ucontrol->value.enumerated.item[0];
892 snd_hda_codec_write_cache(codec, spec->multiout.dig_out_nid, 0,
893 AC_VERB_SET_CONNECT_SEL,
900 static struct snd_kcontrol_new ad1983_mixers[] = {
901 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT),
902 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT),
903 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT),
904 HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT),
905 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT),
906 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT),
907 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
908 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
909 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
910 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
911 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT),
912 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT),
913 HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x10, 1, 0x0, HDA_OUTPUT),
914 HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x10, 1, 0x0, HDA_OUTPUT),
915 HDA_CODEC_VOLUME("Mic Boost", 0x0c, 0x0, HDA_OUTPUT),
916 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
917 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
919 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
920 .name = "Capture Source",
921 .info = ad198x_mux_enum_info,
922 .get = ad198x_mux_enum_get,
923 .put = ad198x_mux_enum_put,
926 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
927 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
928 .info = ad1983_spdif_route_info,
929 .get = ad1983_spdif_route_get,
930 .put = ad1983_spdif_route_put,
935 static struct hda_verb ad1983_init_verbs[] = {
936 /* Front, HP, Mono; mute as default */
937 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
938 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
939 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
940 /* Beep, PCM, Mic, Line-In: mute */
941 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
942 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
943 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
944 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
945 /* Front, HP selectors; from Mix */
946 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
947 {0x06, AC_VERB_SET_CONNECT_SEL, 0x01},
948 /* Mono selector; from Mix */
949 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03},
950 /* Mic selector; Mic */
951 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0},
952 /* Line-in selector: Line-in */
953 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
955 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
956 /* Record selector: mic */
957 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0},
958 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
959 /* SPDIF route: PCM */
960 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0},
962 {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
964 {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
966 {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
968 {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
970 {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
974 #ifdef CONFIG_SND_HDA_POWER_SAVE
975 static struct hda_amp_list ad1983_loopbacks[] = {
976 { 0x12, HDA_OUTPUT, 0 }, /* Mic */
977 { 0x13, HDA_OUTPUT, 0 }, /* Line */
982 static int patch_ad1983(struct hda_codec *codec)
984 struct ad198x_spec *spec;
986 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
992 spec->multiout.max_channels = 2;
993 spec->multiout.num_dacs = ARRAY_SIZE(ad1983_dac_nids);
994 spec->multiout.dac_nids = ad1983_dac_nids;
995 spec->multiout.dig_out_nid = AD1983_SPDIF_OUT;
996 spec->num_adc_nids = 1;
997 spec->adc_nids = ad1983_adc_nids;
998 spec->capsrc_nids = ad1983_capsrc_nids;
999 spec->input_mux = &ad1983_capture_source;
1000 spec->num_mixers = 1;
1001 spec->mixers[0] = ad1983_mixers;
1002 spec->num_init_verbs = 1;
1003 spec->init_verbs[0] = ad1983_init_verbs;
1004 spec->spdif_route = 0;
1005 #ifdef CONFIG_SND_HDA_POWER_SAVE
1006 spec->loopback.amplist = ad1983_loopbacks;
1009 codec->patch_ops = ad198x_patch_ops;
1016 * AD1981 HD specific
1019 #define AD1981_SPDIF_OUT 0x02
1020 #define AD1981_DAC 0x03
1021 #define AD1981_ADC 0x04
1023 static hda_nid_t ad1981_dac_nids[1] = { AD1981_DAC };
1024 static hda_nid_t ad1981_adc_nids[1] = { AD1981_ADC };
1025 static hda_nid_t ad1981_capsrc_nids[1] = { 0x15 };
1027 /* 0x0c, 0x09, 0x0e, 0x0f, 0x19, 0x05, 0x18, 0x17 */
1028 static struct hda_input_mux ad1981_capture_source = {
1031 { "Front Mic", 0x0 },
1034 { "Mix Mono", 0x3 },
1041 static struct snd_kcontrol_new ad1981_mixers[] = {
1042 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT),
1043 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT),
1044 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT),
1045 HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT),
1046 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT),
1047 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT),
1048 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
1049 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
1050 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
1051 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
1052 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1053 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1054 HDA_CODEC_VOLUME("Aux Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
1055 HDA_CODEC_MUTE("Aux Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1056 HDA_CODEC_VOLUME("Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT),
1057 HDA_CODEC_MUTE("Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
1058 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1059 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1060 HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1061 HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x0d, 1, 0x0, HDA_OUTPUT),
1062 HDA_CODEC_VOLUME("Front Mic Boost", 0x08, 0x0, HDA_INPUT),
1063 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x0, HDA_INPUT),
1064 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1065 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
1067 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1068 .name = "Capture Source",
1069 .info = ad198x_mux_enum_info,
1070 .get = ad198x_mux_enum_get,
1071 .put = ad198x_mux_enum_put,
1073 /* identical with AD1983 */
1075 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1076 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
1077 .info = ad1983_spdif_route_info,
1078 .get = ad1983_spdif_route_get,
1079 .put = ad1983_spdif_route_put,
1084 static struct hda_verb ad1981_init_verbs[] = {
1085 /* Front, HP, Mono; mute as default */
1086 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1087 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1088 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1089 /* Beep, PCM, Front Mic, Line, Rear Mic, Aux, CD-In: mute */
1090 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1091 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1092 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1093 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1094 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1095 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1096 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1097 /* Front, HP selectors; from Mix */
1098 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
1099 {0x06, AC_VERB_SET_CONNECT_SEL, 0x01},
1100 /* Mono selector; from Mix */
1101 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03},
1102 /* Mic Mixer; select Front Mic */
1103 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1104 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1105 /* Mic boost: 0dB */
1106 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1107 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1108 /* Record selector: Front mic */
1109 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0},
1110 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1111 /* SPDIF route: PCM */
1112 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0},
1114 {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1116 {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
1118 {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1119 /* Front & Rear Mic Pins */
1120 {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
1121 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
1123 {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
1125 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
1126 /* Line-Out as Input: disabled */
1127 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1131 #ifdef CONFIG_SND_HDA_POWER_SAVE
1132 static struct hda_amp_list ad1981_loopbacks[] = {
1133 { 0x12, HDA_OUTPUT, 0 }, /* Front Mic */
1134 { 0x13, HDA_OUTPUT, 0 }, /* Line */
1135 { 0x1b, HDA_OUTPUT, 0 }, /* Aux */
1136 { 0x1c, HDA_OUTPUT, 0 }, /* Mic */
1137 { 0x1d, HDA_OUTPUT, 0 }, /* CD */
1143 * Patch for HP nx6320
1145 * nx6320 uses EAPD in the reverse way - EAPD-on means the internal
1146 * speaker output enabled _and_ mute-LED off.
1149 #define AD1981_HP_EVENT 0x37
1150 #define AD1981_MIC_EVENT 0x38
1152 static struct hda_verb ad1981_hp_init_verbs[] = {
1153 {0x05, AC_VERB_SET_EAPD_BTLENABLE, 0x00 }, /* default off */
1154 /* pin sensing on HP and Mic jacks */
1155 {0x06, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_HP_EVENT},
1156 {0x08, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_MIC_EVENT},
1160 /* turn on/off EAPD (+ mute HP) as a master switch */
1161 static int ad1981_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1162 struct snd_ctl_elem_value *ucontrol)
1164 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1165 struct ad198x_spec *spec = codec->spec;
1167 if (! ad198x_eapd_put(kcontrol, ucontrol))
1170 /* toggle HP mute appropriately */
1171 snd_hda_codec_amp_stereo(codec, 0x06, HDA_OUTPUT, 0,
1173 spec->cur_eapd ? 0 : HDA_AMP_MUTE);
1177 /* bind volumes of both NID 0x05 and 0x06 */
1178 static struct hda_bind_ctls ad1981_hp_bind_master_vol = {
1179 .ops = &snd_hda_bind_vol,
1181 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
1182 HDA_COMPOSE_AMP_VAL(0x06, 3, 0, HDA_OUTPUT),
1187 /* mute internal speaker if HP is plugged */
1188 static void ad1981_hp_automute(struct hda_codec *codec)
1190 unsigned int present;
1192 present = snd_hda_codec_read(codec, 0x06, 0,
1193 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1194 snd_hda_codec_amp_stereo(codec, 0x05, HDA_OUTPUT, 0,
1195 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
1198 /* toggle input of built-in and mic jack appropriately */
1199 static void ad1981_hp_automic(struct hda_codec *codec)
1201 static struct hda_verb mic_jack_on[] = {
1202 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1203 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1206 static struct hda_verb mic_jack_off[] = {
1207 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1208 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1211 unsigned int present;
1213 present = snd_hda_codec_read(codec, 0x08, 0,
1214 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1216 snd_hda_sequence_write(codec, mic_jack_on);
1218 snd_hda_sequence_write(codec, mic_jack_off);
1221 /* unsolicited event for HP jack sensing */
1222 static void ad1981_hp_unsol_event(struct hda_codec *codec,
1227 case AD1981_HP_EVENT:
1228 ad1981_hp_automute(codec);
1230 case AD1981_MIC_EVENT:
1231 ad1981_hp_automic(codec);
1236 static struct hda_input_mux ad1981_hp_capture_source = {
1240 { "Docking-Station", 0x1 },
1245 static struct snd_kcontrol_new ad1981_hp_mixers[] = {
1246 HDA_BIND_VOL("Master Playback Volume", &ad1981_hp_bind_master_vol),
1248 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1249 .name = "Master Playback Switch",
1250 .info = ad198x_eapd_info,
1251 .get = ad198x_eapd_get,
1252 .put = ad1981_hp_master_sw_put,
1253 .private_value = 0x05,
1255 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
1256 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
1258 /* FIXME: analog mic/line loopback doesn't work with my tests...
1259 * (although recording is OK)
1261 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
1262 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
1263 HDA_CODEC_VOLUME("Docking-Station Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1264 HDA_CODEC_MUTE("Docking-Station Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1265 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT),
1266 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
1267 /* FIXME: does this laptop have analog CD connection? */
1268 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1269 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1271 HDA_CODEC_VOLUME("Mic Boost", 0x08, 0x0, HDA_INPUT),
1272 HDA_CODEC_VOLUME("Internal Mic Boost", 0x18, 0x0, HDA_INPUT),
1273 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1274 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
1276 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1277 .name = "Capture Source",
1278 .info = ad198x_mux_enum_info,
1279 .get = ad198x_mux_enum_get,
1280 .put = ad198x_mux_enum_put,
1285 /* initialize jack-sensing, too */
1286 static int ad1981_hp_init(struct hda_codec *codec)
1289 ad1981_hp_automute(codec);
1290 ad1981_hp_automic(codec);
1294 /* configuration for Toshiba Laptops */
1295 static struct hda_verb ad1981_toshiba_init_verbs[] = {
1296 {0x05, AC_VERB_SET_EAPD_BTLENABLE, 0x01 }, /* default on */
1297 /* pin sensing on HP and Mic jacks */
1298 {0x06, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_HP_EVENT},
1299 {0x08, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_MIC_EVENT},
1303 static struct snd_kcontrol_new ad1981_toshiba_mixers[] = {
1304 HDA_CODEC_VOLUME("Amp Volume", 0x1a, 0x0, HDA_OUTPUT),
1305 HDA_CODEC_MUTE("Amp Switch", 0x1a, 0x0, HDA_OUTPUT),
1309 /* configuration for Lenovo Thinkpad T60 */
1310 static struct snd_kcontrol_new ad1981_thinkpad_mixers[] = {
1311 HDA_CODEC_VOLUME("Master Playback Volume", 0x05, 0x0, HDA_OUTPUT),
1312 HDA_CODEC_MUTE("Master Playback Switch", 0x05, 0x0, HDA_OUTPUT),
1313 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
1314 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
1315 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
1316 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
1317 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1318 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1319 HDA_CODEC_VOLUME("Mic Boost", 0x08, 0x0, HDA_INPUT),
1320 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1321 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
1323 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1324 .name = "Capture Source",
1325 .info = ad198x_mux_enum_info,
1326 .get = ad198x_mux_enum_get,
1327 .put = ad198x_mux_enum_put,
1329 /* identical with AD1983 */
1331 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1332 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
1333 .info = ad1983_spdif_route_info,
1334 .get = ad1983_spdif_route_get,
1335 .put = ad1983_spdif_route_put,
1340 static struct hda_input_mux ad1981_thinkpad_capture_source = {
1358 static const char *ad1981_models[AD1981_MODELS] = {
1360 [AD1981_THINKPAD] = "thinkpad",
1361 [AD1981_BASIC] = "basic",
1362 [AD1981_TOSHIBA] = "toshiba"
1365 static struct snd_pci_quirk ad1981_cfg_tbl[] = {
1367 SND_PCI_QUIRK(0x103c, 0, "HP nx", AD1981_HP),
1368 /* HP nx6320 (reversed SSID, H/W bug) */
1369 SND_PCI_QUIRK(0x30b0, 0x103c, "HP nx6320", AD1981_HP),
1370 /* Lenovo Thinkpad T60/X60/Z6xx */
1371 SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1981_THINKPAD),
1372 SND_PCI_QUIRK(0x1014, 0x0597, "Lenovo Z60", AD1981_THINKPAD),
1373 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba U205", AD1981_TOSHIBA),
1377 static int patch_ad1981(struct hda_codec *codec)
1379 struct ad198x_spec *spec;
1382 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1388 spec->multiout.max_channels = 2;
1389 spec->multiout.num_dacs = ARRAY_SIZE(ad1981_dac_nids);
1390 spec->multiout.dac_nids = ad1981_dac_nids;
1391 spec->multiout.dig_out_nid = AD1981_SPDIF_OUT;
1392 spec->num_adc_nids = 1;
1393 spec->adc_nids = ad1981_adc_nids;
1394 spec->capsrc_nids = ad1981_capsrc_nids;
1395 spec->input_mux = &ad1981_capture_source;
1396 spec->num_mixers = 1;
1397 spec->mixers[0] = ad1981_mixers;
1398 spec->num_init_verbs = 1;
1399 spec->init_verbs[0] = ad1981_init_verbs;
1400 spec->spdif_route = 0;
1401 #ifdef CONFIG_SND_HDA_POWER_SAVE
1402 spec->loopback.amplist = ad1981_loopbacks;
1405 codec->patch_ops = ad198x_patch_ops;
1407 /* override some parameters */
1408 board_config = snd_hda_check_board_config(codec, AD1981_MODELS,
1411 switch (board_config) {
1413 spec->mixers[0] = ad1981_hp_mixers;
1414 spec->num_init_verbs = 2;
1415 spec->init_verbs[1] = ad1981_hp_init_verbs;
1416 spec->multiout.dig_out_nid = 0;
1417 spec->input_mux = &ad1981_hp_capture_source;
1419 codec->patch_ops.init = ad1981_hp_init;
1420 codec->patch_ops.unsol_event = ad1981_hp_unsol_event;
1422 case AD1981_THINKPAD:
1423 spec->mixers[0] = ad1981_thinkpad_mixers;
1424 spec->input_mux = &ad1981_thinkpad_capture_source;
1426 case AD1981_TOSHIBA:
1427 spec->mixers[0] = ad1981_hp_mixers;
1428 spec->mixers[1] = ad1981_toshiba_mixers;
1429 spec->num_init_verbs = 2;
1430 spec->init_verbs[1] = ad1981_toshiba_init_verbs;
1431 spec->multiout.dig_out_nid = 0;
1432 spec->input_mux = &ad1981_hp_capture_source;
1433 codec->patch_ops.init = ad1981_hp_init;
1434 codec->patch_ops.unsol_event = ad1981_hp_unsol_event;
1444 * Output pins and routes
1446 * Pin Mix Sel DAC (*)
1447 * port-A 0x11 (mute/hp) <- 0x22 <- 0x37 <- 03/04/06
1448 * port-B 0x14 (mute/hp) <- 0x2b <- 0x30 <- 03/04/06
1449 * port-C 0x15 (mute) <- 0x2c <- 0x31 <- 05/0a
1450 * port-D 0x12 (mute/hp) <- 0x29 <- 04
1451 * port-E 0x17 (mute/hp) <- 0x26 <- 0x32 <- 05/0a
1452 * port-F 0x16 (mute) <- 0x2a <- 06
1453 * port-G 0x24 (mute) <- 0x27 <- 05
1454 * port-H 0x25 (mute) <- 0x28 <- 0a
1455 * mono 0x13 (mute/amp)<- 0x1e <- 0x36 <- 03/04/06
1457 * DAC0 = 03h, DAC1 = 04h, DAC2 = 05h, DAC3 = 06h, DAC4 = 0ah
1458 * (*) DAC2/3/4 are swapped to DAC3/4/2 on AD198A rev.2 due to a h/w bug.
1460 * Input pins and routes
1462 * pin boost mix input # / adc input #
1463 * port-A 0x11 -> 0x38 -> mix 2, ADC 0
1464 * port-B 0x14 -> 0x39 -> mix 0, ADC 1
1465 * port-C 0x15 -> 0x3a -> 33:0 - mix 1, ADC 2
1466 * port-D 0x12 -> 0x3d -> mix 3, ADC 8
1467 * port-E 0x17 -> 0x3c -> 34:0 - mix 4, ADC 4
1468 * port-F 0x16 -> 0x3b -> mix 5, ADC 3
1469 * port-G 0x24 -> N/A -> 33:1 - mix 1, 34:1 - mix 4, ADC 6
1470 * port-H 0x25 -> N/A -> 33:2 - mix 1, 34:2 - mix 4, ADC 7
1474 * 6stack - front/surr/CLFE/side/opt DACs - 04/06/05/0a/03
1475 * 3stack - front/surr/CLFE/opt DACs - 04/05/0a/03
1477 * Inputs of Analog Mix (0x20)
1478 * 0:Port-B (front mic)
1479 * 1:Port-C/G/H (line-in)
1481 * 3:Port-D (line-in/2)
1482 * 4:Port-E/G/H (mic-in)
1483 * 5:Port-F (mic2-in)
1489 * 1:Port-B (front mic-in)
1490 * 2:Port-C (line-in)
1491 * 3:Port-F (mic2-in)
1496 * 8:Port-D (line-in/2)
1499 * Proposed pin assignments by the datasheet
1502 * Port-A front headphone
1512 * Port-A front headphone
1514 * C rear line-in/surround
1516 * E rear mic-in/CLFE
1522 * D internal speaker (with EAPD)
1523 * E/F quad mic array
1539 /* reivision id to check workarounds */
1540 #define AD1988A_REV2 0x100200
1542 #define is_rev2(codec) \
1543 ((codec)->vendor_id == 0x11d41988 && \
1544 (codec)->revision_id == AD1988A_REV2)
1550 static hda_nid_t ad1988_6stack_dac_nids[4] = {
1551 0x04, 0x06, 0x05, 0x0a
1554 static hda_nid_t ad1988_3stack_dac_nids[3] = {
1558 /* for AD1988A revision-2, DAC2-4 are swapped */
1559 static hda_nid_t ad1988_6stack_dac_nids_rev2[4] = {
1560 0x04, 0x05, 0x0a, 0x06
1563 static hda_nid_t ad1988_3stack_dac_nids_rev2[3] = {
1567 static hda_nid_t ad1988_adc_nids[3] = {
1571 static hda_nid_t ad1988_capsrc_nids[3] = {
1575 #define AD1988_SPDIF_OUT 0x02
1576 #define AD1988_SPDIF_IN 0x07
1578 static struct hda_input_mux ad1988_6stack_capture_source = {
1581 { "Front Mic", 0x0 },
1589 static struct hda_input_mux ad1988_laptop_capture_source = {
1592 { "Mic/Line", 0x0 },
1600 static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol,
1601 struct snd_ctl_elem_info *uinfo)
1603 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1604 struct ad198x_spec *spec = codec->spec;
1605 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
1606 spec->num_channel_mode);
1609 static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol,
1610 struct snd_ctl_elem_value *ucontrol)
1612 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1613 struct ad198x_spec *spec = codec->spec;
1614 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
1615 spec->num_channel_mode, spec->multiout.max_channels);
1618 static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol,
1619 struct snd_ctl_elem_value *ucontrol)
1621 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1622 struct ad198x_spec *spec = codec->spec;
1623 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
1624 spec->num_channel_mode,
1625 &spec->multiout.max_channels);
1626 if (err >= 0 && spec->need_dac_fix)
1627 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
1632 static struct snd_kcontrol_new ad1988_6stack_mixers1[] = {
1633 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1634 HDA_CODEC_VOLUME("Surround Playback Volume", 0x06, 0x0, HDA_OUTPUT),
1635 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT),
1636 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT),
1637 HDA_CODEC_VOLUME("Side Playback Volume", 0x0a, 0x0, HDA_OUTPUT),
1641 static struct snd_kcontrol_new ad1988_6stack_mixers1_rev2[] = {
1642 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1643 HDA_CODEC_VOLUME("Surround Playback Volume", 0x05, 0x0, HDA_OUTPUT),
1644 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
1645 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0a, 2, 0x0, HDA_OUTPUT),
1646 HDA_CODEC_VOLUME("Side Playback Volume", 0x06, 0x0, HDA_OUTPUT),
1650 static struct snd_kcontrol_new ad1988_6stack_mixers2[] = {
1651 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT),
1652 HDA_BIND_MUTE("Surround Playback Switch", 0x2a, 2, HDA_INPUT),
1653 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x27, 1, 2, HDA_INPUT),
1654 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x27, 2, 2, HDA_INPUT),
1655 HDA_BIND_MUTE("Side Playback Switch", 0x28, 2, HDA_INPUT),
1656 HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT),
1657 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT),
1659 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT),
1660 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT),
1661 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT),
1662 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT),
1663 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
1664 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
1665 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT),
1666 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT),
1668 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
1669 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
1671 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
1672 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
1674 HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT),
1675 HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT),
1681 static struct snd_kcontrol_new ad1988_3stack_mixers1[] = {
1682 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1683 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT),
1684 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT),
1685 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT),
1689 static struct snd_kcontrol_new ad1988_3stack_mixers1_rev2[] = {
1690 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1691 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT),
1692 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x06, 1, 0x0, HDA_OUTPUT),
1693 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x06, 2, 0x0, HDA_OUTPUT),
1697 static struct snd_kcontrol_new ad1988_3stack_mixers2[] = {
1698 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT),
1699 HDA_BIND_MUTE("Surround Playback Switch", 0x2c, 2, HDA_INPUT),
1700 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x26, 1, 2, HDA_INPUT),
1701 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x26, 2, 2, HDA_INPUT),
1702 HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT),
1703 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT),
1705 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT),
1706 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT),
1707 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT),
1708 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT),
1709 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
1710 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
1711 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT),
1712 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT),
1714 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
1715 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
1717 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
1718 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
1720 HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT),
1721 HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT),
1723 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1724 .name = "Channel Mode",
1725 .info = ad198x_ch_mode_info,
1726 .get = ad198x_ch_mode_get,
1727 .put = ad198x_ch_mode_put,
1734 static struct snd_kcontrol_new ad1988_laptop_mixers[] = {
1735 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1736 HDA_CODEC_MUTE("PCM Playback Switch", 0x29, 0x0, HDA_INPUT),
1737 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT),
1739 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT),
1740 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT),
1741 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x0, HDA_INPUT),
1742 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x0, HDA_INPUT),
1743 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
1744 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
1746 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
1747 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
1749 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
1750 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
1752 HDA_CODEC_VOLUME("Mic Boost", 0x39, 0x0, HDA_OUTPUT),
1755 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1756 .name = "External Amplifier",
1757 .info = ad198x_eapd_info,
1758 .get = ad198x_eapd_get,
1759 .put = ad198x_eapd_put,
1760 .private_value = 0x12 | (1 << 8), /* port-D, inversed */
1767 static struct snd_kcontrol_new ad1988_capture_mixers[] = {
1768 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
1769 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
1770 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
1771 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
1772 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x0e, 0x0, HDA_OUTPUT),
1773 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x0e, 0x0, HDA_OUTPUT),
1775 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1776 /* The multiple "Capture Source" controls confuse alsamixer
1777 * So call somewhat different..
1778 * FIXME: the controls appear in the "playback" view!
1780 /* .name = "Capture Source", */
1781 .name = "Input Source",
1783 .info = ad198x_mux_enum_info,
1784 .get = ad198x_mux_enum_get,
1785 .put = ad198x_mux_enum_put,
1790 static int ad1988_spdif_playback_source_info(struct snd_kcontrol *kcontrol,
1791 struct snd_ctl_elem_info *uinfo)
1793 static char *texts[] = {
1794 "PCM", "ADC1", "ADC2", "ADC3"
1796 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1798 uinfo->value.enumerated.items = 4;
1799 if (uinfo->value.enumerated.item >= 4)
1800 uinfo->value.enumerated.item = 3;
1801 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1805 static int ad1988_spdif_playback_source_get(struct snd_kcontrol *kcontrol,
1806 struct snd_ctl_elem_value *ucontrol)
1808 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1811 sel = snd_hda_codec_read(codec, 0x1d, 0, AC_VERB_GET_AMP_GAIN_MUTE,
1814 ucontrol->value.enumerated.item[0] = 0;
1816 sel = snd_hda_codec_read(codec, 0x0b, 0,
1817 AC_VERB_GET_CONNECT_SEL, 0);
1822 ucontrol->value.enumerated.item[0] = sel;
1827 static int ad1988_spdif_playback_source_put(struct snd_kcontrol *kcontrol,
1828 struct snd_ctl_elem_value *ucontrol)
1830 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1831 unsigned int val, sel;
1834 val = ucontrol->value.enumerated.item[0];
1836 sel = snd_hda_codec_read(codec, 0x1d, 0,
1837 AC_VERB_GET_AMP_GAIN_MUTE,
1839 change = sel & 0x80;
1841 snd_hda_codec_write_cache(codec, 0x1d, 0,
1842 AC_VERB_SET_AMP_GAIN_MUTE,
1844 snd_hda_codec_write_cache(codec, 0x1d, 0,
1845 AC_VERB_SET_AMP_GAIN_MUTE,
1849 sel = snd_hda_codec_read(codec, 0x1d, 0,
1850 AC_VERB_GET_AMP_GAIN_MUTE,
1851 AC_AMP_GET_INPUT | 0x01);
1852 change = sel & 0x80;
1854 snd_hda_codec_write_cache(codec, 0x1d, 0,
1855 AC_VERB_SET_AMP_GAIN_MUTE,
1857 snd_hda_codec_write_cache(codec, 0x1d, 0,
1858 AC_VERB_SET_AMP_GAIN_MUTE,
1861 sel = snd_hda_codec_read(codec, 0x0b, 0,
1862 AC_VERB_GET_CONNECT_SEL, 0) + 1;
1863 change |= sel != val;
1865 snd_hda_codec_write_cache(codec, 0x0b, 0,
1866 AC_VERB_SET_CONNECT_SEL,
1872 static struct snd_kcontrol_new ad1988_spdif_out_mixers[] = {
1873 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
1875 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1876 .name = "IEC958 Playback Source",
1877 .info = ad1988_spdif_playback_source_info,
1878 .get = ad1988_spdif_playback_source_get,
1879 .put = ad1988_spdif_playback_source_put,
1884 static struct snd_kcontrol_new ad1988_spdif_in_mixers[] = {
1885 HDA_CODEC_VOLUME("IEC958 Capture Volume", 0x1c, 0x0, HDA_INPUT),
1891 * initialization verbs
1895 * for 6-stack (+dig)
1897 static struct hda_verb ad1988_6stack_init_verbs[] = {
1898 /* Front, Surround, CLFE, side DAC; unmute as default */
1899 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1900 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1901 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1902 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1903 /* Port-A front headphon path */
1904 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */
1905 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1906 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1907 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1908 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1909 /* Port-D line-out path */
1910 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1911 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1912 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1913 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1914 /* Port-F surround path */
1915 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1916 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1917 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1918 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1919 /* Port-G CLFE path */
1920 {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1921 {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1922 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1923 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1924 /* Port-H side path */
1925 {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1926 {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1927 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1928 {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1930 {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */
1931 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1932 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1933 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1934 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */
1935 /* Port-B front mic-in path */
1936 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1937 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1938 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1939 /* Port-C line-in path */
1940 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1941 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1942 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1943 {0x33, AC_VERB_SET_CONNECT_SEL, 0x0},
1944 /* Port-E mic-in path */
1945 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1946 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1947 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1948 {0x34, AC_VERB_SET_CONNECT_SEL, 0x0},
1953 static struct hda_verb ad1988_capture_init_verbs[] = {
1954 /* mute analog mix */
1955 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1956 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1957 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1958 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1959 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1960 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
1961 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1962 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
1963 /* select ADCs - front-mic */
1964 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
1965 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
1966 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
1968 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1969 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1970 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1975 static struct hda_verb ad1988_spdif_init_verbs[] = {
1977 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */
1978 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x0}, /* ADC1 */
1979 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1980 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1982 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
1988 * verbs for 3stack (+dig)
1990 static struct hda_verb ad1988_3stack_ch2_init[] = {
1991 /* set port-C to line-in */
1992 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1993 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1994 /* set port-E to mic-in */
1995 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1996 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2000 static struct hda_verb ad1988_3stack_ch6_init[] = {
2001 /* set port-C to surround out */
2002 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2003 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2004 /* set port-E to CLFE out */
2005 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2006 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2010 static struct hda_channel_mode ad1988_3stack_modes[2] = {
2011 { 2, ad1988_3stack_ch2_init },
2012 { 6, ad1988_3stack_ch6_init },
2015 static struct hda_verb ad1988_3stack_init_verbs[] = {
2016 /* Front, Surround, CLFE, side DAC; unmute as default */
2017 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2018 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2019 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2020 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2021 /* Port-A front headphon path */
2022 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */
2023 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2024 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2025 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2026 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2027 /* Port-D line-out path */
2028 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2029 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2030 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2031 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2033 {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */
2034 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2035 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2036 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2037 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */
2038 /* Port-B front mic-in path */
2039 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2040 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2041 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2042 /* Port-C line-in/surround path - 6ch mode as default */
2043 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2044 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2045 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2046 {0x31, AC_VERB_SET_CONNECT_SEL, 0x0}, /* output sel: DAC 0x05 */
2047 {0x33, AC_VERB_SET_CONNECT_SEL, 0x0},
2048 /* Port-E mic-in/CLFE path - 6ch mode as default */
2049 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2050 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2051 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2052 {0x32, AC_VERB_SET_CONNECT_SEL, 0x1}, /* output sel: DAC 0x0a */
2053 {0x34, AC_VERB_SET_CONNECT_SEL, 0x0},
2054 /* mute analog mix */
2055 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2056 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2057 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2058 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2059 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2060 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
2061 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2062 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2063 /* select ADCs - front-mic */
2064 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
2065 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
2066 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
2068 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2069 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2070 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2075 * verbs for laptop mode (+dig)
2077 static struct hda_verb ad1988_laptop_hp_on[] = {
2078 /* unmute port-A and mute port-D */
2079 { 0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2080 { 0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2083 static struct hda_verb ad1988_laptop_hp_off[] = {
2084 /* mute port-A and unmute port-D */
2085 { 0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2086 { 0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2090 #define AD1988_HP_EVENT 0x01
2092 static struct hda_verb ad1988_laptop_init_verbs[] = {
2093 /* Front, Surround, CLFE, side DAC; unmute as default */
2094 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2095 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2096 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2097 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2098 /* Port-A front headphon path */
2099 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */
2100 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2101 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2102 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2103 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2104 /* unsolicited event for pin-sense */
2105 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1988_HP_EVENT },
2106 /* Port-D line-out path + EAPD */
2107 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2108 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2109 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2110 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2111 {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x00}, /* EAPD-off */
2113 {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */
2114 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2115 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2116 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2117 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */
2118 /* Port-B mic-in path */
2119 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2120 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2121 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2122 /* Port-C docking station - try to output */
2123 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2124 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2125 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2126 {0x33, AC_VERB_SET_CONNECT_SEL, 0x0},
2127 /* mute analog mix */
2128 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2129 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2130 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2131 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2132 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2133 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
2134 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2135 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2136 /* select ADCs - mic */
2137 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
2138 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
2139 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
2141 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2142 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2143 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2147 static void ad1988_laptop_unsol_event(struct hda_codec *codec, unsigned int res)
2149 if ((res >> 26) != AD1988_HP_EVENT)
2151 if (snd_hda_codec_read(codec, 0x11, 0, AC_VERB_GET_PIN_SENSE, 0) & (1 << 31))
2152 snd_hda_sequence_write(codec, ad1988_laptop_hp_on);
2154 snd_hda_sequence_write(codec, ad1988_laptop_hp_off);
2157 #ifdef CONFIG_SND_HDA_POWER_SAVE
2158 static struct hda_amp_list ad1988_loopbacks[] = {
2159 { 0x20, HDA_INPUT, 0 }, /* Front Mic */
2160 { 0x20, HDA_INPUT, 1 }, /* Line */
2161 { 0x20, HDA_INPUT, 4 }, /* Mic */
2162 { 0x20, HDA_INPUT, 6 }, /* CD */
2168 * Automatic parse of I/O pins from the BIOS configuration
2171 #define NUM_CONTROL_ALLOC 32
2172 #define NUM_VERB_ALLOC 32
2179 static struct snd_kcontrol_new ad1988_control_templates[] = {
2180 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2181 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2182 HDA_BIND_MUTE(NULL, 0, 0, 0),
2185 /* add dynamic controls */
2186 static int add_control(struct ad198x_spec *spec, int type, const char *name,
2189 struct snd_kcontrol_new *knew;
2191 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2192 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2194 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2197 if (spec->kctl_alloc) {
2198 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2199 kfree(spec->kctl_alloc);
2201 spec->kctl_alloc = knew;
2202 spec->num_kctl_alloc = num;
2205 knew = &spec->kctl_alloc[spec->num_kctl_used];
2206 *knew = ad1988_control_templates[type];
2207 knew->name = kstrdup(name, GFP_KERNEL);
2210 knew->private_value = val;
2211 spec->num_kctl_used++;
2215 #define AD1988_PIN_CD_NID 0x18
2216 #define AD1988_PIN_BEEP_NID 0x10
2218 static hda_nid_t ad1988_mixer_nids[8] = {
2219 /* A B C D E F G H */
2220 0x22, 0x2b, 0x2c, 0x29, 0x26, 0x2a, 0x27, 0x28
2223 static inline hda_nid_t ad1988_idx_to_dac(struct hda_codec *codec, int idx)
2225 static hda_nid_t idx_to_dac[8] = {
2226 /* A B C D E F G H */
2227 0x04, 0x06, 0x05, 0x04, 0x0a, 0x06, 0x05, 0x0a
2229 static hda_nid_t idx_to_dac_rev2[8] = {
2230 /* A B C D E F G H */
2231 0x04, 0x05, 0x0a, 0x04, 0x06, 0x05, 0x0a, 0x06
2234 return idx_to_dac_rev2[idx];
2236 return idx_to_dac[idx];
2239 static hda_nid_t ad1988_boost_nids[8] = {
2240 0x38, 0x39, 0x3a, 0x3d, 0x3c, 0x3b, 0, 0
2243 static int ad1988_pin_idx(hda_nid_t nid)
2245 static hda_nid_t ad1988_io_pins[8] = {
2246 0x11, 0x14, 0x15, 0x12, 0x17, 0x16, 0x24, 0x25
2249 for (i = 0; i < ARRAY_SIZE(ad1988_io_pins); i++)
2250 if (ad1988_io_pins[i] == nid)
2252 return 0; /* should be -1 */
2255 static int ad1988_pin_to_loopback_idx(hda_nid_t nid)
2257 static int loopback_idx[8] = {
2258 2, 0, 1, 3, 4, 5, 1, 4
2261 case AD1988_PIN_CD_NID:
2264 return loopback_idx[ad1988_pin_idx(nid)];
2268 static int ad1988_pin_to_adc_idx(hda_nid_t nid)
2270 static int adc_idx[8] = {
2271 0, 1, 2, 8, 4, 3, 6, 7
2274 case AD1988_PIN_CD_NID:
2277 return adc_idx[ad1988_pin_idx(nid)];
2281 /* fill in the dac_nids table from the parsed pin configuration */
2282 static int ad1988_auto_fill_dac_nids(struct hda_codec *codec,
2283 const struct auto_pin_cfg *cfg)
2285 struct ad198x_spec *spec = codec->spec;
2288 spec->multiout.dac_nids = spec->private_dac_nids;
2290 /* check the pins hardwired to audio widget */
2291 for (i = 0; i < cfg->line_outs; i++) {
2292 idx = ad1988_pin_idx(cfg->line_out_pins[i]);
2293 spec->multiout.dac_nids[i] = ad1988_idx_to_dac(codec, idx);
2295 spec->multiout.num_dacs = cfg->line_outs;
2299 /* add playback controls from the parsed DAC table */
2300 static int ad1988_auto_create_multi_out_ctls(struct ad198x_spec *spec,
2301 const struct auto_pin_cfg *cfg)
2304 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
2308 for (i = 0; i < cfg->line_outs; i++) {
2309 hda_nid_t dac = spec->multiout.dac_nids[i];
2312 nid = ad1988_mixer_nids[ad1988_pin_idx(cfg->line_out_pins[i])];
2315 err = add_control(spec, AD_CTL_WIDGET_VOL,
2316 "Center Playback Volume",
2317 HDA_COMPOSE_AMP_VAL(dac, 1, 0, HDA_OUTPUT));
2320 err = add_control(spec, AD_CTL_WIDGET_VOL,
2321 "LFE Playback Volume",
2322 HDA_COMPOSE_AMP_VAL(dac, 2, 0, HDA_OUTPUT));
2325 err = add_control(spec, AD_CTL_BIND_MUTE,
2326 "Center Playback Switch",
2327 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT));
2330 err = add_control(spec, AD_CTL_BIND_MUTE,
2331 "LFE Playback Switch",
2332 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT));
2336 sprintf(name, "%s Playback Volume", chname[i]);
2337 err = add_control(spec, AD_CTL_WIDGET_VOL, name,
2338 HDA_COMPOSE_AMP_VAL(dac, 3, 0, HDA_OUTPUT));
2341 sprintf(name, "%s Playback Switch", chname[i]);
2342 err = add_control(spec, AD_CTL_BIND_MUTE, name,
2343 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
2351 /* add playback controls for speaker and HP outputs */
2352 static int ad1988_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
2355 struct ad198x_spec *spec = codec->spec;
2363 idx = ad1988_pin_idx(pin);
2364 nid = ad1988_idx_to_dac(codec, idx);
2365 /* specify the DAC as the extra output */
2366 if (! spec->multiout.hp_nid)
2367 spec->multiout.hp_nid = nid;
2369 spec->multiout.extra_out_nid[0] = nid;
2370 /* control HP volume/switch on the output mixer amp */
2371 sprintf(name, "%s Playback Volume", pfx);
2372 if ((err = add_control(spec, AD_CTL_WIDGET_VOL, name,
2373 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2375 nid = ad1988_mixer_nids[idx];
2376 sprintf(name, "%s Playback Switch", pfx);
2377 if ((err = add_control(spec, AD_CTL_BIND_MUTE, name,
2378 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2383 /* create input playback/capture controls for the given pin */
2384 static int new_analog_input(struct ad198x_spec *spec, hda_nid_t pin,
2385 const char *ctlname, int boost)
2390 sprintf(name, "%s Playback Volume", ctlname);
2391 idx = ad1988_pin_to_loopback_idx(pin);
2392 if ((err = add_control(spec, AD_CTL_WIDGET_VOL, name,
2393 HDA_COMPOSE_AMP_VAL(0x20, 3, idx, HDA_INPUT))) < 0)
2395 sprintf(name, "%s Playback Switch", ctlname);
2396 if ((err = add_control(spec, AD_CTL_WIDGET_MUTE, name,
2397 HDA_COMPOSE_AMP_VAL(0x20, 3, idx, HDA_INPUT))) < 0)
2401 idx = ad1988_pin_idx(pin);
2402 bnid = ad1988_boost_nids[idx];
2404 sprintf(name, "%s Boost", ctlname);
2405 return add_control(spec, AD_CTL_WIDGET_VOL, name,
2406 HDA_COMPOSE_AMP_VAL(bnid, 3, idx, HDA_OUTPUT));
2413 /* create playback/capture controls for input pins */
2414 static int ad1988_auto_create_analog_input_ctls(struct ad198x_spec *spec,
2415 const struct auto_pin_cfg *cfg)
2417 struct hda_input_mux *imux = &spec->private_imux;
2420 for (i = 0; i < AUTO_PIN_LAST; i++) {
2421 err = new_analog_input(spec, cfg->input_pins[i],
2422 auto_pin_cfg_labels[i],
2423 i <= AUTO_PIN_FRONT_MIC);
2426 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2427 imux->items[imux->num_items].index = ad1988_pin_to_adc_idx(cfg->input_pins[i]);
2430 imux->items[imux->num_items].label = "Mix";
2431 imux->items[imux->num_items].index = 9;
2434 if ((err = add_control(spec, AD_CTL_WIDGET_VOL,
2435 "Analog Mix Playback Volume",
2436 HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT))) < 0)
2438 if ((err = add_control(spec, AD_CTL_WIDGET_MUTE,
2439 "Analog Mix Playback Switch",
2440 HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT))) < 0)
2446 static void ad1988_auto_set_output_and_unmute(struct hda_codec *codec,
2447 hda_nid_t nid, int pin_type,
2451 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2452 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2454 case 0x11: /* port-A - DAC 04 */
2455 snd_hda_codec_write(codec, 0x37, 0, AC_VERB_SET_CONNECT_SEL, 0x01);
2457 case 0x14: /* port-B - DAC 06 */
2458 snd_hda_codec_write(codec, 0x30, 0, AC_VERB_SET_CONNECT_SEL, 0x02);
2460 case 0x15: /* port-C - DAC 05 */
2461 snd_hda_codec_write(codec, 0x31, 0, AC_VERB_SET_CONNECT_SEL, 0x00);
2463 case 0x17: /* port-E - DAC 0a */
2464 snd_hda_codec_write(codec, 0x32, 0, AC_VERB_SET_CONNECT_SEL, 0x01);
2466 case 0x13: /* mono - DAC 04 */
2467 snd_hda_codec_write(codec, 0x36, 0, AC_VERB_SET_CONNECT_SEL, 0x01);
2472 static void ad1988_auto_init_multi_out(struct hda_codec *codec)
2474 struct ad198x_spec *spec = codec->spec;
2477 for (i = 0; i < spec->autocfg.line_outs; i++) {
2478 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2479 ad1988_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2483 static void ad1988_auto_init_extra_out(struct hda_codec *codec)
2485 struct ad198x_spec *spec = codec->spec;
2488 pin = spec->autocfg.speaker_pins[0];
2489 if (pin) /* connect to front */
2490 ad1988_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
2491 pin = spec->autocfg.hp_pins[0];
2492 if (pin) /* connect to front */
2493 ad1988_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2496 static void ad1988_auto_init_analog_input(struct hda_codec *codec)
2498 struct ad198x_spec *spec = codec->spec;
2501 for (i = 0; i < AUTO_PIN_LAST; i++) {
2502 hda_nid_t nid = spec->autocfg.input_pins[i];
2506 case 0x15: /* port-C */
2507 snd_hda_codec_write(codec, 0x33, 0, AC_VERB_SET_CONNECT_SEL, 0x0);
2509 case 0x17: /* port-E */
2510 snd_hda_codec_write(codec, 0x34, 0, AC_VERB_SET_CONNECT_SEL, 0x0);
2513 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2514 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2515 if (nid != AD1988_PIN_CD_NID)
2516 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2518 idx = ad1988_pin_idx(nid);
2519 if (ad1988_boost_nids[idx])
2520 snd_hda_codec_write(codec, ad1988_boost_nids[idx], 0,
2521 AC_VERB_SET_AMP_GAIN_MUTE,
2526 /* parse the BIOS configuration and set up the alc_spec */
2527 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2528 static int ad1988_parse_auto_config(struct hda_codec *codec)
2530 struct ad198x_spec *spec = codec->spec;
2533 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
2535 if ((err = ad1988_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
2537 if (! spec->autocfg.line_outs)
2538 return 0; /* can't find valid BIOS pin config */
2539 if ((err = ad1988_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
2540 (err = ad1988_auto_create_extra_out(codec,
2541 spec->autocfg.speaker_pins[0],
2543 (err = ad1988_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
2544 "Headphone")) < 0 ||
2545 (err = ad1988_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2548 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2550 if (spec->autocfg.dig_out_pin)
2551 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
2552 if (spec->autocfg.dig_in_pin)
2553 spec->dig_in_nid = AD1988_SPDIF_IN;
2555 if (spec->kctl_alloc)
2556 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2558 spec->init_verbs[spec->num_init_verbs++] = ad1988_6stack_init_verbs;
2560 spec->input_mux = &spec->private_imux;
2565 /* init callback for auto-configuration model -- overriding the default init */
2566 static int ad1988_auto_init(struct hda_codec *codec)
2569 ad1988_auto_init_multi_out(codec);
2570 ad1988_auto_init_extra_out(codec);
2571 ad1988_auto_init_analog_input(codec);
2579 static const char *ad1988_models[AD1988_MODEL_LAST] = {
2580 [AD1988_6STACK] = "6stack",
2581 [AD1988_6STACK_DIG] = "6stack-dig",
2582 [AD1988_3STACK] = "3stack",
2583 [AD1988_3STACK_DIG] = "3stack-dig",
2584 [AD1988_LAPTOP] = "laptop",
2585 [AD1988_LAPTOP_DIG] = "laptop-dig",
2586 [AD1988_AUTO] = "auto",
2589 static struct snd_pci_quirk ad1988_cfg_tbl[] = {
2590 SND_PCI_QUIRK(0x1043, 0x81f6, "Asus M2N-SLI", AD1988_6STACK_DIG),
2591 SND_PCI_QUIRK(0x1043, 0x81ec, "Asus P5B-DLX", AD1988_6STACK_DIG),
2595 static int patch_ad1988(struct hda_codec *codec)
2597 struct ad198x_spec *spec;
2600 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2607 snd_printk(KERN_INFO "patch_analog: AD1988A rev.2 is detected, enable workarounds\n");
2609 board_config = snd_hda_check_board_config(codec, AD1988_MODEL_LAST,
2610 ad1988_models, ad1988_cfg_tbl);
2611 if (board_config < 0) {
2612 printk(KERN_INFO "hda_codec: Unknown model for AD1988, trying auto-probe from BIOS...\n");
2613 board_config = AD1988_AUTO;
2616 if (board_config == AD1988_AUTO) {
2617 /* automatic parse from the BIOS config */
2618 int err = ad1988_parse_auto_config(codec);
2623 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 6-stack mode...\n");
2624 board_config = AD1988_6STACK;
2628 switch (board_config) {
2630 case AD1988_6STACK_DIG:
2631 spec->multiout.max_channels = 8;
2632 spec->multiout.num_dacs = 4;
2634 spec->multiout.dac_nids = ad1988_6stack_dac_nids_rev2;
2636 spec->multiout.dac_nids = ad1988_6stack_dac_nids;
2637 spec->input_mux = &ad1988_6stack_capture_source;
2638 spec->num_mixers = 2;
2640 spec->mixers[0] = ad1988_6stack_mixers1_rev2;
2642 spec->mixers[0] = ad1988_6stack_mixers1;
2643 spec->mixers[1] = ad1988_6stack_mixers2;
2644 spec->num_init_verbs = 1;
2645 spec->init_verbs[0] = ad1988_6stack_init_verbs;
2646 if (board_config == AD1988_6STACK_DIG) {
2647 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
2648 spec->dig_in_nid = AD1988_SPDIF_IN;
2652 case AD1988_3STACK_DIG:
2653 spec->multiout.max_channels = 6;
2654 spec->multiout.num_dacs = 3;
2656 spec->multiout.dac_nids = ad1988_3stack_dac_nids_rev2;
2658 spec->multiout.dac_nids = ad1988_3stack_dac_nids;
2659 spec->input_mux = &ad1988_6stack_capture_source;
2660 spec->channel_mode = ad1988_3stack_modes;
2661 spec->num_channel_mode = ARRAY_SIZE(ad1988_3stack_modes);
2662 spec->num_mixers = 2;
2664 spec->mixers[0] = ad1988_3stack_mixers1_rev2;
2666 spec->mixers[0] = ad1988_3stack_mixers1;
2667 spec->mixers[1] = ad1988_3stack_mixers2;
2668 spec->num_init_verbs = 1;
2669 spec->init_verbs[0] = ad1988_3stack_init_verbs;
2670 if (board_config == AD1988_3STACK_DIG)
2671 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
2674 case AD1988_LAPTOP_DIG:
2675 spec->multiout.max_channels = 2;
2676 spec->multiout.num_dacs = 1;
2677 spec->multiout.dac_nids = ad1988_3stack_dac_nids;
2678 spec->input_mux = &ad1988_laptop_capture_source;
2679 spec->num_mixers = 1;
2680 spec->mixers[0] = ad1988_laptop_mixers;
2681 spec->num_init_verbs = 1;
2682 spec->init_verbs[0] = ad1988_laptop_init_verbs;
2683 if (board_config == AD1988_LAPTOP_DIG)
2684 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
2688 spec->num_adc_nids = ARRAY_SIZE(ad1988_adc_nids);
2689 spec->adc_nids = ad1988_adc_nids;
2690 spec->capsrc_nids = ad1988_capsrc_nids;
2691 spec->mixers[spec->num_mixers++] = ad1988_capture_mixers;
2692 spec->init_verbs[spec->num_init_verbs++] = ad1988_capture_init_verbs;
2693 if (spec->multiout.dig_out_nid) {
2694 spec->mixers[spec->num_mixers++] = ad1988_spdif_out_mixers;
2695 spec->init_verbs[spec->num_init_verbs++] = ad1988_spdif_init_verbs;
2697 if (spec->dig_in_nid)
2698 spec->mixers[spec->num_mixers++] = ad1988_spdif_in_mixers;
2700 codec->patch_ops = ad198x_patch_ops;
2701 switch (board_config) {
2703 codec->patch_ops.init = ad1988_auto_init;
2706 case AD1988_LAPTOP_DIG:
2707 codec->patch_ops.unsol_event = ad1988_laptop_unsol_event;
2710 #ifdef CONFIG_SND_HDA_POWER_SAVE
2711 spec->loopback.amplist = ad1988_loopbacks;
2721 * port-B - front line/mic-in
2722 * port-E - aux in/out
2723 * port-F - aux in/out
2724 * port-C - rear line/mic-in
2725 * port-D - rear line/hp-out
2726 * port-A - front line/hp-out
2728 * AD1984 = AD1884 + two digital mic-ins
2731 * For simplicity, we share the single DAC for both HP and line-outs
2732 * right now. The inidividual playbacks could be easily implemented,
2733 * but no build-up framework is given, so far.
2736 static hda_nid_t ad1884_dac_nids[1] = {
2740 static hda_nid_t ad1884_adc_nids[2] = {
2744 static hda_nid_t ad1884_capsrc_nids[2] = {
2748 #define AD1884_SPDIF_OUT 0x02
2750 static struct hda_input_mux ad1884_capture_source = {
2753 { "Front Mic", 0x0 },
2760 static struct snd_kcontrol_new ad1884_base_mixers[] = {
2761 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
2762 /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */
2763 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
2764 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT),
2765 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT),
2766 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT),
2767 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
2768 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
2769 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
2770 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
2771 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT),
2772 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT),
2774 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x20, 0x03, HDA_INPUT),
2775 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x20, 0x03, HDA_INPUT),
2776 HDA_CODEC_VOLUME("Digital Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
2777 HDA_CODEC_MUTE("Digital Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
2779 HDA_CODEC_VOLUME("Mic Boost", 0x15, 0x0, HDA_INPUT),
2780 HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT),
2781 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
2782 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
2783 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
2784 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
2786 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2787 /* The multiple "Capture Source" controls confuse alsamixer
2788 * So call somewhat different..
2789 * FIXME: the controls appear in the "playback" view!
2791 /* .name = "Capture Source", */
2792 .name = "Input Source",
2794 .info = ad198x_mux_enum_info,
2795 .get = ad198x_mux_enum_get,
2796 .put = ad198x_mux_enum_put,
2798 /* SPDIF controls */
2799 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
2801 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2802 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
2803 /* identical with ad1983 */
2804 .info = ad1983_spdif_route_info,
2805 .get = ad1983_spdif_route_get,
2806 .put = ad1983_spdif_route_put,
2811 static struct snd_kcontrol_new ad1984_dmic_mixers[] = {
2812 HDA_CODEC_VOLUME("Digital Mic Capture Volume", 0x05, 0x0, HDA_INPUT),
2813 HDA_CODEC_MUTE("Digital Mic Capture Switch", 0x05, 0x0, HDA_INPUT),
2814 HDA_CODEC_VOLUME_IDX("Digital Mic Capture Volume", 1, 0x06, 0x0,
2816 HDA_CODEC_MUTE_IDX("Digital Mic Capture Switch", 1, 0x06, 0x0,
2822 * initialization verbs
2824 static struct hda_verb ad1884_init_verbs[] = {
2825 /* DACs; mute as default */
2826 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2827 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2828 /* Port-A (HP) mixer */
2829 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2830 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2832 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2833 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2834 /* HP selector - select DAC2 */
2835 {0x22, AC_VERB_SET_CONNECT_SEL, 0x1},
2836 /* Port-D (Line-out) mixer */
2837 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2838 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2840 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2841 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2842 /* Mono-out mixer */
2843 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2844 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2846 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2847 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2849 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
2850 /* Port-B (front mic) pin */
2851 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2852 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2853 /* Port-C (rear mic) pin */
2854 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2855 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2856 /* Analog mixer; mute as default */
2857 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2858 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2859 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2860 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2861 /* Analog Mix output amp */
2862 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
2863 /* SPDIF output selector */
2864 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */
2865 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
2869 #ifdef CONFIG_SND_HDA_POWER_SAVE
2870 static struct hda_amp_list ad1884_loopbacks[] = {
2871 { 0x20, HDA_INPUT, 0 }, /* Front Mic */
2872 { 0x20, HDA_INPUT, 1 }, /* Mic */
2873 { 0x20, HDA_INPUT, 2 }, /* CD */
2874 { 0x20, HDA_INPUT, 4 }, /* Docking */
2879 static int patch_ad1884(struct hda_codec *codec)
2881 struct ad198x_spec *spec;
2883 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2887 mutex_init(&spec->amp_mutex);
2890 spec->multiout.max_channels = 2;
2891 spec->multiout.num_dacs = ARRAY_SIZE(ad1884_dac_nids);
2892 spec->multiout.dac_nids = ad1884_dac_nids;
2893 spec->multiout.dig_out_nid = AD1884_SPDIF_OUT;
2894 spec->num_adc_nids = ARRAY_SIZE(ad1884_adc_nids);
2895 spec->adc_nids = ad1884_adc_nids;
2896 spec->capsrc_nids = ad1884_capsrc_nids;
2897 spec->input_mux = &ad1884_capture_source;
2898 spec->num_mixers = 1;
2899 spec->mixers[0] = ad1884_base_mixers;
2900 spec->num_init_verbs = 1;
2901 spec->init_verbs[0] = ad1884_init_verbs;
2902 spec->spdif_route = 0;
2903 #ifdef CONFIG_SND_HDA_POWER_SAVE
2904 spec->loopback.amplist = ad1884_loopbacks;
2907 codec->patch_ops = ad198x_patch_ops;
2913 * Lenovo Thinkpad T61/X61
2915 static struct hda_input_mux ad1984_thinkpad_capture_source = {
2919 { "Internal Mic", 0x1 },
2924 static struct snd_kcontrol_new ad1984_thinkpad_mixers[] = {
2925 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
2926 /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */
2927 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
2928 HDA_CODEC_MUTE("Speaker Playback Switch", 0x12, 0x0, HDA_OUTPUT),
2929 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
2930 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
2931 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
2932 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
2933 HDA_CODEC_VOLUME("Docking Mic Playback Volume", 0x20, 0x04, HDA_INPUT),
2934 HDA_CODEC_MUTE("Docking Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
2935 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT),
2936 HDA_CODEC_VOLUME("Internal Mic Boost", 0x15, 0x0, HDA_INPUT),
2937 HDA_CODEC_VOLUME("Docking Mic Boost", 0x25, 0x0, HDA_OUTPUT),
2938 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
2939 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
2940 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
2941 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
2942 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
2943 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
2945 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2946 /* The multiple "Capture Source" controls confuse alsamixer
2947 * So call somewhat different..
2948 * FIXME: the controls appear in the "playback" view!
2950 /* .name = "Capture Source", */
2951 .name = "Input Source",
2953 .info = ad198x_mux_enum_info,
2954 .get = ad198x_mux_enum_get,
2955 .put = ad198x_mux_enum_put,
2960 /* additional verbs */
2961 static struct hda_verb ad1984_thinkpad_init_verbs[] = {
2962 /* Port-E (docking station mic) pin */
2963 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2964 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2965 /* docking mic boost */
2966 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2967 /* Analog mixer - docking mic; mute as default */
2968 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2969 /* enable EAPD bit */
2970 {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
2974 /* Digial MIC ADC NID 0x05 + 0x06 */
2975 static int ad1984_pcm_dmic_prepare(struct hda_pcm_stream *hinfo,
2976 struct hda_codec *codec,
2977 unsigned int stream_tag,
2978 unsigned int format,
2979 struct snd_pcm_substream *substream)
2981 snd_hda_codec_setup_stream(codec, 0x05 + substream->number,
2982 stream_tag, 0, format);
2986 static int ad1984_pcm_dmic_cleanup(struct hda_pcm_stream *hinfo,
2987 struct hda_codec *codec,
2988 struct snd_pcm_substream *substream)
2990 snd_hda_codec_setup_stream(codec, 0x05 + substream->number,
2995 static struct hda_pcm_stream ad1984_pcm_dmic_capture = {
3001 .prepare = ad1984_pcm_dmic_prepare,
3002 .cleanup = ad1984_pcm_dmic_cleanup
3006 static int ad1984_build_pcms(struct hda_codec *codec)
3008 struct ad198x_spec *spec = codec->spec;
3009 struct hda_pcm *info;
3012 err = ad198x_build_pcms(codec);
3016 info = spec->pcm_rec + codec->num_pcms;
3018 info->name = "AD1984 Digital Mic";
3019 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad1984_pcm_dmic_capture;
3030 static const char *ad1984_models[AD1984_MODELS] = {
3031 [AD1984_BASIC] = "basic",
3032 [AD1984_THINKPAD] = "thinkpad",
3035 static struct snd_pci_quirk ad1984_cfg_tbl[] = {
3036 /* Lenovo Thinkpad T61/X61 */
3037 SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1984_THINKPAD),
3041 static int patch_ad1984(struct hda_codec *codec)
3043 struct ad198x_spec *spec;
3044 int board_config, err;
3046 err = patch_ad1884(codec);
3050 board_config = snd_hda_check_board_config(codec, AD1984_MODELS,
3051 ad1984_models, ad1984_cfg_tbl);
3052 switch (board_config) {
3054 /* additional digital mics */
3055 spec->mixers[spec->num_mixers++] = ad1984_dmic_mixers;
3056 codec->patch_ops.build_pcms = ad1984_build_pcms;
3058 case AD1984_THINKPAD:
3059 spec->multiout.dig_out_nid = 0;
3060 spec->input_mux = &ad1984_thinkpad_capture_source;
3061 spec->mixers[0] = ad1984_thinkpad_mixers;
3062 spec->init_verbs[spec->num_init_verbs++] = ad1984_thinkpad_init_verbs;
3072 * port-A - front hp-out
3073 * port-B - front mic-in
3074 * port-C - rear line-in, shared surr-out (3stack)
3075 * port-D - rear line-out
3076 * port-E - rear mic-in, shared clfe-out (3stack)
3077 * port-F - rear surr-out (6stack)
3078 * port-G - rear clfe-out (6stack)
3081 static hda_nid_t ad1882_dac_nids[3] = {
3085 static hda_nid_t ad1882_adc_nids[2] = {
3089 static hda_nid_t ad1882_capsrc_nids[2] = {
3093 #define AD1882_SPDIF_OUT 0x02
3095 /* list: 0x11, 0x39, 0x3a, 0x18, 0x3c, 0x3b, 0x12, 0x20 */
3096 static struct hda_input_mux ad1882_capture_source = {
3099 { "Front Mic", 0x1 },
3107 static struct snd_kcontrol_new ad1882_base_mixers[] = {
3108 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
3109 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
3110 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT),
3111 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT),
3112 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
3113 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT),
3114 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT),
3115 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT),
3116 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
3117 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3118 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
3119 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
3120 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x04, HDA_INPUT),
3121 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x04, HDA_INPUT),
3122 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT),
3123 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT),
3124 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x07, HDA_INPUT),
3125 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x07, HDA_INPUT),
3126 HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT),
3127 HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT),
3128 HDA_CODEC_VOLUME("Line-In Boost", 0x3a, 0x0, HDA_OUTPUT),
3129 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3130 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3131 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
3132 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
3134 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3135 /* The multiple "Capture Source" controls confuse alsamixer
3136 * So call somewhat different..
3137 * FIXME: the controls appear in the "playback" view!
3139 /* .name = "Capture Source", */
3140 .name = "Input Source",
3142 .info = ad198x_mux_enum_info,
3143 .get = ad198x_mux_enum_get,
3144 .put = ad198x_mux_enum_put,
3146 /* SPDIF controls */
3147 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
3149 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3150 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
3151 /* identical with ad1983 */
3152 .info = ad1983_spdif_route_info,
3153 .get = ad1983_spdif_route_get,
3154 .put = ad1983_spdif_route_put,
3159 static struct snd_kcontrol_new ad1882_3stack_mixers[] = {
3160 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3161 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x17, 1, 0x0, HDA_OUTPUT),
3162 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x17, 2, 0x0, HDA_OUTPUT),
3164 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3165 .name = "Channel Mode",
3166 .info = ad198x_ch_mode_info,
3167 .get = ad198x_ch_mode_get,
3168 .put = ad198x_ch_mode_put,
3173 static struct snd_kcontrol_new ad1882_6stack_mixers[] = {
3174 HDA_CODEC_MUTE("Surround Playback Switch", 0x16, 0x0, HDA_OUTPUT),
3175 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x24, 1, 0x0, HDA_OUTPUT),
3176 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x24, 2, 0x0, HDA_OUTPUT),
3180 static struct hda_verb ad1882_ch2_init[] = {
3181 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3182 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3183 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3184 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3185 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3186 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3190 static struct hda_verb ad1882_ch4_init[] = {
3191 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3192 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3193 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3194 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3195 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3196 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3200 static struct hda_verb ad1882_ch6_init[] = {
3201 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3202 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3203 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3204 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3205 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3206 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3210 static struct hda_channel_mode ad1882_modes[3] = {
3211 { 2, ad1882_ch2_init },
3212 { 4, ad1882_ch4_init },
3213 { 6, ad1882_ch6_init },
3217 * initialization verbs
3219 static struct hda_verb ad1882_init_verbs[] = {
3220 /* DACs; mute as default */
3221 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3222 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3223 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3224 /* Port-A (HP) mixer */
3225 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3226 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3228 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3229 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3230 /* HP selector - select DAC2 */
3231 {0x37, AC_VERB_SET_CONNECT_SEL, 0x1},
3232 /* Port-D (Line-out) mixer */
3233 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3234 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3236 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3237 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3238 /* Mono-out mixer */
3239 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3240 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3242 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3243 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3244 /* Port-B (front mic) pin */
3245 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3246 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3247 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* boost */
3248 /* Port-C (line-in) pin */
3249 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3250 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3251 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* boost */
3252 /* Port-C mixer - mute as input */
3253 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3254 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3255 /* Port-E (mic-in) pin */
3256 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3257 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3258 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* boost */
3259 /* Port-E mixer - mute as input */
3260 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3261 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3262 /* Port-F (surround) */
3263 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3264 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3266 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3267 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3268 /* Analog mixer; mute as default */
3269 /* list: 0x39, 0x3a, 0x11, 0x12, 0x3c, 0x3b, 0x18, 0x1a */
3270 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3271 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3272 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3273 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3274 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3275 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
3276 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3277 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
3278 /* Analog Mix output amp */
3279 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
3280 /* SPDIF output selector */
3281 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
3282 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */
3283 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
3287 #ifdef CONFIG_SND_HDA_POWER_SAVE
3288 static struct hda_amp_list ad1882_loopbacks[] = {
3289 { 0x20, HDA_INPUT, 0 }, /* Front Mic */
3290 { 0x20, HDA_INPUT, 1 }, /* Mic */
3291 { 0x20, HDA_INPUT, 4 }, /* Line */
3292 { 0x20, HDA_INPUT, 6 }, /* CD */
3304 static const char *ad1882_models[AD1986A_MODELS] = {
3305 [AD1882_3STACK] = "3stack",
3306 [AD1882_6STACK] = "6stack",
3310 static int patch_ad1882(struct hda_codec *codec)
3312 struct ad198x_spec *spec;
3315 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3319 mutex_init(&spec->amp_mutex);
3322 spec->multiout.max_channels = 6;
3323 spec->multiout.num_dacs = 3;
3324 spec->multiout.dac_nids = ad1882_dac_nids;
3325 spec->multiout.dig_out_nid = AD1882_SPDIF_OUT;
3326 spec->num_adc_nids = ARRAY_SIZE(ad1882_adc_nids);
3327 spec->adc_nids = ad1882_adc_nids;
3328 spec->capsrc_nids = ad1882_capsrc_nids;
3329 spec->input_mux = &ad1882_capture_source;
3330 spec->num_mixers = 1;
3331 spec->mixers[0] = ad1882_base_mixers;
3332 spec->num_init_verbs = 1;
3333 spec->init_verbs[0] = ad1882_init_verbs;
3334 spec->spdif_route = 0;
3335 #ifdef CONFIG_SND_HDA_POWER_SAVE
3336 spec->loopback.amplist = ad1882_loopbacks;
3339 codec->patch_ops = ad198x_patch_ops;
3341 /* override some parameters */
3342 board_config = snd_hda_check_board_config(codec, AD1882_MODELS,
3343 ad1882_models, NULL);
3344 switch (board_config) {
3347 spec->num_mixers = 2;
3348 spec->mixers[1] = ad1882_3stack_mixers;
3349 spec->channel_mode = ad1882_modes;
3350 spec->num_channel_mode = ARRAY_SIZE(ad1882_modes);
3351 spec->need_dac_fix = 1;
3352 spec->multiout.max_channels = 2;
3353 spec->multiout.num_dacs = 1;
3356 spec->num_mixers = 2;
3357 spec->mixers[1] = ad1882_6stack_mixers;
3367 struct hda_codec_preset snd_hda_preset_analog[] = {
3368 { .id = 0x11d41882, .name = "AD1882", .patch = patch_ad1882 },
3369 { .id = 0x11d41884, .name = "AD1884", .patch = patch_ad1884 },
3370 { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 },
3371 { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 },
3372 { .id = 0x11d41984, .name = "AD1984", .patch = patch_ad1984 },
3373 { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a },
3374 { .id = 0x11d41988, .name = "AD1988", .patch = patch_ad1988 },
3375 { .id = 0x11d4198b, .name = "AD1988B", .patch = patch_ad1988 },