2 * HD audio interface patch for AD1981HD, AD1983, AD1986A, AD1988
4 * Copyright (c) 2005 Takashi Iwai <tiwai@suse.de>
6 * This driver is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This driver is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include <sound/driver.h>
22 #include <linux/init.h>
23 #include <linux/delay.h>
24 #include <linux/slab.h>
25 #include <linux/pci.h>
26 #include <linux/mutex.h>
28 #include <sound/core.h>
29 #include "hda_codec.h"
30 #include "hda_local.h"
33 struct snd_kcontrol_new
*mixers
[5];
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
[2]; /* used in alc_build_pcms() */
66 struct mutex amp_mutex
; /* PCM volume/mute control mutex */
67 unsigned int spdif_route
;
69 /* dynamic controls, init_verbs and input_mux */
70 struct auto_pin_cfg autocfg
;
71 unsigned int num_kctl_alloc
, num_kctl_used
;
72 struct snd_kcontrol_new
*kctl_alloc
;
73 struct hda_input_mux private_imux
;
74 hda_nid_t private_dac_nids
[4];
78 * input MUX handling (common part)
80 static int ad198x_mux_enum_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
82 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
83 struct ad198x_spec
*spec
= codec
->spec
;
85 return snd_hda_input_mux_info(spec
->input_mux
, uinfo
);
88 static int ad198x_mux_enum_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
90 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
91 struct ad198x_spec
*spec
= codec
->spec
;
92 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
94 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
98 static int ad198x_mux_enum_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
100 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
101 struct ad198x_spec
*spec
= codec
->spec
;
102 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
104 return snd_hda_input_mux_put(codec
, spec
->input_mux
, ucontrol
,
105 spec
->capsrc_nids
[adc_idx
],
106 &spec
->cur_mux
[adc_idx
]);
110 * initialization (common callbacks)
112 static int ad198x_init(struct hda_codec
*codec
)
114 struct ad198x_spec
*spec
= codec
->spec
;
117 for (i
= 0; i
< spec
->num_init_verbs
; i
++)
118 snd_hda_sequence_write(codec
, spec
->init_verbs
[i
]);
122 static int ad198x_build_controls(struct hda_codec
*codec
)
124 struct ad198x_spec
*spec
= codec
->spec
;
128 for (i
= 0; i
< spec
->num_mixers
; i
++) {
129 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
133 if (spec
->multiout
.dig_out_nid
) {
134 err
= snd_hda_create_spdif_out_ctls(codec
, spec
->multiout
.dig_out_nid
);
138 if (spec
->dig_in_nid
) {
139 err
= snd_hda_create_spdif_in_ctls(codec
, spec
->dig_in_nid
);
147 * Analog playback callbacks
149 static int ad198x_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
150 struct hda_codec
*codec
,
151 struct snd_pcm_substream
*substream
)
153 struct ad198x_spec
*spec
= codec
->spec
;
154 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
);
157 static int ad198x_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
158 struct hda_codec
*codec
,
159 unsigned int stream_tag
,
161 struct snd_pcm_substream
*substream
)
163 struct ad198x_spec
*spec
= codec
->spec
;
164 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
, stream_tag
,
168 static int ad198x_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
169 struct hda_codec
*codec
,
170 struct snd_pcm_substream
*substream
)
172 struct ad198x_spec
*spec
= codec
->spec
;
173 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
179 static int ad198x_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
180 struct hda_codec
*codec
,
181 struct snd_pcm_substream
*substream
)
183 struct ad198x_spec
*spec
= codec
->spec
;
184 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
187 static int ad198x_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
188 struct hda_codec
*codec
,
189 struct snd_pcm_substream
*substream
)
191 struct ad198x_spec
*spec
= codec
->spec
;
192 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
198 static int ad198x_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
199 struct hda_codec
*codec
,
200 unsigned int stream_tag
,
202 struct snd_pcm_substream
*substream
)
204 struct ad198x_spec
*spec
= codec
->spec
;
205 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
],
206 stream_tag
, 0, format
);
210 static int ad198x_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
211 struct hda_codec
*codec
,
212 struct snd_pcm_substream
*substream
)
214 struct ad198x_spec
*spec
= codec
->spec
;
215 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
],
223 static struct hda_pcm_stream ad198x_pcm_analog_playback
= {
226 .channels_max
= 6, /* changed later */
227 .nid
= 0, /* fill later */
229 .open
= ad198x_playback_pcm_open
,
230 .prepare
= ad198x_playback_pcm_prepare
,
231 .cleanup
= ad198x_playback_pcm_cleanup
235 static struct hda_pcm_stream ad198x_pcm_analog_capture
= {
239 .nid
= 0, /* fill later */
241 .prepare
= ad198x_capture_pcm_prepare
,
242 .cleanup
= ad198x_capture_pcm_cleanup
246 static struct hda_pcm_stream ad198x_pcm_digital_playback
= {
250 .nid
= 0, /* fill later */
252 .open
= ad198x_dig_playback_pcm_open
,
253 .close
= ad198x_dig_playback_pcm_close
257 static struct hda_pcm_stream ad198x_pcm_digital_capture
= {
261 /* NID is set in alc_build_pcms */
264 static int ad198x_build_pcms(struct hda_codec
*codec
)
266 struct ad198x_spec
*spec
= codec
->spec
;
267 struct hda_pcm
*info
= spec
->pcm_rec
;
270 codec
->pcm_info
= info
;
272 info
->name
= "AD198x Analog";
273 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = ad198x_pcm_analog_playback
;
274 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
= spec
->multiout
.max_channels
;
275 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dac_nids
[0];
276 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = ad198x_pcm_analog_capture
;
277 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
= spec
->num_adc_nids
;
278 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
280 if (spec
->multiout
.dig_out_nid
) {
283 info
->name
= "AD198x Digital";
284 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = ad198x_pcm_digital_playback
;
285 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dig_out_nid
;
286 if (spec
->dig_in_nid
) {
287 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = ad198x_pcm_digital_capture
;
288 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->dig_in_nid
;
295 static void ad198x_free(struct hda_codec
*codec
)
297 struct ad198x_spec
*spec
= codec
->spec
;
300 if (spec
->kctl_alloc
) {
301 for (i
= 0; i
< spec
->num_kctl_used
; i
++)
302 kfree(spec
->kctl_alloc
[i
].name
);
303 kfree(spec
->kctl_alloc
);
309 static int ad198x_resume(struct hda_codec
*codec
)
311 struct ad198x_spec
*spec
= codec
->spec
;
314 codec
->patch_ops
.init(codec
);
315 for (i
= 0; i
< spec
->num_mixers
; i
++)
316 snd_hda_resume_ctls(codec
, spec
->mixers
[i
]);
317 if (spec
->multiout
.dig_out_nid
)
318 snd_hda_resume_spdif_out(codec
);
319 if (spec
->dig_in_nid
)
320 snd_hda_resume_spdif_in(codec
);
325 static struct hda_codec_ops ad198x_patch_ops
= {
326 .build_controls
= ad198x_build_controls
,
327 .build_pcms
= ad198x_build_pcms
,
331 .resume
= ad198x_resume
,
338 * the private value = nid | (invert << 8)
340 static int ad198x_eapd_info(struct snd_kcontrol
*kcontrol
,
341 struct snd_ctl_elem_info
*uinfo
)
343 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_BOOLEAN
;
345 uinfo
->value
.integer
.min
= 0;
346 uinfo
->value
.integer
.max
= 1;
350 static int ad198x_eapd_get(struct snd_kcontrol
*kcontrol
,
351 struct snd_ctl_elem_value
*ucontrol
)
353 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
354 struct ad198x_spec
*spec
= codec
->spec
;
355 int invert
= (kcontrol
->private_value
>> 8) & 1;
357 ucontrol
->value
.integer
.value
[0] = ! spec
->cur_eapd
;
359 ucontrol
->value
.integer
.value
[0] = spec
->cur_eapd
;
363 static int ad198x_eapd_put(struct snd_kcontrol
*kcontrol
,
364 struct snd_ctl_elem_value
*ucontrol
)
366 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
367 struct ad198x_spec
*spec
= codec
->spec
;
368 int invert
= (kcontrol
->private_value
>> 8) & 1;
369 hda_nid_t nid
= kcontrol
->private_value
& 0xff;
371 eapd
= ucontrol
->value
.integer
.value
[0];
374 if (eapd
== spec
->cur_eapd
&& ! codec
->in_resume
)
376 spec
->cur_eapd
= eapd
;
377 snd_hda_codec_write(codec
, nid
,
378 0, AC_VERB_SET_EAPD_BTLENABLE
,
383 static int ad198x_ch_mode_info(struct snd_kcontrol
*kcontrol
,
384 struct snd_ctl_elem_info
*uinfo
);
385 static int ad198x_ch_mode_get(struct snd_kcontrol
*kcontrol
,
386 struct snd_ctl_elem_value
*ucontrol
);
387 static int ad198x_ch_mode_put(struct snd_kcontrol
*kcontrol
,
388 struct snd_ctl_elem_value
*ucontrol
);
395 #define AD1986A_SPDIF_OUT 0x02
396 #define AD1986A_FRONT_DAC 0x03
397 #define AD1986A_SURR_DAC 0x04
398 #define AD1986A_CLFE_DAC 0x05
399 #define AD1986A_ADC 0x06
401 static hda_nid_t ad1986a_dac_nids
[3] = {
402 AD1986A_FRONT_DAC
, AD1986A_SURR_DAC
, AD1986A_CLFE_DAC
404 static hda_nid_t ad1986a_adc_nids
[1] = { AD1986A_ADC
};
405 static hda_nid_t ad1986a_capsrc_nids
[1] = { 0x12 };
407 static struct hda_input_mux ad1986a_capture_source
= {
423 * bind volumes/mutes of 3 DACs as a single PCM control for simplicity
426 #define ad1986a_pcm_amp_vol_info snd_hda_mixer_amp_volume_info
428 static int ad1986a_pcm_amp_vol_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
430 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
431 struct ad198x_spec
*ad
= codec
->spec
;
433 mutex_lock(&ad
->amp_mutex
);
434 snd_hda_mixer_amp_volume_get(kcontrol
, ucontrol
);
435 mutex_unlock(&ad
->amp_mutex
);
439 static int ad1986a_pcm_amp_vol_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
441 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
442 struct ad198x_spec
*ad
= codec
->spec
;
445 mutex_lock(&ad
->amp_mutex
);
446 for (i
= 0; i
< ARRAY_SIZE(ad1986a_dac_nids
); i
++) {
447 kcontrol
->private_value
= HDA_COMPOSE_AMP_VAL(ad1986a_dac_nids
[i
], 3, 0, HDA_OUTPUT
);
448 change
|= snd_hda_mixer_amp_volume_put(kcontrol
, ucontrol
);
450 kcontrol
->private_value
= HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC
, 3, 0, HDA_OUTPUT
);
451 mutex_unlock(&ad
->amp_mutex
);
455 static int ad1986a_pcm_amp_tlv(struct snd_kcontrol
*kcontrol
, int op_flag
,
456 unsigned int size
, unsigned int __user
*_tlv
)
458 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
459 struct ad198x_spec
*ad
= codec
->spec
;
461 mutex_lock(&ad
->amp_mutex
);
462 snd_hda_mixer_amp_tlv(kcontrol
, op_flag
, size
, _tlv
);
463 mutex_unlock(&ad
->amp_mutex
);
468 #define ad1986a_pcm_amp_sw_info snd_hda_mixer_amp_switch_info
470 static int ad1986a_pcm_amp_sw_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
472 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
473 struct ad198x_spec
*ad
= codec
->spec
;
475 mutex_lock(&ad
->amp_mutex
);
476 snd_hda_mixer_amp_switch_get(kcontrol
, ucontrol
);
477 mutex_unlock(&ad
->amp_mutex
);
481 static int ad1986a_pcm_amp_sw_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
483 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
484 struct ad198x_spec
*ad
= codec
->spec
;
487 mutex_lock(&ad
->amp_mutex
);
488 for (i
= 0; i
< ARRAY_SIZE(ad1986a_dac_nids
); i
++) {
489 kcontrol
->private_value
= HDA_COMPOSE_AMP_VAL(ad1986a_dac_nids
[i
], 3, 0, HDA_OUTPUT
);
490 change
|= snd_hda_mixer_amp_switch_put(kcontrol
, ucontrol
);
492 kcontrol
->private_value
= HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC
, 3, 0, HDA_OUTPUT
);
493 mutex_unlock(&ad
->amp_mutex
);
500 static struct snd_kcontrol_new ad1986a_mixers
[] = {
502 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
503 .name
= "PCM Playback Volume",
504 .access
= SNDRV_CTL_ELEM_ACCESS_READWRITE
|
505 SNDRV_CTL_ELEM_ACCESS_TLV_READ
|
506 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK
,
507 .info
= ad1986a_pcm_amp_vol_info
,
508 .get
= ad1986a_pcm_amp_vol_get
,
509 .put
= ad1986a_pcm_amp_vol_put
,
510 .tlv
.c
= ad1986a_pcm_amp_tlv
,
511 .private_value
= HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC
, 3, 0, HDA_OUTPUT
)
514 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
515 .name
= "PCM Playback Switch",
516 .info
= ad1986a_pcm_amp_sw_info
,
517 .get
= ad1986a_pcm_amp_sw_get
,
518 .put
= ad1986a_pcm_amp_sw_put
,
519 .private_value
= HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC
, 3, 0, HDA_OUTPUT
)
521 HDA_CODEC_VOLUME("Front Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
522 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT
),
523 HDA_CODEC_VOLUME("Surround Playback Volume", 0x1c, 0x0, HDA_OUTPUT
),
524 HDA_CODEC_MUTE("Surround Playback Switch", 0x1c, 0x0, HDA_OUTPUT
),
525 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x1d, 1, 0x0, HDA_OUTPUT
),
526 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x1d, 2, 0x0, HDA_OUTPUT
),
527 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x1d, 1, 0x0, HDA_OUTPUT
),
528 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x1d, 2, 0x0, HDA_OUTPUT
),
529 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT
),
530 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT
),
531 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT
),
532 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT
),
533 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT
),
534 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT
),
535 HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT
),
536 HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT
),
537 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
538 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
539 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT
),
540 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT
),
541 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT
),
542 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT
),
543 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT
),
544 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT
),
546 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
547 .name
= "Capture Source",
548 .info
= ad198x_mux_enum_info
,
549 .get
= ad198x_mux_enum_get
,
550 .put
= ad198x_mux_enum_put
,
552 HDA_CODEC_MUTE("Stereo Downmix Switch", 0x09, 0x0, HDA_OUTPUT
),
556 /* additional mixers for 3stack mode */
557 static struct snd_kcontrol_new ad1986a_3st_mixers
[] = {
559 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
560 .name
= "Channel Mode",
561 .info
= ad198x_ch_mode_info
,
562 .get
= ad198x_ch_mode_get
,
563 .put
= ad198x_ch_mode_put
,
568 /* laptop model - 2ch only */
569 static hda_nid_t ad1986a_laptop_dac_nids
[1] = { AD1986A_FRONT_DAC
};
571 static struct snd_kcontrol_new ad1986a_laptop_mixers
[] = {
572 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT
),
573 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT
),
574 HDA_CODEC_VOLUME("Master Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
575 HDA_CODEC_MUTE("Master Playback Switch", 0x1b, 0x0, HDA_OUTPUT
),
576 /* HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT),
577 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT), */
578 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT
),
579 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT
),
580 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT
),
581 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT
),
582 HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT
),
583 HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT
),
584 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
585 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
586 /* HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT),
587 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT),
588 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
589 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), */
590 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT
),
591 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT
),
593 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
594 .name
= "Capture Source",
595 .info
= ad198x_mux_enum_info
,
596 .get
= ad198x_mux_enum_get
,
597 .put
= ad198x_mux_enum_put
,
602 /* laptop-eapd model - 2ch only */
604 /* master controls both pins 0x1a and 0x1b */
605 static int ad1986a_laptop_master_vol_put(struct snd_kcontrol
*kcontrol
,
606 struct snd_ctl_elem_value
*ucontrol
)
608 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
609 long *valp
= ucontrol
->value
.integer
.value
;
612 change
= snd_hda_codec_amp_update(codec
, 0x1a, 0, HDA_OUTPUT
, 0,
613 0x7f, valp
[0] & 0x7f);
614 change
|= snd_hda_codec_amp_update(codec
, 0x1a, 1, HDA_OUTPUT
, 0,
615 0x7f, valp
[1] & 0x7f);
616 snd_hda_codec_amp_update(codec
, 0x1b, 0, HDA_OUTPUT
, 0,
617 0x7f, valp
[0] & 0x7f);
618 snd_hda_codec_amp_update(codec
, 0x1b, 1, HDA_OUTPUT
, 0,
619 0x7f, valp
[1] & 0x7f);
623 static int ad1986a_laptop_master_sw_put(struct snd_kcontrol
*kcontrol
,
624 struct snd_ctl_elem_value
*ucontrol
)
626 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
627 long *valp
= ucontrol
->value
.integer
.value
;
630 change
= snd_hda_codec_amp_update(codec
, 0x1a, 0, HDA_OUTPUT
, 0,
631 0x80, valp
[0] ? 0 : 0x80);
632 change
|= snd_hda_codec_amp_update(codec
, 0x1a, 1, HDA_OUTPUT
, 0,
633 0x80, valp
[1] ? 0 : 0x80);
634 snd_hda_codec_amp_update(codec
, 0x1b, 0, HDA_OUTPUT
, 0,
635 0x80, valp
[0] ? 0 : 0x80);
636 snd_hda_codec_amp_update(codec
, 0x1b, 1, HDA_OUTPUT
, 0,
637 0x80, valp
[1] ? 0 : 0x80);
641 static struct hda_input_mux ad1986a_laptop_eapd_capture_source
= {
645 { "Internal Mic", 0x4 },
650 static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers
[] = {
652 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
653 .name
= "Master Playback Volume",
654 .info
= snd_hda_mixer_amp_volume_info
,
655 .get
= snd_hda_mixer_amp_volume_get
,
656 .put
= ad1986a_laptop_master_vol_put
,
657 .private_value
= HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT
),
660 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
661 .name
= "Master Playback Switch",
662 .info
= snd_hda_mixer_amp_switch_info
,
663 .get
= snd_hda_mixer_amp_switch_get
,
664 .put
= ad1986a_laptop_master_sw_put
,
665 .private_value
= HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT
),
667 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT
),
668 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT
),
669 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x0, HDA_OUTPUT
),
670 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x0, HDA_OUTPUT
),
671 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
672 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
673 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT
),
674 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT
),
676 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
677 .name
= "Capture Source",
678 .info
= ad198x_mux_enum_info
,
679 .get
= ad198x_mux_enum_get
,
680 .put
= ad198x_mux_enum_put
,
683 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
684 .name
= "External Amplifier",
685 .info
= ad198x_eapd_info
,
686 .get
= ad198x_eapd_get
,
687 .put
= ad198x_eapd_put
,
688 .private_value
= 0x1b | (1 << 8), /* port-D, inversed */
694 * initialization verbs
696 static struct hda_verb ad1986a_init_verbs
[] = {
697 /* Front, Surround, CLFE DAC; mute as default */
698 {0x03, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
699 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
700 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
702 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
703 /* HP, Line-Out, Surround, CLFE selectors */
704 {0x0a, AC_VERB_SET_CONNECT_SEL
, 0x0},
705 {0x0b, AC_VERB_SET_CONNECT_SEL
, 0x0},
706 {0x0c, AC_VERB_SET_CONNECT_SEL
, 0x0},
707 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x0},
709 {0x0e, AC_VERB_SET_CONNECT_SEL
, 0x0},
710 /* Mic selector: Mic 1/2 pin */
711 {0x0f, AC_VERB_SET_CONNECT_SEL
, 0x0},
712 /* Line-in selector: Line-in */
713 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x0},
715 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x0},
716 /* Record selector: mic */
717 {0x12, AC_VERB_SET_CONNECT_SEL
, 0x0},
718 /* Mic, Phone, CD, Aux, Line-In amp; mute as default */
719 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
720 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
721 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
722 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
723 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
725 {0x18, AC_VERB_SET_CONNECT_SEL
, 0x0},
726 /* HP, Line-Out, Surround, CLFE, Mono pins; mute as default */
727 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
728 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
729 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
730 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
731 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
733 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0xc0 },
734 /* Front, Surround, CLFE Pins */
735 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
736 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
737 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
739 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
741 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24 },
742 /* Line, Aux, CD, Beep-In Pin */
743 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
744 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
745 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
746 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
747 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
751 /* additional verbs for 3-stack model */
752 static struct hda_verb ad1986a_3st_init_verbs
[] = {
753 /* Mic and line-in selectors */
754 {0x0f, AC_VERB_SET_CONNECT_SEL
, 0x2},
755 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x1},
759 static struct hda_verb ad1986a_ch2_init
[] = {
760 /* Surround out -> Line In */
761 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24 },
762 { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
764 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24 },
765 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
769 static struct hda_verb ad1986a_ch4_init
[] = {
770 /* Surround out -> Surround */
771 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
772 { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
774 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24 },
775 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
779 static struct hda_verb ad1986a_ch6_init
[] = {
780 /* Surround out -> Surround out */
781 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
782 { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
784 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
785 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
789 static struct hda_channel_mode ad1986a_modes
[3] = {
790 { 2, ad1986a_ch2_init
},
791 { 4, ad1986a_ch4_init
},
792 { 6, ad1986a_ch6_init
},
795 /* eapd initialization */
796 static struct hda_verb ad1986a_eapd_init_verbs
[] = {
797 {0x1b, AC_VERB_SET_EAPD_BTLENABLE
, 0x00},
802 enum { AD1986A_6STACK
, AD1986A_3STACK
, AD1986A_LAPTOP
, AD1986A_LAPTOP_EAPD
};
804 static struct hda_board_config ad1986a_cfg_tbl
[] = {
805 { .modelname
= "6stack", .config
= AD1986A_6STACK
},
806 { .modelname
= "3stack", .config
= AD1986A_3STACK
},
807 { .pci_subvendor
= 0x10de, .pci_subdevice
= 0xcb84,
808 .config
= AD1986A_3STACK
}, /* ASUS A8N-VM CSM */
809 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x81b3,
810 .config
= AD1986A_3STACK
}, /* ASUS P5RD2-VM / P5GPL-X SE */
811 { .modelname
= "laptop", .config
= AD1986A_LAPTOP
},
812 { .pci_subvendor
= 0x144d, .pci_subdevice
= 0xc01e,
813 .config
= AD1986A_LAPTOP
}, /* FSC V2060 */
814 { .pci_subvendor
= 0x17c0, .pci_subdevice
= 0x2017,
815 .config
= AD1986A_LAPTOP
}, /* Samsung M50 */
816 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x818f,
817 .config
= AD1986A_LAPTOP
}, /* ASUS P5GV-MX */
818 { .modelname
= "laptop-eapd", .config
= AD1986A_LAPTOP_EAPD
},
819 { .pci_subvendor
= 0x144d, .pci_subdevice
= 0xc023,
820 .config
= AD1986A_LAPTOP_EAPD
}, /* Samsung X60 Chane */
821 { .pci_subvendor
= 0x144d, .pci_subdevice
= 0xc024,
822 .config
= AD1986A_LAPTOP_EAPD
}, /* Samsung R65-T2300 Charis */
823 { .pci_subvendor
= 0x144d, .pci_subdevice
= 0xc026,
824 .config
= AD1986A_LAPTOP_EAPD
}, /* Samsung X10-T2300 Culesa */
825 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x1153,
826 .config
= AD1986A_LAPTOP_EAPD
}, /* ASUS M9 */
827 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x1213,
828 .config
= AD1986A_LAPTOP_EAPD
}, /* ASUS A6J */
829 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x11f7,
830 .config
= AD1986A_LAPTOP_EAPD
}, /* ASUS U5A */
831 { .pci_subvendor
= 0x1043, .pci_subdevice
= 0x1297,
832 .config
= AD1986A_LAPTOP_EAPD
}, /* ASUS Z62F */
833 { .pci_subvendor
= 0x103c, .pci_subdevice
= 0x30af,
834 .config
= AD1986A_LAPTOP_EAPD
}, /* HP Compaq Presario B2800 */
835 { .pci_subvendor
= 0x17aa, .pci_subdevice
= 0x2066,
836 .config
= AD1986A_LAPTOP_EAPD
}, /* Lenovo 3000 N100-07684JU */
840 static int patch_ad1986a(struct hda_codec
*codec
)
842 struct ad198x_spec
*spec
;
845 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
849 mutex_init(&spec
->amp_mutex
);
852 spec
->multiout
.max_channels
= 6;
853 spec
->multiout
.num_dacs
= ARRAY_SIZE(ad1986a_dac_nids
);
854 spec
->multiout
.dac_nids
= ad1986a_dac_nids
;
855 spec
->multiout
.dig_out_nid
= AD1986A_SPDIF_OUT
;
856 spec
->num_adc_nids
= 1;
857 spec
->adc_nids
= ad1986a_adc_nids
;
858 spec
->capsrc_nids
= ad1986a_capsrc_nids
;
859 spec
->input_mux
= &ad1986a_capture_source
;
860 spec
->num_mixers
= 1;
861 spec
->mixers
[0] = ad1986a_mixers
;
862 spec
->num_init_verbs
= 1;
863 spec
->init_verbs
[0] = ad1986a_init_verbs
;
865 codec
->patch_ops
= ad198x_patch_ops
;
867 /* override some parameters */
868 board_config
= snd_hda_check_board_config(codec
, ad1986a_cfg_tbl
);
869 switch (board_config
) {
871 spec
->num_mixers
= 2;
872 spec
->mixers
[1] = ad1986a_3st_mixers
;
873 spec
->num_init_verbs
= 3;
874 spec
->init_verbs
[1] = ad1986a_3st_init_verbs
;
875 spec
->init_verbs
[2] = ad1986a_ch2_init
;
876 spec
->channel_mode
= ad1986a_modes
;
877 spec
->num_channel_mode
= ARRAY_SIZE(ad1986a_modes
);
878 spec
->need_dac_fix
= 1;
879 spec
->multiout
.max_channels
= 2;
880 spec
->multiout
.num_dacs
= 1;
883 spec
->mixers
[0] = ad1986a_laptop_mixers
;
884 spec
->multiout
.max_channels
= 2;
885 spec
->multiout
.num_dacs
= 1;
886 spec
->multiout
.dac_nids
= ad1986a_laptop_dac_nids
;
888 case AD1986A_LAPTOP_EAPD
:
889 spec
->mixers
[0] = ad1986a_laptop_eapd_mixers
;
890 spec
->num_init_verbs
= 2;
891 spec
->init_verbs
[1] = ad1986a_eapd_init_verbs
;
892 spec
->multiout
.max_channels
= 2;
893 spec
->multiout
.num_dacs
= 1;
894 spec
->multiout
.dac_nids
= ad1986a_laptop_dac_nids
;
895 spec
->multiout
.dig_out_nid
= 0;
896 spec
->input_mux
= &ad1986a_laptop_eapd_capture_source
;
907 #define AD1983_SPDIF_OUT 0x02
908 #define AD1983_DAC 0x03
909 #define AD1983_ADC 0x04
911 static hda_nid_t ad1983_dac_nids
[1] = { AD1983_DAC
};
912 static hda_nid_t ad1983_adc_nids
[1] = { AD1983_ADC
};
913 static hda_nid_t ad1983_capsrc_nids
[1] = { 0x15 };
915 static struct hda_input_mux ad1983_capture_source
= {
926 * SPDIF playback route
928 static int ad1983_spdif_route_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
930 static char *texts
[] = { "PCM", "ADC" };
932 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
934 uinfo
->value
.enumerated
.items
= 2;
935 if (uinfo
->value
.enumerated
.item
> 1)
936 uinfo
->value
.enumerated
.item
= 1;
937 strcpy(uinfo
->value
.enumerated
.name
, texts
[uinfo
->value
.enumerated
.item
]);
941 static int ad1983_spdif_route_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
943 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
944 struct ad198x_spec
*spec
= codec
->spec
;
946 ucontrol
->value
.enumerated
.item
[0] = spec
->spdif_route
;
950 static int ad1983_spdif_route_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
952 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
953 struct ad198x_spec
*spec
= codec
->spec
;
955 if (spec
->spdif_route
!= ucontrol
->value
.enumerated
.item
[0]) {
956 spec
->spdif_route
= ucontrol
->value
.enumerated
.item
[0];
957 snd_hda_codec_write(codec
, spec
->multiout
.dig_out_nid
, 0,
958 AC_VERB_SET_CONNECT_SEL
, spec
->spdif_route
);
964 static struct snd_kcontrol_new ad1983_mixers
[] = {
965 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT
),
966 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT
),
967 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT
),
968 HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT
),
969 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT
),
970 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT
),
971 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
972 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
973 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
974 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
975 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
976 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
977 HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x10, 1, 0x0, HDA_OUTPUT
),
978 HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x10, 1, 0x0, HDA_OUTPUT
),
979 HDA_CODEC_VOLUME("Mic Boost", 0x0c, 0x0, HDA_OUTPUT
),
980 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT
),
981 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT
),
983 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
984 .name
= "Capture Source",
985 .info
= ad198x_mux_enum_info
,
986 .get
= ad198x_mux_enum_get
,
987 .put
= ad198x_mux_enum_put
,
990 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
991 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,NONE
) "Source",
992 .info
= ad1983_spdif_route_info
,
993 .get
= ad1983_spdif_route_get
,
994 .put
= ad1983_spdif_route_put
,
999 static struct hda_verb ad1983_init_verbs
[] = {
1000 /* Front, HP, Mono; mute as default */
1001 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1002 {0x06, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1003 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1004 /* Beep, PCM, Mic, Line-In: mute */
1005 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1006 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1007 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1008 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1009 /* Front, HP selectors; from Mix */
1010 {0x05, AC_VERB_SET_CONNECT_SEL
, 0x01},
1011 {0x06, AC_VERB_SET_CONNECT_SEL
, 0x01},
1012 /* Mono selector; from Mix */
1013 {0x0b, AC_VERB_SET_CONNECT_SEL
, 0x03},
1014 /* Mic selector; Mic */
1015 {0x0c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1016 /* Line-in selector: Line-in */
1017 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x0},
1018 /* Mic boost: 0dB */
1019 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
1020 /* Record selector: mic */
1021 {0x15, AC_VERB_SET_CONNECT_SEL
, 0x0},
1022 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1023 /* SPDIF route: PCM */
1024 {0x02, AC_VERB_SET_CONNECT_SEL
, 0x0},
1026 {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
1028 {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0xc0 },
1030 {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
1032 {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24 },
1034 {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
1039 static int patch_ad1983(struct hda_codec
*codec
)
1041 struct ad198x_spec
*spec
;
1043 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1047 mutex_init(&spec
->amp_mutex
);
1050 spec
->multiout
.max_channels
= 2;
1051 spec
->multiout
.num_dacs
= ARRAY_SIZE(ad1983_dac_nids
);
1052 spec
->multiout
.dac_nids
= ad1983_dac_nids
;
1053 spec
->multiout
.dig_out_nid
= AD1983_SPDIF_OUT
;
1054 spec
->num_adc_nids
= 1;
1055 spec
->adc_nids
= ad1983_adc_nids
;
1056 spec
->capsrc_nids
= ad1983_capsrc_nids
;
1057 spec
->input_mux
= &ad1983_capture_source
;
1058 spec
->num_mixers
= 1;
1059 spec
->mixers
[0] = ad1983_mixers
;
1060 spec
->num_init_verbs
= 1;
1061 spec
->init_verbs
[0] = ad1983_init_verbs
;
1062 spec
->spdif_route
= 0;
1064 codec
->patch_ops
= ad198x_patch_ops
;
1071 * AD1981 HD specific
1074 #define AD1981_SPDIF_OUT 0x02
1075 #define AD1981_DAC 0x03
1076 #define AD1981_ADC 0x04
1078 static hda_nid_t ad1981_dac_nids
[1] = { AD1981_DAC
};
1079 static hda_nid_t ad1981_adc_nids
[1] = { AD1981_ADC
};
1080 static hda_nid_t ad1981_capsrc_nids
[1] = { 0x15 };
1082 /* 0x0c, 0x09, 0x0e, 0x0f, 0x19, 0x05, 0x18, 0x17 */
1083 static struct hda_input_mux ad1981_capture_source
= {
1086 { "Front Mic", 0x0 },
1089 { "Mix Mono", 0x3 },
1096 static struct snd_kcontrol_new ad1981_mixers
[] = {
1097 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT
),
1098 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT
),
1099 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT
),
1100 HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT
),
1101 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT
),
1102 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT
),
1103 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
1104 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
1105 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
1106 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
1107 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
1108 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
1109 HDA_CODEC_VOLUME("Aux Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
1110 HDA_CODEC_MUTE("Aux Playback Switch", 0x1b, 0x0, HDA_OUTPUT
),
1111 HDA_CODEC_VOLUME("Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT
),
1112 HDA_CODEC_MUTE("Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT
),
1113 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
1114 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT
),
1115 HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT
),
1116 HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x0d, 1, 0x0, HDA_OUTPUT
),
1117 HDA_CODEC_VOLUME("Front Mic Boost", 0x08, 0x0, HDA_INPUT
),
1118 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x0, HDA_INPUT
),
1119 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT
),
1120 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT
),
1122 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1123 .name
= "Capture Source",
1124 .info
= ad198x_mux_enum_info
,
1125 .get
= ad198x_mux_enum_get
,
1126 .put
= ad198x_mux_enum_put
,
1128 /* identical with AD1983 */
1130 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1131 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,NONE
) "Source",
1132 .info
= ad1983_spdif_route_info
,
1133 .get
= ad1983_spdif_route_get
,
1134 .put
= ad1983_spdif_route_put
,
1139 static struct hda_verb ad1981_init_verbs
[] = {
1140 /* Front, HP, Mono; mute as default */
1141 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1142 {0x06, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1143 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1144 /* Beep, PCM, Front Mic, Line, Rear Mic, Aux, CD-In: mute */
1145 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1146 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1147 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1148 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1149 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1150 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1151 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1152 /* Front, HP selectors; from Mix */
1153 {0x05, AC_VERB_SET_CONNECT_SEL
, 0x01},
1154 {0x06, AC_VERB_SET_CONNECT_SEL
, 0x01},
1155 /* Mono selector; from Mix */
1156 {0x0b, AC_VERB_SET_CONNECT_SEL
, 0x03},
1157 /* Mic Mixer; select Front Mic */
1158 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
1159 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1160 /* Mic boost: 0dB */
1161 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
1162 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
1163 /* Record selector: Front mic */
1164 {0x15, AC_VERB_SET_CONNECT_SEL
, 0x0},
1165 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1166 /* SPDIF route: PCM */
1167 {0x02, AC_VERB_SET_CONNECT_SEL
, 0x0},
1169 {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
1171 {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0xc0 },
1173 {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
1174 /* Front & Rear Mic Pins */
1175 {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24 },
1176 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24 },
1178 {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
1180 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x00},
1181 /* Line-Out as Input: disabled */
1182 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1187 * Patch for HP nx6320
1189 * nx6320 uses EAPD in the reserve way - EAPD-on means the internal
1190 * speaker output enabled _and_ mute-LED off.
1193 #define AD1981_HP_EVENT 0x37
1194 #define AD1981_MIC_EVENT 0x38
1196 static struct hda_verb ad1981_hp_init_verbs
[] = {
1197 {0x05, AC_VERB_SET_EAPD_BTLENABLE
, 0x00 }, /* default off */
1198 /* pin sensing on HP and Mic jacks */
1199 {0x06, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1981_HP_EVENT
},
1200 {0x08, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1981_MIC_EVENT
},
1204 /* turn on/off EAPD (+ mute HP) as a master switch */
1205 static int ad1981_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1206 struct snd_ctl_elem_value
*ucontrol
)
1208 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1209 struct ad198x_spec
*spec
= codec
->spec
;
1211 if (! ad198x_eapd_put(kcontrol
, ucontrol
))
1214 /* toggle HP mute appropriately */
1215 snd_hda_codec_amp_update(codec
, 0x06, 0, HDA_OUTPUT
, 0,
1216 0x80, spec
->cur_eapd
? 0 : 0x80);
1217 snd_hda_codec_amp_update(codec
, 0x06, 1, HDA_OUTPUT
, 0,
1218 0x80, spec
->cur_eapd
? 0 : 0x80);
1222 /* bind volumes of both NID 0x05 and 0x06 */
1223 static int ad1981_hp_master_vol_put(struct snd_kcontrol
*kcontrol
,
1224 struct snd_ctl_elem_value
*ucontrol
)
1226 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1227 long *valp
= ucontrol
->value
.integer
.value
;
1230 change
= snd_hda_codec_amp_update(codec
, 0x05, 0, HDA_OUTPUT
, 0,
1231 0x7f, valp
[0] & 0x7f);
1232 change
|= snd_hda_codec_amp_update(codec
, 0x05, 1, HDA_OUTPUT
, 0,
1233 0x7f, valp
[1] & 0x7f);
1234 snd_hda_codec_amp_update(codec
, 0x06, 0, HDA_OUTPUT
, 0,
1235 0x7f, valp
[0] & 0x7f);
1236 snd_hda_codec_amp_update(codec
, 0x06, 1, HDA_OUTPUT
, 0,
1237 0x7f, valp
[1] & 0x7f);
1241 /* mute internal speaker if HP is plugged */
1242 static void ad1981_hp_automute(struct hda_codec
*codec
)
1244 unsigned int present
;
1246 present
= snd_hda_codec_read(codec
, 0x06, 0,
1247 AC_VERB_GET_PIN_SENSE
, 0) & 0x80000000;
1248 snd_hda_codec_amp_update(codec
, 0x05, 0, HDA_OUTPUT
, 0,
1249 0x80, present
? 0x80 : 0);
1250 snd_hda_codec_amp_update(codec
, 0x05, 1, HDA_OUTPUT
, 0,
1251 0x80, present
? 0x80 : 0);
1254 /* toggle input of built-in and mic jack appropriately */
1255 static void ad1981_hp_automic(struct hda_codec
*codec
)
1257 static struct hda_verb mic_jack_on
[] = {
1258 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1259 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
1262 static struct hda_verb mic_jack_off
[] = {
1263 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1264 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
1267 unsigned int present
;
1269 present
= snd_hda_codec_read(codec
, 0x08, 0,
1270 AC_VERB_GET_PIN_SENSE
, 0) & 0x80000000;
1272 snd_hda_sequence_write(codec
, mic_jack_on
);
1274 snd_hda_sequence_write(codec
, mic_jack_off
);
1277 /* unsolicited event for HP jack sensing */
1278 static void ad1981_hp_unsol_event(struct hda_codec
*codec
,
1283 case AD1981_HP_EVENT
:
1284 ad1981_hp_automute(codec
);
1286 case AD1981_MIC_EVENT
:
1287 ad1981_hp_automic(codec
);
1292 static struct hda_input_mux ad1981_hp_capture_source
= {
1296 { "Docking-Station", 0x1 },
1301 static struct snd_kcontrol_new ad1981_hp_mixers
[] = {
1303 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1304 .name
= "Master Playback Volume",
1305 .info
= snd_hda_mixer_amp_volume_info
,
1306 .get
= snd_hda_mixer_amp_volume_get
,
1307 .put
= ad1981_hp_master_vol_put
,
1308 .private_value
= HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT
),
1311 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1312 .name
= "Master Playback Switch",
1313 .info
= ad198x_eapd_info
,
1314 .get
= ad198x_eapd_get
,
1315 .put
= ad1981_hp_master_sw_put
,
1316 .private_value
= 0x05,
1318 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
1319 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
1321 /* FIXME: analog mic/line loopback doesn't work with my tests...
1322 * (although recording is OK)
1324 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
1325 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
1326 HDA_CODEC_VOLUME("Docking-Station Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
1327 HDA_CODEC_MUTE("Docking-Station Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
1328 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT
),
1329 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT
),
1330 /* FIXME: does this laptop have analog CD connection? */
1331 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
1332 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT
),
1334 HDA_CODEC_VOLUME("Mic Boost", 0x08, 0x0, HDA_INPUT
),
1335 HDA_CODEC_VOLUME("Internal Mic Boost", 0x18, 0x0, HDA_INPUT
),
1336 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT
),
1337 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT
),
1339 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1340 .name
= "Capture Source",
1341 .info
= ad198x_mux_enum_info
,
1342 .get
= ad198x_mux_enum_get
,
1343 .put
= ad198x_mux_enum_put
,
1348 /* initialize jack-sensing, too */
1349 static int ad1981_hp_init(struct hda_codec
*codec
)
1352 ad1981_hp_automute(codec
);
1353 ad1981_hp_automic(codec
);
1357 /* configuration for Lenovo Thinkpad T60 */
1358 static struct snd_kcontrol_new ad1981_thinkpad_mixers
[] = {
1359 HDA_CODEC_VOLUME("Master Playback Volume", 0x05, 0x0, HDA_OUTPUT
),
1360 HDA_CODEC_MUTE("Master Playback Switch", 0x05, 0x0, HDA_OUTPUT
),
1361 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
1362 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
1363 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
1364 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
1365 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
1366 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT
),
1367 HDA_CODEC_VOLUME("Mic Boost", 0x08, 0x0, HDA_INPUT
),
1368 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT
),
1369 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT
),
1371 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1372 .name
= "Capture Source",
1373 .info
= ad198x_mux_enum_info
,
1374 .get
= ad198x_mux_enum_get
,
1375 .put
= ad198x_mux_enum_put
,
1377 /* identical with AD1983 */
1379 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1380 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,NONE
) "Source",
1381 .info
= ad1983_spdif_route_info
,
1382 .get
= ad1983_spdif_route_get
,
1383 .put
= ad1983_spdif_route_put
,
1388 static struct hda_input_mux ad1981_thinkpad_capture_source
= {
1398 enum { AD1981_BASIC
, AD1981_HP
, AD1981_THINKPAD
};
1400 static struct hda_board_config ad1981_cfg_tbl
[] = {
1401 { .modelname
= "hp", .config
= AD1981_HP
},
1403 { .pci_subvendor
= 0x103c, .config
= AD1981_HP
},
1404 { .pci_subvendor
= 0x30b0, .pci_subdevice
= 0x103c,
1405 .config
= AD1981_HP
}, /* HP nx6320 (reversed SSID, H/W bug) */
1406 { .modelname
= "thinkpad", .config
= AD1981_THINKPAD
},
1407 /* Lenovo Thinkpad T60/X60/Z6xx */
1408 { .pci_subvendor
= 0x17aa, .config
= AD1981_THINKPAD
},
1409 { .pci_subvendor
= 0x1014, .pci_subdevice
= 0x0597,
1410 .config
= AD1981_THINKPAD
}, /* Z60m/t */
1411 { .modelname
= "basic", .config
= AD1981_BASIC
},
1415 static int patch_ad1981(struct hda_codec
*codec
)
1417 struct ad198x_spec
*spec
;
1420 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1424 mutex_init(&spec
->amp_mutex
);
1427 spec
->multiout
.max_channels
= 2;
1428 spec
->multiout
.num_dacs
= ARRAY_SIZE(ad1981_dac_nids
);
1429 spec
->multiout
.dac_nids
= ad1981_dac_nids
;
1430 spec
->multiout
.dig_out_nid
= AD1981_SPDIF_OUT
;
1431 spec
->num_adc_nids
= 1;
1432 spec
->adc_nids
= ad1981_adc_nids
;
1433 spec
->capsrc_nids
= ad1981_capsrc_nids
;
1434 spec
->input_mux
= &ad1981_capture_source
;
1435 spec
->num_mixers
= 1;
1436 spec
->mixers
[0] = ad1981_mixers
;
1437 spec
->num_init_verbs
= 1;
1438 spec
->init_verbs
[0] = ad1981_init_verbs
;
1439 spec
->spdif_route
= 0;
1441 codec
->patch_ops
= ad198x_patch_ops
;
1443 /* override some parameters */
1444 board_config
= snd_hda_check_board_config(codec
, ad1981_cfg_tbl
);
1445 switch (board_config
) {
1447 spec
->mixers
[0] = ad1981_hp_mixers
;
1448 spec
->num_init_verbs
= 2;
1449 spec
->init_verbs
[1] = ad1981_hp_init_verbs
;
1450 spec
->multiout
.dig_out_nid
= 0;
1451 spec
->input_mux
= &ad1981_hp_capture_source
;
1453 codec
->patch_ops
.init
= ad1981_hp_init
;
1454 codec
->patch_ops
.unsol_event
= ad1981_hp_unsol_event
;
1456 case AD1981_THINKPAD
:
1457 spec
->mixers
[0] = ad1981_thinkpad_mixers
;
1458 spec
->input_mux
= &ad1981_thinkpad_capture_source
;
1469 * Output pins and routes
1471 * Pin Mix Sel DAC (*)
1472 * port-A 0x11 (mute/hp) <- 0x22 <- 0x37 <- 03/04/06
1473 * port-B 0x14 (mute/hp) <- 0x2b <- 0x30 <- 03/04/06
1474 * port-C 0x15 (mute) <- 0x2c <- 0x31 <- 05/0a
1475 * port-D 0x12 (mute/hp) <- 0x29 <- 04
1476 * port-E 0x17 (mute/hp) <- 0x26 <- 0x32 <- 05/0a
1477 * port-F 0x16 (mute) <- 0x2a <- 06
1478 * port-G 0x24 (mute) <- 0x27 <- 05
1479 * port-H 0x25 (mute) <- 0x28 <- 0a
1480 * mono 0x13 (mute/amp)<- 0x1e <- 0x36 <- 03/04/06
1482 * DAC0 = 03h, DAC1 = 04h, DAC2 = 05h, DAC3 = 06h, DAC4 = 0ah
1483 * (*) DAC2/3/4 are swapped to DAC3/4/2 on AD198A rev.2 due to a h/w bug.
1485 * Input pins and routes
1487 * pin boost mix input # / adc input #
1488 * port-A 0x11 -> 0x38 -> mix 2, ADC 0
1489 * port-B 0x14 -> 0x39 -> mix 0, ADC 1
1490 * port-C 0x15 -> 0x3a -> 33:0 - mix 1, ADC 2
1491 * port-D 0x12 -> 0x3d -> mix 3, ADC 8
1492 * port-E 0x17 -> 0x3c -> 34:0 - mix 4, ADC 4
1493 * port-F 0x16 -> 0x3b -> mix 5, ADC 3
1494 * port-G 0x24 -> N/A -> 33:1 - mix 1, 34:1 - mix 4, ADC 6
1495 * port-H 0x25 -> N/A -> 33:2 - mix 1, 34:2 - mix 4, ADC 7
1499 * 6stack - front/surr/CLFE/side/opt DACs - 04/06/05/0a/03
1500 * 3stack - front/surr/CLFE/opt DACs - 04/05/0a/03
1502 * Inputs of Analog Mix (0x20)
1503 * 0:Port-B (front mic)
1504 * 1:Port-C/G/H (line-in)
1506 * 3:Port-D (line-in/2)
1507 * 4:Port-E/G/H (mic-in)
1508 * 5:Port-F (mic2-in)
1514 * 1:Port-B (front mic-in)
1515 * 2:Port-C (line-in)
1516 * 3:Port-F (mic2-in)
1521 * 8:Port-D (line-in/2)
1524 * Proposed pin assignments by the datasheet
1527 * Port-A front headphone
1537 * Port-A front headphone
1539 * C rear line-in/surround
1541 * E rear mic-in/CLFE
1547 * D internal speaker (with EAPD)
1548 * E/F quad mic array
1564 /* reivision id to check workarounds */
1565 #define AD1988A_REV2 0x100200
1567 #define is_rev2(codec) \
1568 ((codec)->vendor_id == 0x11d41988 && \
1569 (codec)->revision_id == AD1988A_REV2)
1575 static hda_nid_t ad1988_6stack_dac_nids
[4] = {
1576 0x04, 0x06, 0x05, 0x0a
1579 static hda_nid_t ad1988_3stack_dac_nids
[3] = {
1583 /* for AD1988A revision-2, DAC2-4 are swapped */
1584 static hda_nid_t ad1988_6stack_dac_nids_rev2
[4] = {
1585 0x04, 0x05, 0x0a, 0x06
1588 static hda_nid_t ad1988_3stack_dac_nids_rev2
[3] = {
1592 static hda_nid_t ad1988_adc_nids
[3] = {
1596 static hda_nid_t ad1988_capsrc_nids
[3] = {
1600 #define AD1988_SPDIF_OUT 0x02
1601 #define AD1988_SPDIF_IN 0x07
1603 static struct hda_input_mux ad1988_6stack_capture_source
= {
1606 { "Front Mic", 0x0 },
1614 static struct hda_input_mux ad1988_laptop_capture_source
= {
1617 { "Mic/Line", 0x0 },
1625 static int ad198x_ch_mode_info(struct snd_kcontrol
*kcontrol
,
1626 struct snd_ctl_elem_info
*uinfo
)
1628 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1629 struct ad198x_spec
*spec
= codec
->spec
;
1630 return snd_hda_ch_mode_info(codec
, uinfo
, spec
->channel_mode
,
1631 spec
->num_channel_mode
);
1634 static int ad198x_ch_mode_get(struct snd_kcontrol
*kcontrol
,
1635 struct snd_ctl_elem_value
*ucontrol
)
1637 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1638 struct ad198x_spec
*spec
= codec
->spec
;
1639 return snd_hda_ch_mode_get(codec
, ucontrol
, spec
->channel_mode
,
1640 spec
->num_channel_mode
, spec
->multiout
.max_channels
);
1643 static int ad198x_ch_mode_put(struct snd_kcontrol
*kcontrol
,
1644 struct snd_ctl_elem_value
*ucontrol
)
1646 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1647 struct ad198x_spec
*spec
= codec
->spec
;
1648 if (spec
->need_dac_fix
)
1649 spec
->multiout
.num_dacs
= spec
->multiout
.max_channels
/ 2;
1650 return snd_hda_ch_mode_put(codec
, ucontrol
, spec
->channel_mode
,
1651 spec
->num_channel_mode
, &spec
->multiout
.max_channels
);
1655 static struct snd_kcontrol_new ad1988_6stack_mixers1
[] = {
1656 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
1657 HDA_CODEC_VOLUME("Surround Playback Volume", 0x06, 0x0, HDA_OUTPUT
),
1658 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT
),
1659 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT
),
1660 HDA_CODEC_VOLUME("Side Playback Volume", 0x0a, 0x0, HDA_OUTPUT
),
1664 static struct snd_kcontrol_new ad1988_6stack_mixers1_rev2
[] = {
1665 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
1666 HDA_CODEC_VOLUME("Surround Playback Volume", 0x05, 0x0, HDA_OUTPUT
),
1667 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT
),
1668 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0a, 2, 0x0, HDA_OUTPUT
),
1669 HDA_CODEC_VOLUME("Side Playback Volume", 0x06, 0x0, HDA_OUTPUT
),
1673 static struct snd_kcontrol_new ad1988_6stack_mixers2
[] = {
1674 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT
),
1675 HDA_BIND_MUTE("Surround Playback Switch", 0x2a, 2, HDA_INPUT
),
1676 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x27, 1, 2, HDA_INPUT
),
1677 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x27, 2, 2, HDA_INPUT
),
1678 HDA_BIND_MUTE("Side Playback Switch", 0x28, 2, HDA_INPUT
),
1679 HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT
),
1680 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT
),
1682 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT
),
1683 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT
),
1684 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT
),
1685 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT
),
1686 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT
),
1687 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT
),
1688 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT
),
1689 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT
),
1691 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT
),
1692 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT
),
1694 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT
),
1695 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT
),
1697 HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT
),
1698 HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT
),
1704 static struct snd_kcontrol_new ad1988_3stack_mixers1
[] = {
1705 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
1706 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT
),
1707 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT
),
1708 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT
),
1712 static struct snd_kcontrol_new ad1988_3stack_mixers1_rev2
[] = {
1713 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
1714 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT
),
1715 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x06, 1, 0x0, HDA_OUTPUT
),
1716 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x06, 2, 0x0, HDA_OUTPUT
),
1720 static struct snd_kcontrol_new ad1988_3stack_mixers2
[] = {
1721 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT
),
1722 HDA_BIND_MUTE("Surround Playback Switch", 0x2c, 2, HDA_INPUT
),
1723 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x26, 1, 2, HDA_INPUT
),
1724 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x26, 2, 2, HDA_INPUT
),
1725 HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT
),
1726 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT
),
1728 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT
),
1729 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT
),
1730 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT
),
1731 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT
),
1732 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT
),
1733 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT
),
1734 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT
),
1735 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT
),
1737 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT
),
1738 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT
),
1740 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT
),
1741 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT
),
1743 HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT
),
1744 HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT
),
1746 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1747 .name
= "Channel Mode",
1748 .info
= ad198x_ch_mode_info
,
1749 .get
= ad198x_ch_mode_get
,
1750 .put
= ad198x_ch_mode_put
,
1757 static struct snd_kcontrol_new ad1988_laptop_mixers
[] = {
1758 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
1759 HDA_CODEC_MUTE("PCM Playback Switch", 0x29, 0x0, HDA_INPUT
),
1760 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT
),
1762 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT
),
1763 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT
),
1764 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x0, HDA_INPUT
),
1765 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x0, HDA_INPUT
),
1766 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT
),
1767 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT
),
1769 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT
),
1770 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT
),
1772 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT
),
1773 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT
),
1775 HDA_CODEC_VOLUME("Mic Boost", 0x39, 0x0, HDA_OUTPUT
),
1778 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1779 .name
= "External Amplifier",
1780 .info
= ad198x_eapd_info
,
1781 .get
= ad198x_eapd_get
,
1782 .put
= ad198x_eapd_put
,
1783 .private_value
= 0x12 | (1 << 8), /* port-D, inversed */
1790 static struct snd_kcontrol_new ad1988_capture_mixers
[] = {
1791 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
1792 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
1793 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT
),
1794 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT
),
1795 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x0e, 0x0, HDA_OUTPUT
),
1796 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x0e, 0x0, HDA_OUTPUT
),
1798 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1799 /* The multiple "Capture Source" controls confuse alsamixer
1800 * So call somewhat different..
1801 * FIXME: the controls appear in the "playback" view!
1803 /* .name = "Capture Source", */
1804 .name
= "Input Source",
1806 .info
= ad198x_mux_enum_info
,
1807 .get
= ad198x_mux_enum_get
,
1808 .put
= ad198x_mux_enum_put
,
1813 static int ad1988_spdif_playback_source_info(struct snd_kcontrol
*kcontrol
,
1814 struct snd_ctl_elem_info
*uinfo
)
1816 static char *texts
[] = {
1817 "PCM", "ADC1", "ADC2", "ADC3"
1819 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
1821 uinfo
->value
.enumerated
.items
= 4;
1822 if (uinfo
->value
.enumerated
.item
>= 4)
1823 uinfo
->value
.enumerated
.item
= 3;
1824 strcpy(uinfo
->value
.enumerated
.name
, texts
[uinfo
->value
.enumerated
.item
]);
1828 static int ad1988_spdif_playback_source_get(struct snd_kcontrol
*kcontrol
,
1829 struct snd_ctl_elem_value
*ucontrol
)
1831 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1834 sel
= snd_hda_codec_read(codec
, 0x02, 0, AC_VERB_GET_CONNECT_SEL
, 0);
1836 sel
= snd_hda_codec_read(codec
, 0x0b, 0, AC_VERB_GET_CONNECT_SEL
, 0);
1842 ucontrol
->value
.enumerated
.item
[0] = sel
;
1846 static int ad1988_spdif_playback_source_put(struct snd_kcontrol
*kcontrol
,
1847 struct snd_ctl_elem_value
*ucontrol
)
1849 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1853 sel
= snd_hda_codec_read(codec
, 0x02, 0, AC_VERB_GET_CONNECT_SEL
, 0);
1854 if (! ucontrol
->value
.enumerated
.item
[0]) {
1857 snd_hda_codec_write(codec
, 0x02, 0, AC_VERB_SET_CONNECT_SEL
, 0);
1861 snd_hda_codec_write(codec
, 0x02, 0, AC_VERB_SET_CONNECT_SEL
, 1);
1862 sel
= snd_hda_codec_read(codec
, 0x0b, 0, AC_VERB_GET_CONNECT_SEL
, 0) + 1;
1863 change
|= sel
== ucontrol
->value
.enumerated
.item
[0];
1865 snd_hda_codec_write(codec
, 0x02, 0, AC_VERB_SET_CONNECT_SEL
,
1866 ucontrol
->value
.enumerated
.item
[0] - 1);
1871 static struct snd_kcontrol_new ad1988_spdif_out_mixers
[] = {
1872 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
1874 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1875 .name
= "IEC958 Playback Source",
1876 .info
= ad1988_spdif_playback_source_info
,
1877 .get
= ad1988_spdif_playback_source_get
,
1878 .put
= ad1988_spdif_playback_source_put
,
1883 static struct snd_kcontrol_new ad1988_spdif_in_mixers
[] = {
1884 HDA_CODEC_VOLUME("IEC958 Capture Volume", 0x1c, 0x0, HDA_INPUT
),
1890 * initialization verbs
1894 * for 6-stack (+dig)
1896 static struct hda_verb ad1988_6stack_init_verbs
[] = {
1897 /* Front, Surround, CLFE, side DAC; unmute as default */
1898 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1899 {0x06, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1900 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1901 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1902 /* Port-A front headphon path */
1903 {0x37, AC_VERB_SET_CONNECT_SEL
, 0x01}, /* DAC1:04h */
1904 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1905 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1906 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1907 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
1908 /* Port-D line-out path */
1909 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1910 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1911 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1912 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1913 /* Port-F surround path */
1914 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1915 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1916 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1917 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1918 /* Port-G CLFE path */
1919 {0x27, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1920 {0x27, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1921 {0x24, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1922 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1923 /* Port-H side path */
1924 {0x28, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1925 {0x28, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1926 {0x25, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
1927 {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1929 {0x36, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* DAC1:04h */
1930 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1931 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1932 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
1933 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb01f}, /* unmute, 0dB */
1934 /* Port-B front mic-in path */
1935 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1936 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1937 {0x39, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
1938 /* Port-C line-in path */
1939 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1940 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1941 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
1942 {0x33, AC_VERB_SET_CONNECT_SEL
, 0x0},
1943 /* Port-E mic-in path */
1944 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1945 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
1946 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
1947 {0x34, AC_VERB_SET_CONNECT_SEL
, 0x0},
1952 static struct hda_verb ad1988_capture_init_verbs
[] = {
1953 /* mute analog mix */
1954 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
1955 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
1956 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
1957 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
1958 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
1959 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)},
1960 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)},
1961 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)},
1962 /* select ADCs - front-mic */
1963 {0x0c, AC_VERB_SET_CONNECT_SEL
, 0x1},
1964 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x1},
1965 {0x0e, AC_VERB_SET_CONNECT_SEL
, 0x1},
1967 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1968 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1969 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1974 static struct hda_verb ad1988_spdif_init_verbs
[] = {
1976 {0x02, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* PCM */
1977 {0x0b, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* ADC1 */
1978 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
1979 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
1981 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x27}, /* 0dB */
1982 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0) | 0x17}, /* 0dB */
1988 * verbs for 3stack (+dig)
1990 static struct hda_verb ad1988_3stack_ch2_init
[] = {
1991 /* set port-C to line-in */
1992 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1993 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
1994 /* set port-E to mic-in */
1995 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1996 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2000 static struct hda_verb ad1988_3stack_ch6_init
[] = {
2001 /* set port-C to surround out */
2002 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2003 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2004 /* set port-E to CLFE out */
2005 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2006 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2010 static struct hda_channel_mode ad1988_3stack_modes
[2] = {
2011 { 2, ad1988_3stack_ch2_init
},
2012 { 6, ad1988_3stack_ch6_init
},
2015 static struct hda_verb ad1988_3stack_init_verbs
[] = {
2016 /* Front, Surround, CLFE, side DAC; unmute as default */
2017 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2018 {0x06, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2019 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2020 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2021 /* Port-A front headphon path */
2022 {0x37, AC_VERB_SET_CONNECT_SEL
, 0x01}, /* DAC1:04h */
2023 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2024 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2025 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2026 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2027 /* Port-D line-out path */
2028 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2029 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2030 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2031 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2033 {0x36, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* DAC1:04h */
2034 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2035 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2036 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2037 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb01f}, /* unmute, 0dB */
2038 /* Port-B front mic-in path */
2039 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2040 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2041 {0x39, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2042 /* Port-C line-in/surround path - 6ch mode as default */
2043 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2044 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2045 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2046 {0x31, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* output sel: DAC 0x05 */
2047 {0x33, AC_VERB_SET_CONNECT_SEL
, 0x0},
2048 /* Port-E mic-in/CLFE path - 6ch mode as default */
2049 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2050 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2051 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2052 {0x32, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* output sel: DAC 0x0a */
2053 {0x34, AC_VERB_SET_CONNECT_SEL
, 0x0},
2054 /* mute analog mix */
2055 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2056 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2057 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2058 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2059 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2060 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)},
2061 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)},
2062 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)},
2063 /* select ADCs - front-mic */
2064 {0x0c, AC_VERB_SET_CONNECT_SEL
, 0x1},
2065 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x1},
2066 {0x0e, AC_VERB_SET_CONNECT_SEL
, 0x1},
2068 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2069 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2070 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2075 * verbs for laptop mode (+dig)
2077 static struct hda_verb ad1988_laptop_hp_on
[] = {
2078 /* unmute port-A and mute port-D */
2079 { 0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2080 { 0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2083 static struct hda_verb ad1988_laptop_hp_off
[] = {
2084 /* mute port-A and unmute port-D */
2085 { 0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2086 { 0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2090 #define AD1988_HP_EVENT 0x01
2092 static struct hda_verb ad1988_laptop_init_verbs
[] = {
2093 /* Front, Surround, CLFE, side DAC; unmute as default */
2094 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2095 {0x06, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2096 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2097 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2098 /* Port-A front headphon path */
2099 {0x37, AC_VERB_SET_CONNECT_SEL
, 0x01}, /* DAC1:04h */
2100 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2101 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2102 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2103 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2104 /* unsolicited event for pin-sense */
2105 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1988_HP_EVENT
},
2106 /* Port-D line-out path + EAPD */
2107 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2108 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2109 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2110 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2111 {0x12, AC_VERB_SET_EAPD_BTLENABLE
, 0x00}, /* EAPD-off */
2113 {0x36, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* DAC1:04h */
2114 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2115 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2116 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2117 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb01f}, /* unmute, 0dB */
2118 /* Port-B mic-in path */
2119 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2120 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2121 {0x39, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2122 /* Port-C docking station - try to output */
2123 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2124 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2125 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2126 {0x33, AC_VERB_SET_CONNECT_SEL
, 0x0},
2127 /* mute analog mix */
2128 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2129 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2130 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2131 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2132 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2133 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)},
2134 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)},
2135 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)},
2136 /* select ADCs - mic */
2137 {0x0c, AC_VERB_SET_CONNECT_SEL
, 0x1},
2138 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x1},
2139 {0x0e, AC_VERB_SET_CONNECT_SEL
, 0x1},
2141 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2142 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2143 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2147 static void ad1988_laptop_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2149 if ((res
>> 26) != AD1988_HP_EVENT
)
2151 if (snd_hda_codec_read(codec
, 0x11, 0, AC_VERB_GET_PIN_SENSE
, 0) & (1 << 31))
2152 snd_hda_sequence_write(codec
, ad1988_laptop_hp_on
);
2154 snd_hda_sequence_write(codec
, ad1988_laptop_hp_off
);
2159 * Automatic parse of I/O pins from the BIOS configuration
2162 #define NUM_CONTROL_ALLOC 32
2163 #define NUM_VERB_ALLOC 32
2170 static struct snd_kcontrol_new ad1988_control_templates
[] = {
2171 HDA_CODEC_VOLUME(NULL
, 0, 0, 0),
2172 HDA_CODEC_MUTE(NULL
, 0, 0, 0),
2173 HDA_BIND_MUTE(NULL
, 0, 0, 0),
2176 /* add dynamic controls */
2177 static int add_control(struct ad198x_spec
*spec
, int type
, const char *name
,
2180 struct snd_kcontrol_new
*knew
;
2182 if (spec
->num_kctl_used
>= spec
->num_kctl_alloc
) {
2183 int num
= spec
->num_kctl_alloc
+ NUM_CONTROL_ALLOC
;
2185 knew
= kcalloc(num
+ 1, sizeof(*knew
), GFP_KERNEL
); /* array + terminator */
2188 if (spec
->kctl_alloc
) {
2189 memcpy(knew
, spec
->kctl_alloc
, sizeof(*knew
) * spec
->num_kctl_alloc
);
2190 kfree(spec
->kctl_alloc
);
2192 spec
->kctl_alloc
= knew
;
2193 spec
->num_kctl_alloc
= num
;
2196 knew
= &spec
->kctl_alloc
[spec
->num_kctl_used
];
2197 *knew
= ad1988_control_templates
[type
];
2198 knew
->name
= kstrdup(name
, GFP_KERNEL
);
2201 knew
->private_value
= val
;
2202 spec
->num_kctl_used
++;
2206 #define AD1988_PIN_CD_NID 0x18
2207 #define AD1988_PIN_BEEP_NID 0x10
2209 static hda_nid_t ad1988_mixer_nids
[8] = {
2210 /* A B C D E F G H */
2211 0x22, 0x2b, 0x2c, 0x29, 0x26, 0x2a, 0x27, 0x28
2214 static inline hda_nid_t
ad1988_idx_to_dac(struct hda_codec
*codec
, int idx
)
2216 static hda_nid_t idx_to_dac
[8] = {
2217 /* A B C D E F G H */
2218 0x04, 0x06, 0x05, 0x04, 0x0a, 0x06, 0x05, 0x0a
2220 static hda_nid_t idx_to_dac_rev2
[8] = {
2221 /* A B C D E F G H */
2222 0x04, 0x05, 0x0a, 0x04, 0x06, 0x05, 0x0a, 0x06
2225 return idx_to_dac_rev2
[idx
];
2227 return idx_to_dac
[idx
];
2230 static hda_nid_t ad1988_boost_nids
[8] = {
2231 0x38, 0x39, 0x3a, 0x3d, 0x3c, 0x3b, 0, 0
2234 static int ad1988_pin_idx(hda_nid_t nid
)
2236 static hda_nid_t ad1988_io_pins
[8] = {
2237 0x11, 0x14, 0x15, 0x12, 0x17, 0x16, 0x24, 0x25
2240 for (i
= 0; i
< ARRAY_SIZE(ad1988_io_pins
); i
++)
2241 if (ad1988_io_pins
[i
] == nid
)
2243 return 0; /* should be -1 */
2246 static int ad1988_pin_to_loopback_idx(hda_nid_t nid
)
2248 static int loopback_idx
[8] = {
2249 2, 0, 1, 3, 4, 5, 1, 4
2252 case AD1988_PIN_CD_NID
:
2255 return loopback_idx
[ad1988_pin_idx(nid
)];
2259 static int ad1988_pin_to_adc_idx(hda_nid_t nid
)
2261 static int adc_idx
[8] = {
2262 0, 1, 2, 8, 4, 3, 6, 7
2265 case AD1988_PIN_CD_NID
:
2268 return adc_idx
[ad1988_pin_idx(nid
)];
2272 /* fill in the dac_nids table from the parsed pin configuration */
2273 static int ad1988_auto_fill_dac_nids(struct hda_codec
*codec
,
2274 const struct auto_pin_cfg
*cfg
)
2276 struct ad198x_spec
*spec
= codec
->spec
;
2279 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
2281 /* check the pins hardwired to audio widget */
2282 for (i
= 0; i
< cfg
->line_outs
; i
++) {
2283 idx
= ad1988_pin_idx(cfg
->line_out_pins
[i
]);
2284 spec
->multiout
.dac_nids
[i
] = ad1988_idx_to_dac(codec
, idx
);
2286 spec
->multiout
.num_dacs
= cfg
->line_outs
;
2290 /* add playback controls from the parsed DAC table */
2291 static int ad1988_auto_create_multi_out_ctls(struct ad198x_spec
*spec
,
2292 const struct auto_pin_cfg
*cfg
)
2295 static const char *chname
[4] = { "Front", "Surround", NULL
/*CLFE*/, "Side" };
2299 for (i
= 0; i
< cfg
->line_outs
; i
++) {
2300 hda_nid_t dac
= spec
->multiout
.dac_nids
[i
];
2303 nid
= ad1988_mixer_nids
[ad1988_pin_idx(cfg
->line_out_pins
[i
])];
2306 err
= add_control(spec
, AD_CTL_WIDGET_VOL
,
2307 "Center Playback Volume",
2308 HDA_COMPOSE_AMP_VAL(dac
, 1, 0, HDA_OUTPUT
));
2311 err
= add_control(spec
, AD_CTL_WIDGET_VOL
,
2312 "LFE Playback Volume",
2313 HDA_COMPOSE_AMP_VAL(dac
, 2, 0, HDA_OUTPUT
));
2316 err
= add_control(spec
, AD_CTL_BIND_MUTE
,
2317 "Center Playback Switch",
2318 HDA_COMPOSE_AMP_VAL(nid
, 1, 2, HDA_INPUT
));
2321 err
= add_control(spec
, AD_CTL_BIND_MUTE
,
2322 "LFE Playback Switch",
2323 HDA_COMPOSE_AMP_VAL(nid
, 2, 2, HDA_INPUT
));
2327 sprintf(name
, "%s Playback Volume", chname
[i
]);
2328 err
= add_control(spec
, AD_CTL_WIDGET_VOL
, name
,
2329 HDA_COMPOSE_AMP_VAL(dac
, 3, 0, HDA_OUTPUT
));
2332 sprintf(name
, "%s Playback Switch", chname
[i
]);
2333 err
= add_control(spec
, AD_CTL_BIND_MUTE
, name
,
2334 HDA_COMPOSE_AMP_VAL(nid
, 3, 2, HDA_INPUT
));
2342 /* add playback controls for speaker and HP outputs */
2343 static int ad1988_auto_create_extra_out(struct hda_codec
*codec
, hda_nid_t pin
,
2346 struct ad198x_spec
*spec
= codec
->spec
;
2354 idx
= ad1988_pin_idx(pin
);
2355 nid
= ad1988_idx_to_dac(codec
, idx
);
2356 /* specify the DAC as the extra output */
2357 if (! spec
->multiout
.hp_nid
)
2358 spec
->multiout
.hp_nid
= nid
;
2360 spec
->multiout
.extra_out_nid
[0] = nid
;
2361 /* control HP volume/switch on the output mixer amp */
2362 sprintf(name
, "%s Playback Volume", pfx
);
2363 if ((err
= add_control(spec
, AD_CTL_WIDGET_VOL
, name
,
2364 HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
))) < 0)
2366 nid
= ad1988_mixer_nids
[idx
];
2367 sprintf(name
, "%s Playback Switch", pfx
);
2368 if ((err
= add_control(spec
, AD_CTL_BIND_MUTE
, name
,
2369 HDA_COMPOSE_AMP_VAL(nid
, 3, 2, HDA_INPUT
))) < 0)
2374 /* create input playback/capture controls for the given pin */
2375 static int new_analog_input(struct ad198x_spec
*spec
, hda_nid_t pin
,
2376 const char *ctlname
, int boost
)
2381 sprintf(name
, "%s Playback Volume", ctlname
);
2382 idx
= ad1988_pin_to_loopback_idx(pin
);
2383 if ((err
= add_control(spec
, AD_CTL_WIDGET_VOL
, name
,
2384 HDA_COMPOSE_AMP_VAL(0x20, 3, idx
, HDA_INPUT
))) < 0)
2386 sprintf(name
, "%s Playback Switch", ctlname
);
2387 if ((err
= add_control(spec
, AD_CTL_WIDGET_MUTE
, name
,
2388 HDA_COMPOSE_AMP_VAL(0x20, 3, idx
, HDA_INPUT
))) < 0)
2392 idx
= ad1988_pin_idx(pin
);
2393 bnid
= ad1988_boost_nids
[idx
];
2395 sprintf(name
, "%s Boost", ctlname
);
2396 return add_control(spec
, AD_CTL_WIDGET_VOL
, name
,
2397 HDA_COMPOSE_AMP_VAL(bnid
, 3, idx
, HDA_OUTPUT
));
2404 /* create playback/capture controls for input pins */
2405 static int ad1988_auto_create_analog_input_ctls(struct ad198x_spec
*spec
,
2406 const struct auto_pin_cfg
*cfg
)
2408 struct hda_input_mux
*imux
= &spec
->private_imux
;
2411 for (i
= 0; i
< AUTO_PIN_LAST
; i
++) {
2412 err
= new_analog_input(spec
, cfg
->input_pins
[i
],
2413 auto_pin_cfg_labels
[i
],
2414 i
<= AUTO_PIN_FRONT_MIC
);
2417 imux
->items
[imux
->num_items
].label
= auto_pin_cfg_labels
[i
];
2418 imux
->items
[imux
->num_items
].index
= ad1988_pin_to_adc_idx(cfg
->input_pins
[i
]);
2421 imux
->items
[imux
->num_items
].label
= "Mix";
2422 imux
->items
[imux
->num_items
].index
= 9;
2425 if ((err
= add_control(spec
, AD_CTL_WIDGET_VOL
,
2426 "Analog Mix Playback Volume",
2427 HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT
))) < 0)
2429 if ((err
= add_control(spec
, AD_CTL_WIDGET_MUTE
,
2430 "Analog Mix Playback Switch",
2431 HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT
))) < 0)
2437 static void ad1988_auto_set_output_and_unmute(struct hda_codec
*codec
,
2438 hda_nid_t nid
, int pin_type
,
2442 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
, pin_type
);
2443 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
);
2445 case 0x11: /* port-A - DAC 04 */
2446 snd_hda_codec_write(codec
, 0x37, 0, AC_VERB_SET_CONNECT_SEL
, 0x01);
2448 case 0x14: /* port-B - DAC 06 */
2449 snd_hda_codec_write(codec
, 0x30, 0, AC_VERB_SET_CONNECT_SEL
, 0x02);
2451 case 0x15: /* port-C - DAC 05 */
2452 snd_hda_codec_write(codec
, 0x31, 0, AC_VERB_SET_CONNECT_SEL
, 0x00);
2454 case 0x17: /* port-E - DAC 0a */
2455 snd_hda_codec_write(codec
, 0x32, 0, AC_VERB_SET_CONNECT_SEL
, 0x01);
2457 case 0x13: /* mono - DAC 04 */
2458 snd_hda_codec_write(codec
, 0x36, 0, AC_VERB_SET_CONNECT_SEL
, 0x01);
2463 static void ad1988_auto_init_multi_out(struct hda_codec
*codec
)
2465 struct ad198x_spec
*spec
= codec
->spec
;
2468 for (i
= 0; i
< spec
->autocfg
.line_outs
; i
++) {
2469 hda_nid_t nid
= spec
->autocfg
.line_out_pins
[i
];
2470 ad1988_auto_set_output_and_unmute(codec
, nid
, PIN_OUT
, i
);
2474 static void ad1988_auto_init_extra_out(struct hda_codec
*codec
)
2476 struct ad198x_spec
*spec
= codec
->spec
;
2479 pin
= spec
->autocfg
.speaker_pins
[0];
2480 if (pin
) /* connect to front */
2481 ad1988_auto_set_output_and_unmute(codec
, pin
, PIN_OUT
, 0);
2482 pin
= spec
->autocfg
.hp_pin
;
2483 if (pin
) /* connect to front */
2484 ad1988_auto_set_output_and_unmute(codec
, pin
, PIN_HP
, 0);
2487 static void ad1988_auto_init_analog_input(struct hda_codec
*codec
)
2489 struct ad198x_spec
*spec
= codec
->spec
;
2492 for (i
= 0; i
< AUTO_PIN_LAST
; i
++) {
2493 hda_nid_t nid
= spec
->autocfg
.input_pins
[i
];
2497 case 0x15: /* port-C */
2498 snd_hda_codec_write(codec
, 0x33, 0, AC_VERB_SET_CONNECT_SEL
, 0x0);
2500 case 0x17: /* port-E */
2501 snd_hda_codec_write(codec
, 0x34, 0, AC_VERB_SET_CONNECT_SEL
, 0x0);
2504 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2505 i
<= AUTO_PIN_FRONT_MIC
? PIN_VREF80
: PIN_IN
);
2506 if (nid
!= AD1988_PIN_CD_NID
)
2507 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
2509 idx
= ad1988_pin_idx(nid
);
2510 if (ad1988_boost_nids
[idx
])
2511 snd_hda_codec_write(codec
, ad1988_boost_nids
[idx
], 0,
2512 AC_VERB_SET_AMP_GAIN_MUTE
,
2517 /* parse the BIOS configuration and set up the alc_spec */
2518 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2519 static int ad1988_parse_auto_config(struct hda_codec
*codec
)
2521 struct ad198x_spec
*spec
= codec
->spec
;
2524 if ((err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
)) < 0)
2526 if ((err
= ad1988_auto_fill_dac_nids(codec
, &spec
->autocfg
)) < 0)
2528 if (! spec
->autocfg
.line_outs
)
2529 return 0; /* can't find valid BIOS pin config */
2530 if ((err
= ad1988_auto_create_multi_out_ctls(spec
, &spec
->autocfg
)) < 0 ||
2531 (err
= ad1988_auto_create_extra_out(codec
,
2532 spec
->autocfg
.speaker_pins
[0],
2534 (err
= ad1988_auto_create_extra_out(codec
, spec
->autocfg
.hp_pin
,
2535 "Headphone")) < 0 ||
2536 (err
= ad1988_auto_create_analog_input_ctls(spec
, &spec
->autocfg
)) < 0)
2539 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
2541 if (spec
->autocfg
.dig_out_pin
)
2542 spec
->multiout
.dig_out_nid
= AD1988_SPDIF_OUT
;
2543 if (spec
->autocfg
.dig_in_pin
)
2544 spec
->dig_in_nid
= AD1988_SPDIF_IN
;
2546 if (spec
->kctl_alloc
)
2547 spec
->mixers
[spec
->num_mixers
++] = spec
->kctl_alloc
;
2549 spec
->init_verbs
[spec
->num_init_verbs
++] = ad1988_6stack_init_verbs
;
2551 spec
->input_mux
= &spec
->private_imux
;
2556 /* init callback for auto-configuration model -- overriding the default init */
2557 static int ad1988_auto_init(struct hda_codec
*codec
)
2560 ad1988_auto_init_multi_out(codec
);
2561 ad1988_auto_init_extra_out(codec
);
2562 ad1988_auto_init_analog_input(codec
);
2570 static struct hda_board_config ad1988_cfg_tbl
[] = {
2571 { .modelname
= "6stack", .config
= AD1988_6STACK
},
2572 { .modelname
= "6stack-dig", .config
= AD1988_6STACK_DIG
},
2573 { .modelname
= "3stack", .config
= AD1988_3STACK
},
2574 { .modelname
= "3stack-dig", .config
= AD1988_3STACK_DIG
},
2575 { .modelname
= "laptop", .config
= AD1988_LAPTOP
},
2576 { .modelname
= "laptop-dig", .config
= AD1988_LAPTOP_DIG
},
2577 { .modelname
= "auto", .config
= AD1988_AUTO
},
2581 static int patch_ad1988(struct hda_codec
*codec
)
2583 struct ad198x_spec
*spec
;
2586 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
2590 mutex_init(&spec
->amp_mutex
);
2594 snd_printk(KERN_INFO
"patch_analog: AD1988A rev.2 is detected, enable workarounds\n");
2596 board_config
= snd_hda_check_board_config(codec
, ad1988_cfg_tbl
);
2597 if (board_config
< 0 || board_config
>= AD1988_MODEL_LAST
) {
2598 printk(KERN_INFO
"hda_codec: Unknown model for AD1988, trying auto-probe from BIOS...\n");
2599 board_config
= AD1988_AUTO
;
2602 if (board_config
== AD1988_AUTO
) {
2603 /* automatic parse from the BIOS config */
2604 int err
= ad1988_parse_auto_config(codec
);
2609 printk(KERN_INFO
"hda_codec: Cannot set up configuration from BIOS. Using 6-stack mode...\n");
2610 board_config
= AD1988_6STACK
;
2614 switch (board_config
) {
2616 case AD1988_6STACK_DIG
:
2617 spec
->multiout
.max_channels
= 8;
2618 spec
->multiout
.num_dacs
= 4;
2620 spec
->multiout
.dac_nids
= ad1988_6stack_dac_nids_rev2
;
2622 spec
->multiout
.dac_nids
= ad1988_6stack_dac_nids
;
2623 spec
->input_mux
= &ad1988_6stack_capture_source
;
2624 spec
->num_mixers
= 2;
2626 spec
->mixers
[0] = ad1988_6stack_mixers1_rev2
;
2628 spec
->mixers
[0] = ad1988_6stack_mixers1
;
2629 spec
->mixers
[1] = ad1988_6stack_mixers2
;
2630 spec
->num_init_verbs
= 1;
2631 spec
->init_verbs
[0] = ad1988_6stack_init_verbs
;
2632 if (board_config
== AD1988_6STACK_DIG
) {
2633 spec
->multiout
.dig_out_nid
= AD1988_SPDIF_OUT
;
2634 spec
->dig_in_nid
= AD1988_SPDIF_IN
;
2638 case AD1988_3STACK_DIG
:
2639 spec
->multiout
.max_channels
= 6;
2640 spec
->multiout
.num_dacs
= 3;
2642 spec
->multiout
.dac_nids
= ad1988_3stack_dac_nids_rev2
;
2644 spec
->multiout
.dac_nids
= ad1988_3stack_dac_nids
;
2645 spec
->input_mux
= &ad1988_6stack_capture_source
;
2646 spec
->channel_mode
= ad1988_3stack_modes
;
2647 spec
->num_channel_mode
= ARRAY_SIZE(ad1988_3stack_modes
);
2648 spec
->num_mixers
= 2;
2650 spec
->mixers
[0] = ad1988_3stack_mixers1_rev2
;
2652 spec
->mixers
[0] = ad1988_3stack_mixers1
;
2653 spec
->mixers
[1] = ad1988_3stack_mixers2
;
2654 spec
->num_init_verbs
= 1;
2655 spec
->init_verbs
[0] = ad1988_3stack_init_verbs
;
2656 if (board_config
== AD1988_3STACK_DIG
)
2657 spec
->multiout
.dig_out_nid
= AD1988_SPDIF_OUT
;
2660 case AD1988_LAPTOP_DIG
:
2661 spec
->multiout
.max_channels
= 2;
2662 spec
->multiout
.num_dacs
= 1;
2663 spec
->multiout
.dac_nids
= ad1988_3stack_dac_nids
;
2664 spec
->input_mux
= &ad1988_laptop_capture_source
;
2665 spec
->num_mixers
= 1;
2666 spec
->mixers
[0] = ad1988_laptop_mixers
;
2667 spec
->num_init_verbs
= 1;
2668 spec
->init_verbs
[0] = ad1988_laptop_init_verbs
;
2669 if (board_config
== AD1988_LAPTOP_DIG
)
2670 spec
->multiout
.dig_out_nid
= AD1988_SPDIF_OUT
;
2674 spec
->num_adc_nids
= ARRAY_SIZE(ad1988_adc_nids
);
2675 spec
->adc_nids
= ad1988_adc_nids
;
2676 spec
->capsrc_nids
= ad1988_capsrc_nids
;
2677 spec
->mixers
[spec
->num_mixers
++] = ad1988_capture_mixers
;
2678 spec
->init_verbs
[spec
->num_init_verbs
++] = ad1988_capture_init_verbs
;
2679 if (spec
->multiout
.dig_out_nid
) {
2680 spec
->mixers
[spec
->num_mixers
++] = ad1988_spdif_out_mixers
;
2681 spec
->init_verbs
[spec
->num_init_verbs
++] = ad1988_spdif_init_verbs
;
2683 if (spec
->dig_in_nid
)
2684 spec
->mixers
[spec
->num_mixers
++] = ad1988_spdif_in_mixers
;
2686 codec
->patch_ops
= ad198x_patch_ops
;
2687 switch (board_config
) {
2689 codec
->patch_ops
.init
= ad1988_auto_init
;
2692 case AD1988_LAPTOP_DIG
:
2693 codec
->patch_ops
.unsol_event
= ad1988_laptop_unsol_event
;
2704 struct hda_codec_preset snd_hda_preset_analog
[] = {
2705 { .id
= 0x11d41981, .name
= "AD1981", .patch
= patch_ad1981
},
2706 { .id
= 0x11d41983, .name
= "AD1983", .patch
= patch_ad1983
},
2707 { .id
= 0x11d41986, .name
= "AD1986A", .patch
= patch_ad1986a
},
2708 { .id
= 0x11d41988, .name
= "AD1988", .patch
= patch_ad1988
},
2709 { .id
= 0x11d4198b, .name
= "AD1988B", .patch
= patch_ad1988
},