2 * HD audio interface patch for AD1882, AD1884, AD1981HD, AD1983, AD1984,
5 * Copyright (c) 2005-2007 Takashi Iwai <tiwai@suse.de>
7 * This driver is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This driver is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <linux/init.h>
23 #include <linux/delay.h>
24 #include <linux/slab.h>
25 #include <linux/pci.h>
26 #include <linux/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
[3]; /* 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
[AUTO_CFG_MAX_OUTS
];
76 unsigned int jack_present
:1;
78 #ifdef CONFIG_SND_HDA_POWER_SAVE
79 struct hda_loopback_check loopback
;
81 /* for virtual master */
82 hda_nid_t vmaster_nid
;
84 const char **slave_vols
;
85 const char **slave_sws
;
89 * input MUX handling (common part)
91 static int ad198x_mux_enum_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
93 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
94 struct ad198x_spec
*spec
= codec
->spec
;
96 return snd_hda_input_mux_info(spec
->input_mux
, uinfo
);
99 static int ad198x_mux_enum_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
101 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
102 struct ad198x_spec
*spec
= codec
->spec
;
103 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
105 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
109 static int ad198x_mux_enum_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
111 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
112 struct ad198x_spec
*spec
= codec
->spec
;
113 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
115 return snd_hda_input_mux_put(codec
, spec
->input_mux
, ucontrol
,
116 spec
->capsrc_nids
[adc_idx
],
117 &spec
->cur_mux
[adc_idx
]);
121 * initialization (common callbacks)
123 static int ad198x_init(struct hda_codec
*codec
)
125 struct ad198x_spec
*spec
= codec
->spec
;
128 for (i
= 0; i
< spec
->num_init_verbs
; i
++)
129 snd_hda_sequence_write(codec
, spec
->init_verbs
[i
]);
133 static const char *ad_slave_vols
[] = {
134 "Front Playback Volume",
135 "Surround Playback Volume",
136 "Center Playback Volume",
137 "LFE Playback Volume",
138 "Side Playback Volume",
139 "Headphone Playback Volume",
140 "Mono Playback Volume",
141 "Speaker Playback Volume",
142 "IEC958 Playback Volume",
146 static const char *ad_slave_sws
[] = {
147 "Front Playback Switch",
148 "Surround Playback Switch",
149 "Center Playback Switch",
150 "LFE Playback Switch",
151 "Side Playback Switch",
152 "Headphone Playback Switch",
153 "Mono Playback Switch",
154 "Speaker Playback Switch",
155 "IEC958 Playback Switch",
159 static int ad198x_build_controls(struct hda_codec
*codec
)
161 struct ad198x_spec
*spec
= codec
->spec
;
165 for (i
= 0; i
< spec
->num_mixers
; i
++) {
166 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
170 if (spec
->multiout
.dig_out_nid
) {
171 err
= snd_hda_create_spdif_out_ctls(codec
, spec
->multiout
.dig_out_nid
);
175 if (spec
->dig_in_nid
) {
176 err
= snd_hda_create_spdif_in_ctls(codec
, spec
->dig_in_nid
);
181 /* if we have no master control, let's create it */
182 if (!snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
183 snd_hda_set_vmaster_tlv(codec
, spec
->vmaster_nid
,
184 HDA_OUTPUT
, spec
->vmaster_tlv
);
185 err
= snd_hda_add_vmaster(codec
, "Master Playback Volume",
188 spec
->slave_vols
: ad_slave_vols
));
192 if (!snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
193 err
= snd_hda_add_vmaster(codec
, "Master Playback Switch",
196 spec
->slave_sws
: ad_slave_sws
));
204 #ifdef CONFIG_SND_HDA_POWER_SAVE
205 static int ad198x_check_power_status(struct hda_codec
*codec
, hda_nid_t nid
)
207 struct ad198x_spec
*spec
= codec
->spec
;
208 return snd_hda_check_amp_list_power(codec
, &spec
->loopback
, nid
);
213 * Analog playback callbacks
215 static int ad198x_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
216 struct hda_codec
*codec
,
217 struct snd_pcm_substream
*substream
)
219 struct ad198x_spec
*spec
= codec
->spec
;
220 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
);
223 static int ad198x_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
224 struct hda_codec
*codec
,
225 unsigned int stream_tag
,
227 struct snd_pcm_substream
*substream
)
229 struct ad198x_spec
*spec
= codec
->spec
;
230 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
, stream_tag
,
234 static int ad198x_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
235 struct hda_codec
*codec
,
236 struct snd_pcm_substream
*substream
)
238 struct ad198x_spec
*spec
= codec
->spec
;
239 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
245 static int ad198x_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
246 struct hda_codec
*codec
,
247 struct snd_pcm_substream
*substream
)
249 struct ad198x_spec
*spec
= codec
->spec
;
250 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
253 static int ad198x_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
254 struct hda_codec
*codec
,
255 struct snd_pcm_substream
*substream
)
257 struct ad198x_spec
*spec
= codec
->spec
;
258 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
261 static int ad198x_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
262 struct hda_codec
*codec
,
263 unsigned int stream_tag
,
265 struct snd_pcm_substream
*substream
)
267 struct ad198x_spec
*spec
= codec
->spec
;
268 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
, stream_tag
,
275 static int ad198x_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
276 struct hda_codec
*codec
,
277 unsigned int stream_tag
,
279 struct snd_pcm_substream
*substream
)
281 struct ad198x_spec
*spec
= codec
->spec
;
282 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
],
283 stream_tag
, 0, format
);
287 static int ad198x_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
288 struct hda_codec
*codec
,
289 struct snd_pcm_substream
*substream
)
291 struct ad198x_spec
*spec
= codec
->spec
;
292 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
],
300 static struct hda_pcm_stream ad198x_pcm_analog_playback
= {
303 .channels_max
= 6, /* changed later */
304 .nid
= 0, /* fill later */
306 .open
= ad198x_playback_pcm_open
,
307 .prepare
= ad198x_playback_pcm_prepare
,
308 .cleanup
= ad198x_playback_pcm_cleanup
312 static struct hda_pcm_stream ad198x_pcm_analog_capture
= {
316 .nid
= 0, /* fill later */
318 .prepare
= ad198x_capture_pcm_prepare
,
319 .cleanup
= ad198x_capture_pcm_cleanup
323 static struct hda_pcm_stream ad198x_pcm_digital_playback
= {
327 .nid
= 0, /* fill later */
329 .open
= ad198x_dig_playback_pcm_open
,
330 .close
= ad198x_dig_playback_pcm_close
,
331 .prepare
= ad198x_dig_playback_pcm_prepare
335 static struct hda_pcm_stream ad198x_pcm_digital_capture
= {
339 /* NID is set in alc_build_pcms */
342 static int ad198x_build_pcms(struct hda_codec
*codec
)
344 struct ad198x_spec
*spec
= codec
->spec
;
345 struct hda_pcm
*info
= spec
->pcm_rec
;
348 codec
->pcm_info
= info
;
350 info
->name
= "AD198x Analog";
351 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = ad198x_pcm_analog_playback
;
352 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
= spec
->multiout
.max_channels
;
353 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dac_nids
[0];
354 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = ad198x_pcm_analog_capture
;
355 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
= spec
->num_adc_nids
;
356 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
358 if (spec
->multiout
.dig_out_nid
) {
361 info
->name
= "AD198x Digital";
362 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = ad198x_pcm_digital_playback
;
363 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dig_out_nid
;
364 if (spec
->dig_in_nid
) {
365 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = ad198x_pcm_digital_capture
;
366 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->dig_in_nid
;
373 static void ad198x_free(struct hda_codec
*codec
)
375 struct ad198x_spec
*spec
= codec
->spec
;
378 if (spec
->kctl_alloc
) {
379 for (i
= 0; i
< spec
->num_kctl_used
; i
++)
380 kfree(spec
->kctl_alloc
[i
].name
);
381 kfree(spec
->kctl_alloc
);
386 static struct hda_codec_ops ad198x_patch_ops
= {
387 .build_controls
= ad198x_build_controls
,
388 .build_pcms
= ad198x_build_pcms
,
391 #ifdef CONFIG_SND_HDA_POWER_SAVE
392 .check_power_status
= ad198x_check_power_status
,
399 * the private value = nid | (invert << 8)
401 #define ad198x_eapd_info snd_ctl_boolean_mono_info
403 static int ad198x_eapd_get(struct snd_kcontrol
*kcontrol
,
404 struct snd_ctl_elem_value
*ucontrol
)
406 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
407 struct ad198x_spec
*spec
= codec
->spec
;
408 int invert
= (kcontrol
->private_value
>> 8) & 1;
410 ucontrol
->value
.integer
.value
[0] = ! spec
->cur_eapd
;
412 ucontrol
->value
.integer
.value
[0] = spec
->cur_eapd
;
416 static int ad198x_eapd_put(struct snd_kcontrol
*kcontrol
,
417 struct snd_ctl_elem_value
*ucontrol
)
419 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
420 struct ad198x_spec
*spec
= codec
->spec
;
421 int invert
= (kcontrol
->private_value
>> 8) & 1;
422 hda_nid_t nid
= kcontrol
->private_value
& 0xff;
424 eapd
= !!ucontrol
->value
.integer
.value
[0];
427 if (eapd
== spec
->cur_eapd
)
429 spec
->cur_eapd
= eapd
;
430 snd_hda_codec_write_cache(codec
, nid
,
431 0, AC_VERB_SET_EAPD_BTLENABLE
,
436 static int ad198x_ch_mode_info(struct snd_kcontrol
*kcontrol
,
437 struct snd_ctl_elem_info
*uinfo
);
438 static int ad198x_ch_mode_get(struct snd_kcontrol
*kcontrol
,
439 struct snd_ctl_elem_value
*ucontrol
);
440 static int ad198x_ch_mode_put(struct snd_kcontrol
*kcontrol
,
441 struct snd_ctl_elem_value
*ucontrol
);
448 #define AD1986A_SPDIF_OUT 0x02
449 #define AD1986A_FRONT_DAC 0x03
450 #define AD1986A_SURR_DAC 0x04
451 #define AD1986A_CLFE_DAC 0x05
452 #define AD1986A_ADC 0x06
454 static hda_nid_t ad1986a_dac_nids
[3] = {
455 AD1986A_FRONT_DAC
, AD1986A_SURR_DAC
, AD1986A_CLFE_DAC
457 static hda_nid_t ad1986a_adc_nids
[1] = { AD1986A_ADC
};
458 static hda_nid_t ad1986a_capsrc_nids
[1] = { 0x12 };
460 static struct hda_input_mux ad1986a_capture_source
= {
474 static struct hda_bind_ctls ad1986a_bind_pcm_vol
= {
475 .ops
= &snd_hda_bind_vol
,
477 HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC
, 3, 0, HDA_OUTPUT
),
478 HDA_COMPOSE_AMP_VAL(AD1986A_SURR_DAC
, 3, 0, HDA_OUTPUT
),
479 HDA_COMPOSE_AMP_VAL(AD1986A_CLFE_DAC
, 3, 0, HDA_OUTPUT
),
484 static struct hda_bind_ctls ad1986a_bind_pcm_sw
= {
485 .ops
= &snd_hda_bind_sw
,
487 HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC
, 3, 0, HDA_OUTPUT
),
488 HDA_COMPOSE_AMP_VAL(AD1986A_SURR_DAC
, 3, 0, HDA_OUTPUT
),
489 HDA_COMPOSE_AMP_VAL(AD1986A_CLFE_DAC
, 3, 0, HDA_OUTPUT
),
497 static struct snd_kcontrol_new ad1986a_mixers
[] = {
499 * bind volumes/mutes of 3 DACs as a single PCM control for simplicity
501 HDA_BIND_VOL("PCM Playback Volume", &ad1986a_bind_pcm_vol
),
502 HDA_BIND_SW("PCM Playback Switch", &ad1986a_bind_pcm_sw
),
503 HDA_CODEC_VOLUME("Front Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
504 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT
),
505 HDA_CODEC_VOLUME("Surround Playback Volume", 0x1c, 0x0, HDA_OUTPUT
),
506 HDA_CODEC_MUTE("Surround Playback Switch", 0x1c, 0x0, HDA_OUTPUT
),
507 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x1d, 1, 0x0, HDA_OUTPUT
),
508 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x1d, 2, 0x0, HDA_OUTPUT
),
509 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x1d, 1, 0x0, HDA_OUTPUT
),
510 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x1d, 2, 0x0, HDA_OUTPUT
),
511 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT
),
512 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT
),
513 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT
),
514 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT
),
515 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT
),
516 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT
),
517 HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT
),
518 HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT
),
519 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
520 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
521 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT
),
522 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT
),
523 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT
),
524 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT
),
525 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT
),
526 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT
),
527 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT
),
529 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
530 .name
= "Capture Source",
531 .info
= ad198x_mux_enum_info
,
532 .get
= ad198x_mux_enum_get
,
533 .put
= ad198x_mux_enum_put
,
535 HDA_CODEC_MUTE("Stereo Downmix Switch", 0x09, 0x0, HDA_OUTPUT
),
539 /* additional mixers for 3stack mode */
540 static struct snd_kcontrol_new ad1986a_3st_mixers
[] = {
542 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
543 .name
= "Channel Mode",
544 .info
= ad198x_ch_mode_info
,
545 .get
= ad198x_ch_mode_get
,
546 .put
= ad198x_ch_mode_put
,
551 /* laptop model - 2ch only */
552 static hda_nid_t ad1986a_laptop_dac_nids
[1] = { AD1986A_FRONT_DAC
};
554 /* master controls both pins 0x1a and 0x1b */
555 static struct hda_bind_ctls ad1986a_laptop_master_vol
= {
556 .ops
= &snd_hda_bind_vol
,
558 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT
),
559 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT
),
564 static struct hda_bind_ctls ad1986a_laptop_master_sw
= {
565 .ops
= &snd_hda_bind_sw
,
567 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT
),
568 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT
),
573 static struct snd_kcontrol_new ad1986a_laptop_mixers
[] = {
574 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT
),
575 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT
),
576 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol
),
577 HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw
),
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("Mic Boost", 0x0f, 0x0, HDA_OUTPUT
),
587 /* HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT),
588 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT),
589 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
590 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), */
591 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT
),
592 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT
),
594 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
595 .name
= "Capture Source",
596 .info
= ad198x_mux_enum_info
,
597 .get
= ad198x_mux_enum_get
,
598 .put
= ad198x_mux_enum_put
,
603 /* laptop-eapd model - 2ch only */
605 static struct hda_input_mux ad1986a_laptop_eapd_capture_source
= {
609 { "Internal Mic", 0x4 },
614 static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers
[] = {
615 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol
),
616 HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw
),
617 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT
),
618 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT
),
619 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x0, HDA_OUTPUT
),
620 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x0, HDA_OUTPUT
),
621 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
622 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
623 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT
),
624 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT
),
625 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT
),
627 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
628 .name
= "Capture Source",
629 .info
= ad198x_mux_enum_info
,
630 .get
= ad198x_mux_enum_get
,
631 .put
= ad198x_mux_enum_put
,
634 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
635 .name
= "External Amplifier",
636 .info
= ad198x_eapd_info
,
637 .get
= ad198x_eapd_get
,
638 .put
= ad198x_eapd_put
,
639 .private_value
= 0x1b | (1 << 8), /* port-D, inversed */
644 /* laptop-automute - 2ch only */
646 static void ad1986a_update_hp(struct hda_codec
*codec
)
648 struct ad198x_spec
*spec
= codec
->spec
;
651 if (spec
->jack_present
)
652 mute
= HDA_AMP_MUTE
; /* mute internal speaker */
654 /* unmute internal speaker if necessary */
655 mute
= snd_hda_codec_amp_read(codec
, 0x1a, 0, HDA_OUTPUT
, 0);
656 snd_hda_codec_amp_stereo(codec
, 0x1b, HDA_OUTPUT
, 0,
660 static void ad1986a_hp_automute(struct hda_codec
*codec
)
662 struct ad198x_spec
*spec
= codec
->spec
;
663 unsigned int present
;
665 present
= snd_hda_codec_read(codec
, 0x1a, 0, AC_VERB_GET_PIN_SENSE
, 0);
666 /* Lenovo N100 seems to report the reversed bit for HP jack-sensing */
667 spec
->jack_present
= !(present
& 0x80000000);
668 ad1986a_update_hp(codec
);
671 #define AD1986A_HP_EVENT 0x37
673 static void ad1986a_hp_unsol_event(struct hda_codec
*codec
, unsigned int res
)
675 if ((res
>> 26) != AD1986A_HP_EVENT
)
677 ad1986a_hp_automute(codec
);
680 static int ad1986a_hp_init(struct hda_codec
*codec
)
683 ad1986a_hp_automute(codec
);
687 /* bind hp and internal speaker mute (with plug check) */
688 static int ad1986a_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
689 struct snd_ctl_elem_value
*ucontrol
)
691 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
692 long *valp
= ucontrol
->value
.integer
.value
;
695 change
= snd_hda_codec_amp_update(codec
, 0x1a, 0, HDA_OUTPUT
, 0,
697 valp
[0] ? 0 : HDA_AMP_MUTE
);
698 change
|= snd_hda_codec_amp_update(codec
, 0x1a, 1, HDA_OUTPUT
, 0,
700 valp
[1] ? 0 : HDA_AMP_MUTE
);
702 ad1986a_update_hp(codec
);
706 static struct snd_kcontrol_new ad1986a_laptop_automute_mixers
[] = {
707 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol
),
709 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
710 .name
= "Master Playback Switch",
711 .info
= snd_hda_mixer_amp_switch_info
,
712 .get
= snd_hda_mixer_amp_switch_get
,
713 .put
= ad1986a_hp_master_sw_put
,
714 .private_value
= HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT
),
716 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT
),
717 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT
),
718 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x0, HDA_OUTPUT
),
719 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x0, HDA_OUTPUT
),
720 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
721 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
722 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT
),
723 HDA_CODEC_VOLUME("Beep Playback Volume", 0x18, 0x0, HDA_OUTPUT
),
724 HDA_CODEC_MUTE("Beep Playback Switch", 0x18, 0x0, HDA_OUTPUT
),
725 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT
),
726 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT
),
728 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
729 .name
= "Capture Source",
730 .info
= ad198x_mux_enum_info
,
731 .get
= ad198x_mux_enum_get
,
732 .put
= ad198x_mux_enum_put
,
735 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
736 .name
= "External Amplifier",
737 .info
= ad198x_eapd_info
,
738 .get
= ad198x_eapd_get
,
739 .put
= ad198x_eapd_put
,
740 .private_value
= 0x1b | (1 << 8), /* port-D, inversed */
746 * initialization verbs
748 static struct hda_verb ad1986a_init_verbs
[] = {
749 /* Front, Surround, CLFE DAC; mute as default */
750 {0x03, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
751 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
752 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
754 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
755 /* HP, Line-Out, Surround, CLFE selectors */
756 {0x0a, AC_VERB_SET_CONNECT_SEL
, 0x0},
757 {0x0b, AC_VERB_SET_CONNECT_SEL
, 0x0},
758 {0x0c, AC_VERB_SET_CONNECT_SEL
, 0x0},
759 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x0},
761 {0x0e, AC_VERB_SET_CONNECT_SEL
, 0x0},
762 /* Mic selector: Mic 1/2 pin */
763 {0x0f, AC_VERB_SET_CONNECT_SEL
, 0x0},
764 /* Line-in selector: Line-in */
765 {0x10, AC_VERB_SET_CONNECT_SEL
, 0x0},
767 {0x11, AC_VERB_SET_CONNECT_SEL
, 0x0},
768 /* Record selector: mic */
769 {0x12, AC_VERB_SET_CONNECT_SEL
, 0x0},
770 /* Mic, Phone, CD, Aux, Line-In amp; mute as default */
771 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
772 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
773 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
774 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
775 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
777 {0x18, AC_VERB_SET_CONNECT_SEL
, 0x0},
778 /* HP, Line-Out, Surround, CLFE, Mono pins; mute as default */
779 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
780 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
781 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
782 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
783 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
785 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0xc0 },
786 /* Front, Surround, CLFE Pins */
787 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
788 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
789 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
791 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
793 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24 },
794 /* Line, Aux, CD, Beep-In Pin */
795 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
796 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
797 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
798 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
799 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
803 static struct hda_verb ad1986a_ch2_init
[] = {
804 /* Surround out -> Line In */
805 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
806 /* Line-in selectors */
807 { 0x10, AC_VERB_SET_CONNECT_SEL
, 0x1 },
809 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
810 /* Mic selector, mix C/LFE (backmic) and Mic (frontmic) */
811 { 0x0f, AC_VERB_SET_CONNECT_SEL
, 0x4 },
815 static struct hda_verb ad1986a_ch4_init
[] = {
816 /* Surround out -> Surround */
817 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
818 { 0x10, AC_VERB_SET_CONNECT_SEL
, 0x0 },
820 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
821 { 0x0f, AC_VERB_SET_CONNECT_SEL
, 0x4 },
825 static struct hda_verb ad1986a_ch6_init
[] = {
826 /* Surround out -> Surround out */
827 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
828 { 0x10, AC_VERB_SET_CONNECT_SEL
, 0x0 },
830 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
831 { 0x0f, AC_VERB_SET_CONNECT_SEL
, 0x0 },
835 static struct hda_channel_mode ad1986a_modes
[3] = {
836 { 2, ad1986a_ch2_init
},
837 { 4, ad1986a_ch4_init
},
838 { 6, ad1986a_ch6_init
},
841 /* eapd initialization */
842 static struct hda_verb ad1986a_eapd_init_verbs
[] = {
843 {0x1b, AC_VERB_SET_EAPD_BTLENABLE
, 0x00 },
847 /* Ultra initialization */
848 static struct hda_verb ad1986a_ultra_init
[] = {
849 /* eapd initialization */
850 { 0x1b, AC_VERB_SET_EAPD_BTLENABLE
, 0x00 },
852 { 0x0f, AC_VERB_SET_CONNECT_SEL
, 0x2 },
853 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24 },
854 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080 },
858 /* pin sensing on HP jack */
859 static struct hda_verb ad1986a_hp_init_verbs
[] = {
860 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1986A_HP_EVENT
},
871 AD1986A_LAPTOP_AUTOMUTE
,
876 static const char *ad1986a_models
[AD1986A_MODELS
] = {
877 [AD1986A_6STACK
] = "6stack",
878 [AD1986A_3STACK
] = "3stack",
879 [AD1986A_LAPTOP
] = "laptop",
880 [AD1986A_LAPTOP_EAPD
] = "laptop-eapd",
881 [AD1986A_LAPTOP_AUTOMUTE
] = "laptop-automute",
882 [AD1986A_ULTRA
] = "ultra",
885 static struct snd_pci_quirk ad1986a_cfg_tbl
[] = {
886 SND_PCI_QUIRK(0x103c, 0x30af, "HP B2800", AD1986A_LAPTOP_EAPD
),
887 SND_PCI_QUIRK(0x1043, 0x1153, "ASUS M9", AD1986A_LAPTOP_EAPD
),
888 SND_PCI_QUIRK(0x1043, 0x11f7, "ASUS U5A", AD1986A_LAPTOP_EAPD
),
889 SND_PCI_QUIRK(0x1043, 0x1213, "ASUS A6J", AD1986A_LAPTOP_EAPD
),
890 SND_PCI_QUIRK(0x1043, 0x1263, "ASUS U5F", AD1986A_LAPTOP_EAPD
),
891 SND_PCI_QUIRK(0x1043, 0x1297, "ASUS Z62F", AD1986A_LAPTOP_EAPD
),
892 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS V1j", AD1986A_LAPTOP_EAPD
),
893 SND_PCI_QUIRK(0x1043, 0x1302, "ASUS W3j", AD1986A_LAPTOP_EAPD
),
894 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS VX1", AD1986A_LAPTOP
),
895 SND_PCI_QUIRK(0x1043, 0x1447, "ASUS A8J", AD1986A_3STACK
),
896 SND_PCI_QUIRK(0x1043, 0x817f, "ASUS P5", AD1986A_3STACK
),
897 SND_PCI_QUIRK(0x1043, 0x818f, "ASUS P5", AD1986A_LAPTOP
),
898 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS P5", AD1986A_3STACK
),
899 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS M2N", AD1986A_3STACK
),
900 SND_PCI_QUIRK(0x1043, 0x8234, "ASUS M2N", AD1986A_3STACK
),
901 SND_PCI_QUIRK(0x10de, 0xcb84, "ASUS A8N-VM", AD1986A_3STACK
),
902 SND_PCI_QUIRK(0x1179, 0xff40, "Toshiba", AD1986A_LAPTOP_EAPD
),
903 SND_PCI_QUIRK(0x144d, 0xb03c, "Samsung R55", AD1986A_3STACK
),
904 SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP
),
905 SND_PCI_QUIRK(0x144d, 0xc023, "Samsung X60", AD1986A_LAPTOP_EAPD
),
906 SND_PCI_QUIRK(0x144d, 0xc024, "Samsung R65", AD1986A_LAPTOP_EAPD
),
907 SND_PCI_QUIRK(0x144d, 0xc026, "Samsung X11", AD1986A_LAPTOP_EAPD
),
908 SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_ULTRA
),
909 SND_PCI_QUIRK(0x144d, 0xc504, "Samsung Q35", AD1986A_3STACK
),
910 SND_PCI_QUIRK(0x17aa, 0x1011, "Lenovo M55", AD1986A_LAPTOP
),
911 SND_PCI_QUIRK(0x17aa, 0x1017, "Lenovo A60", AD1986A_3STACK
),
912 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo N100", AD1986A_LAPTOP_AUTOMUTE
),
913 SND_PCI_QUIRK(0x17c0, 0x2017, "Samsung M50", AD1986A_LAPTOP
),
917 #ifdef CONFIG_SND_HDA_POWER_SAVE
918 static struct hda_amp_list ad1986a_loopbacks
[] = {
919 { 0x13, HDA_OUTPUT
, 0 }, /* Mic */
920 { 0x14, HDA_OUTPUT
, 0 }, /* Phone */
921 { 0x15, HDA_OUTPUT
, 0 }, /* CD */
922 { 0x16, HDA_OUTPUT
, 0 }, /* Aux */
923 { 0x17, HDA_OUTPUT
, 0 }, /* Line */
928 static int is_jack_available(struct hda_codec
*codec
, hda_nid_t nid
)
930 unsigned int conf
= snd_hda_codec_read(codec
, nid
, 0,
931 AC_VERB_GET_CONFIG_DEFAULT
, 0);
932 return get_defcfg_connect(conf
) != AC_JACK_PORT_NONE
;
935 static int patch_ad1986a(struct hda_codec
*codec
)
937 struct ad198x_spec
*spec
;
940 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
946 spec
->multiout
.max_channels
= 6;
947 spec
->multiout
.num_dacs
= ARRAY_SIZE(ad1986a_dac_nids
);
948 spec
->multiout
.dac_nids
= ad1986a_dac_nids
;
949 spec
->multiout
.dig_out_nid
= AD1986A_SPDIF_OUT
;
950 spec
->num_adc_nids
= 1;
951 spec
->adc_nids
= ad1986a_adc_nids
;
952 spec
->capsrc_nids
= ad1986a_capsrc_nids
;
953 spec
->input_mux
= &ad1986a_capture_source
;
954 spec
->num_mixers
= 1;
955 spec
->mixers
[0] = ad1986a_mixers
;
956 spec
->num_init_verbs
= 1;
957 spec
->init_verbs
[0] = ad1986a_init_verbs
;
958 #ifdef CONFIG_SND_HDA_POWER_SAVE
959 spec
->loopback
.amplist
= ad1986a_loopbacks
;
961 spec
->vmaster_nid
= 0x1b;
963 codec
->patch_ops
= ad198x_patch_ops
;
965 /* override some parameters */
966 board_config
= snd_hda_check_board_config(codec
, AD1986A_MODELS
,
969 switch (board_config
) {
971 spec
->num_mixers
= 2;
972 spec
->mixers
[1] = ad1986a_3st_mixers
;
973 spec
->num_init_verbs
= 2;
974 spec
->init_verbs
[1] = ad1986a_ch2_init
;
975 spec
->channel_mode
= ad1986a_modes
;
976 spec
->num_channel_mode
= ARRAY_SIZE(ad1986a_modes
);
977 spec
->need_dac_fix
= 1;
978 spec
->multiout
.max_channels
= 2;
979 spec
->multiout
.num_dacs
= 1;
982 spec
->mixers
[0] = ad1986a_laptop_mixers
;
983 spec
->multiout
.max_channels
= 2;
984 spec
->multiout
.num_dacs
= 1;
985 spec
->multiout
.dac_nids
= ad1986a_laptop_dac_nids
;
987 case AD1986A_LAPTOP_EAPD
:
988 spec
->mixers
[0] = ad1986a_laptop_eapd_mixers
;
989 spec
->num_init_verbs
= 2;
990 spec
->init_verbs
[1] = ad1986a_eapd_init_verbs
;
991 spec
->multiout
.max_channels
= 2;
992 spec
->multiout
.num_dacs
= 1;
993 spec
->multiout
.dac_nids
= ad1986a_laptop_dac_nids
;
994 if (!is_jack_available(codec
, 0x25))
995 spec
->multiout
.dig_out_nid
= 0;
996 spec
->input_mux
= &ad1986a_laptop_eapd_capture_source
;
998 case AD1986A_LAPTOP_AUTOMUTE
:
999 spec
->mixers
[0] = ad1986a_laptop_automute_mixers
;
1000 spec
->num_init_verbs
= 3;
1001 spec
->init_verbs
[1] = ad1986a_eapd_init_verbs
;
1002 spec
->init_verbs
[2] = ad1986a_hp_init_verbs
;
1003 spec
->multiout
.max_channels
= 2;
1004 spec
->multiout
.num_dacs
= 1;
1005 spec
->multiout
.dac_nids
= ad1986a_laptop_dac_nids
;
1006 if (!is_jack_available(codec
, 0x25))
1007 spec
->multiout
.dig_out_nid
= 0;
1008 spec
->input_mux
= &ad1986a_laptop_eapd_capture_source
;
1009 codec
->patch_ops
.unsol_event
= ad1986a_hp_unsol_event
;
1010 codec
->patch_ops
.init
= ad1986a_hp_init
;
1013 spec
->mixers
[0] = ad1986a_laptop_eapd_mixers
;
1014 spec
->num_init_verbs
= 2;
1015 spec
->init_verbs
[1] = ad1986a_ultra_init
;
1016 spec
->multiout
.max_channels
= 2;
1017 spec
->multiout
.num_dacs
= 1;
1018 spec
->multiout
.dac_nids
= ad1986a_laptop_dac_nids
;
1019 spec
->multiout
.dig_out_nid
= 0;
1023 /* AD1986A has a hardware problem that it can't share a stream
1024 * with multiple output pins. The copy of front to surrounds
1025 * causes noisy or silent outputs at a certain timing, e.g.
1026 * changing the volume.
1027 * So, let's disable the shared stream.
1029 spec
->multiout
.no_share_stream
= 1;
1038 #define AD1983_SPDIF_OUT 0x02
1039 #define AD1983_DAC 0x03
1040 #define AD1983_ADC 0x04
1042 static hda_nid_t ad1983_dac_nids
[1] = { AD1983_DAC
};
1043 static hda_nid_t ad1983_adc_nids
[1] = { AD1983_ADC
};
1044 static hda_nid_t ad1983_capsrc_nids
[1] = { 0x15 };
1046 static struct hda_input_mux ad1983_capture_source
= {
1052 { "Mix Mono", 0x3 },
1057 * SPDIF playback route
1059 static int ad1983_spdif_route_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
1061 static char *texts
[] = { "PCM", "ADC" };
1063 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
1065 uinfo
->value
.enumerated
.items
= 2;
1066 if (uinfo
->value
.enumerated
.item
> 1)
1067 uinfo
->value
.enumerated
.item
= 1;
1068 strcpy(uinfo
->value
.enumerated
.name
, texts
[uinfo
->value
.enumerated
.item
]);
1072 static int ad1983_spdif_route_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
1074 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1075 struct ad198x_spec
*spec
= codec
->spec
;
1077 ucontrol
->value
.enumerated
.item
[0] = spec
->spdif_route
;
1081 static int ad1983_spdif_route_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
1083 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1084 struct ad198x_spec
*spec
= codec
->spec
;
1086 if (ucontrol
->value
.enumerated
.item
[0] > 1)
1088 if (spec
->spdif_route
!= ucontrol
->value
.enumerated
.item
[0]) {
1089 spec
->spdif_route
= ucontrol
->value
.enumerated
.item
[0];
1090 snd_hda_codec_write_cache(codec
, spec
->multiout
.dig_out_nid
, 0,
1091 AC_VERB_SET_CONNECT_SEL
,
1098 static struct snd_kcontrol_new ad1983_mixers
[] = {
1099 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT
),
1100 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT
),
1101 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT
),
1102 HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT
),
1103 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT
),
1104 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT
),
1105 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
1106 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
1107 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
1108 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
1109 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
1110 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
1111 HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x10, 1, 0x0, HDA_OUTPUT
),
1112 HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x10, 1, 0x0, HDA_OUTPUT
),
1113 HDA_CODEC_VOLUME("Mic Boost", 0x0c, 0x0, HDA_OUTPUT
),
1114 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT
),
1115 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT
),
1117 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1118 .name
= "Capture Source",
1119 .info
= ad198x_mux_enum_info
,
1120 .get
= ad198x_mux_enum_get
,
1121 .put
= ad198x_mux_enum_put
,
1124 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1125 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,NONE
) "Source",
1126 .info
= ad1983_spdif_route_info
,
1127 .get
= ad1983_spdif_route_get
,
1128 .put
= ad1983_spdif_route_put
,
1133 static struct hda_verb ad1983_init_verbs
[] = {
1134 /* Front, HP, Mono; mute as default */
1135 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1136 {0x06, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1137 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1138 /* Beep, PCM, Mic, Line-In: mute */
1139 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1140 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1141 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1142 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1143 /* Front, HP selectors; from Mix */
1144 {0x05, AC_VERB_SET_CONNECT_SEL
, 0x01},
1145 {0x06, AC_VERB_SET_CONNECT_SEL
, 0x01},
1146 /* Mono selector; from Mix */
1147 {0x0b, AC_VERB_SET_CONNECT_SEL
, 0x03},
1148 /* Mic selector; Mic */
1149 {0x0c, AC_VERB_SET_CONNECT_SEL
, 0x0},
1150 /* Line-in selector: Line-in */
1151 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x0},
1152 /* Mic boost: 0dB */
1153 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
1154 /* Record selector: mic */
1155 {0x15, AC_VERB_SET_CONNECT_SEL
, 0x0},
1156 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1157 /* SPDIF route: PCM */
1158 {0x02, AC_VERB_SET_CONNECT_SEL
, 0x0},
1160 {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
1162 {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0xc0 },
1164 {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
1166 {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24 },
1168 {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
1172 #ifdef CONFIG_SND_HDA_POWER_SAVE
1173 static struct hda_amp_list ad1983_loopbacks
[] = {
1174 { 0x12, HDA_OUTPUT
, 0 }, /* Mic */
1175 { 0x13, HDA_OUTPUT
, 0 }, /* Line */
1180 static int patch_ad1983(struct hda_codec
*codec
)
1182 struct ad198x_spec
*spec
;
1184 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1190 spec
->multiout
.max_channels
= 2;
1191 spec
->multiout
.num_dacs
= ARRAY_SIZE(ad1983_dac_nids
);
1192 spec
->multiout
.dac_nids
= ad1983_dac_nids
;
1193 spec
->multiout
.dig_out_nid
= AD1983_SPDIF_OUT
;
1194 spec
->num_adc_nids
= 1;
1195 spec
->adc_nids
= ad1983_adc_nids
;
1196 spec
->capsrc_nids
= ad1983_capsrc_nids
;
1197 spec
->input_mux
= &ad1983_capture_source
;
1198 spec
->num_mixers
= 1;
1199 spec
->mixers
[0] = ad1983_mixers
;
1200 spec
->num_init_verbs
= 1;
1201 spec
->init_verbs
[0] = ad1983_init_verbs
;
1202 spec
->spdif_route
= 0;
1203 #ifdef CONFIG_SND_HDA_POWER_SAVE
1204 spec
->loopback
.amplist
= ad1983_loopbacks
;
1206 spec
->vmaster_nid
= 0x05;
1208 codec
->patch_ops
= ad198x_patch_ops
;
1215 * AD1981 HD specific
1218 #define AD1981_SPDIF_OUT 0x02
1219 #define AD1981_DAC 0x03
1220 #define AD1981_ADC 0x04
1222 static hda_nid_t ad1981_dac_nids
[1] = { AD1981_DAC
};
1223 static hda_nid_t ad1981_adc_nids
[1] = { AD1981_ADC
};
1224 static hda_nid_t ad1981_capsrc_nids
[1] = { 0x15 };
1226 /* 0x0c, 0x09, 0x0e, 0x0f, 0x19, 0x05, 0x18, 0x17 */
1227 static struct hda_input_mux ad1981_capture_source
= {
1230 { "Front Mic", 0x0 },
1233 { "Mix Mono", 0x3 },
1240 static struct snd_kcontrol_new ad1981_mixers
[] = {
1241 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT
),
1242 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT
),
1243 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT
),
1244 HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT
),
1245 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT
),
1246 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT
),
1247 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
1248 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
1249 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
1250 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
1251 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
1252 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
1253 HDA_CODEC_VOLUME("Aux Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
1254 HDA_CODEC_MUTE("Aux Playback Switch", 0x1b, 0x0, HDA_OUTPUT
),
1255 HDA_CODEC_VOLUME("Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT
),
1256 HDA_CODEC_MUTE("Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT
),
1257 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
1258 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT
),
1259 HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT
),
1260 HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x0d, 1, 0x0, HDA_OUTPUT
),
1261 HDA_CODEC_VOLUME("Front Mic Boost", 0x08, 0x0, HDA_INPUT
),
1262 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x0, HDA_INPUT
),
1263 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT
),
1264 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT
),
1266 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1267 .name
= "Capture Source",
1268 .info
= ad198x_mux_enum_info
,
1269 .get
= ad198x_mux_enum_get
,
1270 .put
= ad198x_mux_enum_put
,
1272 /* identical with AD1983 */
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 ad1981_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, Front Mic, Line, Rear Mic, Aux, CD-In: mute */
1289 {0x0d, 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 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1294 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1295 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1296 /* Front, HP selectors; from Mix */
1297 {0x05, AC_VERB_SET_CONNECT_SEL
, 0x01},
1298 {0x06, AC_VERB_SET_CONNECT_SEL
, 0x01},
1299 /* Mono selector; from Mix */
1300 {0x0b, AC_VERB_SET_CONNECT_SEL
, 0x03},
1301 /* Mic Mixer; select Front Mic */
1302 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
1303 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1304 /* Mic boost: 0dB */
1305 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
1306 {0x18, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
1307 /* Record selector: Front mic */
1308 {0x15, AC_VERB_SET_CONNECT_SEL
, 0x0},
1309 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1310 /* SPDIF route: PCM */
1311 {0x02, AC_VERB_SET_CONNECT_SEL
, 0x0},
1313 {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
1315 {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0xc0 },
1317 {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x40 },
1318 /* Front & Rear Mic Pins */
1319 {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24 },
1320 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x24 },
1322 {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL
, 0x20 },
1324 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x00},
1325 /* Line-Out as Input: disabled */
1326 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1330 #ifdef CONFIG_SND_HDA_POWER_SAVE
1331 static struct hda_amp_list ad1981_loopbacks
[] = {
1332 { 0x12, HDA_OUTPUT
, 0 }, /* Front Mic */
1333 { 0x13, HDA_OUTPUT
, 0 }, /* Line */
1334 { 0x1b, HDA_OUTPUT
, 0 }, /* Aux */
1335 { 0x1c, HDA_OUTPUT
, 0 }, /* Mic */
1336 { 0x1d, HDA_OUTPUT
, 0 }, /* CD */
1342 * Patch for HP nx6320
1344 * nx6320 uses EAPD in the reverse way - EAPD-on means the internal
1345 * speaker output enabled _and_ mute-LED off.
1348 #define AD1981_HP_EVENT 0x37
1349 #define AD1981_MIC_EVENT 0x38
1351 static struct hda_verb ad1981_hp_init_verbs
[] = {
1352 {0x05, AC_VERB_SET_EAPD_BTLENABLE
, 0x00 }, /* default off */
1353 /* pin sensing on HP and Mic jacks */
1354 {0x06, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1981_HP_EVENT
},
1355 {0x08, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1981_MIC_EVENT
},
1359 /* turn on/off EAPD (+ mute HP) as a master switch */
1360 static int ad1981_hp_master_sw_put(struct snd_kcontrol
*kcontrol
,
1361 struct snd_ctl_elem_value
*ucontrol
)
1363 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1364 struct ad198x_spec
*spec
= codec
->spec
;
1366 if (! ad198x_eapd_put(kcontrol
, ucontrol
))
1369 /* toggle HP mute appropriately */
1370 snd_hda_codec_amp_stereo(codec
, 0x06, HDA_OUTPUT
, 0,
1372 spec
->cur_eapd
? 0 : HDA_AMP_MUTE
);
1376 /* bind volumes of both NID 0x05 and 0x06 */
1377 static struct hda_bind_ctls ad1981_hp_bind_master_vol
= {
1378 .ops
= &snd_hda_bind_vol
,
1380 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT
),
1381 HDA_COMPOSE_AMP_VAL(0x06, 3, 0, HDA_OUTPUT
),
1386 /* mute internal speaker if HP is plugged */
1387 static void ad1981_hp_automute(struct hda_codec
*codec
)
1389 unsigned int present
;
1391 present
= snd_hda_codec_read(codec
, 0x06, 0,
1392 AC_VERB_GET_PIN_SENSE
, 0) & 0x80000000;
1393 snd_hda_codec_amp_stereo(codec
, 0x05, HDA_OUTPUT
, 0,
1394 HDA_AMP_MUTE
, present
? HDA_AMP_MUTE
: 0);
1397 /* toggle input of built-in and mic jack appropriately */
1398 static void ad1981_hp_automic(struct hda_codec
*codec
)
1400 static struct hda_verb mic_jack_on
[] = {
1401 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1402 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
1405 static struct hda_verb mic_jack_off
[] = {
1406 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb080},
1407 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
1410 unsigned int present
;
1412 present
= snd_hda_codec_read(codec
, 0x08, 0,
1413 AC_VERB_GET_PIN_SENSE
, 0) & 0x80000000;
1415 snd_hda_sequence_write(codec
, mic_jack_on
);
1417 snd_hda_sequence_write(codec
, mic_jack_off
);
1420 /* unsolicited event for HP jack sensing */
1421 static void ad1981_hp_unsol_event(struct hda_codec
*codec
,
1426 case AD1981_HP_EVENT
:
1427 ad1981_hp_automute(codec
);
1429 case AD1981_MIC_EVENT
:
1430 ad1981_hp_automic(codec
);
1435 static struct hda_input_mux ad1981_hp_capture_source
= {
1439 { "Docking-Station", 0x1 },
1444 static struct snd_kcontrol_new ad1981_hp_mixers
[] = {
1445 HDA_BIND_VOL("Master Playback Volume", &ad1981_hp_bind_master_vol
),
1447 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1448 .name
= "Master Playback Switch",
1449 .info
= ad198x_eapd_info
,
1450 .get
= ad198x_eapd_get
,
1451 .put
= ad1981_hp_master_sw_put
,
1452 .private_value
= 0x05,
1454 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
1455 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
1457 /* FIXME: analog mic/line loopback doesn't work with my tests...
1458 * (although recording is OK)
1460 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
1461 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
1462 HDA_CODEC_VOLUME("Docking-Station Playback Volume", 0x13, 0x0, HDA_OUTPUT
),
1463 HDA_CODEC_MUTE("Docking-Station Playback Switch", 0x13, 0x0, HDA_OUTPUT
),
1464 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT
),
1465 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT
),
1466 /* FIXME: does this laptop have analog CD connection? */
1467 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
1468 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT
),
1470 HDA_CODEC_VOLUME("Mic Boost", 0x08, 0x0, HDA_INPUT
),
1471 HDA_CODEC_VOLUME("Internal Mic Boost", 0x18, 0x0, HDA_INPUT
),
1472 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT
),
1473 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT
),
1475 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1476 .name
= "Capture Source",
1477 .info
= ad198x_mux_enum_info
,
1478 .get
= ad198x_mux_enum_get
,
1479 .put
= ad198x_mux_enum_put
,
1484 /* initialize jack-sensing, too */
1485 static int ad1981_hp_init(struct hda_codec
*codec
)
1488 ad1981_hp_automute(codec
);
1489 ad1981_hp_automic(codec
);
1493 /* configuration for Toshiba Laptops */
1494 static struct hda_verb ad1981_toshiba_init_verbs
[] = {
1495 {0x05, AC_VERB_SET_EAPD_BTLENABLE
, 0x01 }, /* default on */
1496 /* pin sensing on HP and Mic jacks */
1497 {0x06, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1981_HP_EVENT
},
1498 {0x08, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1981_MIC_EVENT
},
1502 static struct snd_kcontrol_new ad1981_toshiba_mixers
[] = {
1503 HDA_CODEC_VOLUME("Amp Volume", 0x1a, 0x0, HDA_OUTPUT
),
1504 HDA_CODEC_MUTE("Amp Switch", 0x1a, 0x0, HDA_OUTPUT
),
1508 /* configuration for Lenovo Thinkpad T60 */
1509 static struct snd_kcontrol_new ad1981_thinkpad_mixers
[] = {
1510 HDA_CODEC_VOLUME("Master Playback Volume", 0x05, 0x0, HDA_OUTPUT
),
1511 HDA_CODEC_MUTE("Master Playback Switch", 0x05, 0x0, HDA_OUTPUT
),
1512 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT
),
1513 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
1514 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT
),
1515 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
1516 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT
),
1517 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT
),
1518 HDA_CODEC_VOLUME("Mic Boost", 0x08, 0x0, HDA_INPUT
),
1519 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT
),
1520 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT
),
1522 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1523 .name
= "Capture Source",
1524 .info
= ad198x_mux_enum_info
,
1525 .get
= ad198x_mux_enum_get
,
1526 .put
= ad198x_mux_enum_put
,
1528 /* identical with AD1983 */
1530 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1531 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,NONE
) "Source",
1532 .info
= ad1983_spdif_route_info
,
1533 .get
= ad1983_spdif_route_get
,
1534 .put
= ad1983_spdif_route_put
,
1539 static struct hda_input_mux ad1981_thinkpad_capture_source
= {
1557 static const char *ad1981_models
[AD1981_MODELS
] = {
1559 [AD1981_THINKPAD
] = "thinkpad",
1560 [AD1981_BASIC
] = "basic",
1561 [AD1981_TOSHIBA
] = "toshiba"
1564 static struct snd_pci_quirk ad1981_cfg_tbl
[] = {
1565 SND_PCI_QUIRK(0x1014, 0x0597, "Lenovo Z60", AD1981_THINKPAD
),
1567 SND_PCI_QUIRK(0x103c, 0, "HP nx", AD1981_HP
),
1568 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba U205", AD1981_TOSHIBA
),
1569 /* Lenovo Thinkpad T60/X60/Z6xx */
1570 SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1981_THINKPAD
),
1571 /* HP nx6320 (reversed SSID, H/W bug) */
1572 SND_PCI_QUIRK(0x30b0, 0x103c, "HP nx6320", AD1981_HP
),
1576 static int patch_ad1981(struct hda_codec
*codec
)
1578 struct ad198x_spec
*spec
;
1581 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1587 spec
->multiout
.max_channels
= 2;
1588 spec
->multiout
.num_dacs
= ARRAY_SIZE(ad1981_dac_nids
);
1589 spec
->multiout
.dac_nids
= ad1981_dac_nids
;
1590 spec
->multiout
.dig_out_nid
= AD1981_SPDIF_OUT
;
1591 spec
->num_adc_nids
= 1;
1592 spec
->adc_nids
= ad1981_adc_nids
;
1593 spec
->capsrc_nids
= ad1981_capsrc_nids
;
1594 spec
->input_mux
= &ad1981_capture_source
;
1595 spec
->num_mixers
= 1;
1596 spec
->mixers
[0] = ad1981_mixers
;
1597 spec
->num_init_verbs
= 1;
1598 spec
->init_verbs
[0] = ad1981_init_verbs
;
1599 spec
->spdif_route
= 0;
1600 #ifdef CONFIG_SND_HDA_POWER_SAVE
1601 spec
->loopback
.amplist
= ad1981_loopbacks
;
1603 spec
->vmaster_nid
= 0x05;
1605 codec
->patch_ops
= ad198x_patch_ops
;
1607 /* override some parameters */
1608 board_config
= snd_hda_check_board_config(codec
, AD1981_MODELS
,
1611 switch (board_config
) {
1613 spec
->mixers
[0] = ad1981_hp_mixers
;
1614 spec
->num_init_verbs
= 2;
1615 spec
->init_verbs
[1] = ad1981_hp_init_verbs
;
1616 spec
->multiout
.dig_out_nid
= 0;
1617 spec
->input_mux
= &ad1981_hp_capture_source
;
1619 codec
->patch_ops
.init
= ad1981_hp_init
;
1620 codec
->patch_ops
.unsol_event
= ad1981_hp_unsol_event
;
1622 case AD1981_THINKPAD
:
1623 spec
->mixers
[0] = ad1981_thinkpad_mixers
;
1624 spec
->input_mux
= &ad1981_thinkpad_capture_source
;
1626 case AD1981_TOSHIBA
:
1627 spec
->mixers
[0] = ad1981_hp_mixers
;
1628 spec
->mixers
[1] = ad1981_toshiba_mixers
;
1629 spec
->num_init_verbs
= 2;
1630 spec
->init_verbs
[1] = ad1981_toshiba_init_verbs
;
1631 spec
->multiout
.dig_out_nid
= 0;
1632 spec
->input_mux
= &ad1981_hp_capture_source
;
1633 codec
->patch_ops
.init
= ad1981_hp_init
;
1634 codec
->patch_ops
.unsol_event
= ad1981_hp_unsol_event
;
1644 * Output pins and routes
1646 * Pin Mix Sel DAC (*)
1647 * port-A 0x11 (mute/hp) <- 0x22 <- 0x37 <- 03/04/06
1648 * port-B 0x14 (mute/hp) <- 0x2b <- 0x30 <- 03/04/06
1649 * port-C 0x15 (mute) <- 0x2c <- 0x31 <- 05/0a
1650 * port-D 0x12 (mute/hp) <- 0x29 <- 04
1651 * port-E 0x17 (mute/hp) <- 0x26 <- 0x32 <- 05/0a
1652 * port-F 0x16 (mute) <- 0x2a <- 06
1653 * port-G 0x24 (mute) <- 0x27 <- 05
1654 * port-H 0x25 (mute) <- 0x28 <- 0a
1655 * mono 0x13 (mute/amp)<- 0x1e <- 0x36 <- 03/04/06
1657 * DAC0 = 03h, DAC1 = 04h, DAC2 = 05h, DAC3 = 06h, DAC4 = 0ah
1658 * (*) DAC2/3/4 are swapped to DAC3/4/2 on AD198A rev.2 due to a h/w bug.
1660 * Input pins and routes
1662 * pin boost mix input # / adc input #
1663 * port-A 0x11 -> 0x38 -> mix 2, ADC 0
1664 * port-B 0x14 -> 0x39 -> mix 0, ADC 1
1665 * port-C 0x15 -> 0x3a -> 33:0 - mix 1, ADC 2
1666 * port-D 0x12 -> 0x3d -> mix 3, ADC 8
1667 * port-E 0x17 -> 0x3c -> 34:0 - mix 4, ADC 4
1668 * port-F 0x16 -> 0x3b -> mix 5, ADC 3
1669 * port-G 0x24 -> N/A -> 33:1 - mix 1, 34:1 - mix 4, ADC 6
1670 * port-H 0x25 -> N/A -> 33:2 - mix 1, 34:2 - mix 4, ADC 7
1674 * 6stack - front/surr/CLFE/side/opt DACs - 04/06/05/0a/03
1675 * 3stack - front/surr/CLFE/opt DACs - 04/05/0a/03
1677 * Inputs of Analog Mix (0x20)
1678 * 0:Port-B (front mic)
1679 * 1:Port-C/G/H (line-in)
1681 * 3:Port-D (line-in/2)
1682 * 4:Port-E/G/H (mic-in)
1683 * 5:Port-F (mic2-in)
1689 * 1:Port-B (front mic-in)
1690 * 2:Port-C (line-in)
1691 * 3:Port-F (mic2-in)
1696 * 8:Port-D (line-in/2)
1699 * Proposed pin assignments by the datasheet
1702 * Port-A front headphone
1712 * Port-A front headphone
1714 * C rear line-in/surround
1716 * E rear mic-in/CLFE
1722 * D internal speaker (with EAPD)
1723 * E/F quad mic array
1739 /* reivision id to check workarounds */
1740 #define AD1988A_REV2 0x100200
1742 #define is_rev2(codec) \
1743 ((codec)->vendor_id == 0x11d41988 && \
1744 (codec)->revision_id == AD1988A_REV2)
1750 static hda_nid_t ad1988_6stack_dac_nids
[4] = {
1751 0x04, 0x06, 0x05, 0x0a
1754 static hda_nid_t ad1988_3stack_dac_nids
[3] = {
1758 /* for AD1988A revision-2, DAC2-4 are swapped */
1759 static hda_nid_t ad1988_6stack_dac_nids_rev2
[4] = {
1760 0x04, 0x05, 0x0a, 0x06
1763 static hda_nid_t ad1988_3stack_dac_nids_rev2
[3] = {
1767 static hda_nid_t ad1988_adc_nids
[3] = {
1771 static hda_nid_t ad1988_capsrc_nids
[3] = {
1775 #define AD1988_SPDIF_OUT 0x02
1776 #define AD1988_SPDIF_IN 0x07
1778 static struct hda_input_mux ad1988_6stack_capture_source
= {
1781 <<<<<<< HEAD
:sound
/pci
/hda
/patch_analog
.c
1782 { "Front Mic", 0x0 },
1786 { "Front Mic", 0x1 }, /* port-B */
1787 { "Line", 0x2 }, /* port-C */
1788 { "Mic", 0x4 }, /* port-E */
1789 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:sound
/pci
/hda
/patch_analog
.c
1795 static struct hda_input_mux ad1988_laptop_capture_source
= {
1798 <<<<<<< HEAD
:sound
/pci
/hda
/patch_analog
.c
1799 { "Mic/Line", 0x0 },
1801 { "Mic/Line", 0x1 }, /* port-B */
1802 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:sound
/pci
/hda
/patch_analog
.c
1810 static int ad198x_ch_mode_info(struct snd_kcontrol
*kcontrol
,
1811 struct snd_ctl_elem_info
*uinfo
)
1813 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1814 struct ad198x_spec
*spec
= codec
->spec
;
1815 return snd_hda_ch_mode_info(codec
, uinfo
, spec
->channel_mode
,
1816 spec
->num_channel_mode
);
1819 static int ad198x_ch_mode_get(struct snd_kcontrol
*kcontrol
,
1820 struct snd_ctl_elem_value
*ucontrol
)
1822 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1823 struct ad198x_spec
*spec
= codec
->spec
;
1824 return snd_hda_ch_mode_get(codec
, ucontrol
, spec
->channel_mode
,
1825 spec
->num_channel_mode
, spec
->multiout
.max_channels
);
1828 static int ad198x_ch_mode_put(struct snd_kcontrol
*kcontrol
,
1829 struct snd_ctl_elem_value
*ucontrol
)
1831 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1832 struct ad198x_spec
*spec
= codec
->spec
;
1833 int err
= snd_hda_ch_mode_put(codec
, ucontrol
, spec
->channel_mode
,
1834 spec
->num_channel_mode
,
1835 &spec
->multiout
.max_channels
);
1836 if (err
>= 0 && spec
->need_dac_fix
)
1837 spec
->multiout
.num_dacs
= spec
->multiout
.max_channels
/ 2;
1842 static struct snd_kcontrol_new ad1988_6stack_mixers1
[] = {
1843 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
1844 HDA_CODEC_VOLUME("Surround Playback Volume", 0x06, 0x0, HDA_OUTPUT
),
1845 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT
),
1846 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT
),
1847 HDA_CODEC_VOLUME("Side Playback Volume", 0x0a, 0x0, HDA_OUTPUT
),
1851 static struct snd_kcontrol_new ad1988_6stack_mixers1_rev2
[] = {
1852 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
1853 HDA_CODEC_VOLUME("Surround Playback Volume", 0x05, 0x0, HDA_OUTPUT
),
1854 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT
),
1855 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0a, 2, 0x0, HDA_OUTPUT
),
1856 HDA_CODEC_VOLUME("Side Playback Volume", 0x06, 0x0, HDA_OUTPUT
),
1860 static struct snd_kcontrol_new ad1988_6stack_mixers2
[] = {
1861 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT
),
1862 HDA_BIND_MUTE("Surround Playback Switch", 0x2a, 2, HDA_INPUT
),
1863 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x27, 1, 2, HDA_INPUT
),
1864 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x27, 2, 2, HDA_INPUT
),
1865 HDA_BIND_MUTE("Side Playback Switch", 0x28, 2, HDA_INPUT
),
1866 HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT
),
1867 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT
),
1869 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT
),
1870 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT
),
1871 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT
),
1872 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT
),
1873 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT
),
1874 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT
),
1875 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT
),
1876 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT
),
1878 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT
),
1879 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT
),
1881 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT
),
1882 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT
),
1884 HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT
),
1885 HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT
),
1891 static struct snd_kcontrol_new ad1988_3stack_mixers1
[] = {
1892 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
1893 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT
),
1894 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT
),
1895 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT
),
1899 static struct snd_kcontrol_new ad1988_3stack_mixers1_rev2
[] = {
1900 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
1901 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT
),
1902 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x06, 1, 0x0, HDA_OUTPUT
),
1903 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x06, 2, 0x0, HDA_OUTPUT
),
1907 static struct snd_kcontrol_new ad1988_3stack_mixers2
[] = {
1908 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT
),
1909 HDA_BIND_MUTE("Surround Playback Switch", 0x2c, 2, HDA_INPUT
),
1910 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x26, 1, 2, HDA_INPUT
),
1911 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x26, 2, 2, HDA_INPUT
),
1912 HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT
),
1913 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT
),
1915 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT
),
1916 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT
),
1917 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT
),
1918 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT
),
1919 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT
),
1920 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT
),
1921 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT
),
1922 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT
),
1924 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT
),
1925 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT
),
1927 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT
),
1928 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT
),
1930 HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT
),
1931 HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT
),
1933 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1934 .name
= "Channel Mode",
1935 .info
= ad198x_ch_mode_info
,
1936 .get
= ad198x_ch_mode_get
,
1937 .put
= ad198x_ch_mode_put
,
1944 static struct snd_kcontrol_new ad1988_laptop_mixers
[] = {
1945 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
1946 HDA_CODEC_MUTE("PCM Playback Switch", 0x29, 0x0, HDA_INPUT
),
1947 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT
),
1949 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT
),
1950 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT
),
1951 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x0, HDA_INPUT
),
1952 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x0, HDA_INPUT
),
1953 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT
),
1954 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT
),
1956 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT
),
1957 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT
),
1959 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT
),
1960 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT
),
1962 HDA_CODEC_VOLUME("Mic Boost", 0x39, 0x0, HDA_OUTPUT
),
1965 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1966 .name
= "External Amplifier",
1967 .info
= ad198x_eapd_info
,
1968 .get
= ad198x_eapd_get
,
1969 .put
= ad198x_eapd_put
,
1970 .private_value
= 0x12 | (1 << 8), /* port-D, inversed */
1977 static struct snd_kcontrol_new ad1988_capture_mixers
[] = {
1978 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
1979 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
1980 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT
),
1981 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT
),
1982 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x0e, 0x0, HDA_OUTPUT
),
1983 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x0e, 0x0, HDA_OUTPUT
),
1985 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1986 /* The multiple "Capture Source" controls confuse alsamixer
1987 * So call somewhat different..
1989 /* .name = "Capture Source", */
1990 .name
= "Input Source",
1992 .info
= ad198x_mux_enum_info
,
1993 .get
= ad198x_mux_enum_get
,
1994 .put
= ad198x_mux_enum_put
,
1999 static int ad1988_spdif_playback_source_info(struct snd_kcontrol
*kcontrol
,
2000 struct snd_ctl_elem_info
*uinfo
)
2002 static char *texts
[] = {
2003 "PCM", "ADC1", "ADC2", "ADC3"
2005 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
2007 uinfo
->value
.enumerated
.items
= 4;
2008 if (uinfo
->value
.enumerated
.item
>= 4)
2009 uinfo
->value
.enumerated
.item
= 3;
2010 strcpy(uinfo
->value
.enumerated
.name
, texts
[uinfo
->value
.enumerated
.item
]);
2014 static int ad1988_spdif_playback_source_get(struct snd_kcontrol
*kcontrol
,
2015 struct snd_ctl_elem_value
*ucontrol
)
2017 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2020 sel
= snd_hda_codec_read(codec
, 0x1d, 0, AC_VERB_GET_AMP_GAIN_MUTE
,
2023 ucontrol
->value
.enumerated
.item
[0] = 0;
2025 sel
= snd_hda_codec_read(codec
, 0x0b, 0,
2026 AC_VERB_GET_CONNECT_SEL
, 0);
2031 ucontrol
->value
.enumerated
.item
[0] = sel
;
2036 static int ad1988_spdif_playback_source_put(struct snd_kcontrol
*kcontrol
,
2037 struct snd_ctl_elem_value
*ucontrol
)
2039 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2040 unsigned int val
, sel
;
2043 val
= ucontrol
->value
.enumerated
.item
[0];
2047 sel
= snd_hda_codec_read(codec
, 0x1d, 0,
2048 AC_VERB_GET_AMP_GAIN_MUTE
,
2050 change
= sel
& 0x80;
2052 snd_hda_codec_write_cache(codec
, 0x1d, 0,
2053 AC_VERB_SET_AMP_GAIN_MUTE
,
2055 snd_hda_codec_write_cache(codec
, 0x1d, 0,
2056 AC_VERB_SET_AMP_GAIN_MUTE
,
2060 sel
= snd_hda_codec_read(codec
, 0x1d, 0,
2061 AC_VERB_GET_AMP_GAIN_MUTE
,
2062 AC_AMP_GET_INPUT
| 0x01);
2063 change
= sel
& 0x80;
2065 snd_hda_codec_write_cache(codec
, 0x1d, 0,
2066 AC_VERB_SET_AMP_GAIN_MUTE
,
2068 snd_hda_codec_write_cache(codec
, 0x1d, 0,
2069 AC_VERB_SET_AMP_GAIN_MUTE
,
2072 sel
= snd_hda_codec_read(codec
, 0x0b, 0,
2073 AC_VERB_GET_CONNECT_SEL
, 0) + 1;
2074 change
|= sel
!= val
;
2076 snd_hda_codec_write_cache(codec
, 0x0b, 0,
2077 AC_VERB_SET_CONNECT_SEL
,
2083 static struct snd_kcontrol_new ad1988_spdif_out_mixers
[] = {
2084 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
2086 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2087 .name
= "IEC958 Playback Source",
2088 .info
= ad1988_spdif_playback_source_info
,
2089 .get
= ad1988_spdif_playback_source_get
,
2090 .put
= ad1988_spdif_playback_source_put
,
2095 static struct snd_kcontrol_new ad1988_spdif_in_mixers
[] = {
2096 HDA_CODEC_VOLUME("IEC958 Capture Volume", 0x1c, 0x0, HDA_INPUT
),
2102 * initialization verbs
2106 * for 6-stack (+dig)
2108 static struct hda_verb ad1988_6stack_init_verbs
[] = {
2109 /* Front, Surround, CLFE, side DAC; unmute as default */
2110 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2111 {0x06, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2112 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2113 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2114 /* Port-A front headphon path */
2115 {0x37, AC_VERB_SET_CONNECT_SEL
, 0x01}, /* DAC1:04h */
2116 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2117 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2118 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2119 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2120 /* Port-D line-out path */
2121 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2122 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2123 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2124 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2125 /* Port-F surround path */
2126 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2127 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2128 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2129 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2130 /* Port-G CLFE path */
2131 {0x27, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2132 {0x27, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2133 {0x24, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2134 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2135 /* Port-H side path */
2136 {0x28, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2137 {0x28, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2138 {0x25, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2139 {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2141 {0x36, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* DAC1:04h */
2142 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2143 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2144 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2145 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb01f}, /* unmute, 0dB */
2146 /* Port-B front mic-in path */
2147 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2148 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2149 {0x39, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2150 /* Port-C line-in path */
2151 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2152 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2153 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2154 {0x33, AC_VERB_SET_CONNECT_SEL
, 0x0},
2155 /* Port-E mic-in path */
2156 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2157 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2158 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2159 {0x34, AC_VERB_SET_CONNECT_SEL
, 0x0},
2160 /* Analog CD Input */
2161 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2166 static struct hda_verb ad1988_capture_init_verbs
[] = {
2167 /* mute analog mix */
2168 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2169 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2170 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2171 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2172 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2173 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)},
2174 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)},
2175 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)},
2176 /* select ADCs - front-mic */
2177 {0x0c, AC_VERB_SET_CONNECT_SEL
, 0x1},
2178 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x1},
2179 {0x0e, AC_VERB_SET_CONNECT_SEL
, 0x1},
2181 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2182 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2183 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2188 static struct hda_verb ad1988_spdif_init_verbs
[] = {
2190 {0x02, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* PCM */
2191 {0x0b, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* ADC1 */
2192 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
2193 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2195 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x27}, /* 0dB */
2201 * verbs for 3stack (+dig)
2203 static struct hda_verb ad1988_3stack_ch2_init
[] = {
2204 /* set port-C to line-in */
2205 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2206 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
2207 /* set port-E to mic-in */
2208 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2209 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2213 static struct hda_verb ad1988_3stack_ch6_init
[] = {
2214 /* set port-C to surround out */
2215 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2216 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2217 /* set port-E to CLFE out */
2218 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2219 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2223 static struct hda_channel_mode ad1988_3stack_modes
[2] = {
2224 { 2, ad1988_3stack_ch2_init
},
2225 { 6, ad1988_3stack_ch6_init
},
2228 static struct hda_verb ad1988_3stack_init_verbs
[] = {
2229 /* Front, Surround, CLFE, side DAC; unmute as default */
2230 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2231 {0x06, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2232 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2233 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2234 /* Port-A front headphon path */
2235 {0x37, AC_VERB_SET_CONNECT_SEL
, 0x01}, /* DAC1:04h */
2236 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2237 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2238 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2239 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2240 /* Port-D line-out path */
2241 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2242 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2243 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2244 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2246 {0x36, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* DAC1:04h */
2247 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2248 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2249 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2250 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb01f}, /* unmute, 0dB */
2251 /* Port-B front mic-in path */
2252 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2253 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2254 {0x39, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2255 /* Port-C line-in/surround path - 6ch mode as default */
2256 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2257 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2258 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2259 {0x31, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* output sel: DAC 0x05 */
2260 {0x33, AC_VERB_SET_CONNECT_SEL
, 0x0},
2261 /* Port-E mic-in/CLFE path - 6ch mode as default */
2262 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2263 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2264 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2265 {0x32, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* output sel: DAC 0x0a */
2266 {0x34, AC_VERB_SET_CONNECT_SEL
, 0x0},
2267 /* mute analog mix */
2268 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2269 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2270 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2271 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2272 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2273 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)},
2274 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)},
2275 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)},
2276 /* select ADCs - front-mic */
2277 {0x0c, AC_VERB_SET_CONNECT_SEL
, 0x1},
2278 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x1},
2279 {0x0e, AC_VERB_SET_CONNECT_SEL
, 0x1},
2281 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2282 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2283 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2288 * verbs for laptop mode (+dig)
2290 static struct hda_verb ad1988_laptop_hp_on
[] = {
2291 /* unmute port-A and mute port-D */
2292 { 0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2293 { 0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2296 static struct hda_verb ad1988_laptop_hp_off
[] = {
2297 /* mute port-A and unmute port-D */
2298 { 0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2299 { 0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2303 #define AD1988_HP_EVENT 0x01
2305 static struct hda_verb ad1988_laptop_init_verbs
[] = {
2306 /* Front, Surround, CLFE, side DAC; unmute as default */
2307 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2308 {0x06, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2309 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2310 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2311 /* Port-A front headphon path */
2312 {0x37, AC_VERB_SET_CONNECT_SEL
, 0x01}, /* DAC1:04h */
2313 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2314 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2315 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2316 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
2317 /* unsolicited event for pin-sense */
2318 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| AD1988_HP_EVENT
},
2319 /* Port-D line-out path + EAPD */
2320 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2321 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2322 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2323 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2324 {0x12, AC_VERB_SET_EAPD_BTLENABLE
, 0x00}, /* EAPD-off */
2326 {0x36, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* DAC1:04h */
2327 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2328 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2329 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2330 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb01f}, /* unmute, 0dB */
2331 /* Port-B mic-in path */
2332 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2333 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
2334 {0x39, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2335 /* Port-C docking station - try to output */
2336 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
},
2337 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
2338 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
2339 {0x33, AC_VERB_SET_CONNECT_SEL
, 0x0},
2340 /* mute analog mix */
2341 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
2342 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
2343 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
2344 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
2345 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
2346 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)},
2347 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)},
2348 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)},
2349 /* select ADCs - mic */
2350 {0x0c, AC_VERB_SET_CONNECT_SEL
, 0x1},
2351 {0x0d, AC_VERB_SET_CONNECT_SEL
, 0x1},
2352 {0x0e, AC_VERB_SET_CONNECT_SEL
, 0x1},
2354 {0x08, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2355 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2356 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
2360 static void ad1988_laptop_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2362 if ((res
>> 26) != AD1988_HP_EVENT
)
2364 if (snd_hda_codec_read(codec
, 0x11, 0, AC_VERB_GET_PIN_SENSE
, 0) & (1 << 31))
2365 snd_hda_sequence_write(codec
, ad1988_laptop_hp_on
);
2367 snd_hda_sequence_write(codec
, ad1988_laptop_hp_off
);
2370 #ifdef CONFIG_SND_HDA_POWER_SAVE
2371 static struct hda_amp_list ad1988_loopbacks
[] = {
2372 { 0x20, HDA_INPUT
, 0 }, /* Front Mic */
2373 { 0x20, HDA_INPUT
, 1 }, /* Line */
2374 { 0x20, HDA_INPUT
, 4 }, /* Mic */
2375 { 0x20, HDA_INPUT
, 6 }, /* CD */
2381 * Automatic parse of I/O pins from the BIOS configuration
2384 #define NUM_CONTROL_ALLOC 32
2385 #define NUM_VERB_ALLOC 32
2392 static struct snd_kcontrol_new ad1988_control_templates
[] = {
2393 HDA_CODEC_VOLUME(NULL
, 0, 0, 0),
2394 HDA_CODEC_MUTE(NULL
, 0, 0, 0),
2395 HDA_BIND_MUTE(NULL
, 0, 0, 0),
2398 /* add dynamic controls */
2399 static int add_control(struct ad198x_spec
*spec
, int type
, const char *name
,
2402 struct snd_kcontrol_new
*knew
;
2404 if (spec
->num_kctl_used
>= spec
->num_kctl_alloc
) {
2405 int num
= spec
->num_kctl_alloc
+ NUM_CONTROL_ALLOC
;
2407 knew
= kcalloc(num
+ 1, sizeof(*knew
), GFP_KERNEL
); /* array + terminator */
2410 if (spec
->kctl_alloc
) {
2411 memcpy(knew
, spec
->kctl_alloc
, sizeof(*knew
) * spec
->num_kctl_alloc
);
2412 kfree(spec
->kctl_alloc
);
2414 spec
->kctl_alloc
= knew
;
2415 spec
->num_kctl_alloc
= num
;
2418 knew
= &spec
->kctl_alloc
[spec
->num_kctl_used
];
2419 *knew
= ad1988_control_templates
[type
];
2420 knew
->name
= kstrdup(name
, GFP_KERNEL
);
2423 knew
->private_value
= val
;
2424 spec
->num_kctl_used
++;
2428 #define AD1988_PIN_CD_NID 0x18
2429 #define AD1988_PIN_BEEP_NID 0x10
2431 static hda_nid_t ad1988_mixer_nids
[8] = {
2432 /* A B C D E F G H */
2433 0x22, 0x2b, 0x2c, 0x29, 0x26, 0x2a, 0x27, 0x28
2436 static inline hda_nid_t
ad1988_idx_to_dac(struct hda_codec
*codec
, int idx
)
2438 static hda_nid_t idx_to_dac
[8] = {
2439 /* A B C D E F G H */
2440 0x04, 0x06, 0x05, 0x04, 0x0a, 0x06, 0x05, 0x0a
2442 static hda_nid_t idx_to_dac_rev2
[8] = {
2443 /* A B C D E F G H */
2444 0x04, 0x05, 0x0a, 0x04, 0x06, 0x05, 0x0a, 0x06
2447 return idx_to_dac_rev2
[idx
];
2449 return idx_to_dac
[idx
];
2452 static hda_nid_t ad1988_boost_nids
[8] = {
2453 0x38, 0x39, 0x3a, 0x3d, 0x3c, 0x3b, 0, 0
2456 static int ad1988_pin_idx(hda_nid_t nid
)
2458 static hda_nid_t ad1988_io_pins
[8] = {
2459 0x11, 0x14, 0x15, 0x12, 0x17, 0x16, 0x24, 0x25
2462 for (i
= 0; i
< ARRAY_SIZE(ad1988_io_pins
); i
++)
2463 if (ad1988_io_pins
[i
] == nid
)
2465 return 0; /* should be -1 */
2468 static int ad1988_pin_to_loopback_idx(hda_nid_t nid
)
2470 static int loopback_idx
[8] = {
2471 2, 0, 1, 3, 4, 5, 1, 4
2474 case AD1988_PIN_CD_NID
:
2477 return loopback_idx
[ad1988_pin_idx(nid
)];
2481 static int ad1988_pin_to_adc_idx(hda_nid_t nid
)
2483 static int adc_idx
[8] = {
2484 0, 1, 2, 8, 4, 3, 6, 7
2487 case AD1988_PIN_CD_NID
:
2490 return adc_idx
[ad1988_pin_idx(nid
)];
2494 /* fill in the dac_nids table from the parsed pin configuration */
2495 static int ad1988_auto_fill_dac_nids(struct hda_codec
*codec
,
2496 const struct auto_pin_cfg
*cfg
)
2498 struct ad198x_spec
*spec
= codec
->spec
;
2501 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
2503 /* check the pins hardwired to audio widget */
2504 for (i
= 0; i
< cfg
->line_outs
; i
++) {
2505 idx
= ad1988_pin_idx(cfg
->line_out_pins
[i
]);
2506 spec
->multiout
.dac_nids
[i
] = ad1988_idx_to_dac(codec
, idx
);
2508 spec
->multiout
.num_dacs
= cfg
->line_outs
;
2512 /* add playback controls from the parsed DAC table */
2513 static int ad1988_auto_create_multi_out_ctls(struct ad198x_spec
*spec
,
2514 const struct auto_pin_cfg
*cfg
)
2517 static const char *chname
[4] = { "Front", "Surround", NULL
/*CLFE*/, "Side" };
2521 for (i
= 0; i
< cfg
->line_outs
; i
++) {
2522 hda_nid_t dac
= spec
->multiout
.dac_nids
[i
];
2525 nid
= ad1988_mixer_nids
[ad1988_pin_idx(cfg
->line_out_pins
[i
])];
2528 err
= add_control(spec
, AD_CTL_WIDGET_VOL
,
2529 "Center Playback Volume",
2530 HDA_COMPOSE_AMP_VAL(dac
, 1, 0, HDA_OUTPUT
));
2533 err
= add_control(spec
, AD_CTL_WIDGET_VOL
,
2534 "LFE Playback Volume",
2535 HDA_COMPOSE_AMP_VAL(dac
, 2, 0, HDA_OUTPUT
));
2538 err
= add_control(spec
, AD_CTL_BIND_MUTE
,
2539 "Center Playback Switch",
2540 HDA_COMPOSE_AMP_VAL(nid
, 1, 2, HDA_INPUT
));
2543 err
= add_control(spec
, AD_CTL_BIND_MUTE
,
2544 "LFE Playback Switch",
2545 HDA_COMPOSE_AMP_VAL(nid
, 2, 2, HDA_INPUT
));
2549 sprintf(name
, "%s Playback Volume", chname
[i
]);
2550 err
= add_control(spec
, AD_CTL_WIDGET_VOL
, name
,
2551 HDA_COMPOSE_AMP_VAL(dac
, 3, 0, HDA_OUTPUT
));
2554 sprintf(name
, "%s Playback Switch", chname
[i
]);
2555 err
= add_control(spec
, AD_CTL_BIND_MUTE
, name
,
2556 HDA_COMPOSE_AMP_VAL(nid
, 3, 2, HDA_INPUT
));
2564 /* add playback controls for speaker and HP outputs */
2565 static int ad1988_auto_create_extra_out(struct hda_codec
*codec
, hda_nid_t pin
,
2568 struct ad198x_spec
*spec
= codec
->spec
;
2576 idx
= ad1988_pin_idx(pin
);
2577 nid
= ad1988_idx_to_dac(codec
, idx
);
2578 /* specify the DAC as the extra output */
2579 if (! spec
->multiout
.hp_nid
)
2580 spec
->multiout
.hp_nid
= nid
;
2582 spec
->multiout
.extra_out_nid
[0] = nid
;
2583 /* control HP volume/switch on the output mixer amp */
2584 sprintf(name
, "%s Playback Volume", pfx
);
2585 if ((err
= add_control(spec
, AD_CTL_WIDGET_VOL
, name
,
2586 HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
))) < 0)
2588 nid
= ad1988_mixer_nids
[idx
];
2589 sprintf(name
, "%s Playback Switch", pfx
);
2590 if ((err
= add_control(spec
, AD_CTL_BIND_MUTE
, name
,
2591 HDA_COMPOSE_AMP_VAL(nid
, 3, 2, HDA_INPUT
))) < 0)
2596 /* create input playback/capture controls for the given pin */
2597 static int new_analog_input(struct ad198x_spec
*spec
, hda_nid_t pin
,
2598 const char *ctlname
, int boost
)
2603 sprintf(name
, "%s Playback Volume", ctlname
);
2604 idx
= ad1988_pin_to_loopback_idx(pin
);
2605 if ((err
= add_control(spec
, AD_CTL_WIDGET_VOL
, name
,
2606 HDA_COMPOSE_AMP_VAL(0x20, 3, idx
, HDA_INPUT
))) < 0)
2608 sprintf(name
, "%s Playback Switch", ctlname
);
2609 if ((err
= add_control(spec
, AD_CTL_WIDGET_MUTE
, name
,
2610 HDA_COMPOSE_AMP_VAL(0x20, 3, idx
, HDA_INPUT
))) < 0)
2614 idx
= ad1988_pin_idx(pin
);
2615 bnid
= ad1988_boost_nids
[idx
];
2617 sprintf(name
, "%s Boost", ctlname
);
2618 return add_control(spec
, AD_CTL_WIDGET_VOL
, name
,
2619 HDA_COMPOSE_AMP_VAL(bnid
, 3, idx
, HDA_OUTPUT
));
2626 /* create playback/capture controls for input pins */
2627 static int ad1988_auto_create_analog_input_ctls(struct ad198x_spec
*spec
,
2628 const struct auto_pin_cfg
*cfg
)
2630 struct hda_input_mux
*imux
= &spec
->private_imux
;
2633 for (i
= 0; i
< AUTO_PIN_LAST
; i
++) {
2634 err
= new_analog_input(spec
, cfg
->input_pins
[i
],
2635 auto_pin_cfg_labels
[i
],
2636 i
<= AUTO_PIN_FRONT_MIC
);
2639 imux
->items
[imux
->num_items
].label
= auto_pin_cfg_labels
[i
];
2640 imux
->items
[imux
->num_items
].index
= ad1988_pin_to_adc_idx(cfg
->input_pins
[i
]);
2643 imux
->items
[imux
->num_items
].label
= "Mix";
2644 imux
->items
[imux
->num_items
].index
= 9;
2647 if ((err
= add_control(spec
, AD_CTL_WIDGET_VOL
,
2648 "Analog Mix Playback Volume",
2649 HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT
))) < 0)
2651 if ((err
= add_control(spec
, AD_CTL_WIDGET_MUTE
,
2652 "Analog Mix Playback Switch",
2653 HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT
))) < 0)
2659 static void ad1988_auto_set_output_and_unmute(struct hda_codec
*codec
,
2660 hda_nid_t nid
, int pin_type
,
2664 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
, pin_type
);
2665 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
);
2667 case 0x11: /* port-A - DAC 04 */
2668 snd_hda_codec_write(codec
, 0x37, 0, AC_VERB_SET_CONNECT_SEL
, 0x01);
2670 case 0x14: /* port-B - DAC 06 */
2671 snd_hda_codec_write(codec
, 0x30, 0, AC_VERB_SET_CONNECT_SEL
, 0x02);
2673 case 0x15: /* port-C - DAC 05 */
2674 snd_hda_codec_write(codec
, 0x31, 0, AC_VERB_SET_CONNECT_SEL
, 0x00);
2676 case 0x17: /* port-E - DAC 0a */
2677 snd_hda_codec_write(codec
, 0x32, 0, AC_VERB_SET_CONNECT_SEL
, 0x01);
2679 case 0x13: /* mono - DAC 04 */
2680 snd_hda_codec_write(codec
, 0x36, 0, AC_VERB_SET_CONNECT_SEL
, 0x01);
2685 static void ad1988_auto_init_multi_out(struct hda_codec
*codec
)
2687 struct ad198x_spec
*spec
= codec
->spec
;
2690 for (i
= 0; i
< spec
->autocfg
.line_outs
; i
++) {
2691 hda_nid_t nid
= spec
->autocfg
.line_out_pins
[i
];
2692 ad1988_auto_set_output_and_unmute(codec
, nid
, PIN_OUT
, i
);
2696 static void ad1988_auto_init_extra_out(struct hda_codec
*codec
)
2698 struct ad198x_spec
*spec
= codec
->spec
;
2701 pin
= spec
->autocfg
.speaker_pins
[0];
2702 if (pin
) /* connect to front */
2703 ad1988_auto_set_output_and_unmute(codec
, pin
, PIN_OUT
, 0);
2704 pin
= spec
->autocfg
.hp_pins
[0];
2705 if (pin
) /* connect to front */
2706 ad1988_auto_set_output_and_unmute(codec
, pin
, PIN_HP
, 0);
2709 static void ad1988_auto_init_analog_input(struct hda_codec
*codec
)
2711 struct ad198x_spec
*spec
= codec
->spec
;
2714 for (i
= 0; i
< AUTO_PIN_LAST
; i
++) {
2715 hda_nid_t nid
= spec
->autocfg
.input_pins
[i
];
2719 case 0x15: /* port-C */
2720 snd_hda_codec_write(codec
, 0x33, 0, AC_VERB_SET_CONNECT_SEL
, 0x0);
2722 case 0x17: /* port-E */
2723 snd_hda_codec_write(codec
, 0x34, 0, AC_VERB_SET_CONNECT_SEL
, 0x0);
2726 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2727 i
<= AUTO_PIN_FRONT_MIC
? PIN_VREF80
: PIN_IN
);
2728 if (nid
!= AD1988_PIN_CD_NID
)
2729 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
2731 idx
= ad1988_pin_idx(nid
);
2732 if (ad1988_boost_nids
[idx
])
2733 snd_hda_codec_write(codec
, ad1988_boost_nids
[idx
], 0,
2734 AC_VERB_SET_AMP_GAIN_MUTE
,
2739 /* parse the BIOS configuration and set up the alc_spec */
2740 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2741 static int ad1988_parse_auto_config(struct hda_codec
*codec
)
2743 struct ad198x_spec
*spec
= codec
->spec
;
2746 if ((err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
)) < 0)
2748 if ((err
= ad1988_auto_fill_dac_nids(codec
, &spec
->autocfg
)) < 0)
2750 if (! spec
->autocfg
.line_outs
)
2751 return 0; /* can't find valid BIOS pin config */
2752 if ((err
= ad1988_auto_create_multi_out_ctls(spec
, &spec
->autocfg
)) < 0 ||
2753 (err
= ad1988_auto_create_extra_out(codec
,
2754 spec
->autocfg
.speaker_pins
[0],
2756 (err
= ad1988_auto_create_extra_out(codec
, spec
->autocfg
.hp_pins
[0],
2757 "Headphone")) < 0 ||
2758 (err
= ad1988_auto_create_analog_input_ctls(spec
, &spec
->autocfg
)) < 0)
2761 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
2763 if (spec
->autocfg
.dig_out_pin
)
2764 spec
->multiout
.dig_out_nid
= AD1988_SPDIF_OUT
;
2765 if (spec
->autocfg
.dig_in_pin
)
2766 spec
->dig_in_nid
= AD1988_SPDIF_IN
;
2768 if (spec
->kctl_alloc
)
2769 spec
->mixers
[spec
->num_mixers
++] = spec
->kctl_alloc
;
2771 spec
->init_verbs
[spec
->num_init_verbs
++] = ad1988_6stack_init_verbs
;
2773 spec
->input_mux
= &spec
->private_imux
;
2778 /* init callback for auto-configuration model -- overriding the default init */
2779 static int ad1988_auto_init(struct hda_codec
*codec
)
2782 ad1988_auto_init_multi_out(codec
);
2783 ad1988_auto_init_extra_out(codec
);
2784 ad1988_auto_init_analog_input(codec
);
2792 static const char *ad1988_models
[AD1988_MODEL_LAST
] = {
2793 [AD1988_6STACK
] = "6stack",
2794 [AD1988_6STACK_DIG
] = "6stack-dig",
2795 [AD1988_3STACK
] = "3stack",
2796 [AD1988_3STACK_DIG
] = "3stack-dig",
2797 [AD1988_LAPTOP
] = "laptop",
2798 [AD1988_LAPTOP_DIG
] = "laptop-dig",
2799 [AD1988_AUTO
] = "auto",
2802 static struct snd_pci_quirk ad1988_cfg_tbl
[] = {
2803 SND_PCI_QUIRK(0x1043, 0x81ec, "Asus P5B-DLX", AD1988_6STACK_DIG
),
2804 SND_PCI_QUIRK(0x1043, 0x81f6, "Asus M2N-SLI", AD1988_6STACK_DIG
),
2808 static int patch_ad1988(struct hda_codec
*codec
)
2810 struct ad198x_spec
*spec
;
2813 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
2820 snd_printk(KERN_INFO
"patch_analog: AD1988A rev.2 is detected, enable workarounds\n");
2822 board_config
= snd_hda_check_board_config(codec
, AD1988_MODEL_LAST
,
2823 ad1988_models
, ad1988_cfg_tbl
);
2824 if (board_config
< 0) {
2825 printk(KERN_INFO
"hda_codec: Unknown model for AD1988, trying auto-probe from BIOS...\n");
2826 board_config
= AD1988_AUTO
;
2829 if (board_config
== AD1988_AUTO
) {
2830 /* automatic parse from the BIOS config */
2831 int err
= ad1988_parse_auto_config(codec
);
2836 printk(KERN_INFO
"hda_codec: Cannot set up configuration from BIOS. Using 6-stack mode...\n");
2837 board_config
= AD1988_6STACK
;
2841 switch (board_config
) {
2843 case AD1988_6STACK_DIG
:
2844 spec
->multiout
.max_channels
= 8;
2845 spec
->multiout
.num_dacs
= 4;
2847 spec
->multiout
.dac_nids
= ad1988_6stack_dac_nids_rev2
;
2849 spec
->multiout
.dac_nids
= ad1988_6stack_dac_nids
;
2850 spec
->input_mux
= &ad1988_6stack_capture_source
;
2851 spec
->num_mixers
= 2;
2853 spec
->mixers
[0] = ad1988_6stack_mixers1_rev2
;
2855 spec
->mixers
[0] = ad1988_6stack_mixers1
;
2856 spec
->mixers
[1] = ad1988_6stack_mixers2
;
2857 spec
->num_init_verbs
= 1;
2858 spec
->init_verbs
[0] = ad1988_6stack_init_verbs
;
2859 if (board_config
== AD1988_6STACK_DIG
) {
2860 spec
->multiout
.dig_out_nid
= AD1988_SPDIF_OUT
;
2861 spec
->dig_in_nid
= AD1988_SPDIF_IN
;
2865 case AD1988_3STACK_DIG
:
2866 spec
->multiout
.max_channels
= 6;
2867 spec
->multiout
.num_dacs
= 3;
2869 spec
->multiout
.dac_nids
= ad1988_3stack_dac_nids_rev2
;
2871 spec
->multiout
.dac_nids
= ad1988_3stack_dac_nids
;
2872 spec
->input_mux
= &ad1988_6stack_capture_source
;
2873 spec
->channel_mode
= ad1988_3stack_modes
;
2874 spec
->num_channel_mode
= ARRAY_SIZE(ad1988_3stack_modes
);
2875 spec
->num_mixers
= 2;
2877 spec
->mixers
[0] = ad1988_3stack_mixers1_rev2
;
2879 spec
->mixers
[0] = ad1988_3stack_mixers1
;
2880 spec
->mixers
[1] = ad1988_3stack_mixers2
;
2881 spec
->num_init_verbs
= 1;
2882 spec
->init_verbs
[0] = ad1988_3stack_init_verbs
;
2883 if (board_config
== AD1988_3STACK_DIG
)
2884 spec
->multiout
.dig_out_nid
= AD1988_SPDIF_OUT
;
2887 case AD1988_LAPTOP_DIG
:
2888 spec
->multiout
.max_channels
= 2;
2889 spec
->multiout
.num_dacs
= 1;
2890 spec
->multiout
.dac_nids
= ad1988_3stack_dac_nids
;
2891 spec
->input_mux
= &ad1988_laptop_capture_source
;
2892 spec
->num_mixers
= 1;
2893 spec
->mixers
[0] = ad1988_laptop_mixers
;
2894 spec
->num_init_verbs
= 1;
2895 spec
->init_verbs
[0] = ad1988_laptop_init_verbs
;
2896 if (board_config
== AD1988_LAPTOP_DIG
)
2897 spec
->multiout
.dig_out_nid
= AD1988_SPDIF_OUT
;
2901 spec
->num_adc_nids
= ARRAY_SIZE(ad1988_adc_nids
);
2902 spec
->adc_nids
= ad1988_adc_nids
;
2903 spec
->capsrc_nids
= ad1988_capsrc_nids
;
2904 spec
->mixers
[spec
->num_mixers
++] = ad1988_capture_mixers
;
2905 spec
->init_verbs
[spec
->num_init_verbs
++] = ad1988_capture_init_verbs
;
2906 if (spec
->multiout
.dig_out_nid
) {
2907 spec
->mixers
[spec
->num_mixers
++] = ad1988_spdif_out_mixers
;
2908 spec
->init_verbs
[spec
->num_init_verbs
++] = ad1988_spdif_init_verbs
;
2910 if (spec
->dig_in_nid
)
2911 spec
->mixers
[spec
->num_mixers
++] = ad1988_spdif_in_mixers
;
2913 codec
->patch_ops
= ad198x_patch_ops
;
2914 switch (board_config
) {
2916 codec
->patch_ops
.init
= ad1988_auto_init
;
2919 case AD1988_LAPTOP_DIG
:
2920 codec
->patch_ops
.unsol_event
= ad1988_laptop_unsol_event
;
2923 #ifdef CONFIG_SND_HDA_POWER_SAVE
2924 spec
->loopback
.amplist
= ad1988_loopbacks
;
2926 spec
->vmaster_nid
= 0x04;
2935 * port-B - front line/mic-in
2936 * port-E - aux in/out
2937 * port-F - aux in/out
2938 * port-C - rear line/mic-in
2939 * port-D - rear line/hp-out
2940 * port-A - front line/hp-out
2942 * AD1984 = AD1884 + two digital mic-ins
2945 * For simplicity, we share the single DAC for both HP and line-outs
2946 * right now. The inidividual playbacks could be easily implemented,
2947 * but no build-up framework is given, so far.
2950 static hda_nid_t ad1884_dac_nids
[1] = {
2954 static hda_nid_t ad1884_adc_nids
[2] = {
2958 static hda_nid_t ad1884_capsrc_nids
[2] = {
2962 #define AD1884_SPDIF_OUT 0x02
2964 static struct hda_input_mux ad1884_capture_source
= {
2967 { "Front Mic", 0x0 },
2974 static struct snd_kcontrol_new ad1884_base_mixers
[] = {
2975 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
2976 /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */
2977 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
2978 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
2979 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT
),
2980 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT
),
2981 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT
),
2982 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT
),
2983 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT
),
2984 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT
),
2985 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT
),
2986 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT
),
2988 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x20, 0x03, HDA_INPUT),
2989 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x20, 0x03, HDA_INPUT),
2990 HDA_CODEC_VOLUME("Digital Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
2991 HDA_CODEC_MUTE("Digital Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
2993 HDA_CODEC_VOLUME("Mic Boost", 0x15, 0x0, HDA_INPUT
),
2994 HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT
),
2995 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
2996 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
2997 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT
),
2998 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT
),
3000 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3001 /* The multiple "Capture Source" controls confuse alsamixer
3002 * So call somewhat different..
3004 /* .name = "Capture Source", */
3005 .name
= "Input Source",
3007 .info
= ad198x_mux_enum_info
,
3008 .get
= ad198x_mux_enum_get
,
3009 .put
= ad198x_mux_enum_put
,
3011 /* SPDIF controls */
3012 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
3014 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3015 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,NONE
) "Source",
3016 /* identical with ad1983 */
3017 .info
= ad1983_spdif_route_info
,
3018 .get
= ad1983_spdif_route_get
,
3019 .put
= ad1983_spdif_route_put
,
3024 static struct snd_kcontrol_new ad1984_dmic_mixers
[] = {
3025 HDA_CODEC_VOLUME("Digital Mic Capture Volume", 0x05, 0x0, HDA_INPUT
),
3026 HDA_CODEC_MUTE("Digital Mic Capture Switch", 0x05, 0x0, HDA_INPUT
),
3027 HDA_CODEC_VOLUME_IDX("Digital Mic Capture Volume", 1, 0x06, 0x0,
3029 HDA_CODEC_MUTE_IDX("Digital Mic Capture Switch", 1, 0x06, 0x0,
3035 * initialization verbs
3037 static struct hda_verb ad1884_init_verbs
[] = {
3038 /* DACs; mute as default */
3039 {0x03, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
3040 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
3041 /* Port-A (HP) mixer */
3042 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3043 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3045 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
3046 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3047 /* HP selector - select DAC2 */
3048 {0x22, AC_VERB_SET_CONNECT_SEL
, 0x1},
3049 /* Port-D (Line-out) mixer */
3050 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3051 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3053 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
3054 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3055 /* Mono-out mixer */
3056 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3057 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3059 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
3060 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3062 {0x0e, AC_VERB_SET_CONNECT_SEL
, 0x1},
3063 /* Port-B (front mic) pin */
3064 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
3065 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3066 /* Port-C (rear mic) pin */
3067 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
3068 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3069 /* Analog mixer; mute as default */
3070 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3071 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
3072 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
3073 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
3074 /* Analog Mix output amp */
3075 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x1f}, /* 0dB */
3076 /* SPDIF output selector */
3077 {0x02, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* PCM */
3078 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x27}, /* 0dB */
3082 #ifdef CONFIG_SND_HDA_POWER_SAVE
3083 static struct hda_amp_list ad1884_loopbacks
[] = {
3084 { 0x20, HDA_INPUT
, 0 }, /* Front Mic */
3085 { 0x20, HDA_INPUT
, 1 }, /* Mic */
3086 { 0x20, HDA_INPUT
, 2 }, /* CD */
3087 { 0x20, HDA_INPUT
, 4 }, /* Docking */
3092 static const char *ad1884_slave_vols
[] = {
3093 "PCM Playback Volume",
3094 "Mic Playback Volume",
3095 "Mono Playback Volume",
3096 "Front Mic Playback Volume",
3097 "Mic Playback Volume",
3098 "CD Playback Volume",
3099 "Internal Mic Playback Volume",
3100 "Docking Mic Playback Volume"
3101 "Beep Playback Volume",
3102 "IEC958 Playback Volume",
3106 static int patch_ad1884(struct hda_codec
*codec
)
3108 struct ad198x_spec
*spec
;
3110 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
3114 mutex_init(&spec
->amp_mutex
);
3117 spec
->multiout
.max_channels
= 2;
3118 spec
->multiout
.num_dacs
= ARRAY_SIZE(ad1884_dac_nids
);
3119 spec
->multiout
.dac_nids
= ad1884_dac_nids
;
3120 spec
->multiout
.dig_out_nid
= AD1884_SPDIF_OUT
;
3121 spec
->num_adc_nids
= ARRAY_SIZE(ad1884_adc_nids
);
3122 spec
->adc_nids
= ad1884_adc_nids
;
3123 spec
->capsrc_nids
= ad1884_capsrc_nids
;
3124 spec
->input_mux
= &ad1884_capture_source
;
3125 spec
->num_mixers
= 1;
3126 spec
->mixers
[0] = ad1884_base_mixers
;
3127 spec
->num_init_verbs
= 1;
3128 spec
->init_verbs
[0] = ad1884_init_verbs
;
3129 spec
->spdif_route
= 0;
3130 #ifdef CONFIG_SND_HDA_POWER_SAVE
3131 spec
->loopback
.amplist
= ad1884_loopbacks
;
3133 spec
->vmaster_nid
= 0x04;
3134 /* we need to cover all playback volumes */
3135 spec
->slave_vols
= ad1884_slave_vols
;
3137 codec
->patch_ops
= ad198x_patch_ops
;
3143 * Lenovo Thinkpad T61/X61
3145 static struct hda_input_mux ad1984_thinkpad_capture_source
= {
3149 { "Internal Mic", 0x1 },
3156 * Dell Precision T3400
3158 static struct hda_input_mux ad1984_dell_desktop_capture_source
= {
3161 { "Front Mic", 0x0 },
3168 static struct snd_kcontrol_new ad1984_thinkpad_mixers
[] = {
3169 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
3170 /* HDA_CODEC_VOLUME_IDX("PCM Playback Volume", 1, 0x03, 0x0, HDA_OUTPUT), */
3171 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
3172 HDA_CODEC_MUTE("Speaker Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
3173 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT
),
3174 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT
),
3175 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x20, 0x01, HDA_INPUT
),
3176 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT
),
3177 HDA_CODEC_VOLUME("Docking Mic Playback Volume", 0x20, 0x04, HDA_INPUT
),
3178 HDA_CODEC_MUTE("Docking Mic Playback Switch", 0x20, 0x04, HDA_INPUT
),
3179 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT
),
3180 HDA_CODEC_VOLUME("Internal Mic Boost", 0x15, 0x0, HDA_INPUT
),
3181 HDA_CODEC_VOLUME("Docking Mic Boost", 0x25, 0x0, HDA_OUTPUT
),
3182 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT
),
3183 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT
),
3184 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
3185 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
3186 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT
),
3187 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT
),
3189 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3190 /* The multiple "Capture Source" controls confuse alsamixer
3191 * So call somewhat different..
3193 /* .name = "Capture Source", */
3194 .name
= "Input Source",
3196 .info
= ad198x_mux_enum_info
,
3197 .get
= ad198x_mux_enum_get
,
3198 .put
= ad198x_mux_enum_put
,
3200 /* SPDIF controls */
3201 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
3203 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3204 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,NONE
) "Source",
3205 /* identical with ad1983 */
3206 .info
= ad1983_spdif_route_info
,
3207 .get
= ad1983_spdif_route_get
,
3208 .put
= ad1983_spdif_route_put
,
3213 /* additional verbs */
3214 static struct hda_verb ad1984_thinkpad_init_verbs
[] = {
3215 /* Port-E (docking station mic) pin */
3216 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
3217 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3218 /* docking mic boost */
3219 {0x25, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3220 /* Analog mixer - docking mic; mute as default */
3221 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
3222 /* enable EAPD bit */
3223 {0x12, AC_VERB_SET_EAPD_BTLENABLE
, 0x02},
3228 * Dell Precision T3400
3230 static struct snd_kcontrol_new ad1984_dell_desktop_mixers
[] = {
3231 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
3232 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
3233 HDA_CODEC_MUTE("Speaker Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
3234 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT
),
3235 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT
),
3236 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT
),
3237 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT
),
3238 HDA_CODEC_VOLUME("Line-In Playback Volume", 0x20, 0x01, HDA_INPUT
),
3239 HDA_CODEC_MUTE("Line-In Playback Switch", 0x20, 0x01, HDA_INPUT
),
3241 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x20, 0x03, HDA_INPUT),
3242 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x20, 0x03, HDA_INPUT),
3244 HDA_CODEC_VOLUME("Line-In Boost", 0x15, 0x0, HDA_INPUT
),
3245 HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT
),
3246 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT
),
3247 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT
),
3248 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT
),
3249 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT
),
3251 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3252 /* The multiple "Capture Source" controls confuse alsamixer
3253 * So call somewhat different..
3255 /* .name = "Capture Source", */
3256 .name
= "Input Source",
3258 .info
= ad198x_mux_enum_info
,
3259 .get
= ad198x_mux_enum_get
,
3260 .put
= ad198x_mux_enum_put
,
3265 /* Digial MIC ADC NID 0x05 + 0x06 */
3266 static int ad1984_pcm_dmic_prepare(struct hda_pcm_stream
*hinfo
,
3267 struct hda_codec
*codec
,
3268 unsigned int stream_tag
,
3269 unsigned int format
,
3270 struct snd_pcm_substream
*substream
)
3272 snd_hda_codec_setup_stream(codec
, 0x05 + substream
->number
,
3273 stream_tag
, 0, format
);
3277 static int ad1984_pcm_dmic_cleanup(struct hda_pcm_stream
*hinfo
,
3278 struct hda_codec
*codec
,
3279 struct snd_pcm_substream
*substream
)
3281 snd_hda_codec_setup_stream(codec
, 0x05 + substream
->number
,
3286 static struct hda_pcm_stream ad1984_pcm_dmic_capture
= {
3292 .prepare
= ad1984_pcm_dmic_prepare
,
3293 .cleanup
= ad1984_pcm_dmic_cleanup
3297 static int ad1984_build_pcms(struct hda_codec
*codec
)
3299 struct ad198x_spec
*spec
= codec
->spec
;
3300 struct hda_pcm
*info
;
3303 err
= ad198x_build_pcms(codec
);
3307 info
= spec
->pcm_rec
+ codec
->num_pcms
;
3309 info
->name
= "AD1984 Digital Mic";
3310 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = ad1984_pcm_dmic_capture
;
3318 AD1984_DELL_DESKTOP
,
3322 static const char *ad1984_models
[AD1984_MODELS
] = {
3323 [AD1984_BASIC
] = "basic",
3324 [AD1984_THINKPAD
] = "thinkpad",
3325 [AD1984_DELL_DESKTOP
] = "dell_desktop",
3328 static struct snd_pci_quirk ad1984_cfg_tbl
[] = {
3329 /* Lenovo Thinkpad T61/X61 */
3330 SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1984_THINKPAD
),
3331 SND_PCI_QUIRK(0x1028, 0x0214, "Dell T3400", AD1984_DELL_DESKTOP
),
3335 static int patch_ad1984(struct hda_codec
*codec
)
3337 struct ad198x_spec
*spec
;
3338 int board_config
, err
;
3340 err
= patch_ad1884(codec
);
3344 board_config
= snd_hda_check_board_config(codec
, AD1984_MODELS
,
3345 ad1984_models
, ad1984_cfg_tbl
);
3346 switch (board_config
) {
3348 /* additional digital mics */
3349 spec
->mixers
[spec
->num_mixers
++] = ad1984_dmic_mixers
;
3350 codec
->patch_ops
.build_pcms
= ad1984_build_pcms
;
3352 case AD1984_THINKPAD
:
3353 spec
->multiout
.dig_out_nid
= AD1884_SPDIF_OUT
;
3354 spec
->input_mux
= &ad1984_thinkpad_capture_source
;
3355 spec
->mixers
[0] = ad1984_thinkpad_mixers
;
3356 spec
->init_verbs
[spec
->num_init_verbs
++] = ad1984_thinkpad_init_verbs
;
3358 case AD1984_DELL_DESKTOP
:
3359 spec
->multiout
.dig_out_nid
= 0;
3360 spec
->input_mux
= &ad1984_dell_desktop_capture_source
;
3361 spec
->mixers
[0] = ad1984_dell_desktop_mixers
;
3371 * port-A - front hp-out
3372 * port-B - front mic-in
3373 * port-C - rear line-in, shared surr-out (3stack)
3374 * port-D - rear line-out
3375 * port-E - rear mic-in, shared clfe-out (3stack)
3376 * port-F - rear surr-out (6stack)
3377 * port-G - rear clfe-out (6stack)
3380 static hda_nid_t ad1882_dac_nids
[3] = {
3384 static hda_nid_t ad1882_adc_nids
[2] = {
3388 static hda_nid_t ad1882_capsrc_nids
[2] = {
3392 #define AD1882_SPDIF_OUT 0x02
3394 /* list: 0x11, 0x39, 0x3a, 0x18, 0x3c, 0x3b, 0x12, 0x20 */
3395 static struct hda_input_mux ad1882_capture_source
= {
3398 { "Front Mic", 0x1 },
3406 static struct snd_kcontrol_new ad1882_base_mixers
[] = {
3407 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT
),
3408 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT
),
3409 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT
),
3410 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT
),
3411 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT
),
3412 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT
),
3413 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT
),
3414 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT
),
3415 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT
),
3416 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT
),
3417 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT
),
3418 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT
),
3419 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x04, HDA_INPUT
),
3420 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x04, HDA_INPUT
),
3421 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT
),
3422 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT
),
3423 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x07, HDA_INPUT
),
3424 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x07, HDA_INPUT
),
3425 HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT
),
3426 HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT
),
3427 HDA_CODEC_VOLUME("Line-In Boost", 0x3a, 0x0, HDA_OUTPUT
),
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
,
3444 /* SPDIF controls */
3445 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT
),
3447 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3448 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,NONE
) "Source",
3449 /* identical with ad1983 */
3450 .info
= ad1983_spdif_route_info
,
3451 .get
= ad1983_spdif_route_get
,
3452 .put
= ad1983_spdif_route_put
,
3457 static struct snd_kcontrol_new ad1882_3stack_mixers
[] = {
3458 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT
),
3459 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x17, 1, 0x0, HDA_OUTPUT
),
3460 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x17, 2, 0x0, HDA_OUTPUT
),
3462 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3463 .name
= "Channel Mode",
3464 .info
= ad198x_ch_mode_info
,
3465 .get
= ad198x_ch_mode_get
,
3466 .put
= ad198x_ch_mode_put
,
3471 static struct snd_kcontrol_new ad1882_6stack_mixers
[] = {
3472 HDA_CODEC_MUTE("Surround Playback Switch", 0x16, 0x0, HDA_OUTPUT
),
3473 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x24, 1, 0x0, HDA_OUTPUT
),
3474 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x24, 2, 0x0, HDA_OUTPUT
),
3478 static struct hda_verb ad1882_ch2_init
[] = {
3479 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
3480 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3481 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
3482 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
3483 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3484 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
3488 static struct hda_verb ad1882_ch4_init
[] = {
3489 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
3490 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3491 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3492 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
3493 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3494 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
3498 static struct hda_verb ad1882_ch6_init
[] = {
3499 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
3500 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3501 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3502 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
3503 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3504 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3508 static struct hda_channel_mode ad1882_modes
[3] = {
3509 { 2, ad1882_ch2_init
},
3510 { 4, ad1882_ch4_init
},
3511 { 6, ad1882_ch6_init
},
3515 * initialization verbs
3517 static struct hda_verb ad1882_init_verbs
[] = {
3518 /* DACs; mute as default */
3519 {0x03, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
3520 {0x04, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
3521 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
},
3522 /* Port-A (HP) mixer */
3523 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3524 {0x22, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3526 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
3527 {0x11, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3528 /* HP selector - select DAC2 */
3529 {0x37, AC_VERB_SET_CONNECT_SEL
, 0x1},
3530 /* Port-D (Line-out) mixer */
3531 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3532 {0x29, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3534 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
3535 {0x12, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3536 /* Mono-out mixer */
3537 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
3538 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(1)},
3540 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
},
3541 {0x13, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3542 /* Port-B (front mic) pin */
3543 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
3544 {0x14, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3545 {0x39, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
}, /* boost */
3546 /* Port-C (line-in) pin */
3547 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
},
3548 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3549 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
}, /* boost */
3550 /* Port-C mixer - mute as input */
3551 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3552 {0x2c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
3553 /* Port-E (mic-in) pin */
3554 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
},
3555 {0x17, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3556 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_ZERO
}, /* boost */
3557 /* Port-E mixer - mute as input */
3558 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3559 {0x26, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
3560 /* Port-F (surround) */
3561 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
3562 {0x16, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3564 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
3565 {0x24, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
3566 /* Analog mixer; mute as default */
3567 /* list: 0x39, 0x3a, 0x11, 0x12, 0x3c, 0x3b, 0x18, 0x1a */
3568 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)},
3569 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
3570 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(2)},
3571 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(3)},
3572 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(4)},
3573 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(5)},
3574 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(6)},
3575 {0x20, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(7)},
3576 /* Analog Mix output amp */
3577 {0x21, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x1f}, /* 0dB */
3578 /* SPDIF output selector */
3579 {0x02, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x27}, /* 0dB */
3580 {0x02, AC_VERB_SET_CONNECT_SEL
, 0x0}, /* PCM */
3581 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
| 0x27}, /* 0dB */
3585 #ifdef CONFIG_SND_HDA_POWER_SAVE
3586 static struct hda_amp_list ad1882_loopbacks
[] = {
3587 { 0x20, HDA_INPUT
, 0 }, /* Front Mic */
3588 { 0x20, HDA_INPUT
, 1 }, /* Mic */
3589 { 0x20, HDA_INPUT
, 4 }, /* Line */
3590 { 0x20, HDA_INPUT
, 6 }, /* CD */
3602 static const char *ad1882_models
[AD1986A_MODELS
] = {
3603 [AD1882_3STACK
] = "3stack",
3604 [AD1882_6STACK
] = "6stack",
3608 static int patch_ad1882(struct hda_codec
*codec
)
3610 struct ad198x_spec
*spec
;
3613 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
3617 mutex_init(&spec
->amp_mutex
);
3620 spec
->multiout
.max_channels
= 6;
3621 spec
->multiout
.num_dacs
= 3;
3622 spec
->multiout
.dac_nids
= ad1882_dac_nids
;
3623 spec
->multiout
.dig_out_nid
= AD1882_SPDIF_OUT
;
3624 spec
->num_adc_nids
= ARRAY_SIZE(ad1882_adc_nids
);
3625 spec
->adc_nids
= ad1882_adc_nids
;
3626 spec
->capsrc_nids
= ad1882_capsrc_nids
;
3627 spec
->input_mux
= &ad1882_capture_source
;
3628 spec
->num_mixers
= 1;
3629 spec
->mixers
[0] = ad1882_base_mixers
;
3630 spec
->num_init_verbs
= 1;
3631 spec
->init_verbs
[0] = ad1882_init_verbs
;
3632 spec
->spdif_route
= 0;
3633 #ifdef CONFIG_SND_HDA_POWER_SAVE
3634 spec
->loopback
.amplist
= ad1882_loopbacks
;
3636 spec
->vmaster_nid
= 0x04;
3638 codec
->patch_ops
= ad198x_patch_ops
;
3640 /* override some parameters */
3641 board_config
= snd_hda_check_board_config(codec
, AD1882_MODELS
,
3642 ad1882_models
, NULL
);
3643 switch (board_config
) {
3646 spec
->num_mixers
= 2;
3647 spec
->mixers
[1] = ad1882_3stack_mixers
;
3648 spec
->channel_mode
= ad1882_modes
;
3649 spec
->num_channel_mode
= ARRAY_SIZE(ad1882_modes
);
3650 spec
->need_dac_fix
= 1;
3651 spec
->multiout
.max_channels
= 2;
3652 spec
->multiout
.num_dacs
= 1;
3655 spec
->num_mixers
= 2;
3656 spec
->mixers
[1] = ad1882_6stack_mixers
;
3666 struct hda_codec_preset snd_hda_preset_analog
[] = {
3667 { .id
= 0x11d41882, .name
= "AD1882", .patch
= patch_ad1882
},
3668 { .id
= 0x11d41884, .name
= "AD1884", .patch
= patch_ad1884
},
3669 { .id
= 0x11d41981, .name
= "AD1981", .patch
= patch_ad1981
},
3670 { .id
= 0x11d41983, .name
= "AD1983", .patch
= patch_ad1983
},
3671 { .id
= 0x11d41984, .name
= "AD1984", .patch
= patch_ad1984
},
3672 { .id
= 0x11d41986, .name
= "AD1986A", .patch
= patch_ad1986a
},
3673 { .id
= 0x11d41988, .name
= "AD1988", .patch
= patch_ad1988
},
3674 { .id
= 0x11d4198b, .name
= "AD1988B", .patch
= patch_ad1988
},