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>
27 #include <sound/core.h>
28 #include "hda_codec.h"
29 #include "hda_local.h"
33 struct snd_kcontrol_new
*mixers
[5];
35 unsigned int beep_amp
; /* beep amp value, set via set_beep_amp() */
36 const struct hda_verb
*init_verbs
[5]; /* initialization verbs
37 * don't forget NULL termination!
39 unsigned int num_init_verbs
;
42 struct hda_multi_out multiout
; /* playback set-up
43 * max_channels, dacs must be set
44 * dig_out_nid and hp_nid are optional
46 unsigned int cur_eapd
;
47 unsigned int need_dac_fix
;
50 unsigned int num_adc_nids
;
52 hda_nid_t dig_in_nid
; /* digital-in NID; optional */
55 const struct hda_input_mux
*input_mux
;
56 hda_nid_t
*capsrc_nids
;
57 unsigned int cur_mux
[3];
60 const struct hda_channel_mode
*channel_mode
;
64 struct hda_pcm pcm_rec
[3]; /* used in alc_build_pcms() */
66 unsigned int spdif_route
;
68 /* dynamic controls, init_verbs and input_mux */
69 struct auto_pin_cfg autocfg
;
70 struct snd_array kctls
;
71 struct hda_input_mux private_imux
;
72 hda_nid_t private_dac_nids
[AUTO_CFG_MAX_OUTS
];
74 unsigned int jack_present
:1;
75 unsigned int inv_jack_detect
:1;
77 #ifdef CONFIG_SND_HDA_POWER_SAVE
78 struct hda_loopback_check loopback
;
80 /* for virtual master */
81 hda_nid_t vmaster_nid
;
82 const char **slave_vols
;
83 const char **slave_sws
;
87 * input MUX handling (common part)
89 static int ad198x_mux_enum_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
91 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
92 struct ad198x_spec
*spec
= codec
->spec
;
94 return snd_hda_input_mux_info(spec
->input_mux
, uinfo
);
97 static int ad198x_mux_enum_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
99 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
100 struct ad198x_spec
*spec
= codec
->spec
;
101 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
103 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
107 static int ad198x_mux_enum_put(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 return snd_hda_input_mux_put(codec
, spec
->input_mux
, ucontrol
,
114 spec
->capsrc_nids
[adc_idx
],
115 &spec
->cur_mux
[adc_idx
]);
119 * initialization (common callbacks)
121 static int ad198x_init(struct hda_codec
*codec
)
123 struct ad198x_spec
*spec
= codec
->spec
;
126 for (i
= 0; i
< spec
->num_init_verbs
; i
++)
127 snd_hda_sequence_write(codec
, spec
->init_verbs
[i
]);
131 static const char *ad_slave_vols
[] = {
132 "Front Playback Volume",
133 "Surround Playback Volume",
134 "Center Playback Volume",
135 "LFE Playback Volume",
136 "Side Playback Volume",
137 "Headphone Playback Volume",
138 "Mono Playback Volume",
139 "Speaker Playback Volume",
140 "IEC958 Playback Volume",
144 static const char *ad_slave_sws
[] = {
145 "Front Playback Switch",
146 "Surround Playback Switch",
147 "Center Playback Switch",
148 "LFE Playback Switch",
149 "Side Playback Switch",
150 "Headphone Playback Switch",
151 "Mono Playback Switch",
152 "Speaker Playback Switch",
153 "IEC958 Playback Switch",
157 static void ad198x_free_kctls(struct hda_codec
*codec
);
159 /* additional beep mixers; the actual parameters are overwritten at build */
160 static struct snd_kcontrol_new ad_beep_mixer
[] = {
161 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_OUTPUT
),
162 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_OUTPUT
),
166 #define set_beep_amp(spec, nid, idx, dir) \
167 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir)) /* mono */
169 static int ad198x_build_controls(struct hda_codec
*codec
)
171 struct ad198x_spec
*spec
= codec
->spec
;
175 for (i
= 0; i
< spec
->num_mixers
; i
++) {
176 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
180 if (spec
->multiout
.dig_out_nid
) {
181 err
= snd_hda_create_spdif_out_ctls(codec
, spec
->multiout
.dig_out_nid
);
184 err
= snd_hda_create_spdif_share_sw(codec
,
188 spec
->multiout
.share_spdif
= 1;
190 if (spec
->dig_in_nid
) {
191 err
= snd_hda_create_spdif_in_ctls(codec
, spec
->dig_in_nid
);
196 /* create beep controls if needed */
197 if (spec
->beep_amp
) {
198 struct snd_kcontrol_new
*knew
;
199 for (knew
= ad_beep_mixer
; knew
->name
; knew
++) {
200 struct snd_kcontrol
*kctl
;
201 kctl
= snd_ctl_new1(knew
, codec
);
204 kctl
->private_value
= spec
->beep_amp
;
205 err
= snd_hda_ctl_add(codec
, kctl
);
211 /* if we have no master control, let's create it */
212 if (!snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
213 unsigned int vmaster_tlv
[4];
214 snd_hda_set_vmaster_tlv(codec
, spec
->vmaster_nid
,
215 HDA_OUTPUT
, vmaster_tlv
);
216 err
= snd_hda_add_vmaster(codec
, "Master Playback Volume",
219 spec
->slave_vols
: ad_slave_vols
));
223 if (!snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
224 err
= snd_hda_add_vmaster(codec
, "Master Playback Switch",
227 spec
->slave_sws
: ad_slave_sws
));
232 ad198x_free_kctls(codec
); /* no longer needed */
236 #ifdef CONFIG_SND_HDA_POWER_SAVE
237 static int ad198x_check_power_status(struct hda_codec
*codec
, hda_nid_t nid
)
239 struct ad198x_spec
*spec
= codec
->spec
;
240 return snd_hda_check_amp_list_power(codec
, &spec
->loopback
, nid
);
245 * Analog playback callbacks
247 static int ad198x_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
248 struct hda_codec
*codec
,
249 struct snd_pcm_substream
*substream
)
251 struct ad198x_spec
*spec
= codec
->spec
;
252 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
256 static int ad198x_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
257 struct hda_codec
*codec
,
258 unsigned int stream_tag
,
260 struct snd_pcm_substream
*substream
)
262 struct ad198x_spec
*spec
= codec
->spec
;
263 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
, stream_tag
,
267 static int ad198x_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
268 struct hda_codec
*codec
,
269 struct snd_pcm_substream
*substream
)
271 struct ad198x_spec
*spec
= codec
->spec
;
272 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
278 static int ad198x_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
279 struct hda_codec
*codec
,
280 struct snd_pcm_substream
*substream
)
282 struct ad198x_spec
*spec
= codec
->spec
;
283 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
286 static int ad198x_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
287 struct hda_codec
*codec
,
288 struct snd_pcm_substream
*substream
)
290 struct ad198x_spec
*spec
= codec
->spec
;
291 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
294 static int ad198x_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
295 struct hda_codec
*codec
,
296 unsigned int stream_tag
,
298 struct snd_pcm_substream
*substream
)
300 struct ad198x_spec
*spec
= codec
->spec
;
301 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
, stream_tag
,
305 static int ad198x_dig_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
306 struct hda_codec
*codec
,
307 struct snd_pcm_substream
*substream
)
309 struct ad198x_spec
*spec
= codec
->spec
;
310 return snd_hda_multi_out_dig_cleanup(codec
, &spec
->multiout
);
316 static int ad198x_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
317 struct hda_codec
*codec
,
318 unsigned int stream_tag
,
320 struct snd_pcm_substream
*substream
)
322 struct ad198x_spec
*spec
= codec
->spec
;
323 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
],
324 stream_tag
, 0, format
);
328 static int ad198x_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
329 struct hda_codec
*codec
,
330 struct snd_pcm_substream
*substream
)
332 struct ad198x_spec
*spec
= codec
->spec
;
333 snd_hda_codec_cleanup_stream(codec
, spec
->adc_nids
[substream
->number
]);
340 static struct hda_pcm_stream ad198x_pcm_analog_playback
= {
343 .channels_max
= 6, /* changed later */
344 .nid
= 0, /* fill later */
346 .open
= ad198x_playback_pcm_open
,
347 .prepare
= ad198x_playback_pcm_prepare
,
348 .cleanup
= ad198x_playback_pcm_cleanup
352 static struct hda_pcm_stream ad198x_pcm_analog_capture
= {
356 .nid
= 0, /* fill later */
358 .prepare
= ad198x_capture_pcm_prepare
,
359 .cleanup
= ad198x_capture_pcm_cleanup
363 static struct hda_pcm_stream ad198x_pcm_digital_playback
= {
367 .nid
= 0, /* fill later */
369 .open
= ad198x_dig_playback_pcm_open
,
370 .close
= ad198x_dig_playback_pcm_close
,
371 .prepare
= ad198x_dig_playback_pcm_prepare
,
372 .cleanup
= ad198x_dig_playback_pcm_cleanup
376 static struct hda_pcm_stream ad198x_pcm_digital_capture
= {
380 /* NID is set in alc_build_pcms */
383 static int ad198x_build_pcms(struct hda_codec
*codec
)
385 struct ad198x_spec
*spec
= codec
->spec
;
386 struct hda_pcm
*info
= spec
->pcm_rec
;
389 codec
->pcm_info
= info
;
391 info
->name
= "AD198x Analog";
392 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = ad198x_pcm_analog_playback
;
393 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
= spec
->multiout
.max_channels
;
394 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dac_nids
[0];
395 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = ad198x_pcm_analog_capture
;
396 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
= spec
->num_adc_nids
;
397 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
399 if (spec
->multiout
.dig_out_nid
) {
402 info
->name
= "AD198x Digital";
403 info
->pcm_type
= HDA_PCM_TYPE_SPDIF
;
404 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = ad198x_pcm_digital_playback
;
405 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dig_out_nid
;
406 if (spec
->dig_in_nid
) {
407 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = ad198x_pcm_digital_capture
;
408 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->dig_in_nid
;
415 static void ad198x_free_kctls(struct hda_codec
*codec
)
417 struct ad198x_spec
*spec
= codec
->spec
;
419 if (spec
->kctls
.list
) {
420 struct snd_kcontrol_new
*kctl
= spec
->kctls
.list
;
422 for (i
= 0; i
< spec
->kctls
.used
; i
++)
425 snd_array_free(&spec
->kctls
);
428 static void ad198x_free(struct hda_codec
*codec
)
430 struct ad198x_spec
*spec
= codec
->spec
;
435 ad198x_free_kctls(codec
);
437 snd_hda_detach_beep_device(codec
);
440 static struct hda_codec_ops ad198x_patch_ops
= {
441 .build_controls
= ad198x_build_controls
,
442 .build_pcms
= ad198x_build_pcms
,
445 #ifdef CONFIG_SND_HDA_POWER_SAVE
446 .check_power_status
= ad198x_check_power_status
,
453 * the private value = nid | (invert << 8)
455 #define ad198x_eapd_info snd_ctl_boolean_mono_info
457 static int ad198x_eapd_get(struct snd_kcontrol
*kcontrol
,
458 struct snd_ctl_elem_value
*ucontrol
)
460 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
461 struct ad198x_spec
*spec
= codec
->spec
;
462 int invert
= (kcontrol
->private_value
>> 8) & 1;
464 ucontrol
->value
.integer
.value
[0] = ! spec
->cur_eapd
;
466 ucontrol
->value
.integer
.value
[0] = spec
->cur_eapd
;
470 static int ad198x_eapd_put(struct snd_kcontrol
*kcontrol
,
471 struct snd_ctl_elem_value
*ucontrol
)
473 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
474 struct ad198x_spec
*spec
= codec
->spec
;
475 int invert
= (kcontrol
->private_value
>> 8) & 1;
476 hda_nid_t nid
= kcontrol
->private_value
& 0xff;
478 eapd
= !!ucontrol
->value
.integer
.value
[0];
481 if (eapd
== spec
->cur_eapd
)
483 spec
->cur_eapd
= eapd
;
484 snd_hda_codec_write_cache(codec
, nid
,
485 0, AC_VERB_SET_EAPD_BTLENABLE
,
490 static int ad198x_ch_mode_info(struct snd_kcontrol
*kcontrol
,
491 struct snd_ctl_elem_info
*uinfo
);
492 static int ad198x_ch_mode_get(struct snd_kcontrol
*kcontrol
,
493 struct snd_ctl_elem_value
*ucontrol
);
494 static int ad198x_ch_mode_put(struct snd_kcontrol
*kcontrol
,
495 struct snd_ctl_elem_value
*ucontrol
);
502 #define AD1986A_SPDIF_OUT 0x02
503 #define AD1986A_FRONT_DAC 0x03
504 #define AD1986A_SURR_DAC 0x04
505 #define AD1986A_CLFE_DAC 0x05
506 #define AD1986A_ADC 0x06
508 static hda_nid_t ad1986a_dac_nids
[3] = {
509 AD1986A_FRONT_DAC
, AD1986A_SURR_DAC
, AD1986A_CLFE_DAC
511 static hda_nid_t ad1986a_adc_nids
[1] = { AD1986A_ADC
};
512 static hda_nid_t ad1986a_capsrc_nids
[1] = { 0x12 };
514 static struct hda_input_mux ad1986a_capture_source
= {
528 static struct hda_bind_ctls ad1986a_bind_pcm_vol
= {
529 .ops
= &snd_hda_bind_vol
,
531 HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC
, 3, 0, HDA_OUTPUT
),
532 HDA_COMPOSE_AMP_VAL(AD1986A_SURR_DAC
, 3, 0, HDA_OUTPUT
),
533 HDA_COMPOSE_AMP_VAL(AD1986A_CLFE_DAC
, 3, 0, HDA_OUTPUT
),
538 static struct hda_bind_ctls ad1986a_bind_pcm_sw
= {
539 .ops
= &snd_hda_bind_sw
,
541 HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC
, 3, 0, HDA_OUTPUT
),
542 HDA_COMPOSE_AMP_VAL(AD1986A_SURR_DAC
, 3, 0, HDA_OUTPUT
),
543 HDA_COMPOSE_AMP_VAL(AD1986A_CLFE_DAC
, 3, 0, HDA_OUTPUT
),
551 static struct snd_kcontrol_new ad1986a_mixers
[] = {
553 * bind volumes/mutes of 3 DACs as a single PCM control for simplicity
555 HDA_BIND_VOL("PCM Playback Volume", &ad1986a_bind_pcm_vol
),
556 HDA_BIND_SW("PCM Playback Switch", &ad1986a_bind_pcm_sw
),
557 HDA_CODEC_VOLUME("Front Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
558 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT
),
559 HDA_CODEC_VOLUME("Surround Playback Volume", 0x1c, 0x0, HDA_OUTPUT
),
560 HDA_CODEC_MUTE("Surround Playback Switch", 0x1c, 0x0, HDA_OUTPUT
),
561 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x1d, 1, 0x0, HDA_OUTPUT
),
562 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x1d, 2, 0x0, HDA_OUTPUT
),
563 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x1d, 1, 0x0, HDA_OUTPUT
),
564 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x1d, 2, 0x0, HDA_OUTPUT
),
565 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT
),
566 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT
),
567 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT
),
568 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT
),
569 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT
),
570 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT
),
571 HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT
),
572 HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT
),
573 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
574 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
575 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT
),
576 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT
),
577 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT
),
578 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT
),
579 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT
),
581 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
582 .name
= "Capture Source",
583 .info
= ad198x_mux_enum_info
,
584 .get
= ad198x_mux_enum_get
,
585 .put
= ad198x_mux_enum_put
,
587 HDA_CODEC_MUTE("Stereo Downmix Switch", 0x09, 0x0, HDA_OUTPUT
),
591 /* additional mixers for 3stack mode */
592 static struct snd_kcontrol_new ad1986a_3st_mixers
[] = {
594 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
595 .name
= "Channel Mode",
596 .info
= ad198x_ch_mode_info
,
597 .get
= ad198x_ch_mode_get
,
598 .put
= ad198x_ch_mode_put
,
603 /* laptop model - 2ch only */
604 static hda_nid_t ad1986a_laptop_dac_nids
[1] = { AD1986A_FRONT_DAC
};
606 /* master controls both pins 0x1a and 0x1b */
607 static struct hda_bind_ctls ad1986a_laptop_master_vol
= {
608 .ops
= &snd_hda_bind_vol
,
610 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT
),
611 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT
),
616 static struct hda_bind_ctls ad1986a_laptop_master_sw
= {
617 .ops
= &snd_hda_bind_sw
,
619 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT
),
620 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT
),
625 static struct snd_kcontrol_new ad1986a_laptop_mixers
[] = {
626 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT
),
627 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT
),
628 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol
),
629 HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw
),
630 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT
),
631 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT
),
632 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT
),
633 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT
),
634 HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT
),
635 HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT
),
636 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
637 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
638 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT
),
640 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
641 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), */
642 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT
),
643 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT
),
645 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
646 .name
= "Capture Source",
647 .info
= ad198x_mux_enum_info
,
648 .get
= ad198x_mux_enum_get
,
649 .put
= ad198x_mux_enum_put
,
654 /* laptop-eapd model - 2ch only */
656 static struct hda_input_mux ad1986a_laptop_eapd_capture_source
= {
660 { "Internal Mic", 0x4 },
665 static struct hda_input_mux ad1986a_automic_capture_source
= {
673 static struct snd_kcontrol_new ad1986a_laptop_master_mixers
[] = {
674 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol
),
675 HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw
),
679 static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers
[] = {
680 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT
),
681 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT
),
682 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
683 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
684 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT
),
685 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT
),
686 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT
),
688 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
689 .name
= "Capture Source",
690 .info
= ad198x_mux_enum_info
,
691 .get
= ad198x_mux_enum_get
,
692 .put
= ad198x_mux_enum_put
,
695 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
696 .name
= "External Amplifier",
697 .info
= ad198x_eapd_info
,
698 .get
= ad198x_eapd_get
,
699 .put
= ad198x_eapd_put
,
700 .private_value
= 0x1b | (1 << 8), /* port-D, inversed */
705 static struct snd_kcontrol_new ad1986a_laptop_intmic_mixers
[] = {
706 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0, HDA_OUTPUT
),
707 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0, HDA_OUTPUT
),
711 /* re-connect the mic boost input according to the jack sensing */
712 static void ad1986a_automic(struct hda_codec
*codec
)
714 unsigned int present
;
715 present
= snd_hda_codec_read(codec
, 0x1f, 0, AC_VERB_GET_PIN_SENSE
, 0);
716 /* 0 = 0x1f, 2 = 0x1d, 4 = mixed */
717 snd_hda_codec_write(codec
, 0x0f, 0, AC_VERB_SET_CONNECT_SEL
,
718 (present
& AC_PINSENSE_PRESENCE
) ? 0 : 2);
721 #define AD1986A_MIC_EVENT 0x36
723 static void ad1986a_automic_unsol_event(struct hda_codec
*codec
,
726 if ((res
>> 26) != AD1986A_MIC_EVENT
)
728 ad1986a_automic(codec
);
731 static int ad1986a_automic_init(struct hda_codec
*codec
)
734 ad1986a_automic(codec
);
738 /* laptop-automute - 2ch only */
740 static void ad1986a_update_hp(struct hda_codec
*codec
)
742 struct ad198x_spec
*spec
= codec
->spec
;
745 if (spec
->jack_present
)
746 mute
= HDA_AMP_MUTE
; /* mute internal speaker */
748 /* unmute internal speaker if necessary */
749 mute
= snd_hda_codec_amp_read(codec
, 0x1a, 0, HDA_OUTPUT
, 0);
750 snd_hda_codec_amp_stereo(codec
, 0x1b, HDA_OUTPUT
, 0,
754 static void ad1986a_hp_automute(struct hda_codec
*codec
)
756 struct ad198x_spec
*spec
= codec
->spec
;
757 unsigned int present
;
759 present
= snd_hda_codec_read(codec
, 0x1a, 0, AC_VERB_GET_PIN_SENSE
, 0);
760 spec
->jack_present
= !!(present
& 0x80000000);
761 if (spec
->inv_jack_detect
)
762 spec
->jack_present
= !spec
->jack_present
;
763 ad1986a_update_hp(codec
);
766 #define AD1986A_HP_EVENT 0x37
768 static void ad1986a_hp_unsol_event(struct hda_codec
*codec
, unsigned int res
)
770 if ((res
>> 26) != AD1986A_HP_EVENT
)
772 ad1986a_hp_automute(codec
);
775 static int ad1986a_hp_init(struct hda_codec
*codec
)
778 ad1986a_hp_automute(codec
);
782 /* bind hp and internal speaker mute (with plug check) */
783 static int ad1986a_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
784 struct snd_ctl_elem_value
*ucontrol
)
786 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
787 long *valp
= ucontrol
->value
.integer
.value
;
790 change
= snd_hda_codec_amp_update(codec
, 0x1a, 0, HDA_OUTPUT
, 0,
792 valp
[0] ? 0 : HDA_AMP_MUTE
);
793 change
|= snd_hda_codec_amp_update(codec
, 0x1a, 1, HDA_OUTPUT
, 0,
795 valp
[1] ? 0 : HDA_AMP_MUTE
);
797 ad1986a_update_hp(codec
);
801 static struct snd_kcontrol_new ad1986a_automute_master_mixers
[] = {
802 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol
),
804 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
805 .name
= "Master Playback Switch",
806 .info
= snd_hda_mixer_amp_switch_info
,
807 .get
= snd_hda_mixer_amp_switch_get
,
808 .put
= ad1986a_hp_master_sw_put
,
809 .private_value
= HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT
),
816 * initialization verbs
818 static struct hda_verb ad1986a_init_verbs
[] = {
819 /* Front, Surround, CLFE DAC; mute as default */
820 {0x03, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
821 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
822 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
824 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
825 /* HP, Line-Out, Surround, CLFE selectors */
826 {0x0a, AC_VERB_SET_CONNECT_SEL
, 0x0},
827 {0x0b, AC_VERB_SET_CONNECT_SEL
, 0x0},
828 {0x0c, AC_VERB_SET_CONNECT_SEL
, 0x0},
829 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x0},
831 {0x0e, AC_VERB_SET_CONNECT_SEL
, 0x0},
832 /* Mic selector: Mic 1/2 pin */
833 {0x0f, AC_VERB_SET_CONNECT_SEL
, 0x0},
834 /* Line-in selector: Line-in */
835 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x0},
837 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x0},
838 /* Record selector: mic */
839 {0x12, AC_VERB_SET_CONNECT_SEL
, 0x0},
840 /* Mic, Phone, CD, Aux, Line-In amp; mute as default */
841 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
842 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
843 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
844 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
845 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
847 {0x18, AC_VERB_SET_CONNECT_SEL
, 0x0},
848 /* HP, Line-Out, Surround, CLFE, Mono pins; mute as default */
849 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
850 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
851 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
852 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
853 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
855 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0xc0 },
856 /* Front, Surround, CLFE Pins */
857 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
858 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
859 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
861 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
863 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24 },
864 /* Line, Aux, CD, Beep-In Pin */
865 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
866 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
867 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
868 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
869 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
873 static struct hda_verb ad1986a_ch2_init
[] = {
874 /* Surround out -> Line In */
875 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
876 /* Line-in selectors */
877 { 0x10, AC_VERB_SET_CONNECT_SEL
, 0x1 },
879 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
880 /* Mic selector, mix C/LFE (backmic) and Mic (frontmic) */
881 { 0x0f, AC_VERB_SET_CONNECT_SEL
, 0x4 },
885 static struct hda_verb ad1986a_ch4_init
[] = {
886 /* Surround out -> Surround */
887 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
888 { 0x10, AC_VERB_SET_CONNECT_SEL
, 0x0 },
890 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
891 { 0x0f, AC_VERB_SET_CONNECT_SEL
, 0x4 },
895 static struct hda_verb ad1986a_ch6_init
[] = {
896 /* Surround out -> Surround out */
897 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
898 { 0x10, AC_VERB_SET_CONNECT_SEL
, 0x0 },
900 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
901 { 0x0f, AC_VERB_SET_CONNECT_SEL
, 0x0 },
905 static struct hda_channel_mode ad1986a_modes
[3] = {
906 { 2, ad1986a_ch2_init
},
907 { 4, ad1986a_ch4_init
},
908 { 6, ad1986a_ch6_init
},
911 /* eapd initialization */
912 static struct hda_verb ad1986a_eapd_init_verbs
[] = {
913 {0x1b, AC_VERB_SET_EAPD_BTLENABLE
, 0x00 },
917 static struct hda_verb ad1986a_automic_verbs
[] = {
918 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
919 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
920 /*{0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},*/
921 {0x0f, AC_VERB_SET_CONNECT_SEL
, 0x0},
922 {0x1f, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1986A_MIC_EVENT
},
926 /* Ultra initialization */
927 static struct hda_verb ad1986a_ultra_init
[] = {
928 /* eapd initialization */
929 { 0x1b, AC_VERB_SET_EAPD_BTLENABLE
, 0x00 },
931 { 0x0f, AC_VERB_SET_CONNECT_SEL
, 0x2 },
932 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24 },
933 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080 },
937 /* pin sensing on HP jack */
938 static struct hda_verb ad1986a_hp_init_verbs
[] = {
939 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1986A_HP_EVENT
},
943 static void ad1986a_samsung_p50_unsol_event(struct hda_codec
*codec
,
947 case AD1986A_HP_EVENT
:
948 ad1986a_hp_automute(codec
);
950 case AD1986A_MIC_EVENT
:
951 ad1986a_automic(codec
);
956 static int ad1986a_samsung_p50_init(struct hda_codec
*codec
)
959 ad1986a_hp_automute(codec
);
960 ad1986a_automic(codec
);
971 AD1986A_LAPTOP_AUTOMUTE
,
978 static const char *ad1986a_models
[AD1986A_MODELS
] = {
979 [AD1986A_6STACK
] = "6stack",
980 [AD1986A_3STACK
] = "3stack",
981 [AD1986A_LAPTOP
] = "laptop",
982 [AD1986A_LAPTOP_EAPD
] = "laptop-eapd",
983 [AD1986A_LAPTOP_AUTOMUTE
] = "laptop-automute",
984 [AD1986A_ULTRA
] = "ultra",
985 [AD1986A_SAMSUNG
] = "samsung",
986 [AD1986A_SAMSUNG_P50
] = "samsung-p50",
989 static struct snd_pci_quirk ad1986a_cfg_tbl
[] = {
990 SND_PCI_QUIRK(0x103c, 0x30af, "HP B2800", AD1986A_LAPTOP_EAPD
),
991 SND_PCI_QUIRK(0x1043, 0x1153, "ASUS M9", AD1986A_LAPTOP_EAPD
),
992 SND_PCI_QUIRK(0x1043, 0x11f7, "ASUS U5A", AD1986A_LAPTOP_EAPD
),
993 SND_PCI_QUIRK(0x1043, 0x1213, "ASUS A6J", AD1986A_LAPTOP_EAPD
),
994 SND_PCI_QUIRK(0x1043, 0x1263, "ASUS U5F", AD1986A_LAPTOP_EAPD
),
995 SND_PCI_QUIRK(0x1043, 0x1297, "ASUS Z62F", AD1986A_LAPTOP_EAPD
),
996 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS V1j", AD1986A_LAPTOP_EAPD
),
997 SND_PCI_QUIRK(0x1043, 0x1302, "ASUS W3j", AD1986A_LAPTOP_EAPD
),
998 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS VX1", AD1986A_LAPTOP
),
999 SND_PCI_QUIRK(0x1043, 0x1447, "ASUS A8J", AD1986A_3STACK
),
1000 SND_PCI_QUIRK(0x1043, 0x817f, "ASUS P5", AD1986A_3STACK
),
1001 SND_PCI_QUIRK(0x1043, 0x818f, "ASUS P5", AD1986A_LAPTOP
),
1002 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS P5", AD1986A_3STACK
),
1003 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS M2N", AD1986A_3STACK
),
1004 SND_PCI_QUIRK(0x1043, 0x8234, "ASUS M2N", AD1986A_3STACK
),
1005 SND_PCI_QUIRK(0x10de, 0xcb84, "ASUS A8N-VM", AD1986A_3STACK
),
1006 SND_PCI_QUIRK(0x1179, 0xff40, "Toshiba Satellite L40-10Q", AD1986A_3STACK
),
1007 SND_PCI_QUIRK(0x144d, 0xb03c, "Samsung R55", AD1986A_3STACK
),
1008 SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP
),
1009 SND_PCI_QUIRK(0x144d, 0xc024, "Samsung P50", AD1986A_SAMSUNG_P50
),
1010 SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_ULTRA
),
1011 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc000, "Samsung", AD1986A_SAMSUNG
),
1012 SND_PCI_QUIRK(0x144d, 0xc504, "Samsung Q35", AD1986A_3STACK
),
1013 SND_PCI_QUIRK(0x17aa, 0x1011, "Lenovo M55", AD1986A_LAPTOP
),
1014 SND_PCI_QUIRK(0x17aa, 0x1017, "Lenovo A60", AD1986A_3STACK
),
1015 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo N100", AD1986A_LAPTOP_AUTOMUTE
),
1016 SND_PCI_QUIRK(0x17c0, 0x2017, "Samsung M50", AD1986A_LAPTOP
),
1020 #ifdef CONFIG_SND_HDA_POWER_SAVE
1021 static struct hda_amp_list ad1986a_loopbacks
[] = {
1022 { 0x13, HDA_OUTPUT
, 0 }, /* Mic */
1023 { 0x14, HDA_OUTPUT
, 0 }, /* Phone */
1024 { 0x15, HDA_OUTPUT
, 0 }, /* CD */
1025 { 0x16, HDA_OUTPUT
, 0 }, /* Aux */
1026 { 0x17, HDA_OUTPUT
, 0 }, /* Line */
1031 static int is_jack_available(struct hda_codec
*codec
, hda_nid_t nid
)
1033 unsigned int conf
= snd_hda_codec_get_pincfg(codec
, nid
);
1034 return get_defcfg_connect(conf
) != AC_JACK_PORT_NONE
;
1037 static int patch_ad1986a(struct hda_codec
*codec
)
1039 struct ad198x_spec
*spec
;
1040 int err
, board_config
;
1042 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1048 err
= snd_hda_attach_beep_device(codec
, 0x19);
1053 set_beep_amp(spec
, 0x18, 0, HDA_OUTPUT
);
1055 spec
->multiout
.max_channels
= 6;
1056 spec
->multiout
.num_dacs
= ARRAY_SIZE(ad1986a_dac_nids
);
1057 spec
->multiout
.dac_nids
= ad1986a_dac_nids
;
1058 spec
->multiout
.dig_out_nid
= AD1986A_SPDIF_OUT
;
1059 spec
->num_adc_nids
= 1;
1060 spec
->adc_nids
= ad1986a_adc_nids
;
1061 spec
->capsrc_nids
= ad1986a_capsrc_nids
;
1062 spec
->input_mux
= &ad1986a_capture_source
;
1063 spec
->num_mixers
= 1;
1064 spec
->mixers
[0] = ad1986a_mixers
;
1065 spec
->num_init_verbs
= 1;
1066 spec
->init_verbs
[0] = ad1986a_init_verbs
;
1067 #ifdef CONFIG_SND_HDA_POWER_SAVE
1068 spec
->loopback
.amplist
= ad1986a_loopbacks
;
1070 spec
->vmaster_nid
= 0x1b;
1072 codec
->patch_ops
= ad198x_patch_ops
;
1074 /* override some parameters */
1075 board_config
= snd_hda_check_board_config(codec
, AD1986A_MODELS
,
1078 switch (board_config
) {
1079 case AD1986A_3STACK
:
1080 spec
->num_mixers
= 2;
1081 spec
->mixers
[1] = ad1986a_3st_mixers
;
1082 spec
->num_init_verbs
= 2;
1083 spec
->init_verbs
[1] = ad1986a_ch2_init
;
1084 spec
->channel_mode
= ad1986a_modes
;
1085 spec
->num_channel_mode
= ARRAY_SIZE(ad1986a_modes
);
1086 spec
->need_dac_fix
= 1;
1087 spec
->multiout
.max_channels
= 2;
1088 spec
->multiout
.num_dacs
= 1;
1090 case AD1986A_LAPTOP
:
1091 spec
->mixers
[0] = ad1986a_laptop_mixers
;
1092 spec
->multiout
.max_channels
= 2;
1093 spec
->multiout
.num_dacs
= 1;
1094 spec
->multiout
.dac_nids
= ad1986a_laptop_dac_nids
;
1096 case AD1986A_LAPTOP_EAPD
:
1097 spec
->num_mixers
= 3;
1098 spec
->mixers
[0] = ad1986a_laptop_master_mixers
;
1099 spec
->mixers
[1] = ad1986a_laptop_eapd_mixers
;
1100 spec
->mixers
[2] = ad1986a_laptop_intmic_mixers
;
1101 spec
->num_init_verbs
= 2;
1102 spec
->init_verbs
[1] = ad1986a_eapd_init_verbs
;
1103 spec
->multiout
.max_channels
= 2;
1104 spec
->multiout
.num_dacs
= 1;
1105 spec
->multiout
.dac_nids
= ad1986a_laptop_dac_nids
;
1106 if (!is_jack_available(codec
, 0x25))
1107 spec
->multiout
.dig_out_nid
= 0;
1108 spec
->input_mux
= &ad1986a_laptop_eapd_capture_source
;
1110 case AD1986A_SAMSUNG
:
1111 spec
->num_mixers
= 2;
1112 spec
->mixers
[0] = ad1986a_laptop_master_mixers
;
1113 spec
->mixers
[1] = ad1986a_laptop_eapd_mixers
;
1114 spec
->num_init_verbs
= 3;
1115 spec
->init_verbs
[1] = ad1986a_eapd_init_verbs
;
1116 spec
->init_verbs
[2] = ad1986a_automic_verbs
;
1117 spec
->multiout
.max_channels
= 2;
1118 spec
->multiout
.num_dacs
= 1;
1119 spec
->multiout
.dac_nids
= ad1986a_laptop_dac_nids
;
1120 if (!is_jack_available(codec
, 0x25))
1121 spec
->multiout
.dig_out_nid
= 0;
1122 spec
->input_mux
= &ad1986a_automic_capture_source
;
1123 codec
->patch_ops
.unsol_event
= ad1986a_automic_unsol_event
;
1124 codec
->patch_ops
.init
= ad1986a_automic_init
;
1126 case AD1986A_SAMSUNG_P50
:
1127 spec
->num_mixers
= 2;
1128 spec
->mixers
[0] = ad1986a_automute_master_mixers
;
1129 spec
->mixers
[1] = ad1986a_laptop_eapd_mixers
;
1130 spec
->num_init_verbs
= 4;
1131 spec
->init_verbs
[1] = ad1986a_eapd_init_verbs
;
1132 spec
->init_verbs
[2] = ad1986a_automic_verbs
;
1133 spec
->init_verbs
[3] = ad1986a_hp_init_verbs
;
1134 spec
->multiout
.max_channels
= 2;
1135 spec
->multiout
.num_dacs
= 1;
1136 spec
->multiout
.dac_nids
= ad1986a_laptop_dac_nids
;
1137 if (!is_jack_available(codec
, 0x25))
1138 spec
->multiout
.dig_out_nid
= 0;
1139 spec
->input_mux
= &ad1986a_automic_capture_source
;
1140 codec
->patch_ops
.unsol_event
= ad1986a_samsung_p50_unsol_event
;
1141 codec
->patch_ops
.init
= ad1986a_samsung_p50_init
;
1143 case AD1986A_LAPTOP_AUTOMUTE
:
1144 spec
->num_mixers
= 3;
1145 spec
->mixers
[0] = ad1986a_automute_master_mixers
;
1146 spec
->mixers
[1] = ad1986a_laptop_eapd_mixers
;
1147 spec
->mixers
[2] = ad1986a_laptop_intmic_mixers
;
1148 spec
->num_init_verbs
= 3;
1149 spec
->init_verbs
[1] = ad1986a_eapd_init_verbs
;
1150 spec
->init_verbs
[2] = ad1986a_hp_init_verbs
;
1151 spec
->multiout
.max_channels
= 2;
1152 spec
->multiout
.num_dacs
= 1;
1153 spec
->multiout
.dac_nids
= ad1986a_laptop_dac_nids
;
1154 if (!is_jack_available(codec
, 0x25))
1155 spec
->multiout
.dig_out_nid
= 0;
1156 spec
->input_mux
= &ad1986a_laptop_eapd_capture_source
;
1157 codec
->patch_ops
.unsol_event
= ad1986a_hp_unsol_event
;
1158 codec
->patch_ops
.init
= ad1986a_hp_init
;
1159 /* Lenovo N100 seems to report the reversed bit
1160 * for HP jack-sensing
1162 spec
->inv_jack_detect
= 1;
1165 spec
->mixers
[0] = ad1986a_laptop_eapd_mixers
;
1166 spec
->num_init_verbs
= 2;
1167 spec
->init_verbs
[1] = ad1986a_ultra_init
;
1168 spec
->multiout
.max_channels
= 2;
1169 spec
->multiout
.num_dacs
= 1;
1170 spec
->multiout
.dac_nids
= ad1986a_laptop_dac_nids
;
1171 spec
->multiout
.dig_out_nid
= 0;
1175 /* AD1986A has a hardware problem that it can't share a stream
1176 * with multiple output pins. The copy of front to surrounds
1177 * causes noisy or silent outputs at a certain timing, e.g.
1178 * changing the volume.
1179 * So, let's disable the shared stream.
1181 spec
->multiout
.no_share_stream
= 1;
1190 #define AD1983_SPDIF_OUT 0x02
1191 #define AD1983_DAC 0x03
1192 #define AD1983_ADC 0x04
1194 static hda_nid_t ad1983_dac_nids
[1] = { AD1983_DAC
};
1195 static hda_nid_t ad1983_adc_nids
[1] = { AD1983_ADC
};
1196 static hda_nid_t ad1983_capsrc_nids
[1] = { 0x15 };
1198 static struct hda_input_mux ad1983_capture_source
= {
1204 { "Mix Mono", 0x3 },
1209 * SPDIF playback route
1211 static int ad1983_spdif_route_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
1213 static char *texts
[] = { "PCM", "ADC" };
1215 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
1217 uinfo
->value
.enumerated
.items
= 2;
1218 if (uinfo
->value
.enumerated
.item
> 1)
1219 uinfo
->value
.enumerated
.item
= 1;
1220 strcpy(uinfo
->value
.enumerated
.name
, texts
[uinfo
->value
.enumerated
.item
]);
1224 static int ad1983_spdif_route_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
1226 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1227 struct ad198x_spec
*spec
= codec
->spec
;
1229 ucontrol
->value
.enumerated
.item
[0] = spec
->spdif_route
;
1233 static int ad1983_spdif_route_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
1235 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1236 struct ad198x_spec
*spec
= codec
->spec
;
1238 if (ucontrol
->value
.enumerated
.item
[0] > 1)
1240 if (spec
->spdif_route
!= ucontrol
->value
.enumerated
.item
[0]) {
1241 spec
->spdif_route
= ucontrol
->value
.enumerated
.item
[0];
1242 snd_hda_codec_write_cache(codec
, spec
->multiout
.dig_out_nid
, 0,
1243 AC_VERB_SET_CONNECT_SEL
,
1250 static struct snd_kcontrol_new ad1983_mixers
[] = {
1251 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT
),
1252 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT
),
1253 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT
),
1254 HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT
),
1255 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT
),
1256 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT
),
1257 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
1258 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
1259 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
1260 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
1261 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
1262 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
1263 HDA_CODEC_VOLUME("Mic Boost", 0x0c, 0x0, HDA_OUTPUT
),
1264 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT
),
1265 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT
),
1267 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1268 .name
= "Capture Source",
1269 .info
= ad198x_mux_enum_info
,
1270 .get
= ad198x_mux_enum_get
,
1271 .put
= ad198x_mux_enum_put
,
1274 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1275 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,NONE
) "Source",
1276 .info
= ad1983_spdif_route_info
,
1277 .get
= ad1983_spdif_route_get
,
1278 .put
= ad1983_spdif_route_put
,
1283 static struct hda_verb ad1983_init_verbs
[] = {
1284 /* Front, HP, Mono; mute as default */
1285 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1286 {0x06, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1287 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1288 /* Beep, PCM, Mic, Line-In: mute */
1289 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1290 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1291 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1292 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1293 /* Front, HP selectors; from Mix */
1294 {0x05, AC_VERB_SET_CONNECT_SEL
, 0x01},
1295 {0x06, AC_VERB_SET_CONNECT_SEL
, 0x01},
1296 /* Mono selector; from Mix */
1297 {0x0b, AC_VERB_SET_CONNECT_SEL
, 0x03},
1298 /* Mic selector; Mic */
1299 {0x0c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1300 /* Line-in selector: Line-in */
1301 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x0},
1302 /* Mic boost: 0dB */
1303 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
1304 /* Record selector: mic */
1305 {0x15, AC_VERB_SET_CONNECT_SEL
, 0x0},
1306 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1307 /* SPDIF route: PCM */
1308 {0x02, AC_VERB_SET_CONNECT_SEL
, 0x0},
1310 {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
1312 {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0xc0 },
1314 {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
1316 {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24 },
1318 {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
1322 #ifdef CONFIG_SND_HDA_POWER_SAVE
1323 static struct hda_amp_list ad1983_loopbacks
[] = {
1324 { 0x12, HDA_OUTPUT
, 0 }, /* Mic */
1325 { 0x13, HDA_OUTPUT
, 0 }, /* Line */
1330 static int patch_ad1983(struct hda_codec
*codec
)
1332 struct ad198x_spec
*spec
;
1335 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1341 err
= snd_hda_attach_beep_device(codec
, 0x10);
1346 set_beep_amp(spec
, 0x10, 0, HDA_OUTPUT
);
1348 spec
->multiout
.max_channels
= 2;
1349 spec
->multiout
.num_dacs
= ARRAY_SIZE(ad1983_dac_nids
);
1350 spec
->multiout
.dac_nids
= ad1983_dac_nids
;
1351 spec
->multiout
.dig_out_nid
= AD1983_SPDIF_OUT
;
1352 spec
->num_adc_nids
= 1;
1353 spec
->adc_nids
= ad1983_adc_nids
;
1354 spec
->capsrc_nids
= ad1983_capsrc_nids
;
1355 spec
->input_mux
= &ad1983_capture_source
;
1356 spec
->num_mixers
= 1;
1357 spec
->mixers
[0] = ad1983_mixers
;
1358 spec
->num_init_verbs
= 1;
1359 spec
->init_verbs
[0] = ad1983_init_verbs
;
1360 spec
->spdif_route
= 0;
1361 #ifdef CONFIG_SND_HDA_POWER_SAVE
1362 spec
->loopback
.amplist
= ad1983_loopbacks
;
1364 spec
->vmaster_nid
= 0x05;
1366 codec
->patch_ops
= ad198x_patch_ops
;
1373 * AD1981 HD specific
1376 #define AD1981_SPDIF_OUT 0x02
1377 #define AD1981_DAC 0x03
1378 #define AD1981_ADC 0x04
1380 static hda_nid_t ad1981_dac_nids
[1] = { AD1981_DAC
};
1381 static hda_nid_t ad1981_adc_nids
[1] = { AD1981_ADC
};
1382 static hda_nid_t ad1981_capsrc_nids
[1] = { 0x15 };
1384 /* 0x0c, 0x09, 0x0e, 0x0f, 0x19, 0x05, 0x18, 0x17 */
1385 static struct hda_input_mux ad1981_capture_source
= {
1388 { "Front Mic", 0x0 },
1391 { "Mix Mono", 0x3 },
1398 static struct snd_kcontrol_new ad1981_mixers
[] = {
1399 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT
),
1400 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT
),
1401 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT
),
1402 HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT
),
1403 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT
),
1404 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT
),
1405 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
1406 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
1407 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
1408 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
1409 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
1410 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
1411 HDA_CODEC_VOLUME("Aux Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
1412 HDA_CODEC_MUTE("Aux Playback Switch", 0x1b, 0x0, HDA_OUTPUT
),
1413 HDA_CODEC_VOLUME("Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT
),
1414 HDA_CODEC_MUTE("Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT
),
1415 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
1416 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT
),
1417 HDA_CODEC_VOLUME("Front Mic Boost", 0x08, 0x0, HDA_INPUT
),
1418 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x0, HDA_INPUT
),
1419 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT
),
1420 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT
),
1422 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1423 .name
= "Capture Source",
1424 .info
= ad198x_mux_enum_info
,
1425 .get
= ad198x_mux_enum_get
,
1426 .put
= ad198x_mux_enum_put
,
1428 /* identical with AD1983 */
1430 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1431 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,NONE
) "Source",
1432 .info
= ad1983_spdif_route_info
,
1433 .get
= ad1983_spdif_route_get
,
1434 .put
= ad1983_spdif_route_put
,
1439 static struct hda_verb ad1981_init_verbs
[] = {
1440 /* Front, HP, Mono; mute as default */
1441 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1442 {0x06, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1443 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1444 /* Beep, PCM, Front Mic, Line, Rear Mic, Aux, CD-In: mute */
1445 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1446 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1447 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1448 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1449 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1450 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1451 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1452 /* Front, HP selectors; from Mix */
1453 {0x05, AC_VERB_SET_CONNECT_SEL
, 0x01},
1454 {0x06, AC_VERB_SET_CONNECT_SEL
, 0x01},
1455 /* Mono selector; from Mix */
1456 {0x0b, AC_VERB_SET_CONNECT_SEL
, 0x03},
1457 /* Mic Mixer; select Front Mic */
1458 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
1459 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1460 /* Mic boost: 0dB */
1461 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
1462 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
1463 /* Record selector: Front mic */
1464 {0x15, AC_VERB_SET_CONNECT_SEL
, 0x0},
1465 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1466 /* SPDIF route: PCM */
1467 {0x02, AC_VERB_SET_CONNECT_SEL
, 0x0},
1469 {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
1471 {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0xc0 },
1473 {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
1474 /* Front & Rear Mic Pins */
1475 {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24 },
1476 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24 },
1478 {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
1480 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x00},
1481 /* Line-Out as Input: disabled */
1482 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1486 #ifdef CONFIG_SND_HDA_POWER_SAVE
1487 static struct hda_amp_list ad1981_loopbacks
[] = {
1488 { 0x12, HDA_OUTPUT
, 0 }, /* Front Mic */
1489 { 0x13, HDA_OUTPUT
, 0 }, /* Line */
1490 { 0x1b, HDA_OUTPUT
, 0 }, /* Aux */
1491 { 0x1c, HDA_OUTPUT
, 0 }, /* Mic */
1492 { 0x1d, HDA_OUTPUT
, 0 }, /* CD */
1498 * Patch for HP nx6320
1500 * nx6320 uses EAPD in the reverse way - EAPD-on means the internal
1501 * speaker output enabled _and_ mute-LED off.
1504 #define AD1981_HP_EVENT 0x37
1505 #define AD1981_MIC_EVENT 0x38
1507 static struct hda_verb ad1981_hp_init_verbs
[] = {
1508 {0x05, AC_VERB_SET_EAPD_BTLENABLE
, 0x00 }, /* default off */
1509 /* pin sensing on HP and Mic jacks */
1510 {0x06, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1981_HP_EVENT
},
1511 {0x08, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1981_MIC_EVENT
},
1515 /* turn on/off EAPD (+ mute HP) as a master switch */
1516 static int ad1981_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1517 struct snd_ctl_elem_value
*ucontrol
)
1519 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1520 struct ad198x_spec
*spec
= codec
->spec
;
1522 if (! ad198x_eapd_put(kcontrol
, ucontrol
))
1524 /* change speaker pin appropriately */
1525 snd_hda_codec_write(codec
, 0x05, 0,
1526 AC_VERB_SET_PIN_WIDGET_CONTROL
,
1527 spec
->cur_eapd
? PIN_OUT
: 0);
1528 /* toggle HP mute appropriately */
1529 snd_hda_codec_amp_stereo(codec
, 0x06, HDA_OUTPUT
, 0,
1531 spec
->cur_eapd
? 0 : HDA_AMP_MUTE
);
1535 /* bind volumes of both NID 0x05 and 0x06 */
1536 static struct hda_bind_ctls ad1981_hp_bind_master_vol
= {
1537 .ops
= &snd_hda_bind_vol
,
1539 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT
),
1540 HDA_COMPOSE_AMP_VAL(0x06, 3, 0, HDA_OUTPUT
),
1545 /* mute internal speaker if HP is plugged */
1546 static void ad1981_hp_automute(struct hda_codec
*codec
)
1548 unsigned int present
;
1550 present
= snd_hda_codec_read(codec
, 0x06, 0,
1551 AC_VERB_GET_PIN_SENSE
, 0) & 0x80000000;
1552 snd_hda_codec_amp_stereo(codec
, 0x05, HDA_OUTPUT
, 0,
1553 HDA_AMP_MUTE
, present
? HDA_AMP_MUTE
: 0);
1556 /* toggle input of built-in and mic jack appropriately */
1557 static void ad1981_hp_automic(struct hda_codec
*codec
)
1559 static struct hda_verb mic_jack_on
[] = {
1560 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1561 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
1564 static struct hda_verb mic_jack_off
[] = {
1565 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1566 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
1569 unsigned int present
;
1571 present
= snd_hda_codec_read(codec
, 0x08, 0,
1572 AC_VERB_GET_PIN_SENSE
, 0) & 0x80000000;
1574 snd_hda_sequence_write(codec
, mic_jack_on
);
1576 snd_hda_sequence_write(codec
, mic_jack_off
);
1579 /* unsolicited event for HP jack sensing */
1580 static void ad1981_hp_unsol_event(struct hda_codec
*codec
,
1585 case AD1981_HP_EVENT
:
1586 ad1981_hp_automute(codec
);
1588 case AD1981_MIC_EVENT
:
1589 ad1981_hp_automic(codec
);
1594 static struct hda_input_mux ad1981_hp_capture_source
= {
1598 { "Docking-Station", 0x1 },
1603 static struct snd_kcontrol_new ad1981_hp_mixers
[] = {
1604 HDA_BIND_VOL("Master Playback Volume", &ad1981_hp_bind_master_vol
),
1606 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1607 .name
= "Master Playback Switch",
1608 .info
= ad198x_eapd_info
,
1609 .get
= ad198x_eapd_get
,
1610 .put
= ad1981_hp_master_sw_put
,
1611 .private_value
= 0x05,
1613 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
1614 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
1616 /* FIXME: analog mic/line loopback doesn't work with my tests...
1617 * (although recording is OK)
1619 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
1620 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
1621 HDA_CODEC_VOLUME("Docking-Station Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
1622 HDA_CODEC_MUTE("Docking-Station Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
1623 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT
),
1624 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT
),
1625 /* FIXME: does this laptop have analog CD connection? */
1626 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
1627 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT
),
1629 HDA_CODEC_VOLUME("Mic Boost", 0x08, 0x0, HDA_INPUT
),
1630 HDA_CODEC_VOLUME("Internal Mic Boost", 0x18, 0x0, HDA_INPUT
),
1631 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT
),
1632 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT
),
1634 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1635 .name
= "Capture Source",
1636 .info
= ad198x_mux_enum_info
,
1637 .get
= ad198x_mux_enum_get
,
1638 .put
= ad198x_mux_enum_put
,
1643 /* initialize jack-sensing, too */
1644 static int ad1981_hp_init(struct hda_codec
*codec
)
1647 ad1981_hp_automute(codec
);
1648 ad1981_hp_automic(codec
);
1652 /* configuration for Toshiba Laptops */
1653 static struct hda_verb ad1981_toshiba_init_verbs
[] = {
1654 {0x05, AC_VERB_SET_EAPD_BTLENABLE
, 0x01 }, /* default on */
1655 /* pin sensing on HP and Mic jacks */
1656 {0x06, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1981_HP_EVENT
},
1657 {0x08, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1981_MIC_EVENT
},
1661 static struct snd_kcontrol_new ad1981_toshiba_mixers
[] = {
1662 HDA_CODEC_VOLUME("Amp Volume", 0x1a, 0x0, HDA_OUTPUT
),
1663 HDA_CODEC_MUTE("Amp Switch", 0x1a, 0x0, HDA_OUTPUT
),
1667 /* configuration for Lenovo Thinkpad T60 */
1668 static struct snd_kcontrol_new ad1981_thinkpad_mixers
[] = {
1669 HDA_CODEC_VOLUME("Master Playback Volume", 0x05, 0x0, HDA_OUTPUT
),
1670 HDA_CODEC_MUTE("Master Playback Switch", 0x05, 0x0, HDA_OUTPUT
),
1671 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
1672 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
1673 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
1674 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
1675 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
1676 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT
),
1677 HDA_CODEC_VOLUME("Mic Boost", 0x08, 0x0, HDA_INPUT
),
1678 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT
),
1679 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT
),
1681 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1682 .name
= "Capture Source",
1683 .info
= ad198x_mux_enum_info
,
1684 .get
= ad198x_mux_enum_get
,
1685 .put
= ad198x_mux_enum_put
,
1687 /* identical with AD1983 */
1689 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1690 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,NONE
) "Source",
1691 .info
= ad1983_spdif_route_info
,
1692 .get
= ad1983_spdif_route_get
,
1693 .put
= ad1983_spdif_route_put
,
1698 static struct hda_input_mux ad1981_thinkpad_capture_source
= {
1716 static const char *ad1981_models
[AD1981_MODELS
] = {
1718 [AD1981_THINKPAD
] = "thinkpad",
1719 [AD1981_BASIC
] = "basic",
1720 [AD1981_TOSHIBA
] = "toshiba"
1723 static struct snd_pci_quirk ad1981_cfg_tbl
[] = {
1724 SND_PCI_QUIRK(0x1014, 0x0597, "Lenovo Z60", AD1981_THINKPAD
),
1725 SND_PCI_QUIRK(0x1014, 0x05b7, "Lenovo Z60m", AD1981_THINKPAD
),
1727 SND_PCI_QUIRK_VENDOR(0x103c, "HP nx", AD1981_HP
),
1728 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba U205", AD1981_TOSHIBA
),
1729 /* Lenovo Thinkpad T60/X60/Z6xx */
1730 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo Thinkpad", AD1981_THINKPAD
),
1731 /* HP nx6320 (reversed SSID, H/W bug) */
1732 SND_PCI_QUIRK(0x30b0, 0x103c, "HP nx6320", AD1981_HP
),
1736 static int patch_ad1981(struct hda_codec
*codec
)
1738 struct ad198x_spec
*spec
;
1739 int err
, board_config
;
1741 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1747 err
= snd_hda_attach_beep_device(codec
, 0x10);
1752 set_beep_amp(spec
, 0x0d, 0, HDA_OUTPUT
);
1754 spec
->multiout
.max_channels
= 2;
1755 spec
->multiout
.num_dacs
= ARRAY_SIZE(ad1981_dac_nids
);
1756 spec
->multiout
.dac_nids
= ad1981_dac_nids
;
1757 spec
->multiout
.dig_out_nid
= AD1981_SPDIF_OUT
;
1758 spec
->num_adc_nids
= 1;
1759 spec
->adc_nids
= ad1981_adc_nids
;
1760 spec
->capsrc_nids
= ad1981_capsrc_nids
;
1761 spec
->input_mux
= &ad1981_capture_source
;
1762 spec
->num_mixers
= 1;
1763 spec
->mixers
[0] = ad1981_mixers
;
1764 spec
->num_init_verbs
= 1;
1765 spec
->init_verbs
[0] = ad1981_init_verbs
;
1766 spec
->spdif_route
= 0;
1767 #ifdef CONFIG_SND_HDA_POWER_SAVE
1768 spec
->loopback
.amplist
= ad1981_loopbacks
;
1770 spec
->vmaster_nid
= 0x05;
1772 codec
->patch_ops
= ad198x_patch_ops
;
1774 /* override some parameters */
1775 board_config
= snd_hda_check_board_config(codec
, AD1981_MODELS
,
1778 switch (board_config
) {
1780 spec
->mixers
[0] = ad1981_hp_mixers
;
1781 spec
->num_init_verbs
= 2;
1782 spec
->init_verbs
[1] = ad1981_hp_init_verbs
;
1783 spec
->multiout
.dig_out_nid
= 0;
1784 spec
->input_mux
= &ad1981_hp_capture_source
;
1786 codec
->patch_ops
.init
= ad1981_hp_init
;
1787 codec
->patch_ops
.unsol_event
= ad1981_hp_unsol_event
;
1789 case AD1981_THINKPAD
:
1790 spec
->mixers
[0] = ad1981_thinkpad_mixers
;
1791 spec
->input_mux
= &ad1981_thinkpad_capture_source
;
1792 /* set the upper-limit for mixer amp to 0dB for avoiding the
1793 * possible damage by overloading
1795 snd_hda_override_amp_caps(codec
, 0x11, HDA_INPUT
,
1796 (0x17 << AC_AMPCAP_OFFSET_SHIFT
) |
1797 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
1798 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
1799 (1 << AC_AMPCAP_MUTE_SHIFT
));
1801 case AD1981_TOSHIBA
:
1802 spec
->mixers
[0] = ad1981_hp_mixers
;
1803 spec
->mixers
[1] = ad1981_toshiba_mixers
;
1804 spec
->num_init_verbs
= 2;
1805 spec
->init_verbs
[1] = ad1981_toshiba_init_verbs
;
1806 spec
->multiout
.dig_out_nid
= 0;
1807 spec
->input_mux
= &ad1981_hp_capture_source
;
1808 codec
->patch_ops
.init
= ad1981_hp_init
;
1809 codec
->patch_ops
.unsol_event
= ad1981_hp_unsol_event
;
1819 * Output pins and routes
1821 * Pin Mix Sel DAC (*)
1822 * port-A 0x11 (mute/hp) <- 0x22 <- 0x37 <- 03/04/06
1823 * port-B 0x14 (mute/hp) <- 0x2b <- 0x30 <- 03/04/06
1824 * port-C 0x15 (mute) <- 0x2c <- 0x31 <- 05/0a
1825 * port-D 0x12 (mute/hp) <- 0x29 <- 04
1826 * port-E 0x17 (mute/hp) <- 0x26 <- 0x32 <- 05/0a
1827 * port-F 0x16 (mute) <- 0x2a <- 06
1828 * port-G 0x24 (mute) <- 0x27 <- 05
1829 * port-H 0x25 (mute) <- 0x28 <- 0a
1830 * mono 0x13 (mute/amp)<- 0x1e <- 0x36 <- 03/04/06
1832 * DAC0 = 03h, DAC1 = 04h, DAC2 = 05h, DAC3 = 06h, DAC4 = 0ah
1833 * (*) DAC2/3/4 are swapped to DAC3/4/2 on AD198A rev.2 due to a h/w bug.
1835 * Input pins and routes
1837 * pin boost mix input # / adc input #
1838 * port-A 0x11 -> 0x38 -> mix 2, ADC 0
1839 * port-B 0x14 -> 0x39 -> mix 0, ADC 1
1840 * port-C 0x15 -> 0x3a -> 33:0 - mix 1, ADC 2
1841 * port-D 0x12 -> 0x3d -> mix 3, ADC 8
1842 * port-E 0x17 -> 0x3c -> 34:0 - mix 4, ADC 4
1843 * port-F 0x16 -> 0x3b -> mix 5, ADC 3
1844 * port-G 0x24 -> N/A -> 33:1 - mix 1, 34:1 - mix 4, ADC 6
1845 * port-H 0x25 -> N/A -> 33:2 - mix 1, 34:2 - mix 4, ADC 7
1849 * 6stack - front/surr/CLFE/side/opt DACs - 04/06/05/0a/03
1850 * 3stack - front/surr/CLFE/opt DACs - 04/05/0a/03
1852 * Inputs of Analog Mix (0x20)
1853 * 0:Port-B (front mic)
1854 * 1:Port-C/G/H (line-in)
1856 * 3:Port-D (line-in/2)
1857 * 4:Port-E/G/H (mic-in)
1858 * 5:Port-F (mic2-in)
1864 * 1:Port-B (front mic-in)
1865 * 2:Port-C (line-in)
1866 * 3:Port-F (mic2-in)
1871 * 8:Port-D (line-in/2)
1874 * Proposed pin assignments by the datasheet
1877 * Port-A front headphone
1887 * Port-A front headphone
1889 * C rear line-in/surround
1891 * E rear mic-in/CLFE
1897 * D internal speaker (with EAPD)
1898 * E/F quad mic array
1914 /* reivision id to check workarounds */
1915 #define AD1988A_REV2 0x100200
1917 #define is_rev2(codec) \
1918 ((codec)->vendor_id == 0x11d41988 && \
1919 (codec)->revision_id == AD1988A_REV2)
1925 static hda_nid_t ad1988_6stack_dac_nids
[4] = {
1926 0x04, 0x06, 0x05, 0x0a
1929 static hda_nid_t ad1988_3stack_dac_nids
[3] = {
1933 /* for AD1988A revision-2, DAC2-4 are swapped */
1934 static hda_nid_t ad1988_6stack_dac_nids_rev2
[4] = {
1935 0x04, 0x05, 0x0a, 0x06
1938 static hda_nid_t ad1988_3stack_dac_nids_rev2
[3] = {
1942 static hda_nid_t ad1988_adc_nids
[3] = {
1946 static hda_nid_t ad1988_capsrc_nids
[3] = {
1950 #define AD1988_SPDIF_OUT 0x02
1951 #define AD1988_SPDIF_OUT_HDMI 0x0b
1952 #define AD1988_SPDIF_IN 0x07
1954 static hda_nid_t ad1989b_slave_dig_outs
[] = {
1955 AD1988_SPDIF_OUT
, AD1988_SPDIF_OUT_HDMI
, 0
1958 static struct hda_input_mux ad1988_6stack_capture_source
= {
1961 { "Front Mic", 0x1 }, /* port-B */
1962 { "Line", 0x2 }, /* port-C */
1963 { "Mic", 0x4 }, /* port-E */
1969 static struct hda_input_mux ad1988_laptop_capture_source
= {
1972 { "Mic/Line", 0x1 }, /* port-B */
1980 static int ad198x_ch_mode_info(struct snd_kcontrol
*kcontrol
,
1981 struct snd_ctl_elem_info
*uinfo
)
1983 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1984 struct ad198x_spec
*spec
= codec
->spec
;
1985 return snd_hda_ch_mode_info(codec
, uinfo
, spec
->channel_mode
,
1986 spec
->num_channel_mode
);
1989 static int ad198x_ch_mode_get(struct snd_kcontrol
*kcontrol
,
1990 struct snd_ctl_elem_value
*ucontrol
)
1992 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1993 struct ad198x_spec
*spec
= codec
->spec
;
1994 return snd_hda_ch_mode_get(codec
, ucontrol
, spec
->channel_mode
,
1995 spec
->num_channel_mode
, spec
->multiout
.max_channels
);
1998 static int ad198x_ch_mode_put(struct snd_kcontrol
*kcontrol
,
1999 struct snd_ctl_elem_value
*ucontrol
)
2001 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2002 struct ad198x_spec
*spec
= codec
->spec
;
2003 int err
= snd_hda_ch_mode_put(codec
, ucontrol
, spec
->channel_mode
,
2004 spec
->num_channel_mode
,
2005 &spec
->multiout
.max_channels
);
2006 if (err
>= 0 && spec
->need_dac_fix
)
2007 spec
->multiout
.num_dacs
= spec
->multiout
.max_channels
/ 2;
2012 static struct snd_kcontrol_new ad1988_6stack_mixers1
[] = {
2013 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
2014 HDA_CODEC_VOLUME("Surround Playback Volume", 0x06, 0x0, HDA_OUTPUT
),
2015 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT
),
2016 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT
),
2017 HDA_CODEC_VOLUME("Side Playback Volume", 0x0a, 0x0, HDA_OUTPUT
),
2021 static struct snd_kcontrol_new ad1988_6stack_mixers1_rev2
[] = {
2022 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
2023 HDA_CODEC_VOLUME("Surround Playback Volume", 0x05, 0x0, HDA_OUTPUT
),
2024 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT
),
2025 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0a, 2, 0x0, HDA_OUTPUT
),
2026 HDA_CODEC_VOLUME("Side Playback Volume", 0x06, 0x0, HDA_OUTPUT
),
2030 static struct snd_kcontrol_new ad1988_6stack_mixers2
[] = {
2031 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT
),
2032 HDA_BIND_MUTE("Surround Playback Switch", 0x2a, 2, HDA_INPUT
),
2033 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x27, 1, 2, HDA_INPUT
),
2034 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x27, 2, 2, HDA_INPUT
),
2035 HDA_BIND_MUTE("Side Playback Switch", 0x28, 2, HDA_INPUT
),
2036 HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT
),
2037 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT
),
2039 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT
),
2040 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT
),
2041 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT
),
2042 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT
),
2043 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT
),
2044 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT
),
2045 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT
),
2046 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT
),
2048 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT
),
2049 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT
),
2051 HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT
),
2052 HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT
),
2058 static struct snd_kcontrol_new ad1988_3stack_mixers1
[] = {
2059 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
2060 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT
),
2061 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT
),
2062 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT
),
2066 static struct snd_kcontrol_new ad1988_3stack_mixers1_rev2
[] = {
2067 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
2068 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT
),
2069 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x06, 1, 0x0, HDA_OUTPUT
),
2070 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x06, 2, 0x0, HDA_OUTPUT
),
2074 static struct snd_kcontrol_new ad1988_3stack_mixers2
[] = {
2075 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT
),
2076 HDA_BIND_MUTE("Surround Playback Switch", 0x2c, 2, HDA_INPUT
),
2077 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x26, 1, 2, HDA_INPUT
),
2078 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x26, 2, 2, HDA_INPUT
),
2079 HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT
),
2080 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT
),
2082 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT
),
2083 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT
),
2084 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT
),
2085 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT
),
2086 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT
),
2087 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT
),
2088 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT
),
2089 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT
),
2091 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT
),
2092 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT
),
2094 HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT
),
2095 HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT
),
2097 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2098 .name
= "Channel Mode",
2099 .info
= ad198x_ch_mode_info
,
2100 .get
= ad198x_ch_mode_get
,
2101 .put
= ad198x_ch_mode_put
,
2108 static struct snd_kcontrol_new ad1988_laptop_mixers
[] = {
2109 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
2110 HDA_CODEC_MUTE("PCM Playback Switch", 0x29, 0x0, HDA_INPUT
),
2111 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT
),
2113 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT
),
2114 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT
),
2115 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x0, HDA_INPUT
),
2116 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x0, HDA_INPUT
),
2117 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT
),
2118 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT
),
2120 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT
),
2121 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT
),
2123 HDA_CODEC_VOLUME("Mic Boost", 0x39, 0x0, HDA_OUTPUT
),
2126 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2127 .name
= "External Amplifier",
2128 .info
= ad198x_eapd_info
,
2129 .get
= ad198x_eapd_get
,
2130 .put
= ad198x_eapd_put
,
2131 .private_value
= 0x12 | (1 << 8), /* port-D, inversed */
2138 static struct snd_kcontrol_new ad1988_capture_mixers
[] = {
2139 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
2140 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
2141 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT
),
2142 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT
),
2143 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x0e, 0x0, HDA_OUTPUT
),
2144 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x0e, 0x0, HDA_OUTPUT
),
2146 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2147 /* The multiple "Capture Source" controls confuse alsamixer
2148 * So call somewhat different..
2150 /* .name = "Capture Source", */
2151 .name
= "Input Source",
2153 .info
= ad198x_mux_enum_info
,
2154 .get
= ad198x_mux_enum_get
,
2155 .put
= ad198x_mux_enum_put
,
2160 static int ad1988_spdif_playback_source_info(struct snd_kcontrol
*kcontrol
,
2161 struct snd_ctl_elem_info
*uinfo
)
2163 static char *texts
[] = {
2164 "PCM", "ADC1", "ADC2", "ADC3"
2166 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
2168 uinfo
->value
.enumerated
.items
= 4;
2169 if (uinfo
->value
.enumerated
.item
>= 4)
2170 uinfo
->value
.enumerated
.item
= 3;
2171 strcpy(uinfo
->value
.enumerated
.name
, texts
[uinfo
->value
.enumerated
.item
]);
2175 static int ad1988_spdif_playback_source_get(struct snd_kcontrol
*kcontrol
,
2176 struct snd_ctl_elem_value
*ucontrol
)
2178 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2181 sel
= snd_hda_codec_read(codec
, 0x1d, 0, AC_VERB_GET_AMP_GAIN_MUTE
,
2184 ucontrol
->value
.enumerated
.item
[0] = 0;
2186 sel
= snd_hda_codec_read(codec
, 0x0b, 0,
2187 AC_VERB_GET_CONNECT_SEL
, 0);
2192 ucontrol
->value
.enumerated
.item
[0] = sel
;
2197 static int ad1988_spdif_playback_source_put(struct snd_kcontrol
*kcontrol
,
2198 struct snd_ctl_elem_value
*ucontrol
)
2200 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2201 unsigned int val
, sel
;
2204 val
= ucontrol
->value
.enumerated
.item
[0];
2208 sel
= snd_hda_codec_read(codec
, 0x1d, 0,
2209 AC_VERB_GET_AMP_GAIN_MUTE
,
2211 change
= sel
& 0x80;
2213 snd_hda_codec_write_cache(codec
, 0x1d, 0,
2214 AC_VERB_SET_AMP_GAIN_MUTE
,
2216 snd_hda_codec_write_cache(codec
, 0x1d, 0,
2217 AC_VERB_SET_AMP_GAIN_MUTE
,
2221 sel
= snd_hda_codec_read(codec
, 0x1d, 0,
2222 AC_VERB_GET_AMP_GAIN_MUTE
,
2223 AC_AMP_GET_INPUT
| 0x01);
2224 change
= sel
& 0x80;
2226 snd_hda_codec_write_cache(codec
, 0x1d, 0,
2227 AC_VERB_SET_AMP_GAIN_MUTE
,
2229 snd_hda_codec_write_cache(codec
, 0x1d, 0,
2230 AC_VERB_SET_AMP_GAIN_MUTE
,
2233 sel
= snd_hda_codec_read(codec
, 0x0b, 0,
2234 AC_VERB_GET_CONNECT_SEL
, 0) + 1;
2235 change
|= sel
!= val
;
2237 snd_hda_codec_write_cache(codec
, 0x0b, 0,
2238 AC_VERB_SET_CONNECT_SEL
,
2244 static struct snd_kcontrol_new ad1988_spdif_out_mixers
[] = {
2245 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
2247 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2248 .name
= "IEC958 Playback Source",
2249 .info
= ad1988_spdif_playback_source_info
,
2250 .get
= ad1988_spdif_playback_source_get
,
2251 .put
= ad1988_spdif_playback_source_put
,
2256 static struct snd_kcontrol_new ad1988_spdif_in_mixers
[] = {
2257 HDA_CODEC_VOLUME("IEC958 Capture Volume", 0x1c, 0x0, HDA_INPUT
),
2261 static struct snd_kcontrol_new ad1989_spdif_out_mixers
[] = {
2262 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
2263 HDA_CODEC_VOLUME("HDMI Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
2268 * initialization verbs
2272 * for 6-stack (+dig)
2274 static struct hda_verb ad1988_6stack_init_verbs
[] = {
2275 /* Front, Surround, CLFE, side DAC; unmute as default */
2276 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2277 {0x06, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2278 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2279 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2280 /* Port-A front headphon path */
2281 {0x37, AC_VERB_SET_CONNECT_SEL
, 0x01}, /* DAC1:04h */
2282 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2283 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2284 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2285 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2286 /* Port-D line-out path */
2287 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2288 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2289 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2290 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2291 /* Port-F surround path */
2292 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2293 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2294 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2295 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2296 /* Port-G CLFE path */
2297 {0x27, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2298 {0x27, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2299 {0x24, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2300 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2301 /* Port-H side path */
2302 {0x28, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2303 {0x28, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2304 {0x25, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2305 {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2307 {0x36, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* DAC1:04h */
2308 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2309 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2310 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2311 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb01f}, /* unmute, 0dB */
2312 /* Port-B front mic-in path */
2313 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2314 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2315 {0x39, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2316 /* Port-C line-in path */
2317 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2318 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2319 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2320 {0x33, AC_VERB_SET_CONNECT_SEL
, 0x0},
2321 /* Port-E mic-in path */
2322 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2323 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2324 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2325 {0x34, AC_VERB_SET_CONNECT_SEL
, 0x0},
2326 /* Analog CD Input */
2327 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2328 /* Analog Mix output amp */
2329 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x1f}, /* 0dB */
2334 static struct hda_verb ad1988_capture_init_verbs
[] = {
2335 /* mute analog mix */
2336 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2337 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2338 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2339 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2340 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2341 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)},
2342 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)},
2343 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)},
2344 /* select ADCs - front-mic */
2345 {0x0c, AC_VERB_SET_CONNECT_SEL
, 0x1},
2346 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x1},
2347 {0x0e, AC_VERB_SET_CONNECT_SEL
, 0x1},
2352 static struct hda_verb ad1988_spdif_init_verbs
[] = {
2354 {0x02, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* PCM */
2355 {0x0b, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* ADC1 */
2356 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2357 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2359 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x27}, /* 0dB */
2364 /* AD1989 has no ADC -> SPDIF route */
2365 static struct hda_verb ad1989_spdif_init_verbs
[] = {
2366 /* SPDIF-1 out pin */
2367 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2368 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x27}, /* 0dB */
2369 /* SPDIF-2/HDMI out pin */
2370 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2371 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x27}, /* 0dB */
2376 * verbs for 3stack (+dig)
2378 static struct hda_verb ad1988_3stack_ch2_init
[] = {
2379 /* set port-C to line-in */
2380 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2381 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2382 /* set port-E to mic-in */
2383 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2384 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2388 static struct hda_verb ad1988_3stack_ch6_init
[] = {
2389 /* set port-C to surround out */
2390 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2391 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2392 /* set port-E to CLFE out */
2393 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2394 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2398 static struct hda_channel_mode ad1988_3stack_modes
[2] = {
2399 { 2, ad1988_3stack_ch2_init
},
2400 { 6, ad1988_3stack_ch6_init
},
2403 static struct hda_verb ad1988_3stack_init_verbs
[] = {
2404 /* Front, Surround, CLFE, side DAC; unmute as default */
2405 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2406 {0x06, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2407 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2408 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2409 /* Port-A front headphon path */
2410 {0x37, AC_VERB_SET_CONNECT_SEL
, 0x01}, /* DAC1:04h */
2411 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2412 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2413 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2414 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2415 /* Port-D line-out path */
2416 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2417 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2418 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2419 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2421 {0x36, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* DAC1:04h */
2422 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2423 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2424 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2425 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb01f}, /* unmute, 0dB */
2426 /* Port-B front mic-in path */
2427 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2428 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2429 {0x39, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2430 /* Port-C line-in/surround path - 6ch mode as default */
2431 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2432 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2433 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2434 {0x31, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* output sel: DAC 0x05 */
2435 {0x33, AC_VERB_SET_CONNECT_SEL
, 0x0},
2436 /* Port-E mic-in/CLFE path - 6ch mode as default */
2437 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2438 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2439 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2440 {0x32, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* output sel: DAC 0x0a */
2441 {0x34, AC_VERB_SET_CONNECT_SEL
, 0x0},
2442 /* mute analog mix */
2443 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2444 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2445 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2446 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2447 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2448 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)},
2449 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)},
2450 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)},
2451 /* select ADCs - front-mic */
2452 {0x0c, AC_VERB_SET_CONNECT_SEL
, 0x1},
2453 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x1},
2454 {0x0e, AC_VERB_SET_CONNECT_SEL
, 0x1},
2455 /* Analog Mix output amp */
2456 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x1f}, /* 0dB */
2461 * verbs for laptop mode (+dig)
2463 static struct hda_verb ad1988_laptop_hp_on
[] = {
2464 /* unmute port-A and mute port-D */
2465 { 0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2466 { 0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2469 static struct hda_verb ad1988_laptop_hp_off
[] = {
2470 /* mute port-A and unmute port-D */
2471 { 0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2472 { 0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2476 #define AD1988_HP_EVENT 0x01
2478 static struct hda_verb ad1988_laptop_init_verbs
[] = {
2479 /* Front, Surround, CLFE, side DAC; unmute as default */
2480 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2481 {0x06, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2482 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2483 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2484 /* Port-A front headphon path */
2485 {0x37, AC_VERB_SET_CONNECT_SEL
, 0x01}, /* DAC1:04h */
2486 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2487 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2488 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2489 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2490 /* unsolicited event for pin-sense */
2491 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1988_HP_EVENT
},
2492 /* Port-D line-out path + EAPD */
2493 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2494 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2495 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2496 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2497 {0x12, AC_VERB_SET_EAPD_BTLENABLE
, 0x00}, /* EAPD-off */
2499 {0x36, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* DAC1:04h */
2500 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2501 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2502 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2503 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb01f}, /* unmute, 0dB */
2504 /* Port-B mic-in path */
2505 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2506 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2507 {0x39, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2508 /* Port-C docking station - try to output */
2509 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2510 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2511 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2512 {0x33, AC_VERB_SET_CONNECT_SEL
, 0x0},
2513 /* mute analog mix */
2514 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2515 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2516 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2517 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2518 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2519 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)},
2520 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)},
2521 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)},
2522 /* select ADCs - mic */
2523 {0x0c, AC_VERB_SET_CONNECT_SEL
, 0x1},
2524 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x1},
2525 {0x0e, AC_VERB_SET_CONNECT_SEL
, 0x1},
2526 /* Analog Mix output amp */
2527 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x1f}, /* 0dB */
2531 static void ad1988_laptop_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2533 if ((res
>> 26) != AD1988_HP_EVENT
)
2535 if (snd_hda_codec_read(codec
, 0x11, 0, AC_VERB_GET_PIN_SENSE
, 0) & (1 << 31))
2536 snd_hda_sequence_write(codec
, ad1988_laptop_hp_on
);
2538 snd_hda_sequence_write(codec
, ad1988_laptop_hp_off
);
2541 #ifdef CONFIG_SND_HDA_POWER_SAVE
2542 static struct hda_amp_list ad1988_loopbacks
[] = {
2543 { 0x20, HDA_INPUT
, 0 }, /* Front Mic */
2544 { 0x20, HDA_INPUT
, 1 }, /* Line */
2545 { 0x20, HDA_INPUT
, 4 }, /* Mic */
2546 { 0x20, HDA_INPUT
, 6 }, /* CD */
2552 * Automatic parse of I/O pins from the BIOS configuration
2560 static struct snd_kcontrol_new ad1988_control_templates
[] = {
2561 HDA_CODEC_VOLUME(NULL
, 0, 0, 0),
2562 HDA_CODEC_MUTE(NULL
, 0, 0, 0),
2563 HDA_BIND_MUTE(NULL
, 0, 0, 0),
2566 /* add dynamic controls */
2567 static int add_control(struct ad198x_spec
*spec
, int type
, const char *name
,
2570 struct snd_kcontrol_new
*knew
;
2572 snd_array_init(&spec
->kctls
, sizeof(*knew
), 32);
2573 knew
= snd_array_new(&spec
->kctls
);
2576 *knew
= ad1988_control_templates
[type
];
2577 knew
->name
= kstrdup(name
, GFP_KERNEL
);
2580 knew
->private_value
= val
;
2584 #define AD1988_PIN_CD_NID 0x18
2585 #define AD1988_PIN_BEEP_NID 0x10
2587 static hda_nid_t ad1988_mixer_nids
[8] = {
2588 /* A B C D E F G H */
2589 0x22, 0x2b, 0x2c, 0x29, 0x26, 0x2a, 0x27, 0x28
2592 static inline hda_nid_t
ad1988_idx_to_dac(struct hda_codec
*codec
, int idx
)
2594 static hda_nid_t idx_to_dac
[8] = {
2595 /* A B C D E F G H */
2596 0x04, 0x06, 0x05, 0x04, 0x0a, 0x06, 0x05, 0x0a
2598 static hda_nid_t idx_to_dac_rev2
[8] = {
2599 /* A B C D E F G H */
2600 0x04, 0x05, 0x0a, 0x04, 0x06, 0x05, 0x0a, 0x06
2603 return idx_to_dac_rev2
[idx
];
2605 return idx_to_dac
[idx
];
2608 static hda_nid_t ad1988_boost_nids
[8] = {
2609 0x38, 0x39, 0x3a, 0x3d, 0x3c, 0x3b, 0, 0
2612 static int ad1988_pin_idx(hda_nid_t nid
)
2614 static hda_nid_t ad1988_io_pins
[8] = {
2615 0x11, 0x14, 0x15, 0x12, 0x17, 0x16, 0x24, 0x25
2618 for (i
= 0; i
< ARRAY_SIZE(ad1988_io_pins
); i
++)
2619 if (ad1988_io_pins
[i
] == nid
)
2621 return 0; /* should be -1 */
2624 static int ad1988_pin_to_loopback_idx(hda_nid_t nid
)
2626 static int loopback_idx
[8] = {
2627 2, 0, 1, 3, 4, 5, 1, 4
2630 case AD1988_PIN_CD_NID
:
2633 return loopback_idx
[ad1988_pin_idx(nid
)];
2637 static int ad1988_pin_to_adc_idx(hda_nid_t nid
)
2639 static int adc_idx
[8] = {
2640 0, 1, 2, 8, 4, 3, 6, 7
2643 case AD1988_PIN_CD_NID
:
2646 return adc_idx
[ad1988_pin_idx(nid
)];
2650 /* fill in the dac_nids table from the parsed pin configuration */
2651 static int ad1988_auto_fill_dac_nids(struct hda_codec
*codec
,
2652 const struct auto_pin_cfg
*cfg
)
2654 struct ad198x_spec
*spec
= codec
->spec
;
2657 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
2659 /* check the pins hardwired to audio widget */
2660 for (i
= 0; i
< cfg
->line_outs
; i
++) {
2661 idx
= ad1988_pin_idx(cfg
->line_out_pins
[i
]);
2662 spec
->multiout
.dac_nids
[i
] = ad1988_idx_to_dac(codec
, idx
);
2664 spec
->multiout
.num_dacs
= cfg
->line_outs
;
2668 /* add playback controls from the parsed DAC table */
2669 static int ad1988_auto_create_multi_out_ctls(struct ad198x_spec
*spec
,
2670 const struct auto_pin_cfg
*cfg
)
2673 static const char *chname
[4] = { "Front", "Surround", NULL
/*CLFE*/, "Side" };
2677 for (i
= 0; i
< cfg
->line_outs
; i
++) {
2678 hda_nid_t dac
= spec
->multiout
.dac_nids
[i
];
2681 nid
= ad1988_mixer_nids
[ad1988_pin_idx(cfg
->line_out_pins
[i
])];
2684 err
= add_control(spec
, AD_CTL_WIDGET_VOL
,
2685 "Center Playback Volume",
2686 HDA_COMPOSE_AMP_VAL(dac
, 1, 0, HDA_OUTPUT
));
2689 err
= add_control(spec
, AD_CTL_WIDGET_VOL
,
2690 "LFE Playback Volume",
2691 HDA_COMPOSE_AMP_VAL(dac
, 2, 0, HDA_OUTPUT
));
2694 err
= add_control(spec
, AD_CTL_BIND_MUTE
,
2695 "Center Playback Switch",
2696 HDA_COMPOSE_AMP_VAL(nid
, 1, 2, HDA_INPUT
));
2699 err
= add_control(spec
, AD_CTL_BIND_MUTE
,
2700 "LFE Playback Switch",
2701 HDA_COMPOSE_AMP_VAL(nid
, 2, 2, HDA_INPUT
));
2705 sprintf(name
, "%s Playback Volume", chname
[i
]);
2706 err
= add_control(spec
, AD_CTL_WIDGET_VOL
, name
,
2707 HDA_COMPOSE_AMP_VAL(dac
, 3, 0, HDA_OUTPUT
));
2710 sprintf(name
, "%s Playback Switch", chname
[i
]);
2711 err
= add_control(spec
, AD_CTL_BIND_MUTE
, name
,
2712 HDA_COMPOSE_AMP_VAL(nid
, 3, 2, HDA_INPUT
));
2720 /* add playback controls for speaker and HP outputs */
2721 static int ad1988_auto_create_extra_out(struct hda_codec
*codec
, hda_nid_t pin
,
2724 struct ad198x_spec
*spec
= codec
->spec
;
2732 idx
= ad1988_pin_idx(pin
);
2733 nid
= ad1988_idx_to_dac(codec
, idx
);
2734 /* check whether the corresponding DAC was already taken */
2735 for (i
= 0; i
< spec
->autocfg
.line_outs
; i
++) {
2736 hda_nid_t pin
= spec
->autocfg
.line_out_pins
[i
];
2737 hda_nid_t dac
= ad1988_idx_to_dac(codec
, ad1988_pin_idx(pin
));
2741 if (i
>= spec
->autocfg
.line_outs
) {
2742 /* specify the DAC as the extra output */
2743 if (!spec
->multiout
.hp_nid
)
2744 spec
->multiout
.hp_nid
= nid
;
2746 spec
->multiout
.extra_out_nid
[0] = nid
;
2747 /* control HP volume/switch on the output mixer amp */
2748 sprintf(name
, "%s Playback Volume", pfx
);
2749 err
= add_control(spec
, AD_CTL_WIDGET_VOL
, name
,
2750 HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
));
2754 nid
= ad1988_mixer_nids
[idx
];
2755 sprintf(name
, "%s Playback Switch", pfx
);
2756 if ((err
= add_control(spec
, AD_CTL_BIND_MUTE
, name
,
2757 HDA_COMPOSE_AMP_VAL(nid
, 3, 2, HDA_INPUT
))) < 0)
2762 /* create input playback/capture controls for the given pin */
2763 static int new_analog_input(struct ad198x_spec
*spec
, hda_nid_t pin
,
2764 const char *ctlname
, int boost
)
2769 sprintf(name
, "%s Playback Volume", ctlname
);
2770 idx
= ad1988_pin_to_loopback_idx(pin
);
2771 if ((err
= add_control(spec
, AD_CTL_WIDGET_VOL
, name
,
2772 HDA_COMPOSE_AMP_VAL(0x20, 3, idx
, HDA_INPUT
))) < 0)
2774 sprintf(name
, "%s Playback Switch", ctlname
);
2775 if ((err
= add_control(spec
, AD_CTL_WIDGET_MUTE
, name
,
2776 HDA_COMPOSE_AMP_VAL(0x20, 3, idx
, HDA_INPUT
))) < 0)
2780 idx
= ad1988_pin_idx(pin
);
2781 bnid
= ad1988_boost_nids
[idx
];
2783 sprintf(name
, "%s Boost", ctlname
);
2784 return add_control(spec
, AD_CTL_WIDGET_VOL
, name
,
2785 HDA_COMPOSE_AMP_VAL(bnid
, 3, idx
, HDA_OUTPUT
));
2792 /* create playback/capture controls for input pins */
2793 static int ad1988_auto_create_analog_input_ctls(struct ad198x_spec
*spec
,
2794 const struct auto_pin_cfg
*cfg
)
2796 struct hda_input_mux
*imux
= &spec
->private_imux
;
2799 for (i
= 0; i
< AUTO_PIN_LAST
; i
++) {
2800 err
= new_analog_input(spec
, cfg
->input_pins
[i
],
2801 auto_pin_cfg_labels
[i
],
2802 i
<= AUTO_PIN_FRONT_MIC
);
2805 imux
->items
[imux
->num_items
].label
= auto_pin_cfg_labels
[i
];
2806 imux
->items
[imux
->num_items
].index
= ad1988_pin_to_adc_idx(cfg
->input_pins
[i
]);
2809 imux
->items
[imux
->num_items
].label
= "Mix";
2810 imux
->items
[imux
->num_items
].index
= 9;
2813 if ((err
= add_control(spec
, AD_CTL_WIDGET_VOL
,
2814 "Analog Mix Playback Volume",
2815 HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT
))) < 0)
2817 if ((err
= add_control(spec
, AD_CTL_WIDGET_MUTE
,
2818 "Analog Mix Playback Switch",
2819 HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT
))) < 0)
2825 static void ad1988_auto_set_output_and_unmute(struct hda_codec
*codec
,
2826 hda_nid_t nid
, int pin_type
,
2830 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
, pin_type
);
2831 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
);
2833 case 0x11: /* port-A - DAC 04 */
2834 snd_hda_codec_write(codec
, 0x37, 0, AC_VERB_SET_CONNECT_SEL
, 0x01);
2836 case 0x14: /* port-B - DAC 06 */
2837 snd_hda_codec_write(codec
, 0x30, 0, AC_VERB_SET_CONNECT_SEL
, 0x02);
2839 case 0x15: /* port-C - DAC 05 */
2840 snd_hda_codec_write(codec
, 0x31, 0, AC_VERB_SET_CONNECT_SEL
, 0x00);
2842 case 0x17: /* port-E - DAC 0a */
2843 snd_hda_codec_write(codec
, 0x32, 0, AC_VERB_SET_CONNECT_SEL
, 0x01);
2845 case 0x13: /* mono - DAC 04 */
2846 snd_hda_codec_write(codec
, 0x36, 0, AC_VERB_SET_CONNECT_SEL
, 0x01);
2851 static void ad1988_auto_init_multi_out(struct hda_codec
*codec
)
2853 struct ad198x_spec
*spec
= codec
->spec
;
2856 for (i
= 0; i
< spec
->autocfg
.line_outs
; i
++) {
2857 hda_nid_t nid
= spec
->autocfg
.line_out_pins
[i
];
2858 ad1988_auto_set_output_and_unmute(codec
, nid
, PIN_OUT
, i
);
2862 static void ad1988_auto_init_extra_out(struct hda_codec
*codec
)
2864 struct ad198x_spec
*spec
= codec
->spec
;
2867 pin
= spec
->autocfg
.speaker_pins
[0];
2868 if (pin
) /* connect to front */
2869 ad1988_auto_set_output_and_unmute(codec
, pin
, PIN_OUT
, 0);
2870 pin
= spec
->autocfg
.hp_pins
[0];
2871 if (pin
) /* connect to front */
2872 ad1988_auto_set_output_and_unmute(codec
, pin
, PIN_HP
, 0);
2875 static void ad1988_auto_init_analog_input(struct hda_codec
*codec
)
2877 struct ad198x_spec
*spec
= codec
->spec
;
2880 for (i
= 0; i
< AUTO_PIN_LAST
; i
++) {
2881 hda_nid_t nid
= spec
->autocfg
.input_pins
[i
];
2885 case 0x15: /* port-C */
2886 snd_hda_codec_write(codec
, 0x33, 0, AC_VERB_SET_CONNECT_SEL
, 0x0);
2888 case 0x17: /* port-E */
2889 snd_hda_codec_write(codec
, 0x34, 0, AC_VERB_SET_CONNECT_SEL
, 0x0);
2892 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2893 i
<= AUTO_PIN_FRONT_MIC
? PIN_VREF80
: PIN_IN
);
2894 if (nid
!= AD1988_PIN_CD_NID
)
2895 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
2897 idx
= ad1988_pin_idx(nid
);
2898 if (ad1988_boost_nids
[idx
])
2899 snd_hda_codec_write(codec
, ad1988_boost_nids
[idx
], 0,
2900 AC_VERB_SET_AMP_GAIN_MUTE
,
2905 /* parse the BIOS configuration and set up the alc_spec */
2906 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2907 static int ad1988_parse_auto_config(struct hda_codec
*codec
)
2909 struct ad198x_spec
*spec
= codec
->spec
;
2912 if ((err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
)) < 0)
2914 if ((err
= ad1988_auto_fill_dac_nids(codec
, &spec
->autocfg
)) < 0)
2916 if (! spec
->autocfg
.line_outs
)
2917 return 0; /* can't find valid BIOS pin config */
2918 if ((err
= ad1988_auto_create_multi_out_ctls(spec
, &spec
->autocfg
)) < 0 ||
2919 (err
= ad1988_auto_create_extra_out(codec
,
2920 spec
->autocfg
.speaker_pins
[0],
2922 (err
= ad1988_auto_create_extra_out(codec
, spec
->autocfg
.hp_pins
[0],
2923 "Headphone")) < 0 ||
2924 (err
= ad1988_auto_create_analog_input_ctls(spec
, &spec
->autocfg
)) < 0)
2927 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
2929 if (spec
->autocfg
.dig_outs
)
2930 spec
->multiout
.dig_out_nid
= AD1988_SPDIF_OUT
;
2931 if (spec
->autocfg
.dig_in_pin
)
2932 spec
->dig_in_nid
= AD1988_SPDIF_IN
;
2934 if (spec
->kctls
.list
)
2935 spec
->mixers
[spec
->num_mixers
++] = spec
->kctls
.list
;
2937 spec
->init_verbs
[spec
->num_init_verbs
++] = ad1988_6stack_init_verbs
;
2939 spec
->input_mux
= &spec
->private_imux
;
2944 /* init callback for auto-configuration model -- overriding the default init */
2945 static int ad1988_auto_init(struct hda_codec
*codec
)
2948 ad1988_auto_init_multi_out(codec
);
2949 ad1988_auto_init_extra_out(codec
);
2950 ad1988_auto_init_analog_input(codec
);
2958 static const char *ad1988_models
[AD1988_MODEL_LAST
] = {
2959 [AD1988_6STACK
] = "6stack",
2960 [AD1988_6STACK_DIG
] = "6stack-dig",
2961 [AD1988_3STACK
] = "3stack",
2962 [AD1988_3STACK_DIG
] = "3stack-dig",
2963 [AD1988_LAPTOP
] = "laptop",
2964 [AD1988_LAPTOP_DIG
] = "laptop-dig",
2965 [AD1988_AUTO
] = "auto",
2968 static struct snd_pci_quirk ad1988_cfg_tbl
[] = {
2969 SND_PCI_QUIRK(0x1043, 0x81ec, "Asus P5B-DLX", AD1988_6STACK_DIG
),
2970 SND_PCI_QUIRK(0x1043, 0x81f6, "Asus M2N-SLI", AD1988_6STACK_DIG
),
2971 SND_PCI_QUIRK(0x1043, 0x8277, "Asus P5K-E/WIFI-AP", AD1988_6STACK_DIG
),
2972 SND_PCI_QUIRK(0x1043, 0x8311, "Asus P5Q-Premium/Pro", AD1988_6STACK_DIG
),
2976 static int patch_ad1988(struct hda_codec
*codec
)
2978 struct ad198x_spec
*spec
;
2979 int err
, board_config
;
2981 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
2988 snd_printk(KERN_INFO
"patch_analog: AD1988A rev.2 is detected, enable workarounds\n");
2990 board_config
= snd_hda_check_board_config(codec
, AD1988_MODEL_LAST
,
2991 ad1988_models
, ad1988_cfg_tbl
);
2992 if (board_config
< 0) {
2993 printk(KERN_INFO
"hda_codec: %s: BIOS auto-probing.\n",
2995 board_config
= AD1988_AUTO
;
2998 if (board_config
== AD1988_AUTO
) {
2999 /* automatic parse from the BIOS config */
3000 err
= ad1988_parse_auto_config(codec
);
3005 printk(KERN_INFO
"hda_codec: Cannot set up configuration from BIOS. Using 6-stack mode...\n");
3006 board_config
= AD1988_6STACK
;
3010 err
= snd_hda_attach_beep_device(codec
, 0x10);
3015 set_beep_amp(spec
, 0x10, 0, HDA_OUTPUT
);
3017 switch (board_config
) {
3019 case AD1988_6STACK_DIG
:
3020 spec
->multiout
.max_channels
= 8;
3021 spec
->multiout
.num_dacs
= 4;
3023 spec
->multiout
.dac_nids
= ad1988_6stack_dac_nids_rev2
;
3025 spec
->multiout
.dac_nids
= ad1988_6stack_dac_nids
;
3026 spec
->input_mux
= &ad1988_6stack_capture_source
;
3027 spec
->num_mixers
= 2;
3029 spec
->mixers
[0] = ad1988_6stack_mixers1_rev2
;
3031 spec
->mixers
[0] = ad1988_6stack_mixers1
;
3032 spec
->mixers
[1] = ad1988_6stack_mixers2
;
3033 spec
->num_init_verbs
= 1;
3034 spec
->init_verbs
[0] = ad1988_6stack_init_verbs
;
3035 if (board_config
== AD1988_6STACK_DIG
) {
3036 spec
->multiout
.dig_out_nid
= AD1988_SPDIF_OUT
;
3037 spec
->dig_in_nid
= AD1988_SPDIF_IN
;
3041 case AD1988_3STACK_DIG
:
3042 spec
->multiout
.max_channels
= 6;
3043 spec
->multiout
.num_dacs
= 3;
3045 spec
->multiout
.dac_nids
= ad1988_3stack_dac_nids_rev2
;
3047 spec
->multiout
.dac_nids
= ad1988_3stack_dac_nids
;
3048 spec
->input_mux
= &ad1988_6stack_capture_source
;
3049 spec
->channel_mode
= ad1988_3stack_modes
;
3050 spec
->num_channel_mode
= ARRAY_SIZE(ad1988_3stack_modes
);
3051 spec
->num_mixers
= 2;
3053 spec
->mixers
[0] = ad1988_3stack_mixers1_rev2
;
3055 spec
->mixers
[0] = ad1988_3stack_mixers1
;
3056 spec
->mixers
[1] = ad1988_3stack_mixers2
;
3057 spec
->num_init_verbs
= 1;
3058 spec
->init_verbs
[0] = ad1988_3stack_init_verbs
;
3059 if (board_config
== AD1988_3STACK_DIG
)
3060 spec
->multiout
.dig_out_nid
= AD1988_SPDIF_OUT
;
3063 case AD1988_LAPTOP_DIG
:
3064 spec
->multiout
.max_channels
= 2;
3065 spec
->multiout
.num_dacs
= 1;
3066 spec
->multiout
.dac_nids
= ad1988_3stack_dac_nids
;
3067 spec
->input_mux
= &ad1988_laptop_capture_source
;
3068 spec
->num_mixers
= 1;
3069 spec
->mixers
[0] = ad1988_laptop_mixers
;
3070 spec
->num_init_verbs
= 1;
3071 spec
->init_verbs
[0] = ad1988_laptop_init_verbs
;
3072 if (board_config
== AD1988_LAPTOP_DIG
)
3073 spec
->multiout
.dig_out_nid
= AD1988_SPDIF_OUT
;
3077 spec
->num_adc_nids
= ARRAY_SIZE(ad1988_adc_nids
);
3078 spec
->adc_nids
= ad1988_adc_nids
;
3079 spec
->capsrc_nids
= ad1988_capsrc_nids
;
3080 spec
->mixers
[spec
->num_mixers
++] = ad1988_capture_mixers
;
3081 spec
->init_verbs
[spec
->num_init_verbs
++] = ad1988_capture_init_verbs
;
3082 if (spec
->multiout
.dig_out_nid
) {
3083 if (codec
->vendor_id
>= 0x11d4989a) {
3084 spec
->mixers
[spec
->num_mixers
++] =
3085 ad1989_spdif_out_mixers
;
3086 spec
->init_verbs
[spec
->num_init_verbs
++] =
3087 ad1989_spdif_init_verbs
;
3088 codec
->slave_dig_outs
= ad1989b_slave_dig_outs
;
3090 spec
->mixers
[spec
->num_mixers
++] =
3091 ad1988_spdif_out_mixers
;
3092 spec
->init_verbs
[spec
->num_init_verbs
++] =
3093 ad1988_spdif_init_verbs
;
3096 if (spec
->dig_in_nid
&& codec
->vendor_id
< 0x11d4989a)
3097 spec
->mixers
[spec
->num_mixers
++] = ad1988_spdif_in_mixers
;
3099 codec
->patch_ops
= ad198x_patch_ops
;
3100 switch (board_config
) {
3102 codec
->patch_ops
.init
= ad1988_auto_init
;
3105 case AD1988_LAPTOP_DIG
:
3106 codec
->patch_ops
.unsol_event
= ad1988_laptop_unsol_event
;
3109 #ifdef CONFIG_SND_HDA_POWER_SAVE
3110 spec
->loopback
.amplist
= ad1988_loopbacks
;
3112 spec
->vmaster_nid
= 0x04;
3121 * port-B - front line/mic-in
3122 * port-E - aux in/out
3123 * port-F - aux in/out
3124 * port-C - rear line/mic-in
3125 * port-D - rear line/hp-out
3126 * port-A - front line/hp-out
3128 * AD1984 = AD1884 + two digital mic-ins
3131 * For simplicity, we share the single DAC for both HP and line-outs
3132 * right now. The inidividual playbacks could be easily implemented,
3133 * but no build-up framework is given, so far.
3136 static hda_nid_t ad1884_dac_nids
[1] = {
3140 static hda_nid_t ad1884_adc_nids
[2] = {
3144 static hda_nid_t ad1884_capsrc_nids
[2] = {
3148 #define AD1884_SPDIF_OUT 0x02
3150 static struct hda_input_mux ad1884_capture_source
= {
3153 { "Front Mic", 0x0 },
3160 static struct snd_kcontrol_new ad1884_base_mixers
[] = {
3161 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
3162 /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */
3163 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
3164 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
3165 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT
),
3166 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT
),
3167 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT
),
3168 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT
),
3169 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT
),
3170 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT
),
3171 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT
),
3172 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT
),
3173 HDA_CODEC_VOLUME("Mic Boost", 0x15, 0x0, HDA_INPUT
),
3174 HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT
),
3175 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
3176 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
3177 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT
),
3178 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT
),
3180 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3181 /* The multiple "Capture Source" controls confuse alsamixer
3182 * So call somewhat different..
3184 /* .name = "Capture Source", */
3185 .name
= "Input Source",
3187 .info
= ad198x_mux_enum_info
,
3188 .get
= ad198x_mux_enum_get
,
3189 .put
= ad198x_mux_enum_put
,
3191 /* SPDIF controls */
3192 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
3194 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3195 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,NONE
) "Source",
3196 /* identical with ad1983 */
3197 .info
= ad1983_spdif_route_info
,
3198 .get
= ad1983_spdif_route_get
,
3199 .put
= ad1983_spdif_route_put
,
3204 static struct snd_kcontrol_new ad1984_dmic_mixers
[] = {
3205 HDA_CODEC_VOLUME("Digital Mic Capture Volume", 0x05, 0x0, HDA_INPUT
),
3206 HDA_CODEC_MUTE("Digital Mic Capture Switch", 0x05, 0x0, HDA_INPUT
),
3207 HDA_CODEC_VOLUME_IDX("Digital Mic Capture Volume", 1, 0x06, 0x0,
3209 HDA_CODEC_MUTE_IDX("Digital Mic Capture Switch", 1, 0x06, 0x0,
3215 * initialization verbs
3217 static struct hda_verb ad1884_init_verbs
[] = {
3218 /* DACs; mute as default */
3219 {0x03, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
3220 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
3221 /* Port-A (HP) mixer */
3222 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3223 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3225 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
3226 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3227 /* HP selector - select DAC2 */
3228 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x1},
3229 /* Port-D (Line-out) mixer */
3230 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3231 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3233 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
3234 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3235 /* Mono-out mixer */
3236 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3237 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3239 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
3240 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3242 {0x0e, AC_VERB_SET_CONNECT_SEL
, 0x1},
3243 /* Port-B (front mic) pin */
3244 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
3245 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3246 /* Port-C (rear mic) pin */
3247 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
3248 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3249 /* Analog mixer; mute as default */
3250 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3251 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
3252 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
3253 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
3254 /* Analog Mix output amp */
3255 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x1f}, /* 0dB */
3256 /* SPDIF output selector */
3257 {0x02, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* PCM */
3258 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x27}, /* 0dB */
3262 #ifdef CONFIG_SND_HDA_POWER_SAVE
3263 static struct hda_amp_list ad1884_loopbacks
[] = {
3264 { 0x20, HDA_INPUT
, 0 }, /* Front Mic */
3265 { 0x20, HDA_INPUT
, 1 }, /* Mic */
3266 { 0x20, HDA_INPUT
, 2 }, /* CD */
3267 { 0x20, HDA_INPUT
, 4 }, /* Docking */
3272 static const char *ad1884_slave_vols
[] = {
3273 "PCM Playback Volume",
3274 "Mic Playback Volume",
3275 "Mono Playback Volume",
3276 "Front Mic Playback Volume",
3277 "Mic Playback Volume",
3278 "CD Playback Volume",
3279 "Internal Mic Playback Volume",
3280 "Docking Mic Playback Volume",
3281 /* "Beep Playback Volume", */
3282 "IEC958 Playback Volume",
3286 static int patch_ad1884(struct hda_codec
*codec
)
3288 struct ad198x_spec
*spec
;
3291 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
3297 err
= snd_hda_attach_beep_device(codec
, 0x10);
3302 set_beep_amp(spec
, 0x10, 0, HDA_OUTPUT
);
3304 spec
->multiout
.max_channels
= 2;
3305 spec
->multiout
.num_dacs
= ARRAY_SIZE(ad1884_dac_nids
);
3306 spec
->multiout
.dac_nids
= ad1884_dac_nids
;
3307 spec
->multiout
.dig_out_nid
= AD1884_SPDIF_OUT
;
3308 spec
->num_adc_nids
= ARRAY_SIZE(ad1884_adc_nids
);
3309 spec
->adc_nids
= ad1884_adc_nids
;
3310 spec
->capsrc_nids
= ad1884_capsrc_nids
;
3311 spec
->input_mux
= &ad1884_capture_source
;
3312 spec
->num_mixers
= 1;
3313 spec
->mixers
[0] = ad1884_base_mixers
;
3314 spec
->num_init_verbs
= 1;
3315 spec
->init_verbs
[0] = ad1884_init_verbs
;
3316 spec
->spdif_route
= 0;
3317 #ifdef CONFIG_SND_HDA_POWER_SAVE
3318 spec
->loopback
.amplist
= ad1884_loopbacks
;
3320 spec
->vmaster_nid
= 0x04;
3321 /* we need to cover all playback volumes */
3322 spec
->slave_vols
= ad1884_slave_vols
;
3324 codec
->patch_ops
= ad198x_patch_ops
;
3330 * Lenovo Thinkpad T61/X61
3332 static struct hda_input_mux ad1984_thinkpad_capture_source
= {
3336 { "Internal Mic", 0x1 },
3338 { "Docking-Station", 0x4 },
3344 * Dell Precision T3400
3346 static struct hda_input_mux ad1984_dell_desktop_capture_source
= {
3349 { "Front Mic", 0x0 },
3356 static struct snd_kcontrol_new ad1984_thinkpad_mixers
[] = {
3357 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
3358 /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */
3359 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
3360 HDA_CODEC_MUTE("Speaker Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
3361 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT
),
3362 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT
),
3363 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x20, 0x01, HDA_INPUT
),
3364 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT
),
3365 HDA_CODEC_VOLUME("Docking Mic Playback Volume", 0x20, 0x04, HDA_INPUT
),
3366 HDA_CODEC_MUTE("Docking Mic Playback Switch", 0x20, 0x04, HDA_INPUT
),
3367 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT
),
3368 HDA_CODEC_VOLUME("Internal Mic Boost", 0x15, 0x0, HDA_INPUT
),
3369 HDA_CODEC_VOLUME("Docking Mic Boost", 0x25, 0x0, HDA_OUTPUT
),
3370 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
3371 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
3372 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT
),
3373 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT
),
3375 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3376 /* The multiple "Capture Source" controls confuse alsamixer
3377 * So call somewhat different..
3379 /* .name = "Capture Source", */
3380 .name
= "Input Source",
3382 .info
= ad198x_mux_enum_info
,
3383 .get
= ad198x_mux_enum_get
,
3384 .put
= ad198x_mux_enum_put
,
3386 /* SPDIF controls */
3387 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
3389 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3390 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,NONE
) "Source",
3391 /* identical with ad1983 */
3392 .info
= ad1983_spdif_route_info
,
3393 .get
= ad1983_spdif_route_get
,
3394 .put
= ad1983_spdif_route_put
,
3399 /* additional verbs */
3400 static struct hda_verb ad1984_thinkpad_init_verbs
[] = {
3401 /* Port-E (docking station mic) pin */
3402 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
3403 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3404 /* docking mic boost */
3405 {0x25, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
3406 /* Analog mixer - docking mic; mute as default */
3407 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
3408 /* enable EAPD bit */
3409 {0x12, AC_VERB_SET_EAPD_BTLENABLE
, 0x02},
3414 * Dell Precision T3400
3416 static struct snd_kcontrol_new ad1984_dell_desktop_mixers
[] = {
3417 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
3418 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
3419 HDA_CODEC_MUTE("Speaker Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
3420 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT
),
3421 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT
),
3422 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT
),
3423 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT
),
3424 HDA_CODEC_VOLUME("Line-In Playback Volume", 0x20, 0x01, HDA_INPUT
),
3425 HDA_CODEC_MUTE("Line-In Playback Switch", 0x20, 0x01, HDA_INPUT
),
3426 HDA_CODEC_VOLUME("Line-In Boost", 0x15, 0x0, HDA_INPUT
),
3427 HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT
),
3428 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
3429 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
3430 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT
),
3431 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT
),
3433 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3434 /* The multiple "Capture Source" controls confuse alsamixer
3435 * So call somewhat different..
3437 /* .name = "Capture Source", */
3438 .name
= "Input Source",
3440 .info
= ad198x_mux_enum_info
,
3441 .get
= ad198x_mux_enum_get
,
3442 .put
= ad198x_mux_enum_put
,
3447 /* Digial MIC ADC NID 0x05 + 0x06 */
3448 static int ad1984_pcm_dmic_prepare(struct hda_pcm_stream
*hinfo
,
3449 struct hda_codec
*codec
,
3450 unsigned int stream_tag
,
3451 unsigned int format
,
3452 struct snd_pcm_substream
*substream
)
3454 snd_hda_codec_setup_stream(codec
, 0x05 + substream
->number
,
3455 stream_tag
, 0, format
);
3459 static int ad1984_pcm_dmic_cleanup(struct hda_pcm_stream
*hinfo
,
3460 struct hda_codec
*codec
,
3461 struct snd_pcm_substream
*substream
)
3463 snd_hda_codec_cleanup_stream(codec
, 0x05 + substream
->number
);
3467 static struct hda_pcm_stream ad1984_pcm_dmic_capture
= {
3473 .prepare
= ad1984_pcm_dmic_prepare
,
3474 .cleanup
= ad1984_pcm_dmic_cleanup
3478 static int ad1984_build_pcms(struct hda_codec
*codec
)
3480 struct ad198x_spec
*spec
= codec
->spec
;
3481 struct hda_pcm
*info
;
3484 err
= ad198x_build_pcms(codec
);
3488 info
= spec
->pcm_rec
+ codec
->num_pcms
;
3490 info
->name
= "AD1984 Digital Mic";
3491 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = ad1984_pcm_dmic_capture
;
3499 AD1984_DELL_DESKTOP
,
3503 static const char *ad1984_models
[AD1984_MODELS
] = {
3504 [AD1984_BASIC
] = "basic",
3505 [AD1984_THINKPAD
] = "thinkpad",
3506 [AD1984_DELL_DESKTOP
] = "dell_desktop",
3509 static struct snd_pci_quirk ad1984_cfg_tbl
[] = {
3510 /* Lenovo Thinkpad T61/X61 */
3511 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo Thinkpad", AD1984_THINKPAD
),
3512 SND_PCI_QUIRK(0x1028, 0x0214, "Dell T3400", AD1984_DELL_DESKTOP
),
3513 SND_PCI_QUIRK(0x1028, 0x0233, "Dell Latitude E6400", AD1984_DELL_DESKTOP
),
3517 static int patch_ad1984(struct hda_codec
*codec
)
3519 struct ad198x_spec
*spec
;
3520 int board_config
, err
;
3522 err
= patch_ad1884(codec
);
3526 board_config
= snd_hda_check_board_config(codec
, AD1984_MODELS
,
3527 ad1984_models
, ad1984_cfg_tbl
);
3528 switch (board_config
) {
3530 /* additional digital mics */
3531 spec
->mixers
[spec
->num_mixers
++] = ad1984_dmic_mixers
;
3532 codec
->patch_ops
.build_pcms
= ad1984_build_pcms
;
3534 case AD1984_THINKPAD
:
3535 spec
->multiout
.dig_out_nid
= AD1884_SPDIF_OUT
;
3536 spec
->input_mux
= &ad1984_thinkpad_capture_source
;
3537 spec
->mixers
[0] = ad1984_thinkpad_mixers
;
3538 spec
->init_verbs
[spec
->num_init_verbs
++] = ad1984_thinkpad_init_verbs
;
3540 case AD1984_DELL_DESKTOP
:
3541 spec
->multiout
.dig_out_nid
= 0;
3542 spec
->input_mux
= &ad1984_dell_desktop_capture_source
;
3543 spec
->mixers
[0] = ad1984_dell_desktop_mixers
;
3551 * AD1883 / AD1884A / AD1984A / AD1984B
3553 * port-B (0x14) - front mic-in
3554 * port-E (0x1c) - rear mic-in
3555 * port-F (0x16) - CD / ext out
3556 * port-C (0x15) - rear line-in
3557 * port-D (0x12) - rear line-out
3558 * port-A (0x11) - front hp-out
3560 * AD1984A = AD1884A + digital-mic
3561 * AD1883 = equivalent with AD1984A
3562 * AD1984B = AD1984A + extra SPDIF-out
3565 * We share the single DAC for both HP and line-outs (see AD1884/1984).
3568 static hda_nid_t ad1884a_dac_nids
[1] = {
3572 #define ad1884a_adc_nids ad1884_adc_nids
3573 #define ad1884a_capsrc_nids ad1884_capsrc_nids
3575 #define AD1884A_SPDIF_OUT 0x02
3577 static struct hda_input_mux ad1884a_capture_source
= {
3580 { "Front Mic", 0x0 },
3588 static struct snd_kcontrol_new ad1884a_base_mixers
[] = {
3589 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT
),
3590 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT
),
3591 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
3592 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
3593 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT
),
3594 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT
),
3595 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT
),
3596 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT
),
3597 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT
),
3598 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT
),
3599 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x01, HDA_INPUT
),
3600 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x01, HDA_INPUT
),
3601 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x04, HDA_INPUT
),
3602 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x04, HDA_INPUT
),
3603 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT
),
3604 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT
),
3605 HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT
),
3606 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x0, HDA_INPUT
),
3607 HDA_CODEC_VOLUME("Mic Boost", 0x25, 0x0, HDA_OUTPUT
),
3608 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
3609 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
3610 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT
),
3611 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT
),
3613 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3614 /* The multiple "Capture Source" controls confuse alsamixer
3615 * So call somewhat different..
3617 /* .name = "Capture Source", */
3618 .name
= "Input Source",
3620 .info
= ad198x_mux_enum_info
,
3621 .get
= ad198x_mux_enum_get
,
3622 .put
= ad198x_mux_enum_put
,
3624 /* SPDIF controls */
3625 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
3627 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3628 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,NONE
) "Source",
3629 /* identical with ad1983 */
3630 .info
= ad1983_spdif_route_info
,
3631 .get
= ad1983_spdif_route_get
,
3632 .put
= ad1983_spdif_route_put
,
3638 * initialization verbs
3640 static struct hda_verb ad1884a_init_verbs
[] = {
3641 /* DACs; unmute as default */
3642 {0x03, AC_VERB_SET_AMP_GAIN_MUTE
, 0x27}, /* 0dB */
3643 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, 0x27}, /* 0dB */
3644 /* Port-A (HP) mixer - route only from analog mixer */
3645 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3646 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3648 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
3649 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3650 /* Port-D (Line-out) mixer - route only from analog mixer */
3651 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3652 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3654 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
3655 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3656 /* Mono-out mixer - route only from analog mixer */
3657 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3658 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3660 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
3661 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3662 /* Port-B (front mic) pin */
3663 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
3664 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3665 /* Port-C (rear line-in) pin */
3666 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
3667 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3668 /* Port-E (rear mic) pin */
3669 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
3670 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3671 {0x25, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
}, /* no boost */
3672 /* Port-F (CD) pin */
3673 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
3674 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3675 /* Analog mixer; mute as default */
3676 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3677 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
3678 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
3679 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
3680 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(4)}, /* aux */
3681 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)},
3682 /* Analog Mix output amp */
3683 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3684 /* capture sources */
3685 {0x0c, AC_VERB_SET_CONNECT_SEL
, 0x0},
3686 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3687 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x0},
3688 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3689 /* SPDIF output amp */
3690 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x27}, /* 0dB */
3694 #ifdef CONFIG_SND_HDA_POWER_SAVE
3695 static struct hda_amp_list ad1884a_loopbacks
[] = {
3696 { 0x20, HDA_INPUT
, 0 }, /* Front Mic */
3697 { 0x20, HDA_INPUT
, 1 }, /* Mic */
3698 { 0x20, HDA_INPUT
, 2 }, /* CD */
3699 { 0x20, HDA_INPUT
, 4 }, /* Docking */
3707 * Port A: Headphone jack
3709 * Port C: Internal MIC
3710 * Port D: Dock Line Out (if enabled)
3711 * Port E: Dock Line In (if enabled)
3712 * Port F: Internal speakers
3715 static int ad1884a_mobile_master_sw_put(struct snd_kcontrol
*kcontrol
,
3716 struct snd_ctl_elem_value
*ucontrol
)
3718 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3719 int ret
= snd_hda_mixer_amp_switch_put(kcontrol
, ucontrol
);
3720 int mute
= (!ucontrol
->value
.integer
.value
[0] &&
3721 !ucontrol
->value
.integer
.value
[1]);
3722 /* toggle GPIO1 according to the mute state */
3723 snd_hda_codec_write_cache(codec
, 0x01, 0, AC_VERB_SET_GPIO_DATA
,
3728 static struct snd_kcontrol_new ad1884a_laptop_mixers
[] = {
3729 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT
),
3731 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3732 .name
= "Master Playback Switch",
3733 .info
= snd_hda_mixer_amp_switch_info
,
3734 .get
= snd_hda_mixer_amp_switch_get
,
3735 .put
= ad1884a_mobile_master_sw_put
,
3736 .private_value
= HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT
),
3738 HDA_CODEC_MUTE("Dock Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
3739 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT
),
3740 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT
),
3741 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT
),
3742 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT
),
3743 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x20, 0x01, HDA_INPUT
),
3744 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT
),
3745 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x20, 0x04, HDA_INPUT
),
3746 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x20, 0x04, HDA_INPUT
),
3747 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT
),
3748 HDA_CODEC_VOLUME("Internal Mic Boost", 0x15, 0x0, HDA_INPUT
),
3749 HDA_CODEC_VOLUME("Dock Mic Boost", 0x25, 0x0, HDA_OUTPUT
),
3750 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
3751 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
3755 static struct snd_kcontrol_new ad1884a_mobile_mixers
[] = {
3756 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT
),
3757 /*HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),*/
3759 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3760 .name
= "Master Playback Switch",
3761 .info
= snd_hda_mixer_amp_switch_info
,
3762 .get
= snd_hda_mixer_amp_switch_get
,
3763 .put
= ad1884a_mobile_master_sw_put
,
3764 .private_value
= HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT
),
3766 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT
),
3767 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT
),
3768 HDA_CODEC_VOLUME("Mic Capture Volume", 0x14, 0x0, HDA_INPUT
),
3769 HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x15, 0x0, HDA_INPUT
),
3770 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
3771 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
3775 /* mute internal speaker if HP is plugged */
3776 static void ad1884a_hp_automute(struct hda_codec
*codec
)
3778 unsigned int present
;
3780 present
= snd_hda_codec_read(codec
, 0x11, 0,
3781 AC_VERB_GET_PIN_SENSE
, 0) & 0x80000000;
3782 snd_hda_codec_amp_stereo(codec
, 0x16, HDA_OUTPUT
, 0,
3783 HDA_AMP_MUTE
, present
? HDA_AMP_MUTE
: 0);
3784 snd_hda_codec_write(codec
, 0x16, 0, AC_VERB_SET_EAPD_BTLENABLE
,
3785 present
? 0x00 : 0x02);
3788 /* switch to external mic if plugged */
3789 static void ad1884a_hp_automic(struct hda_codec
*codec
)
3791 unsigned int present
;
3793 present
= snd_hda_codec_read(codec
, 0x14, 0,
3794 AC_VERB_GET_PIN_SENSE
, 0) & 0x80000000;
3795 snd_hda_codec_write(codec
, 0x0c, 0, AC_VERB_SET_CONNECT_SEL
,
3799 #define AD1884A_HP_EVENT 0x37
3800 #define AD1884A_MIC_EVENT 0x36
3802 /* unsolicited event for HP jack sensing */
3803 static void ad1884a_hp_unsol_event(struct hda_codec
*codec
, unsigned int res
)
3805 switch (res
>> 26) {
3806 case AD1884A_HP_EVENT
:
3807 ad1884a_hp_automute(codec
);
3809 case AD1884A_MIC_EVENT
:
3810 ad1884a_hp_automic(codec
);
3815 /* initialize jack-sensing, too */
3816 static int ad1884a_hp_init(struct hda_codec
*codec
)
3819 ad1884a_hp_automute(codec
);
3820 ad1884a_hp_automic(codec
);
3824 /* mute internal speaker if HP or docking HP is plugged */
3825 static void ad1884a_laptop_automute(struct hda_codec
*codec
)
3827 unsigned int present
;
3829 present
= snd_hda_codec_read(codec
, 0x11, 0, AC_VERB_GET_PIN_SENSE
, 0);
3830 present
&= AC_PINSENSE_PRESENCE
;
3832 present
= snd_hda_codec_read(codec
, 0x12, 0,
3833 AC_VERB_GET_PIN_SENSE
, 0);
3834 present
&= AC_PINSENSE_PRESENCE
;
3836 snd_hda_codec_amp_stereo(codec
, 0x16, HDA_OUTPUT
, 0,
3837 HDA_AMP_MUTE
, present
? HDA_AMP_MUTE
: 0);
3838 snd_hda_codec_write(codec
, 0x16, 0, AC_VERB_SET_EAPD_BTLENABLE
,
3839 present
? 0x00 : 0x02);
3842 /* switch to external mic if plugged */
3843 static void ad1884a_laptop_automic(struct hda_codec
*codec
)
3847 if (snd_hda_codec_read(codec
, 0x14, 0, AC_VERB_GET_PIN_SENSE
, 0) &
3848 AC_PINSENSE_PRESENCE
)
3850 else if (snd_hda_codec_read(codec
, 0x1c, 0, AC_VERB_GET_PIN_SENSE
, 0) &
3851 AC_PINSENSE_PRESENCE
)
3855 snd_hda_codec_write(codec
, 0x0c, 0, AC_VERB_SET_CONNECT_SEL
, idx
);
3858 /* unsolicited event for HP jack sensing */
3859 static void ad1884a_laptop_unsol_event(struct hda_codec
*codec
,
3862 switch (res
>> 26) {
3863 case AD1884A_HP_EVENT
:
3864 ad1884a_laptop_automute(codec
);
3866 case AD1884A_MIC_EVENT
:
3867 ad1884a_laptop_automic(codec
);
3872 /* initialize jack-sensing, too */
3873 static int ad1884a_laptop_init(struct hda_codec
*codec
)
3876 ad1884a_laptop_automute(codec
);
3877 ad1884a_laptop_automic(codec
);
3881 /* additional verbs for laptop model */
3882 static struct hda_verb ad1884a_laptop_verbs
[] = {
3883 /* Port-A (HP) pin - always unmuted */
3884 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
3885 /* Port-F (int speaker) mixer - route only from analog mixer */
3886 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3887 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3888 /* Port-F (int speaker) pin */
3889 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
3890 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3891 /* required for compaq 6530s/6531s speaker output */
3892 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
3893 /* Port-C pin - internal mic-in */
3894 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
3895 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0x7002}, /* raise mic as default */
3896 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, 0x7002}, /* raise mic as default */
3897 /* Port-D (docking line-out) pin - default unmuted */
3898 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
3900 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
3901 /* unsolicited event for pin-sense */
3902 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1884A_HP_EVENT
},
3903 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1884A_HP_EVENT
},
3904 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1884A_MIC_EVENT
},
3905 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1884A_MIC_EVENT
},
3906 /* allow to touch GPIO1 (for mute control) */
3907 {0x01, AC_VERB_SET_GPIO_MASK
, 0x02},
3908 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x02},
3909 {0x01, AC_VERB_SET_GPIO_DATA
, 0x02}, /* first muted */
3913 static struct hda_verb ad1884a_mobile_verbs
[] = {
3914 /* DACs; unmute as default */
3915 {0x03, AC_VERB_SET_AMP_GAIN_MUTE
, 0x27}, /* 0dB */
3916 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, 0x27}, /* 0dB */
3917 /* Port-A (HP) mixer - route only from analog mixer */
3918 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3919 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3921 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
3922 /* Port-A (HP) pin - always unmuted */
3923 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
3924 /* Port-B (mic jack) pin */
3925 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
3926 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0x7002}, /* raise mic as default */
3927 /* Port-C (int mic) pin */
3928 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
3929 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, 0x7002}, /* raise mic as default */
3930 /* Port-F (int speaker) mixer - route only from analog mixer */
3931 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3932 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3934 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
3935 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3936 /* Analog mixer; mute as default */
3937 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3938 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
3939 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
3940 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
3941 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
3942 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)},
3943 /* Analog Mix output amp */
3944 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3945 /* capture sources */
3946 /* {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0}, */ /* set via unsol */
3947 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3948 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x0},
3949 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3950 /* unsolicited event for pin-sense */
3951 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1884A_HP_EVENT
},
3952 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1884A_MIC_EVENT
},
3953 /* allow to touch GPIO1 (for mute control) */
3954 {0x01, AC_VERB_SET_GPIO_MASK
, 0x02},
3955 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x02},
3956 {0x01, AC_VERB_SET_GPIO_DATA
, 0x02}, /* first muted */
3965 * 0x17 - built-in mic
3968 static struct hda_verb ad1984a_thinkpad_verbs
[] = {
3970 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
3972 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
3974 {0x12, AC_VERB_SET_EAPD_BTLENABLE
, 0x02},
3975 /* unsolicited event for pin-sense */
3976 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1884A_HP_EVENT
},
3977 /* internal mic - dmic */
3978 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
3979 /* set magic COEFs for dmic */
3980 {0x01, AC_VERB_SET_COEF_INDEX
, 0x13f7},
3981 {0x01, AC_VERB_SET_PROC_COEF
, 0x08},
3985 static struct snd_kcontrol_new ad1984a_thinkpad_mixers
[] = {
3986 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT
),
3987 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT
),
3988 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT
),
3989 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT
),
3990 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT
),
3991 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT
),
3992 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT
),
3993 HDA_CODEC_VOLUME("Internal Mic Boost", 0x17, 0x0, HDA_INPUT
),
3994 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
3995 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
3997 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3998 .name
= "Capture Source",
3999 .info
= ad198x_mux_enum_info
,
4000 .get
= ad198x_mux_enum_get
,
4001 .put
= ad198x_mux_enum_put
,
4006 static struct hda_input_mux ad1984a_thinkpad_capture_source
= {
4010 { "Internal Mic", 0x5 },
4015 /* mute internal speaker if HP is plugged */
4016 static void ad1984a_thinkpad_automute(struct hda_codec
*codec
)
4018 unsigned int present
;
4020 present
= snd_hda_codec_read(codec
, 0x11, 0, AC_VERB_GET_PIN_SENSE
, 0)
4021 & AC_PINSENSE_PRESENCE
;
4022 snd_hda_codec_amp_stereo(codec
, 0x12, HDA_OUTPUT
, 0,
4023 HDA_AMP_MUTE
, present
? HDA_AMP_MUTE
: 0);
4026 /* unsolicited event for HP jack sensing */
4027 static void ad1984a_thinkpad_unsol_event(struct hda_codec
*codec
,
4030 if ((res
>> 26) != AD1884A_HP_EVENT
)
4032 ad1984a_thinkpad_automute(codec
);
4035 /* initialize jack-sensing, too */
4036 static int ad1984a_thinkpad_init(struct hda_codec
*codec
)
4039 ad1984a_thinkpad_automute(codec
);
4045 * port-A (0x11) - front hp-out
4046 * port-B (0x14) - unused
4047 * port-C (0x15) - unused
4048 * port-D (0x12) - rear line out
4049 * port-E (0x1c) - front mic-in
4050 * port-F (0x16) - Internal speakers
4051 * digital-mic (0x17) - Internal mic
4054 static struct hda_verb ad1984a_touchsmart_verbs
[] = {
4055 /* DACs; unmute as default */
4056 {0x03, AC_VERB_SET_AMP_GAIN_MUTE
, 0x27}, /* 0dB */
4057 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, 0x27}, /* 0dB */
4058 /* Port-A (HP) mixer - route only from analog mixer */
4059 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4060 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4062 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
4063 /* Port-A (HP) pin - always unmuted */
4064 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
4065 /* Port-E (int speaker) mixer - route only from analog mixer */
4066 {0x25, AC_VERB_SET_AMP_GAIN_MUTE
, 0x03},
4068 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
4069 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
4070 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
4071 /* Port-F (int speaker) mixer - route only from analog mixer */
4072 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4073 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4075 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
4076 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4077 /* Analog mixer; mute as default */
4078 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4079 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4080 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
4081 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
4082 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
4083 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)},
4084 /* Analog Mix output amp */
4085 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4086 /* capture sources */
4087 /* {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0}, */ /* set via unsol */
4088 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4089 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x0},
4090 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4091 /* unsolicited event for pin-sense */
4092 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1884A_HP_EVENT
},
4093 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1884A_MIC_EVENT
},
4094 /* allow to touch GPIO1 (for mute control) */
4095 {0x01, AC_VERB_SET_GPIO_MASK
, 0x02},
4096 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x02},
4097 {0x01, AC_VERB_SET_GPIO_DATA
, 0x02}, /* first muted */
4098 /* internal mic - dmic */
4099 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
4100 /* set magic COEFs for dmic */
4101 {0x01, AC_VERB_SET_COEF_INDEX
, 0x13f7},
4102 {0x01, AC_VERB_SET_PROC_COEF
, 0x08},
4106 static struct snd_kcontrol_new ad1984a_touchsmart_mixers
[] = {
4107 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT
),
4108 /* HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),*/
4110 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4111 .name
= "Master Playback Switch",
4112 .info
= snd_hda_mixer_amp_switch_info
,
4113 .get
= snd_hda_mixer_amp_switch_get
,
4114 .put
= ad1884a_mobile_master_sw_put
,
4115 .private_value
= HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT
),
4117 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT
),
4118 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT
),
4119 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
4120 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
4121 HDA_CODEC_VOLUME("Mic Boost", 0x25, 0x0, HDA_OUTPUT
),
4122 HDA_CODEC_VOLUME("Internal Mic Boost", 0x17, 0x0, HDA_INPUT
),
4126 /* switch to external mic if plugged */
4127 static void ad1984a_touchsmart_automic(struct hda_codec
*codec
)
4129 if (snd_hda_codec_read(codec
, 0x1c, 0,
4130 AC_VERB_GET_PIN_SENSE
, 0) & 0x80000000) {
4131 snd_hda_codec_write(codec
, 0x0c, 0,
4132 AC_VERB_SET_CONNECT_SEL
, 0x4);
4134 snd_hda_codec_write(codec
, 0x0c, 0,
4135 AC_VERB_SET_CONNECT_SEL
, 0x5);
4140 /* unsolicited event for HP jack sensing */
4141 static void ad1984a_touchsmart_unsol_event(struct hda_codec
*codec
,
4144 switch (res
>> 26) {
4145 case AD1884A_HP_EVENT
:
4146 ad1884a_hp_automute(codec
);
4148 case AD1884A_MIC_EVENT
:
4149 ad1984a_touchsmart_automic(codec
);
4154 /* initialize jack-sensing, too */
4155 static int ad1984a_touchsmart_init(struct hda_codec
*codec
)
4158 ad1884a_hp_automute(codec
);
4159 ad1984a_touchsmart_automic(codec
);
4176 static const char *ad1884a_models
[AD1884A_MODELS
] = {
4177 [AD1884A_DESKTOP
] = "desktop",
4178 [AD1884A_LAPTOP
] = "laptop",
4179 [AD1884A_MOBILE
] = "mobile",
4180 [AD1884A_THINKPAD
] = "thinkpad",
4181 [AD1984A_TOUCHSMART
] = "touchsmart",
4184 static struct snd_pci_quirk ad1884a_cfg_tbl
[] = {
4185 SND_PCI_QUIRK(0x103c, 0x3030, "HP", AD1884A_MOBILE
),
4186 SND_PCI_QUIRK(0x103c, 0x3037, "HP 2230s", AD1884A_LAPTOP
),
4187 SND_PCI_QUIRK(0x103c, 0x3056, "HP", AD1884A_MOBILE
),
4188 SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x3070, "HP", AD1884A_MOBILE
),
4189 SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x30d0, "HP laptop", AD1884A_LAPTOP
),
4190 SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x30e0, "HP laptop", AD1884A_LAPTOP
),
4191 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3600, "HP laptop", AD1884A_LAPTOP
),
4192 SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x7010, "HP laptop", AD1884A_MOBILE
),
4193 SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X300", AD1884A_THINKPAD
),
4194 SND_PCI_QUIRK(0x103c, 0x2a82, "Touchsmart", AD1984A_TOUCHSMART
),
4198 static int patch_ad1884a(struct hda_codec
*codec
)
4200 struct ad198x_spec
*spec
;
4201 int err
, board_config
;
4203 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4209 err
= snd_hda_attach_beep_device(codec
, 0x10);
4214 set_beep_amp(spec
, 0x10, 0, HDA_OUTPUT
);
4216 spec
->multiout
.max_channels
= 2;
4217 spec
->multiout
.num_dacs
= ARRAY_SIZE(ad1884a_dac_nids
);
4218 spec
->multiout
.dac_nids
= ad1884a_dac_nids
;
4219 spec
->multiout
.dig_out_nid
= AD1884A_SPDIF_OUT
;
4220 spec
->num_adc_nids
= ARRAY_SIZE(ad1884a_adc_nids
);
4221 spec
->adc_nids
= ad1884a_adc_nids
;
4222 spec
->capsrc_nids
= ad1884a_capsrc_nids
;
4223 spec
->input_mux
= &ad1884a_capture_source
;
4224 spec
->num_mixers
= 1;
4225 spec
->mixers
[0] = ad1884a_base_mixers
;
4226 spec
->num_init_verbs
= 1;
4227 spec
->init_verbs
[0] = ad1884a_init_verbs
;
4228 spec
->spdif_route
= 0;
4229 #ifdef CONFIG_SND_HDA_POWER_SAVE
4230 spec
->loopback
.amplist
= ad1884a_loopbacks
;
4232 codec
->patch_ops
= ad198x_patch_ops
;
4234 /* override some parameters */
4235 board_config
= snd_hda_check_board_config(codec
, AD1884A_MODELS
,
4238 switch (board_config
) {
4239 case AD1884A_LAPTOP
:
4240 spec
->mixers
[0] = ad1884a_laptop_mixers
;
4241 spec
->init_verbs
[spec
->num_init_verbs
++] = ad1884a_laptop_verbs
;
4242 spec
->multiout
.dig_out_nid
= 0;
4243 codec
->patch_ops
.unsol_event
= ad1884a_laptop_unsol_event
;
4244 codec
->patch_ops
.init
= ad1884a_laptop_init
;
4245 /* set the upper-limit for mixer amp to 0dB for avoiding the
4246 * possible damage by overloading
4248 snd_hda_override_amp_caps(codec
, 0x20, HDA_INPUT
,
4249 (0x17 << AC_AMPCAP_OFFSET_SHIFT
) |
4250 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
4251 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
4252 (1 << AC_AMPCAP_MUTE_SHIFT
));
4254 case AD1884A_MOBILE
:
4255 spec
->mixers
[0] = ad1884a_mobile_mixers
;
4256 spec
->init_verbs
[0] = ad1884a_mobile_verbs
;
4257 spec
->multiout
.dig_out_nid
= 0;
4258 codec
->patch_ops
.unsol_event
= ad1884a_hp_unsol_event
;
4259 codec
->patch_ops
.init
= ad1884a_hp_init
;
4260 /* set the upper-limit for mixer amp to 0dB for avoiding the
4261 * possible damage by overloading
4263 snd_hda_override_amp_caps(codec
, 0x20, HDA_INPUT
,
4264 (0x17 << AC_AMPCAP_OFFSET_SHIFT
) |
4265 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
4266 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
4267 (1 << AC_AMPCAP_MUTE_SHIFT
));
4269 case AD1884A_THINKPAD
:
4270 spec
->mixers
[0] = ad1984a_thinkpad_mixers
;
4271 spec
->init_verbs
[spec
->num_init_verbs
++] =
4272 ad1984a_thinkpad_verbs
;
4273 spec
->multiout
.dig_out_nid
= 0;
4274 spec
->input_mux
= &ad1984a_thinkpad_capture_source
;
4275 codec
->patch_ops
.unsol_event
= ad1984a_thinkpad_unsol_event
;
4276 codec
->patch_ops
.init
= ad1984a_thinkpad_init
;
4278 case AD1984A_TOUCHSMART
:
4279 spec
->mixers
[0] = ad1984a_touchsmart_mixers
;
4280 spec
->init_verbs
[0] = ad1984a_touchsmart_verbs
;
4281 spec
->multiout
.dig_out_nid
= 0;
4282 codec
->patch_ops
.unsol_event
= ad1984a_touchsmart_unsol_event
;
4283 codec
->patch_ops
.init
= ad1984a_touchsmart_init
;
4284 /* set the upper-limit for mixer amp to 0dB for avoiding the
4285 * possible damage by overloading
4287 snd_hda_override_amp_caps(codec
, 0x20, HDA_INPUT
,
4288 (0x17 << AC_AMPCAP_OFFSET_SHIFT
) |
4289 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
4290 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
4291 (1 << AC_AMPCAP_MUTE_SHIFT
));
4302 * port-A - front hp-out
4303 * port-B - front mic-in
4304 * port-C - rear line-in, shared surr-out (3stack)
4305 * port-D - rear line-out
4306 * port-E - rear mic-in, shared clfe-out (3stack)
4307 * port-F - rear surr-out (6stack)
4308 * port-G - rear clfe-out (6stack)
4311 static hda_nid_t ad1882_dac_nids
[3] = {
4315 static hda_nid_t ad1882_adc_nids
[2] = {
4319 static hda_nid_t ad1882_capsrc_nids
[2] = {
4323 #define AD1882_SPDIF_OUT 0x02
4325 /* list: 0x11, 0x39, 0x3a, 0x18, 0x3c, 0x3b, 0x12, 0x20 */
4326 static struct hda_input_mux ad1882_capture_source
= {
4329 { "Front Mic", 0x1 },
4337 /* list: 0x11, 0x39, 0x3a, 0x3c, 0x18, 0x1f, 0x12, 0x20 */
4338 static struct hda_input_mux ad1882a_capture_source
= {
4341 { "Front Mic", 0x1 },
4344 { "Digital Mic", 0x06 },
4349 static struct snd_kcontrol_new ad1882_base_mixers
[] = {
4350 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
4351 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT
),
4352 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT
),
4353 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT
),
4354 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
4355 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
4356 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT
),
4357 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT
),
4359 HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT
),
4360 HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT
),
4361 HDA_CODEC_VOLUME("Line-In Boost", 0x3a, 0x0, HDA_OUTPUT
),
4362 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
4363 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
4364 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT
),
4365 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT
),
4367 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4368 /* The multiple "Capture Source" controls confuse alsamixer
4369 * So call somewhat different..
4371 /* .name = "Capture Source", */
4372 .name
= "Input Source",
4374 .info
= ad198x_mux_enum_info
,
4375 .get
= ad198x_mux_enum_get
,
4376 .put
= ad198x_mux_enum_put
,
4378 /* SPDIF controls */
4379 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
4381 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4382 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,NONE
) "Source",
4383 /* identical with ad1983 */
4384 .info
= ad1983_spdif_route_info
,
4385 .get
= ad1983_spdif_route_get
,
4386 .put
= ad1983_spdif_route_put
,
4391 static struct snd_kcontrol_new ad1882_loopback_mixers
[] = {
4392 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT
),
4393 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT
),
4394 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT
),
4395 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT
),
4396 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x04, HDA_INPUT
),
4397 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x04, HDA_INPUT
),
4398 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT
),
4399 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT
),
4403 static struct snd_kcontrol_new ad1882a_loopback_mixers
[] = {
4404 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT
),
4405 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT
),
4406 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x04, HDA_INPUT
),
4407 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x04, HDA_INPUT
),
4408 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x01, HDA_INPUT
),
4409 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x01, HDA_INPUT
),
4410 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT
),
4411 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT
),
4412 HDA_CODEC_VOLUME("Digital Mic Boost", 0x1f, 0x0, HDA_INPUT
),
4416 static struct snd_kcontrol_new ad1882_3stack_mixers
[] = {
4417 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT
),
4418 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x17, 1, 0x0, HDA_OUTPUT
),
4419 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x17, 2, 0x0, HDA_OUTPUT
),
4421 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4422 .name
= "Channel Mode",
4423 .info
= ad198x_ch_mode_info
,
4424 .get
= ad198x_ch_mode_get
,
4425 .put
= ad198x_ch_mode_put
,
4430 static struct snd_kcontrol_new ad1882_6stack_mixers
[] = {
4431 HDA_CODEC_MUTE("Surround Playback Switch", 0x16, 0x0, HDA_OUTPUT
),
4432 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x24, 1, 0x0, HDA_OUTPUT
),
4433 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x24, 2, 0x0, HDA_OUTPUT
),
4437 static struct hda_verb ad1882_ch2_init
[] = {
4438 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
4439 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4440 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4441 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
4442 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4443 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4447 static struct hda_verb ad1882_ch4_init
[] = {
4448 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
4449 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4450 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4451 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
4452 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4453 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4457 static struct hda_verb ad1882_ch6_init
[] = {
4458 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
4459 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4460 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4461 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
4462 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4463 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4467 static struct hda_channel_mode ad1882_modes
[3] = {
4468 { 2, ad1882_ch2_init
},
4469 { 4, ad1882_ch4_init
},
4470 { 6, ad1882_ch6_init
},
4474 * initialization verbs
4476 static struct hda_verb ad1882_init_verbs
[] = {
4477 /* DACs; mute as default */
4478 {0x03, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
4479 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
4480 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
4481 /* Port-A (HP) mixer */
4482 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4483 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4485 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
4486 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4487 /* HP selector - select DAC2 */
4488 {0x37, AC_VERB_SET_CONNECT_SEL
, 0x1},
4489 /* Port-D (Line-out) mixer */
4490 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4491 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4493 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
4494 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4495 /* Mono-out mixer */
4496 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4497 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
4499 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
4500 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4501 /* Port-B (front mic) pin */
4502 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
4503 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4504 {0x39, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
}, /* boost */
4505 /* Port-C (line-in) pin */
4506 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
4507 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4508 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
}, /* boost */
4509 /* Port-C mixer - mute as input */
4510 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4511 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4512 /* Port-E (mic-in) pin */
4513 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
4514 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4515 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
}, /* boost */
4516 /* Port-E mixer - mute as input */
4517 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4518 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4519 /* Port-F (surround) */
4520 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
4521 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4523 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
4524 {0x24, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
4525 /* Analog mixer; mute as default */
4526 /* list: 0x39, 0x3a, 0x11, 0x12, 0x3c, 0x3b, 0x18, 0x1a */
4527 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
4528 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4529 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
4530 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
4531 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
4532 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)},
4533 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)},
4534 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)},
4535 /* Analog Mix output amp */
4536 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x1f}, /* 0dB */
4537 /* SPDIF output selector */
4538 {0x02, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x27}, /* 0dB */
4539 {0x02, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* PCM */
4540 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x27}, /* 0dB */
4544 #ifdef CONFIG_SND_HDA_POWER_SAVE
4545 static struct hda_amp_list ad1882_loopbacks
[] = {
4546 { 0x20, HDA_INPUT
, 0 }, /* Front Mic */
4547 { 0x20, HDA_INPUT
, 1 }, /* Mic */
4548 { 0x20, HDA_INPUT
, 4 }, /* Line */
4549 { 0x20, HDA_INPUT
, 6 }, /* CD */
4561 static const char *ad1882_models
[AD1986A_MODELS
] = {
4562 [AD1882_3STACK
] = "3stack",
4563 [AD1882_6STACK
] = "6stack",
4567 static int patch_ad1882(struct hda_codec
*codec
)
4569 struct ad198x_spec
*spec
;
4570 int err
, board_config
;
4572 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4578 err
= snd_hda_attach_beep_device(codec
, 0x10);
4583 set_beep_amp(spec
, 0x10, 0, HDA_OUTPUT
);
4585 spec
->multiout
.max_channels
= 6;
4586 spec
->multiout
.num_dacs
= 3;
4587 spec
->multiout
.dac_nids
= ad1882_dac_nids
;
4588 spec
->multiout
.dig_out_nid
= AD1882_SPDIF_OUT
;
4589 spec
->num_adc_nids
= ARRAY_SIZE(ad1882_adc_nids
);
4590 spec
->adc_nids
= ad1882_adc_nids
;
4591 spec
->capsrc_nids
= ad1882_capsrc_nids
;
4592 if (codec
->vendor_id
== 0x11d41882)
4593 spec
->input_mux
= &ad1882_capture_source
;
4595 spec
->input_mux
= &ad1882a_capture_source
;
4596 spec
->num_mixers
= 2;
4597 spec
->mixers
[0] = ad1882_base_mixers
;
4598 if (codec
->vendor_id
== 0x11d41882)
4599 spec
->mixers
[1] = ad1882_loopback_mixers
;
4601 spec
->mixers
[1] = ad1882a_loopback_mixers
;
4602 spec
->num_init_verbs
= 1;
4603 spec
->init_verbs
[0] = ad1882_init_verbs
;
4604 spec
->spdif_route
= 0;
4605 #ifdef CONFIG_SND_HDA_POWER_SAVE
4606 spec
->loopback
.amplist
= ad1882_loopbacks
;
4608 spec
->vmaster_nid
= 0x04;
4610 codec
->patch_ops
= ad198x_patch_ops
;
4612 /* override some parameters */
4613 board_config
= snd_hda_check_board_config(codec
, AD1882_MODELS
,
4614 ad1882_models
, NULL
);
4615 switch (board_config
) {
4618 spec
->num_mixers
= 3;
4619 spec
->mixers
[2] = ad1882_3stack_mixers
;
4620 spec
->channel_mode
= ad1882_modes
;
4621 spec
->num_channel_mode
= ARRAY_SIZE(ad1882_modes
);
4622 spec
->need_dac_fix
= 1;
4623 spec
->multiout
.max_channels
= 2;
4624 spec
->multiout
.num_dacs
= 1;
4627 spec
->num_mixers
= 3;
4628 spec
->mixers
[2] = ad1882_6stack_mixers
;
4638 static struct hda_codec_preset snd_hda_preset_analog
[] = {
4639 { .id
= 0x11d4184a, .name
= "AD1884A", .patch
= patch_ad1884a
},
4640 { .id
= 0x11d41882, .name
= "AD1882", .patch
= patch_ad1882
},
4641 { .id
= 0x11d41883, .name
= "AD1883", .patch
= patch_ad1884a
},
4642 { .id
= 0x11d41884, .name
= "AD1884", .patch
= patch_ad1884
},
4643 { .id
= 0x11d4194a, .name
= "AD1984A", .patch
= patch_ad1884a
},
4644 { .id
= 0x11d4194b, .name
= "AD1984B", .patch
= patch_ad1884a
},
4645 { .id
= 0x11d41981, .name
= "AD1981", .patch
= patch_ad1981
},
4646 { .id
= 0x11d41983, .name
= "AD1983", .patch
= patch_ad1983
},
4647 { .id
= 0x11d41984, .name
= "AD1984", .patch
= patch_ad1984
},
4648 { .id
= 0x11d41986, .name
= "AD1986A", .patch
= patch_ad1986a
},
4649 { .id
= 0x11d41988, .name
= "AD1988", .patch
= patch_ad1988
},
4650 { .id
= 0x11d4198b, .name
= "AD1988B", .patch
= patch_ad1988
},
4651 { .id
= 0x11d4882a, .name
= "AD1882A", .patch
= patch_ad1882
},
4652 { .id
= 0x11d4989a, .name
= "AD1989A", .patch
= patch_ad1988
},
4653 { .id
= 0x11d4989b, .name
= "AD1989B", .patch
= patch_ad1988
},
4657 MODULE_ALIAS("snd-hda-codec-id:11d4*");
4659 MODULE_LICENSE("GPL");
4660 MODULE_DESCRIPTION("Analog Devices HD-audio codec");
4662 static struct hda_codec_preset_list analog_list
= {
4663 .preset
= snd_hda_preset_analog
,
4664 .owner
= THIS_MODULE
,
4667 static int __init
patch_analog_init(void)
4669 return snd_hda_add_codec_preset(&analog_list
);
4672 static void __exit
patch_analog_exit(void)
4674 snd_hda_delete_codec_preset(&analog_list
);
4677 module_init(patch_analog_init
)
4678 module_exit(patch_analog_exit
)