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"
30 #include "hda_patch.h"
33 struct snd_kcontrol_new *mixers[5];
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;
50 unsigned int num_adc_nids;
52 hda_nid_t dig_in_nid; /* digital-in NID; optional */
55 const struct hda_input_mux *input_mux;
56 hda_nid_t *capsrc_nids;
57 unsigned int cur_mux[3];
60 const struct hda_channel_mode *channel_mode;
64 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
66 unsigned int spdif_route;
68 /* dynamic controls, init_verbs and input_mux */
69 struct auto_pin_cfg autocfg;
70 unsigned int num_kctl_alloc, num_kctl_used;
71 struct snd_kcontrol_new *kctl_alloc;
72 struct hda_input_mux private_imux;
73 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
75 unsigned int jack_present :1;
77 #ifdef CONFIG_SND_HDA_POWER_SAVE
78 struct hda_loopback_check loopback;
80 /* for virtual master */
81 hda_nid_t vmaster_nid;
82 const char **slave_vols;
83 const char **slave_sws;
87 * input MUX handling (common part)
89 static int ad198x_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
91 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
92 struct ad198x_spec *spec = codec->spec;
94 return snd_hda_input_mux_info(spec->input_mux, uinfo);
97 static int ad198x_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
99 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
100 struct ad198x_spec *spec = codec->spec;
101 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
103 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
107 static int ad198x_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
109 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
110 struct ad198x_spec *spec = codec->spec;
111 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
113 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
114 spec->capsrc_nids[adc_idx],
115 &spec->cur_mux[adc_idx]);
119 * initialization (common callbacks)
121 static int ad198x_init(struct hda_codec *codec)
123 struct ad198x_spec *spec = codec->spec;
126 for (i = 0; i < spec->num_init_verbs; i++)
127 snd_hda_sequence_write(codec, spec->init_verbs[i]);
131 static const char *ad_slave_vols[] = {
132 "Front Playback Volume",
133 "Surround Playback Volume",
134 "Center Playback Volume",
135 "LFE Playback Volume",
136 "Side Playback Volume",
137 "Headphone Playback Volume",
138 "Mono Playback Volume",
139 "Speaker Playback Volume",
140 "IEC958 Playback Volume",
144 static const char *ad_slave_sws[] = {
145 "Front Playback Switch",
146 "Surround Playback Switch",
147 "Center Playback Switch",
148 "LFE Playback Switch",
149 "Side Playback Switch",
150 "Headphone Playback Switch",
151 "Mono Playback Switch",
152 "Speaker Playback Switch",
153 "IEC958 Playback Switch",
157 static int ad198x_build_controls(struct hda_codec *codec)
159 struct ad198x_spec *spec = codec->spec;
163 for (i = 0; i < spec->num_mixers; i++) {
164 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
168 if (spec->multiout.dig_out_nid) {
169 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
172 err = snd_hda_create_spdif_share_sw(codec,
176 spec->multiout.share_spdif = 1;
178 if (spec->dig_in_nid) {
179 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
184 /* if we have no master control, let's create it */
185 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
186 unsigned int vmaster_tlv[4];
187 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
188 HDA_OUTPUT, vmaster_tlv);
189 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
192 spec->slave_vols : ad_slave_vols));
196 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
197 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
200 spec->slave_sws : ad_slave_sws));
208 #ifdef CONFIG_SND_HDA_POWER_SAVE
209 static int ad198x_check_power_status(struct hda_codec *codec, hda_nid_t nid)
211 struct ad198x_spec *spec = codec->spec;
212 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
217 * Analog playback callbacks
219 static int ad198x_playback_pcm_open(struct hda_pcm_stream *hinfo,
220 struct hda_codec *codec,
221 struct snd_pcm_substream *substream)
223 struct ad198x_spec *spec = codec->spec;
224 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
228 static int ad198x_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
229 struct hda_codec *codec,
230 unsigned int stream_tag,
232 struct snd_pcm_substream *substream)
234 struct ad198x_spec *spec = codec->spec;
235 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
239 static int ad198x_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
240 struct hda_codec *codec,
241 struct snd_pcm_substream *substream)
243 struct ad198x_spec *spec = codec->spec;
244 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
250 static int ad198x_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
251 struct hda_codec *codec,
252 struct snd_pcm_substream *substream)
254 struct ad198x_spec *spec = codec->spec;
255 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
258 static int ad198x_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
259 struct hda_codec *codec,
260 struct snd_pcm_substream *substream)
262 struct ad198x_spec *spec = codec->spec;
263 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
266 static int ad198x_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
267 struct hda_codec *codec,
268 unsigned int stream_tag,
270 struct snd_pcm_substream *substream)
272 struct ad198x_spec *spec = codec->spec;
273 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag,
280 static int ad198x_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
281 struct hda_codec *codec,
282 unsigned int stream_tag,
284 struct snd_pcm_substream *substream)
286 struct ad198x_spec *spec = codec->spec;
287 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
288 stream_tag, 0, format);
292 static int ad198x_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
293 struct hda_codec *codec,
294 struct snd_pcm_substream *substream)
296 struct ad198x_spec *spec = codec->spec;
297 snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
304 static struct hda_pcm_stream ad198x_pcm_analog_playback = {
307 .channels_max = 6, /* changed later */
308 .nid = 0, /* fill later */
310 .open = ad198x_playback_pcm_open,
311 .prepare = ad198x_playback_pcm_prepare,
312 .cleanup = ad198x_playback_pcm_cleanup
316 static struct hda_pcm_stream ad198x_pcm_analog_capture = {
320 .nid = 0, /* fill later */
322 .prepare = ad198x_capture_pcm_prepare,
323 .cleanup = ad198x_capture_pcm_cleanup
327 static struct hda_pcm_stream ad198x_pcm_digital_playback = {
331 .nid = 0, /* fill later */
333 .open = ad198x_dig_playback_pcm_open,
334 .close = ad198x_dig_playback_pcm_close,
335 .prepare = ad198x_dig_playback_pcm_prepare
339 static struct hda_pcm_stream ad198x_pcm_digital_capture = {
343 /* NID is set in alc_build_pcms */
346 static int ad198x_build_pcms(struct hda_codec *codec)
348 struct ad198x_spec *spec = codec->spec;
349 struct hda_pcm *info = spec->pcm_rec;
352 codec->pcm_info = info;
354 info->name = "AD198x Analog";
355 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_analog_playback;
356 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->multiout.max_channels;
357 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
358 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_analog_capture;
359 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adc_nids;
360 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
362 if (spec->multiout.dig_out_nid) {
365 info->name = "AD198x Digital";
366 info->pcm_type = HDA_PCM_TYPE_SPDIF;
367 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_digital_playback;
368 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
369 if (spec->dig_in_nid) {
370 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_digital_capture;
371 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
378 static void ad198x_free(struct hda_codec *codec)
380 struct ad198x_spec *spec = codec->spec;
383 if (spec->kctl_alloc) {
384 for (i = 0; i < spec->num_kctl_used; i++)
385 kfree(spec->kctl_alloc[i].name);
386 kfree(spec->kctl_alloc);
391 static struct hda_codec_ops ad198x_patch_ops = {
392 .build_controls = ad198x_build_controls,
393 .build_pcms = ad198x_build_pcms,
396 #ifdef CONFIG_SND_HDA_POWER_SAVE
397 .check_power_status = ad198x_check_power_status,
404 * the private value = nid | (invert << 8)
406 #define ad198x_eapd_info snd_ctl_boolean_mono_info
408 static int ad198x_eapd_get(struct snd_kcontrol *kcontrol,
409 struct snd_ctl_elem_value *ucontrol)
411 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
412 struct ad198x_spec *spec = codec->spec;
413 int invert = (kcontrol->private_value >> 8) & 1;
415 ucontrol->value.integer.value[0] = ! spec->cur_eapd;
417 ucontrol->value.integer.value[0] = spec->cur_eapd;
421 static int ad198x_eapd_put(struct snd_kcontrol *kcontrol,
422 struct snd_ctl_elem_value *ucontrol)
424 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
425 struct ad198x_spec *spec = codec->spec;
426 int invert = (kcontrol->private_value >> 8) & 1;
427 hda_nid_t nid = kcontrol->private_value & 0xff;
429 eapd = !!ucontrol->value.integer.value[0];
432 if (eapd == spec->cur_eapd)
434 spec->cur_eapd = eapd;
435 snd_hda_codec_write_cache(codec, nid,
436 0, AC_VERB_SET_EAPD_BTLENABLE,
441 static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol,
442 struct snd_ctl_elem_info *uinfo);
443 static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol,
444 struct snd_ctl_elem_value *ucontrol);
445 static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol,
446 struct snd_ctl_elem_value *ucontrol);
453 #define AD1986A_SPDIF_OUT 0x02
454 #define AD1986A_FRONT_DAC 0x03
455 #define AD1986A_SURR_DAC 0x04
456 #define AD1986A_CLFE_DAC 0x05
457 #define AD1986A_ADC 0x06
459 static hda_nid_t ad1986a_dac_nids[3] = {
460 AD1986A_FRONT_DAC, AD1986A_SURR_DAC, AD1986A_CLFE_DAC
462 static hda_nid_t ad1986a_adc_nids[1] = { AD1986A_ADC };
463 static hda_nid_t ad1986a_capsrc_nids[1] = { 0x12 };
465 static struct hda_input_mux ad1986a_capture_source = {
479 static struct hda_bind_ctls ad1986a_bind_pcm_vol = {
480 .ops = &snd_hda_bind_vol,
482 HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT),
483 HDA_COMPOSE_AMP_VAL(AD1986A_SURR_DAC, 3, 0, HDA_OUTPUT),
484 HDA_COMPOSE_AMP_VAL(AD1986A_CLFE_DAC, 3, 0, HDA_OUTPUT),
489 static struct hda_bind_ctls ad1986a_bind_pcm_sw = {
490 .ops = &snd_hda_bind_sw,
492 HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT),
493 HDA_COMPOSE_AMP_VAL(AD1986A_SURR_DAC, 3, 0, HDA_OUTPUT),
494 HDA_COMPOSE_AMP_VAL(AD1986A_CLFE_DAC, 3, 0, HDA_OUTPUT),
502 static struct snd_kcontrol_new ad1986a_mixers[] = {
504 * bind volumes/mutes of 3 DACs as a single PCM control for simplicity
506 HDA_BIND_VOL("PCM Playback Volume", &ad1986a_bind_pcm_vol),
507 HDA_BIND_SW("PCM Playback Switch", &ad1986a_bind_pcm_sw),
508 HDA_CODEC_VOLUME("Front Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
509 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
510 HDA_CODEC_VOLUME("Surround Playback Volume", 0x1c, 0x0, HDA_OUTPUT),
511 HDA_CODEC_MUTE("Surround Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
512 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x1d, 1, 0x0, HDA_OUTPUT),
513 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x1d, 2, 0x0, HDA_OUTPUT),
514 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x1d, 1, 0x0, HDA_OUTPUT),
515 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x1d, 2, 0x0, HDA_OUTPUT),
516 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT),
517 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
518 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT),
519 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT),
520 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT),
521 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT),
522 HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT),
523 HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT),
524 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
525 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
526 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
527 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT),
528 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT),
529 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
530 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT),
531 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
532 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
534 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
535 .name = "Capture Source",
536 .info = ad198x_mux_enum_info,
537 .get = ad198x_mux_enum_get,
538 .put = ad198x_mux_enum_put,
540 HDA_CODEC_MUTE("Stereo Downmix Switch", 0x09, 0x0, HDA_OUTPUT),
544 /* additional mixers for 3stack mode */
545 static struct snd_kcontrol_new ad1986a_3st_mixers[] = {
547 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
548 .name = "Channel Mode",
549 .info = ad198x_ch_mode_info,
550 .get = ad198x_ch_mode_get,
551 .put = ad198x_ch_mode_put,
556 /* laptop model - 2ch only */
557 static hda_nid_t ad1986a_laptop_dac_nids[1] = { AD1986A_FRONT_DAC };
559 /* master controls both pins 0x1a and 0x1b */
560 static struct hda_bind_ctls ad1986a_laptop_master_vol = {
561 .ops = &snd_hda_bind_vol,
563 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT),
564 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
569 static struct hda_bind_ctls ad1986a_laptop_master_sw = {
570 .ops = &snd_hda_bind_sw,
572 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT),
573 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
578 static struct snd_kcontrol_new ad1986a_laptop_mixers[] = {
579 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
580 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
581 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol),
582 HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw),
583 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT),
584 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT),
585 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT),
586 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT),
587 HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT),
588 HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT),
589 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
590 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
591 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
592 /* HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT),
593 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT),
594 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
595 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), */
596 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
597 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
599 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
600 .name = "Capture Source",
601 .info = ad198x_mux_enum_info,
602 .get = ad198x_mux_enum_get,
603 .put = ad198x_mux_enum_put,
608 /* laptop-eapd model - 2ch only */
610 static struct hda_input_mux ad1986a_laptop_eapd_capture_source = {
614 { "Internal Mic", 0x4 },
619 static struct hda_input_mux ad1986a_automic_capture_source = {
627 static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = {
628 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol),
629 HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw),
630 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
631 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
632 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
633 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
634 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
635 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
636 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
638 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
639 .name = "Capture Source",
640 .info = ad198x_mux_enum_info,
641 .get = ad198x_mux_enum_get,
642 .put = ad198x_mux_enum_put,
645 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
646 .name = "External Amplifier",
647 .info = ad198x_eapd_info,
648 .get = ad198x_eapd_get,
649 .put = ad198x_eapd_put,
650 .private_value = 0x1b | (1 << 8), /* port-D, inversed */
655 /* re-connect the mic boost input according to the jack sensing */
656 static void ad1986a_automic(struct hda_codec *codec)
658 unsigned int present;
659 present = snd_hda_codec_read(codec, 0x1f, 0, AC_VERB_GET_PIN_SENSE, 0);
660 /* 0 = 0x1f, 2 = 0x1d, 4 = mixed */
661 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_CONNECT_SEL,
662 (present & AC_PINSENSE_PRESENCE) ? 0 : 2);
665 #define AD1986A_MIC_EVENT 0x36
667 static void ad1986a_automic_unsol_event(struct hda_codec *codec,
670 if ((res >> 26) != AD1986A_MIC_EVENT)
672 ad1986a_automic(codec);
675 static int ad1986a_automic_init(struct hda_codec *codec)
678 ad1986a_automic(codec);
682 /* laptop-automute - 2ch only */
684 static void ad1986a_update_hp(struct hda_codec *codec)
686 struct ad198x_spec *spec = codec->spec;
689 if (spec->jack_present)
690 mute = HDA_AMP_MUTE; /* mute internal speaker */
692 /* unmute internal speaker if necessary */
693 mute = snd_hda_codec_amp_read(codec, 0x1a, 0, HDA_OUTPUT, 0);
694 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
698 static void ad1986a_hp_automute(struct hda_codec *codec)
700 struct ad198x_spec *spec = codec->spec;
701 unsigned int present;
703 present = snd_hda_codec_read(codec, 0x1a, 0, AC_VERB_GET_PIN_SENSE, 0);
704 /* Lenovo N100 seems to report the reversed bit for HP jack-sensing */
705 spec->jack_present = !(present & 0x80000000);
706 ad1986a_update_hp(codec);
709 #define AD1986A_HP_EVENT 0x37
711 static void ad1986a_hp_unsol_event(struct hda_codec *codec, unsigned int res)
713 if ((res >> 26) != AD1986A_HP_EVENT)
715 ad1986a_hp_automute(codec);
718 static int ad1986a_hp_init(struct hda_codec *codec)
721 ad1986a_hp_automute(codec);
725 /* bind hp and internal speaker mute (with plug check) */
726 static int ad1986a_hp_master_sw_put(struct snd_kcontrol *kcontrol,
727 struct snd_ctl_elem_value *ucontrol)
729 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
730 long *valp = ucontrol->value.integer.value;
733 change = snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0,
735 valp[0] ? 0 : HDA_AMP_MUTE);
736 change |= snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0,
738 valp[1] ? 0 : HDA_AMP_MUTE);
740 ad1986a_update_hp(codec);
744 static struct snd_kcontrol_new ad1986a_laptop_automute_mixers[] = {
745 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol),
747 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
748 .name = "Master Playback Switch",
749 .info = snd_hda_mixer_amp_switch_info,
750 .get = snd_hda_mixer_amp_switch_get,
751 .put = ad1986a_hp_master_sw_put,
752 .private_value = HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT),
754 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
755 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
756 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x0, HDA_OUTPUT),
757 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x0, HDA_OUTPUT),
758 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
759 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
760 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
761 HDA_CODEC_VOLUME("Beep Playback Volume", 0x18, 0x0, HDA_OUTPUT),
762 HDA_CODEC_MUTE("Beep Playback Switch", 0x18, 0x0, HDA_OUTPUT),
763 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
764 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
766 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
767 .name = "Capture Source",
768 .info = ad198x_mux_enum_info,
769 .get = ad198x_mux_enum_get,
770 .put = ad198x_mux_enum_put,
773 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
774 .name = "External Amplifier",
775 .info = ad198x_eapd_info,
776 .get = ad198x_eapd_get,
777 .put = ad198x_eapd_put,
778 .private_value = 0x1b | (1 << 8), /* port-D, inversed */
784 * initialization verbs
786 static struct hda_verb ad1986a_init_verbs[] = {
787 /* Front, Surround, CLFE DAC; mute as default */
788 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
789 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
790 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
792 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
793 /* HP, Line-Out, Surround, CLFE selectors */
794 {0x0a, AC_VERB_SET_CONNECT_SEL, 0x0},
795 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x0},
796 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0},
797 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
799 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x0},
800 /* Mic selector: Mic 1/2 pin */
801 {0x0f, AC_VERB_SET_CONNECT_SEL, 0x0},
802 /* Line-in selector: Line-in */
803 {0x10, AC_VERB_SET_CONNECT_SEL, 0x0},
805 {0x11, AC_VERB_SET_CONNECT_SEL, 0x0},
806 /* Record selector: mic */
807 {0x12, AC_VERB_SET_CONNECT_SEL, 0x0},
808 /* Mic, Phone, CD, Aux, Line-In amp; mute as default */
809 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
810 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
811 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
812 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
813 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
815 {0x18, AC_VERB_SET_CONNECT_SEL, 0x0},
816 /* HP, Line-Out, Surround, CLFE, Mono pins; mute as default */
817 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
818 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
819 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
820 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
821 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
823 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
824 /* Front, Surround, CLFE Pins */
825 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
826 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
827 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
829 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
831 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
832 /* Line, Aux, CD, Beep-In Pin */
833 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
834 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
835 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
836 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
837 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
841 static struct hda_verb ad1986a_ch2_init[] = {
842 /* Surround out -> Line In */
843 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
844 /* Line-in selectors */
845 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x1 },
847 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
848 /* Mic selector, mix C/LFE (backmic) and Mic (frontmic) */
849 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 },
853 static struct hda_verb ad1986a_ch4_init[] = {
854 /* Surround out -> Surround */
855 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
856 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
858 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
859 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 },
863 static struct hda_verb ad1986a_ch6_init[] = {
864 /* Surround out -> Surround out */
865 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
866 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
868 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
869 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x0 },
873 static struct hda_channel_mode ad1986a_modes[3] = {
874 { 2, ad1986a_ch2_init },
875 { 4, ad1986a_ch4_init },
876 { 6, ad1986a_ch6_init },
879 /* eapd initialization */
880 static struct hda_verb ad1986a_eapd_init_verbs[] = {
881 {0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00 },
885 static struct hda_verb ad1986a_automic_verbs[] = {
886 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
887 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
888 /*{0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},*/
889 {0x0f, AC_VERB_SET_CONNECT_SEL, 0x0},
890 {0x1f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1986A_MIC_EVENT},
894 /* Ultra initialization */
895 static struct hda_verb ad1986a_ultra_init[] = {
896 /* eapd initialization */
897 { 0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00 },
899 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2 },
900 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
901 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
905 /* pin sensing on HP jack */
906 static struct hda_verb ad1986a_hp_init_verbs[] = {
907 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1986A_HP_EVENT},
918 AD1986A_LAPTOP_AUTOMUTE,
923 static const char *ad1986a_models[AD1986A_MODELS] = {
924 [AD1986A_6STACK] = "6stack",
925 [AD1986A_3STACK] = "3stack",
926 [AD1986A_LAPTOP] = "laptop",
927 [AD1986A_LAPTOP_EAPD] = "laptop-eapd",
928 [AD1986A_LAPTOP_AUTOMUTE] = "laptop-automute",
929 [AD1986A_ULTRA] = "ultra",
932 static struct snd_pci_quirk ad1986a_cfg_tbl[] = {
933 SND_PCI_QUIRK(0x103c, 0x30af, "HP B2800", AD1986A_LAPTOP_EAPD),
934 SND_PCI_QUIRK(0x1043, 0x1153, "ASUS M9", AD1986A_LAPTOP_EAPD),
935 SND_PCI_QUIRK(0x1043, 0x11f7, "ASUS U5A", AD1986A_LAPTOP_EAPD),
936 SND_PCI_QUIRK(0x1043, 0x1213, "ASUS A6J", AD1986A_LAPTOP_EAPD),
937 SND_PCI_QUIRK(0x1043, 0x1263, "ASUS U5F", AD1986A_LAPTOP_EAPD),
938 SND_PCI_QUIRK(0x1043, 0x1297, "ASUS Z62F", AD1986A_LAPTOP_EAPD),
939 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS V1j", AD1986A_LAPTOP_EAPD),
940 SND_PCI_QUIRK(0x1043, 0x1302, "ASUS W3j", AD1986A_LAPTOP_EAPD),
941 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS VX1", AD1986A_LAPTOP),
942 SND_PCI_QUIRK(0x1043, 0x1447, "ASUS A8J", AD1986A_3STACK),
943 SND_PCI_QUIRK(0x1043, 0x817f, "ASUS P5", AD1986A_3STACK),
944 SND_PCI_QUIRK(0x1043, 0x818f, "ASUS P5", AD1986A_LAPTOP),
945 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS P5", AD1986A_3STACK),
946 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS M2N", AD1986A_3STACK),
947 SND_PCI_QUIRK(0x1043, 0x8234, "ASUS M2N", AD1986A_3STACK),
948 SND_PCI_QUIRK(0x10de, 0xcb84, "ASUS A8N-VM", AD1986A_3STACK),
949 SND_PCI_QUIRK(0x1179, 0xff40, "Toshiba", AD1986A_LAPTOP_EAPD),
950 SND_PCI_QUIRK(0x144d, 0xb03c, "Samsung R55", AD1986A_3STACK),
951 SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP),
952 SND_PCI_QUIRK(0x144d, 0xc023, "Samsung X60", AD1986A_LAPTOP_EAPD),
953 SND_PCI_QUIRK(0x144d, 0xc024, "Samsung R65", AD1986A_LAPTOP_EAPD),
954 SND_PCI_QUIRK(0x144d, 0xc026, "Samsung X11", AD1986A_LAPTOP_EAPD),
955 SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_ULTRA),
956 SND_PCI_QUIRK(0x144d, 0xc504, "Samsung Q35", AD1986A_3STACK),
957 SND_PCI_QUIRK(0x17aa, 0x1011, "Lenovo M55", AD1986A_LAPTOP),
958 SND_PCI_QUIRK(0x17aa, 0x1017, "Lenovo A60", AD1986A_3STACK),
959 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo N100", AD1986A_LAPTOP_AUTOMUTE),
960 SND_PCI_QUIRK(0x17c0, 0x2017, "Samsung M50", AD1986A_LAPTOP),
964 #ifdef CONFIG_SND_HDA_POWER_SAVE
965 static struct hda_amp_list ad1986a_loopbacks[] = {
966 { 0x13, HDA_OUTPUT, 0 }, /* Mic */
967 { 0x14, HDA_OUTPUT, 0 }, /* Phone */
968 { 0x15, HDA_OUTPUT, 0 }, /* CD */
969 { 0x16, HDA_OUTPUT, 0 }, /* Aux */
970 { 0x17, HDA_OUTPUT, 0 }, /* Line */
975 static int is_jack_available(struct hda_codec *codec, hda_nid_t nid)
977 unsigned int conf = snd_hda_codec_read(codec, nid, 0,
978 AC_VERB_GET_CONFIG_DEFAULT, 0);
979 return get_defcfg_connect(conf) != AC_JACK_PORT_NONE;
982 static int patch_ad1986a(struct hda_codec *codec)
984 struct ad198x_spec *spec;
987 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
993 spec->multiout.max_channels = 6;
994 spec->multiout.num_dacs = ARRAY_SIZE(ad1986a_dac_nids);
995 spec->multiout.dac_nids = ad1986a_dac_nids;
996 spec->multiout.dig_out_nid = AD1986A_SPDIF_OUT;
997 spec->num_adc_nids = 1;
998 spec->adc_nids = ad1986a_adc_nids;
999 spec->capsrc_nids = ad1986a_capsrc_nids;
1000 spec->input_mux = &ad1986a_capture_source;
1001 spec->num_mixers = 1;
1002 spec->mixers[0] = ad1986a_mixers;
1003 spec->num_init_verbs = 1;
1004 spec->init_verbs[0] = ad1986a_init_verbs;
1005 #ifdef CONFIG_SND_HDA_POWER_SAVE
1006 spec->loopback.amplist = ad1986a_loopbacks;
1008 spec->vmaster_nid = 0x1b;
1010 codec->patch_ops = ad198x_patch_ops;
1012 /* override some parameters */
1013 board_config = snd_hda_check_board_config(codec, AD1986A_MODELS,
1016 switch (board_config) {
1017 case AD1986A_3STACK:
1018 spec->num_mixers = 2;
1019 spec->mixers[1] = ad1986a_3st_mixers;
1020 spec->num_init_verbs = 2;
1021 spec->init_verbs[1] = ad1986a_ch2_init;
1022 spec->channel_mode = ad1986a_modes;
1023 spec->num_channel_mode = ARRAY_SIZE(ad1986a_modes);
1024 spec->need_dac_fix = 1;
1025 spec->multiout.max_channels = 2;
1026 spec->multiout.num_dacs = 1;
1028 case AD1986A_LAPTOP:
1029 spec->mixers[0] = ad1986a_laptop_mixers;
1030 spec->multiout.max_channels = 2;
1031 spec->multiout.num_dacs = 1;
1032 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
1034 case AD1986A_LAPTOP_EAPD:
1035 spec->mixers[0] = ad1986a_laptop_eapd_mixers;
1036 spec->num_init_verbs = 3;
1037 spec->init_verbs[1] = ad1986a_eapd_init_verbs;
1038 spec->init_verbs[2] = ad1986a_automic_verbs;
1039 spec->multiout.max_channels = 2;
1040 spec->multiout.num_dacs = 1;
1041 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
1042 if (!is_jack_available(codec, 0x25))
1043 spec->multiout.dig_out_nid = 0;
1044 spec->input_mux = &ad1986a_automic_capture_source;
1045 codec->patch_ops.unsol_event = ad1986a_automic_unsol_event;
1046 codec->patch_ops.init = ad1986a_automic_init;
1048 case AD1986A_LAPTOP_AUTOMUTE:
1049 spec->mixers[0] = ad1986a_laptop_automute_mixers;
1050 spec->num_init_verbs = 3;
1051 spec->init_verbs[1] = ad1986a_eapd_init_verbs;
1052 spec->init_verbs[2] = ad1986a_hp_init_verbs;
1053 spec->multiout.max_channels = 2;
1054 spec->multiout.num_dacs = 1;
1055 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
1056 if (!is_jack_available(codec, 0x25))
1057 spec->multiout.dig_out_nid = 0;
1058 spec->input_mux = &ad1986a_laptop_eapd_capture_source;
1059 codec->patch_ops.unsol_event = ad1986a_hp_unsol_event;
1060 codec->patch_ops.init = ad1986a_hp_init;
1063 spec->mixers[0] = ad1986a_laptop_eapd_mixers;
1064 spec->num_init_verbs = 2;
1065 spec->init_verbs[1] = ad1986a_ultra_init;
1066 spec->multiout.max_channels = 2;
1067 spec->multiout.num_dacs = 1;
1068 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
1069 spec->multiout.dig_out_nid = 0;
1073 /* AD1986A has a hardware problem that it can't share a stream
1074 * with multiple output pins. The copy of front to surrounds
1075 * causes noisy or silent outputs at a certain timing, e.g.
1076 * changing the volume.
1077 * So, let's disable the shared stream.
1079 spec->multiout.no_share_stream = 1;
1088 #define AD1983_SPDIF_OUT 0x02
1089 #define AD1983_DAC 0x03
1090 #define AD1983_ADC 0x04
1092 static hda_nid_t ad1983_dac_nids[1] = { AD1983_DAC };
1093 static hda_nid_t ad1983_adc_nids[1] = { AD1983_ADC };
1094 static hda_nid_t ad1983_capsrc_nids[1] = { 0x15 };
1096 static struct hda_input_mux ad1983_capture_source = {
1102 { "Mix Mono", 0x3 },
1107 * SPDIF playback route
1109 static int ad1983_spdif_route_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1111 static char *texts[] = { "PCM", "ADC" };
1113 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1115 uinfo->value.enumerated.items = 2;
1116 if (uinfo->value.enumerated.item > 1)
1117 uinfo->value.enumerated.item = 1;
1118 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1122 static int ad1983_spdif_route_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1124 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1125 struct ad198x_spec *spec = codec->spec;
1127 ucontrol->value.enumerated.item[0] = spec->spdif_route;
1131 static int ad1983_spdif_route_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1133 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1134 struct ad198x_spec *spec = codec->spec;
1136 if (ucontrol->value.enumerated.item[0] > 1)
1138 if (spec->spdif_route != ucontrol->value.enumerated.item[0]) {
1139 spec->spdif_route = ucontrol->value.enumerated.item[0];
1140 snd_hda_codec_write_cache(codec, spec->multiout.dig_out_nid, 0,
1141 AC_VERB_SET_CONNECT_SEL,
1148 static struct snd_kcontrol_new ad1983_mixers[] = {
1149 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT),
1150 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT),
1151 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT),
1152 HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT),
1153 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT),
1154 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT),
1155 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
1156 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
1157 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
1158 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
1159 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1160 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1161 HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x10, 1, 0x0, HDA_OUTPUT),
1162 HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x10, 1, 0x0, HDA_OUTPUT),
1163 HDA_CODEC_VOLUME("Mic Boost", 0x0c, 0x0, HDA_OUTPUT),
1164 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1165 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
1167 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1168 .name = "Capture Source",
1169 .info = ad198x_mux_enum_info,
1170 .get = ad198x_mux_enum_get,
1171 .put = ad198x_mux_enum_put,
1174 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1175 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
1176 .info = ad1983_spdif_route_info,
1177 .get = ad1983_spdif_route_get,
1178 .put = ad1983_spdif_route_put,
1183 static struct hda_verb ad1983_init_verbs[] = {
1184 /* Front, HP, Mono; mute as default */
1185 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1186 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1187 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1188 /* Beep, PCM, Mic, Line-In: mute */
1189 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1190 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1191 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1192 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1193 /* Front, HP selectors; from Mix */
1194 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
1195 {0x06, AC_VERB_SET_CONNECT_SEL, 0x01},
1196 /* Mono selector; from Mix */
1197 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03},
1198 /* Mic selector; Mic */
1199 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0},
1200 /* Line-in selector: Line-in */
1201 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
1202 /* Mic boost: 0dB */
1203 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1204 /* Record selector: mic */
1205 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0},
1206 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1207 /* SPDIF route: PCM */
1208 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0},
1210 {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1212 {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
1214 {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1216 {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
1218 {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
1222 #ifdef CONFIG_SND_HDA_POWER_SAVE
1223 static struct hda_amp_list ad1983_loopbacks[] = {
1224 { 0x12, HDA_OUTPUT, 0 }, /* Mic */
1225 { 0x13, HDA_OUTPUT, 0 }, /* Line */
1230 static int patch_ad1983(struct hda_codec *codec)
1232 struct ad198x_spec *spec;
1234 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1240 spec->multiout.max_channels = 2;
1241 spec->multiout.num_dacs = ARRAY_SIZE(ad1983_dac_nids);
1242 spec->multiout.dac_nids = ad1983_dac_nids;
1243 spec->multiout.dig_out_nid = AD1983_SPDIF_OUT;
1244 spec->num_adc_nids = 1;
1245 spec->adc_nids = ad1983_adc_nids;
1246 spec->capsrc_nids = ad1983_capsrc_nids;
1247 spec->input_mux = &ad1983_capture_source;
1248 spec->num_mixers = 1;
1249 spec->mixers[0] = ad1983_mixers;
1250 spec->num_init_verbs = 1;
1251 spec->init_verbs[0] = ad1983_init_verbs;
1252 spec->spdif_route = 0;
1253 #ifdef CONFIG_SND_HDA_POWER_SAVE
1254 spec->loopback.amplist = ad1983_loopbacks;
1256 spec->vmaster_nid = 0x05;
1258 codec->patch_ops = ad198x_patch_ops;
1265 * AD1981 HD specific
1268 #define AD1981_SPDIF_OUT 0x02
1269 #define AD1981_DAC 0x03
1270 #define AD1981_ADC 0x04
1272 static hda_nid_t ad1981_dac_nids[1] = { AD1981_DAC };
1273 static hda_nid_t ad1981_adc_nids[1] = { AD1981_ADC };
1274 static hda_nid_t ad1981_capsrc_nids[1] = { 0x15 };
1276 /* 0x0c, 0x09, 0x0e, 0x0f, 0x19, 0x05, 0x18, 0x17 */
1277 static struct hda_input_mux ad1981_capture_source = {
1280 { "Front Mic", 0x0 },
1283 { "Mix Mono", 0x3 },
1290 static struct snd_kcontrol_new ad1981_mixers[] = {
1291 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT),
1292 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT),
1293 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT),
1294 HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT),
1295 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT),
1296 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT),
1297 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
1298 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
1299 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
1300 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
1301 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1302 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1303 HDA_CODEC_VOLUME("Aux Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
1304 HDA_CODEC_MUTE("Aux Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1305 HDA_CODEC_VOLUME("Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT),
1306 HDA_CODEC_MUTE("Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
1307 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1308 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1309 HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1310 HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x0d, 1, 0x0, HDA_OUTPUT),
1311 HDA_CODEC_VOLUME("Front Mic Boost", 0x08, 0x0, HDA_INPUT),
1312 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x0, HDA_INPUT),
1313 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1314 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
1316 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1317 .name = "Capture Source",
1318 .info = ad198x_mux_enum_info,
1319 .get = ad198x_mux_enum_get,
1320 .put = ad198x_mux_enum_put,
1322 /* identical with AD1983 */
1324 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1325 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
1326 .info = ad1983_spdif_route_info,
1327 .get = ad1983_spdif_route_get,
1328 .put = ad1983_spdif_route_put,
1333 static struct hda_verb ad1981_init_verbs[] = {
1334 /* Front, HP, Mono; mute as default */
1335 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1336 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1337 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1338 /* Beep, PCM, Front Mic, Line, Rear Mic, Aux, CD-In: mute */
1339 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1340 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1341 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1342 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1343 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1344 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1345 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1346 /* Front, HP selectors; from Mix */
1347 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
1348 {0x06, AC_VERB_SET_CONNECT_SEL, 0x01},
1349 /* Mono selector; from Mix */
1350 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03},
1351 /* Mic Mixer; select Front Mic */
1352 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1353 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1354 /* Mic boost: 0dB */
1355 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1356 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1357 /* Record selector: Front mic */
1358 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0},
1359 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1360 /* SPDIF route: PCM */
1361 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0},
1363 {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1365 {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
1367 {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1368 /* Front & Rear Mic Pins */
1369 {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
1370 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
1372 {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
1374 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
1375 /* Line-Out as Input: disabled */
1376 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1380 #ifdef CONFIG_SND_HDA_POWER_SAVE
1381 static struct hda_amp_list ad1981_loopbacks[] = {
1382 { 0x12, HDA_OUTPUT, 0 }, /* Front Mic */
1383 { 0x13, HDA_OUTPUT, 0 }, /* Line */
1384 { 0x1b, HDA_OUTPUT, 0 }, /* Aux */
1385 { 0x1c, HDA_OUTPUT, 0 }, /* Mic */
1386 { 0x1d, HDA_OUTPUT, 0 }, /* CD */
1392 * Patch for HP nx6320
1394 * nx6320 uses EAPD in the reverse way - EAPD-on means the internal
1395 * speaker output enabled _and_ mute-LED off.
1398 #define AD1981_HP_EVENT 0x37
1399 #define AD1981_MIC_EVENT 0x38
1401 static struct hda_verb ad1981_hp_init_verbs[] = {
1402 {0x05, AC_VERB_SET_EAPD_BTLENABLE, 0x00 }, /* default off */
1403 /* pin sensing on HP and Mic jacks */
1404 {0x06, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_HP_EVENT},
1405 {0x08, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_MIC_EVENT},
1409 /* turn on/off EAPD (+ mute HP) as a master switch */
1410 static int ad1981_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1411 struct snd_ctl_elem_value *ucontrol)
1413 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1414 struct ad198x_spec *spec = codec->spec;
1416 if (! ad198x_eapd_put(kcontrol, ucontrol))
1418 /* change speaker pin appropriately */
1419 snd_hda_codec_write(codec, 0x05, 0,
1420 AC_VERB_SET_PIN_WIDGET_CONTROL,
1421 spec->cur_eapd ? PIN_OUT : 0);
1422 /* toggle HP mute appropriately */
1423 snd_hda_codec_amp_stereo(codec, 0x06, HDA_OUTPUT, 0,
1425 spec->cur_eapd ? 0 : HDA_AMP_MUTE);
1429 /* bind volumes of both NID 0x05 and 0x06 */
1430 static struct hda_bind_ctls ad1981_hp_bind_master_vol = {
1431 .ops = &snd_hda_bind_vol,
1433 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
1434 HDA_COMPOSE_AMP_VAL(0x06, 3, 0, HDA_OUTPUT),
1439 /* mute internal speaker if HP is plugged */
1440 static void ad1981_hp_automute(struct hda_codec *codec)
1442 unsigned int present;
1444 present = snd_hda_codec_read(codec, 0x06, 0,
1445 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1446 snd_hda_codec_amp_stereo(codec, 0x05, HDA_OUTPUT, 0,
1447 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
1450 /* toggle input of built-in and mic jack appropriately */
1451 static void ad1981_hp_automic(struct hda_codec *codec)
1453 static struct hda_verb mic_jack_on[] = {
1454 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1455 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1458 static struct hda_verb mic_jack_off[] = {
1459 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1460 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1463 unsigned int present;
1465 present = snd_hda_codec_read(codec, 0x08, 0,
1466 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1468 snd_hda_sequence_write(codec, mic_jack_on);
1470 snd_hda_sequence_write(codec, mic_jack_off);
1473 /* unsolicited event for HP jack sensing */
1474 static void ad1981_hp_unsol_event(struct hda_codec *codec,
1479 case AD1981_HP_EVENT:
1480 ad1981_hp_automute(codec);
1482 case AD1981_MIC_EVENT:
1483 ad1981_hp_automic(codec);
1488 static struct hda_input_mux ad1981_hp_capture_source = {
1492 { "Docking-Station", 0x1 },
1497 static struct snd_kcontrol_new ad1981_hp_mixers[] = {
1498 HDA_BIND_VOL("Master Playback Volume", &ad1981_hp_bind_master_vol),
1500 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1501 .name = "Master Playback Switch",
1502 .info = ad198x_eapd_info,
1503 .get = ad198x_eapd_get,
1504 .put = ad1981_hp_master_sw_put,
1505 .private_value = 0x05,
1507 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
1508 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
1510 /* FIXME: analog mic/line loopback doesn't work with my tests...
1511 * (although recording is OK)
1513 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
1514 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
1515 HDA_CODEC_VOLUME("Docking-Station Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1516 HDA_CODEC_MUTE("Docking-Station Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1517 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT),
1518 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
1519 /* FIXME: does this laptop have analog CD connection? */
1520 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1521 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1523 HDA_CODEC_VOLUME("Mic Boost", 0x08, 0x0, HDA_INPUT),
1524 HDA_CODEC_VOLUME("Internal Mic Boost", 0x18, 0x0, HDA_INPUT),
1525 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1526 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
1528 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1529 .name = "Capture Source",
1530 .info = ad198x_mux_enum_info,
1531 .get = ad198x_mux_enum_get,
1532 .put = ad198x_mux_enum_put,
1537 /* initialize jack-sensing, too */
1538 static int ad1981_hp_init(struct hda_codec *codec)
1541 ad1981_hp_automute(codec);
1542 ad1981_hp_automic(codec);
1546 /* configuration for Toshiba Laptops */
1547 static struct hda_verb ad1981_toshiba_init_verbs[] = {
1548 {0x05, AC_VERB_SET_EAPD_BTLENABLE, 0x01 }, /* default on */
1549 /* pin sensing on HP and Mic jacks */
1550 {0x06, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_HP_EVENT},
1551 {0x08, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_MIC_EVENT},
1555 static struct snd_kcontrol_new ad1981_toshiba_mixers[] = {
1556 HDA_CODEC_VOLUME("Amp Volume", 0x1a, 0x0, HDA_OUTPUT),
1557 HDA_CODEC_MUTE("Amp Switch", 0x1a, 0x0, HDA_OUTPUT),
1561 /* configuration for Lenovo Thinkpad T60 */
1562 static struct snd_kcontrol_new ad1981_thinkpad_mixers[] = {
1563 HDA_CODEC_VOLUME("Master Playback Volume", 0x05, 0x0, HDA_OUTPUT),
1564 HDA_CODEC_MUTE("Master Playback Switch", 0x05, 0x0, HDA_OUTPUT),
1565 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
1566 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
1567 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
1568 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
1569 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1570 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1571 HDA_CODEC_VOLUME("Mic Boost", 0x08, 0x0, HDA_INPUT),
1572 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1573 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
1575 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1576 .name = "Capture Source",
1577 .info = ad198x_mux_enum_info,
1578 .get = ad198x_mux_enum_get,
1579 .put = ad198x_mux_enum_put,
1581 /* identical with AD1983 */
1583 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1584 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
1585 .info = ad1983_spdif_route_info,
1586 .get = ad1983_spdif_route_get,
1587 .put = ad1983_spdif_route_put,
1592 static struct hda_input_mux ad1981_thinkpad_capture_source = {
1610 static const char *ad1981_models[AD1981_MODELS] = {
1612 [AD1981_THINKPAD] = "thinkpad",
1613 [AD1981_BASIC] = "basic",
1614 [AD1981_TOSHIBA] = "toshiba"
1617 static struct snd_pci_quirk ad1981_cfg_tbl[] = {
1618 SND_PCI_QUIRK(0x1014, 0x0597, "Lenovo Z60", AD1981_THINKPAD),
1619 SND_PCI_QUIRK(0x1014, 0x05b7, "Lenovo Z60m", AD1981_THINKPAD),
1621 SND_PCI_QUIRK(0x103c, 0, "HP nx", AD1981_HP),
1622 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba U205", AD1981_TOSHIBA),
1623 /* Lenovo Thinkpad T60/X60/Z6xx */
1624 SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1981_THINKPAD),
1625 /* HP nx6320 (reversed SSID, H/W bug) */
1626 SND_PCI_QUIRK(0x30b0, 0x103c, "HP nx6320", AD1981_HP),
1630 static int patch_ad1981(struct hda_codec *codec)
1632 struct ad198x_spec *spec;
1635 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1641 spec->multiout.max_channels = 2;
1642 spec->multiout.num_dacs = ARRAY_SIZE(ad1981_dac_nids);
1643 spec->multiout.dac_nids = ad1981_dac_nids;
1644 spec->multiout.dig_out_nid = AD1981_SPDIF_OUT;
1645 spec->num_adc_nids = 1;
1646 spec->adc_nids = ad1981_adc_nids;
1647 spec->capsrc_nids = ad1981_capsrc_nids;
1648 spec->input_mux = &ad1981_capture_source;
1649 spec->num_mixers = 1;
1650 spec->mixers[0] = ad1981_mixers;
1651 spec->num_init_verbs = 1;
1652 spec->init_verbs[0] = ad1981_init_verbs;
1653 spec->spdif_route = 0;
1654 #ifdef CONFIG_SND_HDA_POWER_SAVE
1655 spec->loopback.amplist = ad1981_loopbacks;
1657 spec->vmaster_nid = 0x05;
1659 codec->patch_ops = ad198x_patch_ops;
1661 /* override some parameters */
1662 board_config = snd_hda_check_board_config(codec, AD1981_MODELS,
1665 switch (board_config) {
1667 spec->mixers[0] = ad1981_hp_mixers;
1668 spec->num_init_verbs = 2;
1669 spec->init_verbs[1] = ad1981_hp_init_verbs;
1670 spec->multiout.dig_out_nid = 0;
1671 spec->input_mux = &ad1981_hp_capture_source;
1673 codec->patch_ops.init = ad1981_hp_init;
1674 codec->patch_ops.unsol_event = ad1981_hp_unsol_event;
1676 case AD1981_THINKPAD:
1677 spec->mixers[0] = ad1981_thinkpad_mixers;
1678 spec->input_mux = &ad1981_thinkpad_capture_source;
1680 case AD1981_TOSHIBA:
1681 spec->mixers[0] = ad1981_hp_mixers;
1682 spec->mixers[1] = ad1981_toshiba_mixers;
1683 spec->num_init_verbs = 2;
1684 spec->init_verbs[1] = ad1981_toshiba_init_verbs;
1685 spec->multiout.dig_out_nid = 0;
1686 spec->input_mux = &ad1981_hp_capture_source;
1687 codec->patch_ops.init = ad1981_hp_init;
1688 codec->patch_ops.unsol_event = ad1981_hp_unsol_event;
1698 * Output pins and routes
1700 * Pin Mix Sel DAC (*)
1701 * port-A 0x11 (mute/hp) <- 0x22 <- 0x37 <- 03/04/06
1702 * port-B 0x14 (mute/hp) <- 0x2b <- 0x30 <- 03/04/06
1703 * port-C 0x15 (mute) <- 0x2c <- 0x31 <- 05/0a
1704 * port-D 0x12 (mute/hp) <- 0x29 <- 04
1705 * port-E 0x17 (mute/hp) <- 0x26 <- 0x32 <- 05/0a
1706 * port-F 0x16 (mute) <- 0x2a <- 06
1707 * port-G 0x24 (mute) <- 0x27 <- 05
1708 * port-H 0x25 (mute) <- 0x28 <- 0a
1709 * mono 0x13 (mute/amp)<- 0x1e <- 0x36 <- 03/04/06
1711 * DAC0 = 03h, DAC1 = 04h, DAC2 = 05h, DAC3 = 06h, DAC4 = 0ah
1712 * (*) DAC2/3/4 are swapped to DAC3/4/2 on AD198A rev.2 due to a h/w bug.
1714 * Input pins and routes
1716 * pin boost mix input # / adc input #
1717 * port-A 0x11 -> 0x38 -> mix 2, ADC 0
1718 * port-B 0x14 -> 0x39 -> mix 0, ADC 1
1719 * port-C 0x15 -> 0x3a -> 33:0 - mix 1, ADC 2
1720 * port-D 0x12 -> 0x3d -> mix 3, ADC 8
1721 * port-E 0x17 -> 0x3c -> 34:0 - mix 4, ADC 4
1722 * port-F 0x16 -> 0x3b -> mix 5, ADC 3
1723 * port-G 0x24 -> N/A -> 33:1 - mix 1, 34:1 - mix 4, ADC 6
1724 * port-H 0x25 -> N/A -> 33:2 - mix 1, 34:2 - mix 4, ADC 7
1728 * 6stack - front/surr/CLFE/side/opt DACs - 04/06/05/0a/03
1729 * 3stack - front/surr/CLFE/opt DACs - 04/05/0a/03
1731 * Inputs of Analog Mix (0x20)
1732 * 0:Port-B (front mic)
1733 * 1:Port-C/G/H (line-in)
1735 * 3:Port-D (line-in/2)
1736 * 4:Port-E/G/H (mic-in)
1737 * 5:Port-F (mic2-in)
1743 * 1:Port-B (front mic-in)
1744 * 2:Port-C (line-in)
1745 * 3:Port-F (mic2-in)
1750 * 8:Port-D (line-in/2)
1753 * Proposed pin assignments by the datasheet
1756 * Port-A front headphone
1766 * Port-A front headphone
1768 * C rear line-in/surround
1770 * E rear mic-in/CLFE
1776 * D internal speaker (with EAPD)
1777 * E/F quad mic array
1793 /* reivision id to check workarounds */
1794 #define AD1988A_REV2 0x100200
1796 #define is_rev2(codec) \
1797 ((codec)->vendor_id == 0x11d41988 && \
1798 (codec)->revision_id == AD1988A_REV2)
1804 static hda_nid_t ad1988_6stack_dac_nids[4] = {
1805 0x04, 0x06, 0x05, 0x0a
1808 static hda_nid_t ad1988_3stack_dac_nids[3] = {
1812 /* for AD1988A revision-2, DAC2-4 are swapped */
1813 static hda_nid_t ad1988_6stack_dac_nids_rev2[4] = {
1814 0x04, 0x05, 0x0a, 0x06
1817 static hda_nid_t ad1988_3stack_dac_nids_rev2[3] = {
1821 static hda_nid_t ad1988_adc_nids[3] = {
1825 static hda_nid_t ad1988_capsrc_nids[3] = {
1829 #define AD1988_SPDIF_OUT 0x02
1830 #define AD1988_SPDIF_IN 0x07
1832 static struct hda_input_mux ad1988_6stack_capture_source = {
1835 { "Front Mic", 0x1 }, /* port-B */
1836 { "Line", 0x2 }, /* port-C */
1837 { "Mic", 0x4 }, /* port-E */
1843 static struct hda_input_mux ad1988_laptop_capture_source = {
1846 { "Mic/Line", 0x1 }, /* port-B */
1854 static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol,
1855 struct snd_ctl_elem_info *uinfo)
1857 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1858 struct ad198x_spec *spec = codec->spec;
1859 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
1860 spec->num_channel_mode);
1863 static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol,
1864 struct snd_ctl_elem_value *ucontrol)
1866 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1867 struct ad198x_spec *spec = codec->spec;
1868 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
1869 spec->num_channel_mode, spec->multiout.max_channels);
1872 static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol,
1873 struct snd_ctl_elem_value *ucontrol)
1875 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1876 struct ad198x_spec *spec = codec->spec;
1877 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
1878 spec->num_channel_mode,
1879 &spec->multiout.max_channels);
1880 if (err >= 0 && spec->need_dac_fix)
1881 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
1886 static struct snd_kcontrol_new ad1988_6stack_mixers1[] = {
1887 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1888 HDA_CODEC_VOLUME("Surround Playback Volume", 0x06, 0x0, HDA_OUTPUT),
1889 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT),
1890 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT),
1891 HDA_CODEC_VOLUME("Side Playback Volume", 0x0a, 0x0, HDA_OUTPUT),
1895 static struct snd_kcontrol_new ad1988_6stack_mixers1_rev2[] = {
1896 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1897 HDA_CODEC_VOLUME("Surround Playback Volume", 0x05, 0x0, HDA_OUTPUT),
1898 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
1899 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0a, 2, 0x0, HDA_OUTPUT),
1900 HDA_CODEC_VOLUME("Side Playback Volume", 0x06, 0x0, HDA_OUTPUT),
1904 static struct snd_kcontrol_new ad1988_6stack_mixers2[] = {
1905 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT),
1906 HDA_BIND_MUTE("Surround Playback Switch", 0x2a, 2, HDA_INPUT),
1907 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x27, 1, 2, HDA_INPUT),
1908 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x27, 2, 2, HDA_INPUT),
1909 HDA_BIND_MUTE("Side Playback Switch", 0x28, 2, HDA_INPUT),
1910 HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT),
1911 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT),
1913 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT),
1914 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT),
1915 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT),
1916 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT),
1917 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
1918 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
1919 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT),
1920 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT),
1922 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
1923 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
1925 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
1926 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
1928 HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT),
1929 HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT),
1935 static struct snd_kcontrol_new ad1988_3stack_mixers1[] = {
1936 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1937 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT),
1938 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT),
1939 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT),
1943 static struct snd_kcontrol_new ad1988_3stack_mixers1_rev2[] = {
1944 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1945 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT),
1946 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x06, 1, 0x0, HDA_OUTPUT),
1947 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x06, 2, 0x0, HDA_OUTPUT),
1951 static struct snd_kcontrol_new ad1988_3stack_mixers2[] = {
1952 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT),
1953 HDA_BIND_MUTE("Surround Playback Switch", 0x2c, 2, HDA_INPUT),
1954 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x26, 1, 2, HDA_INPUT),
1955 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x26, 2, 2, HDA_INPUT),
1956 HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT),
1957 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT),
1959 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT),
1960 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT),
1961 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT),
1962 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT),
1963 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
1964 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
1965 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT),
1966 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT),
1968 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
1969 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
1971 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
1972 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
1974 HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT),
1975 HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT),
1977 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1978 .name = "Channel Mode",
1979 .info = ad198x_ch_mode_info,
1980 .get = ad198x_ch_mode_get,
1981 .put = ad198x_ch_mode_put,
1988 static struct snd_kcontrol_new ad1988_laptop_mixers[] = {
1989 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1990 HDA_CODEC_MUTE("PCM Playback Switch", 0x29, 0x0, HDA_INPUT),
1991 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT),
1993 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT),
1994 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT),
1995 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x0, HDA_INPUT),
1996 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x0, HDA_INPUT),
1997 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
1998 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
2000 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
2001 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
2003 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
2004 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
2006 HDA_CODEC_VOLUME("Mic Boost", 0x39, 0x0, HDA_OUTPUT),
2009 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2010 .name = "External Amplifier",
2011 .info = ad198x_eapd_info,
2012 .get = ad198x_eapd_get,
2013 .put = ad198x_eapd_put,
2014 .private_value = 0x12 | (1 << 8), /* port-D, inversed */
2021 static struct snd_kcontrol_new ad1988_capture_mixers[] = {
2022 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
2023 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
2024 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
2025 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
2026 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x0e, 0x0, HDA_OUTPUT),
2027 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x0e, 0x0, HDA_OUTPUT),
2029 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2030 /* The multiple "Capture Source" controls confuse alsamixer
2031 * So call somewhat different..
2033 /* .name = "Capture Source", */
2034 .name = "Input Source",
2036 .info = ad198x_mux_enum_info,
2037 .get = ad198x_mux_enum_get,
2038 .put = ad198x_mux_enum_put,
2043 static int ad1988_spdif_playback_source_info(struct snd_kcontrol *kcontrol,
2044 struct snd_ctl_elem_info *uinfo)
2046 static char *texts[] = {
2047 "PCM", "ADC1", "ADC2", "ADC3"
2049 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2051 uinfo->value.enumerated.items = 4;
2052 if (uinfo->value.enumerated.item >= 4)
2053 uinfo->value.enumerated.item = 3;
2054 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2058 static int ad1988_spdif_playback_source_get(struct snd_kcontrol *kcontrol,
2059 struct snd_ctl_elem_value *ucontrol)
2061 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2064 sel = snd_hda_codec_read(codec, 0x1d, 0, AC_VERB_GET_AMP_GAIN_MUTE,
2067 ucontrol->value.enumerated.item[0] = 0;
2069 sel = snd_hda_codec_read(codec, 0x0b, 0,
2070 AC_VERB_GET_CONNECT_SEL, 0);
2075 ucontrol->value.enumerated.item[0] = sel;
2080 static int ad1988_spdif_playback_source_put(struct snd_kcontrol *kcontrol,
2081 struct snd_ctl_elem_value *ucontrol)
2083 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2084 unsigned int val, sel;
2087 val = ucontrol->value.enumerated.item[0];
2091 sel = snd_hda_codec_read(codec, 0x1d, 0,
2092 AC_VERB_GET_AMP_GAIN_MUTE,
2094 change = sel & 0x80;
2096 snd_hda_codec_write_cache(codec, 0x1d, 0,
2097 AC_VERB_SET_AMP_GAIN_MUTE,
2099 snd_hda_codec_write_cache(codec, 0x1d, 0,
2100 AC_VERB_SET_AMP_GAIN_MUTE,
2104 sel = snd_hda_codec_read(codec, 0x1d, 0,
2105 AC_VERB_GET_AMP_GAIN_MUTE,
2106 AC_AMP_GET_INPUT | 0x01);
2107 change = sel & 0x80;
2109 snd_hda_codec_write_cache(codec, 0x1d, 0,
2110 AC_VERB_SET_AMP_GAIN_MUTE,
2112 snd_hda_codec_write_cache(codec, 0x1d, 0,
2113 AC_VERB_SET_AMP_GAIN_MUTE,
2116 sel = snd_hda_codec_read(codec, 0x0b, 0,
2117 AC_VERB_GET_CONNECT_SEL, 0) + 1;
2118 change |= sel != val;
2120 snd_hda_codec_write_cache(codec, 0x0b, 0,
2121 AC_VERB_SET_CONNECT_SEL,
2127 static struct snd_kcontrol_new ad1988_spdif_out_mixers[] = {
2128 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
2130 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2131 .name = "IEC958 Playback Source",
2132 .info = ad1988_spdif_playback_source_info,
2133 .get = ad1988_spdif_playback_source_get,
2134 .put = ad1988_spdif_playback_source_put,
2139 static struct snd_kcontrol_new ad1988_spdif_in_mixers[] = {
2140 HDA_CODEC_VOLUME("IEC958 Capture Volume", 0x1c, 0x0, HDA_INPUT),
2144 static struct snd_kcontrol_new ad1989_spdif_out_mixers[] = {
2145 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
2150 * initialization verbs
2154 * for 6-stack (+dig)
2156 static struct hda_verb ad1988_6stack_init_verbs[] = {
2157 /* Front, Surround, CLFE, side DAC; unmute as default */
2158 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2159 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2160 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2161 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2162 /* Port-A front headphon path */
2163 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */
2164 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2165 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2166 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2167 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2168 /* Port-D line-out path */
2169 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2170 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2171 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2172 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2173 /* Port-F surround path */
2174 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2175 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2176 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2177 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2178 /* Port-G CLFE path */
2179 {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2180 {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2181 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2182 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2183 /* Port-H side path */
2184 {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2185 {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2186 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2187 {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2189 {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */
2190 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2191 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2192 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2193 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */
2194 /* Port-B front mic-in path */
2195 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2196 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2197 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2198 /* Port-C line-in path */
2199 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2200 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2201 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2202 {0x33, AC_VERB_SET_CONNECT_SEL, 0x0},
2203 /* Port-E mic-in path */
2204 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2205 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2206 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2207 {0x34, AC_VERB_SET_CONNECT_SEL, 0x0},
2208 /* Analog CD Input */
2209 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2210 /* Analog Mix output amp */
2211 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
2216 static struct hda_verb ad1988_capture_init_verbs[] = {
2217 /* mute analog mix */
2218 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2219 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2220 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2221 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2222 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2223 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
2224 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2225 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2226 /* select ADCs - front-mic */
2227 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
2228 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
2229 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
2231 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2232 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2233 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2238 static struct hda_verb ad1988_spdif_init_verbs[] = {
2240 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */
2241 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x0}, /* ADC1 */
2242 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2243 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2245 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
2250 /* AD1989 has no ADC -> SPDIF route */
2251 static struct hda_verb ad1989_spdif_init_verbs[] = {
2252 /* SPDIF-1 out pin */
2253 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2254 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
2255 /* SPDIF-2/HDMI out pin */
2256 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2257 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
2262 * verbs for 3stack (+dig)
2264 static struct hda_verb ad1988_3stack_ch2_init[] = {
2265 /* set port-C to line-in */
2266 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2267 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2268 /* set port-E to mic-in */
2269 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2270 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2274 static struct hda_verb ad1988_3stack_ch6_init[] = {
2275 /* set port-C to surround out */
2276 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2277 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2278 /* set port-E to CLFE out */
2279 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2280 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2284 static struct hda_channel_mode ad1988_3stack_modes[2] = {
2285 { 2, ad1988_3stack_ch2_init },
2286 { 6, ad1988_3stack_ch6_init },
2289 static struct hda_verb ad1988_3stack_init_verbs[] = {
2290 /* Front, Surround, CLFE, side DAC; unmute as default */
2291 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2292 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2293 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2294 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2295 /* Port-A front headphon path */
2296 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */
2297 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2298 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2299 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2300 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2301 /* Port-D line-out path */
2302 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2303 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2304 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2305 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2307 {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */
2308 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2309 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2310 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2311 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */
2312 /* Port-B front mic-in path */
2313 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2314 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2315 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2316 /* Port-C line-in/surround path - 6ch mode as default */
2317 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2318 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2319 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2320 {0x31, AC_VERB_SET_CONNECT_SEL, 0x0}, /* output sel: DAC 0x05 */
2321 {0x33, AC_VERB_SET_CONNECT_SEL, 0x0},
2322 /* Port-E mic-in/CLFE path - 6ch mode as default */
2323 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2324 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2325 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2326 {0x32, AC_VERB_SET_CONNECT_SEL, 0x1}, /* output sel: DAC 0x0a */
2327 {0x34, AC_VERB_SET_CONNECT_SEL, 0x0},
2328 /* mute analog mix */
2329 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2330 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2331 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2332 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2333 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2334 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
2335 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2336 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2337 /* select ADCs - front-mic */
2338 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
2339 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
2340 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
2342 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2343 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2344 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2345 /* Analog Mix output amp */
2346 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
2351 * verbs for laptop mode (+dig)
2353 static struct hda_verb ad1988_laptop_hp_on[] = {
2354 /* unmute port-A and mute port-D */
2355 { 0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2356 { 0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2359 static struct hda_verb ad1988_laptop_hp_off[] = {
2360 /* mute port-A and unmute port-D */
2361 { 0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2362 { 0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2366 #define AD1988_HP_EVENT 0x01
2368 static struct hda_verb ad1988_laptop_init_verbs[] = {
2369 /* Front, Surround, CLFE, side DAC; unmute as default */
2370 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2371 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2372 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2373 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2374 /* Port-A front headphon path */
2375 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */
2376 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2377 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2378 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2379 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2380 /* unsolicited event for pin-sense */
2381 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1988_HP_EVENT },
2382 /* Port-D line-out path + EAPD */
2383 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2384 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2385 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2386 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2387 {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x00}, /* EAPD-off */
2389 {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */
2390 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2391 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2392 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2393 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */
2394 /* Port-B mic-in path */
2395 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2396 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2397 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2398 /* Port-C docking station - try to output */
2399 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2400 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2401 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2402 {0x33, AC_VERB_SET_CONNECT_SEL, 0x0},
2403 /* mute analog mix */
2404 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2405 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2406 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2407 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2408 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2409 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
2410 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2411 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2412 /* select ADCs - mic */
2413 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
2414 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
2415 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
2417 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2418 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2419 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2420 /* Analog Mix output amp */
2421 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
2425 static void ad1988_laptop_unsol_event(struct hda_codec *codec, unsigned int res)
2427 if ((res >> 26) != AD1988_HP_EVENT)
2429 if (snd_hda_codec_read(codec, 0x11, 0, AC_VERB_GET_PIN_SENSE, 0) & (1 << 31))
2430 snd_hda_sequence_write(codec, ad1988_laptop_hp_on);
2432 snd_hda_sequence_write(codec, ad1988_laptop_hp_off);
2435 #ifdef CONFIG_SND_HDA_POWER_SAVE
2436 static struct hda_amp_list ad1988_loopbacks[] = {
2437 { 0x20, HDA_INPUT, 0 }, /* Front Mic */
2438 { 0x20, HDA_INPUT, 1 }, /* Line */
2439 { 0x20, HDA_INPUT, 4 }, /* Mic */
2440 { 0x20, HDA_INPUT, 6 }, /* CD */
2446 * Automatic parse of I/O pins from the BIOS configuration
2449 #define NUM_CONTROL_ALLOC 32
2450 #define NUM_VERB_ALLOC 32
2457 static struct snd_kcontrol_new ad1988_control_templates[] = {
2458 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2459 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2460 HDA_BIND_MUTE(NULL, 0, 0, 0),
2463 /* add dynamic controls */
2464 static int add_control(struct ad198x_spec *spec, int type, const char *name,
2467 struct snd_kcontrol_new *knew;
2469 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2470 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2472 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2475 if (spec->kctl_alloc) {
2476 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2477 kfree(spec->kctl_alloc);
2479 spec->kctl_alloc = knew;
2480 spec->num_kctl_alloc = num;
2483 knew = &spec->kctl_alloc[spec->num_kctl_used];
2484 *knew = ad1988_control_templates[type];
2485 knew->name = kstrdup(name, GFP_KERNEL);
2488 knew->private_value = val;
2489 spec->num_kctl_used++;
2493 #define AD1988_PIN_CD_NID 0x18
2494 #define AD1988_PIN_BEEP_NID 0x10
2496 static hda_nid_t ad1988_mixer_nids[8] = {
2497 /* A B C D E F G H */
2498 0x22, 0x2b, 0x2c, 0x29, 0x26, 0x2a, 0x27, 0x28
2501 static inline hda_nid_t ad1988_idx_to_dac(struct hda_codec *codec, int idx)
2503 static hda_nid_t idx_to_dac[8] = {
2504 /* A B C D E F G H */
2505 0x04, 0x06, 0x05, 0x04, 0x0a, 0x06, 0x05, 0x0a
2507 static hda_nid_t idx_to_dac_rev2[8] = {
2508 /* A B C D E F G H */
2509 0x04, 0x05, 0x0a, 0x04, 0x06, 0x05, 0x0a, 0x06
2512 return idx_to_dac_rev2[idx];
2514 return idx_to_dac[idx];
2517 static hda_nid_t ad1988_boost_nids[8] = {
2518 0x38, 0x39, 0x3a, 0x3d, 0x3c, 0x3b, 0, 0
2521 static int ad1988_pin_idx(hda_nid_t nid)
2523 static hda_nid_t ad1988_io_pins[8] = {
2524 0x11, 0x14, 0x15, 0x12, 0x17, 0x16, 0x24, 0x25
2527 for (i = 0; i < ARRAY_SIZE(ad1988_io_pins); i++)
2528 if (ad1988_io_pins[i] == nid)
2530 return 0; /* should be -1 */
2533 static int ad1988_pin_to_loopback_idx(hda_nid_t nid)
2535 static int loopback_idx[8] = {
2536 2, 0, 1, 3, 4, 5, 1, 4
2539 case AD1988_PIN_CD_NID:
2542 return loopback_idx[ad1988_pin_idx(nid)];
2546 static int ad1988_pin_to_adc_idx(hda_nid_t nid)
2548 static int adc_idx[8] = {
2549 0, 1, 2, 8, 4, 3, 6, 7
2552 case AD1988_PIN_CD_NID:
2555 return adc_idx[ad1988_pin_idx(nid)];
2559 /* fill in the dac_nids table from the parsed pin configuration */
2560 static int ad1988_auto_fill_dac_nids(struct hda_codec *codec,
2561 const struct auto_pin_cfg *cfg)
2563 struct ad198x_spec *spec = codec->spec;
2566 spec->multiout.dac_nids = spec->private_dac_nids;
2568 /* check the pins hardwired to audio widget */
2569 for (i = 0; i < cfg->line_outs; i++) {
2570 idx = ad1988_pin_idx(cfg->line_out_pins[i]);
2571 spec->multiout.dac_nids[i] = ad1988_idx_to_dac(codec, idx);
2573 spec->multiout.num_dacs = cfg->line_outs;
2577 /* add playback controls from the parsed DAC table */
2578 static int ad1988_auto_create_multi_out_ctls(struct ad198x_spec *spec,
2579 const struct auto_pin_cfg *cfg)
2582 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
2586 for (i = 0; i < cfg->line_outs; i++) {
2587 hda_nid_t dac = spec->multiout.dac_nids[i];
2590 nid = ad1988_mixer_nids[ad1988_pin_idx(cfg->line_out_pins[i])];
2593 err = add_control(spec, AD_CTL_WIDGET_VOL,
2594 "Center Playback Volume",
2595 HDA_COMPOSE_AMP_VAL(dac, 1, 0, HDA_OUTPUT));
2598 err = add_control(spec, AD_CTL_WIDGET_VOL,
2599 "LFE Playback Volume",
2600 HDA_COMPOSE_AMP_VAL(dac, 2, 0, HDA_OUTPUT));
2603 err = add_control(spec, AD_CTL_BIND_MUTE,
2604 "Center Playback Switch",
2605 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT));
2608 err = add_control(spec, AD_CTL_BIND_MUTE,
2609 "LFE Playback Switch",
2610 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT));
2614 sprintf(name, "%s Playback Volume", chname[i]);
2615 err = add_control(spec, AD_CTL_WIDGET_VOL, name,
2616 HDA_COMPOSE_AMP_VAL(dac, 3, 0, HDA_OUTPUT));
2619 sprintf(name, "%s Playback Switch", chname[i]);
2620 err = add_control(spec, AD_CTL_BIND_MUTE, name,
2621 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
2629 /* add playback controls for speaker and HP outputs */
2630 static int ad1988_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
2633 struct ad198x_spec *spec = codec->spec;
2641 idx = ad1988_pin_idx(pin);
2642 nid = ad1988_idx_to_dac(codec, idx);
2643 /* check whether the corresponding DAC was already taken */
2644 for (i = 0; i < spec->autocfg.line_outs; i++) {
2645 hda_nid_t pin = spec->autocfg.line_out_pins[i];
2646 hda_nid_t dac = ad1988_idx_to_dac(codec, ad1988_pin_idx(pin));
2650 if (i >= spec->autocfg.line_outs) {
2651 /* specify the DAC as the extra output */
2652 if (!spec->multiout.hp_nid)
2653 spec->multiout.hp_nid = nid;
2655 spec->multiout.extra_out_nid[0] = nid;
2656 /* control HP volume/switch on the output mixer amp */
2657 sprintf(name, "%s Playback Volume", pfx);
2658 err = add_control(spec, AD_CTL_WIDGET_VOL, name,
2659 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
2663 nid = ad1988_mixer_nids[idx];
2664 sprintf(name, "%s Playback Switch", pfx);
2665 if ((err = add_control(spec, AD_CTL_BIND_MUTE, name,
2666 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2671 /* create input playback/capture controls for the given pin */
2672 static int new_analog_input(struct ad198x_spec *spec, hda_nid_t pin,
2673 const char *ctlname, int boost)
2678 sprintf(name, "%s Playback Volume", ctlname);
2679 idx = ad1988_pin_to_loopback_idx(pin);
2680 if ((err = add_control(spec, AD_CTL_WIDGET_VOL, name,
2681 HDA_COMPOSE_AMP_VAL(0x20, 3, idx, HDA_INPUT))) < 0)
2683 sprintf(name, "%s Playback Switch", ctlname);
2684 if ((err = add_control(spec, AD_CTL_WIDGET_MUTE, name,
2685 HDA_COMPOSE_AMP_VAL(0x20, 3, idx, HDA_INPUT))) < 0)
2689 idx = ad1988_pin_idx(pin);
2690 bnid = ad1988_boost_nids[idx];
2692 sprintf(name, "%s Boost", ctlname);
2693 return add_control(spec, AD_CTL_WIDGET_VOL, name,
2694 HDA_COMPOSE_AMP_VAL(bnid, 3, idx, HDA_OUTPUT));
2701 /* create playback/capture controls for input pins */
2702 static int ad1988_auto_create_analog_input_ctls(struct ad198x_spec *spec,
2703 const struct auto_pin_cfg *cfg)
2705 struct hda_input_mux *imux = &spec->private_imux;
2708 for (i = 0; i < AUTO_PIN_LAST; i++) {
2709 err = new_analog_input(spec, cfg->input_pins[i],
2710 auto_pin_cfg_labels[i],
2711 i <= AUTO_PIN_FRONT_MIC);
2714 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2715 imux->items[imux->num_items].index = ad1988_pin_to_adc_idx(cfg->input_pins[i]);
2718 imux->items[imux->num_items].label = "Mix";
2719 imux->items[imux->num_items].index = 9;
2722 if ((err = add_control(spec, AD_CTL_WIDGET_VOL,
2723 "Analog Mix Playback Volume",
2724 HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT))) < 0)
2726 if ((err = add_control(spec, AD_CTL_WIDGET_MUTE,
2727 "Analog Mix Playback Switch",
2728 HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT))) < 0)
2734 static void ad1988_auto_set_output_and_unmute(struct hda_codec *codec,
2735 hda_nid_t nid, int pin_type,
2739 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2740 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2742 case 0x11: /* port-A - DAC 04 */
2743 snd_hda_codec_write(codec, 0x37, 0, AC_VERB_SET_CONNECT_SEL, 0x01);
2745 case 0x14: /* port-B - DAC 06 */
2746 snd_hda_codec_write(codec, 0x30, 0, AC_VERB_SET_CONNECT_SEL, 0x02);
2748 case 0x15: /* port-C - DAC 05 */
2749 snd_hda_codec_write(codec, 0x31, 0, AC_VERB_SET_CONNECT_SEL, 0x00);
2751 case 0x17: /* port-E - DAC 0a */
2752 snd_hda_codec_write(codec, 0x32, 0, AC_VERB_SET_CONNECT_SEL, 0x01);
2754 case 0x13: /* mono - DAC 04 */
2755 snd_hda_codec_write(codec, 0x36, 0, AC_VERB_SET_CONNECT_SEL, 0x01);
2760 static void ad1988_auto_init_multi_out(struct hda_codec *codec)
2762 struct ad198x_spec *spec = codec->spec;
2765 for (i = 0; i < spec->autocfg.line_outs; i++) {
2766 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2767 ad1988_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2771 static void ad1988_auto_init_extra_out(struct hda_codec *codec)
2773 struct ad198x_spec *spec = codec->spec;
2776 pin = spec->autocfg.speaker_pins[0];
2777 if (pin) /* connect to front */
2778 ad1988_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
2779 pin = spec->autocfg.hp_pins[0];
2780 if (pin) /* connect to front */
2781 ad1988_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2784 static void ad1988_auto_init_analog_input(struct hda_codec *codec)
2786 struct ad198x_spec *spec = codec->spec;
2789 for (i = 0; i < AUTO_PIN_LAST; i++) {
2790 hda_nid_t nid = spec->autocfg.input_pins[i];
2794 case 0x15: /* port-C */
2795 snd_hda_codec_write(codec, 0x33, 0, AC_VERB_SET_CONNECT_SEL, 0x0);
2797 case 0x17: /* port-E */
2798 snd_hda_codec_write(codec, 0x34, 0, AC_VERB_SET_CONNECT_SEL, 0x0);
2801 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2802 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2803 if (nid != AD1988_PIN_CD_NID)
2804 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2806 idx = ad1988_pin_idx(nid);
2807 if (ad1988_boost_nids[idx])
2808 snd_hda_codec_write(codec, ad1988_boost_nids[idx], 0,
2809 AC_VERB_SET_AMP_GAIN_MUTE,
2814 /* parse the BIOS configuration and set up the alc_spec */
2815 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2816 static int ad1988_parse_auto_config(struct hda_codec *codec)
2818 struct ad198x_spec *spec = codec->spec;
2821 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
2823 if ((err = ad1988_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
2825 if (! spec->autocfg.line_outs)
2826 return 0; /* can't find valid BIOS pin config */
2827 if ((err = ad1988_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
2828 (err = ad1988_auto_create_extra_out(codec,
2829 spec->autocfg.speaker_pins[0],
2831 (err = ad1988_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
2832 "Headphone")) < 0 ||
2833 (err = ad1988_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2836 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2838 if (spec->autocfg.dig_out_pin)
2839 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
2840 if (spec->autocfg.dig_in_pin)
2841 spec->dig_in_nid = AD1988_SPDIF_IN;
2843 if (spec->kctl_alloc)
2844 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2846 spec->init_verbs[spec->num_init_verbs++] = ad1988_6stack_init_verbs;
2848 spec->input_mux = &spec->private_imux;
2853 /* init callback for auto-configuration model -- overriding the default init */
2854 static int ad1988_auto_init(struct hda_codec *codec)
2857 ad1988_auto_init_multi_out(codec);
2858 ad1988_auto_init_extra_out(codec);
2859 ad1988_auto_init_analog_input(codec);
2867 static const char *ad1988_models[AD1988_MODEL_LAST] = {
2868 [AD1988_6STACK] = "6stack",
2869 [AD1988_6STACK_DIG] = "6stack-dig",
2870 [AD1988_3STACK] = "3stack",
2871 [AD1988_3STACK_DIG] = "3stack-dig",
2872 [AD1988_LAPTOP] = "laptop",
2873 [AD1988_LAPTOP_DIG] = "laptop-dig",
2874 [AD1988_AUTO] = "auto",
2877 static struct snd_pci_quirk ad1988_cfg_tbl[] = {
2878 SND_PCI_QUIRK(0x1043, 0x81ec, "Asus P5B-DLX", AD1988_6STACK_DIG),
2879 SND_PCI_QUIRK(0x1043, 0x81f6, "Asus M2N-SLI", AD1988_6STACK_DIG),
2880 SND_PCI_QUIRK(0x1043, 0x8277, "Asus P5K-E/WIFI-AP", AD1988_6STACK_DIG),
2884 static int patch_ad1988(struct hda_codec *codec)
2886 struct ad198x_spec *spec;
2889 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2896 snd_printk(KERN_INFO "patch_analog: AD1988A rev.2 is detected, enable workarounds\n");
2898 board_config = snd_hda_check_board_config(codec, AD1988_MODEL_LAST,
2899 ad1988_models, ad1988_cfg_tbl);
2900 if (board_config < 0) {
2901 printk(KERN_INFO "hda_codec: Unknown model for AD1988, trying auto-probe from BIOS...\n");
2902 board_config = AD1988_AUTO;
2905 if (board_config == AD1988_AUTO) {
2906 /* automatic parse from the BIOS config */
2907 int err = ad1988_parse_auto_config(codec);
2912 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 6-stack mode...\n");
2913 board_config = AD1988_6STACK;
2917 switch (board_config) {
2919 case AD1988_6STACK_DIG:
2920 spec->multiout.max_channels = 8;
2921 spec->multiout.num_dacs = 4;
2923 spec->multiout.dac_nids = ad1988_6stack_dac_nids_rev2;
2925 spec->multiout.dac_nids = ad1988_6stack_dac_nids;
2926 spec->input_mux = &ad1988_6stack_capture_source;
2927 spec->num_mixers = 2;
2929 spec->mixers[0] = ad1988_6stack_mixers1_rev2;
2931 spec->mixers[0] = ad1988_6stack_mixers1;
2932 spec->mixers[1] = ad1988_6stack_mixers2;
2933 spec->num_init_verbs = 1;
2934 spec->init_verbs[0] = ad1988_6stack_init_verbs;
2935 if (board_config == AD1988_6STACK_DIG) {
2936 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
2937 spec->dig_in_nid = AD1988_SPDIF_IN;
2941 case AD1988_3STACK_DIG:
2942 spec->multiout.max_channels = 6;
2943 spec->multiout.num_dacs = 3;
2945 spec->multiout.dac_nids = ad1988_3stack_dac_nids_rev2;
2947 spec->multiout.dac_nids = ad1988_3stack_dac_nids;
2948 spec->input_mux = &ad1988_6stack_capture_source;
2949 spec->channel_mode = ad1988_3stack_modes;
2950 spec->num_channel_mode = ARRAY_SIZE(ad1988_3stack_modes);
2951 spec->num_mixers = 2;
2953 spec->mixers[0] = ad1988_3stack_mixers1_rev2;
2955 spec->mixers[0] = ad1988_3stack_mixers1;
2956 spec->mixers[1] = ad1988_3stack_mixers2;
2957 spec->num_init_verbs = 1;
2958 spec->init_verbs[0] = ad1988_3stack_init_verbs;
2959 if (board_config == AD1988_3STACK_DIG)
2960 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
2963 case AD1988_LAPTOP_DIG:
2964 spec->multiout.max_channels = 2;
2965 spec->multiout.num_dacs = 1;
2966 spec->multiout.dac_nids = ad1988_3stack_dac_nids;
2967 spec->input_mux = &ad1988_laptop_capture_source;
2968 spec->num_mixers = 1;
2969 spec->mixers[0] = ad1988_laptop_mixers;
2970 spec->num_init_verbs = 1;
2971 spec->init_verbs[0] = ad1988_laptop_init_verbs;
2972 if (board_config == AD1988_LAPTOP_DIG)
2973 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
2977 spec->num_adc_nids = ARRAY_SIZE(ad1988_adc_nids);
2978 spec->adc_nids = ad1988_adc_nids;
2979 spec->capsrc_nids = ad1988_capsrc_nids;
2980 spec->mixers[spec->num_mixers++] = ad1988_capture_mixers;
2981 spec->init_verbs[spec->num_init_verbs++] = ad1988_capture_init_verbs;
2982 if (spec->multiout.dig_out_nid) {
2983 if (codec->vendor_id >= 0x11d4989a) {
2984 spec->mixers[spec->num_mixers++] =
2985 ad1989_spdif_out_mixers;
2986 spec->init_verbs[spec->num_init_verbs++] =
2987 ad1989_spdif_init_verbs;
2989 spec->mixers[spec->num_mixers++] =
2990 ad1988_spdif_out_mixers;
2991 spec->init_verbs[spec->num_init_verbs++] =
2992 ad1988_spdif_init_verbs;
2995 if (spec->dig_in_nid && codec->vendor_id < 0x11d4989a)
2996 spec->mixers[spec->num_mixers++] = ad1988_spdif_in_mixers;
2998 codec->patch_ops = ad198x_patch_ops;
2999 switch (board_config) {
3001 codec->patch_ops.init = ad1988_auto_init;
3004 case AD1988_LAPTOP_DIG:
3005 codec->patch_ops.unsol_event = ad1988_laptop_unsol_event;
3008 #ifdef CONFIG_SND_HDA_POWER_SAVE
3009 spec->loopback.amplist = ad1988_loopbacks;
3011 spec->vmaster_nid = 0x04;
3020 * port-B - front line/mic-in
3021 * port-E - aux in/out
3022 * port-F - aux in/out
3023 * port-C - rear line/mic-in
3024 * port-D - rear line/hp-out
3025 * port-A - front line/hp-out
3027 * AD1984 = AD1884 + two digital mic-ins
3030 * For simplicity, we share the single DAC for both HP and line-outs
3031 * right now. The inidividual playbacks could be easily implemented,
3032 * but no build-up framework is given, so far.
3035 static hda_nid_t ad1884_dac_nids[1] = {
3039 static hda_nid_t ad1884_adc_nids[2] = {
3043 static hda_nid_t ad1884_capsrc_nids[2] = {
3047 #define AD1884_SPDIF_OUT 0x02
3049 static struct hda_input_mux ad1884_capture_source = {
3052 { "Front Mic", 0x0 },
3059 static struct snd_kcontrol_new ad1884_base_mixers[] = {
3060 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
3061 /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */
3062 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
3063 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT),
3064 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT),
3065 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT),
3066 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
3067 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3068 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
3069 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
3070 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT),
3071 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT),
3073 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x20, 0x03, HDA_INPUT),
3074 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x20, 0x03, HDA_INPUT),
3075 HDA_CODEC_VOLUME("Digital Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
3076 HDA_CODEC_MUTE("Digital Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3078 HDA_CODEC_VOLUME("Mic Boost", 0x15, 0x0, HDA_INPUT),
3079 HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT),
3080 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3081 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3082 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
3083 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
3085 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3086 /* The multiple "Capture Source" controls confuse alsamixer
3087 * So call somewhat different..
3089 /* .name = "Capture Source", */
3090 .name = "Input Source",
3092 .info = ad198x_mux_enum_info,
3093 .get = ad198x_mux_enum_get,
3094 .put = ad198x_mux_enum_put,
3096 /* SPDIF controls */
3097 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
3099 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3100 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
3101 /* identical with ad1983 */
3102 .info = ad1983_spdif_route_info,
3103 .get = ad1983_spdif_route_get,
3104 .put = ad1983_spdif_route_put,
3109 static struct snd_kcontrol_new ad1984_dmic_mixers[] = {
3110 HDA_CODEC_VOLUME("Digital Mic Capture Volume", 0x05, 0x0, HDA_INPUT),
3111 HDA_CODEC_MUTE("Digital Mic Capture Switch", 0x05, 0x0, HDA_INPUT),
3112 HDA_CODEC_VOLUME_IDX("Digital Mic Capture Volume", 1, 0x06, 0x0,
3114 HDA_CODEC_MUTE_IDX("Digital Mic Capture Switch", 1, 0x06, 0x0,
3120 * initialization verbs
3122 static struct hda_verb ad1884_init_verbs[] = {
3123 /* DACs; mute as default */
3124 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3125 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3126 /* Port-A (HP) mixer */
3127 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3128 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3130 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3131 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3132 /* HP selector - select DAC2 */
3133 {0x22, AC_VERB_SET_CONNECT_SEL, 0x1},
3134 /* Port-D (Line-out) mixer */
3135 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3136 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3138 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3139 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3140 /* Mono-out mixer */
3141 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3142 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3144 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3145 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3147 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
3148 /* Port-B (front mic) pin */
3149 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3150 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3151 /* Port-C (rear mic) pin */
3152 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3153 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3154 /* Analog mixer; mute as default */
3155 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3156 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3157 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3158 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3159 /* Analog Mix output amp */
3160 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
3161 /* SPDIF output selector */
3162 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */
3163 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
3167 #ifdef CONFIG_SND_HDA_POWER_SAVE
3168 static struct hda_amp_list ad1884_loopbacks[] = {
3169 { 0x20, HDA_INPUT, 0 }, /* Front Mic */
3170 { 0x20, HDA_INPUT, 1 }, /* Mic */
3171 { 0x20, HDA_INPUT, 2 }, /* CD */
3172 { 0x20, HDA_INPUT, 4 }, /* Docking */
3177 static const char *ad1884_slave_vols[] = {
3178 "PCM Playback Volume",
3179 "Mic Playback Volume",
3180 "Mono Playback Volume",
3181 "Front Mic Playback Volume",
3182 "Mic Playback Volume",
3183 "CD Playback Volume",
3184 "Internal Mic Playback Volume",
3185 "Docking Mic Playback Volume"
3186 "Beep Playback Volume",
3187 "IEC958 Playback Volume",
3191 static int patch_ad1884(struct hda_codec *codec)
3193 struct ad198x_spec *spec;
3195 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3201 spec->multiout.max_channels = 2;
3202 spec->multiout.num_dacs = ARRAY_SIZE(ad1884_dac_nids);
3203 spec->multiout.dac_nids = ad1884_dac_nids;
3204 spec->multiout.dig_out_nid = AD1884_SPDIF_OUT;
3205 spec->num_adc_nids = ARRAY_SIZE(ad1884_adc_nids);
3206 spec->adc_nids = ad1884_adc_nids;
3207 spec->capsrc_nids = ad1884_capsrc_nids;
3208 spec->input_mux = &ad1884_capture_source;
3209 spec->num_mixers = 1;
3210 spec->mixers[0] = ad1884_base_mixers;
3211 spec->num_init_verbs = 1;
3212 spec->init_verbs[0] = ad1884_init_verbs;
3213 spec->spdif_route = 0;
3214 #ifdef CONFIG_SND_HDA_POWER_SAVE
3215 spec->loopback.amplist = ad1884_loopbacks;
3217 spec->vmaster_nid = 0x04;
3218 /* we need to cover all playback volumes */
3219 spec->slave_vols = ad1884_slave_vols;
3221 codec->patch_ops = ad198x_patch_ops;
3227 * Lenovo Thinkpad T61/X61
3229 static struct hda_input_mux ad1984_thinkpad_capture_source = {
3233 { "Internal Mic", 0x1 },
3235 { "Docking-Station", 0x4 },
3241 * Dell Precision T3400
3243 static struct hda_input_mux ad1984_dell_desktop_capture_source = {
3246 { "Front Mic", 0x0 },
3253 static struct snd_kcontrol_new ad1984_thinkpad_mixers[] = {
3254 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
3255 /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */
3256 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
3257 HDA_CODEC_MUTE("Speaker Playback Switch", 0x12, 0x0, HDA_OUTPUT),
3258 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
3259 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3260 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
3261 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
3262 HDA_CODEC_VOLUME("Docking Mic Playback Volume", 0x20, 0x04, HDA_INPUT),
3263 HDA_CODEC_MUTE("Docking Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
3264 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT),
3265 HDA_CODEC_VOLUME("Internal Mic Boost", 0x15, 0x0, HDA_INPUT),
3266 HDA_CODEC_VOLUME("Docking Mic Boost", 0x25, 0x0, HDA_OUTPUT),
3267 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
3268 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
3269 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3270 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3271 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
3272 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
3274 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3275 /* The multiple "Capture Source" controls confuse alsamixer
3276 * So call somewhat different..
3278 /* .name = "Capture Source", */
3279 .name = "Input Source",
3281 .info = ad198x_mux_enum_info,
3282 .get = ad198x_mux_enum_get,
3283 .put = ad198x_mux_enum_put,
3285 /* SPDIF controls */
3286 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
3288 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3289 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
3290 /* identical with ad1983 */
3291 .info = ad1983_spdif_route_info,
3292 .get = ad1983_spdif_route_get,
3293 .put = ad1983_spdif_route_put,
3298 /* additional verbs */
3299 static struct hda_verb ad1984_thinkpad_init_verbs[] = {
3300 /* Port-E (docking station mic) pin */
3301 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3302 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3303 /* docking mic boost */
3304 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3305 /* Analog mixer - docking mic; mute as default */
3306 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3307 /* enable EAPD bit */
3308 {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
3313 * Dell Precision T3400
3315 static struct snd_kcontrol_new ad1984_dell_desktop_mixers[] = {
3316 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
3317 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
3318 HDA_CODEC_MUTE("Speaker Playback Switch", 0x12, 0x0, HDA_OUTPUT),
3319 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT),
3320 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT),
3321 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
3322 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3323 HDA_CODEC_VOLUME("Line-In Playback Volume", 0x20, 0x01, HDA_INPUT),
3324 HDA_CODEC_MUTE("Line-In Playback Switch", 0x20, 0x01, HDA_INPUT),
3326 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x20, 0x03, HDA_INPUT),
3327 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x20, 0x03, HDA_INPUT),
3329 HDA_CODEC_VOLUME("Line-In Boost", 0x15, 0x0, HDA_INPUT),
3330 HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT),
3331 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3332 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3333 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
3334 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
3336 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3337 /* The multiple "Capture Source" controls confuse alsamixer
3338 * So call somewhat different..
3340 /* .name = "Capture Source", */
3341 .name = "Input Source",
3343 .info = ad198x_mux_enum_info,
3344 .get = ad198x_mux_enum_get,
3345 .put = ad198x_mux_enum_put,
3350 /* Digial MIC ADC NID 0x05 + 0x06 */
3351 static int ad1984_pcm_dmic_prepare(struct hda_pcm_stream *hinfo,
3352 struct hda_codec *codec,
3353 unsigned int stream_tag,
3354 unsigned int format,
3355 struct snd_pcm_substream *substream)
3357 snd_hda_codec_setup_stream(codec, 0x05 + substream->number,
3358 stream_tag, 0, format);
3362 static int ad1984_pcm_dmic_cleanup(struct hda_pcm_stream *hinfo,
3363 struct hda_codec *codec,
3364 struct snd_pcm_substream *substream)
3366 snd_hda_codec_cleanup_stream(codec, 0x05 + substream->number);
3370 static struct hda_pcm_stream ad1984_pcm_dmic_capture = {
3376 .prepare = ad1984_pcm_dmic_prepare,
3377 .cleanup = ad1984_pcm_dmic_cleanup
3381 static int ad1984_build_pcms(struct hda_codec *codec)
3383 struct ad198x_spec *spec = codec->spec;
3384 struct hda_pcm *info;
3387 err = ad198x_build_pcms(codec);
3391 info = spec->pcm_rec + codec->num_pcms;
3393 info->name = "AD1984 Digital Mic";
3394 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad1984_pcm_dmic_capture;
3402 AD1984_DELL_DESKTOP,
3406 static const char *ad1984_models[AD1984_MODELS] = {
3407 [AD1984_BASIC] = "basic",
3408 [AD1984_THINKPAD] = "thinkpad",
3409 [AD1984_DELL_DESKTOP] = "dell_desktop",
3412 static struct snd_pci_quirk ad1984_cfg_tbl[] = {
3413 /* Lenovo Thinkpad T61/X61 */
3414 SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1984_THINKPAD),
3415 SND_PCI_QUIRK(0x1028, 0x0214, "Dell T3400", AD1984_DELL_DESKTOP),
3419 static int patch_ad1984(struct hda_codec *codec)
3421 struct ad198x_spec *spec;
3422 int board_config, err;
3424 err = patch_ad1884(codec);
3428 board_config = snd_hda_check_board_config(codec, AD1984_MODELS,
3429 ad1984_models, ad1984_cfg_tbl);
3430 switch (board_config) {
3432 /* additional digital mics */
3433 spec->mixers[spec->num_mixers++] = ad1984_dmic_mixers;
3434 codec->patch_ops.build_pcms = ad1984_build_pcms;
3436 case AD1984_THINKPAD:
3437 spec->multiout.dig_out_nid = AD1884_SPDIF_OUT;
3438 spec->input_mux = &ad1984_thinkpad_capture_source;
3439 spec->mixers[0] = ad1984_thinkpad_mixers;
3440 spec->init_verbs[spec->num_init_verbs++] = ad1984_thinkpad_init_verbs;
3442 case AD1984_DELL_DESKTOP:
3443 spec->multiout.dig_out_nid = 0;
3444 spec->input_mux = &ad1984_dell_desktop_capture_source;
3445 spec->mixers[0] = ad1984_dell_desktop_mixers;
3453 * AD1883 / AD1884A / AD1984A / AD1984B
3455 * port-B (0x14) - front mic-in
3456 * port-E (0x1c) - rear mic-in
3457 * port-F (0x16) - CD / ext out
3458 * port-C (0x15) - rear line-in
3459 * port-D (0x12) - rear line-out
3460 * port-A (0x11) - front hp-out
3462 * AD1984A = AD1884A + digital-mic
3463 * AD1883 = equivalent with AD1984A
3464 * AD1984B = AD1984A + extra SPDIF-out
3467 * We share the single DAC for both HP and line-outs (see AD1884/1984).
3470 static hda_nid_t ad1884a_dac_nids[1] = {
3474 #define ad1884a_adc_nids ad1884_adc_nids
3475 #define ad1884a_capsrc_nids ad1884_capsrc_nids
3477 #define AD1884A_SPDIF_OUT 0x02
3479 static struct hda_input_mux ad1884a_capture_source = {
3482 { "Front Mic", 0x0 },
3490 static struct snd_kcontrol_new ad1884a_base_mixers[] = {
3491 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT),
3492 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),
3493 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
3494 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT),
3495 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT),
3496 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT),
3497 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
3498 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
3499 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
3500 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3501 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x01, HDA_INPUT),
3502 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x01, HDA_INPUT),
3503 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x04, HDA_INPUT),
3504 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
3505 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT),
3506 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT),
3507 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
3508 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
3509 HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT),
3510 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x0, HDA_INPUT),
3511 HDA_CODEC_VOLUME("Mic Boost", 0x25, 0x0, HDA_OUTPUT),
3512 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3513 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3514 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
3515 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
3517 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3518 /* The multiple "Capture Source" controls confuse alsamixer
3519 * So call somewhat different..
3521 /* .name = "Capture Source", */
3522 .name = "Input Source",
3524 .info = ad198x_mux_enum_info,
3525 .get = ad198x_mux_enum_get,
3526 .put = ad198x_mux_enum_put,
3528 /* SPDIF controls */
3529 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
3531 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3532 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
3533 /* identical with ad1983 */
3534 .info = ad1983_spdif_route_info,
3535 .get = ad1983_spdif_route_get,
3536 .put = ad1983_spdif_route_put,
3542 * initialization verbs
3544 static struct hda_verb ad1884a_init_verbs[] = {
3545 /* DACs; unmute as default */
3546 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */
3547 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */
3548 /* Port-A (HP) mixer - route only from analog mixer */
3549 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3550 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3552 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3553 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3554 /* Port-D (Line-out) mixer - route only from analog mixer */
3555 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3556 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3558 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3559 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3560 /* Mono-out mixer - route only from analog mixer */
3561 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3562 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3564 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3565 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3566 /* Port-B (front mic) pin */
3567 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3568 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3569 /* Port-C (rear line-in) pin */
3570 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3571 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3572 /* Port-E (rear mic) pin */
3573 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3574 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3575 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* no boost */
3576 /* Port-F (CD) pin */
3577 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3578 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3579 /* Analog mixer; mute as default */
3580 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3581 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3582 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3583 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3584 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, /* aux */
3585 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
3586 /* Analog Mix output amp */
3587 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3588 /* capture sources */
3589 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0},
3590 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3591 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
3592 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3593 /* SPDIF output amp */
3594 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
3598 #ifdef CONFIG_SND_HDA_POWER_SAVE
3599 static struct hda_amp_list ad1884a_loopbacks[] = {
3600 { 0x20, HDA_INPUT, 0 }, /* Front Mic */
3601 { 0x20, HDA_INPUT, 1 }, /* Mic */
3602 { 0x20, HDA_INPUT, 2 }, /* CD */
3603 { 0x20, HDA_INPUT, 4 }, /* Docking */
3611 * Port A: Headphone jack
3613 * Port C: Internal MIC
3614 * Port D: Dock Line Out (if enabled)
3615 * Port E: Dock Line In (if enabled)
3616 * Port F: Internal speakers
3619 static struct hda_input_mux ad1884a_laptop_capture_source = {
3622 { "Mic", 0x0 }, /* port-B */
3623 { "Internal Mic", 0x1 }, /* port-C */
3624 { "Dock Mic", 0x4 }, /* port-E */
3629 static struct snd_kcontrol_new ad1884a_laptop_mixers[] = {
3630 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT),
3631 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),
3632 HDA_CODEC_MUTE("Dock Playback Switch", 0x12, 0x0, HDA_OUTPUT),
3633 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
3634 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
3635 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
3636 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3637 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
3638 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
3639 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x20, 0x04, HDA_INPUT),
3640 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
3641 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
3642 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
3643 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT),
3644 HDA_CODEC_VOLUME("Internal Mic Boost", 0x15, 0x0, HDA_INPUT),
3645 HDA_CODEC_VOLUME("Dock Mic Boost", 0x25, 0x0, HDA_OUTPUT),
3646 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3647 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3648 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
3649 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
3651 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3652 /* The multiple "Capture Source" controls confuse alsamixer
3653 * So call somewhat different..
3655 /* .name = "Capture Source", */
3656 .name = "Input Source",
3658 .info = ad198x_mux_enum_info,
3659 .get = ad198x_mux_enum_get,
3660 .put = ad198x_mux_enum_put,
3665 static struct snd_kcontrol_new ad1884a_mobile_mixers[] = {
3666 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT),
3667 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),
3668 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
3669 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
3670 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
3671 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
3672 HDA_CODEC_VOLUME("Mic Capture Volume", 0x14, 0x0, HDA_INPUT),
3673 HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x15, 0x0, HDA_INPUT),
3674 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3675 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3679 /* mute internal speaker if HP is plugged */
3680 static void ad1884a_hp_automute(struct hda_codec *codec)
3682 unsigned int present;
3684 present = snd_hda_codec_read(codec, 0x11, 0,
3685 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
3686 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
3687 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
3688 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_EAPD_BTLENABLE,
3689 present ? 0x00 : 0x02);
3692 /* switch to external mic if plugged */
3693 static void ad1884a_hp_automic(struct hda_codec *codec)
3695 unsigned int present;
3697 present = snd_hda_codec_read(codec, 0x14, 0,
3698 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
3699 snd_hda_codec_write(codec, 0x0c, 0, AC_VERB_SET_CONNECT_SEL,
3703 #define AD1884A_HP_EVENT 0x37
3704 #define AD1884A_MIC_EVENT 0x36
3706 /* unsolicited event for HP jack sensing */
3707 static void ad1884a_hp_unsol_event(struct hda_codec *codec, unsigned int res)
3709 switch (res >> 26) {
3710 case AD1884A_HP_EVENT:
3711 ad1884a_hp_automute(codec);
3713 case AD1884A_MIC_EVENT:
3714 ad1884a_hp_automic(codec);
3719 /* initialize jack-sensing, too */
3720 static int ad1884a_hp_init(struct hda_codec *codec)
3723 ad1884a_hp_automute(codec);
3724 ad1884a_hp_automic(codec);
3728 /* additional verbs for laptop model */
3729 static struct hda_verb ad1884a_laptop_verbs[] = {
3730 /* Port-A (HP) pin - always unmuted */
3731 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3732 /* Port-F (int speaker) mixer - route only from analog mixer */
3733 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3734 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3736 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3737 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3738 /* Port-C pin - internal mic-in */
3739 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3740 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */
3741 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */
3743 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3744 /* unsolicited event for pin-sense */
3745 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT},
3746 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_MIC_EVENT},
3755 * 0x17 - built-in mic
3758 static struct hda_verb ad1984a_thinkpad_verbs[] = {
3760 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3762 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3764 {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
3765 /* unsolicited event for pin-sense */
3766 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT},
3767 /* internal mic - dmic */
3768 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3769 /* set magic COEFs for dmic */
3770 {0x01, AC_VERB_SET_COEF_INDEX, 0x13f7},
3771 {0x01, AC_VERB_SET_PROC_COEF, 0x08},
3775 static struct snd_kcontrol_new ad1984a_thinkpad_mixers[] = {
3776 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT),
3777 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),
3778 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
3779 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
3780 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
3781 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3782 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
3783 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
3784 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT),
3785 HDA_CODEC_VOLUME("Internal Mic Boost", 0x17, 0x0, HDA_INPUT),
3786 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3787 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3789 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3790 .name = "Capture Source",
3791 .info = ad198x_mux_enum_info,
3792 .get = ad198x_mux_enum_get,
3793 .put = ad198x_mux_enum_put,
3798 static struct hda_input_mux ad1984a_thinkpad_capture_source = {
3802 { "Internal Mic", 0x5 },
3807 /* mute internal speaker if HP is plugged */
3808 static void ad1984a_thinkpad_automute(struct hda_codec *codec)
3810 unsigned int present;
3812 present = snd_hda_codec_read(codec, 0x11, 0, AC_VERB_GET_PIN_SENSE, 0)
3813 & AC_PINSENSE_PRESENCE;
3814 snd_hda_codec_amp_stereo(codec, 0x12, HDA_OUTPUT, 0,
3815 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
3818 /* unsolicited event for HP jack sensing */
3819 static void ad1984a_thinkpad_unsol_event(struct hda_codec *codec,
3822 if ((res >> 26) != AD1884A_HP_EVENT)
3824 ad1984a_thinkpad_automute(codec);
3827 /* initialize jack-sensing, too */
3828 static int ad1984a_thinkpad_init(struct hda_codec *codec)
3831 ad1984a_thinkpad_automute(codec);
3846 static const char *ad1884a_models[AD1884A_MODELS] = {
3847 [AD1884A_DESKTOP] = "desktop",
3848 [AD1884A_LAPTOP] = "laptop",
3849 [AD1884A_MOBILE] = "mobile",
3850 [AD1884A_THINKPAD] = "thinkpad",
3853 static struct snd_pci_quirk ad1884a_cfg_tbl[] = {
3854 SND_PCI_QUIRK(0x103c, 0x3030, "HP", AD1884A_MOBILE),
3855 SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X300", AD1884A_THINKPAD),
3859 static int patch_ad1884a(struct hda_codec *codec)
3861 struct ad198x_spec *spec;
3864 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3870 spec->multiout.max_channels = 2;
3871 spec->multiout.num_dacs = ARRAY_SIZE(ad1884a_dac_nids);
3872 spec->multiout.dac_nids = ad1884a_dac_nids;
3873 spec->multiout.dig_out_nid = AD1884A_SPDIF_OUT;
3874 spec->num_adc_nids = ARRAY_SIZE(ad1884a_adc_nids);
3875 spec->adc_nids = ad1884a_adc_nids;
3876 spec->capsrc_nids = ad1884a_capsrc_nids;
3877 spec->input_mux = &ad1884a_capture_source;
3878 spec->num_mixers = 1;
3879 spec->mixers[0] = ad1884a_base_mixers;
3880 spec->num_init_verbs = 1;
3881 spec->init_verbs[0] = ad1884a_init_verbs;
3882 spec->spdif_route = 0;
3883 #ifdef CONFIG_SND_HDA_POWER_SAVE
3884 spec->loopback.amplist = ad1884a_loopbacks;
3886 codec->patch_ops = ad198x_patch_ops;
3888 /* override some parameters */
3889 board_config = snd_hda_check_board_config(codec, AD1884A_MODELS,
3892 switch (board_config) {
3893 case AD1884A_LAPTOP:
3894 spec->mixers[0] = ad1884a_laptop_mixers;
3895 spec->init_verbs[spec->num_init_verbs++] = ad1884a_laptop_verbs;
3896 spec->multiout.dig_out_nid = 0;
3897 spec->input_mux = &ad1884a_laptop_capture_source;
3898 codec->patch_ops.unsol_event = ad1884a_hp_unsol_event;
3899 codec->patch_ops.init = ad1884a_hp_init;
3901 case AD1884A_MOBILE:
3902 spec->mixers[0] = ad1884a_mobile_mixers;
3903 spec->init_verbs[spec->num_init_verbs++] = ad1884a_laptop_verbs;
3904 spec->multiout.dig_out_nid = 0;
3905 codec->patch_ops.unsol_event = ad1884a_hp_unsol_event;
3906 codec->patch_ops.init = ad1884a_hp_init;
3908 case AD1884A_THINKPAD:
3909 spec->mixers[0] = ad1984a_thinkpad_mixers;
3910 spec->init_verbs[spec->num_init_verbs++] =
3911 ad1984a_thinkpad_verbs;
3912 spec->multiout.dig_out_nid = 0;
3913 spec->input_mux = &ad1984a_thinkpad_capture_source;
3914 codec->patch_ops.unsol_event = ad1984a_thinkpad_unsol_event;
3915 codec->patch_ops.init = ad1984a_thinkpad_init;
3926 * port-A - front hp-out
3927 * port-B - front mic-in
3928 * port-C - rear line-in, shared surr-out (3stack)
3929 * port-D - rear line-out
3930 * port-E - rear mic-in, shared clfe-out (3stack)
3931 * port-F - rear surr-out (6stack)
3932 * port-G - rear clfe-out (6stack)
3935 static hda_nid_t ad1882_dac_nids[3] = {
3939 static hda_nid_t ad1882_adc_nids[2] = {
3943 static hda_nid_t ad1882_capsrc_nids[2] = {
3947 #define AD1882_SPDIF_OUT 0x02
3949 /* list: 0x11, 0x39, 0x3a, 0x18, 0x3c, 0x3b, 0x12, 0x20 */
3950 static struct hda_input_mux ad1882_capture_source = {
3953 { "Front Mic", 0x1 },
3961 /* list: 0x11, 0x39, 0x3a, 0x3c, 0x18, 0x1f, 0x12, 0x20 */
3962 static struct hda_input_mux ad1882a_capture_source = {
3965 { "Front Mic", 0x1 },
3968 { "Digital Mic", 0x06 },
3973 static struct snd_kcontrol_new ad1882_base_mixers[] = {
3974 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
3975 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
3976 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT),
3977 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT),
3978 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
3979 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT),
3980 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT),
3981 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT),
3983 HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT),
3984 HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT),
3985 HDA_CODEC_VOLUME("Line-In Boost", 0x3a, 0x0, HDA_OUTPUT),
3986 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3987 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3988 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
3989 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
3991 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3992 /* The multiple "Capture Source" controls confuse alsamixer
3993 * So call somewhat different..
3995 /* .name = "Capture Source", */
3996 .name = "Input Source",
3998 .info = ad198x_mux_enum_info,
3999 .get = ad198x_mux_enum_get,
4000 .put = ad198x_mux_enum_put,
4002 /* SPDIF controls */
4003 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
4005 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4006 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
4007 /* identical with ad1983 */
4008 .info = ad1983_spdif_route_info,
4009 .get = ad1983_spdif_route_get,
4010 .put = ad1983_spdif_route_put,
4015 static struct snd_kcontrol_new ad1882_loopback_mixers[] = {
4016 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
4017 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
4018 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
4019 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
4020 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x04, HDA_INPUT),
4021 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x04, HDA_INPUT),
4022 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT),
4023 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT),
4024 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x07, HDA_INPUT),
4025 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x07, HDA_INPUT),
4029 static struct snd_kcontrol_new ad1882a_loopback_mixers[] = {
4030 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
4031 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
4032 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x04, HDA_INPUT),
4033 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
4034 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x01, HDA_INPUT),
4035 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x01, HDA_INPUT),
4036 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT),
4037 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT),
4038 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x07, HDA_INPUT),
4039 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x07, HDA_INPUT),
4040 HDA_CODEC_VOLUME("Digital Mic Boost", 0x1f, 0x0, HDA_INPUT),
4044 static struct snd_kcontrol_new ad1882_3stack_mixers[] = {
4045 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
4046 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x17, 1, 0x0, HDA_OUTPUT),
4047 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x17, 2, 0x0, HDA_OUTPUT),
4049 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4050 .name = "Channel Mode",
4051 .info = ad198x_ch_mode_info,
4052 .get = ad198x_ch_mode_get,
4053 .put = ad198x_ch_mode_put,
4058 static struct snd_kcontrol_new ad1882_6stack_mixers[] = {
4059 HDA_CODEC_MUTE("Surround Playback Switch", 0x16, 0x0, HDA_OUTPUT),
4060 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x24, 1, 0x0, HDA_OUTPUT),
4061 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x24, 2, 0x0, HDA_OUTPUT),
4065 static struct hda_verb ad1882_ch2_init[] = {
4066 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4067 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4068 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4069 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4070 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4071 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4075 static struct hda_verb ad1882_ch4_init[] = {
4076 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4077 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4078 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4079 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4080 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4081 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4085 static struct hda_verb ad1882_ch6_init[] = {
4086 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4087 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4088 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4089 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4090 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4091 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4095 static struct hda_channel_mode ad1882_modes[3] = {
4096 { 2, ad1882_ch2_init },
4097 { 4, ad1882_ch4_init },
4098 { 6, ad1882_ch6_init },
4102 * initialization verbs
4104 static struct hda_verb ad1882_init_verbs[] = {
4105 /* DACs; mute as default */
4106 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4107 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4108 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4109 /* Port-A (HP) mixer */
4110 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4111 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4113 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4114 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4115 /* HP selector - select DAC2 */
4116 {0x37, AC_VERB_SET_CONNECT_SEL, 0x1},
4117 /* Port-D (Line-out) mixer */
4118 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4119 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4121 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4122 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4123 /* Mono-out mixer */
4124 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4125 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4127 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4128 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4129 /* Port-B (front mic) pin */
4130 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4131 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4132 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* boost */
4133 /* Port-C (line-in) pin */
4134 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4135 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4136 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* boost */
4137 /* Port-C mixer - mute as input */
4138 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4139 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4140 /* Port-E (mic-in) pin */
4141 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4142 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4143 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* boost */
4144 /* Port-E mixer - mute as input */
4145 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4146 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4147 /* Port-F (surround) */
4148 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4149 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4151 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4152 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4153 /* Analog mixer; mute as default */
4154 /* list: 0x39, 0x3a, 0x11, 0x12, 0x3c, 0x3b, 0x18, 0x1a */
4155 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4156 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4157 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4158 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4159 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4160 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
4161 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
4162 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
4163 /* Analog Mix output amp */
4164 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
4165 /* SPDIF output selector */
4166 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
4167 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */
4168 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
4172 #ifdef CONFIG_SND_HDA_POWER_SAVE
4173 static struct hda_amp_list ad1882_loopbacks[] = {
4174 { 0x20, HDA_INPUT, 0 }, /* Front Mic */
4175 { 0x20, HDA_INPUT, 1 }, /* Mic */
4176 { 0x20, HDA_INPUT, 4 }, /* Line */
4177 { 0x20, HDA_INPUT, 6 }, /* CD */
4189 static const char *ad1882_models[AD1986A_MODELS] = {
4190 [AD1882_3STACK] = "3stack",
4191 [AD1882_6STACK] = "6stack",
4195 static int patch_ad1882(struct hda_codec *codec)
4197 struct ad198x_spec *spec;
4200 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4206 spec->multiout.max_channels = 6;
4207 spec->multiout.num_dacs = 3;
4208 spec->multiout.dac_nids = ad1882_dac_nids;
4209 spec->multiout.dig_out_nid = AD1882_SPDIF_OUT;
4210 spec->num_adc_nids = ARRAY_SIZE(ad1882_adc_nids);
4211 spec->adc_nids = ad1882_adc_nids;
4212 spec->capsrc_nids = ad1882_capsrc_nids;
4213 if (codec->vendor_id == 0x11d1882)
4214 spec->input_mux = &ad1882_capture_source;
4216 spec->input_mux = &ad1882a_capture_source;
4217 spec->num_mixers = 2;
4218 spec->mixers[0] = ad1882_base_mixers;
4219 if (codec->vendor_id == 0x11d1882)
4220 spec->mixers[1] = ad1882_loopback_mixers;
4222 spec->mixers[1] = ad1882a_loopback_mixers;
4223 spec->num_init_verbs = 1;
4224 spec->init_verbs[0] = ad1882_init_verbs;
4225 spec->spdif_route = 0;
4226 #ifdef CONFIG_SND_HDA_POWER_SAVE
4227 spec->loopback.amplist = ad1882_loopbacks;
4229 spec->vmaster_nid = 0x04;
4231 codec->patch_ops = ad198x_patch_ops;
4233 /* override some parameters */
4234 board_config = snd_hda_check_board_config(codec, AD1882_MODELS,
4235 ad1882_models, NULL);
4236 switch (board_config) {
4239 spec->num_mixers = 3;
4240 spec->mixers[2] = ad1882_3stack_mixers;
4241 spec->channel_mode = ad1882_modes;
4242 spec->num_channel_mode = ARRAY_SIZE(ad1882_modes);
4243 spec->need_dac_fix = 1;
4244 spec->multiout.max_channels = 2;
4245 spec->multiout.num_dacs = 1;
4248 spec->num_mixers = 3;
4249 spec->mixers[2] = ad1882_6stack_mixers;
4259 struct hda_codec_preset snd_hda_preset_analog[] = {
4260 { .id = 0x11d4184a, .name = "AD1884A", .patch = patch_ad1884a },
4261 { .id = 0x11d41882, .name = "AD1882", .patch = patch_ad1882 },
4262 { .id = 0x11d41883, .name = "AD1883", .patch = patch_ad1884a },
4263 { .id = 0x11d41884, .name = "AD1884", .patch = patch_ad1884 },
4264 { .id = 0x11d4194a, .name = "AD1984A", .patch = patch_ad1884a },
4265 { .id = 0x11d4194b, .name = "AD1984B", .patch = patch_ad1884a },
4266 { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 },
4267 { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 },
4268 { .id = 0x11d41984, .name = "AD1984", .patch = patch_ad1984 },
4269 { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a },
4270 { .id = 0x11d41988, .name = "AD1988", .patch = patch_ad1988 },
4271 { .id = 0x11d4198b, .name = "AD1988B", .patch = patch_ad1988 },
4272 { .id = 0x11d4882a, .name = "AD1882A", .patch = patch_ad1882 },
4273 { .id = 0x11d4989a, .name = "AD1989A", .patch = patch_ad1988 },
4274 { .id = 0x11d4989b, .name = "AD1989B", .patch = patch_ad1988 },