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"
35 const struct snd_kcontrol_new
*mixers
[6];
37 unsigned int beep_amp
; /* beep amp value, set via set_beep_amp() */
38 const struct hda_verb
*init_verbs
[6]; /* initialization verbs
39 * don't forget NULL termination!
41 unsigned int num_init_verbs
;
44 struct hda_multi_out multiout
; /* playback set-up
45 * max_channels, dacs must be set
46 * dig_out_nid and hp_nid are optional
48 unsigned int cur_eapd
;
49 unsigned int need_dac_fix
;
51 const hda_nid_t
*alt_dac_nid
;
52 const struct hda_pcm_stream
*stream_analog_alt_playback
;
54 int num_active_streams
;
57 unsigned int num_adc_nids
;
58 const hda_nid_t
*adc_nids
;
59 hda_nid_t dig_in_nid
; /* digital-in NID; optional */
62 const struct hda_input_mux
*input_mux
;
63 const hda_nid_t
*capsrc_nids
;
64 unsigned int cur_mux
[3];
67 const struct hda_channel_mode
*channel_mode
;
71 struct hda_pcm pcm_rec
[3]; /* used in alc_build_pcms() */
73 unsigned int spdif_route
;
75 /* dynamic controls, init_verbs and input_mux */
76 struct auto_pin_cfg autocfg
;
77 struct snd_array kctls
;
78 struct hda_input_mux private_imux
;
79 hda_nid_t private_dac_nids
[AUTO_CFG_MAX_OUTS
];
81 unsigned int jack_present
: 1;
82 unsigned int inv_jack_detect
: 1;/* inverted jack-detection */
83 unsigned int inv_eapd
: 1; /* inverted EAPD implementation */
84 unsigned int analog_beep
: 1; /* analog beep input present */
85 unsigned int avoid_init_slave_vol
:1;
87 #ifdef CONFIG_SND_HDA_POWER_SAVE
88 struct hda_loopback_check loopback
;
90 /* for virtual master */
91 hda_nid_t vmaster_nid
;
92 const char * const *slave_vols
;
93 const char * const *slave_sws
;
97 * input MUX handling (common part)
99 static int ad198x_mux_enum_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
101 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
102 struct ad198x_spec
*spec
= codec
->spec
;
104 return snd_hda_input_mux_info(spec
->input_mux
, uinfo
);
107 static int ad198x_mux_enum_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
109 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
110 struct ad198x_spec
*spec
= codec
->spec
;
111 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
113 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
117 static int ad198x_mux_enum_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
119 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
120 struct ad198x_spec
*spec
= codec
->spec
;
121 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
123 return snd_hda_input_mux_put(codec
, spec
->input_mux
, ucontrol
,
124 spec
->capsrc_nids
[adc_idx
],
125 &spec
->cur_mux
[adc_idx
]);
129 * initialization (common callbacks)
131 static int ad198x_init(struct hda_codec
*codec
)
133 struct ad198x_spec
*spec
= codec
->spec
;
136 for (i
= 0; i
< spec
->num_init_verbs
; i
++)
137 snd_hda_sequence_write(codec
, spec
->init_verbs
[i
]);
141 static const char * const ad_slave_pfxs
[] = {
142 "Front", "Surround", "Center", "LFE", "Side",
143 "Headphone", "Mono", "Speaker", "IEC958",
147 static const char * const ad1988_6stack_fp_slave_pfxs
[] = {
148 "Front", "Surround", "Center", "LFE", "Side", "IEC958",
152 static void ad198x_free_kctls(struct hda_codec
*codec
);
154 #ifdef CONFIG_SND_HDA_INPUT_BEEP
155 /* additional beep mixers; the actual parameters are overwritten at build */
156 static const struct snd_kcontrol_new ad_beep_mixer
[] = {
157 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_OUTPUT
),
158 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_OUTPUT
),
162 static const struct snd_kcontrol_new ad_beep2_mixer
[] = {
163 HDA_CODEC_VOLUME("Digital Beep Playback Volume", 0, 0, HDA_OUTPUT
),
164 HDA_CODEC_MUTE_BEEP("Digital Beep Playback Switch", 0, 0, HDA_OUTPUT
),
168 #define set_beep_amp(spec, nid, idx, dir) \
169 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir)) /* mono */
171 #define set_beep_amp(spec, nid, idx, dir) /* NOP */
174 static int ad198x_build_controls(struct hda_codec
*codec
)
176 struct ad198x_spec
*spec
= codec
->spec
;
177 struct snd_kcontrol
*kctl
;
181 for (i
= 0; i
< spec
->num_mixers
; i
++) {
182 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
186 if (spec
->multiout
.dig_out_nid
) {
187 err
= snd_hda_create_spdif_out_ctls(codec
,
188 spec
->multiout
.dig_out_nid
,
189 spec
->multiout
.dig_out_nid
);
192 err
= snd_hda_create_spdif_share_sw(codec
,
196 spec
->multiout
.share_spdif
= 1;
198 if (spec
->dig_in_nid
) {
199 err
= snd_hda_create_spdif_in_ctls(codec
, spec
->dig_in_nid
);
204 /* create beep controls if needed */
205 #ifdef CONFIG_SND_HDA_INPUT_BEEP
206 if (spec
->beep_amp
) {
207 const struct snd_kcontrol_new
*knew
;
208 knew
= spec
->analog_beep
? ad_beep2_mixer
: ad_beep_mixer
;
209 for ( ; knew
->name
; knew
++) {
210 struct snd_kcontrol
*kctl
;
211 kctl
= snd_ctl_new1(knew
, codec
);
214 kctl
->private_value
= spec
->beep_amp
;
215 err
= snd_hda_ctl_add(codec
, 0, kctl
);
222 /* if we have no master control, let's create it */
223 if (!snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
224 unsigned int vmaster_tlv
[4];
225 snd_hda_set_vmaster_tlv(codec
, spec
->vmaster_nid
,
226 HDA_OUTPUT
, vmaster_tlv
);
227 err
= __snd_hda_add_vmaster(codec
, "Master Playback Volume",
230 spec
->slave_vols
: ad_slave_pfxs
),
232 !spec
->avoid_init_slave_vol
, NULL
);
236 if (!snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
237 err
= snd_hda_add_vmaster(codec
, "Master Playback Switch",
240 spec
->slave_sws
: ad_slave_pfxs
),
246 ad198x_free_kctls(codec
); /* no longer needed */
248 /* assign Capture Source enums to NID */
249 kctl
= snd_hda_find_mixer_ctl(codec
, "Capture Source");
251 kctl
= snd_hda_find_mixer_ctl(codec
, "Input Source");
252 for (i
= 0; kctl
&& i
< kctl
->count
; i
++) {
253 err
= snd_hda_add_nid(codec
, kctl
, i
, spec
->capsrc_nids
[i
]);
258 /* assign IEC958 enums to NID */
259 kctl
= snd_hda_find_mixer_ctl(codec
,
260 SNDRV_CTL_NAME_IEC958("",PLAYBACK
,NONE
) "Source");
262 err
= snd_hda_add_nid(codec
, kctl
, 0,
263 spec
->multiout
.dig_out_nid
);
271 #ifdef CONFIG_SND_HDA_POWER_SAVE
272 static int ad198x_check_power_status(struct hda_codec
*codec
, hda_nid_t nid
)
274 struct ad198x_spec
*spec
= codec
->spec
;
275 return snd_hda_check_amp_list_power(codec
, &spec
->loopback
, nid
);
279 static void activate_ctl(struct hda_codec
*codec
, const char *name
, int active
)
281 struct snd_kcontrol
*ctl
= snd_hda_find_mixer_ctl(codec
, name
);
283 ctl
->vd
[0].access
&= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE
;
284 ctl
->vd
[0].access
|= active
? 0 :
285 SNDRV_CTL_ELEM_ACCESS_INACTIVE
;
286 ctl
->vd
[0].access
&= ~SNDRV_CTL_ELEM_ACCESS_WRITE
;
287 ctl
->vd
[0].access
|= active
?
288 SNDRV_CTL_ELEM_ACCESS_WRITE
: 0;
289 snd_ctl_notify(codec
->bus
->card
,
290 SNDRV_CTL_EVENT_MASK_INFO
, &ctl
->id
);
294 static void set_stream_active(struct hda_codec
*codec
, bool active
)
296 struct ad198x_spec
*spec
= codec
->spec
;
298 spec
->num_active_streams
++;
300 spec
->num_active_streams
--;
301 activate_ctl(codec
, "Independent HP", spec
->num_active_streams
== 0);
304 static int ad1988_independent_hp_info(struct snd_kcontrol
*kcontrol
,
305 struct snd_ctl_elem_info
*uinfo
)
307 static const char * const texts
[] = { "OFF", "ON", NULL
};
309 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
311 uinfo
->value
.enumerated
.items
= 2;
312 index
= uinfo
->value
.enumerated
.item
;
315 strcpy(uinfo
->value
.enumerated
.name
, texts
[index
]);
319 static int ad1988_independent_hp_get(struct snd_kcontrol
*kcontrol
,
320 struct snd_ctl_elem_value
*ucontrol
)
322 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
323 struct ad198x_spec
*spec
= codec
->spec
;
324 ucontrol
->value
.enumerated
.item
[0] = spec
->independent_hp
;
328 static int ad1988_independent_hp_put(struct snd_kcontrol
*kcontrol
,
329 struct snd_ctl_elem_value
*ucontrol
)
331 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
332 struct ad198x_spec
*spec
= codec
->spec
;
333 unsigned int select
= ucontrol
->value
.enumerated
.item
[0];
334 if (spec
->independent_hp
!= select
) {
335 spec
->independent_hp
= select
;
336 if (spec
->independent_hp
)
337 spec
->multiout
.hp_nid
= 0;
339 spec
->multiout
.hp_nid
= spec
->alt_dac_nid
[0];
346 * Analog playback callbacks
348 static int ad198x_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
349 struct hda_codec
*codec
,
350 struct snd_pcm_substream
*substream
)
352 struct ad198x_spec
*spec
= codec
->spec
;
354 set_stream_active(codec
, true);
355 err
= snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
358 set_stream_active(codec
, false);
364 static int ad198x_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
365 struct hda_codec
*codec
,
366 unsigned int stream_tag
,
368 struct snd_pcm_substream
*substream
)
370 struct ad198x_spec
*spec
= codec
->spec
;
371 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
, stream_tag
,
375 static int ad198x_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
376 struct hda_codec
*codec
,
377 struct snd_pcm_substream
*substream
)
379 struct ad198x_spec
*spec
= codec
->spec
;
380 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
383 static int ad198x_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
384 struct hda_codec
*codec
,
385 struct snd_pcm_substream
*substream
)
387 set_stream_active(codec
, false);
391 static int ad1988_alt_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
392 struct hda_codec
*codec
,
393 struct snd_pcm_substream
*substream
)
395 struct ad198x_spec
*spec
= codec
->spec
;
396 if (!spec
->independent_hp
)
398 set_stream_active(codec
, true);
402 static int ad1988_alt_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
403 struct hda_codec
*codec
,
404 struct snd_pcm_substream
*substream
)
406 set_stream_active(codec
, false);
410 static const struct hda_pcm_stream ad198x_pcm_analog_alt_playback
= {
415 .open
= ad1988_alt_playback_pcm_open
,
416 .close
= ad1988_alt_playback_pcm_close
423 static int ad198x_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
424 struct hda_codec
*codec
,
425 struct snd_pcm_substream
*substream
)
427 struct ad198x_spec
*spec
= codec
->spec
;
428 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
431 static int ad198x_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
432 struct hda_codec
*codec
,
433 struct snd_pcm_substream
*substream
)
435 struct ad198x_spec
*spec
= codec
->spec
;
436 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
439 static int ad198x_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
440 struct hda_codec
*codec
,
441 unsigned int stream_tag
,
443 struct snd_pcm_substream
*substream
)
445 struct ad198x_spec
*spec
= codec
->spec
;
446 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
, stream_tag
,
450 static int ad198x_dig_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
451 struct hda_codec
*codec
,
452 struct snd_pcm_substream
*substream
)
454 struct ad198x_spec
*spec
= codec
->spec
;
455 return snd_hda_multi_out_dig_cleanup(codec
, &spec
->multiout
);
461 static int ad198x_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
462 struct hda_codec
*codec
,
463 unsigned int stream_tag
,
465 struct snd_pcm_substream
*substream
)
467 struct ad198x_spec
*spec
= codec
->spec
;
468 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
],
469 stream_tag
, 0, format
);
473 static int ad198x_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
474 struct hda_codec
*codec
,
475 struct snd_pcm_substream
*substream
)
477 struct ad198x_spec
*spec
= codec
->spec
;
478 snd_hda_codec_cleanup_stream(codec
, spec
->adc_nids
[substream
->number
]);
484 static const struct hda_pcm_stream ad198x_pcm_analog_playback
= {
487 .channels_max
= 6, /* changed later */
488 .nid
= 0, /* fill later */
490 .open
= ad198x_playback_pcm_open
,
491 .prepare
= ad198x_playback_pcm_prepare
,
492 .cleanup
= ad198x_playback_pcm_cleanup
,
493 .close
= ad198x_playback_pcm_close
497 static const struct hda_pcm_stream ad198x_pcm_analog_capture
= {
501 .nid
= 0, /* fill later */
503 .prepare
= ad198x_capture_pcm_prepare
,
504 .cleanup
= ad198x_capture_pcm_cleanup
508 static const struct hda_pcm_stream ad198x_pcm_digital_playback
= {
512 .nid
= 0, /* fill later */
514 .open
= ad198x_dig_playback_pcm_open
,
515 .close
= ad198x_dig_playback_pcm_close
,
516 .prepare
= ad198x_dig_playback_pcm_prepare
,
517 .cleanup
= ad198x_dig_playback_pcm_cleanup
521 static const struct hda_pcm_stream ad198x_pcm_digital_capture
= {
525 /* NID is set in alc_build_pcms */
528 static int ad198x_build_pcms(struct hda_codec
*codec
)
530 struct ad198x_spec
*spec
= codec
->spec
;
531 struct hda_pcm
*info
= spec
->pcm_rec
;
534 codec
->pcm_info
= info
;
536 info
->name
= "AD198x Analog";
537 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = ad198x_pcm_analog_playback
;
538 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
= spec
->multiout
.max_channels
;
539 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dac_nids
[0];
540 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = ad198x_pcm_analog_capture
;
541 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
= spec
->num_adc_nids
;
542 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
544 if (spec
->multiout
.dig_out_nid
) {
547 info
->name
= "AD198x Digital";
548 info
->pcm_type
= HDA_PCM_TYPE_SPDIF
;
549 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = ad198x_pcm_digital_playback
;
550 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dig_out_nid
;
551 if (spec
->dig_in_nid
) {
552 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = ad198x_pcm_digital_capture
;
553 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->dig_in_nid
;
557 if (spec
->alt_dac_nid
&& spec
->stream_analog_alt_playback
) {
559 info
= spec
->pcm_rec
+ 2;
560 info
->name
= "AD198x Headphone";
561 info
->pcm_type
= HDA_PCM_TYPE_AUDIO
;
562 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] =
563 *spec
->stream_analog_alt_playback
;
564 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
565 spec
->alt_dac_nid
[0];
571 static void ad198x_free_kctls(struct hda_codec
*codec
)
573 struct ad198x_spec
*spec
= codec
->spec
;
575 if (spec
->kctls
.list
) {
576 struct snd_kcontrol_new
*kctl
= spec
->kctls
.list
;
578 for (i
= 0; i
< spec
->kctls
.used
; i
++)
581 snd_array_free(&spec
->kctls
);
584 static void ad198x_power_eapd_write(struct hda_codec
*codec
, hda_nid_t front
,
587 struct ad198x_spec
*spec
= codec
->spec
;
588 if (snd_hda_query_pin_caps(codec
, front
) & AC_PINCAP_EAPD
)
589 snd_hda_codec_write(codec
, front
, 0, AC_VERB_SET_EAPD_BTLENABLE
,
590 !spec
->inv_eapd
? 0x00 : 0x02);
591 if (snd_hda_query_pin_caps(codec
, hp
) & AC_PINCAP_EAPD
)
592 snd_hda_codec_write(codec
, hp
, 0, AC_VERB_SET_EAPD_BTLENABLE
,
593 !spec
->inv_eapd
? 0x00 : 0x02);
596 static void ad198x_power_eapd(struct hda_codec
*codec
)
598 /* We currently only handle front, HP */
599 switch (codec
->vendor_id
) {
612 ad198x_power_eapd_write(codec
, 0x12, 0x11);
616 ad198x_power_eapd_write(codec
, 0x05, 0x06);
619 ad198x_power_eapd_write(codec
, 0x1b, 0x1a);
624 static void ad198x_shutup(struct hda_codec
*codec
)
626 snd_hda_shutup_pins(codec
);
627 ad198x_power_eapd(codec
);
630 static void ad198x_free(struct hda_codec
*codec
)
632 struct ad198x_spec
*spec
= codec
->spec
;
637 ad198x_shutup(codec
);
638 ad198x_free_kctls(codec
);
640 snd_hda_detach_beep_device(codec
);
644 static int ad198x_suspend(struct hda_codec
*codec
, pm_message_t state
)
646 ad198x_shutup(codec
);
651 static const struct hda_codec_ops ad198x_patch_ops
= {
652 .build_controls
= ad198x_build_controls
,
653 .build_pcms
= ad198x_build_pcms
,
656 #ifdef CONFIG_SND_HDA_POWER_SAVE
657 .check_power_status
= ad198x_check_power_status
,
660 .suspend
= ad198x_suspend
,
662 .reboot_notify
= ad198x_shutup
,
668 * the private value = nid
670 #define ad198x_eapd_info snd_ctl_boolean_mono_info
672 static int ad198x_eapd_get(struct snd_kcontrol
*kcontrol
,
673 struct snd_ctl_elem_value
*ucontrol
)
675 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
676 struct ad198x_spec
*spec
= codec
->spec
;
678 ucontrol
->value
.integer
.value
[0] = ! spec
->cur_eapd
;
680 ucontrol
->value
.integer
.value
[0] = spec
->cur_eapd
;
684 static int ad198x_eapd_put(struct snd_kcontrol
*kcontrol
,
685 struct snd_ctl_elem_value
*ucontrol
)
687 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
688 struct ad198x_spec
*spec
= codec
->spec
;
689 hda_nid_t nid
= kcontrol
->private_value
& 0xff;
691 eapd
= !!ucontrol
->value
.integer
.value
[0];
694 if (eapd
== spec
->cur_eapd
)
696 spec
->cur_eapd
= eapd
;
697 snd_hda_codec_write_cache(codec
, nid
,
698 0, AC_VERB_SET_EAPD_BTLENABLE
,
703 static int ad198x_ch_mode_info(struct snd_kcontrol
*kcontrol
,
704 struct snd_ctl_elem_info
*uinfo
);
705 static int ad198x_ch_mode_get(struct snd_kcontrol
*kcontrol
,
706 struct snd_ctl_elem_value
*ucontrol
);
707 static int ad198x_ch_mode_put(struct snd_kcontrol
*kcontrol
,
708 struct snd_ctl_elem_value
*ucontrol
);
715 #define AD1986A_SPDIF_OUT 0x02
716 #define AD1986A_FRONT_DAC 0x03
717 #define AD1986A_SURR_DAC 0x04
718 #define AD1986A_CLFE_DAC 0x05
719 #define AD1986A_ADC 0x06
721 static const hda_nid_t ad1986a_dac_nids
[3] = {
722 AD1986A_FRONT_DAC
, AD1986A_SURR_DAC
, AD1986A_CLFE_DAC
724 static const hda_nid_t ad1986a_adc_nids
[1] = { AD1986A_ADC
};
725 static const hda_nid_t ad1986a_capsrc_nids
[1] = { 0x12 };
727 static const struct hda_input_mux ad1986a_capture_source
= {
741 static const struct hda_bind_ctls ad1986a_bind_pcm_vol
= {
742 .ops
= &snd_hda_bind_vol
,
744 HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC
, 3, 0, HDA_OUTPUT
),
745 HDA_COMPOSE_AMP_VAL(AD1986A_SURR_DAC
, 3, 0, HDA_OUTPUT
),
746 HDA_COMPOSE_AMP_VAL(AD1986A_CLFE_DAC
, 3, 0, HDA_OUTPUT
),
751 static const struct hda_bind_ctls ad1986a_bind_pcm_sw
= {
752 .ops
= &snd_hda_bind_sw
,
754 HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC
, 3, 0, HDA_OUTPUT
),
755 HDA_COMPOSE_AMP_VAL(AD1986A_SURR_DAC
, 3, 0, HDA_OUTPUT
),
756 HDA_COMPOSE_AMP_VAL(AD1986A_CLFE_DAC
, 3, 0, HDA_OUTPUT
),
764 static const struct snd_kcontrol_new ad1986a_mixers
[] = {
766 * bind volumes/mutes of 3 DACs as a single PCM control for simplicity
768 HDA_BIND_VOL("PCM Playback Volume", &ad1986a_bind_pcm_vol
),
769 HDA_BIND_SW("PCM Playback Switch", &ad1986a_bind_pcm_sw
),
770 HDA_CODEC_VOLUME("Front Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
771 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT
),
772 HDA_CODEC_VOLUME("Surround Playback Volume", 0x1c, 0x0, HDA_OUTPUT
),
773 HDA_CODEC_MUTE("Surround Playback Switch", 0x1c, 0x0, HDA_OUTPUT
),
774 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x1d, 1, 0x0, HDA_OUTPUT
),
775 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x1d, 2, 0x0, HDA_OUTPUT
),
776 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x1d, 1, 0x0, HDA_OUTPUT
),
777 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x1d, 2, 0x0, HDA_OUTPUT
),
778 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT
),
779 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT
),
780 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT
),
781 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT
),
782 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT
),
783 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT
),
784 HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT
),
785 HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT
),
786 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
787 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
788 HDA_CODEC_VOLUME("Mic Boost Volume", 0x0f, 0x0, HDA_OUTPUT
),
789 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT
),
790 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT
),
791 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT
),
792 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT
),
794 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
795 .name
= "Capture Source",
796 .info
= ad198x_mux_enum_info
,
797 .get
= ad198x_mux_enum_get
,
798 .put
= ad198x_mux_enum_put
,
800 HDA_CODEC_MUTE("Stereo Downmix Switch", 0x09, 0x0, HDA_OUTPUT
),
804 /* additional mixers for 3stack mode */
805 static const struct snd_kcontrol_new ad1986a_3st_mixers
[] = {
807 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
808 .name
= "Channel Mode",
809 .info
= ad198x_ch_mode_info
,
810 .get
= ad198x_ch_mode_get
,
811 .put
= ad198x_ch_mode_put
,
816 /* laptop model - 2ch only */
817 static const hda_nid_t ad1986a_laptop_dac_nids
[1] = { AD1986A_FRONT_DAC
};
819 /* master controls both pins 0x1a and 0x1b */
820 static const struct hda_bind_ctls ad1986a_laptop_master_vol
= {
821 .ops
= &snd_hda_bind_vol
,
823 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT
),
824 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT
),
829 static const struct hda_bind_ctls ad1986a_laptop_master_sw
= {
830 .ops
= &snd_hda_bind_sw
,
832 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT
),
833 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT
),
838 static const struct snd_kcontrol_new ad1986a_laptop_mixers
[] = {
839 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT
),
840 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT
),
841 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol
),
842 HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw
),
843 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT
),
844 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT
),
845 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT
),
846 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT
),
847 HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT
),
848 HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT
),
849 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
850 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
851 HDA_CODEC_VOLUME("Mic Boost Volume", 0x0f, 0x0, HDA_OUTPUT
),
853 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
854 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), */
855 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT
),
856 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT
),
858 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
859 .name
= "Capture Source",
860 .info
= ad198x_mux_enum_info
,
861 .get
= ad198x_mux_enum_get
,
862 .put
= ad198x_mux_enum_put
,
867 /* laptop-eapd model - 2ch only */
869 static const struct hda_input_mux ad1986a_laptop_eapd_capture_source
= {
873 { "Internal Mic", 0x4 },
878 static const struct hda_input_mux ad1986a_automic_capture_source
= {
886 static const struct snd_kcontrol_new ad1986a_laptop_master_mixers
[] = {
887 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol
),
888 HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw
),
892 static const struct snd_kcontrol_new ad1986a_laptop_eapd_mixers
[] = {
893 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT
),
894 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT
),
895 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
896 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
897 HDA_CODEC_VOLUME("Mic Boost Volume", 0x0f, 0x0, HDA_OUTPUT
),
898 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT
),
899 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT
),
901 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
902 .name
= "Capture Source",
903 .info
= ad198x_mux_enum_info
,
904 .get
= ad198x_mux_enum_get
,
905 .put
= ad198x_mux_enum_put
,
908 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
909 .name
= "External Amplifier",
910 .subdevice
= HDA_SUBDEV_NID_FLAG
| 0x1b,
911 .info
= ad198x_eapd_info
,
912 .get
= ad198x_eapd_get
,
913 .put
= ad198x_eapd_put
,
914 .private_value
= 0x1b, /* port-D */
919 static const struct snd_kcontrol_new ad1986a_laptop_intmic_mixers
[] = {
920 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0, HDA_OUTPUT
),
921 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0, HDA_OUTPUT
),
925 /* re-connect the mic boost input according to the jack sensing */
926 static void ad1986a_automic(struct hda_codec
*codec
)
928 unsigned int present
;
929 present
= snd_hda_jack_detect(codec
, 0x1f);
930 /* 0 = 0x1f, 2 = 0x1d, 4 = mixed */
931 snd_hda_codec_write(codec
, 0x0f, 0, AC_VERB_SET_CONNECT_SEL
,
935 #define AD1986A_MIC_EVENT 0x36
937 static void ad1986a_automic_unsol_event(struct hda_codec
*codec
,
940 if ((res
>> 26) != AD1986A_MIC_EVENT
)
942 ad1986a_automic(codec
);
945 static int ad1986a_automic_init(struct hda_codec
*codec
)
948 ad1986a_automic(codec
);
952 /* laptop-automute - 2ch only */
954 static void ad1986a_update_hp(struct hda_codec
*codec
)
956 struct ad198x_spec
*spec
= codec
->spec
;
959 if (spec
->jack_present
)
960 mute
= HDA_AMP_MUTE
; /* mute internal speaker */
962 /* unmute internal speaker if necessary */
963 mute
= snd_hda_codec_amp_read(codec
, 0x1a, 0, HDA_OUTPUT
, 0);
964 snd_hda_codec_amp_stereo(codec
, 0x1b, HDA_OUTPUT
, 0,
968 static void ad1986a_hp_automute(struct hda_codec
*codec
)
970 struct ad198x_spec
*spec
= codec
->spec
;
972 spec
->jack_present
= snd_hda_jack_detect(codec
, 0x1a);
973 if (spec
->inv_jack_detect
)
974 spec
->jack_present
= !spec
->jack_present
;
975 ad1986a_update_hp(codec
);
978 #define AD1986A_HP_EVENT 0x37
980 static void ad1986a_hp_unsol_event(struct hda_codec
*codec
, unsigned int res
)
982 if ((res
>> 26) != AD1986A_HP_EVENT
)
984 ad1986a_hp_automute(codec
);
987 static int ad1986a_hp_init(struct hda_codec
*codec
)
990 ad1986a_hp_automute(codec
);
994 /* bind hp and internal speaker mute (with plug check) */
995 static int ad1986a_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
996 struct snd_ctl_elem_value
*ucontrol
)
998 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
999 long *valp
= ucontrol
->value
.integer
.value
;
1002 change
= snd_hda_codec_amp_update(codec
, 0x1a, 0, HDA_OUTPUT
, 0,
1004 valp
[0] ? 0 : HDA_AMP_MUTE
);
1005 change
|= snd_hda_codec_amp_update(codec
, 0x1a, 1, HDA_OUTPUT
, 0,
1007 valp
[1] ? 0 : HDA_AMP_MUTE
);
1009 ad1986a_update_hp(codec
);
1013 static const struct snd_kcontrol_new ad1986a_automute_master_mixers
[] = {
1014 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol
),
1016 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1017 .name
= "Master Playback Switch",
1018 .subdevice
= HDA_SUBDEV_AMP_FLAG
,
1019 .info
= snd_hda_mixer_amp_switch_info
,
1020 .get
= snd_hda_mixer_amp_switch_get
,
1021 .put
= ad1986a_hp_master_sw_put
,
1022 .private_value
= HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT
),
1029 * initialization verbs
1031 static const struct hda_verb ad1986a_init_verbs
[] = {
1032 /* Front, Surround, CLFE DAC; mute as default */
1033 {0x03, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1034 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1035 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1037 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1038 /* HP, Line-Out, Surround, CLFE selectors */
1039 {0x0a, AC_VERB_SET_CONNECT_SEL
, 0x0},
1040 {0x0b, AC_VERB_SET_CONNECT_SEL
, 0x0},
1041 {0x0c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1042 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x0},
1044 {0x0e, AC_VERB_SET_CONNECT_SEL
, 0x0},
1045 /* Mic selector: Mic 1/2 pin */
1046 {0x0f, AC_VERB_SET_CONNECT_SEL
, 0x0},
1047 /* Line-in selector: Line-in */
1048 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x0},
1050 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x0},
1051 /* Record selector: mic */
1052 {0x12, AC_VERB_SET_CONNECT_SEL
, 0x0},
1053 /* Mic, Phone, CD, Aux, Line-In amp; mute as default */
1054 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1055 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1056 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1057 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1058 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1060 {0x18, AC_VERB_SET_CONNECT_SEL
, 0x0},
1061 /* HP, Line-Out, Surround, CLFE, Mono pins; mute as default */
1062 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1063 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1064 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1065 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1066 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1068 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0xc0 },
1069 /* Front, Surround, CLFE Pins */
1070 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
1071 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
1072 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
1074 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
1076 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24 },
1077 /* Line, Aux, CD, Beep-In Pin */
1078 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
1079 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
1080 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
1081 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
1082 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
1086 static const struct hda_verb ad1986a_ch2_init
[] = {
1087 /* Surround out -> Line In */
1088 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1089 /* Line-in selectors */
1090 { 0x10, AC_VERB_SET_CONNECT_SEL
, 0x1 },
1091 /* CLFE -> Mic in */
1092 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1093 /* Mic selector, mix C/LFE (backmic) and Mic (frontmic) */
1094 { 0x0f, AC_VERB_SET_CONNECT_SEL
, 0x4 },
1098 static const struct hda_verb ad1986a_ch4_init
[] = {
1099 /* Surround out -> Surround */
1100 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1101 { 0x10, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1102 /* CLFE -> Mic in */
1103 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1104 { 0x0f, AC_VERB_SET_CONNECT_SEL
, 0x4 },
1108 static const struct hda_verb ad1986a_ch6_init
[] = {
1109 /* Surround out -> Surround out */
1110 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1111 { 0x10, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1113 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1114 { 0x0f, AC_VERB_SET_CONNECT_SEL
, 0x0 },
1118 static const struct hda_channel_mode ad1986a_modes
[3] = {
1119 { 2, ad1986a_ch2_init
},
1120 { 4, ad1986a_ch4_init
},
1121 { 6, ad1986a_ch6_init
},
1124 /* eapd initialization */
1125 static const struct hda_verb ad1986a_eapd_init_verbs
[] = {
1126 {0x1b, AC_VERB_SET_EAPD_BTLENABLE
, 0x00 },
1130 static const struct hda_verb ad1986a_automic_verbs
[] = {
1131 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1132 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1133 /*{0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},*/
1134 {0x0f, AC_VERB_SET_CONNECT_SEL
, 0x0},
1135 {0x1f, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1986A_MIC_EVENT
},
1139 /* Ultra initialization */
1140 static const struct hda_verb ad1986a_ultra_init
[] = {
1141 /* eapd initialization */
1142 { 0x1b, AC_VERB_SET_EAPD_BTLENABLE
, 0x00 },
1143 /* CLFE -> Mic in */
1144 { 0x0f, AC_VERB_SET_CONNECT_SEL
, 0x2 },
1145 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24 },
1146 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080 },
1150 /* pin sensing on HP jack */
1151 static const struct hda_verb ad1986a_hp_init_verbs
[] = {
1152 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1986A_HP_EVENT
},
1156 static void ad1986a_samsung_p50_unsol_event(struct hda_codec
*codec
,
1159 switch (res
>> 26) {
1160 case AD1986A_HP_EVENT
:
1161 ad1986a_hp_automute(codec
);
1163 case AD1986A_MIC_EVENT
:
1164 ad1986a_automic(codec
);
1169 static int ad1986a_samsung_p50_init(struct hda_codec
*codec
)
1172 ad1986a_hp_automute(codec
);
1173 ad1986a_automic(codec
);
1183 AD1986A_LAPTOP_EAPD
,
1184 AD1986A_LAPTOP_AUTOMUTE
,
1187 AD1986A_SAMSUNG_P50
,
1191 static const char * const ad1986a_models
[AD1986A_MODELS
] = {
1192 [AD1986A_6STACK
] = "6stack",
1193 [AD1986A_3STACK
] = "3stack",
1194 [AD1986A_LAPTOP
] = "laptop",
1195 [AD1986A_LAPTOP_EAPD
] = "laptop-eapd",
1196 [AD1986A_LAPTOP_AUTOMUTE
] = "laptop-automute",
1197 [AD1986A_ULTRA
] = "ultra",
1198 [AD1986A_SAMSUNG
] = "samsung",
1199 [AD1986A_SAMSUNG_P50
] = "samsung-p50",
1202 static const struct snd_pci_quirk ad1986a_cfg_tbl
[] = {
1203 SND_PCI_QUIRK(0x103c, 0x30af, "HP B2800", AD1986A_LAPTOP_EAPD
),
1204 SND_PCI_QUIRK(0x1043, 0x1153, "ASUS M9", AD1986A_LAPTOP_EAPD
),
1205 SND_PCI_QUIRK(0x1043, 0x11f7, "ASUS U5A", AD1986A_LAPTOP_EAPD
),
1206 SND_PCI_QUIRK(0x1043, 0x1213, "ASUS A6J", AD1986A_LAPTOP_EAPD
),
1207 SND_PCI_QUIRK(0x1043, 0x1263, "ASUS U5F", AD1986A_LAPTOP_EAPD
),
1208 SND_PCI_QUIRK(0x1043, 0x1297, "ASUS Z62F", AD1986A_LAPTOP_EAPD
),
1209 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS V1j", AD1986A_LAPTOP_EAPD
),
1210 SND_PCI_QUIRK(0x1043, 0x1302, "ASUS W3j", AD1986A_LAPTOP_EAPD
),
1211 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS VX1", AD1986A_LAPTOP
),
1212 SND_PCI_QUIRK(0x1043, 0x1447, "ASUS A8J", AD1986A_3STACK
),
1213 SND_PCI_QUIRK(0x1043, 0x817f, "ASUS P5", AD1986A_3STACK
),
1214 SND_PCI_QUIRK(0x1043, 0x818f, "ASUS P5", AD1986A_LAPTOP
),
1215 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS P5", AD1986A_3STACK
),
1216 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS M2N", AD1986A_3STACK
),
1217 SND_PCI_QUIRK(0x1043, 0x8234, "ASUS M2N", AD1986A_3STACK
),
1218 SND_PCI_QUIRK(0x10de, 0xcb84, "ASUS A8N-VM", AD1986A_3STACK
),
1219 SND_PCI_QUIRK(0x1179, 0xff40, "Toshiba Satellite L40-10Q", AD1986A_3STACK
),
1220 SND_PCI_QUIRK(0x144d, 0xb03c, "Samsung R55", AD1986A_3STACK
),
1221 SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP
),
1222 SND_PCI_QUIRK(0x144d, 0xc024, "Samsung P50", AD1986A_SAMSUNG_P50
),
1223 SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_ULTRA
),
1224 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc000, "Samsung", AD1986A_SAMSUNG
),
1225 SND_PCI_QUIRK(0x144d, 0xc504, "Samsung Q35", AD1986A_3STACK
),
1226 SND_PCI_QUIRK(0x17aa, 0x1011, "Lenovo M55", AD1986A_LAPTOP
),
1227 SND_PCI_QUIRK(0x17aa, 0x1017, "Lenovo A60", AD1986A_3STACK
),
1228 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo N100", AD1986A_LAPTOP_AUTOMUTE
),
1229 SND_PCI_QUIRK(0x17c0, 0x2017, "Samsung M50", AD1986A_LAPTOP
),
1233 #ifdef CONFIG_SND_HDA_POWER_SAVE
1234 static const struct hda_amp_list ad1986a_loopbacks
[] = {
1235 { 0x13, HDA_OUTPUT
, 0 }, /* Mic */
1236 { 0x14, HDA_OUTPUT
, 0 }, /* Phone */
1237 { 0x15, HDA_OUTPUT
, 0 }, /* CD */
1238 { 0x16, HDA_OUTPUT
, 0 }, /* Aux */
1239 { 0x17, HDA_OUTPUT
, 0 }, /* Line */
1244 static int is_jack_available(struct hda_codec
*codec
, hda_nid_t nid
)
1246 unsigned int conf
= snd_hda_codec_get_pincfg(codec
, nid
);
1247 return get_defcfg_connect(conf
) != AC_JACK_PORT_NONE
;
1250 static int patch_ad1986a(struct hda_codec
*codec
)
1252 struct ad198x_spec
*spec
;
1253 int err
, board_config
;
1255 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1261 err
= snd_hda_attach_beep_device(codec
, 0x19);
1266 set_beep_amp(spec
, 0x18, 0, HDA_OUTPUT
);
1268 spec
->multiout
.max_channels
= 6;
1269 spec
->multiout
.num_dacs
= ARRAY_SIZE(ad1986a_dac_nids
);
1270 spec
->multiout
.dac_nids
= ad1986a_dac_nids
;
1271 spec
->multiout
.dig_out_nid
= AD1986A_SPDIF_OUT
;
1272 spec
->num_adc_nids
= 1;
1273 spec
->adc_nids
= ad1986a_adc_nids
;
1274 spec
->capsrc_nids
= ad1986a_capsrc_nids
;
1275 spec
->input_mux
= &ad1986a_capture_source
;
1276 spec
->num_mixers
= 1;
1277 spec
->mixers
[0] = ad1986a_mixers
;
1278 spec
->num_init_verbs
= 1;
1279 spec
->init_verbs
[0] = ad1986a_init_verbs
;
1280 #ifdef CONFIG_SND_HDA_POWER_SAVE
1281 spec
->loopback
.amplist
= ad1986a_loopbacks
;
1283 spec
->vmaster_nid
= 0x1b;
1284 spec
->inv_eapd
= 1; /* AD1986A has the inverted EAPD implementation */
1286 codec
->patch_ops
= ad198x_patch_ops
;
1288 /* override some parameters */
1289 board_config
= snd_hda_check_board_config(codec
, AD1986A_MODELS
,
1292 switch (board_config
) {
1293 case AD1986A_3STACK
:
1294 spec
->num_mixers
= 2;
1295 spec
->mixers
[1] = ad1986a_3st_mixers
;
1296 spec
->num_init_verbs
= 2;
1297 spec
->init_verbs
[1] = ad1986a_ch2_init
;
1298 spec
->channel_mode
= ad1986a_modes
;
1299 spec
->num_channel_mode
= ARRAY_SIZE(ad1986a_modes
);
1300 spec
->need_dac_fix
= 1;
1301 spec
->multiout
.max_channels
= 2;
1302 spec
->multiout
.num_dacs
= 1;
1304 case AD1986A_LAPTOP
:
1305 spec
->mixers
[0] = ad1986a_laptop_mixers
;
1306 spec
->multiout
.max_channels
= 2;
1307 spec
->multiout
.num_dacs
= 1;
1308 spec
->multiout
.dac_nids
= ad1986a_laptop_dac_nids
;
1310 case AD1986A_LAPTOP_EAPD
:
1311 spec
->num_mixers
= 3;
1312 spec
->mixers
[0] = ad1986a_laptop_master_mixers
;
1313 spec
->mixers
[1] = ad1986a_laptop_eapd_mixers
;
1314 spec
->mixers
[2] = ad1986a_laptop_intmic_mixers
;
1315 spec
->num_init_verbs
= 2;
1316 spec
->init_verbs
[1] = ad1986a_eapd_init_verbs
;
1317 spec
->multiout
.max_channels
= 2;
1318 spec
->multiout
.num_dacs
= 1;
1319 spec
->multiout
.dac_nids
= ad1986a_laptop_dac_nids
;
1320 if (!is_jack_available(codec
, 0x25))
1321 spec
->multiout
.dig_out_nid
= 0;
1322 spec
->input_mux
= &ad1986a_laptop_eapd_capture_source
;
1324 case AD1986A_SAMSUNG
:
1325 spec
->num_mixers
= 2;
1326 spec
->mixers
[0] = ad1986a_laptop_master_mixers
;
1327 spec
->mixers
[1] = ad1986a_laptop_eapd_mixers
;
1328 spec
->num_init_verbs
= 3;
1329 spec
->init_verbs
[1] = ad1986a_eapd_init_verbs
;
1330 spec
->init_verbs
[2] = ad1986a_automic_verbs
;
1331 spec
->multiout
.max_channels
= 2;
1332 spec
->multiout
.num_dacs
= 1;
1333 spec
->multiout
.dac_nids
= ad1986a_laptop_dac_nids
;
1334 if (!is_jack_available(codec
, 0x25))
1335 spec
->multiout
.dig_out_nid
= 0;
1336 spec
->input_mux
= &ad1986a_automic_capture_source
;
1337 codec
->patch_ops
.unsol_event
= ad1986a_automic_unsol_event
;
1338 codec
->patch_ops
.init
= ad1986a_automic_init
;
1340 case AD1986A_SAMSUNG_P50
:
1341 spec
->num_mixers
= 2;
1342 spec
->mixers
[0] = ad1986a_automute_master_mixers
;
1343 spec
->mixers
[1] = ad1986a_laptop_eapd_mixers
;
1344 spec
->num_init_verbs
= 4;
1345 spec
->init_verbs
[1] = ad1986a_eapd_init_verbs
;
1346 spec
->init_verbs
[2] = ad1986a_automic_verbs
;
1347 spec
->init_verbs
[3] = ad1986a_hp_init_verbs
;
1348 spec
->multiout
.max_channels
= 2;
1349 spec
->multiout
.num_dacs
= 1;
1350 spec
->multiout
.dac_nids
= ad1986a_laptop_dac_nids
;
1351 if (!is_jack_available(codec
, 0x25))
1352 spec
->multiout
.dig_out_nid
= 0;
1353 spec
->input_mux
= &ad1986a_automic_capture_source
;
1354 codec
->patch_ops
.unsol_event
= ad1986a_samsung_p50_unsol_event
;
1355 codec
->patch_ops
.init
= ad1986a_samsung_p50_init
;
1357 case AD1986A_LAPTOP_AUTOMUTE
:
1358 spec
->num_mixers
= 3;
1359 spec
->mixers
[0] = ad1986a_automute_master_mixers
;
1360 spec
->mixers
[1] = ad1986a_laptop_eapd_mixers
;
1361 spec
->mixers
[2] = ad1986a_laptop_intmic_mixers
;
1362 spec
->num_init_verbs
= 3;
1363 spec
->init_verbs
[1] = ad1986a_eapd_init_verbs
;
1364 spec
->init_verbs
[2] = ad1986a_hp_init_verbs
;
1365 spec
->multiout
.max_channels
= 2;
1366 spec
->multiout
.num_dacs
= 1;
1367 spec
->multiout
.dac_nids
= ad1986a_laptop_dac_nids
;
1368 if (!is_jack_available(codec
, 0x25))
1369 spec
->multiout
.dig_out_nid
= 0;
1370 spec
->input_mux
= &ad1986a_laptop_eapd_capture_source
;
1371 codec
->patch_ops
.unsol_event
= ad1986a_hp_unsol_event
;
1372 codec
->patch_ops
.init
= ad1986a_hp_init
;
1373 /* Lenovo N100 seems to report the reversed bit
1374 * for HP jack-sensing
1376 spec
->inv_jack_detect
= 1;
1379 spec
->mixers
[0] = ad1986a_laptop_eapd_mixers
;
1380 spec
->num_init_verbs
= 2;
1381 spec
->init_verbs
[1] = ad1986a_ultra_init
;
1382 spec
->multiout
.max_channels
= 2;
1383 spec
->multiout
.num_dacs
= 1;
1384 spec
->multiout
.dac_nids
= ad1986a_laptop_dac_nids
;
1385 spec
->multiout
.dig_out_nid
= 0;
1389 /* AD1986A has a hardware problem that it can't share a stream
1390 * with multiple output pins. The copy of front to surrounds
1391 * causes noisy or silent outputs at a certain timing, e.g.
1392 * changing the volume.
1393 * So, let's disable the shared stream.
1395 spec
->multiout
.no_share_stream
= 1;
1397 codec
->no_trigger_sense
= 1;
1398 codec
->no_sticky_stream
= 1;
1407 #define AD1983_SPDIF_OUT 0x02
1408 #define AD1983_DAC 0x03
1409 #define AD1983_ADC 0x04
1411 static const hda_nid_t ad1983_dac_nids
[1] = { AD1983_DAC
};
1412 static const hda_nid_t ad1983_adc_nids
[1] = { AD1983_ADC
};
1413 static const hda_nid_t ad1983_capsrc_nids
[1] = { 0x15 };
1415 static const struct hda_input_mux ad1983_capture_source
= {
1421 { "Mix Mono", 0x3 },
1426 * SPDIF playback route
1428 static int ad1983_spdif_route_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
1430 static const char * const texts
[] = { "PCM", "ADC" };
1432 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
1434 uinfo
->value
.enumerated
.items
= 2;
1435 if (uinfo
->value
.enumerated
.item
> 1)
1436 uinfo
->value
.enumerated
.item
= 1;
1437 strcpy(uinfo
->value
.enumerated
.name
, texts
[uinfo
->value
.enumerated
.item
]);
1441 static int ad1983_spdif_route_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
1443 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1444 struct ad198x_spec
*spec
= codec
->spec
;
1446 ucontrol
->value
.enumerated
.item
[0] = spec
->spdif_route
;
1450 static int ad1983_spdif_route_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
1452 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1453 struct ad198x_spec
*spec
= codec
->spec
;
1455 if (ucontrol
->value
.enumerated
.item
[0] > 1)
1457 if (spec
->spdif_route
!= ucontrol
->value
.enumerated
.item
[0]) {
1458 spec
->spdif_route
= ucontrol
->value
.enumerated
.item
[0];
1459 snd_hda_codec_write_cache(codec
, spec
->multiout
.dig_out_nid
, 0,
1460 AC_VERB_SET_CONNECT_SEL
,
1467 static const struct snd_kcontrol_new ad1983_mixers
[] = {
1468 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT
),
1469 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT
),
1470 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT
),
1471 HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT
),
1472 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT
),
1473 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT
),
1474 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
1475 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
1476 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
1477 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
1478 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
1479 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
1480 HDA_CODEC_VOLUME("Mic Boost Volume", 0x0c, 0x0, HDA_OUTPUT
),
1481 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT
),
1482 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT
),
1484 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1485 .name
= "Capture Source",
1486 .info
= ad198x_mux_enum_info
,
1487 .get
= ad198x_mux_enum_get
,
1488 .put
= ad198x_mux_enum_put
,
1491 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1492 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,NONE
) "Source",
1493 .info
= ad1983_spdif_route_info
,
1494 .get
= ad1983_spdif_route_get
,
1495 .put
= ad1983_spdif_route_put
,
1500 static const struct hda_verb ad1983_init_verbs
[] = {
1501 /* Front, HP, Mono; mute as default */
1502 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1503 {0x06, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1504 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1505 /* Beep, PCM, Mic, Line-In: mute */
1506 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1507 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1508 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1509 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1510 /* Front, HP selectors; from Mix */
1511 {0x05, AC_VERB_SET_CONNECT_SEL
, 0x01},
1512 {0x06, AC_VERB_SET_CONNECT_SEL
, 0x01},
1513 /* Mono selector; from Mix */
1514 {0x0b, AC_VERB_SET_CONNECT_SEL
, 0x03},
1515 /* Mic selector; Mic */
1516 {0x0c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1517 /* Line-in selector: Line-in */
1518 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x0},
1519 /* Mic boost: 0dB */
1520 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
1521 /* Record selector: mic */
1522 {0x15, AC_VERB_SET_CONNECT_SEL
, 0x0},
1523 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1524 /* SPDIF route: PCM */
1525 {0x02, AC_VERB_SET_CONNECT_SEL
, 0x0},
1527 {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
1529 {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0xc0 },
1531 {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
1533 {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24 },
1535 {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
1539 #ifdef CONFIG_SND_HDA_POWER_SAVE
1540 static const struct hda_amp_list ad1983_loopbacks
[] = {
1541 { 0x12, HDA_OUTPUT
, 0 }, /* Mic */
1542 { 0x13, HDA_OUTPUT
, 0 }, /* Line */
1547 static int patch_ad1983(struct hda_codec
*codec
)
1549 struct ad198x_spec
*spec
;
1552 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1558 err
= snd_hda_attach_beep_device(codec
, 0x10);
1563 set_beep_amp(spec
, 0x10, 0, HDA_OUTPUT
);
1565 spec
->multiout
.max_channels
= 2;
1566 spec
->multiout
.num_dacs
= ARRAY_SIZE(ad1983_dac_nids
);
1567 spec
->multiout
.dac_nids
= ad1983_dac_nids
;
1568 spec
->multiout
.dig_out_nid
= AD1983_SPDIF_OUT
;
1569 spec
->num_adc_nids
= 1;
1570 spec
->adc_nids
= ad1983_adc_nids
;
1571 spec
->capsrc_nids
= ad1983_capsrc_nids
;
1572 spec
->input_mux
= &ad1983_capture_source
;
1573 spec
->num_mixers
= 1;
1574 spec
->mixers
[0] = ad1983_mixers
;
1575 spec
->num_init_verbs
= 1;
1576 spec
->init_verbs
[0] = ad1983_init_verbs
;
1577 spec
->spdif_route
= 0;
1578 #ifdef CONFIG_SND_HDA_POWER_SAVE
1579 spec
->loopback
.amplist
= ad1983_loopbacks
;
1581 spec
->vmaster_nid
= 0x05;
1583 codec
->patch_ops
= ad198x_patch_ops
;
1585 codec
->no_trigger_sense
= 1;
1586 codec
->no_sticky_stream
= 1;
1593 * AD1981 HD specific
1596 #define AD1981_SPDIF_OUT 0x02
1597 #define AD1981_DAC 0x03
1598 #define AD1981_ADC 0x04
1600 static const hda_nid_t ad1981_dac_nids
[1] = { AD1981_DAC
};
1601 static const hda_nid_t ad1981_adc_nids
[1] = { AD1981_ADC
};
1602 static const hda_nid_t ad1981_capsrc_nids
[1] = { 0x15 };
1604 /* 0x0c, 0x09, 0x0e, 0x0f, 0x19, 0x05, 0x18, 0x17 */
1605 static const struct hda_input_mux ad1981_capture_source
= {
1608 { "Front Mic", 0x0 },
1611 { "Mix Mono", 0x3 },
1618 static const struct snd_kcontrol_new ad1981_mixers
[] = {
1619 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT
),
1620 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT
),
1621 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT
),
1622 HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT
),
1623 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT
),
1624 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT
),
1625 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
1626 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
1627 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
1628 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
1629 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
1630 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
1631 HDA_CODEC_VOLUME("Aux Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
1632 HDA_CODEC_MUTE("Aux Playback Switch", 0x1b, 0x0, HDA_OUTPUT
),
1633 HDA_CODEC_VOLUME("Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT
),
1634 HDA_CODEC_MUTE("Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT
),
1635 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
1636 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT
),
1637 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x08, 0x0, HDA_INPUT
),
1638 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x0, HDA_INPUT
),
1639 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT
),
1640 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT
),
1642 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1643 .name
= "Capture Source",
1644 .info
= ad198x_mux_enum_info
,
1645 .get
= ad198x_mux_enum_get
,
1646 .put
= ad198x_mux_enum_put
,
1648 /* identical with AD1983 */
1650 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1651 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,NONE
) "Source",
1652 .info
= ad1983_spdif_route_info
,
1653 .get
= ad1983_spdif_route_get
,
1654 .put
= ad1983_spdif_route_put
,
1659 static const struct hda_verb ad1981_init_verbs
[] = {
1660 /* Front, HP, Mono; mute as default */
1661 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1662 {0x06, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1663 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1664 /* Beep, PCM, Front Mic, Line, Rear Mic, Aux, CD-In: mute */
1665 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1666 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1667 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1668 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1669 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1670 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1671 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1672 /* Front, HP selectors; from Mix */
1673 {0x05, AC_VERB_SET_CONNECT_SEL
, 0x01},
1674 {0x06, AC_VERB_SET_CONNECT_SEL
, 0x01},
1675 /* Mono selector; from Mix */
1676 {0x0b, AC_VERB_SET_CONNECT_SEL
, 0x03},
1677 /* Mic Mixer; select Front Mic */
1678 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
1679 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1680 /* Mic boost: 0dB */
1681 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
1682 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
1683 /* Record selector: Front mic */
1684 {0x15, AC_VERB_SET_CONNECT_SEL
, 0x0},
1685 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1686 /* SPDIF route: PCM */
1687 {0x02, AC_VERB_SET_CONNECT_SEL
, 0x0},
1689 {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
1691 {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0xc0 },
1693 {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
1694 /* Front & Rear Mic Pins */
1695 {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24 },
1696 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24 },
1698 {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
1700 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x00},
1701 /* Line-Out as Input: disabled */
1702 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1706 #ifdef CONFIG_SND_HDA_POWER_SAVE
1707 static const struct hda_amp_list ad1981_loopbacks
[] = {
1708 { 0x12, HDA_OUTPUT
, 0 }, /* Front Mic */
1709 { 0x13, HDA_OUTPUT
, 0 }, /* Line */
1710 { 0x1b, HDA_OUTPUT
, 0 }, /* Aux */
1711 { 0x1c, HDA_OUTPUT
, 0 }, /* Mic */
1712 { 0x1d, HDA_OUTPUT
, 0 }, /* CD */
1718 * Patch for HP nx6320
1720 * nx6320 uses EAPD in the reverse way - EAPD-on means the internal
1721 * speaker output enabled _and_ mute-LED off.
1724 #define AD1981_HP_EVENT 0x37
1725 #define AD1981_MIC_EVENT 0x38
1727 static const struct hda_verb ad1981_hp_init_verbs
[] = {
1728 {0x05, AC_VERB_SET_EAPD_BTLENABLE
, 0x00 }, /* default off */
1729 /* pin sensing on HP and Mic jacks */
1730 {0x06, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1981_HP_EVENT
},
1731 {0x08, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1981_MIC_EVENT
},
1735 /* turn on/off EAPD (+ mute HP) as a master switch */
1736 static int ad1981_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1737 struct snd_ctl_elem_value
*ucontrol
)
1739 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1740 struct ad198x_spec
*spec
= codec
->spec
;
1742 if (! ad198x_eapd_put(kcontrol
, ucontrol
))
1744 /* change speaker pin appropriately */
1745 snd_hda_set_pin_ctl(codec
, 0x05, spec
->cur_eapd
? PIN_OUT
: 0);
1746 /* toggle HP mute appropriately */
1747 snd_hda_codec_amp_stereo(codec
, 0x06, HDA_OUTPUT
, 0,
1749 spec
->cur_eapd
? 0 : HDA_AMP_MUTE
);
1753 /* bind volumes of both NID 0x05 and 0x06 */
1754 static const struct hda_bind_ctls ad1981_hp_bind_master_vol
= {
1755 .ops
= &snd_hda_bind_vol
,
1757 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT
),
1758 HDA_COMPOSE_AMP_VAL(0x06, 3, 0, HDA_OUTPUT
),
1763 /* mute internal speaker if HP is plugged */
1764 static void ad1981_hp_automute(struct hda_codec
*codec
)
1766 unsigned int present
;
1768 present
= snd_hda_jack_detect(codec
, 0x06);
1769 snd_hda_codec_amp_stereo(codec
, 0x05, HDA_OUTPUT
, 0,
1770 HDA_AMP_MUTE
, present
? HDA_AMP_MUTE
: 0);
1773 /* toggle input of built-in and mic jack appropriately */
1774 static void ad1981_hp_automic(struct hda_codec
*codec
)
1776 static const struct hda_verb mic_jack_on
[] = {
1777 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1778 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
1781 static const struct hda_verb mic_jack_off
[] = {
1782 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1783 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
1786 unsigned int present
;
1788 present
= snd_hda_jack_detect(codec
, 0x08);
1790 snd_hda_sequence_write(codec
, mic_jack_on
);
1792 snd_hda_sequence_write(codec
, mic_jack_off
);
1795 /* unsolicited event for HP jack sensing */
1796 static void ad1981_hp_unsol_event(struct hda_codec
*codec
,
1801 case AD1981_HP_EVENT
:
1802 ad1981_hp_automute(codec
);
1804 case AD1981_MIC_EVENT
:
1805 ad1981_hp_automic(codec
);
1810 static const struct hda_input_mux ad1981_hp_capture_source
= {
1814 { "Docking-Station", 0x1 },
1819 static const struct snd_kcontrol_new ad1981_hp_mixers
[] = {
1820 HDA_BIND_VOL("Master Playback Volume", &ad1981_hp_bind_master_vol
),
1822 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1823 .subdevice
= HDA_SUBDEV_NID_FLAG
| 0x05,
1824 .name
= "Master Playback Switch",
1825 .info
= ad198x_eapd_info
,
1826 .get
= ad198x_eapd_get
,
1827 .put
= ad1981_hp_master_sw_put
,
1828 .private_value
= 0x05,
1830 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
1831 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
1833 /* FIXME: analog mic/line loopback doesn't work with my tests...
1834 * (although recording is OK)
1836 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
1837 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
1838 HDA_CODEC_VOLUME("Docking-Station Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
1839 HDA_CODEC_MUTE("Docking-Station Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
1840 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT
),
1841 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT
),
1842 /* FIXME: does this laptop have analog CD connection? */
1843 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
1844 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT
),
1846 HDA_CODEC_VOLUME("Mic Boost Volume", 0x08, 0x0, HDA_INPUT
),
1847 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x18, 0x0, HDA_INPUT
),
1848 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT
),
1849 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT
),
1851 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1852 .name
= "Capture Source",
1853 .info
= ad198x_mux_enum_info
,
1854 .get
= ad198x_mux_enum_get
,
1855 .put
= ad198x_mux_enum_put
,
1860 /* initialize jack-sensing, too */
1861 static int ad1981_hp_init(struct hda_codec
*codec
)
1864 ad1981_hp_automute(codec
);
1865 ad1981_hp_automic(codec
);
1869 /* configuration for Toshiba Laptops */
1870 static const struct hda_verb ad1981_toshiba_init_verbs
[] = {
1871 {0x05, AC_VERB_SET_EAPD_BTLENABLE
, 0x01 }, /* default on */
1872 /* pin sensing on HP and Mic jacks */
1873 {0x06, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1981_HP_EVENT
},
1874 {0x08, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1981_MIC_EVENT
},
1878 static const struct snd_kcontrol_new ad1981_toshiba_mixers
[] = {
1879 HDA_CODEC_VOLUME("Amp Volume", 0x1a, 0x0, HDA_OUTPUT
),
1880 HDA_CODEC_MUTE("Amp Switch", 0x1a, 0x0, HDA_OUTPUT
),
1884 /* configuration for Lenovo Thinkpad T60 */
1885 static const struct snd_kcontrol_new ad1981_thinkpad_mixers
[] = {
1886 HDA_CODEC_VOLUME("Master Playback Volume", 0x05, 0x0, HDA_OUTPUT
),
1887 HDA_CODEC_MUTE("Master Playback Switch", 0x05, 0x0, HDA_OUTPUT
),
1888 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
1889 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
1890 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
1891 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
1892 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
1893 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT
),
1894 HDA_CODEC_VOLUME("Mic Boost Volume", 0x08, 0x0, HDA_INPUT
),
1895 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT
),
1896 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT
),
1898 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1899 .name
= "Capture Source",
1900 .info
= ad198x_mux_enum_info
,
1901 .get
= ad198x_mux_enum_get
,
1902 .put
= ad198x_mux_enum_put
,
1904 /* identical with AD1983 */
1906 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1907 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,NONE
) "Source",
1908 .info
= ad1983_spdif_route_info
,
1909 .get
= ad1983_spdif_route_get
,
1910 .put
= ad1983_spdif_route_put
,
1915 static const struct hda_input_mux ad1981_thinkpad_capture_source
= {
1933 static const char * const ad1981_models
[AD1981_MODELS
] = {
1935 [AD1981_THINKPAD
] = "thinkpad",
1936 [AD1981_BASIC
] = "basic",
1937 [AD1981_TOSHIBA
] = "toshiba"
1940 static const struct snd_pci_quirk ad1981_cfg_tbl
[] = {
1941 SND_PCI_QUIRK(0x1014, 0x0597, "Lenovo Z60", AD1981_THINKPAD
),
1942 SND_PCI_QUIRK(0x1014, 0x05b7, "Lenovo Z60m", AD1981_THINKPAD
),
1944 SND_PCI_QUIRK_VENDOR(0x103c, "HP nx", AD1981_HP
),
1945 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba U205", AD1981_TOSHIBA
),
1946 /* Lenovo Thinkpad T60/X60/Z6xx */
1947 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo Thinkpad", AD1981_THINKPAD
),
1948 /* HP nx6320 (reversed SSID, H/W bug) */
1949 SND_PCI_QUIRK(0x30b0, 0x103c, "HP nx6320", AD1981_HP
),
1953 static int patch_ad1981(struct hda_codec
*codec
)
1955 struct ad198x_spec
*spec
;
1956 int err
, board_config
;
1958 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1964 err
= snd_hda_attach_beep_device(codec
, 0x10);
1969 set_beep_amp(spec
, 0x0d, 0, HDA_OUTPUT
);
1971 spec
->multiout
.max_channels
= 2;
1972 spec
->multiout
.num_dacs
= ARRAY_SIZE(ad1981_dac_nids
);
1973 spec
->multiout
.dac_nids
= ad1981_dac_nids
;
1974 spec
->multiout
.dig_out_nid
= AD1981_SPDIF_OUT
;
1975 spec
->num_adc_nids
= 1;
1976 spec
->adc_nids
= ad1981_adc_nids
;
1977 spec
->capsrc_nids
= ad1981_capsrc_nids
;
1978 spec
->input_mux
= &ad1981_capture_source
;
1979 spec
->num_mixers
= 1;
1980 spec
->mixers
[0] = ad1981_mixers
;
1981 spec
->num_init_verbs
= 1;
1982 spec
->init_verbs
[0] = ad1981_init_verbs
;
1983 spec
->spdif_route
= 0;
1984 #ifdef CONFIG_SND_HDA_POWER_SAVE
1985 spec
->loopback
.amplist
= ad1981_loopbacks
;
1987 spec
->vmaster_nid
= 0x05;
1989 codec
->patch_ops
= ad198x_patch_ops
;
1991 /* override some parameters */
1992 board_config
= snd_hda_check_board_config(codec
, AD1981_MODELS
,
1995 switch (board_config
) {
1997 spec
->mixers
[0] = ad1981_hp_mixers
;
1998 spec
->num_init_verbs
= 2;
1999 spec
->init_verbs
[1] = ad1981_hp_init_verbs
;
2000 if (!is_jack_available(codec
, 0x0a))
2001 spec
->multiout
.dig_out_nid
= 0;
2002 spec
->input_mux
= &ad1981_hp_capture_source
;
2004 codec
->patch_ops
.init
= ad1981_hp_init
;
2005 codec
->patch_ops
.unsol_event
= ad1981_hp_unsol_event
;
2006 /* set the upper-limit for mixer amp to 0dB for avoiding the
2007 * possible damage by overloading
2009 snd_hda_override_amp_caps(codec
, 0x11, HDA_INPUT
,
2010 (0x17 << AC_AMPCAP_OFFSET_SHIFT
) |
2011 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
2012 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
2013 (1 << AC_AMPCAP_MUTE_SHIFT
));
2015 case AD1981_THINKPAD
:
2016 spec
->mixers
[0] = ad1981_thinkpad_mixers
;
2017 spec
->input_mux
= &ad1981_thinkpad_capture_source
;
2018 /* set the upper-limit for mixer amp to 0dB for avoiding the
2019 * possible damage by overloading
2021 snd_hda_override_amp_caps(codec
, 0x11, HDA_INPUT
,
2022 (0x17 << AC_AMPCAP_OFFSET_SHIFT
) |
2023 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
2024 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
2025 (1 << AC_AMPCAP_MUTE_SHIFT
));
2027 case AD1981_TOSHIBA
:
2028 spec
->mixers
[0] = ad1981_hp_mixers
;
2029 spec
->mixers
[1] = ad1981_toshiba_mixers
;
2030 spec
->num_init_verbs
= 2;
2031 spec
->init_verbs
[1] = ad1981_toshiba_init_verbs
;
2032 spec
->multiout
.dig_out_nid
= 0;
2033 spec
->input_mux
= &ad1981_hp_capture_source
;
2034 codec
->patch_ops
.init
= ad1981_hp_init
;
2035 codec
->patch_ops
.unsol_event
= ad1981_hp_unsol_event
;
2039 codec
->no_trigger_sense
= 1;
2040 codec
->no_sticky_stream
= 1;
2049 * Output pins and routes
2051 * Pin Mix Sel DAC (*)
2052 * port-A 0x11 (mute/hp) <- 0x22 <- 0x37 <- 03/04/06
2053 * port-B 0x14 (mute/hp) <- 0x2b <- 0x30 <- 03/04/06
2054 * port-C 0x15 (mute) <- 0x2c <- 0x31 <- 05/0a
2055 * port-D 0x12 (mute/hp) <- 0x29 <- 04
2056 * port-E 0x17 (mute/hp) <- 0x26 <- 0x32 <- 05/0a
2057 * port-F 0x16 (mute) <- 0x2a <- 06
2058 * port-G 0x24 (mute) <- 0x27 <- 05
2059 * port-H 0x25 (mute) <- 0x28 <- 0a
2060 * mono 0x13 (mute/amp)<- 0x1e <- 0x36 <- 03/04/06
2062 * DAC0 = 03h, DAC1 = 04h, DAC2 = 05h, DAC3 = 06h, DAC4 = 0ah
2063 * (*) DAC2/3/4 are swapped to DAC3/4/2 on AD198A rev.2 due to a h/w bug.
2065 * Input pins and routes
2067 * pin boost mix input # / adc input #
2068 * port-A 0x11 -> 0x38 -> mix 2, ADC 0
2069 * port-B 0x14 -> 0x39 -> mix 0, ADC 1
2070 * port-C 0x15 -> 0x3a -> 33:0 - mix 1, ADC 2
2071 * port-D 0x12 -> 0x3d -> mix 3, ADC 8
2072 * port-E 0x17 -> 0x3c -> 34:0 - mix 4, ADC 4
2073 * port-F 0x16 -> 0x3b -> mix 5, ADC 3
2074 * port-G 0x24 -> N/A -> 33:1 - mix 1, 34:1 - mix 4, ADC 6
2075 * port-H 0x25 -> N/A -> 33:2 - mix 1, 34:2 - mix 4, ADC 7
2079 * 6stack - front/surr/CLFE/side/opt DACs - 04/06/05/0a/03
2080 * 3stack - front/surr/CLFE/opt DACs - 04/05/0a/03
2082 * Inputs of Analog Mix (0x20)
2083 * 0:Port-B (front mic)
2084 * 1:Port-C/G/H (line-in)
2086 * 3:Port-D (line-in/2)
2087 * 4:Port-E/G/H (mic-in)
2088 * 5:Port-F (mic2-in)
2094 * 1:Port-B (front mic-in)
2095 * 2:Port-C (line-in)
2096 * 3:Port-F (mic2-in)
2101 * 8:Port-D (line-in/2)
2104 * Proposed pin assignments by the datasheet
2107 * Port-A front headphone
2117 * Port-A front headphone
2119 * C rear line-in/surround
2121 * E rear mic-in/CLFE
2127 * D internal speaker (with EAPD)
2128 * E/F quad mic array
2144 /* reivision id to check workarounds */
2145 #define AD1988A_REV2 0x100200
2147 #define is_rev2(codec) \
2148 ((codec)->vendor_id == 0x11d41988 && \
2149 (codec)->revision_id == AD1988A_REV2)
2155 static const hda_nid_t ad1988_6stack_dac_nids
[4] = {
2156 0x04, 0x06, 0x05, 0x0a
2159 static const hda_nid_t ad1988_3stack_dac_nids
[3] = {
2163 /* for AD1988A revision-2, DAC2-4 are swapped */
2164 static const hda_nid_t ad1988_6stack_dac_nids_rev2
[4] = {
2165 0x04, 0x05, 0x0a, 0x06
2168 static const hda_nid_t ad1988_alt_dac_nid
[1] = {
2172 static const hda_nid_t ad1988_3stack_dac_nids_rev2
[3] = {
2176 static const hda_nid_t ad1988_adc_nids
[3] = {
2180 static const hda_nid_t ad1988_capsrc_nids
[3] = {
2184 #define AD1988_SPDIF_OUT 0x02
2185 #define AD1988_SPDIF_OUT_HDMI 0x0b
2186 #define AD1988_SPDIF_IN 0x07
2188 static const hda_nid_t ad1989b_slave_dig_outs
[] = {
2189 AD1988_SPDIF_OUT
, AD1988_SPDIF_OUT_HDMI
, 0
2192 static const struct hda_input_mux ad1988_6stack_capture_source
= {
2195 { "Front Mic", 0x1 }, /* port-B */
2196 { "Line", 0x2 }, /* port-C */
2197 { "Mic", 0x4 }, /* port-E */
2203 static const struct hda_input_mux ad1988_laptop_capture_source
= {
2206 { "Mic/Line", 0x1 }, /* port-B */
2214 static int ad198x_ch_mode_info(struct snd_kcontrol
*kcontrol
,
2215 struct snd_ctl_elem_info
*uinfo
)
2217 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2218 struct ad198x_spec
*spec
= codec
->spec
;
2219 return snd_hda_ch_mode_info(codec
, uinfo
, spec
->channel_mode
,
2220 spec
->num_channel_mode
);
2223 static int ad198x_ch_mode_get(struct snd_kcontrol
*kcontrol
,
2224 struct snd_ctl_elem_value
*ucontrol
)
2226 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2227 struct ad198x_spec
*spec
= codec
->spec
;
2228 return snd_hda_ch_mode_get(codec
, ucontrol
, spec
->channel_mode
,
2229 spec
->num_channel_mode
, spec
->multiout
.max_channels
);
2232 static int ad198x_ch_mode_put(struct snd_kcontrol
*kcontrol
,
2233 struct snd_ctl_elem_value
*ucontrol
)
2235 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2236 struct ad198x_spec
*spec
= codec
->spec
;
2237 int err
= snd_hda_ch_mode_put(codec
, ucontrol
, spec
->channel_mode
,
2238 spec
->num_channel_mode
,
2239 &spec
->multiout
.max_channels
);
2240 if (err
>= 0 && spec
->need_dac_fix
)
2241 spec
->multiout
.num_dacs
= spec
->multiout
.max_channels
/ 2;
2245 static const struct snd_kcontrol_new ad1988_hp_mixers
[] = {
2247 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2248 .name
= "Independent HP",
2249 .info
= ad1988_independent_hp_info
,
2250 .get
= ad1988_independent_hp_get
,
2251 .put
= ad1988_independent_hp_put
,
2257 static const struct snd_kcontrol_new ad1988_6stack_mixers1
[] = {
2258 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
2259 HDA_CODEC_VOLUME("Surround Playback Volume", 0x06, 0x0, HDA_OUTPUT
),
2260 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT
),
2261 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT
),
2262 HDA_CODEC_VOLUME("Side Playback Volume", 0x0a, 0x0, HDA_OUTPUT
),
2266 static const struct snd_kcontrol_new ad1988_6stack_mixers1_rev2
[] = {
2267 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
2268 HDA_CODEC_VOLUME("Surround Playback Volume", 0x05, 0x0, HDA_OUTPUT
),
2269 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT
),
2270 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0a, 2, 0x0, HDA_OUTPUT
),
2271 HDA_CODEC_VOLUME("Side Playback Volume", 0x06, 0x0, HDA_OUTPUT
),
2275 static const struct snd_kcontrol_new ad1988_6stack_mixers2
[] = {
2276 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT
),
2277 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT
),
2278 HDA_BIND_MUTE("Surround Playback Switch", 0x2a, 2, HDA_INPUT
),
2279 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x27, 1, 2, HDA_INPUT
),
2280 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x27, 2, 2, HDA_INPUT
),
2281 HDA_BIND_MUTE("Side Playback Switch", 0x28, 2, HDA_INPUT
),
2282 HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT
),
2283 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT
),
2285 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT
),
2286 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT
),
2287 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT
),
2288 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT
),
2289 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT
),
2290 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT
),
2291 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT
),
2292 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT
),
2294 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT
),
2295 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT
),
2297 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x39, 0x0, HDA_OUTPUT
),
2298 HDA_CODEC_VOLUME("Mic Boost Volume", 0x3c, 0x0, HDA_OUTPUT
),
2303 static const struct snd_kcontrol_new ad1988_3stack_mixers1
[] = {
2304 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
2305 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT
),
2306 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT
),
2307 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT
),
2311 static const struct snd_kcontrol_new ad1988_3stack_mixers1_rev2
[] = {
2312 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
2313 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT
),
2314 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x06, 1, 0x0, HDA_OUTPUT
),
2315 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x06, 2, 0x0, HDA_OUTPUT
),
2319 static const struct snd_kcontrol_new ad1988_3stack_mixers2
[] = {
2320 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT
),
2321 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT
),
2322 HDA_BIND_MUTE("Surround Playback Switch", 0x2c, 2, HDA_INPUT
),
2323 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x26, 1, 2, HDA_INPUT
),
2324 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x26, 2, 2, HDA_INPUT
),
2325 HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT
),
2326 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT
),
2328 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT
),
2329 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT
),
2330 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT
),
2331 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT
),
2332 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT
),
2333 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT
),
2334 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT
),
2335 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT
),
2337 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT
),
2338 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT
),
2340 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x39, 0x0, HDA_OUTPUT
),
2341 HDA_CODEC_VOLUME("Mic Boost Volume", 0x3c, 0x0, HDA_OUTPUT
),
2343 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2344 .name
= "Channel Mode",
2345 .info
= ad198x_ch_mode_info
,
2346 .get
= ad198x_ch_mode_get
,
2347 .put
= ad198x_ch_mode_put
,
2354 static const struct snd_kcontrol_new ad1988_laptop_mixers
[] = {
2355 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT
),
2356 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
2357 HDA_CODEC_MUTE("PCM Playback Switch", 0x29, 0x0, HDA_INPUT
),
2358 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT
),
2360 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT
),
2361 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT
),
2362 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x0, HDA_INPUT
),
2363 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x0, HDA_INPUT
),
2364 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT
),
2365 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT
),
2367 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT
),
2368 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT
),
2370 HDA_CODEC_VOLUME("Mic Boost Volume", 0x39, 0x0, HDA_OUTPUT
),
2373 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2374 .name
= "External Amplifier",
2375 .subdevice
= HDA_SUBDEV_NID_FLAG
| 0x12,
2376 .info
= ad198x_eapd_info
,
2377 .get
= ad198x_eapd_get
,
2378 .put
= ad198x_eapd_put
,
2379 .private_value
= 0x12, /* port-D */
2386 static const struct snd_kcontrol_new ad1988_capture_mixers
[] = {
2387 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
2388 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
2389 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT
),
2390 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT
),
2391 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x0e, 0x0, HDA_OUTPUT
),
2392 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x0e, 0x0, HDA_OUTPUT
),
2394 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2395 /* The multiple "Capture Source" controls confuse alsamixer
2396 * So call somewhat different..
2398 /* .name = "Capture Source", */
2399 .name
= "Input Source",
2401 .info
= ad198x_mux_enum_info
,
2402 .get
= ad198x_mux_enum_get
,
2403 .put
= ad198x_mux_enum_put
,
2408 static int ad1988_spdif_playback_source_info(struct snd_kcontrol
*kcontrol
,
2409 struct snd_ctl_elem_info
*uinfo
)
2411 static const char * const texts
[] = {
2412 "PCM", "ADC1", "ADC2", "ADC3"
2414 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
2416 uinfo
->value
.enumerated
.items
= 4;
2417 if (uinfo
->value
.enumerated
.item
>= 4)
2418 uinfo
->value
.enumerated
.item
= 3;
2419 strcpy(uinfo
->value
.enumerated
.name
, texts
[uinfo
->value
.enumerated
.item
]);
2423 static int ad1988_spdif_playback_source_get(struct snd_kcontrol
*kcontrol
,
2424 struct snd_ctl_elem_value
*ucontrol
)
2426 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2429 sel
= snd_hda_codec_read(codec
, 0x1d, 0, AC_VERB_GET_AMP_GAIN_MUTE
,
2432 ucontrol
->value
.enumerated
.item
[0] = 0;
2434 sel
= snd_hda_codec_read(codec
, 0x0b, 0,
2435 AC_VERB_GET_CONNECT_SEL
, 0);
2440 ucontrol
->value
.enumerated
.item
[0] = sel
;
2445 static int ad1988_spdif_playback_source_put(struct snd_kcontrol
*kcontrol
,
2446 struct snd_ctl_elem_value
*ucontrol
)
2448 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2449 unsigned int val
, sel
;
2452 val
= ucontrol
->value
.enumerated
.item
[0];
2456 sel
= snd_hda_codec_read(codec
, 0x1d, 0,
2457 AC_VERB_GET_AMP_GAIN_MUTE
,
2459 change
= sel
& 0x80;
2461 snd_hda_codec_write_cache(codec
, 0x1d, 0,
2462 AC_VERB_SET_AMP_GAIN_MUTE
,
2464 snd_hda_codec_write_cache(codec
, 0x1d, 0,
2465 AC_VERB_SET_AMP_GAIN_MUTE
,
2469 sel
= snd_hda_codec_read(codec
, 0x1d, 0,
2470 AC_VERB_GET_AMP_GAIN_MUTE
,
2471 AC_AMP_GET_INPUT
| 0x01);
2472 change
= sel
& 0x80;
2474 snd_hda_codec_write_cache(codec
, 0x1d, 0,
2475 AC_VERB_SET_AMP_GAIN_MUTE
,
2477 snd_hda_codec_write_cache(codec
, 0x1d, 0,
2478 AC_VERB_SET_AMP_GAIN_MUTE
,
2481 sel
= snd_hda_codec_read(codec
, 0x0b, 0,
2482 AC_VERB_GET_CONNECT_SEL
, 0) + 1;
2483 change
|= sel
!= val
;
2485 snd_hda_codec_write_cache(codec
, 0x0b, 0,
2486 AC_VERB_SET_CONNECT_SEL
,
2492 static const struct snd_kcontrol_new ad1988_spdif_out_mixers
[] = {
2493 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
2495 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2496 .name
= "IEC958 Playback Source",
2497 .subdevice
= HDA_SUBDEV_NID_FLAG
| 0x1b,
2498 .info
= ad1988_spdif_playback_source_info
,
2499 .get
= ad1988_spdif_playback_source_get
,
2500 .put
= ad1988_spdif_playback_source_put
,
2505 static const struct snd_kcontrol_new ad1988_spdif_in_mixers
[] = {
2506 HDA_CODEC_VOLUME("IEC958 Capture Volume", 0x1c, 0x0, HDA_INPUT
),
2510 static const struct snd_kcontrol_new ad1989_spdif_out_mixers
[] = {
2511 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
2512 HDA_CODEC_VOLUME("HDMI Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
2517 * initialization verbs
2521 * for 6-stack (+dig)
2523 static const struct hda_verb ad1988_6stack_init_verbs
[] = {
2524 /* Front, Surround, CLFE, side DAC; unmute as default */
2525 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2526 {0x06, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2527 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2528 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2529 /* Port-A front headphon path */
2530 {0x37, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC0:03h */
2531 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2532 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2533 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2534 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2535 /* Port-D line-out path */
2536 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2537 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2538 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2539 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2540 /* Port-F surround path */
2541 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2542 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2543 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2544 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2545 /* Port-G CLFE path */
2546 {0x27, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2547 {0x27, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2548 {0x24, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2549 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2550 /* Port-H side path */
2551 {0x28, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2552 {0x28, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2553 {0x25, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2554 {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2556 {0x36, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* DAC1:04h */
2557 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2558 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2559 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2560 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb01f}, /* unmute, 0dB */
2561 /* Port-B front mic-in path */
2562 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2563 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2564 {0x39, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2565 /* Port-C line-in path */
2566 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2567 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2568 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2569 {0x33, AC_VERB_SET_CONNECT_SEL
, 0x0},
2570 /* Port-E mic-in path */
2571 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2572 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2573 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2574 {0x34, AC_VERB_SET_CONNECT_SEL
, 0x0},
2575 /* Analog CD Input */
2576 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2577 /* Analog Mix output amp */
2578 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x1f}, /* 0dB */
2583 static const struct hda_verb ad1988_6stack_fp_init_verbs
[] = {
2584 /* Headphone; unmute as default */
2585 {0x03, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2586 /* Port-A front headphon path */
2587 {0x37, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC0:03h */
2588 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2589 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2590 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2591 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2596 static const struct hda_verb ad1988_capture_init_verbs
[] = {
2597 /* mute analog mix */
2598 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2599 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2600 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2601 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2602 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2603 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)},
2604 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)},
2605 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)},
2606 /* select ADCs - front-mic */
2607 {0x0c, AC_VERB_SET_CONNECT_SEL
, 0x1},
2608 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x1},
2609 {0x0e, AC_VERB_SET_CONNECT_SEL
, 0x1},
2614 static const struct hda_verb ad1988_spdif_init_verbs
[] = {
2616 {0x02, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* PCM */
2617 {0x0b, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* ADC1 */
2618 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2619 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2621 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x27}, /* 0dB */
2626 static const struct hda_verb ad1988_spdif_in_init_verbs
[] = {
2627 /* unmute SPDIF input pin */
2628 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2632 /* AD1989 has no ADC -> SPDIF route */
2633 static const struct hda_verb ad1989_spdif_init_verbs
[] = {
2634 /* SPDIF-1 out pin */
2635 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2636 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x27}, /* 0dB */
2637 /* SPDIF-2/HDMI out pin */
2638 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2639 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x27}, /* 0dB */
2644 * verbs for 3stack (+dig)
2646 static const struct hda_verb ad1988_3stack_ch2_init
[] = {
2647 /* set port-C to line-in */
2648 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2649 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2650 /* set port-E to mic-in */
2651 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2652 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2656 static const struct hda_verb ad1988_3stack_ch6_init
[] = {
2657 /* set port-C to surround out */
2658 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2659 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2660 /* set port-E to CLFE out */
2661 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2662 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2666 static const struct hda_channel_mode ad1988_3stack_modes
[2] = {
2667 { 2, ad1988_3stack_ch2_init
},
2668 { 6, ad1988_3stack_ch6_init
},
2671 static const struct hda_verb ad1988_3stack_init_verbs
[] = {
2672 /* Front, Surround, CLFE, side DAC; unmute as default */
2673 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2674 {0x06, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2675 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2676 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2677 /* Port-A front headphon path */
2678 {0x37, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC0:03h */
2679 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2680 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2681 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2682 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2683 /* Port-D line-out path */
2684 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2685 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2686 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2687 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2689 {0x36, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* DAC1:04h */
2690 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2691 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2692 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2693 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb01f}, /* unmute, 0dB */
2694 /* Port-B front mic-in path */
2695 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2696 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2697 {0x39, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2698 /* Port-C line-in/surround path - 6ch mode as default */
2699 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2700 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2701 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2702 {0x31, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* output sel: DAC 0x05 */
2703 {0x33, AC_VERB_SET_CONNECT_SEL
, 0x0},
2704 /* Port-E mic-in/CLFE path - 6ch mode as default */
2705 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2706 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2707 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2708 {0x32, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* output sel: DAC 0x0a */
2709 {0x34, AC_VERB_SET_CONNECT_SEL
, 0x0},
2710 /* mute analog mix */
2711 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2712 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2713 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2714 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2715 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2716 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)},
2717 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)},
2718 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)},
2719 /* select ADCs - front-mic */
2720 {0x0c, AC_VERB_SET_CONNECT_SEL
, 0x1},
2721 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x1},
2722 {0x0e, AC_VERB_SET_CONNECT_SEL
, 0x1},
2723 /* Analog Mix output amp */
2724 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x1f}, /* 0dB */
2729 * verbs for laptop mode (+dig)
2731 static const struct hda_verb ad1988_laptop_hp_on
[] = {
2732 /* unmute port-A and mute port-D */
2733 { 0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2734 { 0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2737 static const struct hda_verb ad1988_laptop_hp_off
[] = {
2738 /* mute port-A and unmute port-D */
2739 { 0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2740 { 0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2744 #define AD1988_HP_EVENT 0x01
2746 static const struct hda_verb ad1988_laptop_init_verbs
[] = {
2747 /* Front, Surround, CLFE, side DAC; unmute as default */
2748 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2749 {0x06, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2750 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2751 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2752 /* Port-A front headphon path */
2753 {0x37, AC_VERB_SET_CONNECT_SEL
, 0x00}, /* DAC0:03h */
2754 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2755 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2756 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2757 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2758 /* unsolicited event for pin-sense */
2759 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1988_HP_EVENT
},
2760 /* Port-D line-out path + EAPD */
2761 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2762 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2763 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2764 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2765 {0x12, AC_VERB_SET_EAPD_BTLENABLE
, 0x00}, /* EAPD-off */
2767 {0x36, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* DAC1:04h */
2768 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2769 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2770 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2771 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb01f}, /* unmute, 0dB */
2772 /* Port-B mic-in path */
2773 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2774 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2775 {0x39, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2776 /* Port-C docking station - try to output */
2777 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2778 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2779 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2780 {0x33, AC_VERB_SET_CONNECT_SEL
, 0x0},
2781 /* mute analog mix */
2782 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2783 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2784 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2785 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2786 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2787 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)},
2788 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)},
2789 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)},
2790 /* select ADCs - mic */
2791 {0x0c, AC_VERB_SET_CONNECT_SEL
, 0x1},
2792 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x1},
2793 {0x0e, AC_VERB_SET_CONNECT_SEL
, 0x1},
2794 /* Analog Mix output amp */
2795 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x1f}, /* 0dB */
2799 static void ad1988_laptop_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2801 if ((res
>> 26) != AD1988_HP_EVENT
)
2803 if (snd_hda_jack_detect(codec
, 0x11))
2804 snd_hda_sequence_write(codec
, ad1988_laptop_hp_on
);
2806 snd_hda_sequence_write(codec
, ad1988_laptop_hp_off
);
2809 #ifdef CONFIG_SND_HDA_POWER_SAVE
2810 static const struct hda_amp_list ad1988_loopbacks
[] = {
2811 { 0x20, HDA_INPUT
, 0 }, /* Front Mic */
2812 { 0x20, HDA_INPUT
, 1 }, /* Line */
2813 { 0x20, HDA_INPUT
, 4 }, /* Mic */
2814 { 0x20, HDA_INPUT
, 6 }, /* CD */
2820 * Automatic parse of I/O pins from the BIOS configuration
2828 static const struct snd_kcontrol_new ad1988_control_templates
[] = {
2829 HDA_CODEC_VOLUME(NULL
, 0, 0, 0),
2830 HDA_CODEC_MUTE(NULL
, 0, 0, 0),
2831 HDA_BIND_MUTE(NULL
, 0, 0, 0),
2834 /* add dynamic controls */
2835 static int add_control(struct ad198x_spec
*spec
, int type
, const char *name
,
2838 struct snd_kcontrol_new
*knew
;
2840 snd_array_init(&spec
->kctls
, sizeof(*knew
), 32);
2841 knew
= snd_array_new(&spec
->kctls
);
2844 *knew
= ad1988_control_templates
[type
];
2845 knew
->name
= kstrdup(name
, GFP_KERNEL
);
2848 if (get_amp_nid_(val
))
2849 knew
->subdevice
= HDA_SUBDEV_AMP_FLAG
;
2850 knew
->private_value
= val
;
2854 #define AD1988_PIN_CD_NID 0x18
2855 #define AD1988_PIN_BEEP_NID 0x10
2857 static const hda_nid_t ad1988_mixer_nids
[8] = {
2858 /* A B C D E F G H */
2859 0x22, 0x2b, 0x2c, 0x29, 0x26, 0x2a, 0x27, 0x28
2862 static inline hda_nid_t
ad1988_idx_to_dac(struct hda_codec
*codec
, int idx
)
2864 static const hda_nid_t idx_to_dac
[8] = {
2865 /* A B C D E F G H */
2866 0x03, 0x06, 0x05, 0x04, 0x0a, 0x06, 0x05, 0x0a
2868 static const hda_nid_t idx_to_dac_rev2
[8] = {
2869 /* A B C D E F G H */
2870 0x03, 0x05, 0x0a, 0x04, 0x06, 0x05, 0x0a, 0x06
2873 return idx_to_dac_rev2
[idx
];
2875 return idx_to_dac
[idx
];
2878 static const hda_nid_t ad1988_boost_nids
[8] = {
2879 0x38, 0x39, 0x3a, 0x3d, 0x3c, 0x3b, 0, 0
2882 static int ad1988_pin_idx(hda_nid_t nid
)
2884 static const hda_nid_t ad1988_io_pins
[8] = {
2885 0x11, 0x14, 0x15, 0x12, 0x17, 0x16, 0x24, 0x25
2888 for (i
= 0; i
< ARRAY_SIZE(ad1988_io_pins
); i
++)
2889 if (ad1988_io_pins
[i
] == nid
)
2891 return 0; /* should be -1 */
2894 static int ad1988_pin_to_loopback_idx(hda_nid_t nid
)
2896 static const int loopback_idx
[8] = {
2897 2, 0, 1, 3, 4, 5, 1, 4
2900 case AD1988_PIN_CD_NID
:
2903 return loopback_idx
[ad1988_pin_idx(nid
)];
2907 static int ad1988_pin_to_adc_idx(hda_nid_t nid
)
2909 static const int adc_idx
[8] = {
2910 0, 1, 2, 8, 4, 3, 6, 7
2913 case AD1988_PIN_CD_NID
:
2916 return adc_idx
[ad1988_pin_idx(nid
)];
2920 /* fill in the dac_nids table from the parsed pin configuration */
2921 static int ad1988_auto_fill_dac_nids(struct hda_codec
*codec
,
2922 const struct auto_pin_cfg
*cfg
)
2924 struct ad198x_spec
*spec
= codec
->spec
;
2927 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
2929 /* check the pins hardwired to audio widget */
2930 for (i
= 0; i
< cfg
->line_outs
; i
++) {
2931 idx
= ad1988_pin_idx(cfg
->line_out_pins
[i
]);
2932 spec
->private_dac_nids
[i
] = ad1988_idx_to_dac(codec
, idx
);
2934 spec
->multiout
.num_dacs
= cfg
->line_outs
;
2938 /* add playback controls from the parsed DAC table */
2939 static int ad1988_auto_create_multi_out_ctls(struct ad198x_spec
*spec
,
2940 const struct auto_pin_cfg
*cfg
)
2943 static const char * const chname
[4] = {
2944 "Front", "Surround", NULL
/*CLFE*/, "Side"
2949 for (i
= 0; i
< cfg
->line_outs
; i
++) {
2950 hda_nid_t dac
= spec
->multiout
.dac_nids
[i
];
2953 nid
= ad1988_mixer_nids
[ad1988_pin_idx(cfg
->line_out_pins
[i
])];
2956 err
= add_control(spec
, AD_CTL_WIDGET_VOL
,
2957 "Center Playback Volume",
2958 HDA_COMPOSE_AMP_VAL(dac
, 1, 0, HDA_OUTPUT
));
2961 err
= add_control(spec
, AD_CTL_WIDGET_VOL
,
2962 "LFE Playback Volume",
2963 HDA_COMPOSE_AMP_VAL(dac
, 2, 0, HDA_OUTPUT
));
2966 err
= add_control(spec
, AD_CTL_BIND_MUTE
,
2967 "Center Playback Switch",
2968 HDA_COMPOSE_AMP_VAL(nid
, 1, 2, HDA_INPUT
));
2971 err
= add_control(spec
, AD_CTL_BIND_MUTE
,
2972 "LFE Playback Switch",
2973 HDA_COMPOSE_AMP_VAL(nid
, 2, 2, HDA_INPUT
));
2977 sprintf(name
, "%s Playback Volume", chname
[i
]);
2978 err
= add_control(spec
, AD_CTL_WIDGET_VOL
, name
,
2979 HDA_COMPOSE_AMP_VAL(dac
, 3, 0, HDA_OUTPUT
));
2982 sprintf(name
, "%s Playback Switch", chname
[i
]);
2983 err
= add_control(spec
, AD_CTL_BIND_MUTE
, name
,
2984 HDA_COMPOSE_AMP_VAL(nid
, 3, 2, HDA_INPUT
));
2992 /* add playback controls for speaker and HP outputs */
2993 static int ad1988_auto_create_extra_out(struct hda_codec
*codec
, hda_nid_t pin
,
2996 struct ad198x_spec
*spec
= codec
->spec
;
3004 idx
= ad1988_pin_idx(pin
);
3005 nid
= ad1988_idx_to_dac(codec
, idx
);
3006 /* check whether the corresponding DAC was already taken */
3007 for (i
= 0; i
< spec
->autocfg
.line_outs
; i
++) {
3008 hda_nid_t pin
= spec
->autocfg
.line_out_pins
[i
];
3009 hda_nid_t dac
= ad1988_idx_to_dac(codec
, ad1988_pin_idx(pin
));
3013 if (i
>= spec
->autocfg
.line_outs
) {
3014 /* specify the DAC as the extra output */
3015 if (!spec
->multiout
.hp_nid
)
3016 spec
->multiout
.hp_nid
= nid
;
3018 spec
->multiout
.extra_out_nid
[0] = nid
;
3019 /* control HP volume/switch on the output mixer amp */
3020 sprintf(name
, "%s Playback Volume", pfx
);
3021 err
= add_control(spec
, AD_CTL_WIDGET_VOL
, name
,
3022 HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
));
3026 nid
= ad1988_mixer_nids
[idx
];
3027 sprintf(name
, "%s Playback Switch", pfx
);
3028 if ((err
= add_control(spec
, AD_CTL_BIND_MUTE
, name
,
3029 HDA_COMPOSE_AMP_VAL(nid
, 3, 2, HDA_INPUT
))) < 0)
3034 /* create input playback/capture controls for the given pin */
3035 static int new_analog_input(struct ad198x_spec
*spec
, hda_nid_t pin
,
3036 const char *ctlname
, int ctlidx
, int boost
)
3041 sprintf(name
, "%s Playback Volume", ctlname
);
3042 idx
= ad1988_pin_to_loopback_idx(pin
);
3043 if ((err
= add_control(spec
, AD_CTL_WIDGET_VOL
, name
,
3044 HDA_COMPOSE_AMP_VAL(0x20, 3, idx
, HDA_INPUT
))) < 0)
3046 sprintf(name
, "%s Playback Switch", ctlname
);
3047 if ((err
= add_control(spec
, AD_CTL_WIDGET_MUTE
, name
,
3048 HDA_COMPOSE_AMP_VAL(0x20, 3, idx
, HDA_INPUT
))) < 0)
3052 idx
= ad1988_pin_idx(pin
);
3053 bnid
= ad1988_boost_nids
[idx
];
3055 sprintf(name
, "%s Boost Volume", ctlname
);
3056 return add_control(spec
, AD_CTL_WIDGET_VOL
, name
,
3057 HDA_COMPOSE_AMP_VAL(bnid
, 3, idx
, HDA_OUTPUT
));
3064 /* create playback/capture controls for input pins */
3065 static int ad1988_auto_create_analog_input_ctls(struct hda_codec
*codec
,
3066 const struct auto_pin_cfg
*cfg
)
3068 struct ad198x_spec
*spec
= codec
->spec
;
3069 struct hda_input_mux
*imux
= &spec
->private_imux
;
3070 int i
, err
, type
, type_idx
;
3072 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3074 type
= cfg
->inputs
[i
].type
;
3075 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
3076 snd_hda_add_imux_item(imux
, label
,
3077 ad1988_pin_to_adc_idx(cfg
->inputs
[i
].pin
),
3079 err
= new_analog_input(spec
, cfg
->inputs
[i
].pin
,
3081 type
== AUTO_PIN_MIC
);
3085 snd_hda_add_imux_item(imux
, "Mix", 9, NULL
);
3087 if ((err
= add_control(spec
, AD_CTL_WIDGET_VOL
,
3088 "Analog Mix Playback Volume",
3089 HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT
))) < 0)
3091 if ((err
= add_control(spec
, AD_CTL_WIDGET_MUTE
,
3092 "Analog Mix Playback Switch",
3093 HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT
))) < 0)
3099 static void ad1988_auto_set_output_and_unmute(struct hda_codec
*codec
,
3100 hda_nid_t nid
, int pin_type
,
3104 snd_hda_set_pin_ctl(codec
, nid
, pin_type
);
3105 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
);
3107 case 0x11: /* port-A - DAC 03 */
3108 snd_hda_codec_write(codec
, 0x37, 0, AC_VERB_SET_CONNECT_SEL
, 0x00);
3110 case 0x14: /* port-B - DAC 06 */
3111 snd_hda_codec_write(codec
, 0x30, 0, AC_VERB_SET_CONNECT_SEL
, 0x02);
3113 case 0x15: /* port-C - DAC 05 */
3114 snd_hda_codec_write(codec
, 0x31, 0, AC_VERB_SET_CONNECT_SEL
, 0x00);
3116 case 0x17: /* port-E - DAC 0a */
3117 snd_hda_codec_write(codec
, 0x32, 0, AC_VERB_SET_CONNECT_SEL
, 0x01);
3119 case 0x13: /* mono - DAC 04 */
3120 snd_hda_codec_write(codec
, 0x36, 0, AC_VERB_SET_CONNECT_SEL
, 0x01);
3125 static void ad1988_auto_init_multi_out(struct hda_codec
*codec
)
3127 struct ad198x_spec
*spec
= codec
->spec
;
3130 for (i
= 0; i
< spec
->autocfg
.line_outs
; i
++) {
3131 hda_nid_t nid
= spec
->autocfg
.line_out_pins
[i
];
3132 ad1988_auto_set_output_and_unmute(codec
, nid
, PIN_OUT
, i
);
3136 static void ad1988_auto_init_extra_out(struct hda_codec
*codec
)
3138 struct ad198x_spec
*spec
= codec
->spec
;
3141 pin
= spec
->autocfg
.speaker_pins
[0];
3142 if (pin
) /* connect to front */
3143 ad1988_auto_set_output_and_unmute(codec
, pin
, PIN_OUT
, 0);
3144 pin
= spec
->autocfg
.hp_pins
[0];
3145 if (pin
) /* connect to front */
3146 ad1988_auto_set_output_and_unmute(codec
, pin
, PIN_HP
, 0);
3149 static void ad1988_auto_init_analog_input(struct hda_codec
*codec
)
3151 struct ad198x_spec
*spec
= codec
->spec
;
3152 const struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3155 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3156 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
3157 int type
= cfg
->inputs
[i
].type
;
3160 case 0x15: /* port-C */
3161 snd_hda_codec_write(codec
, 0x33, 0, AC_VERB_SET_CONNECT_SEL
, 0x0);
3163 case 0x17: /* port-E */
3164 snd_hda_codec_write(codec
, 0x34, 0, AC_VERB_SET_CONNECT_SEL
, 0x0);
3168 if (type
== AUTO_PIN_MIC
)
3169 val
|= snd_hda_get_default_vref(codec
, nid
);
3170 snd_hda_set_pin_ctl(codec
, nid
, val
);
3171 if (nid
!= AD1988_PIN_CD_NID
)
3172 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3174 idx
= ad1988_pin_idx(nid
);
3175 if (ad1988_boost_nids
[idx
])
3176 snd_hda_codec_write(codec
, ad1988_boost_nids
[idx
], 0,
3177 AC_VERB_SET_AMP_GAIN_MUTE
,
3182 /* parse the BIOS configuration and set up the alc_spec */
3183 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
3184 static int ad1988_parse_auto_config(struct hda_codec
*codec
)
3186 struct ad198x_spec
*spec
= codec
->spec
;
3189 if ((err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
)) < 0)
3191 if ((err
= ad1988_auto_fill_dac_nids(codec
, &spec
->autocfg
)) < 0)
3193 if (! spec
->autocfg
.line_outs
)
3194 return 0; /* can't find valid BIOS pin config */
3195 if ((err
= ad1988_auto_create_multi_out_ctls(spec
, &spec
->autocfg
)) < 0 ||
3196 (err
= ad1988_auto_create_extra_out(codec
,
3197 spec
->autocfg
.speaker_pins
[0],
3199 (err
= ad1988_auto_create_extra_out(codec
, spec
->autocfg
.hp_pins
[0],
3200 "Headphone")) < 0 ||
3201 (err
= ad1988_auto_create_analog_input_ctls(codec
, &spec
->autocfg
)) < 0)
3204 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
3206 if (spec
->autocfg
.dig_outs
)
3207 spec
->multiout
.dig_out_nid
= AD1988_SPDIF_OUT
;
3208 if (spec
->autocfg
.dig_in_pin
)
3209 spec
->dig_in_nid
= AD1988_SPDIF_IN
;
3211 if (spec
->kctls
.list
)
3212 spec
->mixers
[spec
->num_mixers
++] = spec
->kctls
.list
;
3214 spec
->init_verbs
[spec
->num_init_verbs
++] = ad1988_6stack_init_verbs
;
3216 spec
->input_mux
= &spec
->private_imux
;
3221 /* init callback for auto-configuration model -- overriding the default init */
3222 static int ad1988_auto_init(struct hda_codec
*codec
)
3225 ad1988_auto_init_multi_out(codec
);
3226 ad1988_auto_init_extra_out(codec
);
3227 ad1988_auto_init_analog_input(codec
);
3234 static const char * const ad1988_models
[AD1988_MODEL_LAST
] = {
3235 [AD1988_6STACK
] = "6stack",
3236 [AD1988_6STACK_DIG
] = "6stack-dig",
3237 [AD1988_3STACK
] = "3stack",
3238 [AD1988_3STACK_DIG
] = "3stack-dig",
3239 [AD1988_LAPTOP
] = "laptop",
3240 [AD1988_LAPTOP_DIG
] = "laptop-dig",
3241 [AD1988_AUTO
] = "auto",
3244 static const struct snd_pci_quirk ad1988_cfg_tbl
[] = {
3245 SND_PCI_QUIRK(0x1043, 0x81ec, "Asus P5B-DLX", AD1988_6STACK_DIG
),
3246 SND_PCI_QUIRK(0x1043, 0x81f6, "Asus M2N-SLI", AD1988_6STACK_DIG
),
3247 SND_PCI_QUIRK(0x1043, 0x8277, "Asus P5K-E/WIFI-AP", AD1988_6STACK_DIG
),
3248 SND_PCI_QUIRK(0x1043, 0x82c0, "Asus M3N-HT Deluxe", AD1988_6STACK_DIG
),
3249 SND_PCI_QUIRK(0x1043, 0x8311, "Asus P5Q-Premium/Pro", AD1988_6STACK_DIG
),
3253 static int patch_ad1988(struct hda_codec
*codec
)
3255 struct ad198x_spec
*spec
;
3256 int err
, board_config
;
3258 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
3265 snd_printk(KERN_INFO
"patch_analog: AD1988A rev.2 is detected, enable workarounds\n");
3267 board_config
= snd_hda_check_board_config(codec
, AD1988_MODEL_LAST
,
3268 ad1988_models
, ad1988_cfg_tbl
);
3269 if (board_config
< 0) {
3270 printk(KERN_INFO
"hda_codec: %s: BIOS auto-probing.\n",
3272 board_config
= AD1988_AUTO
;
3275 if (board_config
== AD1988_AUTO
) {
3276 /* automatic parse from the BIOS config */
3277 err
= ad1988_parse_auto_config(codec
);
3282 printk(KERN_INFO
"hda_codec: Cannot set up configuration from BIOS. Using 6-stack mode...\n");
3283 board_config
= AD1988_6STACK
;
3287 err
= snd_hda_attach_beep_device(codec
, 0x10);
3292 set_beep_amp(spec
, 0x10, 0, HDA_OUTPUT
);
3294 if (!spec
->multiout
.hp_nid
)
3295 spec
->multiout
.hp_nid
= ad1988_alt_dac_nid
[0];
3296 switch (board_config
) {
3298 case AD1988_6STACK_DIG
:
3299 spec
->multiout
.max_channels
= 8;
3300 spec
->multiout
.num_dacs
= 4;
3302 spec
->multiout
.dac_nids
= ad1988_6stack_dac_nids_rev2
;
3304 spec
->multiout
.dac_nids
= ad1988_6stack_dac_nids
;
3305 spec
->input_mux
= &ad1988_6stack_capture_source
;
3306 spec
->num_mixers
= 2;
3308 spec
->mixers
[0] = ad1988_6stack_mixers1_rev2
;
3310 spec
->mixers
[0] = ad1988_6stack_mixers1
;
3311 spec
->mixers
[1] = ad1988_6stack_mixers2
;
3312 spec
->num_init_verbs
= 1;
3313 spec
->init_verbs
[0] = ad1988_6stack_init_verbs
;
3314 if (board_config
== AD1988_6STACK_DIG
) {
3315 spec
->multiout
.dig_out_nid
= AD1988_SPDIF_OUT
;
3316 spec
->dig_in_nid
= AD1988_SPDIF_IN
;
3320 case AD1988_3STACK_DIG
:
3321 spec
->multiout
.max_channels
= 6;
3322 spec
->multiout
.num_dacs
= 3;
3324 spec
->multiout
.dac_nids
= ad1988_3stack_dac_nids_rev2
;
3326 spec
->multiout
.dac_nids
= ad1988_3stack_dac_nids
;
3327 spec
->input_mux
= &ad1988_6stack_capture_source
;
3328 spec
->channel_mode
= ad1988_3stack_modes
;
3329 spec
->num_channel_mode
= ARRAY_SIZE(ad1988_3stack_modes
);
3330 spec
->num_mixers
= 2;
3332 spec
->mixers
[0] = ad1988_3stack_mixers1_rev2
;
3334 spec
->mixers
[0] = ad1988_3stack_mixers1
;
3335 spec
->mixers
[1] = ad1988_3stack_mixers2
;
3336 spec
->num_init_verbs
= 1;
3337 spec
->init_verbs
[0] = ad1988_3stack_init_verbs
;
3338 if (board_config
== AD1988_3STACK_DIG
)
3339 spec
->multiout
.dig_out_nid
= AD1988_SPDIF_OUT
;
3342 case AD1988_LAPTOP_DIG
:
3343 spec
->multiout
.max_channels
= 2;
3344 spec
->multiout
.num_dacs
= 1;
3345 spec
->multiout
.dac_nids
= ad1988_3stack_dac_nids
;
3346 spec
->input_mux
= &ad1988_laptop_capture_source
;
3347 spec
->num_mixers
= 1;
3348 spec
->mixers
[0] = ad1988_laptop_mixers
;
3349 spec
->inv_eapd
= 1; /* inverted EAPD */
3350 spec
->num_init_verbs
= 1;
3351 spec
->init_verbs
[0] = ad1988_laptop_init_verbs
;
3352 if (board_config
== AD1988_LAPTOP_DIG
)
3353 spec
->multiout
.dig_out_nid
= AD1988_SPDIF_OUT
;
3357 if (spec
->autocfg
.hp_pins
[0]) {
3358 spec
->mixers
[spec
->num_mixers
++] = ad1988_hp_mixers
;
3359 spec
->slave_vols
= ad1988_6stack_fp_slave_pfxs
;
3360 spec
->slave_sws
= ad1988_6stack_fp_slave_pfxs
;
3361 spec
->alt_dac_nid
= ad1988_alt_dac_nid
;
3362 spec
->stream_analog_alt_playback
=
3363 &ad198x_pcm_analog_alt_playback
;
3366 spec
->num_adc_nids
= ARRAY_SIZE(ad1988_adc_nids
);
3367 spec
->adc_nids
= ad1988_adc_nids
;
3368 spec
->capsrc_nids
= ad1988_capsrc_nids
;
3369 spec
->mixers
[spec
->num_mixers
++] = ad1988_capture_mixers
;
3370 spec
->init_verbs
[spec
->num_init_verbs
++] = ad1988_capture_init_verbs
;
3371 if (spec
->multiout
.dig_out_nid
) {
3372 if (codec
->vendor_id
>= 0x11d4989a) {
3373 spec
->mixers
[spec
->num_mixers
++] =
3374 ad1989_spdif_out_mixers
;
3375 spec
->init_verbs
[spec
->num_init_verbs
++] =
3376 ad1989_spdif_init_verbs
;
3377 codec
->slave_dig_outs
= ad1989b_slave_dig_outs
;
3379 spec
->mixers
[spec
->num_mixers
++] =
3380 ad1988_spdif_out_mixers
;
3381 spec
->init_verbs
[spec
->num_init_verbs
++] =
3382 ad1988_spdif_init_verbs
;
3385 if (spec
->dig_in_nid
&& codec
->vendor_id
< 0x11d4989a) {
3386 spec
->mixers
[spec
->num_mixers
++] = ad1988_spdif_in_mixers
;
3387 spec
->init_verbs
[spec
->num_init_verbs
++] =
3388 ad1988_spdif_in_init_verbs
;
3391 codec
->patch_ops
= ad198x_patch_ops
;
3392 switch (board_config
) {
3394 codec
->patch_ops
.init
= ad1988_auto_init
;
3397 case AD1988_LAPTOP_DIG
:
3398 codec
->patch_ops
.unsol_event
= ad1988_laptop_unsol_event
;
3401 #ifdef CONFIG_SND_HDA_POWER_SAVE
3402 spec
->loopback
.amplist
= ad1988_loopbacks
;
3404 spec
->vmaster_nid
= 0x04;
3406 codec
->no_trigger_sense
= 1;
3407 codec
->no_sticky_stream
= 1;
3416 * port-B - front line/mic-in
3417 * port-E - aux in/out
3418 * port-F - aux in/out
3419 * port-C - rear line/mic-in
3420 * port-D - rear line/hp-out
3421 * port-A - front line/hp-out
3423 * AD1984 = AD1884 + two digital mic-ins
3426 * For simplicity, we share the single DAC for both HP and line-outs
3427 * right now. The inidividual playbacks could be easily implemented,
3428 * but no build-up framework is given, so far.
3431 static const hda_nid_t ad1884_dac_nids
[1] = {
3435 static const hda_nid_t ad1884_adc_nids
[2] = {
3439 static const hda_nid_t ad1884_capsrc_nids
[2] = {
3443 #define AD1884_SPDIF_OUT 0x02
3445 static const struct hda_input_mux ad1884_capture_source
= {
3448 { "Front Mic", 0x0 },
3455 static const struct snd_kcontrol_new ad1884_base_mixers
[] = {
3456 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
3457 /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */
3458 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
3459 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
3460 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT
),
3461 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT
),
3462 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT
),
3463 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT
),
3464 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT
),
3465 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT
),
3466 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT
),
3467 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT
),
3468 HDA_CODEC_VOLUME("Mic Boost Volume", 0x15, 0x0, HDA_INPUT
),
3469 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x14, 0x0, HDA_INPUT
),
3470 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
3471 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
3472 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT
),
3473 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT
),
3475 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3476 /* The multiple "Capture Source" controls confuse alsamixer
3477 * So call somewhat different..
3479 /* .name = "Capture Source", */
3480 .name
= "Input Source",
3482 .info
= ad198x_mux_enum_info
,
3483 .get
= ad198x_mux_enum_get
,
3484 .put
= ad198x_mux_enum_put
,
3486 /* SPDIF controls */
3487 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
3489 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3490 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,NONE
) "Source",
3491 /* identical with ad1983 */
3492 .info
= ad1983_spdif_route_info
,
3493 .get
= ad1983_spdif_route_get
,
3494 .put
= ad1983_spdif_route_put
,
3499 static const struct snd_kcontrol_new ad1984_dmic_mixers
[] = {
3500 HDA_CODEC_VOLUME("Digital Mic Capture Volume", 0x05, 0x0, HDA_INPUT
),
3501 HDA_CODEC_MUTE("Digital Mic Capture Switch", 0x05, 0x0, HDA_INPUT
),
3502 HDA_CODEC_VOLUME_IDX("Digital Mic Capture Volume", 1, 0x06, 0x0,
3504 HDA_CODEC_MUTE_IDX("Digital Mic Capture Switch", 1, 0x06, 0x0,
3510 * initialization verbs
3512 static const struct hda_verb ad1884_init_verbs
[] = {
3513 /* DACs; mute as default */
3514 {0x03, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
3515 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
3516 /* Port-A (HP) mixer */
3517 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3518 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3520 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
3521 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3522 /* HP selector - select DAC2 */
3523 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x1},
3524 /* Port-D (Line-out) mixer */
3525 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3526 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3528 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
3529 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3530 /* Mono-out mixer */
3531 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3532 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3534 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
3535 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3537 {0x0e, AC_VERB_SET_CONNECT_SEL
, 0x1},
3538 /* Port-B (front mic) pin */
3539 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
3540 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3541 /* Port-C (rear mic) pin */
3542 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
3543 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3544 /* Analog mixer; mute as default */
3545 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3546 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
3547 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
3548 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
3549 /* Analog Mix output amp */
3550 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x1f}, /* 0dB */
3551 /* SPDIF output selector */
3552 {0x02, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* PCM */
3553 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x27}, /* 0dB */
3557 #ifdef CONFIG_SND_HDA_POWER_SAVE
3558 static const struct hda_amp_list ad1884_loopbacks
[] = {
3559 { 0x20, HDA_INPUT
, 0 }, /* Front Mic */
3560 { 0x20, HDA_INPUT
, 1 }, /* Mic */
3561 { 0x20, HDA_INPUT
, 2 }, /* CD */
3562 { 0x20, HDA_INPUT
, 4 }, /* Docking */
3567 static const char * const ad1884_slave_vols
[] = {
3568 "PCM", "Mic", "Mono", "Front Mic", "Mic", "CD",
3569 "Internal Mic", "Docking Mic", /* "Beep", */ "IEC958",
3573 static int patch_ad1884(struct hda_codec
*codec
)
3575 struct ad198x_spec
*spec
;
3578 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
3584 err
= snd_hda_attach_beep_device(codec
, 0x10);
3589 set_beep_amp(spec
, 0x10, 0, HDA_OUTPUT
);
3591 spec
->multiout
.max_channels
= 2;
3592 spec
->multiout
.num_dacs
= ARRAY_SIZE(ad1884_dac_nids
);
3593 spec
->multiout
.dac_nids
= ad1884_dac_nids
;
3594 spec
->multiout
.dig_out_nid
= AD1884_SPDIF_OUT
;
3595 spec
->num_adc_nids
= ARRAY_SIZE(ad1884_adc_nids
);
3596 spec
->adc_nids
= ad1884_adc_nids
;
3597 spec
->capsrc_nids
= ad1884_capsrc_nids
;
3598 spec
->input_mux
= &ad1884_capture_source
;
3599 spec
->num_mixers
= 1;
3600 spec
->mixers
[0] = ad1884_base_mixers
;
3601 spec
->num_init_verbs
= 1;
3602 spec
->init_verbs
[0] = ad1884_init_verbs
;
3603 spec
->spdif_route
= 0;
3604 #ifdef CONFIG_SND_HDA_POWER_SAVE
3605 spec
->loopback
.amplist
= ad1884_loopbacks
;
3607 spec
->vmaster_nid
= 0x04;
3608 /* we need to cover all playback volumes */
3609 spec
->slave_vols
= ad1884_slave_vols
;
3610 /* slaves may contain input volumes, so we can't raise to 0dB blindly */
3611 spec
->avoid_init_slave_vol
= 1;
3613 codec
->patch_ops
= ad198x_patch_ops
;
3615 codec
->no_trigger_sense
= 1;
3616 codec
->no_sticky_stream
= 1;
3622 * Lenovo Thinkpad T61/X61
3624 static const struct hda_input_mux ad1984_thinkpad_capture_source
= {
3628 { "Internal Mic", 0x1 },
3630 { "Docking-Station", 0x4 },
3636 * Dell Precision T3400
3638 static const struct hda_input_mux ad1984_dell_desktop_capture_source
= {
3641 { "Front Mic", 0x0 },
3648 static const struct snd_kcontrol_new ad1984_thinkpad_mixers
[] = {
3649 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
3650 /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */
3651 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
3652 HDA_CODEC_MUTE("Speaker Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
3653 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT
),
3654 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT
),
3655 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x20, 0x01, HDA_INPUT
),
3656 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT
),
3657 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT
),
3658 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT
),
3659 HDA_CODEC_VOLUME("Docking Mic Playback Volume", 0x20, 0x04, HDA_INPUT
),
3660 HDA_CODEC_MUTE("Docking Mic Playback Switch", 0x20, 0x04, HDA_INPUT
),
3661 HDA_CODEC_VOLUME("Mic Boost Volume", 0x14, 0x0, HDA_INPUT
),
3662 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x15, 0x0, HDA_INPUT
),
3663 HDA_CODEC_VOLUME("Dock Mic Boost Volume", 0x25, 0x0, HDA_OUTPUT
),
3664 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
3665 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
3666 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT
),
3667 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT
),
3669 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3670 /* The multiple "Capture Source" controls confuse alsamixer
3671 * So call somewhat different..
3673 /* .name = "Capture Source", */
3674 .name
= "Input Source",
3676 .info
= ad198x_mux_enum_info
,
3677 .get
= ad198x_mux_enum_get
,
3678 .put
= ad198x_mux_enum_put
,
3680 /* SPDIF controls */
3681 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
3683 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3684 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,NONE
) "Source",
3685 /* identical with ad1983 */
3686 .info
= ad1983_spdif_route_info
,
3687 .get
= ad1983_spdif_route_get
,
3688 .put
= ad1983_spdif_route_put
,
3693 /* additional verbs */
3694 static const struct hda_verb ad1984_thinkpad_init_verbs
[] = {
3695 /* Port-E (docking station mic) pin */
3696 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
3697 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3698 /* docking mic boost */
3699 {0x25, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
3700 /* Analog PC Beeper - allow firmware/ACPI beeps */
3701 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(3) | 0x1a},
3702 /* Analog mixer - docking mic; mute as default */
3703 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
3704 /* enable EAPD bit */
3705 {0x12, AC_VERB_SET_EAPD_BTLENABLE
, 0x02},
3710 * Dell Precision T3400
3712 static const struct snd_kcontrol_new ad1984_dell_desktop_mixers
[] = {
3713 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
3714 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
3715 HDA_CODEC_MUTE("Speaker Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
3716 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT
),
3717 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT
),
3718 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT
),
3719 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT
),
3720 HDA_CODEC_VOLUME("Line-In Playback Volume", 0x20, 0x01, HDA_INPUT
),
3721 HDA_CODEC_MUTE("Line-In Playback Switch", 0x20, 0x01, HDA_INPUT
),
3722 HDA_CODEC_VOLUME("Line-In Boost Volume", 0x15, 0x0, HDA_INPUT
),
3723 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x14, 0x0, HDA_INPUT
),
3724 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
3725 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
3726 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT
),
3727 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT
),
3729 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3730 /* The multiple "Capture Source" controls confuse alsamixer
3731 * So call somewhat different..
3733 /* .name = "Capture Source", */
3734 .name
= "Input Source",
3736 .info
= ad198x_mux_enum_info
,
3737 .get
= ad198x_mux_enum_get
,
3738 .put
= ad198x_mux_enum_put
,
3743 /* Digial MIC ADC NID 0x05 + 0x06 */
3744 static int ad1984_pcm_dmic_prepare(struct hda_pcm_stream
*hinfo
,
3745 struct hda_codec
*codec
,
3746 unsigned int stream_tag
,
3747 unsigned int format
,
3748 struct snd_pcm_substream
*substream
)
3750 snd_hda_codec_setup_stream(codec
, 0x05 + substream
->number
,
3751 stream_tag
, 0, format
);
3755 static int ad1984_pcm_dmic_cleanup(struct hda_pcm_stream
*hinfo
,
3756 struct hda_codec
*codec
,
3757 struct snd_pcm_substream
*substream
)
3759 snd_hda_codec_cleanup_stream(codec
, 0x05 + substream
->number
);
3763 static const struct hda_pcm_stream ad1984_pcm_dmic_capture
= {
3769 .prepare
= ad1984_pcm_dmic_prepare
,
3770 .cleanup
= ad1984_pcm_dmic_cleanup
3774 static int ad1984_build_pcms(struct hda_codec
*codec
)
3776 struct ad198x_spec
*spec
= codec
->spec
;
3777 struct hda_pcm
*info
;
3780 err
= ad198x_build_pcms(codec
);
3784 info
= spec
->pcm_rec
+ codec
->num_pcms
;
3786 info
->name
= "AD1984 Digital Mic";
3787 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = ad1984_pcm_dmic_capture
;
3795 AD1984_DELL_DESKTOP
,
3799 static const char * const ad1984_models
[AD1984_MODELS
] = {
3800 [AD1984_BASIC
] = "basic",
3801 [AD1984_THINKPAD
] = "thinkpad",
3802 [AD1984_DELL_DESKTOP
] = "dell_desktop",
3805 static const struct snd_pci_quirk ad1984_cfg_tbl
[] = {
3806 /* Lenovo Thinkpad T61/X61 */
3807 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo Thinkpad", AD1984_THINKPAD
),
3808 SND_PCI_QUIRK(0x1028, 0x0214, "Dell T3400", AD1984_DELL_DESKTOP
),
3809 SND_PCI_QUIRK(0x1028, 0x0233, "Dell Latitude E6400", AD1984_DELL_DESKTOP
),
3813 static int patch_ad1984(struct hda_codec
*codec
)
3815 struct ad198x_spec
*spec
;
3816 int board_config
, err
;
3818 err
= patch_ad1884(codec
);
3822 board_config
= snd_hda_check_board_config(codec
, AD1984_MODELS
,
3823 ad1984_models
, ad1984_cfg_tbl
);
3824 switch (board_config
) {
3826 /* additional digital mics */
3827 spec
->mixers
[spec
->num_mixers
++] = ad1984_dmic_mixers
;
3828 codec
->patch_ops
.build_pcms
= ad1984_build_pcms
;
3830 case AD1984_THINKPAD
:
3831 if (codec
->subsystem_id
== 0x17aa20fb) {
3832 /* Thinpad X300 does not have the ability to do SPDIF,
3833 or attach to docking station to use SPDIF */
3834 spec
->multiout
.dig_out_nid
= 0;
3836 spec
->multiout
.dig_out_nid
= AD1884_SPDIF_OUT
;
3837 spec
->input_mux
= &ad1984_thinkpad_capture_source
;
3838 spec
->mixers
[0] = ad1984_thinkpad_mixers
;
3839 spec
->init_verbs
[spec
->num_init_verbs
++] = ad1984_thinkpad_init_verbs
;
3840 spec
->analog_beep
= 1;
3842 case AD1984_DELL_DESKTOP
:
3843 spec
->multiout
.dig_out_nid
= 0;
3844 spec
->input_mux
= &ad1984_dell_desktop_capture_source
;
3845 spec
->mixers
[0] = ad1984_dell_desktop_mixers
;
3853 * AD1883 / AD1884A / AD1984A / AD1984B
3855 * port-B (0x14) - front mic-in
3856 * port-E (0x1c) - rear mic-in
3857 * port-F (0x16) - CD / ext out
3858 * port-C (0x15) - rear line-in
3859 * port-D (0x12) - rear line-out
3860 * port-A (0x11) - front hp-out
3862 * AD1984A = AD1884A + digital-mic
3863 * AD1883 = equivalent with AD1984A
3864 * AD1984B = AD1984A + extra SPDIF-out
3867 * We share the single DAC for both HP and line-outs (see AD1884/1984).
3870 static const hda_nid_t ad1884a_dac_nids
[1] = {
3874 #define ad1884a_adc_nids ad1884_adc_nids
3875 #define ad1884a_capsrc_nids ad1884_capsrc_nids
3877 #define AD1884A_SPDIF_OUT 0x02
3879 static const struct hda_input_mux ad1884a_capture_source
= {
3882 { "Front Mic", 0x0 },
3890 static const struct snd_kcontrol_new ad1884a_base_mixers
[] = {
3891 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT
),
3892 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT
),
3893 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
3894 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
3895 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT
),
3896 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT
),
3897 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT
),
3898 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT
),
3899 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT
),
3900 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT
),
3901 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x01, HDA_INPUT
),
3902 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x01, HDA_INPUT
),
3903 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x04, HDA_INPUT
),
3904 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x04, HDA_INPUT
),
3905 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT
),
3906 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT
),
3907 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x14, 0x0, HDA_INPUT
),
3908 HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x0, HDA_INPUT
),
3909 HDA_CODEC_VOLUME("Mic Boost Volume", 0x25, 0x0, HDA_OUTPUT
),
3910 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
3911 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
3912 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT
),
3913 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT
),
3915 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3916 /* The multiple "Capture Source" controls confuse alsamixer
3917 * So call somewhat different..
3919 /* .name = "Capture Source", */
3920 .name
= "Input Source",
3922 .info
= ad198x_mux_enum_info
,
3923 .get
= ad198x_mux_enum_get
,
3924 .put
= ad198x_mux_enum_put
,
3926 /* SPDIF controls */
3927 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
3929 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3930 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,NONE
) "Source",
3931 /* identical with ad1983 */
3932 .info
= ad1983_spdif_route_info
,
3933 .get
= ad1983_spdif_route_get
,
3934 .put
= ad1983_spdif_route_put
,
3940 * initialization verbs
3942 static const struct hda_verb ad1884a_init_verbs
[] = {
3943 /* DACs; unmute as default */
3944 {0x03, AC_VERB_SET_AMP_GAIN_MUTE
, 0x27}, /* 0dB */
3945 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, 0x27}, /* 0dB */
3946 /* Port-A (HP) mixer - route only from analog mixer */
3947 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3948 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3950 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
3951 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3952 /* Port-D (Line-out) mixer - route only from analog mixer */
3953 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3954 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3956 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
3957 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3958 /* Mono-out mixer - route only from analog mixer */
3959 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3960 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3962 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
3963 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3964 /* Port-B (front mic) pin */
3965 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
3966 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3967 /* Port-C (rear line-in) pin */
3968 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
3969 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3970 /* Port-E (rear mic) pin */
3971 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
3972 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3973 {0x25, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
}, /* no boost */
3974 /* Port-F (CD) pin */
3975 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
3976 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3977 /* Analog mixer; mute as default */
3978 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3979 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
3980 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
3981 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
3982 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(4)}, /* aux */
3983 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)},
3984 /* Analog Mix output amp */
3985 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3986 /* capture sources */
3987 {0x0c, AC_VERB_SET_CONNECT_SEL
, 0x0},
3988 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3989 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x0},
3990 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3991 /* SPDIF output amp */
3992 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x27}, /* 0dB */
3996 #ifdef CONFIG_SND_HDA_POWER_SAVE
3997 static const struct hda_amp_list ad1884a_loopbacks
[] = {
3998 { 0x20, HDA_INPUT
, 0 }, /* Front Mic */
3999 { 0x20, HDA_INPUT
, 1 }, /* Mic */
4000 { 0x20, HDA_INPUT
, 2 }, /* CD */
4001 { 0x20, HDA_INPUT
, 4 }, /* Docking */
4009 * Port A: Headphone jack
4011 * Port C: Internal MIC
4012 * Port D: Dock Line Out (if enabled)
4013 * Port E: Dock Line In (if enabled)
4014 * Port F: Internal speakers
4017 static int ad1884a_mobile_master_sw_put(struct snd_kcontrol
*kcontrol
,
4018 struct snd_ctl_elem_value
*ucontrol
)
4020 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
4021 int ret
= snd_hda_mixer_amp_switch_put(kcontrol
, ucontrol
);
4022 int mute
= (!ucontrol
->value
.integer
.value
[0] &&
4023 !ucontrol
->value
.integer
.value
[1]);
4024 /* toggle GPIO1 according to the mute state */
4025 snd_hda_codec_write_cache(codec
, 0x01, 0, AC_VERB_SET_GPIO_DATA
,
4030 static const struct snd_kcontrol_new ad1884a_laptop_mixers
[] = {
4031 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT
),
4033 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4034 .name
= "Master Playback Switch",
4035 .subdevice
= HDA_SUBDEV_AMP_FLAG
,
4036 .info
= snd_hda_mixer_amp_switch_info
,
4037 .get
= snd_hda_mixer_amp_switch_get
,
4038 .put
= ad1884a_mobile_master_sw_put
,
4039 .private_value
= HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT
),
4041 HDA_CODEC_MUTE("Dock Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
4042 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT
),
4043 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT
),
4044 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT
),
4045 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT
),
4046 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x20, 0x01, HDA_INPUT
),
4047 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT
),
4048 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x20, 0x04, HDA_INPUT
),
4049 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x20, 0x04, HDA_INPUT
),
4050 HDA_CODEC_VOLUME("Mic Boost Volume", 0x14, 0x0, HDA_INPUT
),
4051 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x15, 0x0, HDA_INPUT
),
4052 HDA_CODEC_VOLUME("Dock Mic Boost Volume", 0x25, 0x0, HDA_OUTPUT
),
4053 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
4054 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
4058 static const struct snd_kcontrol_new ad1884a_mobile_mixers
[] = {
4059 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT
),
4060 /*HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),*/
4062 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4063 .name
= "Master Playback Switch",
4064 .subdevice
= HDA_SUBDEV_AMP_FLAG
,
4065 .info
= snd_hda_mixer_amp_switch_info
,
4066 .get
= snd_hda_mixer_amp_switch_get
,
4067 .put
= ad1884a_mobile_master_sw_put
,
4068 .private_value
= HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT
),
4070 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT
),
4071 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT
),
4072 HDA_CODEC_VOLUME("Mic Capture Volume", 0x14, 0x0, HDA_INPUT
),
4073 HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x15, 0x0, HDA_INPUT
),
4074 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
4075 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
4079 /* mute internal speaker if HP is plugged */
4080 static void ad1884a_hp_automute(struct hda_codec
*codec
)
4082 unsigned int present
;
4084 present
= snd_hda_jack_detect(codec
, 0x11);
4085 snd_hda_codec_amp_stereo(codec
, 0x16, HDA_OUTPUT
, 0,
4086 HDA_AMP_MUTE
, present
? HDA_AMP_MUTE
: 0);
4087 snd_hda_codec_write(codec
, 0x16, 0, AC_VERB_SET_EAPD_BTLENABLE
,
4088 present
? 0x00 : 0x02);
4091 /* switch to external mic if plugged */
4092 static void ad1884a_hp_automic(struct hda_codec
*codec
)
4094 unsigned int present
;
4096 present
= snd_hda_jack_detect(codec
, 0x14);
4097 snd_hda_codec_write(codec
, 0x0c, 0, AC_VERB_SET_CONNECT_SEL
,
4101 #define AD1884A_HP_EVENT 0x37
4102 #define AD1884A_MIC_EVENT 0x36
4104 /* unsolicited event for HP jack sensing */
4105 static void ad1884a_hp_unsol_event(struct hda_codec
*codec
, unsigned int res
)
4107 switch (res
>> 26) {
4108 case AD1884A_HP_EVENT
:
4109 ad1884a_hp_automute(codec
);
4111 case AD1884A_MIC_EVENT
:
4112 ad1884a_hp_automic(codec
);
4117 /* initialize jack-sensing, too */
4118 static int ad1884a_hp_init(struct hda_codec
*codec
)
4121 ad1884a_hp_automute(codec
);
4122 ad1884a_hp_automic(codec
);
4126 /* mute internal speaker if HP or docking HP is plugged */
4127 static void ad1884a_laptop_automute(struct hda_codec
*codec
)
4129 unsigned int present
;
4131 present
= snd_hda_jack_detect(codec
, 0x11);
4133 present
= snd_hda_jack_detect(codec
, 0x12);
4134 snd_hda_codec_amp_stereo(codec
, 0x16, HDA_OUTPUT
, 0,
4135 HDA_AMP_MUTE
, present
? HDA_AMP_MUTE
: 0);
4136 snd_hda_codec_write(codec
, 0x16, 0, AC_VERB_SET_EAPD_BTLENABLE
,
4137 present
? 0x00 : 0x02);
4140 /* switch to external mic if plugged */
4141 static void ad1884a_laptop_automic(struct hda_codec
*codec
)
4145 if (snd_hda_jack_detect(codec
, 0x14))
4147 else if (snd_hda_jack_detect(codec
, 0x1c))
4151 snd_hda_codec_write(codec
, 0x0c, 0, AC_VERB_SET_CONNECT_SEL
, idx
);
4154 /* unsolicited event for HP jack sensing */
4155 static void ad1884a_laptop_unsol_event(struct hda_codec
*codec
,
4158 switch (res
>> 26) {
4159 case AD1884A_HP_EVENT
:
4160 ad1884a_laptop_automute(codec
);
4162 case AD1884A_MIC_EVENT
:
4163 ad1884a_laptop_automic(codec
);
4168 /* initialize jack-sensing, too */
4169 static int ad1884a_laptop_init(struct hda_codec
*codec
)
4172 ad1884a_laptop_automute(codec
);
4173 ad1884a_laptop_automic(codec
);
4177 /* additional verbs for laptop model */
4178 static const struct hda_verb ad1884a_laptop_verbs
[] = {
4179 /* Port-A (HP) pin - always unmuted */
4180 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
4181 /* Port-F (int speaker) mixer - route only from analog mixer */
4182 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4183 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4184 /* Port-F (int speaker) pin */
4185 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
4186 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4187 /* required for compaq 6530s/6531s speaker output */
4188 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
4189 /* Port-C pin - internal mic-in */
4190 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
4191 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0x7002}, /* raise mic as default */
4192 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, 0x7002}, /* raise mic as default */
4193 /* Port-D (docking line-out) pin - default unmuted */
4194 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
4196 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
4197 /* unsolicited event for pin-sense */
4198 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1884A_HP_EVENT
},
4199 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1884A_HP_EVENT
},
4200 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1884A_MIC_EVENT
},
4201 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1884A_MIC_EVENT
},
4202 /* allow to touch GPIO1 (for mute control) */
4203 {0x01, AC_VERB_SET_GPIO_MASK
, 0x02},
4204 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x02},
4205 {0x01, AC_VERB_SET_GPIO_DATA
, 0x02}, /* first muted */
4209 static const struct hda_verb ad1884a_mobile_verbs
[] = {
4210 /* DACs; unmute as default */
4211 {0x03, AC_VERB_SET_AMP_GAIN_MUTE
, 0x27}, /* 0dB */
4212 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, 0x27}, /* 0dB */
4213 /* Port-A (HP) mixer - route only from analog mixer */
4214 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4215 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4217 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
4218 /* Port-A (HP) pin - always unmuted */
4219 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
4220 /* Port-B (mic jack) pin */
4221 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
4222 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0x7002}, /* raise mic as default */
4223 /* Port-C (int mic) pin */
4224 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
4225 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, 0x7002}, /* raise mic as default */
4226 /* Port-F (int speaker) mixer - route only from analog mixer */
4227 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4228 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4230 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
4231 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4232 /* Analog mixer; mute as default */
4233 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4234 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4235 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
4236 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
4237 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
4238 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)},
4239 /* Analog Mix output amp */
4240 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4241 /* capture sources */
4242 /* {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0}, */ /* set via unsol */
4243 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4244 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x0},
4245 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4246 /* unsolicited event for pin-sense */
4247 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1884A_HP_EVENT
},
4248 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1884A_MIC_EVENT
},
4249 /* allow to touch GPIO1 (for mute control) */
4250 {0x01, AC_VERB_SET_GPIO_MASK
, 0x02},
4251 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x02},
4252 {0x01, AC_VERB_SET_GPIO_DATA
, 0x02}, /* first muted */
4261 * 0x17 - built-in mic
4264 static const struct hda_verb ad1984a_thinkpad_verbs
[] = {
4266 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
4268 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
4270 {0x12, AC_VERB_SET_EAPD_BTLENABLE
, 0x02},
4271 /* unsolicited event for pin-sense */
4272 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1884A_HP_EVENT
},
4273 /* internal mic - dmic */
4274 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
4275 /* set magic COEFs for dmic */
4276 {0x01, AC_VERB_SET_COEF_INDEX
, 0x13f7},
4277 {0x01, AC_VERB_SET_PROC_COEF
, 0x08},
4281 static const struct snd_kcontrol_new ad1984a_thinkpad_mixers
[] = {
4282 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT
),
4283 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT
),
4284 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT
),
4285 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT
),
4286 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT
),
4287 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT
),
4288 HDA_CODEC_VOLUME("Mic Boost Volume", 0x14, 0x0, HDA_INPUT
),
4289 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x17, 0x0, HDA_INPUT
),
4290 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
4291 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
4293 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4294 .name
= "Capture Source",
4295 .info
= ad198x_mux_enum_info
,
4296 .get
= ad198x_mux_enum_get
,
4297 .put
= ad198x_mux_enum_put
,
4302 static const struct hda_input_mux ad1984a_thinkpad_capture_source
= {
4306 { "Internal Mic", 0x5 },
4311 /* mute internal speaker if HP is plugged */
4312 static void ad1984a_thinkpad_automute(struct hda_codec
*codec
)
4314 unsigned int present
;
4316 present
= snd_hda_jack_detect(codec
, 0x11);
4317 snd_hda_codec_amp_stereo(codec
, 0x12, HDA_OUTPUT
, 0,
4318 HDA_AMP_MUTE
, present
? HDA_AMP_MUTE
: 0);
4321 /* unsolicited event for HP jack sensing */
4322 static void ad1984a_thinkpad_unsol_event(struct hda_codec
*codec
,
4325 if ((res
>> 26) != AD1884A_HP_EVENT
)
4327 ad1984a_thinkpad_automute(codec
);
4330 /* initialize jack-sensing, too */
4331 static int ad1984a_thinkpad_init(struct hda_codec
*codec
)
4334 ad1984a_thinkpad_automute(codec
);
4340 * 0x12 - HP/line-out
4341 * 0x13 - speaker (mono)
4345 static const struct hda_verb ad1984a_precision_verbs
[] = {
4346 /* Unmute main output path */
4347 {0x03, AC_VERB_SET_AMP_GAIN_MUTE
, 0x27}, /* 0dB */
4348 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
+ 0x1f}, /* 0dB */
4349 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(5) + 0x17}, /* 0dB */
4350 /* Analog mixer; mute as default */
4351 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4352 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4353 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
4354 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
4355 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
4356 /* Select mic as input */
4357 {0x0c, AC_VERB_SET_CONNECT_SEL
, 0x1},
4358 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
+ 0x27}, /* 0dB */
4359 /* Configure as mic */
4360 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
4361 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, 0x7002}, /* raise mic as default */
4363 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
4365 {0x13, AC_VERB_SET_EAPD_BTLENABLE
, 0x02},
4366 /* unsolicited event for pin-sense */
4367 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1884A_HP_EVENT
},
4371 static const struct snd_kcontrol_new ad1984a_precision_mixers
[] = {
4372 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT
),
4373 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT
),
4374 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT
),
4375 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT
),
4376 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT
),
4377 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT
),
4378 HDA_CODEC_VOLUME("Mic Boost Volume", 0x15, 0x0, HDA_INPUT
),
4379 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
4380 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
4381 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
4382 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
4387 /* mute internal speaker if HP is plugged */
4388 static void ad1984a_precision_automute(struct hda_codec
*codec
)
4390 unsigned int present
;
4392 present
= snd_hda_jack_detect(codec
, 0x12);
4393 snd_hda_codec_amp_stereo(codec
, 0x13, HDA_OUTPUT
, 0,
4394 HDA_AMP_MUTE
, present
? HDA_AMP_MUTE
: 0);
4398 /* unsolicited event for HP jack sensing */
4399 static void ad1984a_precision_unsol_event(struct hda_codec
*codec
,
4402 if ((res
>> 26) != AD1884A_HP_EVENT
)
4404 ad1984a_precision_automute(codec
);
4407 /* initialize jack-sensing, too */
4408 static int ad1984a_precision_init(struct hda_codec
*codec
)
4411 ad1984a_precision_automute(codec
);
4418 * port-A (0x11) - front hp-out
4419 * port-B (0x14) - unused
4420 * port-C (0x15) - unused
4421 * port-D (0x12) - rear line out
4422 * port-E (0x1c) - front mic-in
4423 * port-F (0x16) - Internal speakers
4424 * digital-mic (0x17) - Internal mic
4427 static const struct hda_verb ad1984a_touchsmart_verbs
[] = {
4428 /* DACs; unmute as default */
4429 {0x03, AC_VERB_SET_AMP_GAIN_MUTE
, 0x27}, /* 0dB */
4430 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, 0x27}, /* 0dB */
4431 /* Port-A (HP) mixer - route only from analog mixer */
4432 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4433 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4435 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
4436 /* Port-A (HP) pin - always unmuted */
4437 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
4438 /* Port-E (int speaker) mixer - route only from analog mixer */
4439 {0x25, AC_VERB_SET_AMP_GAIN_MUTE
, 0x03},
4441 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
4442 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
4443 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
4444 /* Port-F (int speaker) mixer - route only from analog mixer */
4445 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4446 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4448 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
4449 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4450 /* Analog mixer; mute as default */
4451 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4452 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4453 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
4454 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
4455 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
4456 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)},
4457 /* Analog Mix output amp */
4458 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4459 /* capture sources */
4460 /* {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0}, */ /* set via unsol */
4461 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4462 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x0},
4463 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4464 /* unsolicited event for pin-sense */
4465 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1884A_HP_EVENT
},
4466 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1884A_MIC_EVENT
},
4467 /* allow to touch GPIO1 (for mute control) */
4468 {0x01, AC_VERB_SET_GPIO_MASK
, 0x02},
4469 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x02},
4470 {0x01, AC_VERB_SET_GPIO_DATA
, 0x02}, /* first muted */
4471 /* internal mic - dmic */
4472 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
4473 /* set magic COEFs for dmic */
4474 {0x01, AC_VERB_SET_COEF_INDEX
, 0x13f7},
4475 {0x01, AC_VERB_SET_PROC_COEF
, 0x08},
4479 static const struct snd_kcontrol_new ad1984a_touchsmart_mixers
[] = {
4480 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT
),
4481 /* HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),*/
4483 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4484 .subdevice
= HDA_SUBDEV_AMP_FLAG
,
4485 .name
= "Master Playback Switch",
4486 .info
= snd_hda_mixer_amp_switch_info
,
4487 .get
= snd_hda_mixer_amp_switch_get
,
4488 .put
= ad1884a_mobile_master_sw_put
,
4489 .private_value
= HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT
),
4491 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT
),
4492 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT
),
4493 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
4494 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
4495 HDA_CODEC_VOLUME("Mic Boost Volume", 0x25, 0x0, HDA_OUTPUT
),
4496 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x17, 0x0, HDA_INPUT
),
4500 /* switch to external mic if plugged */
4501 static void ad1984a_touchsmart_automic(struct hda_codec
*codec
)
4503 if (snd_hda_jack_detect(codec
, 0x1c))
4504 snd_hda_codec_write(codec
, 0x0c, 0,
4505 AC_VERB_SET_CONNECT_SEL
, 0x4);
4507 snd_hda_codec_write(codec
, 0x0c, 0,
4508 AC_VERB_SET_CONNECT_SEL
, 0x5);
4512 /* unsolicited event for HP jack sensing */
4513 static void ad1984a_touchsmart_unsol_event(struct hda_codec
*codec
,
4516 switch (res
>> 26) {
4517 case AD1884A_HP_EVENT
:
4518 ad1884a_hp_automute(codec
);
4520 case AD1884A_MIC_EVENT
:
4521 ad1984a_touchsmart_automic(codec
);
4526 /* initialize jack-sensing, too */
4527 static int ad1984a_touchsmart_init(struct hda_codec
*codec
)
4530 ad1884a_hp_automute(codec
);
4531 ad1984a_touchsmart_automic(codec
);
4549 static const char * const ad1884a_models
[AD1884A_MODELS
] = {
4550 [AD1884A_DESKTOP
] = "desktop",
4551 [AD1884A_LAPTOP
] = "laptop",
4552 [AD1884A_MOBILE
] = "mobile",
4553 [AD1884A_THINKPAD
] = "thinkpad",
4554 [AD1984A_TOUCHSMART
] = "touchsmart",
4555 [AD1984A_PRECISION
] = "precision",
4558 static const struct snd_pci_quirk ad1884a_cfg_tbl
[] = {
4559 SND_PCI_QUIRK(0x1028, 0x04ac, "Precision R5500", AD1984A_PRECISION
),
4560 SND_PCI_QUIRK(0x103c, 0x3030, "HP", AD1884A_MOBILE
),
4561 SND_PCI_QUIRK(0x103c, 0x3037, "HP 2230s", AD1884A_LAPTOP
),
4562 SND_PCI_QUIRK(0x103c, 0x3056, "HP", AD1884A_MOBILE
),
4563 SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x3070, "HP", AD1884A_MOBILE
),
4564 SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x30d0, "HP laptop", AD1884A_LAPTOP
),
4565 SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x30e0, "HP laptop", AD1884A_LAPTOP
),
4566 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3600, "HP laptop", AD1884A_LAPTOP
),
4567 SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x7010, "HP laptop", AD1884A_MOBILE
),
4568 SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X300", AD1884A_THINKPAD
),
4569 SND_PCI_QUIRK(0x103c, 0x2a82, "Touchsmart", AD1984A_TOUCHSMART
),
4573 static int patch_ad1884a(struct hda_codec
*codec
)
4575 struct ad198x_spec
*spec
;
4576 int err
, board_config
;
4578 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4584 err
= snd_hda_attach_beep_device(codec
, 0x10);
4589 set_beep_amp(spec
, 0x10, 0, HDA_OUTPUT
);
4591 spec
->multiout
.max_channels
= 2;
4592 spec
->multiout
.num_dacs
= ARRAY_SIZE(ad1884a_dac_nids
);
4593 spec
->multiout
.dac_nids
= ad1884a_dac_nids
;
4594 spec
->multiout
.dig_out_nid
= AD1884A_SPDIF_OUT
;
4595 spec
->num_adc_nids
= ARRAY_SIZE(ad1884a_adc_nids
);
4596 spec
->adc_nids
= ad1884a_adc_nids
;
4597 spec
->capsrc_nids
= ad1884a_capsrc_nids
;
4598 spec
->input_mux
= &ad1884a_capture_source
;
4599 spec
->num_mixers
= 1;
4600 spec
->mixers
[0] = ad1884a_base_mixers
;
4601 spec
->num_init_verbs
= 1;
4602 spec
->init_verbs
[0] = ad1884a_init_verbs
;
4603 spec
->spdif_route
= 0;
4604 #ifdef CONFIG_SND_HDA_POWER_SAVE
4605 spec
->loopback
.amplist
= ad1884a_loopbacks
;
4607 codec
->patch_ops
= ad198x_patch_ops
;
4609 /* override some parameters */
4610 board_config
= snd_hda_check_board_config(codec
, AD1884A_MODELS
,
4613 switch (board_config
) {
4614 case AD1884A_LAPTOP
:
4615 spec
->mixers
[0] = ad1884a_laptop_mixers
;
4616 spec
->init_verbs
[spec
->num_init_verbs
++] = ad1884a_laptop_verbs
;
4617 spec
->multiout
.dig_out_nid
= 0;
4618 codec
->patch_ops
.unsol_event
= ad1884a_laptop_unsol_event
;
4619 codec
->patch_ops
.init
= ad1884a_laptop_init
;
4620 /* set the upper-limit for mixer amp to 0dB for avoiding the
4621 * possible damage by overloading
4623 snd_hda_override_amp_caps(codec
, 0x20, HDA_INPUT
,
4624 (0x17 << AC_AMPCAP_OFFSET_SHIFT
) |
4625 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
4626 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
4627 (1 << AC_AMPCAP_MUTE_SHIFT
));
4629 case AD1884A_MOBILE
:
4630 spec
->mixers
[0] = ad1884a_mobile_mixers
;
4631 spec
->init_verbs
[0] = ad1884a_mobile_verbs
;
4632 spec
->multiout
.dig_out_nid
= 0;
4633 codec
->patch_ops
.unsol_event
= ad1884a_hp_unsol_event
;
4634 codec
->patch_ops
.init
= ad1884a_hp_init
;
4635 /* set the upper-limit for mixer amp to 0dB for avoiding the
4636 * possible damage by overloading
4638 snd_hda_override_amp_caps(codec
, 0x20, HDA_INPUT
,
4639 (0x17 << AC_AMPCAP_OFFSET_SHIFT
) |
4640 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
4641 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
4642 (1 << AC_AMPCAP_MUTE_SHIFT
));
4644 case AD1884A_THINKPAD
:
4645 spec
->mixers
[0] = ad1984a_thinkpad_mixers
;
4646 spec
->init_verbs
[spec
->num_init_verbs
++] =
4647 ad1984a_thinkpad_verbs
;
4648 spec
->multiout
.dig_out_nid
= 0;
4649 spec
->input_mux
= &ad1984a_thinkpad_capture_source
;
4650 codec
->patch_ops
.unsol_event
= ad1984a_thinkpad_unsol_event
;
4651 codec
->patch_ops
.init
= ad1984a_thinkpad_init
;
4653 case AD1984A_PRECISION
:
4654 spec
->mixers
[0] = ad1984a_precision_mixers
;
4655 spec
->init_verbs
[spec
->num_init_verbs
++] =
4656 ad1984a_precision_verbs
;
4657 spec
->multiout
.dig_out_nid
= 0;
4658 codec
->patch_ops
.unsol_event
= ad1984a_precision_unsol_event
;
4659 codec
->patch_ops
.init
= ad1984a_precision_init
;
4661 case AD1984A_TOUCHSMART
:
4662 spec
->mixers
[0] = ad1984a_touchsmart_mixers
;
4663 spec
->init_verbs
[0] = ad1984a_touchsmart_verbs
;
4664 spec
->multiout
.dig_out_nid
= 0;
4665 codec
->patch_ops
.unsol_event
= ad1984a_touchsmart_unsol_event
;
4666 codec
->patch_ops
.init
= ad1984a_touchsmart_init
;
4667 /* set the upper-limit for mixer amp to 0dB for avoiding the
4668 * possible damage by overloading
4670 snd_hda_override_amp_caps(codec
, 0x20, HDA_INPUT
,
4671 (0x17 << AC_AMPCAP_OFFSET_SHIFT
) |
4672 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
4673 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
4674 (1 << AC_AMPCAP_MUTE_SHIFT
));
4678 codec
->no_trigger_sense
= 1;
4679 codec
->no_sticky_stream
= 1;
4688 * port-A - front hp-out
4689 * port-B - front mic-in
4690 * port-C - rear line-in, shared surr-out (3stack)
4691 * port-D - rear line-out
4692 * port-E - rear mic-in, shared clfe-out (3stack)
4693 * port-F - rear surr-out (6stack)
4694 * port-G - rear clfe-out (6stack)
4697 static const hda_nid_t ad1882_dac_nids
[3] = {
4701 static const hda_nid_t ad1882_adc_nids
[2] = {
4705 static const hda_nid_t ad1882_capsrc_nids
[2] = {
4709 #define AD1882_SPDIF_OUT 0x02
4711 /* list: 0x11, 0x39, 0x3a, 0x18, 0x3c, 0x3b, 0x12, 0x20 */
4712 static const struct hda_input_mux ad1882_capture_source
= {
4715 { "Front Mic", 0x1 },
4723 /* list: 0x11, 0x39, 0x3a, 0x3c, 0x18, 0x1f, 0x12, 0x20 */
4724 static const struct hda_input_mux ad1882a_capture_source
= {
4727 { "Front Mic", 0x1 },
4730 { "Digital Mic", 0x06 },
4735 static const struct snd_kcontrol_new ad1882_base_mixers
[] = {
4736 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
4737 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT
),
4738 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT
),
4739 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT
),
4740 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
4741 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
4742 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT
),
4743 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT
),
4745 HDA_CODEC_VOLUME("Mic Boost Volume", 0x3c, 0x0, HDA_OUTPUT
),
4746 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x39, 0x0, HDA_OUTPUT
),
4747 HDA_CODEC_VOLUME("Line-In Boost Volume", 0x3a, 0x0, HDA_OUTPUT
),
4748 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
4749 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
4750 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT
),
4751 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT
),
4753 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4754 /* The multiple "Capture Source" controls confuse alsamixer
4755 * So call somewhat different..
4757 /* .name = "Capture Source", */
4758 .name
= "Input Source",
4760 .info
= ad198x_mux_enum_info
,
4761 .get
= ad198x_mux_enum_get
,
4762 .put
= ad198x_mux_enum_put
,
4764 /* SPDIF controls */
4765 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
4767 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4768 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,NONE
) "Source",
4769 /* identical with ad1983 */
4770 .info
= ad1983_spdif_route_info
,
4771 .get
= ad1983_spdif_route_get
,
4772 .put
= ad1983_spdif_route_put
,
4777 static const struct snd_kcontrol_new ad1882_loopback_mixers
[] = {
4778 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT
),
4779 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT
),
4780 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT
),
4781 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT
),
4782 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x04, HDA_INPUT
),
4783 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x04, HDA_INPUT
),
4784 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT
),
4785 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT
),
4789 static const struct snd_kcontrol_new ad1882a_loopback_mixers
[] = {
4790 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT
),
4791 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT
),
4792 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x04, HDA_INPUT
),
4793 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x04, HDA_INPUT
),
4794 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x01, HDA_INPUT
),
4795 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x01, HDA_INPUT
),
4796 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT
),
4797 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT
),
4798 HDA_CODEC_VOLUME("Digital Mic Boost Volume", 0x1f, 0x0, HDA_INPUT
),
4802 static const struct snd_kcontrol_new ad1882_3stack_mixers
[] = {
4803 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT
),
4804 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x17, 1, 0x0, HDA_OUTPUT
),
4805 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x17, 2, 0x0, HDA_OUTPUT
),
4807 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4808 .name
= "Channel Mode",
4809 .info
= ad198x_ch_mode_info
,
4810 .get
= ad198x_ch_mode_get
,
4811 .put
= ad198x_ch_mode_put
,
4816 static const struct snd_kcontrol_new ad1882_6stack_mixers
[] = {
4817 HDA_CODEC_MUTE("Surround Playback Switch", 0x16, 0x0, HDA_OUTPUT
),
4818 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x24, 1, 0x0, HDA_OUTPUT
),
4819 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x24, 2, 0x0, HDA_OUTPUT
),
4823 static const struct hda_verb ad1882_ch2_init
[] = {
4824 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
4825 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4826 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4827 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
4828 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4829 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4833 static const struct hda_verb ad1882_ch4_init
[] = {
4834 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
4835 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4836 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4837 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
4838 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4839 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4843 static const struct hda_verb ad1882_ch6_init
[] = {
4844 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
4845 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4846 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4847 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
4848 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4849 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4853 static const struct hda_channel_mode ad1882_modes
[3] = {
4854 { 2, ad1882_ch2_init
},
4855 { 4, ad1882_ch4_init
},
4856 { 6, ad1882_ch6_init
},
4860 * initialization verbs
4862 static const struct hda_verb ad1882_init_verbs
[] = {
4863 /* DACs; mute as default */
4864 {0x03, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
4865 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
4866 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
4867 /* Port-A (HP) mixer */
4868 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4869 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4871 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
4872 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4873 /* HP selector - select DAC2 */
4874 {0x37, AC_VERB_SET_CONNECT_SEL
, 0x1},
4875 /* Port-D (Line-out) mixer */
4876 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4877 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4879 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
4880 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4881 /* Mono-out mixer */
4882 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4883 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4885 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
4886 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4887 /* Port-B (front mic) pin */
4888 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
4889 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4890 {0x39, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
}, /* boost */
4891 /* Port-C (line-in) pin */
4892 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
4893 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4894 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
}, /* boost */
4895 /* Port-C mixer - mute as input */
4896 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4897 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4898 /* Port-E (mic-in) pin */
4899 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
4900 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4901 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
}, /* boost */
4902 /* Port-E mixer - mute as input */
4903 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4904 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4905 /* Port-F (surround) */
4906 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
4907 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4909 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
4910 {0x24, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4911 /* Analog mixer; mute as default */
4912 /* list: 0x39, 0x3a, 0x11, 0x12, 0x3c, 0x3b, 0x18, 0x1a */
4913 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4914 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4915 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
4916 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
4917 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
4918 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)},
4919 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)},
4920 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)},
4921 /* Analog Mix output amp */
4922 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x1f}, /* 0dB */
4923 /* SPDIF output selector */
4924 {0x02, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x27}, /* 0dB */
4925 {0x02, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* PCM */
4926 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x27}, /* 0dB */
4930 #ifdef CONFIG_SND_HDA_POWER_SAVE
4931 static const struct hda_amp_list ad1882_loopbacks
[] = {
4932 { 0x20, HDA_INPUT
, 0 }, /* Front Mic */
4933 { 0x20, HDA_INPUT
, 1 }, /* Mic */
4934 { 0x20, HDA_INPUT
, 4 }, /* Line */
4935 { 0x20, HDA_INPUT
, 6 }, /* CD */
4947 static const char * const ad1882_models
[AD1986A_MODELS
] = {
4948 [AD1882_3STACK
] = "3stack",
4949 [AD1882_6STACK
] = "6stack",
4953 static int patch_ad1882(struct hda_codec
*codec
)
4955 struct ad198x_spec
*spec
;
4956 int err
, board_config
;
4958 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4964 err
= snd_hda_attach_beep_device(codec
, 0x10);
4969 set_beep_amp(spec
, 0x10, 0, HDA_OUTPUT
);
4971 spec
->multiout
.max_channels
= 6;
4972 spec
->multiout
.num_dacs
= 3;
4973 spec
->multiout
.dac_nids
= ad1882_dac_nids
;
4974 spec
->multiout
.dig_out_nid
= AD1882_SPDIF_OUT
;
4975 spec
->num_adc_nids
= ARRAY_SIZE(ad1882_adc_nids
);
4976 spec
->adc_nids
= ad1882_adc_nids
;
4977 spec
->capsrc_nids
= ad1882_capsrc_nids
;
4978 if (codec
->vendor_id
== 0x11d41882)
4979 spec
->input_mux
= &ad1882_capture_source
;
4981 spec
->input_mux
= &ad1882a_capture_source
;
4982 spec
->num_mixers
= 2;
4983 spec
->mixers
[0] = ad1882_base_mixers
;
4984 if (codec
->vendor_id
== 0x11d41882)
4985 spec
->mixers
[1] = ad1882_loopback_mixers
;
4987 spec
->mixers
[1] = ad1882a_loopback_mixers
;
4988 spec
->num_init_verbs
= 1;
4989 spec
->init_verbs
[0] = ad1882_init_verbs
;
4990 spec
->spdif_route
= 0;
4991 #ifdef CONFIG_SND_HDA_POWER_SAVE
4992 spec
->loopback
.amplist
= ad1882_loopbacks
;
4994 spec
->vmaster_nid
= 0x04;
4996 codec
->patch_ops
= ad198x_patch_ops
;
4998 /* override some parameters */
4999 board_config
= snd_hda_check_board_config(codec
, AD1882_MODELS
,
5000 ad1882_models
, NULL
);
5001 switch (board_config
) {
5004 spec
->num_mixers
= 3;
5005 spec
->mixers
[2] = ad1882_3stack_mixers
;
5006 spec
->channel_mode
= ad1882_modes
;
5007 spec
->num_channel_mode
= ARRAY_SIZE(ad1882_modes
);
5008 spec
->need_dac_fix
= 1;
5009 spec
->multiout
.max_channels
= 2;
5010 spec
->multiout
.num_dacs
= 1;
5013 spec
->num_mixers
= 3;
5014 spec
->mixers
[2] = ad1882_6stack_mixers
;
5018 codec
->no_trigger_sense
= 1;
5019 codec
->no_sticky_stream
= 1;
5028 static const struct hda_codec_preset snd_hda_preset_analog
[] = {
5029 { .id
= 0x11d4184a, .name
= "AD1884A", .patch
= patch_ad1884a
},
5030 { .id
= 0x11d41882, .name
= "AD1882", .patch
= patch_ad1882
},
5031 { .id
= 0x11d41883, .name
= "AD1883", .patch
= patch_ad1884a
},
5032 { .id
= 0x11d41884, .name
= "AD1884", .patch
= patch_ad1884
},
5033 { .id
= 0x11d4194a, .name
= "AD1984A", .patch
= patch_ad1884a
},
5034 { .id
= 0x11d4194b, .name
= "AD1984B", .patch
= patch_ad1884a
},
5035 { .id
= 0x11d41981, .name
= "AD1981", .patch
= patch_ad1981
},
5036 { .id
= 0x11d41983, .name
= "AD1983", .patch
= patch_ad1983
},
5037 { .id
= 0x11d41984, .name
= "AD1984", .patch
= patch_ad1984
},
5038 { .id
= 0x11d41986, .name
= "AD1986A", .patch
= patch_ad1986a
},
5039 { .id
= 0x11d41988, .name
= "AD1988", .patch
= patch_ad1988
},
5040 { .id
= 0x11d4198b, .name
= "AD1988B", .patch
= patch_ad1988
},
5041 { .id
= 0x11d4882a, .name
= "AD1882A", .patch
= patch_ad1882
},
5042 { .id
= 0x11d4989a, .name
= "AD1989A", .patch
= patch_ad1988
},
5043 { .id
= 0x11d4989b, .name
= "AD1989B", .patch
= patch_ad1988
},
5047 MODULE_ALIAS("snd-hda-codec-id:11d4*");
5049 MODULE_LICENSE("GPL");
5050 MODULE_DESCRIPTION("Analog Devices HD-audio codec");
5052 static struct hda_codec_preset_list analog_list
= {
5053 .preset
= snd_hda_preset_analog
,
5054 .owner
= THIS_MODULE
,
5057 static int __init
patch_analog_init(void)
5059 return snd_hda_add_codec_preset(&analog_list
);
5062 static void __exit
patch_analog_exit(void)
5064 snd_hda_delete_codec_preset(&analog_list
);
5067 module_init(patch_analog_init
)
5068 module_exit(patch_analog_exit
)