2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for Realtek ALC codecs
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"
38 /* unsol event tags */
39 #define ALC_FRONT_EVENT 0x01
40 #define ALC_DCVOL_EVENT 0x02
41 #define ALC_HP_EVENT 0x04
42 #define ALC_MIC_EVENT 0x08
45 #define GPIO_MASK 0x03
47 /* extra amp-initialization sequence types */
56 struct alc_customize_define {
58 unsigned char port_connectivity;
59 unsigned char check_sum;
60 unsigned char customization;
61 unsigned char external_amp;
62 unsigned int enable_pcbeep:1;
63 unsigned int platform_type:1;
65 unsigned int override:1;
66 unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */
72 hda_nid_t pin; /* multi-io widget pin NID */
73 hda_nid_t dac; /* DAC to be connected */
74 unsigned int ctl_in; /* cached input-pin control value */
78 ALC_AUTOMUTE_PIN, /* change the pin control */
79 ALC_AUTOMUTE_AMP, /* mute/unmute the pin AMP */
80 ALC_AUTOMUTE_MIXER, /* mute/unmute mixer widget AMP */
84 /* codec parameterization */
85 const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
86 unsigned int num_mixers;
87 const struct snd_kcontrol_new *cap_mixer; /* capture mixer */
88 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
90 const struct hda_verb *init_verbs[10]; /* initialization verbs
94 unsigned int num_init_verbs;
96 char stream_name_analog[32]; /* analog PCM stream */
97 const struct hda_pcm_stream *stream_analog_playback;
98 const struct hda_pcm_stream *stream_analog_capture;
99 const struct hda_pcm_stream *stream_analog_alt_playback;
100 const struct hda_pcm_stream *stream_analog_alt_capture;
102 char stream_name_digital[32]; /* digital PCM stream */
103 const struct hda_pcm_stream *stream_digital_playback;
104 const struct hda_pcm_stream *stream_digital_capture;
107 struct hda_multi_out multiout; /* playback set-up
108 * max_channels, dacs must be set
109 * dig_out_nid and hp_nid are optional
111 hda_nid_t alt_dac_nid;
112 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
116 unsigned int num_adc_nids;
117 const hda_nid_t *adc_nids;
118 const hda_nid_t *capsrc_nids;
119 hda_nid_t dig_in_nid; /* digital-in NID; optional */
120 hda_nid_t mixer_nid; /* analog-mixer NID */
121 DECLARE_BITMAP(vol_ctls, 0x20 << 1);
122 DECLARE_BITMAP(sw_ctls, 0x20 << 1);
124 /* capture setup for dynamic dual-adc switch */
126 unsigned int cur_adc_stream_tag;
127 unsigned int cur_adc_format;
130 unsigned int num_mux_defs;
131 const struct hda_input_mux *input_mux;
132 unsigned int cur_mux[3];
133 hda_nid_t ext_mic_pin;
134 hda_nid_t dock_mic_pin;
135 hda_nid_t int_mic_pin;
138 const struct hda_channel_mode *channel_mode;
139 int num_channel_mode;
141 int const_channel_count;
142 int ext_channel_count;
144 /* PCM information */
145 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
147 /* dynamic controls, init_verbs and input_mux */
148 struct auto_pin_cfg autocfg;
149 struct alc_customize_define cdefine;
150 struct snd_array kctls;
151 struct hda_input_mux private_imux[3];
152 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
153 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
154 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
155 hda_nid_t imux_pins[HDA_MAX_NUM_INPUTS];
156 unsigned int dyn_adc_idx[HDA_MAX_NUM_INPUTS];
157 int int_mic_idx, ext_mic_idx, dock_mic_idx; /* for auto-mic */
160 void (*init_hook)(struct hda_codec *codec);
161 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
162 #ifdef CONFIG_SND_HDA_POWER_SAVE
163 void (*power_hook)(struct hda_codec *codec);
165 void (*shutup)(struct hda_codec *codec);
166 void (*automute_hook)(struct hda_codec *codec);
168 /* for pin sensing */
169 unsigned int hp_jack_present:1;
170 unsigned int line_jack_present:1;
171 unsigned int master_mute:1;
172 unsigned int auto_mic:1;
173 unsigned int auto_mic_valid_imux:1; /* valid imux for auto-mic */
174 unsigned int automute_speaker:1; /* automute speaker outputs */
175 unsigned int automute_lo:1; /* automute LO outputs */
176 unsigned int detect_hp:1; /* Headphone detection enabled */
177 unsigned int detect_lo:1; /* Line-out detection enabled */
178 unsigned int automute_speaker_possible:1; /* there are speakers and either LO or HP */
179 unsigned int automute_lo_possible:1; /* there are line outs and HP */
182 unsigned int no_analog :1; /* digital I/O only */
183 unsigned int dyn_adc_switch:1; /* switch ADCs (for ALC275) */
184 unsigned int single_input_src:1;
185 unsigned int vol_in_capsrc:1; /* use capsrc volume (ADC has no vol) */
186 unsigned int parse_flags; /* passed to snd_hda_parse_pin_defcfg() */
187 unsigned int shared_mic_hp:1; /* HP/Mic-in sharing */
189 /* auto-mute control */
191 hda_nid_t automute_mixer_nid[AUTO_CFG_MAX_OUTS];
194 int codec_variant; /* flag for other variants */
196 /* for virtual master */
197 hda_nid_t vmaster_nid;
198 #ifdef CONFIG_SND_HDA_POWER_SAVE
199 struct hda_loopback_check loopback;
204 unsigned int pll_coef_idx, pll_coef_bit;
209 const struct alc_fixup *fixup_list;
210 const char *fixup_name;
214 struct alc_multi_io multi_io[4];
217 struct snd_array bind_ctls;
220 #define ALC_MODEL_AUTO 0 /* common for all chips */
222 static bool check_amp_caps(struct hda_codec *codec, hda_nid_t nid,
223 int dir, unsigned int bits)
227 if (get_wcaps(codec, nid) & (1 << (dir + 1)))
228 if (query_amp_caps(codec, nid, dir) & bits)
233 #define nid_has_mute(codec, nid, dir) \
234 check_amp_caps(codec, nid, dir, AC_AMPCAP_MUTE)
235 #define nid_has_volume(codec, nid, dir) \
236 check_amp_caps(codec, nid, dir, AC_AMPCAP_NUM_STEPS)
241 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
242 struct snd_ctl_elem_info *uinfo)
244 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
245 struct alc_spec *spec = codec->spec;
246 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
247 if (mux_idx >= spec->num_mux_defs)
249 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
251 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
254 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
255 struct snd_ctl_elem_value *ucontrol)
257 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
258 struct alc_spec *spec = codec->spec;
259 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
261 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
265 static bool alc_dyn_adc_pcm_resetup(struct hda_codec *codec, int cur)
267 struct alc_spec *spec = codec->spec;
268 hda_nid_t new_adc = spec->adc_nids[spec->dyn_adc_idx[cur]];
270 if (spec->cur_adc && spec->cur_adc != new_adc) {
271 /* stream is running, let's swap the current ADC */
272 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
273 spec->cur_adc = new_adc;
274 snd_hda_codec_setup_stream(codec, new_adc,
275 spec->cur_adc_stream_tag, 0,
276 spec->cur_adc_format);
282 static inline hda_nid_t get_capsrc(struct alc_spec *spec, int idx)
284 return spec->capsrc_nids ?
285 spec->capsrc_nids[idx] : spec->adc_nids[idx];
288 static void call_update_outputs(struct hda_codec *codec);
290 /* select the given imux item; either unmute exclusively or select the route */
291 static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx,
292 unsigned int idx, bool force)
294 struct alc_spec *spec = codec->spec;
295 const struct hda_input_mux *imux;
296 unsigned int mux_idx;
297 int i, type, num_conns;
300 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
301 imux = &spec->input_mux[mux_idx];
302 if (!imux->num_items && mux_idx > 0)
303 imux = &spec->input_mux[0];
304 if (!imux->num_items)
307 if (idx >= imux->num_items)
308 idx = imux->num_items - 1;
309 if (spec->cur_mux[adc_idx] == idx && !force)
311 spec->cur_mux[adc_idx] = idx;
313 /* for shared I/O, change the pin-control accordingly */
314 if (spec->shared_mic_hp) {
315 /* NOTE: this assumes that there are only two inputs, the
316 * first is the real internal mic and the second is HP jack.
318 snd_hda_codec_write(codec, spec->autocfg.inputs[1].pin, 0,
319 AC_VERB_SET_PIN_WIDGET_CONTROL,
320 spec->cur_mux[adc_idx] ?
321 PIN_VREF80 : PIN_HP);
322 spec->automute_speaker = !spec->cur_mux[adc_idx];
323 call_update_outputs(codec);
326 if (spec->dyn_adc_switch) {
327 alc_dyn_adc_pcm_resetup(codec, idx);
328 adc_idx = spec->dyn_adc_idx[idx];
331 nid = get_capsrc(spec, adc_idx);
334 num_conns = snd_hda_get_conn_list(codec, nid, NULL);
338 type = get_wcaps_type(get_wcaps(codec, nid));
339 if (type == AC_WID_AUD_MIX) {
340 /* Matrix-mixer style (e.g. ALC882) */
341 int active = imux->items[idx].index;
342 for (i = 0; i < num_conns; i++) {
343 unsigned int v = (i == active) ? 0 : HDA_AMP_MUTE;
344 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, i,
348 /* MUX style (e.g. ALC880) */
349 snd_hda_codec_write_cache(codec, nid, 0,
350 AC_VERB_SET_CONNECT_SEL,
351 imux->items[idx].index);
356 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
357 struct snd_ctl_elem_value *ucontrol)
359 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
360 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
361 return alc_mux_select(codec, adc_idx,
362 ucontrol->value.enumerated.item[0], false);
366 * set up the input pin config (depending on the given auto-pin type)
368 static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
371 unsigned int val = PIN_IN;
373 if (auto_pin_type == AUTO_PIN_MIC) {
376 oldval = snd_hda_codec_read(codec, nid, 0,
377 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
378 pincap = snd_hda_query_pin_caps(codec, nid);
379 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
380 /* if the default pin setup is vref50, we give it priority */
381 if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50)
383 else if (pincap & AC_PINCAP_VREF_50)
385 else if (pincap & AC_PINCAP_VREF_100)
387 else if (pincap & AC_PINCAP_VREF_GRD)
390 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
394 * Append the given mixer and verb elements for the later use
395 * The mixer array is referred in build_controls(), and init_verbs are
398 static void add_mixer(struct alc_spec *spec, const struct snd_kcontrol_new *mix)
400 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
402 spec->mixers[spec->num_mixers++] = mix;
405 static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
407 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
409 spec->init_verbs[spec->num_init_verbs++] = verb;
413 * GPIO setup tables, used in initialization
415 /* Enable GPIO mask and set output */
416 static const struct hda_verb alc_gpio1_init_verbs[] = {
417 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
418 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
419 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
423 static const struct hda_verb alc_gpio2_init_verbs[] = {
424 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
425 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
426 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
430 static const struct hda_verb alc_gpio3_init_verbs[] = {
431 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
432 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
433 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
438 * Fix hardware PLL issue
439 * On some codecs, the analog PLL gating control must be off while
440 * the default value is 1.
442 static void alc_fix_pll(struct hda_codec *codec)
444 struct alc_spec *spec = codec->spec;
449 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
451 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
452 AC_VERB_GET_PROC_COEF, 0);
453 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
455 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
456 val & ~(1 << spec->pll_coef_bit));
459 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
460 unsigned int coef_idx, unsigned int coef_bit)
462 struct alc_spec *spec = codec->spec;
464 spec->pll_coef_idx = coef_idx;
465 spec->pll_coef_bit = coef_bit;
470 * Jack detections for HP auto-mute and mic-switch
473 /* check each pin in the given array; returns true if any of them is plugged */
474 static bool detect_jacks(struct hda_codec *codec, int num_pins, hda_nid_t *pins)
478 for (i = 0; i < num_pins; i++) {
479 hda_nid_t nid = pins[i];
482 present |= snd_hda_jack_detect(codec, nid);
487 /* standard HP/line-out auto-mute helper */
488 static void do_automute(struct hda_codec *codec, int num_pins, hda_nid_t *pins,
489 bool mute, bool hp_out)
491 struct alc_spec *spec = codec->spec;
492 unsigned int mute_bits = mute ? HDA_AMP_MUTE : 0;
493 unsigned int pin_bits = mute ? 0 : (hp_out ? PIN_HP : PIN_OUT);
496 for (i = 0; i < num_pins; i++) {
497 hda_nid_t nid = pins[i];
500 switch (spec->automute_mode) {
501 case ALC_AUTOMUTE_PIN:
502 snd_hda_codec_write(codec, nid, 0,
503 AC_VERB_SET_PIN_WIDGET_CONTROL,
506 case ALC_AUTOMUTE_AMP:
507 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
508 HDA_AMP_MUTE, mute_bits);
510 case ALC_AUTOMUTE_MIXER:
511 nid = spec->automute_mixer_nid[i];
514 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
515 HDA_AMP_MUTE, mute_bits);
516 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 1,
517 HDA_AMP_MUTE, mute_bits);
523 /* Toggle outputs muting */
524 static void update_outputs(struct hda_codec *codec)
526 struct alc_spec *spec = codec->spec;
529 /* Control HP pins/amps depending on master_mute state;
530 * in general, HP pins/amps control should be enabled in all cases,
531 * but currently set only for master_mute, just to be safe
533 if (!spec->shared_mic_hp) /* don't change HP-pin when shared with mic */
534 do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins),
535 spec->autocfg.hp_pins, spec->master_mute, true);
537 if (!spec->automute_speaker)
540 on = spec->hp_jack_present | spec->line_jack_present;
541 on |= spec->master_mute;
542 do_automute(codec, ARRAY_SIZE(spec->autocfg.speaker_pins),
543 spec->autocfg.speaker_pins, on, false);
545 /* toggle line-out mutes if needed, too */
546 /* if LO is a copy of either HP or Speaker, don't need to handle it */
547 if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0] ||
548 spec->autocfg.line_out_pins[0] == spec->autocfg.speaker_pins[0])
550 if (!spec->automute_lo)
553 on = spec->hp_jack_present;
554 on |= spec->master_mute;
555 do_automute(codec, ARRAY_SIZE(spec->autocfg.line_out_pins),
556 spec->autocfg.line_out_pins, on, false);
559 static void call_update_outputs(struct hda_codec *codec)
561 struct alc_spec *spec = codec->spec;
562 if (spec->automute_hook)
563 spec->automute_hook(codec);
565 update_outputs(codec);
568 /* standard HP-automute helper */
569 static void alc_hp_automute(struct hda_codec *codec)
571 struct alc_spec *spec = codec->spec;
573 spec->hp_jack_present =
574 detect_jacks(codec, ARRAY_SIZE(spec->autocfg.hp_pins),
575 spec->autocfg.hp_pins);
576 if (!spec->detect_hp || (!spec->automute_speaker && !spec->automute_lo))
578 call_update_outputs(codec);
581 /* standard line-out-automute helper */
582 static void alc_line_automute(struct hda_codec *codec)
584 struct alc_spec *spec = codec->spec;
586 /* check LO jack only when it's different from HP */
587 if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0])
590 spec->line_jack_present =
591 detect_jacks(codec, ARRAY_SIZE(spec->autocfg.line_out_pins),
592 spec->autocfg.line_out_pins);
593 if (!spec->automute_speaker || !spec->detect_lo)
595 call_update_outputs(codec);
598 #define get_connection_index(codec, mux, nid) \
599 snd_hda_get_conn_index(codec, mux, nid, 0)
601 /* standard mic auto-switch helper */
602 static void alc_mic_automute(struct hda_codec *codec)
604 struct alc_spec *spec = codec->spec;
605 hda_nid_t *pins = spec->imux_pins;
607 if (!spec->auto_mic || !spec->auto_mic_valid_imux)
609 if (snd_BUG_ON(!spec->adc_nids))
611 if (snd_BUG_ON(spec->int_mic_idx < 0 || spec->ext_mic_idx < 0))
614 if (snd_hda_jack_detect(codec, pins[spec->ext_mic_idx]))
615 alc_mux_select(codec, 0, spec->ext_mic_idx, false);
616 else if (spec->dock_mic_idx >= 0 &&
617 snd_hda_jack_detect(codec, pins[spec->dock_mic_idx]))
618 alc_mux_select(codec, 0, spec->dock_mic_idx, false);
620 alc_mux_select(codec, 0, spec->int_mic_idx, false);
623 /* handle the specified unsol action (ALC_XXX_EVENT) */
624 static void alc_exec_unsol_event(struct hda_codec *codec, int action)
628 alc_hp_automute(codec);
630 case ALC_FRONT_EVENT:
631 alc_line_automute(codec);
634 alc_mic_automute(codec);
637 snd_hda_jack_report_sync(codec);
640 /* unsolicited event for HP jack sensing */
641 static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
643 if (codec->vendor_id == 0x10ec0880)
647 res = snd_hda_jack_get_action(codec, res);
648 alc_exec_unsol_event(codec, res);
651 /* call init functions of standard auto-mute helpers */
652 static void alc_inithook(struct hda_codec *codec)
654 alc_hp_automute(codec);
655 alc_line_automute(codec);
656 alc_mic_automute(codec);
659 /* additional initialization for ALC888 variants */
660 static void alc888_coef_init(struct hda_codec *codec)
664 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
665 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
666 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
667 if ((tmp & 0xf0) == 0x20)
669 snd_hda_codec_read(codec, 0x20, 0,
670 AC_VERB_SET_PROC_COEF, 0x830);
673 snd_hda_codec_read(codec, 0x20, 0,
674 AC_VERB_SET_PROC_COEF, 0x3030);
677 /* additional initialization for ALC889 variants */
678 static void alc889_coef_init(struct hda_codec *codec)
682 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
683 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
684 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
685 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
688 /* turn on/off EAPD control (only if available) */
689 static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
691 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
693 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
694 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
698 /* turn on/off EAPD controls of the codec */
699 static void alc_auto_setup_eapd(struct hda_codec *codec, bool on)
701 /* We currently only handle front, HP */
702 static hda_nid_t pins[] = {
703 0x0f, 0x10, 0x14, 0x15, 0
706 for (p = pins; *p; p++)
707 set_eapd(codec, *p, on);
710 /* generic shutup callback;
711 * just turning off EPAD and a little pause for avoiding pop-noise
713 static void alc_eapd_shutup(struct hda_codec *codec)
715 alc_auto_setup_eapd(codec, false);
719 /* generic EAPD initialization */
720 static void alc_auto_init_amp(struct hda_codec *codec, int type)
724 alc_auto_setup_eapd(codec, true);
727 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
730 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
733 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
735 case ALC_INIT_DEFAULT:
736 switch (codec->vendor_id) {
738 snd_hda_codec_write(codec, 0x1a, 0,
739 AC_VERB_SET_COEF_INDEX, 7);
740 tmp = snd_hda_codec_read(codec, 0x1a, 0,
741 AC_VERB_GET_PROC_COEF, 0);
742 snd_hda_codec_write(codec, 0x1a, 0,
743 AC_VERB_SET_COEF_INDEX, 7);
744 snd_hda_codec_write(codec, 0x1a, 0,
745 AC_VERB_SET_PROC_COEF,
754 /*case 0x10ec0889:*/ /* this causes an SPDIF problem */
755 alc889_coef_init(codec);
758 alc888_coef_init(codec);
760 #if 0 /* XXX: This may cause the silent output on speaker on some machines */
763 snd_hda_codec_write(codec, 0x20, 0,
764 AC_VERB_SET_COEF_INDEX, 7);
765 tmp = snd_hda_codec_read(codec, 0x20, 0,
766 AC_VERB_GET_PROC_COEF, 0);
767 snd_hda_codec_write(codec, 0x20, 0,
768 AC_VERB_SET_COEF_INDEX, 7);
769 snd_hda_codec_write(codec, 0x20, 0,
770 AC_VERB_SET_PROC_COEF,
780 * Auto-Mute mode mixer enum support
782 static int alc_automute_mode_info(struct snd_kcontrol *kcontrol,
783 struct snd_ctl_elem_info *uinfo)
785 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
786 struct alc_spec *spec = codec->spec;
787 static const char * const texts2[] = {
788 "Disabled", "Enabled"
790 static const char * const texts3[] = {
791 "Disabled", "Speaker Only", "Line-Out+Speaker"
793 const char * const *texts;
795 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
797 if (spec->automute_speaker_possible && spec->automute_lo_possible) {
798 uinfo->value.enumerated.items = 3;
801 uinfo->value.enumerated.items = 2;
804 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
805 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
806 strcpy(uinfo->value.enumerated.name,
807 texts[uinfo->value.enumerated.item]);
811 static int alc_automute_mode_get(struct snd_kcontrol *kcontrol,
812 struct snd_ctl_elem_value *ucontrol)
814 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
815 struct alc_spec *spec = codec->spec;
816 unsigned int val = 0;
817 if (spec->automute_speaker)
819 if (spec->automute_lo)
822 ucontrol->value.enumerated.item[0] = val;
826 static int alc_automute_mode_put(struct snd_kcontrol *kcontrol,
827 struct snd_ctl_elem_value *ucontrol)
829 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
830 struct alc_spec *spec = codec->spec;
832 switch (ucontrol->value.enumerated.item[0]) {
834 if (!spec->automute_speaker && !spec->automute_lo)
836 spec->automute_speaker = 0;
837 spec->automute_lo = 0;
840 if (spec->automute_speaker_possible) {
841 if (!spec->automute_lo && spec->automute_speaker)
843 spec->automute_speaker = 1;
844 spec->automute_lo = 0;
845 } else if (spec->automute_lo_possible) {
846 if (spec->automute_lo)
848 spec->automute_lo = 1;
853 if (!spec->automute_lo_possible || !spec->automute_speaker_possible)
855 if (spec->automute_speaker && spec->automute_lo)
857 spec->automute_speaker = 1;
858 spec->automute_lo = 1;
863 call_update_outputs(codec);
867 static const struct snd_kcontrol_new alc_automute_mode_enum = {
868 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
869 .name = "Auto-Mute Mode",
870 .info = alc_automute_mode_info,
871 .get = alc_automute_mode_get,
872 .put = alc_automute_mode_put,
875 static struct snd_kcontrol_new *alc_kcontrol_new(struct alc_spec *spec)
877 snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32);
878 return snd_array_new(&spec->kctls);
881 static int alc_add_automute_mode_enum(struct hda_codec *codec)
883 struct alc_spec *spec = codec->spec;
884 struct snd_kcontrol_new *knew;
886 knew = alc_kcontrol_new(spec);
889 *knew = alc_automute_mode_enum;
890 knew->name = kstrdup("Auto-Mute Mode", GFP_KERNEL);
897 * Check the availability of HP/line-out auto-mute;
898 * Set up appropriately if really supported
900 static void alc_init_automute(struct hda_codec *codec)
902 struct alc_spec *spec = codec->spec;
903 struct auto_pin_cfg *cfg = &spec->autocfg;
909 if (cfg->line_out_pins[0])
911 if (cfg->speaker_pins[0])
913 if (present < 2) /* need two different output types */
916 if (!cfg->speaker_pins[0] &&
917 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
918 memcpy(cfg->speaker_pins, cfg->line_out_pins,
919 sizeof(cfg->speaker_pins));
920 cfg->speaker_outs = cfg->line_outs;
923 if (!cfg->hp_pins[0] &&
924 cfg->line_out_type == AUTO_PIN_HP_OUT) {
925 memcpy(cfg->hp_pins, cfg->line_out_pins,
926 sizeof(cfg->hp_pins));
927 cfg->hp_outs = cfg->line_outs;
930 spec->automute_mode = ALC_AUTOMUTE_PIN;
932 for (i = 0; i < cfg->hp_outs; i++) {
933 hda_nid_t nid = cfg->hp_pins[i];
934 if (!is_jack_detectable(codec, nid))
936 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
938 snd_hda_jack_detect_enable(codec, nid, ALC_HP_EVENT);
942 if (cfg->line_out_type == AUTO_PIN_LINE_OUT && cfg->line_outs) {
943 if (cfg->speaker_outs)
944 for (i = 0; i < cfg->line_outs; i++) {
945 hda_nid_t nid = cfg->line_out_pins[i];
946 if (!is_jack_detectable(codec, nid))
948 snd_printdd("realtek: Enable Line-Out "
949 "auto-muting on NID 0x%x\n", nid);
950 snd_hda_jack_detect_enable(codec, nid,
954 spec->automute_lo_possible = spec->detect_hp;
957 spec->automute_speaker_possible = cfg->speaker_outs &&
958 (spec->detect_hp || spec->detect_lo);
960 spec->automute_lo = spec->automute_lo_possible;
961 spec->automute_speaker = spec->automute_speaker_possible;
963 if (spec->automute_speaker_possible || spec->automute_lo_possible) {
964 /* create a control for automute mode */
965 alc_add_automute_mode_enum(codec);
966 spec->unsol_event = alc_sku_unsol_event;
970 /* return the position of NID in the list, or -1 if not found */
971 static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
974 for (i = 0; i < nums; i++)
980 /* check whether dynamic ADC-switching is available */
981 static bool alc_check_dyn_adc_switch(struct hda_codec *codec)
983 struct alc_spec *spec = codec->spec;
984 struct hda_input_mux *imux = &spec->private_imux[0];
988 if (imux != spec->input_mux) /* no dynamic imux? */
991 for (n = 0; n < spec->num_adc_nids; n++) {
992 cap = spec->private_capsrc_nids[n];
993 for (i = 0; i < imux->num_items; i++) {
994 pin = spec->imux_pins[i];
997 if (get_connection_index(codec, cap, pin) < 0)
1000 if (i >= imux->num_items)
1001 return true; /* no ADC-switch is needed */
1004 for (i = 0; i < imux->num_items; i++) {
1005 pin = spec->imux_pins[i];
1006 for (n = 0; n < spec->num_adc_nids; n++) {
1007 cap = spec->private_capsrc_nids[n];
1008 idx = get_connection_index(codec, cap, pin);
1010 imux->items[i].index = idx;
1011 spec->dyn_adc_idx[i] = n;
1017 snd_printdd("realtek: enabling ADC switching\n");
1018 spec->dyn_adc_switch = 1;
1022 /* rebuild imux for matching with the given auto-mic pins (if not yet) */
1023 static bool alc_rebuild_imux_for_auto_mic(struct hda_codec *codec)
1025 struct alc_spec *spec = codec->spec;
1026 struct hda_input_mux *imux;
1027 static char * const texts[3] = {
1028 "Mic", "Internal Mic", "Dock Mic"
1032 if (!spec->auto_mic)
1034 imux = &spec->private_imux[0];
1035 if (spec->input_mux == imux)
1037 spec->imux_pins[0] = spec->ext_mic_pin;
1038 spec->imux_pins[1] = spec->int_mic_pin;
1039 spec->imux_pins[2] = spec->dock_mic_pin;
1040 for (i = 0; i < 3; i++) {
1041 strcpy(imux->items[i].label, texts[i]);
1042 if (spec->imux_pins[i]) {
1043 hda_nid_t pin = spec->imux_pins[i];
1045 for (c = 0; c < spec->num_adc_nids; c++) {
1046 hda_nid_t cap = get_capsrc(spec, c);
1047 int idx = get_connection_index(codec, cap, pin);
1049 imux->items[i].index = idx;
1053 imux->num_items = i + 1;
1056 spec->num_mux_defs = 1;
1057 spec->input_mux = imux;
1061 /* check whether all auto-mic pins are valid; setup indices if OK */
1062 static bool alc_auto_mic_check_imux(struct hda_codec *codec)
1064 struct alc_spec *spec = codec->spec;
1065 const struct hda_input_mux *imux;
1067 if (!spec->auto_mic)
1069 if (spec->auto_mic_valid_imux)
1070 return true; /* already checked */
1072 /* fill up imux indices */
1073 if (!alc_check_dyn_adc_switch(codec)) {
1078 imux = spec->input_mux;
1079 spec->ext_mic_idx = find_idx_in_nid_list(spec->ext_mic_pin,
1080 spec->imux_pins, imux->num_items);
1081 spec->int_mic_idx = find_idx_in_nid_list(spec->int_mic_pin,
1082 spec->imux_pins, imux->num_items);
1083 spec->dock_mic_idx = find_idx_in_nid_list(spec->dock_mic_pin,
1084 spec->imux_pins, imux->num_items);
1085 if (spec->ext_mic_idx < 0 || spec->int_mic_idx < 0) {
1087 return false; /* no corresponding imux */
1090 snd_hda_jack_detect_enable(codec, spec->ext_mic_pin, ALC_MIC_EVENT);
1091 if (spec->dock_mic_pin)
1092 snd_hda_jack_detect_enable(codec, spec->dock_mic_pin,
1095 spec->auto_mic_valid_imux = 1;
1101 * Check the availability of auto-mic switch;
1102 * Set up if really supported
1104 static void alc_init_auto_mic(struct hda_codec *codec)
1106 struct alc_spec *spec = codec->spec;
1107 struct auto_pin_cfg *cfg = &spec->autocfg;
1108 hda_nid_t fixed, ext, dock;
1111 if (spec->shared_mic_hp)
1112 return; /* no auto-mic for the shared I/O */
1114 spec->ext_mic_idx = spec->int_mic_idx = spec->dock_mic_idx = -1;
1116 fixed = ext = dock = 0;
1117 for (i = 0; i < cfg->num_inputs; i++) {
1118 hda_nid_t nid = cfg->inputs[i].pin;
1119 unsigned int defcfg;
1120 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1121 switch (snd_hda_get_input_pin_attr(defcfg)) {
1122 case INPUT_PIN_ATTR_INT:
1124 return; /* already occupied */
1125 if (cfg->inputs[i].type != AUTO_PIN_MIC)
1126 return; /* invalid type */
1129 case INPUT_PIN_ATTR_UNUSED:
1130 return; /* invalid entry */
1131 case INPUT_PIN_ATTR_DOCK:
1133 return; /* already occupied */
1134 if (cfg->inputs[i].type > AUTO_PIN_LINE_IN)
1135 return; /* invalid type */
1140 return; /* already occupied */
1141 if (cfg->inputs[i].type != AUTO_PIN_MIC)
1142 return; /* invalid type */
1153 if (!is_jack_detectable(codec, ext))
1154 return; /* no unsol support */
1155 if (dock && !is_jack_detectable(codec, dock))
1156 return; /* no unsol support */
1158 /* check imux indices */
1159 spec->ext_mic_pin = ext;
1160 spec->int_mic_pin = fixed;
1161 spec->dock_mic_pin = dock;
1164 if (!alc_auto_mic_check_imux(codec))
1167 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n",
1169 spec->unsol_event = alc_sku_unsol_event;
1172 /* check the availabilities of auto-mute and auto-mic switches */
1173 static void alc_auto_check_switches(struct hda_codec *codec)
1175 alc_init_automute(codec);
1176 alc_init_auto_mic(codec);
1180 * Realtek SSID verification
1183 /* Could be any non-zero and even value. When used as fixup, tells
1184 * the driver to ignore any present sku defines.
1186 #define ALC_FIXUP_SKU_IGNORE (2)
1188 static int alc_auto_parse_customize_define(struct hda_codec *codec)
1190 unsigned int ass, tmp, i;
1192 struct alc_spec *spec = codec->spec;
1194 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1196 if (spec->cdefine.fixup) {
1197 ass = spec->cdefine.sku_cfg;
1198 if (ass == ALC_FIXUP_SKU_IGNORE)
1203 ass = codec->subsystem_id & 0xffff;
1204 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
1208 if (codec->vendor_id == 0x10ec0260)
1210 ass = snd_hda_codec_get_pincfg(codec, nid);
1213 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1214 codec->chip_name, ass);
1220 for (i = 1; i < 16; i++) {
1224 if (((ass >> 16) & 0xf) != tmp)
1227 spec->cdefine.port_connectivity = ass >> 30;
1228 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1229 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1230 spec->cdefine.customization = ass >> 8;
1232 spec->cdefine.sku_cfg = ass;
1233 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1234 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1235 spec->cdefine.swap = (ass & 0x2) >> 1;
1236 spec->cdefine.override = ass & 0x1;
1238 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1239 nid, spec->cdefine.sku_cfg);
1240 snd_printd("SKU: port_connectivity=0x%x\n",
1241 spec->cdefine.port_connectivity);
1242 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1243 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1244 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1245 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1246 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1247 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1248 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1253 /* return true if the given NID is found in the list */
1254 static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
1256 return find_idx_in_nid_list(nid, list, nums) >= 0;
1259 /* check subsystem ID and set up device-specific initialization;
1260 * return 1 if initialized, 0 if invalid SSID
1262 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1263 * 31 ~ 16 : Manufacture ID
1265 * 7 ~ 0 : Assembly ID
1266 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1268 static int alc_subsystem_id(struct hda_codec *codec,
1269 hda_nid_t porta, hda_nid_t porte,
1270 hda_nid_t portd, hda_nid_t porti)
1272 unsigned int ass, tmp, i;
1274 struct alc_spec *spec = codec->spec;
1276 if (spec->cdefine.fixup) {
1277 ass = spec->cdefine.sku_cfg;
1278 if (ass == ALC_FIXUP_SKU_IGNORE)
1283 ass = codec->subsystem_id & 0xffff;
1284 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1287 /* invalid SSID, check the special NID pin defcfg instead */
1289 * 31~30 : port connectivity
1292 * 19~16 : Check sum (15:1)
1297 if (codec->vendor_id == 0x10ec0260)
1299 ass = snd_hda_codec_get_pincfg(codec, nid);
1300 snd_printd("realtek: No valid SSID, "
1301 "checking pincfg 0x%08x for NID 0x%x\n",
1305 if ((ass >> 30) != 1) /* no physical connection */
1310 for (i = 1; i < 16; i++) {
1314 if (((ass >> 16) & 0xf) != tmp)
1317 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1318 ass & 0xffff, codec->vendor_id);
1322 * 2 : 0 --> Desktop, 1 --> Laptop
1323 * 3~5 : External Amplifier control
1326 tmp = (ass & 0x38) >> 3; /* external Amp control */
1329 spec->init_amp = ALC_INIT_GPIO1;
1332 spec->init_amp = ALC_INIT_GPIO2;
1335 spec->init_amp = ALC_INIT_GPIO3;
1339 spec->init_amp = ALC_INIT_DEFAULT;
1343 /* is laptop or Desktop and enable the function "Mute internal speaker
1344 * when the external headphone out jack is plugged"
1346 if (!(ass & 0x8000))
1349 * 10~8 : Jack location
1350 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1352 * 15 : 1 --> enable the function "Mute internal speaker
1353 * when the external headphone out jack is plugged"
1355 if (!spec->autocfg.hp_pins[0] &&
1356 !(spec->autocfg.line_out_pins[0] &&
1357 spec->autocfg.line_out_type == AUTO_PIN_HP_OUT)) {
1359 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1370 if (found_in_nid_list(nid, spec->autocfg.line_out_pins,
1371 spec->autocfg.line_outs))
1373 spec->autocfg.hp_pins[0] = nid;
1378 /* Check the validity of ALC subsystem-id
1379 * ports contains an array of 4 pin NIDs for port-A, E, D and I */
1380 static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports)
1382 if (!alc_subsystem_id(codec, ports[0], ports[1], ports[2], ports[3])) {
1383 struct alc_spec *spec = codec->spec;
1384 snd_printd("realtek: "
1385 "Enable default setup for auto mode as fallback\n");
1386 spec->init_amp = ALC_INIT_DEFAULT;
1391 * Fix-up pin default configurations and add default verbs
1399 struct alc_model_fixup {
1410 const struct alc_pincfg *pins;
1411 const struct hda_verb *verbs;
1412 void (*func)(struct hda_codec *codec,
1413 const struct alc_fixup *fix,
1427 ALC_FIXUP_ACT_PRE_PROBE,
1428 ALC_FIXUP_ACT_PROBE,
1432 static void alc_apply_fixup(struct hda_codec *codec, int action)
1434 struct alc_spec *spec = codec->spec;
1435 int id = spec->fixup_id;
1436 #ifdef CONFIG_SND_DEBUG_VERBOSE
1437 const char *modelname = spec->fixup_name;
1441 if (!spec->fixup_list)
1445 const struct alc_fixup *fix = spec->fixup_list + id;
1446 const struct alc_pincfg *cfg;
1448 switch (fix->type) {
1450 if (action != ALC_FIXUP_ACT_PRE_PROBE || !fix->v.sku)
1452 snd_printdd(KERN_INFO "hda_codec: %s: "
1453 "Apply sku override for %s\n",
1454 codec->chip_name, modelname);
1455 spec->cdefine.sku_cfg = fix->v.sku;
1456 spec->cdefine.fixup = 1;
1458 case ALC_FIXUP_PINS:
1460 if (action != ALC_FIXUP_ACT_PRE_PROBE || !cfg)
1462 snd_printdd(KERN_INFO "hda_codec: %s: "
1463 "Apply pincfg for %s\n",
1464 codec->chip_name, modelname);
1465 for (; cfg->nid; cfg++)
1466 snd_hda_codec_set_pincfg(codec, cfg->nid,
1469 case ALC_FIXUP_VERBS:
1470 if (action != ALC_FIXUP_ACT_PROBE || !fix->v.verbs)
1472 snd_printdd(KERN_INFO "hda_codec: %s: "
1473 "Apply fix-verbs for %s\n",
1474 codec->chip_name, modelname);
1475 add_verb(codec->spec, fix->v.verbs);
1477 case ALC_FIXUP_FUNC:
1480 snd_printdd(KERN_INFO "hda_codec: %s: "
1481 "Apply fix-func for %s\n",
1482 codec->chip_name, modelname);
1483 fix->v.func(codec, fix, action);
1486 snd_printk(KERN_ERR "hda_codec: %s: "
1487 "Invalid fixup type %d\n",
1488 codec->chip_name, fix->type);
1499 static void alc_pick_fixup(struct hda_codec *codec,
1500 const struct alc_model_fixup *models,
1501 const struct snd_pci_quirk *quirk,
1502 const struct alc_fixup *fixlist)
1504 struct alc_spec *spec = codec->spec;
1505 const struct snd_pci_quirk *q;
1507 const char *name = NULL;
1509 if (codec->modelname && models) {
1510 while (models->name) {
1511 if (!strcmp(codec->modelname, models->name)) {
1513 name = models->name;
1520 q = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1523 #ifdef CONFIG_SND_DEBUG_VERBOSE
1529 for (q = quirk; q->subvendor; q++) {
1530 unsigned int vendorid =
1531 q->subdevice | (q->subvendor << 16);
1532 if (vendorid == codec->subsystem_id) {
1534 #ifdef CONFIG_SND_DEBUG_VERBOSE
1542 spec->fixup_id = id;
1544 spec->fixup_list = fixlist;
1545 spec->fixup_name = name;
1550 * COEF access helper functions
1552 static int alc_read_coef_idx(struct hda_codec *codec,
1553 unsigned int coef_idx)
1556 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1558 val = snd_hda_codec_read(codec, 0x20, 0,
1559 AC_VERB_GET_PROC_COEF, 0);
1563 static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
1564 unsigned int coef_val)
1566 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1568 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
1572 /* a special bypass for COEF 0; read the cached value at the second time */
1573 static unsigned int alc_get_coef0(struct hda_codec *codec)
1575 struct alc_spec *spec = codec->spec;
1577 spec->coef0 = alc_read_coef_idx(codec, 0);
1582 * Digital I/O handling
1585 /* set right pin controls for digital I/O */
1586 static void alc_auto_init_digital(struct hda_codec *codec)
1588 struct alc_spec *spec = codec->spec;
1592 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1593 pin = spec->autocfg.dig_out_pins[i];
1596 snd_hda_codec_write(codec, pin, 0,
1597 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
1599 dac = spec->multiout.dig_out_nid;
1601 dac = spec->slave_dig_outs[i - 1];
1602 if (!dac || !(get_wcaps(codec, dac) & AC_WCAP_OUT_AMP))
1604 snd_hda_codec_write(codec, dac, 0,
1605 AC_VERB_SET_AMP_GAIN_MUTE,
1608 pin = spec->autocfg.dig_in_pin;
1610 snd_hda_codec_write(codec, pin, 0,
1611 AC_VERB_SET_PIN_WIDGET_CONTROL,
1615 /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1616 static void alc_auto_parse_digital(struct hda_codec *codec)
1618 struct alc_spec *spec = codec->spec;
1622 /* support multiple SPDIFs; the secondary is set up as a slave */
1624 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1626 err = snd_hda_get_connections(codec,
1627 spec->autocfg.dig_out_pins[i],
1628 conn, ARRAY_SIZE(conn));
1631 dig_nid = conn[0]; /* assume the first element is audio-out */
1633 spec->multiout.dig_out_nid = dig_nid;
1634 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1636 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1637 if (nums >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1639 spec->slave_dig_outs[nums - 1] = dig_nid;
1644 if (spec->autocfg.dig_in_pin) {
1645 dig_nid = codec->start_nid;
1646 for (i = 0; i < codec->num_nodes; i++, dig_nid++) {
1647 unsigned int wcaps = get_wcaps(codec, dig_nid);
1648 if (get_wcaps_type(wcaps) != AC_WID_AUD_IN)
1650 if (!(wcaps & AC_WCAP_DIGITAL))
1652 if (!(wcaps & AC_WCAP_CONN_LIST))
1654 err = get_connection_index(codec, dig_nid,
1655 spec->autocfg.dig_in_pin);
1657 spec->dig_in_nid = dig_nid;
1665 * capture mixer elements
1667 static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1668 struct snd_ctl_elem_info *uinfo)
1670 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1671 struct alc_spec *spec = codec->spec;
1675 mutex_lock(&codec->control_mutex);
1676 if (spec->vol_in_capsrc)
1677 val = HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[0], 3, 0, HDA_OUTPUT);
1679 val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, HDA_INPUT);
1680 kcontrol->private_value = val;
1681 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
1682 mutex_unlock(&codec->control_mutex);
1686 static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1687 unsigned int size, unsigned int __user *tlv)
1689 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1690 struct alc_spec *spec = codec->spec;
1694 mutex_lock(&codec->control_mutex);
1695 if (spec->vol_in_capsrc)
1696 val = HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[0], 3, 0, HDA_OUTPUT);
1698 val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, HDA_INPUT);
1699 kcontrol->private_value = val;
1700 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
1701 mutex_unlock(&codec->control_mutex);
1705 typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1706 struct snd_ctl_elem_value *ucontrol);
1708 static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1709 struct snd_ctl_elem_value *ucontrol,
1710 getput_call_t func, bool check_adc_switch)
1712 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1713 struct alc_spec *spec = codec->spec;
1716 mutex_lock(&codec->control_mutex);
1717 if (check_adc_switch && spec->dyn_adc_switch) {
1718 for (i = 0; i < spec->num_adc_nids; i++) {
1719 kcontrol->private_value =
1720 HDA_COMPOSE_AMP_VAL(spec->adc_nids[i],
1722 err = func(kcontrol, ucontrol);
1727 i = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1728 if (spec->vol_in_capsrc)
1729 kcontrol->private_value =
1730 HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[i],
1733 kcontrol->private_value =
1734 HDA_COMPOSE_AMP_VAL(spec->adc_nids[i],
1736 err = func(kcontrol, ucontrol);
1739 mutex_unlock(&codec->control_mutex);
1743 static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1744 struct snd_ctl_elem_value *ucontrol)
1746 return alc_cap_getput_caller(kcontrol, ucontrol,
1747 snd_hda_mixer_amp_volume_get, false);
1750 static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1751 struct snd_ctl_elem_value *ucontrol)
1753 return alc_cap_getput_caller(kcontrol, ucontrol,
1754 snd_hda_mixer_amp_volume_put, true);
1757 /* capture mixer elements */
1758 #define alc_cap_sw_info snd_ctl_boolean_stereo_info
1760 static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1761 struct snd_ctl_elem_value *ucontrol)
1763 return alc_cap_getput_caller(kcontrol, ucontrol,
1764 snd_hda_mixer_amp_switch_get, false);
1767 static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1768 struct snd_ctl_elem_value *ucontrol)
1770 return alc_cap_getput_caller(kcontrol, ucontrol,
1771 snd_hda_mixer_amp_switch_put, true);
1774 #define _DEFINE_CAPMIX(num) \
1776 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1777 .name = "Capture Switch", \
1778 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1780 .info = alc_cap_sw_info, \
1781 .get = alc_cap_sw_get, \
1782 .put = alc_cap_sw_put, \
1785 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1786 .name = "Capture Volume", \
1787 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1788 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1789 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1791 .info = alc_cap_vol_info, \
1792 .get = alc_cap_vol_get, \
1793 .put = alc_cap_vol_put, \
1794 .tlv = { .c = alc_cap_vol_tlv }, \
1797 #define _DEFINE_CAPSRC(num) \
1799 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1800 /* .name = "Capture Source", */ \
1801 .name = "Input Source", \
1803 .info = alc_mux_enum_info, \
1804 .get = alc_mux_enum_get, \
1805 .put = alc_mux_enum_put, \
1808 #define DEFINE_CAPMIX(num) \
1809 static const struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1810 _DEFINE_CAPMIX(num), \
1811 _DEFINE_CAPSRC(num), \
1815 #define DEFINE_CAPMIX_NOSRC(num) \
1816 static const struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
1817 _DEFINE_CAPMIX(num), \
1821 /* up to three ADCs */
1825 DEFINE_CAPMIX_NOSRC(1);
1826 DEFINE_CAPMIX_NOSRC(2);
1827 DEFINE_CAPMIX_NOSRC(3);
1830 * virtual master controls
1834 * slave controls for virtual master
1836 static const char * const alc_slave_vols[] = {
1837 "Front Playback Volume",
1838 "Surround Playback Volume",
1839 "Center Playback Volume",
1840 "LFE Playback Volume",
1841 "Side Playback Volume",
1842 "Headphone Playback Volume",
1843 "Speaker Playback Volume",
1844 "Mono Playback Volume",
1845 "Line-Out Playback Volume",
1846 "PCM Playback Volume",
1850 static const char * const alc_slave_sws[] = {
1851 "Front Playback Switch",
1852 "Surround Playback Switch",
1853 "Center Playback Switch",
1854 "LFE Playback Switch",
1855 "Side Playback Switch",
1856 "Headphone Playback Switch",
1857 "Speaker Playback Switch",
1858 "Mono Playback Switch",
1859 "IEC958 Playback Switch",
1860 "Line-Out Playback Switch",
1861 "PCM Playback Switch",
1866 * build control elements
1869 #define NID_MAPPING (-1)
1871 #define SUBDEV_SPEAKER_ (0 << 6)
1872 #define SUBDEV_HP_ (1 << 6)
1873 #define SUBDEV_LINE_ (2 << 6)
1874 #define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
1875 #define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
1876 #define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
1878 static void alc_free_kctls(struct hda_codec *codec);
1880 #ifdef CONFIG_SND_HDA_INPUT_BEEP
1881 /* additional beep mixers; the actual parameters are overwritten at build */
1882 static const struct snd_kcontrol_new alc_beep_mixer[] = {
1883 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
1884 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
1889 static int __alc_build_controls(struct hda_codec *codec)
1891 struct alc_spec *spec = codec->spec;
1892 struct snd_kcontrol *kctl = NULL;
1893 const struct snd_kcontrol_new *knew;
1898 for (i = 0; i < spec->num_mixers; i++) {
1899 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1903 if (spec->cap_mixer) {
1904 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
1908 if (spec->multiout.dig_out_nid) {
1909 err = snd_hda_create_spdif_out_ctls(codec,
1910 spec->multiout.dig_out_nid,
1911 spec->multiout.dig_out_nid);
1914 if (!spec->no_analog) {
1915 err = snd_hda_create_spdif_share_sw(codec,
1919 spec->multiout.share_spdif = 1;
1922 if (spec->dig_in_nid) {
1923 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1928 #ifdef CONFIG_SND_HDA_INPUT_BEEP
1929 /* create beep controls if needed */
1930 if (spec->beep_amp) {
1931 const struct snd_kcontrol_new *knew;
1932 for (knew = alc_beep_mixer; knew->name; knew++) {
1933 struct snd_kcontrol *kctl;
1934 kctl = snd_ctl_new1(knew, codec);
1937 kctl->private_value = spec->beep_amp;
1938 err = snd_hda_ctl_add(codec, 0, kctl);
1945 /* if we have no master control, let's create it */
1946 if (!spec->no_analog &&
1947 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1948 unsigned int vmaster_tlv[4];
1949 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
1950 HDA_OUTPUT, vmaster_tlv);
1951 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1952 vmaster_tlv, alc_slave_vols);
1956 if (!spec->no_analog &&
1957 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1958 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1959 NULL, alc_slave_sws);
1964 /* assign Capture Source enums to NID */
1965 if (spec->capsrc_nids || spec->adc_nids) {
1966 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
1968 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
1969 for (i = 0; kctl && i < kctl->count; i++) {
1970 err = snd_hda_add_nid(codec, kctl, i,
1971 get_capsrc(spec, i));
1976 if (spec->cap_mixer && spec->adc_nids) {
1977 const char *kname = kctl ? kctl->id.name : NULL;
1978 for (knew = spec->cap_mixer; knew->name; knew++) {
1979 if (kname && strcmp(knew->name, kname) == 0)
1981 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
1982 for (i = 0; kctl && i < kctl->count; i++) {
1983 err = snd_hda_add_nid(codec, kctl, i,
1991 /* other nid->control mapping */
1992 for (i = 0; i < spec->num_mixers; i++) {
1993 for (knew = spec->mixers[i]; knew->name; knew++) {
1994 if (knew->iface != NID_MAPPING)
1996 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
1999 u = knew->subdevice;
2000 for (j = 0; j < 4; j++, u >>= 8) {
2005 case SUBDEV_SPEAKER_:
2006 nid = spec->autocfg.speaker_pins[nid];
2009 nid = spec->autocfg.line_out_pins[nid];
2012 nid = spec->autocfg.hp_pins[nid];
2017 err = snd_hda_add_nid(codec, kctl, 0, nid);
2021 u = knew->private_value;
2022 for (j = 0; j < 4; j++, u >>= 8) {
2026 err = snd_hda_add_nid(codec, kctl, 0, nid);
2033 alc_free_kctls(codec); /* no longer needed */
2038 static int alc_build_controls(struct hda_codec *codec)
2040 struct alc_spec *spec = codec->spec;
2041 int err = __alc_build_controls(codec);
2044 return snd_hda_jack_add_kctls(codec, &spec->autocfg);
2052 static void alc_init_special_input_src(struct hda_codec *codec);
2054 static int alc_init(struct hda_codec *codec)
2056 struct alc_spec *spec = codec->spec;
2060 alc_auto_init_amp(codec, spec->init_amp);
2062 for (i = 0; i < spec->num_init_verbs; i++)
2063 snd_hda_sequence_write(codec, spec->init_verbs[i]);
2064 alc_init_special_input_src(codec);
2066 if (spec->init_hook)
2067 spec->init_hook(codec);
2069 alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT);
2071 snd_hda_jack_report_sync(codec);
2073 hda_call_check_power_status(codec, 0x01);
2077 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2079 struct alc_spec *spec = codec->spec;
2081 if (spec->unsol_event)
2082 spec->unsol_event(codec, res);
2085 #ifdef CONFIG_SND_HDA_POWER_SAVE
2086 static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2088 struct alc_spec *spec = codec->spec;
2089 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2094 * Analog playback callbacks
2096 static int alc_playback_pcm_open(struct hda_pcm_stream *hinfo,
2097 struct hda_codec *codec,
2098 struct snd_pcm_substream *substream)
2100 struct alc_spec *spec = codec->spec;
2101 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2105 static int alc_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2106 struct hda_codec *codec,
2107 unsigned int stream_tag,
2108 unsigned int format,
2109 struct snd_pcm_substream *substream)
2111 struct alc_spec *spec = codec->spec;
2112 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2113 stream_tag, format, substream);
2116 static int alc_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2117 struct hda_codec *codec,
2118 struct snd_pcm_substream *substream)
2120 struct alc_spec *spec = codec->spec;
2121 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2127 static int alc_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2128 struct hda_codec *codec,
2129 struct snd_pcm_substream *substream)
2131 struct alc_spec *spec = codec->spec;
2132 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2135 static int alc_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2136 struct hda_codec *codec,
2137 unsigned int stream_tag,
2138 unsigned int format,
2139 struct snd_pcm_substream *substream)
2141 struct alc_spec *spec = codec->spec;
2142 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2143 stream_tag, format, substream);
2146 static int alc_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2147 struct hda_codec *codec,
2148 struct snd_pcm_substream *substream)
2150 struct alc_spec *spec = codec->spec;
2151 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2154 static int alc_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2155 struct hda_codec *codec,
2156 struct snd_pcm_substream *substream)
2158 struct alc_spec *spec = codec->spec;
2159 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2165 static int alc_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2166 struct hda_codec *codec,
2167 unsigned int stream_tag,
2168 unsigned int format,
2169 struct snd_pcm_substream *substream)
2171 struct alc_spec *spec = codec->spec;
2173 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
2174 stream_tag, 0, format);
2178 static int alc_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2179 struct hda_codec *codec,
2180 struct snd_pcm_substream *substream)
2182 struct alc_spec *spec = codec->spec;
2184 snd_hda_codec_cleanup_stream(codec,
2185 spec->adc_nids[substream->number + 1]);
2189 /* analog capture with dynamic dual-adc changes */
2190 static int dyn_adc_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2191 struct hda_codec *codec,
2192 unsigned int stream_tag,
2193 unsigned int format,
2194 struct snd_pcm_substream *substream)
2196 struct alc_spec *spec = codec->spec;
2197 spec->cur_adc = spec->adc_nids[spec->dyn_adc_idx[spec->cur_mux[0]]];
2198 spec->cur_adc_stream_tag = stream_tag;
2199 spec->cur_adc_format = format;
2200 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
2204 static int dyn_adc_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2205 struct hda_codec *codec,
2206 struct snd_pcm_substream *substream)
2208 struct alc_spec *spec = codec->spec;
2209 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
2214 static const struct hda_pcm_stream dyn_adc_pcm_analog_capture = {
2218 .nid = 0, /* fill later */
2220 .prepare = dyn_adc_capture_pcm_prepare,
2221 .cleanup = dyn_adc_capture_pcm_cleanup
2227 static const struct hda_pcm_stream alc_pcm_analog_playback = {
2231 /* NID is set in alc_build_pcms */
2233 .open = alc_playback_pcm_open,
2234 .prepare = alc_playback_pcm_prepare,
2235 .cleanup = alc_playback_pcm_cleanup
2239 static const struct hda_pcm_stream alc_pcm_analog_capture = {
2243 /* NID is set in alc_build_pcms */
2246 static const struct hda_pcm_stream alc_pcm_analog_alt_playback = {
2250 /* NID is set in alc_build_pcms */
2253 static const struct hda_pcm_stream alc_pcm_analog_alt_capture = {
2254 .substreams = 2, /* can be overridden */
2257 /* NID is set in alc_build_pcms */
2259 .prepare = alc_alt_capture_pcm_prepare,
2260 .cleanup = alc_alt_capture_pcm_cleanup
2264 static const struct hda_pcm_stream alc_pcm_digital_playback = {
2268 /* NID is set in alc_build_pcms */
2270 .open = alc_dig_playback_pcm_open,
2271 .close = alc_dig_playback_pcm_close,
2272 .prepare = alc_dig_playback_pcm_prepare,
2273 .cleanup = alc_dig_playback_pcm_cleanup
2277 static const struct hda_pcm_stream alc_pcm_digital_capture = {
2281 /* NID is set in alc_build_pcms */
2284 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
2285 static const struct hda_pcm_stream alc_pcm_null_stream = {
2291 static int alc_build_pcms(struct hda_codec *codec)
2293 struct alc_spec *spec = codec->spec;
2294 struct hda_pcm *info = spec->pcm_rec;
2295 const struct hda_pcm_stream *p;
2296 bool have_multi_adcs;
2299 codec->num_pcms = 1;
2300 codec->pcm_info = info;
2302 if (spec->no_analog)
2305 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
2306 "%s Analog", codec->chip_name);
2307 info->name = spec->stream_name_analog;
2309 if (spec->multiout.dac_nids > 0) {
2310 p = spec->stream_analog_playback;
2312 p = &alc_pcm_analog_playback;
2313 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p;
2314 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2316 if (spec->adc_nids) {
2317 p = spec->stream_analog_capture;
2319 if (spec->dyn_adc_switch)
2320 p = &dyn_adc_pcm_analog_capture;
2322 p = &alc_pcm_analog_capture;
2324 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p;
2325 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2328 if (spec->channel_mode) {
2329 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2330 for (i = 0; i < spec->num_channel_mode; i++) {
2331 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2332 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2338 /* SPDIF for stream index #1 */
2339 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2340 snprintf(spec->stream_name_digital,
2341 sizeof(spec->stream_name_digital),
2342 "%s Digital", codec->chip_name);
2343 codec->num_pcms = 2;
2344 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
2345 info = spec->pcm_rec + 1;
2346 info->name = spec->stream_name_digital;
2347 if (spec->dig_out_type)
2348 info->pcm_type = spec->dig_out_type;
2350 info->pcm_type = HDA_PCM_TYPE_SPDIF;
2351 if (spec->multiout.dig_out_nid) {
2352 p = spec->stream_digital_playback;
2354 p = &alc_pcm_digital_playback;
2355 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p;
2356 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2358 if (spec->dig_in_nid) {
2359 p = spec->stream_digital_capture;
2361 p = &alc_pcm_digital_capture;
2362 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p;
2363 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2365 /* FIXME: do we need this for all Realtek codec models? */
2366 codec->spdif_status_reset = 1;
2369 if (spec->no_analog)
2372 /* If the use of more than one ADC is requested for the current
2373 * model, configure a second analog capture-only PCM.
2375 have_multi_adcs = (spec->num_adc_nids > 1) &&
2376 !spec->dyn_adc_switch && !spec->auto_mic &&
2377 (!spec->input_mux || spec->input_mux->num_items > 1);
2378 /* Additional Analaog capture for index #2 */
2379 if (spec->alt_dac_nid || have_multi_adcs) {
2380 codec->num_pcms = 3;
2381 info = spec->pcm_rec + 2;
2382 info->name = spec->stream_name_analog;
2383 if (spec->alt_dac_nid) {
2384 p = spec->stream_analog_alt_playback;
2386 p = &alc_pcm_analog_alt_playback;
2387 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p;
2388 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2391 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2392 alc_pcm_null_stream;
2393 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2395 if (have_multi_adcs) {
2396 p = spec->stream_analog_alt_capture;
2398 p = &alc_pcm_analog_alt_capture;
2399 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p;
2400 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2402 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2403 spec->num_adc_nids - 1;
2405 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2406 alc_pcm_null_stream;
2407 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
2414 static inline void alc_shutup(struct hda_codec *codec)
2416 struct alc_spec *spec = codec->spec;
2418 if (spec && spec->shutup)
2419 spec->shutup(codec);
2420 snd_hda_shutup_pins(codec);
2423 static void alc_free_kctls(struct hda_codec *codec)
2425 struct alc_spec *spec = codec->spec;
2427 if (spec->kctls.list) {
2428 struct snd_kcontrol_new *kctl = spec->kctls.list;
2430 for (i = 0; i < spec->kctls.used; i++)
2431 kfree(kctl[i].name);
2433 snd_array_free(&spec->kctls);
2436 static void alc_free_bind_ctls(struct hda_codec *codec)
2438 struct alc_spec *spec = codec->spec;
2439 if (spec->bind_ctls.list) {
2440 struct hda_bind_ctls **ctl = spec->bind_ctls.list;
2442 for (i = 0; i < spec->bind_ctls.used; i++)
2445 snd_array_free(&spec->bind_ctls);
2448 static void alc_free(struct hda_codec *codec)
2450 struct alc_spec *spec = codec->spec;
2456 alc_free_kctls(codec);
2457 alc_free_bind_ctls(codec);
2459 snd_hda_detach_beep_device(codec);
2462 #ifdef CONFIG_SND_HDA_POWER_SAVE
2463 static void alc_power_eapd(struct hda_codec *codec)
2465 alc_auto_setup_eapd(codec, false);
2468 static int alc_suspend(struct hda_codec *codec, pm_message_t state)
2470 struct alc_spec *spec = codec->spec;
2472 if (spec && spec->power_hook)
2473 spec->power_hook(codec);
2479 static int alc_resume(struct hda_codec *codec)
2481 msleep(150); /* to avoid pop noise */
2482 codec->patch_ops.init(codec);
2483 snd_hda_codec_resume_amp(codec);
2484 snd_hda_codec_resume_cache(codec);
2485 hda_call_check_power_status(codec, 0x01);
2492 static const struct hda_codec_ops alc_patch_ops = {
2493 .build_controls = alc_build_controls,
2494 .build_pcms = alc_build_pcms,
2497 .unsol_event = alc_unsol_event,
2499 .resume = alc_resume,
2501 #ifdef CONFIG_SND_HDA_POWER_SAVE
2502 .suspend = alc_suspend,
2503 .check_power_status = alc_check_power_status,
2505 .reboot_notify = alc_shutup,
2508 /* replace the codec chip_name with the given string */
2509 static int alc_codec_rename(struct hda_codec *codec, const char *name)
2511 kfree(codec->chip_name);
2512 codec->chip_name = kstrdup(name, GFP_KERNEL);
2513 if (!codec->chip_name) {
2521 * Rename codecs appropriately from COEF value
2523 struct alc_codec_rename_table {
2524 unsigned int vendor_id;
2525 unsigned short coef_mask;
2526 unsigned short coef_bits;
2530 static struct alc_codec_rename_table rename_tbl[] = {
2531 { 0x10ec0269, 0xfff0, 0x3010, "ALC277" },
2532 { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" },
2533 { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" },
2534 { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" },
2535 { 0x10ec0269, 0xffff, 0xa023, "ALC259" },
2536 { 0x10ec0269, 0xffff, 0x6023, "ALC281X" },
2537 { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" },
2538 { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" },
2539 { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" },
2540 { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" },
2541 { 0x10ec0899, 0x2000, 0x2000, "ALC899" },
2542 { 0x10ec0892, 0xffff, 0x8020, "ALC661" },
2543 { 0x10ec0892, 0xffff, 0x8011, "ALC661" },
2544 { 0x10ec0892, 0xffff, 0x4011, "ALC656" },
2545 { } /* terminator */
2548 static int alc_codec_rename_from_preset(struct hda_codec *codec)
2550 const struct alc_codec_rename_table *p;
2552 for (p = rename_tbl; p->vendor_id; p++) {
2553 if (p->vendor_id != codec->vendor_id)
2555 if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits)
2556 return alc_codec_rename(codec, p->name);
2562 * Automatic parse of I/O pins from the BIOS configuration
2567 ALC_CTL_WIDGET_MUTE,
2572 static const struct snd_kcontrol_new alc_control_templates[] = {
2573 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2574 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2575 HDA_BIND_MUTE(NULL, 0, 0, 0),
2576 HDA_BIND_VOL(NULL, 0),
2577 HDA_BIND_SW(NULL, 0),
2580 /* add dynamic controls */
2581 static int add_control(struct alc_spec *spec, int type, const char *name,
2582 int cidx, unsigned long val)
2584 struct snd_kcontrol_new *knew;
2586 knew = alc_kcontrol_new(spec);
2589 *knew = alc_control_templates[type];
2590 knew->name = kstrdup(name, GFP_KERNEL);
2594 if (get_amp_nid_(val))
2595 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
2596 knew->private_value = val;
2600 static int add_control_with_pfx(struct alc_spec *spec, int type,
2601 const char *pfx, const char *dir,
2602 const char *sfx, int cidx, unsigned long val)
2605 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
2606 return add_control(spec, type, name, cidx, val);
2609 #define add_pb_vol_ctrl(spec, type, pfx, val) \
2610 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
2611 #define add_pb_sw_ctrl(spec, type, pfx, val) \
2612 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
2613 #define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
2614 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
2615 #define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
2616 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
2618 static const char * const channel_name[4] = {
2619 "Front", "Surround", "CLFE", "Side"
2622 static const char *alc_get_line_out_pfx(struct alc_spec *spec, int ch,
2623 bool can_be_master, int *index)
2625 struct auto_pin_cfg *cfg = &spec->autocfg;
2628 if (cfg->line_outs == 1 && !spec->multi_ios &&
2629 !cfg->hp_outs && !cfg->speaker_outs && can_be_master)
2632 switch (cfg->line_out_type) {
2633 case AUTO_PIN_SPEAKER_OUT:
2634 if (cfg->line_outs == 1)
2636 if (cfg->line_outs == 2)
2637 return ch ? "Bass Speaker" : "Speaker";
2639 case AUTO_PIN_HP_OUT:
2640 /* for multi-io case, only the primary out */
2641 if (ch && spec->multi_ios)
2646 if (cfg->line_outs == 1 && !spec->multi_ios)
2650 if (snd_BUG_ON(ch >= ARRAY_SIZE(channel_name)))
2653 return channel_name[ch];
2656 /* create input playback/capture controls for the given pin */
2657 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
2658 const char *ctlname, int ctlidx,
2659 int idx, hda_nid_t mix_nid)
2663 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx,
2664 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
2667 err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx,
2668 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
2674 static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
2676 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
2677 return (pincap & AC_PINCAP_IN) != 0;
2680 /* Parse the codec tree and retrieve ADCs and corresponding capsrc MUXs */
2681 static int alc_auto_fill_adc_caps(struct hda_codec *codec)
2683 struct alc_spec *spec = codec->spec;
2685 hda_nid_t *adc_nids = spec->private_adc_nids;
2686 hda_nid_t *cap_nids = spec->private_capsrc_nids;
2687 int max_nums = ARRAY_SIZE(spec->private_adc_nids);
2690 if (spec->shared_mic_hp)
2691 max_nums = 1; /* no multi streams with the shared HP/mic */
2693 nid = codec->start_nid;
2694 for (i = 0; i < codec->num_nodes; i++, nid++) {
2696 const hda_nid_t *list;
2697 unsigned int caps = get_wcaps(codec, nid);
2698 int type = get_wcaps_type(caps);
2700 if (type != AC_WID_AUD_IN || (caps & AC_WCAP_DIGITAL))
2702 adc_nids[nums] = nid;
2703 cap_nids[nums] = nid;
2707 type = get_wcaps_type(get_wcaps(codec, src));
2708 if (type == AC_WID_PIN)
2710 if (type == AC_WID_AUD_SEL) {
2711 cap_nids[nums] = src;
2714 n = snd_hda_get_conn_list(codec, src, &list);
2716 cap_nids[nums] = src;
2722 if (++nums >= max_nums)
2725 spec->adc_nids = spec->private_adc_nids;
2726 spec->capsrc_nids = spec->private_capsrc_nids;
2727 spec->num_adc_nids = nums;
2731 /* create playback/capture controls for input pins */
2732 static int alc_auto_create_input_ctls(struct hda_codec *codec)
2734 struct alc_spec *spec = codec->spec;
2735 const struct auto_pin_cfg *cfg = &spec->autocfg;
2736 hda_nid_t mixer = spec->mixer_nid;
2737 struct hda_input_mux *imux = &spec->private_imux[0];
2739 int i, c, err, idx, type_idx = 0;
2740 const char *prev_label = NULL;
2742 num_adcs = alc_auto_fill_adc_caps(codec);
2746 for (i = 0; i < cfg->num_inputs; i++) {
2750 pin = cfg->inputs[i].pin;
2751 if (!alc_is_input_pin(codec, pin))
2754 label = hda_get_autocfg_input_label(codec, cfg, i);
2755 if (spec->shared_mic_hp && !strcmp(label, "Misc"))
2756 label = "Headphone Mic";
2757 if (prev_label && !strcmp(label, prev_label))
2764 idx = get_connection_index(codec, mixer, pin);
2766 err = new_analog_input(spec, pin,
2774 for (c = 0; c < num_adcs; c++) {
2775 hda_nid_t cap = get_capsrc(spec, c);
2776 idx = get_connection_index(codec, cap, pin);
2778 spec->imux_pins[imux->num_items] = pin;
2779 snd_hda_add_imux_item(imux, label, idx, NULL);
2785 spec->num_mux_defs = 1;
2786 spec->input_mux = imux;
2791 /* create a shared input with the headphone out */
2792 static int alc_auto_create_shared_input(struct hda_codec *codec)
2794 struct alc_spec *spec = codec->spec;
2795 struct auto_pin_cfg *cfg = &spec->autocfg;
2796 unsigned int defcfg;
2799 /* only one internal input pin? */
2800 if (cfg->num_inputs != 1)
2802 defcfg = snd_hda_codec_get_pincfg(codec, cfg->inputs[0].pin);
2803 if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT)
2806 if (cfg->hp_outs == 1 && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
2807 nid = cfg->hp_pins[0]; /* OK, we have a single HP-out */
2808 else if (cfg->line_outs == 1 && cfg->line_out_type == AUTO_PIN_HP_OUT)
2809 nid = cfg->line_out_pins[0]; /* OK, we have a single line-out */
2811 return 0; /* both not available */
2813 if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_IN))
2814 return 0; /* no input */
2816 cfg->inputs[1].pin = nid;
2817 cfg->inputs[1].type = AUTO_PIN_MIC;
2818 cfg->num_inputs = 2;
2819 spec->shared_mic_hp = 1;
2820 snd_printdd("realtek: Enable shared I/O jack on NID 0x%x\n", nid);
2824 static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
2825 unsigned int pin_type)
2827 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2830 if (nid_has_mute(codec, nid, HDA_OUTPUT))
2831 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2835 static int get_pin_type(int line_out_type)
2837 if (line_out_type == AUTO_PIN_HP_OUT)
2843 static void alc_auto_init_analog_input(struct hda_codec *codec)
2845 struct alc_spec *spec = codec->spec;
2846 struct auto_pin_cfg *cfg = &spec->autocfg;
2849 for (i = 0; i < cfg->num_inputs; i++) {
2850 hda_nid_t nid = cfg->inputs[i].pin;
2851 if (alc_is_input_pin(codec, nid)) {
2852 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
2853 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
2854 snd_hda_codec_write(codec, nid, 0,
2855 AC_VERB_SET_AMP_GAIN_MUTE,
2860 /* mute all loopback inputs */
2861 if (spec->mixer_nid) {
2862 int nums = snd_hda_get_conn_list(codec, spec->mixer_nid, NULL);
2863 for (i = 0; i < nums; i++)
2864 snd_hda_codec_write(codec, spec->mixer_nid, 0,
2865 AC_VERB_SET_AMP_GAIN_MUTE,
2870 /* convert from MIX nid to DAC */
2871 static hda_nid_t alc_auto_mix_to_dac(struct hda_codec *codec, hda_nid_t nid)
2876 if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_AUD_OUT)
2878 num = snd_hda_get_connections(codec, nid, list, ARRAY_SIZE(list));
2879 for (i = 0; i < num; i++) {
2880 if (get_wcaps_type(get_wcaps(codec, list[i])) == AC_WID_AUD_OUT)
2886 /* go down to the selector widget before the mixer */
2887 static hda_nid_t alc_go_down_to_selector(struct hda_codec *codec, hda_nid_t pin)
2890 int num = snd_hda_get_connections(codec, pin, srcs,
2893 get_wcaps_type(get_wcaps(codec, srcs[0])) != AC_WID_AUD_SEL)
2898 /* get MIX nid connected to the given pin targeted to DAC */
2899 static hda_nid_t alc_auto_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
2905 pin = alc_go_down_to_selector(codec, pin);
2906 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
2907 for (i = 0; i < num; i++) {
2908 if (alc_auto_mix_to_dac(codec, mix[i]) == dac)
2914 /* select the connection from pin to DAC if needed */
2915 static int alc_auto_select_dac(struct hda_codec *codec, hda_nid_t pin,
2921 pin = alc_go_down_to_selector(codec, pin);
2922 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
2925 for (i = 0; i < num; i++) {
2926 if (alc_auto_mix_to_dac(codec, mix[i]) == dac) {
2927 snd_hda_codec_update_cache(codec, pin, 0,
2928 AC_VERB_SET_CONNECT_SEL, i);
2935 /* look for an empty DAC slot */
2936 static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
2938 struct alc_spec *spec = codec->spec;
2942 pin = alc_go_down_to_selector(codec, pin);
2943 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
2944 for (i = 0; i < num; i++) {
2945 hda_nid_t nid = alc_auto_mix_to_dac(codec, srcs[i]);
2948 if (found_in_nid_list(nid, spec->multiout.dac_nids,
2949 ARRAY_SIZE(spec->private_dac_nids)))
2951 if (found_in_nid_list(nid, spec->multiout.hp_out_nid,
2952 ARRAY_SIZE(spec->multiout.hp_out_nid)))
2954 if (found_in_nid_list(nid, spec->multiout.extra_out_nid,
2955 ARRAY_SIZE(spec->multiout.extra_out_nid)))
2962 /* check whether the DAC is reachable from the pin */
2963 static bool alc_auto_is_dac_reachable(struct hda_codec *codec,
2964 hda_nid_t pin, hda_nid_t dac)
2969 pin = alc_go_down_to_selector(codec, pin);
2970 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
2971 for (i = 0; i < num; i++) {
2972 hda_nid_t nid = alc_auto_mix_to_dac(codec, srcs[i]);
2979 static hda_nid_t get_dac_if_single(struct hda_codec *codec, hda_nid_t pin)
2981 hda_nid_t sel = alc_go_down_to_selector(codec, pin);
2982 if (snd_hda_get_conn_list(codec, sel, NULL) == 1)
2983 return alc_auto_look_for_dac(codec, pin);
2987 /* return 0 if no possible DAC is found, 1 if one or more found */
2988 static int alc_auto_fill_extra_dacs(struct hda_codec *codec, int num_outs,
2989 const hda_nid_t *pins, hda_nid_t *dacs)
2993 if (num_outs && !dacs[0]) {
2994 dacs[0] = alc_auto_look_for_dac(codec, pins[0]);
2999 for (i = 1; i < num_outs; i++)
3000 dacs[i] = get_dac_if_single(codec, pins[i]);
3001 for (i = 1; i < num_outs; i++) {
3003 dacs[i] = alc_auto_look_for_dac(codec, pins[i]);
3008 static int alc_auto_fill_multi_ios(struct hda_codec *codec,
3009 unsigned int location, int offset);
3010 static hda_nid_t alc_look_for_out_vol_nid(struct hda_codec *codec,
3011 hda_nid_t pin, hda_nid_t dac);
3013 /* fill in the dac_nids table from the parsed pin configuration */
3014 static int alc_auto_fill_dac_nids(struct hda_codec *codec)
3016 struct alc_spec *spec = codec->spec;
3017 struct auto_pin_cfg *cfg = &spec->autocfg;
3018 unsigned int location, defcfg;
3020 bool redone = false;
3024 /* set num_dacs once to full for alc_auto_look_for_dac() */
3025 spec->multiout.num_dacs = cfg->line_outs;
3026 spec->multiout.hp_out_nid[0] = 0;
3027 spec->multiout.extra_out_nid[0] = 0;
3028 memset(spec->private_dac_nids, 0, sizeof(spec->private_dac_nids));
3029 spec->multiout.dac_nids = spec->private_dac_nids;
3030 spec->multi_ios = 0;
3032 /* fill hard-wired DACs first */
3034 for (i = 0; i < cfg->line_outs; i++)
3035 spec->private_dac_nids[i] =
3036 get_dac_if_single(codec, cfg->line_out_pins[i]);
3038 spec->multiout.hp_out_nid[0] =
3039 get_dac_if_single(codec, cfg->hp_pins[0]);
3040 if (cfg->speaker_outs)
3041 spec->multiout.extra_out_nid[0] =
3042 get_dac_if_single(codec, cfg->speaker_pins[0]);
3045 for (i = 0; i < cfg->line_outs; i++) {
3046 hda_nid_t pin = cfg->line_out_pins[i];
3047 if (spec->private_dac_nids[i])
3049 spec->private_dac_nids[i] = alc_auto_look_for_dac(codec, pin);
3050 if (!spec->private_dac_nids[i] && !redone) {
3051 /* if we can't find primary DACs, re-probe without
3052 * checking the hard-wired DACs
3059 /* re-count num_dacs and squash invalid entries */
3060 spec->multiout.num_dacs = 0;
3061 for (i = 0; i < cfg->line_outs; i++) {
3062 if (spec->private_dac_nids[i])
3063 spec->multiout.num_dacs++;
3065 memmove(spec->private_dac_nids + i,
3066 spec->private_dac_nids + i + 1,
3067 sizeof(hda_nid_t) * (cfg->line_outs - i - 1));
3068 spec->private_dac_nids[cfg->line_outs - 1] = 0;
3072 if (cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
3073 /* try to fill multi-io first */
3074 defcfg = snd_hda_codec_get_pincfg(codec, cfg->line_out_pins[0]);
3075 location = get_defcfg_location(defcfg);
3077 num_pins = alc_auto_fill_multi_ios(codec, location, 0);
3079 spec->multi_ios = num_pins;
3080 spec->ext_channel_count = 2;
3081 spec->multiout.num_dacs = num_pins + 1;
3085 if (cfg->line_out_type != AUTO_PIN_HP_OUT)
3086 alc_auto_fill_extra_dacs(codec, cfg->hp_outs, cfg->hp_pins,
3087 spec->multiout.hp_out_nid);
3088 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
3089 int err = alc_auto_fill_extra_dacs(codec, cfg->speaker_outs,
3091 spec->multiout.extra_out_nid);
3092 /* if no speaker volume is assigned, try again as the primary
3095 if (!err && cfg->speaker_outs > 0 &&
3096 cfg->line_out_type == AUTO_PIN_HP_OUT) {
3097 cfg->hp_outs = cfg->line_outs;
3098 memcpy(cfg->hp_pins, cfg->line_out_pins,
3099 sizeof(cfg->hp_pins));
3100 cfg->line_outs = cfg->speaker_outs;
3101 memcpy(cfg->line_out_pins, cfg->speaker_pins,
3102 sizeof(cfg->speaker_pins));
3103 cfg->speaker_outs = 0;
3104 memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins));
3105 cfg->line_out_type = AUTO_PIN_SPEAKER_OUT;
3111 if (!spec->multi_ios &&
3112 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT &&
3114 /* try multi-ios with HP + inputs */
3115 defcfg = snd_hda_codec_get_pincfg(codec, cfg->hp_pins[0]);
3116 location = get_defcfg_location(defcfg);
3118 num_pins = alc_auto_fill_multi_ios(codec, location, 1);
3120 spec->multi_ios = num_pins;
3121 spec->ext_channel_count = 2;
3122 spec->multiout.num_dacs = num_pins + 1;
3126 if (cfg->line_out_pins[0])
3128 alc_look_for_out_vol_nid(codec, cfg->line_out_pins[0],
3129 spec->multiout.dac_nids[0]);
3133 static inline unsigned int get_ctl_pos(unsigned int data)
3135 hda_nid_t nid = get_amp_nid_(data);
3136 unsigned int dir = get_amp_direction_(data);
3137 return (nid << 1) | dir;
3140 #define is_ctl_used(bits, data) \
3141 test_bit(get_ctl_pos(data), bits)
3142 #define mark_ctl_usage(bits, data) \
3143 set_bit(get_ctl_pos(data), bits)
3145 static int alc_auto_add_vol_ctl(struct hda_codec *codec,
3146 const char *pfx, int cidx,
3147 hda_nid_t nid, unsigned int chs)
3149 struct alc_spec *spec = codec->spec;
3153 val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT);
3154 if (is_ctl_used(spec->vol_ctls, val) && chs != 2) /* exclude LFE */
3156 mark_ctl_usage(spec->vol_ctls, val);
3157 return __add_pb_vol_ctrl(codec->spec, ALC_CTL_WIDGET_VOL, pfx, cidx,
3161 static int alc_auto_add_stereo_vol(struct hda_codec *codec,
3162 const char *pfx, int cidx,
3166 if (get_wcaps(codec, nid) & AC_WCAP_STEREO)
3168 return alc_auto_add_vol_ctl(codec, pfx, cidx, nid, chs);
3171 /* create a mute-switch for the given mixer widget;
3172 * if it has multiple sources (e.g. DAC and loopback), create a bind-mute
3174 static int alc_auto_add_sw_ctl(struct hda_codec *codec,
3175 const char *pfx, int cidx,
3176 hda_nid_t nid, unsigned int chs)
3178 struct alc_spec *spec = codec->spec;
3184 wid_type = get_wcaps_type(get_wcaps(codec, nid));
3185 if (wid_type == AC_WID_PIN || wid_type == AC_WID_AUD_OUT) {
3186 type = ALC_CTL_WIDGET_MUTE;
3187 val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT);
3188 } else if (snd_hda_get_conn_list(codec, nid, NULL) == 1) {
3189 type = ALC_CTL_WIDGET_MUTE;
3190 val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT);
3192 type = ALC_CTL_BIND_MUTE;
3193 val = HDA_COMPOSE_AMP_VAL(nid, chs, 2, HDA_INPUT);
3195 if (is_ctl_used(spec->sw_ctls, val) && chs != 2) /* exclude LFE */
3197 mark_ctl_usage(spec->sw_ctls, val);
3198 return __add_pb_sw_ctrl(codec->spec, type, pfx, cidx, val);
3201 static int alc_auto_add_stereo_sw(struct hda_codec *codec, const char *pfx,
3202 int cidx, hda_nid_t nid)
3205 if (get_wcaps(codec, nid) & AC_WCAP_STEREO)
3207 return alc_auto_add_sw_ctl(codec, pfx, cidx, nid, chs);
3210 static hda_nid_t alc_look_for_out_mute_nid(struct hda_codec *codec,
3211 hda_nid_t pin, hda_nid_t dac)
3213 hda_nid_t mix = alc_auto_dac_to_mix(codec, pin, dac);
3214 if (nid_has_mute(codec, pin, HDA_OUTPUT))
3216 else if (mix && nid_has_mute(codec, mix, HDA_INPUT))
3218 else if (nid_has_mute(codec, dac, HDA_OUTPUT))
3223 static hda_nid_t alc_look_for_out_vol_nid(struct hda_codec *codec,
3224 hda_nid_t pin, hda_nid_t dac)
3226 hda_nid_t mix = alc_auto_dac_to_mix(codec, pin, dac);
3227 if (nid_has_volume(codec, dac, HDA_OUTPUT))
3229 else if (nid_has_volume(codec, mix, HDA_OUTPUT))
3231 else if (nid_has_volume(codec, pin, HDA_OUTPUT))
3236 /* add playback controls from the parsed DAC table */
3237 static int alc_auto_create_multi_out_ctls(struct hda_codec *codec,
3238 const struct auto_pin_cfg *cfg)
3240 struct alc_spec *spec = codec->spec;
3241 int i, err, noutputs;
3243 noutputs = cfg->line_outs;
3244 if (spec->multi_ios > 0 && cfg->line_outs < 3)
3245 noutputs += spec->multi_ios;
3247 for (i = 0; i < noutputs; i++) {
3253 dac = spec->multiout.dac_nids[i];
3256 if (i >= cfg->line_outs)
3257 pin = spec->multi_io[i - 1].pin;
3259 pin = cfg->line_out_pins[i];
3261 sw = alc_look_for_out_mute_nid(codec, pin, dac);
3262 vol = alc_look_for_out_vol_nid(codec, pin, dac);
3263 name = alc_get_line_out_pfx(spec, i, true, &index);
3264 if (!name || !strcmp(name, "CLFE")) {
3266 err = alc_auto_add_vol_ctl(codec, "Center", 0, vol, 1);
3269 err = alc_auto_add_vol_ctl(codec, "LFE", 0, vol, 2);
3272 err = alc_auto_add_sw_ctl(codec, "Center", 0, sw, 1);
3275 err = alc_auto_add_sw_ctl(codec, "LFE", 0, sw, 2);
3279 err = alc_auto_add_stereo_vol(codec, name, index, vol);
3282 err = alc_auto_add_stereo_sw(codec, name, index, sw);
3290 static int alc_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
3291 hda_nid_t dac, const char *pfx,
3294 struct alc_spec *spec = codec->spec;
3300 /* the corresponding DAC is already occupied */
3301 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
3302 return 0; /* no way */
3303 /* create a switch only */
3304 val = HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT);
3305 if (is_ctl_used(spec->sw_ctls, val))
3306 return 0; /* already created */
3307 mark_ctl_usage(spec->sw_ctls, val);
3308 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, cidx, val);
3311 sw = alc_look_for_out_mute_nid(codec, pin, dac);
3312 vol = alc_look_for_out_vol_nid(codec, pin, dac);
3313 err = alc_auto_add_stereo_vol(codec, pfx, cidx, vol);
3316 err = alc_auto_add_stereo_sw(codec, pfx, cidx, sw);
3322 static struct hda_bind_ctls *new_bind_ctl(struct hda_codec *codec,
3324 struct hda_ctl_ops *ops)
3326 struct alc_spec *spec = codec->spec;
3327 struct hda_bind_ctls **ctlp, *ctl;
3328 snd_array_init(&spec->bind_ctls, sizeof(ctl), 8);
3329 ctlp = snd_array_new(&spec->bind_ctls);
3332 ctl = kzalloc(sizeof(*ctl) + sizeof(long) * (nums + 1), GFP_KERNEL);
3339 /* add playback controls for speaker and HP outputs */
3340 static int alc_auto_create_extra_outs(struct hda_codec *codec, int num_pins,
3341 const hda_nid_t *pins,
3342 const hda_nid_t *dacs,
3345 struct alc_spec *spec = codec->spec;
3346 struct hda_bind_ctls *ctl;
3350 if (!num_pins || !pins[0])
3353 if (num_pins == 1) {
3354 hda_nid_t dac = *dacs;
3356 dac = spec->multiout.dac_nids[0];
3357 return alc_auto_create_extra_out(codec, *pins, dac, pfx, 0);
3360 if (dacs[num_pins - 1]) {
3361 /* OK, we have a multi-output system with individual volumes */
3362 for (i = 0; i < num_pins; i++) {
3363 if (num_pins >= 3) {
3364 snprintf(name, sizeof(name), "%s %s",
3365 pfx, channel_name[i]);
3366 err = alc_auto_create_extra_out(codec, pins[i], dacs[i],
3369 err = alc_auto_create_extra_out(codec, pins[i], dacs[i],
3378 /* Let's create a bind-controls */
3379 ctl = new_bind_ctl(codec, num_pins, &snd_hda_bind_sw);
3383 for (i = 0; i < num_pins; i++) {
3384 if (get_wcaps(codec, pins[i]) & AC_WCAP_OUT_AMP)
3386 HDA_COMPOSE_AMP_VAL(pins[i], 3, 0, HDA_OUTPUT);
3389 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
3390 err = add_control(spec, ALC_CTL_BIND_SW, name, 0, (long)ctl);
3395 ctl = new_bind_ctl(codec, num_pins, &snd_hda_bind_vol);
3399 for (i = 0; i < num_pins; i++) {
3401 if (!pins[i] || !dacs[i])
3403 vol = alc_look_for_out_vol_nid(codec, pins[i], dacs[i]);
3406 HDA_COMPOSE_AMP_VAL(vol, 3, 0, HDA_OUTPUT);
3409 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
3410 err = add_control(spec, ALC_CTL_BIND_VOL, name, 0, (long)ctl);
3417 static int alc_auto_create_hp_out(struct hda_codec *codec)
3419 struct alc_spec *spec = codec->spec;
3420 return alc_auto_create_extra_outs(codec, spec->autocfg.hp_outs,
3421 spec->autocfg.hp_pins,
3422 spec->multiout.hp_out_nid,
3426 static int alc_auto_create_speaker_out(struct hda_codec *codec)
3428 struct alc_spec *spec = codec->spec;
3429 return alc_auto_create_extra_outs(codec, spec->autocfg.speaker_outs,
3430 spec->autocfg.speaker_pins,
3431 spec->multiout.extra_out_nid,
3435 static void alc_auto_set_output_and_unmute(struct hda_codec *codec,
3436 hda_nid_t pin, int pin_type,
3440 hda_nid_t nid, mix = 0;
3441 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
3443 alc_set_pin_output(codec, pin, pin_type);
3444 nid = alc_go_down_to_selector(codec, pin);
3445 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
3446 for (i = 0; i < num; i++) {
3447 if (alc_auto_mix_to_dac(codec, srcs[i]) != dac)
3455 /* need the manual connection? */
3457 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
3458 /* unmute mixer widget inputs */
3459 if (nid_has_mute(codec, mix, HDA_INPUT)) {
3460 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3462 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3465 /* initialize volume */
3466 nid = alc_look_for_out_vol_nid(codec, pin, dac);
3468 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3471 /* unmute DAC if it's not assigned to a mixer */
3472 nid = alc_look_for_out_mute_nid(codec, pin, dac);
3473 if (nid == mix && nid_has_mute(codec, dac, HDA_OUTPUT))
3474 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3478 static void alc_auto_init_multi_out(struct hda_codec *codec)
3480 struct alc_spec *spec = codec->spec;
3481 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3484 for (i = 0; i <= HDA_SIDE; i++) {
3485 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3487 alc_auto_set_output_and_unmute(codec, nid, pin_type,
3488 spec->multiout.dac_nids[i]);
3492 static void alc_auto_init_extra_out(struct hda_codec *codec)
3494 struct alc_spec *spec = codec->spec;
3498 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3499 if (spec->autocfg.line_out_type == AUTO_PIN_HP_OUT)
3501 pin = spec->autocfg.hp_pins[i];
3504 dac = spec->multiout.hp_out_nid[i];
3506 if (i > 0 && spec->multiout.hp_out_nid[0])
3507 dac = spec->multiout.hp_out_nid[0];
3509 dac = spec->multiout.dac_nids[0];
3511 alc_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
3513 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3514 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
3516 pin = spec->autocfg.speaker_pins[i];
3519 dac = spec->multiout.extra_out_nid[i];
3521 if (i > 0 && spec->multiout.extra_out_nid[0])
3522 dac = spec->multiout.extra_out_nid[0];
3524 dac = spec->multiout.dac_nids[0];
3526 alc_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
3533 static int alc_auto_fill_multi_ios(struct hda_codec *codec,
3534 unsigned int location,
3537 struct alc_spec *spec = codec->spec;
3538 struct auto_pin_cfg *cfg = &spec->autocfg;
3539 hda_nid_t prime_dac = spec->private_dac_nids[0];
3540 int type, i, dacs, num_pins = 0;
3542 dacs = spec->multiout.num_dacs;
3543 for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) {
3544 for (i = 0; i < cfg->num_inputs; i++) {
3545 hda_nid_t nid = cfg->inputs[i].pin;
3547 unsigned int defcfg, caps;
3548 if (cfg->inputs[i].type != type)
3550 defcfg = snd_hda_codec_get_pincfg(codec, nid);
3551 if (get_defcfg_connect(defcfg) != AC_JACK_PORT_COMPLEX)
3553 if (location && get_defcfg_location(defcfg) != location)
3555 caps = snd_hda_query_pin_caps(codec, nid);
3556 if (!(caps & AC_PINCAP_OUT))
3558 if (offset && offset + num_pins < dacs) {
3559 dac = spec->private_dac_nids[offset + num_pins];
3560 if (!alc_auto_is_dac_reachable(codec, nid, dac))
3564 dac = alc_auto_look_for_dac(codec, nid);
3567 spec->multi_io[num_pins].pin = nid;
3568 spec->multi_io[num_pins].dac = dac;
3570 spec->private_dac_nids[spec->multiout.num_dacs++] = dac;
3573 spec->multiout.num_dacs = dacs;
3575 /* clear up again */
3576 memset(spec->private_dac_nids + dacs, 0,
3577 sizeof(hda_nid_t) * (AUTO_CFG_MAX_OUTS - dacs));
3578 spec->private_dac_nids[0] = prime_dac;
3584 static int alc_auto_ch_mode_info(struct snd_kcontrol *kcontrol,
3585 struct snd_ctl_elem_info *uinfo)
3587 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3588 struct alc_spec *spec = codec->spec;
3590 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3592 uinfo->value.enumerated.items = spec->multi_ios + 1;
3593 if (uinfo->value.enumerated.item > spec->multi_ios)
3594 uinfo->value.enumerated.item = spec->multi_ios;
3595 sprintf(uinfo->value.enumerated.name, "%dch",
3596 (uinfo->value.enumerated.item + 1) * 2);
3600 static int alc_auto_ch_mode_get(struct snd_kcontrol *kcontrol,
3601 struct snd_ctl_elem_value *ucontrol)
3603 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3604 struct alc_spec *spec = codec->spec;
3605 ucontrol->value.enumerated.item[0] = (spec->ext_channel_count - 1) / 2;
3609 static int alc_set_multi_io(struct hda_codec *codec, int idx, bool output)
3611 struct alc_spec *spec = codec->spec;
3612 hda_nid_t nid = spec->multi_io[idx].pin;
3614 if (!spec->multi_io[idx].ctl_in)
3615 spec->multi_io[idx].ctl_in =
3616 snd_hda_codec_read(codec, nid, 0,
3617 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3619 snd_hda_codec_update_cache(codec, nid, 0,
3620 AC_VERB_SET_PIN_WIDGET_CONTROL,
3622 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
3623 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3625 alc_auto_select_dac(codec, nid, spec->multi_io[idx].dac);
3627 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
3628 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3629 HDA_AMP_MUTE, HDA_AMP_MUTE);
3630 snd_hda_codec_update_cache(codec, nid, 0,
3631 AC_VERB_SET_PIN_WIDGET_CONTROL,
3632 spec->multi_io[idx].ctl_in);
3637 static int alc_auto_ch_mode_put(struct snd_kcontrol *kcontrol,
3638 struct snd_ctl_elem_value *ucontrol)
3640 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3641 struct alc_spec *spec = codec->spec;
3644 ch = ucontrol->value.enumerated.item[0];
3645 if (ch < 0 || ch > spec->multi_ios)
3647 if (ch == (spec->ext_channel_count - 1) / 2)
3649 spec->ext_channel_count = (ch + 1) * 2;
3650 for (i = 0; i < spec->multi_ios; i++)
3651 alc_set_multi_io(codec, i, i < ch);
3652 spec->multiout.max_channels = spec->ext_channel_count;
3653 if (spec->need_dac_fix && !spec->const_channel_count)
3654 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
3658 static const struct snd_kcontrol_new alc_auto_channel_mode_enum = {
3659 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3660 .name = "Channel Mode",
3661 .info = alc_auto_ch_mode_info,
3662 .get = alc_auto_ch_mode_get,
3663 .put = alc_auto_ch_mode_put,
3666 static int alc_auto_add_multi_channel_mode(struct hda_codec *codec)
3668 struct alc_spec *spec = codec->spec;
3670 if (spec->multi_ios > 0) {
3671 struct snd_kcontrol_new *knew;
3673 knew = alc_kcontrol_new(spec);
3676 *knew = alc_auto_channel_mode_enum;
3677 knew->name = kstrdup("Channel Mode", GFP_KERNEL);
3684 /* filter out invalid adc_nids (and capsrc_nids) that don't give all
3687 static void alc_remove_invalid_adc_nids(struct hda_codec *codec)
3689 struct alc_spec *spec = codec->spec;
3690 const struct hda_input_mux *imux;
3691 hda_nid_t adc_nids[ARRAY_SIZE(spec->private_adc_nids)];
3692 hda_nid_t capsrc_nids[ARRAY_SIZE(spec->private_adc_nids)];
3695 imux = spec->input_mux;
3698 if (spec->dyn_adc_switch)
3702 for (n = 0; n < spec->num_adc_nids; n++) {
3703 hda_nid_t cap = spec->private_capsrc_nids[n];
3704 int num_conns = snd_hda_get_conn_list(codec, cap, NULL);
3705 for (i = 0; i < imux->num_items; i++) {
3706 hda_nid_t pin = spec->imux_pins[i];
3708 if (get_connection_index(codec, cap, pin) < 0)
3710 } else if (num_conns <= imux->items[i].index)
3713 if (i >= imux->num_items) {
3714 adc_nids[nums] = spec->private_adc_nids[n];
3715 capsrc_nids[nums++] = cap;
3719 /* check whether ADC-switch is possible */
3720 if (!alc_check_dyn_adc_switch(codec)) {
3721 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
3722 " using fallback 0x%x\n",
3723 codec->chip_name, spec->private_adc_nids[0]);
3724 spec->num_adc_nids = 1;
3728 } else if (nums != spec->num_adc_nids) {
3729 memcpy(spec->private_adc_nids, adc_nids,
3730 nums * sizeof(hda_nid_t));
3731 memcpy(spec->private_capsrc_nids, capsrc_nids,
3732 nums * sizeof(hda_nid_t));
3733 spec->num_adc_nids = nums;
3737 alc_auto_mic_check_imux(codec); /* check auto-mic setups */
3738 else if (spec->input_mux->num_items == 1)
3739 spec->num_adc_nids = 1; /* reduce to a single ADC */
3743 * initialize ADC paths
3745 static void alc_auto_init_adc(struct hda_codec *codec, int adc_idx)
3747 struct alc_spec *spec = codec->spec;
3750 nid = spec->adc_nids[adc_idx];
3752 if (nid_has_mute(codec, nid, HDA_INPUT)) {
3753 snd_hda_codec_write(codec, nid, 0,
3754 AC_VERB_SET_AMP_GAIN_MUTE,
3758 if (!spec->capsrc_nids)
3760 nid = spec->capsrc_nids[adc_idx];
3761 if (nid_has_mute(codec, nid, HDA_OUTPUT))
3762 snd_hda_codec_write(codec, nid, 0,
3763 AC_VERB_SET_AMP_GAIN_MUTE,
3767 static void alc_auto_init_input_src(struct hda_codec *codec)
3769 struct alc_spec *spec = codec->spec;
3772 for (c = 0; c < spec->num_adc_nids; c++)
3773 alc_auto_init_adc(codec, c);
3774 if (spec->dyn_adc_switch)
3777 nums = spec->num_adc_nids;
3778 for (c = 0; c < nums; c++)
3779 alc_mux_select(codec, 0, spec->cur_mux[c], true);
3782 /* add mic boosts if needed */
3783 static int alc_auto_add_mic_boost(struct hda_codec *codec)
3785 struct alc_spec *spec = codec->spec;
3786 struct auto_pin_cfg *cfg = &spec->autocfg;
3790 const char *prev_label = NULL;
3792 for (i = 0; i < cfg->num_inputs; i++) {
3793 if (cfg->inputs[i].type > AUTO_PIN_MIC)
3795 nid = cfg->inputs[i].pin;
3796 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
3798 char boost_label[32];
3800 label = hda_get_autocfg_input_label(codec, cfg, i);
3801 if (spec->shared_mic_hp && !strcmp(label, "Misc"))
3802 label = "Headphone Mic";
3803 if (prev_label && !strcmp(label, prev_label))
3809 snprintf(boost_label, sizeof(boost_label),
3810 "%s Boost Volume", label);
3811 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3812 boost_label, type_idx,
3813 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
3821 /* select or unmute the given capsrc route */
3822 static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap,
3825 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
3826 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
3828 } else if (snd_hda_get_conn_list(codec, cap, NULL) > 1) {
3829 snd_hda_codec_write_cache(codec, cap, 0,
3830 AC_VERB_SET_CONNECT_SEL, idx);
3834 /* set the default connection to that pin */
3835 static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
3837 struct alc_spec *spec = codec->spec;
3842 for (i = 0; i < spec->num_adc_nids; i++) {
3843 hda_nid_t cap = get_capsrc(spec, i);
3846 idx = get_connection_index(codec, cap, pin);
3849 select_or_unmute_capsrc(codec, cap, idx);
3850 return i; /* return the found index */
3852 return -1; /* not found */
3855 /* initialize some special cases for input sources */
3856 static void alc_init_special_input_src(struct hda_codec *codec)
3858 struct alc_spec *spec = codec->spec;
3861 for (i = 0; i < spec->autocfg.num_inputs; i++)
3862 init_capsrc_for_pin(codec, spec->autocfg.inputs[i].pin);
3865 /* assign appropriate capture mixers */
3866 static void set_capture_mixer(struct hda_codec *codec)
3868 struct alc_spec *spec = codec->spec;
3869 static const struct snd_kcontrol_new *caps[2][3] = {
3870 { alc_capture_mixer_nosrc1,
3871 alc_capture_mixer_nosrc2,
3872 alc_capture_mixer_nosrc3 },
3873 { alc_capture_mixer1,
3875 alc_capture_mixer3 },
3878 /* check whether either of ADC or MUX has a volume control */
3879 if (!nid_has_volume(codec, spec->adc_nids[0], HDA_INPUT)) {
3880 if (!spec->capsrc_nids)
3881 return; /* no volume */
3882 if (!nid_has_volume(codec, spec->capsrc_nids[0], HDA_OUTPUT))
3883 return; /* no volume in capsrc, too */
3884 spec->vol_in_capsrc = 1;
3887 if (spec->num_adc_nids > 0) {
3891 if (spec->input_mux && spec->input_mux->num_items > 1)
3893 if (spec->auto_mic) {
3896 } else if (spec->dyn_adc_switch)
3899 if (spec->num_adc_nids > 3)
3900 spec->num_adc_nids = 3;
3901 else if (!spec->num_adc_nids)
3903 num_adcs = spec->num_adc_nids;
3905 spec->cap_mixer = caps[mux][num_adcs - 1];
3910 * standard auto-parser initializations
3912 static void alc_auto_init_std(struct hda_codec *codec)
3914 struct alc_spec *spec = codec->spec;
3915 alc_auto_init_multi_out(codec);
3916 alc_auto_init_extra_out(codec);
3917 alc_auto_init_analog_input(codec);
3918 alc_auto_init_input_src(codec);
3919 alc_auto_init_digital(codec);
3920 if (spec->unsol_event)
3921 alc_inithook(codec);
3925 * Digital-beep handlers
3927 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3928 #define set_beep_amp(spec, nid, idx, dir) \
3929 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
3931 static const struct snd_pci_quirk beep_white_list[] = {
3932 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
3933 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
3934 SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
3935 SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
3936 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
3940 static inline int has_cdefine_beep(struct hda_codec *codec)
3942 struct alc_spec *spec = codec->spec;
3943 const struct snd_pci_quirk *q;
3944 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
3947 return spec->cdefine.enable_pcbeep;
3950 #define set_beep_amp(spec, nid, idx, dir) /* NOP */
3951 #define has_cdefine_beep(codec) 0
3954 /* parse the BIOS configuration and set up the alc_spec */
3955 /* return 1 if successful, 0 if the proper config is not found,
3956 * or a negative error code
3958 static int alc_parse_auto_config(struct hda_codec *codec,
3959 const hda_nid_t *ignore_nids,
3960 const hda_nid_t *ssid_nids)
3962 struct alc_spec *spec = codec->spec;
3963 struct auto_pin_cfg *cfg = &spec->autocfg;
3966 err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids,
3970 if (!cfg->line_outs) {
3971 if (cfg->dig_outs || cfg->dig_in_pin) {
3972 spec->multiout.max_channels = 2;
3973 spec->no_analog = 1;
3976 return 0; /* can't find valid BIOS pin config */
3979 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT &&
3980 cfg->line_outs <= cfg->hp_outs) {
3981 /* use HP as primary out */
3982 cfg->speaker_outs = cfg->line_outs;
3983 memcpy(cfg->speaker_pins, cfg->line_out_pins,
3984 sizeof(cfg->speaker_pins));
3985 cfg->line_outs = cfg->hp_outs;
3986 memcpy(cfg->line_out_pins, cfg->hp_pins, sizeof(cfg->hp_pins));
3988 memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins));
3989 cfg->line_out_type = AUTO_PIN_HP_OUT;
3992 err = alc_auto_fill_dac_nids(codec);
3995 err = alc_auto_add_multi_channel_mode(codec);
3998 err = alc_auto_create_multi_out_ctls(codec, cfg);
4001 err = alc_auto_create_hp_out(codec);
4004 err = alc_auto_create_speaker_out(codec);
4007 err = alc_auto_create_shared_input(codec);
4010 err = alc_auto_create_input_ctls(codec);
4014 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4017 alc_auto_parse_digital(codec);
4019 if (!spec->no_analog)
4020 alc_remove_invalid_adc_nids(codec);
4023 alc_ssid_check(codec, ssid_nids);
4025 if (!spec->no_analog) {
4026 alc_auto_check_switches(codec);
4027 err = alc_auto_add_mic_boost(codec);
4032 if (spec->kctls.list)
4033 add_mixer(spec, spec->kctls.list);
4038 static int alc880_parse_auto_config(struct hda_codec *codec)
4040 static const hda_nid_t alc880_ignore[] = { 0x1d, 0 };
4041 static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 };
4042 return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids);
4045 #ifdef CONFIG_SND_HDA_POWER_SAVE
4046 static const struct hda_amp_list alc880_loopbacks[] = {
4047 { 0x0b, HDA_INPUT, 0 },
4048 { 0x0b, HDA_INPUT, 1 },
4049 { 0x0b, HDA_INPUT, 2 },
4050 { 0x0b, HDA_INPUT, 3 },
4051 { 0x0b, HDA_INPUT, 4 },
4061 ALC880_FIXUP_MEDION_RIM,
4064 static const struct alc_fixup alc880_fixups[] = {
4065 [ALC880_FIXUP_GPIO2] = {
4066 .type = ALC_FIXUP_VERBS,
4067 .v.verbs = alc_gpio2_init_verbs,
4069 [ALC880_FIXUP_MEDION_RIM] = {
4070 .type = ALC_FIXUP_VERBS,
4071 .v.verbs = (const struct hda_verb[]) {
4072 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4073 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
4077 .chain_id = ALC880_FIXUP_GPIO2,
4081 static const struct snd_pci_quirk alc880_fixup_tbl[] = {
4082 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM),
4090 #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4091 #define alc_board_config \
4092 snd_hda_check_board_config
4093 #define alc_board_codec_sid_config \
4094 snd_hda_check_board_codec_sid_config
4095 #include "alc_quirks.c"
4097 #define alc_board_config(codec, nums, models, tbl) -1
4098 #define alc_board_codec_sid_config(codec, nums, models, tbl) -1
4099 #define setup_preset(codec, x) /* NOP */
4103 * OK, here we have finally the patch for ALC880
4105 #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4106 #include "alc880_quirks.c"
4109 static int patch_alc880(struct hda_codec *codec)
4111 struct alc_spec *spec;
4115 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4121 spec->mixer_nid = 0x0b;
4122 spec->need_dac_fix = 1;
4124 board_config = alc_board_config(codec, ALC880_MODEL_LAST,
4125 alc880_models, alc880_cfg_tbl);
4126 if (board_config < 0) {
4127 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4129 board_config = ALC_MODEL_AUTO;
4132 if (board_config == ALC_MODEL_AUTO) {
4133 alc_pick_fixup(codec, NULL, alc880_fixup_tbl, alc880_fixups);
4134 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
4137 if (board_config == ALC_MODEL_AUTO) {
4138 /* automatic parse from the BIOS config */
4139 err = alc880_parse_auto_config(codec);
4142 #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4145 "hda_codec: Cannot set up configuration "
4146 "from BIOS. Using 3-stack mode...\n");
4147 board_config = ALC880_3ST;
4152 if (board_config != ALC_MODEL_AUTO) {
4153 spec->vmaster_nid = 0x0c;
4154 setup_preset(codec, &alc880_presets[board_config]);
4157 if (!spec->no_analog && !spec->adc_nids) {
4158 alc_auto_fill_adc_caps(codec);
4159 alc_rebuild_imux_for_auto_mic(codec);
4160 alc_remove_invalid_adc_nids(codec);
4163 if (!spec->no_analog && !spec->cap_mixer)
4164 set_capture_mixer(codec);
4166 if (!spec->no_analog) {
4167 err = snd_hda_attach_beep_device(codec, 0x1);
4170 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
4173 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
4175 codec->patch_ops = alc_patch_ops;
4176 if (board_config == ALC_MODEL_AUTO)
4177 spec->init_hook = alc_auto_init_std;
4179 codec->patch_ops.build_controls = __alc_build_controls;
4180 #ifdef CONFIG_SND_HDA_POWER_SAVE
4181 if (!spec->loopback.amplist)
4182 spec->loopback.amplist = alc880_loopbacks;
4196 static int alc260_parse_auto_config(struct hda_codec *codec)
4198 static const hda_nid_t alc260_ignore[] = { 0x17, 0 };
4199 static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 };
4200 return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids);
4203 #ifdef CONFIG_SND_HDA_POWER_SAVE
4204 static const struct hda_amp_list alc260_loopbacks[] = {
4205 { 0x07, HDA_INPUT, 0 },
4206 { 0x07, HDA_INPUT, 1 },
4207 { 0x07, HDA_INPUT, 2 },
4208 { 0x07, HDA_INPUT, 3 },
4209 { 0x07, HDA_INPUT, 4 },
4221 static const struct alc_fixup alc260_fixups[] = {
4222 [PINFIX_HP_DC5750] = {
4223 .type = ALC_FIXUP_PINS,
4224 .v.pins = (const struct alc_pincfg[]) {
4225 { 0x11, 0x90130110 }, /* speaker */
4231 static const struct snd_pci_quirk alc260_fixup_tbl[] = {
4232 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750),
4238 #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4239 #include "alc260_quirks.c"
4242 static int patch_alc260(struct hda_codec *codec)
4244 struct alc_spec *spec;
4245 int err, board_config;
4247 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4253 spec->mixer_nid = 0x07;
4255 board_config = alc_board_config(codec, ALC260_MODEL_LAST,
4256 alc260_models, alc260_cfg_tbl);
4257 if (board_config < 0) {
4258 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4260 board_config = ALC_MODEL_AUTO;
4263 if (board_config == ALC_MODEL_AUTO) {
4264 alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups);
4265 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
4268 if (board_config == ALC_MODEL_AUTO) {
4269 /* automatic parse from the BIOS config */
4270 err = alc260_parse_auto_config(codec);
4273 #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4276 "hda_codec: Cannot set up configuration "
4277 "from BIOS. Using base mode...\n");
4278 board_config = ALC260_BASIC;
4283 if (board_config != ALC_MODEL_AUTO) {
4284 setup_preset(codec, &alc260_presets[board_config]);
4285 spec->vmaster_nid = 0x08;
4288 if (!spec->no_analog && !spec->adc_nids) {
4289 alc_auto_fill_adc_caps(codec);
4290 alc_rebuild_imux_for_auto_mic(codec);
4291 alc_remove_invalid_adc_nids(codec);
4294 if (!spec->no_analog && !spec->cap_mixer)
4295 set_capture_mixer(codec);
4297 if (!spec->no_analog) {
4298 err = snd_hda_attach_beep_device(codec, 0x1);
4301 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
4304 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
4306 codec->patch_ops = alc_patch_ops;
4307 if (board_config == ALC_MODEL_AUTO)
4308 spec->init_hook = alc_auto_init_std;
4310 codec->patch_ops.build_controls = __alc_build_controls;
4311 spec->shutup = alc_eapd_shutup;
4312 #ifdef CONFIG_SND_HDA_POWER_SAVE
4313 if (!spec->loopback.amplist)
4314 spec->loopback.amplist = alc260_loopbacks;
4326 * ALC882/883/885/888/889 support
4328 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4329 * configuration. Each pin widget can choose any input DACs and a mixer.
4330 * Each ADC is connected from a mixer of all inputs. This makes possible
4331 * 6-channel independent captures.
4333 * In addition, an independent DAC for the multi-playback (not used in this
4336 #ifdef CONFIG_SND_HDA_POWER_SAVE
4337 #define alc882_loopbacks alc880_loopbacks
4344 ALC882_FIXUP_ABIT_AW9D_MAX,
4345 ALC882_FIXUP_LENOVO_Y530,
4346 ALC882_FIXUP_PB_M5210,
4347 ALC882_FIXUP_ACER_ASPIRE_7736,
4348 ALC882_FIXUP_ASUS_W90V,
4349 ALC889_FIXUP_VAIO_TT,
4350 ALC888_FIXUP_EEE1601,
4353 ALC883_FIXUP_ACER_EAPD,
4356 ALC882_FIXUP_ASUS_W2JC,
4357 ALC882_FIXUP_ACER_ASPIRE_4930G,
4358 ALC882_FIXUP_ACER_ASPIRE_8930G,
4359 ALC882_FIXUP_ASPIRE_8930G_VERBS,
4360 ALC885_FIXUP_MACPRO_GPIO,
4363 static void alc889_fixup_coef(struct hda_codec *codec,
4364 const struct alc_fixup *fix, int action)
4366 if (action != ALC_FIXUP_ACT_INIT)
4368 alc889_coef_init(codec);
4371 /* toggle speaker-output according to the hp-jack state */
4372 static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
4374 unsigned int gpiostate, gpiomask, gpiodir;
4376 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
4377 AC_VERB_GET_GPIO_DATA, 0);
4380 gpiostate |= (1 << pin);
4382 gpiostate &= ~(1 << pin);
4384 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
4385 AC_VERB_GET_GPIO_MASK, 0);
4386 gpiomask |= (1 << pin);
4388 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
4389 AC_VERB_GET_GPIO_DIRECTION, 0);
4390 gpiodir |= (1 << pin);
4393 snd_hda_codec_write(codec, codec->afg, 0,
4394 AC_VERB_SET_GPIO_MASK, gpiomask);
4395 snd_hda_codec_write(codec, codec->afg, 0,
4396 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
4400 snd_hda_codec_write(codec, codec->afg, 0,
4401 AC_VERB_SET_GPIO_DATA, gpiostate);
4404 /* set up GPIO at initialization */
4405 static void alc885_fixup_macpro_gpio(struct hda_codec *codec,
4406 const struct alc_fixup *fix, int action)
4408 if (action != ALC_FIXUP_ACT_INIT)
4410 alc882_gpio_mute(codec, 0, 0);
4411 alc882_gpio_mute(codec, 1, 0);
4414 static const struct alc_fixup alc882_fixups[] = {
4415 [ALC882_FIXUP_ABIT_AW9D_MAX] = {
4416 .type = ALC_FIXUP_PINS,
4417 .v.pins = (const struct alc_pincfg[]) {
4418 { 0x15, 0x01080104 }, /* side */
4419 { 0x16, 0x01011012 }, /* rear */
4420 { 0x17, 0x01016011 }, /* clfe */
4424 [ALC882_FIXUP_LENOVO_Y530] = {
4425 .type = ALC_FIXUP_PINS,
4426 .v.pins = (const struct alc_pincfg[]) {
4427 { 0x15, 0x99130112 }, /* rear int speakers */
4428 { 0x16, 0x99130111 }, /* subwoofer */
4432 [ALC882_FIXUP_PB_M5210] = {
4433 .type = ALC_FIXUP_VERBS,
4434 .v.verbs = (const struct hda_verb[]) {
4435 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
4439 [ALC882_FIXUP_ACER_ASPIRE_7736] = {
4440 .type = ALC_FIXUP_SKU,
4441 .v.sku = ALC_FIXUP_SKU_IGNORE,
4443 [ALC882_FIXUP_ASUS_W90V] = {
4444 .type = ALC_FIXUP_PINS,
4445 .v.pins = (const struct alc_pincfg[]) {
4446 { 0x16, 0x99130110 }, /* fix sequence for CLFE */
4450 [ALC889_FIXUP_VAIO_TT] = {
4451 .type = ALC_FIXUP_PINS,
4452 .v.pins = (const struct alc_pincfg[]) {
4453 { 0x17, 0x90170111 }, /* hidden surround speaker */
4457 [ALC888_FIXUP_EEE1601] = {
4458 .type = ALC_FIXUP_VERBS,
4459 .v.verbs = (const struct hda_verb[]) {
4460 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
4461 { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 },
4465 [ALC882_FIXUP_EAPD] = {
4466 .type = ALC_FIXUP_VERBS,
4467 .v.verbs = (const struct hda_verb[]) {
4468 /* change to EAPD mode */
4469 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4470 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
4474 [ALC883_FIXUP_EAPD] = {
4475 .type = ALC_FIXUP_VERBS,
4476 .v.verbs = (const struct hda_verb[]) {
4477 /* change to EAPD mode */
4478 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4479 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
4483 [ALC883_FIXUP_ACER_EAPD] = {
4484 .type = ALC_FIXUP_VERBS,
4485 .v.verbs = (const struct hda_verb[]) {
4486 /* eanable EAPD on Acer laptops */
4487 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4488 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
4492 [ALC882_FIXUP_GPIO3] = {
4493 .type = ALC_FIXUP_VERBS,
4494 .v.verbs = alc_gpio3_init_verbs,
4496 [ALC882_FIXUP_ASUS_W2JC] = {
4497 .type = ALC_FIXUP_VERBS,
4498 .v.verbs = alc_gpio1_init_verbs,
4500 .chain_id = ALC882_FIXUP_EAPD,
4502 [ALC889_FIXUP_COEF] = {
4503 .type = ALC_FIXUP_FUNC,
4504 .v.func = alc889_fixup_coef,
4506 [ALC882_FIXUP_ACER_ASPIRE_4930G] = {
4507 .type = ALC_FIXUP_PINS,
4508 .v.pins = (const struct alc_pincfg[]) {
4509 { 0x16, 0x99130111 }, /* CLFE speaker */
4510 { 0x17, 0x99130112 }, /* surround speaker */
4514 [ALC882_FIXUP_ACER_ASPIRE_8930G] = {
4515 .type = ALC_FIXUP_PINS,
4516 .v.pins = (const struct alc_pincfg[]) {
4517 { 0x16, 0x99130111 }, /* CLFE speaker */
4518 { 0x1b, 0x99130112 }, /* surround speaker */
4522 .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS,
4524 [ALC882_FIXUP_ASPIRE_8930G_VERBS] = {
4525 /* additional init verbs for Acer Aspire 8930G */
4526 .type = ALC_FIXUP_VERBS,
4527 .v.verbs = (const struct hda_verb[]) {
4528 /* Enable all DACs */
4529 /* DAC DISABLE/MUTE 1? */
4530 /* setting bits 1-5 disables DAC nids 0x02-0x06
4531 * apparently. Init=0x38 */
4532 { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 },
4533 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
4534 /* DAC DISABLE/MUTE 2? */
4535 /* some bit here disables the other DACs.
4537 { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 },
4538 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
4540 * This laptop has a stereo digital microphone.
4541 * The mics are only 1cm apart which makes the stereo
4542 * useless. However, either the mic or the ALC889
4543 * makes the signal become a difference/sum signal
4544 * instead of standard stereo, which is annoying.
4545 * So instead we flip this bit which makes the
4546 * codec replicate the sum signal to both channels,
4547 * turning it into a normal mono mic.
4549 /* DMIC_CONTROL? Init value = 0x0001 */
4550 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
4551 { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 },
4552 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4553 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
4557 [ALC885_FIXUP_MACPRO_GPIO] = {
4558 .type = ALC_FIXUP_FUNC,
4559 .v.func = alc885_fixup_macpro_gpio,
4563 static const struct snd_pci_quirk alc882_fixup_tbl[] = {
4564 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD),
4565 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
4566 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD),
4567 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
4568 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD),
4569 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD),
4570 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
4571 ALC882_FIXUP_ACER_ASPIRE_4930G),
4572 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
4573 ALC882_FIXUP_ACER_ASPIRE_4930G),
4574 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
4575 ALC882_FIXUP_ACER_ASPIRE_8930G),
4576 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
4577 ALC882_FIXUP_ACER_ASPIRE_8930G),
4578 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
4579 ALC882_FIXUP_ACER_ASPIRE_4930G),
4580 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
4581 ALC882_FIXUP_ACER_ASPIRE_4930G),
4582 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
4583 ALC882_FIXUP_ACER_ASPIRE_4930G),
4584 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210),
4585 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736),
4586 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD),
4587 SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V),
4588 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC),
4589 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
4590 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
4592 /* All Apple entries are in codec SSIDs */
4593 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_FIXUP_MACPRO_GPIO),
4594 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO),
4595 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO),
4596 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD),
4597 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO),
4599 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD),
4600 SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3),
4601 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX),
4602 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
4603 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD),
4604 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530),
4605 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF),
4610 * BIOS auto configuration
4612 /* almost identical with ALC880 parser... */
4613 static int alc882_parse_auto_config(struct hda_codec *codec)
4615 static const hda_nid_t alc882_ignore[] = { 0x1d, 0 };
4616 static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 };
4617 return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids);
4622 #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4623 #include "alc882_quirks.c"
4626 static int patch_alc882(struct hda_codec *codec)
4628 struct alc_spec *spec;
4629 int err, board_config;
4631 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4637 spec->mixer_nid = 0x0b;
4639 switch (codec->vendor_id) {
4644 /* ALC883 and variants */
4645 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
4649 err = alc_codec_rename_from_preset(codec);
4653 board_config = alc_board_config(codec, ALC882_MODEL_LAST,
4654 alc882_models, NULL);
4655 if (board_config < 0)
4656 board_config = alc_board_codec_sid_config(codec,
4657 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
4659 if (board_config < 0) {
4660 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4662 board_config = ALC_MODEL_AUTO;
4665 if (board_config == ALC_MODEL_AUTO) {
4666 alc_pick_fixup(codec, NULL, alc882_fixup_tbl, alc882_fixups);
4667 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
4670 alc_auto_parse_customize_define(codec);
4672 if (board_config == ALC_MODEL_AUTO) {
4673 /* automatic parse from the BIOS config */
4674 err = alc882_parse_auto_config(codec);
4679 if (board_config != ALC_MODEL_AUTO) {
4680 setup_preset(codec, &alc882_presets[board_config]);
4681 spec->vmaster_nid = 0x0c;
4684 if (!spec->no_analog && !spec->adc_nids) {
4685 alc_auto_fill_adc_caps(codec);
4686 alc_rebuild_imux_for_auto_mic(codec);
4687 alc_remove_invalid_adc_nids(codec);
4690 if (!spec->no_analog && !spec->cap_mixer)
4691 set_capture_mixer(codec);
4693 if (!spec->no_analog && has_cdefine_beep(codec)) {
4694 err = snd_hda_attach_beep_device(codec, 0x1);
4697 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
4700 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
4702 codec->patch_ops = alc_patch_ops;
4703 if (board_config == ALC_MODEL_AUTO)
4704 spec->init_hook = alc_auto_init_std;
4706 codec->patch_ops.build_controls = __alc_build_controls;
4708 #ifdef CONFIG_SND_HDA_POWER_SAVE
4709 if (!spec->loopback.amplist)
4710 spec->loopback.amplist = alc882_loopbacks;
4724 static int alc262_parse_auto_config(struct hda_codec *codec)
4726 static const hda_nid_t alc262_ignore[] = { 0x1d, 0 };
4727 static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 };
4728 return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids);
4735 ALC262_FIXUP_FSC_H270,
4736 ALC262_FIXUP_HP_Z200,
4738 ALC262_FIXUP_TOSHIBA_RX1,
4739 ALC262_FIXUP_LENOVO_3000,
4741 ALC262_FIXUP_BENQ_T31,
4744 static const struct alc_fixup alc262_fixups[] = {
4745 [ALC262_FIXUP_FSC_H270] = {
4746 .type = ALC_FIXUP_PINS,
4747 .v.pins = (const struct alc_pincfg[]) {
4748 { 0x14, 0x99130110 }, /* speaker */
4749 { 0x15, 0x0221142f }, /* front HP */
4750 { 0x1b, 0x0121141f }, /* rear HP */
4754 [ALC262_FIXUP_HP_Z200] = {
4755 .type = ALC_FIXUP_PINS,
4756 .v.pins = (const struct alc_pincfg[]) {
4757 { 0x16, 0x99130120 }, /* internal speaker */
4761 [ALC262_FIXUP_TYAN] = {
4762 .type = ALC_FIXUP_PINS,
4763 .v.pins = (const struct alc_pincfg[]) {
4764 { 0x14, 0x1993e1f0 }, /* int AUX */
4768 [ALC262_FIXUP_TOSHIBA_RX1] = {
4769 .type = ALC_FIXUP_PINS,
4770 .v.pins = (const struct alc_pincfg[]) {
4771 { 0x14, 0x90170110 }, /* speaker */
4772 { 0x15, 0x0421101f }, /* HP */
4773 { 0x1a, 0x40f000f0 }, /* N/A */
4774 { 0x1b, 0x40f000f0 }, /* N/A */
4775 { 0x1e, 0x40f000f0 }, /* N/A */
4778 [ALC262_FIXUP_LENOVO_3000] = {
4779 .type = ALC_FIXUP_VERBS,
4780 .v.verbs = (const struct hda_verb[]) {
4781 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
4785 .chain_id = ALC262_FIXUP_BENQ,
4787 [ALC262_FIXUP_BENQ] = {
4788 .type = ALC_FIXUP_VERBS,
4789 .v.verbs = (const struct hda_verb[]) {
4790 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4791 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
4795 [ALC262_FIXUP_BENQ_T31] = {
4796 .type = ALC_FIXUP_VERBS,
4797 .v.verbs = (const struct hda_verb[]) {
4798 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4799 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
4805 static const struct snd_pci_quirk alc262_fixup_tbl[] = {
4806 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200),
4807 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FIXUP_BENQ),
4808 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ),
4809 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN),
4810 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
4811 ALC262_FIXUP_TOSHIBA_RX1),
4812 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270),
4813 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000),
4814 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ),
4815 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31),
4820 #ifdef CONFIG_SND_HDA_POWER_SAVE
4821 #define alc262_loopbacks alc880_loopbacks
4826 static int patch_alc262(struct hda_codec *codec)
4828 struct alc_spec *spec;
4831 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4837 spec->mixer_nid = 0x0b;
4840 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
4845 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
4846 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
4847 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
4848 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
4851 alc_auto_parse_customize_define(codec);
4853 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
4855 alc_pick_fixup(codec, NULL, alc262_fixup_tbl, alc262_fixups);
4856 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
4858 /* automatic parse from the BIOS config */
4859 err = alc262_parse_auto_config(codec);
4863 if (!spec->no_analog && !spec->adc_nids) {
4864 alc_auto_fill_adc_caps(codec);
4865 alc_rebuild_imux_for_auto_mic(codec);
4866 alc_remove_invalid_adc_nids(codec);
4869 if (!spec->no_analog && !spec->cap_mixer)
4870 set_capture_mixer(codec);
4872 if (!spec->no_analog && has_cdefine_beep(codec)) {
4873 err = snd_hda_attach_beep_device(codec, 0x1);
4876 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
4879 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
4881 codec->patch_ops = alc_patch_ops;
4882 spec->init_hook = alc_auto_init_std;
4883 spec->shutup = alc_eapd_shutup;
4885 #ifdef CONFIG_SND_HDA_POWER_SAVE
4886 if (!spec->loopback.amplist)
4887 spec->loopback.amplist = alc262_loopbacks;
4900 /* bind Beep switches of both NID 0x0f and 0x10 */
4901 static const struct hda_bind_ctls alc268_bind_beep_sw = {
4902 .ops = &snd_hda_bind_sw,
4904 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
4905 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
4910 static const struct snd_kcontrol_new alc268_beep_mixer[] = {
4911 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
4912 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
4916 /* set PCBEEP vol = 0, mute connections */
4917 static const struct hda_verb alc268_beep_init_verbs[] = {
4918 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4919 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4920 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4925 * BIOS auto configuration
4927 static int alc268_parse_auto_config(struct hda_codec *codec)
4929 static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 };
4930 struct alc_spec *spec = codec->spec;
4931 int err = alc_parse_auto_config(codec, NULL, alc268_ssids);
4933 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d) {
4934 add_mixer(spec, alc268_beep_mixer);
4935 add_verb(spec, alc268_beep_init_verbs);
4943 static int patch_alc268(struct hda_codec *codec)
4945 struct alc_spec *spec;
4946 int i, has_beep, err;
4948 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4954 /* ALC268 has no aa-loopback mixer */
4956 /* automatic parse from the BIOS config */
4957 err = alc268_parse_auto_config(codec);
4962 for (i = 0; i < spec->num_mixers; i++) {
4963 if (spec->mixers[i] == alc268_beep_mixer) {
4970 err = snd_hda_attach_beep_device(codec, 0x1);
4973 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
4974 /* override the amp caps for beep generator */
4975 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
4976 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
4977 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
4978 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4979 (0 << AC_AMPCAP_MUTE_SHIFT));
4982 if (!spec->no_analog && !spec->adc_nids) {
4983 alc_auto_fill_adc_caps(codec);
4984 alc_rebuild_imux_for_auto_mic(codec);
4985 alc_remove_invalid_adc_nids(codec);
4988 if (!spec->no_analog && !spec->cap_mixer)
4989 set_capture_mixer(codec);
4991 codec->patch_ops = alc_patch_ops;
4992 spec->init_hook = alc_auto_init_std;
4993 spec->shutup = alc_eapd_shutup;
5005 #ifdef CONFIG_SND_HDA_POWER_SAVE
5006 #define alc269_loopbacks alc880_loopbacks
5009 static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
5013 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
5014 /* NID is set in alc_build_pcms */
5016 .open = alc_playback_pcm_open,
5017 .prepare = alc_playback_pcm_prepare,
5018 .cleanup = alc_playback_pcm_cleanup
5022 static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
5026 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
5027 /* NID is set in alc_build_pcms */
5030 #ifdef CONFIG_SND_HDA_POWER_SAVE
5031 static int alc269_mic2_for_mute_led(struct hda_codec *codec)
5033 switch (codec->subsystem_id) {
5040 static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
5042 /* update mute-LED according to the speaker mute state */
5043 if (nid == 0x01 || nid == 0x14) {
5045 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
5050 /* mic2 vref pin is used for mute LED control */
5051 snd_hda_codec_update_cache(codec, 0x19, 0,
5052 AC_VERB_SET_PIN_WIDGET_CONTROL,
5055 return alc_check_power_status(codec, nid);
5057 #endif /* CONFIG_SND_HDA_POWER_SAVE */
5059 /* different alc269-variants */
5061 ALC269_TYPE_ALC269VA,
5062 ALC269_TYPE_ALC269VB,
5063 ALC269_TYPE_ALC269VC,
5067 * BIOS auto configuration
5069 static int alc269_parse_auto_config(struct hda_codec *codec)
5071 static const hda_nid_t alc269_ignore[] = { 0x1d, 0 };
5072 static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 };
5073 static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 };
5074 struct alc_spec *spec = codec->spec;
5075 const hda_nid_t *ssids = spec->codec_variant == ALC269_TYPE_ALC269VA ?
5076 alc269va_ssids : alc269_ssids;
5078 return alc_parse_auto_config(codec, alc269_ignore, ssids);
5081 static void alc269_toggle_power_output(struct hda_codec *codec, int power_up)
5083 int val = alc_read_coef_idx(codec, 0x04);
5088 alc_write_coef_idx(codec, 0x04, val);
5091 static void alc269_shutup(struct hda_codec *codec)
5093 if ((alc_get_coef0(codec) & 0x00ff) == 0x017)
5094 alc269_toggle_power_output(codec, 0);
5095 if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
5096 alc269_toggle_power_output(codec, 0);
5102 static int alc269_resume(struct hda_codec *codec)
5104 if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
5105 alc269_toggle_power_output(codec, 0);
5109 codec->patch_ops.init(codec);
5111 if ((alc_get_coef0(codec) & 0x00ff) == 0x017) {
5112 alc269_toggle_power_output(codec, 1);
5116 if ((alc_get_coef0(codec) & 0x00ff) == 0x018)
5117 alc269_toggle_power_output(codec, 1);
5119 snd_hda_codec_resume_amp(codec);
5120 snd_hda_codec_resume_cache(codec);
5121 hda_call_check_power_status(codec, 0x01);
5124 #endif /* CONFIG_PM */
5126 static void alc269_fixup_hweq(struct hda_codec *codec,
5127 const struct alc_fixup *fix, int action)
5131 if (action != ALC_FIXUP_ACT_INIT)
5133 coef = alc_read_coef_idx(codec, 0x1e);
5134 alc_write_coef_idx(codec, 0x1e, coef | 0x80);
5137 static void alc271_fixup_dmic(struct hda_codec *codec,
5138 const struct alc_fixup *fix, int action)
5140 static const struct hda_verb verbs[] = {
5141 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
5142 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
5147 if (strcmp(codec->chip_name, "ALC271X"))
5149 cfg = snd_hda_codec_get_pincfg(codec, 0x12);
5150 if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED)
5151 snd_hda_sequence_write(codec, verbs);
5154 static void alc269_fixup_pcm_44k(struct hda_codec *codec,
5155 const struct alc_fixup *fix, int action)
5157 struct alc_spec *spec = codec->spec;
5159 if (action != ALC_FIXUP_ACT_PROBE)
5162 /* Due to a hardware problem on Lenovo Ideadpad, we need to
5163 * fix the sample rate of analog I/O to 44.1kHz
5165 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
5166 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
5169 static void alc269_fixup_stereo_dmic(struct hda_codec *codec,
5170 const struct alc_fixup *fix, int action)
5174 if (action != ALC_FIXUP_ACT_INIT)
5176 /* The digital-mic unit sends PDM (differential signal) instead of
5177 * the standard PCM, thus you can't record a valid mono stream as is.
5178 * Below is a workaround specific to ALC269 to control the dmic
5179 * signal source as mono.
5181 coef = alc_read_coef_idx(codec, 0x07);
5182 alc_write_coef_idx(codec, 0x07, coef | 0x80);
5185 static void alc269_quanta_automute(struct hda_codec *codec)
5187 update_outputs(codec);
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, 0x680);
5194 snd_hda_codec_write(codec, 0x20, 0,
5195 AC_VERB_SET_COEF_INDEX, 0x0c);
5196 snd_hda_codec_write(codec, 0x20, 0,
5197 AC_VERB_SET_PROC_COEF, 0x480);
5200 static void alc269_fixup_quanta_mute(struct hda_codec *codec,
5201 const struct alc_fixup *fix, int action)
5203 struct alc_spec *spec = codec->spec;
5204 if (action != ALC_FIXUP_ACT_PROBE)
5206 spec->automute_hook = alc269_quanta_automute;
5210 ALC269_FIXUP_SONY_VAIO,
5211 ALC275_FIXUP_SONY_VAIO_GPIO2,
5212 ALC269_FIXUP_DELL_M101Z,
5213 ALC269_FIXUP_SKU_IGNORE,
5214 ALC269_FIXUP_ASUS_G73JW,
5215 ALC269_FIXUP_LENOVO_EAPD,
5216 ALC275_FIXUP_SONY_HWEQ,
5218 ALC269_FIXUP_PCM_44K,
5219 ALC269_FIXUP_STEREO_DMIC,
5220 ALC269_FIXUP_QUANTA_MUTE,
5221 ALC269_FIXUP_LIFEBOOK,
5224 ALC269VB_FIXUP_AMIC,
5225 ALC269VB_FIXUP_DMIC,
5228 static const struct alc_fixup alc269_fixups[] = {
5229 [ALC269_FIXUP_SONY_VAIO] = {
5230 .type = ALC_FIXUP_VERBS,
5231 .v.verbs = (const struct hda_verb[]) {
5232 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
5236 [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
5237 .type = ALC_FIXUP_VERBS,
5238 .v.verbs = (const struct hda_verb[]) {
5239 {0x01, AC_VERB_SET_GPIO_MASK, 0x04},
5240 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04},
5241 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5245 .chain_id = ALC269_FIXUP_SONY_VAIO
5247 [ALC269_FIXUP_DELL_M101Z] = {
5248 .type = ALC_FIXUP_VERBS,
5249 .v.verbs = (const struct hda_verb[]) {
5250 /* Enables internal speaker */
5251 {0x20, AC_VERB_SET_COEF_INDEX, 13},
5252 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
5256 [ALC269_FIXUP_SKU_IGNORE] = {
5257 .type = ALC_FIXUP_SKU,
5258 .v.sku = ALC_FIXUP_SKU_IGNORE,
5260 [ALC269_FIXUP_ASUS_G73JW] = {
5261 .type = ALC_FIXUP_PINS,
5262 .v.pins = (const struct alc_pincfg[]) {
5263 { 0x17, 0x99130111 }, /* subwoofer */
5267 [ALC269_FIXUP_LENOVO_EAPD] = {
5268 .type = ALC_FIXUP_VERBS,
5269 .v.verbs = (const struct hda_verb[]) {
5270 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
5274 [ALC275_FIXUP_SONY_HWEQ] = {
5275 .type = ALC_FIXUP_FUNC,
5276 .v.func = alc269_fixup_hweq,
5278 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
5280 [ALC271_FIXUP_DMIC] = {
5281 .type = ALC_FIXUP_FUNC,
5282 .v.func = alc271_fixup_dmic,
5284 [ALC269_FIXUP_PCM_44K] = {
5285 .type = ALC_FIXUP_FUNC,
5286 .v.func = alc269_fixup_pcm_44k,
5288 [ALC269_FIXUP_STEREO_DMIC] = {
5289 .type = ALC_FIXUP_FUNC,
5290 .v.func = alc269_fixup_stereo_dmic,
5292 [ALC269_FIXUP_QUANTA_MUTE] = {
5293 .type = ALC_FIXUP_FUNC,
5294 .v.func = alc269_fixup_quanta_mute,
5296 [ALC269_FIXUP_LIFEBOOK] = {
5297 .type = ALC_FIXUP_PINS,
5298 .v.pins = (const struct alc_pincfg[]) {
5299 { 0x1a, 0x2101103f }, /* dock line-out */
5300 { 0x1b, 0x23a11040 }, /* dock mic-in */
5304 .chain_id = ALC269_FIXUP_QUANTA_MUTE
5306 [ALC269_FIXUP_AMIC] = {
5307 .type = ALC_FIXUP_PINS,
5308 .v.pins = (const struct alc_pincfg[]) {
5309 { 0x14, 0x99130110 }, /* speaker */
5310 { 0x15, 0x0121401f }, /* HP out */
5311 { 0x18, 0x01a19c20 }, /* mic */
5312 { 0x19, 0x99a3092f }, /* int-mic */
5316 [ALC269_FIXUP_DMIC] = {
5317 .type = ALC_FIXUP_PINS,
5318 .v.pins = (const struct alc_pincfg[]) {
5319 { 0x12, 0x99a3092f }, /* int-mic */
5320 { 0x14, 0x99130110 }, /* speaker */
5321 { 0x15, 0x0121401f }, /* HP out */
5322 { 0x18, 0x01a19c20 }, /* mic */
5326 [ALC269VB_FIXUP_AMIC] = {
5327 .type = ALC_FIXUP_PINS,
5328 .v.pins = (const struct alc_pincfg[]) {
5329 { 0x14, 0x99130110 }, /* speaker */
5330 { 0x18, 0x01a19c20 }, /* mic */
5331 { 0x19, 0x99a3092f }, /* int-mic */
5332 { 0x21, 0x0121401f }, /* HP out */
5336 [ALC269VB_FIXUP_DMIC] = {
5337 .type = ALC_FIXUP_PINS,
5338 .v.pins = (const struct alc_pincfg[]) {
5339 { 0x12, 0x99a3092f }, /* int-mic */
5340 { 0x14, 0x99130110 }, /* speaker */
5341 { 0x18, 0x01a19c20 }, /* mic */
5342 { 0x21, 0x0121401f }, /* HP out */
5348 static const struct snd_pci_quirk alc269_fixup_tbl[] = {
5349 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
5350 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC),
5351 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC),
5352 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC),
5353 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
5354 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
5355 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
5356 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
5357 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
5358 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
5359 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
5360 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC),
5361 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK),
5362 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
5363 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
5364 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
5365 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
5366 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
5367 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_QUANTA_MUTE),
5368 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Lenovo Ideapd", ALC269_FIXUP_PCM_44K),
5369 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
5372 /* Below is a quirk table taken from the old code.
5373 * Basically the device should work as is without the fixup table.
5374 * If BIOS doesn't give a proper info, enable the corresponding
5377 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
5379 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC),
5380 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269_FIXUP_AMIC),
5381 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC),
5382 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC),
5383 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC),
5384 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC),
5385 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC),
5386 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC),
5387 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC),
5388 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC),
5389 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC),
5390 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC),
5391 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC),
5392 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC),
5393 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC),
5394 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC),
5395 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC),
5396 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC),
5397 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC),
5398 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC),
5399 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC),
5400 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC),
5401 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC),
5402 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC),
5403 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC),
5404 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC),
5405 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC),
5406 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC),
5407 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC),
5408 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC),
5409 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC),
5410 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC),
5411 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC),
5412 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC),
5413 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC),
5414 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC),
5415 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC),
5416 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC),
5417 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC),
5418 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC),
5423 static const struct alc_model_fixup alc269_fixup_models[] = {
5424 {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"},
5425 {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"},
5430 static int alc269_fill_coef(struct hda_codec *codec)
5434 if ((alc_get_coef0(codec) & 0x00ff) < 0x015) {
5435 alc_write_coef_idx(codec, 0xf, 0x960b);
5436 alc_write_coef_idx(codec, 0xe, 0x8817);
5439 if ((alc_get_coef0(codec) & 0x00ff) == 0x016) {
5440 alc_write_coef_idx(codec, 0xf, 0x960b);
5441 alc_write_coef_idx(codec, 0xe, 0x8814);
5444 if ((alc_get_coef0(codec) & 0x00ff) == 0x017) {
5445 val = alc_read_coef_idx(codec, 0x04);
5446 /* Power up output pin */
5447 alc_write_coef_idx(codec, 0x04, val | (1<<11));
5450 if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
5451 val = alc_read_coef_idx(codec, 0xd);
5452 if ((val & 0x0c00) >> 10 != 0x1) {
5453 /* Capless ramp up clock control */
5454 alc_write_coef_idx(codec, 0xd, val | (1<<10));
5456 val = alc_read_coef_idx(codec, 0x17);
5457 if ((val & 0x01c0) >> 6 != 0x4) {
5458 /* Class D power on reset */
5459 alc_write_coef_idx(codec, 0x17, val | (1<<7));
5463 val = alc_read_coef_idx(codec, 0xd); /* Class D */
5464 alc_write_coef_idx(codec, 0xd, val | (1<<14));
5466 val = alc_read_coef_idx(codec, 0x4); /* HP */
5467 alc_write_coef_idx(codec, 0x4, val | (1<<11));
5474 static int patch_alc269(struct hda_codec *codec)
5476 struct alc_spec *spec;
5479 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5485 spec->mixer_nid = 0x0b;
5487 alc_auto_parse_customize_define(codec);
5489 err = alc_codec_rename_from_preset(codec);
5493 if (codec->vendor_id == 0x10ec0269) {
5494 spec->codec_variant = ALC269_TYPE_ALC269VA;
5495 switch (alc_get_coef0(codec) & 0x00f0) {
5497 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
5498 spec->cdefine.platform_type == 1)
5499 err = alc_codec_rename(codec, "ALC271X");
5500 spec->codec_variant = ALC269_TYPE_ALC269VB;
5503 if (codec->bus->pci->subsystem_vendor == 0x17aa &&
5504 codec->bus->pci->subsystem_device == 0x21f3)
5505 err = alc_codec_rename(codec, "ALC3202");
5506 spec->codec_variant = ALC269_TYPE_ALC269VC;
5509 alc_fix_pll_init(codec, 0x20, 0x04, 15);
5513 alc269_fill_coef(codec);
5516 alc_pick_fixup(codec, alc269_fixup_models,
5517 alc269_fixup_tbl, alc269_fixups);
5518 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
5520 /* automatic parse from the BIOS config */
5521 err = alc269_parse_auto_config(codec);
5525 if (!spec->no_analog && !spec->adc_nids) {
5526 alc_auto_fill_adc_caps(codec);
5527 alc_rebuild_imux_for_auto_mic(codec);
5528 alc_remove_invalid_adc_nids(codec);
5531 if (!spec->no_analog && !spec->cap_mixer)
5532 set_capture_mixer(codec);
5534 if (!spec->no_analog && has_cdefine_beep(codec)) {
5535 err = snd_hda_attach_beep_device(codec, 0x1);
5538 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
5541 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
5543 codec->patch_ops = alc_patch_ops;
5545 codec->patch_ops.resume = alc269_resume;
5547 spec->init_hook = alc_auto_init_std;
5548 spec->shutup = alc269_shutup;
5550 #ifdef CONFIG_SND_HDA_POWER_SAVE
5551 if (!spec->loopback.amplist)
5552 spec->loopback.amplist = alc269_loopbacks;
5553 if (alc269_mic2_for_mute_led(codec))
5554 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
5568 static int alc861_parse_auto_config(struct hda_codec *codec)
5570 static const hda_nid_t alc861_ignore[] = { 0x1d, 0 };
5571 static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 };
5572 return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids);
5575 #ifdef CONFIG_SND_HDA_POWER_SAVE
5576 static const struct hda_amp_list alc861_loopbacks[] = {
5577 { 0x15, HDA_INPUT, 0 },
5578 { 0x15, HDA_INPUT, 1 },
5579 { 0x15, HDA_INPUT, 2 },
5580 { 0x15, HDA_INPUT, 3 },
5586 /* Pin config fixes */
5588 PINFIX_FSC_AMILO_PI1505,
5592 static const struct alc_fixup alc861_fixups[] = {
5593 [PINFIX_FSC_AMILO_PI1505] = {
5594 .type = ALC_FIXUP_PINS,
5595 .v.pins = (const struct alc_pincfg[]) {
5596 { 0x0b, 0x0221101f }, /* HP */
5597 { 0x0f, 0x90170310 }, /* speaker */
5601 [PINFIX_ASUS_A6RP] = {
5602 .type = ALC_FIXUP_VERBS,
5603 .v.verbs = (const struct hda_verb[]) {
5604 /* node 0x0f VREF seems controlling the master output */
5605 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
5611 static const struct snd_pci_quirk alc861_fixup_tbl[] = {
5612 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", PINFIX_ASUS_A6RP),
5613 SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", PINFIX_ASUS_A6RP),
5614 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
5620 static int patch_alc861(struct hda_codec *codec)
5622 struct alc_spec *spec;
5625 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5631 spec->mixer_nid = 0x15;
5633 alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
5634 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
5636 /* automatic parse from the BIOS config */
5637 err = alc861_parse_auto_config(codec);
5641 if (!spec->no_analog && !spec->adc_nids) {
5642 alc_auto_fill_adc_caps(codec);
5643 alc_rebuild_imux_for_auto_mic(codec);
5644 alc_remove_invalid_adc_nids(codec);
5647 if (!spec->no_analog && !spec->cap_mixer)
5648 set_capture_mixer(codec);
5650 if (!spec->no_analog) {
5651 err = snd_hda_attach_beep_device(codec, 0x23);
5654 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
5657 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
5659 codec->patch_ops = alc_patch_ops;
5660 spec->init_hook = alc_auto_init_std;
5661 #ifdef CONFIG_SND_HDA_POWER_SAVE
5662 spec->power_hook = alc_power_eapd;
5663 if (!spec->loopback.amplist)
5664 spec->loopback.amplist = alc861_loopbacks;
5679 * In addition, an independent DAC
5681 #ifdef CONFIG_SND_HDA_POWER_SAVE
5682 #define alc861vd_loopbacks alc880_loopbacks
5685 static int alc861vd_parse_auto_config(struct hda_codec *codec)
5687 static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
5688 static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 };
5689 return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids);
5693 ALC660VD_FIX_ASUS_GPIO1,
5694 ALC861VD_FIX_DALLAS,
5697 /* exclude VREF80 */
5698 static void alc861vd_fixup_dallas(struct hda_codec *codec,
5699 const struct alc_fixup *fix, int action)
5701 if (action == ALC_FIXUP_ACT_PRE_PROBE) {
5702 snd_hda_override_pin_caps(codec, 0x18, 0x00001714);
5703 snd_hda_override_pin_caps(codec, 0x19, 0x0000171c);
5707 static const struct alc_fixup alc861vd_fixups[] = {
5708 [ALC660VD_FIX_ASUS_GPIO1] = {
5709 .type = ALC_FIXUP_VERBS,
5710 .v.verbs = (const struct hda_verb[]) {
5712 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5713 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5714 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5718 [ALC861VD_FIX_DALLAS] = {
5719 .type = ALC_FIXUP_FUNC,
5720 .v.func = alc861vd_fixup_dallas,
5724 static const struct snd_pci_quirk alc861vd_fixup_tbl[] = {
5725 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS),
5726 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
5727 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS),
5731 static const struct hda_verb alc660vd_eapd_verbs[] = {
5732 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
5733 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
5739 static int patch_alc861vd(struct hda_codec *codec)
5741 struct alc_spec *spec;
5744 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5750 spec->mixer_nid = 0x0b;
5752 alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
5753 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
5755 /* automatic parse from the BIOS config */
5756 err = alc861vd_parse_auto_config(codec);
5760 if (codec->vendor_id == 0x10ec0660) {
5761 /* always turn on EAPD */
5762 add_verb(spec, alc660vd_eapd_verbs);
5765 if (!spec->no_analog && !spec->adc_nids) {
5766 alc_auto_fill_adc_caps(codec);
5767 alc_rebuild_imux_for_auto_mic(codec);
5768 alc_remove_invalid_adc_nids(codec);
5771 if (!spec->no_analog && !spec->cap_mixer)
5772 set_capture_mixer(codec);
5774 if (!spec->no_analog) {
5775 err = snd_hda_attach_beep_device(codec, 0x23);
5778 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
5781 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
5783 codec->patch_ops = alc_patch_ops;
5785 spec->init_hook = alc_auto_init_std;
5786 spec->shutup = alc_eapd_shutup;
5787 #ifdef CONFIG_SND_HDA_POWER_SAVE
5788 if (!spec->loopback.amplist)
5789 spec->loopback.amplist = alc861vd_loopbacks;
5802 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
5803 * configuration. Each pin widget can choose any input DACs and a mixer.
5804 * Each ADC is connected from a mixer of all inputs. This makes possible
5805 * 6-channel independent captures.
5807 * In addition, an independent DAC for the multi-playback (not used in this
5810 #ifdef CONFIG_SND_HDA_POWER_SAVE
5811 #define alc662_loopbacks alc880_loopbacks
5815 * BIOS auto configuration
5818 static int alc662_parse_auto_config(struct hda_codec *codec)
5820 static const hda_nid_t alc662_ignore[] = { 0x1d, 0 };
5821 static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 };
5822 static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 };
5823 const hda_nid_t *ssids;
5825 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
5826 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
5827 ssids = alc663_ssids;
5829 ssids = alc662_ssids;
5830 return alc_parse_auto_config(codec, alc662_ignore, ssids);
5833 static void alc272_fixup_mario(struct hda_codec *codec,
5834 const struct alc_fixup *fix, int action)
5836 if (action != ALC_FIXUP_ACT_PROBE)
5838 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
5839 (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
5840 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
5841 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5842 (0 << AC_AMPCAP_MUTE_SHIFT)))
5844 "hda_codec: failed to override amp caps for NID 0x2\n");
5848 ALC662_FIXUP_ASPIRE,
5849 ALC662_FIXUP_IDEAPAD,
5851 ALC662_FIXUP_CZC_P10T,
5852 ALC662_FIXUP_SKU_IGNORE,
5853 ALC662_FIXUP_HP_RP5800,
5854 ALC662_FIXUP_ASUS_MODE1,
5855 ALC662_FIXUP_ASUS_MODE2,
5856 ALC662_FIXUP_ASUS_MODE3,
5857 ALC662_FIXUP_ASUS_MODE4,
5858 ALC662_FIXUP_ASUS_MODE5,
5859 ALC662_FIXUP_ASUS_MODE6,
5860 ALC662_FIXUP_ASUS_MODE7,
5861 ALC662_FIXUP_ASUS_MODE8,
5864 static const struct alc_fixup alc662_fixups[] = {
5865 [ALC662_FIXUP_ASPIRE] = {
5866 .type = ALC_FIXUP_PINS,
5867 .v.pins = (const struct alc_pincfg[]) {
5868 { 0x15, 0x99130112 }, /* subwoofer */
5872 [ALC662_FIXUP_IDEAPAD] = {
5873 .type = ALC_FIXUP_PINS,
5874 .v.pins = (const struct alc_pincfg[]) {
5875 { 0x17, 0x99130112 }, /* subwoofer */
5879 [ALC272_FIXUP_MARIO] = {
5880 .type = ALC_FIXUP_FUNC,
5881 .v.func = alc272_fixup_mario,
5883 [ALC662_FIXUP_CZC_P10T] = {
5884 .type = ALC_FIXUP_VERBS,
5885 .v.verbs = (const struct hda_verb[]) {
5886 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
5890 [ALC662_FIXUP_SKU_IGNORE] = {
5891 .type = ALC_FIXUP_SKU,
5892 .v.sku = ALC_FIXUP_SKU_IGNORE,
5894 [ALC662_FIXUP_HP_RP5800] = {
5895 .type = ALC_FIXUP_PINS,
5896 .v.pins = (const struct alc_pincfg[]) {
5897 { 0x14, 0x0221201f }, /* HP out */
5901 .chain_id = ALC662_FIXUP_SKU_IGNORE
5903 [ALC662_FIXUP_ASUS_MODE1] = {
5904 .type = ALC_FIXUP_PINS,
5905 .v.pins = (const struct alc_pincfg[]) {
5906 { 0x14, 0x99130110 }, /* speaker */
5907 { 0x18, 0x01a19c20 }, /* mic */
5908 { 0x19, 0x99a3092f }, /* int-mic */
5909 { 0x21, 0x0121401f }, /* HP out */
5913 .chain_id = ALC662_FIXUP_SKU_IGNORE
5915 [ALC662_FIXUP_ASUS_MODE2] = {
5916 .type = ALC_FIXUP_PINS,
5917 .v.pins = (const struct alc_pincfg[]) {
5918 { 0x14, 0x99130110 }, /* speaker */
5919 { 0x18, 0x01a19820 }, /* mic */
5920 { 0x19, 0x99a3092f }, /* int-mic */
5921 { 0x1b, 0x0121401f }, /* HP out */
5925 .chain_id = ALC662_FIXUP_SKU_IGNORE
5927 [ALC662_FIXUP_ASUS_MODE3] = {
5928 .type = ALC_FIXUP_PINS,
5929 .v.pins = (const struct alc_pincfg[]) {
5930 { 0x14, 0x99130110 }, /* speaker */
5931 { 0x15, 0x0121441f }, /* HP */
5932 { 0x18, 0x01a19840 }, /* mic */
5933 { 0x19, 0x99a3094f }, /* int-mic */
5934 { 0x21, 0x01211420 }, /* HP2 */
5938 .chain_id = ALC662_FIXUP_SKU_IGNORE
5940 [ALC662_FIXUP_ASUS_MODE4] = {
5941 .type = ALC_FIXUP_PINS,
5942 .v.pins = (const struct alc_pincfg[]) {
5943 { 0x14, 0x99130110 }, /* speaker */
5944 { 0x16, 0x99130111 }, /* speaker */
5945 { 0x18, 0x01a19840 }, /* mic */
5946 { 0x19, 0x99a3094f }, /* int-mic */
5947 { 0x21, 0x0121441f }, /* HP */
5951 .chain_id = ALC662_FIXUP_SKU_IGNORE
5953 [ALC662_FIXUP_ASUS_MODE5] = {
5954 .type = ALC_FIXUP_PINS,
5955 .v.pins = (const struct alc_pincfg[]) {
5956 { 0x14, 0x99130110 }, /* speaker */
5957 { 0x15, 0x0121441f }, /* HP */
5958 { 0x16, 0x99130111 }, /* speaker */
5959 { 0x18, 0x01a19840 }, /* mic */
5960 { 0x19, 0x99a3094f }, /* int-mic */
5964 .chain_id = ALC662_FIXUP_SKU_IGNORE
5966 [ALC662_FIXUP_ASUS_MODE6] = {
5967 .type = ALC_FIXUP_PINS,
5968 .v.pins = (const struct alc_pincfg[]) {
5969 { 0x14, 0x99130110 }, /* speaker */
5970 { 0x15, 0x01211420 }, /* HP2 */
5971 { 0x18, 0x01a19840 }, /* mic */
5972 { 0x19, 0x99a3094f }, /* int-mic */
5973 { 0x1b, 0x0121441f }, /* HP */
5977 .chain_id = ALC662_FIXUP_SKU_IGNORE
5979 [ALC662_FIXUP_ASUS_MODE7] = {
5980 .type = ALC_FIXUP_PINS,
5981 .v.pins = (const struct alc_pincfg[]) {
5982 { 0x14, 0x99130110 }, /* speaker */
5983 { 0x17, 0x99130111 }, /* speaker */
5984 { 0x18, 0x01a19840 }, /* mic */
5985 { 0x19, 0x99a3094f }, /* int-mic */
5986 { 0x1b, 0x01214020 }, /* HP */
5987 { 0x21, 0x0121401f }, /* HP */
5991 .chain_id = ALC662_FIXUP_SKU_IGNORE
5993 [ALC662_FIXUP_ASUS_MODE8] = {
5994 .type = ALC_FIXUP_PINS,
5995 .v.pins = (const struct alc_pincfg[]) {
5996 { 0x14, 0x99130110 }, /* speaker */
5997 { 0x12, 0x99a30970 }, /* int-mic */
5998 { 0x15, 0x01214020 }, /* HP */
5999 { 0x17, 0x99130111 }, /* speaker */
6000 { 0x18, 0x01a19840 }, /* mic */
6001 { 0x21, 0x0121401f }, /* HP */
6005 .chain_id = ALC662_FIXUP_SKU_IGNORE
6009 static const struct snd_pci_quirk alc662_fixup_tbl[] = {
6010 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2),
6011 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
6012 SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE),
6013 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
6014 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
6015 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2),
6016 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
6017 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
6018 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
6019 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
6022 /* Below is a quirk table taken from the old code.
6023 * Basically the device should work as is without the fixup table.
6024 * If BIOS doesn't give a proper info, enable the corresponding
6027 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1),
6028 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3),
6029 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1),
6030 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3),
6031 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
6032 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6033 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
6034 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1),
6035 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1),
6036 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6037 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7),
6038 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7),
6039 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8),
6040 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3),
6041 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1),
6042 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6043 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2),
6044 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1),
6045 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6046 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
6047 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
6048 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6049 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1),
6050 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3),
6051 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2),
6052 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6053 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5),
6054 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
6055 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6056 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1),
6057 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6058 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6059 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3),
6060 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3),
6061 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1),
6062 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1),
6063 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1),
6064 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1),
6065 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1),
6066 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6067 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2),
6068 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1),
6069 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
6070 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3),
6071 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1),
6072 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1),
6073 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1),
6074 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2),
6075 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
6076 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4),
6081 static const struct alc_model_fixup alc662_fixup_models[] = {
6082 {.id = ALC272_FIXUP_MARIO, .name = "mario"},
6083 {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"},
6084 {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"},
6085 {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"},
6086 {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"},
6087 {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"},
6088 {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"},
6089 {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"},
6090 {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"},
6097 static int patch_alc662(struct hda_codec *codec)
6099 struct alc_spec *spec;
6102 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6108 spec->mixer_nid = 0x0b;
6110 /* handle multiple HPs as is */
6111 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
6113 alc_auto_parse_customize_define(codec);
6115 alc_fix_pll_init(codec, 0x20, 0x04, 15);
6117 err = alc_codec_rename_from_preset(codec);
6121 if ((alc_get_coef0(codec) & (1 << 14)) &&
6122 codec->bus->pci->subsystem_vendor == 0x1025 &&
6123 spec->cdefine.platform_type == 1) {
6124 if (alc_codec_rename(codec, "ALC272X") < 0)
6128 alc_pick_fixup(codec, alc662_fixup_models,
6129 alc662_fixup_tbl, alc662_fixups);
6130 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
6131 /* automatic parse from the BIOS config */
6132 err = alc662_parse_auto_config(codec);
6136 if (!spec->no_analog && !spec->adc_nids) {
6137 alc_auto_fill_adc_caps(codec);
6138 alc_rebuild_imux_for_auto_mic(codec);
6139 alc_remove_invalid_adc_nids(codec);
6142 if (!spec->no_analog && !spec->cap_mixer)
6143 set_capture_mixer(codec);
6145 if (!spec->no_analog && has_cdefine_beep(codec)) {
6146 err = snd_hda_attach_beep_device(codec, 0x1);
6149 switch (codec->vendor_id) {
6151 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
6156 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
6159 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
6164 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
6166 codec->patch_ops = alc_patch_ops;
6167 spec->init_hook = alc_auto_init_std;
6168 spec->shutup = alc_eapd_shutup;
6170 #ifdef CONFIG_SND_HDA_POWER_SAVE
6171 if (!spec->loopback.amplist)
6172 spec->loopback.amplist = alc662_loopbacks;
6186 static int alc680_parse_auto_config(struct hda_codec *codec)
6188 return alc_parse_auto_config(codec, NULL, NULL);
6193 static int patch_alc680(struct hda_codec *codec)
6195 struct alc_spec *spec;
6198 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6204 /* ALC680 has no aa-loopback mixer */
6206 /* automatic parse from the BIOS config */
6207 err = alc680_parse_auto_config(codec);
6213 if (!spec->no_analog && !spec->cap_mixer)
6214 set_capture_mixer(codec);
6216 codec->patch_ops = alc_patch_ops;
6217 spec->init_hook = alc_auto_init_std;
6225 static const struct hda_codec_preset snd_hda_preset_realtek[] = {
6226 { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 },
6227 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
6228 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
6229 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
6230 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
6231 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
6232 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
6233 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
6234 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
6235 { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 },
6236 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
6237 .patch = patch_alc861 },
6238 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
6239 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
6240 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
6241 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
6242 .patch = patch_alc882 },
6243 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
6244 .patch = patch_alc662 },
6245 { .id = 0x10ec0662, .rev = 0x100300, .name = "ALC662 rev3",
6246 .patch = patch_alc662 },
6247 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
6248 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
6249 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
6250 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
6251 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
6252 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
6253 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
6254 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
6255 .patch = patch_alc882 },
6256 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
6257 .patch = patch_alc882 },
6258 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
6259 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
6260 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
6261 .patch = patch_alc882 },
6262 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
6263 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
6264 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
6265 { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 },
6269 MODULE_ALIAS("snd-hda-codec-id:10ec*");
6271 MODULE_LICENSE("GPL");
6272 MODULE_DESCRIPTION("Realtek HD-audio codec");
6274 static struct hda_codec_preset_list realtek_list = {
6275 .preset = snd_hda_preset_realtek,
6276 .owner = THIS_MODULE,
6279 static int __init patch_realtek_init(void)
6281 return snd_hda_add_codec_preset(&realtek_list);
6284 static void __exit patch_realtek_exit(void)
6286 snd_hda_delete_codec_preset(&realtek_list);
6289 module_init(patch_realtek_init)
6290 module_exit(patch_realtek_exit)