2 * HD audio interface patch for AD1884, AD1981HD, AD1983, AD1984, AD1986A,
5 * Copyright (c) 2005-2007 Takashi Iwai <tiwai@suse.de>
7 * This driver is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This driver is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <sound/driver.h>
23 #include <linux/init.h>
24 #include <linux/delay.h>
25 #include <linux/slab.h>
26 #include <linux/pci.h>
27 #include <linux/mutex.h>
29 #include <sound/core.h>
30 #include "hda_codec.h"
31 #include "hda_local.h"
34 struct snd_kcontrol_new *mixers[5];
37 const struct hda_verb *init_verbs[5]; /* initialization verbs
38 * don't forget NULL termination!
40 unsigned int num_init_verbs;
43 struct hda_multi_out multiout; /* playback set-up
44 * max_channels, dacs must be set
45 * dig_out_nid and hp_nid are optional
47 unsigned int cur_eapd;
48 unsigned int need_dac_fix;
51 unsigned int num_adc_nids;
53 hda_nid_t dig_in_nid; /* digital-in NID; optional */
56 const struct hda_input_mux *input_mux;
57 hda_nid_t *capsrc_nids;
58 unsigned int cur_mux[3];
61 const struct hda_channel_mode *channel_mode;
65 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
67 struct mutex amp_mutex; /* PCM volume/mute control mutex */
68 unsigned int spdif_route;
70 /* dynamic controls, init_verbs and input_mux */
71 struct auto_pin_cfg autocfg;
72 unsigned int num_kctl_alloc, num_kctl_used;
73 struct snd_kcontrol_new *kctl_alloc;
74 struct hda_input_mux private_imux;
75 hda_nid_t private_dac_nids[4];
79 * input MUX handling (common part)
81 static int ad198x_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
83 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
84 struct ad198x_spec *spec = codec->spec;
86 return snd_hda_input_mux_info(spec->input_mux, uinfo);
89 static int ad198x_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
91 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
92 struct ad198x_spec *spec = codec->spec;
93 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
95 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
99 static int ad198x_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
101 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
102 struct ad198x_spec *spec = codec->spec;
103 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
105 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
106 spec->capsrc_nids[adc_idx],
107 &spec->cur_mux[adc_idx]);
111 * initialization (common callbacks)
113 static int ad198x_init(struct hda_codec *codec)
115 struct ad198x_spec *spec = codec->spec;
118 for (i = 0; i < spec->num_init_verbs; i++)
119 snd_hda_sequence_write(codec, spec->init_verbs[i]);
123 static int ad198x_build_controls(struct hda_codec *codec)
125 struct ad198x_spec *spec = codec->spec;
129 for (i = 0; i < spec->num_mixers; i++) {
130 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
134 if (spec->multiout.dig_out_nid) {
135 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
139 if (spec->dig_in_nid) {
140 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
148 * Analog playback callbacks
150 static int ad198x_playback_pcm_open(struct hda_pcm_stream *hinfo,
151 struct hda_codec *codec,
152 struct snd_pcm_substream *substream)
154 struct ad198x_spec *spec = codec->spec;
155 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
158 static int ad198x_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
159 struct hda_codec *codec,
160 unsigned int stream_tag,
162 struct snd_pcm_substream *substream)
164 struct ad198x_spec *spec = codec->spec;
165 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
169 static int ad198x_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
170 struct hda_codec *codec,
171 struct snd_pcm_substream *substream)
173 struct ad198x_spec *spec = codec->spec;
174 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
180 static int ad198x_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
181 struct hda_codec *codec,
182 struct snd_pcm_substream *substream)
184 struct ad198x_spec *spec = codec->spec;
185 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
188 static int ad198x_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
189 struct hda_codec *codec,
190 struct snd_pcm_substream *substream)
192 struct ad198x_spec *spec = codec->spec;
193 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
196 static int ad198x_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
197 struct hda_codec *codec,
198 unsigned int stream_tag,
200 struct snd_pcm_substream *substream)
202 struct ad198x_spec *spec = codec->spec;
203 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag,
210 static int ad198x_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
211 struct hda_codec *codec,
212 unsigned int stream_tag,
214 struct snd_pcm_substream *substream)
216 struct ad198x_spec *spec = codec->spec;
217 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
218 stream_tag, 0, format);
222 static int ad198x_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
223 struct hda_codec *codec,
224 struct snd_pcm_substream *substream)
226 struct ad198x_spec *spec = codec->spec;
227 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
235 static struct hda_pcm_stream ad198x_pcm_analog_playback = {
238 .channels_max = 6, /* changed later */
239 .nid = 0, /* fill later */
241 .open = ad198x_playback_pcm_open,
242 .prepare = ad198x_playback_pcm_prepare,
243 .cleanup = ad198x_playback_pcm_cleanup
247 static struct hda_pcm_stream ad198x_pcm_analog_capture = {
251 .nid = 0, /* fill later */
253 .prepare = ad198x_capture_pcm_prepare,
254 .cleanup = ad198x_capture_pcm_cleanup
258 static struct hda_pcm_stream ad198x_pcm_digital_playback = {
262 .nid = 0, /* fill later */
264 .open = ad198x_dig_playback_pcm_open,
265 .close = ad198x_dig_playback_pcm_close,
266 .prepare = ad198x_dig_playback_pcm_prepare
270 static struct hda_pcm_stream ad198x_pcm_digital_capture = {
274 /* NID is set in alc_build_pcms */
277 static int ad198x_build_pcms(struct hda_codec *codec)
279 struct ad198x_spec *spec = codec->spec;
280 struct hda_pcm *info = spec->pcm_rec;
283 codec->pcm_info = info;
285 info->name = "AD198x Analog";
286 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_analog_playback;
287 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->multiout.max_channels;
288 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
289 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_analog_capture;
290 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adc_nids;
291 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
293 if (spec->multiout.dig_out_nid) {
296 info->name = "AD198x Digital";
297 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_digital_playback;
298 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
299 if (spec->dig_in_nid) {
300 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_digital_capture;
301 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
308 static void ad198x_free(struct hda_codec *codec)
310 struct ad198x_spec *spec = codec->spec;
313 if (spec->kctl_alloc) {
314 for (i = 0; i < spec->num_kctl_used; i++)
315 kfree(spec->kctl_alloc[i].name);
316 kfree(spec->kctl_alloc);
322 static int ad198x_resume(struct hda_codec *codec)
324 struct ad198x_spec *spec = codec->spec;
327 codec->patch_ops.init(codec);
328 for (i = 0; i < spec->num_mixers; i++)
329 snd_hda_resume_ctls(codec, spec->mixers[i]);
330 if (spec->multiout.dig_out_nid)
331 snd_hda_resume_spdif_out(codec);
332 if (spec->dig_in_nid)
333 snd_hda_resume_spdif_in(codec);
338 static struct hda_codec_ops ad198x_patch_ops = {
339 .build_controls = ad198x_build_controls,
340 .build_pcms = ad198x_build_pcms,
344 .resume = ad198x_resume,
351 * the private value = nid | (invert << 8)
353 static int ad198x_eapd_info(struct snd_kcontrol *kcontrol,
354 struct snd_ctl_elem_info *uinfo)
356 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
358 uinfo->value.integer.min = 0;
359 uinfo->value.integer.max = 1;
363 static int ad198x_eapd_get(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;
370 ucontrol->value.integer.value[0] = ! spec->cur_eapd;
372 ucontrol->value.integer.value[0] = spec->cur_eapd;
376 static int ad198x_eapd_put(struct snd_kcontrol *kcontrol,
377 struct snd_ctl_elem_value *ucontrol)
379 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
380 struct ad198x_spec *spec = codec->spec;
381 int invert = (kcontrol->private_value >> 8) & 1;
382 hda_nid_t nid = kcontrol->private_value & 0xff;
384 eapd = ucontrol->value.integer.value[0];
387 if (eapd == spec->cur_eapd && ! codec->in_resume)
389 spec->cur_eapd = eapd;
390 snd_hda_codec_write(codec, nid,
391 0, AC_VERB_SET_EAPD_BTLENABLE,
396 static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol,
397 struct snd_ctl_elem_info *uinfo);
398 static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol,
399 struct snd_ctl_elem_value *ucontrol);
400 static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol,
401 struct snd_ctl_elem_value *ucontrol);
408 #define AD1986A_SPDIF_OUT 0x02
409 #define AD1986A_FRONT_DAC 0x03
410 #define AD1986A_SURR_DAC 0x04
411 #define AD1986A_CLFE_DAC 0x05
412 #define AD1986A_ADC 0x06
414 static hda_nid_t ad1986a_dac_nids[3] = {
415 AD1986A_FRONT_DAC, AD1986A_SURR_DAC, AD1986A_CLFE_DAC
417 static hda_nid_t ad1986a_adc_nids[1] = { AD1986A_ADC };
418 static hda_nid_t ad1986a_capsrc_nids[1] = { 0x12 };
420 static struct hda_input_mux ad1986a_capture_source = {
436 * bind volumes/mutes of 3 DACs as a single PCM control for simplicity
439 #define ad1986a_pcm_amp_vol_info snd_hda_mixer_amp_volume_info
441 static int ad1986a_pcm_amp_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
443 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
444 struct ad198x_spec *ad = codec->spec;
446 mutex_lock(&ad->amp_mutex);
447 snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
448 mutex_unlock(&ad->amp_mutex);
452 static int ad1986a_pcm_amp_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
454 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
455 struct ad198x_spec *ad = codec->spec;
458 mutex_lock(&ad->amp_mutex);
459 for (i = 0; i < ARRAY_SIZE(ad1986a_dac_nids); i++) {
460 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(ad1986a_dac_nids[i], 3, 0, HDA_OUTPUT);
461 change |= snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
463 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT);
464 mutex_unlock(&ad->amp_mutex);
468 #define ad1986a_pcm_amp_sw_info snd_hda_mixer_amp_switch_info
470 static int ad1986a_pcm_amp_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
472 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
473 struct ad198x_spec *ad = codec->spec;
475 mutex_lock(&ad->amp_mutex);
476 snd_hda_mixer_amp_switch_get(kcontrol, ucontrol);
477 mutex_unlock(&ad->amp_mutex);
481 static int ad1986a_pcm_amp_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
483 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
484 struct ad198x_spec *ad = codec->spec;
487 mutex_lock(&ad->amp_mutex);
488 for (i = 0; i < ARRAY_SIZE(ad1986a_dac_nids); i++) {
489 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(ad1986a_dac_nids[i], 3, 0, HDA_OUTPUT);
490 change |= snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
492 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT);
493 mutex_unlock(&ad->amp_mutex);
500 static struct snd_kcontrol_new ad1986a_mixers[] = {
502 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
503 .name = "PCM Playback Volume",
504 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
505 SNDRV_CTL_ELEM_ACCESS_TLV_READ |
506 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK,
507 .info = ad1986a_pcm_amp_vol_info,
508 .get = ad1986a_pcm_amp_vol_get,
509 .put = ad1986a_pcm_amp_vol_put,
510 .tlv = { .c = snd_hda_mixer_amp_tlv },
511 .private_value = HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT)
514 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
515 .name = "PCM Playback Switch",
516 .info = ad1986a_pcm_amp_sw_info,
517 .get = ad1986a_pcm_amp_sw_get,
518 .put = ad1986a_pcm_amp_sw_put,
519 .private_value = HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT)
521 HDA_CODEC_VOLUME("Front Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
522 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
523 HDA_CODEC_VOLUME("Surround Playback Volume", 0x1c, 0x0, HDA_OUTPUT),
524 HDA_CODEC_MUTE("Surround Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
525 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x1d, 1, 0x0, HDA_OUTPUT),
526 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x1d, 2, 0x0, HDA_OUTPUT),
527 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x1d, 1, 0x0, HDA_OUTPUT),
528 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x1d, 2, 0x0, HDA_OUTPUT),
529 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT),
530 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
531 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT),
532 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT),
533 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT),
534 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT),
535 HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT),
536 HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT),
537 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
538 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
539 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
540 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT),
541 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT),
542 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
543 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT),
544 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
545 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
547 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
548 .name = "Capture Source",
549 .info = ad198x_mux_enum_info,
550 .get = ad198x_mux_enum_get,
551 .put = ad198x_mux_enum_put,
553 HDA_CODEC_MUTE("Stereo Downmix Switch", 0x09, 0x0, HDA_OUTPUT),
557 /* additional mixers for 3stack mode */
558 static struct snd_kcontrol_new ad1986a_3st_mixers[] = {
560 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
561 .name = "Channel Mode",
562 .info = ad198x_ch_mode_info,
563 .get = ad198x_ch_mode_get,
564 .put = ad198x_ch_mode_put,
569 /* laptop model - 2ch only */
570 static hda_nid_t ad1986a_laptop_dac_nids[1] = { AD1986A_FRONT_DAC };
572 static struct snd_kcontrol_new ad1986a_laptop_mixers[] = {
573 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
574 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
575 HDA_CODEC_VOLUME("Master Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
576 HDA_CODEC_MUTE("Master Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
577 /* HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT),
578 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT), */
579 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT),
580 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT),
581 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT),
582 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT),
583 HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT),
584 HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT),
585 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
586 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
587 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
588 /* HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT),
589 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT),
590 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
591 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), */
592 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
593 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
595 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
596 .name = "Capture Source",
597 .info = ad198x_mux_enum_info,
598 .get = ad198x_mux_enum_get,
599 .put = ad198x_mux_enum_put,
604 /* laptop-eapd model - 2ch only */
606 /* master controls both pins 0x1a and 0x1b */
607 static int ad1986a_laptop_master_vol_put(struct snd_kcontrol *kcontrol,
608 struct snd_ctl_elem_value *ucontrol)
610 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
611 long *valp = ucontrol->value.integer.value;
614 change = snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0,
615 0x7f, valp[0] & 0x7f);
616 change |= snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0,
617 0x7f, valp[1] & 0x7f);
618 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
619 0x7f, valp[0] & 0x7f);
620 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
621 0x7f, valp[1] & 0x7f);
625 static int ad1986a_laptop_master_sw_put(struct snd_kcontrol *kcontrol,
626 struct snd_ctl_elem_value *ucontrol)
628 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
629 long *valp = ucontrol->value.integer.value;
632 change = snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0,
633 0x80, valp[0] ? 0 : 0x80);
634 change |= snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0,
635 0x80, valp[1] ? 0 : 0x80);
636 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
637 0x80, valp[0] ? 0 : 0x80);
638 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
639 0x80, valp[1] ? 0 : 0x80);
643 static struct hda_input_mux ad1986a_laptop_eapd_capture_source = {
647 { "Internal Mic", 0x4 },
652 static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = {
654 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
655 .name = "Master Playback Volume",
656 .info = snd_hda_mixer_amp_volume_info,
657 .get = snd_hda_mixer_amp_volume_get,
658 .put = ad1986a_laptop_master_vol_put,
659 .tlv = { .c = snd_hda_mixer_amp_tlv },
660 .private_value = HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT),
663 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
664 .name = "Master Playback Switch",
665 .info = snd_hda_mixer_amp_switch_info,
666 .get = snd_hda_mixer_amp_switch_get,
667 .put = ad1986a_laptop_master_sw_put,
668 .private_value = HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT),
670 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
671 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
672 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x0, HDA_OUTPUT),
673 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x0, HDA_OUTPUT),
674 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
675 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
676 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
677 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
678 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
680 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
681 .name = "Capture Source",
682 .info = ad198x_mux_enum_info,
683 .get = ad198x_mux_enum_get,
684 .put = ad198x_mux_enum_put,
687 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
688 .name = "External Amplifier",
689 .info = ad198x_eapd_info,
690 .get = ad198x_eapd_get,
691 .put = ad198x_eapd_put,
692 .private_value = 0x1b | (1 << 8), /* port-D, inversed */
698 * initialization verbs
700 static struct hda_verb ad1986a_init_verbs[] = {
701 /* Front, Surround, CLFE DAC; mute as default */
702 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
703 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
704 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
706 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
707 /* HP, Line-Out, Surround, CLFE selectors */
708 {0x0a, AC_VERB_SET_CONNECT_SEL, 0x0},
709 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x0},
710 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0},
711 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
713 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x0},
714 /* Mic selector: Mic 1/2 pin */
715 {0x0f, AC_VERB_SET_CONNECT_SEL, 0x0},
716 /* Line-in selector: Line-in */
717 {0x10, AC_VERB_SET_CONNECT_SEL, 0x0},
719 {0x11, AC_VERB_SET_CONNECT_SEL, 0x0},
720 /* Record selector: mic */
721 {0x12, AC_VERB_SET_CONNECT_SEL, 0x0},
722 /* Mic, Phone, CD, Aux, Line-In amp; mute as default */
723 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
724 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
725 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
726 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
727 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
729 {0x18, AC_VERB_SET_CONNECT_SEL, 0x0},
730 /* HP, Line-Out, Surround, CLFE, Mono pins; mute as default */
731 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
732 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
733 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
734 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
735 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
737 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
738 /* Front, Surround, CLFE Pins */
739 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
740 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
741 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
743 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
745 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
746 /* Line, Aux, CD, Beep-In Pin */
747 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
748 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
749 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
750 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
751 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
755 static struct hda_verb ad1986a_ch2_init[] = {
756 /* Surround out -> Line In */
757 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
758 /* Line-in selectors */
759 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x1 },
761 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
762 /* Mic selector, mix C/LFE (backmic) and Mic (frontmic) */
763 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 },
767 static struct hda_verb ad1986a_ch4_init[] = {
768 /* Surround out -> Surround */
769 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
770 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
772 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
773 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 },
777 static struct hda_verb ad1986a_ch6_init[] = {
778 /* Surround out -> Surround out */
779 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
780 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
782 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
783 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x0 },
787 static struct hda_channel_mode ad1986a_modes[3] = {
788 { 2, ad1986a_ch2_init },
789 { 4, ad1986a_ch4_init },
790 { 6, ad1986a_ch6_init },
793 /* eapd initialization */
794 static struct hda_verb ad1986a_eapd_init_verbs[] = {
795 {0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00 },
799 /* Ultra initialization */
800 static struct hda_verb ad1986a_ultra_init[] = {
801 /* eapd initialization */
802 { 0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00 },
804 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2 },
805 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
806 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
820 static const char *ad1986a_models[AD1986A_MODELS] = {
821 [AD1986A_6STACK] = "6stack",
822 [AD1986A_3STACK] = "3stack",
823 [AD1986A_LAPTOP] = "laptop",
824 [AD1986A_LAPTOP_EAPD] = "laptop-eapd",
825 [AD1986A_ULTRA] = "ultra",
828 static struct snd_pci_quirk ad1986a_cfg_tbl[] = {
829 SND_PCI_QUIRK(0x103c, 0x30af, "HP B2800", AD1986A_LAPTOP_EAPD),
830 SND_PCI_QUIRK(0x10de, 0xcb84, "ASUS A8N-VM", AD1986A_3STACK),
831 SND_PCI_QUIRK(0x1043, 0x1153, "ASUS M9", AD1986A_LAPTOP_EAPD),
832 SND_PCI_QUIRK(0x1043, 0x1213, "ASUS A6J", AD1986A_LAPTOP_EAPD),
833 SND_PCI_QUIRK(0x1043, 0x11f7, "ASUS U5A", AD1986A_LAPTOP_EAPD),
834 SND_PCI_QUIRK(0x1043, 0x1263, "ASUS U5F", AD1986A_LAPTOP_EAPD),
835 SND_PCI_QUIRK(0x1043, 0x1297, "ASUS Z62F", AD1986A_LAPTOP_EAPD),
836 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS V1j", AD1986A_LAPTOP_EAPD),
837 SND_PCI_QUIRK(0x1043, 0x1302, "ASUS W3j", AD1986A_LAPTOP_EAPD),
838 SND_PCI_QUIRK(0x1043, 0x1447, "ASUS A8J", AD1986A_3STACK),
839 SND_PCI_QUIRK(0x1043, 0x817f, "ASUS P5", AD1986A_3STACK),
840 SND_PCI_QUIRK(0x1043, 0x818f, "ASUS P5", AD1986A_LAPTOP),
841 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS P5", AD1986A_3STACK),
842 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS M2N", AD1986A_3STACK),
843 SND_PCI_QUIRK(0x1043, 0x8234, "ASUS M2N", AD1986A_3STACK),
844 SND_PCI_QUIRK(0x144d, 0xb03c, "Samsung R55", AD1986A_3STACK),
845 SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP),
846 SND_PCI_QUIRK(0x144d, 0xc023, "Samsung X60", AD1986A_LAPTOP_EAPD),
847 SND_PCI_QUIRK(0x144d, 0xc024, "Samsung R65", AD1986A_LAPTOP_EAPD),
848 SND_PCI_QUIRK(0x144d, 0xc026, "Samsung X11", AD1986A_LAPTOP_EAPD),
849 SND_PCI_QUIRK(0x144d, 0xc504, "Samsung Q35", AD1986A_3STACK),
850 SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_ULTRA),
851 SND_PCI_QUIRK(0x17aa, 0x1011, "Lenovo M55", AD1986A_LAPTOP),
852 SND_PCI_QUIRK(0x17aa, 0x1017, "Lenovo A60", AD1986A_3STACK),
853 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo N100", AD1986A_LAPTOP_EAPD),
854 SND_PCI_QUIRK(0x17c0, 0x2017, "Samsung M50", AD1986A_LAPTOP),
858 static int patch_ad1986a(struct hda_codec *codec)
860 struct ad198x_spec *spec;
863 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
867 mutex_init(&spec->amp_mutex);
870 spec->multiout.max_channels = 6;
871 spec->multiout.num_dacs = ARRAY_SIZE(ad1986a_dac_nids);
872 spec->multiout.dac_nids = ad1986a_dac_nids;
873 spec->multiout.dig_out_nid = AD1986A_SPDIF_OUT;
874 spec->num_adc_nids = 1;
875 spec->adc_nids = ad1986a_adc_nids;
876 spec->capsrc_nids = ad1986a_capsrc_nids;
877 spec->input_mux = &ad1986a_capture_source;
878 spec->num_mixers = 1;
879 spec->mixers[0] = ad1986a_mixers;
880 spec->num_init_verbs = 1;
881 spec->init_verbs[0] = ad1986a_init_verbs;
883 codec->patch_ops = ad198x_patch_ops;
885 /* override some parameters */
886 board_config = snd_hda_check_board_config(codec, AD1986A_MODELS,
889 switch (board_config) {
891 spec->num_mixers = 2;
892 spec->mixers[1] = ad1986a_3st_mixers;
893 spec->num_init_verbs = 2;
894 spec->init_verbs[1] = ad1986a_ch2_init;
895 spec->channel_mode = ad1986a_modes;
896 spec->num_channel_mode = ARRAY_SIZE(ad1986a_modes);
897 spec->need_dac_fix = 1;
898 spec->multiout.max_channels = 2;
899 spec->multiout.num_dacs = 1;
902 spec->mixers[0] = ad1986a_laptop_mixers;
903 spec->multiout.max_channels = 2;
904 spec->multiout.num_dacs = 1;
905 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
907 case AD1986A_LAPTOP_EAPD:
908 spec->mixers[0] = ad1986a_laptop_eapd_mixers;
909 spec->num_init_verbs = 2;
910 spec->init_verbs[1] = ad1986a_eapd_init_verbs;
911 spec->multiout.max_channels = 2;
912 spec->multiout.num_dacs = 1;
913 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
914 spec->multiout.dig_out_nid = 0;
915 spec->input_mux = &ad1986a_laptop_eapd_capture_source;
918 spec->mixers[0] = ad1986a_laptop_eapd_mixers;
919 spec->num_init_verbs = 2;
920 spec->init_verbs[1] = ad1986a_ultra_init;
921 spec->multiout.max_channels = 2;
922 spec->multiout.num_dacs = 1;
923 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
924 spec->multiout.dig_out_nid = 0;
935 #define AD1983_SPDIF_OUT 0x02
936 #define AD1983_DAC 0x03
937 #define AD1983_ADC 0x04
939 static hda_nid_t ad1983_dac_nids[1] = { AD1983_DAC };
940 static hda_nid_t ad1983_adc_nids[1] = { AD1983_ADC };
941 static hda_nid_t ad1983_capsrc_nids[1] = { 0x15 };
943 static struct hda_input_mux ad1983_capture_source = {
954 * SPDIF playback route
956 static int ad1983_spdif_route_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
958 static char *texts[] = { "PCM", "ADC" };
960 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
962 uinfo->value.enumerated.items = 2;
963 if (uinfo->value.enumerated.item > 1)
964 uinfo->value.enumerated.item = 1;
965 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
969 static int ad1983_spdif_route_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
971 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
972 struct ad198x_spec *spec = codec->spec;
974 ucontrol->value.enumerated.item[0] = spec->spdif_route;
978 static int ad1983_spdif_route_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
980 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
981 struct ad198x_spec *spec = codec->spec;
983 if (spec->spdif_route != ucontrol->value.enumerated.item[0]) {
984 spec->spdif_route = ucontrol->value.enumerated.item[0];
985 snd_hda_codec_write(codec, spec->multiout.dig_out_nid, 0,
986 AC_VERB_SET_CONNECT_SEL, spec->spdif_route);
992 static struct snd_kcontrol_new ad1983_mixers[] = {
993 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT),
994 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT),
995 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT),
996 HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT),
997 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT),
998 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT),
999 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
1000 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
1001 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
1002 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
1003 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1004 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1005 HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x10, 1, 0x0, HDA_OUTPUT),
1006 HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x10, 1, 0x0, HDA_OUTPUT),
1007 HDA_CODEC_VOLUME("Mic Boost", 0x0c, 0x0, HDA_OUTPUT),
1008 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1009 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
1011 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1012 .name = "Capture Source",
1013 .info = ad198x_mux_enum_info,
1014 .get = ad198x_mux_enum_get,
1015 .put = ad198x_mux_enum_put,
1018 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1019 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
1020 .info = ad1983_spdif_route_info,
1021 .get = ad1983_spdif_route_get,
1022 .put = ad1983_spdif_route_put,
1027 static struct hda_verb ad1983_init_verbs[] = {
1028 /* Front, HP, Mono; mute as default */
1029 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1030 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1031 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1032 /* Beep, PCM, Mic, Line-In: mute */
1033 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1034 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1035 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1036 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1037 /* Front, HP selectors; from Mix */
1038 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
1039 {0x06, AC_VERB_SET_CONNECT_SEL, 0x01},
1040 /* Mono selector; from Mix */
1041 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03},
1042 /* Mic selector; Mic */
1043 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0},
1044 /* Line-in selector: Line-in */
1045 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
1046 /* Mic boost: 0dB */
1047 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1048 /* Record selector: mic */
1049 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0},
1050 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1051 /* SPDIF route: PCM */
1052 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0},
1054 {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1056 {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
1058 {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1060 {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
1062 {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
1067 static int patch_ad1983(struct hda_codec *codec)
1069 struct ad198x_spec *spec;
1071 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1075 mutex_init(&spec->amp_mutex);
1078 spec->multiout.max_channels = 2;
1079 spec->multiout.num_dacs = ARRAY_SIZE(ad1983_dac_nids);
1080 spec->multiout.dac_nids = ad1983_dac_nids;
1081 spec->multiout.dig_out_nid = AD1983_SPDIF_OUT;
1082 spec->num_adc_nids = 1;
1083 spec->adc_nids = ad1983_adc_nids;
1084 spec->capsrc_nids = ad1983_capsrc_nids;
1085 spec->input_mux = &ad1983_capture_source;
1086 spec->num_mixers = 1;
1087 spec->mixers[0] = ad1983_mixers;
1088 spec->num_init_verbs = 1;
1089 spec->init_verbs[0] = ad1983_init_verbs;
1090 spec->spdif_route = 0;
1092 codec->patch_ops = ad198x_patch_ops;
1099 * AD1981 HD specific
1102 #define AD1981_SPDIF_OUT 0x02
1103 #define AD1981_DAC 0x03
1104 #define AD1981_ADC 0x04
1106 static hda_nid_t ad1981_dac_nids[1] = { AD1981_DAC };
1107 static hda_nid_t ad1981_adc_nids[1] = { AD1981_ADC };
1108 static hda_nid_t ad1981_capsrc_nids[1] = { 0x15 };
1110 /* 0x0c, 0x09, 0x0e, 0x0f, 0x19, 0x05, 0x18, 0x17 */
1111 static struct hda_input_mux ad1981_capture_source = {
1114 { "Front Mic", 0x0 },
1117 { "Mix Mono", 0x3 },
1124 static struct snd_kcontrol_new ad1981_mixers[] = {
1125 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT),
1126 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT),
1127 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT),
1128 HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT),
1129 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT),
1130 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT),
1131 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
1132 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
1133 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
1134 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
1135 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1136 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1137 HDA_CODEC_VOLUME("Aux Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
1138 HDA_CODEC_MUTE("Aux Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1139 HDA_CODEC_VOLUME("Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT),
1140 HDA_CODEC_MUTE("Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
1141 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1142 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1143 HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1144 HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x0d, 1, 0x0, HDA_OUTPUT),
1145 HDA_CODEC_VOLUME("Front Mic Boost", 0x08, 0x0, HDA_INPUT),
1146 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x0, HDA_INPUT),
1147 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1148 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
1150 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1151 .name = "Capture Source",
1152 .info = ad198x_mux_enum_info,
1153 .get = ad198x_mux_enum_get,
1154 .put = ad198x_mux_enum_put,
1156 /* identical with AD1983 */
1158 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1159 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
1160 .info = ad1983_spdif_route_info,
1161 .get = ad1983_spdif_route_get,
1162 .put = ad1983_spdif_route_put,
1167 static struct hda_verb ad1981_init_verbs[] = {
1168 /* Front, HP, Mono; mute as default */
1169 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1170 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1171 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1172 /* Beep, PCM, Front Mic, Line, Rear Mic, Aux, CD-In: mute */
1173 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1174 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1175 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1176 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1177 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1178 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1179 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1180 /* Front, HP selectors; from Mix */
1181 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
1182 {0x06, AC_VERB_SET_CONNECT_SEL, 0x01},
1183 /* Mono selector; from Mix */
1184 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03},
1185 /* Mic Mixer; select Front Mic */
1186 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1187 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1188 /* Mic boost: 0dB */
1189 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1190 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1191 /* Record selector: Front mic */
1192 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0},
1193 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1194 /* SPDIF route: PCM */
1195 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0},
1197 {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1199 {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
1201 {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1202 /* Front & Rear Mic Pins */
1203 {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
1204 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
1206 {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
1208 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
1209 /* Line-Out as Input: disabled */
1210 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1215 * Patch for HP nx6320
1217 * nx6320 uses EAPD in the reverse way - EAPD-on means the internal
1218 * speaker output enabled _and_ mute-LED off.
1221 #define AD1981_HP_EVENT 0x37
1222 #define AD1981_MIC_EVENT 0x38
1224 static struct hda_verb ad1981_hp_init_verbs[] = {
1225 {0x05, AC_VERB_SET_EAPD_BTLENABLE, 0x00 }, /* default off */
1226 /* pin sensing on HP and Mic jacks */
1227 {0x06, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_HP_EVENT},
1228 {0x08, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_MIC_EVENT},
1232 /* turn on/off EAPD (+ mute HP) as a master switch */
1233 static int ad1981_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1234 struct snd_ctl_elem_value *ucontrol)
1236 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1237 struct ad198x_spec *spec = codec->spec;
1239 if (! ad198x_eapd_put(kcontrol, ucontrol))
1242 /* toggle HP mute appropriately */
1243 snd_hda_codec_amp_update(codec, 0x06, 0, HDA_OUTPUT, 0,
1244 0x80, spec->cur_eapd ? 0 : 0x80);
1245 snd_hda_codec_amp_update(codec, 0x06, 1, HDA_OUTPUT, 0,
1246 0x80, spec->cur_eapd ? 0 : 0x80);
1250 /* bind volumes of both NID 0x05 and 0x06 */
1251 static int ad1981_hp_master_vol_put(struct snd_kcontrol *kcontrol,
1252 struct snd_ctl_elem_value *ucontrol)
1254 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1255 long *valp = ucontrol->value.integer.value;
1258 change = snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
1259 0x7f, valp[0] & 0x7f);
1260 change |= snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
1261 0x7f, valp[1] & 0x7f);
1262 snd_hda_codec_amp_update(codec, 0x06, 0, HDA_OUTPUT, 0,
1263 0x7f, valp[0] & 0x7f);
1264 snd_hda_codec_amp_update(codec, 0x06, 1, HDA_OUTPUT, 0,
1265 0x7f, valp[1] & 0x7f);
1269 /* mute internal speaker if HP is plugged */
1270 static void ad1981_hp_automute(struct hda_codec *codec)
1272 unsigned int present;
1274 present = snd_hda_codec_read(codec, 0x06, 0,
1275 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1276 snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
1277 0x80, present ? 0x80 : 0);
1278 snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
1279 0x80, present ? 0x80 : 0);
1282 /* toggle input of built-in and mic jack appropriately */
1283 static void ad1981_hp_automic(struct hda_codec *codec)
1285 static struct hda_verb mic_jack_on[] = {
1286 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1287 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1290 static struct hda_verb mic_jack_off[] = {
1291 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1292 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1295 unsigned int present;
1297 present = snd_hda_codec_read(codec, 0x08, 0,
1298 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1300 snd_hda_sequence_write(codec, mic_jack_on);
1302 snd_hda_sequence_write(codec, mic_jack_off);
1305 /* unsolicited event for HP jack sensing */
1306 static void ad1981_hp_unsol_event(struct hda_codec *codec,
1311 case AD1981_HP_EVENT:
1312 ad1981_hp_automute(codec);
1314 case AD1981_MIC_EVENT:
1315 ad1981_hp_automic(codec);
1320 static struct hda_input_mux ad1981_hp_capture_source = {
1324 { "Docking-Station", 0x1 },
1329 static struct snd_kcontrol_new ad1981_hp_mixers[] = {
1331 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1332 .name = "Master Playback Volume",
1333 .info = snd_hda_mixer_amp_volume_info,
1334 .get = snd_hda_mixer_amp_volume_get,
1335 .put = ad1981_hp_master_vol_put,
1336 .private_value = HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
1339 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1340 .name = "Master Playback Switch",
1341 .info = ad198x_eapd_info,
1342 .get = ad198x_eapd_get,
1343 .put = ad1981_hp_master_sw_put,
1344 .private_value = 0x05,
1346 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
1347 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
1349 /* FIXME: analog mic/line loopback doesn't work with my tests...
1350 * (although recording is OK)
1352 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
1353 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
1354 HDA_CODEC_VOLUME("Docking-Station Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1355 HDA_CODEC_MUTE("Docking-Station Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1356 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT),
1357 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
1358 /* FIXME: does this laptop have analog CD connection? */
1359 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1360 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1362 HDA_CODEC_VOLUME("Mic Boost", 0x08, 0x0, HDA_INPUT),
1363 HDA_CODEC_VOLUME("Internal Mic Boost", 0x18, 0x0, HDA_INPUT),
1364 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1365 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
1367 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1368 .name = "Capture Source",
1369 .info = ad198x_mux_enum_info,
1370 .get = ad198x_mux_enum_get,
1371 .put = ad198x_mux_enum_put,
1376 /* initialize jack-sensing, too */
1377 static int ad1981_hp_init(struct hda_codec *codec)
1380 ad1981_hp_automute(codec);
1381 ad1981_hp_automic(codec);
1385 /* configuration for Toshiba Laptops */
1386 static struct hda_verb ad1981_toshiba_init_verbs[] = {
1387 {0x05, AC_VERB_SET_EAPD_BTLENABLE, 0x01 }, /* default on */
1388 /* pin sensing on HP and Mic jacks */
1389 {0x06, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_HP_EVENT},
1390 {0x08, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_MIC_EVENT},
1394 static struct snd_kcontrol_new ad1981_toshiba_mixers[] = {
1395 HDA_CODEC_VOLUME("Amp Volume", 0x1a, 0x0, HDA_OUTPUT),
1396 HDA_CODEC_MUTE("Amp Switch", 0x1a, 0x0, HDA_OUTPUT),
1400 /* configuration for Lenovo Thinkpad T60 */
1401 static struct snd_kcontrol_new ad1981_thinkpad_mixers[] = {
1402 HDA_CODEC_VOLUME("Master Playback Volume", 0x05, 0x0, HDA_OUTPUT),
1403 HDA_CODEC_MUTE("Master Playback Switch", 0x05, 0x0, HDA_OUTPUT),
1404 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
1405 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
1406 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
1407 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
1408 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1409 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1410 HDA_CODEC_VOLUME("Mic Boost", 0x08, 0x0, HDA_INPUT),
1411 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1412 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
1414 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1415 .name = "Capture Source",
1416 .info = ad198x_mux_enum_info,
1417 .get = ad198x_mux_enum_get,
1418 .put = ad198x_mux_enum_put,
1420 /* identical with AD1983 */
1422 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1423 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
1424 .info = ad1983_spdif_route_info,
1425 .get = ad1983_spdif_route_get,
1426 .put = ad1983_spdif_route_put,
1431 static struct hda_input_mux ad1981_thinkpad_capture_source = {
1449 static const char *ad1981_models[AD1981_MODELS] = {
1451 [AD1981_THINKPAD] = "thinkpad",
1452 [AD1981_BASIC] = "basic",
1453 [AD1981_TOSHIBA] = "toshiba"
1456 static struct snd_pci_quirk ad1981_cfg_tbl[] = {
1458 SND_PCI_QUIRK(0x103c, 0, "HP nx", AD1981_HP),
1459 /* HP nx6320 (reversed SSID, H/W bug) */
1460 SND_PCI_QUIRK(0x30b0, 0x103c, "HP nx6320", AD1981_HP),
1461 /* Lenovo Thinkpad T60/X60/Z6xx */
1462 SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1981_THINKPAD),
1463 SND_PCI_QUIRK(0x1014, 0x0597, "Lenovo Z60", AD1981_THINKPAD),
1464 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba U205", AD1981_TOSHIBA),
1468 static int patch_ad1981(struct hda_codec *codec)
1470 struct ad198x_spec *spec;
1473 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1477 mutex_init(&spec->amp_mutex);
1480 spec->multiout.max_channels = 2;
1481 spec->multiout.num_dacs = ARRAY_SIZE(ad1981_dac_nids);
1482 spec->multiout.dac_nids = ad1981_dac_nids;
1483 spec->multiout.dig_out_nid = AD1981_SPDIF_OUT;
1484 spec->num_adc_nids = 1;
1485 spec->adc_nids = ad1981_adc_nids;
1486 spec->capsrc_nids = ad1981_capsrc_nids;
1487 spec->input_mux = &ad1981_capture_source;
1488 spec->num_mixers = 1;
1489 spec->mixers[0] = ad1981_mixers;
1490 spec->num_init_verbs = 1;
1491 spec->init_verbs[0] = ad1981_init_verbs;
1492 spec->spdif_route = 0;
1494 codec->patch_ops = ad198x_patch_ops;
1496 /* override some parameters */
1497 board_config = snd_hda_check_board_config(codec, AD1981_MODELS,
1500 switch (board_config) {
1502 spec->mixers[0] = ad1981_hp_mixers;
1503 spec->num_init_verbs = 2;
1504 spec->init_verbs[1] = ad1981_hp_init_verbs;
1505 spec->multiout.dig_out_nid = 0;
1506 spec->input_mux = &ad1981_hp_capture_source;
1508 codec->patch_ops.init = ad1981_hp_init;
1509 codec->patch_ops.unsol_event = ad1981_hp_unsol_event;
1511 case AD1981_THINKPAD:
1512 spec->mixers[0] = ad1981_thinkpad_mixers;
1513 spec->input_mux = &ad1981_thinkpad_capture_source;
1515 case AD1981_TOSHIBA:
1516 spec->mixers[0] = ad1981_hp_mixers;
1517 spec->mixers[1] = ad1981_toshiba_mixers;
1518 spec->num_init_verbs = 2;
1519 spec->init_verbs[1] = ad1981_toshiba_init_verbs;
1520 spec->multiout.dig_out_nid = 0;
1521 spec->input_mux = &ad1981_hp_capture_source;
1522 codec->patch_ops.init = ad1981_hp_init;
1523 codec->patch_ops.unsol_event = ad1981_hp_unsol_event;
1533 * Output pins and routes
1535 * Pin Mix Sel DAC (*)
1536 * port-A 0x11 (mute/hp) <- 0x22 <- 0x37 <- 03/04/06
1537 * port-B 0x14 (mute/hp) <- 0x2b <- 0x30 <- 03/04/06
1538 * port-C 0x15 (mute) <- 0x2c <- 0x31 <- 05/0a
1539 * port-D 0x12 (mute/hp) <- 0x29 <- 04
1540 * port-E 0x17 (mute/hp) <- 0x26 <- 0x32 <- 05/0a
1541 * port-F 0x16 (mute) <- 0x2a <- 06
1542 * port-G 0x24 (mute) <- 0x27 <- 05
1543 * port-H 0x25 (mute) <- 0x28 <- 0a
1544 * mono 0x13 (mute/amp)<- 0x1e <- 0x36 <- 03/04/06
1546 * DAC0 = 03h, DAC1 = 04h, DAC2 = 05h, DAC3 = 06h, DAC4 = 0ah
1547 * (*) DAC2/3/4 are swapped to DAC3/4/2 on AD198A rev.2 due to a h/w bug.
1549 * Input pins and routes
1551 * pin boost mix input # / adc input #
1552 * port-A 0x11 -> 0x38 -> mix 2, ADC 0
1553 * port-B 0x14 -> 0x39 -> mix 0, ADC 1
1554 * port-C 0x15 -> 0x3a -> 33:0 - mix 1, ADC 2
1555 * port-D 0x12 -> 0x3d -> mix 3, ADC 8
1556 * port-E 0x17 -> 0x3c -> 34:0 - mix 4, ADC 4
1557 * port-F 0x16 -> 0x3b -> mix 5, ADC 3
1558 * port-G 0x24 -> N/A -> 33:1 - mix 1, 34:1 - mix 4, ADC 6
1559 * port-H 0x25 -> N/A -> 33:2 - mix 1, 34:2 - mix 4, ADC 7
1563 * 6stack - front/surr/CLFE/side/opt DACs - 04/06/05/0a/03
1564 * 3stack - front/surr/CLFE/opt DACs - 04/05/0a/03
1566 * Inputs of Analog Mix (0x20)
1567 * 0:Port-B (front mic)
1568 * 1:Port-C/G/H (line-in)
1570 * 3:Port-D (line-in/2)
1571 * 4:Port-E/G/H (mic-in)
1572 * 5:Port-F (mic2-in)
1578 * 1:Port-B (front mic-in)
1579 * 2:Port-C (line-in)
1580 * 3:Port-F (mic2-in)
1585 * 8:Port-D (line-in/2)
1588 * Proposed pin assignments by the datasheet
1591 * Port-A front headphone
1601 * Port-A front headphone
1603 * C rear line-in/surround
1605 * E rear mic-in/CLFE
1611 * D internal speaker (with EAPD)
1612 * E/F quad mic array
1628 /* reivision id to check workarounds */
1629 #define AD1988A_REV2 0x100200
1631 #define is_rev2(codec) \
1632 ((codec)->vendor_id == 0x11d41988 && \
1633 (codec)->revision_id == AD1988A_REV2)
1639 static hda_nid_t ad1988_6stack_dac_nids[4] = {
1640 0x04, 0x06, 0x05, 0x0a
1643 static hda_nid_t ad1988_3stack_dac_nids[3] = {
1647 /* for AD1988A revision-2, DAC2-4 are swapped */
1648 static hda_nid_t ad1988_6stack_dac_nids_rev2[4] = {
1649 0x04, 0x05, 0x0a, 0x06
1652 static hda_nid_t ad1988_3stack_dac_nids_rev2[3] = {
1656 static hda_nid_t ad1988_adc_nids[3] = {
1660 static hda_nid_t ad1988_capsrc_nids[3] = {
1664 #define AD1988_SPDIF_OUT 0x02
1665 #define AD1988_SPDIF_IN 0x07
1667 static struct hda_input_mux ad1988_6stack_capture_source = {
1670 { "Front Mic", 0x0 },
1678 static struct hda_input_mux ad1988_laptop_capture_source = {
1681 { "Mic/Line", 0x0 },
1689 static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol,
1690 struct snd_ctl_elem_info *uinfo)
1692 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1693 struct ad198x_spec *spec = codec->spec;
1694 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
1695 spec->num_channel_mode);
1698 static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol,
1699 struct snd_ctl_elem_value *ucontrol)
1701 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1702 struct ad198x_spec *spec = codec->spec;
1703 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
1704 spec->num_channel_mode, spec->multiout.max_channels);
1707 static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol,
1708 struct snd_ctl_elem_value *ucontrol)
1710 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1711 struct ad198x_spec *spec = codec->spec;
1712 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
1713 spec->num_channel_mode,
1714 &spec->multiout.max_channels);
1715 if (err >= 0 && spec->need_dac_fix)
1716 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
1721 static struct snd_kcontrol_new ad1988_6stack_mixers1[] = {
1722 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1723 HDA_CODEC_VOLUME("Surround Playback Volume", 0x06, 0x0, HDA_OUTPUT),
1724 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT),
1725 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT),
1726 HDA_CODEC_VOLUME("Side Playback Volume", 0x0a, 0x0, HDA_OUTPUT),
1730 static struct snd_kcontrol_new ad1988_6stack_mixers1_rev2[] = {
1731 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1732 HDA_CODEC_VOLUME("Surround Playback Volume", 0x05, 0x0, HDA_OUTPUT),
1733 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
1734 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0a, 2, 0x0, HDA_OUTPUT),
1735 HDA_CODEC_VOLUME("Side Playback Volume", 0x06, 0x0, HDA_OUTPUT),
1739 static struct snd_kcontrol_new ad1988_6stack_mixers2[] = {
1740 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT),
1741 HDA_BIND_MUTE("Surround Playback Switch", 0x2a, 2, HDA_INPUT),
1742 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x27, 1, 2, HDA_INPUT),
1743 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x27, 2, 2, HDA_INPUT),
1744 HDA_BIND_MUTE("Side Playback Switch", 0x28, 2, HDA_INPUT),
1745 HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT),
1746 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT),
1748 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT),
1749 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT),
1750 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT),
1751 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT),
1752 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
1753 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
1754 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT),
1755 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT),
1757 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
1758 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
1760 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
1761 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
1763 HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT),
1764 HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT),
1770 static struct snd_kcontrol_new ad1988_3stack_mixers1[] = {
1771 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1772 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT),
1773 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT),
1774 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT),
1778 static struct snd_kcontrol_new ad1988_3stack_mixers1_rev2[] = {
1779 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1780 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT),
1781 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x06, 1, 0x0, HDA_OUTPUT),
1782 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x06, 2, 0x0, HDA_OUTPUT),
1786 static struct snd_kcontrol_new ad1988_3stack_mixers2[] = {
1787 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT),
1788 HDA_BIND_MUTE("Surround Playback Switch", 0x2c, 2, HDA_INPUT),
1789 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x26, 1, 2, HDA_INPUT),
1790 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x26, 2, 2, HDA_INPUT),
1791 HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT),
1792 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT),
1794 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT),
1795 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT),
1796 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT),
1797 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT),
1798 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
1799 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
1800 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT),
1801 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT),
1803 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
1804 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
1806 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
1807 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
1809 HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT),
1810 HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT),
1812 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1813 .name = "Channel Mode",
1814 .info = ad198x_ch_mode_info,
1815 .get = ad198x_ch_mode_get,
1816 .put = ad198x_ch_mode_put,
1823 static struct snd_kcontrol_new ad1988_laptop_mixers[] = {
1824 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1825 HDA_CODEC_MUTE("PCM Playback Switch", 0x29, 0x0, HDA_INPUT),
1826 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT),
1828 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT),
1829 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT),
1830 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x0, HDA_INPUT),
1831 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x0, HDA_INPUT),
1832 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
1833 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
1835 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
1836 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
1838 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
1839 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
1841 HDA_CODEC_VOLUME("Mic Boost", 0x39, 0x0, HDA_OUTPUT),
1844 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1845 .name = "External Amplifier",
1846 .info = ad198x_eapd_info,
1847 .get = ad198x_eapd_get,
1848 .put = ad198x_eapd_put,
1849 .private_value = 0x12 | (1 << 8), /* port-D, inversed */
1856 static struct snd_kcontrol_new ad1988_capture_mixers[] = {
1857 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
1858 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
1859 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
1860 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
1861 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x0e, 0x0, HDA_OUTPUT),
1862 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x0e, 0x0, HDA_OUTPUT),
1864 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1865 /* The multiple "Capture Source" controls confuse alsamixer
1866 * So call somewhat different..
1867 * FIXME: the controls appear in the "playback" view!
1869 /* .name = "Capture Source", */
1870 .name = "Input Source",
1872 .info = ad198x_mux_enum_info,
1873 .get = ad198x_mux_enum_get,
1874 .put = ad198x_mux_enum_put,
1879 static int ad1988_spdif_playback_source_info(struct snd_kcontrol *kcontrol,
1880 struct snd_ctl_elem_info *uinfo)
1882 static char *texts[] = {
1883 "PCM", "ADC1", "ADC2", "ADC3"
1885 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1887 uinfo->value.enumerated.items = 4;
1888 if (uinfo->value.enumerated.item >= 4)
1889 uinfo->value.enumerated.item = 3;
1890 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1894 static int ad1988_spdif_playback_source_get(struct snd_kcontrol *kcontrol,
1895 struct snd_ctl_elem_value *ucontrol)
1897 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1900 sel = snd_hda_codec_read(codec, 0x02, 0, AC_VERB_GET_CONNECT_SEL, 0);
1902 sel = snd_hda_codec_read(codec, 0x0b, 0,
1903 AC_VERB_GET_CONNECT_SEL, 0);
1909 ucontrol->value.enumerated.item[0] = sel;
1913 static int ad1988_spdif_playback_source_put(struct snd_kcontrol *kcontrol,
1914 struct snd_ctl_elem_value *ucontrol)
1916 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1917 unsigned int val, sel;
1920 val = ucontrol->value.enumerated.item[0];
1921 sel = snd_hda_codec_read(codec, 0x02, 0, AC_VERB_GET_CONNECT_SEL, 0);
1924 if (change || codec->in_resume)
1925 snd_hda_codec_write(codec, 0x02, 0,
1926 AC_VERB_SET_CONNECT_SEL, 0);
1929 if (change || codec->in_resume)
1930 snd_hda_codec_write(codec, 0x02, 0,
1931 AC_VERB_SET_CONNECT_SEL, 1);
1932 sel = snd_hda_codec_read(codec, 0x0b, 0,
1933 AC_VERB_GET_CONNECT_SEL, 0) + 1;
1934 change |= sel != val;
1935 if (change || codec->in_resume)
1936 snd_hda_codec_write(codec, 0x0b, 0,
1937 AC_VERB_SET_CONNECT_SEL, val - 1);
1942 static struct snd_kcontrol_new ad1988_spdif_out_mixers[] = {
1943 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
1945 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1946 .name = "IEC958 Playback Source",
1947 .info = ad1988_spdif_playback_source_info,
1948 .get = ad1988_spdif_playback_source_get,
1949 .put = ad1988_spdif_playback_source_put,
1954 static struct snd_kcontrol_new ad1988_spdif_in_mixers[] = {
1955 HDA_CODEC_VOLUME("IEC958 Capture Volume", 0x1c, 0x0, HDA_INPUT),
1961 * initialization verbs
1965 * for 6-stack (+dig)
1967 static struct hda_verb ad1988_6stack_init_verbs[] = {
1968 /* Front, Surround, CLFE, side DAC; unmute as default */
1969 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1970 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1971 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1972 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1973 /* Port-A front headphon path */
1974 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */
1975 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1976 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1977 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1978 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1979 /* Port-D line-out path */
1980 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1981 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1982 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1983 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1984 /* Port-F surround path */
1985 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1986 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1987 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1988 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1989 /* Port-G CLFE path */
1990 {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1991 {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1992 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1993 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1994 /* Port-H side path */
1995 {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1996 {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1997 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1998 {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2000 {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */
2001 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2002 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2003 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2004 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */
2005 /* Port-B front mic-in path */
2006 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2007 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2008 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2009 /* Port-C line-in path */
2010 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2011 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2012 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2013 {0x33, AC_VERB_SET_CONNECT_SEL, 0x0},
2014 /* Port-E mic-in path */
2015 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2016 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2017 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2018 {0x34, AC_VERB_SET_CONNECT_SEL, 0x0},
2023 static struct hda_verb ad1988_capture_init_verbs[] = {
2024 /* mute analog mix */
2025 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2026 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2027 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2028 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2029 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2030 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
2031 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2032 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2033 /* select ADCs - front-mic */
2034 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
2035 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
2036 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
2038 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2039 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2040 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2045 static struct hda_verb ad1988_spdif_init_verbs[] = {
2047 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */
2048 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x0}, /* ADC1 */
2049 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2050 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2052 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
2053 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x17}, /* 0dB */
2059 * verbs for 3stack (+dig)
2061 static struct hda_verb ad1988_3stack_ch2_init[] = {
2062 /* set port-C to line-in */
2063 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2064 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2065 /* set port-E to mic-in */
2066 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2067 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2071 static struct hda_verb ad1988_3stack_ch6_init[] = {
2072 /* set port-C to surround out */
2073 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2074 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2075 /* set port-E to CLFE out */
2076 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2077 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2081 static struct hda_channel_mode ad1988_3stack_modes[2] = {
2082 { 2, ad1988_3stack_ch2_init },
2083 { 6, ad1988_3stack_ch6_init },
2086 static struct hda_verb ad1988_3stack_init_verbs[] = {
2087 /* Front, Surround, CLFE, side DAC; unmute as default */
2088 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2089 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2090 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2091 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2092 /* Port-A front headphon path */
2093 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */
2094 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2095 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2096 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2097 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2098 /* Port-D line-out path */
2099 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2100 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2101 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2102 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2104 {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */
2105 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2106 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2107 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2108 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */
2109 /* Port-B front mic-in path */
2110 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2111 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2112 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2113 /* Port-C line-in/surround path - 6ch mode as default */
2114 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2115 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2116 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2117 {0x31, AC_VERB_SET_CONNECT_SEL, 0x0}, /* output sel: DAC 0x05 */
2118 {0x33, AC_VERB_SET_CONNECT_SEL, 0x0},
2119 /* Port-E mic-in/CLFE path - 6ch mode as default */
2120 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2121 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2122 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2123 {0x32, AC_VERB_SET_CONNECT_SEL, 0x1}, /* output sel: DAC 0x0a */
2124 {0x34, AC_VERB_SET_CONNECT_SEL, 0x0},
2125 /* mute analog mix */
2126 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2127 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2128 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2129 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2130 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2131 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
2132 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2133 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2134 /* select ADCs - front-mic */
2135 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
2136 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
2137 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
2139 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2140 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2141 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2146 * verbs for laptop mode (+dig)
2148 static struct hda_verb ad1988_laptop_hp_on[] = {
2149 /* unmute port-A and mute port-D */
2150 { 0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2151 { 0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2154 static struct hda_verb ad1988_laptop_hp_off[] = {
2155 /* mute port-A and unmute port-D */
2156 { 0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2157 { 0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2161 #define AD1988_HP_EVENT 0x01
2163 static struct hda_verb ad1988_laptop_init_verbs[] = {
2164 /* Front, Surround, CLFE, side DAC; unmute as default */
2165 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2166 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2167 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2168 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2169 /* Port-A front headphon path */
2170 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */
2171 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2172 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2173 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2174 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2175 /* unsolicited event for pin-sense */
2176 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1988_HP_EVENT },
2177 /* Port-D line-out path + EAPD */
2178 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2179 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2180 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2181 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2182 {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x00}, /* EAPD-off */
2184 {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */
2185 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2186 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2187 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2188 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */
2189 /* Port-B mic-in path */
2190 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2191 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2192 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2193 /* Port-C docking station - try to output */
2194 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2195 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2196 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2197 {0x33, AC_VERB_SET_CONNECT_SEL, 0x0},
2198 /* mute analog mix */
2199 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2200 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2201 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2202 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2203 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2204 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
2205 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2206 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2207 /* select ADCs - mic */
2208 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
2209 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
2210 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
2212 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2213 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2214 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2218 static void ad1988_laptop_unsol_event(struct hda_codec *codec, unsigned int res)
2220 if ((res >> 26) != AD1988_HP_EVENT)
2222 if (snd_hda_codec_read(codec, 0x11, 0, AC_VERB_GET_PIN_SENSE, 0) & (1 << 31))
2223 snd_hda_sequence_write(codec, ad1988_laptop_hp_on);
2225 snd_hda_sequence_write(codec, ad1988_laptop_hp_off);
2230 * Automatic parse of I/O pins from the BIOS configuration
2233 #define NUM_CONTROL_ALLOC 32
2234 #define NUM_VERB_ALLOC 32
2241 static struct snd_kcontrol_new ad1988_control_templates[] = {
2242 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2243 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2244 HDA_BIND_MUTE(NULL, 0, 0, 0),
2247 /* add dynamic controls */
2248 static int add_control(struct ad198x_spec *spec, int type, const char *name,
2251 struct snd_kcontrol_new *knew;
2253 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2254 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2256 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2259 if (spec->kctl_alloc) {
2260 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2261 kfree(spec->kctl_alloc);
2263 spec->kctl_alloc = knew;
2264 spec->num_kctl_alloc = num;
2267 knew = &spec->kctl_alloc[spec->num_kctl_used];
2268 *knew = ad1988_control_templates[type];
2269 knew->name = kstrdup(name, GFP_KERNEL);
2272 knew->private_value = val;
2273 spec->num_kctl_used++;
2277 #define AD1988_PIN_CD_NID 0x18
2278 #define AD1988_PIN_BEEP_NID 0x10
2280 static hda_nid_t ad1988_mixer_nids[8] = {
2281 /* A B C D E F G H */
2282 0x22, 0x2b, 0x2c, 0x29, 0x26, 0x2a, 0x27, 0x28
2285 static inline hda_nid_t ad1988_idx_to_dac(struct hda_codec *codec, int idx)
2287 static hda_nid_t idx_to_dac[8] = {
2288 /* A B C D E F G H */
2289 0x04, 0x06, 0x05, 0x04, 0x0a, 0x06, 0x05, 0x0a
2291 static hda_nid_t idx_to_dac_rev2[8] = {
2292 /* A B C D E F G H */
2293 0x04, 0x05, 0x0a, 0x04, 0x06, 0x05, 0x0a, 0x06
2296 return idx_to_dac_rev2[idx];
2298 return idx_to_dac[idx];
2301 static hda_nid_t ad1988_boost_nids[8] = {
2302 0x38, 0x39, 0x3a, 0x3d, 0x3c, 0x3b, 0, 0
2305 static int ad1988_pin_idx(hda_nid_t nid)
2307 static hda_nid_t ad1988_io_pins[8] = {
2308 0x11, 0x14, 0x15, 0x12, 0x17, 0x16, 0x24, 0x25
2311 for (i = 0; i < ARRAY_SIZE(ad1988_io_pins); i++)
2312 if (ad1988_io_pins[i] == nid)
2314 return 0; /* should be -1 */
2317 static int ad1988_pin_to_loopback_idx(hda_nid_t nid)
2319 static int loopback_idx[8] = {
2320 2, 0, 1, 3, 4, 5, 1, 4
2323 case AD1988_PIN_CD_NID:
2326 return loopback_idx[ad1988_pin_idx(nid)];
2330 static int ad1988_pin_to_adc_idx(hda_nid_t nid)
2332 static int adc_idx[8] = {
2333 0, 1, 2, 8, 4, 3, 6, 7
2336 case AD1988_PIN_CD_NID:
2339 return adc_idx[ad1988_pin_idx(nid)];
2343 /* fill in the dac_nids table from the parsed pin configuration */
2344 static int ad1988_auto_fill_dac_nids(struct hda_codec *codec,
2345 const struct auto_pin_cfg *cfg)
2347 struct ad198x_spec *spec = codec->spec;
2350 spec->multiout.dac_nids = spec->private_dac_nids;
2352 /* check the pins hardwired to audio widget */
2353 for (i = 0; i < cfg->line_outs; i++) {
2354 idx = ad1988_pin_idx(cfg->line_out_pins[i]);
2355 spec->multiout.dac_nids[i] = ad1988_idx_to_dac(codec, idx);
2357 spec->multiout.num_dacs = cfg->line_outs;
2361 /* add playback controls from the parsed DAC table */
2362 static int ad1988_auto_create_multi_out_ctls(struct ad198x_spec *spec,
2363 const struct auto_pin_cfg *cfg)
2366 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
2370 for (i = 0; i < cfg->line_outs; i++) {
2371 hda_nid_t dac = spec->multiout.dac_nids[i];
2374 nid = ad1988_mixer_nids[ad1988_pin_idx(cfg->line_out_pins[i])];
2377 err = add_control(spec, AD_CTL_WIDGET_VOL,
2378 "Center Playback Volume",
2379 HDA_COMPOSE_AMP_VAL(dac, 1, 0, HDA_OUTPUT));
2382 err = add_control(spec, AD_CTL_WIDGET_VOL,
2383 "LFE Playback Volume",
2384 HDA_COMPOSE_AMP_VAL(dac, 2, 0, HDA_OUTPUT));
2387 err = add_control(spec, AD_CTL_BIND_MUTE,
2388 "Center Playback Switch",
2389 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT));
2392 err = add_control(spec, AD_CTL_BIND_MUTE,
2393 "LFE Playback Switch",
2394 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT));
2398 sprintf(name, "%s Playback Volume", chname[i]);
2399 err = add_control(spec, AD_CTL_WIDGET_VOL, name,
2400 HDA_COMPOSE_AMP_VAL(dac, 3, 0, HDA_OUTPUT));
2403 sprintf(name, "%s Playback Switch", chname[i]);
2404 err = add_control(spec, AD_CTL_BIND_MUTE, name,
2405 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
2413 /* add playback controls for speaker and HP outputs */
2414 static int ad1988_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
2417 struct ad198x_spec *spec = codec->spec;
2425 idx = ad1988_pin_idx(pin);
2426 nid = ad1988_idx_to_dac(codec, idx);
2427 /* specify the DAC as the extra output */
2428 if (! spec->multiout.hp_nid)
2429 spec->multiout.hp_nid = nid;
2431 spec->multiout.extra_out_nid[0] = nid;
2432 /* control HP volume/switch on the output mixer amp */
2433 sprintf(name, "%s Playback Volume", pfx);
2434 if ((err = add_control(spec, AD_CTL_WIDGET_VOL, name,
2435 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2437 nid = ad1988_mixer_nids[idx];
2438 sprintf(name, "%s Playback Switch", pfx);
2439 if ((err = add_control(spec, AD_CTL_BIND_MUTE, name,
2440 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2445 /* create input playback/capture controls for the given pin */
2446 static int new_analog_input(struct ad198x_spec *spec, hda_nid_t pin,
2447 const char *ctlname, int boost)
2452 sprintf(name, "%s Playback Volume", ctlname);
2453 idx = ad1988_pin_to_loopback_idx(pin);
2454 if ((err = add_control(spec, AD_CTL_WIDGET_VOL, name,
2455 HDA_COMPOSE_AMP_VAL(0x20, 3, idx, HDA_INPUT))) < 0)
2457 sprintf(name, "%s Playback Switch", ctlname);
2458 if ((err = add_control(spec, AD_CTL_WIDGET_MUTE, name,
2459 HDA_COMPOSE_AMP_VAL(0x20, 3, idx, HDA_INPUT))) < 0)
2463 idx = ad1988_pin_idx(pin);
2464 bnid = ad1988_boost_nids[idx];
2466 sprintf(name, "%s Boost", ctlname);
2467 return add_control(spec, AD_CTL_WIDGET_VOL, name,
2468 HDA_COMPOSE_AMP_VAL(bnid, 3, idx, HDA_OUTPUT));
2475 /* create playback/capture controls for input pins */
2476 static int ad1988_auto_create_analog_input_ctls(struct ad198x_spec *spec,
2477 const struct auto_pin_cfg *cfg)
2479 struct hda_input_mux *imux = &spec->private_imux;
2482 for (i = 0; i < AUTO_PIN_LAST; i++) {
2483 err = new_analog_input(spec, cfg->input_pins[i],
2484 auto_pin_cfg_labels[i],
2485 i <= AUTO_PIN_FRONT_MIC);
2488 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2489 imux->items[imux->num_items].index = ad1988_pin_to_adc_idx(cfg->input_pins[i]);
2492 imux->items[imux->num_items].label = "Mix";
2493 imux->items[imux->num_items].index = 9;
2496 if ((err = add_control(spec, AD_CTL_WIDGET_VOL,
2497 "Analog Mix Playback Volume",
2498 HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT))) < 0)
2500 if ((err = add_control(spec, AD_CTL_WIDGET_MUTE,
2501 "Analog Mix Playback Switch",
2502 HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT))) < 0)
2508 static void ad1988_auto_set_output_and_unmute(struct hda_codec *codec,
2509 hda_nid_t nid, int pin_type,
2513 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2514 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2516 case 0x11: /* port-A - DAC 04 */
2517 snd_hda_codec_write(codec, 0x37, 0, AC_VERB_SET_CONNECT_SEL, 0x01);
2519 case 0x14: /* port-B - DAC 06 */
2520 snd_hda_codec_write(codec, 0x30, 0, AC_VERB_SET_CONNECT_SEL, 0x02);
2522 case 0x15: /* port-C - DAC 05 */
2523 snd_hda_codec_write(codec, 0x31, 0, AC_VERB_SET_CONNECT_SEL, 0x00);
2525 case 0x17: /* port-E - DAC 0a */
2526 snd_hda_codec_write(codec, 0x32, 0, AC_VERB_SET_CONNECT_SEL, 0x01);
2528 case 0x13: /* mono - DAC 04 */
2529 snd_hda_codec_write(codec, 0x36, 0, AC_VERB_SET_CONNECT_SEL, 0x01);
2534 static void ad1988_auto_init_multi_out(struct hda_codec *codec)
2536 struct ad198x_spec *spec = codec->spec;
2539 for (i = 0; i < spec->autocfg.line_outs; i++) {
2540 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2541 ad1988_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2545 static void ad1988_auto_init_extra_out(struct hda_codec *codec)
2547 struct ad198x_spec *spec = codec->spec;
2550 pin = spec->autocfg.speaker_pins[0];
2551 if (pin) /* connect to front */
2552 ad1988_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
2553 pin = spec->autocfg.hp_pins[0];
2554 if (pin) /* connect to front */
2555 ad1988_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2558 static void ad1988_auto_init_analog_input(struct hda_codec *codec)
2560 struct ad198x_spec *spec = codec->spec;
2563 for (i = 0; i < AUTO_PIN_LAST; i++) {
2564 hda_nid_t nid = spec->autocfg.input_pins[i];
2568 case 0x15: /* port-C */
2569 snd_hda_codec_write(codec, 0x33, 0, AC_VERB_SET_CONNECT_SEL, 0x0);
2571 case 0x17: /* port-E */
2572 snd_hda_codec_write(codec, 0x34, 0, AC_VERB_SET_CONNECT_SEL, 0x0);
2575 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2576 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2577 if (nid != AD1988_PIN_CD_NID)
2578 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2580 idx = ad1988_pin_idx(nid);
2581 if (ad1988_boost_nids[idx])
2582 snd_hda_codec_write(codec, ad1988_boost_nids[idx], 0,
2583 AC_VERB_SET_AMP_GAIN_MUTE,
2588 /* parse the BIOS configuration and set up the alc_spec */
2589 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2590 static int ad1988_parse_auto_config(struct hda_codec *codec)
2592 struct ad198x_spec *spec = codec->spec;
2595 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
2597 if ((err = ad1988_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
2599 if (! spec->autocfg.line_outs)
2600 return 0; /* can't find valid BIOS pin config */
2601 if ((err = ad1988_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
2602 (err = ad1988_auto_create_extra_out(codec,
2603 spec->autocfg.speaker_pins[0],
2605 (err = ad1988_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
2606 "Headphone")) < 0 ||
2607 (err = ad1988_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2610 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2612 if (spec->autocfg.dig_out_pin)
2613 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
2614 if (spec->autocfg.dig_in_pin)
2615 spec->dig_in_nid = AD1988_SPDIF_IN;
2617 if (spec->kctl_alloc)
2618 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2620 spec->init_verbs[spec->num_init_verbs++] = ad1988_6stack_init_verbs;
2622 spec->input_mux = &spec->private_imux;
2627 /* init callback for auto-configuration model -- overriding the default init */
2628 static int ad1988_auto_init(struct hda_codec *codec)
2631 ad1988_auto_init_multi_out(codec);
2632 ad1988_auto_init_extra_out(codec);
2633 ad1988_auto_init_analog_input(codec);
2641 static const char *ad1988_models[AD1988_MODEL_LAST] = {
2642 [AD1988_6STACK] = "6stack",
2643 [AD1988_6STACK_DIG] = "6stack-dig",
2644 [AD1988_3STACK] = "3stack",
2645 [AD1988_3STACK_DIG] = "3stack-dig",
2646 [AD1988_LAPTOP] = "laptop",
2647 [AD1988_LAPTOP_DIG] = "laptop-dig",
2648 [AD1988_AUTO] = "auto",
2651 static struct snd_pci_quirk ad1988_cfg_tbl[] = {
2652 SND_PCI_QUIRK(0x1043, 0x81f6, "Asus M2N-SLI", AD1988_6STACK_DIG),
2653 SND_PCI_QUIRK(0x1043, 0x81ec, "Asus P5B-DLX", AD1988_6STACK_DIG),
2657 static int patch_ad1988(struct hda_codec *codec)
2659 struct ad198x_spec *spec;
2662 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2666 mutex_init(&spec->amp_mutex);
2670 snd_printk(KERN_INFO "patch_analog: AD1988A rev.2 is detected, enable workarounds\n");
2672 board_config = snd_hda_check_board_config(codec, AD1988_MODEL_LAST,
2673 ad1988_models, ad1988_cfg_tbl);
2674 if (board_config < 0) {
2675 printk(KERN_INFO "hda_codec: Unknown model for AD1988, trying auto-probe from BIOS...\n");
2676 board_config = AD1988_AUTO;
2679 if (board_config == AD1988_AUTO) {
2680 /* automatic parse from the BIOS config */
2681 int err = ad1988_parse_auto_config(codec);
2686 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 6-stack mode...\n");
2687 board_config = AD1988_6STACK;
2691 switch (board_config) {
2693 case AD1988_6STACK_DIG:
2694 spec->multiout.max_channels = 8;
2695 spec->multiout.num_dacs = 4;
2697 spec->multiout.dac_nids = ad1988_6stack_dac_nids_rev2;
2699 spec->multiout.dac_nids = ad1988_6stack_dac_nids;
2700 spec->input_mux = &ad1988_6stack_capture_source;
2701 spec->num_mixers = 2;
2703 spec->mixers[0] = ad1988_6stack_mixers1_rev2;
2705 spec->mixers[0] = ad1988_6stack_mixers1;
2706 spec->mixers[1] = ad1988_6stack_mixers2;
2707 spec->num_init_verbs = 1;
2708 spec->init_verbs[0] = ad1988_6stack_init_verbs;
2709 if (board_config == AD1988_6STACK_DIG) {
2710 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
2711 spec->dig_in_nid = AD1988_SPDIF_IN;
2715 case AD1988_3STACK_DIG:
2716 spec->multiout.max_channels = 6;
2717 spec->multiout.num_dacs = 3;
2719 spec->multiout.dac_nids = ad1988_3stack_dac_nids_rev2;
2721 spec->multiout.dac_nids = ad1988_3stack_dac_nids;
2722 spec->input_mux = &ad1988_6stack_capture_source;
2723 spec->channel_mode = ad1988_3stack_modes;
2724 spec->num_channel_mode = ARRAY_SIZE(ad1988_3stack_modes);
2725 spec->num_mixers = 2;
2727 spec->mixers[0] = ad1988_3stack_mixers1_rev2;
2729 spec->mixers[0] = ad1988_3stack_mixers1;
2730 spec->mixers[1] = ad1988_3stack_mixers2;
2731 spec->num_init_verbs = 1;
2732 spec->init_verbs[0] = ad1988_3stack_init_verbs;
2733 if (board_config == AD1988_3STACK_DIG)
2734 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
2737 case AD1988_LAPTOP_DIG:
2738 spec->multiout.max_channels = 2;
2739 spec->multiout.num_dacs = 1;
2740 spec->multiout.dac_nids = ad1988_3stack_dac_nids;
2741 spec->input_mux = &ad1988_laptop_capture_source;
2742 spec->num_mixers = 1;
2743 spec->mixers[0] = ad1988_laptop_mixers;
2744 spec->num_init_verbs = 1;
2745 spec->init_verbs[0] = ad1988_laptop_init_verbs;
2746 if (board_config == AD1988_LAPTOP_DIG)
2747 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
2751 spec->num_adc_nids = ARRAY_SIZE(ad1988_adc_nids);
2752 spec->adc_nids = ad1988_adc_nids;
2753 spec->capsrc_nids = ad1988_capsrc_nids;
2754 spec->mixers[spec->num_mixers++] = ad1988_capture_mixers;
2755 spec->init_verbs[spec->num_init_verbs++] = ad1988_capture_init_verbs;
2756 if (spec->multiout.dig_out_nid) {
2757 spec->mixers[spec->num_mixers++] = ad1988_spdif_out_mixers;
2758 spec->init_verbs[spec->num_init_verbs++] = ad1988_spdif_init_verbs;
2760 if (spec->dig_in_nid)
2761 spec->mixers[spec->num_mixers++] = ad1988_spdif_in_mixers;
2763 codec->patch_ops = ad198x_patch_ops;
2764 switch (board_config) {
2766 codec->patch_ops.init = ad1988_auto_init;
2769 case AD1988_LAPTOP_DIG:
2770 codec->patch_ops.unsol_event = ad1988_laptop_unsol_event;
2781 * port-B - front line/mic-in
2782 * port-E - aux in/out
2783 * port-F - aux in/out
2784 * port-C - rear line/mic-in
2785 * port-D - rear line/hp-out
2786 * port-A - front line/hp-out
2788 * AD1984 = AD1884 + two digital mic-ins
2791 * For simplicity, we share the single DAC for both HP and line-outs
2792 * right now. The inidividual playbacks could be easily implemented,
2793 * but no build-up framework is given, so far.
2796 static hda_nid_t ad1884_dac_nids[1] = {
2800 static hda_nid_t ad1884_adc_nids[2] = {
2804 static hda_nid_t ad1884_capsrc_nids[2] = {
2808 #define AD1884_SPDIF_OUT 0x02
2810 static struct hda_input_mux ad1884_capture_source = {
2813 { "Front Mic", 0x0 },
2820 static struct snd_kcontrol_new ad1884_base_mixers[] = {
2821 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
2822 /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */
2823 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
2824 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT),
2825 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT),
2826 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT),
2827 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
2828 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
2829 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
2830 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
2831 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT),
2832 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT),
2834 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x20, 0x03, HDA_INPUT),
2835 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x20, 0x03, HDA_INPUT),
2836 HDA_CODEC_VOLUME("Digital Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
2837 HDA_CODEC_MUTE("Digital Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
2839 HDA_CODEC_VOLUME("Mic Boost", 0x15, 0x0, HDA_INPUT),
2840 HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT),
2841 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
2842 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
2843 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
2844 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
2846 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2847 /* The multiple "Capture Source" controls confuse alsamixer
2848 * So call somewhat different..
2849 * FIXME: the controls appear in the "playback" view!
2851 /* .name = "Capture Source", */
2852 .name = "Input Source",
2854 .info = ad198x_mux_enum_info,
2855 .get = ad198x_mux_enum_get,
2856 .put = ad198x_mux_enum_put,
2858 /* SPDIF controls */
2859 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
2861 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2862 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
2863 /* identical with ad1983 */
2864 .info = ad1983_spdif_route_info,
2865 .get = ad1983_spdif_route_get,
2866 .put = ad1983_spdif_route_put,
2871 static struct snd_kcontrol_new ad1984_dmic_mixers[] = {
2872 HDA_CODEC_VOLUME("Digital Mic Capture Volume", 0x05, 0x0, HDA_INPUT),
2873 HDA_CODEC_MUTE("Digital Mic Capture Switch", 0x05, 0x0, HDA_INPUT),
2874 HDA_CODEC_VOLUME_IDX("Digital Mic Capture Volume", 1, 0x06, 0x0,
2876 HDA_CODEC_MUTE_IDX("Digital Mic Capture Switch", 1, 0x06, 0x0,
2882 * initialization verbs
2884 static struct hda_verb ad1884_init_verbs[] = {
2885 /* DACs; mute as default */
2886 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2887 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2888 /* Port-A (HP) mixer */
2889 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2890 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2892 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2893 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2894 /* HP selector - select DAC2 */
2895 {0x22, AC_VERB_SET_CONNECT_SEL, 0x1},
2896 /* Port-D (Line-out) mixer */
2897 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2898 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2900 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2901 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2902 /* Mono-out mixer */
2903 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2904 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2906 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2907 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2909 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
2910 /* Port-B (front mic) pin */
2911 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2912 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2913 /* Port-C (rear mic) pin */
2914 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2915 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2916 /* Analog mixer; mute as default */
2917 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2918 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2919 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2920 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2921 /* Analog Mix output amp */
2922 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
2923 /* SPDIF output selector */
2924 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */
2925 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
2929 static int patch_ad1884(struct hda_codec *codec)
2931 struct ad198x_spec *spec;
2933 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2937 mutex_init(&spec->amp_mutex);
2940 spec->multiout.max_channels = 2;
2941 spec->multiout.num_dacs = ARRAY_SIZE(ad1884_dac_nids);
2942 spec->multiout.dac_nids = ad1884_dac_nids;
2943 spec->multiout.dig_out_nid = AD1884_SPDIF_OUT;
2944 spec->num_adc_nids = ARRAY_SIZE(ad1884_adc_nids);
2945 spec->adc_nids = ad1884_adc_nids;
2946 spec->capsrc_nids = ad1884_capsrc_nids;
2947 spec->input_mux = &ad1884_capture_source;
2948 spec->num_mixers = 1;
2949 spec->mixers[0] = ad1884_base_mixers;
2950 spec->num_init_verbs = 1;
2951 spec->init_verbs[0] = ad1884_init_verbs;
2952 spec->spdif_route = 0;
2954 codec->patch_ops = ad198x_patch_ops;
2960 * Lenovo Thinkpad T61/X61
2962 static struct hda_input_mux ad1984_thinkpad_capture_source = {
2966 { "Internal Mic", 0x1 },
2971 static struct snd_kcontrol_new ad1984_thinkpad_mixers[] = {
2972 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
2973 /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */
2974 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
2975 HDA_CODEC_MUTE("Speaker Playback Switch", 0x12, 0x0, HDA_OUTPUT),
2976 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
2977 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
2978 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
2979 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
2980 HDA_CODEC_VOLUME("Docking Mic Playback Volume", 0x20, 0x04, HDA_INPUT),
2981 HDA_CODEC_MUTE("Docking Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
2982 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT),
2983 HDA_CODEC_VOLUME("Internal Mic Boost", 0x15, 0x0, HDA_INPUT),
2984 HDA_CODEC_VOLUME("Docking Mic Boost", 0x25, 0x0, HDA_OUTPUT),
2985 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
2986 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
2987 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
2988 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
2989 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
2990 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
2992 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2993 /* The multiple "Capture Source" controls confuse alsamixer
2994 * So call somewhat different..
2995 * FIXME: the controls appear in the "playback" view!
2997 /* .name = "Capture Source", */
2998 .name = "Input Source",
3000 .info = ad198x_mux_enum_info,
3001 .get = ad198x_mux_enum_get,
3002 .put = ad198x_mux_enum_put,
3007 /* additional verbs */
3008 static struct hda_verb ad1984_thinkpad_init_verbs[] = {
3009 /* Port-E (docking station mic) pin */
3010 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3011 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3012 /* docking mic boost */
3013 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3014 /* Analog mixer - docking mic; mute as default */
3015 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3016 /* enable EAPD bit */
3017 {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
3021 /* Digial MIC ADC NID 0x05 + 0x06 */
3022 static int ad1984_pcm_dmic_prepare(struct hda_pcm_stream *hinfo,
3023 struct hda_codec *codec,
3024 unsigned int stream_tag,
3025 unsigned int format,
3026 struct snd_pcm_substream *substream)
3028 snd_hda_codec_setup_stream(codec, 0x05 + substream->number,
3029 stream_tag, 0, format);
3033 static int ad1984_pcm_dmic_cleanup(struct hda_pcm_stream *hinfo,
3034 struct hda_codec *codec,
3035 struct snd_pcm_substream *substream)
3037 snd_hda_codec_setup_stream(codec, 0x05 + substream->number,
3042 static struct hda_pcm_stream ad1984_pcm_dmic_capture = {
3048 .prepare = ad1984_pcm_dmic_prepare,
3049 .cleanup = ad1984_pcm_dmic_cleanup
3053 static int ad1984_build_pcms(struct hda_codec *codec)
3055 struct ad198x_spec *spec = codec->spec;
3056 struct hda_pcm *info;
3059 err = ad198x_build_pcms(codec);
3063 info = spec->pcm_rec + codec->num_pcms;
3065 info->name = "AD1984 Digital Mic";
3066 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad1984_pcm_dmic_capture;
3077 static const char *ad1984_models[AD1984_MODELS] = {
3078 [AD1984_BASIC] = "basic",
3079 [AD1984_THINKPAD] = "thinkpad",
3082 static struct snd_pci_quirk ad1984_cfg_tbl[] = {
3083 /* Lenovo Thinkpad T61/X61 */
3084 SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1984_THINKPAD),
3088 static int patch_ad1984(struct hda_codec *codec)
3090 struct ad198x_spec *spec;
3091 int board_config, err;
3093 err = patch_ad1884(codec);
3097 board_config = snd_hda_check_board_config(codec, AD1984_MODELS,
3098 ad1984_models, ad1984_cfg_tbl);
3099 switch (board_config) {
3101 /* additional digital mics */
3102 spec->mixers[spec->num_mixers++] = ad1984_dmic_mixers;
3103 codec->patch_ops.build_pcms = ad1984_build_pcms;
3105 case AD1984_THINKPAD:
3106 spec->multiout.dig_out_nid = 0;
3107 spec->input_mux = &ad1984_thinkpad_capture_source;
3108 spec->mixers[0] = ad1984_thinkpad_mixers;
3109 spec->init_verbs[spec->num_init_verbs++] = ad1984_thinkpad_init_verbs;
3119 struct hda_codec_preset snd_hda_preset_analog[] = {
3120 { .id = 0x11d41884, .name = "AD1884", .patch = patch_ad1884 },
3121 { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 },
3122 { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 },
3123 { .id = 0x11d41984, .name = "AD1984", .patch = patch_ad1984 },
3124 { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a },
3125 { .id = 0x11d41988, .name = "AD1988", .patch = patch_ad1988 },
3126 { .id = 0x11d4198b, .name = "AD1988B", .patch = patch_ad1988 },