2 * HD audio interface patch for AD1981HD, AD1983, AD1986A, AD1988
4 * Copyright (c) 2005 Takashi Iwai <tiwai@suse.de>
6 * This driver is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This driver is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include <sound/driver.h>
22 #include <linux/init.h>
23 #include <linux/delay.h>
24 #include <linux/slab.h>
25 #include <linux/pci.h>
26 #include <linux/mutex.h>
28 #include <sound/core.h>
29 #include "hda_codec.h"
30 #include "hda_local.h"
33 struct snd_kcontrol_new *mixers[5];
36 const struct hda_verb *init_verbs[5]; /* initialization verbs
37 * don't forget NULL termination!
39 unsigned int num_init_verbs;
42 struct hda_multi_out multiout; /* playback set-up
43 * max_channels, dacs must be set
44 * dig_out_nid and hp_nid are optional
46 unsigned int cur_eapd;
47 unsigned int need_dac_fix;
50 unsigned int num_adc_nids;
52 hda_nid_t dig_in_nid; /* digital-in NID; optional */
55 const struct hda_input_mux *input_mux;
56 hda_nid_t *capsrc_nids;
57 unsigned int cur_mux[3];
60 const struct hda_channel_mode *channel_mode;
64 struct hda_pcm pcm_rec[2]; /* used in alc_build_pcms() */
66 struct mutex amp_mutex; /* PCM volume/mute control mutex */
67 unsigned int spdif_route;
69 /* dynamic controls, init_verbs and input_mux */
70 struct auto_pin_cfg autocfg;
71 unsigned int num_kctl_alloc, num_kctl_used;
72 struct snd_kcontrol_new *kctl_alloc;
73 struct hda_input_mux private_imux;
74 hda_nid_t private_dac_nids[4];
78 * input MUX handling (common part)
80 static int ad198x_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
82 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
83 struct ad198x_spec *spec = codec->spec;
85 return snd_hda_input_mux_info(spec->input_mux, uinfo);
88 static int ad198x_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
90 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
91 struct ad198x_spec *spec = codec->spec;
92 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
94 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
98 static int ad198x_mux_enum_put(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 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
105 spec->capsrc_nids[adc_idx],
106 &spec->cur_mux[adc_idx]);
110 * initialization (common callbacks)
112 static int ad198x_init(struct hda_codec *codec)
114 struct ad198x_spec *spec = codec->spec;
117 for (i = 0; i < spec->num_init_verbs; i++)
118 snd_hda_sequence_write(codec, spec->init_verbs[i]);
122 static int ad198x_build_controls(struct hda_codec *codec)
124 struct ad198x_spec *spec = codec->spec;
128 for (i = 0; i < spec->num_mixers; i++) {
129 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
133 if (spec->multiout.dig_out_nid) {
134 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
138 if (spec->dig_in_nid) {
139 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
147 * Analog playback callbacks
149 static int ad198x_playback_pcm_open(struct hda_pcm_stream *hinfo,
150 struct hda_codec *codec,
151 struct snd_pcm_substream *substream)
153 struct ad198x_spec *spec = codec->spec;
154 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
157 static int ad198x_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
158 struct hda_codec *codec,
159 unsigned int stream_tag,
161 struct snd_pcm_substream *substream)
163 struct ad198x_spec *spec = codec->spec;
164 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
168 static int ad198x_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
169 struct hda_codec *codec,
170 struct snd_pcm_substream *substream)
172 struct ad198x_spec *spec = codec->spec;
173 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
179 static int ad198x_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
180 struct hda_codec *codec,
181 struct snd_pcm_substream *substream)
183 struct ad198x_spec *spec = codec->spec;
184 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
187 static int ad198x_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
188 struct hda_codec *codec,
189 struct snd_pcm_substream *substream)
191 struct ad198x_spec *spec = codec->spec;
192 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
198 static int ad198x_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
199 struct hda_codec *codec,
200 unsigned int stream_tag,
202 struct snd_pcm_substream *substream)
204 struct ad198x_spec *spec = codec->spec;
205 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
206 stream_tag, 0, format);
210 static int ad198x_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
211 struct hda_codec *codec,
212 struct snd_pcm_substream *substream)
214 struct ad198x_spec *spec = codec->spec;
215 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
223 static struct hda_pcm_stream ad198x_pcm_analog_playback = {
226 .channels_max = 6, /* changed later */
227 .nid = 0, /* fill later */
229 .open = ad198x_playback_pcm_open,
230 .prepare = ad198x_playback_pcm_prepare,
231 .cleanup = ad198x_playback_pcm_cleanup
235 static struct hda_pcm_stream ad198x_pcm_analog_capture = {
239 .nid = 0, /* fill later */
241 .prepare = ad198x_capture_pcm_prepare,
242 .cleanup = ad198x_capture_pcm_cleanup
246 static struct hda_pcm_stream ad198x_pcm_digital_playback = {
250 .nid = 0, /* fill later */
252 .open = ad198x_dig_playback_pcm_open,
253 .close = ad198x_dig_playback_pcm_close
257 static struct hda_pcm_stream ad198x_pcm_digital_capture = {
261 /* NID is set in alc_build_pcms */
264 static int ad198x_build_pcms(struct hda_codec *codec)
266 struct ad198x_spec *spec = codec->spec;
267 struct hda_pcm *info = spec->pcm_rec;
270 codec->pcm_info = info;
272 info->name = "AD198x Analog";
273 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_analog_playback;
274 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->multiout.max_channels;
275 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
276 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_analog_capture;
277 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adc_nids;
278 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
280 if (spec->multiout.dig_out_nid) {
283 info->name = "AD198x Digital";
284 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_digital_playback;
285 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
286 if (spec->dig_in_nid) {
287 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_digital_capture;
288 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
295 static void ad198x_free(struct hda_codec *codec)
297 struct ad198x_spec *spec = codec->spec;
300 if (spec->kctl_alloc) {
301 for (i = 0; i < spec->num_kctl_used; i++)
302 kfree(spec->kctl_alloc[i].name);
303 kfree(spec->kctl_alloc);
309 static int ad198x_resume(struct hda_codec *codec)
311 struct ad198x_spec *spec = codec->spec;
314 codec->patch_ops.init(codec);
315 for (i = 0; i < spec->num_mixers; i++)
316 snd_hda_resume_ctls(codec, spec->mixers[i]);
317 if (spec->multiout.dig_out_nid)
318 snd_hda_resume_spdif_out(codec);
319 if (spec->dig_in_nid)
320 snd_hda_resume_spdif_in(codec);
325 static struct hda_codec_ops ad198x_patch_ops = {
326 .build_controls = ad198x_build_controls,
327 .build_pcms = ad198x_build_pcms,
331 .resume = ad198x_resume,
338 * the private value = nid | (invert << 8)
340 static int ad198x_eapd_info(struct snd_kcontrol *kcontrol,
341 struct snd_ctl_elem_info *uinfo)
343 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
345 uinfo->value.integer.min = 0;
346 uinfo->value.integer.max = 1;
350 static int ad198x_eapd_get(struct snd_kcontrol *kcontrol,
351 struct snd_ctl_elem_value *ucontrol)
353 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
354 struct ad198x_spec *spec = codec->spec;
355 int invert = (kcontrol->private_value >> 8) & 1;
357 ucontrol->value.integer.value[0] = ! spec->cur_eapd;
359 ucontrol->value.integer.value[0] = spec->cur_eapd;
363 static int ad198x_eapd_put(struct snd_kcontrol *kcontrol,
364 struct snd_ctl_elem_value *ucontrol)
366 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
367 struct ad198x_spec *spec = codec->spec;
368 int invert = (kcontrol->private_value >> 8) & 1;
369 hda_nid_t nid = kcontrol->private_value & 0xff;
371 eapd = ucontrol->value.integer.value[0];
374 if (eapd == spec->cur_eapd && ! codec->in_resume)
376 spec->cur_eapd = eapd;
377 snd_hda_codec_write(codec, nid,
378 0, AC_VERB_SET_EAPD_BTLENABLE,
383 static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol,
384 struct snd_ctl_elem_info *uinfo);
385 static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol,
386 struct snd_ctl_elem_value *ucontrol);
387 static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol,
388 struct snd_ctl_elem_value *ucontrol);
395 #define AD1986A_SPDIF_OUT 0x02
396 #define AD1986A_FRONT_DAC 0x03
397 #define AD1986A_SURR_DAC 0x04
398 #define AD1986A_CLFE_DAC 0x05
399 #define AD1986A_ADC 0x06
401 static hda_nid_t ad1986a_dac_nids[3] = {
402 AD1986A_FRONT_DAC, AD1986A_SURR_DAC, AD1986A_CLFE_DAC
404 static hda_nid_t ad1986a_adc_nids[1] = { AD1986A_ADC };
405 static hda_nid_t ad1986a_capsrc_nids[1] = { 0x12 };
407 static struct hda_input_mux ad1986a_capture_source = {
423 * bind volumes/mutes of 3 DACs as a single PCM control for simplicity
426 #define ad1986a_pcm_amp_vol_info snd_hda_mixer_amp_volume_info
428 static int ad1986a_pcm_amp_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
430 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
431 struct ad198x_spec *ad = codec->spec;
433 mutex_lock(&ad->amp_mutex);
434 snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
435 mutex_unlock(&ad->amp_mutex);
439 static int ad1986a_pcm_amp_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
441 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
442 struct ad198x_spec *ad = codec->spec;
445 mutex_lock(&ad->amp_mutex);
446 for (i = 0; i < ARRAY_SIZE(ad1986a_dac_nids); i++) {
447 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(ad1986a_dac_nids[i], 3, 0, HDA_OUTPUT);
448 change |= snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
450 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT);
451 mutex_unlock(&ad->amp_mutex);
455 #define ad1986a_pcm_amp_sw_info snd_hda_mixer_amp_switch_info
457 static int ad1986a_pcm_amp_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
459 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
460 struct ad198x_spec *ad = codec->spec;
462 mutex_lock(&ad->amp_mutex);
463 snd_hda_mixer_amp_switch_get(kcontrol, ucontrol);
464 mutex_unlock(&ad->amp_mutex);
468 static int ad1986a_pcm_amp_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
470 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
471 struct ad198x_spec *ad = codec->spec;
474 mutex_lock(&ad->amp_mutex);
475 for (i = 0; i < ARRAY_SIZE(ad1986a_dac_nids); i++) {
476 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(ad1986a_dac_nids[i], 3, 0, HDA_OUTPUT);
477 change |= snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
479 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT);
480 mutex_unlock(&ad->amp_mutex);
487 static struct snd_kcontrol_new ad1986a_mixers[] = {
489 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
490 .name = "PCM Playback Volume",
491 .info = ad1986a_pcm_amp_vol_info,
492 .get = ad1986a_pcm_amp_vol_get,
493 .put = ad1986a_pcm_amp_vol_put,
494 .private_value = HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT)
497 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
498 .name = "PCM Playback Switch",
499 .info = ad1986a_pcm_amp_sw_info,
500 .get = ad1986a_pcm_amp_sw_get,
501 .put = ad1986a_pcm_amp_sw_put,
502 .private_value = HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT)
504 HDA_CODEC_VOLUME("Front Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
505 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
506 HDA_CODEC_VOLUME("Surround Playback Volume", 0x1c, 0x0, HDA_OUTPUT),
507 HDA_CODEC_MUTE("Surround Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
508 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x1d, 1, 0x0, HDA_OUTPUT),
509 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x1d, 2, 0x0, HDA_OUTPUT),
510 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x1d, 1, 0x0, HDA_OUTPUT),
511 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x1d, 2, 0x0, HDA_OUTPUT),
512 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT),
513 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
514 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT),
515 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT),
516 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT),
517 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT),
518 HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT),
519 HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT),
520 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
521 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
522 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT),
523 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT),
524 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
525 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT),
526 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
527 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
529 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
530 .name = "Capture Source",
531 .info = ad198x_mux_enum_info,
532 .get = ad198x_mux_enum_get,
533 .put = ad198x_mux_enum_put,
535 HDA_CODEC_MUTE("Stereo Downmix Switch", 0x09, 0x0, HDA_OUTPUT),
539 /* additional mixers for 3stack mode */
540 static struct snd_kcontrol_new ad1986a_3st_mixers[] = {
542 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
543 .name = "Channel Mode",
544 .info = ad198x_ch_mode_info,
545 .get = ad198x_ch_mode_get,
546 .put = ad198x_ch_mode_put,
551 /* laptop model - 2ch only */
552 static hda_nid_t ad1986a_laptop_dac_nids[1] = { AD1986A_FRONT_DAC };
554 static struct snd_kcontrol_new ad1986a_laptop_mixers[] = {
555 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
556 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
557 HDA_CODEC_VOLUME("Master Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
558 HDA_CODEC_MUTE("Master Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
559 /* HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT),
560 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT), */
561 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT),
562 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT),
563 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT),
564 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT),
565 HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT),
566 HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT),
567 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
568 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
569 /* HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT),
570 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT),
571 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
572 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), */
573 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
574 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
576 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
577 .name = "Capture Source",
578 .info = ad198x_mux_enum_info,
579 .get = ad198x_mux_enum_get,
580 .put = ad198x_mux_enum_put,
585 /* laptop-eapd model - 2ch only */
587 /* master controls both pins 0x1a and 0x1b */
588 static int ad1986a_laptop_master_vol_put(struct snd_kcontrol *kcontrol,
589 struct snd_ctl_elem_value *ucontrol)
591 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
592 long *valp = ucontrol->value.integer.value;
595 change = snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0,
596 0x7f, valp[0] & 0x7f);
597 change |= snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0,
598 0x7f, valp[1] & 0x7f);
599 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
600 0x7f, valp[0] & 0x7f);
601 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
602 0x7f, valp[1] & 0x7f);
606 static int ad1986a_laptop_master_sw_put(struct snd_kcontrol *kcontrol,
607 struct snd_ctl_elem_value *ucontrol)
609 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
610 long *valp = ucontrol->value.integer.value;
613 change = snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0,
614 0x80, valp[0] ? 0 : 0x80);
615 change |= snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0,
616 0x80, valp[1] ? 0 : 0x80);
617 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
618 0x80, valp[0] ? 0 : 0x80);
619 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
620 0x80, valp[1] ? 0 : 0x80);
624 static struct hda_input_mux ad1986a_laptop_eapd_capture_source = {
628 { "Internal Mic", 0x4 },
633 static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = {
635 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
636 .name = "Master Playback Volume",
637 .info = snd_hda_mixer_amp_volume_info,
638 .get = snd_hda_mixer_amp_volume_get,
639 .put = ad1986a_laptop_master_vol_put,
640 .private_value = HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT),
643 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
644 .name = "Master Playback Switch",
645 .info = snd_hda_mixer_amp_switch_info,
646 .get = snd_hda_mixer_amp_switch_get,
647 .put = ad1986a_laptop_master_sw_put,
648 .private_value = HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT),
650 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
651 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
652 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x0, HDA_OUTPUT),
653 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x0, HDA_OUTPUT),
654 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
655 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
656 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
657 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
659 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
660 .name = "Capture Source",
661 .info = ad198x_mux_enum_info,
662 .get = ad198x_mux_enum_get,
663 .put = ad198x_mux_enum_put,
666 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
667 .name = "External Amplifier",
668 .info = ad198x_eapd_info,
669 .get = ad198x_eapd_get,
670 .put = ad198x_eapd_put,
671 .private_value = 0x1b | (1 << 8), /* port-D, inversed */
677 * initialization verbs
679 static struct hda_verb ad1986a_init_verbs[] = {
680 /* Front, Surround, CLFE DAC; mute as default */
681 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
682 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
683 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
685 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
686 /* HP, Line-Out, Surround, CLFE selectors */
687 {0x0a, AC_VERB_SET_CONNECT_SEL, 0x0},
688 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x0},
689 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0},
690 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
692 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x0},
693 /* Mic selector: Mic 1/2 pin */
694 {0x0f, AC_VERB_SET_CONNECT_SEL, 0x0},
695 /* Line-in selector: Line-in */
696 {0x10, AC_VERB_SET_CONNECT_SEL, 0x0},
698 {0x11, AC_VERB_SET_CONNECT_SEL, 0x0},
699 /* Record selector: mic */
700 {0x12, AC_VERB_SET_CONNECT_SEL, 0x0},
701 /* Mic, Phone, CD, Aux, Line-In amp; mute as default */
702 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
703 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
704 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
705 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
706 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
708 {0x18, AC_VERB_SET_CONNECT_SEL, 0x0},
709 /* HP, Line-Out, Surround, CLFE, Mono pins; mute as default */
710 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
711 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
712 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
713 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
714 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
716 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
717 /* Front, Surround, CLFE Pins */
718 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
719 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
720 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
722 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
724 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
725 /* Line, Aux, CD, Beep-In Pin */
726 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
727 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
728 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
729 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
730 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
734 /* additional verbs for 3-stack model */
735 static struct hda_verb ad1986a_3st_init_verbs[] = {
736 /* Mic and line-in selectors */
737 {0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
738 {0x10, AC_VERB_SET_CONNECT_SEL, 0x1},
742 static struct hda_verb ad1986a_ch2_init[] = {
743 /* Surround out -> Line In */
744 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
745 { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
747 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
748 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
752 static struct hda_verb ad1986a_ch4_init[] = {
753 /* Surround out -> Surround */
754 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
755 { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
757 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
758 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
762 static struct hda_verb ad1986a_ch6_init[] = {
763 /* Surround out -> Surround out */
764 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
765 { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
767 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
768 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
772 static struct hda_channel_mode ad1986a_modes[3] = {
773 { 2, ad1986a_ch2_init },
774 { 4, ad1986a_ch4_init },
775 { 6, ad1986a_ch6_init },
778 /* eapd initialization */
779 static struct hda_verb ad1986a_eapd_init_verbs[] = {
780 {0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00},
785 enum { AD1986A_6STACK, AD1986A_3STACK, AD1986A_LAPTOP, AD1986A_LAPTOP_EAPD };
787 static struct hda_board_config ad1986a_cfg_tbl[] = {
788 { .modelname = "6stack", .config = AD1986A_6STACK },
789 { .modelname = "3stack", .config = AD1986A_3STACK },
790 { .pci_subvendor = 0x10de, .pci_subdevice = 0xcb84,
791 .config = AD1986A_3STACK }, /* ASUS A8N-VM CSM */
792 { .modelname = "laptop", .config = AD1986A_LAPTOP },
793 { .pci_subvendor = 0x144d, .pci_subdevice = 0xc01e,
794 .config = AD1986A_LAPTOP }, /* FSC V2060 */
795 { .pci_subvendor = 0x17c0, .pci_subdevice = 0x2017,
796 .config = AD1986A_LAPTOP }, /* Samsung M50 */
797 { .pci_subvendor = 0x1043, .pci_subdevice = 0x818f,
798 .config = AD1986A_LAPTOP }, /* ASUS P5GV-MX */
799 { .modelname = "laptop-eapd", .config = AD1986A_LAPTOP_EAPD },
800 { .pci_subvendor = 0x144d, .pci_subdevice = 0xc024,
801 .config = AD1986A_LAPTOP_EAPD }, /* Samsung R65-T2300 Charis */
802 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1153,
803 .config = AD1986A_LAPTOP_EAPD }, /* ASUS M9 */
804 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1213,
805 .config = AD1986A_LAPTOP_EAPD }, /* ASUS A6J */
806 { .pci_subvendor = 0x1043, .pci_subdevice = 0x11f7,
807 .config = AD1986A_LAPTOP_EAPD }, /* ASUS U5A */
808 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1297,
809 .config = AD1986A_LAPTOP_EAPD }, /* ASUS Z62F */
810 { .pci_subvendor = 0x103c, .pci_subdevice = 0x30af,
811 .config = AD1986A_LAPTOP_EAPD }, /* HP Compaq Presario B2800 */
815 static int patch_ad1986a(struct hda_codec *codec)
817 struct ad198x_spec *spec;
820 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
824 mutex_init(&spec->amp_mutex);
827 spec->multiout.max_channels = 6;
828 spec->multiout.num_dacs = ARRAY_SIZE(ad1986a_dac_nids);
829 spec->multiout.dac_nids = ad1986a_dac_nids;
830 spec->multiout.dig_out_nid = AD1986A_SPDIF_OUT;
831 spec->num_adc_nids = 1;
832 spec->adc_nids = ad1986a_adc_nids;
833 spec->capsrc_nids = ad1986a_capsrc_nids;
834 spec->input_mux = &ad1986a_capture_source;
835 spec->num_mixers = 1;
836 spec->mixers[0] = ad1986a_mixers;
837 spec->num_init_verbs = 1;
838 spec->init_verbs[0] = ad1986a_init_verbs;
840 codec->patch_ops = ad198x_patch_ops;
842 /* override some parameters */
843 board_config = snd_hda_check_board_config(codec, ad1986a_cfg_tbl);
844 switch (board_config) {
846 spec->num_mixers = 2;
847 spec->mixers[1] = ad1986a_3st_mixers;
848 spec->num_init_verbs = 3;
849 spec->init_verbs[1] = ad1986a_3st_init_verbs;
850 spec->init_verbs[2] = ad1986a_ch2_init;
851 spec->channel_mode = ad1986a_modes;
852 spec->num_channel_mode = ARRAY_SIZE(ad1986a_modes);
853 spec->need_dac_fix = 1;
854 spec->multiout.max_channels = 2;
855 spec->multiout.num_dacs = 1;
858 spec->mixers[0] = ad1986a_laptop_mixers;
859 spec->multiout.max_channels = 2;
860 spec->multiout.num_dacs = 1;
861 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
863 case AD1986A_LAPTOP_EAPD:
864 spec->mixers[0] = ad1986a_laptop_eapd_mixers;
865 spec->num_init_verbs = 2;
866 spec->init_verbs[1] = ad1986a_eapd_init_verbs;
867 spec->multiout.max_channels = 2;
868 spec->multiout.num_dacs = 1;
869 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
870 spec->multiout.dig_out_nid = 0;
871 spec->input_mux = &ad1986a_laptop_eapd_capture_source;
882 #define AD1983_SPDIF_OUT 0x02
883 #define AD1983_DAC 0x03
884 #define AD1983_ADC 0x04
886 static hda_nid_t ad1983_dac_nids[1] = { AD1983_DAC };
887 static hda_nid_t ad1983_adc_nids[1] = { AD1983_ADC };
888 static hda_nid_t ad1983_capsrc_nids[1] = { 0x15 };
890 static struct hda_input_mux ad1983_capture_source = {
901 * SPDIF playback route
903 static int ad1983_spdif_route_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
905 static char *texts[] = { "PCM", "ADC" };
907 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
909 uinfo->value.enumerated.items = 2;
910 if (uinfo->value.enumerated.item > 1)
911 uinfo->value.enumerated.item = 1;
912 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
916 static int ad1983_spdif_route_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
918 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
919 struct ad198x_spec *spec = codec->spec;
921 ucontrol->value.enumerated.item[0] = spec->spdif_route;
925 static int ad1983_spdif_route_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
927 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
928 struct ad198x_spec *spec = codec->spec;
930 if (spec->spdif_route != ucontrol->value.enumerated.item[0]) {
931 spec->spdif_route = ucontrol->value.enumerated.item[0];
932 snd_hda_codec_write(codec, spec->multiout.dig_out_nid, 0,
933 AC_VERB_SET_CONNECT_SEL, spec->spdif_route);
939 static struct snd_kcontrol_new ad1983_mixers[] = {
940 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT),
941 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT),
942 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT),
943 HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT),
944 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT),
945 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT),
946 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
947 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
948 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
949 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
950 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT),
951 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT),
952 HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x10, 1, 0x0, HDA_OUTPUT),
953 HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x10, 1, 0x0, HDA_OUTPUT),
954 HDA_CODEC_VOLUME("Mic Boost", 0x0c, 0x0, HDA_OUTPUT),
955 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
956 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
958 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
959 .name = "Capture Source",
960 .info = ad198x_mux_enum_info,
961 .get = ad198x_mux_enum_get,
962 .put = ad198x_mux_enum_put,
965 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
966 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Route",
967 .info = ad1983_spdif_route_info,
968 .get = ad1983_spdif_route_get,
969 .put = ad1983_spdif_route_put,
974 static struct hda_verb ad1983_init_verbs[] = {
975 /* Front, HP, Mono; mute as default */
976 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
977 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
978 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
979 /* Beep, PCM, Mic, Line-In: mute */
980 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
981 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
982 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
983 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
984 /* Front, HP selectors; from Mix */
985 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
986 {0x06, AC_VERB_SET_CONNECT_SEL, 0x01},
987 /* Mono selector; from Mix */
988 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03},
989 /* Mic selector; Mic */
990 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0},
991 /* Line-in selector: Line-in */
992 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
994 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
995 /* Record selector: mic */
996 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0},
997 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
998 /* SPDIF route: PCM */
999 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0},
1001 {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1003 {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
1005 {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1007 {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
1009 {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
1014 static int patch_ad1983(struct hda_codec *codec)
1016 struct ad198x_spec *spec;
1018 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1022 mutex_init(&spec->amp_mutex);
1025 spec->multiout.max_channels = 2;
1026 spec->multiout.num_dacs = ARRAY_SIZE(ad1983_dac_nids);
1027 spec->multiout.dac_nids = ad1983_dac_nids;
1028 spec->multiout.dig_out_nid = AD1983_SPDIF_OUT;
1029 spec->num_adc_nids = 1;
1030 spec->adc_nids = ad1983_adc_nids;
1031 spec->capsrc_nids = ad1983_capsrc_nids;
1032 spec->input_mux = &ad1983_capture_source;
1033 spec->num_mixers = 1;
1034 spec->mixers[0] = ad1983_mixers;
1035 spec->num_init_verbs = 1;
1036 spec->init_verbs[0] = ad1983_init_verbs;
1037 spec->spdif_route = 0;
1039 codec->patch_ops = ad198x_patch_ops;
1046 * AD1981 HD specific
1049 #define AD1981_SPDIF_OUT 0x02
1050 #define AD1981_DAC 0x03
1051 #define AD1981_ADC 0x04
1053 static hda_nid_t ad1981_dac_nids[1] = { AD1981_DAC };
1054 static hda_nid_t ad1981_adc_nids[1] = { AD1981_ADC };
1055 static hda_nid_t ad1981_capsrc_nids[1] = { 0x15 };
1057 /* 0x0c, 0x09, 0x0e, 0x0f, 0x19, 0x05, 0x18, 0x17 */
1058 static struct hda_input_mux ad1981_capture_source = {
1061 { "Front Mic", 0x0 },
1064 { "Mix Mono", 0x3 },
1071 static struct snd_kcontrol_new ad1981_mixers[] = {
1072 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT),
1073 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT),
1074 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT),
1075 HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT),
1076 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT),
1077 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT),
1078 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
1079 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
1080 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
1081 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
1082 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1083 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1084 HDA_CODEC_VOLUME("Aux Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
1085 HDA_CODEC_MUTE("Aux Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1086 HDA_CODEC_VOLUME("Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT),
1087 HDA_CODEC_MUTE("Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
1088 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1089 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1090 HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1091 HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x0d, 1, 0x0, HDA_OUTPUT),
1092 HDA_CODEC_VOLUME("Front Mic Boost", 0x08, 0x0, HDA_INPUT),
1093 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x0, HDA_INPUT),
1094 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1095 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
1097 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1098 .name = "Capture Source",
1099 .info = ad198x_mux_enum_info,
1100 .get = ad198x_mux_enum_get,
1101 .put = ad198x_mux_enum_put,
1103 /* identical with AD1983 */
1105 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1106 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Route",
1107 .info = ad1983_spdif_route_info,
1108 .get = ad1983_spdif_route_get,
1109 .put = ad1983_spdif_route_put,
1114 static struct hda_verb ad1981_init_verbs[] = {
1115 /* Front, HP, Mono; mute as default */
1116 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1117 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1118 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1119 /* Beep, PCM, Front Mic, Line, Rear Mic, Aux, CD-In: mute */
1120 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1121 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1122 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1123 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1124 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1125 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1126 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1127 /* Front, HP selectors; from Mix */
1128 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
1129 {0x06, AC_VERB_SET_CONNECT_SEL, 0x01},
1130 /* Mono selector; from Mix */
1131 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03},
1132 /* Mic Mixer; select Front Mic */
1133 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1134 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1135 /* Mic boost: 0dB */
1136 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1137 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1138 /* Record selector: Front mic */
1139 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0},
1140 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1141 /* SPDIF route: PCM */
1142 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0},
1144 {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1146 {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
1148 {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1149 /* Front & Rear Mic Pins */
1150 {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
1151 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
1153 {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
1155 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
1156 /* Line-Out as Input: disabled */
1157 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1162 * Patch for HP nx6320
1164 * nx6320 uses EAPD in the reserve way - EAPD-on means the internal
1165 * speaker output enabled _and_ mute-LED off.
1168 #define AD1981_HP_EVENT 0x37
1169 #define AD1981_MIC_EVENT 0x38
1171 static struct hda_verb ad1981_hp_init_verbs[] = {
1172 {0x05, AC_VERB_SET_EAPD_BTLENABLE, 0x00 }, /* default off */
1173 /* pin sensing on HP and Mic jacks */
1174 {0x06, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_HP_EVENT},
1175 {0x08, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_MIC_EVENT},
1179 /* turn on/off EAPD (+ mute HP) as a master switch */
1180 static int ad1981_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1181 struct snd_ctl_elem_value *ucontrol)
1183 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1184 struct ad198x_spec *spec = codec->spec;
1186 if (! ad198x_eapd_put(kcontrol, ucontrol))
1189 /* toggle HP mute appropriately */
1190 snd_hda_codec_amp_update(codec, 0x06, 0, HDA_OUTPUT, 0,
1191 0x80, spec->cur_eapd ? 0 : 0x80);
1192 snd_hda_codec_amp_update(codec, 0x06, 1, HDA_OUTPUT, 0,
1193 0x80, spec->cur_eapd ? 0 : 0x80);
1197 /* bind volumes of both NID 0x05 and 0x06 */
1198 static int ad1981_hp_master_vol_put(struct snd_kcontrol *kcontrol,
1199 struct snd_ctl_elem_value *ucontrol)
1201 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1202 long *valp = ucontrol->value.integer.value;
1205 change = snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
1206 0x7f, valp[0] & 0x7f);
1207 change |= snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
1208 0x7f, valp[1] & 0x7f);
1209 snd_hda_codec_amp_update(codec, 0x06, 0, HDA_OUTPUT, 0,
1210 0x7f, valp[0] & 0x7f);
1211 snd_hda_codec_amp_update(codec, 0x06, 1, HDA_OUTPUT, 0,
1212 0x7f, valp[1] & 0x7f);
1216 /* mute internal speaker if HP is plugged */
1217 static void ad1981_hp_automute(struct hda_codec *codec)
1219 unsigned int present;
1221 present = snd_hda_codec_read(codec, 0x06, 0,
1222 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1223 snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
1224 0x80, present ? 0x80 : 0);
1225 snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
1226 0x80, present ? 0x80 : 0);
1229 /* toggle input of built-in and mic jack appropriately */
1230 static void ad1981_hp_automic(struct hda_codec *codec)
1232 static struct hda_verb mic_jack_on[] = {
1233 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1234 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1237 static struct hda_verb mic_jack_off[] = {
1238 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1239 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1242 unsigned int present;
1244 present = snd_hda_codec_read(codec, 0x08, 0,
1245 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1247 snd_hda_sequence_write(codec, mic_jack_on);
1249 snd_hda_sequence_write(codec, mic_jack_off);
1252 /* unsolicited event for HP jack sensing */
1253 static void ad1981_hp_unsol_event(struct hda_codec *codec,
1258 case AD1981_HP_EVENT:
1259 ad1981_hp_automute(codec);
1261 case AD1981_MIC_EVENT:
1262 ad1981_hp_automic(codec);
1267 static struct hda_input_mux ad1981_hp_capture_source = {
1271 { "Docking-Station", 0x1 },
1276 static struct snd_kcontrol_new ad1981_hp_mixers[] = {
1278 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1279 .name = "Master Playback Volume",
1280 .info = snd_hda_mixer_amp_volume_info,
1281 .get = snd_hda_mixer_amp_volume_get,
1282 .put = ad1981_hp_master_vol_put,
1283 .private_value = HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
1286 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1287 .name = "Master Playback Switch",
1288 .info = ad198x_eapd_info,
1289 .get = ad198x_eapd_get,
1290 .put = ad1981_hp_master_sw_put,
1291 .private_value = 0x05,
1293 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
1294 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
1296 /* FIXME: analog mic/line loopback doesn't work with my tests...
1297 * (although recording is OK)
1299 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
1300 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
1301 HDA_CODEC_VOLUME("Docking-Station Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1302 HDA_CODEC_MUTE("Docking-Station Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1303 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT),
1304 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
1305 /* FIXME: does this laptop have analog CD connection? */
1306 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1307 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1309 HDA_CODEC_VOLUME("Mic Boost", 0x08, 0x0, HDA_INPUT),
1310 HDA_CODEC_VOLUME("Internal Mic Boost", 0x18, 0x0, HDA_INPUT),
1311 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1312 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
1314 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1315 .name = "Capture Source",
1316 .info = ad198x_mux_enum_info,
1317 .get = ad198x_mux_enum_get,
1318 .put = ad198x_mux_enum_put,
1323 /* initialize jack-sensing, too */
1324 static int ad1981_hp_init(struct hda_codec *codec)
1327 ad1981_hp_automute(codec);
1328 ad1981_hp_automic(codec);
1333 enum { AD1981_BASIC, AD1981_HP };
1335 static struct hda_board_config ad1981_cfg_tbl[] = {
1336 { .modelname = "hp", .config = AD1981_HP },
1338 { .pci_subvendor = 0x103c, .config = AD1981_HP },
1339 { .modelname = "basic", .config = AD1981_BASIC },
1343 static int patch_ad1981(struct hda_codec *codec)
1345 struct ad198x_spec *spec;
1348 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1352 mutex_init(&spec->amp_mutex);
1355 spec->multiout.max_channels = 2;
1356 spec->multiout.num_dacs = ARRAY_SIZE(ad1981_dac_nids);
1357 spec->multiout.dac_nids = ad1981_dac_nids;
1358 spec->multiout.dig_out_nid = AD1981_SPDIF_OUT;
1359 spec->num_adc_nids = 1;
1360 spec->adc_nids = ad1981_adc_nids;
1361 spec->capsrc_nids = ad1981_capsrc_nids;
1362 spec->input_mux = &ad1981_capture_source;
1363 spec->num_mixers = 1;
1364 spec->mixers[0] = ad1981_mixers;
1365 spec->num_init_verbs = 1;
1366 spec->init_verbs[0] = ad1981_init_verbs;
1367 spec->spdif_route = 0;
1369 codec->patch_ops = ad198x_patch_ops;
1371 /* override some parameters */
1372 board_config = snd_hda_check_board_config(codec, ad1981_cfg_tbl);
1373 switch (board_config) {
1375 spec->mixers[0] = ad1981_hp_mixers;
1376 spec->num_init_verbs = 2;
1377 spec->init_verbs[1] = ad1981_hp_init_verbs;
1378 spec->multiout.dig_out_nid = 0;
1379 spec->input_mux = &ad1981_hp_capture_source;
1381 codec->patch_ops.init = ad1981_hp_init;
1382 codec->patch_ops.unsol_event = ad1981_hp_unsol_event;
1393 * Output pins and routes
1395 * Pin Mix Sel DAC (*)
1396 * port-A 0x11 (mute/hp) <- 0x22 <- 0x37 <- 03/04/06
1397 * port-B 0x14 (mute/hp) <- 0x2b <- 0x30 <- 03/04/06
1398 * port-C 0x15 (mute) <- 0x2c <- 0x31 <- 05/0a
1399 * port-D 0x12 (mute/hp) <- 0x29 <- 04
1400 * port-E 0x17 (mute/hp) <- 0x26 <- 0x32 <- 05/0a
1401 * port-F 0x16 (mute) <- 0x2a <- 06
1402 * port-G 0x24 (mute) <- 0x27 <- 05
1403 * port-H 0x25 (mute) <- 0x28 <- 0a
1404 * mono 0x13 (mute/amp)<- 0x1e <- 0x36 <- 03/04/06
1406 * DAC0 = 03h, DAC1 = 04h, DAC2 = 05h, DAC3 = 06h, DAC4 = 0ah
1407 * (*) DAC2/3/4 are swapped to DAC3/4/2 on AD198A rev.2 due to a h/w bug.
1409 * Input pins and routes
1411 * pin boost mix input # / adc input #
1412 * port-A 0x11 -> 0x38 -> mix 2, ADC 0
1413 * port-B 0x14 -> 0x39 -> mix 0, ADC 1
1414 * port-C 0x15 -> 0x3a -> 33:0 - mix 1, ADC 2
1415 * port-D 0x12 -> 0x3d -> mix 3, ADC 8
1416 * port-E 0x17 -> 0x3c -> 34:0 - mix 4, ADC 4
1417 * port-F 0x16 -> 0x3b -> mix 5, ADC 3
1418 * port-G 0x24 -> N/A -> 33:1 - mix 1, 34:1 - mix 4, ADC 6
1419 * port-H 0x25 -> N/A -> 33:2 - mix 1, 34:2 - mix 4, ADC 7
1423 * 6stack - front/surr/CLFE/side/opt DACs - 04/06/05/0a/03
1424 * 3stack - front/surr/CLFE/opt DACs - 04/05/0a/03
1426 * Inputs of Analog Mix (0x20)
1427 * 0:Port-B (front mic)
1428 * 1:Port-C/G/H (line-in)
1430 * 3:Port-D (line-in/2)
1431 * 4:Port-E/G/H (mic-in)
1432 * 5:Port-F (mic2-in)
1438 * 1:Port-B (front mic-in)
1439 * 2:Port-C (line-in)
1440 * 3:Port-F (mic2-in)
1445 * 8:Port-D (line-in/2)
1448 * Proposed pin assignments by the datasheet
1451 * Port-A front headphone
1461 * Port-A front headphone
1463 * C rear line-in/surround
1465 * E rear mic-in/CLFE
1471 * D internal speaker (with EAPD)
1472 * E/F quad mic array
1488 /* reivision id to check workarounds */
1489 #define AD1988A_REV2 0x100200
1496 static hda_nid_t ad1988_6stack_dac_nids[4] = {
1497 0x04, 0x06, 0x05, 0x0a
1500 static hda_nid_t ad1988_3stack_dac_nids[3] = {
1504 /* for AD1988A revision-2, DAC2-4 are swapped */
1505 static hda_nid_t ad1988_6stack_dac_nids_rev2[4] = {
1506 0x04, 0x05, 0x0a, 0x06
1509 static hda_nid_t ad1988_3stack_dac_nids_rev2[3] = {
1513 static hda_nid_t ad1988_adc_nids[3] = {
1517 static hda_nid_t ad1988_capsrc_nids[3] = {
1521 #define AD1988_SPDIF_OUT 0x02
1522 #define AD1988_SPDIF_IN 0x07
1524 static struct hda_input_mux ad1988_6stack_capture_source = {
1527 { "Front Mic", 0x0 },
1535 static struct hda_input_mux ad1988_laptop_capture_source = {
1538 { "Mic/Line", 0x0 },
1546 static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol,
1547 struct snd_ctl_elem_info *uinfo)
1549 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1550 struct ad198x_spec *spec = codec->spec;
1551 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
1552 spec->num_channel_mode);
1555 static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol,
1556 struct snd_ctl_elem_value *ucontrol)
1558 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1559 struct ad198x_spec *spec = codec->spec;
1560 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
1561 spec->num_channel_mode, spec->multiout.max_channels);
1564 static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol,
1565 struct snd_ctl_elem_value *ucontrol)
1567 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1568 struct ad198x_spec *spec = codec->spec;
1569 if (spec->need_dac_fix)
1570 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
1571 return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
1572 spec->num_channel_mode, &spec->multiout.max_channels);
1576 static struct snd_kcontrol_new ad1988_6stack_mixers1[] = {
1577 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1578 HDA_CODEC_VOLUME("Surround Playback Volume", 0x06, 0x0, HDA_OUTPUT),
1579 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT),
1580 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT),
1581 HDA_CODEC_VOLUME("Side Playback Volume", 0x0a, 0x0, HDA_OUTPUT),
1584 static struct snd_kcontrol_new ad1988_6stack_mixers1_rev2[] = {
1585 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1586 HDA_CODEC_VOLUME("Surround Playback Volume", 0x05, 0x0, HDA_OUTPUT),
1587 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
1588 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0a, 2, 0x0, HDA_OUTPUT),
1589 HDA_CODEC_VOLUME("Side Playback Volume", 0x06, 0x0, HDA_OUTPUT),
1592 static struct snd_kcontrol_new ad1988_6stack_mixers2[] = {
1593 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT),
1594 HDA_BIND_MUTE("Surround Playback Switch", 0x2a, 2, HDA_INPUT),
1595 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x27, 1, 2, HDA_INPUT),
1596 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x27, 2, 2, HDA_INPUT),
1597 HDA_BIND_MUTE("Side Playback Switch", 0x28, 2, HDA_INPUT),
1598 HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT),
1599 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT),
1601 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT),
1602 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT),
1603 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT),
1604 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT),
1605 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
1606 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
1607 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT),
1608 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT),
1610 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
1611 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
1613 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
1614 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
1616 HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT),
1617 HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT),
1623 static struct snd_kcontrol_new ad1988_3stack_mixers1[] = {
1624 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1625 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT),
1626 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT),
1627 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT),
1630 static struct snd_kcontrol_new ad1988_3stack_mixers1_rev2[] = {
1631 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1632 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT),
1633 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x06, 1, 0x0, HDA_OUTPUT),
1634 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x06, 2, 0x0, HDA_OUTPUT),
1637 static struct snd_kcontrol_new ad1988_3stack_mixers2[] = {
1638 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT),
1639 HDA_BIND_MUTE("Surround Playback Switch", 0x2c, 2, HDA_INPUT),
1640 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x26, 1, 2, HDA_INPUT),
1641 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x26, 2, 2, HDA_INPUT),
1642 HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT),
1643 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT),
1645 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT),
1646 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT),
1647 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT),
1648 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT),
1649 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
1650 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
1651 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT),
1652 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT),
1654 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
1655 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
1657 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
1658 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
1660 HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT),
1661 HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT),
1663 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1664 .name = "Channel Mode",
1665 .info = ad198x_ch_mode_info,
1666 .get = ad198x_ch_mode_get,
1667 .put = ad198x_ch_mode_put,
1674 static struct snd_kcontrol_new ad1988_laptop_mixers[] = {
1675 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1676 HDA_CODEC_MUTE("PCM Playback Switch", 0x29, 0x0, HDA_INPUT),
1677 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT),
1679 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT),
1680 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT),
1681 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x0, HDA_INPUT),
1682 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x0, HDA_INPUT),
1683 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
1684 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
1686 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
1687 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
1689 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
1690 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
1692 HDA_CODEC_VOLUME("Mic Boost", 0x39, 0x0, HDA_OUTPUT),
1695 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1696 .name = "External Amplifier",
1697 .info = ad198x_eapd_info,
1698 .get = ad198x_eapd_get,
1699 .put = ad198x_eapd_put,
1700 .private_value = 0x12 | (1 << 8), /* port-D, inversed */
1707 static struct snd_kcontrol_new ad1988_capture_mixers[] = {
1708 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
1709 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
1710 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
1711 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
1712 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x0e, 0x0, HDA_OUTPUT),
1713 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x0e, 0x0, HDA_OUTPUT),
1715 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1716 /* The multiple "Capture Source" controls confuse alsamixer
1717 * So call somewhat different..
1718 * FIXME: the controls appear in the "playback" view!
1720 /* .name = "Capture Source", */
1721 .name = "Input Source",
1723 .info = ad198x_mux_enum_info,
1724 .get = ad198x_mux_enum_get,
1725 .put = ad198x_mux_enum_put,
1730 static int ad1988_spdif_playback_source_info(struct snd_kcontrol *kcontrol,
1731 struct snd_ctl_elem_info *uinfo)
1733 static char *texts[] = {
1734 "PCM", "ADC1", "ADC2", "ADC3"
1736 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1738 uinfo->value.enumerated.items = 4;
1739 if (uinfo->value.enumerated.item >= 4)
1740 uinfo->value.enumerated.item = 3;
1741 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1745 static int ad1988_spdif_playback_source_get(struct snd_kcontrol *kcontrol,
1746 struct snd_ctl_elem_value *ucontrol)
1748 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1751 sel = snd_hda_codec_read(codec, 0x02, 0, AC_VERB_GET_CONNECT_SEL, 0);
1753 sel = snd_hda_codec_read(codec, 0x0b, 0, AC_VERB_GET_CONNECT_SEL, 0);
1759 ucontrol->value.enumerated.item[0] = sel;
1763 static int ad1988_spdif_playback_source_put(struct snd_kcontrol *kcontrol,
1764 struct snd_ctl_elem_value *ucontrol)
1766 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1770 sel = snd_hda_codec_read(codec, 0x02, 0, AC_VERB_GET_CONNECT_SEL, 0);
1771 if (! ucontrol->value.enumerated.item[0]) {
1774 snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL, 0);
1778 snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL, 1);
1779 sel = snd_hda_codec_read(codec, 0x0b, 0, AC_VERB_GET_CONNECT_SEL, 0) + 1;
1780 change |= sel == ucontrol->value.enumerated.item[0];
1782 snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL,
1783 ucontrol->value.enumerated.item[0] - 1);
1788 static struct snd_kcontrol_new ad1988_spdif_out_mixers[] = {
1789 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
1791 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1792 .name = "IEC958 Playback Source",
1793 .info = ad1988_spdif_playback_source_info,
1794 .get = ad1988_spdif_playback_source_get,
1795 .put = ad1988_spdif_playback_source_put,
1800 static struct snd_kcontrol_new ad1988_spdif_in_mixers[] = {
1801 HDA_CODEC_VOLUME("IEC958 Capture Volume", 0x1c, 0x0, HDA_INPUT),
1807 * initialization verbs
1811 * for 6-stack (+dig)
1813 static struct hda_verb ad1988_6stack_init_verbs[] = {
1814 /* Front, Surround, CLFE, side DAC; unmute as default */
1815 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1816 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1817 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1818 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1819 /* Port-A front headphon path */
1820 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */
1821 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1822 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1823 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1824 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1825 /* Port-D line-out path */
1826 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1827 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1828 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1829 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1830 /* Port-F surround path */
1831 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1832 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1833 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1834 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1835 /* Port-G CLFE path */
1836 {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1837 {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1838 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1839 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1840 /* Port-H side path */
1841 {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1842 {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1843 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1844 {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1846 {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */
1847 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1848 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1849 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1850 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */
1851 /* Port-B front mic-in path */
1852 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1853 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1854 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1855 /* Port-C line-in path */
1856 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1857 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1858 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1859 {0x33, AC_VERB_SET_CONNECT_SEL, 0x0},
1860 /* Port-E mic-in path */
1861 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1862 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1863 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1864 {0x34, AC_VERB_SET_CONNECT_SEL, 0x0},
1869 static struct hda_verb ad1988_capture_init_verbs[] = {
1870 /* mute analog mix */
1871 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1872 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1873 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1874 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1875 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1876 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
1877 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1878 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
1879 /* select ADCs - front-mic */
1880 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
1881 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
1882 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
1884 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1885 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1886 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1891 static struct hda_verb ad1988_spdif_init_verbs[] = {
1893 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */
1894 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x0}, /* ADC1 */
1895 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1896 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1898 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
1899 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x17}, /* 0dB */
1905 * verbs for 3stack (+dig)
1907 static struct hda_verb ad1988_3stack_ch2_init[] = {
1908 /* set port-C to line-in */
1909 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1910 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1911 /* set port-E to mic-in */
1912 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1913 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1917 static struct hda_verb ad1988_3stack_ch6_init[] = {
1918 /* set port-C to surround out */
1919 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1920 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1921 /* set port-E to CLFE out */
1922 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1923 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1927 static struct hda_channel_mode ad1988_3stack_modes[2] = {
1928 { 2, ad1988_3stack_ch2_init },
1929 { 6, ad1988_3stack_ch6_init },
1932 static struct hda_verb ad1988_3stack_init_verbs[] = {
1933 /* Front, Surround, CLFE, side DAC; unmute as default */
1934 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1935 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1936 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1937 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1938 /* Port-A front headphon path */
1939 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */
1940 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1941 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1942 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1943 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1944 /* Port-D line-out path */
1945 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1946 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1947 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1948 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1950 {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */
1951 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1952 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1953 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1954 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */
1955 /* Port-B front mic-in path */
1956 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1957 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1958 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1959 /* Port-C line-in/surround path - 6ch mode as default */
1960 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1961 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1962 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1963 {0x31, AC_VERB_SET_CONNECT_SEL, 0x0}, /* output sel: DAC 0x05 */
1964 {0x33, AC_VERB_SET_CONNECT_SEL, 0x0},
1965 /* Port-E mic-in/CLFE path - 6ch mode as default */
1966 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1967 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1968 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1969 {0x32, AC_VERB_SET_CONNECT_SEL, 0x1}, /* output sel: DAC 0x0a */
1970 {0x34, AC_VERB_SET_CONNECT_SEL, 0x0},
1971 /* mute analog mix */
1972 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1973 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1974 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1975 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1976 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1977 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
1978 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1979 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
1980 /* select ADCs - front-mic */
1981 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
1982 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
1983 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
1985 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1986 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1987 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1992 * verbs for laptop mode (+dig)
1994 static struct hda_verb ad1988_laptop_hp_on[] = {
1995 /* unmute port-A and mute port-D */
1996 { 0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1997 { 0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2000 static struct hda_verb ad1988_laptop_hp_off[] = {
2001 /* mute port-A and unmute port-D */
2002 { 0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2003 { 0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2007 #define AD1988_HP_EVENT 0x01
2009 static struct hda_verb ad1988_laptop_init_verbs[] = {
2010 /* Front, Surround, CLFE, side DAC; unmute as default */
2011 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2012 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2013 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2014 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2015 /* Port-A front headphon path */
2016 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */
2017 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2018 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2019 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2020 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2021 /* unsolicited event for pin-sense */
2022 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1988_HP_EVENT },
2023 /* Port-D line-out path + EAPD */
2024 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2025 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2026 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2027 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2028 {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x00}, /* EAPD-off */
2030 {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */
2031 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2032 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2033 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2034 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */
2035 /* Port-B mic-in path */
2036 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2037 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2038 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2039 /* Port-C docking station - try to output */
2040 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2041 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2042 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2043 {0x33, AC_VERB_SET_CONNECT_SEL, 0x0},
2044 /* mute analog mix */
2045 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2046 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2047 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2048 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2049 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2050 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
2051 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2052 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2053 /* select ADCs - mic */
2054 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
2055 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
2056 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
2058 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2059 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2060 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2064 static void ad1988_laptop_unsol_event(struct hda_codec *codec, unsigned int res)
2066 if ((res >> 26) != AD1988_HP_EVENT)
2068 if (snd_hda_codec_read(codec, 0x11, 0, AC_VERB_GET_PIN_SENSE, 0) & (1 << 31))
2069 snd_hda_sequence_write(codec, ad1988_laptop_hp_on);
2071 snd_hda_sequence_write(codec, ad1988_laptop_hp_off);
2076 * Automatic parse of I/O pins from the BIOS configuration
2079 #define NUM_CONTROL_ALLOC 32
2080 #define NUM_VERB_ALLOC 32
2087 static struct snd_kcontrol_new ad1988_control_templates[] = {
2088 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2089 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2090 HDA_BIND_MUTE(NULL, 0, 0, 0),
2093 /* add dynamic controls */
2094 static int add_control(struct ad198x_spec *spec, int type, const char *name,
2097 struct snd_kcontrol_new *knew;
2099 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2100 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2102 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2105 if (spec->kctl_alloc) {
2106 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2107 kfree(spec->kctl_alloc);
2109 spec->kctl_alloc = knew;
2110 spec->num_kctl_alloc = num;
2113 knew = &spec->kctl_alloc[spec->num_kctl_used];
2114 *knew = ad1988_control_templates[type];
2115 knew->name = kstrdup(name, GFP_KERNEL);
2118 knew->private_value = val;
2119 spec->num_kctl_used++;
2123 #define AD1988_PIN_CD_NID 0x18
2124 #define AD1988_PIN_BEEP_NID 0x10
2126 static hda_nid_t ad1988_mixer_nids[8] = {
2127 /* A B C D E F G H */
2128 0x22, 0x2b, 0x2c, 0x29, 0x26, 0x2a, 0x27, 0x28
2131 static inline hda_nid_t ad1988_idx_to_dac(struct hda_codec *codec, int idx)
2133 static hda_nid_t idx_to_dac[8] = {
2134 /* A B C D E F G H */
2135 0x04, 0x06, 0x05, 0x04, 0x0a, 0x06, 0x05, 0x0a
2137 static hda_nid_t idx_to_dac_rev2[8] = {
2138 /* A B C D E F G H */
2139 0x04, 0x05, 0x0a, 0x04, 0x06, 0x05, 0x0a, 0x06
2141 if (codec->revision_id == AD1988A_REV2)
2142 return idx_to_dac_rev2[idx];
2144 return idx_to_dac[idx];
2147 static hda_nid_t ad1988_boost_nids[8] = {
2148 0x38, 0x39, 0x3a, 0x3d, 0x3c, 0x3b, 0, 0
2151 static int ad1988_pin_idx(hda_nid_t nid)
2153 static hda_nid_t ad1988_io_pins[8] = {
2154 0x11, 0x14, 0x15, 0x12, 0x17, 0x16, 0x24, 0x25
2157 for (i = 0; i < ARRAY_SIZE(ad1988_io_pins); i++)
2158 if (ad1988_io_pins[i] == nid)
2160 return 0; /* should be -1 */
2163 static int ad1988_pin_to_loopback_idx(hda_nid_t nid)
2165 static int loopback_idx[8] = {
2166 2, 0, 1, 3, 4, 5, 1, 4
2169 case AD1988_PIN_CD_NID:
2172 return loopback_idx[ad1988_pin_idx(nid)];
2176 static int ad1988_pin_to_adc_idx(hda_nid_t nid)
2178 static int adc_idx[8] = {
2179 0, 1, 2, 8, 4, 3, 6, 7
2182 case AD1988_PIN_CD_NID:
2185 return adc_idx[ad1988_pin_idx(nid)];
2189 /* fill in the dac_nids table from the parsed pin configuration */
2190 static int ad1988_auto_fill_dac_nids(struct hda_codec *codec,
2191 const struct auto_pin_cfg *cfg)
2193 struct ad198x_spec *spec = codec->spec;
2196 spec->multiout.dac_nids = spec->private_dac_nids;
2198 /* check the pins hardwired to audio widget */
2199 for (i = 0; i < cfg->line_outs; i++) {
2200 idx = ad1988_pin_idx(cfg->line_out_pins[i]);
2201 spec->multiout.dac_nids[i] = ad1988_idx_to_dac(codec, idx);
2203 spec->multiout.num_dacs = cfg->line_outs;
2207 /* add playback controls from the parsed DAC table */
2208 static int ad1988_auto_create_multi_out_ctls(struct ad198x_spec *spec,
2209 const struct auto_pin_cfg *cfg)
2212 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
2216 for (i = 0; i < cfg->line_outs; i++) {
2217 hda_nid_t dac = spec->multiout.dac_nids[i];
2220 nid = ad1988_mixer_nids[ad1988_pin_idx(cfg->line_out_pins[i])];
2223 err = add_control(spec, AD_CTL_WIDGET_VOL,
2224 "Center Playback Volume",
2225 HDA_COMPOSE_AMP_VAL(dac, 1, 0, HDA_OUTPUT));
2228 err = add_control(spec, AD_CTL_WIDGET_VOL,
2229 "LFE Playback Volume",
2230 HDA_COMPOSE_AMP_VAL(dac, 2, 0, HDA_OUTPUT));
2233 err = add_control(spec, AD_CTL_BIND_MUTE,
2234 "Center Playback Switch",
2235 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT));
2238 err = add_control(spec, AD_CTL_BIND_MUTE,
2239 "LFE Playback Switch",
2240 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT));
2244 sprintf(name, "%s Playback Volume", chname[i]);
2245 err = add_control(spec, AD_CTL_WIDGET_VOL, name,
2246 HDA_COMPOSE_AMP_VAL(dac, 3, 0, HDA_OUTPUT));
2249 sprintf(name, "%s Playback Switch", chname[i]);
2250 err = add_control(spec, AD_CTL_BIND_MUTE, name,
2251 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
2259 /* add playback controls for speaker and HP outputs */
2260 static int ad1988_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
2263 struct ad198x_spec *spec = codec->spec;
2271 idx = ad1988_pin_idx(pin);
2272 nid = ad1988_idx_to_dac(codec, idx);
2273 /* specify the DAC as the extra output */
2274 if (! spec->multiout.hp_nid)
2275 spec->multiout.hp_nid = nid;
2277 spec->multiout.extra_out_nid[0] = nid;
2278 /* control HP volume/switch on the output mixer amp */
2279 sprintf(name, "%s Playback Volume", pfx);
2280 if ((err = add_control(spec, AD_CTL_WIDGET_VOL, name,
2281 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2283 nid = ad1988_mixer_nids[idx];
2284 sprintf(name, "%s Playback Switch", pfx);
2285 if ((err = add_control(spec, AD_CTL_BIND_MUTE, name,
2286 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2291 /* create input playback/capture controls for the given pin */
2292 static int new_analog_input(struct ad198x_spec *spec, hda_nid_t pin,
2293 const char *ctlname, int boost)
2298 sprintf(name, "%s Playback Volume", ctlname);
2299 idx = ad1988_pin_to_loopback_idx(pin);
2300 if ((err = add_control(spec, AD_CTL_WIDGET_VOL, name,
2301 HDA_COMPOSE_AMP_VAL(0x20, 3, idx, HDA_INPUT))) < 0)
2303 sprintf(name, "%s Playback Switch", ctlname);
2304 if ((err = add_control(spec, AD_CTL_WIDGET_MUTE, name,
2305 HDA_COMPOSE_AMP_VAL(0x20, 3, idx, HDA_INPUT))) < 0)
2309 idx = ad1988_pin_idx(pin);
2310 bnid = ad1988_boost_nids[idx];
2312 sprintf(name, "%s Boost", ctlname);
2313 return add_control(spec, AD_CTL_WIDGET_VOL, name,
2314 HDA_COMPOSE_AMP_VAL(bnid, 3, idx, HDA_OUTPUT));
2321 /* create playback/capture controls for input pins */
2322 static int ad1988_auto_create_analog_input_ctls(struct ad198x_spec *spec,
2323 const struct auto_pin_cfg *cfg)
2325 struct hda_input_mux *imux = &spec->private_imux;
2328 for (i = 0; i < AUTO_PIN_LAST; i++) {
2329 err = new_analog_input(spec, cfg->input_pins[i],
2330 auto_pin_cfg_labels[i],
2331 i <= AUTO_PIN_FRONT_MIC);
2334 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2335 imux->items[imux->num_items].index = ad1988_pin_to_adc_idx(cfg->input_pins[i]);
2338 imux->items[imux->num_items].label = "Mix";
2339 imux->items[imux->num_items].index = 9;
2342 if ((err = add_control(spec, AD_CTL_WIDGET_VOL,
2343 "Analog Mix Playback Volume",
2344 HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT))) < 0)
2346 if ((err = add_control(spec, AD_CTL_WIDGET_MUTE,
2347 "Analog Mix Playback Switch",
2348 HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT))) < 0)
2354 static void ad1988_auto_set_output_and_unmute(struct hda_codec *codec,
2355 hda_nid_t nid, int pin_type,
2359 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2360 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2362 case 0x11: /* port-A - DAC 04 */
2363 snd_hda_codec_write(codec, 0x37, 0, AC_VERB_SET_CONNECT_SEL, 0x01);
2365 case 0x14: /* port-B - DAC 06 */
2366 snd_hda_codec_write(codec, 0x30, 0, AC_VERB_SET_CONNECT_SEL, 0x02);
2368 case 0x15: /* port-C - DAC 05 */
2369 snd_hda_codec_write(codec, 0x31, 0, AC_VERB_SET_CONNECT_SEL, 0x00);
2371 case 0x17: /* port-E - DAC 0a */
2372 snd_hda_codec_write(codec, 0x32, 0, AC_VERB_SET_CONNECT_SEL, 0x01);
2374 case 0x13: /* mono - DAC 04 */
2375 snd_hda_codec_write(codec, 0x36, 0, AC_VERB_SET_CONNECT_SEL, 0x01);
2380 static void ad1988_auto_init_multi_out(struct hda_codec *codec)
2382 struct ad198x_spec *spec = codec->spec;
2385 for (i = 0; i < spec->autocfg.line_outs; i++) {
2386 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2387 ad1988_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2391 static void ad1988_auto_init_extra_out(struct hda_codec *codec)
2393 struct ad198x_spec *spec = codec->spec;
2396 pin = spec->autocfg.speaker_pins[0];
2397 if (pin) /* connect to front */
2398 ad1988_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
2399 pin = spec->autocfg.hp_pin;
2400 if (pin) /* connect to front */
2401 ad1988_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2404 static void ad1988_auto_init_analog_input(struct hda_codec *codec)
2406 struct ad198x_spec *spec = codec->spec;
2409 for (i = 0; i < AUTO_PIN_LAST; i++) {
2410 hda_nid_t nid = spec->autocfg.input_pins[i];
2414 case 0x15: /* port-C */
2415 snd_hda_codec_write(codec, 0x33, 0, AC_VERB_SET_CONNECT_SEL, 0x0);
2417 case 0x17: /* port-E */
2418 snd_hda_codec_write(codec, 0x34, 0, AC_VERB_SET_CONNECT_SEL, 0x0);
2421 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2422 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2423 if (nid != AD1988_PIN_CD_NID)
2424 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2426 idx = ad1988_pin_idx(nid);
2427 if (ad1988_boost_nids[idx])
2428 snd_hda_codec_write(codec, ad1988_boost_nids[idx], 0,
2429 AC_VERB_SET_AMP_GAIN_MUTE,
2434 /* parse the BIOS configuration and set up the alc_spec */
2435 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2436 static int ad1988_parse_auto_config(struct hda_codec *codec)
2438 struct ad198x_spec *spec = codec->spec;
2441 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
2443 if ((err = ad1988_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
2445 if (! spec->autocfg.line_outs)
2446 return 0; /* can't find valid BIOS pin config */
2447 if ((err = ad1988_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
2448 (err = ad1988_auto_create_extra_out(codec,
2449 spec->autocfg.speaker_pins[0],
2451 (err = ad1988_auto_create_extra_out(codec, spec->autocfg.hp_pin,
2452 "Headphone")) < 0 ||
2453 (err = ad1988_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2456 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2458 if (spec->autocfg.dig_out_pin)
2459 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
2460 if (spec->autocfg.dig_in_pin)
2461 spec->dig_in_nid = AD1988_SPDIF_IN;
2463 if (spec->kctl_alloc)
2464 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2466 spec->init_verbs[spec->num_init_verbs++] = ad1988_6stack_init_verbs;
2468 spec->input_mux = &spec->private_imux;
2473 /* init callback for auto-configuration model -- overriding the default init */
2474 static int ad1988_auto_init(struct hda_codec *codec)
2477 ad1988_auto_init_multi_out(codec);
2478 ad1988_auto_init_extra_out(codec);
2479 ad1988_auto_init_analog_input(codec);
2487 static struct hda_board_config ad1988_cfg_tbl[] = {
2488 { .modelname = "6stack", .config = AD1988_6STACK },
2489 { .modelname = "6stack-dig", .config = AD1988_6STACK_DIG },
2490 { .modelname = "3stack", .config = AD1988_3STACK },
2491 { .modelname = "3stack-dig", .config = AD1988_3STACK_DIG },
2492 { .modelname = "laptop", .config = AD1988_LAPTOP },
2493 { .modelname = "laptop-dig", .config = AD1988_LAPTOP_DIG },
2494 { .modelname = "auto", .config = AD1988_AUTO },
2498 static int patch_ad1988(struct hda_codec *codec)
2500 struct ad198x_spec *spec;
2503 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2507 mutex_init(&spec->amp_mutex);
2510 if (codec->revision_id == AD1988A_REV2)
2511 snd_printk(KERN_INFO "patch_analog: AD1988A rev.2 is detected, enable workarounds\n");
2513 board_config = snd_hda_check_board_config(codec, ad1988_cfg_tbl);
2514 if (board_config < 0 || board_config >= AD1988_MODEL_LAST) {
2515 printk(KERN_INFO "hda_codec: Unknown model for AD1988, trying auto-probe from BIOS...\n");
2516 board_config = AD1988_AUTO;
2519 if (board_config == AD1988_AUTO) {
2520 /* automatic parse from the BIOS config */
2521 int err = ad1988_parse_auto_config(codec);
2526 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 6-stack mode...\n");
2527 board_config = AD1988_6STACK;
2531 switch (board_config) {
2533 case AD1988_6STACK_DIG:
2534 spec->multiout.max_channels = 8;
2535 spec->multiout.num_dacs = 4;
2536 if (codec->revision_id == AD1988A_REV2)
2537 spec->multiout.dac_nids = ad1988_6stack_dac_nids_rev2;
2539 spec->multiout.dac_nids = ad1988_6stack_dac_nids;
2540 spec->input_mux = &ad1988_6stack_capture_source;
2541 spec->num_mixers = 2;
2542 if (codec->revision_id == AD1988A_REV2)
2543 spec->mixers[0] = ad1988_6stack_mixers1_rev2;
2545 spec->mixers[0] = ad1988_6stack_mixers1;
2546 spec->mixers[1] = ad1988_6stack_mixers2;
2547 spec->num_init_verbs = 1;
2548 spec->init_verbs[0] = ad1988_6stack_init_verbs;
2549 if (board_config == AD1988_6STACK_DIG) {
2550 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
2551 spec->dig_in_nid = AD1988_SPDIF_IN;
2555 case AD1988_3STACK_DIG:
2556 spec->multiout.max_channels = 6;
2557 spec->multiout.num_dacs = 3;
2558 if (codec->revision_id == AD1988A_REV2)
2559 spec->multiout.dac_nids = ad1988_3stack_dac_nids_rev2;
2561 spec->multiout.dac_nids = ad1988_3stack_dac_nids;
2562 spec->input_mux = &ad1988_6stack_capture_source;
2563 spec->channel_mode = ad1988_3stack_modes;
2564 spec->num_channel_mode = ARRAY_SIZE(ad1988_3stack_modes);
2565 spec->num_mixers = 2;
2566 if (codec->revision_id == AD1988A_REV2)
2567 spec->mixers[0] = ad1988_3stack_mixers1_rev2;
2569 spec->mixers[0] = ad1988_3stack_mixers1;
2570 spec->mixers[1] = ad1988_3stack_mixers2;
2571 spec->num_init_verbs = 1;
2572 spec->init_verbs[0] = ad1988_3stack_init_verbs;
2573 if (board_config == AD1988_3STACK_DIG)
2574 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
2577 case AD1988_LAPTOP_DIG:
2578 spec->multiout.max_channels = 2;
2579 spec->multiout.num_dacs = 1;
2580 spec->multiout.dac_nids = ad1988_3stack_dac_nids;
2581 spec->input_mux = &ad1988_laptop_capture_source;
2582 spec->num_mixers = 1;
2583 spec->mixers[0] = ad1988_laptop_mixers;
2584 spec->num_init_verbs = 1;
2585 spec->init_verbs[0] = ad1988_laptop_init_verbs;
2586 if (board_config == AD1988_LAPTOP_DIG)
2587 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
2591 spec->num_adc_nids = ARRAY_SIZE(ad1988_adc_nids);
2592 spec->adc_nids = ad1988_adc_nids;
2593 spec->capsrc_nids = ad1988_capsrc_nids;
2594 spec->mixers[spec->num_mixers++] = ad1988_capture_mixers;
2595 spec->init_verbs[spec->num_init_verbs++] = ad1988_capture_init_verbs;
2596 if (spec->multiout.dig_out_nid) {
2597 spec->mixers[spec->num_mixers++] = ad1988_spdif_out_mixers;
2598 spec->init_verbs[spec->num_init_verbs++] = ad1988_spdif_init_verbs;
2600 if (spec->dig_in_nid)
2601 spec->mixers[spec->num_mixers++] = ad1988_spdif_in_mixers;
2603 codec->patch_ops = ad198x_patch_ops;
2604 switch (board_config) {
2606 codec->patch_ops.init = ad1988_auto_init;
2609 case AD1988_LAPTOP_DIG:
2610 codec->patch_ops.unsol_event = ad1988_laptop_unsol_event;
2621 struct hda_codec_preset snd_hda_preset_analog[] = {
2622 { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 },
2623 { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 },
2624 { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a },
2625 { .id = 0x11d41988, .name = "AD1988", .patch = patch_ad1988 },
2626 { .id = 0x11d4198b, .name = "AD1988B", .patch = patch_ad1988 },