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 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
492 SNDRV_CTL_ELEM_ACCESS_TLV_READ |
493 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK,
494 .info = ad1986a_pcm_amp_vol_info,
495 .get = ad1986a_pcm_amp_vol_get,
496 .put = ad1986a_pcm_amp_vol_put,
497 .tlv = { .c = snd_hda_mixer_amp_tlv },
498 .private_value = HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT)
501 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
502 .name = "PCM Playback Switch",
503 .info = ad1986a_pcm_amp_sw_info,
504 .get = ad1986a_pcm_amp_sw_get,
505 .put = ad1986a_pcm_amp_sw_put,
506 .private_value = HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT)
508 HDA_CODEC_VOLUME("Front Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
509 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
510 HDA_CODEC_VOLUME("Surround Playback Volume", 0x1c, 0x0, HDA_OUTPUT),
511 HDA_CODEC_MUTE("Surround Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
512 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x1d, 1, 0x0, HDA_OUTPUT),
513 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x1d, 2, 0x0, HDA_OUTPUT),
514 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x1d, 1, 0x0, HDA_OUTPUT),
515 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x1d, 2, 0x0, HDA_OUTPUT),
516 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT),
517 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
518 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT),
519 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT),
520 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT),
521 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT),
522 HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT),
523 HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT),
524 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
525 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
526 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT),
527 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT),
528 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
529 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT),
530 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
531 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
533 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
534 .name = "Capture Source",
535 .info = ad198x_mux_enum_info,
536 .get = ad198x_mux_enum_get,
537 .put = ad198x_mux_enum_put,
539 HDA_CODEC_MUTE("Stereo Downmix Switch", 0x09, 0x0, HDA_OUTPUT),
543 /* additional mixers for 3stack mode */
544 static struct snd_kcontrol_new ad1986a_3st_mixers[] = {
546 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
547 .name = "Channel Mode",
548 .info = ad198x_ch_mode_info,
549 .get = ad198x_ch_mode_get,
550 .put = ad198x_ch_mode_put,
555 /* laptop model - 2ch only */
556 static hda_nid_t ad1986a_laptop_dac_nids[1] = { AD1986A_FRONT_DAC };
558 static struct snd_kcontrol_new ad1986a_laptop_mixers[] = {
559 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
560 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
561 HDA_CODEC_VOLUME("Master Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
562 HDA_CODEC_MUTE("Master Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
563 /* HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT),
564 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT), */
565 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT),
566 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT),
567 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT),
568 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT),
569 HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT),
570 HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT),
571 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
572 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
573 /* HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT),
574 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT),
575 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
576 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), */
577 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
578 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
580 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
581 .name = "Capture Source",
582 .info = ad198x_mux_enum_info,
583 .get = ad198x_mux_enum_get,
584 .put = ad198x_mux_enum_put,
589 /* laptop-eapd model - 2ch only */
591 /* master controls both pins 0x1a and 0x1b */
592 static int ad1986a_laptop_master_vol_put(struct snd_kcontrol *kcontrol,
593 struct snd_ctl_elem_value *ucontrol)
595 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
596 long *valp = ucontrol->value.integer.value;
599 change = snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0,
600 0x7f, valp[0] & 0x7f);
601 change |= snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0,
602 0x7f, valp[1] & 0x7f);
603 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
604 0x7f, valp[0] & 0x7f);
605 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
606 0x7f, valp[1] & 0x7f);
610 static int ad1986a_laptop_master_sw_put(struct snd_kcontrol *kcontrol,
611 struct snd_ctl_elem_value *ucontrol)
613 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
614 long *valp = ucontrol->value.integer.value;
617 change = snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0,
618 0x80, valp[0] ? 0 : 0x80);
619 change |= snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0,
620 0x80, valp[1] ? 0 : 0x80);
621 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
622 0x80, valp[0] ? 0 : 0x80);
623 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
624 0x80, valp[1] ? 0 : 0x80);
628 static struct hda_input_mux ad1986a_laptop_eapd_capture_source = {
632 { "Internal Mic", 0x4 },
637 static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = {
639 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
640 .name = "Master Playback Volume",
641 .info = snd_hda_mixer_amp_volume_info,
642 .get = snd_hda_mixer_amp_volume_get,
643 .put = ad1986a_laptop_master_vol_put,
644 .tlv = { .c = snd_hda_mixer_amp_tlv },
645 .private_value = HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT),
648 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
649 .name = "Master Playback Switch",
650 .info = snd_hda_mixer_amp_switch_info,
651 .get = snd_hda_mixer_amp_switch_get,
652 .put = ad1986a_laptop_master_sw_put,
653 .private_value = HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT),
655 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
656 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
657 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x0, HDA_OUTPUT),
658 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x0, HDA_OUTPUT),
659 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
660 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
661 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
662 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
664 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
665 .name = "Capture Source",
666 .info = ad198x_mux_enum_info,
667 .get = ad198x_mux_enum_get,
668 .put = ad198x_mux_enum_put,
671 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
672 .name = "External Amplifier",
673 .info = ad198x_eapd_info,
674 .get = ad198x_eapd_get,
675 .put = ad198x_eapd_put,
676 .private_value = 0x1b | (1 << 8), /* port-D, inversed */
682 * initialization verbs
684 static struct hda_verb ad1986a_init_verbs[] = {
685 /* Front, Surround, CLFE DAC; mute as default */
686 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
687 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
688 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
690 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
691 /* HP, Line-Out, Surround, CLFE selectors */
692 {0x0a, AC_VERB_SET_CONNECT_SEL, 0x0},
693 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x0},
694 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0},
695 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
697 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x0},
698 /* Mic selector: Mic 1/2 pin */
699 {0x0f, AC_VERB_SET_CONNECT_SEL, 0x0},
700 /* Line-in selector: Line-in */
701 {0x10, AC_VERB_SET_CONNECT_SEL, 0x0},
703 {0x11, AC_VERB_SET_CONNECT_SEL, 0x0},
704 /* Record selector: mic */
705 {0x12, AC_VERB_SET_CONNECT_SEL, 0x0},
706 /* Mic, Phone, CD, Aux, Line-In amp; mute as default */
707 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
708 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
709 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
710 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
711 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
713 {0x18, AC_VERB_SET_CONNECT_SEL, 0x0},
714 /* HP, Line-Out, Surround, CLFE, Mono pins; mute as default */
715 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
716 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
717 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
718 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
719 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
721 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
722 /* Front, Surround, CLFE Pins */
723 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
724 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
725 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
727 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
729 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
730 /* Line, Aux, CD, Beep-In Pin */
731 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
732 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
733 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
734 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
735 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
739 /* additional verbs for 3-stack model */
740 static struct hda_verb ad1986a_3st_init_verbs[] = {
741 /* Mic and line-in selectors */
742 {0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
743 {0x10, AC_VERB_SET_CONNECT_SEL, 0x1},
747 static struct hda_verb ad1986a_ch2_init[] = {
748 /* Surround out -> Line In */
749 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
750 { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
752 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
753 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
757 static struct hda_verb ad1986a_ch4_init[] = {
758 /* Surround out -> Surround */
759 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
760 { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
762 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
763 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
767 static struct hda_verb ad1986a_ch6_init[] = {
768 /* Surround out -> Surround out */
769 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
770 { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
772 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
773 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
777 static struct hda_channel_mode ad1986a_modes[3] = {
778 { 2, ad1986a_ch2_init },
779 { 4, ad1986a_ch4_init },
780 { 6, ad1986a_ch6_init },
783 /* eapd initialization */
784 static struct hda_verb ad1986a_eapd_init_verbs[] = {
785 {0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00},
798 static const char *ad1986a_models[AD1986A_MODELS] = {
799 [AD1986A_6STACK] = "6stack",
800 [AD1986A_3STACK] = "3stack",
801 [AD1986A_LAPTOP] = "laptop",
802 [AD1986A_LAPTOP_EAPD] = "laptop-eapd",
805 static struct snd_pci_quirk ad1986a_cfg_tbl[] = {
806 SND_PCI_QUIRK(0x103c, 0x30af, "HP B2800", AD1986A_LAPTOP_EAPD),
807 SND_PCI_QUIRK(0x10de, 0xcb84, "ASUS A8N-VM", AD1986A_3STACK),
808 SND_PCI_QUIRK(0x1043, 0x1153, "ASUS M9", AD1986A_LAPTOP_EAPD),
809 SND_PCI_QUIRK(0x1043, 0x1213, "ASUS A6J", AD1986A_LAPTOP_EAPD),
810 SND_PCI_QUIRK(0x1043, 0x11f7, "ASUS U5A", AD1986A_LAPTOP_EAPD),
811 SND_PCI_QUIRK(0x1043, 0x1263, "ASUS U5F", AD1986A_LAPTOP_EAPD),
812 SND_PCI_QUIRK(0x1043, 0x1297, "ASUS Z62F", AD1986A_LAPTOP_EAPD),
813 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS V1j", AD1986A_LAPTOP_EAPD),
814 SND_PCI_QUIRK(0x1043, 0x1302, "ASUS W3j", AD1986A_LAPTOP_EAPD),
815 SND_PCI_QUIRK(0x1043, 0x817f, "ASUS P5", AD1986A_3STACK),
816 SND_PCI_QUIRK(0x1043, 0x818f, "ASUS P5", AD1986A_LAPTOP),
817 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS P5", AD1986A_3STACK),
818 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS M2N", AD1986A_3STACK),
819 SND_PCI_QUIRK(0x1043, 0x8234, "ASUS M2N", AD1986A_3STACK),
820 SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP),
821 SND_PCI_QUIRK(0x144d, 0xc023, "Samsung X60", AD1986A_LAPTOP_EAPD),
822 SND_PCI_QUIRK(0x144d, 0xc024, "Samsung R65", AD1986A_LAPTOP_EAPD),
823 SND_PCI_QUIRK(0x144d, 0xc026, "Samsung X11", AD1986A_LAPTOP_EAPD),
824 SND_PCI_QUIRK(0x17aa, 0x1017, "Lenovo A60", AD1986A_3STACK),
825 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo N100", AD1986A_LAPTOP_EAPD),
826 SND_PCI_QUIRK(0x17c0, 0x2017, "Samsung M50", AD1986A_LAPTOP),
830 static int patch_ad1986a(struct hda_codec *codec)
832 struct ad198x_spec *spec;
835 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
839 mutex_init(&spec->amp_mutex);
842 spec->multiout.max_channels = 6;
843 spec->multiout.num_dacs = ARRAY_SIZE(ad1986a_dac_nids);
844 spec->multiout.dac_nids = ad1986a_dac_nids;
845 spec->multiout.dig_out_nid = AD1986A_SPDIF_OUT;
846 spec->num_adc_nids = 1;
847 spec->adc_nids = ad1986a_adc_nids;
848 spec->capsrc_nids = ad1986a_capsrc_nids;
849 spec->input_mux = &ad1986a_capture_source;
850 spec->num_mixers = 1;
851 spec->mixers[0] = ad1986a_mixers;
852 spec->num_init_verbs = 1;
853 spec->init_verbs[0] = ad1986a_init_verbs;
855 codec->patch_ops = ad198x_patch_ops;
857 /* override some parameters */
858 board_config = snd_hda_check_board_config(codec, AD1986A_MODELS,
861 switch (board_config) {
863 spec->num_mixers = 2;
864 spec->mixers[1] = ad1986a_3st_mixers;
865 spec->num_init_verbs = 3;
866 spec->init_verbs[1] = ad1986a_3st_init_verbs;
867 spec->init_verbs[2] = ad1986a_ch2_init;
868 spec->channel_mode = ad1986a_modes;
869 spec->num_channel_mode = ARRAY_SIZE(ad1986a_modes);
870 spec->need_dac_fix = 1;
871 spec->multiout.max_channels = 2;
872 spec->multiout.num_dacs = 1;
875 spec->mixers[0] = ad1986a_laptop_mixers;
876 spec->multiout.max_channels = 2;
877 spec->multiout.num_dacs = 1;
878 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
880 case AD1986A_LAPTOP_EAPD:
881 spec->mixers[0] = ad1986a_laptop_eapd_mixers;
882 spec->num_init_verbs = 2;
883 spec->init_verbs[1] = ad1986a_eapd_init_verbs;
884 spec->multiout.max_channels = 2;
885 spec->multiout.num_dacs = 1;
886 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
887 spec->multiout.dig_out_nid = 0;
888 spec->input_mux = &ad1986a_laptop_eapd_capture_source;
899 #define AD1983_SPDIF_OUT 0x02
900 #define AD1983_DAC 0x03
901 #define AD1983_ADC 0x04
903 static hda_nid_t ad1983_dac_nids[1] = { AD1983_DAC };
904 static hda_nid_t ad1983_adc_nids[1] = { AD1983_ADC };
905 static hda_nid_t ad1983_capsrc_nids[1] = { 0x15 };
907 static struct hda_input_mux ad1983_capture_source = {
918 * SPDIF playback route
920 static int ad1983_spdif_route_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
922 static char *texts[] = { "PCM", "ADC" };
924 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
926 uinfo->value.enumerated.items = 2;
927 if (uinfo->value.enumerated.item > 1)
928 uinfo->value.enumerated.item = 1;
929 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
933 static int ad1983_spdif_route_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
935 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
936 struct ad198x_spec *spec = codec->spec;
938 ucontrol->value.enumerated.item[0] = spec->spdif_route;
942 static int ad1983_spdif_route_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
944 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
945 struct ad198x_spec *spec = codec->spec;
947 if (spec->spdif_route != ucontrol->value.enumerated.item[0]) {
948 spec->spdif_route = ucontrol->value.enumerated.item[0];
949 snd_hda_codec_write(codec, spec->multiout.dig_out_nid, 0,
950 AC_VERB_SET_CONNECT_SEL, spec->spdif_route);
956 static struct snd_kcontrol_new ad1983_mixers[] = {
957 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT),
958 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT),
959 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT),
960 HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT),
961 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT),
962 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT),
963 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
964 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
965 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
966 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
967 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT),
968 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT),
969 HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x10, 1, 0x0, HDA_OUTPUT),
970 HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x10, 1, 0x0, HDA_OUTPUT),
971 HDA_CODEC_VOLUME("Mic Boost", 0x0c, 0x0, HDA_OUTPUT),
972 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
973 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
975 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
976 .name = "Capture Source",
977 .info = ad198x_mux_enum_info,
978 .get = ad198x_mux_enum_get,
979 .put = ad198x_mux_enum_put,
982 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
983 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
984 .info = ad1983_spdif_route_info,
985 .get = ad1983_spdif_route_get,
986 .put = ad1983_spdif_route_put,
991 static struct hda_verb ad1983_init_verbs[] = {
992 /* Front, HP, Mono; mute as default */
993 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
994 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
995 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
996 /* Beep, PCM, Mic, Line-In: mute */
997 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
998 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
999 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1000 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1001 /* Front, HP selectors; from Mix */
1002 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
1003 {0x06, AC_VERB_SET_CONNECT_SEL, 0x01},
1004 /* Mono selector; from Mix */
1005 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03},
1006 /* Mic selector; Mic */
1007 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0},
1008 /* Line-in selector: Line-in */
1009 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
1010 /* Mic boost: 0dB */
1011 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1012 /* Record selector: mic */
1013 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0},
1014 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1015 /* SPDIF route: PCM */
1016 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0},
1018 {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1020 {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
1022 {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1024 {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
1026 {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
1031 static int patch_ad1983(struct hda_codec *codec)
1033 struct ad198x_spec *spec;
1035 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1039 mutex_init(&spec->amp_mutex);
1042 spec->multiout.max_channels = 2;
1043 spec->multiout.num_dacs = ARRAY_SIZE(ad1983_dac_nids);
1044 spec->multiout.dac_nids = ad1983_dac_nids;
1045 spec->multiout.dig_out_nid = AD1983_SPDIF_OUT;
1046 spec->num_adc_nids = 1;
1047 spec->adc_nids = ad1983_adc_nids;
1048 spec->capsrc_nids = ad1983_capsrc_nids;
1049 spec->input_mux = &ad1983_capture_source;
1050 spec->num_mixers = 1;
1051 spec->mixers[0] = ad1983_mixers;
1052 spec->num_init_verbs = 1;
1053 spec->init_verbs[0] = ad1983_init_verbs;
1054 spec->spdif_route = 0;
1056 codec->patch_ops = ad198x_patch_ops;
1063 * AD1981 HD specific
1066 #define AD1981_SPDIF_OUT 0x02
1067 #define AD1981_DAC 0x03
1068 #define AD1981_ADC 0x04
1070 static hda_nid_t ad1981_dac_nids[1] = { AD1981_DAC };
1071 static hda_nid_t ad1981_adc_nids[1] = { AD1981_ADC };
1072 static hda_nid_t ad1981_capsrc_nids[1] = { 0x15 };
1074 /* 0x0c, 0x09, 0x0e, 0x0f, 0x19, 0x05, 0x18, 0x17 */
1075 static struct hda_input_mux ad1981_capture_source = {
1078 { "Front Mic", 0x0 },
1081 { "Mix Mono", 0x3 },
1088 static struct snd_kcontrol_new ad1981_mixers[] = {
1089 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT),
1090 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT),
1091 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT),
1092 HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT),
1093 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT),
1094 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT),
1095 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
1096 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
1097 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
1098 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
1099 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1100 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1101 HDA_CODEC_VOLUME("Aux Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
1102 HDA_CODEC_MUTE("Aux Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1103 HDA_CODEC_VOLUME("Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT),
1104 HDA_CODEC_MUTE("Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
1105 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1106 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1107 HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1108 HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x0d, 1, 0x0, HDA_OUTPUT),
1109 HDA_CODEC_VOLUME("Front Mic Boost", 0x08, 0x0, HDA_INPUT),
1110 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x0, HDA_INPUT),
1111 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1112 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
1114 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1115 .name = "Capture Source",
1116 .info = ad198x_mux_enum_info,
1117 .get = ad198x_mux_enum_get,
1118 .put = ad198x_mux_enum_put,
1120 /* identical with AD1983 */
1122 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1123 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
1124 .info = ad1983_spdif_route_info,
1125 .get = ad1983_spdif_route_get,
1126 .put = ad1983_spdif_route_put,
1131 static struct hda_verb ad1981_init_verbs[] = {
1132 /* Front, HP, Mono; mute as default */
1133 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1134 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1135 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1136 /* Beep, PCM, Front Mic, Line, Rear Mic, Aux, CD-In: mute */
1137 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1138 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1139 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1140 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1141 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1142 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1143 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1144 /* Front, HP selectors; from Mix */
1145 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
1146 {0x06, AC_VERB_SET_CONNECT_SEL, 0x01},
1147 /* Mono selector; from Mix */
1148 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03},
1149 /* Mic Mixer; select Front Mic */
1150 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1151 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1152 /* Mic boost: 0dB */
1153 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1154 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1155 /* Record selector: Front mic */
1156 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0},
1157 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1158 /* SPDIF route: PCM */
1159 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0},
1161 {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1163 {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
1165 {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1166 /* Front & Rear Mic Pins */
1167 {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
1168 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
1170 {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
1172 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
1173 /* Line-Out as Input: disabled */
1174 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1179 * Patch for HP nx6320
1181 * nx6320 uses EAPD in the reserve way - EAPD-on means the internal
1182 * speaker output enabled _and_ mute-LED off.
1185 #define AD1981_HP_EVENT 0x37
1186 #define AD1981_MIC_EVENT 0x38
1188 static struct hda_verb ad1981_hp_init_verbs[] = {
1189 {0x05, AC_VERB_SET_EAPD_BTLENABLE, 0x00 }, /* default off */
1190 /* pin sensing on HP and Mic jacks */
1191 {0x06, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_HP_EVENT},
1192 {0x08, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_MIC_EVENT},
1196 /* turn on/off EAPD (+ mute HP) as a master switch */
1197 static int ad1981_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1198 struct snd_ctl_elem_value *ucontrol)
1200 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1201 struct ad198x_spec *spec = codec->spec;
1203 if (! ad198x_eapd_put(kcontrol, ucontrol))
1206 /* toggle HP mute appropriately */
1207 snd_hda_codec_amp_update(codec, 0x06, 0, HDA_OUTPUT, 0,
1208 0x80, spec->cur_eapd ? 0 : 0x80);
1209 snd_hda_codec_amp_update(codec, 0x06, 1, HDA_OUTPUT, 0,
1210 0x80, spec->cur_eapd ? 0 : 0x80);
1214 /* bind volumes of both NID 0x05 and 0x06 */
1215 static int ad1981_hp_master_vol_put(struct snd_kcontrol *kcontrol,
1216 struct snd_ctl_elem_value *ucontrol)
1218 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1219 long *valp = ucontrol->value.integer.value;
1222 change = snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
1223 0x7f, valp[0] & 0x7f);
1224 change |= snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
1225 0x7f, valp[1] & 0x7f);
1226 snd_hda_codec_amp_update(codec, 0x06, 0, HDA_OUTPUT, 0,
1227 0x7f, valp[0] & 0x7f);
1228 snd_hda_codec_amp_update(codec, 0x06, 1, HDA_OUTPUT, 0,
1229 0x7f, valp[1] & 0x7f);
1233 /* mute internal speaker if HP is plugged */
1234 static void ad1981_hp_automute(struct hda_codec *codec)
1236 unsigned int present;
1238 present = snd_hda_codec_read(codec, 0x06, 0,
1239 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1240 snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
1241 0x80, present ? 0x80 : 0);
1242 snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
1243 0x80, present ? 0x80 : 0);
1246 /* toggle input of built-in and mic jack appropriately */
1247 static void ad1981_hp_automic(struct hda_codec *codec)
1249 static struct hda_verb mic_jack_on[] = {
1250 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1251 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1254 static struct hda_verb mic_jack_off[] = {
1255 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1256 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1259 unsigned int present;
1261 present = snd_hda_codec_read(codec, 0x08, 0,
1262 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1264 snd_hda_sequence_write(codec, mic_jack_on);
1266 snd_hda_sequence_write(codec, mic_jack_off);
1269 /* unsolicited event for HP jack sensing */
1270 static void ad1981_hp_unsol_event(struct hda_codec *codec,
1275 case AD1981_HP_EVENT:
1276 ad1981_hp_automute(codec);
1278 case AD1981_MIC_EVENT:
1279 ad1981_hp_automic(codec);
1284 static struct hda_input_mux ad1981_hp_capture_source = {
1288 { "Docking-Station", 0x1 },
1293 static struct snd_kcontrol_new ad1981_hp_mixers[] = {
1295 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1296 .name = "Master Playback Volume",
1297 .info = snd_hda_mixer_amp_volume_info,
1298 .get = snd_hda_mixer_amp_volume_get,
1299 .put = ad1981_hp_master_vol_put,
1300 .private_value = HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
1303 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1304 .name = "Master Playback Switch",
1305 .info = ad198x_eapd_info,
1306 .get = ad198x_eapd_get,
1307 .put = ad1981_hp_master_sw_put,
1308 .private_value = 0x05,
1310 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
1311 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
1313 /* FIXME: analog mic/line loopback doesn't work with my tests...
1314 * (although recording is OK)
1316 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
1317 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
1318 HDA_CODEC_VOLUME("Docking-Station Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1319 HDA_CODEC_MUTE("Docking-Station Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1320 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT),
1321 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
1322 /* FIXME: does this laptop have analog CD connection? */
1323 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1324 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1326 HDA_CODEC_VOLUME("Mic Boost", 0x08, 0x0, HDA_INPUT),
1327 HDA_CODEC_VOLUME("Internal Mic Boost", 0x18, 0x0, HDA_INPUT),
1328 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1329 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
1331 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1332 .name = "Capture Source",
1333 .info = ad198x_mux_enum_info,
1334 .get = ad198x_mux_enum_get,
1335 .put = ad198x_mux_enum_put,
1340 /* initialize jack-sensing, too */
1341 static int ad1981_hp_init(struct hda_codec *codec)
1344 ad1981_hp_automute(codec);
1345 ad1981_hp_automic(codec);
1349 /* configuration for Lenovo Thinkpad T60 */
1350 static struct snd_kcontrol_new ad1981_thinkpad_mixers[] = {
1351 HDA_CODEC_VOLUME("Master Playback Volume", 0x05, 0x0, HDA_OUTPUT),
1352 HDA_CODEC_MUTE("Master Playback Switch", 0x05, 0x0, HDA_OUTPUT),
1353 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
1354 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
1355 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
1356 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
1357 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1358 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1359 HDA_CODEC_VOLUME("Mic Boost", 0x08, 0x0, HDA_INPUT),
1360 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1361 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
1363 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1364 .name = "Capture Source",
1365 .info = ad198x_mux_enum_info,
1366 .get = ad198x_mux_enum_get,
1367 .put = ad198x_mux_enum_put,
1369 /* identical with AD1983 */
1371 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1372 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
1373 .info = ad1983_spdif_route_info,
1374 .get = ad1983_spdif_route_get,
1375 .put = ad1983_spdif_route_put,
1380 static struct hda_input_mux ad1981_thinkpad_capture_source = {
1397 static const char *ad1981_models[AD1981_MODELS] = {
1399 [AD1981_THINKPAD] = "thinkpad",
1400 [AD1981_BASIC] = "basic",
1403 static struct snd_pci_quirk ad1981_cfg_tbl[] = {
1405 SND_PCI_QUIRK(0x103c, 0, "HP nx", AD1981_HP),
1406 /* HP nx6320 (reversed SSID, H/W bug) */
1407 SND_PCI_QUIRK(0x30b0, 0x103c, "HP nx6320", AD1981_HP),
1408 /* Lenovo Thinkpad T60/X60/Z6xx */
1409 SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1981_THINKPAD),
1410 SND_PCI_QUIRK(0x1014, 0x0597, "Lenovo Z60", AD1981_THINKPAD),
1414 static int patch_ad1981(struct hda_codec *codec)
1416 struct ad198x_spec *spec;
1419 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1423 mutex_init(&spec->amp_mutex);
1426 spec->multiout.max_channels = 2;
1427 spec->multiout.num_dacs = ARRAY_SIZE(ad1981_dac_nids);
1428 spec->multiout.dac_nids = ad1981_dac_nids;
1429 spec->multiout.dig_out_nid = AD1981_SPDIF_OUT;
1430 spec->num_adc_nids = 1;
1431 spec->adc_nids = ad1981_adc_nids;
1432 spec->capsrc_nids = ad1981_capsrc_nids;
1433 spec->input_mux = &ad1981_capture_source;
1434 spec->num_mixers = 1;
1435 spec->mixers[0] = ad1981_mixers;
1436 spec->num_init_verbs = 1;
1437 spec->init_verbs[0] = ad1981_init_verbs;
1438 spec->spdif_route = 0;
1440 codec->patch_ops = ad198x_patch_ops;
1442 /* override some parameters */
1443 board_config = snd_hda_check_board_config(codec, AD1981_MODELS,
1446 switch (board_config) {
1448 spec->mixers[0] = ad1981_hp_mixers;
1449 spec->num_init_verbs = 2;
1450 spec->init_verbs[1] = ad1981_hp_init_verbs;
1451 spec->multiout.dig_out_nid = 0;
1452 spec->input_mux = &ad1981_hp_capture_source;
1454 codec->patch_ops.init = ad1981_hp_init;
1455 codec->patch_ops.unsol_event = ad1981_hp_unsol_event;
1457 case AD1981_THINKPAD:
1458 spec->mixers[0] = ad1981_thinkpad_mixers;
1459 spec->input_mux = &ad1981_thinkpad_capture_source;
1470 * Output pins and routes
1472 * Pin Mix Sel DAC (*)
1473 * port-A 0x11 (mute/hp) <- 0x22 <- 0x37 <- 03/04/06
1474 * port-B 0x14 (mute/hp) <- 0x2b <- 0x30 <- 03/04/06
1475 * port-C 0x15 (mute) <- 0x2c <- 0x31 <- 05/0a
1476 * port-D 0x12 (mute/hp) <- 0x29 <- 04
1477 * port-E 0x17 (mute/hp) <- 0x26 <- 0x32 <- 05/0a
1478 * port-F 0x16 (mute) <- 0x2a <- 06
1479 * port-G 0x24 (mute) <- 0x27 <- 05
1480 * port-H 0x25 (mute) <- 0x28 <- 0a
1481 * mono 0x13 (mute/amp)<- 0x1e <- 0x36 <- 03/04/06
1483 * DAC0 = 03h, DAC1 = 04h, DAC2 = 05h, DAC3 = 06h, DAC4 = 0ah
1484 * (*) DAC2/3/4 are swapped to DAC3/4/2 on AD198A rev.2 due to a h/w bug.
1486 * Input pins and routes
1488 * pin boost mix input # / adc input #
1489 * port-A 0x11 -> 0x38 -> mix 2, ADC 0
1490 * port-B 0x14 -> 0x39 -> mix 0, ADC 1
1491 * port-C 0x15 -> 0x3a -> 33:0 - mix 1, ADC 2
1492 * port-D 0x12 -> 0x3d -> mix 3, ADC 8
1493 * port-E 0x17 -> 0x3c -> 34:0 - mix 4, ADC 4
1494 * port-F 0x16 -> 0x3b -> mix 5, ADC 3
1495 * port-G 0x24 -> N/A -> 33:1 - mix 1, 34:1 - mix 4, ADC 6
1496 * port-H 0x25 -> N/A -> 33:2 - mix 1, 34:2 - mix 4, ADC 7
1500 * 6stack - front/surr/CLFE/side/opt DACs - 04/06/05/0a/03
1501 * 3stack - front/surr/CLFE/opt DACs - 04/05/0a/03
1503 * Inputs of Analog Mix (0x20)
1504 * 0:Port-B (front mic)
1505 * 1:Port-C/G/H (line-in)
1507 * 3:Port-D (line-in/2)
1508 * 4:Port-E/G/H (mic-in)
1509 * 5:Port-F (mic2-in)
1515 * 1:Port-B (front mic-in)
1516 * 2:Port-C (line-in)
1517 * 3:Port-F (mic2-in)
1522 * 8:Port-D (line-in/2)
1525 * Proposed pin assignments by the datasheet
1528 * Port-A front headphone
1538 * Port-A front headphone
1540 * C rear line-in/surround
1542 * E rear mic-in/CLFE
1548 * D internal speaker (with EAPD)
1549 * E/F quad mic array
1565 /* reivision id to check workarounds */
1566 #define AD1988A_REV2 0x100200
1568 #define is_rev2(codec) \
1569 ((codec)->vendor_id == 0x11d41988 && \
1570 (codec)->revision_id == AD1988A_REV2)
1576 static hda_nid_t ad1988_6stack_dac_nids[4] = {
1577 0x04, 0x06, 0x05, 0x0a
1580 static hda_nid_t ad1988_3stack_dac_nids[3] = {
1584 /* for AD1988A revision-2, DAC2-4 are swapped */
1585 static hda_nid_t ad1988_6stack_dac_nids_rev2[4] = {
1586 0x04, 0x05, 0x0a, 0x06
1589 static hda_nid_t ad1988_3stack_dac_nids_rev2[3] = {
1593 static hda_nid_t ad1988_adc_nids[3] = {
1597 static hda_nid_t ad1988_capsrc_nids[3] = {
1601 #define AD1988_SPDIF_OUT 0x02
1602 #define AD1988_SPDIF_IN 0x07
1604 static struct hda_input_mux ad1988_6stack_capture_source = {
1607 { "Front Mic", 0x0 },
1615 static struct hda_input_mux ad1988_laptop_capture_source = {
1618 { "Mic/Line", 0x0 },
1626 static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol,
1627 struct snd_ctl_elem_info *uinfo)
1629 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1630 struct ad198x_spec *spec = codec->spec;
1631 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
1632 spec->num_channel_mode);
1635 static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol,
1636 struct snd_ctl_elem_value *ucontrol)
1638 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1639 struct ad198x_spec *spec = codec->spec;
1640 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
1641 spec->num_channel_mode, spec->multiout.max_channels);
1644 static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol,
1645 struct snd_ctl_elem_value *ucontrol)
1647 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1648 struct ad198x_spec *spec = codec->spec;
1649 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
1650 spec->num_channel_mode,
1651 &spec->multiout.max_channels);
1652 if (err >= 0 && spec->need_dac_fix)
1653 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
1658 static struct snd_kcontrol_new ad1988_6stack_mixers1[] = {
1659 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1660 HDA_CODEC_VOLUME("Surround Playback Volume", 0x06, 0x0, HDA_OUTPUT),
1661 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT),
1662 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT),
1663 HDA_CODEC_VOLUME("Side Playback Volume", 0x0a, 0x0, HDA_OUTPUT),
1667 static struct snd_kcontrol_new ad1988_6stack_mixers1_rev2[] = {
1668 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1669 HDA_CODEC_VOLUME("Surround Playback Volume", 0x05, 0x0, HDA_OUTPUT),
1670 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
1671 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0a, 2, 0x0, HDA_OUTPUT),
1672 HDA_CODEC_VOLUME("Side Playback Volume", 0x06, 0x0, HDA_OUTPUT),
1676 static struct snd_kcontrol_new ad1988_6stack_mixers2[] = {
1677 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT),
1678 HDA_BIND_MUTE("Surround Playback Switch", 0x2a, 2, HDA_INPUT),
1679 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x27, 1, 2, HDA_INPUT),
1680 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x27, 2, 2, HDA_INPUT),
1681 HDA_BIND_MUTE("Side Playback Switch", 0x28, 2, HDA_INPUT),
1682 HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT),
1683 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT),
1685 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT),
1686 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT),
1687 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT),
1688 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT),
1689 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
1690 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
1691 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT),
1692 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT),
1694 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
1695 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
1697 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
1698 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
1700 HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT),
1701 HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT),
1707 static struct snd_kcontrol_new ad1988_3stack_mixers1[] = {
1708 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1709 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT),
1710 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT),
1711 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT),
1715 static struct snd_kcontrol_new ad1988_3stack_mixers1_rev2[] = {
1716 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1717 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT),
1718 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x06, 1, 0x0, HDA_OUTPUT),
1719 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x06, 2, 0x0, HDA_OUTPUT),
1723 static struct snd_kcontrol_new ad1988_3stack_mixers2[] = {
1724 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT),
1725 HDA_BIND_MUTE("Surround Playback Switch", 0x2c, 2, HDA_INPUT),
1726 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x26, 1, 2, HDA_INPUT),
1727 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x26, 2, 2, HDA_INPUT),
1728 HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT),
1729 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT),
1731 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT),
1732 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT),
1733 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT),
1734 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT),
1735 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
1736 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
1737 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT),
1738 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT),
1740 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
1741 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
1743 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
1744 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
1746 HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT),
1747 HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT),
1749 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1750 .name = "Channel Mode",
1751 .info = ad198x_ch_mode_info,
1752 .get = ad198x_ch_mode_get,
1753 .put = ad198x_ch_mode_put,
1760 static struct snd_kcontrol_new ad1988_laptop_mixers[] = {
1761 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1762 HDA_CODEC_MUTE("PCM Playback Switch", 0x29, 0x0, HDA_INPUT),
1763 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT),
1765 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT),
1766 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT),
1767 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x0, HDA_INPUT),
1768 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x0, HDA_INPUT),
1769 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
1770 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
1772 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
1773 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
1775 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
1776 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
1778 HDA_CODEC_VOLUME("Mic Boost", 0x39, 0x0, HDA_OUTPUT),
1781 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1782 .name = "External Amplifier",
1783 .info = ad198x_eapd_info,
1784 .get = ad198x_eapd_get,
1785 .put = ad198x_eapd_put,
1786 .private_value = 0x12 | (1 << 8), /* port-D, inversed */
1793 static struct snd_kcontrol_new ad1988_capture_mixers[] = {
1794 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
1795 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
1796 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
1797 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
1798 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x0e, 0x0, HDA_OUTPUT),
1799 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x0e, 0x0, HDA_OUTPUT),
1801 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1802 /* The multiple "Capture Source" controls confuse alsamixer
1803 * So call somewhat different..
1804 * FIXME: the controls appear in the "playback" view!
1806 /* .name = "Capture Source", */
1807 .name = "Input Source",
1809 .info = ad198x_mux_enum_info,
1810 .get = ad198x_mux_enum_get,
1811 .put = ad198x_mux_enum_put,
1816 static int ad1988_spdif_playback_source_info(struct snd_kcontrol *kcontrol,
1817 struct snd_ctl_elem_info *uinfo)
1819 static char *texts[] = {
1820 "PCM", "ADC1", "ADC2", "ADC3"
1822 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1824 uinfo->value.enumerated.items = 4;
1825 if (uinfo->value.enumerated.item >= 4)
1826 uinfo->value.enumerated.item = 3;
1827 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1831 static int ad1988_spdif_playback_source_get(struct snd_kcontrol *kcontrol,
1832 struct snd_ctl_elem_value *ucontrol)
1834 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1837 sel = snd_hda_codec_read(codec, 0x02, 0, AC_VERB_GET_CONNECT_SEL, 0);
1839 sel = snd_hda_codec_read(codec, 0x0b, 0, AC_VERB_GET_CONNECT_SEL, 0);
1845 ucontrol->value.enumerated.item[0] = sel;
1849 static int ad1988_spdif_playback_source_put(struct snd_kcontrol *kcontrol,
1850 struct snd_ctl_elem_value *ucontrol)
1852 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1856 sel = snd_hda_codec_read(codec, 0x02, 0, AC_VERB_GET_CONNECT_SEL, 0);
1857 if (! ucontrol->value.enumerated.item[0]) {
1860 snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL, 0);
1864 snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL, 1);
1865 sel = snd_hda_codec_read(codec, 0x0b, 0, AC_VERB_GET_CONNECT_SEL, 0) + 1;
1866 change |= sel == ucontrol->value.enumerated.item[0];
1868 snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL,
1869 ucontrol->value.enumerated.item[0] - 1);
1874 static struct snd_kcontrol_new ad1988_spdif_out_mixers[] = {
1875 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
1877 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1878 .name = "IEC958 Playback Source",
1879 .info = ad1988_spdif_playback_source_info,
1880 .get = ad1988_spdif_playback_source_get,
1881 .put = ad1988_spdif_playback_source_put,
1886 static struct snd_kcontrol_new ad1988_spdif_in_mixers[] = {
1887 HDA_CODEC_VOLUME("IEC958 Capture Volume", 0x1c, 0x0, HDA_INPUT),
1893 * initialization verbs
1897 * for 6-stack (+dig)
1899 static struct hda_verb ad1988_6stack_init_verbs[] = {
1900 /* Front, Surround, CLFE, side DAC; unmute as default */
1901 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1902 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1903 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1904 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1905 /* Port-A front headphon path */
1906 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */
1907 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1908 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1909 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1910 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1911 /* Port-D line-out path */
1912 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1913 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1914 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1915 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1916 /* Port-F surround path */
1917 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1918 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1919 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1920 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1921 /* Port-G CLFE path */
1922 {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1923 {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1924 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1925 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1926 /* Port-H side path */
1927 {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1928 {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1929 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1930 {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1932 {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */
1933 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1934 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1935 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1936 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */
1937 /* Port-B front mic-in path */
1938 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1939 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1940 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1941 /* Port-C line-in path */
1942 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1943 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1944 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1945 {0x33, AC_VERB_SET_CONNECT_SEL, 0x0},
1946 /* Port-E mic-in path */
1947 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1948 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1949 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1950 {0x34, AC_VERB_SET_CONNECT_SEL, 0x0},
1955 static struct hda_verb ad1988_capture_init_verbs[] = {
1956 /* mute analog mix */
1957 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1958 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1959 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1960 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1961 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1962 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
1963 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1964 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
1965 /* select ADCs - front-mic */
1966 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
1967 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
1968 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
1970 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1971 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1972 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1977 static struct hda_verb ad1988_spdif_init_verbs[] = {
1979 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */
1980 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x0}, /* ADC1 */
1981 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1982 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1984 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
1985 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x17}, /* 0dB */
1991 * verbs for 3stack (+dig)
1993 static struct hda_verb ad1988_3stack_ch2_init[] = {
1994 /* set port-C to line-in */
1995 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1996 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1997 /* set port-E to mic-in */
1998 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1999 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2003 static struct hda_verb ad1988_3stack_ch6_init[] = {
2004 /* set port-C to surround out */
2005 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2006 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2007 /* set port-E to CLFE out */
2008 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2009 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2013 static struct hda_channel_mode ad1988_3stack_modes[2] = {
2014 { 2, ad1988_3stack_ch2_init },
2015 { 6, ad1988_3stack_ch6_init },
2018 static struct hda_verb ad1988_3stack_init_verbs[] = {
2019 /* Front, Surround, CLFE, side DAC; unmute as default */
2020 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2021 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2022 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2023 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2024 /* Port-A front headphon path */
2025 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */
2026 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2027 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2028 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2029 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2030 /* Port-D line-out path */
2031 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2032 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2033 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2034 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2036 {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */
2037 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2038 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2039 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2040 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */
2041 /* Port-B front mic-in path */
2042 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2043 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2044 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2045 /* Port-C line-in/surround path - 6ch mode as default */
2046 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2047 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2048 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2049 {0x31, AC_VERB_SET_CONNECT_SEL, 0x0}, /* output sel: DAC 0x05 */
2050 {0x33, AC_VERB_SET_CONNECT_SEL, 0x0},
2051 /* Port-E mic-in/CLFE path - 6ch mode as default */
2052 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2053 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2054 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2055 {0x32, AC_VERB_SET_CONNECT_SEL, 0x1}, /* output sel: DAC 0x0a */
2056 {0x34, AC_VERB_SET_CONNECT_SEL, 0x0},
2057 /* mute analog mix */
2058 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2059 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2060 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2061 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2062 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2063 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
2064 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2065 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2066 /* select ADCs - front-mic */
2067 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
2068 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
2069 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
2071 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2072 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2073 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2078 * verbs for laptop mode (+dig)
2080 static struct hda_verb ad1988_laptop_hp_on[] = {
2081 /* unmute port-A and mute port-D */
2082 { 0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2083 { 0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2086 static struct hda_verb ad1988_laptop_hp_off[] = {
2087 /* mute port-A and unmute port-D */
2088 { 0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2089 { 0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2093 #define AD1988_HP_EVENT 0x01
2095 static struct hda_verb ad1988_laptop_init_verbs[] = {
2096 /* Front, Surround, CLFE, side DAC; unmute as default */
2097 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2098 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2099 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2100 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2101 /* Port-A front headphon path */
2102 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */
2103 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2104 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2105 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2106 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2107 /* unsolicited event for pin-sense */
2108 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1988_HP_EVENT },
2109 /* Port-D line-out path + EAPD */
2110 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2111 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2112 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2113 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2114 {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x00}, /* EAPD-off */
2116 {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */
2117 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2118 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2119 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2120 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */
2121 /* Port-B mic-in path */
2122 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2123 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2124 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2125 /* Port-C docking station - try to output */
2126 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2127 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2128 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2129 {0x33, AC_VERB_SET_CONNECT_SEL, 0x0},
2130 /* mute analog mix */
2131 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2132 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2133 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2134 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2135 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2136 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
2137 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2138 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2139 /* select ADCs - mic */
2140 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
2141 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
2142 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
2144 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2145 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2146 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2150 static void ad1988_laptop_unsol_event(struct hda_codec *codec, unsigned int res)
2152 if ((res >> 26) != AD1988_HP_EVENT)
2154 if (snd_hda_codec_read(codec, 0x11, 0, AC_VERB_GET_PIN_SENSE, 0) & (1 << 31))
2155 snd_hda_sequence_write(codec, ad1988_laptop_hp_on);
2157 snd_hda_sequence_write(codec, ad1988_laptop_hp_off);
2162 * Automatic parse of I/O pins from the BIOS configuration
2165 #define NUM_CONTROL_ALLOC 32
2166 #define NUM_VERB_ALLOC 32
2173 static struct snd_kcontrol_new ad1988_control_templates[] = {
2174 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2175 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2176 HDA_BIND_MUTE(NULL, 0, 0, 0),
2179 /* add dynamic controls */
2180 static int add_control(struct ad198x_spec *spec, int type, const char *name,
2183 struct snd_kcontrol_new *knew;
2185 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2186 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2188 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2191 if (spec->kctl_alloc) {
2192 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2193 kfree(spec->kctl_alloc);
2195 spec->kctl_alloc = knew;
2196 spec->num_kctl_alloc = num;
2199 knew = &spec->kctl_alloc[spec->num_kctl_used];
2200 *knew = ad1988_control_templates[type];
2201 knew->name = kstrdup(name, GFP_KERNEL);
2204 knew->private_value = val;
2205 spec->num_kctl_used++;
2209 #define AD1988_PIN_CD_NID 0x18
2210 #define AD1988_PIN_BEEP_NID 0x10
2212 static hda_nid_t ad1988_mixer_nids[8] = {
2213 /* A B C D E F G H */
2214 0x22, 0x2b, 0x2c, 0x29, 0x26, 0x2a, 0x27, 0x28
2217 static inline hda_nid_t ad1988_idx_to_dac(struct hda_codec *codec, int idx)
2219 static hda_nid_t idx_to_dac[8] = {
2220 /* A B C D E F G H */
2221 0x04, 0x06, 0x05, 0x04, 0x0a, 0x06, 0x05, 0x0a
2223 static hda_nid_t idx_to_dac_rev2[8] = {
2224 /* A B C D E F G H */
2225 0x04, 0x05, 0x0a, 0x04, 0x06, 0x05, 0x0a, 0x06
2228 return idx_to_dac_rev2[idx];
2230 return idx_to_dac[idx];
2233 static hda_nid_t ad1988_boost_nids[8] = {
2234 0x38, 0x39, 0x3a, 0x3d, 0x3c, 0x3b, 0, 0
2237 static int ad1988_pin_idx(hda_nid_t nid)
2239 static hda_nid_t ad1988_io_pins[8] = {
2240 0x11, 0x14, 0x15, 0x12, 0x17, 0x16, 0x24, 0x25
2243 for (i = 0; i < ARRAY_SIZE(ad1988_io_pins); i++)
2244 if (ad1988_io_pins[i] == nid)
2246 return 0; /* should be -1 */
2249 static int ad1988_pin_to_loopback_idx(hda_nid_t nid)
2251 static int loopback_idx[8] = {
2252 2, 0, 1, 3, 4, 5, 1, 4
2255 case AD1988_PIN_CD_NID:
2258 return loopback_idx[ad1988_pin_idx(nid)];
2262 static int ad1988_pin_to_adc_idx(hda_nid_t nid)
2264 static int adc_idx[8] = {
2265 0, 1, 2, 8, 4, 3, 6, 7
2268 case AD1988_PIN_CD_NID:
2271 return adc_idx[ad1988_pin_idx(nid)];
2275 /* fill in the dac_nids table from the parsed pin configuration */
2276 static int ad1988_auto_fill_dac_nids(struct hda_codec *codec,
2277 const struct auto_pin_cfg *cfg)
2279 struct ad198x_spec *spec = codec->spec;
2282 spec->multiout.dac_nids = spec->private_dac_nids;
2284 /* check the pins hardwired to audio widget */
2285 for (i = 0; i < cfg->line_outs; i++) {
2286 idx = ad1988_pin_idx(cfg->line_out_pins[i]);
2287 spec->multiout.dac_nids[i] = ad1988_idx_to_dac(codec, idx);
2289 spec->multiout.num_dacs = cfg->line_outs;
2293 /* add playback controls from the parsed DAC table */
2294 static int ad1988_auto_create_multi_out_ctls(struct ad198x_spec *spec,
2295 const struct auto_pin_cfg *cfg)
2298 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
2302 for (i = 0; i < cfg->line_outs; i++) {
2303 hda_nid_t dac = spec->multiout.dac_nids[i];
2306 nid = ad1988_mixer_nids[ad1988_pin_idx(cfg->line_out_pins[i])];
2309 err = add_control(spec, AD_CTL_WIDGET_VOL,
2310 "Center Playback Volume",
2311 HDA_COMPOSE_AMP_VAL(dac, 1, 0, HDA_OUTPUT));
2314 err = add_control(spec, AD_CTL_WIDGET_VOL,
2315 "LFE Playback Volume",
2316 HDA_COMPOSE_AMP_VAL(dac, 2, 0, HDA_OUTPUT));
2319 err = add_control(spec, AD_CTL_BIND_MUTE,
2320 "Center Playback Switch",
2321 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT));
2324 err = add_control(spec, AD_CTL_BIND_MUTE,
2325 "LFE Playback Switch",
2326 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT));
2330 sprintf(name, "%s Playback Volume", chname[i]);
2331 err = add_control(spec, AD_CTL_WIDGET_VOL, name,
2332 HDA_COMPOSE_AMP_VAL(dac, 3, 0, HDA_OUTPUT));
2335 sprintf(name, "%s Playback Switch", chname[i]);
2336 err = add_control(spec, AD_CTL_BIND_MUTE, name,
2337 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
2345 /* add playback controls for speaker and HP outputs */
2346 static int ad1988_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
2349 struct ad198x_spec *spec = codec->spec;
2357 idx = ad1988_pin_idx(pin);
2358 nid = ad1988_idx_to_dac(codec, idx);
2359 /* specify the DAC as the extra output */
2360 if (! spec->multiout.hp_nid)
2361 spec->multiout.hp_nid = nid;
2363 spec->multiout.extra_out_nid[0] = nid;
2364 /* control HP volume/switch on the output mixer amp */
2365 sprintf(name, "%s Playback Volume", pfx);
2366 if ((err = add_control(spec, AD_CTL_WIDGET_VOL, name,
2367 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2369 nid = ad1988_mixer_nids[idx];
2370 sprintf(name, "%s Playback Switch", pfx);
2371 if ((err = add_control(spec, AD_CTL_BIND_MUTE, name,
2372 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2377 /* create input playback/capture controls for the given pin */
2378 static int new_analog_input(struct ad198x_spec *spec, hda_nid_t pin,
2379 const char *ctlname, int boost)
2384 sprintf(name, "%s Playback Volume", ctlname);
2385 idx = ad1988_pin_to_loopback_idx(pin);
2386 if ((err = add_control(spec, AD_CTL_WIDGET_VOL, name,
2387 HDA_COMPOSE_AMP_VAL(0x20, 3, idx, HDA_INPUT))) < 0)
2389 sprintf(name, "%s Playback Switch", ctlname);
2390 if ((err = add_control(spec, AD_CTL_WIDGET_MUTE, name,
2391 HDA_COMPOSE_AMP_VAL(0x20, 3, idx, HDA_INPUT))) < 0)
2395 idx = ad1988_pin_idx(pin);
2396 bnid = ad1988_boost_nids[idx];
2398 sprintf(name, "%s Boost", ctlname);
2399 return add_control(spec, AD_CTL_WIDGET_VOL, name,
2400 HDA_COMPOSE_AMP_VAL(bnid, 3, idx, HDA_OUTPUT));
2407 /* create playback/capture controls for input pins */
2408 static int ad1988_auto_create_analog_input_ctls(struct ad198x_spec *spec,
2409 const struct auto_pin_cfg *cfg)
2411 struct hda_input_mux *imux = &spec->private_imux;
2414 for (i = 0; i < AUTO_PIN_LAST; i++) {
2415 err = new_analog_input(spec, cfg->input_pins[i],
2416 auto_pin_cfg_labels[i],
2417 i <= AUTO_PIN_FRONT_MIC);
2420 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2421 imux->items[imux->num_items].index = ad1988_pin_to_adc_idx(cfg->input_pins[i]);
2424 imux->items[imux->num_items].label = "Mix";
2425 imux->items[imux->num_items].index = 9;
2428 if ((err = add_control(spec, AD_CTL_WIDGET_VOL,
2429 "Analog Mix Playback Volume",
2430 HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT))) < 0)
2432 if ((err = add_control(spec, AD_CTL_WIDGET_MUTE,
2433 "Analog Mix Playback Switch",
2434 HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT))) < 0)
2440 static void ad1988_auto_set_output_and_unmute(struct hda_codec *codec,
2441 hda_nid_t nid, int pin_type,
2445 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2446 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2448 case 0x11: /* port-A - DAC 04 */
2449 snd_hda_codec_write(codec, 0x37, 0, AC_VERB_SET_CONNECT_SEL, 0x01);
2451 case 0x14: /* port-B - DAC 06 */
2452 snd_hda_codec_write(codec, 0x30, 0, AC_VERB_SET_CONNECT_SEL, 0x02);
2454 case 0x15: /* port-C - DAC 05 */
2455 snd_hda_codec_write(codec, 0x31, 0, AC_VERB_SET_CONNECT_SEL, 0x00);
2457 case 0x17: /* port-E - DAC 0a */
2458 snd_hda_codec_write(codec, 0x32, 0, AC_VERB_SET_CONNECT_SEL, 0x01);
2460 case 0x13: /* mono - DAC 04 */
2461 snd_hda_codec_write(codec, 0x36, 0, AC_VERB_SET_CONNECT_SEL, 0x01);
2466 static void ad1988_auto_init_multi_out(struct hda_codec *codec)
2468 struct ad198x_spec *spec = codec->spec;
2471 for (i = 0; i < spec->autocfg.line_outs; i++) {
2472 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2473 ad1988_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2477 static void ad1988_auto_init_extra_out(struct hda_codec *codec)
2479 struct ad198x_spec *spec = codec->spec;
2482 pin = spec->autocfg.speaker_pins[0];
2483 if (pin) /* connect to front */
2484 ad1988_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
2485 pin = spec->autocfg.hp_pins[0];
2486 if (pin) /* connect to front */
2487 ad1988_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2490 static void ad1988_auto_init_analog_input(struct hda_codec *codec)
2492 struct ad198x_spec *spec = codec->spec;
2495 for (i = 0; i < AUTO_PIN_LAST; i++) {
2496 hda_nid_t nid = spec->autocfg.input_pins[i];
2500 case 0x15: /* port-C */
2501 snd_hda_codec_write(codec, 0x33, 0, AC_VERB_SET_CONNECT_SEL, 0x0);
2503 case 0x17: /* port-E */
2504 snd_hda_codec_write(codec, 0x34, 0, AC_VERB_SET_CONNECT_SEL, 0x0);
2507 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2508 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2509 if (nid != AD1988_PIN_CD_NID)
2510 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2512 idx = ad1988_pin_idx(nid);
2513 if (ad1988_boost_nids[idx])
2514 snd_hda_codec_write(codec, ad1988_boost_nids[idx], 0,
2515 AC_VERB_SET_AMP_GAIN_MUTE,
2520 /* parse the BIOS configuration and set up the alc_spec */
2521 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2522 static int ad1988_parse_auto_config(struct hda_codec *codec)
2524 struct ad198x_spec *spec = codec->spec;
2527 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
2529 if ((err = ad1988_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
2531 if (! spec->autocfg.line_outs)
2532 return 0; /* can't find valid BIOS pin config */
2533 if ((err = ad1988_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
2534 (err = ad1988_auto_create_extra_out(codec,
2535 spec->autocfg.speaker_pins[0],
2537 (err = ad1988_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
2538 "Headphone")) < 0 ||
2539 (err = ad1988_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2542 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2544 if (spec->autocfg.dig_out_pin)
2545 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
2546 if (spec->autocfg.dig_in_pin)
2547 spec->dig_in_nid = AD1988_SPDIF_IN;
2549 if (spec->kctl_alloc)
2550 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2552 spec->init_verbs[spec->num_init_verbs++] = ad1988_6stack_init_verbs;
2554 spec->input_mux = &spec->private_imux;
2559 /* init callback for auto-configuration model -- overriding the default init */
2560 static int ad1988_auto_init(struct hda_codec *codec)
2563 ad1988_auto_init_multi_out(codec);
2564 ad1988_auto_init_extra_out(codec);
2565 ad1988_auto_init_analog_input(codec);
2573 static const char *ad1988_models[AD1988_MODEL_LAST] = {
2574 [AD1988_6STACK] = "6stack",
2575 [AD1988_6STACK_DIG] = "6stack-dig",
2576 [AD1988_3STACK] = "3stack",
2577 [AD1988_3STACK_DIG] = "3stack-dig",
2578 [AD1988_LAPTOP] = "laptop",
2579 [AD1988_LAPTOP_DIG] = "laptop-dig",
2580 [AD1988_AUTO] = "auto",
2583 static int patch_ad1988(struct hda_codec *codec)
2585 struct ad198x_spec *spec;
2588 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2592 mutex_init(&spec->amp_mutex);
2596 snd_printk(KERN_INFO "patch_analog: AD1988A rev.2 is detected, enable workarounds\n");
2598 board_config = snd_hda_check_board_config(codec, AD1988_MODEL_LAST,
2599 ad1988_models, NULL);
2600 if (board_config < 0) {
2601 printk(KERN_INFO "hda_codec: Unknown model for AD1988, trying auto-probe from BIOS...\n");
2602 board_config = AD1988_AUTO;
2605 if (board_config == AD1988_AUTO) {
2606 /* automatic parse from the BIOS config */
2607 int err = ad1988_parse_auto_config(codec);
2612 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 6-stack mode...\n");
2613 board_config = AD1988_6STACK;
2617 switch (board_config) {
2619 case AD1988_6STACK_DIG:
2620 spec->multiout.max_channels = 8;
2621 spec->multiout.num_dacs = 4;
2623 spec->multiout.dac_nids = ad1988_6stack_dac_nids_rev2;
2625 spec->multiout.dac_nids = ad1988_6stack_dac_nids;
2626 spec->input_mux = &ad1988_6stack_capture_source;
2627 spec->num_mixers = 2;
2629 spec->mixers[0] = ad1988_6stack_mixers1_rev2;
2631 spec->mixers[0] = ad1988_6stack_mixers1;
2632 spec->mixers[1] = ad1988_6stack_mixers2;
2633 spec->num_init_verbs = 1;
2634 spec->init_verbs[0] = ad1988_6stack_init_verbs;
2635 if (board_config == AD1988_6STACK_DIG) {
2636 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
2637 spec->dig_in_nid = AD1988_SPDIF_IN;
2641 case AD1988_3STACK_DIG:
2642 spec->multiout.max_channels = 6;
2643 spec->multiout.num_dacs = 3;
2645 spec->multiout.dac_nids = ad1988_3stack_dac_nids_rev2;
2647 spec->multiout.dac_nids = ad1988_3stack_dac_nids;
2648 spec->input_mux = &ad1988_6stack_capture_source;
2649 spec->channel_mode = ad1988_3stack_modes;
2650 spec->num_channel_mode = ARRAY_SIZE(ad1988_3stack_modes);
2651 spec->num_mixers = 2;
2653 spec->mixers[0] = ad1988_3stack_mixers1_rev2;
2655 spec->mixers[0] = ad1988_3stack_mixers1;
2656 spec->mixers[1] = ad1988_3stack_mixers2;
2657 spec->num_init_verbs = 1;
2658 spec->init_verbs[0] = ad1988_3stack_init_verbs;
2659 if (board_config == AD1988_3STACK_DIG)
2660 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
2663 case AD1988_LAPTOP_DIG:
2664 spec->multiout.max_channels = 2;
2665 spec->multiout.num_dacs = 1;
2666 spec->multiout.dac_nids = ad1988_3stack_dac_nids;
2667 spec->input_mux = &ad1988_laptop_capture_source;
2668 spec->num_mixers = 1;
2669 spec->mixers[0] = ad1988_laptop_mixers;
2670 spec->num_init_verbs = 1;
2671 spec->init_verbs[0] = ad1988_laptop_init_verbs;
2672 if (board_config == AD1988_LAPTOP_DIG)
2673 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
2677 spec->num_adc_nids = ARRAY_SIZE(ad1988_adc_nids);
2678 spec->adc_nids = ad1988_adc_nids;
2679 spec->capsrc_nids = ad1988_capsrc_nids;
2680 spec->mixers[spec->num_mixers++] = ad1988_capture_mixers;
2681 spec->init_verbs[spec->num_init_verbs++] = ad1988_capture_init_verbs;
2682 if (spec->multiout.dig_out_nid) {
2683 spec->mixers[spec->num_mixers++] = ad1988_spdif_out_mixers;
2684 spec->init_verbs[spec->num_init_verbs++] = ad1988_spdif_init_verbs;
2686 if (spec->dig_in_nid)
2687 spec->mixers[spec->num_mixers++] = ad1988_spdif_in_mixers;
2689 codec->patch_ops = ad198x_patch_ops;
2690 switch (board_config) {
2692 codec->patch_ops.init = ad1988_auto_init;
2695 case AD1988_LAPTOP_DIG:
2696 codec->patch_ops.unsol_event = ad1988_laptop_unsol_event;
2707 struct hda_codec_preset snd_hda_preset_analog[] = {
2708 { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 },
2709 { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 },
2710 { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a },
2711 { .id = 0x11d41988, .name = "AD1988", .patch = patch_ad1988 },
2712 { .id = 0x11d4198b, .name = "AD1988B", .patch = patch_ad1988 },