2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for Realtek ALC codecs
6 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
8 * Takashi Iwai <tiwai@suse.de>
9 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <linux/init.h>
27 #include <linux/delay.h>
28 #include <linux/slab.h>
29 #include <linux/pci.h>
30 #include <linux/module.h>
31 #include <sound/core.h>
32 #include <sound/jack.h>
33 #include "hda_codec.h"
34 #include "hda_local.h"
37 /* unsol event tags */
38 #define ALC_FRONT_EVENT 0x01
39 #define ALC_DCVOL_EVENT 0x02
40 #define ALC_HP_EVENT 0x04
41 #define ALC_MIC_EVENT 0x08
44 #define GPIO_MASK 0x03
46 /* extra amp-initialization sequence types */
55 struct alc_customize_define {
57 unsigned char port_connectivity;
58 unsigned char check_sum;
59 unsigned char customization;
60 unsigned char external_amp;
61 unsigned int enable_pcbeep:1;
62 unsigned int platform_type:1;
64 unsigned int override:1;
65 unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */
71 hda_nid_t pin; /* multi-io widget pin NID */
72 hda_nid_t dac; /* DAC to be connected */
73 unsigned int ctl_in; /* cached input-pin control value */
77 ALC_AUTOMUTE_PIN, /* change the pin control */
78 ALC_AUTOMUTE_AMP, /* mute/unmute the pin AMP */
79 ALC_AUTOMUTE_MIXER, /* mute/unmute mixer widget AMP */
83 /* codec parameterization */
84 const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
85 unsigned int num_mixers;
86 const struct snd_kcontrol_new *cap_mixer; /* capture mixer */
87 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
89 const struct hda_verb *init_verbs[10]; /* initialization verbs
93 unsigned int num_init_verbs;
95 char stream_name_analog[32]; /* analog PCM stream */
96 const struct hda_pcm_stream *stream_analog_playback;
97 const struct hda_pcm_stream *stream_analog_capture;
98 const struct hda_pcm_stream *stream_analog_alt_playback;
99 const struct hda_pcm_stream *stream_analog_alt_capture;
101 char stream_name_digital[32]; /* digital PCM stream */
102 const struct hda_pcm_stream *stream_digital_playback;
103 const struct hda_pcm_stream *stream_digital_capture;
106 struct hda_multi_out multiout; /* playback set-up
107 * max_channels, dacs must be set
108 * dig_out_nid and hp_nid are optional
110 hda_nid_t alt_dac_nid;
111 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
115 unsigned int num_adc_nids;
116 const hda_nid_t *adc_nids;
117 const hda_nid_t *capsrc_nids;
118 hda_nid_t dig_in_nid; /* digital-in NID; optional */
119 hda_nid_t mixer_nid; /* analog-mixer NID */
120 DECLARE_BITMAP(vol_ctls, 0x20 << 1);
121 DECLARE_BITMAP(sw_ctls, 0x20 << 1);
123 /* capture setup for dynamic dual-adc switch */
125 unsigned int cur_adc_stream_tag;
126 unsigned int cur_adc_format;
129 unsigned int num_mux_defs;
130 const struct hda_input_mux *input_mux;
131 unsigned int cur_mux[3];
132 hda_nid_t ext_mic_pin;
133 hda_nid_t dock_mic_pin;
134 hda_nid_t int_mic_pin;
137 const struct hda_channel_mode *channel_mode;
138 int num_channel_mode;
140 int const_channel_count;
141 int ext_channel_count;
143 /* PCM information */
144 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
146 /* dynamic controls, init_verbs and input_mux */
147 struct auto_pin_cfg autocfg;
148 struct alc_customize_define cdefine;
149 struct snd_array kctls;
150 struct hda_input_mux private_imux[3];
151 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
152 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
153 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
154 hda_nid_t imux_pins[HDA_MAX_NUM_INPUTS];
155 unsigned int dyn_adc_idx[HDA_MAX_NUM_INPUTS];
156 int int_mic_idx, ext_mic_idx, dock_mic_idx; /* for auto-mic */
159 void (*init_hook)(struct hda_codec *codec);
160 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
161 #ifdef CONFIG_SND_HDA_POWER_SAVE
162 void (*power_hook)(struct hda_codec *codec);
164 void (*shutup)(struct hda_codec *codec);
165 void (*automute_hook)(struct hda_codec *codec);
167 /* for pin sensing */
168 unsigned int hp_jack_present:1;
169 unsigned int line_jack_present:1;
170 unsigned int master_mute:1;
171 unsigned int auto_mic:1;
172 unsigned int auto_mic_valid_imux:1; /* valid imux for auto-mic */
173 unsigned int automute_speaker:1; /* automute speaker outputs */
174 unsigned int automute_lo:1; /* automute LO outputs */
175 unsigned int detect_hp:1; /* Headphone detection enabled */
176 unsigned int detect_lo:1; /* Line-out detection enabled */
177 unsigned int automute_speaker_possible:1; /* there are speakers and either LO or HP */
178 unsigned int automute_lo_possible:1; /* there are line outs and HP */
181 unsigned int no_analog :1; /* digital I/O only */
182 unsigned int dyn_adc_switch:1; /* switch ADCs (for ALC275) */
183 unsigned int single_input_src:1;
184 unsigned int vol_in_capsrc:1; /* use capsrc volume (ADC has no vol) */
185 unsigned int parse_flags; /* passed to snd_hda_parse_pin_defcfg() */
186 unsigned int shared_mic_hp:1; /* HP/Mic-in sharing */
188 /* auto-mute control */
190 hda_nid_t automute_mixer_nid[AUTO_CFG_MAX_OUTS];
193 int codec_variant; /* flag for other variants */
195 /* for virtual master */
196 hda_nid_t vmaster_nid;
197 #ifdef CONFIG_SND_HDA_POWER_SAVE
198 struct hda_loopback_check loopback;
203 unsigned int pll_coef_idx, pll_coef_bit;
208 const struct alc_fixup *fixup_list;
209 const char *fixup_name;
213 struct alc_multi_io multi_io[4];
216 struct snd_array bind_ctls;
219 #define ALC_MODEL_AUTO 0 /* common for all chips */
221 static bool check_amp_caps(struct hda_codec *codec, hda_nid_t nid,
222 int dir, unsigned int bits)
226 if (get_wcaps(codec, nid) & (1 << (dir + 1)))
227 if (query_amp_caps(codec, nid, dir) & bits)
232 #define nid_has_mute(codec, nid, dir) \
233 check_amp_caps(codec, nid, dir, AC_AMPCAP_MUTE)
234 #define nid_has_volume(codec, nid, dir) \
235 check_amp_caps(codec, nid, dir, AC_AMPCAP_NUM_STEPS)
240 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
241 struct snd_ctl_elem_info *uinfo)
243 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
244 struct alc_spec *spec = codec->spec;
245 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
246 if (mux_idx >= spec->num_mux_defs)
248 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
250 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
253 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
254 struct snd_ctl_elem_value *ucontrol)
256 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
257 struct alc_spec *spec = codec->spec;
258 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
260 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
264 static bool alc_dyn_adc_pcm_resetup(struct hda_codec *codec, int cur)
266 struct alc_spec *spec = codec->spec;
267 hda_nid_t new_adc = spec->adc_nids[spec->dyn_adc_idx[cur]];
269 if (spec->cur_adc && spec->cur_adc != new_adc) {
270 /* stream is running, let's swap the current ADC */
271 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
272 spec->cur_adc = new_adc;
273 snd_hda_codec_setup_stream(codec, new_adc,
274 spec->cur_adc_stream_tag, 0,
275 spec->cur_adc_format);
281 static inline hda_nid_t get_capsrc(struct alc_spec *spec, int idx)
283 return spec->capsrc_nids ?
284 spec->capsrc_nids[idx] : spec->adc_nids[idx];
287 static void call_update_outputs(struct hda_codec *codec);
289 /* select the given imux item; either unmute exclusively or select the route */
290 static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx,
291 unsigned int idx, bool force)
293 struct alc_spec *spec = codec->spec;
294 const struct hda_input_mux *imux;
295 unsigned int mux_idx;
296 int i, type, num_conns;
299 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
300 imux = &spec->input_mux[mux_idx];
301 if (!imux->num_items && mux_idx > 0)
302 imux = &spec->input_mux[0];
304 if (idx >= imux->num_items)
305 idx = imux->num_items - 1;
306 if (spec->cur_mux[adc_idx] == idx && !force)
308 spec->cur_mux[adc_idx] = idx;
310 /* for shared I/O, change the pin-control accordingly */
311 if (spec->shared_mic_hp) {
312 /* NOTE: this assumes that there are only two inputs, the
313 * first is the real internal mic and the second is HP jack.
315 snd_hda_codec_write(codec, spec->autocfg.inputs[1].pin, 0,
316 AC_VERB_SET_PIN_WIDGET_CONTROL,
317 spec->cur_mux[adc_idx] ?
318 PIN_VREF80 : PIN_HP);
319 spec->automute_speaker = !spec->cur_mux[adc_idx];
320 call_update_outputs(codec);
323 if (spec->dyn_adc_switch) {
324 alc_dyn_adc_pcm_resetup(codec, idx);
325 adc_idx = spec->dyn_adc_idx[idx];
328 nid = get_capsrc(spec, adc_idx);
331 num_conns = snd_hda_get_conn_list(codec, nid, NULL);
335 type = get_wcaps_type(get_wcaps(codec, nid));
336 if (type == AC_WID_AUD_MIX) {
337 /* Matrix-mixer style (e.g. ALC882) */
338 int active = imux->items[idx].index;
339 for (i = 0; i < num_conns; i++) {
340 unsigned int v = (i == active) ? 0 : HDA_AMP_MUTE;
341 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, i,
345 /* MUX style (e.g. ALC880) */
346 snd_hda_codec_write_cache(codec, nid, 0,
347 AC_VERB_SET_CONNECT_SEL,
348 imux->items[idx].index);
353 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
354 struct snd_ctl_elem_value *ucontrol)
356 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
357 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
358 return alc_mux_select(codec, adc_idx,
359 ucontrol->value.enumerated.item[0], false);
363 * set up the input pin config (depending on the given auto-pin type)
365 static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
368 unsigned int val = PIN_IN;
370 if (auto_pin_type == AUTO_PIN_MIC) {
373 oldval = snd_hda_codec_read(codec, nid, 0,
374 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
375 pincap = snd_hda_query_pin_caps(codec, nid);
376 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
377 /* if the default pin setup is vref50, we give it priority */
378 if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50)
380 else if (pincap & AC_PINCAP_VREF_50)
382 else if (pincap & AC_PINCAP_VREF_100)
384 else if (pincap & AC_PINCAP_VREF_GRD)
387 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
391 * Append the given mixer and verb elements for the later use
392 * The mixer array is referred in build_controls(), and init_verbs are
395 static void add_mixer(struct alc_spec *spec, const struct snd_kcontrol_new *mix)
397 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
399 spec->mixers[spec->num_mixers++] = mix;
402 static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
404 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
406 spec->init_verbs[spec->num_init_verbs++] = verb;
410 * GPIO setup tables, used in initialization
412 /* Enable GPIO mask and set output */
413 static const struct hda_verb alc_gpio1_init_verbs[] = {
414 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
415 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
416 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
420 static const struct hda_verb alc_gpio2_init_verbs[] = {
421 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
422 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
423 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
427 static const struct hda_verb alc_gpio3_init_verbs[] = {
428 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
429 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
430 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
435 * Fix hardware PLL issue
436 * On some codecs, the analog PLL gating control must be off while
437 * the default value is 1.
439 static void alc_fix_pll(struct hda_codec *codec)
441 struct alc_spec *spec = codec->spec;
446 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
448 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
449 AC_VERB_GET_PROC_COEF, 0);
450 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
452 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
453 val & ~(1 << spec->pll_coef_bit));
456 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
457 unsigned int coef_idx, unsigned int coef_bit)
459 struct alc_spec *spec = codec->spec;
461 spec->pll_coef_idx = coef_idx;
462 spec->pll_coef_bit = coef_bit;
467 * Jack-reporting via input-jack layer
470 /* initialization of jacks; currently checks only a few known pins */
471 static int alc_init_jacks(struct hda_codec *codec)
473 #ifdef CONFIG_SND_HDA_INPUT_JACK
474 struct alc_spec *spec = codec->spec;
476 unsigned int hp_nid = spec->autocfg.hp_pins[0];
477 unsigned int mic_nid = spec->ext_mic_pin;
478 unsigned int dock_nid = spec->dock_mic_pin;
481 err = snd_hda_input_jack_add(codec, hp_nid,
482 SND_JACK_HEADPHONE, NULL);
485 snd_hda_input_jack_report(codec, hp_nid);
489 err = snd_hda_input_jack_add(codec, mic_nid,
490 SND_JACK_MICROPHONE, NULL);
493 snd_hda_input_jack_report(codec, mic_nid);
496 err = snd_hda_input_jack_add(codec, dock_nid,
497 SND_JACK_MICROPHONE, NULL);
500 snd_hda_input_jack_report(codec, dock_nid);
502 #endif /* CONFIG_SND_HDA_INPUT_JACK */
507 * Jack detections for HP auto-mute and mic-switch
510 /* check each pin in the given array; returns true if any of them is plugged */
511 static bool detect_jacks(struct hda_codec *codec, int num_pins, hda_nid_t *pins)
515 for (i = 0; i < num_pins; i++) {
516 hda_nid_t nid = pins[i];
519 snd_hda_input_jack_report(codec, nid);
520 present |= snd_hda_jack_detect(codec, nid);
525 /* standard HP/line-out auto-mute helper */
526 static void do_automute(struct hda_codec *codec, int num_pins, hda_nid_t *pins,
527 bool mute, bool hp_out)
529 struct alc_spec *spec = codec->spec;
530 unsigned int mute_bits = mute ? HDA_AMP_MUTE : 0;
531 unsigned int pin_bits = mute ? 0 : (hp_out ? PIN_HP : PIN_OUT);
534 for (i = 0; i < num_pins; i++) {
535 hda_nid_t nid = pins[i];
538 switch (spec->automute_mode) {
539 case ALC_AUTOMUTE_PIN:
540 snd_hda_codec_write(codec, nid, 0,
541 AC_VERB_SET_PIN_WIDGET_CONTROL,
544 case ALC_AUTOMUTE_AMP:
545 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
546 HDA_AMP_MUTE, mute_bits);
548 case ALC_AUTOMUTE_MIXER:
549 nid = spec->automute_mixer_nid[i];
552 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
553 HDA_AMP_MUTE, mute_bits);
554 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 1,
555 HDA_AMP_MUTE, mute_bits);
561 /* Toggle outputs muting */
562 static void update_outputs(struct hda_codec *codec)
564 struct alc_spec *spec = codec->spec;
567 /* Control HP pins/amps depending on master_mute state;
568 * in general, HP pins/amps control should be enabled in all cases,
569 * but currently set only for master_mute, just to be safe
571 if (!spec->shared_mic_hp) /* don't change HP-pin when shared with mic */
572 do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins),
573 spec->autocfg.hp_pins, spec->master_mute, true);
575 if (!spec->automute_speaker)
578 on = spec->hp_jack_present | spec->line_jack_present;
579 on |= spec->master_mute;
580 do_automute(codec, ARRAY_SIZE(spec->autocfg.speaker_pins),
581 spec->autocfg.speaker_pins, on, false);
583 /* toggle line-out mutes if needed, too */
584 /* if LO is a copy of either HP or Speaker, don't need to handle it */
585 if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0] ||
586 spec->autocfg.line_out_pins[0] == spec->autocfg.speaker_pins[0])
588 if (!spec->automute_lo)
591 on = spec->hp_jack_present;
592 on |= spec->master_mute;
593 do_automute(codec, ARRAY_SIZE(spec->autocfg.line_out_pins),
594 spec->autocfg.line_out_pins, on, false);
597 static void call_update_outputs(struct hda_codec *codec)
599 struct alc_spec *spec = codec->spec;
600 if (spec->automute_hook)
601 spec->automute_hook(codec);
603 update_outputs(codec);
606 /* standard HP-automute helper */
607 static void alc_hp_automute(struct hda_codec *codec)
609 struct alc_spec *spec = codec->spec;
611 spec->hp_jack_present =
612 detect_jacks(codec, ARRAY_SIZE(spec->autocfg.hp_pins),
613 spec->autocfg.hp_pins);
614 if (!spec->detect_hp || (!spec->automute_speaker && !spec->automute_lo))
616 call_update_outputs(codec);
619 /* standard line-out-automute helper */
620 static void alc_line_automute(struct hda_codec *codec)
622 struct alc_spec *spec = codec->spec;
624 /* check LO jack only when it's different from HP */
625 if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0])
628 spec->line_jack_present =
629 detect_jacks(codec, ARRAY_SIZE(spec->autocfg.line_out_pins),
630 spec->autocfg.line_out_pins);
631 if (!spec->automute_speaker || !spec->detect_lo)
633 call_update_outputs(codec);
636 #define get_connection_index(codec, mux, nid) \
637 snd_hda_get_conn_index(codec, mux, nid, 0)
639 /* standard mic auto-switch helper */
640 static void alc_mic_automute(struct hda_codec *codec)
642 struct alc_spec *spec = codec->spec;
643 hda_nid_t *pins = spec->imux_pins;
645 if (!spec->auto_mic || !spec->auto_mic_valid_imux)
647 if (snd_BUG_ON(!spec->adc_nids))
649 if (snd_BUG_ON(spec->int_mic_idx < 0 || spec->ext_mic_idx < 0))
652 if (snd_hda_jack_detect(codec, pins[spec->ext_mic_idx]))
653 alc_mux_select(codec, 0, spec->ext_mic_idx, false);
654 else if (spec->dock_mic_idx >= 0 &&
655 snd_hda_jack_detect(codec, pins[spec->dock_mic_idx]))
656 alc_mux_select(codec, 0, spec->dock_mic_idx, false);
658 alc_mux_select(codec, 0, spec->int_mic_idx, false);
660 snd_hda_input_jack_report(codec, pins[spec->ext_mic_idx]);
661 if (spec->dock_mic_idx >= 0)
662 snd_hda_input_jack_report(codec, pins[spec->dock_mic_idx]);
665 /* unsolicited event for HP jack sensing */
666 static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
668 if (codec->vendor_id == 0x10ec0880)
674 alc_hp_automute(codec);
676 case ALC_FRONT_EVENT:
677 alc_line_automute(codec);
680 alc_mic_automute(codec);
685 /* call init functions of standard auto-mute helpers */
686 static void alc_inithook(struct hda_codec *codec)
688 alc_hp_automute(codec);
689 alc_line_automute(codec);
690 alc_mic_automute(codec);
693 /* additional initialization for ALC888 variants */
694 static void alc888_coef_init(struct hda_codec *codec)
698 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
699 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
700 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
701 if ((tmp & 0xf0) == 0x20)
703 snd_hda_codec_read(codec, 0x20, 0,
704 AC_VERB_SET_PROC_COEF, 0x830);
707 snd_hda_codec_read(codec, 0x20, 0,
708 AC_VERB_SET_PROC_COEF, 0x3030);
711 /* additional initialization for ALC889 variants */
712 static void alc889_coef_init(struct hda_codec *codec)
716 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
717 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
718 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
719 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
722 /* turn on/off EAPD control (only if available) */
723 static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
725 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
727 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
728 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
732 /* turn on/off EAPD controls of the codec */
733 static void alc_auto_setup_eapd(struct hda_codec *codec, bool on)
735 /* We currently only handle front, HP */
736 static hda_nid_t pins[] = {
737 0x0f, 0x10, 0x14, 0x15, 0
740 for (p = pins; *p; p++)
741 set_eapd(codec, *p, on);
744 /* generic shutup callback;
745 * just turning off EPAD and a little pause for avoiding pop-noise
747 static void alc_eapd_shutup(struct hda_codec *codec)
749 alc_auto_setup_eapd(codec, false);
753 /* generic EAPD initialization */
754 static void alc_auto_init_amp(struct hda_codec *codec, int type)
758 alc_auto_setup_eapd(codec, true);
761 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
764 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
767 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
769 case ALC_INIT_DEFAULT:
770 switch (codec->vendor_id) {
772 snd_hda_codec_write(codec, 0x1a, 0,
773 AC_VERB_SET_COEF_INDEX, 7);
774 tmp = snd_hda_codec_read(codec, 0x1a, 0,
775 AC_VERB_GET_PROC_COEF, 0);
776 snd_hda_codec_write(codec, 0x1a, 0,
777 AC_VERB_SET_COEF_INDEX, 7);
778 snd_hda_codec_write(codec, 0x1a, 0,
779 AC_VERB_SET_PROC_COEF,
788 /*case 0x10ec0889:*/ /* this causes an SPDIF problem */
789 alc889_coef_init(codec);
792 alc888_coef_init(codec);
794 #if 0 /* XXX: This may cause the silent output on speaker on some machines */
797 snd_hda_codec_write(codec, 0x20, 0,
798 AC_VERB_SET_COEF_INDEX, 7);
799 tmp = snd_hda_codec_read(codec, 0x20, 0,
800 AC_VERB_GET_PROC_COEF, 0);
801 snd_hda_codec_write(codec, 0x20, 0,
802 AC_VERB_SET_COEF_INDEX, 7);
803 snd_hda_codec_write(codec, 0x20, 0,
804 AC_VERB_SET_PROC_COEF,
814 * Auto-Mute mode mixer enum support
816 static int alc_automute_mode_info(struct snd_kcontrol *kcontrol,
817 struct snd_ctl_elem_info *uinfo)
819 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
820 struct alc_spec *spec = codec->spec;
821 static const char * const texts2[] = {
822 "Disabled", "Enabled"
824 static const char * const texts3[] = {
825 "Disabled", "Speaker Only", "Line-Out+Speaker"
827 const char * const *texts;
829 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
831 if (spec->automute_speaker_possible && spec->automute_lo_possible) {
832 uinfo->value.enumerated.items = 3;
835 uinfo->value.enumerated.items = 2;
838 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
839 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
840 strcpy(uinfo->value.enumerated.name,
841 texts[uinfo->value.enumerated.item]);
845 static int alc_automute_mode_get(struct snd_kcontrol *kcontrol,
846 struct snd_ctl_elem_value *ucontrol)
848 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
849 struct alc_spec *spec = codec->spec;
850 unsigned int val = 0;
851 if (spec->automute_speaker)
853 if (spec->automute_lo)
856 ucontrol->value.enumerated.item[0] = val;
860 static int alc_automute_mode_put(struct snd_kcontrol *kcontrol,
861 struct snd_ctl_elem_value *ucontrol)
863 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
864 struct alc_spec *spec = codec->spec;
866 switch (ucontrol->value.enumerated.item[0]) {
868 if (!spec->automute_speaker && !spec->automute_lo)
870 spec->automute_speaker = 0;
871 spec->automute_lo = 0;
874 if (spec->automute_speaker_possible) {
875 if (!spec->automute_lo && spec->automute_speaker)
877 spec->automute_speaker = 1;
878 spec->automute_lo = 0;
879 } else if (spec->automute_lo_possible) {
880 if (spec->automute_lo)
882 spec->automute_lo = 1;
887 if (!spec->automute_lo_possible || !spec->automute_speaker_possible)
889 if (spec->automute_speaker && spec->automute_lo)
891 spec->automute_speaker = 1;
892 spec->automute_lo = 1;
897 call_update_outputs(codec);
901 static const struct snd_kcontrol_new alc_automute_mode_enum = {
902 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
903 .name = "Auto-Mute Mode",
904 .info = alc_automute_mode_info,
905 .get = alc_automute_mode_get,
906 .put = alc_automute_mode_put,
909 static struct snd_kcontrol_new *alc_kcontrol_new(struct alc_spec *spec)
911 snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32);
912 return snd_array_new(&spec->kctls);
915 static int alc_add_automute_mode_enum(struct hda_codec *codec)
917 struct alc_spec *spec = codec->spec;
918 struct snd_kcontrol_new *knew;
920 knew = alc_kcontrol_new(spec);
923 *knew = alc_automute_mode_enum;
924 knew->name = kstrdup("Auto-Mute Mode", GFP_KERNEL);
931 * Check the availability of HP/line-out auto-mute;
932 * Set up appropriately if really supported
934 static void alc_init_automute(struct hda_codec *codec)
936 struct alc_spec *spec = codec->spec;
937 struct auto_pin_cfg *cfg = &spec->autocfg;
943 if (cfg->line_out_pins[0])
945 if (cfg->speaker_pins[0])
947 if (present < 2) /* need two different output types */
950 if (!cfg->speaker_pins[0] &&
951 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
952 memcpy(cfg->speaker_pins, cfg->line_out_pins,
953 sizeof(cfg->speaker_pins));
954 cfg->speaker_outs = cfg->line_outs;
957 if (!cfg->hp_pins[0] &&
958 cfg->line_out_type == AUTO_PIN_HP_OUT) {
959 memcpy(cfg->hp_pins, cfg->line_out_pins,
960 sizeof(cfg->hp_pins));
961 cfg->hp_outs = cfg->line_outs;
964 spec->automute_mode = ALC_AUTOMUTE_PIN;
966 for (i = 0; i < cfg->hp_outs; i++) {
967 hda_nid_t nid = cfg->hp_pins[i];
968 if (!is_jack_detectable(codec, nid))
970 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
972 snd_hda_codec_write_cache(codec, nid, 0,
973 AC_VERB_SET_UNSOLICITED_ENABLE,
974 AC_USRSP_EN | ALC_HP_EVENT);
978 if (cfg->line_out_type == AUTO_PIN_LINE_OUT && cfg->line_outs) {
979 if (cfg->speaker_outs)
980 for (i = 0; i < cfg->line_outs; i++) {
981 hda_nid_t nid = cfg->line_out_pins[i];
982 if (!is_jack_detectable(codec, nid))
984 snd_printdd("realtek: Enable Line-Out "
985 "auto-muting on NID 0x%x\n", nid);
986 snd_hda_codec_write_cache(codec, nid, 0,
987 AC_VERB_SET_UNSOLICITED_ENABLE,
988 AC_USRSP_EN | ALC_FRONT_EVENT);
991 spec->automute_lo_possible = spec->detect_hp;
994 spec->automute_speaker_possible = cfg->speaker_outs &&
995 (spec->detect_hp || spec->detect_lo);
997 spec->automute_lo = spec->automute_lo_possible;
998 spec->automute_speaker = spec->automute_speaker_possible;
1000 if (spec->automute_speaker_possible || spec->automute_lo_possible) {
1001 /* create a control for automute mode */
1002 alc_add_automute_mode_enum(codec);
1003 spec->unsol_event = alc_sku_unsol_event;
1007 /* return the position of NID in the list, or -1 if not found */
1008 static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
1011 for (i = 0; i < nums; i++)
1017 /* check whether dynamic ADC-switching is available */
1018 static bool alc_check_dyn_adc_switch(struct hda_codec *codec)
1020 struct alc_spec *spec = codec->spec;
1021 struct hda_input_mux *imux = &spec->private_imux[0];
1025 if (imux != spec->input_mux) /* no dynamic imux? */
1028 for (n = 0; n < spec->num_adc_nids; n++) {
1029 cap = spec->private_capsrc_nids[n];
1030 for (i = 0; i < imux->num_items; i++) {
1031 pin = spec->imux_pins[i];
1034 if (get_connection_index(codec, cap, pin) < 0)
1037 if (i >= imux->num_items)
1038 return true; /* no ADC-switch is needed */
1041 for (i = 0; i < imux->num_items; i++) {
1042 pin = spec->imux_pins[i];
1043 for (n = 0; n < spec->num_adc_nids; n++) {
1044 cap = spec->private_capsrc_nids[n];
1045 idx = get_connection_index(codec, cap, pin);
1047 imux->items[i].index = idx;
1048 spec->dyn_adc_idx[i] = n;
1054 snd_printdd("realtek: enabling ADC switching\n");
1055 spec->dyn_adc_switch = 1;
1059 /* rebuild imux for matching with the given auto-mic pins (if not yet) */
1060 static bool alc_rebuild_imux_for_auto_mic(struct hda_codec *codec)
1062 struct alc_spec *spec = codec->spec;
1063 struct hda_input_mux *imux;
1064 static char * const texts[3] = {
1065 "Mic", "Internal Mic", "Dock Mic"
1069 if (!spec->auto_mic)
1071 imux = &spec->private_imux[0];
1072 if (spec->input_mux == imux)
1074 spec->imux_pins[0] = spec->ext_mic_pin;
1075 spec->imux_pins[1] = spec->int_mic_pin;
1076 spec->imux_pins[2] = spec->dock_mic_pin;
1077 for (i = 0; i < 3; i++) {
1078 strcpy(imux->items[i].label, texts[i]);
1079 if (spec->imux_pins[i]) {
1080 hda_nid_t pin = spec->imux_pins[i];
1082 for (c = 0; c < spec->num_adc_nids; c++) {
1083 hda_nid_t cap = get_capsrc(spec, c);
1084 int idx = get_connection_index(codec, cap, pin);
1086 imux->items[i].index = idx;
1090 imux->num_items = i + 1;
1093 spec->num_mux_defs = 1;
1094 spec->input_mux = imux;
1098 /* check whether all auto-mic pins are valid; setup indices if OK */
1099 static bool alc_auto_mic_check_imux(struct hda_codec *codec)
1101 struct alc_spec *spec = codec->spec;
1102 const struct hda_input_mux *imux;
1104 if (!spec->auto_mic)
1106 if (spec->auto_mic_valid_imux)
1107 return true; /* already checked */
1109 /* fill up imux indices */
1110 if (!alc_check_dyn_adc_switch(codec)) {
1115 imux = spec->input_mux;
1116 spec->ext_mic_idx = find_idx_in_nid_list(spec->ext_mic_pin,
1117 spec->imux_pins, imux->num_items);
1118 spec->int_mic_idx = find_idx_in_nid_list(spec->int_mic_pin,
1119 spec->imux_pins, imux->num_items);
1120 spec->dock_mic_idx = find_idx_in_nid_list(spec->dock_mic_pin,
1121 spec->imux_pins, imux->num_items);
1122 if (spec->ext_mic_idx < 0 || spec->int_mic_idx < 0) {
1124 return false; /* no corresponding imux */
1127 snd_hda_codec_write_cache(codec, spec->ext_mic_pin, 0,
1128 AC_VERB_SET_UNSOLICITED_ENABLE,
1129 AC_USRSP_EN | ALC_MIC_EVENT);
1130 if (spec->dock_mic_pin)
1131 snd_hda_codec_write_cache(codec, spec->dock_mic_pin, 0,
1132 AC_VERB_SET_UNSOLICITED_ENABLE,
1133 AC_USRSP_EN | ALC_MIC_EVENT);
1135 spec->auto_mic_valid_imux = 1;
1141 * Check the availability of auto-mic switch;
1142 * Set up if really supported
1144 static void alc_init_auto_mic(struct hda_codec *codec)
1146 struct alc_spec *spec = codec->spec;
1147 struct auto_pin_cfg *cfg = &spec->autocfg;
1148 hda_nid_t fixed, ext, dock;
1151 if (spec->shared_mic_hp)
1152 return; /* no auto-mic for the shared I/O */
1154 spec->ext_mic_idx = spec->int_mic_idx = spec->dock_mic_idx = -1;
1156 fixed = ext = dock = 0;
1157 for (i = 0; i < cfg->num_inputs; i++) {
1158 hda_nid_t nid = cfg->inputs[i].pin;
1159 unsigned int defcfg;
1160 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1161 switch (snd_hda_get_input_pin_attr(defcfg)) {
1162 case INPUT_PIN_ATTR_INT:
1164 return; /* already occupied */
1165 if (cfg->inputs[i].type != AUTO_PIN_MIC)
1166 return; /* invalid type */
1169 case INPUT_PIN_ATTR_UNUSED:
1170 return; /* invalid entry */
1171 case INPUT_PIN_ATTR_DOCK:
1173 return; /* already occupied */
1174 if (cfg->inputs[i].type > AUTO_PIN_LINE_IN)
1175 return; /* invalid type */
1180 return; /* already occupied */
1181 if (cfg->inputs[i].type != AUTO_PIN_MIC)
1182 return; /* invalid type */
1193 if (!is_jack_detectable(codec, ext))
1194 return; /* no unsol support */
1195 if (dock && !is_jack_detectable(codec, dock))
1196 return; /* no unsol support */
1198 /* check imux indices */
1199 spec->ext_mic_pin = ext;
1200 spec->int_mic_pin = fixed;
1201 spec->dock_mic_pin = dock;
1204 if (!alc_auto_mic_check_imux(codec))
1207 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n",
1209 spec->unsol_event = alc_sku_unsol_event;
1212 /* check the availabilities of auto-mute and auto-mic switches */
1213 static void alc_auto_check_switches(struct hda_codec *codec)
1215 alc_init_automute(codec);
1216 alc_init_auto_mic(codec);
1220 * Realtek SSID verification
1223 /* Could be any non-zero and even value. When used as fixup, tells
1224 * the driver to ignore any present sku defines.
1226 #define ALC_FIXUP_SKU_IGNORE (2)
1228 static int alc_auto_parse_customize_define(struct hda_codec *codec)
1230 unsigned int ass, tmp, i;
1232 struct alc_spec *spec = codec->spec;
1234 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1236 if (spec->cdefine.fixup) {
1237 ass = spec->cdefine.sku_cfg;
1238 if (ass == ALC_FIXUP_SKU_IGNORE)
1243 ass = codec->subsystem_id & 0xffff;
1244 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
1248 if (codec->vendor_id == 0x10ec0260)
1250 ass = snd_hda_codec_get_pincfg(codec, nid);
1253 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1254 codec->chip_name, ass);
1260 for (i = 1; i < 16; i++) {
1264 if (((ass >> 16) & 0xf) != tmp)
1267 spec->cdefine.port_connectivity = ass >> 30;
1268 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1269 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1270 spec->cdefine.customization = ass >> 8;
1272 spec->cdefine.sku_cfg = ass;
1273 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1274 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1275 spec->cdefine.swap = (ass & 0x2) >> 1;
1276 spec->cdefine.override = ass & 0x1;
1278 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1279 nid, spec->cdefine.sku_cfg);
1280 snd_printd("SKU: port_connectivity=0x%x\n",
1281 spec->cdefine.port_connectivity);
1282 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1283 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1284 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1285 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1286 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1287 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1288 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1293 /* return true if the given NID is found in the list */
1294 static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
1296 return find_idx_in_nid_list(nid, list, nums) >= 0;
1299 /* check subsystem ID and set up device-specific initialization;
1300 * return 1 if initialized, 0 if invalid SSID
1302 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1303 * 31 ~ 16 : Manufacture ID
1305 * 7 ~ 0 : Assembly ID
1306 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1308 static int alc_subsystem_id(struct hda_codec *codec,
1309 hda_nid_t porta, hda_nid_t porte,
1310 hda_nid_t portd, hda_nid_t porti)
1312 unsigned int ass, tmp, i;
1314 struct alc_spec *spec = codec->spec;
1316 if (spec->cdefine.fixup) {
1317 ass = spec->cdefine.sku_cfg;
1318 if (ass == ALC_FIXUP_SKU_IGNORE)
1323 ass = codec->subsystem_id & 0xffff;
1324 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1327 /* invalid SSID, check the special NID pin defcfg instead */
1329 * 31~30 : port connectivity
1332 * 19~16 : Check sum (15:1)
1337 if (codec->vendor_id == 0x10ec0260)
1339 ass = snd_hda_codec_get_pincfg(codec, nid);
1340 snd_printd("realtek: No valid SSID, "
1341 "checking pincfg 0x%08x for NID 0x%x\n",
1345 if ((ass >> 30) != 1) /* no physical connection */
1350 for (i = 1; i < 16; i++) {
1354 if (((ass >> 16) & 0xf) != tmp)
1357 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1358 ass & 0xffff, codec->vendor_id);
1362 * 2 : 0 --> Desktop, 1 --> Laptop
1363 * 3~5 : External Amplifier control
1366 tmp = (ass & 0x38) >> 3; /* external Amp control */
1369 spec->init_amp = ALC_INIT_GPIO1;
1372 spec->init_amp = ALC_INIT_GPIO2;
1375 spec->init_amp = ALC_INIT_GPIO3;
1379 spec->init_amp = ALC_INIT_DEFAULT;
1383 /* is laptop or Desktop and enable the function "Mute internal speaker
1384 * when the external headphone out jack is plugged"
1386 if (!(ass & 0x8000))
1389 * 10~8 : Jack location
1390 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1392 * 15 : 1 --> enable the function "Mute internal speaker
1393 * when the external headphone out jack is plugged"
1395 if (!spec->autocfg.hp_pins[0] &&
1396 !(spec->autocfg.line_out_pins[0] &&
1397 spec->autocfg.line_out_type == AUTO_PIN_HP_OUT)) {
1399 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1410 if (found_in_nid_list(nid, spec->autocfg.line_out_pins,
1411 spec->autocfg.line_outs))
1413 spec->autocfg.hp_pins[0] = nid;
1418 /* Check the validity of ALC subsystem-id
1419 * ports contains an array of 4 pin NIDs for port-A, E, D and I */
1420 static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports)
1422 if (!alc_subsystem_id(codec, ports[0], ports[1], ports[2], ports[3])) {
1423 struct alc_spec *spec = codec->spec;
1424 snd_printd("realtek: "
1425 "Enable default setup for auto mode as fallback\n");
1426 spec->init_amp = ALC_INIT_DEFAULT;
1431 * Fix-up pin default configurations and add default verbs
1439 struct alc_model_fixup {
1450 const struct alc_pincfg *pins;
1451 const struct hda_verb *verbs;
1452 void (*func)(struct hda_codec *codec,
1453 const struct alc_fixup *fix,
1467 ALC_FIXUP_ACT_PRE_PROBE,
1468 ALC_FIXUP_ACT_PROBE,
1472 static void alc_apply_fixup(struct hda_codec *codec, int action)
1474 struct alc_spec *spec = codec->spec;
1475 int id = spec->fixup_id;
1476 #ifdef CONFIG_SND_DEBUG_VERBOSE
1477 const char *modelname = spec->fixup_name;
1481 if (!spec->fixup_list)
1485 const struct alc_fixup *fix = spec->fixup_list + id;
1486 const struct alc_pincfg *cfg;
1488 switch (fix->type) {
1490 if (action != ALC_FIXUP_ACT_PRE_PROBE || !fix->v.sku)
1492 snd_printdd(KERN_INFO "hda_codec: %s: "
1493 "Apply sku override for %s\n",
1494 codec->chip_name, modelname);
1495 spec->cdefine.sku_cfg = fix->v.sku;
1496 spec->cdefine.fixup = 1;
1498 case ALC_FIXUP_PINS:
1500 if (action != ALC_FIXUP_ACT_PRE_PROBE || !cfg)
1502 snd_printdd(KERN_INFO "hda_codec: %s: "
1503 "Apply pincfg for %s\n",
1504 codec->chip_name, modelname);
1505 for (; cfg->nid; cfg++)
1506 snd_hda_codec_set_pincfg(codec, cfg->nid,
1509 case ALC_FIXUP_VERBS:
1510 if (action != ALC_FIXUP_ACT_PROBE || !fix->v.verbs)
1512 snd_printdd(KERN_INFO "hda_codec: %s: "
1513 "Apply fix-verbs for %s\n",
1514 codec->chip_name, modelname);
1515 add_verb(codec->spec, fix->v.verbs);
1517 case ALC_FIXUP_FUNC:
1520 snd_printdd(KERN_INFO "hda_codec: %s: "
1521 "Apply fix-func for %s\n",
1522 codec->chip_name, modelname);
1523 fix->v.func(codec, fix, action);
1526 snd_printk(KERN_ERR "hda_codec: %s: "
1527 "Invalid fixup type %d\n",
1528 codec->chip_name, fix->type);
1539 static void alc_pick_fixup(struct hda_codec *codec,
1540 const struct alc_model_fixup *models,
1541 const struct snd_pci_quirk *quirk,
1542 const struct alc_fixup *fixlist)
1544 struct alc_spec *spec = codec->spec;
1545 const struct snd_pci_quirk *q;
1547 const char *name = NULL;
1549 if (codec->modelname && models) {
1550 while (models->name) {
1551 if (!strcmp(codec->modelname, models->name)) {
1553 name = models->name;
1560 q = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1563 #ifdef CONFIG_SND_DEBUG_VERBOSE
1569 for (q = quirk; q->subvendor; q++) {
1570 unsigned int vendorid =
1571 q->subdevice | (q->subvendor << 16);
1572 if (vendorid == codec->subsystem_id) {
1574 #ifdef CONFIG_SND_DEBUG_VERBOSE
1582 spec->fixup_id = id;
1584 spec->fixup_list = fixlist;
1585 spec->fixup_name = name;
1590 * COEF access helper functions
1592 static int alc_read_coef_idx(struct hda_codec *codec,
1593 unsigned int coef_idx)
1596 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1598 val = snd_hda_codec_read(codec, 0x20, 0,
1599 AC_VERB_GET_PROC_COEF, 0);
1603 static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
1604 unsigned int coef_val)
1606 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1608 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
1612 /* a special bypass for COEF 0; read the cached value at the second time */
1613 static unsigned int alc_get_coef0(struct hda_codec *codec)
1615 struct alc_spec *spec = codec->spec;
1617 spec->coef0 = alc_read_coef_idx(codec, 0);
1622 * Digital I/O handling
1625 /* set right pin controls for digital I/O */
1626 static void alc_auto_init_digital(struct hda_codec *codec)
1628 struct alc_spec *spec = codec->spec;
1632 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1633 pin = spec->autocfg.dig_out_pins[i];
1636 snd_hda_codec_write(codec, pin, 0,
1637 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
1639 dac = spec->multiout.dig_out_nid;
1641 dac = spec->slave_dig_outs[i - 1];
1642 if (!dac || !(get_wcaps(codec, dac) & AC_WCAP_OUT_AMP))
1644 snd_hda_codec_write(codec, dac, 0,
1645 AC_VERB_SET_AMP_GAIN_MUTE,
1648 pin = spec->autocfg.dig_in_pin;
1650 snd_hda_codec_write(codec, pin, 0,
1651 AC_VERB_SET_PIN_WIDGET_CONTROL,
1655 /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1656 static void alc_auto_parse_digital(struct hda_codec *codec)
1658 struct alc_spec *spec = codec->spec;
1662 /* support multiple SPDIFs; the secondary is set up as a slave */
1664 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1666 err = snd_hda_get_connections(codec,
1667 spec->autocfg.dig_out_pins[i],
1668 conn, ARRAY_SIZE(conn));
1671 dig_nid = conn[0]; /* assume the first element is audio-out */
1673 spec->multiout.dig_out_nid = dig_nid;
1674 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1676 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1677 if (nums >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1679 spec->slave_dig_outs[nums - 1] = dig_nid;
1684 if (spec->autocfg.dig_in_pin) {
1685 dig_nid = codec->start_nid;
1686 for (i = 0; i < codec->num_nodes; i++, dig_nid++) {
1687 unsigned int wcaps = get_wcaps(codec, dig_nid);
1688 if (get_wcaps_type(wcaps) != AC_WID_AUD_IN)
1690 if (!(wcaps & AC_WCAP_DIGITAL))
1692 if (!(wcaps & AC_WCAP_CONN_LIST))
1694 err = get_connection_index(codec, dig_nid,
1695 spec->autocfg.dig_in_pin);
1697 spec->dig_in_nid = dig_nid;
1705 * capture mixer elements
1707 static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1708 struct snd_ctl_elem_info *uinfo)
1710 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1711 struct alc_spec *spec = codec->spec;
1715 mutex_lock(&codec->control_mutex);
1716 if (spec->vol_in_capsrc)
1717 val = HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[0], 3, 0, HDA_OUTPUT);
1719 val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, HDA_INPUT);
1720 kcontrol->private_value = val;
1721 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
1722 mutex_unlock(&codec->control_mutex);
1726 static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1727 unsigned int size, unsigned int __user *tlv)
1729 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1730 struct alc_spec *spec = codec->spec;
1734 mutex_lock(&codec->control_mutex);
1735 if (spec->vol_in_capsrc)
1736 val = HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[0], 3, 0, HDA_OUTPUT);
1738 val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, HDA_INPUT);
1739 kcontrol->private_value = val;
1740 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
1741 mutex_unlock(&codec->control_mutex);
1745 typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1746 struct snd_ctl_elem_value *ucontrol);
1748 static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1749 struct snd_ctl_elem_value *ucontrol,
1750 getput_call_t func, bool check_adc_switch)
1752 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1753 struct alc_spec *spec = codec->spec;
1756 mutex_lock(&codec->control_mutex);
1757 if (check_adc_switch && spec->dyn_adc_switch) {
1758 for (i = 0; i < spec->num_adc_nids; i++) {
1759 kcontrol->private_value =
1760 HDA_COMPOSE_AMP_VAL(spec->adc_nids[i],
1762 err = func(kcontrol, ucontrol);
1767 i = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1768 if (spec->vol_in_capsrc)
1769 kcontrol->private_value =
1770 HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[i],
1773 kcontrol->private_value =
1774 HDA_COMPOSE_AMP_VAL(spec->adc_nids[i],
1776 err = func(kcontrol, ucontrol);
1779 mutex_unlock(&codec->control_mutex);
1783 static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1784 struct snd_ctl_elem_value *ucontrol)
1786 return alc_cap_getput_caller(kcontrol, ucontrol,
1787 snd_hda_mixer_amp_volume_get, false);
1790 static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1791 struct snd_ctl_elem_value *ucontrol)
1793 return alc_cap_getput_caller(kcontrol, ucontrol,
1794 snd_hda_mixer_amp_volume_put, true);
1797 /* capture mixer elements */
1798 #define alc_cap_sw_info snd_ctl_boolean_stereo_info
1800 static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1801 struct snd_ctl_elem_value *ucontrol)
1803 return alc_cap_getput_caller(kcontrol, ucontrol,
1804 snd_hda_mixer_amp_switch_get, false);
1807 static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1808 struct snd_ctl_elem_value *ucontrol)
1810 return alc_cap_getput_caller(kcontrol, ucontrol,
1811 snd_hda_mixer_amp_switch_put, true);
1814 #define _DEFINE_CAPMIX(num) \
1816 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1817 .name = "Capture Switch", \
1818 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1820 .info = alc_cap_sw_info, \
1821 .get = alc_cap_sw_get, \
1822 .put = alc_cap_sw_put, \
1825 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1826 .name = "Capture Volume", \
1827 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1828 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1829 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1831 .info = alc_cap_vol_info, \
1832 .get = alc_cap_vol_get, \
1833 .put = alc_cap_vol_put, \
1834 .tlv = { .c = alc_cap_vol_tlv }, \
1837 #define _DEFINE_CAPSRC(num) \
1839 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1840 /* .name = "Capture Source", */ \
1841 .name = "Input Source", \
1843 .info = alc_mux_enum_info, \
1844 .get = alc_mux_enum_get, \
1845 .put = alc_mux_enum_put, \
1848 #define DEFINE_CAPMIX(num) \
1849 static const struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1850 _DEFINE_CAPMIX(num), \
1851 _DEFINE_CAPSRC(num), \
1855 #define DEFINE_CAPMIX_NOSRC(num) \
1856 static const struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
1857 _DEFINE_CAPMIX(num), \
1861 /* up to three ADCs */
1865 DEFINE_CAPMIX_NOSRC(1);
1866 DEFINE_CAPMIX_NOSRC(2);
1867 DEFINE_CAPMIX_NOSRC(3);
1870 * virtual master controls
1874 * slave controls for virtual master
1876 static const char * const alc_slave_vols[] = {
1877 "Front Playback Volume",
1878 "Surround Playback Volume",
1879 "Center Playback Volume",
1880 "LFE Playback Volume",
1881 "Side Playback Volume",
1882 "Headphone Playback Volume",
1883 "Speaker Playback Volume",
1884 "Mono Playback Volume",
1885 "Line-Out Playback Volume",
1886 "PCM Playback Volume",
1890 static const char * const alc_slave_sws[] = {
1891 "Front Playback Switch",
1892 "Surround Playback Switch",
1893 "Center Playback Switch",
1894 "LFE Playback Switch",
1895 "Side Playback Switch",
1896 "Headphone Playback Switch",
1897 "Speaker Playback Switch",
1898 "Mono Playback Switch",
1899 "IEC958 Playback Switch",
1900 "Line-Out Playback Switch",
1901 "PCM Playback Switch",
1906 * build control elements
1909 #define NID_MAPPING (-1)
1911 #define SUBDEV_SPEAKER_ (0 << 6)
1912 #define SUBDEV_HP_ (1 << 6)
1913 #define SUBDEV_LINE_ (2 << 6)
1914 #define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
1915 #define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
1916 #define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
1918 static void alc_free_kctls(struct hda_codec *codec);
1920 #ifdef CONFIG_SND_HDA_INPUT_BEEP
1921 /* additional beep mixers; the actual parameters are overwritten at build */
1922 static const struct snd_kcontrol_new alc_beep_mixer[] = {
1923 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
1924 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
1929 static int alc_build_controls(struct hda_codec *codec)
1931 struct alc_spec *spec = codec->spec;
1932 struct snd_kcontrol *kctl = NULL;
1933 const struct snd_kcontrol_new *knew;
1938 for (i = 0; i < spec->num_mixers; i++) {
1939 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1943 if (spec->cap_mixer) {
1944 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
1948 if (spec->multiout.dig_out_nid) {
1949 err = snd_hda_create_spdif_out_ctls(codec,
1950 spec->multiout.dig_out_nid,
1951 spec->multiout.dig_out_nid);
1954 if (!spec->no_analog) {
1955 err = snd_hda_create_spdif_share_sw(codec,
1959 spec->multiout.share_spdif = 1;
1962 if (spec->dig_in_nid) {
1963 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1968 #ifdef CONFIG_SND_HDA_INPUT_BEEP
1969 /* create beep controls if needed */
1970 if (spec->beep_amp) {
1971 const struct snd_kcontrol_new *knew;
1972 for (knew = alc_beep_mixer; knew->name; knew++) {
1973 struct snd_kcontrol *kctl;
1974 kctl = snd_ctl_new1(knew, codec);
1977 kctl->private_value = spec->beep_amp;
1978 err = snd_hda_ctl_add(codec, 0, kctl);
1985 /* if we have no master control, let's create it */
1986 if (!spec->no_analog &&
1987 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1988 unsigned int vmaster_tlv[4];
1989 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
1990 HDA_OUTPUT, vmaster_tlv);
1991 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1992 vmaster_tlv, alc_slave_vols);
1996 if (!spec->no_analog &&
1997 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1998 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1999 NULL, alc_slave_sws);
2004 /* assign Capture Source enums to NID */
2005 if (spec->capsrc_nids || spec->adc_nids) {
2006 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2008 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
2009 for (i = 0; kctl && i < kctl->count; i++) {
2010 err = snd_hda_add_nid(codec, kctl, i,
2011 get_capsrc(spec, i));
2016 if (spec->cap_mixer && spec->adc_nids) {
2017 const char *kname = kctl ? kctl->id.name : NULL;
2018 for (knew = spec->cap_mixer; knew->name; knew++) {
2019 if (kname && strcmp(knew->name, kname) == 0)
2021 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2022 for (i = 0; kctl && i < kctl->count; i++) {
2023 err = snd_hda_add_nid(codec, kctl, i,
2031 /* other nid->control mapping */
2032 for (i = 0; i < spec->num_mixers; i++) {
2033 for (knew = spec->mixers[i]; knew->name; knew++) {
2034 if (knew->iface != NID_MAPPING)
2036 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2039 u = knew->subdevice;
2040 for (j = 0; j < 4; j++, u >>= 8) {
2045 case SUBDEV_SPEAKER_:
2046 nid = spec->autocfg.speaker_pins[nid];
2049 nid = spec->autocfg.line_out_pins[nid];
2052 nid = spec->autocfg.hp_pins[nid];
2057 err = snd_hda_add_nid(codec, kctl, 0, nid);
2061 u = knew->private_value;
2062 for (j = 0; j < 4; j++, u >>= 8) {
2066 err = snd_hda_add_nid(codec, kctl, 0, nid);
2073 alc_free_kctls(codec); /* no longer needed */
2083 static void alc_init_special_input_src(struct hda_codec *codec);
2085 static int alc_init(struct hda_codec *codec)
2087 struct alc_spec *spec = codec->spec;
2091 alc_auto_init_amp(codec, spec->init_amp);
2093 for (i = 0; i < spec->num_init_verbs; i++)
2094 snd_hda_sequence_write(codec, spec->init_verbs[i]);
2095 alc_init_special_input_src(codec);
2097 if (spec->init_hook)
2098 spec->init_hook(codec);
2100 alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT);
2102 hda_call_check_power_status(codec, 0x01);
2106 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2108 struct alc_spec *spec = codec->spec;
2110 if (spec->unsol_event)
2111 spec->unsol_event(codec, res);
2114 #ifdef CONFIG_SND_HDA_POWER_SAVE
2115 static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2117 struct alc_spec *spec = codec->spec;
2118 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2123 * Analog playback callbacks
2125 static int alc_playback_pcm_open(struct hda_pcm_stream *hinfo,
2126 struct hda_codec *codec,
2127 struct snd_pcm_substream *substream)
2129 struct alc_spec *spec = codec->spec;
2130 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2134 static int alc_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2135 struct hda_codec *codec,
2136 unsigned int stream_tag,
2137 unsigned int format,
2138 struct snd_pcm_substream *substream)
2140 struct alc_spec *spec = codec->spec;
2141 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2142 stream_tag, format, substream);
2145 static int alc_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2146 struct hda_codec *codec,
2147 struct snd_pcm_substream *substream)
2149 struct alc_spec *spec = codec->spec;
2150 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2156 static int alc_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2157 struct hda_codec *codec,
2158 struct snd_pcm_substream *substream)
2160 struct alc_spec *spec = codec->spec;
2161 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2164 static int alc_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2165 struct hda_codec *codec,
2166 unsigned int stream_tag,
2167 unsigned int format,
2168 struct snd_pcm_substream *substream)
2170 struct alc_spec *spec = codec->spec;
2171 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2172 stream_tag, format, substream);
2175 static int alc_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2176 struct hda_codec *codec,
2177 struct snd_pcm_substream *substream)
2179 struct alc_spec *spec = codec->spec;
2180 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2183 static int alc_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2184 struct hda_codec *codec,
2185 struct snd_pcm_substream *substream)
2187 struct alc_spec *spec = codec->spec;
2188 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2194 static int alc_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2195 struct hda_codec *codec,
2196 unsigned int stream_tag,
2197 unsigned int format,
2198 struct snd_pcm_substream *substream)
2200 struct alc_spec *spec = codec->spec;
2202 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
2203 stream_tag, 0, format);
2207 static int alc_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2208 struct hda_codec *codec,
2209 struct snd_pcm_substream *substream)
2211 struct alc_spec *spec = codec->spec;
2213 snd_hda_codec_cleanup_stream(codec,
2214 spec->adc_nids[substream->number + 1]);
2218 /* analog capture with dynamic dual-adc changes */
2219 static int dyn_adc_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2220 struct hda_codec *codec,
2221 unsigned int stream_tag,
2222 unsigned int format,
2223 struct snd_pcm_substream *substream)
2225 struct alc_spec *spec = codec->spec;
2226 spec->cur_adc = spec->adc_nids[spec->dyn_adc_idx[spec->cur_mux[0]]];
2227 spec->cur_adc_stream_tag = stream_tag;
2228 spec->cur_adc_format = format;
2229 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
2233 static int dyn_adc_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2234 struct hda_codec *codec,
2235 struct snd_pcm_substream *substream)
2237 struct alc_spec *spec = codec->spec;
2238 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
2243 static const struct hda_pcm_stream dyn_adc_pcm_analog_capture = {
2247 .nid = 0, /* fill later */
2249 .prepare = dyn_adc_capture_pcm_prepare,
2250 .cleanup = dyn_adc_capture_pcm_cleanup
2256 static const struct hda_pcm_stream alc_pcm_analog_playback = {
2260 /* NID is set in alc_build_pcms */
2262 .open = alc_playback_pcm_open,
2263 .prepare = alc_playback_pcm_prepare,
2264 .cleanup = alc_playback_pcm_cleanup
2268 static const struct hda_pcm_stream alc_pcm_analog_capture = {
2272 /* NID is set in alc_build_pcms */
2275 static const struct hda_pcm_stream alc_pcm_analog_alt_playback = {
2279 /* NID is set in alc_build_pcms */
2282 static const struct hda_pcm_stream alc_pcm_analog_alt_capture = {
2283 .substreams = 2, /* can be overridden */
2286 /* NID is set in alc_build_pcms */
2288 .prepare = alc_alt_capture_pcm_prepare,
2289 .cleanup = alc_alt_capture_pcm_cleanup
2293 static const struct hda_pcm_stream alc_pcm_digital_playback = {
2297 /* NID is set in alc_build_pcms */
2299 .open = alc_dig_playback_pcm_open,
2300 .close = alc_dig_playback_pcm_close,
2301 .prepare = alc_dig_playback_pcm_prepare,
2302 .cleanup = alc_dig_playback_pcm_cleanup
2306 static const struct hda_pcm_stream alc_pcm_digital_capture = {
2310 /* NID is set in alc_build_pcms */
2313 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
2314 static const struct hda_pcm_stream alc_pcm_null_stream = {
2320 static int alc_build_pcms(struct hda_codec *codec)
2322 struct alc_spec *spec = codec->spec;
2323 struct hda_pcm *info = spec->pcm_rec;
2324 const struct hda_pcm_stream *p;
2325 bool have_multi_adcs;
2328 codec->num_pcms = 1;
2329 codec->pcm_info = info;
2331 if (spec->no_analog)
2334 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
2335 "%s Analog", codec->chip_name);
2336 info->name = spec->stream_name_analog;
2338 if (spec->multiout.dac_nids > 0) {
2339 p = spec->stream_analog_playback;
2341 p = &alc_pcm_analog_playback;
2342 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p;
2343 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2345 if (spec->adc_nids) {
2346 p = spec->stream_analog_capture;
2348 if (spec->dyn_adc_switch)
2349 p = &dyn_adc_pcm_analog_capture;
2351 p = &alc_pcm_analog_capture;
2353 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p;
2354 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2357 if (spec->channel_mode) {
2358 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2359 for (i = 0; i < spec->num_channel_mode; i++) {
2360 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2361 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2367 /* SPDIF for stream index #1 */
2368 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2369 snprintf(spec->stream_name_digital,
2370 sizeof(spec->stream_name_digital),
2371 "%s Digital", codec->chip_name);
2372 codec->num_pcms = 2;
2373 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
2374 info = spec->pcm_rec + 1;
2375 info->name = spec->stream_name_digital;
2376 if (spec->dig_out_type)
2377 info->pcm_type = spec->dig_out_type;
2379 info->pcm_type = HDA_PCM_TYPE_SPDIF;
2380 if (spec->multiout.dig_out_nid) {
2381 p = spec->stream_digital_playback;
2383 p = &alc_pcm_digital_playback;
2384 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p;
2385 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2387 if (spec->dig_in_nid) {
2388 p = spec->stream_digital_capture;
2390 p = &alc_pcm_digital_capture;
2391 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p;
2392 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2394 /* FIXME: do we need this for all Realtek codec models? */
2395 codec->spdif_status_reset = 1;
2398 if (spec->no_analog)
2401 /* If the use of more than one ADC is requested for the current
2402 * model, configure a second analog capture-only PCM.
2404 have_multi_adcs = (spec->num_adc_nids > 1) &&
2405 !spec->dyn_adc_switch && !spec->auto_mic &&
2406 (!spec->input_mux || spec->input_mux->num_items > 1);
2407 /* Additional Analaog capture for index #2 */
2408 if (spec->alt_dac_nid || have_multi_adcs) {
2409 codec->num_pcms = 3;
2410 info = spec->pcm_rec + 2;
2411 info->name = spec->stream_name_analog;
2412 if (spec->alt_dac_nid) {
2413 p = spec->stream_analog_alt_playback;
2415 p = &alc_pcm_analog_alt_playback;
2416 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p;
2417 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2420 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2421 alc_pcm_null_stream;
2422 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2424 if (have_multi_adcs) {
2425 p = spec->stream_analog_alt_capture;
2427 p = &alc_pcm_analog_alt_capture;
2428 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p;
2429 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2431 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2432 spec->num_adc_nids - 1;
2434 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2435 alc_pcm_null_stream;
2436 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
2443 static inline void alc_shutup(struct hda_codec *codec)
2445 struct alc_spec *spec = codec->spec;
2447 if (spec && spec->shutup)
2448 spec->shutup(codec);
2449 snd_hda_shutup_pins(codec);
2452 static void alc_free_kctls(struct hda_codec *codec)
2454 struct alc_spec *spec = codec->spec;
2456 if (spec->kctls.list) {
2457 struct snd_kcontrol_new *kctl = spec->kctls.list;
2459 for (i = 0; i < spec->kctls.used; i++)
2460 kfree(kctl[i].name);
2462 snd_array_free(&spec->kctls);
2465 static void alc_free_bind_ctls(struct hda_codec *codec)
2467 struct alc_spec *spec = codec->spec;
2468 if (spec->bind_ctls.list) {
2469 struct hda_bind_ctls **ctl = spec->bind_ctls.list;
2471 for (i = 0; i < spec->bind_ctls.used; i++)
2474 snd_array_free(&spec->bind_ctls);
2477 static void alc_free(struct hda_codec *codec)
2479 struct alc_spec *spec = codec->spec;
2485 snd_hda_input_jack_free(codec);
2486 alc_free_kctls(codec);
2487 alc_free_bind_ctls(codec);
2489 snd_hda_detach_beep_device(codec);
2492 #ifdef CONFIG_SND_HDA_POWER_SAVE
2493 static void alc_power_eapd(struct hda_codec *codec)
2495 alc_auto_setup_eapd(codec, false);
2498 static int alc_suspend(struct hda_codec *codec, pm_message_t state)
2500 struct alc_spec *spec = codec->spec;
2502 if (spec && spec->power_hook)
2503 spec->power_hook(codec);
2509 static int alc_resume(struct hda_codec *codec)
2511 msleep(150); /* to avoid pop noise */
2512 codec->patch_ops.init(codec);
2513 snd_hda_codec_resume_amp(codec);
2514 snd_hda_codec_resume_cache(codec);
2515 hda_call_check_power_status(codec, 0x01);
2522 static const struct hda_codec_ops alc_patch_ops = {
2523 .build_controls = alc_build_controls,
2524 .build_pcms = alc_build_pcms,
2527 .unsol_event = alc_unsol_event,
2529 .resume = alc_resume,
2531 #ifdef CONFIG_SND_HDA_POWER_SAVE
2532 .suspend = alc_suspend,
2533 .check_power_status = alc_check_power_status,
2535 .reboot_notify = alc_shutup,
2538 /* replace the codec chip_name with the given string */
2539 static int alc_codec_rename(struct hda_codec *codec, const char *name)
2541 kfree(codec->chip_name);
2542 codec->chip_name = kstrdup(name, GFP_KERNEL);
2543 if (!codec->chip_name) {
2551 * Rename codecs appropriately from COEF value
2553 struct alc_codec_rename_table {
2554 unsigned int vendor_id;
2555 unsigned short coef_mask;
2556 unsigned short coef_bits;
2560 static struct alc_codec_rename_table rename_tbl[] = {
2561 { 0x10ec0269, 0xfff0, 0x3010, "ALC277" },
2562 { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" },
2563 { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" },
2564 { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" },
2565 { 0x10ec0269, 0xffff, 0xa023, "ALC259" },
2566 { 0x10ec0269, 0xffff, 0x6023, "ALC281X" },
2567 { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" },
2568 { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" },
2569 { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" },
2570 { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" },
2571 { 0x10ec0899, 0x2000, 0x2000, "ALC899" },
2572 { 0x10ec0892, 0xffff, 0x8020, "ALC661" },
2573 { 0x10ec0892, 0xffff, 0x8011, "ALC661" },
2574 { 0x10ec0892, 0xffff, 0x4011, "ALC656" },
2575 { } /* terminator */
2578 static int alc_codec_rename_from_preset(struct hda_codec *codec)
2580 const struct alc_codec_rename_table *p;
2582 for (p = rename_tbl; p->vendor_id; p++) {
2583 if (p->vendor_id != codec->vendor_id)
2585 if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits)
2586 return alc_codec_rename(codec, p->name);
2592 * Automatic parse of I/O pins from the BIOS configuration
2597 ALC_CTL_WIDGET_MUTE,
2602 static const struct snd_kcontrol_new alc_control_templates[] = {
2603 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2604 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2605 HDA_BIND_MUTE(NULL, 0, 0, 0),
2606 HDA_BIND_VOL(NULL, 0),
2607 HDA_BIND_SW(NULL, 0),
2610 /* add dynamic controls */
2611 static int add_control(struct alc_spec *spec, int type, const char *name,
2612 int cidx, unsigned long val)
2614 struct snd_kcontrol_new *knew;
2616 knew = alc_kcontrol_new(spec);
2619 *knew = alc_control_templates[type];
2620 knew->name = kstrdup(name, GFP_KERNEL);
2624 if (get_amp_nid_(val))
2625 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
2626 knew->private_value = val;
2630 static int add_control_with_pfx(struct alc_spec *spec, int type,
2631 const char *pfx, const char *dir,
2632 const char *sfx, int cidx, unsigned long val)
2635 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
2636 return add_control(spec, type, name, cidx, val);
2639 #define add_pb_vol_ctrl(spec, type, pfx, val) \
2640 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
2641 #define add_pb_sw_ctrl(spec, type, pfx, val) \
2642 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
2643 #define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
2644 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
2645 #define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
2646 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
2648 static const char * const channel_name[4] = {
2649 "Front", "Surround", "CLFE", "Side"
2652 static const char *alc_get_line_out_pfx(struct alc_spec *spec, int ch,
2653 bool can_be_master, int *index)
2655 struct auto_pin_cfg *cfg = &spec->autocfg;
2658 if (cfg->line_outs == 1 && !spec->multi_ios &&
2659 !cfg->hp_outs && !cfg->speaker_outs && can_be_master)
2662 switch (cfg->line_out_type) {
2663 case AUTO_PIN_SPEAKER_OUT:
2664 if (cfg->line_outs == 1)
2667 case AUTO_PIN_HP_OUT:
2668 /* for multi-io case, only the primary out */
2669 if (ch && spec->multi_ios)
2674 if (cfg->line_outs == 1 && !spec->multi_ios)
2678 if (snd_BUG_ON(ch >= ARRAY_SIZE(channel_name)))
2681 return channel_name[ch];
2684 /* create input playback/capture controls for the given pin */
2685 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
2686 const char *ctlname, int ctlidx,
2687 int idx, hda_nid_t mix_nid)
2691 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx,
2692 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
2695 err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx,
2696 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
2702 static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
2704 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
2705 return (pincap & AC_PINCAP_IN) != 0;
2708 /* Parse the codec tree and retrieve ADCs and corresponding capsrc MUXs */
2709 static int alc_auto_fill_adc_caps(struct hda_codec *codec)
2711 struct alc_spec *spec = codec->spec;
2713 hda_nid_t *adc_nids = spec->private_adc_nids;
2714 hda_nid_t *cap_nids = spec->private_capsrc_nids;
2715 int max_nums = ARRAY_SIZE(spec->private_adc_nids);
2718 if (spec->shared_mic_hp)
2719 max_nums = 1; /* no multi streams with the shared HP/mic */
2721 nid = codec->start_nid;
2722 for (i = 0; i < codec->num_nodes; i++, nid++) {
2724 const hda_nid_t *list;
2725 unsigned int caps = get_wcaps(codec, nid);
2726 int type = get_wcaps_type(caps);
2728 if (type != AC_WID_AUD_IN || (caps & AC_WCAP_DIGITAL))
2730 adc_nids[nums] = nid;
2731 cap_nids[nums] = nid;
2735 type = get_wcaps_type(get_wcaps(codec, src));
2736 if (type == AC_WID_PIN)
2738 if (type == AC_WID_AUD_SEL) {
2739 cap_nids[nums] = src;
2742 n = snd_hda_get_conn_list(codec, src, &list);
2744 cap_nids[nums] = src;
2750 if (++nums >= max_nums)
2753 spec->adc_nids = spec->private_adc_nids;
2754 spec->capsrc_nids = spec->private_capsrc_nids;
2755 spec->num_adc_nids = nums;
2759 /* create playback/capture controls for input pins */
2760 static int alc_auto_create_input_ctls(struct hda_codec *codec)
2762 struct alc_spec *spec = codec->spec;
2763 const struct auto_pin_cfg *cfg = &spec->autocfg;
2764 hda_nid_t mixer = spec->mixer_nid;
2765 struct hda_input_mux *imux = &spec->private_imux[0];
2767 int i, c, err, idx, type_idx = 0;
2768 const char *prev_label = NULL;
2770 num_adcs = alc_auto_fill_adc_caps(codec);
2774 for (i = 0; i < cfg->num_inputs; i++) {
2778 pin = cfg->inputs[i].pin;
2779 if (!alc_is_input_pin(codec, pin))
2782 label = hda_get_autocfg_input_label(codec, cfg, i);
2783 if (spec->shared_mic_hp && !strcmp(label, "Misc"))
2784 label = "Headphone Mic";
2785 if (prev_label && !strcmp(label, prev_label))
2792 idx = get_connection_index(codec, mixer, pin);
2794 err = new_analog_input(spec, pin,
2802 for (c = 0; c < num_adcs; c++) {
2803 hda_nid_t cap = get_capsrc(spec, c);
2804 idx = get_connection_index(codec, cap, pin);
2806 spec->imux_pins[imux->num_items] = pin;
2807 snd_hda_add_imux_item(imux, label, idx, NULL);
2813 spec->num_mux_defs = 1;
2814 spec->input_mux = imux;
2819 /* create a shared input with the headphone out */
2820 static int alc_auto_create_shared_input(struct hda_codec *codec)
2822 struct alc_spec *spec = codec->spec;
2823 struct auto_pin_cfg *cfg = &spec->autocfg;
2824 unsigned int defcfg;
2827 /* only one internal input pin? */
2828 if (cfg->num_inputs != 1)
2830 defcfg = snd_hda_codec_get_pincfg(codec, cfg->inputs[0].pin);
2831 if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT)
2834 if (cfg->hp_outs == 1 && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
2835 nid = cfg->hp_pins[0]; /* OK, we have a single HP-out */
2836 else if (cfg->line_outs == 1 && cfg->line_out_type == AUTO_PIN_HP_OUT)
2837 nid = cfg->line_out_pins[0]; /* OK, we have a single line-out */
2839 return 0; /* both not available */
2841 if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_IN))
2842 return 0; /* no input */
2844 cfg->inputs[1].pin = nid;
2845 cfg->inputs[1].type = AUTO_PIN_MIC;
2846 cfg->num_inputs = 2;
2847 spec->shared_mic_hp = 1;
2848 snd_printdd("realtek: Enable shared I/O jack on NID 0x%x\n", nid);
2852 static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
2853 unsigned int pin_type)
2855 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2858 if (nid_has_mute(codec, nid, HDA_OUTPUT))
2859 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2863 static int get_pin_type(int line_out_type)
2865 if (line_out_type == AUTO_PIN_HP_OUT)
2871 static void alc_auto_init_analog_input(struct hda_codec *codec)
2873 struct alc_spec *spec = codec->spec;
2874 struct auto_pin_cfg *cfg = &spec->autocfg;
2877 for (i = 0; i < cfg->num_inputs; i++) {
2878 hda_nid_t nid = cfg->inputs[i].pin;
2879 if (alc_is_input_pin(codec, nid)) {
2880 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
2881 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
2882 snd_hda_codec_write(codec, nid, 0,
2883 AC_VERB_SET_AMP_GAIN_MUTE,
2888 /* mute all loopback inputs */
2889 if (spec->mixer_nid) {
2890 int nums = snd_hda_get_conn_list(codec, spec->mixer_nid, NULL);
2891 for (i = 0; i < nums; i++)
2892 snd_hda_codec_write(codec, spec->mixer_nid, 0,
2893 AC_VERB_SET_AMP_GAIN_MUTE,
2898 /* convert from MIX nid to DAC */
2899 static hda_nid_t alc_auto_mix_to_dac(struct hda_codec *codec, hda_nid_t nid)
2904 if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_AUD_OUT)
2906 num = snd_hda_get_connections(codec, nid, list, ARRAY_SIZE(list));
2907 for (i = 0; i < num; i++) {
2908 if (get_wcaps_type(get_wcaps(codec, list[i])) == AC_WID_AUD_OUT)
2914 /* go down to the selector widget before the mixer */
2915 static hda_nid_t alc_go_down_to_selector(struct hda_codec *codec, hda_nid_t pin)
2918 int num = snd_hda_get_connections(codec, pin, srcs,
2921 get_wcaps_type(get_wcaps(codec, srcs[0])) != AC_WID_AUD_SEL)
2926 /* get MIX nid connected to the given pin targeted to DAC */
2927 static hda_nid_t alc_auto_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
2933 pin = alc_go_down_to_selector(codec, pin);
2934 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
2935 for (i = 0; i < num; i++) {
2936 if (alc_auto_mix_to_dac(codec, mix[i]) == dac)
2942 /* select the connection from pin to DAC if needed */
2943 static int alc_auto_select_dac(struct hda_codec *codec, hda_nid_t pin,
2949 pin = alc_go_down_to_selector(codec, pin);
2950 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
2953 for (i = 0; i < num; i++) {
2954 if (alc_auto_mix_to_dac(codec, mix[i]) == dac) {
2955 snd_hda_codec_update_cache(codec, pin, 0,
2956 AC_VERB_SET_CONNECT_SEL, i);
2963 /* look for an empty DAC slot */
2964 static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
2966 struct alc_spec *spec = codec->spec;
2970 pin = alc_go_down_to_selector(codec, pin);
2971 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
2972 for (i = 0; i < num; i++) {
2973 hda_nid_t nid = alc_auto_mix_to_dac(codec, srcs[i]);
2976 if (found_in_nid_list(nid, spec->multiout.dac_nids,
2977 spec->multiout.num_dacs))
2979 if (found_in_nid_list(nid, spec->multiout.hp_out_nid,
2980 ARRAY_SIZE(spec->multiout.hp_out_nid)))
2982 if (found_in_nid_list(nid, spec->multiout.extra_out_nid,
2983 ARRAY_SIZE(spec->multiout.extra_out_nid)))
2990 /* check whether the DAC is reachable from the pin */
2991 static bool alc_auto_is_dac_reachable(struct hda_codec *codec,
2992 hda_nid_t pin, hda_nid_t dac)
2997 pin = alc_go_down_to_selector(codec, pin);
2998 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
2999 for (i = 0; i < num; i++) {
3000 hda_nid_t nid = alc_auto_mix_to_dac(codec, srcs[i]);
3007 static hda_nid_t get_dac_if_single(struct hda_codec *codec, hda_nid_t pin)
3009 hda_nid_t sel = alc_go_down_to_selector(codec, pin);
3010 if (snd_hda_get_conn_list(codec, sel, NULL) == 1)
3011 return alc_auto_look_for_dac(codec, pin);
3015 static int alc_auto_fill_extra_dacs(struct hda_codec *codec, int num_outs,
3016 const hda_nid_t *pins, hda_nid_t *dacs)
3020 if (num_outs && !dacs[0]) {
3021 dacs[0] = alc_auto_look_for_dac(codec, pins[0]);
3026 for (i = 1; i < num_outs; i++)
3027 dacs[i] = get_dac_if_single(codec, pins[i]);
3028 for (i = 1; i < num_outs; i++) {
3030 dacs[i] = alc_auto_look_for_dac(codec, pins[i]);
3035 static int alc_auto_fill_multi_ios(struct hda_codec *codec,
3036 unsigned int location, int offset);
3038 /* fill in the dac_nids table from the parsed pin configuration */
3039 static int alc_auto_fill_dac_nids(struct hda_codec *codec)
3041 struct alc_spec *spec = codec->spec;
3042 const struct auto_pin_cfg *cfg = &spec->autocfg;
3043 unsigned int location, defcfg;
3045 bool redone = false;
3049 /* set num_dacs once to full for alc_auto_look_for_dac() */
3050 spec->multiout.num_dacs = cfg->line_outs;
3051 spec->multiout.hp_out_nid[0] = 0;
3052 spec->multiout.extra_out_nid[0] = 0;
3053 memset(spec->private_dac_nids, 0, sizeof(spec->private_dac_nids));
3054 spec->multiout.dac_nids = spec->private_dac_nids;
3056 /* fill hard-wired DACs first */
3058 for (i = 0; i < cfg->line_outs; i++)
3059 spec->private_dac_nids[i] =
3060 get_dac_if_single(codec, cfg->line_out_pins[i]);
3062 spec->multiout.hp_out_nid[0] =
3063 get_dac_if_single(codec, cfg->hp_pins[0]);
3064 if (cfg->speaker_outs)
3065 spec->multiout.extra_out_nid[0] =
3066 get_dac_if_single(codec, cfg->speaker_pins[0]);
3069 for (i = 0; i < cfg->line_outs; i++) {
3070 hda_nid_t pin = cfg->line_out_pins[i];
3071 if (spec->private_dac_nids[i])
3073 spec->private_dac_nids[i] = alc_auto_look_for_dac(codec, pin);
3074 if (!spec->private_dac_nids[i] && !redone) {
3075 /* if we can't find primary DACs, re-probe without
3076 * checking the hard-wired DACs
3083 /* re-count num_dacs and squash invalid entries */
3084 spec->multiout.num_dacs = 0;
3085 for (i = 0; i < cfg->line_outs; i++) {
3086 if (spec->private_dac_nids[i])
3087 spec->multiout.num_dacs++;
3089 memmove(spec->private_dac_nids + i,
3090 spec->private_dac_nids + i + 1,
3091 sizeof(hda_nid_t) * (cfg->line_outs - i - 1));
3094 if (cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
3095 /* try to fill multi-io first */
3096 defcfg = snd_hda_codec_get_pincfg(codec, cfg->line_out_pins[0]);
3097 location = get_defcfg_location(defcfg);
3099 num_pins = alc_auto_fill_multi_ios(codec, location, 0);
3101 spec->multi_ios = num_pins;
3102 spec->ext_channel_count = 2;
3103 spec->multiout.num_dacs = num_pins + 1;
3107 if (cfg->line_out_type != AUTO_PIN_HP_OUT)
3108 alc_auto_fill_extra_dacs(codec, cfg->hp_outs, cfg->hp_pins,
3109 spec->multiout.hp_out_nid);
3110 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT)
3111 alc_auto_fill_extra_dacs(codec, cfg->speaker_outs, cfg->speaker_pins,
3112 spec->multiout.extra_out_nid);
3114 if (!spec->multi_ios &&
3115 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT &&
3117 /* try multi-ios with HP + inputs */
3118 defcfg = snd_hda_codec_get_pincfg(codec, cfg->hp_pins[0]);
3119 location = get_defcfg_location(defcfg);
3121 num_pins = alc_auto_fill_multi_ios(codec, location, 1);
3123 spec->multi_ios = num_pins;
3124 spec->ext_channel_count = 2;
3125 spec->multiout.num_dacs = num_pins + 1;
3132 static inline unsigned int get_ctl_pos(unsigned int data)
3134 hda_nid_t nid = get_amp_nid_(data);
3135 unsigned int dir = get_amp_direction_(data);
3136 return (nid << 1) | dir;
3139 #define is_ctl_used(bits, data) \
3140 test_bit(get_ctl_pos(data), bits)
3141 #define mark_ctl_usage(bits, data) \
3142 set_bit(get_ctl_pos(data), bits)
3144 static int alc_auto_add_vol_ctl(struct hda_codec *codec,
3145 const char *pfx, int cidx,
3146 hda_nid_t nid, unsigned int chs)
3148 struct alc_spec *spec = codec->spec;
3152 val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT);
3153 if (is_ctl_used(spec->vol_ctls, val) && chs != 2) /* exclude LFE */
3155 mark_ctl_usage(spec->vol_ctls, val);
3156 return __add_pb_vol_ctrl(codec->spec, ALC_CTL_WIDGET_VOL, pfx, cidx,
3160 static int alc_auto_add_stereo_vol(struct hda_codec *codec,
3161 const char *pfx, int cidx,
3165 if (get_wcaps(codec, nid) & AC_WCAP_STEREO)
3167 return alc_auto_add_vol_ctl(codec, pfx, cidx, nid, chs);
3170 /* create a mute-switch for the given mixer widget;
3171 * if it has multiple sources (e.g. DAC and loopback), create a bind-mute
3173 static int alc_auto_add_sw_ctl(struct hda_codec *codec,
3174 const char *pfx, int cidx,
3175 hda_nid_t nid, unsigned int chs)
3177 struct alc_spec *spec = codec->spec;
3183 wid_type = get_wcaps_type(get_wcaps(codec, nid));
3184 if (wid_type == AC_WID_PIN || wid_type == AC_WID_AUD_OUT) {
3185 type = ALC_CTL_WIDGET_MUTE;
3186 val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT);
3187 } else if (snd_hda_get_conn_list(codec, nid, NULL) == 1) {
3188 type = ALC_CTL_WIDGET_MUTE;
3189 val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT);
3191 type = ALC_CTL_BIND_MUTE;
3192 val = HDA_COMPOSE_AMP_VAL(nid, chs, 2, HDA_INPUT);
3194 if (is_ctl_used(spec->sw_ctls, val) && chs != 2) /* exclude LFE */
3196 mark_ctl_usage(spec->sw_ctls, val);
3197 return __add_pb_sw_ctrl(codec->spec, type, pfx, cidx, val);
3200 static int alc_auto_add_stereo_sw(struct hda_codec *codec, const char *pfx,
3201 int cidx, hda_nid_t nid)
3204 if (get_wcaps(codec, nid) & AC_WCAP_STEREO)
3206 return alc_auto_add_sw_ctl(codec, pfx, cidx, nid, chs);
3209 static hda_nid_t alc_look_for_out_mute_nid(struct hda_codec *codec,
3210 hda_nid_t pin, hda_nid_t dac)
3212 hda_nid_t mix = alc_auto_dac_to_mix(codec, pin, dac);
3213 if (nid_has_mute(codec, pin, HDA_OUTPUT))
3215 else if (mix && nid_has_mute(codec, mix, HDA_INPUT))
3217 else if (nid_has_mute(codec, dac, HDA_OUTPUT))
3222 static hda_nid_t alc_look_for_out_vol_nid(struct hda_codec *codec,
3223 hda_nid_t pin, hda_nid_t dac)
3225 hda_nid_t mix = alc_auto_dac_to_mix(codec, pin, dac);
3226 if (nid_has_volume(codec, dac, HDA_OUTPUT))
3228 else if (nid_has_volume(codec, mix, HDA_OUTPUT))
3230 else if (nid_has_volume(codec, pin, HDA_OUTPUT))
3235 /* add playback controls from the parsed DAC table */
3236 static int alc_auto_create_multi_out_ctls(struct hda_codec *codec,
3237 const struct auto_pin_cfg *cfg)
3239 struct alc_spec *spec = codec->spec;
3240 int i, err, noutputs;
3242 noutputs = cfg->line_outs;
3243 if (spec->multi_ios > 0)
3244 noutputs += spec->multi_ios;
3246 for (i = 0; i < noutputs; i++) {
3252 dac = spec->multiout.dac_nids[i];
3255 if (i >= cfg->line_outs)
3256 pin = spec->multi_io[i - 1].pin;
3258 pin = cfg->line_out_pins[i];
3260 sw = alc_look_for_out_mute_nid(codec, pin, dac);
3261 vol = alc_look_for_out_vol_nid(codec, pin, dac);
3262 name = alc_get_line_out_pfx(spec, i, true, &index);
3263 if (!name || !strcmp(name, "CLFE")) {
3265 err = alc_auto_add_vol_ctl(codec, "Center", 0, vol, 1);
3268 err = alc_auto_add_vol_ctl(codec, "LFE", 0, vol, 2);
3271 err = alc_auto_add_sw_ctl(codec, "Center", 0, sw, 1);
3274 err = alc_auto_add_sw_ctl(codec, "LFE", 0, sw, 2);
3278 err = alc_auto_add_stereo_vol(codec, name, index, vol);
3281 err = alc_auto_add_stereo_sw(codec, name, index, sw);
3289 static int alc_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
3290 hda_nid_t dac, const char *pfx)
3292 struct alc_spec *spec = codec->spec;
3298 /* the corresponding DAC is already occupied */
3299 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
3300 return 0; /* no way */
3301 /* create a switch only */
3302 val = HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT);
3303 if (is_ctl_used(spec->sw_ctls, val))
3304 return 0; /* already created */
3305 mark_ctl_usage(spec->sw_ctls, val);
3306 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val);
3309 sw = alc_look_for_out_mute_nid(codec, pin, dac);
3310 vol = alc_look_for_out_vol_nid(codec, pin, dac);
3311 err = alc_auto_add_stereo_vol(codec, pfx, 0, vol);
3314 err = alc_auto_add_stereo_sw(codec, pfx, 0, sw);
3320 static struct hda_bind_ctls *new_bind_ctl(struct hda_codec *codec,
3322 struct hda_ctl_ops *ops)
3324 struct alc_spec *spec = codec->spec;
3325 struct hda_bind_ctls **ctlp, *ctl;
3326 snd_array_init(&spec->bind_ctls, sizeof(ctl), 8);
3327 ctlp = snd_array_new(&spec->bind_ctls);
3330 ctl = kzalloc(sizeof(*ctl) + sizeof(long) * (nums + 1), GFP_KERNEL);
3337 /* add playback controls for speaker and HP outputs */
3338 static int alc_auto_create_extra_outs(struct hda_codec *codec, int num_pins,
3339 const hda_nid_t *pins,
3340 const hda_nid_t *dacs,
3343 struct alc_spec *spec = codec->spec;
3344 struct hda_bind_ctls *ctl;
3348 if (!num_pins || !pins[0])
3351 if (num_pins == 1) {
3352 hda_nid_t dac = *dacs;
3354 dac = spec->multiout.dac_nids[0];
3355 return alc_auto_create_extra_out(codec, *pins, dac, pfx);
3358 if (dacs[num_pins - 1]) {
3359 /* OK, we have a multi-output system with individual volumes */
3360 for (i = 0; i < num_pins; i++) {
3361 snprintf(name, sizeof(name), "%s %s",
3362 pfx, channel_name[i]);
3363 err = alc_auto_create_extra_out(codec, pins[i], dacs[i],
3371 /* Let's create a bind-controls */
3372 ctl = new_bind_ctl(codec, num_pins, &snd_hda_bind_sw);
3376 for (i = 0; i < num_pins; i++) {
3377 if (get_wcaps(codec, pins[i]) & AC_WCAP_OUT_AMP)
3379 HDA_COMPOSE_AMP_VAL(pins[i], 3, 0, HDA_OUTPUT);
3382 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
3383 err = add_control(spec, ALC_CTL_BIND_SW, name, 0, (long)ctl);
3388 ctl = new_bind_ctl(codec, num_pins, &snd_hda_bind_vol);
3392 for (i = 0; i < num_pins; i++) {
3394 if (!pins[i] || !dacs[i])
3396 vol = alc_look_for_out_vol_nid(codec, pins[i], dacs[i]);
3399 HDA_COMPOSE_AMP_VAL(vol, 3, 0, HDA_OUTPUT);
3402 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
3403 err = add_control(spec, ALC_CTL_BIND_VOL, name, 0, (long)ctl);
3410 static int alc_auto_create_hp_out(struct hda_codec *codec)
3412 struct alc_spec *spec = codec->spec;
3413 return alc_auto_create_extra_outs(codec, spec->autocfg.hp_outs,
3414 spec->autocfg.hp_pins,
3415 spec->multiout.hp_out_nid,
3419 static int alc_auto_create_speaker_out(struct hda_codec *codec)
3421 struct alc_spec *spec = codec->spec;
3422 return alc_auto_create_extra_outs(codec, spec->autocfg.speaker_outs,
3423 spec->autocfg.speaker_pins,
3424 spec->multiout.extra_out_nid,
3428 static void alc_auto_set_output_and_unmute(struct hda_codec *codec,
3429 hda_nid_t pin, int pin_type,
3433 hda_nid_t nid, mix = 0;
3434 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
3436 alc_set_pin_output(codec, pin, pin_type);
3437 nid = alc_go_down_to_selector(codec, pin);
3438 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
3439 for (i = 0; i < num; i++) {
3440 if (alc_auto_mix_to_dac(codec, srcs[i]) != dac)
3448 /* need the manual connection? */
3450 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
3451 /* unmute mixer widget inputs */
3452 if (nid_has_mute(codec, mix, HDA_INPUT)) {
3453 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3455 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3458 /* initialize volume */
3459 nid = alc_look_for_out_vol_nid(codec, pin, dac);
3461 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3464 /* unmute DAC if it's not assigned to a mixer */
3465 nid = alc_look_for_out_mute_nid(codec, pin, dac);
3466 if (nid == mix && nid_has_mute(codec, dac, HDA_OUTPUT))
3467 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3471 static void alc_auto_init_multi_out(struct hda_codec *codec)
3473 struct alc_spec *spec = codec->spec;
3474 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3477 for (i = 0; i <= HDA_SIDE; i++) {
3478 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3480 alc_auto_set_output_and_unmute(codec, nid, pin_type,
3481 spec->multiout.dac_nids[i]);
3485 static void alc_auto_init_extra_out(struct hda_codec *codec)
3487 struct alc_spec *spec = codec->spec;
3491 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3492 if (spec->autocfg.line_out_type == AUTO_PIN_HP_OUT)
3494 pin = spec->autocfg.hp_pins[i];
3497 dac = spec->multiout.hp_out_nid[i];
3499 if (i > 0 && spec->multiout.hp_out_nid[0])
3500 dac = spec->multiout.hp_out_nid[0];
3502 dac = spec->multiout.dac_nids[0];
3504 alc_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
3506 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3507 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
3509 pin = spec->autocfg.speaker_pins[i];
3512 dac = spec->multiout.extra_out_nid[i];
3514 if (i > 0 && spec->multiout.extra_out_nid[0])
3515 dac = spec->multiout.extra_out_nid[0];
3517 dac = spec->multiout.dac_nids[0];
3519 alc_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
3526 static int alc_auto_fill_multi_ios(struct hda_codec *codec,
3527 unsigned int location,
3530 struct alc_spec *spec = codec->spec;
3531 struct auto_pin_cfg *cfg = &spec->autocfg;
3532 hda_nid_t prime_dac = spec->private_dac_nids[0];
3533 int type, i, dacs, num_pins = 0;
3535 dacs = spec->multiout.num_dacs;
3536 for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) {
3537 for (i = 0; i < cfg->num_inputs; i++) {
3538 hda_nid_t nid = cfg->inputs[i].pin;
3540 unsigned int defcfg, caps;
3541 if (cfg->inputs[i].type != type)
3543 defcfg = snd_hda_codec_get_pincfg(codec, nid);
3544 if (get_defcfg_connect(defcfg) != AC_JACK_PORT_COMPLEX)
3546 if (location && get_defcfg_location(defcfg) != location)
3548 caps = snd_hda_query_pin_caps(codec, nid);
3549 if (!(caps & AC_PINCAP_OUT))
3551 if (offset && offset + num_pins < dacs) {
3552 dac = spec->private_dac_nids[offset + num_pins];
3553 if (!alc_auto_is_dac_reachable(codec, nid, dac))
3557 dac = alc_auto_look_for_dac(codec, nid);
3560 spec->multi_io[num_pins].pin = nid;
3561 spec->multi_io[num_pins].dac = dac;
3563 spec->private_dac_nids[spec->multiout.num_dacs++] = dac;
3566 spec->multiout.num_dacs = dacs;
3568 /* clear up again */
3569 memset(spec->private_dac_nids + dacs, 0,
3570 sizeof(hda_nid_t) * (AUTO_CFG_MAX_OUTS - dacs));
3571 spec->private_dac_nids[0] = prime_dac;
3577 static int alc_auto_ch_mode_info(struct snd_kcontrol *kcontrol,
3578 struct snd_ctl_elem_info *uinfo)
3580 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3581 struct alc_spec *spec = codec->spec;
3583 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3585 uinfo->value.enumerated.items = spec->multi_ios + 1;
3586 if (uinfo->value.enumerated.item > spec->multi_ios)
3587 uinfo->value.enumerated.item = spec->multi_ios;
3588 sprintf(uinfo->value.enumerated.name, "%dch",
3589 (uinfo->value.enumerated.item + 1) * 2);
3593 static int alc_auto_ch_mode_get(struct snd_kcontrol *kcontrol,
3594 struct snd_ctl_elem_value *ucontrol)
3596 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3597 struct alc_spec *spec = codec->spec;
3598 ucontrol->value.enumerated.item[0] = (spec->ext_channel_count - 1) / 2;
3602 static int alc_set_multi_io(struct hda_codec *codec, int idx, bool output)
3604 struct alc_spec *spec = codec->spec;
3605 hda_nid_t nid = spec->multi_io[idx].pin;
3607 if (!spec->multi_io[idx].ctl_in)
3608 spec->multi_io[idx].ctl_in =
3609 snd_hda_codec_read(codec, nid, 0,
3610 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3612 snd_hda_codec_update_cache(codec, nid, 0,
3613 AC_VERB_SET_PIN_WIDGET_CONTROL,
3615 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
3616 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3618 alc_auto_select_dac(codec, nid, spec->multi_io[idx].dac);
3620 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
3621 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3622 HDA_AMP_MUTE, HDA_AMP_MUTE);
3623 snd_hda_codec_update_cache(codec, nid, 0,
3624 AC_VERB_SET_PIN_WIDGET_CONTROL,
3625 spec->multi_io[idx].ctl_in);
3630 static int alc_auto_ch_mode_put(struct snd_kcontrol *kcontrol,
3631 struct snd_ctl_elem_value *ucontrol)
3633 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3634 struct alc_spec *spec = codec->spec;
3637 ch = ucontrol->value.enumerated.item[0];
3638 if (ch < 0 || ch > spec->multi_ios)
3640 if (ch == (spec->ext_channel_count - 1) / 2)
3642 spec->ext_channel_count = (ch + 1) * 2;
3643 for (i = 0; i < spec->multi_ios; i++)
3644 alc_set_multi_io(codec, i, i < ch);
3645 spec->multiout.max_channels = spec->ext_channel_count;
3646 if (spec->need_dac_fix && !spec->const_channel_count)
3647 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
3651 static const struct snd_kcontrol_new alc_auto_channel_mode_enum = {
3652 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3653 .name = "Channel Mode",
3654 .info = alc_auto_ch_mode_info,
3655 .get = alc_auto_ch_mode_get,
3656 .put = alc_auto_ch_mode_put,
3659 static int alc_auto_add_multi_channel_mode(struct hda_codec *codec)
3661 struct alc_spec *spec = codec->spec;
3663 if (spec->multi_ios > 0) {
3664 struct snd_kcontrol_new *knew;
3666 knew = alc_kcontrol_new(spec);
3669 *knew = alc_auto_channel_mode_enum;
3670 knew->name = kstrdup("Channel Mode", GFP_KERNEL);
3677 /* filter out invalid adc_nids (and capsrc_nids) that don't give all
3680 static void alc_remove_invalid_adc_nids(struct hda_codec *codec)
3682 struct alc_spec *spec = codec->spec;
3683 const struct hda_input_mux *imux;
3684 hda_nid_t adc_nids[ARRAY_SIZE(spec->private_adc_nids)];
3685 hda_nid_t capsrc_nids[ARRAY_SIZE(spec->private_adc_nids)];
3688 imux = spec->input_mux;
3691 if (spec->dyn_adc_switch)
3695 for (n = 0; n < spec->num_adc_nids; n++) {
3696 hda_nid_t cap = spec->private_capsrc_nids[n];
3697 int num_conns = snd_hda_get_conn_list(codec, cap, NULL);
3698 for (i = 0; i < imux->num_items; i++) {
3699 hda_nid_t pin = spec->imux_pins[i];
3701 if (get_connection_index(codec, cap, pin) < 0)
3703 } else if (num_conns <= imux->items[i].index)
3706 if (i >= imux->num_items) {
3707 adc_nids[nums] = spec->private_adc_nids[n];
3708 capsrc_nids[nums++] = cap;
3712 /* check whether ADC-switch is possible */
3713 if (!alc_check_dyn_adc_switch(codec)) {
3714 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
3715 " using fallback 0x%x\n",
3716 codec->chip_name, spec->private_adc_nids[0]);
3717 spec->num_adc_nids = 1;
3721 } else if (nums != spec->num_adc_nids) {
3722 memcpy(spec->private_adc_nids, adc_nids,
3723 nums * sizeof(hda_nid_t));
3724 memcpy(spec->private_capsrc_nids, capsrc_nids,
3725 nums * sizeof(hda_nid_t));
3726 spec->num_adc_nids = nums;
3730 alc_auto_mic_check_imux(codec); /* check auto-mic setups */
3731 else if (spec->input_mux->num_items == 1)
3732 spec->num_adc_nids = 1; /* reduce to a single ADC */
3736 * initialize ADC paths
3738 static void alc_auto_init_adc(struct hda_codec *codec, int adc_idx)
3740 struct alc_spec *spec = codec->spec;
3743 nid = spec->adc_nids[adc_idx];
3745 if (nid_has_mute(codec, nid, HDA_INPUT)) {
3746 snd_hda_codec_write(codec, nid, 0,
3747 AC_VERB_SET_AMP_GAIN_MUTE,
3751 if (!spec->capsrc_nids)
3753 nid = spec->capsrc_nids[adc_idx];
3754 if (nid_has_mute(codec, nid, HDA_OUTPUT))
3755 snd_hda_codec_write(codec, nid, 0,
3756 AC_VERB_SET_AMP_GAIN_MUTE,
3760 static void alc_auto_init_input_src(struct hda_codec *codec)
3762 struct alc_spec *spec = codec->spec;
3765 for (c = 0; c < spec->num_adc_nids; c++)
3766 alc_auto_init_adc(codec, c);
3767 if (spec->dyn_adc_switch)
3770 nums = spec->num_adc_nids;
3771 for (c = 0; c < nums; c++)
3772 alc_mux_select(codec, 0, spec->cur_mux[c], true);
3775 /* add mic boosts if needed */
3776 static int alc_auto_add_mic_boost(struct hda_codec *codec)
3778 struct alc_spec *spec = codec->spec;
3779 struct auto_pin_cfg *cfg = &spec->autocfg;
3783 const char *prev_label = NULL;
3785 for (i = 0; i < cfg->num_inputs; i++) {
3786 if (cfg->inputs[i].type > AUTO_PIN_MIC)
3788 nid = cfg->inputs[i].pin;
3789 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
3791 char boost_label[32];
3793 label = hda_get_autocfg_input_label(codec, cfg, i);
3794 if (spec->shared_mic_hp && !strcmp(label, "Misc"))
3795 label = "Headphone Mic";
3796 if (prev_label && !strcmp(label, prev_label))
3802 snprintf(boost_label, sizeof(boost_label),
3803 "%s Boost Volume", label);
3804 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3805 boost_label, type_idx,
3806 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
3814 /* select or unmute the given capsrc route */
3815 static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap,
3818 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
3819 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
3821 } else if (snd_hda_get_conn_list(codec, cap, NULL) > 1) {
3822 snd_hda_codec_write_cache(codec, cap, 0,
3823 AC_VERB_SET_CONNECT_SEL, idx);
3827 /* set the default connection to that pin */
3828 static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
3830 struct alc_spec *spec = codec->spec;
3835 for (i = 0; i < spec->num_adc_nids; i++) {
3836 hda_nid_t cap = get_capsrc(spec, i);
3839 idx = get_connection_index(codec, cap, pin);
3842 select_or_unmute_capsrc(codec, cap, idx);
3843 return i; /* return the found index */
3845 return -1; /* not found */
3848 /* initialize some special cases for input sources */
3849 static void alc_init_special_input_src(struct hda_codec *codec)
3851 struct alc_spec *spec = codec->spec;
3854 for (i = 0; i < spec->autocfg.num_inputs; i++)
3855 init_capsrc_for_pin(codec, spec->autocfg.inputs[i].pin);
3858 /* assign appropriate capture mixers */
3859 static void set_capture_mixer(struct hda_codec *codec)
3861 struct alc_spec *spec = codec->spec;
3862 static const struct snd_kcontrol_new *caps[2][3] = {
3863 { alc_capture_mixer_nosrc1,
3864 alc_capture_mixer_nosrc2,
3865 alc_capture_mixer_nosrc3 },
3866 { alc_capture_mixer1,
3868 alc_capture_mixer3 },
3871 /* check whether either of ADC or MUX has a volume control */
3872 if (!nid_has_volume(codec, spec->adc_nids[0], HDA_INPUT)) {
3873 if (!spec->capsrc_nids)
3874 return; /* no volume */
3875 if (!nid_has_volume(codec, spec->capsrc_nids[0], HDA_OUTPUT))
3876 return; /* no volume in capsrc, too */
3877 spec->vol_in_capsrc = 1;
3880 if (spec->num_adc_nids > 0) {
3884 if (spec->input_mux && spec->input_mux->num_items > 1)
3886 if (spec->auto_mic) {
3889 } else if (spec->dyn_adc_switch)
3892 if (spec->num_adc_nids > 3)
3893 spec->num_adc_nids = 3;
3894 else if (!spec->num_adc_nids)
3896 num_adcs = spec->num_adc_nids;
3898 spec->cap_mixer = caps[mux][num_adcs - 1];
3903 * standard auto-parser initializations
3905 static void alc_auto_init_std(struct hda_codec *codec)
3907 struct alc_spec *spec = codec->spec;
3908 alc_auto_init_multi_out(codec);
3909 alc_auto_init_extra_out(codec);
3910 alc_auto_init_analog_input(codec);
3911 alc_auto_init_input_src(codec);
3912 alc_auto_init_digital(codec);
3913 if (spec->unsol_event)
3914 alc_inithook(codec);
3918 * Digital-beep handlers
3920 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3921 #define set_beep_amp(spec, nid, idx, dir) \
3922 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
3924 static const struct snd_pci_quirk beep_white_list[] = {
3925 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
3926 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
3927 SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
3928 SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
3929 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
3933 static inline int has_cdefine_beep(struct hda_codec *codec)
3935 struct alc_spec *spec = codec->spec;
3936 const struct snd_pci_quirk *q;
3937 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
3940 return spec->cdefine.enable_pcbeep;
3943 #define set_beep_amp(spec, nid, idx, dir) /* NOP */
3944 #define has_cdefine_beep(codec) 0
3947 /* parse the BIOS configuration and set up the alc_spec */
3948 /* return 1 if successful, 0 if the proper config is not found,
3949 * or a negative error code
3951 static int alc_parse_auto_config(struct hda_codec *codec,
3952 const hda_nid_t *ignore_nids,
3953 const hda_nid_t *ssid_nids)
3955 struct alc_spec *spec = codec->spec;
3956 struct auto_pin_cfg *cfg = &spec->autocfg;
3959 err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids,
3963 if (!cfg->line_outs) {
3964 if (cfg->dig_outs || cfg->dig_in_pin) {
3965 spec->multiout.max_channels = 2;
3966 spec->no_analog = 1;
3969 return 0; /* can't find valid BIOS pin config */
3972 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT &&
3973 cfg->line_outs <= cfg->hp_outs) {
3974 /* use HP as primary out */
3975 cfg->speaker_outs = cfg->line_outs;
3976 memcpy(cfg->speaker_pins, cfg->line_out_pins,
3977 sizeof(cfg->speaker_pins));
3978 cfg->line_outs = cfg->hp_outs;
3979 memcpy(cfg->line_out_pins, cfg->hp_pins, sizeof(cfg->hp_pins));
3981 memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins));
3982 cfg->line_out_type = AUTO_PIN_HP_OUT;
3985 err = alc_auto_fill_dac_nids(codec);
3988 err = alc_auto_add_multi_channel_mode(codec);
3991 err = alc_auto_create_multi_out_ctls(codec, cfg);
3994 err = alc_auto_create_hp_out(codec);
3997 err = alc_auto_create_speaker_out(codec);
4000 err = alc_auto_create_shared_input(codec);
4003 err = alc_auto_create_input_ctls(codec);
4007 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4010 alc_auto_parse_digital(codec);
4012 if (!spec->no_analog)
4013 alc_remove_invalid_adc_nids(codec);
4016 alc_ssid_check(codec, ssid_nids);
4018 if (!spec->no_analog) {
4019 alc_auto_check_switches(codec);
4020 err = alc_auto_add_mic_boost(codec);
4025 if (spec->kctls.list)
4026 add_mixer(spec, spec->kctls.list);
4031 static int alc880_parse_auto_config(struct hda_codec *codec)
4033 static const hda_nid_t alc880_ignore[] = { 0x1d, 0 };
4034 static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 };
4035 return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids);
4038 #ifdef CONFIG_SND_HDA_POWER_SAVE
4039 static const struct hda_amp_list alc880_loopbacks[] = {
4040 { 0x0b, HDA_INPUT, 0 },
4041 { 0x0b, HDA_INPUT, 1 },
4042 { 0x0b, HDA_INPUT, 2 },
4043 { 0x0b, HDA_INPUT, 3 },
4044 { 0x0b, HDA_INPUT, 4 },
4054 ALC880_FIXUP_MEDION_RIM,
4057 static const struct alc_fixup alc880_fixups[] = {
4058 [ALC880_FIXUP_GPIO2] = {
4059 .type = ALC_FIXUP_VERBS,
4060 .v.verbs = alc_gpio2_init_verbs,
4062 [ALC880_FIXUP_MEDION_RIM] = {
4063 .type = ALC_FIXUP_VERBS,
4064 .v.verbs = (const struct hda_verb[]) {
4065 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4066 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
4070 .chain_id = ALC880_FIXUP_GPIO2,
4074 static const struct snd_pci_quirk alc880_fixup_tbl[] = {
4075 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM),
4083 #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4084 #define alc_board_config \
4085 snd_hda_check_board_config
4086 #define alc_board_codec_sid_config \
4087 snd_hda_check_board_codec_sid_config
4088 #include "alc_quirks.c"
4090 #define alc_board_config(codec, nums, models, tbl) -1
4091 #define alc_board_codec_sid_config(codec, nums, models, tbl) -1
4092 #define setup_preset(codec, x) /* NOP */
4096 * OK, here we have finally the patch for ALC880
4098 #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4099 #include "alc880_quirks.c"
4102 static int patch_alc880(struct hda_codec *codec)
4104 struct alc_spec *spec;
4108 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4114 spec->mixer_nid = 0x0b;
4115 spec->need_dac_fix = 1;
4117 board_config = alc_board_config(codec, ALC880_MODEL_LAST,
4118 alc880_models, alc880_cfg_tbl);
4119 if (board_config < 0) {
4120 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4122 board_config = ALC_MODEL_AUTO;
4125 if (board_config == ALC_MODEL_AUTO) {
4126 alc_pick_fixup(codec, NULL, alc880_fixup_tbl, alc880_fixups);
4127 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
4130 if (board_config == ALC_MODEL_AUTO) {
4131 /* automatic parse from the BIOS config */
4132 err = alc880_parse_auto_config(codec);
4135 #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4138 "hda_codec: Cannot set up configuration "
4139 "from BIOS. Using 3-stack mode...\n");
4140 board_config = ALC880_3ST;
4145 if (board_config != ALC_MODEL_AUTO)
4146 setup_preset(codec, &alc880_presets[board_config]);
4148 if (!spec->no_analog && !spec->adc_nids) {
4149 alc_auto_fill_adc_caps(codec);
4150 alc_rebuild_imux_for_auto_mic(codec);
4151 alc_remove_invalid_adc_nids(codec);
4154 if (!spec->no_analog && !spec->cap_mixer)
4155 set_capture_mixer(codec);
4157 if (!spec->no_analog) {
4158 err = snd_hda_attach_beep_device(codec, 0x1);
4161 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
4164 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
4166 spec->vmaster_nid = 0x0c;
4168 codec->patch_ops = alc_patch_ops;
4169 if (board_config == ALC_MODEL_AUTO)
4170 spec->init_hook = alc_auto_init_std;
4171 #ifdef CONFIG_SND_HDA_POWER_SAVE
4172 if (!spec->loopback.amplist)
4173 spec->loopback.amplist = alc880_loopbacks;
4187 static int alc260_parse_auto_config(struct hda_codec *codec)
4189 static const hda_nid_t alc260_ignore[] = { 0x17, 0 };
4190 static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 };
4191 return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids);
4194 #ifdef CONFIG_SND_HDA_POWER_SAVE
4195 static const struct hda_amp_list alc260_loopbacks[] = {
4196 { 0x07, HDA_INPUT, 0 },
4197 { 0x07, HDA_INPUT, 1 },
4198 { 0x07, HDA_INPUT, 2 },
4199 { 0x07, HDA_INPUT, 3 },
4200 { 0x07, HDA_INPUT, 4 },
4212 static const struct alc_fixup alc260_fixups[] = {
4213 [PINFIX_HP_DC5750] = {
4214 .type = ALC_FIXUP_PINS,
4215 .v.pins = (const struct alc_pincfg[]) {
4216 { 0x11, 0x90130110 }, /* speaker */
4222 static const struct snd_pci_quirk alc260_fixup_tbl[] = {
4223 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750),
4229 #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4230 #include "alc260_quirks.c"
4233 static int patch_alc260(struct hda_codec *codec)
4235 struct alc_spec *spec;
4236 int err, board_config;
4238 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4244 spec->mixer_nid = 0x07;
4246 board_config = alc_board_config(codec, ALC260_MODEL_LAST,
4247 alc260_models, alc260_cfg_tbl);
4248 if (board_config < 0) {
4249 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4251 board_config = ALC_MODEL_AUTO;
4254 if (board_config == ALC_MODEL_AUTO) {
4255 alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups);
4256 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
4259 if (board_config == ALC_MODEL_AUTO) {
4260 /* automatic parse from the BIOS config */
4261 err = alc260_parse_auto_config(codec);
4264 #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4267 "hda_codec: Cannot set up configuration "
4268 "from BIOS. Using base mode...\n");
4269 board_config = ALC260_BASIC;
4274 if (board_config != ALC_MODEL_AUTO)
4275 setup_preset(codec, &alc260_presets[board_config]);
4277 if (!spec->no_analog && !spec->adc_nids) {
4278 alc_auto_fill_adc_caps(codec);
4279 alc_rebuild_imux_for_auto_mic(codec);
4280 alc_remove_invalid_adc_nids(codec);
4283 if (!spec->no_analog && !spec->cap_mixer)
4284 set_capture_mixer(codec);
4286 if (!spec->no_analog) {
4287 err = snd_hda_attach_beep_device(codec, 0x1);
4290 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
4293 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
4295 spec->vmaster_nid = 0x08;
4297 codec->patch_ops = alc_patch_ops;
4298 if (board_config == ALC_MODEL_AUTO)
4299 spec->init_hook = alc_auto_init_std;
4300 spec->shutup = alc_eapd_shutup;
4301 #ifdef CONFIG_SND_HDA_POWER_SAVE
4302 if (!spec->loopback.amplist)
4303 spec->loopback.amplist = alc260_loopbacks;
4315 * ALC882/883/885/888/889 support
4317 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4318 * configuration. Each pin widget can choose any input DACs and a mixer.
4319 * Each ADC is connected from a mixer of all inputs. This makes possible
4320 * 6-channel independent captures.
4322 * In addition, an independent DAC for the multi-playback (not used in this
4325 #ifdef CONFIG_SND_HDA_POWER_SAVE
4326 #define alc882_loopbacks alc880_loopbacks
4333 ALC882_FIXUP_ABIT_AW9D_MAX,
4334 ALC882_FIXUP_LENOVO_Y530,
4335 ALC882_FIXUP_PB_M5210,
4336 ALC882_FIXUP_ACER_ASPIRE_7736,
4337 ALC882_FIXUP_ASUS_W90V,
4338 ALC889_FIXUP_VAIO_TT,
4339 ALC888_FIXUP_EEE1601,
4342 ALC883_FIXUP_ACER_EAPD,
4345 ALC882_FIXUP_ASUS_W2JC,
4346 ALC882_FIXUP_ACER_ASPIRE_4930G,
4347 ALC882_FIXUP_ACER_ASPIRE_8930G,
4348 ALC882_FIXUP_ASPIRE_8930G_VERBS,
4349 ALC885_FIXUP_MACPRO_GPIO,
4352 static void alc889_fixup_coef(struct hda_codec *codec,
4353 const struct alc_fixup *fix, int action)
4355 if (action != ALC_FIXUP_ACT_INIT)
4357 alc889_coef_init(codec);
4360 /* toggle speaker-output according to the hp-jack state */
4361 static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
4363 unsigned int gpiostate, gpiomask, gpiodir;
4365 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
4366 AC_VERB_GET_GPIO_DATA, 0);
4369 gpiostate |= (1 << pin);
4371 gpiostate &= ~(1 << pin);
4373 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
4374 AC_VERB_GET_GPIO_MASK, 0);
4375 gpiomask |= (1 << pin);
4377 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
4378 AC_VERB_GET_GPIO_DIRECTION, 0);
4379 gpiodir |= (1 << pin);
4382 snd_hda_codec_write(codec, codec->afg, 0,
4383 AC_VERB_SET_GPIO_MASK, gpiomask);
4384 snd_hda_codec_write(codec, codec->afg, 0,
4385 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
4389 snd_hda_codec_write(codec, codec->afg, 0,
4390 AC_VERB_SET_GPIO_DATA, gpiostate);
4393 /* set up GPIO at initialization */
4394 static void alc885_fixup_macpro_gpio(struct hda_codec *codec,
4395 const struct alc_fixup *fix, int action)
4397 if (action != ALC_FIXUP_ACT_INIT)
4399 alc882_gpio_mute(codec, 0, 0);
4400 alc882_gpio_mute(codec, 1, 0);
4403 static const struct alc_fixup alc882_fixups[] = {
4404 [ALC882_FIXUP_ABIT_AW9D_MAX] = {
4405 .type = ALC_FIXUP_PINS,
4406 .v.pins = (const struct alc_pincfg[]) {
4407 { 0x15, 0x01080104 }, /* side */
4408 { 0x16, 0x01011012 }, /* rear */
4409 { 0x17, 0x01016011 }, /* clfe */
4413 [ALC882_FIXUP_LENOVO_Y530] = {
4414 .type = ALC_FIXUP_PINS,
4415 .v.pins = (const struct alc_pincfg[]) {
4416 { 0x15, 0x99130112 }, /* rear int speakers */
4417 { 0x16, 0x99130111 }, /* subwoofer */
4421 [ALC882_FIXUP_PB_M5210] = {
4422 .type = ALC_FIXUP_VERBS,
4423 .v.verbs = (const struct hda_verb[]) {
4424 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
4428 [ALC882_FIXUP_ACER_ASPIRE_7736] = {
4429 .type = ALC_FIXUP_SKU,
4430 .v.sku = ALC_FIXUP_SKU_IGNORE,
4432 [ALC882_FIXUP_ASUS_W90V] = {
4433 .type = ALC_FIXUP_PINS,
4434 .v.pins = (const struct alc_pincfg[]) {
4435 { 0x16, 0x99130110 }, /* fix sequence for CLFE */
4439 [ALC889_FIXUP_VAIO_TT] = {
4440 .type = ALC_FIXUP_PINS,
4441 .v.pins = (const struct alc_pincfg[]) {
4442 { 0x17, 0x90170111 }, /* hidden surround speaker */
4446 [ALC888_FIXUP_EEE1601] = {
4447 .type = ALC_FIXUP_VERBS,
4448 .v.verbs = (const struct hda_verb[]) {
4449 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
4450 { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 },
4454 [ALC882_FIXUP_EAPD] = {
4455 .type = ALC_FIXUP_VERBS,
4456 .v.verbs = (const struct hda_verb[]) {
4457 /* change to EAPD mode */
4458 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4459 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
4463 [ALC883_FIXUP_EAPD] = {
4464 .type = ALC_FIXUP_VERBS,
4465 .v.verbs = (const struct hda_verb[]) {
4466 /* change to EAPD mode */
4467 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4468 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
4472 [ALC883_FIXUP_ACER_EAPD] = {
4473 .type = ALC_FIXUP_VERBS,
4474 .v.verbs = (const struct hda_verb[]) {
4475 /* eanable EAPD on Acer laptops */
4476 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4477 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
4481 [ALC882_FIXUP_GPIO3] = {
4482 .type = ALC_FIXUP_VERBS,
4483 .v.verbs = alc_gpio3_init_verbs,
4485 [ALC882_FIXUP_ASUS_W2JC] = {
4486 .type = ALC_FIXUP_VERBS,
4487 .v.verbs = alc_gpio1_init_verbs,
4489 .chain_id = ALC882_FIXUP_EAPD,
4491 [ALC889_FIXUP_COEF] = {
4492 .type = ALC_FIXUP_FUNC,
4493 .v.func = alc889_fixup_coef,
4495 [ALC882_FIXUP_ACER_ASPIRE_4930G] = {
4496 .type = ALC_FIXUP_PINS,
4497 .v.pins = (const struct alc_pincfg[]) {
4498 { 0x16, 0x99130111 }, /* CLFE speaker */
4499 { 0x17, 0x99130112 }, /* surround speaker */
4503 [ALC882_FIXUP_ACER_ASPIRE_8930G] = {
4504 .type = ALC_FIXUP_PINS,
4505 .v.pins = (const struct alc_pincfg[]) {
4506 { 0x16, 0x99130111 }, /* CLFE speaker */
4507 { 0x1b, 0x99130112 }, /* surround speaker */
4511 .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS,
4513 [ALC882_FIXUP_ASPIRE_8930G_VERBS] = {
4514 /* additional init verbs for Acer Aspire 8930G */
4515 .type = ALC_FIXUP_VERBS,
4516 .v.verbs = (const struct hda_verb[]) {
4517 /* Enable all DACs */
4518 /* DAC DISABLE/MUTE 1? */
4519 /* setting bits 1-5 disables DAC nids 0x02-0x06
4520 * apparently. Init=0x38 */
4521 { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 },
4522 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
4523 /* DAC DISABLE/MUTE 2? */
4524 /* some bit here disables the other DACs.
4526 { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 },
4527 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
4529 * This laptop has a stereo digital microphone.
4530 * The mics are only 1cm apart which makes the stereo
4531 * useless. However, either the mic or the ALC889
4532 * makes the signal become a difference/sum signal
4533 * instead of standard stereo, which is annoying.
4534 * So instead we flip this bit which makes the
4535 * codec replicate the sum signal to both channels,
4536 * turning it into a normal mono mic.
4538 /* DMIC_CONTROL? Init value = 0x0001 */
4539 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
4540 { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 },
4541 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4542 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
4546 [ALC885_FIXUP_MACPRO_GPIO] = {
4547 .type = ALC_FIXUP_FUNC,
4548 .v.func = alc885_fixup_macpro_gpio,
4552 static const struct snd_pci_quirk alc882_fixup_tbl[] = {
4553 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD),
4554 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
4555 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD),
4556 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
4557 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD),
4558 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD),
4559 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
4560 ALC882_FIXUP_ACER_ASPIRE_4930G),
4561 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
4562 ALC882_FIXUP_ACER_ASPIRE_4930G),
4563 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
4564 ALC882_FIXUP_ACER_ASPIRE_8930G),
4565 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
4566 ALC882_FIXUP_ACER_ASPIRE_8930G),
4567 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
4568 ALC882_FIXUP_ACER_ASPIRE_4930G),
4569 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
4570 ALC882_FIXUP_ACER_ASPIRE_4930G),
4571 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
4572 ALC882_FIXUP_ACER_ASPIRE_4930G),
4573 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210),
4574 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736),
4575 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD),
4576 SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V),
4577 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC),
4578 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
4579 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
4581 /* All Apple entries are in codec SSIDs */
4582 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_FIXUP_MACPRO_GPIO),
4583 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO),
4584 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO),
4585 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD),
4586 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO),
4588 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD),
4589 SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3),
4590 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX),
4591 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
4592 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD),
4593 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530),
4594 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF),
4599 * BIOS auto configuration
4601 /* almost identical with ALC880 parser... */
4602 static int alc882_parse_auto_config(struct hda_codec *codec)
4604 static const hda_nid_t alc882_ignore[] = { 0x1d, 0 };
4605 static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 };
4606 return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids);
4611 #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4612 #include "alc882_quirks.c"
4615 static int patch_alc882(struct hda_codec *codec)
4617 struct alc_spec *spec;
4618 int err, board_config;
4620 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4626 spec->mixer_nid = 0x0b;
4628 switch (codec->vendor_id) {
4633 /* ALC883 and variants */
4634 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
4638 err = alc_codec_rename_from_preset(codec);
4642 board_config = alc_board_config(codec, ALC882_MODEL_LAST,
4643 alc882_models, NULL);
4644 if (board_config < 0)
4645 board_config = alc_board_codec_sid_config(codec,
4646 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
4648 if (board_config < 0) {
4649 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4651 board_config = ALC_MODEL_AUTO;
4654 if (board_config == ALC_MODEL_AUTO) {
4655 alc_pick_fixup(codec, NULL, alc882_fixup_tbl, alc882_fixups);
4656 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
4659 alc_auto_parse_customize_define(codec);
4661 if (board_config == ALC_MODEL_AUTO) {
4662 /* automatic parse from the BIOS config */
4663 err = alc882_parse_auto_config(codec);
4668 if (board_config != ALC_MODEL_AUTO)
4669 setup_preset(codec, &alc882_presets[board_config]);
4671 if (!spec->no_analog && !spec->adc_nids) {
4672 alc_auto_fill_adc_caps(codec);
4673 alc_rebuild_imux_for_auto_mic(codec);
4674 alc_remove_invalid_adc_nids(codec);
4677 if (!spec->no_analog && !spec->cap_mixer)
4678 set_capture_mixer(codec);
4680 if (!spec->no_analog && has_cdefine_beep(codec)) {
4681 err = snd_hda_attach_beep_device(codec, 0x1);
4684 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
4687 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
4689 spec->vmaster_nid = 0x0c;
4691 codec->patch_ops = alc_patch_ops;
4692 if (board_config == ALC_MODEL_AUTO)
4693 spec->init_hook = alc_auto_init_std;
4695 alc_init_jacks(codec);
4696 #ifdef CONFIG_SND_HDA_POWER_SAVE
4697 if (!spec->loopback.amplist)
4698 spec->loopback.amplist = alc882_loopbacks;
4712 static int alc262_parse_auto_config(struct hda_codec *codec)
4714 static const hda_nid_t alc262_ignore[] = { 0x1d, 0 };
4715 static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 };
4716 return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids);
4723 ALC262_FIXUP_FSC_H270,
4724 ALC262_FIXUP_HP_Z200,
4726 ALC262_FIXUP_TOSHIBA_RX1,
4727 ALC262_FIXUP_LENOVO_3000,
4729 ALC262_FIXUP_BENQ_T31,
4732 static const struct alc_fixup alc262_fixups[] = {
4733 [ALC262_FIXUP_FSC_H270] = {
4734 .type = ALC_FIXUP_PINS,
4735 .v.pins = (const struct alc_pincfg[]) {
4736 { 0x14, 0x99130110 }, /* speaker */
4737 { 0x15, 0x0221142f }, /* front HP */
4738 { 0x1b, 0x0121141f }, /* rear HP */
4742 [ALC262_FIXUP_HP_Z200] = {
4743 .type = ALC_FIXUP_PINS,
4744 .v.pins = (const struct alc_pincfg[]) {
4745 { 0x16, 0x99130120 }, /* internal speaker */
4749 [ALC262_FIXUP_TYAN] = {
4750 .type = ALC_FIXUP_PINS,
4751 .v.pins = (const struct alc_pincfg[]) {
4752 { 0x14, 0x1993e1f0 }, /* int AUX */
4756 [ALC262_FIXUP_TOSHIBA_RX1] = {
4757 .type = ALC_FIXUP_PINS,
4758 .v.pins = (const struct alc_pincfg[]) {
4759 { 0x14, 0x90170110 }, /* speaker */
4760 { 0x15, 0x0421101f }, /* HP */
4761 { 0x1a, 0x40f000f0 }, /* N/A */
4762 { 0x1b, 0x40f000f0 }, /* N/A */
4763 { 0x1e, 0x40f000f0 }, /* N/A */
4766 [ALC262_FIXUP_LENOVO_3000] = {
4767 .type = ALC_FIXUP_VERBS,
4768 .v.verbs = (const struct hda_verb[]) {
4769 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
4773 .chain_id = ALC262_FIXUP_BENQ,
4775 [ALC262_FIXUP_BENQ] = {
4776 .type = ALC_FIXUP_VERBS,
4777 .v.verbs = (const struct hda_verb[]) {
4778 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4779 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
4783 [ALC262_FIXUP_BENQ_T31] = {
4784 .type = ALC_FIXUP_VERBS,
4785 .v.verbs = (const struct hda_verb[]) {
4786 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4787 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
4793 static const struct snd_pci_quirk alc262_fixup_tbl[] = {
4794 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200),
4795 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FIXUP_BENQ),
4796 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ),
4797 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN),
4798 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
4799 ALC262_FIXUP_TOSHIBA_RX1),
4800 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270),
4801 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000),
4802 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ),
4803 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31),
4808 #ifdef CONFIG_SND_HDA_POWER_SAVE
4809 #define alc262_loopbacks alc880_loopbacks
4814 static int patch_alc262(struct hda_codec *codec)
4816 struct alc_spec *spec;
4819 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4825 spec->mixer_nid = 0x0b;
4828 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
4833 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
4834 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
4835 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
4836 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
4839 alc_auto_parse_customize_define(codec);
4841 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
4843 alc_pick_fixup(codec, NULL, alc262_fixup_tbl, alc262_fixups);
4844 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
4846 /* automatic parse from the BIOS config */
4847 err = alc262_parse_auto_config(codec);
4851 if (!spec->no_analog && !spec->adc_nids) {
4852 alc_auto_fill_adc_caps(codec);
4853 alc_rebuild_imux_for_auto_mic(codec);
4854 alc_remove_invalid_adc_nids(codec);
4857 if (!spec->no_analog && !spec->cap_mixer)
4858 set_capture_mixer(codec);
4860 if (!spec->no_analog && has_cdefine_beep(codec)) {
4861 err = snd_hda_attach_beep_device(codec, 0x1);
4864 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
4867 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
4869 spec->vmaster_nid = 0x0c;
4871 codec->patch_ops = alc_patch_ops;
4872 spec->init_hook = alc_auto_init_std;
4873 spec->shutup = alc_eapd_shutup;
4875 alc_init_jacks(codec);
4876 #ifdef CONFIG_SND_HDA_POWER_SAVE
4877 if (!spec->loopback.amplist)
4878 spec->loopback.amplist = alc262_loopbacks;
4891 /* bind Beep switches of both NID 0x0f and 0x10 */
4892 static const struct hda_bind_ctls alc268_bind_beep_sw = {
4893 .ops = &snd_hda_bind_sw,
4895 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
4896 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
4901 static const struct snd_kcontrol_new alc268_beep_mixer[] = {
4902 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
4903 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
4907 /* set PCBEEP vol = 0, mute connections */
4908 static const struct hda_verb alc268_beep_init_verbs[] = {
4909 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4910 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4911 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4916 * BIOS auto configuration
4918 static int alc268_parse_auto_config(struct hda_codec *codec)
4920 static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 };
4921 struct alc_spec *spec = codec->spec;
4922 int err = alc_parse_auto_config(codec, NULL, alc268_ssids);
4924 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d) {
4925 add_mixer(spec, alc268_beep_mixer);
4926 add_verb(spec, alc268_beep_init_verbs);
4934 static int patch_alc268(struct hda_codec *codec)
4936 struct alc_spec *spec;
4937 int i, has_beep, err;
4939 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4945 /* ALC268 has no aa-loopback mixer */
4947 /* automatic parse from the BIOS config */
4948 err = alc268_parse_auto_config(codec);
4953 for (i = 0; i < spec->num_mixers; i++) {
4954 if (spec->mixers[i] == alc268_beep_mixer) {
4961 err = snd_hda_attach_beep_device(codec, 0x1);
4964 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
4965 /* override the amp caps for beep generator */
4966 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
4967 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
4968 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
4969 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4970 (0 << AC_AMPCAP_MUTE_SHIFT));
4973 if (!spec->no_analog && !spec->adc_nids) {
4974 alc_auto_fill_adc_caps(codec);
4975 alc_rebuild_imux_for_auto_mic(codec);
4976 alc_remove_invalid_adc_nids(codec);
4979 if (!spec->no_analog && !spec->cap_mixer)
4980 set_capture_mixer(codec);
4982 spec->vmaster_nid = 0x02;
4984 codec->patch_ops = alc_patch_ops;
4985 spec->init_hook = alc_auto_init_std;
4986 spec->shutup = alc_eapd_shutup;
4988 alc_init_jacks(codec);
5000 #ifdef CONFIG_SND_HDA_POWER_SAVE
5001 #define alc269_loopbacks alc880_loopbacks
5004 static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
5008 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
5009 /* NID is set in alc_build_pcms */
5011 .open = alc_playback_pcm_open,
5012 .prepare = alc_playback_pcm_prepare,
5013 .cleanup = alc_playback_pcm_cleanup
5017 static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
5021 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
5022 /* NID is set in alc_build_pcms */
5025 #ifdef CONFIG_SND_HDA_POWER_SAVE
5026 static int alc269_mic2_for_mute_led(struct hda_codec *codec)
5028 switch (codec->subsystem_id) {
5035 static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
5037 /* update mute-LED according to the speaker mute state */
5038 if (nid == 0x01 || nid == 0x14) {
5040 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
5045 /* mic2 vref pin is used for mute LED control */
5046 snd_hda_codec_update_cache(codec, 0x19, 0,
5047 AC_VERB_SET_PIN_WIDGET_CONTROL,
5050 return alc_check_power_status(codec, nid);
5052 #endif /* CONFIG_SND_HDA_POWER_SAVE */
5054 /* different alc269-variants */
5056 ALC269_TYPE_ALC269VA,
5057 ALC269_TYPE_ALC269VB,
5058 ALC269_TYPE_ALC269VC,
5062 * BIOS auto configuration
5064 static int alc269_parse_auto_config(struct hda_codec *codec)
5066 static const hda_nid_t alc269_ignore[] = { 0x1d, 0 };
5067 static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 };
5068 static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 };
5069 struct alc_spec *spec = codec->spec;
5070 const hda_nid_t *ssids = spec->codec_variant == ALC269_TYPE_ALC269VA ?
5071 alc269va_ssids : alc269_ssids;
5073 return alc_parse_auto_config(codec, alc269_ignore, ssids);
5076 static void alc269_toggle_power_output(struct hda_codec *codec, int power_up)
5078 int val = alc_read_coef_idx(codec, 0x04);
5083 alc_write_coef_idx(codec, 0x04, val);
5086 static void alc269_shutup(struct hda_codec *codec)
5088 if ((alc_get_coef0(codec) & 0x00ff) == 0x017)
5089 alc269_toggle_power_output(codec, 0);
5090 if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
5091 alc269_toggle_power_output(codec, 0);
5097 static int alc269_resume(struct hda_codec *codec)
5099 if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
5100 alc269_toggle_power_output(codec, 0);
5104 codec->patch_ops.init(codec);
5106 if ((alc_get_coef0(codec) & 0x00ff) == 0x017) {
5107 alc269_toggle_power_output(codec, 1);
5111 if ((alc_get_coef0(codec) & 0x00ff) == 0x018)
5112 alc269_toggle_power_output(codec, 1);
5114 snd_hda_codec_resume_amp(codec);
5115 snd_hda_codec_resume_cache(codec);
5116 hda_call_check_power_status(codec, 0x01);
5119 #endif /* CONFIG_PM */
5121 static void alc269_fixup_hweq(struct hda_codec *codec,
5122 const struct alc_fixup *fix, int action)
5126 if (action != ALC_FIXUP_ACT_INIT)
5128 coef = alc_read_coef_idx(codec, 0x1e);
5129 alc_write_coef_idx(codec, 0x1e, coef | 0x80);
5132 static void alc271_fixup_dmic(struct hda_codec *codec,
5133 const struct alc_fixup *fix, int action)
5135 static const struct hda_verb verbs[] = {
5136 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
5137 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
5142 if (strcmp(codec->chip_name, "ALC271X"))
5144 cfg = snd_hda_codec_get_pincfg(codec, 0x12);
5145 if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED)
5146 snd_hda_sequence_write(codec, verbs);
5149 static void alc269_fixup_pcm_44k(struct hda_codec *codec,
5150 const struct alc_fixup *fix, int action)
5152 struct alc_spec *spec = codec->spec;
5154 if (action != ALC_FIXUP_ACT_PROBE)
5157 /* Due to a hardware problem on Lenovo Ideadpad, we need to
5158 * fix the sample rate of analog I/O to 44.1kHz
5160 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
5161 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
5164 static void alc269_fixup_stereo_dmic(struct hda_codec *codec,
5165 const struct alc_fixup *fix, int action)
5169 if (action != ALC_FIXUP_ACT_INIT)
5171 /* The digital-mic unit sends PDM (differential signal) instead of
5172 * the standard PCM, thus you can't record a valid mono stream as is.
5173 * Below is a workaround specific to ALC269 to control the dmic
5174 * signal source as mono.
5176 coef = alc_read_coef_idx(codec, 0x07);
5177 alc_write_coef_idx(codec, 0x07, coef | 0x80);
5180 static void alc269_quanta_automute(struct hda_codec *codec)
5182 update_outputs(codec);
5184 snd_hda_codec_write(codec, 0x20, 0,
5185 AC_VERB_SET_COEF_INDEX, 0x0c);
5186 snd_hda_codec_write(codec, 0x20, 0,
5187 AC_VERB_SET_PROC_COEF, 0x680);
5189 snd_hda_codec_write(codec, 0x20, 0,
5190 AC_VERB_SET_COEF_INDEX, 0x0c);
5191 snd_hda_codec_write(codec, 0x20, 0,
5192 AC_VERB_SET_PROC_COEF, 0x480);
5195 static void alc269_fixup_quanta_mute(struct hda_codec *codec,
5196 const struct alc_fixup *fix, int action)
5198 struct alc_spec *spec = codec->spec;
5199 if (action != ALC_FIXUP_ACT_PROBE)
5201 spec->automute_hook = alc269_quanta_automute;
5205 ALC269_FIXUP_SONY_VAIO,
5206 ALC275_FIXUP_SONY_VAIO_GPIO2,
5207 ALC269_FIXUP_DELL_M101Z,
5208 ALC269_FIXUP_SKU_IGNORE,
5209 ALC269_FIXUP_ASUS_G73JW,
5210 ALC269_FIXUP_LENOVO_EAPD,
5211 ALC275_FIXUP_SONY_HWEQ,
5213 ALC269_FIXUP_PCM_44K,
5214 ALC269_FIXUP_STEREO_DMIC,
5215 ALC269_FIXUP_QUANTA_MUTE,
5216 ALC269_FIXUP_LIFEBOOK,
5219 ALC269VB_FIXUP_AMIC,
5220 ALC269VB_FIXUP_DMIC,
5223 static const struct alc_fixup alc269_fixups[] = {
5224 [ALC269_FIXUP_SONY_VAIO] = {
5225 .type = ALC_FIXUP_VERBS,
5226 .v.verbs = (const struct hda_verb[]) {
5227 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
5231 [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
5232 .type = ALC_FIXUP_VERBS,
5233 .v.verbs = (const struct hda_verb[]) {
5234 {0x01, AC_VERB_SET_GPIO_MASK, 0x04},
5235 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04},
5236 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5240 .chain_id = ALC269_FIXUP_SONY_VAIO
5242 [ALC269_FIXUP_DELL_M101Z] = {
5243 .type = ALC_FIXUP_VERBS,
5244 .v.verbs = (const struct hda_verb[]) {
5245 /* Enables internal speaker */
5246 {0x20, AC_VERB_SET_COEF_INDEX, 13},
5247 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
5251 [ALC269_FIXUP_SKU_IGNORE] = {
5252 .type = ALC_FIXUP_SKU,
5253 .v.sku = ALC_FIXUP_SKU_IGNORE,
5255 [ALC269_FIXUP_ASUS_G73JW] = {
5256 .type = ALC_FIXUP_PINS,
5257 .v.pins = (const struct alc_pincfg[]) {
5258 { 0x17, 0x99130111 }, /* subwoofer */
5262 [ALC269_FIXUP_LENOVO_EAPD] = {
5263 .type = ALC_FIXUP_VERBS,
5264 .v.verbs = (const struct hda_verb[]) {
5265 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
5269 [ALC275_FIXUP_SONY_HWEQ] = {
5270 .type = ALC_FIXUP_FUNC,
5271 .v.func = alc269_fixup_hweq,
5273 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
5275 [ALC271_FIXUP_DMIC] = {
5276 .type = ALC_FIXUP_FUNC,
5277 .v.func = alc271_fixup_dmic,
5279 [ALC269_FIXUP_PCM_44K] = {
5280 .type = ALC_FIXUP_FUNC,
5281 .v.func = alc269_fixup_pcm_44k,
5283 [ALC269_FIXUP_STEREO_DMIC] = {
5284 .type = ALC_FIXUP_FUNC,
5285 .v.func = alc269_fixup_stereo_dmic,
5287 [ALC269_FIXUP_QUANTA_MUTE] = {
5288 .type = ALC_FIXUP_FUNC,
5289 .v.func = alc269_fixup_quanta_mute,
5291 [ALC269_FIXUP_LIFEBOOK] = {
5292 .type = ALC_FIXUP_PINS,
5293 .v.pins = (const struct alc_pincfg[]) {
5294 { 0x1a, 0x2101103f }, /* dock line-out */
5295 { 0x1b, 0x23a11040 }, /* dock mic-in */
5299 .chain_id = ALC269_FIXUP_QUANTA_MUTE
5301 [ALC269_FIXUP_AMIC] = {
5302 .type = ALC_FIXUP_PINS,
5303 .v.pins = (const struct alc_pincfg[]) {
5304 { 0x14, 0x99130110 }, /* speaker */
5305 { 0x15, 0x0121401f }, /* HP out */
5306 { 0x18, 0x01a19c20 }, /* mic */
5307 { 0x19, 0x99a3092f }, /* int-mic */
5311 [ALC269_FIXUP_DMIC] = {
5312 .type = ALC_FIXUP_PINS,
5313 .v.pins = (const struct alc_pincfg[]) {
5314 { 0x12, 0x99a3092f }, /* int-mic */
5315 { 0x14, 0x99130110 }, /* speaker */
5316 { 0x15, 0x0121401f }, /* HP out */
5317 { 0x18, 0x01a19c20 }, /* mic */
5321 [ALC269VB_FIXUP_AMIC] = {
5322 .type = ALC_FIXUP_PINS,
5323 .v.pins = (const struct alc_pincfg[]) {
5324 { 0x14, 0x99130110 }, /* speaker */
5325 { 0x18, 0x01a19c20 }, /* mic */
5326 { 0x19, 0x99a3092f }, /* int-mic */
5327 { 0x21, 0x0121401f }, /* HP out */
5331 [ALC269_FIXUP_DMIC] = {
5332 .type = ALC_FIXUP_PINS,
5333 .v.pins = (const struct alc_pincfg[]) {
5334 { 0x12, 0x99a3092f }, /* int-mic */
5335 { 0x14, 0x99130110 }, /* speaker */
5336 { 0x18, 0x01a19c20 }, /* mic */
5337 { 0x21, 0x0121401f }, /* HP out */
5343 static const struct snd_pci_quirk alc269_fixup_tbl[] = {
5344 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
5345 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC),
5346 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC),
5347 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC),
5348 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
5349 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
5350 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
5351 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
5352 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
5353 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
5354 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
5355 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC),
5356 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK),
5357 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
5358 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
5359 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
5360 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
5361 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
5362 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_QUANTA_MUTE),
5363 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Lenovo Ideapd", ALC269_FIXUP_PCM_44K),
5364 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
5367 /* Below is a quirk table taken from the old code.
5368 * Basically the device should work as is without the fixup table.
5369 * If BIOS doesn't give a proper info, enable the corresponding
5372 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
5374 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC),
5375 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269_FIXUP_AMIC),
5376 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC),
5377 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC),
5378 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC),
5379 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC),
5380 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC),
5381 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC),
5382 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC),
5383 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC),
5384 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC),
5385 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC),
5386 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC),
5387 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC),
5388 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC),
5389 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC),
5390 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC),
5391 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC),
5392 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC),
5393 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC),
5394 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC),
5395 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC),
5396 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC),
5397 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC),
5398 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC),
5399 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC),
5400 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC),
5401 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC),
5402 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC),
5403 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC),
5404 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC),
5405 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC),
5406 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC),
5407 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC),
5408 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC),
5409 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC),
5410 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC),
5411 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC),
5412 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC),
5413 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC),
5418 static const struct alc_model_fixup alc269_fixup_models[] = {
5419 {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"},
5420 {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"},
5425 static int alc269_fill_coef(struct hda_codec *codec)
5429 if ((alc_get_coef0(codec) & 0x00ff) < 0x015) {
5430 alc_write_coef_idx(codec, 0xf, 0x960b);
5431 alc_write_coef_idx(codec, 0xe, 0x8817);
5434 if ((alc_get_coef0(codec) & 0x00ff) == 0x016) {
5435 alc_write_coef_idx(codec, 0xf, 0x960b);
5436 alc_write_coef_idx(codec, 0xe, 0x8814);
5439 if ((alc_get_coef0(codec) & 0x00ff) == 0x017) {
5440 val = alc_read_coef_idx(codec, 0x04);
5441 /* Power up output pin */
5442 alc_write_coef_idx(codec, 0x04, val | (1<<11));
5445 if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
5446 val = alc_read_coef_idx(codec, 0xd);
5447 if ((val & 0x0c00) >> 10 != 0x1) {
5448 /* Capless ramp up clock control */
5449 alc_write_coef_idx(codec, 0xd, val | (1<<10));
5451 val = alc_read_coef_idx(codec, 0x17);
5452 if ((val & 0x01c0) >> 6 != 0x4) {
5453 /* Class D power on reset */
5454 alc_write_coef_idx(codec, 0x17, val | (1<<7));
5458 val = alc_read_coef_idx(codec, 0xd); /* Class D */
5459 alc_write_coef_idx(codec, 0xd, val | (1<<14));
5461 val = alc_read_coef_idx(codec, 0x4); /* HP */
5462 alc_write_coef_idx(codec, 0x4, val | (1<<11));
5469 static int patch_alc269(struct hda_codec *codec)
5471 struct alc_spec *spec;
5474 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5480 spec->mixer_nid = 0x0b;
5482 alc_auto_parse_customize_define(codec);
5484 err = alc_codec_rename_from_preset(codec);
5488 if (codec->vendor_id == 0x10ec0269) {
5489 spec->codec_variant = ALC269_TYPE_ALC269VA;
5490 switch (alc_get_coef0(codec) & 0x00f0) {
5492 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
5493 spec->cdefine.platform_type == 1)
5494 err = alc_codec_rename(codec, "ALC271X");
5495 spec->codec_variant = ALC269_TYPE_ALC269VB;
5498 if (codec->bus->pci->subsystem_vendor == 0x17aa &&
5499 codec->bus->pci->subsystem_device == 0x21f3)
5500 err = alc_codec_rename(codec, "ALC3202");
5501 spec->codec_variant = ALC269_TYPE_ALC269VC;
5504 alc_fix_pll_init(codec, 0x20, 0x04, 15);
5508 alc269_fill_coef(codec);
5511 alc_pick_fixup(codec, alc269_fixup_models,
5512 alc269_fixup_tbl, alc269_fixups);
5513 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
5515 /* automatic parse from the BIOS config */
5516 err = alc269_parse_auto_config(codec);
5520 if (!spec->no_analog && !spec->adc_nids) {
5521 alc_auto_fill_adc_caps(codec);
5522 alc_rebuild_imux_for_auto_mic(codec);
5523 alc_remove_invalid_adc_nids(codec);
5526 if (!spec->no_analog && !spec->cap_mixer)
5527 set_capture_mixer(codec);
5529 if (!spec->no_analog && has_cdefine_beep(codec)) {
5530 err = snd_hda_attach_beep_device(codec, 0x1);
5533 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
5536 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
5538 spec->vmaster_nid = 0x02;
5540 codec->patch_ops = alc_patch_ops;
5542 codec->patch_ops.resume = alc269_resume;
5544 spec->init_hook = alc_auto_init_std;
5545 spec->shutup = alc269_shutup;
5547 alc_init_jacks(codec);
5548 #ifdef CONFIG_SND_HDA_POWER_SAVE
5549 if (!spec->loopback.amplist)
5550 spec->loopback.amplist = alc269_loopbacks;
5551 if (alc269_mic2_for_mute_led(codec))
5552 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
5566 static int alc861_parse_auto_config(struct hda_codec *codec)
5568 static const hda_nid_t alc861_ignore[] = { 0x1d, 0 };
5569 static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 };
5570 return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids);
5573 #ifdef CONFIG_SND_HDA_POWER_SAVE
5574 static const struct hda_amp_list alc861_loopbacks[] = {
5575 { 0x15, HDA_INPUT, 0 },
5576 { 0x15, HDA_INPUT, 1 },
5577 { 0x15, HDA_INPUT, 2 },
5578 { 0x15, HDA_INPUT, 3 },
5584 /* Pin config fixes */
5586 PINFIX_FSC_AMILO_PI1505,
5589 static const struct alc_fixup alc861_fixups[] = {
5590 [PINFIX_FSC_AMILO_PI1505] = {
5591 .type = ALC_FIXUP_PINS,
5592 .v.pins = (const struct alc_pincfg[]) {
5593 { 0x0b, 0x0221101f }, /* HP */
5594 { 0x0f, 0x90170310 }, /* speaker */
5600 static const struct snd_pci_quirk alc861_fixup_tbl[] = {
5601 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
5607 static int patch_alc861(struct hda_codec *codec)
5609 struct alc_spec *spec;
5612 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5618 spec->mixer_nid = 0x15;
5620 alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
5621 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
5623 /* automatic parse from the BIOS config */
5624 err = alc861_parse_auto_config(codec);
5628 if (!spec->no_analog && !spec->adc_nids) {
5629 alc_auto_fill_adc_caps(codec);
5630 alc_rebuild_imux_for_auto_mic(codec);
5631 alc_remove_invalid_adc_nids(codec);
5634 if (!spec->no_analog && !spec->cap_mixer)
5635 set_capture_mixer(codec);
5637 if (!spec->no_analog) {
5638 err = snd_hda_attach_beep_device(codec, 0x23);
5641 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
5644 spec->vmaster_nid = 0x03;
5646 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
5648 codec->patch_ops = alc_patch_ops;
5649 spec->init_hook = alc_auto_init_std;
5650 #ifdef CONFIG_SND_HDA_POWER_SAVE
5651 spec->power_hook = alc_power_eapd;
5652 if (!spec->loopback.amplist)
5653 spec->loopback.amplist = alc861_loopbacks;
5668 * In addition, an independent DAC
5670 #ifdef CONFIG_SND_HDA_POWER_SAVE
5671 #define alc861vd_loopbacks alc880_loopbacks
5674 static int alc861vd_parse_auto_config(struct hda_codec *codec)
5676 static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
5677 static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 };
5678 return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids);
5682 ALC660VD_FIX_ASUS_GPIO1,
5683 ALC861VD_FIX_DALLAS,
5686 /* exclude VREF80 */
5687 static void alc861vd_fixup_dallas(struct hda_codec *codec,
5688 const struct alc_fixup *fix, int action)
5690 if (action == ALC_FIXUP_ACT_PRE_PROBE) {
5691 snd_hda_override_pin_caps(codec, 0x18, 0x00001714);
5692 snd_hda_override_pin_caps(codec, 0x19, 0x0000171c);
5696 static const struct alc_fixup alc861vd_fixups[] = {
5697 [ALC660VD_FIX_ASUS_GPIO1] = {
5698 .type = ALC_FIXUP_VERBS,
5699 .v.verbs = (const struct hda_verb[]) {
5701 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5702 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5703 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5707 [ALC861VD_FIX_DALLAS] = {
5708 .type = ALC_FIXUP_FUNC,
5709 .v.func = alc861vd_fixup_dallas,
5713 static const struct snd_pci_quirk alc861vd_fixup_tbl[] = {
5714 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS),
5715 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
5716 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS),
5720 static const struct hda_verb alc660vd_eapd_verbs[] = {
5721 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
5722 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
5728 static int patch_alc861vd(struct hda_codec *codec)
5730 struct alc_spec *spec;
5733 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5739 spec->mixer_nid = 0x0b;
5741 alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
5742 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
5744 /* automatic parse from the BIOS config */
5745 err = alc861vd_parse_auto_config(codec);
5749 if (codec->vendor_id == 0x10ec0660) {
5750 /* always turn on EAPD */
5751 add_verb(spec, alc660vd_eapd_verbs);
5754 if (!spec->no_analog && !spec->adc_nids) {
5755 alc_auto_fill_adc_caps(codec);
5756 alc_rebuild_imux_for_auto_mic(codec);
5757 alc_remove_invalid_adc_nids(codec);
5760 if (!spec->no_analog && !spec->cap_mixer)
5761 set_capture_mixer(codec);
5763 if (!spec->no_analog) {
5764 err = snd_hda_attach_beep_device(codec, 0x23);
5767 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
5770 spec->vmaster_nid = 0x02;
5772 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
5774 codec->patch_ops = alc_patch_ops;
5776 spec->init_hook = alc_auto_init_std;
5777 spec->shutup = alc_eapd_shutup;
5778 #ifdef CONFIG_SND_HDA_POWER_SAVE
5779 if (!spec->loopback.amplist)
5780 spec->loopback.amplist = alc861vd_loopbacks;
5793 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
5794 * configuration. Each pin widget can choose any input DACs and a mixer.
5795 * Each ADC is connected from a mixer of all inputs. This makes possible
5796 * 6-channel independent captures.
5798 * In addition, an independent DAC for the multi-playback (not used in this
5801 #ifdef CONFIG_SND_HDA_POWER_SAVE
5802 #define alc662_loopbacks alc880_loopbacks
5806 * BIOS auto configuration
5809 static int alc662_parse_auto_config(struct hda_codec *codec)
5811 static const hda_nid_t alc662_ignore[] = { 0x1d, 0 };
5812 static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 };
5813 static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 };
5814 const hda_nid_t *ssids;
5816 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
5817 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
5818 ssids = alc663_ssids;
5820 ssids = alc662_ssids;
5821 return alc_parse_auto_config(codec, alc662_ignore, ssids);
5824 static void alc272_fixup_mario(struct hda_codec *codec,
5825 const struct alc_fixup *fix, int action)
5827 if (action != ALC_FIXUP_ACT_PROBE)
5829 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
5830 (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
5831 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
5832 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5833 (0 << AC_AMPCAP_MUTE_SHIFT)))
5835 "hda_codec: failed to override amp caps for NID 0x2\n");
5839 ALC662_FIXUP_ASPIRE,
5840 ALC662_FIXUP_IDEAPAD,
5842 ALC662_FIXUP_CZC_P10T,
5843 ALC662_FIXUP_SKU_IGNORE,
5844 ALC662_FIXUP_HP_RP5800,
5845 ALC662_FIXUP_ASUS_MODE1,
5846 ALC662_FIXUP_ASUS_MODE2,
5847 ALC662_FIXUP_ASUS_MODE3,
5848 ALC662_FIXUP_ASUS_MODE4,
5849 ALC662_FIXUP_ASUS_MODE5,
5850 ALC662_FIXUP_ASUS_MODE6,
5851 ALC662_FIXUP_ASUS_MODE7,
5852 ALC662_FIXUP_ASUS_MODE8,
5855 static const struct alc_fixup alc662_fixups[] = {
5856 [ALC662_FIXUP_ASPIRE] = {
5857 .type = ALC_FIXUP_PINS,
5858 .v.pins = (const struct alc_pincfg[]) {
5859 { 0x15, 0x99130112 }, /* subwoofer */
5863 [ALC662_FIXUP_IDEAPAD] = {
5864 .type = ALC_FIXUP_PINS,
5865 .v.pins = (const struct alc_pincfg[]) {
5866 { 0x17, 0x99130112 }, /* subwoofer */
5870 [ALC272_FIXUP_MARIO] = {
5871 .type = ALC_FIXUP_FUNC,
5872 .v.func = alc272_fixup_mario,
5874 [ALC662_FIXUP_CZC_P10T] = {
5875 .type = ALC_FIXUP_VERBS,
5876 .v.verbs = (const struct hda_verb[]) {
5877 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
5881 [ALC662_FIXUP_SKU_IGNORE] = {
5882 .type = ALC_FIXUP_SKU,
5883 .v.sku = ALC_FIXUP_SKU_IGNORE,
5885 [ALC662_FIXUP_HP_RP5800] = {
5886 .type = ALC_FIXUP_PINS,
5887 .v.pins = (const struct alc_pincfg[]) {
5888 { 0x14, 0x0221201f }, /* HP out */
5892 .chain_id = ALC662_FIXUP_SKU_IGNORE
5894 [ALC662_FIXUP_ASUS_MODE1] = {
5895 .type = ALC_FIXUP_PINS,
5896 .v.pins = (const struct alc_pincfg[]) {
5897 { 0x14, 0x99130110 }, /* speaker */
5898 { 0x18, 0x01a19c20 }, /* mic */
5899 { 0x19, 0x99a3092f }, /* int-mic */
5900 { 0x21, 0x0121401f }, /* HP out */
5904 .chain_id = ALC662_FIXUP_SKU_IGNORE
5906 [ALC662_FIXUP_ASUS_MODE2] = {
5907 .type = ALC_FIXUP_PINS,
5908 .v.pins = (const struct alc_pincfg[]) {
5909 { 0x14, 0x99130110 }, /* speaker */
5910 { 0x18, 0x01a19820 }, /* mic */
5911 { 0x19, 0x99a3092f }, /* int-mic */
5912 { 0x1b, 0x0121401f }, /* HP out */
5916 .chain_id = ALC662_FIXUP_SKU_IGNORE
5918 [ALC662_FIXUP_ASUS_MODE3] = {
5919 .type = ALC_FIXUP_PINS,
5920 .v.pins = (const struct alc_pincfg[]) {
5921 { 0x14, 0x99130110 }, /* speaker */
5922 { 0x15, 0x0121441f }, /* HP */
5923 { 0x18, 0x01a19840 }, /* mic */
5924 { 0x19, 0x99a3094f }, /* int-mic */
5925 { 0x21, 0x01211420 }, /* HP2 */
5929 .chain_id = ALC662_FIXUP_SKU_IGNORE
5931 [ALC662_FIXUP_ASUS_MODE4] = {
5932 .type = ALC_FIXUP_PINS,
5933 .v.pins = (const struct alc_pincfg[]) {
5934 { 0x14, 0x99130110 }, /* speaker */
5935 { 0x16, 0x99130111 }, /* speaker */
5936 { 0x18, 0x01a19840 }, /* mic */
5937 { 0x19, 0x99a3094f }, /* int-mic */
5938 { 0x21, 0x0121441f }, /* HP */
5942 .chain_id = ALC662_FIXUP_SKU_IGNORE
5944 [ALC662_FIXUP_ASUS_MODE5] = {
5945 .type = ALC_FIXUP_PINS,
5946 .v.pins = (const struct alc_pincfg[]) {
5947 { 0x14, 0x99130110 }, /* speaker */
5948 { 0x15, 0x0121441f }, /* HP */
5949 { 0x16, 0x99130111 }, /* speaker */
5950 { 0x18, 0x01a19840 }, /* mic */
5951 { 0x19, 0x99a3094f }, /* int-mic */
5955 .chain_id = ALC662_FIXUP_SKU_IGNORE
5957 [ALC662_FIXUP_ASUS_MODE6] = {
5958 .type = ALC_FIXUP_PINS,
5959 .v.pins = (const struct alc_pincfg[]) {
5960 { 0x14, 0x99130110 }, /* speaker */
5961 { 0x15, 0x01211420 }, /* HP2 */
5962 { 0x18, 0x01a19840 }, /* mic */
5963 { 0x19, 0x99a3094f }, /* int-mic */
5964 { 0x1b, 0x0121441f }, /* HP */
5968 .chain_id = ALC662_FIXUP_SKU_IGNORE
5970 [ALC662_FIXUP_ASUS_MODE7] = {
5971 .type = ALC_FIXUP_PINS,
5972 .v.pins = (const struct alc_pincfg[]) {
5973 { 0x14, 0x99130110 }, /* speaker */
5974 { 0x17, 0x99130111 }, /* speaker */
5975 { 0x18, 0x01a19840 }, /* mic */
5976 { 0x19, 0x99a3094f }, /* int-mic */
5977 { 0x1b, 0x01214020 }, /* HP */
5978 { 0x21, 0x0121401f }, /* HP */
5982 .chain_id = ALC662_FIXUP_SKU_IGNORE
5984 [ALC662_FIXUP_ASUS_MODE8] = {
5985 .type = ALC_FIXUP_PINS,
5986 .v.pins = (const struct alc_pincfg[]) {
5987 { 0x14, 0x99130110 }, /* speaker */
5988 { 0x12, 0x99a30970 }, /* int-mic */
5989 { 0x15, 0x01214020 }, /* HP */
5990 { 0x17, 0x99130111 }, /* speaker */
5991 { 0x18, 0x01a19840 }, /* mic */
5992 { 0x21, 0x0121401f }, /* HP */
5996 .chain_id = ALC662_FIXUP_SKU_IGNORE
6000 static const struct snd_pci_quirk alc662_fixup_tbl[] = {
6001 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2),
6002 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
6003 SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE),
6004 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
6005 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
6006 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2),
6007 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
6008 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
6009 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
6010 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
6013 /* Below is a quirk table taken from the old code.
6014 * Basically the device should work as is without the fixup table.
6015 * If BIOS doesn't give a proper info, enable the corresponding
6018 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1),
6019 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3),
6020 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1),
6021 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3),
6022 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
6023 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6024 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
6025 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1),
6026 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1),
6027 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6028 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7),
6029 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7),
6030 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8),
6031 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3),
6032 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1),
6033 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6034 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2),
6035 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1),
6036 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6037 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
6038 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
6039 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6040 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1),
6041 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3),
6042 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2),
6043 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6044 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5),
6045 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
6046 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6047 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1),
6048 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6049 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6050 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3),
6051 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3),
6052 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1),
6053 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1),
6054 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1),
6055 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1),
6056 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1),
6057 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6058 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2),
6059 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1),
6060 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
6061 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3),
6062 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1),
6063 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1),
6064 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1),
6065 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2),
6066 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
6067 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4),
6072 static const struct alc_model_fixup alc662_fixup_models[] = {
6073 {.id = ALC272_FIXUP_MARIO, .name = "mario"},
6074 {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"},
6075 {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"},
6076 {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"},
6077 {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"},
6078 {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"},
6079 {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"},
6080 {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"},
6081 {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"},
6088 static int patch_alc662(struct hda_codec *codec)
6090 struct alc_spec *spec;
6093 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6099 spec->mixer_nid = 0x0b;
6101 /* handle multiple HPs as is */
6102 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
6104 alc_auto_parse_customize_define(codec);
6106 alc_fix_pll_init(codec, 0x20, 0x04, 15);
6108 err = alc_codec_rename_from_preset(codec);
6112 if ((alc_get_coef0(codec) & (1 << 14)) &&
6113 codec->bus->pci->subsystem_vendor == 0x1025 &&
6114 spec->cdefine.platform_type == 1) {
6115 if (alc_codec_rename(codec, "ALC272X") < 0)
6119 alc_pick_fixup(codec, alc662_fixup_models,
6120 alc662_fixup_tbl, alc662_fixups);
6121 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
6122 /* automatic parse from the BIOS config */
6123 err = alc662_parse_auto_config(codec);
6127 if (!spec->no_analog && !spec->adc_nids) {
6128 alc_auto_fill_adc_caps(codec);
6129 alc_rebuild_imux_for_auto_mic(codec);
6130 alc_remove_invalid_adc_nids(codec);
6133 if (!spec->no_analog && !spec->cap_mixer)
6134 set_capture_mixer(codec);
6136 if (!spec->no_analog && has_cdefine_beep(codec)) {
6137 err = snd_hda_attach_beep_device(codec, 0x1);
6140 switch (codec->vendor_id) {
6142 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
6147 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
6150 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
6154 spec->vmaster_nid = 0x02;
6156 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
6158 codec->patch_ops = alc_patch_ops;
6159 spec->init_hook = alc_auto_init_std;
6160 spec->shutup = alc_eapd_shutup;
6162 alc_init_jacks(codec);
6164 #ifdef CONFIG_SND_HDA_POWER_SAVE
6165 if (!spec->loopback.amplist)
6166 spec->loopback.amplist = alc662_loopbacks;
6180 static int alc680_parse_auto_config(struct hda_codec *codec)
6182 return alc_parse_auto_config(codec, NULL, NULL);
6187 static int patch_alc680(struct hda_codec *codec)
6189 struct alc_spec *spec;
6192 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6198 /* ALC680 has no aa-loopback mixer */
6200 /* automatic parse from the BIOS config */
6201 err = alc680_parse_auto_config(codec);
6207 if (!spec->no_analog && !spec->cap_mixer)
6208 set_capture_mixer(codec);
6210 spec->vmaster_nid = 0x02;
6212 codec->patch_ops = alc_patch_ops;
6213 spec->init_hook = alc_auto_init_std;
6221 static const struct hda_codec_preset snd_hda_preset_realtek[] = {
6222 { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 },
6223 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
6224 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
6225 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
6226 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
6227 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
6228 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
6229 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
6230 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
6231 { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 },
6232 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
6233 .patch = patch_alc861 },
6234 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
6235 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
6236 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
6237 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
6238 .patch = patch_alc882 },
6239 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
6240 .patch = patch_alc662 },
6241 { .id = 0x10ec0662, .rev = 0x100300, .name = "ALC662 rev3",
6242 .patch = patch_alc662 },
6243 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
6244 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
6245 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
6246 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
6247 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
6248 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
6249 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
6250 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
6251 .patch = patch_alc882 },
6252 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
6253 .patch = patch_alc882 },
6254 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
6255 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
6256 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
6257 .patch = patch_alc882 },
6258 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
6259 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
6260 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
6261 { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 },
6265 MODULE_ALIAS("snd-hda-codec-id:10ec*");
6267 MODULE_LICENSE("GPL");
6268 MODULE_DESCRIPTION("Realtek HD-audio codec");
6270 static struct hda_codec_preset_list realtek_list = {
6271 .preset = snd_hda_preset_realtek,
6272 .owner = THIS_MODULE,
6275 static int __init patch_realtek_init(void)
6277 return snd_hda_add_codec_preset(&realtek_list);
6280 static void __exit patch_realtek_exit(void)
6282 snd_hda_delete_codec_preset(&realtek_list);
6285 module_init(patch_realtek_init)
6286 module_exit(patch_realtek_exit)