2 * HD audio interface patch for AD1882, AD1884, AD1981HD, AD1983, AD1984,
5 * Copyright (c) 2005-2007 Takashi Iwai <tiwai@suse.de>
7 * This driver is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This driver is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <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];
77 #ifdef CONFIG_SND_HDA_POWER_SAVE
78 struct hda_loopback_check loopback;
83 * input MUX handling (common part)
85 static int ad198x_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
87 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
88 struct ad198x_spec *spec = codec->spec;
90 return snd_hda_input_mux_info(spec->input_mux, uinfo);
93 static int ad198x_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
95 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
96 struct ad198x_spec *spec = codec->spec;
97 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
99 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
103 static int ad198x_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
105 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
106 struct ad198x_spec *spec = codec->spec;
107 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
109 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
110 spec->capsrc_nids[adc_idx],
111 &spec->cur_mux[adc_idx]);
115 * initialization (common callbacks)
117 static int ad198x_init(struct hda_codec *codec)
119 struct ad198x_spec *spec = codec->spec;
122 for (i = 0; i < spec->num_init_verbs; i++)
123 snd_hda_sequence_write(codec, spec->init_verbs[i]);
127 static int ad198x_build_controls(struct hda_codec *codec)
129 struct ad198x_spec *spec = codec->spec;
133 for (i = 0; i < spec->num_mixers; i++) {
134 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
138 if (spec->multiout.dig_out_nid) {
139 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
143 if (spec->dig_in_nid) {
144 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
151 #ifdef CONFIG_SND_HDA_POWER_SAVE
152 static int ad198x_check_power_status(struct hda_codec *codec, hda_nid_t nid)
154 struct ad198x_spec *spec = codec->spec;
155 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
160 * Analog playback callbacks
162 static int ad198x_playback_pcm_open(struct hda_pcm_stream *hinfo,
163 struct hda_codec *codec,
164 struct snd_pcm_substream *substream)
166 struct ad198x_spec *spec = codec->spec;
167 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
170 static int ad198x_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
171 struct hda_codec *codec,
172 unsigned int stream_tag,
174 struct snd_pcm_substream *substream)
176 struct ad198x_spec *spec = codec->spec;
177 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
181 static int ad198x_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
182 struct hda_codec *codec,
183 struct snd_pcm_substream *substream)
185 struct ad198x_spec *spec = codec->spec;
186 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
192 static int ad198x_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
193 struct hda_codec *codec,
194 struct snd_pcm_substream *substream)
196 struct ad198x_spec *spec = codec->spec;
197 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
200 static int ad198x_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
201 struct hda_codec *codec,
202 struct snd_pcm_substream *substream)
204 struct ad198x_spec *spec = codec->spec;
205 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
208 static int ad198x_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
209 struct hda_codec *codec,
210 unsigned int stream_tag,
212 struct snd_pcm_substream *substream)
214 struct ad198x_spec *spec = codec->spec;
215 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag,
222 static int ad198x_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
223 struct hda_codec *codec,
224 unsigned int stream_tag,
226 struct snd_pcm_substream *substream)
228 struct ad198x_spec *spec = codec->spec;
229 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
230 stream_tag, 0, format);
234 static int ad198x_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
235 struct hda_codec *codec,
236 struct snd_pcm_substream *substream)
238 struct ad198x_spec *spec = codec->spec;
239 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
247 static struct hda_pcm_stream ad198x_pcm_analog_playback = {
250 .channels_max = 6, /* changed later */
251 .nid = 0, /* fill later */
253 .open = ad198x_playback_pcm_open,
254 .prepare = ad198x_playback_pcm_prepare,
255 .cleanup = ad198x_playback_pcm_cleanup
259 static struct hda_pcm_stream ad198x_pcm_analog_capture = {
263 .nid = 0, /* fill later */
265 .prepare = ad198x_capture_pcm_prepare,
266 .cleanup = ad198x_capture_pcm_cleanup
270 static struct hda_pcm_stream ad198x_pcm_digital_playback = {
274 .nid = 0, /* fill later */
276 .open = ad198x_dig_playback_pcm_open,
277 .close = ad198x_dig_playback_pcm_close,
278 .prepare = ad198x_dig_playback_pcm_prepare
282 static struct hda_pcm_stream ad198x_pcm_digital_capture = {
286 /* NID is set in alc_build_pcms */
289 static int ad198x_build_pcms(struct hda_codec *codec)
291 struct ad198x_spec *spec = codec->spec;
292 struct hda_pcm *info = spec->pcm_rec;
295 codec->pcm_info = info;
297 info->name = "AD198x Analog";
298 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_analog_playback;
299 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->multiout.max_channels;
300 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
301 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_analog_capture;
302 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adc_nids;
303 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
305 if (spec->multiout.dig_out_nid) {
308 info->name = "AD198x Digital";
309 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_digital_playback;
310 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
311 if (spec->dig_in_nid) {
312 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_digital_capture;
313 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
320 static void ad198x_free(struct hda_codec *codec)
322 struct ad198x_spec *spec = codec->spec;
325 if (spec->kctl_alloc) {
326 for (i = 0; i < spec->num_kctl_used; i++)
327 kfree(spec->kctl_alloc[i].name);
328 kfree(spec->kctl_alloc);
333 static struct hda_codec_ops ad198x_patch_ops = {
334 .build_controls = ad198x_build_controls,
335 .build_pcms = ad198x_build_pcms,
338 #ifdef CONFIG_SND_HDA_POWER_SAVE
339 .check_power_status = ad198x_check_power_status,
346 * the private value = nid | (invert << 8)
348 #define ad198x_eapd_info snd_ctl_boolean_mono_info
350 static int ad198x_eapd_get(struct snd_kcontrol *kcontrol,
351 struct snd_ctl_elem_value *ucontrol)
353 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
354 struct ad198x_spec *spec = codec->spec;
355 int invert = (kcontrol->private_value >> 8) & 1;
357 ucontrol->value.integer.value[0] = ! spec->cur_eapd;
359 ucontrol->value.integer.value[0] = spec->cur_eapd;
363 static int ad198x_eapd_put(struct snd_kcontrol *kcontrol,
364 struct snd_ctl_elem_value *ucontrol)
366 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
367 struct ad198x_spec *spec = codec->spec;
368 int invert = (kcontrol->private_value >> 8) & 1;
369 hda_nid_t nid = kcontrol->private_value & 0xff;
371 eapd = ucontrol->value.integer.value[0];
374 if (eapd == spec->cur_eapd)
376 spec->cur_eapd = eapd;
377 snd_hda_codec_write_cache(codec, nid,
378 0, AC_VERB_SET_EAPD_BTLENABLE,
383 static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol,
384 struct snd_ctl_elem_info *uinfo);
385 static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol,
386 struct snd_ctl_elem_value *ucontrol);
387 static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol,
388 struct snd_ctl_elem_value *ucontrol);
395 #define AD1986A_SPDIF_OUT 0x02
396 #define AD1986A_FRONT_DAC 0x03
397 #define AD1986A_SURR_DAC 0x04
398 #define AD1986A_CLFE_DAC 0x05
399 #define AD1986A_ADC 0x06
401 static hda_nid_t ad1986a_dac_nids[3] = {
402 AD1986A_FRONT_DAC, AD1986A_SURR_DAC, AD1986A_CLFE_DAC
404 static hda_nid_t ad1986a_adc_nids[1] = { AD1986A_ADC };
405 static hda_nid_t ad1986a_capsrc_nids[1] = { 0x12 };
407 static struct hda_input_mux ad1986a_capture_source = {
421 static struct hda_bind_ctls ad1986a_bind_pcm_vol = {
422 .ops = &snd_hda_bind_vol,
424 HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT),
425 HDA_COMPOSE_AMP_VAL(AD1986A_SURR_DAC, 3, 0, HDA_OUTPUT),
426 HDA_COMPOSE_AMP_VAL(AD1986A_CLFE_DAC, 3, 0, HDA_OUTPUT),
431 static struct hda_bind_ctls ad1986a_bind_pcm_sw = {
432 .ops = &snd_hda_bind_sw,
434 HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT),
435 HDA_COMPOSE_AMP_VAL(AD1986A_SURR_DAC, 3, 0, HDA_OUTPUT),
436 HDA_COMPOSE_AMP_VAL(AD1986A_CLFE_DAC, 3, 0, HDA_OUTPUT),
444 static struct snd_kcontrol_new ad1986a_mixers[] = {
446 * bind volumes/mutes of 3 DACs as a single PCM control for simplicity
448 HDA_BIND_VOL("PCM Playback Volume", &ad1986a_bind_pcm_vol),
449 HDA_BIND_SW("PCM Playback Switch", &ad1986a_bind_pcm_sw),
450 HDA_CODEC_VOLUME("Front Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
451 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
452 HDA_CODEC_VOLUME("Surround Playback Volume", 0x1c, 0x0, HDA_OUTPUT),
453 HDA_CODEC_MUTE("Surround Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
454 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x1d, 1, 0x0, HDA_OUTPUT),
455 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x1d, 2, 0x0, HDA_OUTPUT),
456 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x1d, 1, 0x0, HDA_OUTPUT),
457 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x1d, 2, 0x0, HDA_OUTPUT),
458 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT),
459 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
460 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT),
461 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT),
462 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT),
463 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT),
464 HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT),
465 HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT),
466 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
467 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
468 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
469 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT),
470 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT),
471 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
472 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT),
473 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
474 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
476 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
477 .name = "Capture Source",
478 .info = ad198x_mux_enum_info,
479 .get = ad198x_mux_enum_get,
480 .put = ad198x_mux_enum_put,
482 HDA_CODEC_MUTE("Stereo Downmix Switch", 0x09, 0x0, HDA_OUTPUT),
486 /* additional mixers for 3stack mode */
487 static struct snd_kcontrol_new ad1986a_3st_mixers[] = {
489 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
490 .name = "Channel Mode",
491 .info = ad198x_ch_mode_info,
492 .get = ad198x_ch_mode_get,
493 .put = ad198x_ch_mode_put,
498 /* laptop model - 2ch only */
499 static hda_nid_t ad1986a_laptop_dac_nids[1] = { AD1986A_FRONT_DAC };
501 static struct snd_kcontrol_new ad1986a_laptop_mixers[] = {
502 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
503 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
504 HDA_CODEC_VOLUME("Master Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
505 HDA_CODEC_MUTE("Master Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
506 /* HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT),
507 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT), */
508 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT),
509 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT),
510 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT),
511 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT),
512 HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT),
513 HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT),
514 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
515 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
516 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
517 /* HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT),
518 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT),
519 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
520 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), */
521 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
522 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
524 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
525 .name = "Capture Source",
526 .info = ad198x_mux_enum_info,
527 .get = ad198x_mux_enum_get,
528 .put = ad198x_mux_enum_put,
533 /* laptop-eapd model - 2ch only */
535 /* master controls both pins 0x1a and 0x1b */
536 static struct hda_bind_ctls ad1986a_laptop_master_vol = {
537 .ops = &snd_hda_bind_vol,
539 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT),
540 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
545 static struct hda_bind_ctls ad1986a_laptop_master_sw = {
546 .ops = &snd_hda_bind_sw,
548 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT),
549 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
554 static struct hda_input_mux ad1986a_laptop_eapd_capture_source = {
558 { "Internal Mic", 0x4 },
563 static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = {
564 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol),
565 HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw),
566 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
567 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
568 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x0, HDA_OUTPUT),
569 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x0, HDA_OUTPUT),
570 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
571 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
572 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
573 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
574 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
576 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
577 .name = "Capture Source",
578 .info = ad198x_mux_enum_info,
579 .get = ad198x_mux_enum_get,
580 .put = ad198x_mux_enum_put,
583 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
584 .name = "External Amplifier",
585 .info = ad198x_eapd_info,
586 .get = ad198x_eapd_get,
587 .put = ad198x_eapd_put,
588 .private_value = 0x1b | (1 << 8), /* port-D, inversed */
594 * initialization verbs
596 static struct hda_verb ad1986a_init_verbs[] = {
597 /* Front, Surround, CLFE DAC; mute as default */
598 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
599 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
600 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
602 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
603 /* HP, Line-Out, Surround, CLFE selectors */
604 {0x0a, AC_VERB_SET_CONNECT_SEL, 0x0},
605 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x0},
606 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0},
607 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
609 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x0},
610 /* Mic selector: Mic 1/2 pin */
611 {0x0f, AC_VERB_SET_CONNECT_SEL, 0x0},
612 /* Line-in selector: Line-in */
613 {0x10, AC_VERB_SET_CONNECT_SEL, 0x0},
615 {0x11, AC_VERB_SET_CONNECT_SEL, 0x0},
616 /* Record selector: mic */
617 {0x12, AC_VERB_SET_CONNECT_SEL, 0x0},
618 /* Mic, Phone, CD, Aux, Line-In amp; mute as default */
619 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
620 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
621 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
622 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
623 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
625 {0x18, AC_VERB_SET_CONNECT_SEL, 0x0},
626 /* HP, Line-Out, Surround, CLFE, Mono pins; mute as default */
627 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
628 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
629 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
630 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
631 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
633 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
634 /* Front, Surround, CLFE Pins */
635 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
636 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
637 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
639 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
641 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
642 /* Line, Aux, CD, Beep-In Pin */
643 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
644 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
645 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
646 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
647 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
651 static struct hda_verb ad1986a_ch2_init[] = {
652 /* Surround out -> Line In */
653 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
654 /* Line-in selectors */
655 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x1 },
657 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
658 /* Mic selector, mix C/LFE (backmic) and Mic (frontmic) */
659 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 },
663 static struct hda_verb ad1986a_ch4_init[] = {
664 /* Surround out -> Surround */
665 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
666 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
668 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
669 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 },
673 static struct hda_verb ad1986a_ch6_init[] = {
674 /* Surround out -> Surround out */
675 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
676 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
678 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
679 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x0 },
683 static struct hda_channel_mode ad1986a_modes[3] = {
684 { 2, ad1986a_ch2_init },
685 { 4, ad1986a_ch4_init },
686 { 6, ad1986a_ch6_init },
689 /* eapd initialization */
690 static struct hda_verb ad1986a_eapd_init_verbs[] = {
691 {0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00 },
695 /* Ultra initialization */
696 static struct hda_verb ad1986a_ultra_init[] = {
697 /* eapd initialization */
698 { 0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00 },
700 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2 },
701 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
702 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
716 static const char *ad1986a_models[AD1986A_MODELS] = {
717 [AD1986A_6STACK] = "6stack",
718 [AD1986A_3STACK] = "3stack",
719 [AD1986A_LAPTOP] = "laptop",
720 [AD1986A_LAPTOP_EAPD] = "laptop-eapd",
721 [AD1986A_ULTRA] = "ultra",
724 static struct snd_pci_quirk ad1986a_cfg_tbl[] = {
725 SND_PCI_QUIRK(0x103c, 0x30af, "HP B2800", AD1986A_LAPTOP_EAPD),
726 SND_PCI_QUIRK(0x10de, 0xcb84, "ASUS A8N-VM", AD1986A_3STACK),
727 SND_PCI_QUIRK(0x1043, 0x1153, "ASUS M9", AD1986A_LAPTOP_EAPD),
728 SND_PCI_QUIRK(0x1043, 0x1213, "ASUS A6J", AD1986A_LAPTOP_EAPD),
729 SND_PCI_QUIRK(0x1043, 0x11f7, "ASUS U5A", AD1986A_LAPTOP_EAPD),
730 SND_PCI_QUIRK(0x1043, 0x1263, "ASUS U5F", AD1986A_LAPTOP_EAPD),
731 SND_PCI_QUIRK(0x1043, 0x1297, "ASUS Z62F", AD1986A_LAPTOP_EAPD),
732 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS V1j", AD1986A_LAPTOP_EAPD),
733 SND_PCI_QUIRK(0x1043, 0x1302, "ASUS W3j", AD1986A_LAPTOP_EAPD),
734 SND_PCI_QUIRK(0x1043, 0x1447, "ASUS A8J", AD1986A_3STACK),
735 SND_PCI_QUIRK(0x1043, 0x817f, "ASUS P5", AD1986A_3STACK),
736 SND_PCI_QUIRK(0x1043, 0x818f, "ASUS P5", AD1986A_LAPTOP),
737 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS P5", AD1986A_3STACK),
738 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS M2N", AD1986A_3STACK),
739 SND_PCI_QUIRK(0x1043, 0x8234, "ASUS M2N", AD1986A_3STACK),
740 SND_PCI_QUIRK(0x144d, 0xb03c, "Samsung R55", AD1986A_3STACK),
741 SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP),
742 SND_PCI_QUIRK(0x144d, 0xc023, "Samsung X60", AD1986A_LAPTOP_EAPD),
743 SND_PCI_QUIRK(0x144d, 0xc024, "Samsung R65", AD1986A_LAPTOP_EAPD),
744 SND_PCI_QUIRK(0x144d, 0xc026, "Samsung X11", AD1986A_LAPTOP_EAPD),
745 SND_PCI_QUIRK(0x144d, 0xc504, "Samsung Q35", AD1986A_3STACK),
746 SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_ULTRA),
747 SND_PCI_QUIRK(0x17aa, 0x1011, "Lenovo M55", AD1986A_LAPTOP),
748 SND_PCI_QUIRK(0x17aa, 0x1017, "Lenovo A60", AD1986A_3STACK),
749 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo N100", AD1986A_LAPTOP_EAPD),
750 SND_PCI_QUIRK(0x17c0, 0x2017, "Samsung M50", AD1986A_LAPTOP),
754 #ifdef CONFIG_SND_HDA_POWER_SAVE
755 static struct hda_amp_list ad1986a_loopbacks[] = {
756 { 0x13, HDA_OUTPUT, 0 }, /* Mic */
757 { 0x14, HDA_OUTPUT, 0 }, /* Phone */
758 { 0x15, HDA_OUTPUT, 0 }, /* CD */
759 { 0x16, HDA_OUTPUT, 0 }, /* Aux */
760 { 0x17, HDA_OUTPUT, 0 }, /* Line */
765 static int patch_ad1986a(struct hda_codec *codec)
767 struct ad198x_spec *spec;
770 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
776 spec->multiout.max_channels = 6;
777 spec->multiout.num_dacs = ARRAY_SIZE(ad1986a_dac_nids);
778 spec->multiout.dac_nids = ad1986a_dac_nids;
779 spec->multiout.dig_out_nid = AD1986A_SPDIF_OUT;
780 spec->num_adc_nids = 1;
781 spec->adc_nids = ad1986a_adc_nids;
782 spec->capsrc_nids = ad1986a_capsrc_nids;
783 spec->input_mux = &ad1986a_capture_source;
784 spec->num_mixers = 1;
785 spec->mixers[0] = ad1986a_mixers;
786 spec->num_init_verbs = 1;
787 spec->init_verbs[0] = ad1986a_init_verbs;
788 #ifdef CONFIG_SND_HDA_POWER_SAVE
789 spec->loopback.amplist = ad1986a_loopbacks;
792 codec->patch_ops = ad198x_patch_ops;
794 /* override some parameters */
795 board_config = snd_hda_check_board_config(codec, AD1986A_MODELS,
798 switch (board_config) {
800 spec->num_mixers = 2;
801 spec->mixers[1] = ad1986a_3st_mixers;
802 spec->num_init_verbs = 2;
803 spec->init_verbs[1] = ad1986a_ch2_init;
804 spec->channel_mode = ad1986a_modes;
805 spec->num_channel_mode = ARRAY_SIZE(ad1986a_modes);
806 spec->need_dac_fix = 1;
807 spec->multiout.max_channels = 2;
808 spec->multiout.num_dacs = 1;
811 spec->mixers[0] = ad1986a_laptop_mixers;
812 spec->multiout.max_channels = 2;
813 spec->multiout.num_dacs = 1;
814 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
816 case AD1986A_LAPTOP_EAPD:
817 spec->mixers[0] = ad1986a_laptop_eapd_mixers;
818 spec->num_init_verbs = 2;
819 spec->init_verbs[1] = ad1986a_eapd_init_verbs;
820 spec->multiout.max_channels = 2;
821 spec->multiout.num_dacs = 1;
822 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
823 spec->multiout.dig_out_nid = 0;
824 spec->input_mux = &ad1986a_laptop_eapd_capture_source;
827 spec->mixers[0] = ad1986a_laptop_eapd_mixers;
828 spec->num_init_verbs = 2;
829 spec->init_verbs[1] = ad1986a_ultra_init;
830 spec->multiout.max_channels = 2;
831 spec->multiout.num_dacs = 1;
832 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
833 spec->multiout.dig_out_nid = 0;
844 #define AD1983_SPDIF_OUT 0x02
845 #define AD1983_DAC 0x03
846 #define AD1983_ADC 0x04
848 static hda_nid_t ad1983_dac_nids[1] = { AD1983_DAC };
849 static hda_nid_t ad1983_adc_nids[1] = { AD1983_ADC };
850 static hda_nid_t ad1983_capsrc_nids[1] = { 0x15 };
852 static struct hda_input_mux ad1983_capture_source = {
863 * SPDIF playback route
865 static int ad1983_spdif_route_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
867 static char *texts[] = { "PCM", "ADC" };
869 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
871 uinfo->value.enumerated.items = 2;
872 if (uinfo->value.enumerated.item > 1)
873 uinfo->value.enumerated.item = 1;
874 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
878 static int ad1983_spdif_route_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
880 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
881 struct ad198x_spec *spec = codec->spec;
883 ucontrol->value.enumerated.item[0] = spec->spdif_route;
887 static int ad1983_spdif_route_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
889 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
890 struct ad198x_spec *spec = codec->spec;
892 if (spec->spdif_route != ucontrol->value.enumerated.item[0]) {
893 spec->spdif_route = ucontrol->value.enumerated.item[0];
894 snd_hda_codec_write_cache(codec, spec->multiout.dig_out_nid, 0,
895 AC_VERB_SET_CONNECT_SEL,
902 static struct snd_kcontrol_new ad1983_mixers[] = {
903 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT),
904 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT),
905 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT),
906 HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT),
907 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT),
908 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT),
909 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
910 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
911 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
912 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
913 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT),
914 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT),
915 HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x10, 1, 0x0, HDA_OUTPUT),
916 HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x10, 1, 0x0, HDA_OUTPUT),
917 HDA_CODEC_VOLUME("Mic Boost", 0x0c, 0x0, HDA_OUTPUT),
918 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
919 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
921 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
922 .name = "Capture Source",
923 .info = ad198x_mux_enum_info,
924 .get = ad198x_mux_enum_get,
925 .put = ad198x_mux_enum_put,
928 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
929 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
930 .info = ad1983_spdif_route_info,
931 .get = ad1983_spdif_route_get,
932 .put = ad1983_spdif_route_put,
937 static struct hda_verb ad1983_init_verbs[] = {
938 /* Front, HP, Mono; mute as default */
939 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
940 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
941 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
942 /* Beep, PCM, Mic, Line-In: mute */
943 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
944 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
945 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
946 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
947 /* Front, HP selectors; from Mix */
948 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
949 {0x06, AC_VERB_SET_CONNECT_SEL, 0x01},
950 /* Mono selector; from Mix */
951 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03},
952 /* Mic selector; Mic */
953 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0},
954 /* Line-in selector: Line-in */
955 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
957 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
958 /* Record selector: mic */
959 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0},
960 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
961 /* SPDIF route: PCM */
962 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0},
964 {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
966 {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
968 {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
970 {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
972 {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
976 #ifdef CONFIG_SND_HDA_POWER_SAVE
977 static struct hda_amp_list ad1983_loopbacks[] = {
978 { 0x12, HDA_OUTPUT, 0 }, /* Mic */
979 { 0x13, HDA_OUTPUT, 0 }, /* Line */
984 static int patch_ad1983(struct hda_codec *codec)
986 struct ad198x_spec *spec;
988 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
994 spec->multiout.max_channels = 2;
995 spec->multiout.num_dacs = ARRAY_SIZE(ad1983_dac_nids);
996 spec->multiout.dac_nids = ad1983_dac_nids;
997 spec->multiout.dig_out_nid = AD1983_SPDIF_OUT;
998 spec->num_adc_nids = 1;
999 spec->adc_nids = ad1983_adc_nids;
1000 spec->capsrc_nids = ad1983_capsrc_nids;
1001 spec->input_mux = &ad1983_capture_source;
1002 spec->num_mixers = 1;
1003 spec->mixers[0] = ad1983_mixers;
1004 spec->num_init_verbs = 1;
1005 spec->init_verbs[0] = ad1983_init_verbs;
1006 spec->spdif_route = 0;
1007 #ifdef CONFIG_SND_HDA_POWER_SAVE
1008 spec->loopback.amplist = ad1983_loopbacks;
1011 codec->patch_ops = ad198x_patch_ops;
1018 * AD1981 HD specific
1021 #define AD1981_SPDIF_OUT 0x02
1022 #define AD1981_DAC 0x03
1023 #define AD1981_ADC 0x04
1025 static hda_nid_t ad1981_dac_nids[1] = { AD1981_DAC };
1026 static hda_nid_t ad1981_adc_nids[1] = { AD1981_ADC };
1027 static hda_nid_t ad1981_capsrc_nids[1] = { 0x15 };
1029 /* 0x0c, 0x09, 0x0e, 0x0f, 0x19, 0x05, 0x18, 0x17 */
1030 static struct hda_input_mux ad1981_capture_source = {
1033 { "Front Mic", 0x0 },
1036 { "Mix Mono", 0x3 },
1043 static struct snd_kcontrol_new ad1981_mixers[] = {
1044 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT),
1045 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT),
1046 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT),
1047 HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT),
1048 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT),
1049 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT),
1050 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
1051 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
1052 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
1053 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
1054 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1055 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1056 HDA_CODEC_VOLUME("Aux Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
1057 HDA_CODEC_MUTE("Aux Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1058 HDA_CODEC_VOLUME("Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT),
1059 HDA_CODEC_MUTE("Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
1060 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1061 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1062 HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1063 HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x0d, 1, 0x0, HDA_OUTPUT),
1064 HDA_CODEC_VOLUME("Front Mic Boost", 0x08, 0x0, HDA_INPUT),
1065 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x0, HDA_INPUT),
1066 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1067 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
1069 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1070 .name = "Capture Source",
1071 .info = ad198x_mux_enum_info,
1072 .get = ad198x_mux_enum_get,
1073 .put = ad198x_mux_enum_put,
1075 /* identical with AD1983 */
1077 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1078 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
1079 .info = ad1983_spdif_route_info,
1080 .get = ad1983_spdif_route_get,
1081 .put = ad1983_spdif_route_put,
1086 static struct hda_verb ad1981_init_verbs[] = {
1087 /* Front, HP, Mono; mute as default */
1088 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1089 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1090 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1091 /* Beep, PCM, Front Mic, Line, Rear Mic, Aux, CD-In: mute */
1092 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1093 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1094 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1095 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1096 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1097 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1098 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1099 /* Front, HP selectors; from Mix */
1100 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
1101 {0x06, AC_VERB_SET_CONNECT_SEL, 0x01},
1102 /* Mono selector; from Mix */
1103 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03},
1104 /* Mic Mixer; select Front Mic */
1105 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1106 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1107 /* Mic boost: 0dB */
1108 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1109 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1110 /* Record selector: Front mic */
1111 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0},
1112 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1113 /* SPDIF route: PCM */
1114 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0},
1116 {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1118 {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
1120 {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
1121 /* Front & Rear Mic Pins */
1122 {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
1123 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
1125 {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
1127 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
1128 /* Line-Out as Input: disabled */
1129 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1133 #ifdef CONFIG_SND_HDA_POWER_SAVE
1134 static struct hda_amp_list ad1981_loopbacks[] = {
1135 { 0x12, HDA_OUTPUT, 0 }, /* Front Mic */
1136 { 0x13, HDA_OUTPUT, 0 }, /* Line */
1137 { 0x1b, HDA_OUTPUT, 0 }, /* Aux */
1138 { 0x1c, HDA_OUTPUT, 0 }, /* Mic */
1139 { 0x1d, HDA_OUTPUT, 0 }, /* CD */
1145 * Patch for HP nx6320
1147 * nx6320 uses EAPD in the reverse way - EAPD-on means the internal
1148 * speaker output enabled _and_ mute-LED off.
1151 #define AD1981_HP_EVENT 0x37
1152 #define AD1981_MIC_EVENT 0x38
1154 static struct hda_verb ad1981_hp_init_verbs[] = {
1155 {0x05, AC_VERB_SET_EAPD_BTLENABLE, 0x00 }, /* default off */
1156 /* pin sensing on HP and Mic jacks */
1157 {0x06, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_HP_EVENT},
1158 {0x08, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_MIC_EVENT},
1162 /* turn on/off EAPD (+ mute HP) as a master switch */
1163 static int ad1981_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1164 struct snd_ctl_elem_value *ucontrol)
1166 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1167 struct ad198x_spec *spec = codec->spec;
1169 if (! ad198x_eapd_put(kcontrol, ucontrol))
1172 /* toggle HP mute appropriately */
1173 snd_hda_codec_amp_stereo(codec, 0x06, HDA_OUTPUT, 0,
1175 spec->cur_eapd ? 0 : HDA_AMP_MUTE);
1179 /* bind volumes of both NID 0x05 and 0x06 */
1180 static struct hda_bind_ctls ad1981_hp_bind_master_vol = {
1181 .ops = &snd_hda_bind_vol,
1183 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
1184 HDA_COMPOSE_AMP_VAL(0x06, 3, 0, HDA_OUTPUT),
1189 /* mute internal speaker if HP is plugged */
1190 static void ad1981_hp_automute(struct hda_codec *codec)
1192 unsigned int present;
1194 present = snd_hda_codec_read(codec, 0x06, 0,
1195 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1196 snd_hda_codec_amp_stereo(codec, 0x05, HDA_OUTPUT, 0,
1197 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
1200 /* toggle input of built-in and mic jack appropriately */
1201 static void ad1981_hp_automic(struct hda_codec *codec)
1203 static struct hda_verb mic_jack_on[] = {
1204 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1205 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1208 static struct hda_verb mic_jack_off[] = {
1209 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1210 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1213 unsigned int present;
1215 present = snd_hda_codec_read(codec, 0x08, 0,
1216 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1218 snd_hda_sequence_write(codec, mic_jack_on);
1220 snd_hda_sequence_write(codec, mic_jack_off);
1223 /* unsolicited event for HP jack sensing */
1224 static void ad1981_hp_unsol_event(struct hda_codec *codec,
1229 case AD1981_HP_EVENT:
1230 ad1981_hp_automute(codec);
1232 case AD1981_MIC_EVENT:
1233 ad1981_hp_automic(codec);
1238 static struct hda_input_mux ad1981_hp_capture_source = {
1242 { "Docking-Station", 0x1 },
1247 static struct snd_kcontrol_new ad1981_hp_mixers[] = {
1248 HDA_BIND_VOL("Master Playback Volume", &ad1981_hp_bind_master_vol),
1250 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1251 .name = "Master Playback Switch",
1252 .info = ad198x_eapd_info,
1253 .get = ad198x_eapd_get,
1254 .put = ad1981_hp_master_sw_put,
1255 .private_value = 0x05,
1257 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
1258 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
1260 /* FIXME: analog mic/line loopback doesn't work with my tests...
1261 * (although recording is OK)
1263 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
1264 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
1265 HDA_CODEC_VOLUME("Docking-Station Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1266 HDA_CODEC_MUTE("Docking-Station Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1267 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT),
1268 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
1269 /* FIXME: does this laptop have analog CD connection? */
1270 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1271 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1273 HDA_CODEC_VOLUME("Mic Boost", 0x08, 0x0, HDA_INPUT),
1274 HDA_CODEC_VOLUME("Internal Mic Boost", 0x18, 0x0, HDA_INPUT),
1275 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1276 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
1278 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1279 .name = "Capture Source",
1280 .info = ad198x_mux_enum_info,
1281 .get = ad198x_mux_enum_get,
1282 .put = ad198x_mux_enum_put,
1287 /* initialize jack-sensing, too */
1288 static int ad1981_hp_init(struct hda_codec *codec)
1291 ad1981_hp_automute(codec);
1292 ad1981_hp_automic(codec);
1296 /* configuration for Toshiba Laptops */
1297 static struct hda_verb ad1981_toshiba_init_verbs[] = {
1298 {0x05, AC_VERB_SET_EAPD_BTLENABLE, 0x01 }, /* default on */
1299 /* pin sensing on HP and Mic jacks */
1300 {0x06, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_HP_EVENT},
1301 {0x08, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1981_MIC_EVENT},
1305 static struct snd_kcontrol_new ad1981_toshiba_mixers[] = {
1306 HDA_CODEC_VOLUME("Amp Volume", 0x1a, 0x0, HDA_OUTPUT),
1307 HDA_CODEC_MUTE("Amp Switch", 0x1a, 0x0, HDA_OUTPUT),
1311 /* configuration for Lenovo Thinkpad T60 */
1312 static struct snd_kcontrol_new ad1981_thinkpad_mixers[] = {
1313 HDA_CODEC_VOLUME("Master Playback Volume", 0x05, 0x0, HDA_OUTPUT),
1314 HDA_CODEC_MUTE("Master Playback Switch", 0x05, 0x0, HDA_OUTPUT),
1315 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
1316 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
1317 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
1318 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
1319 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1320 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1321 HDA_CODEC_VOLUME("Mic Boost", 0x08, 0x0, HDA_INPUT),
1322 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1323 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
1325 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1326 .name = "Capture Source",
1327 .info = ad198x_mux_enum_info,
1328 .get = ad198x_mux_enum_get,
1329 .put = ad198x_mux_enum_put,
1331 /* identical with AD1983 */
1333 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1334 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
1335 .info = ad1983_spdif_route_info,
1336 .get = ad1983_spdif_route_get,
1337 .put = ad1983_spdif_route_put,
1342 static struct hda_input_mux ad1981_thinkpad_capture_source = {
1360 static const char *ad1981_models[AD1981_MODELS] = {
1362 [AD1981_THINKPAD] = "thinkpad",
1363 [AD1981_BASIC] = "basic",
1364 [AD1981_TOSHIBA] = "toshiba"
1367 static struct snd_pci_quirk ad1981_cfg_tbl[] = {
1369 SND_PCI_QUIRK(0x103c, 0, "HP nx", AD1981_HP),
1370 /* HP nx6320 (reversed SSID, H/W bug) */
1371 SND_PCI_QUIRK(0x30b0, 0x103c, "HP nx6320", AD1981_HP),
1372 /* Lenovo Thinkpad T60/X60/Z6xx */
1373 SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1981_THINKPAD),
1374 SND_PCI_QUIRK(0x1014, 0x0597, "Lenovo Z60", AD1981_THINKPAD),
1375 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba U205", AD1981_TOSHIBA),
1379 static int patch_ad1981(struct hda_codec *codec)
1381 struct ad198x_spec *spec;
1384 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1390 spec->multiout.max_channels = 2;
1391 spec->multiout.num_dacs = ARRAY_SIZE(ad1981_dac_nids);
1392 spec->multiout.dac_nids = ad1981_dac_nids;
1393 spec->multiout.dig_out_nid = AD1981_SPDIF_OUT;
1394 spec->num_adc_nids = 1;
1395 spec->adc_nids = ad1981_adc_nids;
1396 spec->capsrc_nids = ad1981_capsrc_nids;
1397 spec->input_mux = &ad1981_capture_source;
1398 spec->num_mixers = 1;
1399 spec->mixers[0] = ad1981_mixers;
1400 spec->num_init_verbs = 1;
1401 spec->init_verbs[0] = ad1981_init_verbs;
1402 spec->spdif_route = 0;
1403 #ifdef CONFIG_SND_HDA_POWER_SAVE
1404 spec->loopback.amplist = ad1981_loopbacks;
1407 codec->patch_ops = ad198x_patch_ops;
1409 /* override some parameters */
1410 board_config = snd_hda_check_board_config(codec, AD1981_MODELS,
1413 switch (board_config) {
1415 spec->mixers[0] = ad1981_hp_mixers;
1416 spec->num_init_verbs = 2;
1417 spec->init_verbs[1] = ad1981_hp_init_verbs;
1418 spec->multiout.dig_out_nid = 0;
1419 spec->input_mux = &ad1981_hp_capture_source;
1421 codec->patch_ops.init = ad1981_hp_init;
1422 codec->patch_ops.unsol_event = ad1981_hp_unsol_event;
1424 case AD1981_THINKPAD:
1425 spec->mixers[0] = ad1981_thinkpad_mixers;
1426 spec->input_mux = &ad1981_thinkpad_capture_source;
1428 case AD1981_TOSHIBA:
1429 spec->mixers[0] = ad1981_hp_mixers;
1430 spec->mixers[1] = ad1981_toshiba_mixers;
1431 spec->num_init_verbs = 2;
1432 spec->init_verbs[1] = ad1981_toshiba_init_verbs;
1433 spec->multiout.dig_out_nid = 0;
1434 spec->input_mux = &ad1981_hp_capture_source;
1435 codec->patch_ops.init = ad1981_hp_init;
1436 codec->patch_ops.unsol_event = ad1981_hp_unsol_event;
1446 * Output pins and routes
1448 * Pin Mix Sel DAC (*)
1449 * port-A 0x11 (mute/hp) <- 0x22 <- 0x37 <- 03/04/06
1450 * port-B 0x14 (mute/hp) <- 0x2b <- 0x30 <- 03/04/06
1451 * port-C 0x15 (mute) <- 0x2c <- 0x31 <- 05/0a
1452 * port-D 0x12 (mute/hp) <- 0x29 <- 04
1453 * port-E 0x17 (mute/hp) <- 0x26 <- 0x32 <- 05/0a
1454 * port-F 0x16 (mute) <- 0x2a <- 06
1455 * port-G 0x24 (mute) <- 0x27 <- 05
1456 * port-H 0x25 (mute) <- 0x28 <- 0a
1457 * mono 0x13 (mute/amp)<- 0x1e <- 0x36 <- 03/04/06
1459 * DAC0 = 03h, DAC1 = 04h, DAC2 = 05h, DAC3 = 06h, DAC4 = 0ah
1460 * (*) DAC2/3/4 are swapped to DAC3/4/2 on AD198A rev.2 due to a h/w bug.
1462 * Input pins and routes
1464 * pin boost mix input # / adc input #
1465 * port-A 0x11 -> 0x38 -> mix 2, ADC 0
1466 * port-B 0x14 -> 0x39 -> mix 0, ADC 1
1467 * port-C 0x15 -> 0x3a -> 33:0 - mix 1, ADC 2
1468 * port-D 0x12 -> 0x3d -> mix 3, ADC 8
1469 * port-E 0x17 -> 0x3c -> 34:0 - mix 4, ADC 4
1470 * port-F 0x16 -> 0x3b -> mix 5, ADC 3
1471 * port-G 0x24 -> N/A -> 33:1 - mix 1, 34:1 - mix 4, ADC 6
1472 * port-H 0x25 -> N/A -> 33:2 - mix 1, 34:2 - mix 4, ADC 7
1476 * 6stack - front/surr/CLFE/side/opt DACs - 04/06/05/0a/03
1477 * 3stack - front/surr/CLFE/opt DACs - 04/05/0a/03
1479 * Inputs of Analog Mix (0x20)
1480 * 0:Port-B (front mic)
1481 * 1:Port-C/G/H (line-in)
1483 * 3:Port-D (line-in/2)
1484 * 4:Port-E/G/H (mic-in)
1485 * 5:Port-F (mic2-in)
1491 * 1:Port-B (front mic-in)
1492 * 2:Port-C (line-in)
1493 * 3:Port-F (mic2-in)
1498 * 8:Port-D (line-in/2)
1501 * Proposed pin assignments by the datasheet
1504 * Port-A front headphone
1514 * Port-A front headphone
1516 * C rear line-in/surround
1518 * E rear mic-in/CLFE
1524 * D internal speaker (with EAPD)
1525 * E/F quad mic array
1541 /* reivision id to check workarounds */
1542 #define AD1988A_REV2 0x100200
1544 #define is_rev2(codec) \
1545 ((codec)->vendor_id == 0x11d41988 && \
1546 (codec)->revision_id == AD1988A_REV2)
1552 static hda_nid_t ad1988_6stack_dac_nids[4] = {
1553 0x04, 0x06, 0x05, 0x0a
1556 static hda_nid_t ad1988_3stack_dac_nids[3] = {
1560 /* for AD1988A revision-2, DAC2-4 are swapped */
1561 static hda_nid_t ad1988_6stack_dac_nids_rev2[4] = {
1562 0x04, 0x05, 0x0a, 0x06
1565 static hda_nid_t ad1988_3stack_dac_nids_rev2[3] = {
1569 static hda_nid_t ad1988_adc_nids[3] = {
1573 static hda_nid_t ad1988_capsrc_nids[3] = {
1577 #define AD1988_SPDIF_OUT 0x02
1578 #define AD1988_SPDIF_IN 0x07
1580 static struct hda_input_mux ad1988_6stack_capture_source = {
1583 { "Front Mic", 0x0 },
1591 static struct hda_input_mux ad1988_laptop_capture_source = {
1594 { "Mic/Line", 0x0 },
1602 static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol,
1603 struct snd_ctl_elem_info *uinfo)
1605 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1606 struct ad198x_spec *spec = codec->spec;
1607 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
1608 spec->num_channel_mode);
1611 static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol,
1612 struct snd_ctl_elem_value *ucontrol)
1614 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1615 struct ad198x_spec *spec = codec->spec;
1616 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
1617 spec->num_channel_mode, spec->multiout.max_channels);
1620 static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol,
1621 struct snd_ctl_elem_value *ucontrol)
1623 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1624 struct ad198x_spec *spec = codec->spec;
1625 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
1626 spec->num_channel_mode,
1627 &spec->multiout.max_channels);
1628 if (err >= 0 && spec->need_dac_fix)
1629 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
1634 static struct snd_kcontrol_new ad1988_6stack_mixers1[] = {
1635 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1636 HDA_CODEC_VOLUME("Surround Playback Volume", 0x06, 0x0, HDA_OUTPUT),
1637 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT),
1638 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT),
1639 HDA_CODEC_VOLUME("Side Playback Volume", 0x0a, 0x0, HDA_OUTPUT),
1643 static struct snd_kcontrol_new ad1988_6stack_mixers1_rev2[] = {
1644 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1645 HDA_CODEC_VOLUME("Surround Playback Volume", 0x05, 0x0, HDA_OUTPUT),
1646 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
1647 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0a, 2, 0x0, HDA_OUTPUT),
1648 HDA_CODEC_VOLUME("Side Playback Volume", 0x06, 0x0, HDA_OUTPUT),
1652 static struct snd_kcontrol_new ad1988_6stack_mixers2[] = {
1653 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT),
1654 HDA_BIND_MUTE("Surround Playback Switch", 0x2a, 2, HDA_INPUT),
1655 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x27, 1, 2, HDA_INPUT),
1656 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x27, 2, 2, HDA_INPUT),
1657 HDA_BIND_MUTE("Side Playback Switch", 0x28, 2, HDA_INPUT),
1658 HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT),
1659 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT),
1661 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT),
1662 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT),
1663 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT),
1664 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT),
1665 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
1666 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
1667 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT),
1668 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT),
1670 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
1671 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
1673 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
1674 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
1676 HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT),
1677 HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT),
1683 static struct snd_kcontrol_new ad1988_3stack_mixers1[] = {
1684 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1685 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT),
1686 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT),
1687 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT),
1691 static struct snd_kcontrol_new ad1988_3stack_mixers1_rev2[] = {
1692 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1693 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT),
1694 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x06, 1, 0x0, HDA_OUTPUT),
1695 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x06, 2, 0x0, HDA_OUTPUT),
1699 static struct snd_kcontrol_new ad1988_3stack_mixers2[] = {
1700 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT),
1701 HDA_BIND_MUTE("Surround Playback Switch", 0x2c, 2, HDA_INPUT),
1702 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x26, 1, 2, HDA_INPUT),
1703 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x26, 2, 2, HDA_INPUT),
1704 HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT),
1705 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT),
1707 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT),
1708 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT),
1709 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT),
1710 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT),
1711 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
1712 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
1713 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT),
1714 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT),
1716 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
1717 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
1719 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
1720 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
1722 HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT),
1723 HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT),
1725 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1726 .name = "Channel Mode",
1727 .info = ad198x_ch_mode_info,
1728 .get = ad198x_ch_mode_get,
1729 .put = ad198x_ch_mode_put,
1736 static struct snd_kcontrol_new ad1988_laptop_mixers[] = {
1737 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
1738 HDA_CODEC_MUTE("PCM Playback Switch", 0x29, 0x0, HDA_INPUT),
1739 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT),
1741 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT),
1742 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT),
1743 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x0, HDA_INPUT),
1744 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x0, HDA_INPUT),
1745 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
1746 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
1748 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
1749 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
1751 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
1752 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
1754 HDA_CODEC_VOLUME("Mic Boost", 0x39, 0x0, HDA_OUTPUT),
1757 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1758 .name = "External Amplifier",
1759 .info = ad198x_eapd_info,
1760 .get = ad198x_eapd_get,
1761 .put = ad198x_eapd_put,
1762 .private_value = 0x12 | (1 << 8), /* port-D, inversed */
1769 static struct snd_kcontrol_new ad1988_capture_mixers[] = {
1770 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
1771 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
1772 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
1773 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
1774 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x0e, 0x0, HDA_OUTPUT),
1775 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x0e, 0x0, HDA_OUTPUT),
1777 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1778 /* The multiple "Capture Source" controls confuse alsamixer
1779 * So call somewhat different..
1780 * FIXME: the controls appear in the "playback" view!
1782 /* .name = "Capture Source", */
1783 .name = "Input Source",
1785 .info = ad198x_mux_enum_info,
1786 .get = ad198x_mux_enum_get,
1787 .put = ad198x_mux_enum_put,
1792 static int ad1988_spdif_playback_source_info(struct snd_kcontrol *kcontrol,
1793 struct snd_ctl_elem_info *uinfo)
1795 static char *texts[] = {
1796 "PCM", "ADC1", "ADC2", "ADC3"
1798 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1800 uinfo->value.enumerated.items = 4;
1801 if (uinfo->value.enumerated.item >= 4)
1802 uinfo->value.enumerated.item = 3;
1803 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1807 static int ad1988_spdif_playback_source_get(struct snd_kcontrol *kcontrol,
1808 struct snd_ctl_elem_value *ucontrol)
1810 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1813 sel = snd_hda_codec_read(codec, 0x1d, 0, AC_VERB_GET_AMP_GAIN_MUTE,
1816 ucontrol->value.enumerated.item[0] = 0;
1818 sel = snd_hda_codec_read(codec, 0x0b, 0,
1819 AC_VERB_GET_CONNECT_SEL, 0);
1824 ucontrol->value.enumerated.item[0] = sel;
1829 static int ad1988_spdif_playback_source_put(struct snd_kcontrol *kcontrol,
1830 struct snd_ctl_elem_value *ucontrol)
1832 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1833 unsigned int val, sel;
1836 val = ucontrol->value.enumerated.item[0];
1838 sel = snd_hda_codec_read(codec, 0x1d, 0,
1839 AC_VERB_GET_AMP_GAIN_MUTE,
1841 change = sel & 0x80;
1843 snd_hda_codec_write_cache(codec, 0x1d, 0,
1844 AC_VERB_SET_AMP_GAIN_MUTE,
1846 snd_hda_codec_write_cache(codec, 0x1d, 0,
1847 AC_VERB_SET_AMP_GAIN_MUTE,
1851 sel = snd_hda_codec_read(codec, 0x1d, 0,
1852 AC_VERB_GET_AMP_GAIN_MUTE,
1853 AC_AMP_GET_INPUT | 0x01);
1854 change = sel & 0x80;
1856 snd_hda_codec_write_cache(codec, 0x1d, 0,
1857 AC_VERB_SET_AMP_GAIN_MUTE,
1859 snd_hda_codec_write_cache(codec, 0x1d, 0,
1860 AC_VERB_SET_AMP_GAIN_MUTE,
1863 sel = snd_hda_codec_read(codec, 0x0b, 0,
1864 AC_VERB_GET_CONNECT_SEL, 0) + 1;
1865 change |= sel != val;
1867 snd_hda_codec_write_cache(codec, 0x0b, 0,
1868 AC_VERB_SET_CONNECT_SEL,
1874 static struct snd_kcontrol_new ad1988_spdif_out_mixers[] = {
1875 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
1877 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1878 .name = "IEC958 Playback Source",
1879 .info = ad1988_spdif_playback_source_info,
1880 .get = ad1988_spdif_playback_source_get,
1881 .put = ad1988_spdif_playback_source_put,
1886 static struct snd_kcontrol_new ad1988_spdif_in_mixers[] = {
1887 HDA_CODEC_VOLUME("IEC958 Capture Volume", 0x1c, 0x0, HDA_INPUT),
1893 * initialization verbs
1897 * for 6-stack (+dig)
1899 static struct hda_verb ad1988_6stack_init_verbs[] = {
1900 /* Front, Surround, CLFE, side DAC; unmute as default */
1901 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1902 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1903 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1904 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1905 /* Port-A front headphon path */
1906 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */
1907 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1908 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1909 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1910 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1911 /* Port-D line-out path */
1912 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1913 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1914 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1915 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1916 /* Port-F surround path */
1917 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1918 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1919 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1920 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1921 /* Port-G CLFE path */
1922 {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1923 {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1924 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1925 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1926 /* Port-H side path */
1927 {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1928 {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1929 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1930 {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1932 {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */
1933 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1934 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1935 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1936 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */
1937 /* Port-B front mic-in path */
1938 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1939 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1940 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1941 /* Port-C line-in path */
1942 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1943 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1944 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1945 {0x33, AC_VERB_SET_CONNECT_SEL, 0x0},
1946 /* Port-E mic-in path */
1947 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1948 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1949 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1950 {0x34, AC_VERB_SET_CONNECT_SEL, 0x0},
1955 static struct hda_verb ad1988_capture_init_verbs[] = {
1956 /* mute analog mix */
1957 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1958 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1959 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1960 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1961 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1962 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
1963 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1964 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
1965 /* select ADCs - front-mic */
1966 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
1967 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
1968 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
1970 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1971 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1972 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1977 static struct hda_verb ad1988_spdif_init_verbs[] = {
1979 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */
1980 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x0}, /* ADC1 */
1981 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1982 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1984 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
1990 * verbs for 3stack (+dig)
1992 static struct hda_verb ad1988_3stack_ch2_init[] = {
1993 /* set port-C to line-in */
1994 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1995 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1996 /* set port-E to mic-in */
1997 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1998 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2002 static struct hda_verb ad1988_3stack_ch6_init[] = {
2003 /* set port-C to surround out */
2004 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2005 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2006 /* set port-E to CLFE out */
2007 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2008 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2012 static struct hda_channel_mode ad1988_3stack_modes[2] = {
2013 { 2, ad1988_3stack_ch2_init },
2014 { 6, ad1988_3stack_ch6_init },
2017 static struct hda_verb ad1988_3stack_init_verbs[] = {
2018 /* Front, Surround, CLFE, side DAC; unmute as default */
2019 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2020 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2021 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2022 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2023 /* Port-A front headphon path */
2024 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */
2025 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2026 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2027 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2028 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2029 /* Port-D line-out path */
2030 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2031 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2032 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2033 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2035 {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */
2036 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2037 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2038 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2039 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */
2040 /* Port-B front mic-in path */
2041 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2042 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2043 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2044 /* Port-C line-in/surround path - 6ch mode as default */
2045 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2046 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2047 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2048 {0x31, AC_VERB_SET_CONNECT_SEL, 0x0}, /* output sel: DAC 0x05 */
2049 {0x33, AC_VERB_SET_CONNECT_SEL, 0x0},
2050 /* Port-E mic-in/CLFE path - 6ch mode as default */
2051 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2052 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2053 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2054 {0x32, AC_VERB_SET_CONNECT_SEL, 0x1}, /* output sel: DAC 0x0a */
2055 {0x34, AC_VERB_SET_CONNECT_SEL, 0x0},
2056 /* mute analog mix */
2057 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2058 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2059 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2060 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2061 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2062 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
2063 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2064 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2065 /* select ADCs - front-mic */
2066 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
2067 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
2068 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
2070 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2071 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2072 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2077 * verbs for laptop mode (+dig)
2079 static struct hda_verb ad1988_laptop_hp_on[] = {
2080 /* unmute port-A and mute port-D */
2081 { 0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2082 { 0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2085 static struct hda_verb ad1988_laptop_hp_off[] = {
2086 /* mute port-A and unmute port-D */
2087 { 0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2088 { 0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2092 #define AD1988_HP_EVENT 0x01
2094 static struct hda_verb ad1988_laptop_init_verbs[] = {
2095 /* Front, Surround, CLFE, side DAC; unmute as default */
2096 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2097 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2098 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2099 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2100 /* Port-A front headphon path */
2101 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */
2102 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2103 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2104 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2105 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2106 /* unsolicited event for pin-sense */
2107 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1988_HP_EVENT },
2108 /* Port-D line-out path + EAPD */
2109 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2110 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2111 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2112 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2113 {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x00}, /* EAPD-off */
2115 {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */
2116 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2117 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2118 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2119 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */
2120 /* Port-B mic-in path */
2121 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2122 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2123 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2124 /* Port-C docking station - try to output */
2125 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2126 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2127 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2128 {0x33, AC_VERB_SET_CONNECT_SEL, 0x0},
2129 /* mute analog mix */
2130 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2131 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2132 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2133 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2134 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2135 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
2136 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2137 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2138 /* select ADCs - mic */
2139 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
2140 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
2141 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
2143 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2144 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2145 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2149 static void ad1988_laptop_unsol_event(struct hda_codec *codec, unsigned int res)
2151 if ((res >> 26) != AD1988_HP_EVENT)
2153 if (snd_hda_codec_read(codec, 0x11, 0, AC_VERB_GET_PIN_SENSE, 0) & (1 << 31))
2154 snd_hda_sequence_write(codec, ad1988_laptop_hp_on);
2156 snd_hda_sequence_write(codec, ad1988_laptop_hp_off);
2159 #ifdef CONFIG_SND_HDA_POWER_SAVE
2160 static struct hda_amp_list ad1988_loopbacks[] = {
2161 { 0x20, HDA_INPUT, 0 }, /* Front Mic */
2162 { 0x20, HDA_INPUT, 1 }, /* Line */
2163 { 0x20, HDA_INPUT, 4 }, /* Mic */
2164 { 0x20, HDA_INPUT, 6 }, /* CD */
2170 * Automatic parse of I/O pins from the BIOS configuration
2173 #define NUM_CONTROL_ALLOC 32
2174 #define NUM_VERB_ALLOC 32
2181 static struct snd_kcontrol_new ad1988_control_templates[] = {
2182 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2183 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2184 HDA_BIND_MUTE(NULL, 0, 0, 0),
2187 /* add dynamic controls */
2188 static int add_control(struct ad198x_spec *spec, int type, const char *name,
2191 struct snd_kcontrol_new *knew;
2193 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2194 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2196 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2199 if (spec->kctl_alloc) {
2200 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2201 kfree(spec->kctl_alloc);
2203 spec->kctl_alloc = knew;
2204 spec->num_kctl_alloc = num;
2207 knew = &spec->kctl_alloc[spec->num_kctl_used];
2208 *knew = ad1988_control_templates[type];
2209 knew->name = kstrdup(name, GFP_KERNEL);
2212 knew->private_value = val;
2213 spec->num_kctl_used++;
2217 #define AD1988_PIN_CD_NID 0x18
2218 #define AD1988_PIN_BEEP_NID 0x10
2220 static hda_nid_t ad1988_mixer_nids[8] = {
2221 /* A B C D E F G H */
2222 0x22, 0x2b, 0x2c, 0x29, 0x26, 0x2a, 0x27, 0x28
2225 static inline hda_nid_t ad1988_idx_to_dac(struct hda_codec *codec, int idx)
2227 static hda_nid_t idx_to_dac[8] = {
2228 /* A B C D E F G H */
2229 0x04, 0x06, 0x05, 0x04, 0x0a, 0x06, 0x05, 0x0a
2231 static hda_nid_t idx_to_dac_rev2[8] = {
2232 /* A B C D E F G H */
2233 0x04, 0x05, 0x0a, 0x04, 0x06, 0x05, 0x0a, 0x06
2236 return idx_to_dac_rev2[idx];
2238 return idx_to_dac[idx];
2241 static hda_nid_t ad1988_boost_nids[8] = {
2242 0x38, 0x39, 0x3a, 0x3d, 0x3c, 0x3b, 0, 0
2245 static int ad1988_pin_idx(hda_nid_t nid)
2247 static hda_nid_t ad1988_io_pins[8] = {
2248 0x11, 0x14, 0x15, 0x12, 0x17, 0x16, 0x24, 0x25
2251 for (i = 0; i < ARRAY_SIZE(ad1988_io_pins); i++)
2252 if (ad1988_io_pins[i] == nid)
2254 return 0; /* should be -1 */
2257 static int ad1988_pin_to_loopback_idx(hda_nid_t nid)
2259 static int loopback_idx[8] = {
2260 2, 0, 1, 3, 4, 5, 1, 4
2263 case AD1988_PIN_CD_NID:
2266 return loopback_idx[ad1988_pin_idx(nid)];
2270 static int ad1988_pin_to_adc_idx(hda_nid_t nid)
2272 static int adc_idx[8] = {
2273 0, 1, 2, 8, 4, 3, 6, 7
2276 case AD1988_PIN_CD_NID:
2279 return adc_idx[ad1988_pin_idx(nid)];
2283 /* fill in the dac_nids table from the parsed pin configuration */
2284 static int ad1988_auto_fill_dac_nids(struct hda_codec *codec,
2285 const struct auto_pin_cfg *cfg)
2287 struct ad198x_spec *spec = codec->spec;
2290 spec->multiout.dac_nids = spec->private_dac_nids;
2292 /* check the pins hardwired to audio widget */
2293 for (i = 0; i < cfg->line_outs; i++) {
2294 idx = ad1988_pin_idx(cfg->line_out_pins[i]);
2295 spec->multiout.dac_nids[i] = ad1988_idx_to_dac(codec, idx);
2297 spec->multiout.num_dacs = cfg->line_outs;
2301 /* add playback controls from the parsed DAC table */
2302 static int ad1988_auto_create_multi_out_ctls(struct ad198x_spec *spec,
2303 const struct auto_pin_cfg *cfg)
2306 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
2310 for (i = 0; i < cfg->line_outs; i++) {
2311 hda_nid_t dac = spec->multiout.dac_nids[i];
2314 nid = ad1988_mixer_nids[ad1988_pin_idx(cfg->line_out_pins[i])];
2317 err = add_control(spec, AD_CTL_WIDGET_VOL,
2318 "Center Playback Volume",
2319 HDA_COMPOSE_AMP_VAL(dac, 1, 0, HDA_OUTPUT));
2322 err = add_control(spec, AD_CTL_WIDGET_VOL,
2323 "LFE Playback Volume",
2324 HDA_COMPOSE_AMP_VAL(dac, 2, 0, HDA_OUTPUT));
2327 err = add_control(spec, AD_CTL_BIND_MUTE,
2328 "Center Playback Switch",
2329 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT));
2332 err = add_control(spec, AD_CTL_BIND_MUTE,
2333 "LFE Playback Switch",
2334 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT));
2338 sprintf(name, "%s Playback Volume", chname[i]);
2339 err = add_control(spec, AD_CTL_WIDGET_VOL, name,
2340 HDA_COMPOSE_AMP_VAL(dac, 3, 0, HDA_OUTPUT));
2343 sprintf(name, "%s Playback Switch", chname[i]);
2344 err = add_control(spec, AD_CTL_BIND_MUTE, name,
2345 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
2353 /* add playback controls for speaker and HP outputs */
2354 static int ad1988_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
2357 struct ad198x_spec *spec = codec->spec;
2365 idx = ad1988_pin_idx(pin);
2366 nid = ad1988_idx_to_dac(codec, idx);
2367 /* specify the DAC as the extra output */
2368 if (! spec->multiout.hp_nid)
2369 spec->multiout.hp_nid = nid;
2371 spec->multiout.extra_out_nid[0] = nid;
2372 /* control HP volume/switch on the output mixer amp */
2373 sprintf(name, "%s Playback Volume", pfx);
2374 if ((err = add_control(spec, AD_CTL_WIDGET_VOL, name,
2375 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2377 nid = ad1988_mixer_nids[idx];
2378 sprintf(name, "%s Playback Switch", pfx);
2379 if ((err = add_control(spec, AD_CTL_BIND_MUTE, name,
2380 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2385 /* create input playback/capture controls for the given pin */
2386 static int new_analog_input(struct ad198x_spec *spec, hda_nid_t pin,
2387 const char *ctlname, int boost)
2392 sprintf(name, "%s Playback Volume", ctlname);
2393 idx = ad1988_pin_to_loopback_idx(pin);
2394 if ((err = add_control(spec, AD_CTL_WIDGET_VOL, name,
2395 HDA_COMPOSE_AMP_VAL(0x20, 3, idx, HDA_INPUT))) < 0)
2397 sprintf(name, "%s Playback Switch", ctlname);
2398 if ((err = add_control(spec, AD_CTL_WIDGET_MUTE, name,
2399 HDA_COMPOSE_AMP_VAL(0x20, 3, idx, HDA_INPUT))) < 0)
2403 idx = ad1988_pin_idx(pin);
2404 bnid = ad1988_boost_nids[idx];
2406 sprintf(name, "%s Boost", ctlname);
2407 return add_control(spec, AD_CTL_WIDGET_VOL, name,
2408 HDA_COMPOSE_AMP_VAL(bnid, 3, idx, HDA_OUTPUT));
2415 /* create playback/capture controls for input pins */
2416 static int ad1988_auto_create_analog_input_ctls(struct ad198x_spec *spec,
2417 const struct auto_pin_cfg *cfg)
2419 struct hda_input_mux *imux = &spec->private_imux;
2422 for (i = 0; i < AUTO_PIN_LAST; i++) {
2423 err = new_analog_input(spec, cfg->input_pins[i],
2424 auto_pin_cfg_labels[i],
2425 i <= AUTO_PIN_FRONT_MIC);
2428 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2429 imux->items[imux->num_items].index = ad1988_pin_to_adc_idx(cfg->input_pins[i]);
2432 imux->items[imux->num_items].label = "Mix";
2433 imux->items[imux->num_items].index = 9;
2436 if ((err = add_control(spec, AD_CTL_WIDGET_VOL,
2437 "Analog Mix Playback Volume",
2438 HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT))) < 0)
2440 if ((err = add_control(spec, AD_CTL_WIDGET_MUTE,
2441 "Analog Mix Playback Switch",
2442 HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT))) < 0)
2448 static void ad1988_auto_set_output_and_unmute(struct hda_codec *codec,
2449 hda_nid_t nid, int pin_type,
2453 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2454 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2456 case 0x11: /* port-A - DAC 04 */
2457 snd_hda_codec_write(codec, 0x37, 0, AC_VERB_SET_CONNECT_SEL, 0x01);
2459 case 0x14: /* port-B - DAC 06 */
2460 snd_hda_codec_write(codec, 0x30, 0, AC_VERB_SET_CONNECT_SEL, 0x02);
2462 case 0x15: /* port-C - DAC 05 */
2463 snd_hda_codec_write(codec, 0x31, 0, AC_VERB_SET_CONNECT_SEL, 0x00);
2465 case 0x17: /* port-E - DAC 0a */
2466 snd_hda_codec_write(codec, 0x32, 0, AC_VERB_SET_CONNECT_SEL, 0x01);
2468 case 0x13: /* mono - DAC 04 */
2469 snd_hda_codec_write(codec, 0x36, 0, AC_VERB_SET_CONNECT_SEL, 0x01);
2474 static void ad1988_auto_init_multi_out(struct hda_codec *codec)
2476 struct ad198x_spec *spec = codec->spec;
2479 for (i = 0; i < spec->autocfg.line_outs; i++) {
2480 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2481 ad1988_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2485 static void ad1988_auto_init_extra_out(struct hda_codec *codec)
2487 struct ad198x_spec *spec = codec->spec;
2490 pin = spec->autocfg.speaker_pins[0];
2491 if (pin) /* connect to front */
2492 ad1988_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
2493 pin = spec->autocfg.hp_pins[0];
2494 if (pin) /* connect to front */
2495 ad1988_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2498 static void ad1988_auto_init_analog_input(struct hda_codec *codec)
2500 struct ad198x_spec *spec = codec->spec;
2503 for (i = 0; i < AUTO_PIN_LAST; i++) {
2504 hda_nid_t nid = spec->autocfg.input_pins[i];
2508 case 0x15: /* port-C */
2509 snd_hda_codec_write(codec, 0x33, 0, AC_VERB_SET_CONNECT_SEL, 0x0);
2511 case 0x17: /* port-E */
2512 snd_hda_codec_write(codec, 0x34, 0, AC_VERB_SET_CONNECT_SEL, 0x0);
2515 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2516 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2517 if (nid != AD1988_PIN_CD_NID)
2518 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2520 idx = ad1988_pin_idx(nid);
2521 if (ad1988_boost_nids[idx])
2522 snd_hda_codec_write(codec, ad1988_boost_nids[idx], 0,
2523 AC_VERB_SET_AMP_GAIN_MUTE,
2528 /* parse the BIOS configuration and set up the alc_spec */
2529 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2530 static int ad1988_parse_auto_config(struct hda_codec *codec)
2532 struct ad198x_spec *spec = codec->spec;
2535 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
2537 if ((err = ad1988_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
2539 if (! spec->autocfg.line_outs)
2540 return 0; /* can't find valid BIOS pin config */
2541 if ((err = ad1988_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
2542 (err = ad1988_auto_create_extra_out(codec,
2543 spec->autocfg.speaker_pins[0],
2545 (err = ad1988_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
2546 "Headphone")) < 0 ||
2547 (err = ad1988_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2550 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2552 if (spec->autocfg.dig_out_pin)
2553 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
2554 if (spec->autocfg.dig_in_pin)
2555 spec->dig_in_nid = AD1988_SPDIF_IN;
2557 if (spec->kctl_alloc)
2558 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2560 spec->init_verbs[spec->num_init_verbs++] = ad1988_6stack_init_verbs;
2562 spec->input_mux = &spec->private_imux;
2567 /* init callback for auto-configuration model -- overriding the default init */
2568 static int ad1988_auto_init(struct hda_codec *codec)
2571 ad1988_auto_init_multi_out(codec);
2572 ad1988_auto_init_extra_out(codec);
2573 ad1988_auto_init_analog_input(codec);
2581 static const char *ad1988_models[AD1988_MODEL_LAST] = {
2582 [AD1988_6STACK] = "6stack",
2583 [AD1988_6STACK_DIG] = "6stack-dig",
2584 [AD1988_3STACK] = "3stack",
2585 [AD1988_3STACK_DIG] = "3stack-dig",
2586 [AD1988_LAPTOP] = "laptop",
2587 [AD1988_LAPTOP_DIG] = "laptop-dig",
2588 [AD1988_AUTO] = "auto",
2591 static struct snd_pci_quirk ad1988_cfg_tbl[] = {
2592 SND_PCI_QUIRK(0x1043, 0x81f6, "Asus M2N-SLI", AD1988_6STACK_DIG),
2593 SND_PCI_QUIRK(0x1043, 0x81ec, "Asus P5B-DLX", AD1988_6STACK_DIG),
2597 static int patch_ad1988(struct hda_codec *codec)
2599 struct ad198x_spec *spec;
2602 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2609 snd_printk(KERN_INFO "patch_analog: AD1988A rev.2 is detected, enable workarounds\n");
2611 board_config = snd_hda_check_board_config(codec, AD1988_MODEL_LAST,
2612 ad1988_models, ad1988_cfg_tbl);
2613 if (board_config < 0) {
2614 printk(KERN_INFO "hda_codec: Unknown model for AD1988, trying auto-probe from BIOS...\n");
2615 board_config = AD1988_AUTO;
2618 if (board_config == AD1988_AUTO) {
2619 /* automatic parse from the BIOS config */
2620 int err = ad1988_parse_auto_config(codec);
2625 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 6-stack mode...\n");
2626 board_config = AD1988_6STACK;
2630 switch (board_config) {
2632 case AD1988_6STACK_DIG:
2633 spec->multiout.max_channels = 8;
2634 spec->multiout.num_dacs = 4;
2636 spec->multiout.dac_nids = ad1988_6stack_dac_nids_rev2;
2638 spec->multiout.dac_nids = ad1988_6stack_dac_nids;
2639 spec->input_mux = &ad1988_6stack_capture_source;
2640 spec->num_mixers = 2;
2642 spec->mixers[0] = ad1988_6stack_mixers1_rev2;
2644 spec->mixers[0] = ad1988_6stack_mixers1;
2645 spec->mixers[1] = ad1988_6stack_mixers2;
2646 spec->num_init_verbs = 1;
2647 spec->init_verbs[0] = ad1988_6stack_init_verbs;
2648 if (board_config == AD1988_6STACK_DIG) {
2649 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
2650 spec->dig_in_nid = AD1988_SPDIF_IN;
2654 case AD1988_3STACK_DIG:
2655 spec->multiout.max_channels = 6;
2656 spec->multiout.num_dacs = 3;
2658 spec->multiout.dac_nids = ad1988_3stack_dac_nids_rev2;
2660 spec->multiout.dac_nids = ad1988_3stack_dac_nids;
2661 spec->input_mux = &ad1988_6stack_capture_source;
2662 spec->channel_mode = ad1988_3stack_modes;
2663 spec->num_channel_mode = ARRAY_SIZE(ad1988_3stack_modes);
2664 spec->num_mixers = 2;
2666 spec->mixers[0] = ad1988_3stack_mixers1_rev2;
2668 spec->mixers[0] = ad1988_3stack_mixers1;
2669 spec->mixers[1] = ad1988_3stack_mixers2;
2670 spec->num_init_verbs = 1;
2671 spec->init_verbs[0] = ad1988_3stack_init_verbs;
2672 if (board_config == AD1988_3STACK_DIG)
2673 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
2676 case AD1988_LAPTOP_DIG:
2677 spec->multiout.max_channels = 2;
2678 spec->multiout.num_dacs = 1;
2679 spec->multiout.dac_nids = ad1988_3stack_dac_nids;
2680 spec->input_mux = &ad1988_laptop_capture_source;
2681 spec->num_mixers = 1;
2682 spec->mixers[0] = ad1988_laptop_mixers;
2683 spec->num_init_verbs = 1;
2684 spec->init_verbs[0] = ad1988_laptop_init_verbs;
2685 if (board_config == AD1988_LAPTOP_DIG)
2686 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
2690 spec->num_adc_nids = ARRAY_SIZE(ad1988_adc_nids);
2691 spec->adc_nids = ad1988_adc_nids;
2692 spec->capsrc_nids = ad1988_capsrc_nids;
2693 spec->mixers[spec->num_mixers++] = ad1988_capture_mixers;
2694 spec->init_verbs[spec->num_init_verbs++] = ad1988_capture_init_verbs;
2695 if (spec->multiout.dig_out_nid) {
2696 spec->mixers[spec->num_mixers++] = ad1988_spdif_out_mixers;
2697 spec->init_verbs[spec->num_init_verbs++] = ad1988_spdif_init_verbs;
2699 if (spec->dig_in_nid)
2700 spec->mixers[spec->num_mixers++] = ad1988_spdif_in_mixers;
2702 codec->patch_ops = ad198x_patch_ops;
2703 switch (board_config) {
2705 codec->patch_ops.init = ad1988_auto_init;
2708 case AD1988_LAPTOP_DIG:
2709 codec->patch_ops.unsol_event = ad1988_laptop_unsol_event;
2712 #ifdef CONFIG_SND_HDA_POWER_SAVE
2713 spec->loopback.amplist = ad1988_loopbacks;
2723 * port-B - front line/mic-in
2724 * port-E - aux in/out
2725 * port-F - aux in/out
2726 * port-C - rear line/mic-in
2727 * port-D - rear line/hp-out
2728 * port-A - front line/hp-out
2730 * AD1984 = AD1884 + two digital mic-ins
2733 * For simplicity, we share the single DAC for both HP and line-outs
2734 * right now. The inidividual playbacks could be easily implemented,
2735 * but no build-up framework is given, so far.
2738 static hda_nid_t ad1884_dac_nids[1] = {
2742 static hda_nid_t ad1884_adc_nids[2] = {
2746 static hda_nid_t ad1884_capsrc_nids[2] = {
2750 #define AD1884_SPDIF_OUT 0x02
2752 static struct hda_input_mux ad1884_capture_source = {
2755 { "Front Mic", 0x0 },
2762 static struct snd_kcontrol_new ad1884_base_mixers[] = {
2763 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
2764 /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */
2765 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
2766 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT),
2767 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT),
2768 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT),
2769 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
2770 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
2771 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
2772 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
2773 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT),
2774 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT),
2776 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x20, 0x03, HDA_INPUT),
2777 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x20, 0x03, HDA_INPUT),
2778 HDA_CODEC_VOLUME("Digital Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
2779 HDA_CODEC_MUTE("Digital Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
2781 HDA_CODEC_VOLUME("Mic Boost", 0x15, 0x0, HDA_INPUT),
2782 HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT),
2783 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
2784 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
2785 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
2786 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
2788 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2789 /* The multiple "Capture Source" controls confuse alsamixer
2790 * So call somewhat different..
2791 * FIXME: the controls appear in the "playback" view!
2793 /* .name = "Capture Source", */
2794 .name = "Input Source",
2796 .info = ad198x_mux_enum_info,
2797 .get = ad198x_mux_enum_get,
2798 .put = ad198x_mux_enum_put,
2800 /* SPDIF controls */
2801 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
2803 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2804 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
2805 /* identical with ad1983 */
2806 .info = ad1983_spdif_route_info,
2807 .get = ad1983_spdif_route_get,
2808 .put = ad1983_spdif_route_put,
2813 static struct snd_kcontrol_new ad1984_dmic_mixers[] = {
2814 HDA_CODEC_VOLUME("Digital Mic Capture Volume", 0x05, 0x0, HDA_INPUT),
2815 HDA_CODEC_MUTE("Digital Mic Capture Switch", 0x05, 0x0, HDA_INPUT),
2816 HDA_CODEC_VOLUME_IDX("Digital Mic Capture Volume", 1, 0x06, 0x0,
2818 HDA_CODEC_MUTE_IDX("Digital Mic Capture Switch", 1, 0x06, 0x0,
2824 * initialization verbs
2826 static struct hda_verb ad1884_init_verbs[] = {
2827 /* DACs; mute as default */
2828 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2829 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2830 /* Port-A (HP) mixer */
2831 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2832 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2834 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2835 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2836 /* HP selector - select DAC2 */
2837 {0x22, AC_VERB_SET_CONNECT_SEL, 0x1},
2838 /* Port-D (Line-out) mixer */
2839 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2840 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2842 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2843 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2844 /* Mono-out mixer */
2845 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2846 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2848 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2849 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2851 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
2852 /* Port-B (front mic) pin */
2853 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2854 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2855 /* Port-C (rear mic) pin */
2856 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2857 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2858 /* Analog mixer; mute as default */
2859 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2860 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2861 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2862 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2863 /* Analog Mix output amp */
2864 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
2865 /* SPDIF output selector */
2866 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */
2867 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
2871 #ifdef CONFIG_SND_HDA_POWER_SAVE
2872 static struct hda_amp_list ad1884_loopbacks[] = {
2873 { 0x20, HDA_INPUT, 0 }, /* Front Mic */
2874 { 0x20, HDA_INPUT, 1 }, /* Mic */
2875 { 0x20, HDA_INPUT, 2 }, /* CD */
2876 { 0x20, HDA_INPUT, 4 }, /* Docking */
2881 static int patch_ad1884(struct hda_codec *codec)
2883 struct ad198x_spec *spec;
2885 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2889 mutex_init(&spec->amp_mutex);
2892 spec->multiout.max_channels = 2;
2893 spec->multiout.num_dacs = ARRAY_SIZE(ad1884_dac_nids);
2894 spec->multiout.dac_nids = ad1884_dac_nids;
2895 spec->multiout.dig_out_nid = AD1884_SPDIF_OUT;
2896 spec->num_adc_nids = ARRAY_SIZE(ad1884_adc_nids);
2897 spec->adc_nids = ad1884_adc_nids;
2898 spec->capsrc_nids = ad1884_capsrc_nids;
2899 spec->input_mux = &ad1884_capture_source;
2900 spec->num_mixers = 1;
2901 spec->mixers[0] = ad1884_base_mixers;
2902 spec->num_init_verbs = 1;
2903 spec->init_verbs[0] = ad1884_init_verbs;
2904 spec->spdif_route = 0;
2905 #ifdef CONFIG_SND_HDA_POWER_SAVE
2906 spec->loopback.amplist = ad1884_loopbacks;
2909 codec->patch_ops = ad198x_patch_ops;
2915 * Lenovo Thinkpad T61/X61
2917 static struct hda_input_mux ad1984_thinkpad_capture_source = {
2921 { "Internal Mic", 0x1 },
2926 static struct snd_kcontrol_new ad1984_thinkpad_mixers[] = {
2927 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT),
2928 /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */
2929 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
2930 HDA_CODEC_MUTE("Speaker Playback Switch", 0x12, 0x0, HDA_OUTPUT),
2931 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
2932 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
2933 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
2934 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
2935 HDA_CODEC_VOLUME("Docking Mic Playback Volume", 0x20, 0x04, HDA_INPUT),
2936 HDA_CODEC_MUTE("Docking Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
2937 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT),
2938 HDA_CODEC_VOLUME("Internal Mic Boost", 0x15, 0x0, HDA_INPUT),
2939 HDA_CODEC_VOLUME("Docking Mic Boost", 0x25, 0x0, HDA_OUTPUT),
2940 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
2941 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
2942 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
2943 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
2944 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
2945 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
2947 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2948 /* The multiple "Capture Source" controls confuse alsamixer
2949 * So call somewhat different..
2950 * FIXME: the controls appear in the "playback" view!
2952 /* .name = "Capture Source", */
2953 .name = "Input Source",
2955 .info = ad198x_mux_enum_info,
2956 .get = ad198x_mux_enum_get,
2957 .put = ad198x_mux_enum_put,
2962 /* additional verbs */
2963 static struct hda_verb ad1984_thinkpad_init_verbs[] = {
2964 /* Port-E (docking station mic) pin */
2965 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2966 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2967 /* docking mic boost */
2968 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2969 /* Analog mixer - docking mic; mute as default */
2970 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2971 /* enable EAPD bit */
2972 {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
2976 /* Digial MIC ADC NID 0x05 + 0x06 */
2977 static int ad1984_pcm_dmic_prepare(struct hda_pcm_stream *hinfo,
2978 struct hda_codec *codec,
2979 unsigned int stream_tag,
2980 unsigned int format,
2981 struct snd_pcm_substream *substream)
2983 snd_hda_codec_setup_stream(codec, 0x05 + substream->number,
2984 stream_tag, 0, format);
2988 static int ad1984_pcm_dmic_cleanup(struct hda_pcm_stream *hinfo,
2989 struct hda_codec *codec,
2990 struct snd_pcm_substream *substream)
2992 snd_hda_codec_setup_stream(codec, 0x05 + substream->number,
2997 static struct hda_pcm_stream ad1984_pcm_dmic_capture = {
3003 .prepare = ad1984_pcm_dmic_prepare,
3004 .cleanup = ad1984_pcm_dmic_cleanup
3008 static int ad1984_build_pcms(struct hda_codec *codec)
3010 struct ad198x_spec *spec = codec->spec;
3011 struct hda_pcm *info;
3014 err = ad198x_build_pcms(codec);
3018 info = spec->pcm_rec + codec->num_pcms;
3020 info->name = "AD1984 Digital Mic";
3021 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad1984_pcm_dmic_capture;
3032 static const char *ad1984_models[AD1984_MODELS] = {
3033 [AD1984_BASIC] = "basic",
3034 [AD1984_THINKPAD] = "thinkpad",
3037 static struct snd_pci_quirk ad1984_cfg_tbl[] = {
3038 /* Lenovo Thinkpad T61/X61 */
3039 SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1984_THINKPAD),
3043 static int patch_ad1984(struct hda_codec *codec)
3045 struct ad198x_spec *spec;
3046 int board_config, err;
3048 err = patch_ad1884(codec);
3052 board_config = snd_hda_check_board_config(codec, AD1984_MODELS,
3053 ad1984_models, ad1984_cfg_tbl);
3054 switch (board_config) {
3056 /* additional digital mics */
3057 spec->mixers[spec->num_mixers++] = ad1984_dmic_mixers;
3058 codec->patch_ops.build_pcms = ad1984_build_pcms;
3060 case AD1984_THINKPAD:
3061 spec->multiout.dig_out_nid = 0;
3062 spec->input_mux = &ad1984_thinkpad_capture_source;
3063 spec->mixers[0] = ad1984_thinkpad_mixers;
3064 spec->init_verbs[spec->num_init_verbs++] = ad1984_thinkpad_init_verbs;
3074 * port-A - front hp-out
3075 * port-B - front mic-in
3076 * port-C - rear line-in, shared surr-out (3stack)
3077 * port-D - rear line-out
3078 * port-E - rear mic-in, shared clfe-out (3stack)
3079 * port-F - rear surr-out (6stack)
3080 * port-G - rear clfe-out (6stack)
3083 static hda_nid_t ad1882_dac_nids[3] = {
3087 static hda_nid_t ad1882_adc_nids[2] = {
3091 static hda_nid_t ad1882_capsrc_nids[2] = {
3095 #define AD1882_SPDIF_OUT 0x02
3097 /* list: 0x11, 0x39, 0x3a, 0x18, 0x3c, 0x3b, 0x12, 0x20 */
3098 static struct hda_input_mux ad1882_capture_source = {
3101 { "Front Mic", 0x1 },
3109 static struct snd_kcontrol_new ad1882_base_mixers[] = {
3110 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT),
3111 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
3112 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT),
3113 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT),
3114 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
3115 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT),
3116 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT),
3117 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT),
3118 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
3119 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3120 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
3121 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
3122 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x04, HDA_INPUT),
3123 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x04, HDA_INPUT),
3124 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT),
3125 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT),
3126 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x07, HDA_INPUT),
3127 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x07, HDA_INPUT),
3128 HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT),
3129 HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT),
3130 HDA_CODEC_VOLUME("Line-In Boost", 0x3a, 0x0, HDA_OUTPUT),
3131 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3132 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3133 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
3134 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
3136 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3137 /* The multiple "Capture Source" controls confuse alsamixer
3138 * So call somewhat different..
3139 * FIXME: the controls appear in the "playback" view!
3141 /* .name = "Capture Source", */
3142 .name = "Input Source",
3144 .info = ad198x_mux_enum_info,
3145 .get = ad198x_mux_enum_get,
3146 .put = ad198x_mux_enum_put,
3148 /* SPDIF controls */
3149 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
3151 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3152 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
3153 /* identical with ad1983 */
3154 .info = ad1983_spdif_route_info,
3155 .get = ad1983_spdif_route_get,
3156 .put = ad1983_spdif_route_put,
3161 static struct snd_kcontrol_new ad1882_3stack_mixers[] = {
3162 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3163 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x17, 1, 0x0, HDA_OUTPUT),
3164 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x17, 2, 0x0, HDA_OUTPUT),
3166 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3167 .name = "Channel Mode",
3168 .info = ad198x_ch_mode_info,
3169 .get = ad198x_ch_mode_get,
3170 .put = ad198x_ch_mode_put,
3175 static struct snd_kcontrol_new ad1882_6stack_mixers[] = {
3176 HDA_CODEC_MUTE("Surround Playback Switch", 0x16, 0x0, HDA_OUTPUT),
3177 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x24, 1, 0x0, HDA_OUTPUT),
3178 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x24, 2, 0x0, HDA_OUTPUT),
3182 static struct hda_verb ad1882_ch2_init[] = {
3183 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3184 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3185 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3186 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3187 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3188 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3192 static struct hda_verb ad1882_ch4_init[] = {
3193 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3194 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3195 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3196 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3197 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3198 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3202 static struct hda_verb ad1882_ch6_init[] = {
3203 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3204 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3205 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3206 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3207 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3208 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3212 static struct hda_channel_mode ad1882_modes[3] = {
3213 { 2, ad1882_ch2_init },
3214 { 4, ad1882_ch4_init },
3215 { 6, ad1882_ch6_init },
3219 * initialization verbs
3221 static struct hda_verb ad1882_init_verbs[] = {
3222 /* DACs; mute as default */
3223 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3224 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3225 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3226 /* Port-A (HP) mixer */
3227 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3228 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3230 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3231 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3232 /* HP selector - select DAC2 */
3233 {0x37, AC_VERB_SET_CONNECT_SEL, 0x1},
3234 /* Port-D (Line-out) mixer */
3235 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3236 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3238 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3239 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3240 /* Mono-out mixer */
3241 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3242 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3244 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3245 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3246 /* Port-B (front mic) pin */
3247 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3248 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3249 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* boost */
3250 /* Port-C (line-in) pin */
3251 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3252 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3253 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* boost */
3254 /* Port-C mixer - mute as input */
3255 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3256 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3257 /* Port-E (mic-in) pin */
3258 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3259 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3260 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* boost */
3261 /* Port-E mixer - mute as input */
3262 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3263 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3264 /* Port-F (surround) */
3265 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3266 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3268 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3269 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3270 /* Analog mixer; mute as default */
3271 /* list: 0x39, 0x3a, 0x11, 0x12, 0x3c, 0x3b, 0x18, 0x1a */
3272 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3273 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3274 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3275 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3276 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3277 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
3278 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3279 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
3280 /* Analog Mix output amp */
3281 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
3282 /* SPDIF output selector */
3283 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
3284 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */
3285 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
3289 #ifdef CONFIG_SND_HDA_POWER_SAVE
3290 static struct hda_amp_list ad1882_loopbacks[] = {
3291 { 0x20, HDA_INPUT, 0 }, /* Front Mic */
3292 { 0x20, HDA_INPUT, 1 }, /* Mic */
3293 { 0x20, HDA_INPUT, 4 }, /* Line */
3294 { 0x20, HDA_INPUT, 6 }, /* CD */
3306 static const char *ad1882_models[AD1986A_MODELS] = {
3307 [AD1882_3STACK] = "3stack",
3308 [AD1882_6STACK] = "6stack",
3312 static int patch_ad1882(struct hda_codec *codec)
3314 struct ad198x_spec *spec;
3317 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3321 mutex_init(&spec->amp_mutex);
3324 spec->multiout.max_channels = 6;
3325 spec->multiout.num_dacs = 3;
3326 spec->multiout.dac_nids = ad1882_dac_nids;
3327 spec->multiout.dig_out_nid = AD1882_SPDIF_OUT;
3328 spec->num_adc_nids = ARRAY_SIZE(ad1882_adc_nids);
3329 spec->adc_nids = ad1882_adc_nids;
3330 spec->capsrc_nids = ad1882_capsrc_nids;
3331 spec->input_mux = &ad1882_capture_source;
3332 spec->num_mixers = 1;
3333 spec->mixers[0] = ad1882_base_mixers;
3334 spec->num_init_verbs = 1;
3335 spec->init_verbs[0] = ad1882_init_verbs;
3336 spec->spdif_route = 0;
3337 #ifdef CONFIG_SND_HDA_POWER_SAVE
3338 spec->loopback.amplist = ad1882_loopbacks;
3341 codec->patch_ops = ad198x_patch_ops;
3343 /* override some parameters */
3344 board_config = snd_hda_check_board_config(codec, AD1882_MODELS,
3345 ad1882_models, NULL);
3346 switch (board_config) {
3349 spec->num_mixers = 2;
3350 spec->mixers[1] = ad1882_3stack_mixers;
3351 spec->channel_mode = ad1882_modes;
3352 spec->num_channel_mode = ARRAY_SIZE(ad1882_modes);
3353 spec->need_dac_fix = 1;
3354 spec->multiout.max_channels = 2;
3355 spec->multiout.num_dacs = 1;
3358 spec->num_mixers = 2;
3359 spec->mixers[1] = ad1882_6stack_mixers;
3369 struct hda_codec_preset snd_hda_preset_analog[] = {
3370 { .id = 0x11d41882, .name = "AD1882", .patch = patch_ad1882 },
3371 { .id = 0x11d41884, .name = "AD1884", .patch = patch_ad1884 },
3372 { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 },
3373 { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 },
3374 { .id = 0x11d41984, .name = "AD1984", .patch = patch_ad1984 },
3375 { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a },
3376 { .id = 0x11d41988, .name = "AD1988", .patch = patch_ad1988 },
3377 { .id = 0x11d4198b, .name = "AD1988B", .patch = patch_ad1988 },