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 <linux/init.h>
23 #include <linux/delay.h>
24 #include <linux/slab.h>
25 #include <linux/pci.h>
27 #include <sound/core.h>
28 #include "hda_codec.h"
29 #include "hda_local.h"
33 struct snd_kcontrol_new *mixers[5];
35 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
36 const struct hda_verb *init_verbs[5]; /* initialization verbs
37 * don't forget NULL termination!
39 unsigned int num_init_verbs;
42 struct hda_multi_out multiout; /* playback set-up
43 * max_channels, dacs must be set
44 * dig_out_nid and hp_nid are optional
46 unsigned int cur_eapd;
47 unsigned int need_dac_fix;
49 hda_nid_t *alt_dac_nid;
50 struct hda_pcm_stream *stream_analog_alt_playback;
53 unsigned int num_adc_nids;
55 hda_nid_t dig_in_nid; /* digital-in NID; optional */
58 const struct hda_input_mux *input_mux;
59 hda_nid_t *capsrc_nids;
60 unsigned int cur_mux[3];
63 const struct hda_channel_mode *channel_mode;
67 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
69 unsigned int spdif_route;
71 /* dynamic controls, init_verbs and input_mux */
72 struct auto_pin_cfg autocfg;
73 struct snd_array kctls;
74 struct hda_input_mux private_imux;
75 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
77 unsigned int jack_present: 1;
78 unsigned int inv_jack_detect: 1;/* inverted jack-detection */
79 unsigned int inv_eapd: 1; /* inverted EAPD implementation */
80 unsigned int analog_beep: 1; /* analog beep input present */
82 #ifdef CONFIG_SND_HDA_POWER_SAVE
83 struct hda_loopback_check loopback;
85 /* for virtual master */
86 hda_nid_t vmaster_nid;
87 const char * const *slave_vols;
88 const char * const *slave_sws;
92 * input MUX handling (common part)
94 static int ad198x_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
96 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
97 struct ad198x_spec *spec = codec->spec;
99 return snd_hda_input_mux_info(spec->input_mux, uinfo);
102 static int ad198x_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
104 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
105 struct ad198x_spec *spec = codec->spec;
106 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
108 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
112 static int ad198x_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
114 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
115 struct ad198x_spec *spec = codec->spec;
116 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
118 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
119 spec->capsrc_nids[adc_idx],
120 &spec->cur_mux[adc_idx]);
124 * initialization (common callbacks)
126 static int ad198x_init(struct hda_codec *codec)
128 struct ad198x_spec *spec = codec->spec;
131 for (i = 0; i < spec->num_init_verbs; i++)
132 snd_hda_sequence_write(codec, spec->init_verbs[i]);
136 static const char * const ad_slave_vols[] = {
137 "Front Playback Volume",
138 "Surround Playback Volume",
139 "Center Playback Volume",
140 "LFE Playback Volume",
141 "Side Playback Volume",
142 "Headphone Playback Volume",
143 "Mono Playback Volume",
144 "Speaker Playback Volume",
145 "IEC958 Playback Volume",
149 static const char * const ad_slave_sws[] = {
150 "Front Playback Switch",
151 "Surround Playback Switch",
152 "Center Playback Switch",
153 "LFE Playback Switch",
154 "Side Playback Switch",
155 "Headphone Playback Switch",
156 "Mono Playback Switch",
157 "Speaker Playback Switch",
158 "IEC958 Playback Switch",
162 static const char * const ad1988_6stack_fp_slave_vols[] = {
163 "Front Playback Volume",
164 "Surround Playback Volume",
165 "Center Playback Volume",
166 "LFE Playback Volume",
167 "Side Playback Volume",
168 "IEC958 Playback Volume",
172 static const char * const ad1988_6stack_fp_slave_sws[] = {
173 "Front Playback Switch",
174 "Surround Playback Switch",
175 "Center Playback Switch",
176 "LFE Playback Switch",
177 "Side Playback Switch",
178 "IEC958 Playback Switch",
181 static void ad198x_free_kctls(struct hda_codec *codec);
183 #ifdef CONFIG_SND_HDA_INPUT_BEEP
184 /* additional beep mixers; the actual parameters are overwritten at build */
185 static struct snd_kcontrol_new ad_beep_mixer[] = {
186 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_OUTPUT),
187 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_OUTPUT),
191 static struct snd_kcontrol_new ad_beep2_mixer[] = {
192 HDA_CODEC_VOLUME("Digital Beep Playback Volume", 0, 0, HDA_OUTPUT),
193 HDA_CODEC_MUTE_BEEP("Digital Beep Playback Switch", 0, 0, HDA_OUTPUT),
197 #define set_beep_amp(spec, nid, idx, dir) \
198 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir)) /* mono */
200 #define set_beep_amp(spec, nid, idx, dir) /* NOP */
203 static int ad198x_build_controls(struct hda_codec *codec)
205 struct ad198x_spec *spec = codec->spec;
206 struct snd_kcontrol *kctl;
210 for (i = 0; i < spec->num_mixers; i++) {
211 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
215 if (spec->multiout.dig_out_nid) {
216 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
219 err = snd_hda_create_spdif_share_sw(codec,
223 spec->multiout.share_spdif = 1;
225 if (spec->dig_in_nid) {
226 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
231 /* create beep controls if needed */
232 #ifdef CONFIG_SND_HDA_INPUT_BEEP
233 if (spec->beep_amp) {
234 struct snd_kcontrol_new *knew;
235 knew = spec->analog_beep ? ad_beep2_mixer : ad_beep_mixer;
236 for ( ; knew->name; knew++) {
237 struct snd_kcontrol *kctl;
238 kctl = snd_ctl_new1(knew, codec);
241 kctl->private_value = spec->beep_amp;
242 err = snd_hda_ctl_add(codec, 0, kctl);
249 /* if we have no master control, let's create it */
250 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
251 unsigned int vmaster_tlv[4];
252 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
253 HDA_OUTPUT, vmaster_tlv);
254 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
257 spec->slave_vols : ad_slave_vols));
261 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
262 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
265 spec->slave_sws : ad_slave_sws));
270 ad198x_free_kctls(codec); /* no longer needed */
272 /* assign Capture Source enums to NID */
273 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
275 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
276 for (i = 0; kctl && i < kctl->count; i++) {
277 err = snd_hda_add_nid(codec, kctl, i, spec->capsrc_nids[i]);
282 /* assign IEC958 enums to NID */
283 kctl = snd_hda_find_mixer_ctl(codec,
284 SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source");
286 err = snd_hda_add_nid(codec, kctl, 0,
287 spec->multiout.dig_out_nid);
295 #ifdef CONFIG_SND_HDA_POWER_SAVE
296 static int ad198x_check_power_status(struct hda_codec *codec, hda_nid_t nid)
298 struct ad198x_spec *spec = codec->spec;
299 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
304 * Analog playback callbacks
306 static int ad198x_playback_pcm_open(struct hda_pcm_stream *hinfo,
307 struct hda_codec *codec,
308 struct snd_pcm_substream *substream)
310 struct ad198x_spec *spec = codec->spec;
311 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
315 static int ad198x_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
316 struct hda_codec *codec,
317 unsigned int stream_tag,
319 struct snd_pcm_substream *substream)
321 struct ad198x_spec *spec = codec->spec;
322 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
326 static int ad198x_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
327 struct hda_codec *codec,
328 struct snd_pcm_substream *substream)
330 struct ad198x_spec *spec = codec->spec;
331 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
334 static int ad198x_alt_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
335 struct hda_codec *codec,
336 unsigned int stream_tag,
338 struct snd_pcm_substream *substream)
340 struct ad198x_spec *spec = codec->spec;
341 snd_hda_codec_setup_stream(codec, spec->alt_dac_nid[0], stream_tag,
346 static int ad198x_alt_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
347 struct hda_codec *codec,
348 struct snd_pcm_substream *substream)
350 struct ad198x_spec *spec = codec->spec;
351 snd_hda_codec_cleanup_stream(codec, spec->alt_dac_nid[0]);
355 static struct hda_pcm_stream ad198x_pcm_analog_alt_playback = {
359 /* NID is set in ad198x_build_pcms */
361 .prepare = ad198x_alt_playback_pcm_prepare,
362 .cleanup = ad198x_alt_playback_pcm_cleanup
369 static int ad198x_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
370 struct hda_codec *codec,
371 struct snd_pcm_substream *substream)
373 struct ad198x_spec *spec = codec->spec;
374 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
377 static int ad198x_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
378 struct hda_codec *codec,
379 struct snd_pcm_substream *substream)
381 struct ad198x_spec *spec = codec->spec;
382 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
385 static int ad198x_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
386 struct hda_codec *codec,
387 unsigned int stream_tag,
389 struct snd_pcm_substream *substream)
391 struct ad198x_spec *spec = codec->spec;
392 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag,
396 static int ad198x_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
397 struct hda_codec *codec,
398 struct snd_pcm_substream *substream)
400 struct ad198x_spec *spec = codec->spec;
401 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
407 static int ad198x_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
408 struct hda_codec *codec,
409 unsigned int stream_tag,
411 struct snd_pcm_substream *substream)
413 struct ad198x_spec *spec = codec->spec;
414 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
415 stream_tag, 0, format);
419 static int ad198x_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
420 struct hda_codec *codec,
421 struct snd_pcm_substream *substream)
423 struct ad198x_spec *spec = codec->spec;
424 snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
431 static struct hda_pcm_stream ad198x_pcm_analog_playback = {
434 .channels_max = 6, /* changed later */
435 .nid = 0, /* fill later */
437 .open = ad198x_playback_pcm_open,
438 .prepare = ad198x_playback_pcm_prepare,
439 .cleanup = ad198x_playback_pcm_cleanup
443 static struct hda_pcm_stream ad198x_pcm_analog_capture = {
447 .nid = 0, /* fill later */
449 .prepare = ad198x_capture_pcm_prepare,
450 .cleanup = ad198x_capture_pcm_cleanup
454 static struct hda_pcm_stream ad198x_pcm_digital_playback = {
458 .nid = 0, /* fill later */
460 .open = ad198x_dig_playback_pcm_open,
461 .close = ad198x_dig_playback_pcm_close,
462 .prepare = ad198x_dig_playback_pcm_prepare,
463 .cleanup = ad198x_dig_playback_pcm_cleanup
467 static struct hda_pcm_stream ad198x_pcm_digital_capture = {
471 /* NID is set in alc_build_pcms */
474 static int ad198x_build_pcms(struct hda_codec *codec)
476 struct ad198x_spec *spec = codec->spec;
477 struct hda_pcm *info = spec->pcm_rec;
480 codec->pcm_info = info;
482 info->name = "AD198x Analog";
483 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_analog_playback;
484 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->multiout.max_channels;
485 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
486 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_analog_capture;
487 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adc_nids;
488 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
490 if (spec->multiout.dig_out_nid) {
493 info->name = "AD198x Digital";
494 info->pcm_type = HDA_PCM_TYPE_SPDIF;
495 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_digital_playback;
496 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
497 if (spec->dig_in_nid) {
498 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_digital_capture;
499 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
503 if (spec->alt_dac_nid && spec->stream_analog_alt_playback) {
505 info = spec->pcm_rec + 2;
506 info->name = "AD198x Headphone";
507 info->pcm_type = HDA_PCM_TYPE_AUDIO;
508 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
509 *spec->stream_analog_alt_playback;
510 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
511 spec->alt_dac_nid[0];
517 static inline void ad198x_shutup(struct hda_codec *codec)
519 snd_hda_shutup_pins(codec);
522 static void ad198x_free_kctls(struct hda_codec *codec)
524 struct ad198x_spec *spec = codec->spec;
526 if (spec->kctls.list) {
527 struct snd_kcontrol_new *kctl = spec->kctls.list;
529 for (i = 0; i < spec->kctls.used; i++)
532 snd_array_free(&spec->kctls);
535 static void ad198x_power_eapd_write(struct hda_codec *codec, hda_nid_t front,
538 struct ad198x_spec *spec = codec->spec;
539 snd_hda_codec_write(codec, front, 0, AC_VERB_SET_EAPD_BTLENABLE,
540 !spec->inv_eapd ? 0x00 : 0x02);
541 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_EAPD_BTLENABLE,
542 !spec->inv_eapd ? 0x00 : 0x02);
545 static void ad198x_power_eapd(struct hda_codec *codec)
547 /* We currently only handle front, HP */
548 switch (codec->vendor_id) {
557 ad198x_power_eapd_write(codec, 0x12, 0x11);
561 ad198x_power_eapd_write(codec, 0x05, 0x06);
564 ad198x_power_eapd_write(codec, 0x1b, 0x1a);
570 ad198x_power_eapd_write(codec, 0x29, 0x22);
575 static void ad198x_free(struct hda_codec *codec)
577 struct ad198x_spec *spec = codec->spec;
582 ad198x_shutup(codec);
583 ad198x_free_kctls(codec);
585 snd_hda_detach_beep_device(codec);
588 #ifdef SND_HDA_NEEDS_RESUME
589 static int ad198x_suspend(struct hda_codec *codec, pm_message_t state)
591 ad198x_shutup(codec);
592 ad198x_power_eapd(codec);
597 static struct hda_codec_ops ad198x_patch_ops = {
598 .build_controls = ad198x_build_controls,
599 .build_pcms = ad198x_build_pcms,
602 #ifdef CONFIG_SND_HDA_POWER_SAVE
603 .check_power_status = ad198x_check_power_status,
605 #ifdef SND_HDA_NEEDS_RESUME
606 .suspend = ad198x_suspend,
608 .reboot_notify = ad198x_shutup,
614 * the private value = nid
616 #define ad198x_eapd_info snd_ctl_boolean_mono_info
618 static int ad198x_eapd_get(struct snd_kcontrol *kcontrol,
619 struct snd_ctl_elem_value *ucontrol)
621 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
622 struct ad198x_spec *spec = codec->spec;
624 ucontrol->value.integer.value[0] = ! spec->cur_eapd;
626 ucontrol->value.integer.value[0] = spec->cur_eapd;
630 static int ad198x_eapd_put(struct snd_kcontrol *kcontrol,
631 struct snd_ctl_elem_value *ucontrol)
633 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
634 struct ad198x_spec *spec = codec->spec;
635 hda_nid_t nid = kcontrol->private_value & 0xff;
637 eapd = !!ucontrol->value.integer.value[0];
640 if (eapd == spec->cur_eapd)
642 spec->cur_eapd = eapd;
643 snd_hda_codec_write_cache(codec, nid,
644 0, AC_VERB_SET_EAPD_BTLENABLE,
649 static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol,
650 struct snd_ctl_elem_info *uinfo);
651 static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol,
652 struct snd_ctl_elem_value *ucontrol);
653 static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol,
654 struct snd_ctl_elem_value *ucontrol);
661 #define AD1986A_SPDIF_OUT 0x02
662 #define AD1986A_FRONT_DAC 0x03
663 #define AD1986A_SURR_DAC 0x04
664 #define AD1986A_CLFE_DAC 0x05
665 #define AD1986A_ADC 0x06
667 static hda_nid_t ad1986a_dac_nids[3] = {
668 AD1986A_FRONT_DAC, AD1986A_SURR_DAC, AD1986A_CLFE_DAC
670 static hda_nid_t ad1986a_adc_nids[1] = { AD1986A_ADC };
671 static hda_nid_t ad1986a_capsrc_nids[1] = { 0x12 };
673 static struct hda_input_mux ad1986a_capture_source = {
687 static struct hda_bind_ctls ad1986a_bind_pcm_vol = {
688 .ops = &snd_hda_bind_vol,
690 HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT),
691 HDA_COMPOSE_AMP_VAL(AD1986A_SURR_DAC, 3, 0, HDA_OUTPUT),
692 HDA_COMPOSE_AMP_VAL(AD1986A_CLFE_DAC, 3, 0, HDA_OUTPUT),
697 static struct hda_bind_ctls ad1986a_bind_pcm_sw = {
698 .ops = &snd_hda_bind_sw,
700 HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT),
701 HDA_COMPOSE_AMP_VAL(AD1986A_SURR_DAC, 3, 0, HDA_OUTPUT),
702 HDA_COMPOSE_AMP_VAL(AD1986A_CLFE_DAC, 3, 0, HDA_OUTPUT),
710 static struct snd_kcontrol_new ad1986a_mixers[] = {
712 * bind volumes/mutes of 3 DACs as a single PCM control for simplicity
714 HDA_BIND_VOL("PCM Playback Volume", &ad1986a_bind_pcm_vol),
715 HDA_BIND_SW("PCM Playback Switch", &ad1986a_bind_pcm_sw),
716 HDA_CODEC_VOLUME("Front Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
717 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
718 HDA_CODEC_VOLUME("Surround Playback Volume", 0x1c, 0x0, HDA_OUTPUT),
719 HDA_CODEC_MUTE("Surround Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
720 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x1d, 1, 0x0, HDA_OUTPUT),
721 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x1d, 2, 0x0, HDA_OUTPUT),
722 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x1d, 1, 0x0, HDA_OUTPUT),
723 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x1d, 2, 0x0, HDA_OUTPUT),
724 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT),
725 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
726 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT),
727 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT),
728 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT),
729 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT),
730 HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT),
731 HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT),
732 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
733 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
734 HDA_CODEC_VOLUME("Mic Boost Volume", 0x0f, 0x0, HDA_OUTPUT),
735 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
736 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT),
737 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
738 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
740 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
741 .name = "Capture Source",
742 .info = ad198x_mux_enum_info,
743 .get = ad198x_mux_enum_get,
744 .put = ad198x_mux_enum_put,
746 HDA_CODEC_MUTE("Stereo Downmix Switch", 0x09, 0x0, HDA_OUTPUT),
750 /* additional mixers for 3stack mode */
751 static struct snd_kcontrol_new ad1986a_3st_mixers[] = {
753 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
754 .name = "Channel Mode",
755 .info = ad198x_ch_mode_info,
756 .get = ad198x_ch_mode_get,
757 .put = ad198x_ch_mode_put,
762 /* laptop model - 2ch only */
763 static hda_nid_t ad1986a_laptop_dac_nids[1] = { AD1986A_FRONT_DAC };
765 /* master controls both pins 0x1a and 0x1b */
766 static struct hda_bind_ctls ad1986a_laptop_master_vol = {
767 .ops = &snd_hda_bind_vol,
769 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT),
770 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
775 static struct hda_bind_ctls ad1986a_laptop_master_sw = {
776 .ops = &snd_hda_bind_sw,
778 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT),
779 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
784 static struct snd_kcontrol_new ad1986a_laptop_mixers[] = {
785 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
786 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
787 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol),
788 HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw),
789 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT),
790 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT),
791 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT),
792 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT),
793 HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT),
794 HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT),
795 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
796 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
797 HDA_CODEC_VOLUME("Mic Boost Volume", 0x0f, 0x0, HDA_OUTPUT),
799 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
800 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), */
801 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
802 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
804 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
805 .name = "Capture Source",
806 .info = ad198x_mux_enum_info,
807 .get = ad198x_mux_enum_get,
808 .put = ad198x_mux_enum_put,
813 /* laptop-eapd model - 2ch only */
815 static struct hda_input_mux ad1986a_laptop_eapd_capture_source = {
819 { "Internal Mic", 0x4 },
824 static struct hda_input_mux ad1986a_automic_capture_source = {
832 static struct snd_kcontrol_new ad1986a_laptop_master_mixers[] = {
833 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol),
834 HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw),
838 static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = {
839 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
840 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
841 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
842 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
843 HDA_CODEC_VOLUME("Mic Boost Volume", 0x0f, 0x0, HDA_OUTPUT),
844 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
845 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
847 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
848 .name = "Capture Source",
849 .info = ad198x_mux_enum_info,
850 .get = ad198x_mux_enum_get,
851 .put = ad198x_mux_enum_put,
854 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
855 .name = "External Amplifier",
856 .subdevice = HDA_SUBDEV_NID_FLAG | 0x1b,
857 .info = ad198x_eapd_info,
858 .get = ad198x_eapd_get,
859 .put = ad198x_eapd_put,
860 .private_value = 0x1b, /* port-D */
865 static struct snd_kcontrol_new ad1986a_laptop_intmic_mixers[] = {
866 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0, HDA_OUTPUT),
867 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0, HDA_OUTPUT),
871 /* re-connect the mic boost input according to the jack sensing */
872 static void ad1986a_automic(struct hda_codec *codec)
874 unsigned int present;
875 present = snd_hda_jack_detect(codec, 0x1f);
876 /* 0 = 0x1f, 2 = 0x1d, 4 = mixed */
877 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_CONNECT_SEL,
881 #define AD1986A_MIC_EVENT 0x36
883 static void ad1986a_automic_unsol_event(struct hda_codec *codec,
886 if ((res >> 26) != AD1986A_MIC_EVENT)
888 ad1986a_automic(codec);
891 static int ad1986a_automic_init(struct hda_codec *codec)
894 ad1986a_automic(codec);
898 /* laptop-automute - 2ch only */
900 static void ad1986a_update_hp(struct hda_codec *codec)
902 struct ad198x_spec *spec = codec->spec;
905 if (spec->jack_present)
906 mute = HDA_AMP_MUTE; /* mute internal speaker */
908 /* unmute internal speaker if necessary */
909 mute = snd_hda_codec_amp_read(codec, 0x1a, 0, HDA_OUTPUT, 0);
910 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
914 static void ad1986a_hp_automute(struct hda_codec *codec)
916 struct ad198x_spec *spec = codec->spec;
918 spec->jack_present = snd_hda_jack_detect(codec, 0x1a);
919 if (spec->inv_jack_detect)
920 spec->jack_present = !spec->jack_present;
921 ad1986a_update_hp(codec);
924 #define AD1986A_HP_EVENT 0x37
926 static void ad1986a_hp_unsol_event(struct hda_codec *codec, unsigned int res)
928 if ((res >> 26) != AD1986A_HP_EVENT)
930 ad1986a_hp_automute(codec);
933 static int ad1986a_hp_init(struct hda_codec *codec)
936 ad1986a_hp_automute(codec);
940 /* bind hp and internal speaker mute (with plug check) */
941 static int ad1986a_hp_master_sw_put(struct snd_kcontrol *kcontrol,
942 struct snd_ctl_elem_value *ucontrol)
944 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
945 long *valp = ucontrol->value.integer.value;
948 change = snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0,
950 valp[0] ? 0 : HDA_AMP_MUTE);
951 change |= snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0,
953 valp[1] ? 0 : HDA_AMP_MUTE);
955 ad1986a_update_hp(codec);
959 static struct snd_kcontrol_new ad1986a_automute_master_mixers[] = {
960 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol),
962 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
963 .name = "Master Playback Switch",
964 .subdevice = HDA_SUBDEV_AMP_FLAG,
965 .info = snd_hda_mixer_amp_switch_info,
966 .get = snd_hda_mixer_amp_switch_get,
967 .put = ad1986a_hp_master_sw_put,
968 .private_value = HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT),
975 * initialization verbs
977 static struct hda_verb ad1986a_init_verbs[] = {
978 /* Front, Surround, CLFE DAC; mute as default */
979 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
980 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
981 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
983 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
984 /* HP, Line-Out, Surround, CLFE selectors */
985 {0x0a, AC_VERB_SET_CONNECT_SEL, 0x0},
986 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x0},
987 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0},
988 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
990 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x0},
991 /* Mic selector: Mic 1/2 pin */
992 {0x0f, AC_VERB_SET_CONNECT_SEL, 0x0},
993 /* Line-in selector: Line-in */
994 {0x10, AC_VERB_SET_CONNECT_SEL, 0x0},
996 {0x11, AC_VERB_SET_CONNECT_SEL, 0x0},
997 /* Record selector: mic */
998 {0x12, AC_VERB_SET_CONNECT_SEL, 0x0},
999 /* Mic, Phone, CD, Aux, Line-In amp; mute as default */
1000 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1001 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1002 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1003 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1004 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1006 {0x18, AC_VERB_SET_CONNECT_SEL, 0x0},
1007 /* HP, Line-Out, Surround, CLFE, Mono pins; mute as default */
1008 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1009 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1010 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1011 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1012 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1014 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
1015 /* Front, Surround, CLFE Pins */
1016 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1017 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1018 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1020 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1022 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
1023 /* Line, Aux, CD, Beep-In Pin */
1024 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
1025 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
1026 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
1027 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
1028 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
1032 static struct hda_verb ad1986a_ch2_init[] = {
1033 /* Surround out -> Line In */
1034 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1035 /* Line-in selectors */
1036 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x1 },
1037 /* CLFE -> Mic in */
1038 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1039 /* Mic selector, mix C/LFE (backmic) and Mic (frontmic) */
1040 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 },
1044 static struct hda_verb ad1986a_ch4_init[] = {
1045 /* Surround out -> Surround */
1046 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1047 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
1048 /* CLFE -> Mic in */
1049 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1050 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 },
1054 static struct hda_verb ad1986a_ch6_init[] = {
1055 /* Surround out -> Surround out */
1056 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1057 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
1059 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1060 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x0 },
1064 static struct hda_channel_mode ad1986a_modes[3] = {
1065 { 2, ad1986a_ch2_init },
1066 { 4, ad1986a_ch4_init },
1067 { 6, ad1986a_ch6_init },
1070 /* eapd initialization */
1071 static struct hda_verb ad1986a_eapd_init_verbs[] = {
1072 {0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00 },
1076 static struct hda_verb ad1986a_automic_verbs[] = {
1077 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1078 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1079 /*{0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},*/
1080 {0x0f, AC_VERB_SET_CONNECT_SEL, 0x0},
1081 {0x1f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1986A_MIC_EVENT},
1085 /* Ultra initialization */
1086 static struct hda_verb ad1986a_ultra_init[] = {
1087 /* eapd initialization */
1088 { 0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00 },
1089 /* CLFE -> Mic in */
1090 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2 },
1091 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
1092 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
1096 /* pin sensing on HP jack */
1097 static struct hda_verb ad1986a_hp_init_verbs[] = {
1098 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1986A_HP_EVENT},
1102 static void ad1986a_samsung_p50_unsol_event(struct hda_codec *codec,
1105 switch (res >> 26) {
1106 case AD1986A_HP_EVENT:
1107 ad1986a_hp_automute(codec);
1109 case AD1986A_MIC_EVENT:
1110 ad1986a_automic(codec);
1115 static int ad1986a_samsung_p50_init(struct hda_codec *codec)
1118 ad1986a_hp_automute(codec);
1119 ad1986a_automic(codec);
1129 AD1986A_LAPTOP_EAPD,
1130 AD1986A_LAPTOP_AUTOMUTE,
1133 AD1986A_SAMSUNG_P50,
1137 static const char * const ad1986a_models[AD1986A_MODELS] = {
1138 [AD1986A_6STACK] = "6stack",
1139 [AD1986A_3STACK] = "3stack",
1140 [AD1986A_LAPTOP] = "laptop",
1141 [AD1986A_LAPTOP_EAPD] = "laptop-eapd",
1142 [AD1986A_LAPTOP_AUTOMUTE] = "laptop-automute",
1143 [AD1986A_ULTRA] = "ultra",
1144 [AD1986A_SAMSUNG] = "samsung",
1145 [AD1986A_SAMSUNG_P50] = "samsung-p50",
1148 static struct snd_pci_quirk ad1986a_cfg_tbl[] = {
1149 SND_PCI_QUIRK(0x103c, 0x30af, "HP B2800", AD1986A_LAPTOP_EAPD),
1150 SND_PCI_QUIRK(0x1043, 0x1153, "ASUS M9", AD1986A_LAPTOP_EAPD),
1151 SND_PCI_QUIRK(0x1043, 0x11f7, "ASUS U5A", AD1986A_LAPTOP_EAPD),
1152 SND_PCI_QUIRK(0x1043, 0x1213, "ASUS A6J", AD1986A_LAPTOP_EAPD),
1153 SND_PCI_QUIRK(0x1043, 0x1263, "ASUS U5F", AD1986A_LAPTOP_EAPD),
1154 SND_PCI_QUIRK(0x1043, 0x1297, "ASUS Z62F", AD1986A_LAPTOP_EAPD),
1155 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS V1j", AD1986A_LAPTOP_EAPD),
1156 SND_PCI_QUIRK(0x1043, 0x1302, "ASUS W3j", AD1986A_LAPTOP_EAPD),
1157 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS VX1", AD1986A_LAPTOP),
1158 SND_PCI_QUIRK(0x1043, 0x1447, "ASUS A8J", AD1986A_3STACK),
1159 SND_PCI_QUIRK(0x1043, 0x817f, "ASUS P5", AD1986A_3STACK),
1160 SND_PCI_QUIRK(0x1043, 0x818f, "ASUS P5", AD1986A_LAPTOP),
1161 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS P5", AD1986A_3STACK),
1162 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS M2N", AD1986A_3STACK),
1163 SND_PCI_QUIRK(0x1043, 0x8234, "ASUS M2N", AD1986A_3STACK),
1164 SND_PCI_QUIRK(0x10de, 0xcb84, "ASUS A8N-VM", AD1986A_3STACK),
1165 SND_PCI_QUIRK(0x1179, 0xff40, "Toshiba Satellite L40-10Q", AD1986A_3STACK),
1166 SND_PCI_QUIRK(0x144d, 0xb03c, "Samsung R55", AD1986A_3STACK),
1167 SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP),
1168 SND_PCI_QUIRK(0x144d, 0xc024, "Samsung P50", AD1986A_SAMSUNG_P50),
1169 SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_ULTRA),
1170 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc000, "Samsung", AD1986A_SAMSUNG),
1171 SND_PCI_QUIRK(0x144d, 0xc504, "Samsung Q35", AD1986A_3STACK),
1172 SND_PCI_QUIRK(0x17aa, 0x1011, "Lenovo M55", AD1986A_LAPTOP),
1173 SND_PCI_QUIRK(0x17aa, 0x1017, "Lenovo A60", AD1986A_3STACK),
1174 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo N100", AD1986A_LAPTOP_AUTOMUTE),
1175 SND_PCI_QUIRK(0x17c0, 0x2017, "Samsung M50", AD1986A_LAPTOP),
1179 #ifdef CONFIG_SND_HDA_POWER_SAVE
1180 static struct hda_amp_list ad1986a_loopbacks[] = {
1181 { 0x13, HDA_OUTPUT, 0 }, /* Mic */
1182 { 0x14, HDA_OUTPUT, 0 }, /* Phone */
1183 { 0x15, HDA_OUTPUT, 0 }, /* CD */
1184 { 0x16, HDA_OUTPUT, 0 }, /* Aux */
1185 { 0x17, HDA_OUTPUT, 0 }, /* Line */
1190 static int is_jack_available(struct hda_codec *codec, hda_nid_t nid)
1192 unsigned int conf = snd_hda_codec_get_pincfg(codec, nid);
1193 return get_defcfg_connect(conf) != AC_JACK_PORT_NONE;
1196 static int patch_ad1986a(struct hda_codec *codec)
1198 struct ad198x_spec *spec;
1199 int err, board_config;
1201 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1207 err = snd_hda_attach_beep_device(codec, 0x19);
1212 set_beep_amp(spec, 0x18, 0, HDA_OUTPUT);
1214 spec->multiout.max_channels = 6;
1215 spec->multiout.num_dacs = ARRAY_SIZE(ad1986a_dac_nids);
1216 spec->multiout.dac_nids = ad1986a_dac_nids;
1217 spec->multiout.dig_out_nid = AD1986A_SPDIF_OUT;
1218 spec->num_adc_nids = 1;
1219 spec->adc_nids = ad1986a_adc_nids;
1220 spec->capsrc_nids = ad1986a_capsrc_nids;
1221 spec->input_mux = &ad1986a_capture_source;
1222 spec->num_mixers = 1;
1223 spec->mixers[0] = ad1986a_mixers;
1224 spec->num_init_verbs = 1;
1225 spec->init_verbs[0] = ad1986a_init_verbs;
1226 #ifdef CONFIG_SND_HDA_POWER_SAVE
1227 spec->loopback.amplist = ad1986a_loopbacks;
1229 spec->vmaster_nid = 0x1b;
1230 spec->inv_eapd = 1; /* AD1986A has the inverted EAPD implementation */
1232 codec->patch_ops = ad198x_patch_ops;
1234 /* override some parameters */
1235 board_config = snd_hda_check_board_config(codec, AD1986A_MODELS,
1238 switch (board_config) {
1239 case AD1986A_3STACK:
1240 spec->num_mixers = 2;
1241 spec->mixers[1] = ad1986a_3st_mixers;
1242 spec->num_init_verbs = 2;
1243 spec->init_verbs[1] = ad1986a_ch2_init;
1244 spec->channel_mode = ad1986a_modes;
1245 spec->num_channel_mode = ARRAY_SIZE(ad1986a_modes);
1246 spec->need_dac_fix = 1;
1247 spec->multiout.max_channels = 2;
1248 spec->multiout.num_dacs = 1;
1250 case AD1986A_LAPTOP:
1251 spec->mixers[0] = ad1986a_laptop_mixers;
1252 spec->multiout.max_channels = 2;
1253 spec->multiout.num_dacs = 1;
1254 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
1256 case AD1986A_LAPTOP_EAPD:
1257 spec->num_mixers = 3;
1258 spec->mixers[0] = ad1986a_laptop_master_mixers;
1259 spec->mixers[1] = ad1986a_laptop_eapd_mixers;
1260 spec->mixers[2] = ad1986a_laptop_intmic_mixers;
1261 spec->num_init_verbs = 2;
1262 spec->init_verbs[1] = ad1986a_eapd_init_verbs;
1263 spec->multiout.max_channels = 2;
1264 spec->multiout.num_dacs = 1;
1265 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
1266 if (!is_jack_available(codec, 0x25))
1267 spec->multiout.dig_out_nid = 0;
1268 spec->input_mux = &ad1986a_laptop_eapd_capture_source;
1270 case AD1986A_SAMSUNG:
1271 spec->num_mixers = 2;
1272 spec->mixers[0] = ad1986a_laptop_master_mixers;
1273 spec->mixers[1] = ad1986a_laptop_eapd_mixers;
1274 spec->num_init_verbs = 3;
1275 spec->init_verbs[1] = ad1986a_eapd_init_verbs;
1276 spec->init_verbs[2] = ad1986a_automic_verbs;
1277 spec->multiout.max_channels = 2;
1278 spec->multiout.num_dacs = 1;
1279 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
1280 if (!is_jack_available(codec, 0x25))
1281 spec->multiout.dig_out_nid = 0;
1282 spec->input_mux = &ad1986a_automic_capture_source;
1283 codec->patch_ops.unsol_event = ad1986a_automic_unsol_event;
1284 codec->patch_ops.init = ad1986a_automic_init;
1286 case AD1986A_SAMSUNG_P50:
1287 spec->num_mixers = 2;
1288 spec->mixers[0] = ad1986a_automute_master_mixers;
1289 spec->mixers[1] = ad1986a_laptop_eapd_mixers;
1290 spec->num_init_verbs = 4;
1291 spec->init_verbs[1] = ad1986a_eapd_init_verbs;
1292 spec->init_verbs[2] = ad1986a_automic_verbs;
1293 spec->init_verbs[3] = ad1986a_hp_init_verbs;
1294 spec->multiout.max_channels = 2;
1295 spec->multiout.num_dacs = 1;
1296 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
1297 if (!is_jack_available(codec, 0x25))
1298 spec->multiout.dig_out_nid = 0;
1299 spec->input_mux = &ad1986a_automic_capture_source;
1300 codec->patch_ops.unsol_event = ad1986a_samsung_p50_unsol_event;
1301 codec->patch_ops.init = ad1986a_samsung_p50_init;
1303 case AD1986A_LAPTOP_AUTOMUTE:
1304 spec->num_mixers = 3;
1305 spec->mixers[0] = ad1986a_automute_master_mixers;
1306 spec->mixers[1] = ad1986a_laptop_eapd_mixers;
1307 spec->mixers[2] = ad1986a_laptop_intmic_mixers;
1308 spec->num_init_verbs = 3;
1309 spec->init_verbs[1] = ad1986a_eapd_init_verbs;
1310 spec->init_verbs[2] = ad1986a_hp_init_verbs;
1311 spec->multiout.max_channels = 2;
1312 spec->multiout.num_dacs = 1;
1313 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
1314 if (!is_jack_available(codec, 0x25))
1315 spec->multiout.dig_out_nid = 0;
1316 spec->input_mux = &ad1986a_laptop_eapd_capture_source;
1317 codec->patch_ops.unsol_event = ad1986a_hp_unsol_event;
1318 codec->patch_ops.init = ad1986a_hp_init;
1319 /* Lenovo N100 seems to report the reversed bit
1320 * for HP jack-sensing
1322 spec->inv_jack_detect = 1;
1325 spec->mixers[0] = ad1986a_laptop_eapd_mixers;
1326 spec->num_init_verbs = 2;
1327 spec->init_verbs[1] = ad1986a_ultra_init;
1328 spec->multiout.max_channels = 2;
1329 spec->multiout.num_dacs = 1;
1330 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
1331 spec->multiout.dig_out_nid = 0;
1335 /* AD1986A has a hardware problem that it can't share a stream
1336 * with multiple output pins. The copy of front to surrounds
1337 * causes noisy or silent outputs at a certain timing, e.g.
1338 * changing the volume.
1339 * So, let's disable the shared stream.
1341 spec->multiout.no_share_stream = 1;
1343 codec->no_trigger_sense = 1;
1344 codec->no_sticky_stream = 1;
1353 #define AD1983_SPDIF_OUT 0x02
1354 #define AD1983_DAC 0x03
1355 #define AD1983_ADC 0x04
1357 static hda_nid_t ad1983_dac_nids[1] = { AD1983_DAC };
1358 static hda_nid_t ad1983_adc_nids[1] = { AD1983_ADC };
1359 static hda_nid_t ad1983_capsrc_nids[1] = { 0x15 };
1361 static struct hda_input_mux ad1983_capture_source = {
1367 { "Mix Mono", 0x3 },
1372 * SPDIF playback route
1374 static int ad1983_spdif_route_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1376 static char *texts[] = { "PCM", "ADC" };
1378 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1380 uinfo->value.enumerated.items = 2;
1381 if (uinfo->value.enumerated.item > 1)
1382 uinfo->value.enumerated.item = 1;
1383 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1387 static int ad1983_spdif_route_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1389 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1390 struct ad198x_spec *spec = codec->spec;
1392 ucontrol->value.enumerated.item[0] = spec->spdif_route;
1396 static int ad1983_spdif_route_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1398 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1399 struct ad198x_spec *spec = codec->spec;
1401 if (ucontrol->value.enumerated.item[0] > 1)
1403 if (spec->spdif_route != ucontrol->value.enumerated.item[0]) {
1404 spec->spdif_route = ucontrol->value.enumerated.item[0];
1405 snd_hda_codec_write_cache(codec, spec->multiout.dig_out_nid, 0,
1406 AC_VERB_SET_CONNECT_SEL,
1413 static struct snd_kcontrol_new ad1983_mixers[] = {
1414 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT),
1415 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT),
1416 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT),
1417 HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT),
1418 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT),
1419 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT),
1420 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
1421 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
1422 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
1423 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
1424 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1425 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1426 HDA_CODEC_VOLUME("Mic Boost Volume", 0x0c, 0x0, HDA_OUTPUT),
1427 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1428 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
1430 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1431 .name = "Capture Source",
1432 .info = ad198x_mux_enum_info,
1433 .get = ad198x_mux_enum_get,
1434 .put = ad198x_mux_enum_put,
1437 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1438 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
1439 .info = ad1983_spdif_route_info,
1440 .get = ad1983_spdif_route_get,
1441 .put = ad1983_spdif_route_put,
1446 static struct hda_verb ad1983_init_verbs[] = {
1447 /* Front, HP, Mono; mute as default */
1448 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1449 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1450 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1451 /* Beep, PCM, Mic, Line-In: mute */
1452 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1453 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1454 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1455 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1456 /* Front, HP selectors; from Mix */
1457 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
1458 {0x06, AC_VERB_SET_CONNECT_SEL, 0x01},
1459 /* Mono selector; from Mix */
1460 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03},
1461 /* Mic selector; Mic */
1462 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0},
1463 /* Line-in selector: Line-in */
1464 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
1465 /* Mic boost: 0dB */
1466 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1467 /* Record selector: mic */
1468 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0},
1469 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1470 /* SPDIF route: PCM */
1471 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0},
1473 {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1475 {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
1477 {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1479 {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
1481 {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
1485 #ifdef CONFIG_SND_HDA_POWER_SAVE
1486 static struct hda_amp_list ad1983_loopbacks[] = {
1487 { 0x12, HDA_OUTPUT, 0 }, /* Mic */
1488 { 0x13, HDA_OUTPUT, 0 }, /* Line */
1493 static int patch_ad1983(struct hda_codec *codec)
1495 struct ad198x_spec *spec;
1498 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1504 err = snd_hda_attach_beep_device(codec, 0x10);
1509 set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
1511 spec->multiout.max_channels = 2;
1512 spec->multiout.num_dacs = ARRAY_SIZE(ad1983_dac_nids);
1513 spec->multiout.dac_nids = ad1983_dac_nids;
1514 spec->multiout.dig_out_nid = AD1983_SPDIF_OUT;
1515 spec->num_adc_nids = 1;
1516 spec->adc_nids = ad1983_adc_nids;
1517 spec->capsrc_nids = ad1983_capsrc_nids;
1518 spec->input_mux = &ad1983_capture_source;
1519 spec->num_mixers = 1;
1520 spec->mixers[0] = ad1983_mixers;
1521 spec->num_init_verbs = 1;
1522 spec->init_verbs[0] = ad1983_init_verbs;
1523 spec->spdif_route = 0;
1524 #ifdef CONFIG_SND_HDA_POWER_SAVE
1525 spec->loopback.amplist = ad1983_loopbacks;
1527 spec->vmaster_nid = 0x05;
1529 codec->patch_ops = ad198x_patch_ops;
1531 codec->no_trigger_sense = 1;
1532 codec->no_sticky_stream = 1;
1539 * AD1981 HD specific
1542 #define AD1981_SPDIF_OUT 0x02
1543 #define AD1981_DAC 0x03
1544 #define AD1981_ADC 0x04
1546 static hda_nid_t ad1981_dac_nids[1] = { AD1981_DAC };
1547 static hda_nid_t ad1981_adc_nids[1] = { AD1981_ADC };
1548 static hda_nid_t ad1981_capsrc_nids[1] = { 0x15 };
1550 /* 0x0c, 0x09, 0x0e, 0x0f, 0x19, 0x05, 0x18, 0x17 */
1551 static struct hda_input_mux ad1981_capture_source = {
1554 { "Front Mic", 0x0 },
1557 { "Mix Mono", 0x3 },
1564 static struct snd_kcontrol_new ad1981_mixers[] = {
1565 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT),
1566 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT),
1567 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT),
1568 HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT),
1569 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT),
1570 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT),
1571 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
1572 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
1573 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
1574 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
1575 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1576 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1577 HDA_CODEC_VOLUME("Aux Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
1578 HDA_CODEC_MUTE("Aux Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1579 HDA_CODEC_VOLUME("Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT),
1580 HDA_CODEC_MUTE("Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
1581 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1582 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1583 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x08, 0x0, HDA_INPUT),
1584 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x0, HDA_INPUT),
1585 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1586 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
1588 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1589 .name = "Capture Source",
1590 .info = ad198x_mux_enum_info,
1591 .get = ad198x_mux_enum_get,
1592 .put = ad198x_mux_enum_put,
1594 /* identical with AD1983 */
1596 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1597 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
1598 .info = ad1983_spdif_route_info,
1599 .get = ad1983_spdif_route_get,
1600 .put = ad1983_spdif_route_put,
1605 static struct hda_verb ad1981_init_verbs[] = {
1606 /* Front, HP, Mono; mute as default */
1607 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1608 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1609 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1610 /* Beep, PCM, Front Mic, Line, Rear Mic, Aux, CD-In: mute */
1611 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1612 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1613 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1614 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1615 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1616 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1617 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1618 /* Front, HP selectors; from Mix */
1619 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
1620 {0x06, AC_VERB_SET_CONNECT_SEL, 0x01},
1621 /* Mono selector; from Mix */
1622 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03},
1623 /* Mic Mixer; select Front Mic */
1624 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1625 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1626 /* Mic boost: 0dB */
1627 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1628 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1629 /* Record selector: Front mic */
1630 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0},
1631 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1632 /* SPDIF route: PCM */
1633 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0},
1635 {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1637 {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
1639 {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1640 /* Front & Rear Mic Pins */
1641 {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
1642 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
1644 {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
1646 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
1647 /* Line-Out as Input: disabled */
1648 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1652 #ifdef CONFIG_SND_HDA_POWER_SAVE
1653 static struct hda_amp_list ad1981_loopbacks[] = {
1654 { 0x12, HDA_OUTPUT, 0 }, /* Front Mic */
1655 { 0x13, HDA_OUTPUT, 0 }, /* Line */
1656 { 0x1b, HDA_OUTPUT, 0 }, /* Aux */
1657 { 0x1c, HDA_OUTPUT, 0 }, /* Mic */
1658 { 0x1d, HDA_OUTPUT, 0 }, /* CD */
1664 * Patch for HP nx6320
1666 * nx6320 uses EAPD in the reverse way - EAPD-on means the internal
1667 * speaker output enabled _and_ mute-LED off.
1670 #define AD1981_HP_EVENT 0x37
1671 #define AD1981_MIC_EVENT 0x38
1673 static struct hda_verb ad1981_hp_init_verbs[] = {
1674 {0x05, AC_VERB_SET_EAPD_BTLENABLE, 0x00 }, /* default off */
1675 /* pin sensing on HP and Mic jacks */
1676 {0x06, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_HP_EVENT},
1677 {0x08, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_MIC_EVENT},
1681 /* turn on/off EAPD (+ mute HP) as a master switch */
1682 static int ad1981_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1683 struct snd_ctl_elem_value *ucontrol)
1685 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1686 struct ad198x_spec *spec = codec->spec;
1688 if (! ad198x_eapd_put(kcontrol, ucontrol))
1690 /* change speaker pin appropriately */
1691 snd_hda_codec_write(codec, 0x05, 0,
1692 AC_VERB_SET_PIN_WIDGET_CONTROL,
1693 spec->cur_eapd ? PIN_OUT : 0);
1694 /* toggle HP mute appropriately */
1695 snd_hda_codec_amp_stereo(codec, 0x06, HDA_OUTPUT, 0,
1697 spec->cur_eapd ? 0 : HDA_AMP_MUTE);
1701 /* bind volumes of both NID 0x05 and 0x06 */
1702 static struct hda_bind_ctls ad1981_hp_bind_master_vol = {
1703 .ops = &snd_hda_bind_vol,
1705 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
1706 HDA_COMPOSE_AMP_VAL(0x06, 3, 0, HDA_OUTPUT),
1711 /* mute internal speaker if HP is plugged */
1712 static void ad1981_hp_automute(struct hda_codec *codec)
1714 unsigned int present;
1716 present = snd_hda_jack_detect(codec, 0x06);
1717 snd_hda_codec_amp_stereo(codec, 0x05, HDA_OUTPUT, 0,
1718 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
1721 /* toggle input of built-in and mic jack appropriately */
1722 static void ad1981_hp_automic(struct hda_codec *codec)
1724 static struct hda_verb mic_jack_on[] = {
1725 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1726 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1729 static struct hda_verb mic_jack_off[] = {
1730 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1731 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1734 unsigned int present;
1736 present = snd_hda_jack_detect(codec, 0x08);
1738 snd_hda_sequence_write(codec, mic_jack_on);
1740 snd_hda_sequence_write(codec, mic_jack_off);
1743 /* unsolicited event for HP jack sensing */
1744 static void ad1981_hp_unsol_event(struct hda_codec *codec,
1749 case AD1981_HP_EVENT:
1750 ad1981_hp_automute(codec);
1752 case AD1981_MIC_EVENT:
1753 ad1981_hp_automic(codec);
1758 static struct hda_input_mux ad1981_hp_capture_source = {
1762 { "Docking-Station", 0x1 },
1767 static struct snd_kcontrol_new ad1981_hp_mixers[] = {
1768 HDA_BIND_VOL("Master Playback Volume", &ad1981_hp_bind_master_vol),
1770 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1771 .subdevice = HDA_SUBDEV_NID_FLAG | 0x05,
1772 .name = "Master Playback Switch",
1773 .info = ad198x_eapd_info,
1774 .get = ad198x_eapd_get,
1775 .put = ad1981_hp_master_sw_put,
1776 .private_value = 0x05,
1778 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
1779 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
1781 /* FIXME: analog mic/line loopback doesn't work with my tests...
1782 * (although recording is OK)
1784 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
1785 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
1786 HDA_CODEC_VOLUME("Docking-Station Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1787 HDA_CODEC_MUTE("Docking-Station Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1788 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT),
1789 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
1790 /* FIXME: does this laptop have analog CD connection? */
1791 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1792 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1794 HDA_CODEC_VOLUME("Mic Boost Volume", 0x08, 0x0, HDA_INPUT),
1795 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x18, 0x0, HDA_INPUT),
1796 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1797 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
1799 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1800 .name = "Capture Source",
1801 .info = ad198x_mux_enum_info,
1802 .get = ad198x_mux_enum_get,
1803 .put = ad198x_mux_enum_put,
1808 /* initialize jack-sensing, too */
1809 static int ad1981_hp_init(struct hda_codec *codec)
1812 ad1981_hp_automute(codec);
1813 ad1981_hp_automic(codec);
1817 /* configuration for Toshiba Laptops */
1818 static struct hda_verb ad1981_toshiba_init_verbs[] = {
1819 {0x05, AC_VERB_SET_EAPD_BTLENABLE, 0x01 }, /* default on */
1820 /* pin sensing on HP and Mic jacks */
1821 {0x06, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_HP_EVENT},
1822 {0x08, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_MIC_EVENT},
1826 static struct snd_kcontrol_new ad1981_toshiba_mixers[] = {
1827 HDA_CODEC_VOLUME("Amp Volume", 0x1a, 0x0, HDA_OUTPUT),
1828 HDA_CODEC_MUTE("Amp Switch", 0x1a, 0x0, HDA_OUTPUT),
1832 /* configuration for Lenovo Thinkpad T60 */
1833 static struct snd_kcontrol_new ad1981_thinkpad_mixers[] = {
1834 HDA_CODEC_VOLUME("Master Playback Volume", 0x05, 0x0, HDA_OUTPUT),
1835 HDA_CODEC_MUTE("Master Playback Switch", 0x05, 0x0, HDA_OUTPUT),
1836 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
1837 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
1838 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
1839 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
1840 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1841 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1842 HDA_CODEC_VOLUME("Mic Boost Volume", 0x08, 0x0, HDA_INPUT),
1843 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1844 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
1846 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1847 .name = "Capture Source",
1848 .info = ad198x_mux_enum_info,
1849 .get = ad198x_mux_enum_get,
1850 .put = ad198x_mux_enum_put,
1852 /* identical with AD1983 */
1854 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1855 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
1856 .info = ad1983_spdif_route_info,
1857 .get = ad1983_spdif_route_get,
1858 .put = ad1983_spdif_route_put,
1863 static struct hda_input_mux ad1981_thinkpad_capture_source = {
1881 static const char * const ad1981_models[AD1981_MODELS] = {
1883 [AD1981_THINKPAD] = "thinkpad",
1884 [AD1981_BASIC] = "basic",
1885 [AD1981_TOSHIBA] = "toshiba"
1888 static struct snd_pci_quirk ad1981_cfg_tbl[] = {
1889 SND_PCI_QUIRK(0x1014, 0x0597, "Lenovo Z60", AD1981_THINKPAD),
1890 SND_PCI_QUIRK(0x1014, 0x05b7, "Lenovo Z60m", AD1981_THINKPAD),
1892 SND_PCI_QUIRK_VENDOR(0x103c, "HP nx", AD1981_HP),
1893 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba U205", AD1981_TOSHIBA),
1894 /* Lenovo Thinkpad T60/X60/Z6xx */
1895 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo Thinkpad", AD1981_THINKPAD),
1896 /* HP nx6320 (reversed SSID, H/W bug) */
1897 SND_PCI_QUIRK(0x30b0, 0x103c, "HP nx6320", AD1981_HP),
1901 static int patch_ad1981(struct hda_codec *codec)
1903 struct ad198x_spec *spec;
1904 int err, board_config;
1906 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1912 err = snd_hda_attach_beep_device(codec, 0x10);
1917 set_beep_amp(spec, 0x0d, 0, HDA_OUTPUT);
1919 spec->multiout.max_channels = 2;
1920 spec->multiout.num_dacs = ARRAY_SIZE(ad1981_dac_nids);
1921 spec->multiout.dac_nids = ad1981_dac_nids;
1922 spec->multiout.dig_out_nid = AD1981_SPDIF_OUT;
1923 spec->num_adc_nids = 1;
1924 spec->adc_nids = ad1981_adc_nids;
1925 spec->capsrc_nids = ad1981_capsrc_nids;
1926 spec->input_mux = &ad1981_capture_source;
1927 spec->num_mixers = 1;
1928 spec->mixers[0] = ad1981_mixers;
1929 spec->num_init_verbs = 1;
1930 spec->init_verbs[0] = ad1981_init_verbs;
1931 spec->spdif_route = 0;
1932 #ifdef CONFIG_SND_HDA_POWER_SAVE
1933 spec->loopback.amplist = ad1981_loopbacks;
1935 spec->vmaster_nid = 0x05;
1937 codec->patch_ops = ad198x_patch_ops;
1939 /* override some parameters */
1940 board_config = snd_hda_check_board_config(codec, AD1981_MODELS,
1943 switch (board_config) {
1945 spec->mixers[0] = ad1981_hp_mixers;
1946 spec->num_init_verbs = 2;
1947 spec->init_verbs[1] = ad1981_hp_init_verbs;
1948 spec->multiout.dig_out_nid = 0;
1949 spec->input_mux = &ad1981_hp_capture_source;
1951 codec->patch_ops.init = ad1981_hp_init;
1952 codec->patch_ops.unsol_event = ad1981_hp_unsol_event;
1953 /* set the upper-limit for mixer amp to 0dB for avoiding the
1954 * possible damage by overloading
1956 snd_hda_override_amp_caps(codec, 0x11, HDA_INPUT,
1957 (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
1958 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
1959 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
1960 (1 << AC_AMPCAP_MUTE_SHIFT));
1962 case AD1981_THINKPAD:
1963 spec->mixers[0] = ad1981_thinkpad_mixers;
1964 spec->input_mux = &ad1981_thinkpad_capture_source;
1965 /* set the upper-limit for mixer amp to 0dB for avoiding the
1966 * possible damage by overloading
1968 snd_hda_override_amp_caps(codec, 0x11, HDA_INPUT,
1969 (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
1970 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
1971 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
1972 (1 << AC_AMPCAP_MUTE_SHIFT));
1974 case AD1981_TOSHIBA:
1975 spec->mixers[0] = ad1981_hp_mixers;
1976 spec->mixers[1] = ad1981_toshiba_mixers;
1977 spec->num_init_verbs = 2;
1978 spec->init_verbs[1] = ad1981_toshiba_init_verbs;
1979 spec->multiout.dig_out_nid = 0;
1980 spec->input_mux = &ad1981_hp_capture_source;
1981 codec->patch_ops.init = ad1981_hp_init;
1982 codec->patch_ops.unsol_event = ad1981_hp_unsol_event;
1986 codec->no_trigger_sense = 1;
1987 codec->no_sticky_stream = 1;
1996 * Output pins and routes
1998 * Pin Mix Sel DAC (*)
1999 * port-A 0x11 (mute/hp) <- 0x22 <- 0x37 <- 03/04/06
2000 * port-B 0x14 (mute/hp) <- 0x2b <- 0x30 <- 03/04/06
2001 * port-C 0x15 (mute) <- 0x2c <- 0x31 <- 05/0a
2002 * port-D 0x12 (mute/hp) <- 0x29 <- 04
2003 * port-E 0x17 (mute/hp) <- 0x26 <- 0x32 <- 05/0a
2004 * port-F 0x16 (mute) <- 0x2a <- 06
2005 * port-G 0x24 (mute) <- 0x27 <- 05
2006 * port-H 0x25 (mute) <- 0x28 <- 0a
2007 * mono 0x13 (mute/amp)<- 0x1e <- 0x36 <- 03/04/06
2009 * DAC0 = 03h, DAC1 = 04h, DAC2 = 05h, DAC3 = 06h, DAC4 = 0ah
2010 * (*) DAC2/3/4 are swapped to DAC3/4/2 on AD198A rev.2 due to a h/w bug.
2012 * Input pins and routes
2014 * pin boost mix input # / adc input #
2015 * port-A 0x11 -> 0x38 -> mix 2, ADC 0
2016 * port-B 0x14 -> 0x39 -> mix 0, ADC 1
2017 * port-C 0x15 -> 0x3a -> 33:0 - mix 1, ADC 2
2018 * port-D 0x12 -> 0x3d -> mix 3, ADC 8
2019 * port-E 0x17 -> 0x3c -> 34:0 - mix 4, ADC 4
2020 * port-F 0x16 -> 0x3b -> mix 5, ADC 3
2021 * port-G 0x24 -> N/A -> 33:1 - mix 1, 34:1 - mix 4, ADC 6
2022 * port-H 0x25 -> N/A -> 33:2 - mix 1, 34:2 - mix 4, ADC 7
2026 * 6stack - front/surr/CLFE/side/opt DACs - 04/06/05/0a/03
2027 * 3stack - front/surr/CLFE/opt DACs - 04/05/0a/03
2029 * Inputs of Analog Mix (0x20)
2030 * 0:Port-B (front mic)
2031 * 1:Port-C/G/H (line-in)
2033 * 3:Port-D (line-in/2)
2034 * 4:Port-E/G/H (mic-in)
2035 * 5:Port-F (mic2-in)
2041 * 1:Port-B (front mic-in)
2042 * 2:Port-C (line-in)
2043 * 3:Port-F (mic2-in)
2048 * 8:Port-D (line-in/2)
2051 * Proposed pin assignments by the datasheet
2054 * Port-A front headphone
2064 * Port-A front headphone
2066 * C rear line-in/surround
2068 * E rear mic-in/CLFE
2074 * D internal speaker (with EAPD)
2075 * E/F quad mic array
2083 AD1988_6STACK_DIG_FP,
2092 /* reivision id to check workarounds */
2093 #define AD1988A_REV2 0x100200
2095 #define is_rev2(codec) \
2096 ((codec)->vendor_id == 0x11d41988 && \
2097 (codec)->revision_id == AD1988A_REV2)
2103 static hda_nid_t ad1988_6stack_dac_nids[4] = {
2104 0x04, 0x06, 0x05, 0x0a
2107 static hda_nid_t ad1988_3stack_dac_nids[3] = {
2111 /* for AD1988A revision-2, DAC2-4 are swapped */
2112 static hda_nid_t ad1988_6stack_dac_nids_rev2[4] = {
2113 0x04, 0x05, 0x0a, 0x06
2116 static hda_nid_t ad1988_alt_dac_nid[1] = {
2120 static hda_nid_t ad1988_3stack_dac_nids_rev2[3] = {
2124 static hda_nid_t ad1988_adc_nids[3] = {
2128 static hda_nid_t ad1988_capsrc_nids[3] = {
2132 #define AD1988_SPDIF_OUT 0x02
2133 #define AD1988_SPDIF_OUT_HDMI 0x0b
2134 #define AD1988_SPDIF_IN 0x07
2136 static hda_nid_t ad1989b_slave_dig_outs[] = {
2137 AD1988_SPDIF_OUT, AD1988_SPDIF_OUT_HDMI, 0
2140 static struct hda_input_mux ad1988_6stack_capture_source = {
2143 { "Front Mic", 0x1 }, /* port-B */
2144 { "Line", 0x2 }, /* port-C */
2145 { "Mic", 0x4 }, /* port-E */
2151 static struct hda_input_mux ad1988_laptop_capture_source = {
2154 { "Mic/Line", 0x1 }, /* port-B */
2162 static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol,
2163 struct snd_ctl_elem_info *uinfo)
2165 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2166 struct ad198x_spec *spec = codec->spec;
2167 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
2168 spec->num_channel_mode);
2171 static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol,
2172 struct snd_ctl_elem_value *ucontrol)
2174 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2175 struct ad198x_spec *spec = codec->spec;
2176 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
2177 spec->num_channel_mode, spec->multiout.max_channels);
2180 static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol,
2181 struct snd_ctl_elem_value *ucontrol)
2183 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2184 struct ad198x_spec *spec = codec->spec;
2185 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
2186 spec->num_channel_mode,
2187 &spec->multiout.max_channels);
2188 if (err >= 0 && spec->need_dac_fix)
2189 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
2194 static struct snd_kcontrol_new ad1988_6stack_mixers1[] = {
2195 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
2196 HDA_CODEC_VOLUME("Surround Playback Volume", 0x06, 0x0, HDA_OUTPUT),
2197 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT),
2198 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT),
2199 HDA_CODEC_VOLUME("Side Playback Volume", 0x0a, 0x0, HDA_OUTPUT),
2203 static struct snd_kcontrol_new ad1988_6stack_mixers1_rev2[] = {
2204 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
2205 HDA_CODEC_VOLUME("Surround Playback Volume", 0x05, 0x0, HDA_OUTPUT),
2206 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2207 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0a, 2, 0x0, HDA_OUTPUT),
2208 HDA_CODEC_VOLUME("Side Playback Volume", 0x06, 0x0, HDA_OUTPUT),
2212 static struct snd_kcontrol_new ad1988_6stack_mixers2[] = {
2213 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT),
2214 HDA_BIND_MUTE("Surround Playback Switch", 0x2a, 2, HDA_INPUT),
2215 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x27, 1, 2, HDA_INPUT),
2216 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x27, 2, 2, HDA_INPUT),
2217 HDA_BIND_MUTE("Side Playback Switch", 0x28, 2, HDA_INPUT),
2218 HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT),
2219 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT),
2221 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT),
2222 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT),
2223 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT),
2224 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT),
2225 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
2226 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
2227 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT),
2228 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT),
2230 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
2231 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
2233 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x39, 0x0, HDA_OUTPUT),
2234 HDA_CODEC_VOLUME("Mic Boost Volume", 0x3c, 0x0, HDA_OUTPUT),
2239 static struct snd_kcontrol_new ad1988_6stack_fp_mixers[] = {
2240 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
2242 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT),
2243 HDA_BIND_MUTE("Surround Playback Switch", 0x2a, 2, HDA_INPUT),
2244 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x27, 1, 2, HDA_INPUT),
2245 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x27, 2, 2, HDA_INPUT),
2246 HDA_BIND_MUTE("Side Playback Switch", 0x28, 2, HDA_INPUT),
2247 HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT),
2248 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT),
2250 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT),
2251 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT),
2252 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT),
2253 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT),
2254 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
2255 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
2256 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT),
2257 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT),
2259 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
2260 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
2262 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x39, 0x0, HDA_OUTPUT),
2263 HDA_CODEC_VOLUME("Mic Boost Volume", 0x3c, 0x0, HDA_OUTPUT),
2269 static struct snd_kcontrol_new ad1988_3stack_mixers1[] = {
2270 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
2271 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT),
2272 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT),
2273 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT),
2277 static struct snd_kcontrol_new ad1988_3stack_mixers1_rev2[] = {
2278 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
2279 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT),
2280 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x06, 1, 0x0, HDA_OUTPUT),
2281 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x06, 2, 0x0, HDA_OUTPUT),
2285 static struct snd_kcontrol_new ad1988_3stack_mixers2[] = {
2286 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT),
2287 HDA_BIND_MUTE("Surround Playback Switch", 0x2c, 2, HDA_INPUT),
2288 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x26, 1, 2, HDA_INPUT),
2289 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x26, 2, 2, HDA_INPUT),
2290 HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT),
2291 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT),
2293 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT),
2294 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT),
2295 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT),
2296 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT),
2297 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
2298 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
2299 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT),
2300 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT),
2302 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
2303 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
2305 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x39, 0x0, HDA_OUTPUT),
2306 HDA_CODEC_VOLUME("Mic Boost Volume", 0x3c, 0x0, HDA_OUTPUT),
2308 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2309 .name = "Channel Mode",
2310 .info = ad198x_ch_mode_info,
2311 .get = ad198x_ch_mode_get,
2312 .put = ad198x_ch_mode_put,
2319 static struct snd_kcontrol_new ad1988_laptop_mixers[] = {
2320 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
2321 HDA_CODEC_MUTE("PCM Playback Switch", 0x29, 0x0, HDA_INPUT),
2322 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT),
2324 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT),
2325 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT),
2326 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x0, HDA_INPUT),
2327 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x0, HDA_INPUT),
2328 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
2329 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
2331 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
2332 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
2334 HDA_CODEC_VOLUME("Mic Boost Volume", 0x39, 0x0, HDA_OUTPUT),
2337 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2338 .name = "External Amplifier",
2339 .subdevice = HDA_SUBDEV_NID_FLAG | 0x12,
2340 .info = ad198x_eapd_info,
2341 .get = ad198x_eapd_get,
2342 .put = ad198x_eapd_put,
2343 .private_value = 0x12, /* port-D */
2350 static struct snd_kcontrol_new ad1988_capture_mixers[] = {
2351 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
2352 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
2353 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
2354 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
2355 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x0e, 0x0, HDA_OUTPUT),
2356 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x0e, 0x0, HDA_OUTPUT),
2358 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2359 /* The multiple "Capture Source" controls confuse alsamixer
2360 * So call somewhat different..
2362 /* .name = "Capture Source", */
2363 .name = "Input Source",
2365 .info = ad198x_mux_enum_info,
2366 .get = ad198x_mux_enum_get,
2367 .put = ad198x_mux_enum_put,
2372 static int ad1988_spdif_playback_source_info(struct snd_kcontrol *kcontrol,
2373 struct snd_ctl_elem_info *uinfo)
2375 static char *texts[] = {
2376 "PCM", "ADC1", "ADC2", "ADC3"
2378 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2380 uinfo->value.enumerated.items = 4;
2381 if (uinfo->value.enumerated.item >= 4)
2382 uinfo->value.enumerated.item = 3;
2383 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2387 static int ad1988_spdif_playback_source_get(struct snd_kcontrol *kcontrol,
2388 struct snd_ctl_elem_value *ucontrol)
2390 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2393 sel = snd_hda_codec_read(codec, 0x1d, 0, AC_VERB_GET_AMP_GAIN_MUTE,
2396 ucontrol->value.enumerated.item[0] = 0;
2398 sel = snd_hda_codec_read(codec, 0x0b, 0,
2399 AC_VERB_GET_CONNECT_SEL, 0);
2404 ucontrol->value.enumerated.item[0] = sel;
2409 static int ad1988_spdif_playback_source_put(struct snd_kcontrol *kcontrol,
2410 struct snd_ctl_elem_value *ucontrol)
2412 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2413 unsigned int val, sel;
2416 val = ucontrol->value.enumerated.item[0];
2420 sel = snd_hda_codec_read(codec, 0x1d, 0,
2421 AC_VERB_GET_AMP_GAIN_MUTE,
2423 change = sel & 0x80;
2425 snd_hda_codec_write_cache(codec, 0x1d, 0,
2426 AC_VERB_SET_AMP_GAIN_MUTE,
2428 snd_hda_codec_write_cache(codec, 0x1d, 0,
2429 AC_VERB_SET_AMP_GAIN_MUTE,
2433 sel = snd_hda_codec_read(codec, 0x1d, 0,
2434 AC_VERB_GET_AMP_GAIN_MUTE,
2435 AC_AMP_GET_INPUT | 0x01);
2436 change = sel & 0x80;
2438 snd_hda_codec_write_cache(codec, 0x1d, 0,
2439 AC_VERB_SET_AMP_GAIN_MUTE,
2441 snd_hda_codec_write_cache(codec, 0x1d, 0,
2442 AC_VERB_SET_AMP_GAIN_MUTE,
2445 sel = snd_hda_codec_read(codec, 0x0b, 0,
2446 AC_VERB_GET_CONNECT_SEL, 0) + 1;
2447 change |= sel != val;
2449 snd_hda_codec_write_cache(codec, 0x0b, 0,
2450 AC_VERB_SET_CONNECT_SEL,
2456 static struct snd_kcontrol_new ad1988_spdif_out_mixers[] = {
2457 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
2459 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2460 .name = "IEC958 Playback Source",
2461 .subdevice = HDA_SUBDEV_NID_FLAG | 0x1b,
2462 .info = ad1988_spdif_playback_source_info,
2463 .get = ad1988_spdif_playback_source_get,
2464 .put = ad1988_spdif_playback_source_put,
2469 static struct snd_kcontrol_new ad1988_spdif_in_mixers[] = {
2470 HDA_CODEC_VOLUME("IEC958 Capture Volume", 0x1c, 0x0, HDA_INPUT),
2474 static struct snd_kcontrol_new ad1989_spdif_out_mixers[] = {
2475 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
2476 HDA_CODEC_VOLUME("HDMI Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
2481 * initialization verbs
2485 * for 6-stack (+dig)
2487 static struct hda_verb ad1988_6stack_init_verbs[] = {
2488 /* Front, Surround, CLFE, side DAC; unmute as default */
2489 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2490 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2491 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2492 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2493 /* Port-A front headphon path */
2494 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */
2495 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2496 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2497 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2498 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2499 /* Port-D line-out path */
2500 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2501 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2502 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2503 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2504 /* Port-F surround path */
2505 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2506 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2507 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2508 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2509 /* Port-G CLFE path */
2510 {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2511 {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2512 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2513 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2514 /* Port-H side path */
2515 {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2516 {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2517 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2518 {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2520 {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */
2521 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2522 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2523 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2524 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */
2525 /* Port-B front mic-in path */
2526 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2527 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2528 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2529 /* Port-C line-in path */
2530 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2531 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2532 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2533 {0x33, AC_VERB_SET_CONNECT_SEL, 0x0},
2534 /* Port-E mic-in path */
2535 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2536 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2537 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2538 {0x34, AC_VERB_SET_CONNECT_SEL, 0x0},
2539 /* Analog CD Input */
2540 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2541 /* Analog Mix output amp */
2542 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
2547 static struct hda_verb ad1988_6stack_fp_init_verbs[] = {
2548 /* Front, Surround, CLFE, side DAC; unmute as default */
2549 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2550 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2551 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2552 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2553 /* Headphone; unmute as default */
2554 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2555 /* Port-A front headphon path */
2556 {0x37, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC0:03h */
2557 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2558 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2559 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2560 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2561 /* Port-D line-out path */
2562 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2563 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2564 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2565 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2566 /* Port-F surround path */
2567 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2568 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2569 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2570 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2571 /* Port-G CLFE path */
2572 {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2573 {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2574 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2575 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2576 /* Port-H side path */
2577 {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2578 {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2579 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2580 {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2582 {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */
2583 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2584 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2585 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2586 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */
2587 /* Port-B front mic-in path */
2588 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2589 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2590 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2591 /* Port-C line-in path */
2592 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2593 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2594 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2595 {0x33, AC_VERB_SET_CONNECT_SEL, 0x0},
2596 /* Port-E mic-in path */
2597 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2598 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2599 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2600 {0x34, AC_VERB_SET_CONNECT_SEL, 0x0},
2601 /* Analog CD Input */
2602 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2603 /* Analog Mix output amp */
2604 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
2609 static struct hda_verb ad1988_capture_init_verbs[] = {
2610 /* mute analog mix */
2611 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2612 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2613 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2614 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2615 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2616 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
2617 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2618 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2619 /* select ADCs - front-mic */
2620 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
2621 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
2622 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
2627 static struct hda_verb ad1988_spdif_init_verbs[] = {
2629 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */
2630 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x0}, /* ADC1 */
2631 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2632 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2634 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
2639 static struct hda_verb ad1988_spdif_in_init_verbs[] = {
2640 /* unmute SPDIF input pin */
2641 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2645 /* AD1989 has no ADC -> SPDIF route */
2646 static struct hda_verb ad1989_spdif_init_verbs[] = {
2647 /* SPDIF-1 out pin */
2648 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2649 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
2650 /* SPDIF-2/HDMI out pin */
2651 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2652 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
2657 * verbs for 3stack (+dig)
2659 static struct hda_verb ad1988_3stack_ch2_init[] = {
2660 /* set port-C to line-in */
2661 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2662 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2663 /* set port-E to mic-in */
2664 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2665 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2669 static struct hda_verb ad1988_3stack_ch6_init[] = {
2670 /* set port-C to surround out */
2671 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2672 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2673 /* set port-E to CLFE out */
2674 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2675 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2679 static struct hda_channel_mode ad1988_3stack_modes[2] = {
2680 { 2, ad1988_3stack_ch2_init },
2681 { 6, ad1988_3stack_ch6_init },
2684 static struct hda_verb ad1988_3stack_init_verbs[] = {
2685 /* Front, Surround, CLFE, side DAC; unmute as default */
2686 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2687 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2688 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2689 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2690 /* Port-A front headphon path */
2691 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */
2692 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2693 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2694 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2695 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2696 /* Port-D line-out path */
2697 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2698 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2699 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2700 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2702 {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */
2703 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2704 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2705 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2706 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */
2707 /* Port-B front mic-in path */
2708 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2709 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2710 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2711 /* Port-C line-in/surround path - 6ch mode as default */
2712 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2713 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2714 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2715 {0x31, AC_VERB_SET_CONNECT_SEL, 0x0}, /* output sel: DAC 0x05 */
2716 {0x33, AC_VERB_SET_CONNECT_SEL, 0x0},
2717 /* Port-E mic-in/CLFE path - 6ch mode as default */
2718 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2719 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2720 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2721 {0x32, AC_VERB_SET_CONNECT_SEL, 0x1}, /* output sel: DAC 0x0a */
2722 {0x34, AC_VERB_SET_CONNECT_SEL, 0x0},
2723 /* mute analog mix */
2724 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2725 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2726 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2727 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2728 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2729 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
2730 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2731 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2732 /* select ADCs - front-mic */
2733 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
2734 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
2735 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
2736 /* Analog Mix output amp */
2737 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
2742 * verbs for laptop mode (+dig)
2744 static struct hda_verb ad1988_laptop_hp_on[] = {
2745 /* unmute port-A and mute port-D */
2746 { 0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2747 { 0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2750 static struct hda_verb ad1988_laptop_hp_off[] = {
2751 /* mute port-A and unmute port-D */
2752 { 0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2753 { 0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2757 #define AD1988_HP_EVENT 0x01
2759 static struct hda_verb ad1988_laptop_init_verbs[] = {
2760 /* Front, Surround, CLFE, side DAC; unmute as default */
2761 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2762 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2763 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2764 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2765 /* Port-A front headphon path */
2766 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */
2767 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2768 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2769 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2770 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2771 /* unsolicited event for pin-sense */
2772 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1988_HP_EVENT },
2773 /* Port-D line-out path + EAPD */
2774 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2775 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2776 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2777 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2778 {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x00}, /* EAPD-off */
2780 {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */
2781 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2782 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2783 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2784 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */
2785 /* Port-B mic-in path */
2786 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2787 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2788 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2789 /* Port-C docking station - try to output */
2790 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2791 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2792 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2793 {0x33, AC_VERB_SET_CONNECT_SEL, 0x0},
2794 /* mute analog mix */
2795 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2796 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2797 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2798 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2799 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2800 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
2801 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2802 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2803 /* select ADCs - mic */
2804 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
2805 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
2806 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
2807 /* Analog Mix output amp */
2808 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
2812 static void ad1988_laptop_unsol_event(struct hda_codec *codec, unsigned int res)
2814 if ((res >> 26) != AD1988_HP_EVENT)
2816 if (snd_hda_jack_detect(codec, 0x11))
2817 snd_hda_sequence_write(codec, ad1988_laptop_hp_on);
2819 snd_hda_sequence_write(codec, ad1988_laptop_hp_off);
2822 #ifdef CONFIG_SND_HDA_POWER_SAVE
2823 static struct hda_amp_list ad1988_loopbacks[] = {
2824 { 0x20, HDA_INPUT, 0 }, /* Front Mic */
2825 { 0x20, HDA_INPUT, 1 }, /* Line */
2826 { 0x20, HDA_INPUT, 4 }, /* Mic */
2827 { 0x20, HDA_INPUT, 6 }, /* CD */
2833 * Automatic parse of I/O pins from the BIOS configuration
2841 static struct snd_kcontrol_new ad1988_control_templates[] = {
2842 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2843 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2844 HDA_BIND_MUTE(NULL, 0, 0, 0),
2847 /* add dynamic controls */
2848 static int add_control(struct ad198x_spec *spec, int type, const char *name,
2851 struct snd_kcontrol_new *knew;
2853 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2854 knew = snd_array_new(&spec->kctls);
2857 *knew = ad1988_control_templates[type];
2858 knew->name = kstrdup(name, GFP_KERNEL);
2861 if (get_amp_nid_(val))
2862 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
2863 knew->private_value = val;
2867 #define AD1988_PIN_CD_NID 0x18
2868 #define AD1988_PIN_BEEP_NID 0x10
2870 static hda_nid_t ad1988_mixer_nids[8] = {
2871 /* A B C D E F G H */
2872 0x22, 0x2b, 0x2c, 0x29, 0x26, 0x2a, 0x27, 0x28
2875 static inline hda_nid_t ad1988_idx_to_dac(struct hda_codec *codec, int idx)
2877 static hda_nid_t idx_to_dac[8] = {
2878 /* A B C D E F G H */
2879 0x04, 0x06, 0x05, 0x04, 0x0a, 0x06, 0x05, 0x0a
2881 static hda_nid_t idx_to_dac_rev2[8] = {
2882 /* A B C D E F G H */
2883 0x04, 0x05, 0x0a, 0x04, 0x06, 0x05, 0x0a, 0x06
2886 return idx_to_dac_rev2[idx];
2888 return idx_to_dac[idx];
2891 static hda_nid_t ad1988_boost_nids[8] = {
2892 0x38, 0x39, 0x3a, 0x3d, 0x3c, 0x3b, 0, 0
2895 static int ad1988_pin_idx(hda_nid_t nid)
2897 static hda_nid_t ad1988_io_pins[8] = {
2898 0x11, 0x14, 0x15, 0x12, 0x17, 0x16, 0x24, 0x25
2901 for (i = 0; i < ARRAY_SIZE(ad1988_io_pins); i++)
2902 if (ad1988_io_pins[i] == nid)
2904 return 0; /* should be -1 */
2907 static int ad1988_pin_to_loopback_idx(hda_nid_t nid)
2909 static int loopback_idx[8] = {
2910 2, 0, 1, 3, 4, 5, 1, 4
2913 case AD1988_PIN_CD_NID:
2916 return loopback_idx[ad1988_pin_idx(nid)];
2920 static int ad1988_pin_to_adc_idx(hda_nid_t nid)
2922 static int adc_idx[8] = {
2923 0, 1, 2, 8, 4, 3, 6, 7
2926 case AD1988_PIN_CD_NID:
2929 return adc_idx[ad1988_pin_idx(nid)];
2933 /* fill in the dac_nids table from the parsed pin configuration */
2934 static int ad1988_auto_fill_dac_nids(struct hda_codec *codec,
2935 const struct auto_pin_cfg *cfg)
2937 struct ad198x_spec *spec = codec->spec;
2940 spec->multiout.dac_nids = spec->private_dac_nids;
2942 /* check the pins hardwired to audio widget */
2943 for (i = 0; i < cfg->line_outs; i++) {
2944 idx = ad1988_pin_idx(cfg->line_out_pins[i]);
2945 spec->multiout.dac_nids[i] = ad1988_idx_to_dac(codec, idx);
2947 spec->multiout.num_dacs = cfg->line_outs;
2951 /* add playback controls from the parsed DAC table */
2952 static int ad1988_auto_create_multi_out_ctls(struct ad198x_spec *spec,
2953 const struct auto_pin_cfg *cfg)
2956 static const char * const chname[4] = {
2957 "Front", "Surround", NULL /*CLFE*/, "Side"
2962 for (i = 0; i < cfg->line_outs; i++) {
2963 hda_nid_t dac = spec->multiout.dac_nids[i];
2966 nid = ad1988_mixer_nids[ad1988_pin_idx(cfg->line_out_pins[i])];
2969 err = add_control(spec, AD_CTL_WIDGET_VOL,
2970 "Center Playback Volume",
2971 HDA_COMPOSE_AMP_VAL(dac, 1, 0, HDA_OUTPUT));
2974 err = add_control(spec, AD_CTL_WIDGET_VOL,
2975 "LFE Playback Volume",
2976 HDA_COMPOSE_AMP_VAL(dac, 2, 0, HDA_OUTPUT));
2979 err = add_control(spec, AD_CTL_BIND_MUTE,
2980 "Center Playback Switch",
2981 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT));
2984 err = add_control(spec, AD_CTL_BIND_MUTE,
2985 "LFE Playback Switch",
2986 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT));
2990 sprintf(name, "%s Playback Volume", chname[i]);
2991 err = add_control(spec, AD_CTL_WIDGET_VOL, name,
2992 HDA_COMPOSE_AMP_VAL(dac, 3, 0, HDA_OUTPUT));
2995 sprintf(name, "%s Playback Switch", chname[i]);
2996 err = add_control(spec, AD_CTL_BIND_MUTE, name,
2997 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3005 /* add playback controls for speaker and HP outputs */
3006 static int ad1988_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
3009 struct ad198x_spec *spec = codec->spec;
3017 idx = ad1988_pin_idx(pin);
3018 nid = ad1988_idx_to_dac(codec, idx);
3019 /* check whether the corresponding DAC was already taken */
3020 for (i = 0; i < spec->autocfg.line_outs; i++) {
3021 hda_nid_t pin = spec->autocfg.line_out_pins[i];
3022 hda_nid_t dac = ad1988_idx_to_dac(codec, ad1988_pin_idx(pin));
3026 if (i >= spec->autocfg.line_outs) {
3027 /* specify the DAC as the extra output */
3028 if (!spec->multiout.hp_nid)
3029 spec->multiout.hp_nid = nid;
3031 spec->multiout.extra_out_nid[0] = nid;
3032 /* control HP volume/switch on the output mixer amp */
3033 sprintf(name, "%s Playback Volume", pfx);
3034 err = add_control(spec, AD_CTL_WIDGET_VOL, name,
3035 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3039 nid = ad1988_mixer_nids[idx];
3040 sprintf(name, "%s Playback Switch", pfx);
3041 if ((err = add_control(spec, AD_CTL_BIND_MUTE, name,
3042 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
3047 /* create input playback/capture controls for the given pin */
3048 static int new_analog_input(struct ad198x_spec *spec, hda_nid_t pin,
3049 const char *ctlname, int ctlidx, int boost)
3054 sprintf(name, "%s Playback Volume", ctlname);
3055 idx = ad1988_pin_to_loopback_idx(pin);
3056 if ((err = add_control(spec, AD_CTL_WIDGET_VOL, name,
3057 HDA_COMPOSE_AMP_VAL(0x20, 3, idx, HDA_INPUT))) < 0)
3059 sprintf(name, "%s Playback Switch", ctlname);
3060 if ((err = add_control(spec, AD_CTL_WIDGET_MUTE, name,
3061 HDA_COMPOSE_AMP_VAL(0x20, 3, idx, HDA_INPUT))) < 0)
3065 idx = ad1988_pin_idx(pin);
3066 bnid = ad1988_boost_nids[idx];
3068 sprintf(name, "%s Boost Volume", ctlname);
3069 return add_control(spec, AD_CTL_WIDGET_VOL, name,
3070 HDA_COMPOSE_AMP_VAL(bnid, 3, idx, HDA_OUTPUT));
3077 /* create playback/capture controls for input pins */
3078 static int ad1988_auto_create_analog_input_ctls(struct hda_codec *codec,
3079 const struct auto_pin_cfg *cfg)
3081 struct ad198x_spec *spec = codec->spec;
3082 struct hda_input_mux *imux = &spec->private_imux;
3083 int i, err, type, type_idx;
3085 for (i = 0; i < cfg->num_inputs; i++) {
3087 type = cfg->inputs[i].type;
3088 label = hda_get_autocfg_input_label(codec, cfg, i);
3089 snd_hda_add_imux_item(imux, label,
3090 ad1988_pin_to_adc_idx(cfg->inputs[i].pin),
3092 err = new_analog_input(spec, cfg->inputs[i].pin,
3094 type == AUTO_PIN_MIC);
3098 snd_hda_add_imux_item(imux, "Mix", 9, NULL);
3100 if ((err = add_control(spec, AD_CTL_WIDGET_VOL,
3101 "Analog Mix Playback Volume",
3102 HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT))) < 0)
3104 if ((err = add_control(spec, AD_CTL_WIDGET_MUTE,
3105 "Analog Mix Playback Switch",
3106 HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT))) < 0)
3112 static void ad1988_auto_set_output_and_unmute(struct hda_codec *codec,
3113 hda_nid_t nid, int pin_type,
3117 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
3118 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
3120 case 0x11: /* port-A - DAC 04 */
3121 snd_hda_codec_write(codec, 0x37, 0, AC_VERB_SET_CONNECT_SEL, 0x01);
3123 case 0x14: /* port-B - DAC 06 */
3124 snd_hda_codec_write(codec, 0x30, 0, AC_VERB_SET_CONNECT_SEL, 0x02);
3126 case 0x15: /* port-C - DAC 05 */
3127 snd_hda_codec_write(codec, 0x31, 0, AC_VERB_SET_CONNECT_SEL, 0x00);
3129 case 0x17: /* port-E - DAC 0a */
3130 snd_hda_codec_write(codec, 0x32, 0, AC_VERB_SET_CONNECT_SEL, 0x01);
3132 case 0x13: /* mono - DAC 04 */
3133 snd_hda_codec_write(codec, 0x36, 0, AC_VERB_SET_CONNECT_SEL, 0x01);
3138 static void ad1988_auto_init_multi_out(struct hda_codec *codec)
3140 struct ad198x_spec *spec = codec->spec;
3143 for (i = 0; i < spec->autocfg.line_outs; i++) {
3144 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3145 ad1988_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
3149 static void ad1988_auto_init_extra_out(struct hda_codec *codec)
3151 struct ad198x_spec *spec = codec->spec;
3154 pin = spec->autocfg.speaker_pins[0];
3155 if (pin) /* connect to front */
3156 ad1988_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
3157 pin = spec->autocfg.hp_pins[0];
3158 if (pin) /* connect to front */
3159 ad1988_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3162 static void ad1988_auto_init_analog_input(struct hda_codec *codec)
3164 struct ad198x_spec *spec = codec->spec;
3165 const struct auto_pin_cfg *cfg = &spec->autocfg;
3168 for (i = 0; i < cfg->num_inputs; i++) {
3169 hda_nid_t nid = cfg->inputs[i].pin;
3170 int type = cfg->inputs[i].type;
3172 case 0x15: /* port-C */
3173 snd_hda_codec_write(codec, 0x33, 0, AC_VERB_SET_CONNECT_SEL, 0x0);
3175 case 0x17: /* port-E */
3176 snd_hda_codec_write(codec, 0x34, 0, AC_VERB_SET_CONNECT_SEL, 0x0);
3179 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3180 type == AUTO_PIN_MIC ? PIN_VREF80 : PIN_IN);
3181 if (nid != AD1988_PIN_CD_NID)
3182 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3184 idx = ad1988_pin_idx(nid);
3185 if (ad1988_boost_nids[idx])
3186 snd_hda_codec_write(codec, ad1988_boost_nids[idx], 0,
3187 AC_VERB_SET_AMP_GAIN_MUTE,
3192 /* parse the BIOS configuration and set up the alc_spec */
3193 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
3194 static int ad1988_parse_auto_config(struct hda_codec *codec)
3196 struct ad198x_spec *spec = codec->spec;
3199 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
3201 if ((err = ad1988_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
3203 if (! spec->autocfg.line_outs)
3204 return 0; /* can't find valid BIOS pin config */
3205 if ((err = ad1988_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
3206 (err = ad1988_auto_create_extra_out(codec,
3207 spec->autocfg.speaker_pins[0],
3209 (err = ad1988_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
3210 "Headphone")) < 0 ||
3211 (err = ad1988_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3214 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3216 if (spec->autocfg.dig_outs)
3217 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
3218 if (spec->autocfg.dig_in_pin)
3219 spec->dig_in_nid = AD1988_SPDIF_IN;
3221 if (spec->kctls.list)
3222 spec->mixers[spec->num_mixers++] = spec->kctls.list;
3224 spec->init_verbs[spec->num_init_verbs++] = ad1988_6stack_init_verbs;
3226 spec->input_mux = &spec->private_imux;
3231 /* init callback for auto-configuration model -- overriding the default init */
3232 static int ad1988_auto_init(struct hda_codec *codec)
3235 ad1988_auto_init_multi_out(codec);
3236 ad1988_auto_init_extra_out(codec);
3237 ad1988_auto_init_analog_input(codec);
3244 static const char * const ad1988_models[AD1988_MODEL_LAST] = {
3245 [AD1988_6STACK] = "6stack",
3246 [AD1988_6STACK_DIG] = "6stack-dig",
3247 [AD1988_6STACK_DIG_FP] = "6stack-dig-fp",
3248 [AD1988_3STACK] = "3stack",
3249 [AD1988_3STACK_DIG] = "3stack-dig",
3250 [AD1988_LAPTOP] = "laptop",
3251 [AD1988_LAPTOP_DIG] = "laptop-dig",
3252 [AD1988_AUTO] = "auto",
3255 static struct snd_pci_quirk ad1988_cfg_tbl[] = {
3256 SND_PCI_QUIRK(0x1043, 0x81ec, "Asus P5B-DLX", AD1988_6STACK_DIG),
3257 SND_PCI_QUIRK(0x1043, 0x81f6, "Asus M2N-SLI", AD1988_6STACK_DIG),
3258 SND_PCI_QUIRK(0x1043, 0x8277, "Asus P5K-E/WIFI-AP", AD1988_6STACK_DIG),
3259 SND_PCI_QUIRK(0x1043, 0x8311, "Asus P5Q-Premium/Pro", AD1988_6STACK_DIG),
3263 static int patch_ad1988(struct hda_codec *codec)
3265 struct ad198x_spec *spec;
3266 int err, board_config;
3268 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3275 snd_printk(KERN_INFO "patch_analog: AD1988A rev.2 is detected, enable workarounds\n");
3277 board_config = snd_hda_check_board_config(codec, AD1988_MODEL_LAST,
3278 ad1988_models, ad1988_cfg_tbl);
3279 if (board_config < 0) {
3280 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
3282 board_config = AD1988_AUTO;
3285 if (board_config == AD1988_AUTO) {
3286 /* automatic parse from the BIOS config */
3287 err = ad1988_parse_auto_config(codec);
3292 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 6-stack mode...\n");
3293 board_config = AD1988_6STACK;
3297 err = snd_hda_attach_beep_device(codec, 0x10);
3302 set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
3304 switch (board_config) {
3306 case AD1988_6STACK_DIG:
3307 case AD1988_6STACK_DIG_FP:
3308 spec->multiout.max_channels = 8;
3309 spec->multiout.num_dacs = 4;
3311 spec->multiout.dac_nids = ad1988_6stack_dac_nids_rev2;
3313 spec->multiout.dac_nids = ad1988_6stack_dac_nids;
3314 spec->input_mux = &ad1988_6stack_capture_source;
3315 spec->num_mixers = 2;
3317 spec->mixers[0] = ad1988_6stack_mixers1_rev2;
3319 spec->mixers[0] = ad1988_6stack_mixers1;
3320 if (board_config == AD1988_6STACK_DIG_FP) {
3321 spec->mixers[1] = ad1988_6stack_fp_mixers;
3322 spec->slave_vols = ad1988_6stack_fp_slave_vols;
3323 spec->slave_sws = ad1988_6stack_fp_slave_sws;
3324 spec->alt_dac_nid = ad1988_alt_dac_nid;
3325 spec->stream_analog_alt_playback =
3326 &ad198x_pcm_analog_alt_playback;
3328 spec->mixers[1] = ad1988_6stack_mixers2;
3329 spec->num_init_verbs = 1;
3330 if (board_config == AD1988_6STACK_DIG_FP)
3331 spec->init_verbs[0] = ad1988_6stack_fp_init_verbs;
3333 spec->init_verbs[0] = ad1988_6stack_init_verbs;
3334 if ((board_config == AD1988_6STACK_DIG) ||
3335 (board_config == AD1988_6STACK_DIG_FP)) {
3336 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
3337 spec->dig_in_nid = AD1988_SPDIF_IN;
3341 case AD1988_3STACK_DIG:
3342 spec->multiout.max_channels = 6;
3343 spec->multiout.num_dacs = 3;
3345 spec->multiout.dac_nids = ad1988_3stack_dac_nids_rev2;
3347 spec->multiout.dac_nids = ad1988_3stack_dac_nids;
3348 spec->input_mux = &ad1988_6stack_capture_source;
3349 spec->channel_mode = ad1988_3stack_modes;
3350 spec->num_channel_mode = ARRAY_SIZE(ad1988_3stack_modes);
3351 spec->num_mixers = 2;
3353 spec->mixers[0] = ad1988_3stack_mixers1_rev2;
3355 spec->mixers[0] = ad1988_3stack_mixers1;
3356 spec->mixers[1] = ad1988_3stack_mixers2;
3357 spec->num_init_verbs = 1;
3358 spec->init_verbs[0] = ad1988_3stack_init_verbs;
3359 if (board_config == AD1988_3STACK_DIG)
3360 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
3363 case AD1988_LAPTOP_DIG:
3364 spec->multiout.max_channels = 2;
3365 spec->multiout.num_dacs = 1;
3366 spec->multiout.dac_nids = ad1988_3stack_dac_nids;
3367 spec->input_mux = &ad1988_laptop_capture_source;
3368 spec->num_mixers = 1;
3369 spec->mixers[0] = ad1988_laptop_mixers;
3370 spec->inv_eapd = 1; /* inverted EAPD */
3371 spec->num_init_verbs = 1;
3372 spec->init_verbs[0] = ad1988_laptop_init_verbs;
3373 if (board_config == AD1988_LAPTOP_DIG)
3374 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
3378 spec->num_adc_nids = ARRAY_SIZE(ad1988_adc_nids);
3379 spec->adc_nids = ad1988_adc_nids;
3380 spec->capsrc_nids = ad1988_capsrc_nids;
3381 spec->mixers[spec->num_mixers++] = ad1988_capture_mixers;
3382 spec->init_verbs[spec->num_init_verbs++] = ad1988_capture_init_verbs;
3383 if (spec->multiout.dig_out_nid) {
3384 if (codec->vendor_id >= 0x11d4989a) {
3385 spec->mixers[spec->num_mixers++] =
3386 ad1989_spdif_out_mixers;
3387 spec->init_verbs[spec->num_init_verbs++] =
3388 ad1989_spdif_init_verbs;
3389 codec->slave_dig_outs = ad1989b_slave_dig_outs;
3391 spec->mixers[spec->num_mixers++] =
3392 ad1988_spdif_out_mixers;
3393 spec->init_verbs[spec->num_init_verbs++] =
3394 ad1988_spdif_init_verbs;
3397 if (spec->dig_in_nid && codec->vendor_id < 0x11d4989a) {
3398 spec->mixers[spec->num_mixers++] = ad1988_spdif_in_mixers;
3399 spec->init_verbs[spec->num_init_verbs++] =
3400 ad1988_spdif_in_init_verbs;
3403 codec->patch_ops = ad198x_patch_ops;
3404 switch (board_config) {
3406 codec->patch_ops.init = ad1988_auto_init;
3409 case AD1988_LAPTOP_DIG:
3410 codec->patch_ops.unsol_event = ad1988_laptop_unsol_event;
3413 #ifdef CONFIG_SND_HDA_POWER_SAVE
3414 spec->loopback.amplist = ad1988_loopbacks;
3416 spec->vmaster_nid = 0x04;
3418 codec->no_trigger_sense = 1;
3419 codec->no_sticky_stream = 1;
3428 * port-B - front line/mic-in
3429 * port-E - aux in/out
3430 * port-F - aux in/out
3431 * port-C - rear line/mic-in
3432 * port-D - rear line/hp-out
3433 * port-A - front line/hp-out
3435 * AD1984 = AD1884 + two digital mic-ins
3438 * For simplicity, we share the single DAC for both HP and line-outs
3439 * right now. The inidividual playbacks could be easily implemented,
3440 * but no build-up framework is given, so far.
3443 static hda_nid_t ad1884_dac_nids[1] = {
3447 static hda_nid_t ad1884_adc_nids[2] = {
3451 static hda_nid_t ad1884_capsrc_nids[2] = {
3455 #define AD1884_SPDIF_OUT 0x02
3457 static struct hda_input_mux ad1884_capture_source = {
3460 { "Front Mic", 0x0 },
3467 static struct snd_kcontrol_new ad1884_base_mixers[] = {
3468 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
3469 /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */
3470 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
3471 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT),
3472 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT),
3473 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT),
3474 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
3475 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3476 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
3477 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
3478 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT),
3479 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT),
3480 HDA_CODEC_VOLUME("Mic Boost Volume", 0x15, 0x0, HDA_INPUT),
3481 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x14, 0x0, HDA_INPUT),
3482 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3483 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3484 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
3485 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
3487 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3488 /* The multiple "Capture Source" controls confuse alsamixer
3489 * So call somewhat different..
3491 /* .name = "Capture Source", */
3492 .name = "Input Source",
3494 .info = ad198x_mux_enum_info,
3495 .get = ad198x_mux_enum_get,
3496 .put = ad198x_mux_enum_put,
3498 /* SPDIF controls */
3499 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
3501 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3502 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
3503 /* identical with ad1983 */
3504 .info = ad1983_spdif_route_info,
3505 .get = ad1983_spdif_route_get,
3506 .put = ad1983_spdif_route_put,
3511 static struct snd_kcontrol_new ad1984_dmic_mixers[] = {
3512 HDA_CODEC_VOLUME("Digital Mic Capture Volume", 0x05, 0x0, HDA_INPUT),
3513 HDA_CODEC_MUTE("Digital Mic Capture Switch", 0x05, 0x0, HDA_INPUT),
3514 HDA_CODEC_VOLUME_IDX("Digital Mic Capture Volume", 1, 0x06, 0x0,
3516 HDA_CODEC_MUTE_IDX("Digital Mic Capture Switch", 1, 0x06, 0x0,
3522 * initialization verbs
3524 static struct hda_verb ad1884_init_verbs[] = {
3525 /* DACs; mute as default */
3526 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3527 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3528 /* Port-A (HP) mixer */
3529 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3530 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3532 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3533 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3534 /* HP selector - select DAC2 */
3535 {0x22, AC_VERB_SET_CONNECT_SEL, 0x1},
3536 /* Port-D (Line-out) mixer */
3537 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3538 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3540 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3541 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3542 /* Mono-out mixer */
3543 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3544 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3546 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3547 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3549 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
3550 /* Port-B (front mic) pin */
3551 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3552 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3553 /* Port-C (rear mic) pin */
3554 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3555 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3556 /* Analog mixer; mute as default */
3557 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3558 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3559 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3560 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3561 /* Analog Mix output amp */
3562 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
3563 /* SPDIF output selector */
3564 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */
3565 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
3569 #ifdef CONFIG_SND_HDA_POWER_SAVE
3570 static struct hda_amp_list ad1884_loopbacks[] = {
3571 { 0x20, HDA_INPUT, 0 }, /* Front Mic */
3572 { 0x20, HDA_INPUT, 1 }, /* Mic */
3573 { 0x20, HDA_INPUT, 2 }, /* CD */
3574 { 0x20, HDA_INPUT, 4 }, /* Docking */
3579 static const char * const ad1884_slave_vols[] = {
3580 "PCM Playback Volume",
3581 "Mic Playback Volume",
3582 "Mono Playback Volume",
3583 "Front Mic Playback Volume",
3584 "Mic Playback Volume",
3585 "CD Playback Volume",
3586 "Internal Mic Playback Volume",
3587 "Docking Mic Playback Volume",
3588 /* "Beep Playback Volume", */
3589 "IEC958 Playback Volume",
3593 static int patch_ad1884(struct hda_codec *codec)
3595 struct ad198x_spec *spec;
3598 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3604 err = snd_hda_attach_beep_device(codec, 0x10);
3609 set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
3611 spec->multiout.max_channels = 2;
3612 spec->multiout.num_dacs = ARRAY_SIZE(ad1884_dac_nids);
3613 spec->multiout.dac_nids = ad1884_dac_nids;
3614 spec->multiout.dig_out_nid = AD1884_SPDIF_OUT;
3615 spec->num_adc_nids = ARRAY_SIZE(ad1884_adc_nids);
3616 spec->adc_nids = ad1884_adc_nids;
3617 spec->capsrc_nids = ad1884_capsrc_nids;
3618 spec->input_mux = &ad1884_capture_source;
3619 spec->num_mixers = 1;
3620 spec->mixers[0] = ad1884_base_mixers;
3621 spec->num_init_verbs = 1;
3622 spec->init_verbs[0] = ad1884_init_verbs;
3623 spec->spdif_route = 0;
3624 #ifdef CONFIG_SND_HDA_POWER_SAVE
3625 spec->loopback.amplist = ad1884_loopbacks;
3627 spec->vmaster_nid = 0x04;
3628 /* we need to cover all playback volumes */
3629 spec->slave_vols = ad1884_slave_vols;
3631 codec->patch_ops = ad198x_patch_ops;
3633 codec->no_trigger_sense = 1;
3634 codec->no_sticky_stream = 1;
3640 * Lenovo Thinkpad T61/X61
3642 static struct hda_input_mux ad1984_thinkpad_capture_source = {
3646 { "Internal Mic", 0x1 },
3648 { "Docking-Station", 0x4 },
3654 * Dell Precision T3400
3656 static struct hda_input_mux ad1984_dell_desktop_capture_source = {
3659 { "Front Mic", 0x0 },
3666 static struct snd_kcontrol_new ad1984_thinkpad_mixers[] = {
3667 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
3668 /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */
3669 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
3670 HDA_CODEC_MUTE("Speaker Playback Switch", 0x12, 0x0, HDA_OUTPUT),
3671 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
3672 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3673 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
3674 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
3675 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
3676 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
3677 HDA_CODEC_VOLUME("Docking Mic Playback Volume", 0x20, 0x04, HDA_INPUT),
3678 HDA_CODEC_MUTE("Docking Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
3679 HDA_CODEC_VOLUME("Mic Boost Volume", 0x14, 0x0, HDA_INPUT),
3680 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x15, 0x0, HDA_INPUT),
3681 HDA_CODEC_VOLUME("Dock Mic Boost Volume", 0x25, 0x0, HDA_OUTPUT),
3682 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3683 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3684 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
3685 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
3687 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3688 /* The multiple "Capture Source" controls confuse alsamixer
3689 * So call somewhat different..
3691 /* .name = "Capture Source", */
3692 .name = "Input Source",
3694 .info = ad198x_mux_enum_info,
3695 .get = ad198x_mux_enum_get,
3696 .put = ad198x_mux_enum_put,
3698 /* SPDIF controls */
3699 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
3701 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3702 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
3703 /* identical with ad1983 */
3704 .info = ad1983_spdif_route_info,
3705 .get = ad1983_spdif_route_get,
3706 .put = ad1983_spdif_route_put,
3711 /* additional verbs */
3712 static struct hda_verb ad1984_thinkpad_init_verbs[] = {
3713 /* Port-E (docking station mic) pin */
3714 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3715 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3716 /* docking mic boost */
3717 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3718 /* Analog PC Beeper - allow firmware/ACPI beeps */
3719 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3) | 0x1a},
3720 /* Analog mixer - docking mic; mute as default */
3721 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3722 /* enable EAPD bit */
3723 {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
3728 * Dell Precision T3400
3730 static struct snd_kcontrol_new ad1984_dell_desktop_mixers[] = {
3731 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
3732 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
3733 HDA_CODEC_MUTE("Speaker Playback Switch", 0x12, 0x0, HDA_OUTPUT),
3734 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT),
3735 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT),
3736 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
3737 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3738 HDA_CODEC_VOLUME("Line-In Playback Volume", 0x20, 0x01, HDA_INPUT),
3739 HDA_CODEC_MUTE("Line-In Playback Switch", 0x20, 0x01, HDA_INPUT),
3740 HDA_CODEC_VOLUME("Line-In Boost Volume", 0x15, 0x0, HDA_INPUT),
3741 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x14, 0x0, HDA_INPUT),
3742 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3743 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3744 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
3745 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
3747 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3748 /* The multiple "Capture Source" controls confuse alsamixer
3749 * So call somewhat different..
3751 /* .name = "Capture Source", */
3752 .name = "Input Source",
3754 .info = ad198x_mux_enum_info,
3755 .get = ad198x_mux_enum_get,
3756 .put = ad198x_mux_enum_put,
3761 /* Digial MIC ADC NID 0x05 + 0x06 */
3762 static int ad1984_pcm_dmic_prepare(struct hda_pcm_stream *hinfo,
3763 struct hda_codec *codec,
3764 unsigned int stream_tag,
3765 unsigned int format,
3766 struct snd_pcm_substream *substream)
3768 snd_hda_codec_setup_stream(codec, 0x05 + substream->number,
3769 stream_tag, 0, format);
3773 static int ad1984_pcm_dmic_cleanup(struct hda_pcm_stream *hinfo,
3774 struct hda_codec *codec,
3775 struct snd_pcm_substream *substream)
3777 snd_hda_codec_cleanup_stream(codec, 0x05 + substream->number);
3781 static struct hda_pcm_stream ad1984_pcm_dmic_capture = {
3787 .prepare = ad1984_pcm_dmic_prepare,
3788 .cleanup = ad1984_pcm_dmic_cleanup
3792 static int ad1984_build_pcms(struct hda_codec *codec)
3794 struct ad198x_spec *spec = codec->spec;
3795 struct hda_pcm *info;
3798 err = ad198x_build_pcms(codec);
3802 info = spec->pcm_rec + codec->num_pcms;
3804 info->name = "AD1984 Digital Mic";
3805 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad1984_pcm_dmic_capture;
3813 AD1984_DELL_DESKTOP,
3817 static const char * const ad1984_models[AD1984_MODELS] = {
3818 [AD1984_BASIC] = "basic",
3819 [AD1984_THINKPAD] = "thinkpad",
3820 [AD1984_DELL_DESKTOP] = "dell_desktop",
3823 static struct snd_pci_quirk ad1984_cfg_tbl[] = {
3824 /* Lenovo Thinkpad T61/X61 */
3825 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo Thinkpad", AD1984_THINKPAD),
3826 SND_PCI_QUIRK(0x1028, 0x0214, "Dell T3400", AD1984_DELL_DESKTOP),
3827 SND_PCI_QUIRK(0x1028, 0x0233, "Dell Latitude E6400", AD1984_DELL_DESKTOP),
3831 static int patch_ad1984(struct hda_codec *codec)
3833 struct ad198x_spec *spec;
3834 int board_config, err;
3836 err = patch_ad1884(codec);
3840 board_config = snd_hda_check_board_config(codec, AD1984_MODELS,
3841 ad1984_models, ad1984_cfg_tbl);
3842 switch (board_config) {
3844 /* additional digital mics */
3845 spec->mixers[spec->num_mixers++] = ad1984_dmic_mixers;
3846 codec->patch_ops.build_pcms = ad1984_build_pcms;
3848 case AD1984_THINKPAD:
3849 if (codec->subsystem_id == 0x17aa20fb) {
3850 /* Thinpad X300 does not have the ability to do SPDIF,
3851 or attach to docking station to use SPDIF */
3852 spec->multiout.dig_out_nid = 0;
3854 spec->multiout.dig_out_nid = AD1884_SPDIF_OUT;
3855 spec->input_mux = &ad1984_thinkpad_capture_source;
3856 spec->mixers[0] = ad1984_thinkpad_mixers;
3857 spec->init_verbs[spec->num_init_verbs++] = ad1984_thinkpad_init_verbs;
3858 spec->analog_beep = 1;
3860 case AD1984_DELL_DESKTOP:
3861 spec->multiout.dig_out_nid = 0;
3862 spec->input_mux = &ad1984_dell_desktop_capture_source;
3863 spec->mixers[0] = ad1984_dell_desktop_mixers;
3871 * AD1883 / AD1884A / AD1984A / AD1984B
3873 * port-B (0x14) - front mic-in
3874 * port-E (0x1c) - rear mic-in
3875 * port-F (0x16) - CD / ext out
3876 * port-C (0x15) - rear line-in
3877 * port-D (0x12) - rear line-out
3878 * port-A (0x11) - front hp-out
3880 * AD1984A = AD1884A + digital-mic
3881 * AD1883 = equivalent with AD1984A
3882 * AD1984B = AD1984A + extra SPDIF-out
3885 * We share the single DAC for both HP and line-outs (see AD1884/1984).
3888 static hda_nid_t ad1884a_dac_nids[1] = {
3892 #define ad1884a_adc_nids ad1884_adc_nids
3893 #define ad1884a_capsrc_nids ad1884_capsrc_nids
3895 #define AD1884A_SPDIF_OUT 0x02
3897 static struct hda_input_mux ad1884a_capture_source = {
3900 { "Front Mic", 0x0 },
3908 static struct snd_kcontrol_new ad1884a_base_mixers[] = {
3909 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT),
3910 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),
3911 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
3912 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT),
3913 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT),
3914 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT),
3915 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
3916 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
3917 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
3918 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3919 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x01, HDA_INPUT),
3920 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x01, HDA_INPUT),
3921 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x04, HDA_INPUT),
3922 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
3923 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT),
3924 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT),
3925 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x14, 0x0, HDA_INPUT),
3926 HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x0, HDA_INPUT),
3927 HDA_CODEC_VOLUME("Mic Boost Volume", 0x25, 0x0, HDA_OUTPUT),
3928 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3929 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3930 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
3931 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
3933 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3934 /* The multiple "Capture Source" controls confuse alsamixer
3935 * So call somewhat different..
3937 /* .name = "Capture Source", */
3938 .name = "Input Source",
3940 .info = ad198x_mux_enum_info,
3941 .get = ad198x_mux_enum_get,
3942 .put = ad198x_mux_enum_put,
3944 /* SPDIF controls */
3945 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
3947 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3948 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
3949 /* identical with ad1983 */
3950 .info = ad1983_spdif_route_info,
3951 .get = ad1983_spdif_route_get,
3952 .put = ad1983_spdif_route_put,
3958 * initialization verbs
3960 static struct hda_verb ad1884a_init_verbs[] = {
3961 /* DACs; unmute as default */
3962 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */
3963 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */
3964 /* Port-A (HP) mixer - route only from analog mixer */
3965 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3966 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3968 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3969 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3970 /* Port-D (Line-out) mixer - route only from analog mixer */
3971 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3972 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3974 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3975 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3976 /* Mono-out mixer - route only from analog mixer */
3977 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3978 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3980 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3981 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3982 /* Port-B (front mic) pin */
3983 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3984 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3985 /* Port-C (rear line-in) pin */
3986 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3987 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3988 /* Port-E (rear mic) pin */
3989 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3990 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3991 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* no boost */
3992 /* Port-F (CD) pin */
3993 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3994 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3995 /* Analog mixer; mute as default */
3996 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3997 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3998 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3999 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4000 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, /* aux */
4001 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
4002 /* Analog Mix output amp */
4003 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4004 /* capture sources */
4005 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0},
4006 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4007 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
4008 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4009 /* SPDIF output amp */
4010 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
4014 #ifdef CONFIG_SND_HDA_POWER_SAVE
4015 static struct hda_amp_list ad1884a_loopbacks[] = {
4016 { 0x20, HDA_INPUT, 0 }, /* Front Mic */
4017 { 0x20, HDA_INPUT, 1 }, /* Mic */
4018 { 0x20, HDA_INPUT, 2 }, /* CD */
4019 { 0x20, HDA_INPUT, 4 }, /* Docking */
4027 * Port A: Headphone jack
4029 * Port C: Internal MIC
4030 * Port D: Dock Line Out (if enabled)
4031 * Port E: Dock Line In (if enabled)
4032 * Port F: Internal speakers
4035 static int ad1884a_mobile_master_sw_put(struct snd_kcontrol *kcontrol,
4036 struct snd_ctl_elem_value *ucontrol)
4038 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4039 int ret = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
4040 int mute = (!ucontrol->value.integer.value[0] &&
4041 !ucontrol->value.integer.value[1]);
4042 /* toggle GPIO1 according to the mute state */
4043 snd_hda_codec_write_cache(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
4048 static struct snd_kcontrol_new ad1884a_laptop_mixers[] = {
4049 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT),
4051 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4052 .name = "Master Playback Switch",
4053 .subdevice = HDA_SUBDEV_AMP_FLAG,
4054 .info = snd_hda_mixer_amp_switch_info,
4055 .get = snd_hda_mixer_amp_switch_get,
4056 .put = ad1884a_mobile_master_sw_put,
4057 .private_value = HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
4059 HDA_CODEC_MUTE("Dock Playback Switch", 0x12, 0x0, HDA_OUTPUT),
4060 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
4061 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
4062 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
4063 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
4064 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
4065 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
4066 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x20, 0x04, HDA_INPUT),
4067 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
4068 HDA_CODEC_VOLUME("Mic Boost Volume", 0x14, 0x0, HDA_INPUT),
4069 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x15, 0x0, HDA_INPUT),
4070 HDA_CODEC_VOLUME("Dock Mic Boost Volume", 0x25, 0x0, HDA_OUTPUT),
4071 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
4072 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
4076 static struct snd_kcontrol_new ad1884a_mobile_mixers[] = {
4077 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT),
4078 /*HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),*/
4080 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4081 .name = "Master Playback Switch",
4082 .subdevice = HDA_SUBDEV_AMP_FLAG,
4083 .info = snd_hda_mixer_amp_switch_info,
4084 .get = snd_hda_mixer_amp_switch_get,
4085 .put = ad1884a_mobile_master_sw_put,
4086 .private_value = HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
4088 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
4089 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
4090 HDA_CODEC_VOLUME("Mic Capture Volume", 0x14, 0x0, HDA_INPUT),
4091 HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x15, 0x0, HDA_INPUT),
4092 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
4093 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
4097 /* mute internal speaker if HP is plugged */
4098 static void ad1884a_hp_automute(struct hda_codec *codec)
4100 unsigned int present;
4102 present = snd_hda_jack_detect(codec, 0x11);
4103 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
4104 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
4105 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_EAPD_BTLENABLE,
4106 present ? 0x00 : 0x02);
4109 /* switch to external mic if plugged */
4110 static void ad1884a_hp_automic(struct hda_codec *codec)
4112 unsigned int present;
4114 present = snd_hda_jack_detect(codec, 0x14);
4115 snd_hda_codec_write(codec, 0x0c, 0, AC_VERB_SET_CONNECT_SEL,
4119 #define AD1884A_HP_EVENT 0x37
4120 #define AD1884A_MIC_EVENT 0x36
4122 /* unsolicited event for HP jack sensing */
4123 static void ad1884a_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4125 switch (res >> 26) {
4126 case AD1884A_HP_EVENT:
4127 ad1884a_hp_automute(codec);
4129 case AD1884A_MIC_EVENT:
4130 ad1884a_hp_automic(codec);
4135 /* initialize jack-sensing, too */
4136 static int ad1884a_hp_init(struct hda_codec *codec)
4139 ad1884a_hp_automute(codec);
4140 ad1884a_hp_automic(codec);
4144 /* mute internal speaker if HP or docking HP is plugged */
4145 static void ad1884a_laptop_automute(struct hda_codec *codec)
4147 unsigned int present;
4149 present = snd_hda_jack_detect(codec, 0x11);
4151 present = snd_hda_jack_detect(codec, 0x12);
4152 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
4153 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
4154 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_EAPD_BTLENABLE,
4155 present ? 0x00 : 0x02);
4158 /* switch to external mic if plugged */
4159 static void ad1884a_laptop_automic(struct hda_codec *codec)
4163 if (snd_hda_jack_detect(codec, 0x14))
4165 else if (snd_hda_jack_detect(codec, 0x1c))
4169 snd_hda_codec_write(codec, 0x0c, 0, AC_VERB_SET_CONNECT_SEL, idx);
4172 /* unsolicited event for HP jack sensing */
4173 static void ad1884a_laptop_unsol_event(struct hda_codec *codec,
4176 switch (res >> 26) {
4177 case AD1884A_HP_EVENT:
4178 ad1884a_laptop_automute(codec);
4180 case AD1884A_MIC_EVENT:
4181 ad1884a_laptop_automic(codec);
4186 /* initialize jack-sensing, too */
4187 static int ad1884a_laptop_init(struct hda_codec *codec)
4190 ad1884a_laptop_automute(codec);
4191 ad1884a_laptop_automic(codec);
4195 /* additional verbs for laptop model */
4196 static struct hda_verb ad1884a_laptop_verbs[] = {
4197 /* Port-A (HP) pin - always unmuted */
4198 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4199 /* Port-F (int speaker) mixer - route only from analog mixer */
4200 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4201 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4202 /* Port-F (int speaker) pin */
4203 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4204 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4205 /* required for compaq 6530s/6531s speaker output */
4206 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4207 /* Port-C pin - internal mic-in */
4208 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4209 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */
4210 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */
4211 /* Port-D (docking line-out) pin - default unmuted */
4212 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4214 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4215 /* unsolicited event for pin-sense */
4216 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT},
4217 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT},
4218 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_MIC_EVENT},
4219 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_MIC_EVENT},
4220 /* allow to touch GPIO1 (for mute control) */
4221 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
4222 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
4223 {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, /* first muted */
4227 static struct hda_verb ad1884a_mobile_verbs[] = {
4228 /* DACs; unmute as default */
4229 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */
4230 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */
4231 /* Port-A (HP) mixer - route only from analog mixer */
4232 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4233 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4235 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4236 /* Port-A (HP) pin - always unmuted */
4237 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4238 /* Port-B (mic jack) pin */
4239 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4240 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */
4241 /* Port-C (int mic) pin */
4242 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4243 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */
4244 /* Port-F (int speaker) mixer - route only from analog mixer */
4245 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4246 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4248 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4249 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4250 /* Analog mixer; mute as default */
4251 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4252 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4253 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4254 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4255 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4256 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
4257 /* Analog Mix output amp */
4258 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4259 /* capture sources */
4260 /* {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0}, */ /* set via unsol */
4261 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4262 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
4263 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4264 /* unsolicited event for pin-sense */
4265 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT},
4266 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_MIC_EVENT},
4267 /* allow to touch GPIO1 (for mute control) */
4268 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
4269 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
4270 {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, /* first muted */
4279 * 0x17 - built-in mic
4282 static struct hda_verb ad1984a_thinkpad_verbs[] = {
4284 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4286 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4288 {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4289 /* unsolicited event for pin-sense */
4290 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT},
4291 /* internal mic - dmic */
4292 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4293 /* set magic COEFs for dmic */
4294 {0x01, AC_VERB_SET_COEF_INDEX, 0x13f7},
4295 {0x01, AC_VERB_SET_PROC_COEF, 0x08},
4299 static struct snd_kcontrol_new ad1984a_thinkpad_mixers[] = {
4300 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT),
4301 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),
4302 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
4303 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
4304 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
4305 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
4306 HDA_CODEC_VOLUME("Mic Boost Volume", 0x14, 0x0, HDA_INPUT),
4307 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x17, 0x0, HDA_INPUT),
4308 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
4309 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
4311 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4312 .name = "Capture Source",
4313 .info = ad198x_mux_enum_info,
4314 .get = ad198x_mux_enum_get,
4315 .put = ad198x_mux_enum_put,
4320 static struct hda_input_mux ad1984a_thinkpad_capture_source = {
4324 { "Internal Mic", 0x5 },
4329 /* mute internal speaker if HP is plugged */
4330 static void ad1984a_thinkpad_automute(struct hda_codec *codec)
4332 unsigned int present;
4334 present = snd_hda_jack_detect(codec, 0x11);
4335 snd_hda_codec_amp_stereo(codec, 0x12, HDA_OUTPUT, 0,
4336 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
4339 /* unsolicited event for HP jack sensing */
4340 static void ad1984a_thinkpad_unsol_event(struct hda_codec *codec,
4343 if ((res >> 26) != AD1884A_HP_EVENT)
4345 ad1984a_thinkpad_automute(codec);
4348 /* initialize jack-sensing, too */
4349 static int ad1984a_thinkpad_init(struct hda_codec *codec)
4352 ad1984a_thinkpad_automute(codec);
4358 * 0x12 - HP/line-out
4359 * 0x13 - speaker (mono)
4363 static struct hda_verb ad1984a_precision_verbs[] = {
4364 /* Unmute main output path */
4365 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */
4366 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE + 0x1f}, /* 0dB */
4367 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) + 0x17}, /* 0dB */
4368 /* Analog mixer; mute as default */
4369 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4370 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4371 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4372 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4373 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4374 /* Select mic as input */
4375 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
4376 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE + 0x27}, /* 0dB */
4377 /* Configure as mic */
4378 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4379 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */
4381 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4383 {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4384 /* unsolicited event for pin-sense */
4385 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT},
4389 static struct snd_kcontrol_new ad1984a_precision_mixers[] = {
4390 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT),
4391 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),
4392 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
4393 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
4394 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
4395 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
4396 HDA_CODEC_VOLUME("Mic Boost Volume", 0x15, 0x0, HDA_INPUT),
4397 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT),
4398 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x13, 0x0, HDA_OUTPUT),
4399 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
4400 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
4405 /* mute internal speaker if HP is plugged */
4406 static void ad1984a_precision_automute(struct hda_codec *codec)
4408 unsigned int present;
4410 present = snd_hda_jack_detect(codec, 0x12);
4411 snd_hda_codec_amp_stereo(codec, 0x13, HDA_OUTPUT, 0,
4412 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
4416 /* unsolicited event for HP jack sensing */
4417 static void ad1984a_precision_unsol_event(struct hda_codec *codec,
4420 if ((res >> 26) != AD1884A_HP_EVENT)
4422 ad1984a_precision_automute(codec);
4425 /* initialize jack-sensing, too */
4426 static int ad1984a_precision_init(struct hda_codec *codec)
4429 ad1984a_precision_automute(codec);
4436 * port-A (0x11) - front hp-out
4437 * port-B (0x14) - unused
4438 * port-C (0x15) - unused
4439 * port-D (0x12) - rear line out
4440 * port-E (0x1c) - front mic-in
4441 * port-F (0x16) - Internal speakers
4442 * digital-mic (0x17) - Internal mic
4445 static struct hda_verb ad1984a_touchsmart_verbs[] = {
4446 /* DACs; unmute as default */
4447 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */
4448 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */
4449 /* Port-A (HP) mixer - route only from analog mixer */
4450 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4451 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4453 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4454 /* Port-A (HP) pin - always unmuted */
4455 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4456 /* Port-E (int speaker) mixer - route only from analog mixer */
4457 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, 0x03},
4459 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4460 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4461 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4462 /* Port-F (int speaker) mixer - route only from analog mixer */
4463 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4464 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4466 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4467 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4468 /* Analog mixer; mute as default */
4469 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4470 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4471 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4472 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4473 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4474 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
4475 /* Analog Mix output amp */
4476 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4477 /* capture sources */
4478 /* {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0}, */ /* set via unsol */
4479 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4480 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
4481 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4482 /* unsolicited event for pin-sense */
4483 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT},
4484 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_MIC_EVENT},
4485 /* allow to touch GPIO1 (for mute control) */
4486 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
4487 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
4488 {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, /* first muted */
4489 /* internal mic - dmic */
4490 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4491 /* set magic COEFs for dmic */
4492 {0x01, AC_VERB_SET_COEF_INDEX, 0x13f7},
4493 {0x01, AC_VERB_SET_PROC_COEF, 0x08},
4497 static struct snd_kcontrol_new ad1984a_touchsmart_mixers[] = {
4498 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT),
4499 /* HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),*/
4501 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4502 .subdevice = HDA_SUBDEV_AMP_FLAG,
4503 .name = "Master Playback Switch",
4504 .info = snd_hda_mixer_amp_switch_info,
4505 .get = snd_hda_mixer_amp_switch_get,
4506 .put = ad1884a_mobile_master_sw_put,
4507 .private_value = HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
4509 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
4510 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
4511 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
4512 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
4513 HDA_CODEC_VOLUME("Mic Boost Volume", 0x25, 0x0, HDA_OUTPUT),
4514 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x17, 0x0, HDA_INPUT),
4518 /* switch to external mic if plugged */
4519 static void ad1984a_touchsmart_automic(struct hda_codec *codec)
4521 if (snd_hda_jack_detect(codec, 0x1c))
4522 snd_hda_codec_write(codec, 0x0c, 0,
4523 AC_VERB_SET_CONNECT_SEL, 0x4);
4525 snd_hda_codec_write(codec, 0x0c, 0,
4526 AC_VERB_SET_CONNECT_SEL, 0x5);
4530 /* unsolicited event for HP jack sensing */
4531 static void ad1984a_touchsmart_unsol_event(struct hda_codec *codec,
4534 switch (res >> 26) {
4535 case AD1884A_HP_EVENT:
4536 ad1884a_hp_automute(codec);
4538 case AD1884A_MIC_EVENT:
4539 ad1984a_touchsmart_automic(codec);
4544 /* initialize jack-sensing, too */
4545 static int ad1984a_touchsmart_init(struct hda_codec *codec)
4548 ad1884a_hp_automute(codec);
4549 ad1984a_touchsmart_automic(codec);
4567 static const char * const ad1884a_models[AD1884A_MODELS] = {
4568 [AD1884A_DESKTOP] = "desktop",
4569 [AD1884A_LAPTOP] = "laptop",
4570 [AD1884A_MOBILE] = "mobile",
4571 [AD1884A_THINKPAD] = "thinkpad",
4572 [AD1984A_TOUCHSMART] = "touchsmart",
4573 [AD1984A_PRECISION] = "precision",
4576 static struct snd_pci_quirk ad1884a_cfg_tbl[] = {
4577 SND_PCI_QUIRK(0x1028, 0x04ac, "Precision R5500", AD1984A_PRECISION),
4578 SND_PCI_QUIRK(0x103c, 0x3030, "HP", AD1884A_MOBILE),
4579 SND_PCI_QUIRK(0x103c, 0x3037, "HP 2230s", AD1884A_LAPTOP),
4580 SND_PCI_QUIRK(0x103c, 0x3056, "HP", AD1884A_MOBILE),
4581 SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x3070, "HP", AD1884A_MOBILE),
4582 SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x30d0, "HP laptop", AD1884A_LAPTOP),
4583 SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x30e0, "HP laptop", AD1884A_LAPTOP),
4584 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3600, "HP laptop", AD1884A_LAPTOP),
4585 SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x7010, "HP laptop", AD1884A_MOBILE),
4586 SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X300", AD1884A_THINKPAD),
4587 SND_PCI_QUIRK(0x103c, 0x2a82, "Touchsmart", AD1984A_TOUCHSMART),
4591 static int patch_ad1884a(struct hda_codec *codec)
4593 struct ad198x_spec *spec;
4594 int err, board_config;
4596 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4602 err = snd_hda_attach_beep_device(codec, 0x10);
4607 set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
4609 spec->multiout.max_channels = 2;
4610 spec->multiout.num_dacs = ARRAY_SIZE(ad1884a_dac_nids);
4611 spec->multiout.dac_nids = ad1884a_dac_nids;
4612 spec->multiout.dig_out_nid = AD1884A_SPDIF_OUT;
4613 spec->num_adc_nids = ARRAY_SIZE(ad1884a_adc_nids);
4614 spec->adc_nids = ad1884a_adc_nids;
4615 spec->capsrc_nids = ad1884a_capsrc_nids;
4616 spec->input_mux = &ad1884a_capture_source;
4617 spec->num_mixers = 1;
4618 spec->mixers[0] = ad1884a_base_mixers;
4619 spec->num_init_verbs = 1;
4620 spec->init_verbs[0] = ad1884a_init_verbs;
4621 spec->spdif_route = 0;
4622 #ifdef CONFIG_SND_HDA_POWER_SAVE
4623 spec->loopback.amplist = ad1884a_loopbacks;
4625 codec->patch_ops = ad198x_patch_ops;
4627 /* override some parameters */
4628 board_config = snd_hda_check_board_config(codec, AD1884A_MODELS,
4631 switch (board_config) {
4632 case AD1884A_LAPTOP:
4633 spec->mixers[0] = ad1884a_laptop_mixers;
4634 spec->init_verbs[spec->num_init_verbs++] = ad1884a_laptop_verbs;
4635 spec->multiout.dig_out_nid = 0;
4636 codec->patch_ops.unsol_event = ad1884a_laptop_unsol_event;
4637 codec->patch_ops.init = ad1884a_laptop_init;
4638 /* set the upper-limit for mixer amp to 0dB for avoiding the
4639 * possible damage by overloading
4641 snd_hda_override_amp_caps(codec, 0x20, HDA_INPUT,
4642 (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
4643 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4644 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4645 (1 << AC_AMPCAP_MUTE_SHIFT));
4647 case AD1884A_MOBILE:
4648 spec->mixers[0] = ad1884a_mobile_mixers;
4649 spec->init_verbs[0] = ad1884a_mobile_verbs;
4650 spec->multiout.dig_out_nid = 0;
4651 codec->patch_ops.unsol_event = ad1884a_hp_unsol_event;
4652 codec->patch_ops.init = ad1884a_hp_init;
4653 /* set the upper-limit for mixer amp to 0dB for avoiding the
4654 * possible damage by overloading
4656 snd_hda_override_amp_caps(codec, 0x20, HDA_INPUT,
4657 (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
4658 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4659 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4660 (1 << AC_AMPCAP_MUTE_SHIFT));
4662 case AD1884A_THINKPAD:
4663 spec->mixers[0] = ad1984a_thinkpad_mixers;
4664 spec->init_verbs[spec->num_init_verbs++] =
4665 ad1984a_thinkpad_verbs;
4666 spec->multiout.dig_out_nid = 0;
4667 spec->input_mux = &ad1984a_thinkpad_capture_source;
4668 codec->patch_ops.unsol_event = ad1984a_thinkpad_unsol_event;
4669 codec->patch_ops.init = ad1984a_thinkpad_init;
4671 case AD1984A_PRECISION:
4672 spec->mixers[0] = ad1984a_precision_mixers;
4673 spec->init_verbs[spec->num_init_verbs++] =
4674 ad1984a_precision_verbs;
4675 spec->multiout.dig_out_nid = 0;
4676 codec->patch_ops.unsol_event = ad1984a_precision_unsol_event;
4677 codec->patch_ops.init = ad1984a_precision_init;
4679 case AD1984A_TOUCHSMART:
4680 spec->mixers[0] = ad1984a_touchsmart_mixers;
4681 spec->init_verbs[0] = ad1984a_touchsmart_verbs;
4682 spec->multiout.dig_out_nid = 0;
4683 codec->patch_ops.unsol_event = ad1984a_touchsmart_unsol_event;
4684 codec->patch_ops.init = ad1984a_touchsmart_init;
4685 /* set the upper-limit for mixer amp to 0dB for avoiding the
4686 * possible damage by overloading
4688 snd_hda_override_amp_caps(codec, 0x20, HDA_INPUT,
4689 (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
4690 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4691 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4692 (1 << AC_AMPCAP_MUTE_SHIFT));
4696 codec->no_trigger_sense = 1;
4697 codec->no_sticky_stream = 1;
4706 * port-A - front hp-out
4707 * port-B - front mic-in
4708 * port-C - rear line-in, shared surr-out (3stack)
4709 * port-D - rear line-out
4710 * port-E - rear mic-in, shared clfe-out (3stack)
4711 * port-F - rear surr-out (6stack)
4712 * port-G - rear clfe-out (6stack)
4715 static hda_nid_t ad1882_dac_nids[3] = {
4719 static hda_nid_t ad1882_adc_nids[2] = {
4723 static hda_nid_t ad1882_capsrc_nids[2] = {
4727 #define AD1882_SPDIF_OUT 0x02
4729 /* list: 0x11, 0x39, 0x3a, 0x18, 0x3c, 0x3b, 0x12, 0x20 */
4730 static struct hda_input_mux ad1882_capture_source = {
4733 { "Front Mic", 0x1 },
4741 /* list: 0x11, 0x39, 0x3a, 0x3c, 0x18, 0x1f, 0x12, 0x20 */
4742 static struct hda_input_mux ad1882a_capture_source = {
4745 { "Front Mic", 0x1 },
4748 { "Digital Mic", 0x06 },
4753 static struct snd_kcontrol_new ad1882_base_mixers[] = {
4754 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
4755 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
4756 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT),
4757 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT),
4758 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
4759 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT),
4760 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT),
4761 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT),
4763 HDA_CODEC_VOLUME("Mic Boost Volume", 0x3c, 0x0, HDA_OUTPUT),
4764 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x39, 0x0, HDA_OUTPUT),
4765 HDA_CODEC_VOLUME("Line-In Boost Volume", 0x3a, 0x0, HDA_OUTPUT),
4766 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
4767 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
4768 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
4769 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
4771 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4772 /* The multiple "Capture Source" controls confuse alsamixer
4773 * So call somewhat different..
4775 /* .name = "Capture Source", */
4776 .name = "Input Source",
4778 .info = ad198x_mux_enum_info,
4779 .get = ad198x_mux_enum_get,
4780 .put = ad198x_mux_enum_put,
4782 /* SPDIF controls */
4783 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
4785 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4786 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
4787 /* identical with ad1983 */
4788 .info = ad1983_spdif_route_info,
4789 .get = ad1983_spdif_route_get,
4790 .put = ad1983_spdif_route_put,
4795 static struct snd_kcontrol_new ad1882_loopback_mixers[] = {
4796 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
4797 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
4798 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
4799 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
4800 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x04, HDA_INPUT),
4801 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x04, HDA_INPUT),
4802 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT),
4803 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT),
4807 static struct snd_kcontrol_new ad1882a_loopback_mixers[] = {
4808 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
4809 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
4810 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x04, HDA_INPUT),
4811 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
4812 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x01, HDA_INPUT),
4813 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x01, HDA_INPUT),
4814 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT),
4815 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT),
4816 HDA_CODEC_VOLUME("Digital Mic Boost Volume", 0x1f, 0x0, HDA_INPUT),
4820 static struct snd_kcontrol_new ad1882_3stack_mixers[] = {
4821 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
4822 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x17, 1, 0x0, HDA_OUTPUT),
4823 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x17, 2, 0x0, HDA_OUTPUT),
4825 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4826 .name = "Channel Mode",
4827 .info = ad198x_ch_mode_info,
4828 .get = ad198x_ch_mode_get,
4829 .put = ad198x_ch_mode_put,
4834 static struct snd_kcontrol_new ad1882_6stack_mixers[] = {
4835 HDA_CODEC_MUTE("Surround Playback Switch", 0x16, 0x0, HDA_OUTPUT),
4836 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x24, 1, 0x0, HDA_OUTPUT),
4837 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x24, 2, 0x0, HDA_OUTPUT),
4841 static struct hda_verb ad1882_ch2_init[] = {
4842 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4843 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4844 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4845 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4846 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4847 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4851 static struct hda_verb ad1882_ch4_init[] = {
4852 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4853 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4854 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4855 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4856 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4857 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4861 static struct hda_verb ad1882_ch6_init[] = {
4862 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4863 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4864 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4865 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4866 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4867 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4871 static struct hda_channel_mode ad1882_modes[3] = {
4872 { 2, ad1882_ch2_init },
4873 { 4, ad1882_ch4_init },
4874 { 6, ad1882_ch6_init },
4878 * initialization verbs
4880 static struct hda_verb ad1882_init_verbs[] = {
4881 /* DACs; mute as default */
4882 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4883 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4884 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4885 /* Port-A (HP) mixer */
4886 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4887 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4889 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4890 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4891 /* HP selector - select DAC2 */
4892 {0x37, AC_VERB_SET_CONNECT_SEL, 0x1},
4893 /* Port-D (Line-out) mixer */
4894 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4895 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4897 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4898 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4899 /* Mono-out mixer */
4900 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4901 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4903 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4904 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4905 /* Port-B (front mic) pin */
4906 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4907 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4908 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* boost */
4909 /* Port-C (line-in) pin */
4910 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4911 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4912 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* boost */
4913 /* Port-C mixer - mute as input */
4914 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4915 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4916 /* Port-E (mic-in) pin */
4917 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4918 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4919 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* boost */
4920 /* Port-E mixer - mute as input */
4921 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4922 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4923 /* Port-F (surround) */
4924 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4925 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4927 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4928 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4929 /* Analog mixer; mute as default */
4930 /* list: 0x39, 0x3a, 0x11, 0x12, 0x3c, 0x3b, 0x18, 0x1a */
4931 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4932 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4933 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4934 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4935 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4936 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
4937 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
4938 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
4939 /* Analog Mix output amp */
4940 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
4941 /* SPDIF output selector */
4942 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
4943 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */
4944 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
4948 #ifdef CONFIG_SND_HDA_POWER_SAVE
4949 static struct hda_amp_list ad1882_loopbacks[] = {
4950 { 0x20, HDA_INPUT, 0 }, /* Front Mic */
4951 { 0x20, HDA_INPUT, 1 }, /* Mic */
4952 { 0x20, HDA_INPUT, 4 }, /* Line */
4953 { 0x20, HDA_INPUT, 6 }, /* CD */
4965 static const char * const ad1882_models[AD1986A_MODELS] = {
4966 [AD1882_3STACK] = "3stack",
4967 [AD1882_6STACK] = "6stack",
4971 static int patch_ad1882(struct hda_codec *codec)
4973 struct ad198x_spec *spec;
4974 int err, board_config;
4976 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4982 err = snd_hda_attach_beep_device(codec, 0x10);
4987 set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
4989 spec->multiout.max_channels = 6;
4990 spec->multiout.num_dacs = 3;
4991 spec->multiout.dac_nids = ad1882_dac_nids;
4992 spec->multiout.dig_out_nid = AD1882_SPDIF_OUT;
4993 spec->num_adc_nids = ARRAY_SIZE(ad1882_adc_nids);
4994 spec->adc_nids = ad1882_adc_nids;
4995 spec->capsrc_nids = ad1882_capsrc_nids;
4996 if (codec->vendor_id == 0x11d41882)
4997 spec->input_mux = &ad1882_capture_source;
4999 spec->input_mux = &ad1882a_capture_source;
5000 spec->num_mixers = 2;
5001 spec->mixers[0] = ad1882_base_mixers;
5002 if (codec->vendor_id == 0x11d41882)
5003 spec->mixers[1] = ad1882_loopback_mixers;
5005 spec->mixers[1] = ad1882a_loopback_mixers;
5006 spec->num_init_verbs = 1;
5007 spec->init_verbs[0] = ad1882_init_verbs;
5008 spec->spdif_route = 0;
5009 #ifdef CONFIG_SND_HDA_POWER_SAVE
5010 spec->loopback.amplist = ad1882_loopbacks;
5012 spec->vmaster_nid = 0x04;
5014 codec->patch_ops = ad198x_patch_ops;
5016 /* override some parameters */
5017 board_config = snd_hda_check_board_config(codec, AD1882_MODELS,
5018 ad1882_models, NULL);
5019 switch (board_config) {
5022 spec->num_mixers = 3;
5023 spec->mixers[2] = ad1882_3stack_mixers;
5024 spec->channel_mode = ad1882_modes;
5025 spec->num_channel_mode = ARRAY_SIZE(ad1882_modes);
5026 spec->need_dac_fix = 1;
5027 spec->multiout.max_channels = 2;
5028 spec->multiout.num_dacs = 1;
5031 spec->num_mixers = 3;
5032 spec->mixers[2] = ad1882_6stack_mixers;
5036 codec->no_trigger_sense = 1;
5037 codec->no_sticky_stream = 1;
5046 static struct hda_codec_preset snd_hda_preset_analog[] = {
5047 { .id = 0x11d4184a, .name = "AD1884A", .patch = patch_ad1884a },
5048 { .id = 0x11d41882, .name = "AD1882", .patch = patch_ad1882 },
5049 { .id = 0x11d41883, .name = "AD1883", .patch = patch_ad1884a },
5050 { .id = 0x11d41884, .name = "AD1884", .patch = patch_ad1884 },
5051 { .id = 0x11d4194a, .name = "AD1984A", .patch = patch_ad1884a },
5052 { .id = 0x11d4194b, .name = "AD1984B", .patch = patch_ad1884a },
5053 { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 },
5054 { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 },
5055 { .id = 0x11d41984, .name = "AD1984", .patch = patch_ad1984 },
5056 { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a },
5057 { .id = 0x11d41988, .name = "AD1988", .patch = patch_ad1988 },
5058 { .id = 0x11d4198b, .name = "AD1988B", .patch = patch_ad1988 },
5059 { .id = 0x11d4882a, .name = "AD1882A", .patch = patch_ad1882 },
5060 { .id = 0x11d4989a, .name = "AD1989A", .patch = patch_ad1988 },
5061 { .id = 0x11d4989b, .name = "AD1989B", .patch = patch_ad1988 },
5065 MODULE_ALIAS("snd-hda-codec-id:11d4*");
5067 MODULE_LICENSE("GPL");
5068 MODULE_DESCRIPTION("Analog Devices HD-audio codec");
5070 static struct hda_codec_preset_list analog_list = {
5071 .preset = snd_hda_preset_analog,
5072 .owner = THIS_MODULE,
5075 static int __init patch_analog_init(void)
5077 return snd_hda_add_codec_preset(&analog_list);
5080 static void __exit patch_analog_exit(void)
5082 snd_hda_delete_codec_preset(&analog_list);
5085 module_init(patch_analog_init)
5086 module_exit(patch_analog_exit)