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/slab.h>
24 #include <linux/pci.h>
25 #include <linux/module.h>
27 #include <sound/core.h>
28 #include "hda_codec.h"
29 #include "hda_local.h"
30 #include "hda_auto_parser.h"
33 #include "hda_generic.h"
35 #define ENABLE_AD_STATIC_QUIRKS
38 struct hda_gen_spec gen;
42 unsigned int cur_smux;
45 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
47 #ifdef ENABLE_AD_STATIC_QUIRKS
48 const struct snd_kcontrol_new *mixers[6];
50 const struct hda_verb *init_verbs[6]; /* initialization verbs
51 * don't forget NULL termination!
53 unsigned int num_init_verbs;
56 struct hda_multi_out multiout; /* playback set-up
57 * max_channels, dacs must be set
58 * dig_out_nid and hp_nid are optional
60 unsigned int cur_eapd;
61 unsigned int need_dac_fix;
64 unsigned int num_adc_nids;
65 const hda_nid_t *adc_nids;
66 hda_nid_t dig_in_nid; /* digital-in NID; optional */
69 const struct hda_input_mux *input_mux;
70 const hda_nid_t *capsrc_nids;
71 unsigned int cur_mux[3];
74 const struct hda_channel_mode *channel_mode;
78 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
80 unsigned int spdif_route;
82 unsigned int jack_present: 1;
83 unsigned int inv_jack_detect: 1;/* inverted jack-detection */
84 unsigned int analog_beep: 1; /* analog beep input present */
85 unsigned int avoid_init_slave_vol:1;
88 struct hda_loopback_check loopback;
90 /* for virtual master */
91 hda_nid_t vmaster_nid;
92 const char * const *slave_vols;
93 const char * const *slave_sws;
94 #endif /* ENABLE_AD_STATIC_QUIRKS */
97 #ifdef ENABLE_AD_STATIC_QUIRKS
99 * input MUX handling (common part)
101 static int ad198x_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
103 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
104 struct ad198x_spec *spec = codec->spec;
106 return snd_hda_input_mux_info(spec->input_mux, uinfo);
109 static int ad198x_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
111 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
112 struct ad198x_spec *spec = codec->spec;
113 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
115 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
119 static int ad198x_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
121 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
122 struct ad198x_spec *spec = codec->spec;
123 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
125 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
126 spec->capsrc_nids[adc_idx],
127 &spec->cur_mux[adc_idx]);
131 * initialization (common callbacks)
133 static int ad198x_init(struct hda_codec *codec)
135 struct ad198x_spec *spec = codec->spec;
138 for (i = 0; i < spec->num_init_verbs; i++)
139 snd_hda_sequence_write(codec, spec->init_verbs[i]);
143 static const char * const ad_slave_pfxs[] = {
144 "Front", "Surround", "Center", "LFE", "Side",
145 "Headphone", "Mono", "Speaker", "IEC958",
149 static const char * const ad1988_6stack_fp_slave_pfxs[] = {
150 "Front", "Surround", "Center", "LFE", "Side", "IEC958",
153 #endif /* ENABLE_AD_STATIC_QUIRKS */
155 #ifdef CONFIG_SND_HDA_INPUT_BEEP
156 /* additional beep mixers; the actual parameters are overwritten at build */
157 static const struct snd_kcontrol_new ad_beep_mixer[] = {
158 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_OUTPUT),
159 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_OUTPUT),
163 static const struct snd_kcontrol_new ad_beep2_mixer[] = {
164 HDA_CODEC_VOLUME("Digital Beep Playback Volume", 0, 0, HDA_OUTPUT),
165 HDA_CODEC_MUTE_BEEP("Digital Beep Playback Switch", 0, 0, HDA_OUTPUT),
169 #define set_beep_amp(spec, nid, idx, dir) \
170 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir)) /* mono */
172 #define set_beep_amp(spec, nid, idx, dir) /* NOP */
175 #ifdef CONFIG_SND_HDA_INPUT_BEEP
176 static int create_beep_ctls(struct hda_codec *codec)
178 struct ad198x_spec *spec = codec->spec;
179 const struct snd_kcontrol_new *knew;
184 knew = spec->analog_beep ? ad_beep2_mixer : ad_beep_mixer;
185 for ( ; knew->name; knew++) {
187 struct snd_kcontrol *kctl;
188 kctl = snd_ctl_new1(knew, codec);
191 kctl->private_value = spec->beep_amp;
192 err = snd_hda_ctl_add(codec, 0, kctl);
199 #define create_beep_ctls(codec) 0
202 #ifdef ENABLE_AD_STATIC_QUIRKS
203 static int ad198x_build_controls(struct hda_codec *codec)
205 struct ad198x_spec *spec = codec->spec;
206 struct snd_kcontrol *kctl;
210 for (i = 0; i < spec->num_mixers; i++) {
211 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
215 if (spec->multiout.dig_out_nid) {
216 err = snd_hda_create_spdif_out_ctls(codec,
217 spec->multiout.dig_out_nid,
218 spec->multiout.dig_out_nid);
221 err = snd_hda_create_spdif_share_sw(codec,
225 spec->multiout.share_spdif = 1;
227 if (spec->dig_in_nid) {
228 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
233 /* create beep controls if needed */
234 err = create_beep_ctls(codec);
238 /* if we have no master control, let's create it */
239 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
240 unsigned int vmaster_tlv[4];
241 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
242 HDA_OUTPUT, vmaster_tlv);
243 err = __snd_hda_add_vmaster(codec, "Master Playback Volume",
246 spec->slave_vols : ad_slave_pfxs),
248 !spec->avoid_init_slave_vol, NULL);
252 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
253 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
256 spec->slave_sws : ad_slave_pfxs),
262 /* assign Capture Source enums to NID */
263 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
265 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
266 for (i = 0; kctl && i < kctl->count; i++) {
267 err = snd_hda_add_nid(codec, kctl, i, spec->capsrc_nids[i]);
272 /* assign IEC958 enums to NID */
273 kctl = snd_hda_find_mixer_ctl(codec,
274 SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source");
276 err = snd_hda_add_nid(codec, kctl, 0,
277 spec->multiout.dig_out_nid);
286 static int ad198x_check_power_status(struct hda_codec *codec, hda_nid_t nid)
288 struct ad198x_spec *spec = codec->spec;
289 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
294 * Analog playback callbacks
296 static int ad198x_playback_pcm_open(struct hda_pcm_stream *hinfo,
297 struct hda_codec *codec,
298 struct snd_pcm_substream *substream)
300 struct ad198x_spec *spec = codec->spec;
301 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
305 static int ad198x_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
306 struct hda_codec *codec,
307 unsigned int stream_tag,
309 struct snd_pcm_substream *substream)
311 struct ad198x_spec *spec = codec->spec;
312 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
316 static int ad198x_playback_pcm_cleanup(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_analog_cleanup(codec, &spec->multiout);
327 static int ad198x_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
328 struct hda_codec *codec,
329 struct snd_pcm_substream *substream)
331 struct ad198x_spec *spec = codec->spec;
332 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
335 static int ad198x_dig_playback_pcm_close(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_close(codec, &spec->multiout);
343 static int ad198x_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
344 struct hda_codec *codec,
345 unsigned int stream_tag,
347 struct snd_pcm_substream *substream)
349 struct ad198x_spec *spec = codec->spec;
350 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag,
354 static int ad198x_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
355 struct hda_codec *codec,
356 struct snd_pcm_substream *substream)
358 struct ad198x_spec *spec = codec->spec;
359 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
365 static int ad198x_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
366 struct hda_codec *codec,
367 unsigned int stream_tag,
369 struct snd_pcm_substream *substream)
371 struct ad198x_spec *spec = codec->spec;
372 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
373 stream_tag, 0, format);
377 static int ad198x_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
378 struct hda_codec *codec,
379 struct snd_pcm_substream *substream)
381 struct ad198x_spec *spec = codec->spec;
382 snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
388 static const struct hda_pcm_stream ad198x_pcm_analog_playback = {
391 .channels_max = 6, /* changed later */
392 .nid = 0, /* fill later */
394 .open = ad198x_playback_pcm_open,
395 .prepare = ad198x_playback_pcm_prepare,
396 .cleanup = ad198x_playback_pcm_cleanup,
400 static const struct hda_pcm_stream ad198x_pcm_analog_capture = {
404 .nid = 0, /* fill later */
406 .prepare = ad198x_capture_pcm_prepare,
407 .cleanup = ad198x_capture_pcm_cleanup
411 static const struct hda_pcm_stream ad198x_pcm_digital_playback = {
415 .nid = 0, /* fill later */
417 .open = ad198x_dig_playback_pcm_open,
418 .close = ad198x_dig_playback_pcm_close,
419 .prepare = ad198x_dig_playback_pcm_prepare,
420 .cleanup = ad198x_dig_playback_pcm_cleanup
424 static const struct hda_pcm_stream ad198x_pcm_digital_capture = {
428 /* NID is set in alc_build_pcms */
431 static int ad198x_build_pcms(struct hda_codec *codec)
433 struct ad198x_spec *spec = codec->spec;
434 struct hda_pcm *info = spec->pcm_rec;
437 codec->pcm_info = info;
439 info->name = "AD198x Analog";
440 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_analog_playback;
441 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->multiout.max_channels;
442 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
443 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_analog_capture;
444 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adc_nids;
445 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
447 if (spec->multiout.dig_out_nid) {
450 codec->spdif_status_reset = 1;
451 info->name = "AD198x Digital";
452 info->pcm_type = HDA_PCM_TYPE_SPDIF;
453 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_digital_playback;
454 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
455 if (spec->dig_in_nid) {
456 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_digital_capture;
457 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
463 #endif /* ENABLE_AD_STATIC_QUIRKS */
465 static void ad198x_power_eapd_write(struct hda_codec *codec, hda_nid_t front,
468 if (snd_hda_query_pin_caps(codec, front) & AC_PINCAP_EAPD)
469 snd_hda_codec_write(codec, front, 0, AC_VERB_SET_EAPD_BTLENABLE,
470 !codec->inv_eapd ? 0x00 : 0x02);
471 if (snd_hda_query_pin_caps(codec, hp) & AC_PINCAP_EAPD)
472 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_EAPD_BTLENABLE,
473 !codec->inv_eapd ? 0x00 : 0x02);
476 static void ad198x_power_eapd(struct hda_codec *codec)
478 /* We currently only handle front, HP */
479 switch (codec->vendor_id) {
492 ad198x_power_eapd_write(codec, 0x12, 0x11);
496 ad198x_power_eapd_write(codec, 0x05, 0x06);
499 ad198x_power_eapd_write(codec, 0x1b, 0x1a);
504 static void ad198x_shutup(struct hda_codec *codec)
506 snd_hda_shutup_pins(codec);
507 ad198x_power_eapd(codec);
510 static void ad198x_free(struct hda_codec *codec)
512 struct ad198x_spec *spec = codec->spec;
517 snd_hda_gen_spec_free(&spec->gen);
519 snd_hda_detach_beep_device(codec);
523 static int ad198x_suspend(struct hda_codec *codec)
525 ad198x_shutup(codec);
530 #ifdef ENABLE_AD_STATIC_QUIRKS
531 static const struct hda_codec_ops ad198x_patch_ops = {
532 .build_controls = ad198x_build_controls,
533 .build_pcms = ad198x_build_pcms,
537 .check_power_status = ad198x_check_power_status,
538 .suspend = ad198x_suspend,
540 .reboot_notify = ad198x_shutup,
546 * the private value = nid
548 #define ad198x_eapd_info snd_ctl_boolean_mono_info
550 static int ad198x_eapd_get(struct snd_kcontrol *kcontrol,
551 struct snd_ctl_elem_value *ucontrol)
553 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
554 struct ad198x_spec *spec = codec->spec;
556 ucontrol->value.integer.value[0] = ! spec->cur_eapd;
558 ucontrol->value.integer.value[0] = spec->cur_eapd;
562 static int ad198x_eapd_put(struct snd_kcontrol *kcontrol,
563 struct snd_ctl_elem_value *ucontrol)
565 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
566 struct ad198x_spec *spec = codec->spec;
567 hda_nid_t nid = kcontrol->private_value & 0xff;
569 eapd = !!ucontrol->value.integer.value[0];
572 if (eapd == spec->cur_eapd)
574 spec->cur_eapd = eapd;
575 snd_hda_codec_write_cache(codec, nid,
576 0, AC_VERB_SET_EAPD_BTLENABLE,
581 static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol,
582 struct snd_ctl_elem_info *uinfo);
583 static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol,
584 struct snd_ctl_elem_value *ucontrol);
585 static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol,
586 struct snd_ctl_elem_value *ucontrol);
587 #endif /* ENABLE_AD_STATIC_QUIRKS */
591 * Automatic parse of I/O pins from the BIOS configuration
594 static int ad198x_auto_build_controls(struct hda_codec *codec)
598 err = snd_hda_gen_build_controls(codec);
601 err = create_beep_ctls(codec);
607 static const struct hda_codec_ops ad198x_auto_patch_ops = {
608 .build_controls = ad198x_auto_build_controls,
609 .build_pcms = snd_hda_gen_build_pcms,
610 .init = snd_hda_gen_init,
611 .free = snd_hda_gen_free,
612 .unsol_event = snd_hda_jack_unsol_event,
614 .check_power_status = snd_hda_gen_check_power_status,
615 .suspend = ad198x_suspend,
617 .reboot_notify = ad198x_shutup,
621 static int ad198x_parse_auto_config(struct hda_codec *codec)
623 struct ad198x_spec *spec = codec->spec;
624 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
627 codec->spdif_status_reset = 1;
628 codec->no_trigger_sense = 1;
629 codec->no_sticky_stream = 1;
631 spec->gen.indep_hp = 1;
633 err = snd_hda_parse_pin_defcfg(codec, cfg, NULL, 0);
636 err = snd_hda_gen_parse_auto_config(codec, cfg);
640 codec->patch_ops = ad198x_auto_patch_ops;
649 #ifdef ENABLE_AD_STATIC_QUIRKS
650 #define AD1986A_SPDIF_OUT 0x02
651 #define AD1986A_FRONT_DAC 0x03
652 #define AD1986A_SURR_DAC 0x04
653 #define AD1986A_CLFE_DAC 0x05
654 #define AD1986A_ADC 0x06
656 static const hda_nid_t ad1986a_dac_nids[3] = {
657 AD1986A_FRONT_DAC, AD1986A_SURR_DAC, AD1986A_CLFE_DAC
659 static const hda_nid_t ad1986a_adc_nids[1] = { AD1986A_ADC };
660 static const hda_nid_t ad1986a_capsrc_nids[1] = { 0x12 };
662 static const struct hda_input_mux ad1986a_capture_source = {
676 static const struct hda_bind_ctls ad1986a_bind_pcm_vol = {
677 .ops = &snd_hda_bind_vol,
679 HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT),
680 HDA_COMPOSE_AMP_VAL(AD1986A_SURR_DAC, 3, 0, HDA_OUTPUT),
681 HDA_COMPOSE_AMP_VAL(AD1986A_CLFE_DAC, 3, 0, HDA_OUTPUT),
686 static const struct hda_bind_ctls ad1986a_bind_pcm_sw = {
687 .ops = &snd_hda_bind_sw,
689 HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT),
690 HDA_COMPOSE_AMP_VAL(AD1986A_SURR_DAC, 3, 0, HDA_OUTPUT),
691 HDA_COMPOSE_AMP_VAL(AD1986A_CLFE_DAC, 3, 0, HDA_OUTPUT),
699 static const struct snd_kcontrol_new ad1986a_mixers[] = {
701 * bind volumes/mutes of 3 DACs as a single PCM control for simplicity
703 HDA_BIND_VOL("PCM Playback Volume", &ad1986a_bind_pcm_vol),
704 HDA_BIND_SW("PCM Playback Switch", &ad1986a_bind_pcm_sw),
705 HDA_CODEC_VOLUME("Front Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
706 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
707 HDA_CODEC_VOLUME("Surround Playback Volume", 0x1c, 0x0, HDA_OUTPUT),
708 HDA_CODEC_MUTE("Surround Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
709 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x1d, 1, 0x0, HDA_OUTPUT),
710 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x1d, 2, 0x0, HDA_OUTPUT),
711 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x1d, 1, 0x0, HDA_OUTPUT),
712 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x1d, 2, 0x0, HDA_OUTPUT),
713 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT),
714 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
715 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT),
716 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT),
717 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT),
718 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT),
719 HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT),
720 HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT),
721 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
722 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
723 HDA_CODEC_VOLUME("Mic Boost Volume", 0x0f, 0x0, HDA_OUTPUT),
724 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
725 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT),
726 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
727 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
729 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
730 .name = "Capture Source",
731 .info = ad198x_mux_enum_info,
732 .get = ad198x_mux_enum_get,
733 .put = ad198x_mux_enum_put,
735 HDA_CODEC_MUTE("Stereo Downmix Switch", 0x09, 0x0, HDA_OUTPUT),
739 /* additional mixers for 3stack mode */
740 static const struct snd_kcontrol_new ad1986a_3st_mixers[] = {
742 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
743 .name = "Channel Mode",
744 .info = ad198x_ch_mode_info,
745 .get = ad198x_ch_mode_get,
746 .put = ad198x_ch_mode_put,
751 /* laptop model - 2ch only */
752 static const hda_nid_t ad1986a_laptop_dac_nids[1] = { AD1986A_FRONT_DAC };
754 /* master controls both pins 0x1a and 0x1b */
755 static const struct hda_bind_ctls ad1986a_laptop_master_vol = {
756 .ops = &snd_hda_bind_vol,
758 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT),
759 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
764 static const struct hda_bind_ctls ad1986a_laptop_master_sw = {
765 .ops = &snd_hda_bind_sw,
767 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT),
768 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
773 static const struct snd_kcontrol_new ad1986a_laptop_mixers[] = {
774 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
775 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
776 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol),
777 HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw),
778 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT),
779 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT),
780 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT),
781 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT),
782 HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT),
783 HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT),
784 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
785 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
786 HDA_CODEC_VOLUME("Mic Boost Volume", 0x0f, 0x0, HDA_OUTPUT),
788 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
789 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), */
790 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
791 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
793 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
794 .name = "Capture Source",
795 .info = ad198x_mux_enum_info,
796 .get = ad198x_mux_enum_get,
797 .put = ad198x_mux_enum_put,
802 /* laptop-eapd model - 2ch only */
804 static const struct hda_input_mux ad1986a_laptop_eapd_capture_source = {
808 { "Internal Mic", 0x4 },
813 static const struct hda_input_mux ad1986a_automic_capture_source = {
821 static const struct snd_kcontrol_new ad1986a_laptop_master_mixers[] = {
822 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol),
823 HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw),
827 static const struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = {
828 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
829 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
830 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
831 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
832 HDA_CODEC_VOLUME("Mic Boost Volume", 0x0f, 0x0, HDA_OUTPUT),
833 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
834 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
836 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
837 .name = "Capture Source",
838 .info = ad198x_mux_enum_info,
839 .get = ad198x_mux_enum_get,
840 .put = ad198x_mux_enum_put,
843 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
844 .name = "External Amplifier",
845 .subdevice = HDA_SUBDEV_NID_FLAG | 0x1b,
846 .info = ad198x_eapd_info,
847 .get = ad198x_eapd_get,
848 .put = ad198x_eapd_put,
849 .private_value = 0x1b, /* port-D */
854 static const struct snd_kcontrol_new ad1986a_laptop_intmic_mixers[] = {
855 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0, HDA_OUTPUT),
856 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0, HDA_OUTPUT),
860 /* laptop-automute - 2ch only */
862 static void ad1986a_update_hp(struct hda_codec *codec)
864 struct ad198x_spec *spec = codec->spec;
867 if (spec->jack_present)
868 mute = HDA_AMP_MUTE; /* mute internal speaker */
870 /* unmute internal speaker if necessary */
871 mute = snd_hda_codec_amp_read(codec, 0x1a, 0, HDA_OUTPUT, 0);
872 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
876 static void ad1986a_hp_automute(struct hda_codec *codec)
878 struct ad198x_spec *spec = codec->spec;
880 spec->jack_present = snd_hda_jack_detect(codec, 0x1a);
881 if (spec->inv_jack_detect)
882 spec->jack_present = !spec->jack_present;
883 ad1986a_update_hp(codec);
886 #define AD1986A_HP_EVENT 0x37
888 static void ad1986a_hp_unsol_event(struct hda_codec *codec, unsigned int res)
890 if ((res >> 26) != AD1986A_HP_EVENT)
892 ad1986a_hp_automute(codec);
895 static int ad1986a_hp_init(struct hda_codec *codec)
898 ad1986a_hp_automute(codec);
902 /* bind hp and internal speaker mute (with plug check) */
903 static int ad1986a_hp_master_sw_put(struct snd_kcontrol *kcontrol,
904 struct snd_ctl_elem_value *ucontrol)
906 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
907 int change = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
909 ad1986a_update_hp(codec);
913 static const struct snd_kcontrol_new ad1986a_automute_master_mixers[] = {
914 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol),
916 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
917 .name = "Master Playback Switch",
918 .subdevice = HDA_SUBDEV_AMP_FLAG,
919 .info = snd_hda_mixer_amp_switch_info,
920 .get = snd_hda_mixer_amp_switch_get,
921 .put = ad1986a_hp_master_sw_put,
922 .private_value = HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT),
929 * initialization verbs
931 static const struct hda_verb ad1986a_init_verbs[] = {
932 /* Front, Surround, CLFE DAC; mute as default */
933 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
934 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
935 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
937 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
938 /* HP, Line-Out, Surround, CLFE selectors */
939 {0x0a, AC_VERB_SET_CONNECT_SEL, 0x0},
940 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x0},
941 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0},
942 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
944 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x0},
945 /* Mic selector: Mic 1/2 pin */
946 {0x0f, AC_VERB_SET_CONNECT_SEL, 0x0},
947 /* Line-in selector: Line-in */
948 {0x10, AC_VERB_SET_CONNECT_SEL, 0x0},
950 {0x11, AC_VERB_SET_CONNECT_SEL, 0x0},
951 /* Record selector: mic */
952 {0x12, AC_VERB_SET_CONNECT_SEL, 0x0},
953 /* Mic, Phone, CD, Aux, Line-In amp; mute as default */
954 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
955 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
956 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
957 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
958 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
960 {0x18, AC_VERB_SET_CONNECT_SEL, 0x0},
961 /* HP, Line-Out, Surround, CLFE, Mono pins; mute as default */
962 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
963 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
964 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
965 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
966 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
968 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
969 /* Front, Surround, CLFE Pins */
970 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
971 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
972 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
974 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
976 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
977 /* Line, Aux, CD, Beep-In Pin */
978 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
979 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
980 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
981 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
982 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
986 static const struct hda_verb ad1986a_ch2_init[] = {
987 /* Surround out -> Line In */
988 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
989 /* Line-in selectors */
990 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x1 },
992 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
993 /* Mic selector, mix C/LFE (backmic) and Mic (frontmic) */
994 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 },
998 static const struct hda_verb ad1986a_ch4_init[] = {
999 /* Surround out -> Surround */
1000 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1001 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
1002 /* CLFE -> Mic in */
1003 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1004 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 },
1008 static const struct hda_verb ad1986a_ch6_init[] = {
1009 /* Surround out -> Surround out */
1010 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1011 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
1013 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1014 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x0 },
1018 static const struct hda_channel_mode ad1986a_modes[3] = {
1019 { 2, ad1986a_ch2_init },
1020 { 4, ad1986a_ch4_init },
1021 { 6, ad1986a_ch6_init },
1024 /* eapd initialization */
1025 static const struct hda_verb ad1986a_eapd_init_verbs[] = {
1026 {0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00 },
1030 /* pin sensing on HP jack */
1031 static const struct hda_verb ad1986a_hp_init_verbs[] = {
1032 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1986A_HP_EVENT},
1043 AD1986A_LAPTOP_EAPD,
1044 AD1986A_LAPTOP_AUTOMUTE,
1048 static const char * const ad1986a_models[AD1986A_MODELS] = {
1049 [AD1986A_AUTO] = "auto",
1050 [AD1986A_6STACK] = "6stack",
1051 [AD1986A_3STACK] = "3stack",
1052 [AD1986A_LAPTOP] = "laptop",
1053 [AD1986A_LAPTOP_EAPD] = "laptop-eapd",
1054 [AD1986A_LAPTOP_AUTOMUTE] = "laptop-automute",
1057 static const struct snd_pci_quirk ad1986a_cfg_tbl[] = {
1058 SND_PCI_QUIRK(0x103c, 0x30af, "HP B2800", AD1986A_LAPTOP_EAPD),
1059 SND_PCI_QUIRK(0x1043, 0x817f, "ASUS P5", AD1986A_3STACK),
1060 SND_PCI_QUIRK(0x1043, 0x818f, "ASUS P5", AD1986A_LAPTOP),
1061 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS P5", AD1986A_3STACK),
1062 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS M2N", AD1986A_3STACK),
1063 SND_PCI_QUIRK(0x1043, 0x8234, "ASUS M2N", AD1986A_3STACK),
1064 SND_PCI_QUIRK(0x10de, 0xcb84, "ASUS A8N-VM", AD1986A_3STACK),
1065 SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP),
1066 SND_PCI_QUIRK(0x17aa, 0x1011, "Lenovo M55", AD1986A_LAPTOP),
1067 SND_PCI_QUIRK(0x17aa, 0x1017, "Lenovo A60", AD1986A_3STACK),
1072 static const struct hda_amp_list ad1986a_loopbacks[] = {
1073 { 0x13, HDA_OUTPUT, 0 }, /* Mic */
1074 { 0x14, HDA_OUTPUT, 0 }, /* Phone */
1075 { 0x15, HDA_OUTPUT, 0 }, /* CD */
1076 { 0x16, HDA_OUTPUT, 0 }, /* Aux */
1077 { 0x17, HDA_OUTPUT, 0 }, /* Line */
1082 static int is_jack_available(struct hda_codec *codec, hda_nid_t nid)
1084 unsigned int conf = snd_hda_codec_get_pincfg(codec, nid);
1085 return get_defcfg_connect(conf) != AC_JACK_PORT_NONE;
1087 #endif /* ENABLE_AD_STATIC_QUIRKS */
1089 static int alloc_ad_spec(struct hda_codec *codec)
1091 struct ad198x_spec *spec;
1093 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1097 snd_hda_gen_spec_init(&spec->gen);
1102 * AD1986A fixup codes
1105 /* Lenovo N100 seems to report the reversed bit for HP jack-sensing */
1106 static void ad_fixup_inv_jack_detect(struct hda_codec *codec,
1107 const struct hda_fixup *fix, int action)
1109 if (action == HDA_FIXUP_ACT_PRE_PROBE)
1110 codec->inv_jack_detect = 1;
1114 AD1986A_FIXUP_INV_JACK_DETECT,
1115 AD1986A_FIXUP_ULTRA,
1116 AD1986A_FIXUP_SAMSUNG,
1119 static const struct hda_fixup ad1986a_fixups[] = {
1120 [AD1986A_FIXUP_INV_JACK_DETECT] = {
1121 .type = HDA_FIXUP_FUNC,
1122 .v.func = ad_fixup_inv_jack_detect,
1124 [AD1986A_FIXUP_ULTRA] = {
1125 .type = HDA_FIXUP_PINS,
1126 .v.pins = (const struct hda_pintbl[]) {
1127 { 0x1b, 0x90170110 }, /* speaker */
1128 { 0x1d, 0x90a7013e }, /* int mic */
1132 [AD1986A_FIXUP_SAMSUNG] = {
1133 .type = HDA_FIXUP_PINS,
1134 .v.pins = (const struct hda_pintbl[]) {
1135 { 0x1b, 0x90170110 }, /* speaker */
1136 { 0x1d, 0x90a7013e }, /* int mic */
1137 { 0x20, 0x411111f0 }, /* N/A */
1138 { 0x24, 0x411111f0 }, /* N/A */
1144 static const struct snd_pci_quirk ad1986a_fixup_tbl[] = {
1145 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc000, "Samsung", AD1986A_FIXUP_SAMSUNG),
1146 SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_FIXUP_ULTRA),
1147 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo N100", AD1986A_FIXUP_INV_JACK_DETECT),
1153 static int ad1986a_parse_auto_config(struct hda_codec *codec)
1156 struct ad198x_spec *spec;
1158 err = alloc_ad_spec(codec);
1163 /* AD1986A has the inverted EAPD implementation */
1164 codec->inv_eapd = 1;
1166 spec->gen.mixer_nid = 0x07;
1167 spec->gen.beep_nid = 0x19;
1168 set_beep_amp(spec, 0x18, 0, HDA_OUTPUT);
1170 /* AD1986A has a hardware problem that it can't share a stream
1171 * with multiple output pins. The copy of front to surrounds
1172 * causes noisy or silent outputs at a certain timing, e.g.
1173 * changing the volume.
1174 * So, let's disable the shared stream.
1176 spec->gen.multiout.no_share_stream = 1;
1178 snd_hda_pick_fixup(codec, NULL, ad1986a_fixup_tbl, ad1986a_fixups);
1179 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1181 err = ad198x_parse_auto_config(codec);
1183 snd_hda_gen_free(codec);
1187 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
1192 #ifdef ENABLE_AD_STATIC_QUIRKS
1193 static int patch_ad1986a(struct hda_codec *codec)
1195 struct ad198x_spec *spec;
1196 int err, board_config;
1198 board_config = snd_hda_check_board_config(codec, AD1986A_MODELS,
1201 if (board_config < 0) {
1202 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
1204 board_config = AD1986A_AUTO;
1207 if (board_config == AD1986A_AUTO)
1208 return ad1986a_parse_auto_config(codec);
1210 err = alloc_ad_spec(codec);
1215 err = snd_hda_attach_beep_device(codec, 0x19);
1220 set_beep_amp(spec, 0x18, 0, HDA_OUTPUT);
1222 spec->multiout.max_channels = 6;
1223 spec->multiout.num_dacs = ARRAY_SIZE(ad1986a_dac_nids);
1224 spec->multiout.dac_nids = ad1986a_dac_nids;
1225 spec->multiout.dig_out_nid = AD1986A_SPDIF_OUT;
1226 spec->num_adc_nids = 1;
1227 spec->adc_nids = ad1986a_adc_nids;
1228 spec->capsrc_nids = ad1986a_capsrc_nids;
1229 spec->input_mux = &ad1986a_capture_source;
1230 spec->num_mixers = 1;
1231 spec->mixers[0] = ad1986a_mixers;
1232 spec->num_init_verbs = 1;
1233 spec->init_verbs[0] = ad1986a_init_verbs;
1235 spec->loopback.amplist = ad1986a_loopbacks;
1237 spec->vmaster_nid = 0x1b;
1238 codec->inv_eapd = 1; /* AD1986A has the inverted EAPD implementation */
1240 codec->patch_ops = ad198x_patch_ops;
1242 /* override some parameters */
1243 switch (board_config) {
1244 case AD1986A_3STACK:
1245 spec->num_mixers = 2;
1246 spec->mixers[1] = ad1986a_3st_mixers;
1247 spec->num_init_verbs = 2;
1248 spec->init_verbs[1] = ad1986a_ch2_init;
1249 spec->channel_mode = ad1986a_modes;
1250 spec->num_channel_mode = ARRAY_SIZE(ad1986a_modes);
1251 spec->need_dac_fix = 1;
1252 spec->multiout.max_channels = 2;
1253 spec->multiout.num_dacs = 1;
1255 case AD1986A_LAPTOP:
1256 spec->mixers[0] = ad1986a_laptop_mixers;
1257 spec->multiout.max_channels = 2;
1258 spec->multiout.num_dacs = 1;
1259 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
1261 case AD1986A_LAPTOP_EAPD:
1262 spec->num_mixers = 3;
1263 spec->mixers[0] = ad1986a_laptop_master_mixers;
1264 spec->mixers[1] = ad1986a_laptop_eapd_mixers;
1265 spec->mixers[2] = ad1986a_laptop_intmic_mixers;
1266 spec->num_init_verbs = 2;
1267 spec->init_verbs[1] = ad1986a_eapd_init_verbs;
1268 spec->multiout.max_channels = 2;
1269 spec->multiout.num_dacs = 1;
1270 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
1271 if (!is_jack_available(codec, 0x25))
1272 spec->multiout.dig_out_nid = 0;
1273 spec->input_mux = &ad1986a_laptop_eapd_capture_source;
1275 case AD1986A_LAPTOP_AUTOMUTE:
1276 spec->num_mixers = 3;
1277 spec->mixers[0] = ad1986a_automute_master_mixers;
1278 spec->mixers[1] = ad1986a_laptop_eapd_mixers;
1279 spec->mixers[2] = ad1986a_laptop_intmic_mixers;
1280 spec->num_init_verbs = 3;
1281 spec->init_verbs[1] = ad1986a_eapd_init_verbs;
1282 spec->init_verbs[2] = ad1986a_hp_init_verbs;
1283 spec->multiout.max_channels = 2;
1284 spec->multiout.num_dacs = 1;
1285 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
1286 if (!is_jack_available(codec, 0x25))
1287 spec->multiout.dig_out_nid = 0;
1288 spec->input_mux = &ad1986a_laptop_eapd_capture_source;
1289 codec->patch_ops.unsol_event = ad1986a_hp_unsol_event;
1290 codec->patch_ops.init = ad1986a_hp_init;
1291 /* Lenovo N100 seems to report the reversed bit
1292 * for HP jack-sensing
1294 spec->inv_jack_detect = 1;
1298 /* AD1986A has a hardware problem that it can't share a stream
1299 * with multiple output pins. The copy of front to surrounds
1300 * causes noisy or silent outputs at a certain timing, e.g.
1301 * changing the volume.
1302 * So, let's disable the shared stream.
1304 spec->multiout.no_share_stream = 1;
1306 codec->no_trigger_sense = 1;
1307 codec->no_sticky_stream = 1;
1311 #else /* ENABLE_AD_STATIC_QUIRKS */
1312 #define patch_ad1986a ad1986a_parse_auto_config
1313 #endif /* ENABLE_AD_STATIC_QUIRKS */
1320 * SPDIF mux control for AD1983 auto-parser
1322 static int ad1983_auto_smux_enum_info(struct snd_kcontrol *kcontrol,
1323 struct snd_ctl_elem_info *uinfo)
1325 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1326 struct ad198x_spec *spec = codec->spec;
1327 static const char * const texts2[] = { "PCM", "ADC" };
1328 static const char * const texts3[] = { "PCM", "ADC1", "ADC2" };
1329 hda_nid_t dig_out = spec->gen.multiout.dig_out_nid;
1330 int num_conns = snd_hda_get_num_conns(codec, dig_out);
1333 return snd_hda_enum_helper_info(kcontrol, uinfo, 2, texts2);
1334 else if (num_conns == 3)
1335 return snd_hda_enum_helper_info(kcontrol, uinfo, 3, texts3);
1340 static int ad1983_auto_smux_enum_get(struct snd_kcontrol *kcontrol,
1341 struct snd_ctl_elem_value *ucontrol)
1343 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1344 struct ad198x_spec *spec = codec->spec;
1346 ucontrol->value.enumerated.item[0] = spec->cur_smux;
1350 static int ad1983_auto_smux_enum_put(struct snd_kcontrol *kcontrol,
1351 struct snd_ctl_elem_value *ucontrol)
1353 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1354 struct ad198x_spec *spec = codec->spec;
1355 unsigned int val = ucontrol->value.enumerated.item[0];
1356 hda_nid_t dig_out = spec->gen.multiout.dig_out_nid;
1357 int num_conns = snd_hda_get_num_conns(codec, dig_out);
1359 if (val >= num_conns)
1361 if (spec->cur_smux == val)
1363 spec->cur_smux = val;
1364 snd_hda_codec_write_cache(codec, dig_out, 0,
1365 AC_VERB_SET_CONNECT_SEL, val);
1369 static struct snd_kcontrol_new ad1983_auto_smux_mixer = {
1370 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1371 .name = "IEC958 Playback Source",
1372 .info = ad1983_auto_smux_enum_info,
1373 .get = ad1983_auto_smux_enum_get,
1374 .put = ad1983_auto_smux_enum_put,
1377 static int ad1983_add_spdif_mux_ctl(struct hda_codec *codec)
1379 struct ad198x_spec *spec = codec->spec;
1380 hda_nid_t dig_out = spec->gen.multiout.dig_out_nid;
1385 num_conns = snd_hda_get_num_conns(codec, dig_out);
1386 if (num_conns != 2 && num_conns != 3)
1388 if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &ad1983_auto_smux_mixer))
1393 static int patch_ad1983(struct hda_codec *codec)
1395 struct ad198x_spec *spec;
1398 err = alloc_ad_spec(codec);
1403 spec->gen.beep_nid = 0x10;
1404 set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
1405 err = ad198x_parse_auto_config(codec);
1408 err = ad1983_add_spdif_mux_ctl(codec);
1414 snd_hda_gen_free(codec);
1420 * AD1981 HD specific
1423 /* follow EAPD via vmaster hook */
1424 static void ad_vmaster_eapd_hook(void *private_data, int enabled)
1426 struct hda_codec *codec = private_data;
1427 struct ad198x_spec *spec = codec->spec;
1429 if (!spec->eapd_nid)
1431 snd_hda_codec_update_cache(codec, spec->eapd_nid, 0,
1432 AC_VERB_SET_EAPD_BTLENABLE,
1433 enabled ? 0x02 : 0x00);
1436 static void ad1981_fixup_hp_eapd(struct hda_codec *codec,
1437 const struct hda_fixup *fix, int action)
1439 struct ad198x_spec *spec = codec->spec;
1441 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
1442 spec->gen.vmaster_mute.hook = ad_vmaster_eapd_hook;
1443 spec->eapd_nid = 0x05;
1447 /* set the upper-limit for mixer amp to 0dB for avoiding the possible
1448 * damage by overloading
1450 static void ad1981_fixup_amp_override(struct hda_codec *codec,
1451 const struct hda_fixup *fix, int action)
1453 if (action == HDA_FIXUP_ACT_PRE_PROBE)
1454 snd_hda_override_amp_caps(codec, 0x11, HDA_INPUT,
1455 (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
1456 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
1457 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
1458 (1 << AC_AMPCAP_MUTE_SHIFT));
1462 AD1981_FIXUP_AMP_OVERRIDE,
1463 AD1981_FIXUP_HP_EAPD,
1466 static const struct hda_fixup ad1981_fixups[] = {
1467 [AD1981_FIXUP_AMP_OVERRIDE] = {
1468 .type = HDA_FIXUP_FUNC,
1469 .v.func = ad1981_fixup_amp_override,
1471 [AD1981_FIXUP_HP_EAPD] = {
1472 .type = HDA_FIXUP_FUNC,
1473 .v.func = ad1981_fixup_hp_eapd,
1475 .chain_id = AD1981_FIXUP_AMP_OVERRIDE,
1479 static const struct snd_pci_quirk ad1981_fixup_tbl[] = {
1480 SND_PCI_QUIRK_VENDOR(0x1014, "Lenovo", AD1981_FIXUP_AMP_OVERRIDE),
1481 SND_PCI_QUIRK_VENDOR(0x103c, "HP", AD1981_FIXUP_HP_EAPD),
1482 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", AD1981_FIXUP_AMP_OVERRIDE),
1483 /* HP nx6320 (reversed SSID, H/W bug) */
1484 SND_PCI_QUIRK(0x30b0, 0x103c, "HP nx6320", AD1981_FIXUP_HP_EAPD),
1488 static int patch_ad1981(struct hda_codec *codec)
1490 struct ad198x_spec *spec;
1493 err = alloc_ad_spec(codec);
1498 spec->gen.mixer_nid = 0x0e;
1499 spec->gen.beep_nid = 0x10;
1500 set_beep_amp(spec, 0x0d, 0, HDA_OUTPUT);
1502 snd_hda_pick_fixup(codec, NULL, ad1981_fixup_tbl, ad1981_fixups);
1503 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1505 err = ad198x_parse_auto_config(codec);
1508 err = ad1983_add_spdif_mux_ctl(codec);
1512 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
1517 snd_hda_gen_free(codec);
1525 * Output pins and routes
1527 * Pin Mix Sel DAC (*)
1528 * port-A 0x11 (mute/hp) <- 0x22 <- 0x37 <- 03/04/06
1529 * port-B 0x14 (mute/hp) <- 0x2b <- 0x30 <- 03/04/06
1530 * port-C 0x15 (mute) <- 0x2c <- 0x31 <- 05/0a
1531 * port-D 0x12 (mute/hp) <- 0x29 <- 04
1532 * port-E 0x17 (mute/hp) <- 0x26 <- 0x32 <- 05/0a
1533 * port-F 0x16 (mute) <- 0x2a <- 06
1534 * port-G 0x24 (mute) <- 0x27 <- 05
1535 * port-H 0x25 (mute) <- 0x28 <- 0a
1536 * mono 0x13 (mute/amp)<- 0x1e <- 0x36 <- 03/04/06
1538 * DAC0 = 03h, DAC1 = 04h, DAC2 = 05h, DAC3 = 06h, DAC4 = 0ah
1539 * (*) DAC2/3/4 are swapped to DAC3/4/2 on AD198A rev.2 due to a h/w bug.
1541 * Input pins and routes
1543 * pin boost mix input # / adc input #
1544 * port-A 0x11 -> 0x38 -> mix 2, ADC 0
1545 * port-B 0x14 -> 0x39 -> mix 0, ADC 1
1546 * port-C 0x15 -> 0x3a -> 33:0 - mix 1, ADC 2
1547 * port-D 0x12 -> 0x3d -> mix 3, ADC 8
1548 * port-E 0x17 -> 0x3c -> 34:0 - mix 4, ADC 4
1549 * port-F 0x16 -> 0x3b -> mix 5, ADC 3
1550 * port-G 0x24 -> N/A -> 33:1 - mix 1, 34:1 - mix 4, ADC 6
1551 * port-H 0x25 -> N/A -> 33:2 - mix 1, 34:2 - mix 4, ADC 7
1555 * 6stack - front/surr/CLFE/side/opt DACs - 04/06/05/0a/03
1556 * 3stack - front/surr/CLFE/opt DACs - 04/05/0a/03
1558 * Inputs of Analog Mix (0x20)
1559 * 0:Port-B (front mic)
1560 * 1:Port-C/G/H (line-in)
1562 * 3:Port-D (line-in/2)
1563 * 4:Port-E/G/H (mic-in)
1564 * 5:Port-F (mic2-in)
1570 * 1:Port-B (front mic-in)
1571 * 2:Port-C (line-in)
1572 * 3:Port-F (mic2-in)
1577 * 8:Port-D (line-in/2)
1580 * Proposed pin assignments by the datasheet
1583 * Port-A front headphone
1593 * Port-A front headphone
1595 * C rear line-in/surround
1597 * E rear mic-in/CLFE
1603 * D internal speaker (with EAPD)
1604 * E/F quad mic array
1607 #ifdef ENABLE_AD_STATIC_QUIRKS
1608 static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol,
1609 struct snd_ctl_elem_info *uinfo)
1611 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1612 struct ad198x_spec *spec = codec->spec;
1613 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
1614 spec->num_channel_mode);
1617 static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol,
1618 struct snd_ctl_elem_value *ucontrol)
1620 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1621 struct ad198x_spec *spec = codec->spec;
1622 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
1623 spec->num_channel_mode, spec->multiout.max_channels);
1626 static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol,
1627 struct snd_ctl_elem_value *ucontrol)
1629 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1630 struct ad198x_spec *spec = codec->spec;
1631 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
1632 spec->num_channel_mode,
1633 &spec->multiout.max_channels);
1634 if (err >= 0 && spec->need_dac_fix)
1635 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
1638 #endif /* ENABLE_AD_STATIC_QUIRKS */
1640 static int ad1988_auto_smux_enum_info(struct snd_kcontrol *kcontrol,
1641 struct snd_ctl_elem_info *uinfo)
1643 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1644 static const char * const texts[] = {
1645 "PCM", "ADC1", "ADC2", "ADC3",
1647 int num_conns = snd_hda_get_num_conns(codec, 0x0b) + 1;
1650 return snd_hda_enum_helper_info(kcontrol, uinfo, num_conns, texts);
1653 static int ad1988_auto_smux_enum_get(struct snd_kcontrol *kcontrol,
1654 struct snd_ctl_elem_value *ucontrol)
1656 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1657 struct ad198x_spec *spec = codec->spec;
1659 ucontrol->value.enumerated.item[0] = spec->cur_smux;
1663 static int ad1988_auto_smux_enum_put(struct snd_kcontrol *kcontrol,
1664 struct snd_ctl_elem_value *ucontrol)
1666 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1667 struct ad198x_spec *spec = codec->spec;
1668 unsigned int val = ucontrol->value.enumerated.item[0];
1669 struct nid_path *path;
1670 int num_conns = snd_hda_get_num_conns(codec, 0x0b) + 1;
1672 if (val >= num_conns)
1674 if (spec->cur_smux == val)
1677 mutex_lock(&codec->control_mutex);
1678 codec->cached_write = 1;
1679 path = snd_hda_get_path_from_idx(codec,
1680 spec->smux_paths[spec->cur_smux]);
1682 snd_hda_activate_path(codec, path, false, true);
1683 path = snd_hda_get_path_from_idx(codec, spec->smux_paths[val]);
1685 snd_hda_activate_path(codec, path, true, true);
1686 spec->cur_smux = val;
1687 codec->cached_write = 0;
1688 mutex_unlock(&codec->control_mutex);
1689 snd_hda_codec_flush_cache(codec); /* flush the updates */
1693 static struct snd_kcontrol_new ad1988_auto_smux_mixer = {
1694 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1695 .name = "IEC958 Playback Source",
1696 .info = ad1988_auto_smux_enum_info,
1697 .get = ad1988_auto_smux_enum_get,
1698 .put = ad1988_auto_smux_enum_put,
1701 static int ad1988_auto_init(struct hda_codec *codec)
1703 struct ad198x_spec *spec = codec->spec;
1706 err = snd_hda_gen_init(codec);
1709 if (!spec->gen.autocfg.dig_outs)
1712 for (i = 0; i < 4; i++) {
1713 struct nid_path *path;
1714 path = snd_hda_get_path_from_idx(codec, spec->smux_paths[i]);
1716 snd_hda_activate_path(codec, path, path->active, false);
1722 static int ad1988_add_spdif_mux_ctl(struct hda_codec *codec)
1724 struct ad198x_spec *spec = codec->spec;
1726 /* we create four static faked paths, since AD codecs have odd
1727 * widget connections regarding the SPDIF out source
1729 static struct nid_path fake_paths[4] = {
1732 .path = { 0x02, 0x1d, 0x1b },
1734 .multi = { 0, 0, 0 },
1738 .path = { 0x08, 0x0b, 0x1d, 0x1b },
1739 .idx = { 0, 0, 1, 0 },
1740 .multi = { 0, 1, 0, 0 },
1744 .path = { 0x09, 0x0b, 0x1d, 0x1b },
1745 .idx = { 0, 1, 1, 0 },
1746 .multi = { 0, 1, 0, 0 },
1750 .path = { 0x0f, 0x0b, 0x1d, 0x1b },
1751 .idx = { 0, 2, 1, 0 },
1752 .multi = { 0, 1, 0, 0 },
1756 /* SPDIF source mux appears to be present only on AD1988A */
1757 if (!spec->gen.autocfg.dig_outs ||
1758 get_wcaps_type(get_wcaps(codec, 0x1d)) != AC_WID_AUD_MIX)
1761 num_conns = snd_hda_get_num_conns(codec, 0x0b) + 1;
1762 if (num_conns != 3 && num_conns != 4)
1765 for (i = 0; i < num_conns; i++) {
1766 struct nid_path *path = snd_array_new(&spec->gen.paths);
1769 *path = fake_paths[i];
1772 spec->smux_paths[i] = snd_hda_get_path_idx(codec, path);
1775 if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &ad1988_auto_smux_mixer))
1778 codec->patch_ops.init = ad1988_auto_init;
1787 AD1988_FIXUP_6STACK_DIG,
1790 static const struct hda_fixup ad1988_fixups[] = {
1791 [AD1988_FIXUP_6STACK_DIG] = {
1792 .type = HDA_FIXUP_PINS,
1793 .v.pins = (const struct hda_pintbl[]) {
1794 { 0x11, 0x02214130 }, /* front-hp */
1795 { 0x12, 0x01014010 }, /* line-out */
1796 { 0x14, 0x02a19122 }, /* front-mic */
1797 { 0x15, 0x01813021 }, /* line-in */
1798 { 0x16, 0x01011012 }, /* line-out */
1799 { 0x17, 0x01a19020 }, /* mic */
1800 { 0x1b, 0x0145f1f0 }, /* SPDIF */
1801 { 0x24, 0x01016011 }, /* line-out */
1802 { 0x25, 0x01012013 }, /* line-out */
1808 static const struct hda_model_fixup ad1988_fixup_models[] = {
1809 { .id = AD1988_FIXUP_6STACK_DIG, .name = "6stack-dig" },
1813 static int patch_ad1988(struct hda_codec *codec)
1815 struct ad198x_spec *spec;
1818 err = alloc_ad_spec(codec);
1823 spec->gen.mixer_nid = 0x20;
1824 spec->gen.mixer_merge_nid = 0x21;
1825 spec->gen.beep_nid = 0x10;
1826 set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
1828 snd_hda_pick_fixup(codec, ad1988_fixup_models, NULL, ad1988_fixups);
1829 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1831 err = ad198x_parse_auto_config(codec);
1834 err = ad1988_add_spdif_mux_ctl(codec);
1838 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
1843 snd_hda_gen_free(codec);
1851 * port-B - front line/mic-in
1852 * port-E - aux in/out
1853 * port-F - aux in/out
1854 * port-C - rear line/mic-in
1855 * port-D - rear line/hp-out
1856 * port-A - front line/hp-out
1858 * AD1984 = AD1884 + two digital mic-ins
1860 * AD1883 / AD1884A / AD1984A / AD1984B
1862 * port-B (0x14) - front mic-in
1863 * port-E (0x1c) - rear mic-in
1864 * port-F (0x16) - CD / ext out
1865 * port-C (0x15) - rear line-in
1866 * port-D (0x12) - rear line-out
1867 * port-A (0x11) - front hp-out
1869 * AD1984A = AD1884A + digital-mic
1870 * AD1883 = equivalent with AD1984A
1871 * AD1984B = AD1984A + extra SPDIF-out
1874 /* set the upper-limit for mixer amp to 0dB for avoiding the possible
1875 * damage by overloading
1877 static void ad1884_fixup_amp_override(struct hda_codec *codec,
1878 const struct hda_fixup *fix, int action)
1880 if (action == HDA_FIXUP_ACT_PRE_PROBE)
1881 snd_hda_override_amp_caps(codec, 0x20, HDA_INPUT,
1882 (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
1883 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
1884 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
1885 (1 << AC_AMPCAP_MUTE_SHIFT));
1888 /* toggle GPIO1 according to the mute state */
1889 static void ad1884_vmaster_hp_gpio_hook(void *private_data, int enabled)
1891 struct hda_codec *codec = private_data;
1892 struct ad198x_spec *spec = codec->spec;
1895 ad_vmaster_eapd_hook(private_data, enabled);
1896 snd_hda_codec_update_cache(codec, 0x01, 0,
1897 AC_VERB_SET_GPIO_DATA,
1898 enabled ? 0x00 : 0x02);
1901 static void ad1884_fixup_hp_eapd(struct hda_codec *codec,
1902 const struct hda_fixup *fix, int action)
1904 struct ad198x_spec *spec = codec->spec;
1905 static const struct hda_verb gpio_init_verbs[] = {
1906 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1907 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1908 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
1913 case HDA_FIXUP_ACT_PRE_PROBE:
1914 spec->gen.vmaster_mute.hook = ad1884_vmaster_hp_gpio_hook;
1915 snd_hda_sequence_write_cache(codec, gpio_init_verbs);
1917 case HDA_FIXUP_ACT_PROBE:
1918 if (spec->gen.autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
1919 spec->eapd_nid = spec->gen.autocfg.line_out_pins[0];
1921 spec->eapd_nid = spec->gen.autocfg.speaker_pins[0];
1926 /* set magic COEFs for dmic */
1927 static const struct hda_verb ad1884_dmic_init_verbs[] = {
1928 {0x01, AC_VERB_SET_COEF_INDEX, 0x13f7},
1929 {0x01, AC_VERB_SET_PROC_COEF, 0x08},
1934 AD1884_FIXUP_AMP_OVERRIDE,
1935 AD1884_FIXUP_HP_EAPD,
1936 AD1884_FIXUP_DMIC_COEF,
1937 AD1884_FIXUP_HP_TOUCHSMART,
1940 static const struct hda_fixup ad1884_fixups[] = {
1941 [AD1884_FIXUP_AMP_OVERRIDE] = {
1942 .type = HDA_FIXUP_FUNC,
1943 .v.func = ad1884_fixup_amp_override,
1945 [AD1884_FIXUP_HP_EAPD] = {
1946 .type = HDA_FIXUP_FUNC,
1947 .v.func = ad1884_fixup_hp_eapd,
1949 .chain_id = AD1884_FIXUP_AMP_OVERRIDE,
1951 [AD1884_FIXUP_DMIC_COEF] = {
1952 .type = HDA_FIXUP_VERBS,
1953 .v.verbs = ad1884_dmic_init_verbs,
1955 [AD1884_FIXUP_HP_TOUCHSMART] = {
1956 .type = HDA_FIXUP_VERBS,
1957 .v.verbs = ad1884_dmic_init_verbs,
1959 .chain_id = AD1884_FIXUP_HP_EAPD,
1963 static const struct snd_pci_quirk ad1884_fixup_tbl[] = {
1964 SND_PCI_QUIRK(0x103c, 0x2a82, "HP Touchsmart", AD1884_FIXUP_HP_TOUCHSMART),
1965 SND_PCI_QUIRK_VENDOR(0x103c, "HP", AD1884_FIXUP_HP_EAPD),
1966 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo Thinkpad", AD1884_FIXUP_DMIC_COEF),
1971 static int patch_ad1884(struct hda_codec *codec)
1973 struct ad198x_spec *spec;
1976 err = alloc_ad_spec(codec);
1981 spec->gen.mixer_nid = 0x20;
1982 spec->gen.beep_nid = 0x10;
1983 set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
1985 snd_hda_pick_fixup(codec, NULL, ad1884_fixup_tbl, ad1884_fixups);
1986 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1988 err = ad198x_parse_auto_config(codec);
1991 err = ad1983_add_spdif_mux_ctl(codec);
1995 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2000 snd_hda_gen_free(codec);
2007 * port-A - front hp-out
2008 * port-B - front mic-in
2009 * port-C - rear line-in, shared surr-out (3stack)
2010 * port-D - rear line-out
2011 * port-E - rear mic-in, shared clfe-out (3stack)
2012 * port-F - rear surr-out (6stack)
2013 * port-G - rear clfe-out (6stack)
2016 static int patch_ad1882(struct hda_codec *codec)
2018 struct ad198x_spec *spec;
2021 err = alloc_ad_spec(codec);
2026 spec->gen.mixer_nid = 0x20;
2027 spec->gen.mixer_merge_nid = 0x21;
2028 spec->gen.beep_nid = 0x10;
2029 set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
2030 err = ad198x_parse_auto_config(codec);
2033 err = ad1988_add_spdif_mux_ctl(codec);
2039 snd_hda_gen_free(codec);
2047 static const struct hda_codec_preset snd_hda_preset_analog[] = {
2048 { .id = 0x11d4184a, .name = "AD1884A", .patch = patch_ad1884 },
2049 { .id = 0x11d41882, .name = "AD1882", .patch = patch_ad1882 },
2050 { .id = 0x11d41883, .name = "AD1883", .patch = patch_ad1884 },
2051 { .id = 0x11d41884, .name = "AD1884", .patch = patch_ad1884 },
2052 { .id = 0x11d4194a, .name = "AD1984A", .patch = patch_ad1884 },
2053 { .id = 0x11d4194b, .name = "AD1984B", .patch = patch_ad1884 },
2054 { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 },
2055 { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 },
2056 { .id = 0x11d41984, .name = "AD1984", .patch = patch_ad1884 },
2057 { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a },
2058 { .id = 0x11d41988, .name = "AD1988", .patch = patch_ad1988 },
2059 { .id = 0x11d4198b, .name = "AD1988B", .patch = patch_ad1988 },
2060 { .id = 0x11d4882a, .name = "AD1882A", .patch = patch_ad1882 },
2061 { .id = 0x11d4989a, .name = "AD1989A", .patch = patch_ad1988 },
2062 { .id = 0x11d4989b, .name = "AD1989B", .patch = patch_ad1988 },
2066 MODULE_ALIAS("snd-hda-codec-id:11d4*");
2068 MODULE_LICENSE("GPL");
2069 MODULE_DESCRIPTION("Analog Devices HD-audio codec");
2071 static struct hda_codec_preset_list analog_list = {
2072 .preset = snd_hda_preset_analog,
2073 .owner = THIS_MODULE,
2076 static int __init patch_analog_init(void)
2078 return snd_hda_add_codec_preset(&analog_list);
2081 static void __exit patch_analog_exit(void)
2083 snd_hda_delete_codec_preset(&analog_list);
2086 module_init(patch_analog_init)
2087 module_exit(patch_analog_exit)