2 * HD audio interface patch for AD1882, AD1884, AD1981HD, AD1983, AD1984,
5 * Copyright (c) 2005-2007 Takashi Iwai <tiwai@suse.de>
7 * This driver is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This driver is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <linux/init.h>
23 #include <linux/delay.h>
24 #include <linux/slab.h>
25 #include <linux/pci.h>
26 #include <linux/module.h>
28 #include <sound/core.h>
29 #include "hda_codec.h"
30 #include "hda_local.h"
31 #include "hda_auto_parser.h"
36 const struct snd_kcontrol_new
*mixers
[6];
38 unsigned int beep_amp
; /* beep amp value, set via set_beep_amp() */
39 const struct hda_verb
*init_verbs
[6]; /* initialization verbs
40 * don't forget NULL termination!
42 unsigned int num_init_verbs
;
45 struct hda_multi_out multiout
; /* playback set-up
46 * max_channels, dacs must be set
47 * dig_out_nid and hp_nid are optional
49 unsigned int cur_eapd
;
50 unsigned int need_dac_fix
;
52 const hda_nid_t
*alt_dac_nid
;
53 const struct hda_pcm_stream
*stream_analog_alt_playback
;
55 int num_active_streams
;
58 unsigned int num_adc_nids
;
59 const hda_nid_t
*adc_nids
;
60 hda_nid_t dig_in_nid
; /* digital-in NID; optional */
63 const struct hda_input_mux
*input_mux
;
64 const hda_nid_t
*capsrc_nids
;
65 unsigned int cur_mux
[3];
68 const struct hda_channel_mode
*channel_mode
;
72 struct hda_pcm pcm_rec
[3]; /* used in alc_build_pcms() */
74 unsigned int spdif_route
;
76 /* dynamic controls, init_verbs and input_mux */
77 struct auto_pin_cfg autocfg
;
78 struct snd_array kctls
;
79 struct hda_input_mux private_imux
;
80 hda_nid_t private_dac_nids
[AUTO_CFG_MAX_OUTS
];
82 unsigned int jack_present
: 1;
83 unsigned int inv_jack_detect
: 1;/* inverted jack-detection */
84 unsigned int inv_eapd
: 1; /* inverted EAPD implementation */
85 unsigned int analog_beep
: 1; /* analog beep input present */
86 unsigned int avoid_init_slave_vol
:1;
89 struct hda_loopback_check loopback
;
91 /* for virtual master */
92 hda_nid_t vmaster_nid
;
93 const char * const *slave_vols
;
94 const char * const *slave_sws
;
98 * input MUX handling (common part)
100 static int ad198x_mux_enum_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
102 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
103 struct ad198x_spec
*spec
= codec
->spec
;
105 return snd_hda_input_mux_info(spec
->input_mux
, uinfo
);
108 static int ad198x_mux_enum_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
110 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
111 struct ad198x_spec
*spec
= codec
->spec
;
112 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
114 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
118 static int ad198x_mux_enum_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
120 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
121 struct ad198x_spec
*spec
= codec
->spec
;
122 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
124 return snd_hda_input_mux_put(codec
, spec
->input_mux
, ucontrol
,
125 spec
->capsrc_nids
[adc_idx
],
126 &spec
->cur_mux
[adc_idx
]);
130 * initialization (common callbacks)
132 static int ad198x_init(struct hda_codec
*codec
)
134 struct ad198x_spec
*spec
= codec
->spec
;
137 for (i
= 0; i
< spec
->num_init_verbs
; i
++)
138 snd_hda_sequence_write(codec
, spec
->init_verbs
[i
]);
142 static const char * const ad_slave_pfxs
[] = {
143 "Front", "Surround", "Center", "LFE", "Side",
144 "Headphone", "Mono", "Speaker", "IEC958",
148 static const char * const ad1988_6stack_fp_slave_pfxs
[] = {
149 "Front", "Surround", "Center", "LFE", "Side", "IEC958",
153 static void ad198x_free_kctls(struct hda_codec
*codec
);
155 #ifdef CONFIG_SND_HDA_INPUT_BEEP
156 /* additional beep mixers; the actual parameters are overwritten at build */
157 static const struct snd_kcontrol_new ad_beep_mixer
[] = {
158 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_OUTPUT
),
159 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_OUTPUT
),
163 static const struct snd_kcontrol_new ad_beep2_mixer
[] = {
164 HDA_CODEC_VOLUME("Digital Beep Playback Volume", 0, 0, HDA_OUTPUT
),
165 HDA_CODEC_MUTE_BEEP("Digital Beep Playback Switch", 0, 0, HDA_OUTPUT
),
169 #define set_beep_amp(spec, nid, idx, dir) \
170 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir)) /* mono */
172 #define set_beep_amp(spec, nid, idx, dir) /* NOP */
175 static int ad198x_build_controls(struct hda_codec
*codec
)
177 struct ad198x_spec
*spec
= codec
->spec
;
178 struct snd_kcontrol
*kctl
;
182 for (i
= 0; i
< spec
->num_mixers
; i
++) {
183 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
187 if (spec
->multiout
.dig_out_nid
) {
188 err
= snd_hda_create_spdif_out_ctls(codec
,
189 spec
->multiout
.dig_out_nid
,
190 spec
->multiout
.dig_out_nid
);
193 err
= snd_hda_create_spdif_share_sw(codec
,
197 spec
->multiout
.share_spdif
= 1;
199 if (spec
->dig_in_nid
) {
200 err
= snd_hda_create_spdif_in_ctls(codec
, spec
->dig_in_nid
);
205 /* create beep controls if needed */
206 #ifdef CONFIG_SND_HDA_INPUT_BEEP
207 if (spec
->beep_amp
) {
208 const struct snd_kcontrol_new
*knew
;
209 knew
= spec
->analog_beep
? ad_beep2_mixer
: ad_beep_mixer
;
210 for ( ; knew
->name
; knew
++) {
211 struct snd_kcontrol
*kctl
;
212 kctl
= snd_ctl_new1(knew
, codec
);
215 kctl
->private_value
= spec
->beep_amp
;
216 err
= snd_hda_ctl_add(codec
, 0, kctl
);
223 /* if we have no master control, let's create it */
224 if (!snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
225 unsigned int vmaster_tlv
[4];
226 snd_hda_set_vmaster_tlv(codec
, spec
->vmaster_nid
,
227 HDA_OUTPUT
, vmaster_tlv
);
228 err
= __snd_hda_add_vmaster(codec
, "Master Playback Volume",
231 spec
->slave_vols
: ad_slave_pfxs
),
233 !spec
->avoid_init_slave_vol
, NULL
);
237 if (!snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
238 err
= snd_hda_add_vmaster(codec
, "Master Playback Switch",
241 spec
->slave_sws
: ad_slave_pfxs
),
247 ad198x_free_kctls(codec
); /* no longer needed */
249 /* assign Capture Source enums to NID */
250 kctl
= snd_hda_find_mixer_ctl(codec
, "Capture Source");
252 kctl
= snd_hda_find_mixer_ctl(codec
, "Input Source");
253 for (i
= 0; kctl
&& i
< kctl
->count
; i
++) {
254 err
= snd_hda_add_nid(codec
, kctl
, i
, spec
->capsrc_nids
[i
]);
259 /* assign IEC958 enums to NID */
260 kctl
= snd_hda_find_mixer_ctl(codec
,
261 SNDRV_CTL_NAME_IEC958("",PLAYBACK
,NONE
) "Source");
263 err
= snd_hda_add_nid(codec
, kctl
, 0,
264 spec
->multiout
.dig_out_nid
);
273 static int ad198x_check_power_status(struct hda_codec
*codec
, hda_nid_t nid
)
275 struct ad198x_spec
*spec
= codec
->spec
;
276 return snd_hda_check_amp_list_power(codec
, &spec
->loopback
, nid
);
280 static void activate_ctl(struct hda_codec
*codec
, const char *name
, int active
)
282 struct snd_kcontrol
*ctl
= snd_hda_find_mixer_ctl(codec
, name
);
284 ctl
->vd
[0].access
&= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE
;
285 ctl
->vd
[0].access
|= active
? 0 :
286 SNDRV_CTL_ELEM_ACCESS_INACTIVE
;
287 ctl
->vd
[0].access
&= ~SNDRV_CTL_ELEM_ACCESS_WRITE
;
288 ctl
->vd
[0].access
|= active
?
289 SNDRV_CTL_ELEM_ACCESS_WRITE
: 0;
290 snd_ctl_notify(codec
->bus
->card
,
291 SNDRV_CTL_EVENT_MASK_INFO
, &ctl
->id
);
295 static void set_stream_active(struct hda_codec
*codec
, bool active
)
297 struct ad198x_spec
*spec
= codec
->spec
;
299 spec
->num_active_streams
++;
301 spec
->num_active_streams
--;
302 activate_ctl(codec
, "Independent HP", spec
->num_active_streams
== 0);
305 static int ad1988_independent_hp_info(struct snd_kcontrol
*kcontrol
,
306 struct snd_ctl_elem_info
*uinfo
)
308 static const char * const texts
[] = { "OFF", "ON", NULL
};
310 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
312 uinfo
->value
.enumerated
.items
= 2;
313 index
= uinfo
->value
.enumerated
.item
;
316 strcpy(uinfo
->value
.enumerated
.name
, texts
[index
]);
320 static int ad1988_independent_hp_get(struct snd_kcontrol
*kcontrol
,
321 struct snd_ctl_elem_value
*ucontrol
)
323 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
324 struct ad198x_spec
*spec
= codec
->spec
;
325 ucontrol
->value
.enumerated
.item
[0] = spec
->independent_hp
;
329 static int ad1988_independent_hp_put(struct snd_kcontrol
*kcontrol
,
330 struct snd_ctl_elem_value
*ucontrol
)
332 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
333 struct ad198x_spec
*spec
= codec
->spec
;
334 unsigned int select
= ucontrol
->value
.enumerated
.item
[0];
335 if (spec
->independent_hp
!= select
) {
336 spec
->independent_hp
= select
;
337 if (spec
->independent_hp
)
338 spec
->multiout
.hp_nid
= 0;
340 spec
->multiout
.hp_nid
= spec
->alt_dac_nid
[0];
347 * Analog playback callbacks
349 static int ad198x_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
350 struct hda_codec
*codec
,
351 struct snd_pcm_substream
*substream
)
353 struct ad198x_spec
*spec
= codec
->spec
;
355 set_stream_active(codec
, true);
356 err
= snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
359 set_stream_active(codec
, false);
365 static int ad198x_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
366 struct hda_codec
*codec
,
367 unsigned int stream_tag
,
369 struct snd_pcm_substream
*substream
)
371 struct ad198x_spec
*spec
= codec
->spec
;
372 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
, stream_tag
,
376 static int ad198x_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
377 struct hda_codec
*codec
,
378 struct snd_pcm_substream
*substream
)
380 struct ad198x_spec
*spec
= codec
->spec
;
381 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
384 static int ad198x_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
385 struct hda_codec
*codec
,
386 struct snd_pcm_substream
*substream
)
388 set_stream_active(codec
, false);
392 static int ad1988_alt_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
393 struct hda_codec
*codec
,
394 struct snd_pcm_substream
*substream
)
396 struct ad198x_spec
*spec
= codec
->spec
;
397 if (!spec
->independent_hp
)
399 set_stream_active(codec
, true);
403 static int ad1988_alt_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
404 struct hda_codec
*codec
,
405 struct snd_pcm_substream
*substream
)
407 set_stream_active(codec
, false);
411 static const struct hda_pcm_stream ad198x_pcm_analog_alt_playback
= {
416 .open
= ad1988_alt_playback_pcm_open
,
417 .close
= ad1988_alt_playback_pcm_close
424 static int ad198x_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
425 struct hda_codec
*codec
,
426 struct snd_pcm_substream
*substream
)
428 struct ad198x_spec
*spec
= codec
->spec
;
429 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
432 static int ad198x_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
433 struct hda_codec
*codec
,
434 struct snd_pcm_substream
*substream
)
436 struct ad198x_spec
*spec
= codec
->spec
;
437 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
440 static int ad198x_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
441 struct hda_codec
*codec
,
442 unsigned int stream_tag
,
444 struct snd_pcm_substream
*substream
)
446 struct ad198x_spec
*spec
= codec
->spec
;
447 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
, stream_tag
,
451 static int ad198x_dig_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
452 struct hda_codec
*codec
,
453 struct snd_pcm_substream
*substream
)
455 struct ad198x_spec
*spec
= codec
->spec
;
456 return snd_hda_multi_out_dig_cleanup(codec
, &spec
->multiout
);
462 static int ad198x_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
463 struct hda_codec
*codec
,
464 unsigned int stream_tag
,
466 struct snd_pcm_substream
*substream
)
468 struct ad198x_spec
*spec
= codec
->spec
;
469 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
],
470 stream_tag
, 0, format
);
474 static int ad198x_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
475 struct hda_codec
*codec
,
476 struct snd_pcm_substream
*substream
)
478 struct ad198x_spec
*spec
= codec
->spec
;
479 snd_hda_codec_cleanup_stream(codec
, spec
->adc_nids
[substream
->number
]);
485 static const struct hda_pcm_stream ad198x_pcm_analog_playback
= {
488 .channels_max
= 6, /* changed later */
489 .nid
= 0, /* fill later */
491 .open
= ad198x_playback_pcm_open
,
492 .prepare
= ad198x_playback_pcm_prepare
,
493 .cleanup
= ad198x_playback_pcm_cleanup
,
494 .close
= ad198x_playback_pcm_close
498 static const struct hda_pcm_stream ad198x_pcm_analog_capture
= {
502 .nid
= 0, /* fill later */
504 .prepare
= ad198x_capture_pcm_prepare
,
505 .cleanup
= ad198x_capture_pcm_cleanup
509 static const struct hda_pcm_stream ad198x_pcm_digital_playback
= {
513 .nid
= 0, /* fill later */
515 .open
= ad198x_dig_playback_pcm_open
,
516 .close
= ad198x_dig_playback_pcm_close
,
517 .prepare
= ad198x_dig_playback_pcm_prepare
,
518 .cleanup
= ad198x_dig_playback_pcm_cleanup
522 static const struct hda_pcm_stream ad198x_pcm_digital_capture
= {
526 /* NID is set in alc_build_pcms */
529 static int ad198x_build_pcms(struct hda_codec
*codec
)
531 struct ad198x_spec
*spec
= codec
->spec
;
532 struct hda_pcm
*info
= spec
->pcm_rec
;
535 codec
->pcm_info
= info
;
537 info
->name
= "AD198x Analog";
538 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = ad198x_pcm_analog_playback
;
539 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
= spec
->multiout
.max_channels
;
540 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dac_nids
[0];
541 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = ad198x_pcm_analog_capture
;
542 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
= spec
->num_adc_nids
;
543 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
545 if (spec
->multiout
.dig_out_nid
) {
548 info
->name
= "AD198x Digital";
549 info
->pcm_type
= HDA_PCM_TYPE_SPDIF
;
550 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = ad198x_pcm_digital_playback
;
551 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dig_out_nid
;
552 if (spec
->dig_in_nid
) {
553 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = ad198x_pcm_digital_capture
;
554 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->dig_in_nid
;
558 if (spec
->alt_dac_nid
&& spec
->stream_analog_alt_playback
) {
560 info
= spec
->pcm_rec
+ 2;
561 info
->name
= "AD198x Headphone";
562 info
->pcm_type
= HDA_PCM_TYPE_AUDIO
;
563 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] =
564 *spec
->stream_analog_alt_playback
;
565 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
566 spec
->alt_dac_nid
[0];
572 static void ad198x_free_kctls(struct hda_codec
*codec
)
574 struct ad198x_spec
*spec
= codec
->spec
;
576 if (spec
->kctls
.list
) {
577 struct snd_kcontrol_new
*kctl
= spec
->kctls
.list
;
579 for (i
= 0; i
< spec
->kctls
.used
; i
++)
582 snd_array_free(&spec
->kctls
);
585 static void ad198x_power_eapd_write(struct hda_codec
*codec
, hda_nid_t front
,
588 struct ad198x_spec
*spec
= codec
->spec
;
589 if (snd_hda_query_pin_caps(codec
, front
) & AC_PINCAP_EAPD
)
590 snd_hda_codec_write(codec
, front
, 0, AC_VERB_SET_EAPD_BTLENABLE
,
591 !spec
->inv_eapd
? 0x00 : 0x02);
592 if (snd_hda_query_pin_caps(codec
, hp
) & AC_PINCAP_EAPD
)
593 snd_hda_codec_write(codec
, hp
, 0, AC_VERB_SET_EAPD_BTLENABLE
,
594 !spec
->inv_eapd
? 0x00 : 0x02);
597 static void ad198x_power_eapd(struct hda_codec
*codec
)
599 /* We currently only handle front, HP */
600 switch (codec
->vendor_id
) {
613 ad198x_power_eapd_write(codec
, 0x12, 0x11);
617 ad198x_power_eapd_write(codec
, 0x05, 0x06);
620 ad198x_power_eapd_write(codec
, 0x1b, 0x1a);
625 static void ad198x_shutup(struct hda_codec
*codec
)
627 snd_hda_shutup_pins(codec
);
628 ad198x_power_eapd(codec
);
631 static void ad198x_free(struct hda_codec
*codec
)
633 struct ad198x_spec
*spec
= codec
->spec
;
638 ad198x_shutup(codec
);
639 ad198x_free_kctls(codec
);
641 snd_hda_detach_beep_device(codec
);
645 static int ad198x_suspend(struct hda_codec
*codec
)
647 ad198x_shutup(codec
);
652 static const struct hda_codec_ops ad198x_patch_ops
= {
653 .build_controls
= ad198x_build_controls
,
654 .build_pcms
= ad198x_build_pcms
,
658 .check_power_status
= ad198x_check_power_status
,
659 .suspend
= ad198x_suspend
,
661 .reboot_notify
= ad198x_shutup
,
667 * the private value = nid
669 #define ad198x_eapd_info snd_ctl_boolean_mono_info
671 static int ad198x_eapd_get(struct snd_kcontrol
*kcontrol
,
672 struct snd_ctl_elem_value
*ucontrol
)
674 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
675 struct ad198x_spec
*spec
= codec
->spec
;
677 ucontrol
->value
.integer
.value
[0] = ! spec
->cur_eapd
;
679 ucontrol
->value
.integer
.value
[0] = spec
->cur_eapd
;
683 static int ad198x_eapd_put(struct snd_kcontrol
*kcontrol
,
684 struct snd_ctl_elem_value
*ucontrol
)
686 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
687 struct ad198x_spec
*spec
= codec
->spec
;
688 hda_nid_t nid
= kcontrol
->private_value
& 0xff;
690 eapd
= !!ucontrol
->value
.integer
.value
[0];
693 if (eapd
== spec
->cur_eapd
)
695 spec
->cur_eapd
= eapd
;
696 snd_hda_codec_write_cache(codec
, nid
,
697 0, AC_VERB_SET_EAPD_BTLENABLE
,
702 static int ad198x_ch_mode_info(struct snd_kcontrol
*kcontrol
,
703 struct snd_ctl_elem_info
*uinfo
);
704 static int ad198x_ch_mode_get(struct snd_kcontrol
*kcontrol
,
705 struct snd_ctl_elem_value
*ucontrol
);
706 static int ad198x_ch_mode_put(struct snd_kcontrol
*kcontrol
,
707 struct snd_ctl_elem_value
*ucontrol
);
714 #define AD1986A_SPDIF_OUT 0x02
715 #define AD1986A_FRONT_DAC 0x03
716 #define AD1986A_SURR_DAC 0x04
717 #define AD1986A_CLFE_DAC 0x05
718 #define AD1986A_ADC 0x06
720 static const hda_nid_t ad1986a_dac_nids
[3] = {
721 AD1986A_FRONT_DAC
, AD1986A_SURR_DAC
, AD1986A_CLFE_DAC
723 static const hda_nid_t ad1986a_adc_nids
[1] = { AD1986A_ADC
};
724 static const hda_nid_t ad1986a_capsrc_nids
[1] = { 0x12 };
726 static const struct hda_input_mux ad1986a_capture_source
= {
740 static const struct hda_bind_ctls ad1986a_bind_pcm_vol
= {
741 .ops
= &snd_hda_bind_vol
,
743 HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC
, 3, 0, HDA_OUTPUT
),
744 HDA_COMPOSE_AMP_VAL(AD1986A_SURR_DAC
, 3, 0, HDA_OUTPUT
),
745 HDA_COMPOSE_AMP_VAL(AD1986A_CLFE_DAC
, 3, 0, HDA_OUTPUT
),
750 static const struct hda_bind_ctls ad1986a_bind_pcm_sw
= {
751 .ops
= &snd_hda_bind_sw
,
753 HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC
, 3, 0, HDA_OUTPUT
),
754 HDA_COMPOSE_AMP_VAL(AD1986A_SURR_DAC
, 3, 0, HDA_OUTPUT
),
755 HDA_COMPOSE_AMP_VAL(AD1986A_CLFE_DAC
, 3, 0, HDA_OUTPUT
),
763 static const struct snd_kcontrol_new ad1986a_mixers
[] = {
765 * bind volumes/mutes of 3 DACs as a single PCM control for simplicity
767 HDA_BIND_VOL("PCM Playback Volume", &ad1986a_bind_pcm_vol
),
768 HDA_BIND_SW("PCM Playback Switch", &ad1986a_bind_pcm_sw
),
769 HDA_CODEC_VOLUME("Front Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
770 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT
),
771 HDA_CODEC_VOLUME("Surround Playback Volume", 0x1c, 0x0, HDA_OUTPUT
),
772 HDA_CODEC_MUTE("Surround Playback Switch", 0x1c, 0x0, HDA_OUTPUT
),
773 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x1d, 1, 0x0, HDA_OUTPUT
),
774 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x1d, 2, 0x0, HDA_OUTPUT
),
775 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x1d, 1, 0x0, HDA_OUTPUT
),
776 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x1d, 2, 0x0, HDA_OUTPUT
),
777 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT
),
778 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT
),
779 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT
),
780 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT
),
781 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT
),
782 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT
),
783 HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT
),
784 HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT
),
785 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
786 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
787 HDA_CODEC_VOLUME("Mic Boost Volume", 0x0f, 0x0, HDA_OUTPUT
),
788 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT
),
789 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT
),
790 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT
),
791 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT
),
793 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
794 .name
= "Capture Source",
795 .info
= ad198x_mux_enum_info
,
796 .get
= ad198x_mux_enum_get
,
797 .put
= ad198x_mux_enum_put
,
799 HDA_CODEC_MUTE("Stereo Downmix Switch", 0x09, 0x0, HDA_OUTPUT
),
803 /* additional mixers for 3stack mode */
804 static const struct snd_kcontrol_new ad1986a_3st_mixers
[] = {
806 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
807 .name
= "Channel Mode",
808 .info
= ad198x_ch_mode_info
,
809 .get
= ad198x_ch_mode_get
,
810 .put
= ad198x_ch_mode_put
,
815 /* laptop model - 2ch only */
816 static const hda_nid_t ad1986a_laptop_dac_nids
[1] = { AD1986A_FRONT_DAC
};
818 /* master controls both pins 0x1a and 0x1b */
819 static const struct hda_bind_ctls ad1986a_laptop_master_vol
= {
820 .ops
= &snd_hda_bind_vol
,
822 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT
),
823 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT
),
828 static const struct hda_bind_ctls ad1986a_laptop_master_sw
= {
829 .ops
= &snd_hda_bind_sw
,
831 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT
),
832 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT
),
837 static const struct snd_kcontrol_new ad1986a_laptop_mixers
[] = {
838 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT
),
839 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT
),
840 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol
),
841 HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw
),
842 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT
),
843 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT
),
844 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT
),
845 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT
),
846 HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT
),
847 HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT
),
848 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
849 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
850 HDA_CODEC_VOLUME("Mic Boost Volume", 0x0f, 0x0, HDA_OUTPUT
),
852 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
853 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), */
854 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT
),
855 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT
),
857 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
858 .name
= "Capture Source",
859 .info
= ad198x_mux_enum_info
,
860 .get
= ad198x_mux_enum_get
,
861 .put
= ad198x_mux_enum_put
,
866 /* laptop-eapd model - 2ch only */
868 static const struct hda_input_mux ad1986a_laptop_eapd_capture_source
= {
872 { "Internal Mic", 0x4 },
877 static const struct hda_input_mux ad1986a_automic_capture_source
= {
885 static const struct snd_kcontrol_new ad1986a_laptop_master_mixers
[] = {
886 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol
),
887 HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw
),
891 static const struct snd_kcontrol_new ad1986a_laptop_eapd_mixers
[] = {
892 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT
),
893 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT
),
894 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
895 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
896 HDA_CODEC_VOLUME("Mic Boost Volume", 0x0f, 0x0, HDA_OUTPUT
),
897 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT
),
898 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT
),
900 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
901 .name
= "Capture Source",
902 .info
= ad198x_mux_enum_info
,
903 .get
= ad198x_mux_enum_get
,
904 .put
= ad198x_mux_enum_put
,
907 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
908 .name
= "External Amplifier",
909 .subdevice
= HDA_SUBDEV_NID_FLAG
| 0x1b,
910 .info
= ad198x_eapd_info
,
911 .get
= ad198x_eapd_get
,
912 .put
= ad198x_eapd_put
,
913 .private_value
= 0x1b, /* port-D */
918 static const struct snd_kcontrol_new ad1986a_laptop_intmic_mixers
[] = {
919 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0, HDA_OUTPUT
),
920 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0, HDA_OUTPUT
),
924 /* re-connect the mic boost input according to the jack sensing */
925 static void ad1986a_automic(struct hda_codec
*codec
)
927 unsigned int present
;
928 present
= snd_hda_jack_detect(codec
, 0x1f);
929 /* 0 = 0x1f, 2 = 0x1d, 4 = mixed */
930 snd_hda_codec_write(codec
, 0x0f, 0, AC_VERB_SET_CONNECT_SEL
,
934 #define AD1986A_MIC_EVENT 0x36
936 static void ad1986a_automic_unsol_event(struct hda_codec
*codec
,
939 if ((res
>> 26) != AD1986A_MIC_EVENT
)
941 ad1986a_automic(codec
);
944 static int ad1986a_automic_init(struct hda_codec
*codec
)
947 ad1986a_automic(codec
);
951 /* laptop-automute - 2ch only */
953 static void ad1986a_update_hp(struct hda_codec
*codec
)
955 struct ad198x_spec
*spec
= codec
->spec
;
958 if (spec
->jack_present
)
959 mute
= HDA_AMP_MUTE
; /* mute internal speaker */
961 /* unmute internal speaker if necessary */
962 mute
= snd_hda_codec_amp_read(codec
, 0x1a, 0, HDA_OUTPUT
, 0);
963 snd_hda_codec_amp_stereo(codec
, 0x1b, HDA_OUTPUT
, 0,
967 static void ad1986a_hp_automute(struct hda_codec
*codec
)
969 struct ad198x_spec
*spec
= codec
->spec
;
971 spec
->jack_present
= snd_hda_jack_detect(codec
, 0x1a);
972 if (spec
->inv_jack_detect
)
973 spec
->jack_present
= !spec
->jack_present
;
974 ad1986a_update_hp(codec
);
977 #define AD1986A_HP_EVENT 0x37
979 static void ad1986a_hp_unsol_event(struct hda_codec
*codec
, unsigned int res
)
981 if ((res
>> 26) != AD1986A_HP_EVENT
)
983 ad1986a_hp_automute(codec
);
986 static int ad1986a_hp_init(struct hda_codec
*codec
)
989 ad1986a_hp_automute(codec
);
993 /* bind hp and internal speaker mute (with plug check) */
994 static int ad1986a_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
995 struct snd_ctl_elem_value
*ucontrol
)
997 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
998 long *valp
= ucontrol
->value
.integer
.value
;
1001 change
= snd_hda_codec_amp_update(codec
, 0x1a, 0, HDA_OUTPUT
, 0,
1003 valp
[0] ? 0 : HDA_AMP_MUTE
);
1004 change
|= snd_hda_codec_amp_update(codec
, 0x1a, 1, HDA_OUTPUT
, 0,
1006 valp
[1] ? 0 : HDA_AMP_MUTE
);
1008 ad1986a_update_hp(codec
);
1012 static const struct snd_kcontrol_new ad1986a_automute_master_mixers
[] = {
1013 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol
),
1015 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1016 .name
= "Master Playback Switch",
1017 .subdevice
= HDA_SUBDEV_AMP_FLAG
,
1018 .info
= snd_hda_mixer_amp_switch_info
,
1019 .get
= snd_hda_mixer_amp_switch_get
,
1020 .put
= ad1986a_hp_master_sw_put
,
1021 .private_value
= HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT
),
1028 * initialization verbs
1030 static const struct hda_verb ad1986a_init_verbs
[] = {
1031 /* Front, Surround, CLFE DAC; mute as default */
1032 {0x03, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1033 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1034 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1036 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1037 /* HP, Line-Out, Surround, CLFE selectors */
1038 {0x0a, AC_VERB_SET_CONNECT_SEL
, 0x0},
1039 {0x0b, AC_VERB_SET_CONNECT_SEL
, 0x0},
1040 {0x0c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1041 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x0},
1043 {0x0e, AC_VERB_SET_CONNECT_SEL
, 0x0},
1044 /* Mic selector: Mic 1/2 pin */
1045 {0x0f, AC_VERB_SET_CONNECT_SEL
, 0x0},
1046 /* Line-in selector: Line-in */
1047 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x0},
1049 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x0},
1050 /* Record selector: mic */
1051 {0x12, AC_VERB_SET_CONNECT_SEL
, 0x0},
1052 /* Mic, Phone, CD, Aux, Line-In amp; mute as default */
1053 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1054 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1055 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1056 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1057 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1059 {0x18, AC_VERB_SET_CONNECT_SEL
, 0x0},
1060 /* HP, Line-Out, Surround, CLFE, Mono pins; mute as default */
1061 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1062 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1063 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1064 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1065 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1067 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0xc0 },
1068 /* Front, Surround, CLFE Pins */
1069 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
1070 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
1071 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
1073 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
1075 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24 },
1076 /* Line, Aux, CD, Beep-In Pin */
1077 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
1078 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
1079 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
1080 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
1081 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
1085 static const struct hda_verb ad1986a_ch2_init
[] = {
1086 /* Surround out -> Line In */
1087 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1088 /* Line-in selectors */
1089 { 0x10, AC_VERB_SET_CONNECT_SEL
, 0x1 },
1090 /* CLFE -> Mic in */
1091 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1092 /* Mic selector, mix C/LFE (backmic) and Mic (frontmic) */
1093 { 0x0f, AC_VERB_SET_CONNECT_SEL
, 0x4 },
1097 static const struct hda_verb ad1986a_ch4_init
[] = {
1098 /* Surround out -> Surround */
1099 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1100 { 0x10, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1101 /* CLFE -> Mic in */
1102 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1103 { 0x0f, AC_VERB_SET_CONNECT_SEL
, 0x4 },
1107 static const struct hda_verb ad1986a_ch6_init
[] = {
1108 /* Surround out -> Surround out */
1109 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1110 { 0x10, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1112 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1113 { 0x0f, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1117 static const struct hda_channel_mode ad1986a_modes
[3] = {
1118 { 2, ad1986a_ch2_init
},
1119 { 4, ad1986a_ch4_init
},
1120 { 6, ad1986a_ch6_init
},
1123 /* eapd initialization */
1124 static const struct hda_verb ad1986a_eapd_init_verbs
[] = {
1125 {0x1b, AC_VERB_SET_EAPD_BTLENABLE
, 0x00 },
1129 static const struct hda_verb ad1986a_automic_verbs
[] = {
1130 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1131 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1132 /*{0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},*/
1133 {0x0f, AC_VERB_SET_CONNECT_SEL
, 0x0},
1134 {0x1f, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1986A_MIC_EVENT
},
1138 /* Ultra initialization */
1139 static const struct hda_verb ad1986a_ultra_init
[] = {
1140 /* eapd initialization */
1141 { 0x1b, AC_VERB_SET_EAPD_BTLENABLE
, 0x00 },
1142 /* CLFE -> Mic in */
1143 { 0x0f, AC_VERB_SET_CONNECT_SEL
, 0x2 },
1144 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24 },
1145 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080 },
1149 /* pin sensing on HP jack */
1150 static const struct hda_verb ad1986a_hp_init_verbs
[] = {
1151 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1986A_HP_EVENT
},
1155 static void ad1986a_samsung_p50_unsol_event(struct hda_codec
*codec
,
1158 switch (res
>> 26) {
1159 case AD1986A_HP_EVENT
:
1160 ad1986a_hp_automute(codec
);
1162 case AD1986A_MIC_EVENT
:
1163 ad1986a_automic(codec
);
1168 static int ad1986a_samsung_p50_init(struct hda_codec
*codec
)
1171 ad1986a_hp_automute(codec
);
1172 ad1986a_automic(codec
);
1182 AD1986A_LAPTOP_EAPD
,
1183 AD1986A_LAPTOP_AUTOMUTE
,
1186 AD1986A_SAMSUNG_P50
,
1190 static const char * const ad1986a_models
[AD1986A_MODELS
] = {
1191 [AD1986A_6STACK
] = "6stack",
1192 [AD1986A_3STACK
] = "3stack",
1193 [AD1986A_LAPTOP
] = "laptop",
1194 [AD1986A_LAPTOP_EAPD
] = "laptop-eapd",
1195 [AD1986A_LAPTOP_AUTOMUTE
] = "laptop-automute",
1196 [AD1986A_ULTRA
] = "ultra",
1197 [AD1986A_SAMSUNG
] = "samsung",
1198 [AD1986A_SAMSUNG_P50
] = "samsung-p50",
1201 static const struct snd_pci_quirk ad1986a_cfg_tbl
[] = {
1202 SND_PCI_QUIRK(0x103c, 0x30af, "HP B2800", AD1986A_LAPTOP_EAPD
),
1203 SND_PCI_QUIRK(0x1043, 0x1153, "ASUS M9", AD1986A_LAPTOP_EAPD
),
1204 SND_PCI_QUIRK(0x1043, 0x11f7, "ASUS U5A", AD1986A_LAPTOP_EAPD
),
1205 SND_PCI_QUIRK(0x1043, 0x1213, "ASUS A6J", AD1986A_LAPTOP_EAPD
),
1206 SND_PCI_QUIRK(0x1043, 0x1263, "ASUS U5F", AD1986A_LAPTOP_EAPD
),
1207 SND_PCI_QUIRK(0x1043, 0x1297, "ASUS Z62F", AD1986A_LAPTOP_EAPD
),
1208 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS V1j", AD1986A_LAPTOP_EAPD
),
1209 SND_PCI_QUIRK(0x1043, 0x1302, "ASUS W3j", AD1986A_LAPTOP_EAPD
),
1210 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS VX1", AD1986A_LAPTOP
),
1211 SND_PCI_QUIRK(0x1043, 0x1447, "ASUS A8J", AD1986A_3STACK
),
1212 SND_PCI_QUIRK(0x1043, 0x817f, "ASUS P5", AD1986A_3STACK
),
1213 SND_PCI_QUIRK(0x1043, 0x818f, "ASUS P5", AD1986A_LAPTOP
),
1214 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS P5", AD1986A_3STACK
),
1215 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS M2N", AD1986A_3STACK
),
1216 SND_PCI_QUIRK(0x1043, 0x8234, "ASUS M2N", AD1986A_3STACK
),
1217 SND_PCI_QUIRK(0x10de, 0xcb84, "ASUS A8N-VM", AD1986A_3STACK
),
1218 SND_PCI_QUIRK(0x1179, 0xff40, "Toshiba Satellite L40-10Q", AD1986A_3STACK
),
1219 SND_PCI_QUIRK(0x144d, 0xb03c, "Samsung R55", AD1986A_3STACK
),
1220 SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP
),
1221 SND_PCI_QUIRK(0x144d, 0xc024, "Samsung P50", AD1986A_SAMSUNG_P50
),
1222 SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_ULTRA
),
1223 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc000, "Samsung", AD1986A_SAMSUNG
),
1224 SND_PCI_QUIRK(0x144d, 0xc504, "Samsung Q35", AD1986A_3STACK
),
1225 SND_PCI_QUIRK(0x17aa, 0x1011, "Lenovo M55", AD1986A_LAPTOP
),
1226 SND_PCI_QUIRK(0x17aa, 0x1017, "Lenovo A60", AD1986A_3STACK
),
1227 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo N100", AD1986A_LAPTOP_AUTOMUTE
),
1228 SND_PCI_QUIRK(0x17c0, 0x2017, "Samsung M50", AD1986A_LAPTOP
),
1233 static const struct hda_amp_list ad1986a_loopbacks
[] = {
1234 { 0x13, HDA_OUTPUT
, 0 }, /* Mic */
1235 { 0x14, HDA_OUTPUT
, 0 }, /* Phone */
1236 { 0x15, HDA_OUTPUT
, 0 }, /* CD */
1237 { 0x16, HDA_OUTPUT
, 0 }, /* Aux */
1238 { 0x17, HDA_OUTPUT
, 0 }, /* Line */
1243 static int is_jack_available(struct hda_codec
*codec
, hda_nid_t nid
)
1245 unsigned int conf
= snd_hda_codec_get_pincfg(codec
, nid
);
1246 return get_defcfg_connect(conf
) != AC_JACK_PORT_NONE
;
1249 static int patch_ad1986a(struct hda_codec
*codec
)
1251 struct ad198x_spec
*spec
;
1252 int err
, board_config
;
1254 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1260 err
= snd_hda_attach_beep_device(codec
, 0x19);
1265 set_beep_amp(spec
, 0x18, 0, HDA_OUTPUT
);
1267 spec
->multiout
.max_channels
= 6;
1268 spec
->multiout
.num_dacs
= ARRAY_SIZE(ad1986a_dac_nids
);
1269 spec
->multiout
.dac_nids
= ad1986a_dac_nids
;
1270 spec
->multiout
.dig_out_nid
= AD1986A_SPDIF_OUT
;
1271 spec
->num_adc_nids
= 1;
1272 spec
->adc_nids
= ad1986a_adc_nids
;
1273 spec
->capsrc_nids
= ad1986a_capsrc_nids
;
1274 spec
->input_mux
= &ad1986a_capture_source
;
1275 spec
->num_mixers
= 1;
1276 spec
->mixers
[0] = ad1986a_mixers
;
1277 spec
->num_init_verbs
= 1;
1278 spec
->init_verbs
[0] = ad1986a_init_verbs
;
1280 spec
->loopback
.amplist
= ad1986a_loopbacks
;
1282 spec
->vmaster_nid
= 0x1b;
1283 spec
->inv_eapd
= 1; /* AD1986A has the inverted EAPD implementation */
1285 codec
->patch_ops
= ad198x_patch_ops
;
1287 /* override some parameters */
1288 board_config
= snd_hda_check_board_config(codec
, AD1986A_MODELS
,
1291 switch (board_config
) {
1292 case AD1986A_3STACK
:
1293 spec
->num_mixers
= 2;
1294 spec
->mixers
[1] = ad1986a_3st_mixers
;
1295 spec
->num_init_verbs
= 2;
1296 spec
->init_verbs
[1] = ad1986a_ch2_init
;
1297 spec
->channel_mode
= ad1986a_modes
;
1298 spec
->num_channel_mode
= ARRAY_SIZE(ad1986a_modes
);
1299 spec
->need_dac_fix
= 1;
1300 spec
->multiout
.max_channels
= 2;
1301 spec
->multiout
.num_dacs
= 1;
1303 case AD1986A_LAPTOP
:
1304 spec
->mixers
[0] = ad1986a_laptop_mixers
;
1305 spec
->multiout
.max_channels
= 2;
1306 spec
->multiout
.num_dacs
= 1;
1307 spec
->multiout
.dac_nids
= ad1986a_laptop_dac_nids
;
1309 case AD1986A_LAPTOP_EAPD
:
1310 spec
->num_mixers
= 3;
1311 spec
->mixers
[0] = ad1986a_laptop_master_mixers
;
1312 spec
->mixers
[1] = ad1986a_laptop_eapd_mixers
;
1313 spec
->mixers
[2] = ad1986a_laptop_intmic_mixers
;
1314 spec
->num_init_verbs
= 2;
1315 spec
->init_verbs
[1] = ad1986a_eapd_init_verbs
;
1316 spec
->multiout
.max_channels
= 2;
1317 spec
->multiout
.num_dacs
= 1;
1318 spec
->multiout
.dac_nids
= ad1986a_laptop_dac_nids
;
1319 if (!is_jack_available(codec
, 0x25))
1320 spec
->multiout
.dig_out_nid
= 0;
1321 spec
->input_mux
= &ad1986a_laptop_eapd_capture_source
;
1323 case AD1986A_SAMSUNG
:
1324 spec
->num_mixers
= 2;
1325 spec
->mixers
[0] = ad1986a_laptop_master_mixers
;
1326 spec
->mixers
[1] = ad1986a_laptop_eapd_mixers
;
1327 spec
->num_init_verbs
= 3;
1328 spec
->init_verbs
[1] = ad1986a_eapd_init_verbs
;
1329 spec
->init_verbs
[2] = ad1986a_automic_verbs
;
1330 spec
->multiout
.max_channels
= 2;
1331 spec
->multiout
.num_dacs
= 1;
1332 spec
->multiout
.dac_nids
= ad1986a_laptop_dac_nids
;
1333 if (!is_jack_available(codec
, 0x25))
1334 spec
->multiout
.dig_out_nid
= 0;
1335 spec
->input_mux
= &ad1986a_automic_capture_source
;
1336 codec
->patch_ops
.unsol_event
= ad1986a_automic_unsol_event
;
1337 codec
->patch_ops
.init
= ad1986a_automic_init
;
1339 case AD1986A_SAMSUNG_P50
:
1340 spec
->num_mixers
= 2;
1341 spec
->mixers
[0] = ad1986a_automute_master_mixers
;
1342 spec
->mixers
[1] = ad1986a_laptop_eapd_mixers
;
1343 spec
->num_init_verbs
= 4;
1344 spec
->init_verbs
[1] = ad1986a_eapd_init_verbs
;
1345 spec
->init_verbs
[2] = ad1986a_automic_verbs
;
1346 spec
->init_verbs
[3] = ad1986a_hp_init_verbs
;
1347 spec
->multiout
.max_channels
= 2;
1348 spec
->multiout
.num_dacs
= 1;
1349 spec
->multiout
.dac_nids
= ad1986a_laptop_dac_nids
;
1350 if (!is_jack_available(codec
, 0x25))
1351 spec
->multiout
.dig_out_nid
= 0;
1352 spec
->input_mux
= &ad1986a_automic_capture_source
;
1353 codec
->patch_ops
.unsol_event
= ad1986a_samsung_p50_unsol_event
;
1354 codec
->patch_ops
.init
= ad1986a_samsung_p50_init
;
1356 case AD1986A_LAPTOP_AUTOMUTE
:
1357 spec
->num_mixers
= 3;
1358 spec
->mixers
[0] = ad1986a_automute_master_mixers
;
1359 spec
->mixers
[1] = ad1986a_laptop_eapd_mixers
;
1360 spec
->mixers
[2] = ad1986a_laptop_intmic_mixers
;
1361 spec
->num_init_verbs
= 3;
1362 spec
->init_verbs
[1] = ad1986a_eapd_init_verbs
;
1363 spec
->init_verbs
[2] = ad1986a_hp_init_verbs
;
1364 spec
->multiout
.max_channels
= 2;
1365 spec
->multiout
.num_dacs
= 1;
1366 spec
->multiout
.dac_nids
= ad1986a_laptop_dac_nids
;
1367 if (!is_jack_available(codec
, 0x25))
1368 spec
->multiout
.dig_out_nid
= 0;
1369 spec
->input_mux
= &ad1986a_laptop_eapd_capture_source
;
1370 codec
->patch_ops
.unsol_event
= ad1986a_hp_unsol_event
;
1371 codec
->patch_ops
.init
= ad1986a_hp_init
;
1372 /* Lenovo N100 seems to report the reversed bit
1373 * for HP jack-sensing
1375 spec
->inv_jack_detect
= 1;
1378 spec
->mixers
[0] = ad1986a_laptop_eapd_mixers
;
1379 spec
->num_init_verbs
= 2;
1380 spec
->init_verbs
[1] = ad1986a_ultra_init
;
1381 spec
->multiout
.max_channels
= 2;
1382 spec
->multiout
.num_dacs
= 1;
1383 spec
->multiout
.dac_nids
= ad1986a_laptop_dac_nids
;
1384 spec
->multiout
.dig_out_nid
= 0;
1388 /* AD1986A has a hardware problem that it can't share a stream
1389 * with multiple output pins. The copy of front to surrounds
1390 * causes noisy or silent outputs at a certain timing, e.g.
1391 * changing the volume.
1392 * So, let's disable the shared stream.
1394 spec
->multiout
.no_share_stream
= 1;
1396 codec
->no_trigger_sense
= 1;
1397 codec
->no_sticky_stream
= 1;
1406 #define AD1983_SPDIF_OUT 0x02
1407 #define AD1983_DAC 0x03
1408 #define AD1983_ADC 0x04
1410 static const hda_nid_t ad1983_dac_nids
[1] = { AD1983_DAC
};
1411 static const hda_nid_t ad1983_adc_nids
[1] = { AD1983_ADC
};
1412 static const hda_nid_t ad1983_capsrc_nids
[1] = { 0x15 };
1414 static const struct hda_input_mux ad1983_capture_source
= {
1420 { "Mix Mono", 0x3 },
1425 * SPDIF playback route
1427 static int ad1983_spdif_route_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
1429 static const char * const texts
[] = { "PCM", "ADC" };
1431 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
1433 uinfo
->value
.enumerated
.items
= 2;
1434 if (uinfo
->value
.enumerated
.item
> 1)
1435 uinfo
->value
.enumerated
.item
= 1;
1436 strcpy(uinfo
->value
.enumerated
.name
, texts
[uinfo
->value
.enumerated
.item
]);
1440 static int ad1983_spdif_route_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
1442 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1443 struct ad198x_spec
*spec
= codec
->spec
;
1445 ucontrol
->value
.enumerated
.item
[0] = spec
->spdif_route
;
1449 static int ad1983_spdif_route_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
1451 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1452 struct ad198x_spec
*spec
= codec
->spec
;
1454 if (ucontrol
->value
.enumerated
.item
[0] > 1)
1456 if (spec
->spdif_route
!= ucontrol
->value
.enumerated
.item
[0]) {
1457 spec
->spdif_route
= ucontrol
->value
.enumerated
.item
[0];
1458 snd_hda_codec_write_cache(codec
, spec
->multiout
.dig_out_nid
, 0,
1459 AC_VERB_SET_CONNECT_SEL
,
1466 static const struct snd_kcontrol_new ad1983_mixers
[] = {
1467 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT
),
1468 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT
),
1469 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT
),
1470 HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT
),
1471 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT
),
1472 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT
),
1473 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
1474 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
1475 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
1476 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
1477 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
1478 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
1479 HDA_CODEC_VOLUME("Mic Boost Volume", 0x0c, 0x0, HDA_OUTPUT
),
1480 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT
),
1481 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT
),
1483 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1484 .name
= "Capture Source",
1485 .info
= ad198x_mux_enum_info
,
1486 .get
= ad198x_mux_enum_get
,
1487 .put
= ad198x_mux_enum_put
,
1490 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1491 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,NONE
) "Source",
1492 .info
= ad1983_spdif_route_info
,
1493 .get
= ad1983_spdif_route_get
,
1494 .put
= ad1983_spdif_route_put
,
1499 static const struct hda_verb ad1983_init_verbs
[] = {
1500 /* Front, HP, Mono; mute as default */
1501 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1502 {0x06, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1503 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1504 /* Beep, PCM, Mic, Line-In: mute */
1505 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1506 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1507 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1508 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1509 /* Front, HP selectors; from Mix */
1510 {0x05, AC_VERB_SET_CONNECT_SEL
, 0x01},
1511 {0x06, AC_VERB_SET_CONNECT_SEL
, 0x01},
1512 /* Mono selector; from Mix */
1513 {0x0b, AC_VERB_SET_CONNECT_SEL
, 0x03},
1514 /* Mic selector; Mic */
1515 {0x0c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1516 /* Line-in selector: Line-in */
1517 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x0},
1518 /* Mic boost: 0dB */
1519 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
1520 /* Record selector: mic */
1521 {0x15, AC_VERB_SET_CONNECT_SEL
, 0x0},
1522 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1523 /* SPDIF route: PCM */
1524 {0x02, AC_VERB_SET_CONNECT_SEL
, 0x0},
1526 {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
1528 {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0xc0 },
1530 {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
1532 {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24 },
1534 {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
1539 static const struct hda_amp_list ad1983_loopbacks
[] = {
1540 { 0x12, HDA_OUTPUT
, 0 }, /* Mic */
1541 { 0x13, HDA_OUTPUT
, 0 }, /* Line */
1546 static int patch_ad1983(struct hda_codec
*codec
)
1548 struct ad198x_spec
*spec
;
1551 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1557 err
= snd_hda_attach_beep_device(codec
, 0x10);
1562 set_beep_amp(spec
, 0x10, 0, HDA_OUTPUT
);
1564 spec
->multiout
.max_channels
= 2;
1565 spec
->multiout
.num_dacs
= ARRAY_SIZE(ad1983_dac_nids
);
1566 spec
->multiout
.dac_nids
= ad1983_dac_nids
;
1567 spec
->multiout
.dig_out_nid
= AD1983_SPDIF_OUT
;
1568 spec
->num_adc_nids
= 1;
1569 spec
->adc_nids
= ad1983_adc_nids
;
1570 spec
->capsrc_nids
= ad1983_capsrc_nids
;
1571 spec
->input_mux
= &ad1983_capture_source
;
1572 spec
->num_mixers
= 1;
1573 spec
->mixers
[0] = ad1983_mixers
;
1574 spec
->num_init_verbs
= 1;
1575 spec
->init_verbs
[0] = ad1983_init_verbs
;
1576 spec
->spdif_route
= 0;
1578 spec
->loopback
.amplist
= ad1983_loopbacks
;
1580 spec
->vmaster_nid
= 0x05;
1582 codec
->patch_ops
= ad198x_patch_ops
;
1584 codec
->no_trigger_sense
= 1;
1585 codec
->no_sticky_stream
= 1;
1592 * AD1981 HD specific
1595 #define AD1981_SPDIF_OUT 0x02
1596 #define AD1981_DAC 0x03
1597 #define AD1981_ADC 0x04
1599 static const hda_nid_t ad1981_dac_nids
[1] = { AD1981_DAC
};
1600 static const hda_nid_t ad1981_adc_nids
[1] = { AD1981_ADC
};
1601 static const hda_nid_t ad1981_capsrc_nids
[1] = { 0x15 };
1603 /* 0x0c, 0x09, 0x0e, 0x0f, 0x19, 0x05, 0x18, 0x17 */
1604 static const struct hda_input_mux ad1981_capture_source
= {
1607 { "Front Mic", 0x0 },
1610 { "Mix Mono", 0x3 },
1617 static const struct snd_kcontrol_new ad1981_mixers
[] = {
1618 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT
),
1619 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT
),
1620 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT
),
1621 HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT
),
1622 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT
),
1623 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT
),
1624 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
1625 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
1626 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
1627 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
1628 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
1629 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
1630 HDA_CODEC_VOLUME("Aux Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
1631 HDA_CODEC_MUTE("Aux Playback Switch", 0x1b, 0x0, HDA_OUTPUT
),
1632 HDA_CODEC_VOLUME("Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT
),
1633 HDA_CODEC_MUTE("Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT
),
1634 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
1635 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT
),
1636 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x08, 0x0, HDA_INPUT
),
1637 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x0, HDA_INPUT
),
1638 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT
),
1639 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT
),
1641 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1642 .name
= "Capture Source",
1643 .info
= ad198x_mux_enum_info
,
1644 .get
= ad198x_mux_enum_get
,
1645 .put
= ad198x_mux_enum_put
,
1647 /* identical with AD1983 */
1649 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1650 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,NONE
) "Source",
1651 .info
= ad1983_spdif_route_info
,
1652 .get
= ad1983_spdif_route_get
,
1653 .put
= ad1983_spdif_route_put
,
1658 static const struct hda_verb ad1981_init_verbs
[] = {
1659 /* Front, HP, Mono; mute as default */
1660 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1661 {0x06, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1662 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1663 /* Beep, PCM, Front Mic, Line, Rear Mic, Aux, CD-In: mute */
1664 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1665 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1666 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1667 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1668 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1669 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1670 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1671 /* Front, HP selectors; from Mix */
1672 {0x05, AC_VERB_SET_CONNECT_SEL
, 0x01},
1673 {0x06, AC_VERB_SET_CONNECT_SEL
, 0x01},
1674 /* Mono selector; from Mix */
1675 {0x0b, AC_VERB_SET_CONNECT_SEL
, 0x03},
1676 /* Mic Mixer; select Front Mic */
1677 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
1678 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1679 /* Mic boost: 0dB */
1680 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
1681 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
1682 /* Record selector: Front mic */
1683 {0x15, AC_VERB_SET_CONNECT_SEL
, 0x0},
1684 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1685 /* SPDIF route: PCM */
1686 {0x02, AC_VERB_SET_CONNECT_SEL
, 0x0},
1688 {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
1690 {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0xc0 },
1692 {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
1693 /* Front & Rear Mic Pins */
1694 {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24 },
1695 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24 },
1697 {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
1699 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x00},
1700 /* Line-Out as Input: disabled */
1701 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1706 static const struct hda_amp_list ad1981_loopbacks
[] = {
1707 { 0x12, HDA_OUTPUT
, 0 }, /* Front Mic */
1708 { 0x13, HDA_OUTPUT
, 0 }, /* Line */
1709 { 0x1b, HDA_OUTPUT
, 0 }, /* Aux */
1710 { 0x1c, HDA_OUTPUT
, 0 }, /* Mic */
1711 { 0x1d, HDA_OUTPUT
, 0 }, /* CD */
1717 * Patch for HP nx6320
1719 * nx6320 uses EAPD in the reverse way - EAPD-on means the internal
1720 * speaker output enabled _and_ mute-LED off.
1723 #define AD1981_HP_EVENT 0x37
1724 #define AD1981_MIC_EVENT 0x38
1726 static const struct hda_verb ad1981_hp_init_verbs
[] = {
1727 {0x05, AC_VERB_SET_EAPD_BTLENABLE
, 0x00 }, /* default off */
1728 /* pin sensing on HP and Mic jacks */
1729 {0x06, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1981_HP_EVENT
},
1730 {0x08, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1981_MIC_EVENT
},
1734 /* turn on/off EAPD (+ mute HP) as a master switch */
1735 static int ad1981_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1736 struct snd_ctl_elem_value
*ucontrol
)
1738 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1739 struct ad198x_spec
*spec
= codec
->spec
;
1741 if (! ad198x_eapd_put(kcontrol
, ucontrol
))
1743 /* change speaker pin appropriately */
1744 snd_hda_set_pin_ctl(codec
, 0x05, spec
->cur_eapd
? PIN_OUT
: 0);
1745 /* toggle HP mute appropriately */
1746 snd_hda_codec_amp_stereo(codec
, 0x06, HDA_OUTPUT
, 0,
1748 spec
->cur_eapd
? 0 : HDA_AMP_MUTE
);
1752 /* bind volumes of both NID 0x05 and 0x06 */
1753 static const struct hda_bind_ctls ad1981_hp_bind_master_vol
= {
1754 .ops
= &snd_hda_bind_vol
,
1756 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT
),
1757 HDA_COMPOSE_AMP_VAL(0x06, 3, 0, HDA_OUTPUT
),
1762 /* mute internal speaker if HP is plugged */
1763 static void ad1981_hp_automute(struct hda_codec
*codec
)
1765 unsigned int present
;
1767 present
= snd_hda_jack_detect(codec
, 0x06);
1768 snd_hda_codec_amp_stereo(codec
, 0x05, HDA_OUTPUT
, 0,
1769 HDA_AMP_MUTE
, present
? HDA_AMP_MUTE
: 0);
1772 /* toggle input of built-in and mic jack appropriately */
1773 static void ad1981_hp_automic(struct hda_codec
*codec
)
1775 static const struct hda_verb mic_jack_on
[] = {
1776 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1777 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
1780 static const struct hda_verb mic_jack_off
[] = {
1781 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1782 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
1785 unsigned int present
;
1787 present
= snd_hda_jack_detect(codec
, 0x08);
1789 snd_hda_sequence_write(codec
, mic_jack_on
);
1791 snd_hda_sequence_write(codec
, mic_jack_off
);
1794 /* unsolicited event for HP jack sensing */
1795 static void ad1981_hp_unsol_event(struct hda_codec
*codec
,
1800 case AD1981_HP_EVENT
:
1801 ad1981_hp_automute(codec
);
1803 case AD1981_MIC_EVENT
:
1804 ad1981_hp_automic(codec
);
1809 static const struct hda_input_mux ad1981_hp_capture_source
= {
1813 { "Dock Mic", 0x1 },
1818 static const struct snd_kcontrol_new ad1981_hp_mixers
[] = {
1819 HDA_BIND_VOL("Master Playback Volume", &ad1981_hp_bind_master_vol
),
1821 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1822 .subdevice
= HDA_SUBDEV_NID_FLAG
| 0x05,
1823 .name
= "Master Playback Switch",
1824 .info
= ad198x_eapd_info
,
1825 .get
= ad198x_eapd_get
,
1826 .put
= ad1981_hp_master_sw_put
,
1827 .private_value
= 0x05,
1829 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
1830 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
1832 /* FIXME: analog mic/line loopback doesn't work with my tests...
1833 * (although recording is OK)
1835 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
1836 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
1837 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
1838 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
1839 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT
),
1840 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT
),
1841 /* FIXME: does this laptop have analog CD connection? */
1842 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
1843 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT
),
1845 HDA_CODEC_VOLUME("Mic Boost Volume", 0x08, 0x0, HDA_INPUT
),
1846 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x18, 0x0, HDA_INPUT
),
1847 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT
),
1848 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT
),
1850 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1851 .name
= "Capture Source",
1852 .info
= ad198x_mux_enum_info
,
1853 .get
= ad198x_mux_enum_get
,
1854 .put
= ad198x_mux_enum_put
,
1859 /* initialize jack-sensing, too */
1860 static int ad1981_hp_init(struct hda_codec
*codec
)
1863 ad1981_hp_automute(codec
);
1864 ad1981_hp_automic(codec
);
1868 /* configuration for Toshiba Laptops */
1869 static const struct hda_verb ad1981_toshiba_init_verbs
[] = {
1870 {0x05, AC_VERB_SET_EAPD_BTLENABLE
, 0x01 }, /* default on */
1871 /* pin sensing on HP and Mic jacks */
1872 {0x06, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1981_HP_EVENT
},
1873 {0x08, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1981_MIC_EVENT
},
1877 static const struct snd_kcontrol_new ad1981_toshiba_mixers
[] = {
1878 HDA_CODEC_VOLUME("Amp Volume", 0x1a, 0x0, HDA_OUTPUT
),
1879 HDA_CODEC_MUTE("Amp Switch", 0x1a, 0x0, HDA_OUTPUT
),
1883 /* configuration for Lenovo Thinkpad T60 */
1884 static const struct snd_kcontrol_new ad1981_thinkpad_mixers
[] = {
1885 HDA_CODEC_VOLUME("Master Playback Volume", 0x05, 0x0, HDA_OUTPUT
),
1886 HDA_CODEC_MUTE("Master Playback Switch", 0x05, 0x0, HDA_OUTPUT
),
1887 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
1888 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
1889 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
1890 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
1891 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
1892 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT
),
1893 HDA_CODEC_VOLUME("Mic Boost Volume", 0x08, 0x0, HDA_INPUT
),
1894 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT
),
1895 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT
),
1897 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1898 .name
= "Capture Source",
1899 .info
= ad198x_mux_enum_info
,
1900 .get
= ad198x_mux_enum_get
,
1901 .put
= ad198x_mux_enum_put
,
1903 /* identical with AD1983 */
1905 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1906 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,NONE
) "Source",
1907 .info
= ad1983_spdif_route_info
,
1908 .get
= ad1983_spdif_route_get
,
1909 .put
= ad1983_spdif_route_put
,
1914 static const struct hda_input_mux ad1981_thinkpad_capture_source
= {
1932 static const char * const ad1981_models
[AD1981_MODELS
] = {
1934 [AD1981_THINKPAD
] = "thinkpad",
1935 [AD1981_BASIC
] = "basic",
1936 [AD1981_TOSHIBA
] = "toshiba"
1939 static const struct snd_pci_quirk ad1981_cfg_tbl
[] = {
1940 SND_PCI_QUIRK(0x1014, 0x0597, "Lenovo Z60", AD1981_THINKPAD
),
1941 SND_PCI_QUIRK(0x1014, 0x05b7, "Lenovo Z60m", AD1981_THINKPAD
),
1943 SND_PCI_QUIRK_VENDOR(0x103c, "HP nx", AD1981_HP
),
1944 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba U205", AD1981_TOSHIBA
),
1945 /* Lenovo Thinkpad T60/X60/Z6xx */
1946 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo Thinkpad", AD1981_THINKPAD
),
1947 /* HP nx6320 (reversed SSID, H/W bug) */
1948 SND_PCI_QUIRK(0x30b0, 0x103c, "HP nx6320", AD1981_HP
),
1952 static int patch_ad1981(struct hda_codec
*codec
)
1954 struct ad198x_spec
*spec
;
1955 int err
, board_config
;
1957 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1963 err
= snd_hda_attach_beep_device(codec
, 0x10);
1968 set_beep_amp(spec
, 0x0d, 0, HDA_OUTPUT
);
1970 spec
->multiout
.max_channels
= 2;
1971 spec
->multiout
.num_dacs
= ARRAY_SIZE(ad1981_dac_nids
);
1972 spec
->multiout
.dac_nids
= ad1981_dac_nids
;
1973 spec
->multiout
.dig_out_nid
= AD1981_SPDIF_OUT
;
1974 spec
->num_adc_nids
= 1;
1975 spec
->adc_nids
= ad1981_adc_nids
;
1976 spec
->capsrc_nids
= ad1981_capsrc_nids
;
1977 spec
->input_mux
= &ad1981_capture_source
;
1978 spec
->num_mixers
= 1;
1979 spec
->mixers
[0] = ad1981_mixers
;
1980 spec
->num_init_verbs
= 1;
1981 spec
->init_verbs
[0] = ad1981_init_verbs
;
1982 spec
->spdif_route
= 0;
1984 spec
->loopback
.amplist
= ad1981_loopbacks
;
1986 spec
->vmaster_nid
= 0x05;
1988 codec
->patch_ops
= ad198x_patch_ops
;
1990 /* override some parameters */
1991 board_config
= snd_hda_check_board_config(codec
, AD1981_MODELS
,
1994 switch (board_config
) {
1996 spec
->mixers
[0] = ad1981_hp_mixers
;
1997 spec
->num_init_verbs
= 2;
1998 spec
->init_verbs
[1] = ad1981_hp_init_verbs
;
1999 if (!is_jack_available(codec
, 0x0a))
2000 spec
->multiout
.dig_out_nid
= 0;
2001 spec
->input_mux
= &ad1981_hp_capture_source
;
2003 codec
->patch_ops
.init
= ad1981_hp_init
;
2004 codec
->patch_ops
.unsol_event
= ad1981_hp_unsol_event
;
2005 /* set the upper-limit for mixer amp to 0dB for avoiding the
2006 * possible damage by overloading
2008 snd_hda_override_amp_caps(codec
, 0x11, HDA_INPUT
,
2009 (0x17 << AC_AMPCAP_OFFSET_SHIFT
) |
2010 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
2011 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
2012 (1 << AC_AMPCAP_MUTE_SHIFT
));
2014 case AD1981_THINKPAD
:
2015 spec
->mixers
[0] = ad1981_thinkpad_mixers
;
2016 spec
->input_mux
= &ad1981_thinkpad_capture_source
;
2017 /* set the upper-limit for mixer amp to 0dB for avoiding the
2018 * possible damage by overloading
2020 snd_hda_override_amp_caps(codec
, 0x11, HDA_INPUT
,
2021 (0x17 << AC_AMPCAP_OFFSET_SHIFT
) |
2022 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
2023 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
2024 (1 << AC_AMPCAP_MUTE_SHIFT
));
2026 case AD1981_TOSHIBA
:
2027 spec
->mixers
[0] = ad1981_hp_mixers
;
2028 spec
->mixers
[1] = ad1981_toshiba_mixers
;
2029 spec
->num_init_verbs
= 2;
2030 spec
->init_verbs
[1] = ad1981_toshiba_init_verbs
;
2031 spec
->multiout
.dig_out_nid
= 0;
2032 spec
->input_mux
= &ad1981_hp_capture_source
;
2033 codec
->patch_ops
.init
= ad1981_hp_init
;
2034 codec
->patch_ops
.unsol_event
= ad1981_hp_unsol_event
;
2038 codec
->no_trigger_sense
= 1;
2039 codec
->no_sticky_stream
= 1;
2048 * Output pins and routes
2050 * Pin Mix Sel DAC (*)
2051 * port-A 0x11 (mute/hp) <- 0x22 <- 0x37 <- 03/04/06
2052 * port-B 0x14 (mute/hp) <- 0x2b <- 0x30 <- 03/04/06
2053 * port-C 0x15 (mute) <- 0x2c <- 0x31 <- 05/0a
2054 * port-D 0x12 (mute/hp) <- 0x29 <- 04
2055 * port-E 0x17 (mute/hp) <- 0x26 <- 0x32 <- 05/0a
2056 * port-F 0x16 (mute) <- 0x2a <- 06
2057 * port-G 0x24 (mute) <- 0x27 <- 05
2058 * port-H 0x25 (mute) <- 0x28 <- 0a
2059 * mono 0x13 (mute/amp)<- 0x1e <- 0x36 <- 03/04/06
2061 * DAC0 = 03h, DAC1 = 04h, DAC2 = 05h, DAC3 = 06h, DAC4 = 0ah
2062 * (*) DAC2/3/4 are swapped to DAC3/4/2 on AD198A rev.2 due to a h/w bug.
2064 * Input pins and routes
2066 * pin boost mix input # / adc input #
2067 * port-A 0x11 -> 0x38 -> mix 2, ADC 0
2068 * port-B 0x14 -> 0x39 -> mix 0, ADC 1
2069 * port-C 0x15 -> 0x3a -> 33:0 - mix 1, ADC 2
2070 * port-D 0x12 -> 0x3d -> mix 3, ADC 8
2071 * port-E 0x17 -> 0x3c -> 34:0 - mix 4, ADC 4
2072 * port-F 0x16 -> 0x3b -> mix 5, ADC 3
2073 * port-G 0x24 -> N/A -> 33:1 - mix 1, 34:1 - mix 4, ADC 6
2074 * port-H 0x25 -> N/A -> 33:2 - mix 1, 34:2 - mix 4, ADC 7
2078 * 6stack - front/surr/CLFE/side/opt DACs - 04/06/05/0a/03
2079 * 3stack - front/surr/CLFE/opt DACs - 04/05/0a/03
2081 * Inputs of Analog Mix (0x20)
2082 * 0:Port-B (front mic)
2083 * 1:Port-C/G/H (line-in)
2085 * 3:Port-D (line-in/2)
2086 * 4:Port-E/G/H (mic-in)
2087 * 5:Port-F (mic2-in)
2093 * 1:Port-B (front mic-in)
2094 * 2:Port-C (line-in)
2095 * 3:Port-F (mic2-in)
2100 * 8:Port-D (line-in/2)
2103 * Proposed pin assignments by the datasheet
2106 * Port-A front headphone
2116 * Port-A front headphone
2118 * C rear line-in/surround
2120 * E rear mic-in/CLFE
2126 * D internal speaker (with EAPD)
2127 * E/F quad mic array
2143 /* reivision id to check workarounds */
2144 #define AD1988A_REV2 0x100200
2146 #define is_rev2(codec) \
2147 ((codec)->vendor_id == 0x11d41988 && \
2148 (codec)->revision_id == AD1988A_REV2)
2154 static const hda_nid_t ad1988_6stack_dac_nids
[4] = {
2155 0x04, 0x06, 0x05, 0x0a
2158 static const hda_nid_t ad1988_3stack_dac_nids
[3] = {
2162 /* for AD1988A revision-2, DAC2-4 are swapped */
2163 static const hda_nid_t ad1988_6stack_dac_nids_rev2
[4] = {
2164 0x04, 0x05, 0x0a, 0x06
2167 static const hda_nid_t ad1988_alt_dac_nid
[1] = {
2171 static const hda_nid_t ad1988_3stack_dac_nids_rev2
[3] = {
2175 static const hda_nid_t ad1988_adc_nids
[3] = {
2179 static const hda_nid_t ad1988_capsrc_nids
[3] = {
2183 #define AD1988_SPDIF_OUT 0x02
2184 #define AD1988_SPDIF_OUT_HDMI 0x0b
2185 #define AD1988_SPDIF_IN 0x07
2187 static const hda_nid_t ad1989b_slave_dig_outs
[] = {
2188 AD1988_SPDIF_OUT
, AD1988_SPDIF_OUT_HDMI
, 0
2191 static const struct hda_input_mux ad1988_6stack_capture_source
= {
2194 { "Front Mic", 0x1 }, /* port-B */
2195 { "Line", 0x2 }, /* port-C */
2196 { "Mic", 0x4 }, /* port-E */
2202 static const struct hda_input_mux ad1988_laptop_capture_source
= {
2205 { "Mic/Line", 0x1 }, /* port-B */
2213 static int ad198x_ch_mode_info(struct snd_kcontrol
*kcontrol
,
2214 struct snd_ctl_elem_info
*uinfo
)
2216 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2217 struct ad198x_spec
*spec
= codec
->spec
;
2218 return snd_hda_ch_mode_info(codec
, uinfo
, spec
->channel_mode
,
2219 spec
->num_channel_mode
);
2222 static int ad198x_ch_mode_get(struct snd_kcontrol
*kcontrol
,
2223 struct snd_ctl_elem_value
*ucontrol
)
2225 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2226 struct ad198x_spec
*spec
= codec
->spec
;
2227 return snd_hda_ch_mode_get(codec
, ucontrol
, spec
->channel_mode
,
2228 spec
->num_channel_mode
, spec
->multiout
.max_channels
);
2231 static int ad198x_ch_mode_put(struct snd_kcontrol
*kcontrol
,
2232 struct snd_ctl_elem_value
*ucontrol
)
2234 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2235 struct ad198x_spec
*spec
= codec
->spec
;
2236 int err
= snd_hda_ch_mode_put(codec
, ucontrol
, spec
->channel_mode
,
2237 spec
->num_channel_mode
,
2238 &spec
->multiout
.max_channels
);
2239 if (err
>= 0 && spec
->need_dac_fix
)
2240 spec
->multiout
.num_dacs
= spec
->multiout
.max_channels
/ 2;
2244 static const struct snd_kcontrol_new ad1988_hp_mixers
[] = {
2246 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2247 .name
= "Independent HP",
2248 .info
= ad1988_independent_hp_info
,
2249 .get
= ad1988_independent_hp_get
,
2250 .put
= ad1988_independent_hp_put
,
2256 static const struct snd_kcontrol_new ad1988_6stack_mixers1
[] = {
2257 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
2258 HDA_CODEC_VOLUME("Surround Playback Volume", 0x06, 0x0, HDA_OUTPUT
),
2259 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT
),
2260 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT
),
2261 HDA_CODEC_VOLUME("Side Playback Volume", 0x0a, 0x0, HDA_OUTPUT
),
2265 static const struct snd_kcontrol_new ad1988_6stack_mixers1_rev2
[] = {
2266 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
2267 HDA_CODEC_VOLUME("Surround Playback Volume", 0x05, 0x0, HDA_OUTPUT
),
2268 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT
),
2269 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0a, 2, 0x0, HDA_OUTPUT
),
2270 HDA_CODEC_VOLUME("Side Playback Volume", 0x06, 0x0, HDA_OUTPUT
),
2274 static const struct snd_kcontrol_new ad1988_6stack_mixers2
[] = {
2275 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT
),
2276 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT
),
2277 HDA_BIND_MUTE("Surround Playback Switch", 0x2a, 2, HDA_INPUT
),
2278 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x27, 1, 2, HDA_INPUT
),
2279 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x27, 2, 2, HDA_INPUT
),
2280 HDA_BIND_MUTE("Side Playback Switch", 0x28, 2, HDA_INPUT
),
2281 HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT
),
2282 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT
),
2284 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT
),
2285 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT
),
2286 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT
),
2287 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT
),
2288 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT
),
2289 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT
),
2290 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT
),
2291 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT
),
2293 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT
),
2294 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT
),
2296 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x39, 0x0, HDA_OUTPUT
),
2297 HDA_CODEC_VOLUME("Mic Boost Volume", 0x3c, 0x0, HDA_OUTPUT
),
2302 static const struct snd_kcontrol_new ad1988_3stack_mixers1
[] = {
2303 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
2304 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT
),
2305 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT
),
2306 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT
),
2310 static const struct snd_kcontrol_new ad1988_3stack_mixers1_rev2
[] = {
2311 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
2312 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT
),
2313 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x06, 1, 0x0, HDA_OUTPUT
),
2314 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x06, 2, 0x0, HDA_OUTPUT
),
2318 static const struct snd_kcontrol_new ad1988_3stack_mixers2
[] = {
2319 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT
),
2320 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT
),
2321 HDA_BIND_MUTE("Surround Playback Switch", 0x2c, 2, HDA_INPUT
),
2322 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x26, 1, 2, HDA_INPUT
),
2323 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x26, 2, 2, HDA_INPUT
),
2324 HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT
),
2325 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT
),
2327 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT
),
2328 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT
),
2329 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT
),
2330 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT
),
2331 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT
),
2332 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT
),
2333 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT
),
2334 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT
),
2336 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT
),
2337 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT
),
2339 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x39, 0x0, HDA_OUTPUT
),
2340 HDA_CODEC_VOLUME("Mic Boost Volume", 0x3c, 0x0, HDA_OUTPUT
),
2342 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2343 .name
= "Channel Mode",
2344 .info
= ad198x_ch_mode_info
,
2345 .get
= ad198x_ch_mode_get
,
2346 .put
= ad198x_ch_mode_put
,
2353 static const struct snd_kcontrol_new ad1988_laptop_mixers
[] = {
2354 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT
),
2355 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
2356 HDA_CODEC_MUTE("PCM Playback Switch", 0x29, 0x0, HDA_INPUT
),
2357 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT
),
2359 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT
),
2360 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT
),
2361 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x0, HDA_INPUT
),
2362 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x0, HDA_INPUT
),
2363 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT
),
2364 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT
),
2366 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT
),
2367 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT
),
2369 HDA_CODEC_VOLUME("Mic Boost Volume", 0x39, 0x0, HDA_OUTPUT
),
2372 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2373 .name
= "External Amplifier",
2374 .subdevice
= HDA_SUBDEV_NID_FLAG
| 0x12,
2375 .info
= ad198x_eapd_info
,
2376 .get
= ad198x_eapd_get
,
2377 .put
= ad198x_eapd_put
,
2378 .private_value
= 0x12, /* port-D */
2385 static const struct snd_kcontrol_new ad1988_capture_mixers
[] = {
2386 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
2387 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
2388 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT
),
2389 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT
),
2390 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x0e, 0x0, HDA_OUTPUT
),
2391 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x0e, 0x0, HDA_OUTPUT
),
2393 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2394 /* The multiple "Capture Source" controls confuse alsamixer
2395 * So call somewhat different..
2397 /* .name = "Capture Source", */
2398 .name
= "Input Source",
2400 .info
= ad198x_mux_enum_info
,
2401 .get
= ad198x_mux_enum_get
,
2402 .put
= ad198x_mux_enum_put
,
2407 static int ad1988_spdif_playback_source_info(struct snd_kcontrol
*kcontrol
,
2408 struct snd_ctl_elem_info
*uinfo
)
2410 static const char * const texts
[] = {
2411 "PCM", "ADC1", "ADC2", "ADC3"
2413 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
2415 uinfo
->value
.enumerated
.items
= 4;
2416 if (uinfo
->value
.enumerated
.item
>= 4)
2417 uinfo
->value
.enumerated
.item
= 3;
2418 strcpy(uinfo
->value
.enumerated
.name
, texts
[uinfo
->value
.enumerated
.item
]);
2422 static int ad1988_spdif_playback_source_get(struct snd_kcontrol
*kcontrol
,
2423 struct snd_ctl_elem_value
*ucontrol
)
2425 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2428 sel
= snd_hda_codec_read(codec
, 0x1d, 0, AC_VERB_GET_AMP_GAIN_MUTE
,
2431 ucontrol
->value
.enumerated
.item
[0] = 0;
2433 sel
= snd_hda_codec_read(codec
, 0x0b, 0,
2434 AC_VERB_GET_CONNECT_SEL
, 0);
2439 ucontrol
->value
.enumerated
.item
[0] = sel
;
2444 static int ad1988_spdif_playback_source_put(struct snd_kcontrol
*kcontrol
,
2445 struct snd_ctl_elem_value
*ucontrol
)
2447 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2448 unsigned int val
, sel
;
2451 val
= ucontrol
->value
.enumerated
.item
[0];
2455 sel
= snd_hda_codec_read(codec
, 0x1d, 0,
2456 AC_VERB_GET_AMP_GAIN_MUTE
,
2458 change
= sel
& 0x80;
2460 snd_hda_codec_write_cache(codec
, 0x1d, 0,
2461 AC_VERB_SET_AMP_GAIN_MUTE
,
2463 snd_hda_codec_write_cache(codec
, 0x1d, 0,
2464 AC_VERB_SET_AMP_GAIN_MUTE
,
2468 sel
= snd_hda_codec_read(codec
, 0x1d, 0,
2469 AC_VERB_GET_AMP_GAIN_MUTE
,
2470 AC_AMP_GET_INPUT
| 0x01);
2471 change
= sel
& 0x80;
2473 snd_hda_codec_write_cache(codec
, 0x1d, 0,
2474 AC_VERB_SET_AMP_GAIN_MUTE
,
2476 snd_hda_codec_write_cache(codec
, 0x1d, 0,
2477 AC_VERB_SET_AMP_GAIN_MUTE
,
2480 sel
= snd_hda_codec_read(codec
, 0x0b, 0,
2481 AC_VERB_GET_CONNECT_SEL
, 0) + 1;
2482 change
|= sel
!= val
;
2484 snd_hda_codec_write_cache(codec
, 0x0b, 0,
2485 AC_VERB_SET_CONNECT_SEL
,
2491 static const struct snd_kcontrol_new ad1988_spdif_out_mixers
[] = {
2492 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
2494 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2495 .name
= "IEC958 Playback Source",
2496 .subdevice
= HDA_SUBDEV_NID_FLAG
| 0x1b,
2497 .info
= ad1988_spdif_playback_source_info
,
2498 .get
= ad1988_spdif_playback_source_get
,
2499 .put
= ad1988_spdif_playback_source_put
,
2504 static const struct snd_kcontrol_new ad1988_spdif_in_mixers
[] = {
2505 HDA_CODEC_VOLUME("IEC958 Capture Volume", 0x1c, 0x0, HDA_INPUT
),
2509 static const struct snd_kcontrol_new ad1989_spdif_out_mixers
[] = {
2510 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
2511 HDA_CODEC_VOLUME("HDMI Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
2516 * initialization verbs
2520 * for 6-stack (+dig)
2522 static const struct hda_verb ad1988_6stack_init_verbs
[] = {
2523 /* Front, Surround, CLFE, side DAC; unmute as default */
2524 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2525 {0x06, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2526 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2527 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2528 /* Port-A front headphon path */
2529 {0x37, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC0:03h */
2530 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2531 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2532 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2533 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2534 /* Port-D line-out path */
2535 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2536 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2537 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2538 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2539 /* Port-F surround path */
2540 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2541 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2542 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2543 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2544 /* Port-G CLFE path */
2545 {0x27, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2546 {0x27, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2547 {0x24, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2548 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2549 /* Port-H side path */
2550 {0x28, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2551 {0x28, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2552 {0x25, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2553 {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2555 {0x36, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* DAC1:04h */
2556 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2557 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2558 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2559 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb01f}, /* unmute, 0dB */
2560 /* Port-B front mic-in path */
2561 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2562 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2563 {0x39, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2564 /* Port-C line-in path */
2565 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2566 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2567 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2568 {0x33, AC_VERB_SET_CONNECT_SEL
, 0x0},
2569 /* Port-E mic-in path */
2570 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2571 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2572 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2573 {0x34, AC_VERB_SET_CONNECT_SEL
, 0x0},
2574 /* Analog CD Input */
2575 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2576 /* Analog Mix output amp */
2577 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x1f}, /* 0dB */
2582 static const struct hda_verb ad1988_6stack_fp_init_verbs
[] = {
2583 /* Headphone; unmute as default */
2584 {0x03, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2585 /* Port-A front headphon path */
2586 {0x37, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC0:03h */
2587 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2588 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2589 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2590 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2595 static const struct hda_verb ad1988_capture_init_verbs
[] = {
2596 /* mute analog mix */
2597 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2598 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2599 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2600 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2601 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2602 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)},
2603 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)},
2604 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)},
2605 /* select ADCs - front-mic */
2606 {0x0c, AC_VERB_SET_CONNECT_SEL
, 0x1},
2607 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x1},
2608 {0x0e, AC_VERB_SET_CONNECT_SEL
, 0x1},
2613 static const struct hda_verb ad1988_spdif_init_verbs
[] = {
2615 {0x02, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* PCM */
2616 {0x0b, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* ADC1 */
2617 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2618 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2620 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x27}, /* 0dB */
2625 static const struct hda_verb ad1988_spdif_in_init_verbs
[] = {
2626 /* unmute SPDIF input pin */
2627 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2631 /* AD1989 has no ADC -> SPDIF route */
2632 static const struct hda_verb ad1989_spdif_init_verbs
[] = {
2633 /* SPDIF-1 out pin */
2634 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2635 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x27}, /* 0dB */
2636 /* SPDIF-2/HDMI out pin */
2637 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2638 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x27}, /* 0dB */
2643 * verbs for 3stack (+dig)
2645 static const struct hda_verb ad1988_3stack_ch2_init
[] = {
2646 /* set port-C to line-in */
2647 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2648 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2649 /* set port-E to mic-in */
2650 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2651 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2655 static const struct hda_verb ad1988_3stack_ch6_init
[] = {
2656 /* set port-C to surround out */
2657 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2658 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2659 /* set port-E to CLFE out */
2660 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2661 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2665 static const struct hda_channel_mode ad1988_3stack_modes
[2] = {
2666 { 2, ad1988_3stack_ch2_init
},
2667 { 6, ad1988_3stack_ch6_init
},
2670 static const struct hda_verb ad1988_3stack_init_verbs
[] = {
2671 /* Front, Surround, CLFE, side DAC; unmute as default */
2672 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2673 {0x06, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2674 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2675 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2676 /* Port-A front headphon path */
2677 {0x37, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC0:03h */
2678 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2679 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2680 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2681 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2682 /* Port-D line-out path */
2683 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2684 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2685 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2686 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2688 {0x36, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* DAC1:04h */
2689 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2690 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2691 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2692 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb01f}, /* unmute, 0dB */
2693 /* Port-B front mic-in path */
2694 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2695 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2696 {0x39, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2697 /* Port-C line-in/surround path - 6ch mode as default */
2698 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2699 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2700 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2701 {0x31, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* output sel: DAC 0x05 */
2702 {0x33, AC_VERB_SET_CONNECT_SEL
, 0x0},
2703 /* Port-E mic-in/CLFE path - 6ch mode as default */
2704 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2705 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2706 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2707 {0x32, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* output sel: DAC 0x0a */
2708 {0x34, AC_VERB_SET_CONNECT_SEL
, 0x0},
2709 /* mute analog mix */
2710 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2711 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2712 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2713 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2714 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2715 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)},
2716 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)},
2717 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)},
2718 /* select ADCs - front-mic */
2719 {0x0c, AC_VERB_SET_CONNECT_SEL
, 0x1},
2720 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x1},
2721 {0x0e, AC_VERB_SET_CONNECT_SEL
, 0x1},
2722 /* Analog Mix output amp */
2723 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x1f}, /* 0dB */
2728 * verbs for laptop mode (+dig)
2730 static const struct hda_verb ad1988_laptop_hp_on
[] = {
2731 /* unmute port-A and mute port-D */
2732 { 0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2733 { 0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2736 static const struct hda_verb ad1988_laptop_hp_off
[] = {
2737 /* mute port-A and unmute port-D */
2738 { 0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2739 { 0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2743 #define AD1988_HP_EVENT 0x01
2745 static const struct hda_verb ad1988_laptop_init_verbs
[] = {
2746 /* Front, Surround, CLFE, side DAC; unmute as default */
2747 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2748 {0x06, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2749 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2750 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2751 /* Port-A front headphon path */
2752 {0x37, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC0:03h */
2753 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2754 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2755 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2756 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2757 /* unsolicited event for pin-sense */
2758 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1988_HP_EVENT
},
2759 /* Port-D line-out path + EAPD */
2760 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2761 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2762 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2763 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2764 {0x12, AC_VERB_SET_EAPD_BTLENABLE
, 0x00}, /* EAPD-off */
2766 {0x36, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* DAC1:04h */
2767 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2768 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2769 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2770 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb01f}, /* unmute, 0dB */
2771 /* Port-B mic-in path */
2772 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2773 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2774 {0x39, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2775 /* Port-C docking station - try to output */
2776 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2777 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2778 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2779 {0x33, AC_VERB_SET_CONNECT_SEL
, 0x0},
2780 /* mute analog mix */
2781 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2782 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2783 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2784 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2785 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2786 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)},
2787 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)},
2788 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)},
2789 /* select ADCs - mic */
2790 {0x0c, AC_VERB_SET_CONNECT_SEL
, 0x1},
2791 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x1},
2792 {0x0e, AC_VERB_SET_CONNECT_SEL
, 0x1},
2793 /* Analog Mix output amp */
2794 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x1f}, /* 0dB */
2798 static void ad1988_laptop_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2800 if ((res
>> 26) != AD1988_HP_EVENT
)
2802 if (snd_hda_jack_detect(codec
, 0x11))
2803 snd_hda_sequence_write(codec
, ad1988_laptop_hp_on
);
2805 snd_hda_sequence_write(codec
, ad1988_laptop_hp_off
);
2809 static const struct hda_amp_list ad1988_loopbacks
[] = {
2810 { 0x20, HDA_INPUT
, 0 }, /* Front Mic */
2811 { 0x20, HDA_INPUT
, 1 }, /* Line */
2812 { 0x20, HDA_INPUT
, 4 }, /* Mic */
2813 { 0x20, HDA_INPUT
, 6 }, /* CD */
2819 * Automatic parse of I/O pins from the BIOS configuration
2827 static const struct snd_kcontrol_new ad1988_control_templates
[] = {
2828 HDA_CODEC_VOLUME(NULL
, 0, 0, 0),
2829 HDA_CODEC_MUTE(NULL
, 0, 0, 0),
2830 HDA_BIND_MUTE(NULL
, 0, 0, 0),
2833 /* add dynamic controls */
2834 static int add_control(struct ad198x_spec
*spec
, int type
, const char *name
,
2837 struct snd_kcontrol_new
*knew
;
2839 snd_array_init(&spec
->kctls
, sizeof(*knew
), 32);
2840 knew
= snd_array_new(&spec
->kctls
);
2843 *knew
= ad1988_control_templates
[type
];
2844 knew
->name
= kstrdup(name
, GFP_KERNEL
);
2847 if (get_amp_nid_(val
))
2848 knew
->subdevice
= HDA_SUBDEV_AMP_FLAG
;
2849 knew
->private_value
= val
;
2853 #define AD1988_PIN_CD_NID 0x18
2854 #define AD1988_PIN_BEEP_NID 0x10
2856 static const hda_nid_t ad1988_mixer_nids
[8] = {
2857 /* A B C D E F G H */
2858 0x22, 0x2b, 0x2c, 0x29, 0x26, 0x2a, 0x27, 0x28
2861 static inline hda_nid_t
ad1988_idx_to_dac(struct hda_codec
*codec
, int idx
)
2863 static const hda_nid_t idx_to_dac
[8] = {
2864 /* A B C D E F G H */
2865 0x03, 0x06, 0x05, 0x04, 0x0a, 0x06, 0x05, 0x0a
2867 static const hda_nid_t idx_to_dac_rev2
[8] = {
2868 /* A B C D E F G H */
2869 0x03, 0x05, 0x0a, 0x04, 0x06, 0x05, 0x0a, 0x06
2872 return idx_to_dac_rev2
[idx
];
2874 return idx_to_dac
[idx
];
2877 static const hda_nid_t ad1988_boost_nids
[8] = {
2878 0x38, 0x39, 0x3a, 0x3d, 0x3c, 0x3b, 0, 0
2881 static int ad1988_pin_idx(hda_nid_t nid
)
2883 static const hda_nid_t ad1988_io_pins
[8] = {
2884 0x11, 0x14, 0x15, 0x12, 0x17, 0x16, 0x24, 0x25
2887 for (i
= 0; i
< ARRAY_SIZE(ad1988_io_pins
); i
++)
2888 if (ad1988_io_pins
[i
] == nid
)
2890 return 0; /* should be -1 */
2893 static int ad1988_pin_to_loopback_idx(hda_nid_t nid
)
2895 static const int loopback_idx
[8] = {
2896 2, 0, 1, 3, 4, 5, 1, 4
2899 case AD1988_PIN_CD_NID
:
2902 return loopback_idx
[ad1988_pin_idx(nid
)];
2906 static int ad1988_pin_to_adc_idx(hda_nid_t nid
)
2908 static const int adc_idx
[8] = {
2909 0, 1, 2, 8, 4, 3, 6, 7
2912 case AD1988_PIN_CD_NID
:
2915 return adc_idx
[ad1988_pin_idx(nid
)];
2919 /* fill in the dac_nids table from the parsed pin configuration */
2920 static int ad1988_auto_fill_dac_nids(struct hda_codec
*codec
,
2921 const struct auto_pin_cfg
*cfg
)
2923 struct ad198x_spec
*spec
= codec
->spec
;
2926 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
2928 /* check the pins hardwired to audio widget */
2929 for (i
= 0; i
< cfg
->line_outs
; i
++) {
2930 idx
= ad1988_pin_idx(cfg
->line_out_pins
[i
]);
2931 spec
->private_dac_nids
[i
] = ad1988_idx_to_dac(codec
, idx
);
2933 spec
->multiout
.num_dacs
= cfg
->line_outs
;
2937 /* add playback controls from the parsed DAC table */
2938 static int ad1988_auto_create_multi_out_ctls(struct ad198x_spec
*spec
,
2939 const struct auto_pin_cfg
*cfg
)
2942 static const char * const chname
[4] = {
2943 "Front", "Surround", NULL
/*CLFE*/, "Side"
2948 for (i
= 0; i
< cfg
->line_outs
; i
++) {
2949 hda_nid_t dac
= spec
->multiout
.dac_nids
[i
];
2952 nid
= ad1988_mixer_nids
[ad1988_pin_idx(cfg
->line_out_pins
[i
])];
2955 err
= add_control(spec
, AD_CTL_WIDGET_VOL
,
2956 "Center Playback Volume",
2957 HDA_COMPOSE_AMP_VAL(dac
, 1, 0, HDA_OUTPUT
));
2960 err
= add_control(spec
, AD_CTL_WIDGET_VOL
,
2961 "LFE Playback Volume",
2962 HDA_COMPOSE_AMP_VAL(dac
, 2, 0, HDA_OUTPUT
));
2965 err
= add_control(spec
, AD_CTL_BIND_MUTE
,
2966 "Center Playback Switch",
2967 HDA_COMPOSE_AMP_VAL(nid
, 1, 2, HDA_INPUT
));
2970 err
= add_control(spec
, AD_CTL_BIND_MUTE
,
2971 "LFE Playback Switch",
2972 HDA_COMPOSE_AMP_VAL(nid
, 2, 2, HDA_INPUT
));
2976 sprintf(name
, "%s Playback Volume", chname
[i
]);
2977 err
= add_control(spec
, AD_CTL_WIDGET_VOL
, name
,
2978 HDA_COMPOSE_AMP_VAL(dac
, 3, 0, HDA_OUTPUT
));
2981 sprintf(name
, "%s Playback Switch", chname
[i
]);
2982 err
= add_control(spec
, AD_CTL_BIND_MUTE
, name
,
2983 HDA_COMPOSE_AMP_VAL(nid
, 3, 2, HDA_INPUT
));
2991 /* add playback controls for speaker and HP outputs */
2992 static int ad1988_auto_create_extra_out(struct hda_codec
*codec
, hda_nid_t pin
,
2995 struct ad198x_spec
*spec
= codec
->spec
;
3003 idx
= ad1988_pin_idx(pin
);
3004 nid
= ad1988_idx_to_dac(codec
, idx
);
3005 /* check whether the corresponding DAC was already taken */
3006 for (i
= 0; i
< spec
->autocfg
.line_outs
; i
++) {
3007 hda_nid_t pin
= spec
->autocfg
.line_out_pins
[i
];
3008 hda_nid_t dac
= ad1988_idx_to_dac(codec
, ad1988_pin_idx(pin
));
3012 if (i
>= spec
->autocfg
.line_outs
) {
3013 /* specify the DAC as the extra output */
3014 if (!spec
->multiout
.hp_nid
)
3015 spec
->multiout
.hp_nid
= nid
;
3017 spec
->multiout
.extra_out_nid
[0] = nid
;
3018 /* control HP volume/switch on the output mixer amp */
3019 sprintf(name
, "%s Playback Volume", pfx
);
3020 err
= add_control(spec
, AD_CTL_WIDGET_VOL
, name
,
3021 HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
));
3025 nid
= ad1988_mixer_nids
[idx
];
3026 sprintf(name
, "%s Playback Switch", pfx
);
3027 if ((err
= add_control(spec
, AD_CTL_BIND_MUTE
, name
,
3028 HDA_COMPOSE_AMP_VAL(nid
, 3, 2, HDA_INPUT
))) < 0)
3033 /* create input playback/capture controls for the given pin */
3034 static int new_analog_input(struct ad198x_spec
*spec
, hda_nid_t pin
,
3035 const char *ctlname
, int ctlidx
, int boost
)
3040 sprintf(name
, "%s Playback Volume", ctlname
);
3041 idx
= ad1988_pin_to_loopback_idx(pin
);
3042 if ((err
= add_control(spec
, AD_CTL_WIDGET_VOL
, name
,
3043 HDA_COMPOSE_AMP_VAL(0x20, 3, idx
, HDA_INPUT
))) < 0)
3045 sprintf(name
, "%s Playback Switch", ctlname
);
3046 if ((err
= add_control(spec
, AD_CTL_WIDGET_MUTE
, name
,
3047 HDA_COMPOSE_AMP_VAL(0x20, 3, idx
, HDA_INPUT
))) < 0)
3051 idx
= ad1988_pin_idx(pin
);
3052 bnid
= ad1988_boost_nids
[idx
];
3054 sprintf(name
, "%s Boost Volume", ctlname
);
3055 return add_control(spec
, AD_CTL_WIDGET_VOL
, name
,
3056 HDA_COMPOSE_AMP_VAL(bnid
, 3, idx
, HDA_OUTPUT
));
3063 /* create playback/capture controls for input pins */
3064 static int ad1988_auto_create_analog_input_ctls(struct hda_codec
*codec
,
3065 const struct auto_pin_cfg
*cfg
)
3067 struct ad198x_spec
*spec
= codec
->spec
;
3068 struct hda_input_mux
*imux
= &spec
->private_imux
;
3069 int i
, err
, type
, type_idx
;
3071 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3073 type
= cfg
->inputs
[i
].type
;
3074 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
3075 snd_hda_add_imux_item(imux
, label
,
3076 ad1988_pin_to_adc_idx(cfg
->inputs
[i
].pin
),
3078 err
= new_analog_input(spec
, cfg
->inputs
[i
].pin
,
3080 type
== AUTO_PIN_MIC
);
3084 snd_hda_add_imux_item(imux
, "Mix", 9, NULL
);
3086 if ((err
= add_control(spec
, AD_CTL_WIDGET_VOL
,
3087 "Analog Mix Playback Volume",
3088 HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT
))) < 0)
3090 if ((err
= add_control(spec
, AD_CTL_WIDGET_MUTE
,
3091 "Analog Mix Playback Switch",
3092 HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT
))) < 0)
3098 static void ad1988_auto_set_output_and_unmute(struct hda_codec
*codec
,
3099 hda_nid_t nid
, int pin_type
,
3103 snd_hda_set_pin_ctl(codec
, nid
, pin_type
);
3104 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
);
3106 case 0x11: /* port-A - DAC 03 */
3107 snd_hda_codec_write(codec
, 0x37, 0, AC_VERB_SET_CONNECT_SEL
, 0x00);
3109 case 0x14: /* port-B - DAC 06 */
3110 snd_hda_codec_write(codec
, 0x30, 0, AC_VERB_SET_CONNECT_SEL
, 0x02);
3112 case 0x15: /* port-C - DAC 05 */
3113 snd_hda_codec_write(codec
, 0x31, 0, AC_VERB_SET_CONNECT_SEL
, 0x00);
3115 case 0x17: /* port-E - DAC 0a */
3116 snd_hda_codec_write(codec
, 0x32, 0, AC_VERB_SET_CONNECT_SEL
, 0x01);
3118 case 0x13: /* mono - DAC 04 */
3119 snd_hda_codec_write(codec
, 0x36, 0, AC_VERB_SET_CONNECT_SEL
, 0x01);
3124 static void ad1988_auto_init_multi_out(struct hda_codec
*codec
)
3126 struct ad198x_spec
*spec
= codec
->spec
;
3129 for (i
= 0; i
< spec
->autocfg
.line_outs
; i
++) {
3130 hda_nid_t nid
= spec
->autocfg
.line_out_pins
[i
];
3131 ad1988_auto_set_output_and_unmute(codec
, nid
, PIN_OUT
, i
);
3135 static void ad1988_auto_init_extra_out(struct hda_codec
*codec
)
3137 struct ad198x_spec
*spec
= codec
->spec
;
3140 pin
= spec
->autocfg
.speaker_pins
[0];
3141 if (pin
) /* connect to front */
3142 ad1988_auto_set_output_and_unmute(codec
, pin
, PIN_OUT
, 0);
3143 pin
= spec
->autocfg
.hp_pins
[0];
3144 if (pin
) /* connect to front */
3145 ad1988_auto_set_output_and_unmute(codec
, pin
, PIN_HP
, 0);
3148 static void ad1988_auto_init_analog_input(struct hda_codec
*codec
)
3150 struct ad198x_spec
*spec
= codec
->spec
;
3151 const struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3154 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3155 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
3156 int type
= cfg
->inputs
[i
].type
;
3159 case 0x15: /* port-C */
3160 snd_hda_codec_write(codec
, 0x33, 0, AC_VERB_SET_CONNECT_SEL
, 0x0);
3162 case 0x17: /* port-E */
3163 snd_hda_codec_write(codec
, 0x34, 0, AC_VERB_SET_CONNECT_SEL
, 0x0);
3167 if (type
== AUTO_PIN_MIC
)
3168 val
|= snd_hda_get_default_vref(codec
, nid
);
3169 snd_hda_set_pin_ctl(codec
, nid
, val
);
3170 if (nid
!= AD1988_PIN_CD_NID
)
3171 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3173 idx
= ad1988_pin_idx(nid
);
3174 if (ad1988_boost_nids
[idx
])
3175 snd_hda_codec_write(codec
, ad1988_boost_nids
[idx
], 0,
3176 AC_VERB_SET_AMP_GAIN_MUTE
,
3181 /* parse the BIOS configuration and set up the alc_spec */
3182 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
3183 static int ad1988_parse_auto_config(struct hda_codec
*codec
)
3185 struct ad198x_spec
*spec
= codec
->spec
;
3188 if ((err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
)) < 0)
3190 if ((err
= ad1988_auto_fill_dac_nids(codec
, &spec
->autocfg
)) < 0)
3192 if (! spec
->autocfg
.line_outs
)
3193 return 0; /* can't find valid BIOS pin config */
3194 if ((err
= ad1988_auto_create_multi_out_ctls(spec
, &spec
->autocfg
)) < 0 ||
3195 (err
= ad1988_auto_create_extra_out(codec
,
3196 spec
->autocfg
.speaker_pins
[0],
3198 (err
= ad1988_auto_create_extra_out(codec
, spec
->autocfg
.hp_pins
[0],
3199 "Headphone")) < 0 ||
3200 (err
= ad1988_auto_create_analog_input_ctls(codec
, &spec
->autocfg
)) < 0)
3203 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
3205 if (spec
->autocfg
.dig_outs
)
3206 spec
->multiout
.dig_out_nid
= AD1988_SPDIF_OUT
;
3207 if (spec
->autocfg
.dig_in_pin
)
3208 spec
->dig_in_nid
= AD1988_SPDIF_IN
;
3210 if (spec
->kctls
.list
)
3211 spec
->mixers
[spec
->num_mixers
++] = spec
->kctls
.list
;
3213 spec
->init_verbs
[spec
->num_init_verbs
++] = ad1988_6stack_init_verbs
;
3215 spec
->input_mux
= &spec
->private_imux
;
3220 /* init callback for auto-configuration model -- overriding the default init */
3221 static int ad1988_auto_init(struct hda_codec
*codec
)
3224 ad1988_auto_init_multi_out(codec
);
3225 ad1988_auto_init_extra_out(codec
);
3226 ad1988_auto_init_analog_input(codec
);
3233 static const char * const ad1988_models
[AD1988_MODEL_LAST
] = {
3234 [AD1988_6STACK
] = "6stack",
3235 [AD1988_6STACK_DIG
] = "6stack-dig",
3236 [AD1988_3STACK
] = "3stack",
3237 [AD1988_3STACK_DIG
] = "3stack-dig",
3238 [AD1988_LAPTOP
] = "laptop",
3239 [AD1988_LAPTOP_DIG
] = "laptop-dig",
3240 [AD1988_AUTO
] = "auto",
3243 static const struct snd_pci_quirk ad1988_cfg_tbl
[] = {
3244 SND_PCI_QUIRK(0x1043, 0x81ec, "Asus P5B-DLX", AD1988_6STACK_DIG
),
3245 SND_PCI_QUIRK(0x1043, 0x81f6, "Asus M2N-SLI", AD1988_6STACK_DIG
),
3246 SND_PCI_QUIRK(0x1043, 0x8277, "Asus P5K-E/WIFI-AP", AD1988_6STACK_DIG
),
3247 SND_PCI_QUIRK(0x1043, 0x82c0, "Asus M3N-HT Deluxe", AD1988_6STACK_DIG
),
3248 SND_PCI_QUIRK(0x1043, 0x8311, "Asus P5Q-Premium/Pro", AD1988_6STACK_DIG
),
3252 static int patch_ad1988(struct hda_codec
*codec
)
3254 struct ad198x_spec
*spec
;
3255 int err
, board_config
;
3257 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
3264 snd_printk(KERN_INFO
"patch_analog: AD1988A rev.2 is detected, enable workarounds\n");
3266 board_config
= snd_hda_check_board_config(codec
, AD1988_MODEL_LAST
,
3267 ad1988_models
, ad1988_cfg_tbl
);
3268 if (board_config
< 0) {
3269 printk(KERN_INFO
"hda_codec: %s: BIOS auto-probing.\n",
3271 board_config
= AD1988_AUTO
;
3274 if (board_config
== AD1988_AUTO
) {
3275 /* automatic parse from the BIOS config */
3276 err
= ad1988_parse_auto_config(codec
);
3281 printk(KERN_INFO
"hda_codec: Cannot set up configuration from BIOS. Using 6-stack mode...\n");
3282 board_config
= AD1988_6STACK
;
3286 err
= snd_hda_attach_beep_device(codec
, 0x10);
3291 set_beep_amp(spec
, 0x10, 0, HDA_OUTPUT
);
3293 if (!spec
->multiout
.hp_nid
)
3294 spec
->multiout
.hp_nid
= ad1988_alt_dac_nid
[0];
3295 switch (board_config
) {
3297 case AD1988_6STACK_DIG
:
3298 spec
->multiout
.max_channels
= 8;
3299 spec
->multiout
.num_dacs
= 4;
3301 spec
->multiout
.dac_nids
= ad1988_6stack_dac_nids_rev2
;
3303 spec
->multiout
.dac_nids
= ad1988_6stack_dac_nids
;
3304 spec
->input_mux
= &ad1988_6stack_capture_source
;
3305 spec
->num_mixers
= 2;
3307 spec
->mixers
[0] = ad1988_6stack_mixers1_rev2
;
3309 spec
->mixers
[0] = ad1988_6stack_mixers1
;
3310 spec
->mixers
[1] = ad1988_6stack_mixers2
;
3311 spec
->num_init_verbs
= 1;
3312 spec
->init_verbs
[0] = ad1988_6stack_init_verbs
;
3313 if (board_config
== AD1988_6STACK_DIG
) {
3314 spec
->multiout
.dig_out_nid
= AD1988_SPDIF_OUT
;
3315 spec
->dig_in_nid
= AD1988_SPDIF_IN
;
3319 case AD1988_3STACK_DIG
:
3320 spec
->multiout
.max_channels
= 6;
3321 spec
->multiout
.num_dacs
= 3;
3323 spec
->multiout
.dac_nids
= ad1988_3stack_dac_nids_rev2
;
3325 spec
->multiout
.dac_nids
= ad1988_3stack_dac_nids
;
3326 spec
->input_mux
= &ad1988_6stack_capture_source
;
3327 spec
->channel_mode
= ad1988_3stack_modes
;
3328 spec
->num_channel_mode
= ARRAY_SIZE(ad1988_3stack_modes
);
3329 spec
->num_mixers
= 2;
3331 spec
->mixers
[0] = ad1988_3stack_mixers1_rev2
;
3333 spec
->mixers
[0] = ad1988_3stack_mixers1
;
3334 spec
->mixers
[1] = ad1988_3stack_mixers2
;
3335 spec
->num_init_verbs
= 1;
3336 spec
->init_verbs
[0] = ad1988_3stack_init_verbs
;
3337 if (board_config
== AD1988_3STACK_DIG
)
3338 spec
->multiout
.dig_out_nid
= AD1988_SPDIF_OUT
;
3341 case AD1988_LAPTOP_DIG
:
3342 spec
->multiout
.max_channels
= 2;
3343 spec
->multiout
.num_dacs
= 1;
3344 spec
->multiout
.dac_nids
= ad1988_3stack_dac_nids
;
3345 spec
->input_mux
= &ad1988_laptop_capture_source
;
3346 spec
->num_mixers
= 1;
3347 spec
->mixers
[0] = ad1988_laptop_mixers
;
3348 spec
->inv_eapd
= 1; /* inverted EAPD */
3349 spec
->num_init_verbs
= 1;
3350 spec
->init_verbs
[0] = ad1988_laptop_init_verbs
;
3351 if (board_config
== AD1988_LAPTOP_DIG
)
3352 spec
->multiout
.dig_out_nid
= AD1988_SPDIF_OUT
;
3356 if (spec
->autocfg
.hp_pins
[0]) {
3357 spec
->mixers
[spec
->num_mixers
++] = ad1988_hp_mixers
;
3358 spec
->slave_vols
= ad1988_6stack_fp_slave_pfxs
;
3359 spec
->slave_sws
= ad1988_6stack_fp_slave_pfxs
;
3360 spec
->alt_dac_nid
= ad1988_alt_dac_nid
;
3361 spec
->stream_analog_alt_playback
=
3362 &ad198x_pcm_analog_alt_playback
;
3365 spec
->num_adc_nids
= ARRAY_SIZE(ad1988_adc_nids
);
3366 spec
->adc_nids
= ad1988_adc_nids
;
3367 spec
->capsrc_nids
= ad1988_capsrc_nids
;
3368 spec
->mixers
[spec
->num_mixers
++] = ad1988_capture_mixers
;
3369 spec
->init_verbs
[spec
->num_init_verbs
++] = ad1988_capture_init_verbs
;
3370 if (spec
->multiout
.dig_out_nid
) {
3371 if (codec
->vendor_id
>= 0x11d4989a) {
3372 spec
->mixers
[spec
->num_mixers
++] =
3373 ad1989_spdif_out_mixers
;
3374 spec
->init_verbs
[spec
->num_init_verbs
++] =
3375 ad1989_spdif_init_verbs
;
3376 codec
->slave_dig_outs
= ad1989b_slave_dig_outs
;
3378 spec
->mixers
[spec
->num_mixers
++] =
3379 ad1988_spdif_out_mixers
;
3380 spec
->init_verbs
[spec
->num_init_verbs
++] =
3381 ad1988_spdif_init_verbs
;
3384 if (spec
->dig_in_nid
&& codec
->vendor_id
< 0x11d4989a) {
3385 spec
->mixers
[spec
->num_mixers
++] = ad1988_spdif_in_mixers
;
3386 spec
->init_verbs
[spec
->num_init_verbs
++] =
3387 ad1988_spdif_in_init_verbs
;
3390 codec
->patch_ops
= ad198x_patch_ops
;
3391 switch (board_config
) {
3393 codec
->patch_ops
.init
= ad1988_auto_init
;
3396 case AD1988_LAPTOP_DIG
:
3397 codec
->patch_ops
.unsol_event
= ad1988_laptop_unsol_event
;
3401 spec
->loopback
.amplist
= ad1988_loopbacks
;
3403 spec
->vmaster_nid
= 0x04;
3405 codec
->no_trigger_sense
= 1;
3406 codec
->no_sticky_stream
= 1;
3415 * port-B - front line/mic-in
3416 * port-E - aux in/out
3417 * port-F - aux in/out
3418 * port-C - rear line/mic-in
3419 * port-D - rear line/hp-out
3420 * port-A - front line/hp-out
3422 * AD1984 = AD1884 + two digital mic-ins
3425 * For simplicity, we share the single DAC for both HP and line-outs
3426 * right now. The inidividual playbacks could be easily implemented,
3427 * but no build-up framework is given, so far.
3430 static const hda_nid_t ad1884_dac_nids
[1] = {
3434 static const hda_nid_t ad1884_adc_nids
[2] = {
3438 static const hda_nid_t ad1884_capsrc_nids
[2] = {
3442 #define AD1884_SPDIF_OUT 0x02
3444 static const struct hda_input_mux ad1884_capture_source
= {
3447 { "Front Mic", 0x0 },
3454 static const struct snd_kcontrol_new ad1884_base_mixers
[] = {
3455 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
3456 /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */
3457 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
3458 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
3459 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT
),
3460 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT
),
3461 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT
),
3462 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT
),
3463 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT
),
3464 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT
),
3465 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT
),
3466 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT
),
3467 HDA_CODEC_VOLUME("Mic Boost Volume", 0x15, 0x0, HDA_INPUT
),
3468 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x14, 0x0, HDA_INPUT
),
3469 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
3470 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
3471 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT
),
3472 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT
),
3474 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3475 /* The multiple "Capture Source" controls confuse alsamixer
3476 * So call somewhat different..
3478 /* .name = "Capture Source", */
3479 .name
= "Input Source",
3481 .info
= ad198x_mux_enum_info
,
3482 .get
= ad198x_mux_enum_get
,
3483 .put
= ad198x_mux_enum_put
,
3485 /* SPDIF controls */
3486 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
3488 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3489 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,NONE
) "Source",
3490 /* identical with ad1983 */
3491 .info
= ad1983_spdif_route_info
,
3492 .get
= ad1983_spdif_route_get
,
3493 .put
= ad1983_spdif_route_put
,
3498 static const struct snd_kcontrol_new ad1984_dmic_mixers
[] = {
3499 HDA_CODEC_VOLUME("Digital Mic Capture Volume", 0x05, 0x0, HDA_INPUT
),
3500 HDA_CODEC_MUTE("Digital Mic Capture Switch", 0x05, 0x0, HDA_INPUT
),
3501 HDA_CODEC_VOLUME_IDX("Digital Mic Capture Volume", 1, 0x06, 0x0,
3503 HDA_CODEC_MUTE_IDX("Digital Mic Capture Switch", 1, 0x06, 0x0,
3509 * initialization verbs
3511 static const struct hda_verb ad1884_init_verbs
[] = {
3512 /* DACs; mute as default */
3513 {0x03, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
3514 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
3515 /* Port-A (HP) mixer */
3516 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3517 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3519 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
3520 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3521 /* HP selector - select DAC2 */
3522 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x1},
3523 /* Port-D (Line-out) mixer */
3524 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3525 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3527 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
3528 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3529 /* Mono-out mixer */
3530 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3531 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3533 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
3534 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3536 {0x0e, AC_VERB_SET_CONNECT_SEL
, 0x1},
3537 /* Port-B (front mic) pin */
3538 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
3539 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3540 /* Port-C (rear mic) pin */
3541 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
3542 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3543 /* Analog mixer; mute as default */
3544 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3545 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
3546 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
3547 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
3548 /* Analog Mix output amp */
3549 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x1f}, /* 0dB */
3550 /* SPDIF output selector */
3551 {0x02, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* PCM */
3552 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x27}, /* 0dB */
3557 static const struct hda_amp_list ad1884_loopbacks
[] = {
3558 { 0x20, HDA_INPUT
, 0 }, /* Front Mic */
3559 { 0x20, HDA_INPUT
, 1 }, /* Mic */
3560 { 0x20, HDA_INPUT
, 2 }, /* CD */
3561 { 0x20, HDA_INPUT
, 4 }, /* Docking */
3566 static const char * const ad1884_slave_vols
[] = {
3567 "PCM", "Mic", "Mono", "Front Mic", "Mic", "CD",
3568 "Internal Mic", "Dock Mic", /* "Beep", */ "IEC958",
3572 static int patch_ad1884(struct hda_codec
*codec
)
3574 struct ad198x_spec
*spec
;
3577 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
3583 err
= snd_hda_attach_beep_device(codec
, 0x10);
3588 set_beep_amp(spec
, 0x10, 0, HDA_OUTPUT
);
3590 spec
->multiout
.max_channels
= 2;
3591 spec
->multiout
.num_dacs
= ARRAY_SIZE(ad1884_dac_nids
);
3592 spec
->multiout
.dac_nids
= ad1884_dac_nids
;
3593 spec
->multiout
.dig_out_nid
= AD1884_SPDIF_OUT
;
3594 spec
->num_adc_nids
= ARRAY_SIZE(ad1884_adc_nids
);
3595 spec
->adc_nids
= ad1884_adc_nids
;
3596 spec
->capsrc_nids
= ad1884_capsrc_nids
;
3597 spec
->input_mux
= &ad1884_capture_source
;
3598 spec
->num_mixers
= 1;
3599 spec
->mixers
[0] = ad1884_base_mixers
;
3600 spec
->num_init_verbs
= 1;
3601 spec
->init_verbs
[0] = ad1884_init_verbs
;
3602 spec
->spdif_route
= 0;
3604 spec
->loopback
.amplist
= ad1884_loopbacks
;
3606 spec
->vmaster_nid
= 0x04;
3607 /* we need to cover all playback volumes */
3608 spec
->slave_vols
= ad1884_slave_vols
;
3609 /* slaves may contain input volumes, so we can't raise to 0dB blindly */
3610 spec
->avoid_init_slave_vol
= 1;
3612 codec
->patch_ops
= ad198x_patch_ops
;
3614 codec
->no_trigger_sense
= 1;
3615 codec
->no_sticky_stream
= 1;
3621 * Lenovo Thinkpad T61/X61
3623 static const struct hda_input_mux ad1984_thinkpad_capture_source
= {
3627 { "Internal Mic", 0x1 },
3629 { "Dock Mic", 0x4 },
3635 * Dell Precision T3400
3637 static const struct hda_input_mux ad1984_dell_desktop_capture_source
= {
3640 { "Front Mic", 0x0 },
3647 static const struct snd_kcontrol_new ad1984_thinkpad_mixers
[] = {
3648 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
3649 /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */
3650 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
3651 HDA_CODEC_MUTE("Speaker Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
3652 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT
),
3653 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT
),
3654 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x20, 0x01, HDA_INPUT
),
3655 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT
),
3656 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT
),
3657 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT
),
3658 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x20, 0x04, HDA_INPUT
),
3659 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x20, 0x04, HDA_INPUT
),
3660 HDA_CODEC_VOLUME("Mic Boost Volume", 0x14, 0x0, HDA_INPUT
),
3661 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x15, 0x0, HDA_INPUT
),
3662 HDA_CODEC_VOLUME("Dock Mic Boost Volume", 0x25, 0x0, HDA_OUTPUT
),
3663 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
3664 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
3665 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT
),
3666 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT
),
3668 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3669 /* The multiple "Capture Source" controls confuse alsamixer
3670 * So call somewhat different..
3672 /* .name = "Capture Source", */
3673 .name
= "Input Source",
3675 .info
= ad198x_mux_enum_info
,
3676 .get
= ad198x_mux_enum_get
,
3677 .put
= ad198x_mux_enum_put
,
3679 /* SPDIF controls */
3680 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
3682 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3683 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,NONE
) "Source",
3684 /* identical with ad1983 */
3685 .info
= ad1983_spdif_route_info
,
3686 .get
= ad1983_spdif_route_get
,
3687 .put
= ad1983_spdif_route_put
,
3692 /* additional verbs */
3693 static const struct hda_verb ad1984_thinkpad_init_verbs
[] = {
3694 /* Port-E (docking station mic) pin */
3695 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
3696 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3697 /* docking mic boost */
3698 {0x25, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
3699 /* Analog PC Beeper - allow firmware/ACPI beeps */
3700 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(3) | 0x1a},
3701 /* Analog mixer - docking mic; mute as default */
3702 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
3703 /* enable EAPD bit */
3704 {0x12, AC_VERB_SET_EAPD_BTLENABLE
, 0x02},
3709 * Dell Precision T3400
3711 static const struct snd_kcontrol_new ad1984_dell_desktop_mixers
[] = {
3712 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
3713 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
3714 HDA_CODEC_MUTE("Speaker Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
3715 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT
),
3716 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT
),
3717 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT
),
3718 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT
),
3719 HDA_CODEC_VOLUME("Line-In Playback Volume", 0x20, 0x01, HDA_INPUT
),
3720 HDA_CODEC_MUTE("Line-In Playback Switch", 0x20, 0x01, HDA_INPUT
),
3721 HDA_CODEC_VOLUME("Line-In Boost Volume", 0x15, 0x0, HDA_INPUT
),
3722 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x14, 0x0, HDA_INPUT
),
3723 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
3724 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
3725 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT
),
3726 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT
),
3728 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3729 /* The multiple "Capture Source" controls confuse alsamixer
3730 * So call somewhat different..
3732 /* .name = "Capture Source", */
3733 .name
= "Input Source",
3735 .info
= ad198x_mux_enum_info
,
3736 .get
= ad198x_mux_enum_get
,
3737 .put
= ad198x_mux_enum_put
,
3742 /* Digial MIC ADC NID 0x05 + 0x06 */
3743 static int ad1984_pcm_dmic_prepare(struct hda_pcm_stream
*hinfo
,
3744 struct hda_codec
*codec
,
3745 unsigned int stream_tag
,
3746 unsigned int format
,
3747 struct snd_pcm_substream
*substream
)
3749 snd_hda_codec_setup_stream(codec
, 0x05 + substream
->number
,
3750 stream_tag
, 0, format
);
3754 static int ad1984_pcm_dmic_cleanup(struct hda_pcm_stream
*hinfo
,
3755 struct hda_codec
*codec
,
3756 struct snd_pcm_substream
*substream
)
3758 snd_hda_codec_cleanup_stream(codec
, 0x05 + substream
->number
);
3762 static const struct hda_pcm_stream ad1984_pcm_dmic_capture
= {
3768 .prepare
= ad1984_pcm_dmic_prepare
,
3769 .cleanup
= ad1984_pcm_dmic_cleanup
3773 static int ad1984_build_pcms(struct hda_codec
*codec
)
3775 struct ad198x_spec
*spec
= codec
->spec
;
3776 struct hda_pcm
*info
;
3779 err
= ad198x_build_pcms(codec
);
3783 info
= spec
->pcm_rec
+ codec
->num_pcms
;
3785 info
->name
= "AD1984 Digital Mic";
3786 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = ad1984_pcm_dmic_capture
;
3794 AD1984_DELL_DESKTOP
,
3798 static const char * const ad1984_models
[AD1984_MODELS
] = {
3799 [AD1984_BASIC
] = "basic",
3800 [AD1984_THINKPAD
] = "thinkpad",
3801 [AD1984_DELL_DESKTOP
] = "dell_desktop",
3804 static const struct snd_pci_quirk ad1984_cfg_tbl
[] = {
3805 /* Lenovo Thinkpad T61/X61 */
3806 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo Thinkpad", AD1984_THINKPAD
),
3807 SND_PCI_QUIRK(0x1028, 0x0214, "Dell T3400", AD1984_DELL_DESKTOP
),
3808 SND_PCI_QUIRK(0x1028, 0x0233, "Dell Latitude E6400", AD1984_DELL_DESKTOP
),
3812 static int patch_ad1984(struct hda_codec
*codec
)
3814 struct ad198x_spec
*spec
;
3815 int board_config
, err
;
3817 err
= patch_ad1884(codec
);
3821 board_config
= snd_hda_check_board_config(codec
, AD1984_MODELS
,
3822 ad1984_models
, ad1984_cfg_tbl
);
3823 switch (board_config
) {
3825 /* additional digital mics */
3826 spec
->mixers
[spec
->num_mixers
++] = ad1984_dmic_mixers
;
3827 codec
->patch_ops
.build_pcms
= ad1984_build_pcms
;
3829 case AD1984_THINKPAD
:
3830 if (codec
->subsystem_id
== 0x17aa20fb) {
3831 /* Thinpad X300 does not have the ability to do SPDIF,
3832 or attach to docking station to use SPDIF */
3833 spec
->multiout
.dig_out_nid
= 0;
3835 spec
->multiout
.dig_out_nid
= AD1884_SPDIF_OUT
;
3836 spec
->input_mux
= &ad1984_thinkpad_capture_source
;
3837 spec
->mixers
[0] = ad1984_thinkpad_mixers
;
3838 spec
->init_verbs
[spec
->num_init_verbs
++] = ad1984_thinkpad_init_verbs
;
3839 spec
->analog_beep
= 1;
3841 case AD1984_DELL_DESKTOP
:
3842 spec
->multiout
.dig_out_nid
= 0;
3843 spec
->input_mux
= &ad1984_dell_desktop_capture_source
;
3844 spec
->mixers
[0] = ad1984_dell_desktop_mixers
;
3852 * AD1883 / AD1884A / AD1984A / AD1984B
3854 * port-B (0x14) - front mic-in
3855 * port-E (0x1c) - rear mic-in
3856 * port-F (0x16) - CD / ext out
3857 * port-C (0x15) - rear line-in
3858 * port-D (0x12) - rear line-out
3859 * port-A (0x11) - front hp-out
3861 * AD1984A = AD1884A + digital-mic
3862 * AD1883 = equivalent with AD1984A
3863 * AD1984B = AD1984A + extra SPDIF-out
3866 * We share the single DAC for both HP and line-outs (see AD1884/1984).
3869 static const hda_nid_t ad1884a_dac_nids
[1] = {
3873 #define ad1884a_adc_nids ad1884_adc_nids
3874 #define ad1884a_capsrc_nids ad1884_capsrc_nids
3876 #define AD1884A_SPDIF_OUT 0x02
3878 static const struct hda_input_mux ad1884a_capture_source
= {
3881 { "Front Mic", 0x0 },
3889 static const struct snd_kcontrol_new ad1884a_base_mixers
[] = {
3890 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT
),
3891 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT
),
3892 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
3893 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
3894 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT
),
3895 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT
),
3896 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT
),
3897 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT
),
3898 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT
),
3899 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT
),
3900 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x01, HDA_INPUT
),
3901 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x01, HDA_INPUT
),
3902 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x04, HDA_INPUT
),
3903 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x04, HDA_INPUT
),
3904 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT
),
3905 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT
),
3906 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x14, 0x0, HDA_INPUT
),
3907 HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x0, HDA_INPUT
),
3908 HDA_CODEC_VOLUME("Mic Boost Volume", 0x25, 0x0, HDA_OUTPUT
),
3909 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
3910 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
3911 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT
),
3912 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT
),
3914 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3915 /* The multiple "Capture Source" controls confuse alsamixer
3916 * So call somewhat different..
3918 /* .name = "Capture Source", */
3919 .name
= "Input Source",
3921 .info
= ad198x_mux_enum_info
,
3922 .get
= ad198x_mux_enum_get
,
3923 .put
= ad198x_mux_enum_put
,
3925 /* SPDIF controls */
3926 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
3928 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3929 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,NONE
) "Source",
3930 /* identical with ad1983 */
3931 .info
= ad1983_spdif_route_info
,
3932 .get
= ad1983_spdif_route_get
,
3933 .put
= ad1983_spdif_route_put
,
3939 * initialization verbs
3941 static const struct hda_verb ad1884a_init_verbs
[] = {
3942 /* DACs; unmute as default */
3943 {0x03, AC_VERB_SET_AMP_GAIN_MUTE
, 0x27}, /* 0dB */
3944 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, 0x27}, /* 0dB */
3945 /* Port-A (HP) mixer - route only from analog mixer */
3946 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3947 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3949 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
3950 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3951 /* Port-D (Line-out) mixer - route only from analog mixer */
3952 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3953 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3955 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
3956 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3957 /* Mono-out mixer - route only from analog mixer */
3958 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3959 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3961 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
3962 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3963 /* Port-B (front mic) pin */
3964 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
3965 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3966 /* Port-C (rear line-in) pin */
3967 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
3968 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3969 /* Port-E (rear mic) pin */
3970 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
3971 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3972 {0x25, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
}, /* no boost */
3973 /* Port-F (CD) pin */
3974 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
3975 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3976 /* Analog mixer; mute as default */
3977 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3978 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
3979 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
3980 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
3981 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(4)}, /* aux */
3982 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)},
3983 /* Analog Mix output amp */
3984 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3985 /* capture sources */
3986 {0x0c, AC_VERB_SET_CONNECT_SEL
, 0x0},
3987 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3988 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x0},
3989 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3990 /* SPDIF output amp */
3991 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x27}, /* 0dB */
3996 static const struct hda_amp_list ad1884a_loopbacks
[] = {
3997 { 0x20, HDA_INPUT
, 0 }, /* Front Mic */
3998 { 0x20, HDA_INPUT
, 1 }, /* Mic */
3999 { 0x20, HDA_INPUT
, 2 }, /* CD */
4000 { 0x20, HDA_INPUT
, 4 }, /* Docking */
4008 * Port A: Headphone jack
4010 * Port C: Internal MIC
4011 * Port D: Dock Line Out (if enabled)
4012 * Port E: Dock Line In (if enabled)
4013 * Port F: Internal speakers
4016 static int ad1884a_mobile_master_sw_put(struct snd_kcontrol
*kcontrol
,
4017 struct snd_ctl_elem_value
*ucontrol
)
4019 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
4020 int ret
= snd_hda_mixer_amp_switch_put(kcontrol
, ucontrol
);
4021 int mute
= (!ucontrol
->value
.integer
.value
[0] &&
4022 !ucontrol
->value
.integer
.value
[1]);
4023 /* toggle GPIO1 according to the mute state */
4024 snd_hda_codec_write_cache(codec
, 0x01, 0, AC_VERB_SET_GPIO_DATA
,
4029 static const struct snd_kcontrol_new ad1884a_laptop_mixers
[] = {
4030 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT
),
4032 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4033 .name
= "Master Playback Switch",
4034 .subdevice
= HDA_SUBDEV_AMP_FLAG
,
4035 .info
= snd_hda_mixer_amp_switch_info
,
4036 .get
= snd_hda_mixer_amp_switch_get
,
4037 .put
= ad1884a_mobile_master_sw_put
,
4038 .private_value
= HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT
),
4040 HDA_CODEC_MUTE("Dock Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
4041 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT
),
4042 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT
),
4043 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT
),
4044 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT
),
4045 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x20, 0x01, HDA_INPUT
),
4046 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT
),
4047 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x20, 0x04, HDA_INPUT
),
4048 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x20, 0x04, HDA_INPUT
),
4049 HDA_CODEC_VOLUME("Mic Boost Volume", 0x14, 0x0, HDA_INPUT
),
4050 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x15, 0x0, HDA_INPUT
),
4051 HDA_CODEC_VOLUME("Dock Mic Boost Volume", 0x25, 0x0, HDA_OUTPUT
),
4052 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
4053 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
4057 static const struct snd_kcontrol_new ad1884a_mobile_mixers
[] = {
4058 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT
),
4059 /*HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),*/
4061 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4062 .name
= "Master Playback Switch",
4063 .subdevice
= HDA_SUBDEV_AMP_FLAG
,
4064 .info
= snd_hda_mixer_amp_switch_info
,
4065 .get
= snd_hda_mixer_amp_switch_get
,
4066 .put
= ad1884a_mobile_master_sw_put
,
4067 .private_value
= HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT
),
4069 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT
),
4070 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT
),
4071 HDA_CODEC_VOLUME("Mic Capture Volume", 0x14, 0x0, HDA_INPUT
),
4072 HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x15, 0x0, HDA_INPUT
),
4073 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
4074 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
4078 /* mute internal speaker if HP is plugged */
4079 static void ad1884a_hp_automute(struct hda_codec
*codec
)
4081 unsigned int present
;
4083 present
= snd_hda_jack_detect(codec
, 0x11);
4084 snd_hda_codec_amp_stereo(codec
, 0x16, HDA_OUTPUT
, 0,
4085 HDA_AMP_MUTE
, present
? HDA_AMP_MUTE
: 0);
4086 snd_hda_codec_write(codec
, 0x16, 0, AC_VERB_SET_EAPD_BTLENABLE
,
4087 present
? 0x00 : 0x02);
4090 /* switch to external mic if plugged */
4091 static void ad1884a_hp_automic(struct hda_codec
*codec
)
4093 unsigned int present
;
4095 present
= snd_hda_jack_detect(codec
, 0x14);
4096 snd_hda_codec_write(codec
, 0x0c, 0, AC_VERB_SET_CONNECT_SEL
,
4100 #define AD1884A_HP_EVENT 0x37
4101 #define AD1884A_MIC_EVENT 0x36
4103 /* unsolicited event for HP jack sensing */
4104 static void ad1884a_hp_unsol_event(struct hda_codec
*codec
, unsigned int res
)
4106 switch (res
>> 26) {
4107 case AD1884A_HP_EVENT
:
4108 ad1884a_hp_automute(codec
);
4110 case AD1884A_MIC_EVENT
:
4111 ad1884a_hp_automic(codec
);
4116 /* initialize jack-sensing, too */
4117 static int ad1884a_hp_init(struct hda_codec
*codec
)
4120 ad1884a_hp_automute(codec
);
4121 ad1884a_hp_automic(codec
);
4125 /* mute internal speaker if HP or docking HP is plugged */
4126 static void ad1884a_laptop_automute(struct hda_codec
*codec
)
4128 unsigned int present
;
4130 present
= snd_hda_jack_detect(codec
, 0x11);
4132 present
= snd_hda_jack_detect(codec
, 0x12);
4133 snd_hda_codec_amp_stereo(codec
, 0x16, HDA_OUTPUT
, 0,
4134 HDA_AMP_MUTE
, present
? HDA_AMP_MUTE
: 0);
4135 snd_hda_codec_write(codec
, 0x16, 0, AC_VERB_SET_EAPD_BTLENABLE
,
4136 present
? 0x00 : 0x02);
4139 /* switch to external mic if plugged */
4140 static void ad1884a_laptop_automic(struct hda_codec
*codec
)
4144 if (snd_hda_jack_detect(codec
, 0x14))
4146 else if (snd_hda_jack_detect(codec
, 0x1c))
4150 snd_hda_codec_write(codec
, 0x0c, 0, AC_VERB_SET_CONNECT_SEL
, idx
);
4153 /* unsolicited event for HP jack sensing */
4154 static void ad1884a_laptop_unsol_event(struct hda_codec
*codec
,
4157 switch (res
>> 26) {
4158 case AD1884A_HP_EVENT
:
4159 ad1884a_laptop_automute(codec
);
4161 case AD1884A_MIC_EVENT
:
4162 ad1884a_laptop_automic(codec
);
4167 /* initialize jack-sensing, too */
4168 static int ad1884a_laptop_init(struct hda_codec
*codec
)
4171 ad1884a_laptop_automute(codec
);
4172 ad1884a_laptop_automic(codec
);
4176 /* additional verbs for laptop model */
4177 static const struct hda_verb ad1884a_laptop_verbs
[] = {
4178 /* Port-A (HP) pin - always unmuted */
4179 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
4180 /* Port-F (int speaker) mixer - route only from analog mixer */
4181 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4182 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4183 /* Port-F (int speaker) pin */
4184 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
4185 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4186 /* required for compaq 6530s/6531s speaker output */
4187 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
4188 /* Port-C pin - internal mic-in */
4189 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
4190 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0x7002}, /* raise mic as default */
4191 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, 0x7002}, /* raise mic as default */
4192 /* Port-D (docking line-out) pin - default unmuted */
4193 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
4195 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
4196 /* unsolicited event for pin-sense */
4197 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1884A_HP_EVENT
},
4198 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1884A_HP_EVENT
},
4199 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1884A_MIC_EVENT
},
4200 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1884A_MIC_EVENT
},
4201 /* allow to touch GPIO1 (for mute control) */
4202 {0x01, AC_VERB_SET_GPIO_MASK
, 0x02},
4203 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x02},
4204 {0x01, AC_VERB_SET_GPIO_DATA
, 0x02}, /* first muted */
4208 static const struct hda_verb ad1884a_mobile_verbs
[] = {
4209 /* DACs; unmute as default */
4210 {0x03, AC_VERB_SET_AMP_GAIN_MUTE
, 0x27}, /* 0dB */
4211 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, 0x27}, /* 0dB */
4212 /* Port-A (HP) mixer - route only from analog mixer */
4213 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4214 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4216 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
4217 /* Port-A (HP) pin - always unmuted */
4218 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
4219 /* Port-B (mic jack) pin */
4220 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
4221 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0x7002}, /* raise mic as default */
4222 /* Port-C (int mic) pin */
4223 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
4224 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, 0x7002}, /* raise mic as default */
4225 /* Port-F (int speaker) mixer - route only from analog mixer */
4226 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4227 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4229 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
4230 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4231 /* Analog mixer; mute as default */
4232 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4233 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4234 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
4235 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
4236 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
4237 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)},
4238 /* Analog Mix output amp */
4239 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4240 /* capture sources */
4241 /* {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0}, */ /* set via unsol */
4242 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4243 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x0},
4244 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4245 /* unsolicited event for pin-sense */
4246 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1884A_HP_EVENT
},
4247 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1884A_MIC_EVENT
},
4248 /* allow to touch GPIO1 (for mute control) */
4249 {0x01, AC_VERB_SET_GPIO_MASK
, 0x02},
4250 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x02},
4251 {0x01, AC_VERB_SET_GPIO_DATA
, 0x02}, /* first muted */
4260 * 0x17 - built-in mic
4263 static const struct hda_verb ad1984a_thinkpad_verbs
[] = {
4265 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
4267 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
4269 {0x12, AC_VERB_SET_EAPD_BTLENABLE
, 0x02},
4270 /* unsolicited event for pin-sense */
4271 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1884A_HP_EVENT
},
4272 /* internal mic - dmic */
4273 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
4274 /* set magic COEFs for dmic */
4275 {0x01, AC_VERB_SET_COEF_INDEX
, 0x13f7},
4276 {0x01, AC_VERB_SET_PROC_COEF
, 0x08},
4280 static const struct snd_kcontrol_new ad1984a_thinkpad_mixers
[] = {
4281 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT
),
4282 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT
),
4283 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT
),
4284 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT
),
4285 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT
),
4286 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT
),
4287 HDA_CODEC_VOLUME("Mic Boost Volume", 0x14, 0x0, HDA_INPUT
),
4288 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x17, 0x0, HDA_INPUT
),
4289 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
4290 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
4292 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4293 .name
= "Capture Source",
4294 .info
= ad198x_mux_enum_info
,
4295 .get
= ad198x_mux_enum_get
,
4296 .put
= ad198x_mux_enum_put
,
4301 static const struct hda_input_mux ad1984a_thinkpad_capture_source
= {
4305 { "Internal Mic", 0x5 },
4310 /* mute internal speaker if HP is plugged */
4311 static void ad1984a_thinkpad_automute(struct hda_codec
*codec
)
4313 unsigned int present
;
4315 present
= snd_hda_jack_detect(codec
, 0x11);
4316 snd_hda_codec_amp_stereo(codec
, 0x12, HDA_OUTPUT
, 0,
4317 HDA_AMP_MUTE
, present
? HDA_AMP_MUTE
: 0);
4320 /* unsolicited event for HP jack sensing */
4321 static void ad1984a_thinkpad_unsol_event(struct hda_codec
*codec
,
4324 if ((res
>> 26) != AD1884A_HP_EVENT
)
4326 ad1984a_thinkpad_automute(codec
);
4329 /* initialize jack-sensing, too */
4330 static int ad1984a_thinkpad_init(struct hda_codec
*codec
)
4333 ad1984a_thinkpad_automute(codec
);
4339 * 0x12 - HP/line-out
4340 * 0x13 - speaker (mono)
4344 static const struct hda_verb ad1984a_precision_verbs
[] = {
4345 /* Unmute main output path */
4346 {0x03, AC_VERB_SET_AMP_GAIN_MUTE
, 0x27}, /* 0dB */
4347 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
+ 0x1f}, /* 0dB */
4348 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(5) + 0x17}, /* 0dB */
4349 /* Analog mixer; mute as default */
4350 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4351 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4352 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
4353 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
4354 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
4355 /* Select mic as input */
4356 {0x0c, AC_VERB_SET_CONNECT_SEL
, 0x1},
4357 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
+ 0x27}, /* 0dB */
4358 /* Configure as mic */
4359 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
4360 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, 0x7002}, /* raise mic as default */
4362 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
4364 {0x13, AC_VERB_SET_EAPD_BTLENABLE
, 0x02},
4365 /* unsolicited event for pin-sense */
4366 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1884A_HP_EVENT
},
4370 static const struct snd_kcontrol_new ad1984a_precision_mixers
[] = {
4371 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT
),
4372 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT
),
4373 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT
),
4374 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT
),
4375 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT
),
4376 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT
),
4377 HDA_CODEC_VOLUME("Mic Boost Volume", 0x15, 0x0, HDA_INPUT
),
4378 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
4379 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
4380 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
4381 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
4386 /* mute internal speaker if HP is plugged */
4387 static void ad1984a_precision_automute(struct hda_codec
*codec
)
4389 unsigned int present
;
4391 present
= snd_hda_jack_detect(codec
, 0x12);
4392 snd_hda_codec_amp_stereo(codec
, 0x13, HDA_OUTPUT
, 0,
4393 HDA_AMP_MUTE
, present
? HDA_AMP_MUTE
: 0);
4397 /* unsolicited event for HP jack sensing */
4398 static void ad1984a_precision_unsol_event(struct hda_codec
*codec
,
4401 if ((res
>> 26) != AD1884A_HP_EVENT
)
4403 ad1984a_precision_automute(codec
);
4406 /* initialize jack-sensing, too */
4407 static int ad1984a_precision_init(struct hda_codec
*codec
)
4410 ad1984a_precision_automute(codec
);
4417 * port-A (0x11) - front hp-out
4418 * port-B (0x14) - unused
4419 * port-C (0x15) - unused
4420 * port-D (0x12) - rear line out
4421 * port-E (0x1c) - front mic-in
4422 * port-F (0x16) - Internal speakers
4423 * digital-mic (0x17) - Internal mic
4426 static const struct hda_verb ad1984a_touchsmart_verbs
[] = {
4427 /* DACs; unmute as default */
4428 {0x03, AC_VERB_SET_AMP_GAIN_MUTE
, 0x27}, /* 0dB */
4429 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, 0x27}, /* 0dB */
4430 /* Port-A (HP) mixer - route only from analog mixer */
4431 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4432 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4434 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
4435 /* Port-A (HP) pin - always unmuted */
4436 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
4437 /* Port-E (int speaker) mixer - route only from analog mixer */
4438 {0x25, AC_VERB_SET_AMP_GAIN_MUTE
, 0x03},
4440 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
4441 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
4442 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
4443 /* Port-F (int speaker) mixer - route only from analog mixer */
4444 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4445 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4447 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
4448 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4449 /* Analog mixer; mute as default */
4450 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4451 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4452 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
4453 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
4454 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
4455 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)},
4456 /* Analog Mix output amp */
4457 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4458 /* capture sources */
4459 /* {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0}, */ /* set via unsol */
4460 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4461 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x0},
4462 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4463 /* unsolicited event for pin-sense */
4464 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1884A_HP_EVENT
},
4465 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1884A_MIC_EVENT
},
4466 /* allow to touch GPIO1 (for mute control) */
4467 {0x01, AC_VERB_SET_GPIO_MASK
, 0x02},
4468 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x02},
4469 {0x01, AC_VERB_SET_GPIO_DATA
, 0x02}, /* first muted */
4470 /* internal mic - dmic */
4471 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
4472 /* set magic COEFs for dmic */
4473 {0x01, AC_VERB_SET_COEF_INDEX
, 0x13f7},
4474 {0x01, AC_VERB_SET_PROC_COEF
, 0x08},
4478 static const struct snd_kcontrol_new ad1984a_touchsmart_mixers
[] = {
4479 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT
),
4480 /* HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),*/
4482 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4483 .subdevice
= HDA_SUBDEV_AMP_FLAG
,
4484 .name
= "Master Playback Switch",
4485 .info
= snd_hda_mixer_amp_switch_info
,
4486 .get
= snd_hda_mixer_amp_switch_get
,
4487 .put
= ad1884a_mobile_master_sw_put
,
4488 .private_value
= HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT
),
4490 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT
),
4491 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT
),
4492 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
4493 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
4494 HDA_CODEC_VOLUME("Mic Boost Volume", 0x25, 0x0, HDA_OUTPUT
),
4495 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x17, 0x0, HDA_INPUT
),
4499 /* switch to external mic if plugged */
4500 static void ad1984a_touchsmart_automic(struct hda_codec
*codec
)
4502 if (snd_hda_jack_detect(codec
, 0x1c))
4503 snd_hda_codec_write(codec
, 0x0c, 0,
4504 AC_VERB_SET_CONNECT_SEL
, 0x4);
4506 snd_hda_codec_write(codec
, 0x0c, 0,
4507 AC_VERB_SET_CONNECT_SEL
, 0x5);
4511 /* unsolicited event for HP jack sensing */
4512 static void ad1984a_touchsmart_unsol_event(struct hda_codec
*codec
,
4515 switch (res
>> 26) {
4516 case AD1884A_HP_EVENT
:
4517 ad1884a_hp_automute(codec
);
4519 case AD1884A_MIC_EVENT
:
4520 ad1984a_touchsmart_automic(codec
);
4525 /* initialize jack-sensing, too */
4526 static int ad1984a_touchsmart_init(struct hda_codec
*codec
)
4529 ad1884a_hp_automute(codec
);
4530 ad1984a_touchsmart_automic(codec
);
4548 static const char * const ad1884a_models
[AD1884A_MODELS
] = {
4549 [AD1884A_DESKTOP
] = "desktop",
4550 [AD1884A_LAPTOP
] = "laptop",
4551 [AD1884A_MOBILE
] = "mobile",
4552 [AD1884A_THINKPAD
] = "thinkpad",
4553 [AD1984A_TOUCHSMART
] = "touchsmart",
4554 [AD1984A_PRECISION
] = "precision",
4557 static const struct snd_pci_quirk ad1884a_cfg_tbl
[] = {
4558 SND_PCI_QUIRK(0x1028, 0x04ac, "Precision R5500", AD1984A_PRECISION
),
4559 SND_PCI_QUIRK(0x103c, 0x3030, "HP", AD1884A_MOBILE
),
4560 SND_PCI_QUIRK(0x103c, 0x3037, "HP 2230s", AD1884A_LAPTOP
),
4561 SND_PCI_QUIRK(0x103c, 0x3056, "HP", AD1884A_MOBILE
),
4562 SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x3070, "HP", AD1884A_MOBILE
),
4563 SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x30d0, "HP laptop", AD1884A_LAPTOP
),
4564 SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x30e0, "HP laptop", AD1884A_LAPTOP
),
4565 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3600, "HP laptop", AD1884A_LAPTOP
),
4566 SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x7010, "HP laptop", AD1884A_MOBILE
),
4567 SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X300", AD1884A_THINKPAD
),
4568 SND_PCI_QUIRK(0x103c, 0x2a82, "Touchsmart", AD1984A_TOUCHSMART
),
4572 static int patch_ad1884a(struct hda_codec
*codec
)
4574 struct ad198x_spec
*spec
;
4575 int err
, board_config
;
4577 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4583 err
= snd_hda_attach_beep_device(codec
, 0x10);
4588 set_beep_amp(spec
, 0x10, 0, HDA_OUTPUT
);
4590 spec
->multiout
.max_channels
= 2;
4591 spec
->multiout
.num_dacs
= ARRAY_SIZE(ad1884a_dac_nids
);
4592 spec
->multiout
.dac_nids
= ad1884a_dac_nids
;
4593 spec
->multiout
.dig_out_nid
= AD1884A_SPDIF_OUT
;
4594 spec
->num_adc_nids
= ARRAY_SIZE(ad1884a_adc_nids
);
4595 spec
->adc_nids
= ad1884a_adc_nids
;
4596 spec
->capsrc_nids
= ad1884a_capsrc_nids
;
4597 spec
->input_mux
= &ad1884a_capture_source
;
4598 spec
->num_mixers
= 1;
4599 spec
->mixers
[0] = ad1884a_base_mixers
;
4600 spec
->num_init_verbs
= 1;
4601 spec
->init_verbs
[0] = ad1884a_init_verbs
;
4602 spec
->spdif_route
= 0;
4604 spec
->loopback
.amplist
= ad1884a_loopbacks
;
4606 codec
->patch_ops
= ad198x_patch_ops
;
4608 /* override some parameters */
4609 board_config
= snd_hda_check_board_config(codec
, AD1884A_MODELS
,
4612 switch (board_config
) {
4613 case AD1884A_LAPTOP
:
4614 spec
->mixers
[0] = ad1884a_laptop_mixers
;
4615 spec
->init_verbs
[spec
->num_init_verbs
++] = ad1884a_laptop_verbs
;
4616 spec
->multiout
.dig_out_nid
= 0;
4617 codec
->patch_ops
.unsol_event
= ad1884a_laptop_unsol_event
;
4618 codec
->patch_ops
.init
= ad1884a_laptop_init
;
4619 /* set the upper-limit for mixer amp to 0dB for avoiding the
4620 * possible damage by overloading
4622 snd_hda_override_amp_caps(codec
, 0x20, HDA_INPUT
,
4623 (0x17 << AC_AMPCAP_OFFSET_SHIFT
) |
4624 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
4625 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
4626 (1 << AC_AMPCAP_MUTE_SHIFT
));
4628 case AD1884A_MOBILE
:
4629 spec
->mixers
[0] = ad1884a_mobile_mixers
;
4630 spec
->init_verbs
[0] = ad1884a_mobile_verbs
;
4631 spec
->multiout
.dig_out_nid
= 0;
4632 codec
->patch_ops
.unsol_event
= ad1884a_hp_unsol_event
;
4633 codec
->patch_ops
.init
= ad1884a_hp_init
;
4634 /* set the upper-limit for mixer amp to 0dB for avoiding the
4635 * possible damage by overloading
4637 snd_hda_override_amp_caps(codec
, 0x20, HDA_INPUT
,
4638 (0x17 << AC_AMPCAP_OFFSET_SHIFT
) |
4639 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
4640 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
4641 (1 << AC_AMPCAP_MUTE_SHIFT
));
4643 case AD1884A_THINKPAD
:
4644 spec
->mixers
[0] = ad1984a_thinkpad_mixers
;
4645 spec
->init_verbs
[spec
->num_init_verbs
++] =
4646 ad1984a_thinkpad_verbs
;
4647 spec
->multiout
.dig_out_nid
= 0;
4648 spec
->input_mux
= &ad1984a_thinkpad_capture_source
;
4649 codec
->patch_ops
.unsol_event
= ad1984a_thinkpad_unsol_event
;
4650 codec
->patch_ops
.init
= ad1984a_thinkpad_init
;
4652 case AD1984A_PRECISION
:
4653 spec
->mixers
[0] = ad1984a_precision_mixers
;
4654 spec
->init_verbs
[spec
->num_init_verbs
++] =
4655 ad1984a_precision_verbs
;
4656 spec
->multiout
.dig_out_nid
= 0;
4657 codec
->patch_ops
.unsol_event
= ad1984a_precision_unsol_event
;
4658 codec
->patch_ops
.init
= ad1984a_precision_init
;
4660 case AD1984A_TOUCHSMART
:
4661 spec
->mixers
[0] = ad1984a_touchsmart_mixers
;
4662 spec
->init_verbs
[0] = ad1984a_touchsmart_verbs
;
4663 spec
->multiout
.dig_out_nid
= 0;
4664 codec
->patch_ops
.unsol_event
= ad1984a_touchsmart_unsol_event
;
4665 codec
->patch_ops
.init
= ad1984a_touchsmart_init
;
4666 /* set the upper-limit for mixer amp to 0dB for avoiding the
4667 * possible damage by overloading
4669 snd_hda_override_amp_caps(codec
, 0x20, HDA_INPUT
,
4670 (0x17 << AC_AMPCAP_OFFSET_SHIFT
) |
4671 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
4672 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
4673 (1 << AC_AMPCAP_MUTE_SHIFT
));
4677 codec
->no_trigger_sense
= 1;
4678 codec
->no_sticky_stream
= 1;
4687 * port-A - front hp-out
4688 * port-B - front mic-in
4689 * port-C - rear line-in, shared surr-out (3stack)
4690 * port-D - rear line-out
4691 * port-E - rear mic-in, shared clfe-out (3stack)
4692 * port-F - rear surr-out (6stack)
4693 * port-G - rear clfe-out (6stack)
4696 static const hda_nid_t ad1882_dac_nids
[3] = {
4700 static const hda_nid_t ad1882_adc_nids
[2] = {
4704 static const hda_nid_t ad1882_capsrc_nids
[2] = {
4708 #define AD1882_SPDIF_OUT 0x02
4710 /* list: 0x11, 0x39, 0x3a, 0x18, 0x3c, 0x3b, 0x12, 0x20 */
4711 static const struct hda_input_mux ad1882_capture_source
= {
4714 { "Front Mic", 0x1 },
4722 /* list: 0x11, 0x39, 0x3a, 0x3c, 0x18, 0x1f, 0x12, 0x20 */
4723 static const struct hda_input_mux ad1882a_capture_source
= {
4726 { "Front Mic", 0x1 },
4729 { "Digital Mic", 0x06 },
4734 static const struct snd_kcontrol_new ad1882_base_mixers
[] = {
4735 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
4736 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT
),
4737 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT
),
4738 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT
),
4739 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
4740 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
4741 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT
),
4742 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT
),
4744 HDA_CODEC_VOLUME("Mic Boost Volume", 0x3c, 0x0, HDA_OUTPUT
),
4745 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x39, 0x0, HDA_OUTPUT
),
4746 HDA_CODEC_VOLUME("Line-In Boost Volume", 0x3a, 0x0, HDA_OUTPUT
),
4747 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
4748 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
4749 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT
),
4750 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT
),
4752 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4753 /* The multiple "Capture Source" controls confuse alsamixer
4754 * So call somewhat different..
4756 /* .name = "Capture Source", */
4757 .name
= "Input Source",
4759 .info
= ad198x_mux_enum_info
,
4760 .get
= ad198x_mux_enum_get
,
4761 .put
= ad198x_mux_enum_put
,
4763 /* SPDIF controls */
4764 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
4766 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4767 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,NONE
) "Source",
4768 /* identical with ad1983 */
4769 .info
= ad1983_spdif_route_info
,
4770 .get
= ad1983_spdif_route_get
,
4771 .put
= ad1983_spdif_route_put
,
4776 static const struct snd_kcontrol_new ad1882_loopback_mixers
[] = {
4777 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT
),
4778 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT
),
4779 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT
),
4780 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT
),
4781 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x04, HDA_INPUT
),
4782 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x04, HDA_INPUT
),
4783 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT
),
4784 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT
),
4788 static const struct snd_kcontrol_new ad1882a_loopback_mixers
[] = {
4789 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT
),
4790 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT
),
4791 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x04, HDA_INPUT
),
4792 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x04, HDA_INPUT
),
4793 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x01, HDA_INPUT
),
4794 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x01, HDA_INPUT
),
4795 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT
),
4796 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT
),
4797 HDA_CODEC_VOLUME("Digital Mic Boost Volume", 0x1f, 0x0, HDA_INPUT
),
4801 static const struct snd_kcontrol_new ad1882_3stack_mixers
[] = {
4802 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT
),
4803 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x17, 1, 0x0, HDA_OUTPUT
),
4804 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x17, 2, 0x0, HDA_OUTPUT
),
4806 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4807 .name
= "Channel Mode",
4808 .info
= ad198x_ch_mode_info
,
4809 .get
= ad198x_ch_mode_get
,
4810 .put
= ad198x_ch_mode_put
,
4815 /* simple auto-mute control for AD1882 3-stack board */
4816 #define AD1882_HP_EVENT 0x01
4818 static void ad1882_3stack_automute(struct hda_codec
*codec
)
4820 bool mute
= snd_hda_jack_detect(codec
, 0x11);
4821 snd_hda_codec_write(codec
, 0x12, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
4822 mute
? 0 : PIN_OUT
);
4825 static int ad1882_3stack_automute_init(struct hda_codec
*codec
)
4828 ad1882_3stack_automute(codec
);
4832 static void ad1882_3stack_unsol_event(struct hda_codec
*codec
, unsigned int res
)
4834 switch (res
>> 26) {
4835 case AD1882_HP_EVENT
:
4836 ad1882_3stack_automute(codec
);
4841 static const struct snd_kcontrol_new ad1882_6stack_mixers
[] = {
4842 HDA_CODEC_MUTE("Surround Playback Switch", 0x16, 0x0, HDA_OUTPUT
),
4843 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x24, 1, 0x0, HDA_OUTPUT
),
4844 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x24, 2, 0x0, HDA_OUTPUT
),
4848 static const struct hda_verb ad1882_ch2_init
[] = {
4849 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
4850 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4851 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4852 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
4853 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4854 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4858 static const struct hda_verb ad1882_ch4_init
[] = {
4859 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
4860 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4861 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4862 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
4863 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4864 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4868 static const struct hda_verb ad1882_ch6_init
[] = {
4869 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
4870 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4871 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4872 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
4873 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4874 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4878 static const struct hda_channel_mode ad1882_modes
[3] = {
4879 { 2, ad1882_ch2_init
},
4880 { 4, ad1882_ch4_init
},
4881 { 6, ad1882_ch6_init
},
4885 * initialization verbs
4887 static const struct hda_verb ad1882_init_verbs
[] = {
4888 /* DACs; mute as default */
4889 {0x03, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
4890 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
4891 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
4892 /* Port-A (HP) mixer */
4893 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4894 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4896 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
4897 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4898 /* HP selector - select DAC2 */
4899 {0x37, AC_VERB_SET_CONNECT_SEL
, 0x1},
4900 /* Port-D (Line-out) mixer */
4901 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4902 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4904 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
4905 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4906 /* Mono-out mixer */
4907 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4908 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4910 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
4911 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4912 /* Port-B (front mic) pin */
4913 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
4914 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4915 {0x39, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
}, /* boost */
4916 /* Port-C (line-in) pin */
4917 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
4918 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4919 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
}, /* boost */
4920 /* Port-C mixer - mute as input */
4921 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4922 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4923 /* Port-E (mic-in) pin */
4924 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
4925 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4926 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
}, /* boost */
4927 /* Port-E mixer - mute as input */
4928 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4929 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4930 /* Port-F (surround) */
4931 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
4932 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4934 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
4935 {0x24, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4936 /* Analog mixer; mute as default */
4937 /* list: 0x39, 0x3a, 0x11, 0x12, 0x3c, 0x3b, 0x18, 0x1a */
4938 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4939 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4940 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
4941 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
4942 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
4943 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)},
4944 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)},
4945 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)},
4946 /* Analog Mix output amp */
4947 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x1f}, /* 0dB */
4948 /* SPDIF output selector */
4949 {0x02, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x27}, /* 0dB */
4950 {0x02, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* PCM */
4951 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x27}, /* 0dB */
4955 static const struct hda_verb ad1882_3stack_automute_verbs
[] = {
4956 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1882_HP_EVENT
},
4961 static const struct hda_amp_list ad1882_loopbacks
[] = {
4962 { 0x20, HDA_INPUT
, 0 }, /* Front Mic */
4963 { 0x20, HDA_INPUT
, 1 }, /* Mic */
4964 { 0x20, HDA_INPUT
, 4 }, /* Line */
4965 { 0x20, HDA_INPUT
, 6 }, /* CD */
4974 AD1882_3STACK_AUTOMUTE
,
4978 static const char * const ad1882_models
[AD1986A_MODELS
] = {
4979 [AD1882_3STACK
] = "3stack",
4980 [AD1882_6STACK
] = "6stack",
4981 [AD1882_3STACK_AUTOMUTE
] = "3stack-automute",
4985 static int patch_ad1882(struct hda_codec
*codec
)
4987 struct ad198x_spec
*spec
;
4988 int err
, board_config
;
4990 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4996 err
= snd_hda_attach_beep_device(codec
, 0x10);
5001 set_beep_amp(spec
, 0x10, 0, HDA_OUTPUT
);
5003 spec
->multiout
.max_channels
= 6;
5004 spec
->multiout
.num_dacs
= 3;
5005 spec
->multiout
.dac_nids
= ad1882_dac_nids
;
5006 spec
->multiout
.dig_out_nid
= AD1882_SPDIF_OUT
;
5007 spec
->num_adc_nids
= ARRAY_SIZE(ad1882_adc_nids
);
5008 spec
->adc_nids
= ad1882_adc_nids
;
5009 spec
->capsrc_nids
= ad1882_capsrc_nids
;
5010 if (codec
->vendor_id
== 0x11d41882)
5011 spec
->input_mux
= &ad1882_capture_source
;
5013 spec
->input_mux
= &ad1882a_capture_source
;
5014 spec
->num_mixers
= 2;
5015 spec
->mixers
[0] = ad1882_base_mixers
;
5016 if (codec
->vendor_id
== 0x11d41882)
5017 spec
->mixers
[1] = ad1882_loopback_mixers
;
5019 spec
->mixers
[1] = ad1882a_loopback_mixers
;
5020 spec
->num_init_verbs
= 1;
5021 spec
->init_verbs
[0] = ad1882_init_verbs
;
5022 spec
->spdif_route
= 0;
5024 spec
->loopback
.amplist
= ad1882_loopbacks
;
5026 spec
->vmaster_nid
= 0x04;
5028 codec
->patch_ops
= ad198x_patch_ops
;
5030 /* override some parameters */
5031 board_config
= snd_hda_check_board_config(codec
, AD1882_MODELS
,
5032 ad1882_models
, NULL
);
5033 switch (board_config
) {
5036 case AD1882_3STACK_AUTOMUTE
:
5037 spec
->num_mixers
= 3;
5038 spec
->mixers
[2] = ad1882_3stack_mixers
;
5039 spec
->channel_mode
= ad1882_modes
;
5040 spec
->num_channel_mode
= ARRAY_SIZE(ad1882_modes
);
5041 spec
->need_dac_fix
= 1;
5042 spec
->multiout
.max_channels
= 2;
5043 spec
->multiout
.num_dacs
= 1;
5044 if (board_config
!= AD1882_3STACK
) {
5045 spec
->init_verbs
[spec
->num_init_verbs
++] =
5046 ad1882_3stack_automute_verbs
;
5047 codec
->patch_ops
.unsol_event
= ad1882_3stack_unsol_event
;
5048 codec
->patch_ops
.init
= ad1882_3stack_automute_init
;
5052 spec
->num_mixers
= 3;
5053 spec
->mixers
[2] = ad1882_6stack_mixers
;
5057 codec
->no_trigger_sense
= 1;
5058 codec
->no_sticky_stream
= 1;
5067 static const struct hda_codec_preset snd_hda_preset_analog
[] = {
5068 { .id
= 0x11d4184a, .name
= "AD1884A", .patch
= patch_ad1884a
},
5069 { .id
= 0x11d41882, .name
= "AD1882", .patch
= patch_ad1882
},
5070 { .id
= 0x11d41883, .name
= "AD1883", .patch
= patch_ad1884a
},
5071 { .id
= 0x11d41884, .name
= "AD1884", .patch
= patch_ad1884
},
5072 { .id
= 0x11d4194a, .name
= "AD1984A", .patch
= patch_ad1884a
},
5073 { .id
= 0x11d4194b, .name
= "AD1984B", .patch
= patch_ad1884a
},
5074 { .id
= 0x11d41981, .name
= "AD1981", .patch
= patch_ad1981
},
5075 { .id
= 0x11d41983, .name
= "AD1983", .patch
= patch_ad1983
},
5076 { .id
= 0x11d41984, .name
= "AD1984", .patch
= patch_ad1984
},
5077 { .id
= 0x11d41986, .name
= "AD1986A", .patch
= patch_ad1986a
},
5078 { .id
= 0x11d41988, .name
= "AD1988", .patch
= patch_ad1988
},
5079 { .id
= 0x11d4198b, .name
= "AD1988B", .patch
= patch_ad1988
},
5080 { .id
= 0x11d4882a, .name
= "AD1882A", .patch
= patch_ad1882
},
5081 { .id
= 0x11d4989a, .name
= "AD1989A", .patch
= patch_ad1988
},
5082 { .id
= 0x11d4989b, .name
= "AD1989B", .patch
= patch_ad1988
},
5086 MODULE_ALIAS("snd-hda-codec-id:11d4*");
5088 MODULE_LICENSE("GPL");
5089 MODULE_DESCRIPTION("Analog Devices HD-audio codec");
5091 static struct hda_codec_preset_list analog_list
= {
5092 .preset
= snd_hda_preset_analog
,
5093 .owner
= THIS_MODULE
,
5096 static int __init
patch_analog_init(void)
5098 return snd_hda_add_codec_preset(&analog_list
);
5101 static void __exit
patch_analog_exit(void)
5103 snd_hda_delete_codec_preset(&analog_list
);
5106 module_init(patch_analog_init
)
5107 module_exit(patch_analog_exit
)