2 * HD audio interface patch for AD1882, AD1884, AD1981HD, AD1983, AD1984,
5 * Copyright (c) 2005-2007 Takashi Iwai <tiwai@suse.de>
7 * This driver is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This driver is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <linux/init.h>
23 #include <linux/delay.h>
24 #include <linux/slab.h>
25 #include <linux/pci.h>
27 #include <sound/core.h>
28 #include "hda_codec.h"
29 #include "hda_local.h"
33 struct snd_kcontrol_new *mixers[5];
35 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
36 const struct hda_verb *init_verbs[5]; /* initialization verbs
37 * don't forget NULL termination!
39 unsigned int num_init_verbs;
42 struct hda_multi_out multiout; /* playback set-up
43 * max_channels, dacs must be set
44 * dig_out_nid and hp_nid are optional
46 unsigned int cur_eapd;
47 unsigned int need_dac_fix;
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 struct snd_array kctls;
71 struct hda_input_mux private_imux;
72 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
74 unsigned int jack_present :1;
75 unsigned int inv_jack_detect:1; /* inverted jack-detection */
76 unsigned int inv_eapd:1; /* inverted EAPD implementation */
78 #ifdef CONFIG_SND_HDA_POWER_SAVE
79 struct hda_loopback_check loopback;
81 /* for virtual master */
82 hda_nid_t vmaster_nid;
83 const char **slave_vols;
84 const char **slave_sws;
88 * input MUX handling (common part)
90 static int ad198x_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
92 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
93 struct ad198x_spec *spec = codec->spec;
95 return snd_hda_input_mux_info(spec->input_mux, uinfo);
98 static int ad198x_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
100 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
101 struct ad198x_spec *spec = codec->spec;
102 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
104 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
108 static int ad198x_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
110 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
111 struct ad198x_spec *spec = codec->spec;
112 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
114 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
115 spec->capsrc_nids[adc_idx],
116 &spec->cur_mux[adc_idx]);
120 * initialization (common callbacks)
122 static int ad198x_init(struct hda_codec *codec)
124 struct ad198x_spec *spec = codec->spec;
127 for (i = 0; i < spec->num_init_verbs; i++)
128 snd_hda_sequence_write(codec, spec->init_verbs[i]);
132 static const char *ad_slave_vols[] = {
133 "Front Playback Volume",
134 "Surround Playback Volume",
135 "Center Playback Volume",
136 "LFE Playback Volume",
137 "Side Playback Volume",
138 "Headphone Playback Volume",
139 "Mono Playback Volume",
140 "Speaker Playback Volume",
141 "IEC958 Playback Volume",
145 static const char *ad_slave_sws[] = {
146 "Front Playback Switch",
147 "Surround Playback Switch",
148 "Center Playback Switch",
149 "LFE Playback Switch",
150 "Side Playback Switch",
151 "Headphone Playback Switch",
152 "Mono Playback Switch",
153 "Speaker Playback Switch",
154 "IEC958 Playback Switch",
158 static void ad198x_free_kctls(struct hda_codec *codec);
160 #ifdef CONFIG_SND_HDA_INPUT_BEEP
161 /* additional beep mixers; the actual parameters are overwritten at build */
162 static struct snd_kcontrol_new ad_beep_mixer[] = {
163 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_OUTPUT),
164 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_OUTPUT),
168 #define set_beep_amp(spec, nid, idx, dir) \
169 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir)) /* mono */
171 #define set_beep_amp(spec, nid, idx, dir) /* NOP */
174 static int ad198x_build_controls(struct hda_codec *codec)
176 struct ad198x_spec *spec = codec->spec;
177 struct snd_kcontrol *kctl;
181 for (i = 0; i < spec->num_mixers; i++) {
182 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
186 if (spec->multiout.dig_out_nid) {
187 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
190 err = snd_hda_create_spdif_share_sw(codec,
194 spec->multiout.share_spdif = 1;
196 if (spec->dig_in_nid) {
197 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
202 /* create beep controls if needed */
203 #ifdef CONFIG_SND_HDA_INPUT_BEEP
204 if (spec->beep_amp) {
205 struct snd_kcontrol_new *knew;
206 for (knew = ad_beep_mixer; knew->name; knew++) {
207 struct snd_kcontrol *kctl;
208 kctl = snd_ctl_new1(knew, codec);
211 kctl->private_value = spec->beep_amp;
212 err = snd_hda_ctl_add(codec, 0, kctl);
219 /* if we have no master control, let's create it */
220 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
221 unsigned int vmaster_tlv[4];
222 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
223 HDA_OUTPUT, vmaster_tlv);
224 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
227 spec->slave_vols : ad_slave_vols));
231 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
232 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
235 spec->slave_sws : ad_slave_sws));
240 ad198x_free_kctls(codec); /* no longer needed */
242 /* assign Capture Source enums to NID */
243 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
245 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
246 for (i = 0; kctl && i < kctl->count; i++) {
247 err = snd_hda_add_nids(codec, kctl, i, spec->capsrc_nids,
248 spec->input_mux->num_items);
253 /* assign IEC958 enums to NID */
254 kctl = snd_hda_find_mixer_ctl(codec,
255 SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source");
257 err = snd_hda_add_nid(codec, kctl, 0,
258 spec->multiout.dig_out_nid);
266 #ifdef CONFIG_SND_HDA_POWER_SAVE
267 static int ad198x_check_power_status(struct hda_codec *codec, hda_nid_t nid)
269 struct ad198x_spec *spec = codec->spec;
270 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
275 * Analog playback callbacks
277 static int ad198x_playback_pcm_open(struct hda_pcm_stream *hinfo,
278 struct hda_codec *codec,
279 struct snd_pcm_substream *substream)
281 struct ad198x_spec *spec = codec->spec;
282 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
286 static int ad198x_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
287 struct hda_codec *codec,
288 unsigned int stream_tag,
290 struct snd_pcm_substream *substream)
292 struct ad198x_spec *spec = codec->spec;
293 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
297 static int ad198x_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
298 struct hda_codec *codec,
299 struct snd_pcm_substream *substream)
301 struct ad198x_spec *spec = codec->spec;
302 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
308 static int ad198x_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
309 struct hda_codec *codec,
310 struct snd_pcm_substream *substream)
312 struct ad198x_spec *spec = codec->spec;
313 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
316 static int ad198x_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
317 struct hda_codec *codec,
318 struct snd_pcm_substream *substream)
320 struct ad198x_spec *spec = codec->spec;
321 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
324 static int ad198x_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
325 struct hda_codec *codec,
326 unsigned int stream_tag,
328 struct snd_pcm_substream *substream)
330 struct ad198x_spec *spec = codec->spec;
331 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag,
335 static int ad198x_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
336 struct hda_codec *codec,
337 struct snd_pcm_substream *substream)
339 struct ad198x_spec *spec = codec->spec;
340 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
346 static int ad198x_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
347 struct hda_codec *codec,
348 unsigned int stream_tag,
350 struct snd_pcm_substream *substream)
352 struct ad198x_spec *spec = codec->spec;
353 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
354 stream_tag, 0, format);
358 static int ad198x_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
359 struct hda_codec *codec,
360 struct snd_pcm_substream *substream)
362 struct ad198x_spec *spec = codec->spec;
363 snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
370 static struct hda_pcm_stream ad198x_pcm_analog_playback = {
373 .channels_max = 6, /* changed later */
374 .nid = 0, /* fill later */
376 .open = ad198x_playback_pcm_open,
377 .prepare = ad198x_playback_pcm_prepare,
378 .cleanup = ad198x_playback_pcm_cleanup
382 static struct hda_pcm_stream ad198x_pcm_analog_capture = {
386 .nid = 0, /* fill later */
388 .prepare = ad198x_capture_pcm_prepare,
389 .cleanup = ad198x_capture_pcm_cleanup
393 static struct hda_pcm_stream ad198x_pcm_digital_playback = {
397 .nid = 0, /* fill later */
399 .open = ad198x_dig_playback_pcm_open,
400 .close = ad198x_dig_playback_pcm_close,
401 .prepare = ad198x_dig_playback_pcm_prepare,
402 .cleanup = ad198x_dig_playback_pcm_cleanup
406 static struct hda_pcm_stream ad198x_pcm_digital_capture = {
410 /* NID is set in alc_build_pcms */
413 static int ad198x_build_pcms(struct hda_codec *codec)
415 struct ad198x_spec *spec = codec->spec;
416 struct hda_pcm *info = spec->pcm_rec;
419 codec->pcm_info = info;
421 info->name = "AD198x Analog";
422 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_analog_playback;
423 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->multiout.max_channels;
424 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
425 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_analog_capture;
426 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adc_nids;
427 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
429 if (spec->multiout.dig_out_nid) {
432 info->name = "AD198x Digital";
433 info->pcm_type = HDA_PCM_TYPE_SPDIF;
434 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_digital_playback;
435 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
436 if (spec->dig_in_nid) {
437 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_digital_capture;
438 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
445 static void ad198x_free_kctls(struct hda_codec *codec)
447 struct ad198x_spec *spec = codec->spec;
449 if (spec->kctls.list) {
450 struct snd_kcontrol_new *kctl = spec->kctls.list;
452 for (i = 0; i < spec->kctls.used; i++)
455 snd_array_free(&spec->kctls);
458 static void ad198x_free(struct hda_codec *codec)
460 struct ad198x_spec *spec = codec->spec;
465 ad198x_free_kctls(codec);
467 snd_hda_detach_beep_device(codec);
470 static struct hda_codec_ops ad198x_patch_ops = {
471 .build_controls = ad198x_build_controls,
472 .build_pcms = ad198x_build_pcms,
475 #ifdef CONFIG_SND_HDA_POWER_SAVE
476 .check_power_status = ad198x_check_power_status,
483 * the private value = nid
485 #define ad198x_eapd_info snd_ctl_boolean_mono_info
487 static int ad198x_eapd_get(struct snd_kcontrol *kcontrol,
488 struct snd_ctl_elem_value *ucontrol)
490 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
491 struct ad198x_spec *spec = codec->spec;
493 ucontrol->value.integer.value[0] = ! spec->cur_eapd;
495 ucontrol->value.integer.value[0] = spec->cur_eapd;
499 static int ad198x_eapd_put(struct snd_kcontrol *kcontrol,
500 struct snd_ctl_elem_value *ucontrol)
502 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
503 struct ad198x_spec *spec = codec->spec;
504 hda_nid_t nid = kcontrol->private_value & 0xff;
506 eapd = !!ucontrol->value.integer.value[0];
509 if (eapd == spec->cur_eapd)
511 spec->cur_eapd = eapd;
512 snd_hda_codec_write_cache(codec, nid,
513 0, AC_VERB_SET_EAPD_BTLENABLE,
518 static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol,
519 struct snd_ctl_elem_info *uinfo);
520 static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol,
521 struct snd_ctl_elem_value *ucontrol);
522 static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol,
523 struct snd_ctl_elem_value *ucontrol);
530 #define AD1986A_SPDIF_OUT 0x02
531 #define AD1986A_FRONT_DAC 0x03
532 #define AD1986A_SURR_DAC 0x04
533 #define AD1986A_CLFE_DAC 0x05
534 #define AD1986A_ADC 0x06
536 static hda_nid_t ad1986a_dac_nids[3] = {
537 AD1986A_FRONT_DAC, AD1986A_SURR_DAC, AD1986A_CLFE_DAC
539 static hda_nid_t ad1986a_adc_nids[1] = { AD1986A_ADC };
540 static hda_nid_t ad1986a_capsrc_nids[1] = { 0x12 };
542 static struct hda_input_mux ad1986a_capture_source = {
556 static struct hda_bind_ctls ad1986a_bind_pcm_vol = {
557 .ops = &snd_hda_bind_vol,
559 HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT),
560 HDA_COMPOSE_AMP_VAL(AD1986A_SURR_DAC, 3, 0, HDA_OUTPUT),
561 HDA_COMPOSE_AMP_VAL(AD1986A_CLFE_DAC, 3, 0, HDA_OUTPUT),
566 static struct hda_bind_ctls ad1986a_bind_pcm_sw = {
567 .ops = &snd_hda_bind_sw,
569 HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT),
570 HDA_COMPOSE_AMP_VAL(AD1986A_SURR_DAC, 3, 0, HDA_OUTPUT),
571 HDA_COMPOSE_AMP_VAL(AD1986A_CLFE_DAC, 3, 0, HDA_OUTPUT),
579 static struct snd_kcontrol_new ad1986a_mixers[] = {
581 * bind volumes/mutes of 3 DACs as a single PCM control for simplicity
583 HDA_BIND_VOL("PCM Playback Volume", &ad1986a_bind_pcm_vol),
584 HDA_BIND_SW("PCM Playback Switch", &ad1986a_bind_pcm_sw),
585 HDA_CODEC_VOLUME("Front Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
586 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
587 HDA_CODEC_VOLUME("Surround Playback Volume", 0x1c, 0x0, HDA_OUTPUT),
588 HDA_CODEC_MUTE("Surround Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
589 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x1d, 1, 0x0, HDA_OUTPUT),
590 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x1d, 2, 0x0, HDA_OUTPUT),
591 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x1d, 1, 0x0, HDA_OUTPUT),
592 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x1d, 2, 0x0, HDA_OUTPUT),
593 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT),
594 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
595 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT),
596 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT),
597 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT),
598 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT),
599 HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT),
600 HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT),
601 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
602 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
603 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
604 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
605 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT),
606 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
607 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
609 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
610 .name = "Capture Source",
611 .info = ad198x_mux_enum_info,
612 .get = ad198x_mux_enum_get,
613 .put = ad198x_mux_enum_put,
615 HDA_CODEC_MUTE("Stereo Downmix Switch", 0x09, 0x0, HDA_OUTPUT),
619 /* additional mixers for 3stack mode */
620 static struct snd_kcontrol_new ad1986a_3st_mixers[] = {
622 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
623 .name = "Channel Mode",
624 .info = ad198x_ch_mode_info,
625 .get = ad198x_ch_mode_get,
626 .put = ad198x_ch_mode_put,
631 /* laptop model - 2ch only */
632 static hda_nid_t ad1986a_laptop_dac_nids[1] = { AD1986A_FRONT_DAC };
634 /* master controls both pins 0x1a and 0x1b */
635 static struct hda_bind_ctls ad1986a_laptop_master_vol = {
636 .ops = &snd_hda_bind_vol,
638 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT),
639 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
644 static struct hda_bind_ctls ad1986a_laptop_master_sw = {
645 .ops = &snd_hda_bind_sw,
647 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT),
648 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
653 static struct snd_kcontrol_new ad1986a_laptop_mixers[] = {
654 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
655 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
656 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol),
657 HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw),
658 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT),
659 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT),
660 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT),
661 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT),
662 HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT),
663 HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT),
664 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
665 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
666 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
668 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
669 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), */
670 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
671 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
673 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
674 .name = "Capture Source",
675 .info = ad198x_mux_enum_info,
676 .get = ad198x_mux_enum_get,
677 .put = ad198x_mux_enum_put,
682 /* laptop-eapd model - 2ch only */
684 static struct hda_input_mux ad1986a_laptop_eapd_capture_source = {
688 { "Internal Mic", 0x4 },
693 static struct hda_input_mux ad1986a_automic_capture_source = {
701 static struct snd_kcontrol_new ad1986a_laptop_master_mixers[] = {
702 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol),
703 HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw),
707 static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = {
708 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
709 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
710 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
711 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
712 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
713 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
714 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
716 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
717 .name = "Capture Source",
718 .info = ad198x_mux_enum_info,
719 .get = ad198x_mux_enum_get,
720 .put = ad198x_mux_enum_put,
723 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
724 .name = "External Amplifier",
725 .subdevice = HDA_SUBDEV_NID_FLAG | 0x1b,
726 .info = ad198x_eapd_info,
727 .get = ad198x_eapd_get,
728 .put = ad198x_eapd_put,
729 .private_value = 0x1b, /* port-D */
734 static struct snd_kcontrol_new ad1986a_laptop_intmic_mixers[] = {
735 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0, HDA_OUTPUT),
736 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0, HDA_OUTPUT),
740 /* re-connect the mic boost input according to the jack sensing */
741 static void ad1986a_automic(struct hda_codec *codec)
743 unsigned int present;
744 present = snd_hda_jack_detect(codec, 0x1f);
745 /* 0 = 0x1f, 2 = 0x1d, 4 = mixed */
746 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_CONNECT_SEL,
750 #define AD1986A_MIC_EVENT 0x36
752 static void ad1986a_automic_unsol_event(struct hda_codec *codec,
755 if ((res >> 26) != AD1986A_MIC_EVENT)
757 ad1986a_automic(codec);
760 static int ad1986a_automic_init(struct hda_codec *codec)
763 ad1986a_automic(codec);
767 /* laptop-automute - 2ch only */
769 static void ad1986a_update_hp(struct hda_codec *codec)
771 struct ad198x_spec *spec = codec->spec;
774 if (spec->jack_present)
775 mute = HDA_AMP_MUTE; /* mute internal speaker */
777 /* unmute internal speaker if necessary */
778 mute = snd_hda_codec_amp_read(codec, 0x1a, 0, HDA_OUTPUT, 0);
779 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
783 static void ad1986a_hp_automute(struct hda_codec *codec)
785 struct ad198x_spec *spec = codec->spec;
787 spec->jack_present = snd_hda_jack_detect(codec, 0x1a);
788 if (spec->inv_jack_detect)
789 spec->jack_present = !spec->jack_present;
790 ad1986a_update_hp(codec);
793 #define AD1986A_HP_EVENT 0x37
795 static void ad1986a_hp_unsol_event(struct hda_codec *codec, unsigned int res)
797 if ((res >> 26) != AD1986A_HP_EVENT)
799 ad1986a_hp_automute(codec);
802 static int ad1986a_hp_init(struct hda_codec *codec)
805 ad1986a_hp_automute(codec);
809 /* bind hp and internal speaker mute (with plug check) */
810 static int ad1986a_hp_master_sw_put(struct snd_kcontrol *kcontrol,
811 struct snd_ctl_elem_value *ucontrol)
813 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
814 long *valp = ucontrol->value.integer.value;
817 change = snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0,
819 valp[0] ? 0 : HDA_AMP_MUTE);
820 change |= snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0,
822 valp[1] ? 0 : HDA_AMP_MUTE);
824 ad1986a_update_hp(codec);
828 static struct snd_kcontrol_new ad1986a_automute_master_mixers[] = {
829 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol),
831 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
832 .name = "Master Playback Switch",
833 .subdevice = HDA_SUBDEV_AMP_FLAG,
834 .info = snd_hda_mixer_amp_switch_info,
835 .get = snd_hda_mixer_amp_switch_get,
836 .put = ad1986a_hp_master_sw_put,
837 .private_value = HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT),
844 * initialization verbs
846 static struct hda_verb ad1986a_init_verbs[] = {
847 /* Front, Surround, CLFE DAC; mute as default */
848 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
849 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
850 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
852 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
853 /* HP, Line-Out, Surround, CLFE selectors */
854 {0x0a, AC_VERB_SET_CONNECT_SEL, 0x0},
855 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x0},
856 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0},
857 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
859 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x0},
860 /* Mic selector: Mic 1/2 pin */
861 {0x0f, AC_VERB_SET_CONNECT_SEL, 0x0},
862 /* Line-in selector: Line-in */
863 {0x10, AC_VERB_SET_CONNECT_SEL, 0x0},
865 {0x11, AC_VERB_SET_CONNECT_SEL, 0x0},
866 /* Record selector: mic */
867 {0x12, AC_VERB_SET_CONNECT_SEL, 0x0},
868 /* Mic, Phone, CD, Aux, Line-In amp; mute as default */
869 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
870 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
871 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
872 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
873 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
875 {0x18, AC_VERB_SET_CONNECT_SEL, 0x0},
876 /* HP, Line-Out, Surround, CLFE, Mono pins; mute as default */
877 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
878 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
879 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
880 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
881 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
883 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
884 /* Front, Surround, CLFE Pins */
885 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
886 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
887 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
889 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
891 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
892 /* Line, Aux, CD, Beep-In Pin */
893 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
894 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
895 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
896 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
897 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
901 static struct hda_verb ad1986a_ch2_init[] = {
902 /* Surround out -> Line In */
903 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
904 /* Line-in selectors */
905 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x1 },
907 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
908 /* Mic selector, mix C/LFE (backmic) and Mic (frontmic) */
909 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 },
913 static struct hda_verb ad1986a_ch4_init[] = {
914 /* Surround out -> Surround */
915 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
916 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
918 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
919 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 },
923 static struct hda_verb ad1986a_ch6_init[] = {
924 /* Surround out -> Surround out */
925 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
926 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
928 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
929 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x0 },
933 static struct hda_channel_mode ad1986a_modes[3] = {
934 { 2, ad1986a_ch2_init },
935 { 4, ad1986a_ch4_init },
936 { 6, ad1986a_ch6_init },
939 /* eapd initialization */
940 static struct hda_verb ad1986a_eapd_init_verbs[] = {
941 {0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00 },
945 static struct hda_verb ad1986a_automic_verbs[] = {
946 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
947 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
948 /*{0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},*/
949 {0x0f, AC_VERB_SET_CONNECT_SEL, 0x0},
950 {0x1f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1986A_MIC_EVENT},
954 /* Ultra initialization */
955 static struct hda_verb ad1986a_ultra_init[] = {
956 /* eapd initialization */
957 { 0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00 },
959 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2 },
960 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
961 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
965 /* pin sensing on HP jack */
966 static struct hda_verb ad1986a_hp_init_verbs[] = {
967 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1986A_HP_EVENT},
971 static void ad1986a_samsung_p50_unsol_event(struct hda_codec *codec,
975 case AD1986A_HP_EVENT:
976 ad1986a_hp_automute(codec);
978 case AD1986A_MIC_EVENT:
979 ad1986a_automic(codec);
984 static int ad1986a_samsung_p50_init(struct hda_codec *codec)
987 ad1986a_hp_automute(codec);
988 ad1986a_automic(codec);
999 AD1986A_LAPTOP_AUTOMUTE,
1002 AD1986A_SAMSUNG_P50,
1006 static const char *ad1986a_models[AD1986A_MODELS] = {
1007 [AD1986A_6STACK] = "6stack",
1008 [AD1986A_3STACK] = "3stack",
1009 [AD1986A_LAPTOP] = "laptop",
1010 [AD1986A_LAPTOP_EAPD] = "laptop-eapd",
1011 [AD1986A_LAPTOP_AUTOMUTE] = "laptop-automute",
1012 [AD1986A_ULTRA] = "ultra",
1013 [AD1986A_SAMSUNG] = "samsung",
1014 [AD1986A_SAMSUNG_P50] = "samsung-p50",
1017 static struct snd_pci_quirk ad1986a_cfg_tbl[] = {
1018 SND_PCI_QUIRK(0x103c, 0x30af, "HP B2800", AD1986A_LAPTOP_EAPD),
1019 SND_PCI_QUIRK(0x1043, 0x1153, "ASUS M9", AD1986A_LAPTOP_EAPD),
1020 SND_PCI_QUIRK(0x1043, 0x11f7, "ASUS U5A", AD1986A_LAPTOP_EAPD),
1021 SND_PCI_QUIRK(0x1043, 0x1213, "ASUS A6J", AD1986A_LAPTOP_EAPD),
1022 SND_PCI_QUIRK(0x1043, 0x1263, "ASUS U5F", AD1986A_LAPTOP_EAPD),
1023 SND_PCI_QUIRK(0x1043, 0x1297, "ASUS Z62F", AD1986A_LAPTOP_EAPD),
1024 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS V1j", AD1986A_LAPTOP_EAPD),
1025 SND_PCI_QUIRK(0x1043, 0x1302, "ASUS W3j", AD1986A_LAPTOP_EAPD),
1026 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS VX1", AD1986A_LAPTOP),
1027 SND_PCI_QUIRK(0x1043, 0x1447, "ASUS A8J", AD1986A_3STACK),
1028 SND_PCI_QUIRK(0x1043, 0x817f, "ASUS P5", AD1986A_3STACK),
1029 SND_PCI_QUIRK(0x1043, 0x818f, "ASUS P5", AD1986A_LAPTOP),
1030 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS P5", AD1986A_3STACK),
1031 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS M2N", AD1986A_3STACK),
1032 SND_PCI_QUIRK(0x1043, 0x8234, "ASUS M2N", AD1986A_3STACK),
1033 SND_PCI_QUIRK(0x10de, 0xcb84, "ASUS A8N-VM", AD1986A_3STACK),
1034 SND_PCI_QUIRK(0x1179, 0xff40, "Toshiba", AD1986A_LAPTOP_EAPD),
1035 SND_PCI_QUIRK(0x144d, 0xb03c, "Samsung R55", AD1986A_3STACK),
1036 SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP),
1037 SND_PCI_QUIRK(0x144d, 0xc024, "Samsung P50", AD1986A_SAMSUNG_P50),
1038 SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_ULTRA),
1039 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc000, "Samsung", AD1986A_SAMSUNG),
1040 SND_PCI_QUIRK(0x144d, 0xc504, "Samsung Q35", AD1986A_3STACK),
1041 SND_PCI_QUIRK(0x17aa, 0x1011, "Lenovo M55", AD1986A_LAPTOP),
1042 SND_PCI_QUIRK(0x17aa, 0x1017, "Lenovo A60", AD1986A_3STACK),
1043 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo N100", AD1986A_LAPTOP_AUTOMUTE),
1044 SND_PCI_QUIRK(0x17c0, 0x2017, "Samsung M50", AD1986A_LAPTOP),
1048 #ifdef CONFIG_SND_HDA_POWER_SAVE
1049 static struct hda_amp_list ad1986a_loopbacks[] = {
1050 { 0x13, HDA_OUTPUT, 0 }, /* Mic */
1051 { 0x14, HDA_OUTPUT, 0 }, /* Phone */
1052 { 0x15, HDA_OUTPUT, 0 }, /* CD */
1053 { 0x16, HDA_OUTPUT, 0 }, /* Aux */
1054 { 0x17, HDA_OUTPUT, 0 }, /* Line */
1059 static int is_jack_available(struct hda_codec *codec, hda_nid_t nid)
1061 unsigned int conf = snd_hda_codec_get_pincfg(codec, nid);
1062 return get_defcfg_connect(conf) != AC_JACK_PORT_NONE;
1065 static int patch_ad1986a(struct hda_codec *codec)
1067 struct ad198x_spec *spec;
1068 int err, board_config;
1070 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1076 err = snd_hda_attach_beep_device(codec, 0x19);
1081 set_beep_amp(spec, 0x18, 0, HDA_OUTPUT);
1083 spec->multiout.max_channels = 6;
1084 spec->multiout.num_dacs = ARRAY_SIZE(ad1986a_dac_nids);
1085 spec->multiout.dac_nids = ad1986a_dac_nids;
1086 spec->multiout.dig_out_nid = AD1986A_SPDIF_OUT;
1087 spec->num_adc_nids = 1;
1088 spec->adc_nids = ad1986a_adc_nids;
1089 spec->capsrc_nids = ad1986a_capsrc_nids;
1090 spec->input_mux = &ad1986a_capture_source;
1091 spec->num_mixers = 1;
1092 spec->mixers[0] = ad1986a_mixers;
1093 spec->num_init_verbs = 1;
1094 spec->init_verbs[0] = ad1986a_init_verbs;
1095 #ifdef CONFIG_SND_HDA_POWER_SAVE
1096 spec->loopback.amplist = ad1986a_loopbacks;
1098 spec->vmaster_nid = 0x1b;
1099 spec->inv_eapd = 1; /* AD1986A has the inverted EAPD implementation */
1101 codec->patch_ops = ad198x_patch_ops;
1103 /* override some parameters */
1104 board_config = snd_hda_check_board_config(codec, AD1986A_MODELS,
1107 switch (board_config) {
1108 case AD1986A_3STACK:
1109 spec->num_mixers = 2;
1110 spec->mixers[1] = ad1986a_3st_mixers;
1111 spec->num_init_verbs = 2;
1112 spec->init_verbs[1] = ad1986a_ch2_init;
1113 spec->channel_mode = ad1986a_modes;
1114 spec->num_channel_mode = ARRAY_SIZE(ad1986a_modes);
1115 spec->need_dac_fix = 1;
1116 spec->multiout.max_channels = 2;
1117 spec->multiout.num_dacs = 1;
1119 case AD1986A_LAPTOP:
1120 spec->mixers[0] = ad1986a_laptop_mixers;
1121 spec->multiout.max_channels = 2;
1122 spec->multiout.num_dacs = 1;
1123 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
1125 case AD1986A_LAPTOP_EAPD:
1126 spec->num_mixers = 3;
1127 spec->mixers[0] = ad1986a_laptop_master_mixers;
1128 spec->mixers[1] = ad1986a_laptop_eapd_mixers;
1129 spec->mixers[2] = ad1986a_laptop_intmic_mixers;
1130 spec->num_init_verbs = 2;
1131 spec->init_verbs[1] = ad1986a_eapd_init_verbs;
1132 spec->multiout.max_channels = 2;
1133 spec->multiout.num_dacs = 1;
1134 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
1135 if (!is_jack_available(codec, 0x25))
1136 spec->multiout.dig_out_nid = 0;
1137 spec->input_mux = &ad1986a_laptop_eapd_capture_source;
1139 case AD1986A_SAMSUNG:
1140 spec->num_mixers = 2;
1141 spec->mixers[0] = ad1986a_laptop_master_mixers;
1142 spec->mixers[1] = ad1986a_laptop_eapd_mixers;
1143 spec->num_init_verbs = 3;
1144 spec->init_verbs[1] = ad1986a_eapd_init_verbs;
1145 spec->init_verbs[2] = ad1986a_automic_verbs;
1146 spec->multiout.max_channels = 2;
1147 spec->multiout.num_dacs = 1;
1148 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
1149 if (!is_jack_available(codec, 0x25))
1150 spec->multiout.dig_out_nid = 0;
1151 spec->input_mux = &ad1986a_automic_capture_source;
1152 codec->patch_ops.unsol_event = ad1986a_automic_unsol_event;
1153 codec->patch_ops.init = ad1986a_automic_init;
1155 case AD1986A_SAMSUNG_P50:
1156 spec->num_mixers = 2;
1157 spec->mixers[0] = ad1986a_automute_master_mixers;
1158 spec->mixers[1] = ad1986a_laptop_eapd_mixers;
1159 spec->num_init_verbs = 4;
1160 spec->init_verbs[1] = ad1986a_eapd_init_verbs;
1161 spec->init_verbs[2] = ad1986a_automic_verbs;
1162 spec->init_verbs[3] = ad1986a_hp_init_verbs;
1163 spec->multiout.max_channels = 2;
1164 spec->multiout.num_dacs = 1;
1165 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
1166 if (!is_jack_available(codec, 0x25))
1167 spec->multiout.dig_out_nid = 0;
1168 spec->input_mux = &ad1986a_automic_capture_source;
1169 codec->patch_ops.unsol_event = ad1986a_samsung_p50_unsol_event;
1170 codec->patch_ops.init = ad1986a_samsung_p50_init;
1172 case AD1986A_LAPTOP_AUTOMUTE:
1173 spec->num_mixers = 3;
1174 spec->mixers[0] = ad1986a_automute_master_mixers;
1175 spec->mixers[1] = ad1986a_laptop_eapd_mixers;
1176 spec->mixers[2] = ad1986a_laptop_intmic_mixers;
1177 spec->num_init_verbs = 3;
1178 spec->init_verbs[1] = ad1986a_eapd_init_verbs;
1179 spec->init_verbs[2] = ad1986a_hp_init_verbs;
1180 spec->multiout.max_channels = 2;
1181 spec->multiout.num_dacs = 1;
1182 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
1183 if (!is_jack_available(codec, 0x25))
1184 spec->multiout.dig_out_nid = 0;
1185 spec->input_mux = &ad1986a_laptop_eapd_capture_source;
1186 codec->patch_ops.unsol_event = ad1986a_hp_unsol_event;
1187 codec->patch_ops.init = ad1986a_hp_init;
1188 /* Lenovo N100 seems to report the reversed bit
1189 * for HP jack-sensing
1191 spec->inv_jack_detect = 1;
1194 spec->mixers[0] = ad1986a_laptop_eapd_mixers;
1195 spec->num_init_verbs = 2;
1196 spec->init_verbs[1] = ad1986a_ultra_init;
1197 spec->multiout.max_channels = 2;
1198 spec->multiout.num_dacs = 1;
1199 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
1200 spec->multiout.dig_out_nid = 0;
1204 /* AD1986A has a hardware problem that it can't share a stream
1205 * with multiple output pins. The copy of front to surrounds
1206 * causes noisy or silent outputs at a certain timing, e.g.
1207 * changing the volume.
1208 * So, let's disable the shared stream.
1210 spec->multiout.no_share_stream = 1;
1219 #define AD1983_SPDIF_OUT 0x02
1220 #define AD1983_DAC 0x03
1221 #define AD1983_ADC 0x04
1223 static hda_nid_t ad1983_dac_nids[1] = { AD1983_DAC };
1224 static hda_nid_t ad1983_adc_nids[1] = { AD1983_ADC };
1225 static hda_nid_t ad1983_capsrc_nids[1] = { 0x15 };
1227 static struct hda_input_mux ad1983_capture_source = {
1233 { "Mix Mono", 0x3 },
1238 * SPDIF playback route
1240 static int ad1983_spdif_route_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1242 static char *texts[] = { "PCM", "ADC" };
1244 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1246 uinfo->value.enumerated.items = 2;
1247 if (uinfo->value.enumerated.item > 1)
1248 uinfo->value.enumerated.item = 1;
1249 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1253 static int ad1983_spdif_route_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1255 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1256 struct ad198x_spec *spec = codec->spec;
1258 ucontrol->value.enumerated.item[0] = spec->spdif_route;
1262 static int ad1983_spdif_route_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1264 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1265 struct ad198x_spec *spec = codec->spec;
1267 if (ucontrol->value.enumerated.item[0] > 1)
1269 if (spec->spdif_route != ucontrol->value.enumerated.item[0]) {
1270 spec->spdif_route = ucontrol->value.enumerated.item[0];
1271 snd_hda_codec_write_cache(codec, spec->multiout.dig_out_nid, 0,
1272 AC_VERB_SET_CONNECT_SEL,
1279 static struct snd_kcontrol_new ad1983_mixers[] = {
1280 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT),
1281 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT),
1282 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT),
1283 HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT),
1284 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT),
1285 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT),
1286 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
1287 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
1288 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
1289 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
1290 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1291 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1292 HDA_CODEC_VOLUME("Mic Boost", 0x0c, 0x0, HDA_OUTPUT),
1293 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1294 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
1296 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1297 .name = "Capture Source",
1298 .info = ad198x_mux_enum_info,
1299 .get = ad198x_mux_enum_get,
1300 .put = ad198x_mux_enum_put,
1303 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1304 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
1305 .info = ad1983_spdif_route_info,
1306 .get = ad1983_spdif_route_get,
1307 .put = ad1983_spdif_route_put,
1312 static struct hda_verb ad1983_init_verbs[] = {
1313 /* Front, HP, Mono; mute as default */
1314 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1315 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1316 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1317 /* Beep, PCM, Mic, Line-In: mute */
1318 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1319 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1320 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1321 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1322 /* Front, HP selectors; from Mix */
1323 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
1324 {0x06, AC_VERB_SET_CONNECT_SEL, 0x01},
1325 /* Mono selector; from Mix */
1326 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03},
1327 /* Mic selector; Mic */
1328 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0},
1329 /* Line-in selector: Line-in */
1330 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
1331 /* Mic boost: 0dB */
1332 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1333 /* Record selector: mic */
1334 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0},
1335 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1336 /* SPDIF route: PCM */
1337 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0},
1339 {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1341 {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
1343 {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1345 {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
1347 {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
1351 #ifdef CONFIG_SND_HDA_POWER_SAVE
1352 static struct hda_amp_list ad1983_loopbacks[] = {
1353 { 0x12, HDA_OUTPUT, 0 }, /* Mic */
1354 { 0x13, HDA_OUTPUT, 0 }, /* Line */
1359 static int patch_ad1983(struct hda_codec *codec)
1361 struct ad198x_spec *spec;
1364 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1370 err = snd_hda_attach_beep_device(codec, 0x10);
1375 set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
1377 spec->multiout.max_channels = 2;
1378 spec->multiout.num_dacs = ARRAY_SIZE(ad1983_dac_nids);
1379 spec->multiout.dac_nids = ad1983_dac_nids;
1380 spec->multiout.dig_out_nid = AD1983_SPDIF_OUT;
1381 spec->num_adc_nids = 1;
1382 spec->adc_nids = ad1983_adc_nids;
1383 spec->capsrc_nids = ad1983_capsrc_nids;
1384 spec->input_mux = &ad1983_capture_source;
1385 spec->num_mixers = 1;
1386 spec->mixers[0] = ad1983_mixers;
1387 spec->num_init_verbs = 1;
1388 spec->init_verbs[0] = ad1983_init_verbs;
1389 spec->spdif_route = 0;
1390 #ifdef CONFIG_SND_HDA_POWER_SAVE
1391 spec->loopback.amplist = ad1983_loopbacks;
1393 spec->vmaster_nid = 0x05;
1395 codec->patch_ops = ad198x_patch_ops;
1402 * AD1981 HD specific
1405 #define AD1981_SPDIF_OUT 0x02
1406 #define AD1981_DAC 0x03
1407 #define AD1981_ADC 0x04
1409 static hda_nid_t ad1981_dac_nids[1] = { AD1981_DAC };
1410 static hda_nid_t ad1981_adc_nids[1] = { AD1981_ADC };
1411 static hda_nid_t ad1981_capsrc_nids[1] = { 0x15 };
1413 /* 0x0c, 0x09, 0x0e, 0x0f, 0x19, 0x05, 0x18, 0x17 */
1414 static struct hda_input_mux ad1981_capture_source = {
1417 { "Front Mic", 0x0 },
1420 { "Mix Mono", 0x3 },
1427 static struct snd_kcontrol_new ad1981_mixers[] = {
1428 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT),
1429 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT),
1430 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT),
1431 HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT),
1432 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT),
1433 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT),
1434 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
1435 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
1436 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
1437 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
1438 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1439 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1440 HDA_CODEC_VOLUME("Aux Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
1441 HDA_CODEC_MUTE("Aux Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1442 HDA_CODEC_VOLUME("Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT),
1443 HDA_CODEC_MUTE("Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
1444 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1445 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1446 HDA_CODEC_VOLUME("Front Mic Boost", 0x08, 0x0, HDA_INPUT),
1447 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x0, HDA_INPUT),
1448 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1449 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
1451 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1452 .name = "Capture Source",
1453 .info = ad198x_mux_enum_info,
1454 .get = ad198x_mux_enum_get,
1455 .put = ad198x_mux_enum_put,
1457 /* identical with AD1983 */
1459 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1460 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
1461 .info = ad1983_spdif_route_info,
1462 .get = ad1983_spdif_route_get,
1463 .put = ad1983_spdif_route_put,
1468 static struct hda_verb ad1981_init_verbs[] = {
1469 /* Front, HP, Mono; mute as default */
1470 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1471 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1472 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1473 /* Beep, PCM, Front Mic, Line, Rear Mic, Aux, CD-In: mute */
1474 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1475 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1476 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1477 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1478 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1479 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1480 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1481 /* Front, HP selectors; from Mix */
1482 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
1483 {0x06, AC_VERB_SET_CONNECT_SEL, 0x01},
1484 /* Mono selector; from Mix */
1485 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03},
1486 /* Mic Mixer; select Front Mic */
1487 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1488 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1489 /* Mic boost: 0dB */
1490 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1491 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1492 /* Record selector: Front mic */
1493 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0},
1494 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1495 /* SPDIF route: PCM */
1496 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0},
1498 {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1500 {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
1502 {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1503 /* Front & Rear Mic Pins */
1504 {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
1505 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
1507 {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
1509 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
1510 /* Line-Out as Input: disabled */
1511 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1515 #ifdef CONFIG_SND_HDA_POWER_SAVE
1516 static struct hda_amp_list ad1981_loopbacks[] = {
1517 { 0x12, HDA_OUTPUT, 0 }, /* Front Mic */
1518 { 0x13, HDA_OUTPUT, 0 }, /* Line */
1519 { 0x1b, HDA_OUTPUT, 0 }, /* Aux */
1520 { 0x1c, HDA_OUTPUT, 0 }, /* Mic */
1521 { 0x1d, HDA_OUTPUT, 0 }, /* CD */
1527 * Patch for HP nx6320
1529 * nx6320 uses EAPD in the reverse way - EAPD-on means the internal
1530 * speaker output enabled _and_ mute-LED off.
1533 #define AD1981_HP_EVENT 0x37
1534 #define AD1981_MIC_EVENT 0x38
1536 static struct hda_verb ad1981_hp_init_verbs[] = {
1537 {0x05, AC_VERB_SET_EAPD_BTLENABLE, 0x00 }, /* default off */
1538 /* pin sensing on HP and Mic jacks */
1539 {0x06, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_HP_EVENT},
1540 {0x08, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_MIC_EVENT},
1544 /* turn on/off EAPD (+ mute HP) as a master switch */
1545 static int ad1981_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1546 struct snd_ctl_elem_value *ucontrol)
1548 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1549 struct ad198x_spec *spec = codec->spec;
1551 if (! ad198x_eapd_put(kcontrol, ucontrol))
1553 /* change speaker pin appropriately */
1554 snd_hda_codec_write(codec, 0x05, 0,
1555 AC_VERB_SET_PIN_WIDGET_CONTROL,
1556 spec->cur_eapd ? PIN_OUT : 0);
1557 /* toggle HP mute appropriately */
1558 snd_hda_codec_amp_stereo(codec, 0x06, HDA_OUTPUT, 0,
1560 spec->cur_eapd ? 0 : HDA_AMP_MUTE);
1564 /* bind volumes of both NID 0x05 and 0x06 */
1565 static struct hda_bind_ctls ad1981_hp_bind_master_vol = {
1566 .ops = &snd_hda_bind_vol,
1568 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
1569 HDA_COMPOSE_AMP_VAL(0x06, 3, 0, HDA_OUTPUT),
1574 /* mute internal speaker if HP is plugged */
1575 static void ad1981_hp_automute(struct hda_codec *codec)
1577 unsigned int present;
1579 present = snd_hda_jack_detect(codec, 0x06);
1580 snd_hda_codec_amp_stereo(codec, 0x05, HDA_OUTPUT, 0,
1581 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
1584 /* toggle input of built-in and mic jack appropriately */
1585 static void ad1981_hp_automic(struct hda_codec *codec)
1587 static struct hda_verb mic_jack_on[] = {
1588 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1589 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1592 static struct hda_verb mic_jack_off[] = {
1593 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1594 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1597 unsigned int present;
1599 present = snd_hda_jack_detect(codec, 0x08);
1601 snd_hda_sequence_write(codec, mic_jack_on);
1603 snd_hda_sequence_write(codec, mic_jack_off);
1606 /* unsolicited event for HP jack sensing */
1607 static void ad1981_hp_unsol_event(struct hda_codec *codec,
1612 case AD1981_HP_EVENT:
1613 ad1981_hp_automute(codec);
1615 case AD1981_MIC_EVENT:
1616 ad1981_hp_automic(codec);
1621 static struct hda_input_mux ad1981_hp_capture_source = {
1625 { "Docking-Station", 0x1 },
1630 static struct snd_kcontrol_new ad1981_hp_mixers[] = {
1631 HDA_BIND_VOL("Master Playback Volume", &ad1981_hp_bind_master_vol),
1633 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1634 .subdevice = HDA_SUBDEV_NID_FLAG | 0x05,
1635 .name = "Master Playback Switch",
1636 .info = ad198x_eapd_info,
1637 .get = ad198x_eapd_get,
1638 .put = ad1981_hp_master_sw_put,
1639 .private_value = 0x05,
1641 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
1642 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
1644 /* FIXME: analog mic/line loopback doesn't work with my tests...
1645 * (although recording is OK)
1647 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
1648 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
1649 HDA_CODEC_VOLUME("Docking-Station Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1650 HDA_CODEC_MUTE("Docking-Station Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1651 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT),
1652 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
1653 /* FIXME: does this laptop have analog CD connection? */
1654 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1655 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1657 HDA_CODEC_VOLUME("Mic Boost", 0x08, 0x0, HDA_INPUT),
1658 HDA_CODEC_VOLUME("Internal Mic Boost", 0x18, 0x0, HDA_INPUT),
1659 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1660 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
1662 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1663 .name = "Capture Source",
1664 .info = ad198x_mux_enum_info,
1665 .get = ad198x_mux_enum_get,
1666 .put = ad198x_mux_enum_put,
1671 /* initialize jack-sensing, too */
1672 static int ad1981_hp_init(struct hda_codec *codec)
1675 ad1981_hp_automute(codec);
1676 ad1981_hp_automic(codec);
1680 /* configuration for Toshiba Laptops */
1681 static struct hda_verb ad1981_toshiba_init_verbs[] = {
1682 {0x05, AC_VERB_SET_EAPD_BTLENABLE, 0x01 }, /* default on */
1683 /* pin sensing on HP and Mic jacks */
1684 {0x06, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_HP_EVENT},
1685 {0x08, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_MIC_EVENT},
1689 static struct snd_kcontrol_new ad1981_toshiba_mixers[] = {
1690 HDA_CODEC_VOLUME("Amp Volume", 0x1a, 0x0, HDA_OUTPUT),
1691 HDA_CODEC_MUTE("Amp Switch", 0x1a, 0x0, HDA_OUTPUT),
1695 /* configuration for Lenovo Thinkpad T60 */
1696 static struct snd_kcontrol_new ad1981_thinkpad_mixers[] = {
1697 HDA_CODEC_VOLUME("Master Playback Volume", 0x05, 0x0, HDA_OUTPUT),
1698 HDA_CODEC_MUTE("Master Playback Switch", 0x05, 0x0, HDA_OUTPUT),
1699 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
1700 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
1701 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
1702 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
1703 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1704 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1705 HDA_CODEC_VOLUME("Mic Boost", 0x08, 0x0, HDA_INPUT),
1706 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1707 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
1709 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1710 .name = "Capture Source",
1711 .info = ad198x_mux_enum_info,
1712 .get = ad198x_mux_enum_get,
1713 .put = ad198x_mux_enum_put,
1715 /* identical with AD1983 */
1717 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1718 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
1719 .info = ad1983_spdif_route_info,
1720 .get = ad1983_spdif_route_get,
1721 .put = ad1983_spdif_route_put,
1726 static struct hda_input_mux ad1981_thinkpad_capture_source = {
1744 static const char *ad1981_models[AD1981_MODELS] = {
1746 [AD1981_THINKPAD] = "thinkpad",
1747 [AD1981_BASIC] = "basic",
1748 [AD1981_TOSHIBA] = "toshiba"
1751 static struct snd_pci_quirk ad1981_cfg_tbl[] = {
1752 SND_PCI_QUIRK(0x1014, 0x0597, "Lenovo Z60", AD1981_THINKPAD),
1753 SND_PCI_QUIRK(0x1014, 0x05b7, "Lenovo Z60m", AD1981_THINKPAD),
1755 SND_PCI_QUIRK_VENDOR(0x103c, "HP nx", AD1981_HP),
1756 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba U205", AD1981_TOSHIBA),
1757 /* Lenovo Thinkpad T60/X60/Z6xx */
1758 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo Thinkpad", AD1981_THINKPAD),
1759 /* HP nx6320 (reversed SSID, H/W bug) */
1760 SND_PCI_QUIRK(0x30b0, 0x103c, "HP nx6320", AD1981_HP),
1764 static int patch_ad1981(struct hda_codec *codec)
1766 struct ad198x_spec *spec;
1767 int err, board_config;
1769 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1775 err = snd_hda_attach_beep_device(codec, 0x10);
1780 set_beep_amp(spec, 0x0d, 0, HDA_OUTPUT);
1782 spec->multiout.max_channels = 2;
1783 spec->multiout.num_dacs = ARRAY_SIZE(ad1981_dac_nids);
1784 spec->multiout.dac_nids = ad1981_dac_nids;
1785 spec->multiout.dig_out_nid = AD1981_SPDIF_OUT;
1786 spec->num_adc_nids = 1;
1787 spec->adc_nids = ad1981_adc_nids;
1788 spec->capsrc_nids = ad1981_capsrc_nids;
1789 spec->input_mux = &ad1981_capture_source;
1790 spec->num_mixers = 1;
1791 spec->mixers[0] = ad1981_mixers;
1792 spec->num_init_verbs = 1;
1793 spec->init_verbs[0] = ad1981_init_verbs;
1794 spec->spdif_route = 0;
1795 #ifdef CONFIG_SND_HDA_POWER_SAVE
1796 spec->loopback.amplist = ad1981_loopbacks;
1798 spec->vmaster_nid = 0x05;
1800 codec->patch_ops = ad198x_patch_ops;
1802 /* override some parameters */
1803 board_config = snd_hda_check_board_config(codec, AD1981_MODELS,
1806 switch (board_config) {
1808 spec->mixers[0] = ad1981_hp_mixers;
1809 spec->num_init_verbs = 2;
1810 spec->init_verbs[1] = ad1981_hp_init_verbs;
1811 spec->multiout.dig_out_nid = 0;
1812 spec->input_mux = &ad1981_hp_capture_source;
1814 codec->patch_ops.init = ad1981_hp_init;
1815 codec->patch_ops.unsol_event = ad1981_hp_unsol_event;
1817 case AD1981_THINKPAD:
1818 spec->mixers[0] = ad1981_thinkpad_mixers;
1819 spec->input_mux = &ad1981_thinkpad_capture_source;
1821 case AD1981_TOSHIBA:
1822 spec->mixers[0] = ad1981_hp_mixers;
1823 spec->mixers[1] = ad1981_toshiba_mixers;
1824 spec->num_init_verbs = 2;
1825 spec->init_verbs[1] = ad1981_toshiba_init_verbs;
1826 spec->multiout.dig_out_nid = 0;
1827 spec->input_mux = &ad1981_hp_capture_source;
1828 codec->patch_ops.init = ad1981_hp_init;
1829 codec->patch_ops.unsol_event = ad1981_hp_unsol_event;
1839 * Output pins and routes
1841 * Pin Mix Sel DAC (*)
1842 * port-A 0x11 (mute/hp) <- 0x22 <- 0x37 <- 03/04/06
1843 * port-B 0x14 (mute/hp) <- 0x2b <- 0x30 <- 03/04/06
1844 * port-C 0x15 (mute) <- 0x2c <- 0x31 <- 05/0a
1845 * port-D 0x12 (mute/hp) <- 0x29 <- 04
1846 * port-E 0x17 (mute/hp) <- 0x26 <- 0x32 <- 05/0a
1847 * port-F 0x16 (mute) <- 0x2a <- 06
1848 * port-G 0x24 (mute) <- 0x27 <- 05
1849 * port-H 0x25 (mute) <- 0x28 <- 0a
1850 * mono 0x13 (mute/amp)<- 0x1e <- 0x36 <- 03/04/06
1852 * DAC0 = 03h, DAC1 = 04h, DAC2 = 05h, DAC3 = 06h, DAC4 = 0ah
1853 * (*) DAC2/3/4 are swapped to DAC3/4/2 on AD198A rev.2 due to a h/w bug.
1855 * Input pins and routes
1857 * pin boost mix input # / adc input #
1858 * port-A 0x11 -> 0x38 -> mix 2, ADC 0
1859 * port-B 0x14 -> 0x39 -> mix 0, ADC 1
1860 * port-C 0x15 -> 0x3a -> 33:0 - mix 1, ADC 2
1861 * port-D 0x12 -> 0x3d -> mix 3, ADC 8
1862 * port-E 0x17 -> 0x3c -> 34:0 - mix 4, ADC 4
1863 * port-F 0x16 -> 0x3b -> mix 5, ADC 3
1864 * port-G 0x24 -> N/A -> 33:1 - mix 1, 34:1 - mix 4, ADC 6
1865 * port-H 0x25 -> N/A -> 33:2 - mix 1, 34:2 - mix 4, ADC 7
1869 * 6stack - front/surr/CLFE/side/opt DACs - 04/06/05/0a/03
1870 * 3stack - front/surr/CLFE/opt DACs - 04/05/0a/03
1872 * Inputs of Analog Mix (0x20)
1873 * 0:Port-B (front mic)
1874 * 1:Port-C/G/H (line-in)
1876 * 3:Port-D (line-in/2)
1877 * 4:Port-E/G/H (mic-in)
1878 * 5:Port-F (mic2-in)
1884 * 1:Port-B (front mic-in)
1885 * 2:Port-C (line-in)
1886 * 3:Port-F (mic2-in)
1891 * 8:Port-D (line-in/2)
1894 * Proposed pin assignments by the datasheet
1897 * Port-A front headphone
1907 * Port-A front headphone
1909 * C rear line-in/surround
1911 * E rear mic-in/CLFE
1917 * D internal speaker (with EAPD)
1918 * E/F quad mic array
1934 /* reivision id to check workarounds */
1935 #define AD1988A_REV2 0x100200
1937 #define is_rev2(codec) \
1938 ((codec)->vendor_id == 0x11d41988 && \
1939 (codec)->revision_id == AD1988A_REV2)
1945 static hda_nid_t ad1988_6stack_dac_nids[4] = {
1946 0x04, 0x06, 0x05, 0x0a
1949 static hda_nid_t ad1988_3stack_dac_nids[3] = {
1953 /* for AD1988A revision-2, DAC2-4 are swapped */
1954 static hda_nid_t ad1988_6stack_dac_nids_rev2[4] = {
1955 0x04, 0x05, 0x0a, 0x06
1958 static hda_nid_t ad1988_3stack_dac_nids_rev2[3] = {
1962 static hda_nid_t ad1988_adc_nids[3] = {
1966 static hda_nid_t ad1988_capsrc_nids[3] = {
1970 #define AD1988_SPDIF_OUT 0x02
1971 #define AD1988_SPDIF_OUT_HDMI 0x0b
1972 #define AD1988_SPDIF_IN 0x07
1974 static hda_nid_t ad1989b_slave_dig_outs[] = {
1975 AD1988_SPDIF_OUT, AD1988_SPDIF_OUT_HDMI, 0
1978 static struct hda_input_mux ad1988_6stack_capture_source = {
1981 { "Front Mic", 0x1 }, /* port-B */
1982 { "Line", 0x2 }, /* port-C */
1983 { "Mic", 0x4 }, /* port-E */
1989 static struct hda_input_mux ad1988_laptop_capture_source = {
1992 { "Mic/Line", 0x1 }, /* port-B */
2000 static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol,
2001 struct snd_ctl_elem_info *uinfo)
2003 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2004 struct ad198x_spec *spec = codec->spec;
2005 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
2006 spec->num_channel_mode);
2009 static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol,
2010 struct snd_ctl_elem_value *ucontrol)
2012 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2013 struct ad198x_spec *spec = codec->spec;
2014 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
2015 spec->num_channel_mode, spec->multiout.max_channels);
2018 static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol,
2019 struct snd_ctl_elem_value *ucontrol)
2021 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2022 struct ad198x_spec *spec = codec->spec;
2023 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
2024 spec->num_channel_mode,
2025 &spec->multiout.max_channels);
2026 if (err >= 0 && spec->need_dac_fix)
2027 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
2032 static struct snd_kcontrol_new ad1988_6stack_mixers1[] = {
2033 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
2034 HDA_CODEC_VOLUME("Surround Playback Volume", 0x06, 0x0, HDA_OUTPUT),
2035 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT),
2036 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT),
2037 HDA_CODEC_VOLUME("Side Playback Volume", 0x0a, 0x0, HDA_OUTPUT),
2041 static struct snd_kcontrol_new ad1988_6stack_mixers1_rev2[] = {
2042 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
2043 HDA_CODEC_VOLUME("Surround Playback Volume", 0x05, 0x0, HDA_OUTPUT),
2044 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2045 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0a, 2, 0x0, HDA_OUTPUT),
2046 HDA_CODEC_VOLUME("Side Playback Volume", 0x06, 0x0, HDA_OUTPUT),
2050 static struct snd_kcontrol_new ad1988_6stack_mixers2[] = {
2051 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT),
2052 HDA_BIND_MUTE("Surround Playback Switch", 0x2a, 2, HDA_INPUT),
2053 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x27, 1, 2, HDA_INPUT),
2054 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x27, 2, 2, HDA_INPUT),
2055 HDA_BIND_MUTE("Side Playback Switch", 0x28, 2, HDA_INPUT),
2056 HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT),
2057 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT),
2059 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT),
2060 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT),
2061 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT),
2062 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT),
2063 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
2064 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
2065 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT),
2066 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT),
2068 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
2069 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
2071 HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT),
2072 HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT),
2078 static struct snd_kcontrol_new ad1988_3stack_mixers1[] = {
2079 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
2080 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT),
2081 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT),
2082 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT),
2086 static struct snd_kcontrol_new ad1988_3stack_mixers1_rev2[] = {
2087 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
2088 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT),
2089 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x06, 1, 0x0, HDA_OUTPUT),
2090 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x06, 2, 0x0, HDA_OUTPUT),
2094 static struct snd_kcontrol_new ad1988_3stack_mixers2[] = {
2095 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT),
2096 HDA_BIND_MUTE("Surround Playback Switch", 0x2c, 2, HDA_INPUT),
2097 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x26, 1, 2, HDA_INPUT),
2098 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x26, 2, 2, HDA_INPUT),
2099 HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT),
2100 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT),
2102 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT),
2103 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT),
2104 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT),
2105 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT),
2106 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
2107 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
2108 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT),
2109 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT),
2111 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
2112 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
2114 HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT),
2115 HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT),
2117 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2118 .name = "Channel Mode",
2119 .info = ad198x_ch_mode_info,
2120 .get = ad198x_ch_mode_get,
2121 .put = ad198x_ch_mode_put,
2128 static struct snd_kcontrol_new ad1988_laptop_mixers[] = {
2129 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
2130 HDA_CODEC_MUTE("PCM Playback Switch", 0x29, 0x0, HDA_INPUT),
2131 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT),
2133 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT),
2134 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT),
2135 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x0, HDA_INPUT),
2136 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x0, HDA_INPUT),
2137 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
2138 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
2140 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
2141 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
2143 HDA_CODEC_VOLUME("Mic Boost", 0x39, 0x0, HDA_OUTPUT),
2146 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2147 .name = "External Amplifier",
2148 .subdevice = HDA_SUBDEV_NID_FLAG | 0x12,
2149 .info = ad198x_eapd_info,
2150 .get = ad198x_eapd_get,
2151 .put = ad198x_eapd_put,
2152 .private_value = 0x12, /* port-D */
2159 static struct snd_kcontrol_new ad1988_capture_mixers[] = {
2160 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
2161 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
2162 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
2163 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
2164 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x0e, 0x0, HDA_OUTPUT),
2165 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x0e, 0x0, HDA_OUTPUT),
2167 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2168 /* The multiple "Capture Source" controls confuse alsamixer
2169 * So call somewhat different..
2171 /* .name = "Capture Source", */
2172 .name = "Input Source",
2174 .info = ad198x_mux_enum_info,
2175 .get = ad198x_mux_enum_get,
2176 .put = ad198x_mux_enum_put,
2181 static int ad1988_spdif_playback_source_info(struct snd_kcontrol *kcontrol,
2182 struct snd_ctl_elem_info *uinfo)
2184 static char *texts[] = {
2185 "PCM", "ADC1", "ADC2", "ADC3"
2187 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2189 uinfo->value.enumerated.items = 4;
2190 if (uinfo->value.enumerated.item >= 4)
2191 uinfo->value.enumerated.item = 3;
2192 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2196 static int ad1988_spdif_playback_source_get(struct snd_kcontrol *kcontrol,
2197 struct snd_ctl_elem_value *ucontrol)
2199 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2202 sel = snd_hda_codec_read(codec, 0x1d, 0, AC_VERB_GET_AMP_GAIN_MUTE,
2205 ucontrol->value.enumerated.item[0] = 0;
2207 sel = snd_hda_codec_read(codec, 0x0b, 0,
2208 AC_VERB_GET_CONNECT_SEL, 0);
2213 ucontrol->value.enumerated.item[0] = sel;
2218 static int ad1988_spdif_playback_source_put(struct snd_kcontrol *kcontrol,
2219 struct snd_ctl_elem_value *ucontrol)
2221 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2222 unsigned int val, sel;
2225 val = ucontrol->value.enumerated.item[0];
2229 sel = snd_hda_codec_read(codec, 0x1d, 0,
2230 AC_VERB_GET_AMP_GAIN_MUTE,
2232 change = sel & 0x80;
2234 snd_hda_codec_write_cache(codec, 0x1d, 0,
2235 AC_VERB_SET_AMP_GAIN_MUTE,
2237 snd_hda_codec_write_cache(codec, 0x1d, 0,
2238 AC_VERB_SET_AMP_GAIN_MUTE,
2242 sel = snd_hda_codec_read(codec, 0x1d, 0,
2243 AC_VERB_GET_AMP_GAIN_MUTE,
2244 AC_AMP_GET_INPUT | 0x01);
2245 change = sel & 0x80;
2247 snd_hda_codec_write_cache(codec, 0x1d, 0,
2248 AC_VERB_SET_AMP_GAIN_MUTE,
2250 snd_hda_codec_write_cache(codec, 0x1d, 0,
2251 AC_VERB_SET_AMP_GAIN_MUTE,
2254 sel = snd_hda_codec_read(codec, 0x0b, 0,
2255 AC_VERB_GET_CONNECT_SEL, 0) + 1;
2256 change |= sel != val;
2258 snd_hda_codec_write_cache(codec, 0x0b, 0,
2259 AC_VERB_SET_CONNECT_SEL,
2265 static struct snd_kcontrol_new ad1988_spdif_out_mixers[] = {
2266 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
2268 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2269 .name = "IEC958 Playback Source",
2270 .subdevice = HDA_SUBDEV_NID_FLAG | 0x1b,
2271 .info = ad1988_spdif_playback_source_info,
2272 .get = ad1988_spdif_playback_source_get,
2273 .put = ad1988_spdif_playback_source_put,
2278 static struct snd_kcontrol_new ad1988_spdif_in_mixers[] = {
2279 HDA_CODEC_VOLUME("IEC958 Capture Volume", 0x1c, 0x0, HDA_INPUT),
2283 static struct snd_kcontrol_new ad1989_spdif_out_mixers[] = {
2284 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
2285 HDA_CODEC_VOLUME("HDMI Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
2290 * initialization verbs
2294 * for 6-stack (+dig)
2296 static struct hda_verb ad1988_6stack_init_verbs[] = {
2297 /* Front, Surround, CLFE, side DAC; unmute as default */
2298 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2299 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2300 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2301 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2302 /* Port-A front headphon path */
2303 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */
2304 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2305 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2306 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2307 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2308 /* Port-D line-out path */
2309 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2310 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2311 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2312 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2313 /* Port-F surround path */
2314 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2315 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2316 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2317 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2318 /* Port-G CLFE path */
2319 {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2320 {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2321 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2322 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2323 /* Port-H side path */
2324 {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2325 {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2326 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2327 {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2329 {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */
2330 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2331 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2332 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2333 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */
2334 /* Port-B front mic-in path */
2335 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2336 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2337 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2338 /* Port-C line-in path */
2339 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2340 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2341 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2342 {0x33, AC_VERB_SET_CONNECT_SEL, 0x0},
2343 /* Port-E mic-in path */
2344 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2345 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2346 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2347 {0x34, AC_VERB_SET_CONNECT_SEL, 0x0},
2348 /* Analog CD Input */
2349 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2350 /* Analog Mix output amp */
2351 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
2356 static struct hda_verb ad1988_capture_init_verbs[] = {
2357 /* mute analog mix */
2358 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2359 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2360 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2361 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2362 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2363 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
2364 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2365 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2366 /* select ADCs - front-mic */
2367 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
2368 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
2369 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
2374 static struct hda_verb ad1988_spdif_init_verbs[] = {
2376 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */
2377 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x0}, /* ADC1 */
2378 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2379 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2381 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
2386 /* AD1989 has no ADC -> SPDIF route */
2387 static struct hda_verb ad1989_spdif_init_verbs[] = {
2388 /* SPDIF-1 out pin */
2389 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2390 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
2391 /* SPDIF-2/HDMI out pin */
2392 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2393 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
2398 * verbs for 3stack (+dig)
2400 static struct hda_verb ad1988_3stack_ch2_init[] = {
2401 /* set port-C to line-in */
2402 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2403 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2404 /* set port-E to mic-in */
2405 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2406 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2410 static struct hda_verb ad1988_3stack_ch6_init[] = {
2411 /* set port-C to surround out */
2412 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2413 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2414 /* set port-E to CLFE out */
2415 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2416 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2420 static struct hda_channel_mode ad1988_3stack_modes[2] = {
2421 { 2, ad1988_3stack_ch2_init },
2422 { 6, ad1988_3stack_ch6_init },
2425 static struct hda_verb ad1988_3stack_init_verbs[] = {
2426 /* Front, Surround, CLFE, side DAC; unmute as default */
2427 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2428 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2429 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2430 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2431 /* Port-A front headphon path */
2432 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */
2433 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2434 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2435 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2436 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2437 /* Port-D line-out path */
2438 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2439 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2440 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2441 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2443 {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */
2444 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2445 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2446 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2447 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */
2448 /* Port-B front mic-in path */
2449 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2450 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2451 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2452 /* Port-C line-in/surround path - 6ch mode as default */
2453 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2454 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2455 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2456 {0x31, AC_VERB_SET_CONNECT_SEL, 0x0}, /* output sel: DAC 0x05 */
2457 {0x33, AC_VERB_SET_CONNECT_SEL, 0x0},
2458 /* Port-E mic-in/CLFE path - 6ch mode as default */
2459 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2460 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2461 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2462 {0x32, AC_VERB_SET_CONNECT_SEL, 0x1}, /* output sel: DAC 0x0a */
2463 {0x34, AC_VERB_SET_CONNECT_SEL, 0x0},
2464 /* mute analog mix */
2465 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2466 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2467 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2468 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2469 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2470 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
2471 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2472 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2473 /* select ADCs - front-mic */
2474 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
2475 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
2476 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
2477 /* Analog Mix output amp */
2478 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
2483 * verbs for laptop mode (+dig)
2485 static struct hda_verb ad1988_laptop_hp_on[] = {
2486 /* unmute port-A and mute port-D */
2487 { 0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2488 { 0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2491 static struct hda_verb ad1988_laptop_hp_off[] = {
2492 /* mute port-A and unmute port-D */
2493 { 0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2494 { 0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2498 #define AD1988_HP_EVENT 0x01
2500 static struct hda_verb ad1988_laptop_init_verbs[] = {
2501 /* Front, Surround, CLFE, side DAC; unmute as default */
2502 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2503 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2504 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2505 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2506 /* Port-A front headphon path */
2507 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */
2508 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2509 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2510 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2511 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2512 /* unsolicited event for pin-sense */
2513 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1988_HP_EVENT },
2514 /* Port-D line-out path + EAPD */
2515 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2516 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2517 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2518 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2519 {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x00}, /* EAPD-off */
2521 {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */
2522 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2523 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2524 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2525 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */
2526 /* Port-B mic-in path */
2527 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2528 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2529 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2530 /* Port-C docking station - try to output */
2531 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2532 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2533 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2534 {0x33, AC_VERB_SET_CONNECT_SEL, 0x0},
2535 /* mute analog mix */
2536 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2537 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2538 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2539 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2540 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2541 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
2542 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2543 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2544 /* select ADCs - mic */
2545 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
2546 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
2547 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
2548 /* Analog Mix output amp */
2549 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
2553 static void ad1988_laptop_unsol_event(struct hda_codec *codec, unsigned int res)
2555 if ((res >> 26) != AD1988_HP_EVENT)
2557 if (snd_hda_jack_detect(codec, 0x11))
2558 snd_hda_sequence_write(codec, ad1988_laptop_hp_on);
2560 snd_hda_sequence_write(codec, ad1988_laptop_hp_off);
2563 #ifdef CONFIG_SND_HDA_POWER_SAVE
2564 static struct hda_amp_list ad1988_loopbacks[] = {
2565 { 0x20, HDA_INPUT, 0 }, /* Front Mic */
2566 { 0x20, HDA_INPUT, 1 }, /* Line */
2567 { 0x20, HDA_INPUT, 4 }, /* Mic */
2568 { 0x20, HDA_INPUT, 6 }, /* CD */
2574 * Automatic parse of I/O pins from the BIOS configuration
2582 static struct snd_kcontrol_new ad1988_control_templates[] = {
2583 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2584 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2585 HDA_BIND_MUTE(NULL, 0, 0, 0),
2588 /* add dynamic controls */
2589 static int add_control(struct ad198x_spec *spec, int type, const char *name,
2592 struct snd_kcontrol_new *knew;
2594 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2595 knew = snd_array_new(&spec->kctls);
2598 *knew = ad1988_control_templates[type];
2599 knew->name = kstrdup(name, GFP_KERNEL);
2602 if (get_amp_nid_(val))
2603 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
2604 knew->private_value = val;
2608 #define AD1988_PIN_CD_NID 0x18
2609 #define AD1988_PIN_BEEP_NID 0x10
2611 static hda_nid_t ad1988_mixer_nids[8] = {
2612 /* A B C D E F G H */
2613 0x22, 0x2b, 0x2c, 0x29, 0x26, 0x2a, 0x27, 0x28
2616 static inline hda_nid_t ad1988_idx_to_dac(struct hda_codec *codec, int idx)
2618 static hda_nid_t idx_to_dac[8] = {
2619 /* A B C D E F G H */
2620 0x04, 0x06, 0x05, 0x04, 0x0a, 0x06, 0x05, 0x0a
2622 static hda_nid_t idx_to_dac_rev2[8] = {
2623 /* A B C D E F G H */
2624 0x04, 0x05, 0x0a, 0x04, 0x06, 0x05, 0x0a, 0x06
2627 return idx_to_dac_rev2[idx];
2629 return idx_to_dac[idx];
2632 static hda_nid_t ad1988_boost_nids[8] = {
2633 0x38, 0x39, 0x3a, 0x3d, 0x3c, 0x3b, 0, 0
2636 static int ad1988_pin_idx(hda_nid_t nid)
2638 static hda_nid_t ad1988_io_pins[8] = {
2639 0x11, 0x14, 0x15, 0x12, 0x17, 0x16, 0x24, 0x25
2642 for (i = 0; i < ARRAY_SIZE(ad1988_io_pins); i++)
2643 if (ad1988_io_pins[i] == nid)
2645 return 0; /* should be -1 */
2648 static int ad1988_pin_to_loopback_idx(hda_nid_t nid)
2650 static int loopback_idx[8] = {
2651 2, 0, 1, 3, 4, 5, 1, 4
2654 case AD1988_PIN_CD_NID:
2657 return loopback_idx[ad1988_pin_idx(nid)];
2661 static int ad1988_pin_to_adc_idx(hda_nid_t nid)
2663 static int adc_idx[8] = {
2664 0, 1, 2, 8, 4, 3, 6, 7
2667 case AD1988_PIN_CD_NID:
2670 return adc_idx[ad1988_pin_idx(nid)];
2674 /* fill in the dac_nids table from the parsed pin configuration */
2675 static int ad1988_auto_fill_dac_nids(struct hda_codec *codec,
2676 const struct auto_pin_cfg *cfg)
2678 struct ad198x_spec *spec = codec->spec;
2681 spec->multiout.dac_nids = spec->private_dac_nids;
2683 /* check the pins hardwired to audio widget */
2684 for (i = 0; i < cfg->line_outs; i++) {
2685 idx = ad1988_pin_idx(cfg->line_out_pins[i]);
2686 spec->multiout.dac_nids[i] = ad1988_idx_to_dac(codec, idx);
2688 spec->multiout.num_dacs = cfg->line_outs;
2692 /* add playback controls from the parsed DAC table */
2693 static int ad1988_auto_create_multi_out_ctls(struct ad198x_spec *spec,
2694 const struct auto_pin_cfg *cfg)
2697 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
2701 for (i = 0; i < cfg->line_outs; i++) {
2702 hda_nid_t dac = spec->multiout.dac_nids[i];
2705 nid = ad1988_mixer_nids[ad1988_pin_idx(cfg->line_out_pins[i])];
2708 err = add_control(spec, AD_CTL_WIDGET_VOL,
2709 "Center Playback Volume",
2710 HDA_COMPOSE_AMP_VAL(dac, 1, 0, HDA_OUTPUT));
2713 err = add_control(spec, AD_CTL_WIDGET_VOL,
2714 "LFE Playback Volume",
2715 HDA_COMPOSE_AMP_VAL(dac, 2, 0, HDA_OUTPUT));
2718 err = add_control(spec, AD_CTL_BIND_MUTE,
2719 "Center Playback Switch",
2720 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT));
2723 err = add_control(spec, AD_CTL_BIND_MUTE,
2724 "LFE Playback Switch",
2725 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT));
2729 sprintf(name, "%s Playback Volume", chname[i]);
2730 err = add_control(spec, AD_CTL_WIDGET_VOL, name,
2731 HDA_COMPOSE_AMP_VAL(dac, 3, 0, HDA_OUTPUT));
2734 sprintf(name, "%s Playback Switch", chname[i]);
2735 err = add_control(spec, AD_CTL_BIND_MUTE, name,
2736 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
2744 /* add playback controls for speaker and HP outputs */
2745 static int ad1988_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
2748 struct ad198x_spec *spec = codec->spec;
2756 idx = ad1988_pin_idx(pin);
2757 nid = ad1988_idx_to_dac(codec, idx);
2758 /* check whether the corresponding DAC was already taken */
2759 for (i = 0; i < spec->autocfg.line_outs; i++) {
2760 hda_nid_t pin = spec->autocfg.line_out_pins[i];
2761 hda_nid_t dac = ad1988_idx_to_dac(codec, ad1988_pin_idx(pin));
2765 if (i >= spec->autocfg.line_outs) {
2766 /* specify the DAC as the extra output */
2767 if (!spec->multiout.hp_nid)
2768 spec->multiout.hp_nid = nid;
2770 spec->multiout.extra_out_nid[0] = nid;
2771 /* control HP volume/switch on the output mixer amp */
2772 sprintf(name, "%s Playback Volume", pfx);
2773 err = add_control(spec, AD_CTL_WIDGET_VOL, name,
2774 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
2778 nid = ad1988_mixer_nids[idx];
2779 sprintf(name, "%s Playback Switch", pfx);
2780 if ((err = add_control(spec, AD_CTL_BIND_MUTE, name,
2781 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2786 /* create input playback/capture controls for the given pin */
2787 static int new_analog_input(struct ad198x_spec *spec, hda_nid_t pin,
2788 const char *ctlname, int boost)
2793 sprintf(name, "%s Playback Volume", ctlname);
2794 idx = ad1988_pin_to_loopback_idx(pin);
2795 if ((err = add_control(spec, AD_CTL_WIDGET_VOL, name,
2796 HDA_COMPOSE_AMP_VAL(0x20, 3, idx, HDA_INPUT))) < 0)
2798 sprintf(name, "%s Playback Switch", ctlname);
2799 if ((err = add_control(spec, AD_CTL_WIDGET_MUTE, name,
2800 HDA_COMPOSE_AMP_VAL(0x20, 3, idx, HDA_INPUT))) < 0)
2804 idx = ad1988_pin_idx(pin);
2805 bnid = ad1988_boost_nids[idx];
2807 sprintf(name, "%s Boost", ctlname);
2808 return add_control(spec, AD_CTL_WIDGET_VOL, name,
2809 HDA_COMPOSE_AMP_VAL(bnid, 3, idx, HDA_OUTPUT));
2816 /* create playback/capture controls for input pins */
2817 static int ad1988_auto_create_analog_input_ctls(struct ad198x_spec *spec,
2818 const struct auto_pin_cfg *cfg)
2820 struct hda_input_mux *imux = &spec->private_imux;
2823 for (i = 0; i < AUTO_PIN_LAST; i++) {
2824 err = new_analog_input(spec, cfg->input_pins[i],
2825 auto_pin_cfg_labels[i],
2826 i <= AUTO_PIN_FRONT_MIC);
2829 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2830 imux->items[imux->num_items].index = ad1988_pin_to_adc_idx(cfg->input_pins[i]);
2833 imux->items[imux->num_items].label = "Mix";
2834 imux->items[imux->num_items].index = 9;
2837 if ((err = add_control(spec, AD_CTL_WIDGET_VOL,
2838 "Analog Mix Playback Volume",
2839 HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT))) < 0)
2841 if ((err = add_control(spec, AD_CTL_WIDGET_MUTE,
2842 "Analog Mix Playback Switch",
2843 HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT))) < 0)
2849 static void ad1988_auto_set_output_and_unmute(struct hda_codec *codec,
2850 hda_nid_t nid, int pin_type,
2854 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2855 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2857 case 0x11: /* port-A - DAC 04 */
2858 snd_hda_codec_write(codec, 0x37, 0, AC_VERB_SET_CONNECT_SEL, 0x01);
2860 case 0x14: /* port-B - DAC 06 */
2861 snd_hda_codec_write(codec, 0x30, 0, AC_VERB_SET_CONNECT_SEL, 0x02);
2863 case 0x15: /* port-C - DAC 05 */
2864 snd_hda_codec_write(codec, 0x31, 0, AC_VERB_SET_CONNECT_SEL, 0x00);
2866 case 0x17: /* port-E - DAC 0a */
2867 snd_hda_codec_write(codec, 0x32, 0, AC_VERB_SET_CONNECT_SEL, 0x01);
2869 case 0x13: /* mono - DAC 04 */
2870 snd_hda_codec_write(codec, 0x36, 0, AC_VERB_SET_CONNECT_SEL, 0x01);
2875 static void ad1988_auto_init_multi_out(struct hda_codec *codec)
2877 struct ad198x_spec *spec = codec->spec;
2880 for (i = 0; i < spec->autocfg.line_outs; i++) {
2881 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2882 ad1988_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2886 static void ad1988_auto_init_extra_out(struct hda_codec *codec)
2888 struct ad198x_spec *spec = codec->spec;
2891 pin = spec->autocfg.speaker_pins[0];
2892 if (pin) /* connect to front */
2893 ad1988_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
2894 pin = spec->autocfg.hp_pins[0];
2895 if (pin) /* connect to front */
2896 ad1988_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2899 static void ad1988_auto_init_analog_input(struct hda_codec *codec)
2901 struct ad198x_spec *spec = codec->spec;
2904 for (i = 0; i < AUTO_PIN_LAST; i++) {
2905 hda_nid_t nid = spec->autocfg.input_pins[i];
2909 case 0x15: /* port-C */
2910 snd_hda_codec_write(codec, 0x33, 0, AC_VERB_SET_CONNECT_SEL, 0x0);
2912 case 0x17: /* port-E */
2913 snd_hda_codec_write(codec, 0x34, 0, AC_VERB_SET_CONNECT_SEL, 0x0);
2916 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2917 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2918 if (nid != AD1988_PIN_CD_NID)
2919 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2921 idx = ad1988_pin_idx(nid);
2922 if (ad1988_boost_nids[idx])
2923 snd_hda_codec_write(codec, ad1988_boost_nids[idx], 0,
2924 AC_VERB_SET_AMP_GAIN_MUTE,
2929 /* parse the BIOS configuration and set up the alc_spec */
2930 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2931 static int ad1988_parse_auto_config(struct hda_codec *codec)
2933 struct ad198x_spec *spec = codec->spec;
2936 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
2938 if ((err = ad1988_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
2940 if (! spec->autocfg.line_outs)
2941 return 0; /* can't find valid BIOS pin config */
2942 if ((err = ad1988_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
2943 (err = ad1988_auto_create_extra_out(codec,
2944 spec->autocfg.speaker_pins[0],
2946 (err = ad1988_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
2947 "Headphone")) < 0 ||
2948 (err = ad1988_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2951 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2953 if (spec->autocfg.dig_outs)
2954 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
2955 if (spec->autocfg.dig_in_pin)
2956 spec->dig_in_nid = AD1988_SPDIF_IN;
2958 if (spec->kctls.list)
2959 spec->mixers[spec->num_mixers++] = spec->kctls.list;
2961 spec->init_verbs[spec->num_init_verbs++] = ad1988_6stack_init_verbs;
2963 spec->input_mux = &spec->private_imux;
2968 /* init callback for auto-configuration model -- overriding the default init */
2969 static int ad1988_auto_init(struct hda_codec *codec)
2972 ad1988_auto_init_multi_out(codec);
2973 ad1988_auto_init_extra_out(codec);
2974 ad1988_auto_init_analog_input(codec);
2982 static const char *ad1988_models[AD1988_MODEL_LAST] = {
2983 [AD1988_6STACK] = "6stack",
2984 [AD1988_6STACK_DIG] = "6stack-dig",
2985 [AD1988_3STACK] = "3stack",
2986 [AD1988_3STACK_DIG] = "3stack-dig",
2987 [AD1988_LAPTOP] = "laptop",
2988 [AD1988_LAPTOP_DIG] = "laptop-dig",
2989 [AD1988_AUTO] = "auto",
2992 static struct snd_pci_quirk ad1988_cfg_tbl[] = {
2993 SND_PCI_QUIRK(0x1043, 0x81ec, "Asus P5B-DLX", AD1988_6STACK_DIG),
2994 SND_PCI_QUIRK(0x1043, 0x81f6, "Asus M2N-SLI", AD1988_6STACK_DIG),
2995 SND_PCI_QUIRK(0x1043, 0x8277, "Asus P5K-E/WIFI-AP", AD1988_6STACK_DIG),
2996 SND_PCI_QUIRK(0x1043, 0x8311, "Asus P5Q-Premium/Pro", AD1988_6STACK_DIG),
3000 static int patch_ad1988(struct hda_codec *codec)
3002 struct ad198x_spec *spec;
3003 int err, board_config;
3005 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3012 snd_printk(KERN_INFO "patch_analog: AD1988A rev.2 is detected, enable workarounds\n");
3014 board_config = snd_hda_check_board_config(codec, AD1988_MODEL_LAST,
3015 ad1988_models, ad1988_cfg_tbl);
3016 if (board_config < 0) {
3017 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
3019 board_config = AD1988_AUTO;
3022 if (board_config == AD1988_AUTO) {
3023 /* automatic parse from the BIOS config */
3024 err = ad1988_parse_auto_config(codec);
3029 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 6-stack mode...\n");
3030 board_config = AD1988_6STACK;
3034 err = snd_hda_attach_beep_device(codec, 0x10);
3039 set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
3041 switch (board_config) {
3043 case AD1988_6STACK_DIG:
3044 spec->multiout.max_channels = 8;
3045 spec->multiout.num_dacs = 4;
3047 spec->multiout.dac_nids = ad1988_6stack_dac_nids_rev2;
3049 spec->multiout.dac_nids = ad1988_6stack_dac_nids;
3050 spec->input_mux = &ad1988_6stack_capture_source;
3051 spec->num_mixers = 2;
3053 spec->mixers[0] = ad1988_6stack_mixers1_rev2;
3055 spec->mixers[0] = ad1988_6stack_mixers1;
3056 spec->mixers[1] = ad1988_6stack_mixers2;
3057 spec->num_init_verbs = 1;
3058 spec->init_verbs[0] = ad1988_6stack_init_verbs;
3059 if (board_config == AD1988_6STACK_DIG) {
3060 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
3061 spec->dig_in_nid = AD1988_SPDIF_IN;
3065 case AD1988_3STACK_DIG:
3066 spec->multiout.max_channels = 6;
3067 spec->multiout.num_dacs = 3;
3069 spec->multiout.dac_nids = ad1988_3stack_dac_nids_rev2;
3071 spec->multiout.dac_nids = ad1988_3stack_dac_nids;
3072 spec->input_mux = &ad1988_6stack_capture_source;
3073 spec->channel_mode = ad1988_3stack_modes;
3074 spec->num_channel_mode = ARRAY_SIZE(ad1988_3stack_modes);
3075 spec->num_mixers = 2;
3077 spec->mixers[0] = ad1988_3stack_mixers1_rev2;
3079 spec->mixers[0] = ad1988_3stack_mixers1;
3080 spec->mixers[1] = ad1988_3stack_mixers2;
3081 spec->num_init_verbs = 1;
3082 spec->init_verbs[0] = ad1988_3stack_init_verbs;
3083 if (board_config == AD1988_3STACK_DIG)
3084 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
3087 case AD1988_LAPTOP_DIG:
3088 spec->multiout.max_channels = 2;
3089 spec->multiout.num_dacs = 1;
3090 spec->multiout.dac_nids = ad1988_3stack_dac_nids;
3091 spec->input_mux = &ad1988_laptop_capture_source;
3092 spec->num_mixers = 1;
3093 spec->mixers[0] = ad1988_laptop_mixers;
3094 spec->inv_eapd = 1; /* inverted EAPD */
3095 spec->num_init_verbs = 1;
3096 spec->init_verbs[0] = ad1988_laptop_init_verbs;
3097 if (board_config == AD1988_LAPTOP_DIG)
3098 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
3102 spec->num_adc_nids = ARRAY_SIZE(ad1988_adc_nids);
3103 spec->adc_nids = ad1988_adc_nids;
3104 spec->capsrc_nids = ad1988_capsrc_nids;
3105 spec->mixers[spec->num_mixers++] = ad1988_capture_mixers;
3106 spec->init_verbs[spec->num_init_verbs++] = ad1988_capture_init_verbs;
3107 if (spec->multiout.dig_out_nid) {
3108 if (codec->vendor_id >= 0x11d4989a) {
3109 spec->mixers[spec->num_mixers++] =
3110 ad1989_spdif_out_mixers;
3111 spec->init_verbs[spec->num_init_verbs++] =
3112 ad1989_spdif_init_verbs;
3113 codec->slave_dig_outs = ad1989b_slave_dig_outs;
3115 spec->mixers[spec->num_mixers++] =
3116 ad1988_spdif_out_mixers;
3117 spec->init_verbs[spec->num_init_verbs++] =
3118 ad1988_spdif_init_verbs;
3121 if (spec->dig_in_nid && codec->vendor_id < 0x11d4989a)
3122 spec->mixers[spec->num_mixers++] = ad1988_spdif_in_mixers;
3124 codec->patch_ops = ad198x_patch_ops;
3125 switch (board_config) {
3127 codec->patch_ops.init = ad1988_auto_init;
3130 case AD1988_LAPTOP_DIG:
3131 codec->patch_ops.unsol_event = ad1988_laptop_unsol_event;
3134 #ifdef CONFIG_SND_HDA_POWER_SAVE
3135 spec->loopback.amplist = ad1988_loopbacks;
3137 spec->vmaster_nid = 0x04;
3146 * port-B - front line/mic-in
3147 * port-E - aux in/out
3148 * port-F - aux in/out
3149 * port-C - rear line/mic-in
3150 * port-D - rear line/hp-out
3151 * port-A - front line/hp-out
3153 * AD1984 = AD1884 + two digital mic-ins
3156 * For simplicity, we share the single DAC for both HP and line-outs
3157 * right now. The inidividual playbacks could be easily implemented,
3158 * but no build-up framework is given, so far.
3161 static hda_nid_t ad1884_dac_nids[1] = {
3165 static hda_nid_t ad1884_adc_nids[2] = {
3169 static hda_nid_t ad1884_capsrc_nids[2] = {
3173 #define AD1884_SPDIF_OUT 0x02
3175 static struct hda_input_mux ad1884_capture_source = {
3178 { "Front Mic", 0x0 },
3185 static struct snd_kcontrol_new ad1884_base_mixers[] = {
3186 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
3187 /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */
3188 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
3189 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT),
3190 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT),
3191 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT),
3192 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
3193 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3194 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
3195 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
3196 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT),
3197 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT),
3198 HDA_CODEC_VOLUME("Mic Boost", 0x15, 0x0, HDA_INPUT),
3199 HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT),
3200 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3201 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3202 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
3203 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
3205 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3206 /* The multiple "Capture Source" controls confuse alsamixer
3207 * So call somewhat different..
3209 /* .name = "Capture Source", */
3210 .name = "Input Source",
3212 .info = ad198x_mux_enum_info,
3213 .get = ad198x_mux_enum_get,
3214 .put = ad198x_mux_enum_put,
3216 /* SPDIF controls */
3217 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
3219 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3220 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
3221 /* identical with ad1983 */
3222 .info = ad1983_spdif_route_info,
3223 .get = ad1983_spdif_route_get,
3224 .put = ad1983_spdif_route_put,
3229 static struct snd_kcontrol_new ad1984_dmic_mixers[] = {
3230 HDA_CODEC_VOLUME("Digital Mic Capture Volume", 0x05, 0x0, HDA_INPUT),
3231 HDA_CODEC_MUTE("Digital Mic Capture Switch", 0x05, 0x0, HDA_INPUT),
3232 HDA_CODEC_VOLUME_IDX("Digital Mic Capture Volume", 1, 0x06, 0x0,
3234 HDA_CODEC_MUTE_IDX("Digital Mic Capture Switch", 1, 0x06, 0x0,
3240 * initialization verbs
3242 static struct hda_verb ad1884_init_verbs[] = {
3243 /* DACs; mute as default */
3244 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3245 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3246 /* Port-A (HP) mixer */
3247 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3248 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3250 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3251 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3252 /* HP selector - select DAC2 */
3253 {0x22, AC_VERB_SET_CONNECT_SEL, 0x1},
3254 /* Port-D (Line-out) mixer */
3255 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3256 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3258 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3259 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3260 /* Mono-out mixer */
3261 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3262 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3264 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3265 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3267 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
3268 /* Port-B (front mic) pin */
3269 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3270 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3271 /* Port-C (rear mic) pin */
3272 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3273 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3274 /* Analog mixer; mute as default */
3275 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3276 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3277 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3278 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3279 /* Analog Mix output amp */
3280 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
3281 /* SPDIF output selector */
3282 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */
3283 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
3287 #ifdef CONFIG_SND_HDA_POWER_SAVE
3288 static struct hda_amp_list ad1884_loopbacks[] = {
3289 { 0x20, HDA_INPUT, 0 }, /* Front Mic */
3290 { 0x20, HDA_INPUT, 1 }, /* Mic */
3291 { 0x20, HDA_INPUT, 2 }, /* CD */
3292 { 0x20, HDA_INPUT, 4 }, /* Docking */
3297 static const char *ad1884_slave_vols[] = {
3298 "PCM Playback Volume",
3299 "Mic Playback Volume",
3300 "Mono Playback Volume",
3301 "Front Mic Playback Volume",
3302 "Mic Playback Volume",
3303 "CD Playback Volume",
3304 "Internal Mic Playback Volume",
3305 "Docking Mic Playback Volume",
3306 /* "Beep Playback Volume", */
3307 "IEC958 Playback Volume",
3311 static int patch_ad1884(struct hda_codec *codec)
3313 struct ad198x_spec *spec;
3316 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3322 err = snd_hda_attach_beep_device(codec, 0x10);
3327 set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
3329 spec->multiout.max_channels = 2;
3330 spec->multiout.num_dacs = ARRAY_SIZE(ad1884_dac_nids);
3331 spec->multiout.dac_nids = ad1884_dac_nids;
3332 spec->multiout.dig_out_nid = AD1884_SPDIF_OUT;
3333 spec->num_adc_nids = ARRAY_SIZE(ad1884_adc_nids);
3334 spec->adc_nids = ad1884_adc_nids;
3335 spec->capsrc_nids = ad1884_capsrc_nids;
3336 spec->input_mux = &ad1884_capture_source;
3337 spec->num_mixers = 1;
3338 spec->mixers[0] = ad1884_base_mixers;
3339 spec->num_init_verbs = 1;
3340 spec->init_verbs[0] = ad1884_init_verbs;
3341 spec->spdif_route = 0;
3342 #ifdef CONFIG_SND_HDA_POWER_SAVE
3343 spec->loopback.amplist = ad1884_loopbacks;
3345 spec->vmaster_nid = 0x04;
3346 /* we need to cover all playback volumes */
3347 spec->slave_vols = ad1884_slave_vols;
3349 codec->patch_ops = ad198x_patch_ops;
3355 * Lenovo Thinkpad T61/X61
3357 static struct hda_input_mux ad1984_thinkpad_capture_source = {
3361 { "Internal Mic", 0x1 },
3363 { "Docking-Station", 0x4 },
3369 * Dell Precision T3400
3371 static struct hda_input_mux ad1984_dell_desktop_capture_source = {
3374 { "Front Mic", 0x0 },
3381 static struct snd_kcontrol_new ad1984_thinkpad_mixers[] = {
3382 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
3383 /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */
3384 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
3385 HDA_CODEC_MUTE("Speaker Playback Switch", 0x12, 0x0, HDA_OUTPUT),
3386 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
3387 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3388 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
3389 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
3390 HDA_CODEC_VOLUME("Docking Mic Playback Volume", 0x20, 0x04, HDA_INPUT),
3391 HDA_CODEC_MUTE("Docking Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
3392 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT),
3393 HDA_CODEC_VOLUME("Internal Mic Boost", 0x15, 0x0, HDA_INPUT),
3394 HDA_CODEC_VOLUME("Docking Mic Boost", 0x25, 0x0, HDA_OUTPUT),
3395 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3396 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3397 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
3398 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
3400 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3401 /* The multiple "Capture Source" controls confuse alsamixer
3402 * So call somewhat different..
3404 /* .name = "Capture Source", */
3405 .name = "Input Source",
3407 .info = ad198x_mux_enum_info,
3408 .get = ad198x_mux_enum_get,
3409 .put = ad198x_mux_enum_put,
3411 /* SPDIF controls */
3412 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
3414 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3415 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
3416 /* identical with ad1983 */
3417 .info = ad1983_spdif_route_info,
3418 .get = ad1983_spdif_route_get,
3419 .put = ad1983_spdif_route_put,
3424 /* additional verbs */
3425 static struct hda_verb ad1984_thinkpad_init_verbs[] = {
3426 /* Port-E (docking station mic) pin */
3427 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3428 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3429 /* docking mic boost */
3430 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3431 /* Analog mixer - docking mic; mute as default */
3432 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3433 /* enable EAPD bit */
3434 {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
3439 * Dell Precision T3400
3441 static struct snd_kcontrol_new ad1984_dell_desktop_mixers[] = {
3442 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
3443 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
3444 HDA_CODEC_MUTE("Speaker Playback Switch", 0x12, 0x0, HDA_OUTPUT),
3445 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT),
3446 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT),
3447 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
3448 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3449 HDA_CODEC_VOLUME("Line-In Playback Volume", 0x20, 0x01, HDA_INPUT),
3450 HDA_CODEC_MUTE("Line-In Playback Switch", 0x20, 0x01, HDA_INPUT),
3451 HDA_CODEC_VOLUME("Line-In Boost", 0x15, 0x0, HDA_INPUT),
3452 HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT),
3453 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3454 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3455 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
3456 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
3458 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3459 /* The multiple "Capture Source" controls confuse alsamixer
3460 * So call somewhat different..
3462 /* .name = "Capture Source", */
3463 .name = "Input Source",
3465 .info = ad198x_mux_enum_info,
3466 .get = ad198x_mux_enum_get,
3467 .put = ad198x_mux_enum_put,
3472 /* Digial MIC ADC NID 0x05 + 0x06 */
3473 static int ad1984_pcm_dmic_prepare(struct hda_pcm_stream *hinfo,
3474 struct hda_codec *codec,
3475 unsigned int stream_tag,
3476 unsigned int format,
3477 struct snd_pcm_substream *substream)
3479 snd_hda_codec_setup_stream(codec, 0x05 + substream->number,
3480 stream_tag, 0, format);
3484 static int ad1984_pcm_dmic_cleanup(struct hda_pcm_stream *hinfo,
3485 struct hda_codec *codec,
3486 struct snd_pcm_substream *substream)
3488 snd_hda_codec_cleanup_stream(codec, 0x05 + substream->number);
3492 static struct hda_pcm_stream ad1984_pcm_dmic_capture = {
3498 .prepare = ad1984_pcm_dmic_prepare,
3499 .cleanup = ad1984_pcm_dmic_cleanup
3503 static int ad1984_build_pcms(struct hda_codec *codec)
3505 struct ad198x_spec *spec = codec->spec;
3506 struct hda_pcm *info;
3509 err = ad198x_build_pcms(codec);
3513 info = spec->pcm_rec + codec->num_pcms;
3515 info->name = "AD1984 Digital Mic";
3516 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad1984_pcm_dmic_capture;
3524 AD1984_DELL_DESKTOP,
3528 static const char *ad1984_models[AD1984_MODELS] = {
3529 [AD1984_BASIC] = "basic",
3530 [AD1984_THINKPAD] = "thinkpad",
3531 [AD1984_DELL_DESKTOP] = "dell_desktop",
3534 static struct snd_pci_quirk ad1984_cfg_tbl[] = {
3535 /* Lenovo Thinkpad T61/X61 */
3536 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo Thinkpad", AD1984_THINKPAD),
3537 SND_PCI_QUIRK(0x1028, 0x0214, "Dell T3400", AD1984_DELL_DESKTOP),
3541 static int patch_ad1984(struct hda_codec *codec)
3543 struct ad198x_spec *spec;
3544 int board_config, err;
3546 err = patch_ad1884(codec);
3550 board_config = snd_hda_check_board_config(codec, AD1984_MODELS,
3551 ad1984_models, ad1984_cfg_tbl);
3552 switch (board_config) {
3554 /* additional digital mics */
3555 spec->mixers[spec->num_mixers++] = ad1984_dmic_mixers;
3556 codec->patch_ops.build_pcms = ad1984_build_pcms;
3558 case AD1984_THINKPAD:
3559 spec->multiout.dig_out_nid = AD1884_SPDIF_OUT;
3560 spec->input_mux = &ad1984_thinkpad_capture_source;
3561 spec->mixers[0] = ad1984_thinkpad_mixers;
3562 spec->init_verbs[spec->num_init_verbs++] = ad1984_thinkpad_init_verbs;
3564 case AD1984_DELL_DESKTOP:
3565 spec->multiout.dig_out_nid = 0;
3566 spec->input_mux = &ad1984_dell_desktop_capture_source;
3567 spec->mixers[0] = ad1984_dell_desktop_mixers;
3575 * AD1883 / AD1884A / AD1984A / AD1984B
3577 * port-B (0x14) - front mic-in
3578 * port-E (0x1c) - rear mic-in
3579 * port-F (0x16) - CD / ext out
3580 * port-C (0x15) - rear line-in
3581 * port-D (0x12) - rear line-out
3582 * port-A (0x11) - front hp-out
3584 * AD1984A = AD1884A + digital-mic
3585 * AD1883 = equivalent with AD1984A
3586 * AD1984B = AD1984A + extra SPDIF-out
3589 * We share the single DAC for both HP and line-outs (see AD1884/1984).
3592 static hda_nid_t ad1884a_dac_nids[1] = {
3596 #define ad1884a_adc_nids ad1884_adc_nids
3597 #define ad1884a_capsrc_nids ad1884_capsrc_nids
3599 #define AD1884A_SPDIF_OUT 0x02
3601 static struct hda_input_mux ad1884a_capture_source = {
3604 { "Front Mic", 0x0 },
3612 static struct snd_kcontrol_new ad1884a_base_mixers[] = {
3613 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT),
3614 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),
3615 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
3616 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT),
3617 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT),
3618 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT),
3619 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
3620 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
3621 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
3622 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3623 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x01, HDA_INPUT),
3624 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x01, HDA_INPUT),
3625 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x04, HDA_INPUT),
3626 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
3627 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT),
3628 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT),
3629 HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT),
3630 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x0, HDA_INPUT),
3631 HDA_CODEC_VOLUME("Mic Boost", 0x25, 0x0, HDA_OUTPUT),
3632 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3633 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3634 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
3635 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
3637 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3638 /* The multiple "Capture Source" controls confuse alsamixer
3639 * So call somewhat different..
3641 /* .name = "Capture Source", */
3642 .name = "Input Source",
3644 .info = ad198x_mux_enum_info,
3645 .get = ad198x_mux_enum_get,
3646 .put = ad198x_mux_enum_put,
3648 /* SPDIF controls */
3649 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
3651 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3652 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
3653 /* identical with ad1983 */
3654 .info = ad1983_spdif_route_info,
3655 .get = ad1983_spdif_route_get,
3656 .put = ad1983_spdif_route_put,
3662 * initialization verbs
3664 static struct hda_verb ad1884a_init_verbs[] = {
3665 /* DACs; unmute as default */
3666 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */
3667 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */
3668 /* Port-A (HP) mixer - route only from analog mixer */
3669 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3670 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3672 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3673 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3674 /* Port-D (Line-out) mixer - route only from analog mixer */
3675 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3676 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3678 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3679 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3680 /* Mono-out mixer - route only from analog mixer */
3681 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3682 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3684 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3685 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3686 /* Port-B (front mic) pin */
3687 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3688 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3689 /* Port-C (rear line-in) pin */
3690 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3691 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3692 /* Port-E (rear mic) pin */
3693 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3694 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3695 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* no boost */
3696 /* Port-F (CD) pin */
3697 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3698 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3699 /* Analog mixer; mute as default */
3700 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3701 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3702 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3703 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3704 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, /* aux */
3705 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
3706 /* Analog Mix output amp */
3707 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3708 /* capture sources */
3709 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0},
3710 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3711 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
3712 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3713 /* SPDIF output amp */
3714 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
3718 #ifdef CONFIG_SND_HDA_POWER_SAVE
3719 static struct hda_amp_list ad1884a_loopbacks[] = {
3720 { 0x20, HDA_INPUT, 0 }, /* Front Mic */
3721 { 0x20, HDA_INPUT, 1 }, /* Mic */
3722 { 0x20, HDA_INPUT, 2 }, /* CD */
3723 { 0x20, HDA_INPUT, 4 }, /* Docking */
3731 * Port A: Headphone jack
3733 * Port C: Internal MIC
3734 * Port D: Dock Line Out (if enabled)
3735 * Port E: Dock Line In (if enabled)
3736 * Port F: Internal speakers
3739 static int ad1884a_mobile_master_sw_put(struct snd_kcontrol *kcontrol,
3740 struct snd_ctl_elem_value *ucontrol)
3742 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3743 int ret = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
3744 int mute = (!ucontrol->value.integer.value[0] &&
3745 !ucontrol->value.integer.value[1]);
3746 /* toggle GPIO1 according to the mute state */
3747 snd_hda_codec_write_cache(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
3752 static struct snd_kcontrol_new ad1884a_laptop_mixers[] = {
3753 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT),
3755 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3756 .name = "Master Playback Switch",
3757 .subdevice = HDA_SUBDEV_AMP_FLAG,
3758 .info = snd_hda_mixer_amp_switch_info,
3759 .get = snd_hda_mixer_amp_switch_get,
3760 .put = ad1884a_mobile_master_sw_put,
3761 .private_value = HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
3763 HDA_CODEC_MUTE("Dock Playback Switch", 0x12, 0x0, HDA_OUTPUT),
3764 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
3765 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
3766 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
3767 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3768 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
3769 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
3770 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x20, 0x04, HDA_INPUT),
3771 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
3772 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT),
3773 HDA_CODEC_VOLUME("Internal Mic Boost", 0x15, 0x0, HDA_INPUT),
3774 HDA_CODEC_VOLUME("Dock Mic Boost", 0x25, 0x0, HDA_OUTPUT),
3775 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3776 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3780 static struct snd_kcontrol_new ad1884a_mobile_mixers[] = {
3781 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT),
3782 /*HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),*/
3784 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3785 .name = "Master Playback Switch",
3786 .subdevice = HDA_SUBDEV_AMP_FLAG,
3787 .info = snd_hda_mixer_amp_switch_info,
3788 .get = snd_hda_mixer_amp_switch_get,
3789 .put = ad1884a_mobile_master_sw_put,
3790 .private_value = HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
3792 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
3793 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
3794 HDA_CODEC_VOLUME("Mic Capture Volume", 0x14, 0x0, HDA_INPUT),
3795 HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x15, 0x0, HDA_INPUT),
3796 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3797 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3801 /* mute internal speaker if HP is plugged */
3802 static void ad1884a_hp_automute(struct hda_codec *codec)
3804 unsigned int present;
3806 present = snd_hda_jack_detect(codec, 0x11);
3807 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
3808 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
3809 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_EAPD_BTLENABLE,
3810 present ? 0x00 : 0x02);
3813 /* switch to external mic if plugged */
3814 static void ad1884a_hp_automic(struct hda_codec *codec)
3816 unsigned int present;
3818 present = snd_hda_jack_detect(codec, 0x14);
3819 snd_hda_codec_write(codec, 0x0c, 0, AC_VERB_SET_CONNECT_SEL,
3823 #define AD1884A_HP_EVENT 0x37
3824 #define AD1884A_MIC_EVENT 0x36
3826 /* unsolicited event for HP jack sensing */
3827 static void ad1884a_hp_unsol_event(struct hda_codec *codec, unsigned int res)
3829 switch (res >> 26) {
3830 case AD1884A_HP_EVENT:
3831 ad1884a_hp_automute(codec);
3833 case AD1884A_MIC_EVENT:
3834 ad1884a_hp_automic(codec);
3839 /* initialize jack-sensing, too */
3840 static int ad1884a_hp_init(struct hda_codec *codec)
3843 ad1884a_hp_automute(codec);
3844 ad1884a_hp_automic(codec);
3848 /* mute internal speaker if HP or docking HP is plugged */
3849 static void ad1884a_laptop_automute(struct hda_codec *codec)
3851 unsigned int present;
3853 present = snd_hda_jack_detect(codec, 0x11);
3855 present = snd_hda_jack_detect(codec, 0x12);
3856 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
3857 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
3858 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_EAPD_BTLENABLE,
3859 present ? 0x00 : 0x02);
3862 /* switch to external mic if plugged */
3863 static void ad1884a_laptop_automic(struct hda_codec *codec)
3867 if (snd_hda_jack_detect(codec, 0x14))
3869 else if (snd_hda_jack_detect(codec, 0x1c))
3873 snd_hda_codec_write(codec, 0x0c, 0, AC_VERB_SET_CONNECT_SEL, idx);
3876 /* unsolicited event for HP jack sensing */
3877 static void ad1884a_laptop_unsol_event(struct hda_codec *codec,
3880 switch (res >> 26) {
3881 case AD1884A_HP_EVENT:
3882 ad1884a_laptop_automute(codec);
3884 case AD1884A_MIC_EVENT:
3885 ad1884a_laptop_automic(codec);
3890 /* initialize jack-sensing, too */
3891 static int ad1884a_laptop_init(struct hda_codec *codec)
3894 ad1884a_laptop_automute(codec);
3895 ad1884a_laptop_automic(codec);
3899 /* additional verbs for laptop model */
3900 static struct hda_verb ad1884a_laptop_verbs[] = {
3901 /* Port-A (HP) pin - always unmuted */
3902 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3903 /* Port-F (int speaker) mixer - route only from analog mixer */
3904 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3905 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3906 /* Port-F (int speaker) pin */
3907 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3908 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3909 /* required for compaq 6530s/6531s speaker output */
3910 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3911 /* Port-C pin - internal mic-in */
3912 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3913 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */
3914 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */
3915 /* Port-D (docking line-out) pin - default unmuted */
3916 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3918 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3919 /* unsolicited event for pin-sense */
3920 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT},
3921 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT},
3922 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_MIC_EVENT},
3923 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_MIC_EVENT},
3924 /* allow to touch GPIO1 (for mute control) */
3925 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
3926 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
3927 {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, /* first muted */
3931 static struct hda_verb ad1884a_mobile_verbs[] = {
3932 /* DACs; unmute as default */
3933 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */
3934 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */
3935 /* Port-A (HP) mixer - route only from analog mixer */
3936 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3937 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3939 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3940 /* Port-A (HP) pin - always unmuted */
3941 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3942 /* Port-B (mic jack) pin */
3943 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3944 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */
3945 /* Port-C (int mic) pin */
3946 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3947 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */
3948 /* Port-F (int speaker) mixer - route only from analog mixer */
3949 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3950 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3952 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3953 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3954 /* Analog mixer; mute as default */
3955 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3956 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3957 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3958 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3959 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3960 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
3961 /* Analog Mix output amp */
3962 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3963 /* capture sources */
3964 /* {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0}, */ /* set via unsol */
3965 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3966 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
3967 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3968 /* unsolicited event for pin-sense */
3969 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT},
3970 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_MIC_EVENT},
3971 /* allow to touch GPIO1 (for mute control) */
3972 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
3973 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
3974 {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, /* first muted */
3983 * 0x17 - built-in mic
3986 static struct hda_verb ad1984a_thinkpad_verbs[] = {
3988 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3990 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3992 {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
3993 /* unsolicited event for pin-sense */
3994 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT},
3995 /* internal mic - dmic */
3996 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3997 /* set magic COEFs for dmic */
3998 {0x01, AC_VERB_SET_COEF_INDEX, 0x13f7},
3999 {0x01, AC_VERB_SET_PROC_COEF, 0x08},
4003 static struct snd_kcontrol_new ad1984a_thinkpad_mixers[] = {
4004 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT),
4005 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),
4006 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
4007 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
4008 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
4009 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
4010 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT),
4011 HDA_CODEC_VOLUME("Internal Mic Boost", 0x17, 0x0, HDA_INPUT),
4012 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
4013 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
4015 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4016 .name = "Capture Source",
4017 .info = ad198x_mux_enum_info,
4018 .get = ad198x_mux_enum_get,
4019 .put = ad198x_mux_enum_put,
4024 static struct hda_input_mux ad1984a_thinkpad_capture_source = {
4028 { "Internal Mic", 0x5 },
4033 /* mute internal speaker if HP is plugged */
4034 static void ad1984a_thinkpad_automute(struct hda_codec *codec)
4036 unsigned int present;
4038 present = snd_hda_jack_detect(codec, 0x11);
4039 snd_hda_codec_amp_stereo(codec, 0x12, HDA_OUTPUT, 0,
4040 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
4043 /* unsolicited event for HP jack sensing */
4044 static void ad1984a_thinkpad_unsol_event(struct hda_codec *codec,
4047 if ((res >> 26) != AD1884A_HP_EVENT)
4049 ad1984a_thinkpad_automute(codec);
4052 /* initialize jack-sensing, too */
4053 static int ad1984a_thinkpad_init(struct hda_codec *codec)
4056 ad1984a_thinkpad_automute(codec);
4062 * port-A (0x11) - front hp-out
4063 * port-B (0x14) - unused
4064 * port-C (0x15) - unused
4065 * port-D (0x12) - rear line out
4066 * port-E (0x1c) - front mic-in
4067 * port-F (0x16) - Internal speakers
4068 * digital-mic (0x17) - Internal mic
4071 static struct hda_verb ad1984a_touchsmart_verbs[] = {
4072 /* DACs; unmute as default */
4073 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */
4074 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */
4075 /* Port-A (HP) mixer - route only from analog mixer */
4076 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4077 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4079 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4080 /* Port-A (HP) pin - always unmuted */
4081 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4082 /* Port-E (int speaker) mixer - route only from analog mixer */
4083 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, 0x03},
4085 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4086 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4087 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4088 /* Port-F (int speaker) mixer - route only from analog mixer */
4089 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4090 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4092 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4093 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4094 /* Analog mixer; mute as default */
4095 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4096 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4097 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4098 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4099 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4100 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
4101 /* Analog Mix output amp */
4102 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4103 /* capture sources */
4104 /* {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0}, */ /* set via unsol */
4105 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4106 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
4107 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4108 /* unsolicited event for pin-sense */
4109 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT},
4110 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_MIC_EVENT},
4111 /* allow to touch GPIO1 (for mute control) */
4112 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
4113 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
4114 {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, /* first muted */
4115 /* internal mic - dmic */
4116 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4117 /* set magic COEFs for dmic */
4118 {0x01, AC_VERB_SET_COEF_INDEX, 0x13f7},
4119 {0x01, AC_VERB_SET_PROC_COEF, 0x08},
4123 static struct snd_kcontrol_new ad1984a_touchsmart_mixers[] = {
4124 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT),
4125 /* HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),*/
4127 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4128 .subdevice = HDA_SUBDEV_AMP_FLAG,
4129 .name = "Master Playback Switch",
4130 .info = snd_hda_mixer_amp_switch_info,
4131 .get = snd_hda_mixer_amp_switch_get,
4132 .put = ad1884a_mobile_master_sw_put,
4133 .private_value = HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
4135 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
4136 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
4137 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
4138 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
4139 HDA_CODEC_VOLUME("Mic Boost", 0x25, 0x0, HDA_OUTPUT),
4140 HDA_CODEC_VOLUME("Internal Mic Boost", 0x17, 0x0, HDA_INPUT),
4144 /* switch to external mic if plugged */
4145 static void ad1984a_touchsmart_automic(struct hda_codec *codec)
4147 if (snd_hda_jack_detect(codec, 0x1c))
4148 snd_hda_codec_write(codec, 0x0c, 0,
4149 AC_VERB_SET_CONNECT_SEL, 0x4);
4151 snd_hda_codec_write(codec, 0x0c, 0,
4152 AC_VERB_SET_CONNECT_SEL, 0x5);
4156 /* unsolicited event for HP jack sensing */
4157 static void ad1984a_touchsmart_unsol_event(struct hda_codec *codec,
4160 switch (res >> 26) {
4161 case AD1884A_HP_EVENT:
4162 ad1884a_hp_automute(codec);
4164 case AD1884A_MIC_EVENT:
4165 ad1984a_touchsmart_automic(codec);
4170 /* initialize jack-sensing, too */
4171 static int ad1984a_touchsmart_init(struct hda_codec *codec)
4174 ad1884a_hp_automute(codec);
4175 ad1984a_touchsmart_automic(codec);
4192 static const char *ad1884a_models[AD1884A_MODELS] = {
4193 [AD1884A_DESKTOP] = "desktop",
4194 [AD1884A_LAPTOP] = "laptop",
4195 [AD1884A_MOBILE] = "mobile",
4196 [AD1884A_THINKPAD] = "thinkpad",
4197 [AD1984A_TOUCHSMART] = "touchsmart",
4200 static struct snd_pci_quirk ad1884a_cfg_tbl[] = {
4201 SND_PCI_QUIRK(0x103c, 0x3030, "HP", AD1884A_MOBILE),
4202 SND_PCI_QUIRK(0x103c, 0x3037, "HP 2230s", AD1884A_LAPTOP),
4203 SND_PCI_QUIRK(0x103c, 0x3056, "HP", AD1884A_MOBILE),
4204 SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x3070, "HP", AD1884A_MOBILE),
4205 SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x30d0, "HP laptop", AD1884A_LAPTOP),
4206 SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x30e0, "HP laptop", AD1884A_LAPTOP),
4207 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3600, "HP laptop", AD1884A_LAPTOP),
4208 SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x7010, "HP laptop", AD1884A_MOBILE),
4209 SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X300", AD1884A_THINKPAD),
4210 SND_PCI_QUIRK(0x103c, 0x2a82, "Touchsmart", AD1984A_TOUCHSMART),
4214 static int patch_ad1884a(struct hda_codec *codec)
4216 struct ad198x_spec *spec;
4217 int err, board_config;
4219 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4225 err = snd_hda_attach_beep_device(codec, 0x10);
4230 set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
4232 spec->multiout.max_channels = 2;
4233 spec->multiout.num_dacs = ARRAY_SIZE(ad1884a_dac_nids);
4234 spec->multiout.dac_nids = ad1884a_dac_nids;
4235 spec->multiout.dig_out_nid = AD1884A_SPDIF_OUT;
4236 spec->num_adc_nids = ARRAY_SIZE(ad1884a_adc_nids);
4237 spec->adc_nids = ad1884a_adc_nids;
4238 spec->capsrc_nids = ad1884a_capsrc_nids;
4239 spec->input_mux = &ad1884a_capture_source;
4240 spec->num_mixers = 1;
4241 spec->mixers[0] = ad1884a_base_mixers;
4242 spec->num_init_verbs = 1;
4243 spec->init_verbs[0] = ad1884a_init_verbs;
4244 spec->spdif_route = 0;
4245 #ifdef CONFIG_SND_HDA_POWER_SAVE
4246 spec->loopback.amplist = ad1884a_loopbacks;
4248 codec->patch_ops = ad198x_patch_ops;
4250 /* override some parameters */
4251 board_config = snd_hda_check_board_config(codec, AD1884A_MODELS,
4254 switch (board_config) {
4255 case AD1884A_LAPTOP:
4256 spec->mixers[0] = ad1884a_laptop_mixers;
4257 spec->init_verbs[spec->num_init_verbs++] = ad1884a_laptop_verbs;
4258 spec->multiout.dig_out_nid = 0;
4259 codec->patch_ops.unsol_event = ad1884a_laptop_unsol_event;
4260 codec->patch_ops.init = ad1884a_laptop_init;
4261 /* set the upper-limit for mixer amp to 0dB for avoiding the
4262 * possible damage by overloading
4264 snd_hda_override_amp_caps(codec, 0x20, HDA_INPUT,
4265 (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
4266 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4267 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4268 (1 << AC_AMPCAP_MUTE_SHIFT));
4270 case AD1884A_MOBILE:
4271 spec->mixers[0] = ad1884a_mobile_mixers;
4272 spec->init_verbs[0] = ad1884a_mobile_verbs;
4273 spec->multiout.dig_out_nid = 0;
4274 codec->patch_ops.unsol_event = ad1884a_hp_unsol_event;
4275 codec->patch_ops.init = ad1884a_hp_init;
4276 /* set the upper-limit for mixer amp to 0dB for avoiding the
4277 * possible damage by overloading
4279 snd_hda_override_amp_caps(codec, 0x20, HDA_INPUT,
4280 (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
4281 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4282 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4283 (1 << AC_AMPCAP_MUTE_SHIFT));
4285 case AD1884A_THINKPAD:
4286 spec->mixers[0] = ad1984a_thinkpad_mixers;
4287 spec->init_verbs[spec->num_init_verbs++] =
4288 ad1984a_thinkpad_verbs;
4289 spec->multiout.dig_out_nid = 0;
4290 spec->input_mux = &ad1984a_thinkpad_capture_source;
4291 codec->patch_ops.unsol_event = ad1984a_thinkpad_unsol_event;
4292 codec->patch_ops.init = ad1984a_thinkpad_init;
4294 case AD1984A_TOUCHSMART:
4295 spec->mixers[0] = ad1984a_touchsmart_mixers;
4296 spec->init_verbs[0] = ad1984a_touchsmart_verbs;
4297 spec->multiout.dig_out_nid = 0;
4298 codec->patch_ops.unsol_event = ad1984a_touchsmart_unsol_event;
4299 codec->patch_ops.init = ad1984a_touchsmart_init;
4300 /* set the upper-limit for mixer amp to 0dB for avoiding the
4301 * possible damage by overloading
4303 snd_hda_override_amp_caps(codec, 0x20, HDA_INPUT,
4304 (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
4305 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4306 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4307 (1 << AC_AMPCAP_MUTE_SHIFT));
4318 * port-A - front hp-out
4319 * port-B - front mic-in
4320 * port-C - rear line-in, shared surr-out (3stack)
4321 * port-D - rear line-out
4322 * port-E - rear mic-in, shared clfe-out (3stack)
4323 * port-F - rear surr-out (6stack)
4324 * port-G - rear clfe-out (6stack)
4327 static hda_nid_t ad1882_dac_nids[3] = {
4331 static hda_nid_t ad1882_adc_nids[2] = {
4335 static hda_nid_t ad1882_capsrc_nids[2] = {
4339 #define AD1882_SPDIF_OUT 0x02
4341 /* list: 0x11, 0x39, 0x3a, 0x18, 0x3c, 0x3b, 0x12, 0x20 */
4342 static struct hda_input_mux ad1882_capture_source = {
4345 { "Front Mic", 0x1 },
4353 /* list: 0x11, 0x39, 0x3a, 0x3c, 0x18, 0x1f, 0x12, 0x20 */
4354 static struct hda_input_mux ad1882a_capture_source = {
4357 { "Front Mic", 0x1 },
4360 { "Digital Mic", 0x06 },
4365 static struct snd_kcontrol_new ad1882_base_mixers[] = {
4366 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
4367 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
4368 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT),
4369 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT),
4370 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
4371 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT),
4372 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT),
4373 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT),
4375 HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT),
4376 HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT),
4377 HDA_CODEC_VOLUME("Line-In Boost", 0x3a, 0x0, HDA_OUTPUT),
4378 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
4379 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
4380 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
4381 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
4383 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4384 /* The multiple "Capture Source" controls confuse alsamixer
4385 * So call somewhat different..
4387 /* .name = "Capture Source", */
4388 .name = "Input Source",
4390 .info = ad198x_mux_enum_info,
4391 .get = ad198x_mux_enum_get,
4392 .put = ad198x_mux_enum_put,
4394 /* SPDIF controls */
4395 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
4397 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4398 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
4399 /* identical with ad1983 */
4400 .info = ad1983_spdif_route_info,
4401 .get = ad1983_spdif_route_get,
4402 .put = ad1983_spdif_route_put,
4407 static struct snd_kcontrol_new ad1882_loopback_mixers[] = {
4408 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
4409 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
4410 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
4411 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
4412 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x04, HDA_INPUT),
4413 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x04, HDA_INPUT),
4414 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT),
4415 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT),
4419 static struct snd_kcontrol_new ad1882a_loopback_mixers[] = {
4420 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
4421 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
4422 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x04, HDA_INPUT),
4423 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
4424 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x01, HDA_INPUT),
4425 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x01, HDA_INPUT),
4426 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT),
4427 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT),
4428 HDA_CODEC_VOLUME("Digital Mic Boost", 0x1f, 0x0, HDA_INPUT),
4432 static struct snd_kcontrol_new ad1882_3stack_mixers[] = {
4433 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
4434 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x17, 1, 0x0, HDA_OUTPUT),
4435 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x17, 2, 0x0, HDA_OUTPUT),
4437 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4438 .name = "Channel Mode",
4439 .info = ad198x_ch_mode_info,
4440 .get = ad198x_ch_mode_get,
4441 .put = ad198x_ch_mode_put,
4446 static struct snd_kcontrol_new ad1882_6stack_mixers[] = {
4447 HDA_CODEC_MUTE("Surround Playback Switch", 0x16, 0x0, HDA_OUTPUT),
4448 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x24, 1, 0x0, HDA_OUTPUT),
4449 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x24, 2, 0x0, HDA_OUTPUT),
4453 static struct hda_verb ad1882_ch2_init[] = {
4454 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4455 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4456 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4457 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4458 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4459 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4463 static struct hda_verb ad1882_ch4_init[] = {
4464 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4465 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4466 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4467 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4468 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4469 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4473 static struct hda_verb ad1882_ch6_init[] = {
4474 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4475 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4476 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4477 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4478 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4479 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4483 static struct hda_channel_mode ad1882_modes[3] = {
4484 { 2, ad1882_ch2_init },
4485 { 4, ad1882_ch4_init },
4486 { 6, ad1882_ch6_init },
4490 * initialization verbs
4492 static struct hda_verb ad1882_init_verbs[] = {
4493 /* DACs; mute as default */
4494 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4495 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4496 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4497 /* Port-A (HP) mixer */
4498 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4499 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4501 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4502 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4503 /* HP selector - select DAC2 */
4504 {0x37, AC_VERB_SET_CONNECT_SEL, 0x1},
4505 /* Port-D (Line-out) mixer */
4506 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4507 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4509 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4510 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4511 /* Mono-out mixer */
4512 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4513 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4515 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4516 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4517 /* Port-B (front mic) pin */
4518 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4519 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4520 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* boost */
4521 /* Port-C (line-in) pin */
4522 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4523 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4524 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* boost */
4525 /* Port-C mixer - mute as input */
4526 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4527 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4528 /* Port-E (mic-in) pin */
4529 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4530 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4531 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* boost */
4532 /* Port-E mixer - mute as input */
4533 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4534 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4535 /* Port-F (surround) */
4536 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4537 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4539 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4540 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4541 /* Analog mixer; mute as default */
4542 /* list: 0x39, 0x3a, 0x11, 0x12, 0x3c, 0x3b, 0x18, 0x1a */
4543 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4544 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4545 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4546 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4547 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4548 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
4549 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
4550 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
4551 /* Analog Mix output amp */
4552 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
4553 /* SPDIF output selector */
4554 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
4555 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */
4556 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
4560 #ifdef CONFIG_SND_HDA_POWER_SAVE
4561 static struct hda_amp_list ad1882_loopbacks[] = {
4562 { 0x20, HDA_INPUT, 0 }, /* Front Mic */
4563 { 0x20, HDA_INPUT, 1 }, /* Mic */
4564 { 0x20, HDA_INPUT, 4 }, /* Line */
4565 { 0x20, HDA_INPUT, 6 }, /* CD */
4577 static const char *ad1882_models[AD1986A_MODELS] = {
4578 [AD1882_3STACK] = "3stack",
4579 [AD1882_6STACK] = "6stack",
4583 static int patch_ad1882(struct hda_codec *codec)
4585 struct ad198x_spec *spec;
4586 int err, board_config;
4588 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4594 err = snd_hda_attach_beep_device(codec, 0x10);
4599 set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
4601 spec->multiout.max_channels = 6;
4602 spec->multiout.num_dacs = 3;
4603 spec->multiout.dac_nids = ad1882_dac_nids;
4604 spec->multiout.dig_out_nid = AD1882_SPDIF_OUT;
4605 spec->num_adc_nids = ARRAY_SIZE(ad1882_adc_nids);
4606 spec->adc_nids = ad1882_adc_nids;
4607 spec->capsrc_nids = ad1882_capsrc_nids;
4608 if (codec->vendor_id == 0x11d41882)
4609 spec->input_mux = &ad1882_capture_source;
4611 spec->input_mux = &ad1882a_capture_source;
4612 spec->num_mixers = 2;
4613 spec->mixers[0] = ad1882_base_mixers;
4614 if (codec->vendor_id == 0x11d41882)
4615 spec->mixers[1] = ad1882_loopback_mixers;
4617 spec->mixers[1] = ad1882a_loopback_mixers;
4618 spec->num_init_verbs = 1;
4619 spec->init_verbs[0] = ad1882_init_verbs;
4620 spec->spdif_route = 0;
4621 #ifdef CONFIG_SND_HDA_POWER_SAVE
4622 spec->loopback.amplist = ad1882_loopbacks;
4624 spec->vmaster_nid = 0x04;
4626 codec->patch_ops = ad198x_patch_ops;
4628 /* override some parameters */
4629 board_config = snd_hda_check_board_config(codec, AD1882_MODELS,
4630 ad1882_models, NULL);
4631 switch (board_config) {
4634 spec->num_mixers = 3;
4635 spec->mixers[2] = ad1882_3stack_mixers;
4636 spec->channel_mode = ad1882_modes;
4637 spec->num_channel_mode = ARRAY_SIZE(ad1882_modes);
4638 spec->need_dac_fix = 1;
4639 spec->multiout.max_channels = 2;
4640 spec->multiout.num_dacs = 1;
4643 spec->num_mixers = 3;
4644 spec->mixers[2] = ad1882_6stack_mixers;
4654 static struct hda_codec_preset snd_hda_preset_analog[] = {
4655 { .id = 0x11d4184a, .name = "AD1884A", .patch = patch_ad1884a },
4656 { .id = 0x11d41882, .name = "AD1882", .patch = patch_ad1882 },
4657 { .id = 0x11d41883, .name = "AD1883", .patch = patch_ad1884a },
4658 { .id = 0x11d41884, .name = "AD1884", .patch = patch_ad1884 },
4659 { .id = 0x11d4194a, .name = "AD1984A", .patch = patch_ad1884a },
4660 { .id = 0x11d4194b, .name = "AD1984B", .patch = patch_ad1884a },
4661 { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 },
4662 { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 },
4663 { .id = 0x11d41984, .name = "AD1984", .patch = patch_ad1984 },
4664 { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a },
4665 { .id = 0x11d41988, .name = "AD1988", .patch = patch_ad1988 },
4666 { .id = 0x11d4198b, .name = "AD1988B", .patch = patch_ad1988 },
4667 { .id = 0x11d4882a, .name = "AD1882A", .patch = patch_ad1882 },
4668 { .id = 0x11d4989a, .name = "AD1989A", .patch = patch_ad1988 },
4669 { .id = 0x11d4989b, .name = "AD1989B", .patch = patch_ad1988 },
4673 MODULE_ALIAS("snd-hda-codec-id:11d4*");
4675 MODULE_LICENSE("GPL");
4676 MODULE_DESCRIPTION("Analog Devices HD-audio codec");
4678 static struct hda_codec_preset_list analog_list = {
4679 .preset = snd_hda_preset_analog,
4680 .owner = THIS_MODULE,
4683 static int __init patch_analog_init(void)
4685 return snd_hda_add_codec_preset(&analog_list);
4688 static void __exit patch_analog_exit(void)
4690 snd_hda_delete_codec_preset(&analog_list);
4693 module_init(patch_analog_init)
4694 module_exit(patch_analog_exit)