2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for Realtek ALC codecs
6 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
8 * Takashi Iwai <tiwai@suse.de>
9 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <linux/init.h>
27 #include <linux/delay.h>
28 #include <linux/slab.h>
29 #include <linux/pci.h>
30 #include <sound/core.h>
31 #include <sound/jack.h>
32 #include "hda_codec.h"
33 #include "hda_local.h"
36 /* unsol event tags */
37 #define ALC_FRONT_EVENT 0x01
38 #define ALC_DCVOL_EVENT 0x02
39 #define ALC_HP_EVENT 0x04
40 #define ALC_MIC_EVENT 0x08
43 #define GPIO_MASK 0x03
45 /* extra amp-initialization sequence types */
54 struct alc_customize_define {
56 unsigned char port_connectivity;
57 unsigned char check_sum;
58 unsigned char customization;
59 unsigned char external_amp;
60 unsigned int enable_pcbeep:1;
61 unsigned int platform_type:1;
63 unsigned int override:1;
64 unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */
70 hda_nid_t pin; /* multi-io widget pin NID */
71 hda_nid_t dac; /* DAC to be connected */
72 unsigned int ctl_in; /* cached input-pin control value */
76 ALC_AUTOMUTE_PIN, /* change the pin control */
77 ALC_AUTOMUTE_AMP, /* mute/unmute the pin AMP */
78 ALC_AUTOMUTE_MIXER, /* mute/unmute mixer widget AMP */
82 /* codec parameterization */
83 const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
84 unsigned int num_mixers;
85 const struct snd_kcontrol_new *cap_mixer; /* capture mixer */
86 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
88 const struct hda_verb *init_verbs[10]; /* initialization verbs
92 unsigned int num_init_verbs;
94 char stream_name_analog[32]; /* analog PCM stream */
95 const struct hda_pcm_stream *stream_analog_playback;
96 const struct hda_pcm_stream *stream_analog_capture;
97 const struct hda_pcm_stream *stream_analog_alt_playback;
98 const struct hda_pcm_stream *stream_analog_alt_capture;
100 char stream_name_digital[32]; /* digital PCM stream */
101 const struct hda_pcm_stream *stream_digital_playback;
102 const struct hda_pcm_stream *stream_digital_capture;
105 struct hda_multi_out multiout; /* playback set-up
106 * max_channels, dacs must be set
107 * dig_out_nid and hp_nid are optional
109 hda_nid_t alt_dac_nid;
110 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
114 unsigned int num_adc_nids;
115 const hda_nid_t *adc_nids;
116 const hda_nid_t *capsrc_nids;
117 hda_nid_t dig_in_nid; /* digital-in NID; optional */
118 hda_nid_t mixer_nid; /* analog-mixer NID */
120 /* capture setup for dynamic dual-adc switch */
122 unsigned int cur_adc_stream_tag;
123 unsigned int cur_adc_format;
126 unsigned int num_mux_defs;
127 const struct hda_input_mux *input_mux;
128 unsigned int cur_mux[3];
129 hda_nid_t ext_mic_pin;
130 hda_nid_t dock_mic_pin;
131 hda_nid_t int_mic_pin;
134 const struct hda_channel_mode *channel_mode;
135 int num_channel_mode;
137 int const_channel_count;
138 int ext_channel_count;
140 /* PCM information */
141 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
143 /* dynamic controls, init_verbs and input_mux */
144 struct auto_pin_cfg autocfg;
145 struct alc_customize_define cdefine;
146 struct snd_array kctls;
147 struct hda_input_mux private_imux[3];
148 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
149 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
150 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
151 hda_nid_t imux_pins[HDA_MAX_NUM_INPUTS];
152 unsigned int dyn_adc_idx[HDA_MAX_NUM_INPUTS];
153 int int_mic_idx, ext_mic_idx, dock_mic_idx; /* for auto-mic */
156 void (*init_hook)(struct hda_codec *codec);
157 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
158 #ifdef CONFIG_SND_HDA_POWER_SAVE
159 void (*power_hook)(struct hda_codec *codec);
161 void (*shutup)(struct hda_codec *codec);
162 void (*automute_hook)(struct hda_codec *codec);
164 /* for pin sensing */
165 unsigned int hp_jack_present:1;
166 unsigned int line_jack_present:1;
167 unsigned int master_mute:1;
168 unsigned int auto_mic:1;
169 unsigned int auto_mic_valid_imux:1; /* valid imux for auto-mic */
170 unsigned int automute_speaker:1; /* automute speaker outputs */
171 unsigned int automute_lo:1; /* automute LO outputs */
172 unsigned int detect_hp:1; /* Headphone detection enabled */
173 unsigned int detect_lo:1; /* Line-out detection enabled */
174 unsigned int automute_speaker_possible:1; /* there are speakers and either LO or HP */
175 unsigned int automute_lo_possible:1; /* there are line outs and HP */
178 unsigned int no_analog :1; /* digital I/O only */
179 unsigned int dyn_adc_switch:1; /* switch ADCs (for ALC275) */
180 unsigned int single_input_src:1;
181 unsigned int vol_in_capsrc:1; /* use capsrc volume (ADC has no vol) */
182 unsigned int parse_flags; /* passed to snd_hda_parse_pin_defcfg() */
184 /* auto-mute control */
186 hda_nid_t automute_mixer_nid[AUTO_CFG_MAX_OUTS];
189 int codec_variant; /* flag for other variants */
191 /* for virtual master */
192 hda_nid_t vmaster_nid;
193 #ifdef CONFIG_SND_HDA_POWER_SAVE
194 struct hda_loopback_check loopback;
199 unsigned int pll_coef_idx, pll_coef_bit;
203 const struct alc_fixup *fixup_list;
204 const char *fixup_name;
208 struct alc_multi_io multi_io[4];
211 struct snd_array bind_ctls;
214 #define ALC_MODEL_AUTO 0 /* common for all chips */
216 static bool check_amp_caps(struct hda_codec *codec, hda_nid_t nid,
217 int dir, unsigned int bits)
221 if (get_wcaps(codec, nid) & (1 << (dir + 1)))
222 if (query_amp_caps(codec, nid, dir) & bits)
227 #define nid_has_mute(codec, nid, dir) \
228 check_amp_caps(codec, nid, dir, AC_AMPCAP_MUTE)
229 #define nid_has_volume(codec, nid, dir) \
230 check_amp_caps(codec, nid, dir, AC_AMPCAP_NUM_STEPS)
235 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
236 struct snd_ctl_elem_info *uinfo)
238 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
239 struct alc_spec *spec = codec->spec;
240 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
241 if (mux_idx >= spec->num_mux_defs)
243 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
245 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
248 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
249 struct snd_ctl_elem_value *ucontrol)
251 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
252 struct alc_spec *spec = codec->spec;
253 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
255 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
259 static bool alc_dyn_adc_pcm_resetup(struct hda_codec *codec, int cur)
261 struct alc_spec *spec = codec->spec;
262 hda_nid_t new_adc = spec->adc_nids[spec->dyn_adc_idx[cur]];
264 if (spec->cur_adc && spec->cur_adc != new_adc) {
265 /* stream is running, let's swap the current ADC */
266 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
267 spec->cur_adc = new_adc;
268 snd_hda_codec_setup_stream(codec, new_adc,
269 spec->cur_adc_stream_tag, 0,
270 spec->cur_adc_format);
276 /* select the given imux item; either unmute exclusively or select the route */
277 static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx,
278 unsigned int idx, bool force)
280 struct alc_spec *spec = codec->spec;
281 const struct hda_input_mux *imux;
282 unsigned int mux_idx;
286 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
287 imux = &spec->input_mux[mux_idx];
288 if (!imux->num_items && mux_idx > 0)
289 imux = &spec->input_mux[0];
291 if (idx >= imux->num_items)
292 idx = imux->num_items - 1;
293 if (spec->cur_mux[adc_idx] == idx && !force)
295 spec->cur_mux[adc_idx] = idx;
297 if (spec->dyn_adc_switch) {
298 alc_dyn_adc_pcm_resetup(codec, idx);
299 adc_idx = spec->dyn_adc_idx[idx];
302 nid = spec->capsrc_nids ?
303 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
306 if (snd_hda_get_conn_list(codec, nid, NULL) <= 1)
309 type = get_wcaps_type(get_wcaps(codec, nid));
310 if (type == AC_WID_AUD_MIX) {
311 /* Matrix-mixer style (e.g. ALC882) */
312 for (i = 0; i < imux->num_items; i++) {
313 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
314 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
315 imux->items[i].index,
319 /* MUX style (e.g. ALC880) */
320 snd_hda_codec_write_cache(codec, nid, 0,
321 AC_VERB_SET_CONNECT_SEL,
322 imux->items[idx].index);
327 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
328 struct snd_ctl_elem_value *ucontrol)
330 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
331 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
332 return alc_mux_select(codec, adc_idx,
333 ucontrol->value.enumerated.item[0], false);
337 * set up the input pin config (depending on the given auto-pin type)
339 static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
342 unsigned int val = PIN_IN;
344 if (auto_pin_type == AUTO_PIN_MIC) {
347 oldval = snd_hda_codec_read(codec, nid, 0,
348 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
349 pincap = snd_hda_query_pin_caps(codec, nid);
350 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
351 /* if the default pin setup is vref50, we give it priority */
352 if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50)
354 else if (pincap & AC_PINCAP_VREF_50)
356 else if (pincap & AC_PINCAP_VREF_100)
358 else if (pincap & AC_PINCAP_VREF_GRD)
361 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
365 * Append the given mixer and verb elements for the later use
366 * The mixer array is referred in build_controls(), and init_verbs are
369 static void add_mixer(struct alc_spec *spec, const struct snd_kcontrol_new *mix)
371 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
373 spec->mixers[spec->num_mixers++] = mix;
376 static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
378 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
380 spec->init_verbs[spec->num_init_verbs++] = verb;
384 * GPIO setup tables, used in initialization
386 /* Enable GPIO mask and set output */
387 static const struct hda_verb alc_gpio1_init_verbs[] = {
388 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
389 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
390 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
394 static const struct hda_verb alc_gpio2_init_verbs[] = {
395 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
396 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
397 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
401 static const struct hda_verb alc_gpio3_init_verbs[] = {
402 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
403 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
404 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
409 * Fix hardware PLL issue
410 * On some codecs, the analog PLL gating control must be off while
411 * the default value is 1.
413 static void alc_fix_pll(struct hda_codec *codec)
415 struct alc_spec *spec = codec->spec;
420 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
422 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
423 AC_VERB_GET_PROC_COEF, 0);
424 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
426 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
427 val & ~(1 << spec->pll_coef_bit));
430 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
431 unsigned int coef_idx, unsigned int coef_bit)
433 struct alc_spec *spec = codec->spec;
435 spec->pll_coef_idx = coef_idx;
436 spec->pll_coef_bit = coef_bit;
441 * Jack-reporting via input-jack layer
444 /* initialization of jacks; currently checks only a few known pins */
445 static int alc_init_jacks(struct hda_codec *codec)
447 #ifdef CONFIG_SND_HDA_INPUT_JACK
448 struct alc_spec *spec = codec->spec;
450 unsigned int hp_nid = spec->autocfg.hp_pins[0];
451 unsigned int mic_nid = spec->ext_mic_pin;
452 unsigned int dock_nid = spec->dock_mic_pin;
455 err = snd_hda_input_jack_add(codec, hp_nid,
456 SND_JACK_HEADPHONE, NULL);
459 snd_hda_input_jack_report(codec, hp_nid);
463 err = snd_hda_input_jack_add(codec, mic_nid,
464 SND_JACK_MICROPHONE, NULL);
467 snd_hda_input_jack_report(codec, mic_nid);
470 err = snd_hda_input_jack_add(codec, dock_nid,
471 SND_JACK_MICROPHONE, NULL);
474 snd_hda_input_jack_report(codec, dock_nid);
476 #endif /* CONFIG_SND_HDA_INPUT_JACK */
481 * Jack detections for HP auto-mute and mic-switch
484 /* check each pin in the given array; returns true if any of them is plugged */
485 static bool detect_jacks(struct hda_codec *codec, int num_pins, hda_nid_t *pins)
489 for (i = 0; i < num_pins; i++) {
490 hda_nid_t nid = pins[i];
493 snd_hda_input_jack_report(codec, nid);
494 present |= snd_hda_jack_detect(codec, nid);
499 /* standard HP/line-out auto-mute helper */
500 static void do_automute(struct hda_codec *codec, int num_pins, hda_nid_t *pins,
501 bool mute, bool hp_out)
503 struct alc_spec *spec = codec->spec;
504 unsigned int mute_bits = mute ? HDA_AMP_MUTE : 0;
505 unsigned int pin_bits = mute ? 0 : (hp_out ? PIN_HP : PIN_OUT);
508 for (i = 0; i < num_pins; i++) {
509 hda_nid_t nid = pins[i];
512 switch (spec->automute_mode) {
513 case ALC_AUTOMUTE_PIN:
514 snd_hda_codec_write(codec, nid, 0,
515 AC_VERB_SET_PIN_WIDGET_CONTROL,
518 case ALC_AUTOMUTE_AMP:
519 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
520 HDA_AMP_MUTE, mute_bits);
522 case ALC_AUTOMUTE_MIXER:
523 nid = spec->automute_mixer_nid[i];
526 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
527 HDA_AMP_MUTE, mute_bits);
528 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 1,
529 HDA_AMP_MUTE, mute_bits);
535 /* Toggle outputs muting */
536 static void update_outputs(struct hda_codec *codec)
538 struct alc_spec *spec = codec->spec;
541 /* Control HP pins/amps depending on master_mute state;
542 * in general, HP pins/amps control should be enabled in all cases,
543 * but currently set only for master_mute, just to be safe
545 do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins),
546 spec->autocfg.hp_pins, spec->master_mute, true);
548 if (!spec->automute_speaker)
551 on = spec->hp_jack_present | spec->line_jack_present;
552 on |= spec->master_mute;
553 do_automute(codec, ARRAY_SIZE(spec->autocfg.speaker_pins),
554 spec->autocfg.speaker_pins, on, false);
556 /* toggle line-out mutes if needed, too */
557 /* if LO is a copy of either HP or Speaker, don't need to handle it */
558 if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0] ||
559 spec->autocfg.line_out_pins[0] == spec->autocfg.speaker_pins[0])
561 if (!spec->automute_lo)
564 on = spec->hp_jack_present;
565 on |= spec->master_mute;
566 do_automute(codec, ARRAY_SIZE(spec->autocfg.line_out_pins),
567 spec->autocfg.line_out_pins, on, false);
570 static void call_update_outputs(struct hda_codec *codec)
572 struct alc_spec *spec = codec->spec;
573 if (spec->automute_hook)
574 spec->automute_hook(codec);
576 update_outputs(codec);
579 /* standard HP-automute helper */
580 static void alc_hp_automute(struct hda_codec *codec)
582 struct alc_spec *spec = codec->spec;
584 spec->hp_jack_present =
585 detect_jacks(codec, ARRAY_SIZE(spec->autocfg.hp_pins),
586 spec->autocfg.hp_pins);
587 if (!spec->detect_hp || (!spec->automute_speaker && !spec->automute_lo))
589 call_update_outputs(codec);
592 /* standard line-out-automute helper */
593 static void alc_line_automute(struct hda_codec *codec)
595 struct alc_spec *spec = codec->spec;
597 /* check LO jack only when it's different from HP */
598 if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0])
601 spec->line_jack_present =
602 detect_jacks(codec, ARRAY_SIZE(spec->autocfg.line_out_pins),
603 spec->autocfg.line_out_pins);
604 if (!spec->automute_speaker || !spec->detect_lo)
606 call_update_outputs(codec);
609 #define get_connection_index(codec, mux, nid) \
610 snd_hda_get_conn_index(codec, mux, nid, 0)
612 /* standard mic auto-switch helper */
613 static void alc_mic_automute(struct hda_codec *codec)
615 struct alc_spec *spec = codec->spec;
616 hda_nid_t *pins = spec->imux_pins;
618 if (!spec->auto_mic || !spec->auto_mic_valid_imux)
620 if (snd_BUG_ON(!spec->adc_nids))
622 if (snd_BUG_ON(spec->int_mic_idx < 0 || spec->ext_mic_idx < 0))
625 if (snd_hda_jack_detect(codec, pins[spec->ext_mic_idx]))
626 alc_mux_select(codec, 0, spec->ext_mic_idx, false);
627 else if (spec->dock_mic_idx >= 0 &&
628 snd_hda_jack_detect(codec, pins[spec->dock_mic_idx]))
629 alc_mux_select(codec, 0, spec->dock_mic_idx, false);
631 alc_mux_select(codec, 0, spec->int_mic_idx, false);
633 snd_hda_input_jack_report(codec, pins[spec->ext_mic_idx]);
634 if (spec->dock_mic_idx >= 0)
635 snd_hda_input_jack_report(codec, pins[spec->dock_mic_idx]);
638 /* unsolicited event for HP jack sensing */
639 static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
641 if (codec->vendor_id == 0x10ec0880)
647 alc_hp_automute(codec);
649 case ALC_FRONT_EVENT:
650 alc_line_automute(codec);
653 alc_mic_automute(codec);
658 /* call init functions of standard auto-mute helpers */
659 static void alc_inithook(struct hda_codec *codec)
661 alc_hp_automute(codec);
662 alc_line_automute(codec);
663 alc_mic_automute(codec);
666 /* additional initialization for ALC888 variants */
667 static void alc888_coef_init(struct hda_codec *codec)
671 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
672 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
673 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
674 if ((tmp & 0xf0) == 0x20)
676 snd_hda_codec_read(codec, 0x20, 0,
677 AC_VERB_SET_PROC_COEF, 0x830);
680 snd_hda_codec_read(codec, 0x20, 0,
681 AC_VERB_SET_PROC_COEF, 0x3030);
684 /* additional initialization for ALC889 variants */
685 static void alc889_coef_init(struct hda_codec *codec)
689 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
690 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
691 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
692 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
695 /* turn on/off EAPD control (only if available) */
696 static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
698 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
700 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
701 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
705 /* turn on/off EAPD controls of the codec */
706 static void alc_auto_setup_eapd(struct hda_codec *codec, bool on)
708 /* We currently only handle front, HP */
709 static hda_nid_t pins[] = {
710 0x0f, 0x10, 0x14, 0x15, 0
713 for (p = pins; *p; p++)
714 set_eapd(codec, *p, on);
717 /* generic shutup callback;
718 * just turning off EPAD and a little pause for avoiding pop-noise
720 static void alc_eapd_shutup(struct hda_codec *codec)
722 alc_auto_setup_eapd(codec, false);
726 /* generic EAPD initialization */
727 static void alc_auto_init_amp(struct hda_codec *codec, int type)
731 alc_auto_setup_eapd(codec, true);
734 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
737 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
740 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
742 case ALC_INIT_DEFAULT:
743 switch (codec->vendor_id) {
745 snd_hda_codec_write(codec, 0x1a, 0,
746 AC_VERB_SET_COEF_INDEX, 7);
747 tmp = snd_hda_codec_read(codec, 0x1a, 0,
748 AC_VERB_GET_PROC_COEF, 0);
749 snd_hda_codec_write(codec, 0x1a, 0,
750 AC_VERB_SET_COEF_INDEX, 7);
751 snd_hda_codec_write(codec, 0x1a, 0,
752 AC_VERB_SET_PROC_COEF,
761 /*case 0x10ec0889:*/ /* this causes an SPDIF problem */
762 alc889_coef_init(codec);
765 alc888_coef_init(codec);
767 #if 0 /* XXX: This may cause the silent output on speaker on some machines */
770 snd_hda_codec_write(codec, 0x20, 0,
771 AC_VERB_SET_COEF_INDEX, 7);
772 tmp = snd_hda_codec_read(codec, 0x20, 0,
773 AC_VERB_GET_PROC_COEF, 0);
774 snd_hda_codec_write(codec, 0x20, 0,
775 AC_VERB_SET_COEF_INDEX, 7);
776 snd_hda_codec_write(codec, 0x20, 0,
777 AC_VERB_SET_PROC_COEF,
787 * Auto-Mute mode mixer enum support
789 static int alc_automute_mode_info(struct snd_kcontrol *kcontrol,
790 struct snd_ctl_elem_info *uinfo)
792 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
793 struct alc_spec *spec = codec->spec;
794 static const char * const texts2[] = {
795 "Disabled", "Enabled"
797 static const char * const texts3[] = {
798 "Disabled", "Speaker Only", "Line-Out+Speaker"
800 const char * const *texts;
802 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
804 if (spec->automute_speaker_possible && spec->automute_lo_possible) {
805 uinfo->value.enumerated.items = 3;
808 uinfo->value.enumerated.items = 2;
811 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
812 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
813 strcpy(uinfo->value.enumerated.name,
814 texts[uinfo->value.enumerated.item]);
818 static int alc_automute_mode_get(struct snd_kcontrol *kcontrol,
819 struct snd_ctl_elem_value *ucontrol)
821 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
822 struct alc_spec *spec = codec->spec;
823 unsigned int val = 0;
824 if (spec->automute_speaker)
826 if (spec->automute_lo)
829 ucontrol->value.enumerated.item[0] = val;
833 static int alc_automute_mode_put(struct snd_kcontrol *kcontrol,
834 struct snd_ctl_elem_value *ucontrol)
836 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
837 struct alc_spec *spec = codec->spec;
839 switch (ucontrol->value.enumerated.item[0]) {
841 if (!spec->automute_speaker && !spec->automute_lo)
843 spec->automute_speaker = 0;
844 spec->automute_lo = 0;
847 if (spec->automute_speaker_possible) {
848 if (!spec->automute_lo && spec->automute_speaker)
850 spec->automute_speaker = 1;
851 spec->automute_lo = 0;
852 } else if (spec->automute_lo_possible) {
853 if (spec->automute_lo)
855 spec->automute_lo = 1;
860 if (!spec->automute_lo_possible || !spec->automute_speaker_possible)
862 if (spec->automute_speaker && spec->automute_lo)
864 spec->automute_speaker = 1;
865 spec->automute_lo = 1;
870 call_update_outputs(codec);
874 static const struct snd_kcontrol_new alc_automute_mode_enum = {
875 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
876 .name = "Auto-Mute Mode",
877 .info = alc_automute_mode_info,
878 .get = alc_automute_mode_get,
879 .put = alc_automute_mode_put,
882 static struct snd_kcontrol_new *alc_kcontrol_new(struct alc_spec *spec)
884 snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32);
885 return snd_array_new(&spec->kctls);
888 static int alc_add_automute_mode_enum(struct hda_codec *codec)
890 struct alc_spec *spec = codec->spec;
891 struct snd_kcontrol_new *knew;
893 knew = alc_kcontrol_new(spec);
896 *knew = alc_automute_mode_enum;
897 knew->name = kstrdup("Auto-Mute Mode", GFP_KERNEL);
904 * Check the availability of HP/line-out auto-mute;
905 * Set up appropriately if really supported
907 static void alc_init_automute(struct hda_codec *codec)
909 struct alc_spec *spec = codec->spec;
910 struct auto_pin_cfg *cfg = &spec->autocfg;
916 if (cfg->line_out_pins[0])
918 if (cfg->speaker_pins[0])
920 if (present < 2) /* need two different output types */
923 if (!cfg->speaker_pins[0] &&
924 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
925 memcpy(cfg->speaker_pins, cfg->line_out_pins,
926 sizeof(cfg->speaker_pins));
927 cfg->speaker_outs = cfg->line_outs;
930 if (!cfg->hp_pins[0] &&
931 cfg->line_out_type == AUTO_PIN_HP_OUT) {
932 memcpy(cfg->hp_pins, cfg->line_out_pins,
933 sizeof(cfg->hp_pins));
934 cfg->hp_outs = cfg->line_outs;
937 spec->automute_mode = ALC_AUTOMUTE_PIN;
939 for (i = 0; i < cfg->hp_outs; i++) {
940 hda_nid_t nid = cfg->hp_pins[i];
941 if (!is_jack_detectable(codec, nid))
943 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
945 snd_hda_codec_write_cache(codec, nid, 0,
946 AC_VERB_SET_UNSOLICITED_ENABLE,
947 AC_USRSP_EN | ALC_HP_EVENT);
951 if (cfg->line_out_type == AUTO_PIN_LINE_OUT && cfg->line_outs) {
952 if (cfg->speaker_outs)
953 for (i = 0; i < cfg->line_outs; i++) {
954 hda_nid_t nid = cfg->line_out_pins[i];
955 if (!is_jack_detectable(codec, nid))
957 snd_printdd("realtek: Enable Line-Out "
958 "auto-muting on NID 0x%x\n", nid);
959 snd_hda_codec_write_cache(codec, nid, 0,
960 AC_VERB_SET_UNSOLICITED_ENABLE,
961 AC_USRSP_EN | ALC_FRONT_EVENT);
964 spec->automute_lo_possible = spec->detect_hp;
967 spec->automute_speaker_possible = cfg->speaker_outs &&
968 (spec->detect_hp || spec->detect_lo);
970 spec->automute_lo = spec->automute_lo_possible;
971 spec->automute_speaker = spec->automute_speaker_possible;
973 if (spec->automute_speaker_possible || spec->automute_lo_possible) {
974 /* create a control for automute mode */
975 alc_add_automute_mode_enum(codec);
976 spec->unsol_event = alc_sku_unsol_event;
980 /* return the position of NID in the list, or -1 if not found */
981 static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
984 for (i = 0; i < nums; i++)
990 /* check whether dynamic ADC-switching is available */
991 static bool alc_check_dyn_adc_switch(struct hda_codec *codec)
993 struct alc_spec *spec = codec->spec;
994 struct hda_input_mux *imux = &spec->private_imux[0];
998 if (imux != spec->input_mux) /* no dynamic imux? */
1001 for (n = 0; n < spec->num_adc_nids; n++) {
1002 cap = spec->private_capsrc_nids[n];
1003 for (i = 0; i < imux->num_items; i++) {
1004 pin = spec->imux_pins[i];
1007 if (get_connection_index(codec, cap, pin) < 0)
1010 if (i >= imux->num_items)
1011 return true; /* no ADC-switch is needed */
1014 for (i = 0; i < imux->num_items; i++) {
1015 pin = spec->imux_pins[i];
1016 for (n = 0; n < spec->num_adc_nids; n++) {
1017 cap = spec->private_capsrc_nids[n];
1018 idx = get_connection_index(codec, cap, pin);
1020 imux->items[i].index = idx;
1021 spec->dyn_adc_idx[i] = n;
1027 snd_printdd("realtek: enabling ADC switching\n");
1028 spec->dyn_adc_switch = 1;
1032 /* rebuild imux for matching with the given auto-mic pins (if not yet) */
1033 static bool alc_rebuild_imux_for_auto_mic(struct hda_codec *codec)
1035 struct alc_spec *spec = codec->spec;
1036 struct hda_input_mux *imux;
1037 static char * const texts[3] = {
1038 "Mic", "Internal Mic", "Dock Mic"
1042 if (!spec->auto_mic)
1044 imux = &spec->private_imux[0];
1045 if (spec->input_mux == imux)
1047 spec->imux_pins[0] = spec->ext_mic_pin;
1048 spec->imux_pins[1] = spec->int_mic_pin;
1049 spec->imux_pins[2] = spec->dock_mic_pin;
1050 for (i = 0; i < 3; i++) {
1051 strcpy(imux->items[i].label, texts[i]);
1052 if (spec->imux_pins[i])
1053 imux->num_items = i + 1;
1055 spec->num_mux_defs = 1;
1056 spec->input_mux = imux;
1060 /* check whether all auto-mic pins are valid; setup indices if OK */
1061 static bool alc_auto_mic_check_imux(struct hda_codec *codec)
1063 struct alc_spec *spec = codec->spec;
1064 const struct hda_input_mux *imux;
1066 if (!spec->auto_mic)
1068 if (spec->auto_mic_valid_imux)
1069 return true; /* already checked */
1071 /* fill up imux indices */
1072 if (!alc_check_dyn_adc_switch(codec)) {
1077 imux = spec->input_mux;
1078 spec->ext_mic_idx = find_idx_in_nid_list(spec->ext_mic_pin,
1079 spec->imux_pins, imux->num_items);
1080 spec->int_mic_idx = find_idx_in_nid_list(spec->int_mic_pin,
1081 spec->imux_pins, imux->num_items);
1082 spec->dock_mic_idx = find_idx_in_nid_list(spec->dock_mic_pin,
1083 spec->imux_pins, imux->num_items);
1084 if (spec->ext_mic_idx < 0 || spec->int_mic_idx < 0) {
1086 return false; /* no corresponding imux */
1089 snd_hda_codec_write_cache(codec, spec->ext_mic_pin, 0,
1090 AC_VERB_SET_UNSOLICITED_ENABLE,
1091 AC_USRSP_EN | ALC_MIC_EVENT);
1092 if (spec->dock_mic_pin)
1093 snd_hda_codec_write_cache(codec, spec->dock_mic_pin, 0,
1094 AC_VERB_SET_UNSOLICITED_ENABLE,
1095 AC_USRSP_EN | ALC_MIC_EVENT);
1097 spec->auto_mic_valid_imux = 1;
1103 * Check the availability of auto-mic switch;
1104 * Set up if really supported
1106 static void alc_init_auto_mic(struct hda_codec *codec)
1108 struct alc_spec *spec = codec->spec;
1109 struct auto_pin_cfg *cfg = &spec->autocfg;
1110 hda_nid_t fixed, ext, dock;
1113 spec->ext_mic_idx = spec->int_mic_idx = spec->dock_mic_idx = -1;
1115 fixed = ext = dock = 0;
1116 for (i = 0; i < cfg->num_inputs; i++) {
1117 hda_nid_t nid = cfg->inputs[i].pin;
1118 unsigned int defcfg;
1119 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1120 switch (snd_hda_get_input_pin_attr(defcfg)) {
1121 case INPUT_PIN_ATTR_INT:
1123 return; /* already occupied */
1124 if (cfg->inputs[i].type != AUTO_PIN_MIC)
1125 return; /* invalid type */
1128 case INPUT_PIN_ATTR_UNUSED:
1129 return; /* invalid entry */
1130 case INPUT_PIN_ATTR_DOCK:
1132 return; /* already occupied */
1133 if (cfg->inputs[i].type > AUTO_PIN_LINE_IN)
1134 return; /* invalid type */
1139 return; /* already occupied */
1140 if (cfg->inputs[i].type != AUTO_PIN_MIC)
1141 return; /* invalid type */
1152 if (!is_jack_detectable(codec, ext))
1153 return; /* no unsol support */
1154 if (dock && !is_jack_detectable(codec, dock))
1155 return; /* no unsol support */
1157 /* check imux indices */
1158 spec->ext_mic_pin = ext;
1159 spec->int_mic_pin = fixed;
1160 spec->dock_mic_pin = dock;
1163 if (!alc_auto_mic_check_imux(codec))
1166 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n",
1168 spec->unsol_event = alc_sku_unsol_event;
1171 /* check the availabilities of auto-mute and auto-mic switches */
1172 static void alc_auto_check_switches(struct hda_codec *codec)
1174 alc_init_automute(codec);
1175 alc_init_auto_mic(codec);
1179 * Realtek SSID verification
1182 /* Could be any non-zero and even value. When used as fixup, tells
1183 * the driver to ignore any present sku defines.
1185 #define ALC_FIXUP_SKU_IGNORE (2)
1187 static int alc_auto_parse_customize_define(struct hda_codec *codec)
1189 unsigned int ass, tmp, i;
1191 struct alc_spec *spec = codec->spec;
1193 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1195 if (spec->cdefine.fixup) {
1196 ass = spec->cdefine.sku_cfg;
1197 if (ass == ALC_FIXUP_SKU_IGNORE)
1202 ass = codec->subsystem_id & 0xffff;
1203 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
1207 if (codec->vendor_id == 0x10ec0260)
1209 ass = snd_hda_codec_get_pincfg(codec, nid);
1212 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1213 codec->chip_name, ass);
1219 for (i = 1; i < 16; i++) {
1223 if (((ass >> 16) & 0xf) != tmp)
1226 spec->cdefine.port_connectivity = ass >> 30;
1227 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1228 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1229 spec->cdefine.customization = ass >> 8;
1231 spec->cdefine.sku_cfg = ass;
1232 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1233 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1234 spec->cdefine.swap = (ass & 0x2) >> 1;
1235 spec->cdefine.override = ass & 0x1;
1237 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1238 nid, spec->cdefine.sku_cfg);
1239 snd_printd("SKU: port_connectivity=0x%x\n",
1240 spec->cdefine.port_connectivity);
1241 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1242 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1243 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1244 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1245 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1246 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1247 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1252 /* return true if the given NID is found in the list */
1253 static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
1255 return find_idx_in_nid_list(nid, list, nums) >= 0;
1258 /* check subsystem ID and set up device-specific initialization;
1259 * return 1 if initialized, 0 if invalid SSID
1261 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1262 * 31 ~ 16 : Manufacture ID
1264 * 7 ~ 0 : Assembly ID
1265 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1267 static int alc_subsystem_id(struct hda_codec *codec,
1268 hda_nid_t porta, hda_nid_t porte,
1269 hda_nid_t portd, hda_nid_t porti)
1271 unsigned int ass, tmp, i;
1273 struct alc_spec *spec = codec->spec;
1275 if (spec->cdefine.fixup) {
1276 ass = spec->cdefine.sku_cfg;
1277 if (ass == ALC_FIXUP_SKU_IGNORE)
1282 ass = codec->subsystem_id & 0xffff;
1283 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1286 /* invalid SSID, check the special NID pin defcfg instead */
1288 * 31~30 : port connectivity
1291 * 19~16 : Check sum (15:1)
1296 if (codec->vendor_id == 0x10ec0260)
1298 ass = snd_hda_codec_get_pincfg(codec, nid);
1299 snd_printd("realtek: No valid SSID, "
1300 "checking pincfg 0x%08x for NID 0x%x\n",
1304 if ((ass >> 30) != 1) /* no physical connection */
1309 for (i = 1; i < 16; i++) {
1313 if (((ass >> 16) & 0xf) != tmp)
1316 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1317 ass & 0xffff, codec->vendor_id);
1321 * 2 : 0 --> Desktop, 1 --> Laptop
1322 * 3~5 : External Amplifier control
1325 tmp = (ass & 0x38) >> 3; /* external Amp control */
1328 spec->init_amp = ALC_INIT_GPIO1;
1331 spec->init_amp = ALC_INIT_GPIO2;
1334 spec->init_amp = ALC_INIT_GPIO3;
1338 spec->init_amp = ALC_INIT_DEFAULT;
1342 /* is laptop or Desktop and enable the function "Mute internal speaker
1343 * when the external headphone out jack is plugged"
1345 if (!(ass & 0x8000))
1348 * 10~8 : Jack location
1349 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1351 * 15 : 1 --> enable the function "Mute internal speaker
1352 * when the external headphone out jack is plugged"
1354 if (!spec->autocfg.hp_pins[0] &&
1355 !(spec->autocfg.line_out_pins[0] &&
1356 spec->autocfg.line_out_type == AUTO_PIN_HP_OUT)) {
1358 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1369 if (found_in_nid_list(nid, spec->autocfg.line_out_pins,
1370 spec->autocfg.line_outs))
1372 spec->autocfg.hp_pins[0] = nid;
1377 /* Check the validity of ALC subsystem-id
1378 * ports contains an array of 4 pin NIDs for port-A, E, D and I */
1379 static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports)
1381 if (!alc_subsystem_id(codec, ports[0], ports[1], ports[2], ports[3])) {
1382 struct alc_spec *spec = codec->spec;
1383 snd_printd("realtek: "
1384 "Enable default setup for auto mode as fallback\n");
1385 spec->init_amp = ALC_INIT_DEFAULT;
1390 * Fix-up pin default configurations and add default verbs
1398 struct alc_model_fixup {
1409 const struct alc_pincfg *pins;
1410 const struct hda_verb *verbs;
1411 void (*func)(struct hda_codec *codec,
1412 const struct alc_fixup *fix,
1426 ALC_FIXUP_ACT_PRE_PROBE,
1427 ALC_FIXUP_ACT_PROBE,
1431 static void alc_apply_fixup(struct hda_codec *codec, int action)
1433 struct alc_spec *spec = codec->spec;
1434 int id = spec->fixup_id;
1435 #ifdef CONFIG_SND_DEBUG_VERBOSE
1436 const char *modelname = spec->fixup_name;
1440 if (!spec->fixup_list)
1444 const struct alc_fixup *fix = spec->fixup_list + id;
1445 const struct alc_pincfg *cfg;
1447 switch (fix->type) {
1449 if (action != ALC_FIXUP_ACT_PRE_PROBE || !fix->v.sku)
1451 snd_printdd(KERN_INFO "hda_codec: %s: "
1452 "Apply sku override for %s\n",
1453 codec->chip_name, modelname);
1454 spec->cdefine.sku_cfg = fix->v.sku;
1455 spec->cdefine.fixup = 1;
1457 case ALC_FIXUP_PINS:
1459 if (action != ALC_FIXUP_ACT_PRE_PROBE || !cfg)
1461 snd_printdd(KERN_INFO "hda_codec: %s: "
1462 "Apply pincfg for %s\n",
1463 codec->chip_name, modelname);
1464 for (; cfg->nid; cfg++)
1465 snd_hda_codec_set_pincfg(codec, cfg->nid,
1468 case ALC_FIXUP_VERBS:
1469 if (action != ALC_FIXUP_ACT_PROBE || !fix->v.verbs)
1471 snd_printdd(KERN_INFO "hda_codec: %s: "
1472 "Apply fix-verbs for %s\n",
1473 codec->chip_name, modelname);
1474 add_verb(codec->spec, fix->v.verbs);
1476 case ALC_FIXUP_FUNC:
1479 snd_printdd(KERN_INFO "hda_codec: %s: "
1480 "Apply fix-func for %s\n",
1481 codec->chip_name, modelname);
1482 fix->v.func(codec, fix, action);
1485 snd_printk(KERN_ERR "hda_codec: %s: "
1486 "Invalid fixup type %d\n",
1487 codec->chip_name, fix->type);
1498 static void alc_pick_fixup(struct hda_codec *codec,
1499 const struct alc_model_fixup *models,
1500 const struct snd_pci_quirk *quirk,
1501 const struct alc_fixup *fixlist)
1503 struct alc_spec *spec = codec->spec;
1505 const char *name = NULL;
1507 if (codec->modelname && models) {
1508 while (models->name) {
1509 if (!strcmp(codec->modelname, models->name)) {
1511 name = models->name;
1518 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1521 #ifdef CONFIG_SND_DEBUG_VERBOSE
1527 spec->fixup_id = id;
1529 spec->fixup_list = fixlist;
1530 spec->fixup_name = name;
1535 * COEF access helper functions
1537 static int alc_read_coef_idx(struct hda_codec *codec,
1538 unsigned int coef_idx)
1541 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1543 val = snd_hda_codec_read(codec, 0x20, 0,
1544 AC_VERB_GET_PROC_COEF, 0);
1548 static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
1549 unsigned int coef_val)
1551 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1553 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
1558 * Digital I/O handling
1561 /* set right pin controls for digital I/O */
1562 static void alc_auto_init_digital(struct hda_codec *codec)
1564 struct alc_spec *spec = codec->spec;
1568 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1569 pin = spec->autocfg.dig_out_pins[i];
1572 snd_hda_codec_write(codec, pin, 0,
1573 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
1575 dac = spec->multiout.dig_out_nid;
1577 dac = spec->slave_dig_outs[i - 1];
1578 if (!dac || !(get_wcaps(codec, dac) & AC_WCAP_OUT_AMP))
1580 snd_hda_codec_write(codec, dac, 0,
1581 AC_VERB_SET_AMP_GAIN_MUTE,
1584 pin = spec->autocfg.dig_in_pin;
1586 snd_hda_codec_write(codec, pin, 0,
1587 AC_VERB_SET_PIN_WIDGET_CONTROL,
1591 /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1592 static void alc_auto_parse_digital(struct hda_codec *codec)
1594 struct alc_spec *spec = codec->spec;
1598 /* support multiple SPDIFs; the secondary is set up as a slave */
1599 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1601 err = snd_hda_get_connections(codec,
1602 spec->autocfg.dig_out_pins[i],
1603 conn, ARRAY_SIZE(conn));
1606 dig_nid = conn[0]; /* assume the first element is audio-out */
1608 spec->multiout.dig_out_nid = dig_nid;
1609 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1611 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1612 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1614 spec->slave_dig_outs[i - 1] = dig_nid;
1618 if (spec->autocfg.dig_in_pin) {
1619 dig_nid = codec->start_nid;
1620 for (i = 0; i < codec->num_nodes; i++, dig_nid++) {
1621 unsigned int wcaps = get_wcaps(codec, dig_nid);
1622 if (get_wcaps_type(wcaps) != AC_WID_AUD_IN)
1624 if (!(wcaps & AC_WCAP_DIGITAL))
1626 if (!(wcaps & AC_WCAP_CONN_LIST))
1628 err = get_connection_index(codec, dig_nid,
1629 spec->autocfg.dig_in_pin);
1631 spec->dig_in_nid = dig_nid;
1639 * capture mixer elements
1641 static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1642 struct snd_ctl_elem_info *uinfo)
1644 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1645 struct alc_spec *spec = codec->spec;
1649 mutex_lock(&codec->control_mutex);
1650 if (spec->vol_in_capsrc)
1651 val = HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[0], 3, 0, HDA_OUTPUT);
1653 val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, HDA_INPUT);
1654 kcontrol->private_value = val;
1655 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
1656 mutex_unlock(&codec->control_mutex);
1660 static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1661 unsigned int size, unsigned int __user *tlv)
1663 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1664 struct alc_spec *spec = codec->spec;
1668 mutex_lock(&codec->control_mutex);
1669 if (spec->vol_in_capsrc)
1670 val = HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[0], 3, 0, HDA_OUTPUT);
1672 val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, HDA_INPUT);
1673 kcontrol->private_value = val;
1674 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
1675 mutex_unlock(&codec->control_mutex);
1679 typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1680 struct snd_ctl_elem_value *ucontrol);
1682 static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1683 struct snd_ctl_elem_value *ucontrol,
1684 getput_call_t func, bool check_adc_switch)
1686 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1687 struct alc_spec *spec = codec->spec;
1690 mutex_lock(&codec->control_mutex);
1691 if (check_adc_switch && spec->dyn_adc_switch) {
1692 for (i = 0; i < spec->num_adc_nids; i++) {
1693 kcontrol->private_value =
1694 HDA_COMPOSE_AMP_VAL(spec->adc_nids[i],
1696 err = func(kcontrol, ucontrol);
1701 i = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1702 if (spec->vol_in_capsrc)
1703 kcontrol->private_value =
1704 HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[i],
1707 kcontrol->private_value =
1708 HDA_COMPOSE_AMP_VAL(spec->adc_nids[i],
1710 err = func(kcontrol, ucontrol);
1713 mutex_unlock(&codec->control_mutex);
1717 static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1718 struct snd_ctl_elem_value *ucontrol)
1720 return alc_cap_getput_caller(kcontrol, ucontrol,
1721 snd_hda_mixer_amp_volume_get, false);
1724 static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1725 struct snd_ctl_elem_value *ucontrol)
1727 return alc_cap_getput_caller(kcontrol, ucontrol,
1728 snd_hda_mixer_amp_volume_put, true);
1731 /* capture mixer elements */
1732 #define alc_cap_sw_info snd_ctl_boolean_stereo_info
1734 static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1735 struct snd_ctl_elem_value *ucontrol)
1737 return alc_cap_getput_caller(kcontrol, ucontrol,
1738 snd_hda_mixer_amp_switch_get, false);
1741 static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1742 struct snd_ctl_elem_value *ucontrol)
1744 return alc_cap_getput_caller(kcontrol, ucontrol,
1745 snd_hda_mixer_amp_switch_put, true);
1748 #define _DEFINE_CAPMIX(num) \
1750 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1751 .name = "Capture Switch", \
1752 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1754 .info = alc_cap_sw_info, \
1755 .get = alc_cap_sw_get, \
1756 .put = alc_cap_sw_put, \
1759 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1760 .name = "Capture Volume", \
1761 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1762 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1763 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1765 .info = alc_cap_vol_info, \
1766 .get = alc_cap_vol_get, \
1767 .put = alc_cap_vol_put, \
1768 .tlv = { .c = alc_cap_vol_tlv }, \
1771 #define _DEFINE_CAPSRC(num) \
1773 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1774 /* .name = "Capture Source", */ \
1775 .name = "Input Source", \
1777 .info = alc_mux_enum_info, \
1778 .get = alc_mux_enum_get, \
1779 .put = alc_mux_enum_put, \
1782 #define DEFINE_CAPMIX(num) \
1783 static const struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1784 _DEFINE_CAPMIX(num), \
1785 _DEFINE_CAPSRC(num), \
1789 #define DEFINE_CAPMIX_NOSRC(num) \
1790 static const struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
1791 _DEFINE_CAPMIX(num), \
1795 /* up to three ADCs */
1799 DEFINE_CAPMIX_NOSRC(1);
1800 DEFINE_CAPMIX_NOSRC(2);
1801 DEFINE_CAPMIX_NOSRC(3);
1804 * virtual master controls
1808 * slave controls for virtual master
1810 static const char * const alc_slave_vols[] = {
1811 "Front Playback Volume",
1812 "Surround Playback Volume",
1813 "Center Playback Volume",
1814 "LFE Playback Volume",
1815 "Side Playback Volume",
1816 "Headphone Playback Volume",
1817 "Speaker Playback Volume",
1818 "Mono Playback Volume",
1819 "Line-Out Playback Volume",
1820 "PCM Playback Volume",
1824 static const char * const alc_slave_sws[] = {
1825 "Front Playback Switch",
1826 "Surround Playback Switch",
1827 "Center Playback Switch",
1828 "LFE Playback Switch",
1829 "Side Playback Switch",
1830 "Headphone Playback Switch",
1831 "Speaker Playback Switch",
1832 "Mono Playback Switch",
1833 "IEC958 Playback Switch",
1834 "Line-Out Playback Switch",
1835 "PCM Playback Switch",
1840 * build control elements
1843 #define NID_MAPPING (-1)
1845 #define SUBDEV_SPEAKER_ (0 << 6)
1846 #define SUBDEV_HP_ (1 << 6)
1847 #define SUBDEV_LINE_ (2 << 6)
1848 #define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
1849 #define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
1850 #define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
1852 static void alc_free_kctls(struct hda_codec *codec);
1854 #ifdef CONFIG_SND_HDA_INPUT_BEEP
1855 /* additional beep mixers; the actual parameters are overwritten at build */
1856 static const struct snd_kcontrol_new alc_beep_mixer[] = {
1857 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
1858 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
1863 static int alc_build_controls(struct hda_codec *codec)
1865 struct alc_spec *spec = codec->spec;
1866 struct snd_kcontrol *kctl = NULL;
1867 const struct snd_kcontrol_new *knew;
1872 for (i = 0; i < spec->num_mixers; i++) {
1873 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1877 if (spec->cap_mixer) {
1878 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
1882 if (spec->multiout.dig_out_nid) {
1883 err = snd_hda_create_spdif_out_ctls(codec,
1884 spec->multiout.dig_out_nid,
1885 spec->multiout.dig_out_nid);
1888 if (!spec->no_analog) {
1889 err = snd_hda_create_spdif_share_sw(codec,
1893 spec->multiout.share_spdif = 1;
1896 if (spec->dig_in_nid) {
1897 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1902 #ifdef CONFIG_SND_HDA_INPUT_BEEP
1903 /* create beep controls if needed */
1904 if (spec->beep_amp) {
1905 const struct snd_kcontrol_new *knew;
1906 for (knew = alc_beep_mixer; knew->name; knew++) {
1907 struct snd_kcontrol *kctl;
1908 kctl = snd_ctl_new1(knew, codec);
1911 kctl->private_value = spec->beep_amp;
1912 err = snd_hda_ctl_add(codec, 0, kctl);
1919 /* if we have no master control, let's create it */
1920 if (!spec->no_analog &&
1921 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1922 unsigned int vmaster_tlv[4];
1923 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
1924 HDA_OUTPUT, vmaster_tlv);
1925 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1926 vmaster_tlv, alc_slave_vols);
1930 if (!spec->no_analog &&
1931 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1932 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1933 NULL, alc_slave_sws);
1938 /* assign Capture Source enums to NID */
1939 if (spec->capsrc_nids || spec->adc_nids) {
1940 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
1942 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
1943 for (i = 0; kctl && i < kctl->count; i++) {
1944 const hda_nid_t *nids = spec->capsrc_nids;
1946 nids = spec->adc_nids;
1947 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
1952 if (spec->cap_mixer && spec->adc_nids) {
1953 const char *kname = kctl ? kctl->id.name : NULL;
1954 for (knew = spec->cap_mixer; knew->name; knew++) {
1955 if (kname && strcmp(knew->name, kname) == 0)
1957 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
1958 for (i = 0; kctl && i < kctl->count; i++) {
1959 err = snd_hda_add_nid(codec, kctl, i,
1967 /* other nid->control mapping */
1968 for (i = 0; i < spec->num_mixers; i++) {
1969 for (knew = spec->mixers[i]; knew->name; knew++) {
1970 if (knew->iface != NID_MAPPING)
1972 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
1975 u = knew->subdevice;
1976 for (j = 0; j < 4; j++, u >>= 8) {
1981 case SUBDEV_SPEAKER_:
1982 nid = spec->autocfg.speaker_pins[nid];
1985 nid = spec->autocfg.line_out_pins[nid];
1988 nid = spec->autocfg.hp_pins[nid];
1993 err = snd_hda_add_nid(codec, kctl, 0, nid);
1997 u = knew->private_value;
1998 for (j = 0; j < 4; j++, u >>= 8) {
2002 err = snd_hda_add_nid(codec, kctl, 0, nid);
2009 alc_free_kctls(codec); /* no longer needed */
2019 static void alc_init_special_input_src(struct hda_codec *codec);
2021 static int alc_init(struct hda_codec *codec)
2023 struct alc_spec *spec = codec->spec;
2027 alc_auto_init_amp(codec, spec->init_amp);
2029 for (i = 0; i < spec->num_init_verbs; i++)
2030 snd_hda_sequence_write(codec, spec->init_verbs[i]);
2031 alc_init_special_input_src(codec);
2033 if (spec->init_hook)
2034 spec->init_hook(codec);
2036 alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT);
2038 hda_call_check_power_status(codec, 0x01);
2042 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2044 struct alc_spec *spec = codec->spec;
2046 if (spec->unsol_event)
2047 spec->unsol_event(codec, res);
2050 #ifdef CONFIG_SND_HDA_POWER_SAVE
2051 static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2053 struct alc_spec *spec = codec->spec;
2054 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2059 * Analog playback callbacks
2061 static int alc_playback_pcm_open(struct hda_pcm_stream *hinfo,
2062 struct hda_codec *codec,
2063 struct snd_pcm_substream *substream)
2065 struct alc_spec *spec = codec->spec;
2066 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2070 static int alc_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2071 struct hda_codec *codec,
2072 unsigned int stream_tag,
2073 unsigned int format,
2074 struct snd_pcm_substream *substream)
2076 struct alc_spec *spec = codec->spec;
2077 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2078 stream_tag, format, substream);
2081 static int alc_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2082 struct hda_codec *codec,
2083 struct snd_pcm_substream *substream)
2085 struct alc_spec *spec = codec->spec;
2086 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2092 static int alc_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2093 struct hda_codec *codec,
2094 struct snd_pcm_substream *substream)
2096 struct alc_spec *spec = codec->spec;
2097 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2100 static int alc_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2101 struct hda_codec *codec,
2102 unsigned int stream_tag,
2103 unsigned int format,
2104 struct snd_pcm_substream *substream)
2106 struct alc_spec *spec = codec->spec;
2107 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2108 stream_tag, format, substream);
2111 static int alc_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2112 struct hda_codec *codec,
2113 struct snd_pcm_substream *substream)
2115 struct alc_spec *spec = codec->spec;
2116 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2119 static int alc_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2120 struct hda_codec *codec,
2121 struct snd_pcm_substream *substream)
2123 struct alc_spec *spec = codec->spec;
2124 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2130 static int alc_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2131 struct hda_codec *codec,
2132 unsigned int stream_tag,
2133 unsigned int format,
2134 struct snd_pcm_substream *substream)
2136 struct alc_spec *spec = codec->spec;
2138 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
2139 stream_tag, 0, format);
2143 static int alc_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2144 struct hda_codec *codec,
2145 struct snd_pcm_substream *substream)
2147 struct alc_spec *spec = codec->spec;
2149 snd_hda_codec_cleanup_stream(codec,
2150 spec->adc_nids[substream->number + 1]);
2154 /* analog capture with dynamic dual-adc changes */
2155 static int dyn_adc_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2156 struct hda_codec *codec,
2157 unsigned int stream_tag,
2158 unsigned int format,
2159 struct snd_pcm_substream *substream)
2161 struct alc_spec *spec = codec->spec;
2162 spec->cur_adc = spec->adc_nids[spec->dyn_adc_idx[spec->cur_mux[0]]];
2163 spec->cur_adc_stream_tag = stream_tag;
2164 spec->cur_adc_format = format;
2165 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
2169 static int dyn_adc_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2170 struct hda_codec *codec,
2171 struct snd_pcm_substream *substream)
2173 struct alc_spec *spec = codec->spec;
2174 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
2179 static const struct hda_pcm_stream dyn_adc_pcm_analog_capture = {
2183 .nid = 0, /* fill later */
2185 .prepare = dyn_adc_capture_pcm_prepare,
2186 .cleanup = dyn_adc_capture_pcm_cleanup
2192 static const struct hda_pcm_stream alc_pcm_analog_playback = {
2196 /* NID is set in alc_build_pcms */
2198 .open = alc_playback_pcm_open,
2199 .prepare = alc_playback_pcm_prepare,
2200 .cleanup = alc_playback_pcm_cleanup
2204 static const struct hda_pcm_stream alc_pcm_analog_capture = {
2208 /* NID is set in alc_build_pcms */
2211 static const struct hda_pcm_stream alc_pcm_analog_alt_playback = {
2215 /* NID is set in alc_build_pcms */
2218 static const struct hda_pcm_stream alc_pcm_analog_alt_capture = {
2219 .substreams = 2, /* can be overridden */
2222 /* NID is set in alc_build_pcms */
2224 .prepare = alc_alt_capture_pcm_prepare,
2225 .cleanup = alc_alt_capture_pcm_cleanup
2229 static const struct hda_pcm_stream alc_pcm_digital_playback = {
2233 /* NID is set in alc_build_pcms */
2235 .open = alc_dig_playback_pcm_open,
2236 .close = alc_dig_playback_pcm_close,
2237 .prepare = alc_dig_playback_pcm_prepare,
2238 .cleanup = alc_dig_playback_pcm_cleanup
2242 static const struct hda_pcm_stream alc_pcm_digital_capture = {
2246 /* NID is set in alc_build_pcms */
2249 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
2250 static const struct hda_pcm_stream alc_pcm_null_stream = {
2256 static int alc_build_pcms(struct hda_codec *codec)
2258 struct alc_spec *spec = codec->spec;
2259 struct hda_pcm *info = spec->pcm_rec;
2260 const struct hda_pcm_stream *p;
2263 codec->num_pcms = 1;
2264 codec->pcm_info = info;
2266 if (spec->no_analog)
2269 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
2270 "%s Analog", codec->chip_name);
2271 info->name = spec->stream_name_analog;
2273 if (spec->multiout.dac_nids > 0) {
2274 p = spec->stream_analog_playback;
2276 p = &alc_pcm_analog_playback;
2277 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p;
2278 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2280 if (spec->adc_nids) {
2281 p = spec->stream_analog_capture;
2283 if (spec->dyn_adc_switch)
2284 p = &dyn_adc_pcm_analog_capture;
2286 p = &alc_pcm_analog_capture;
2288 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p;
2289 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2292 if (spec->channel_mode) {
2293 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2294 for (i = 0; i < spec->num_channel_mode; i++) {
2295 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2296 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2302 /* SPDIF for stream index #1 */
2303 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2304 snprintf(spec->stream_name_digital,
2305 sizeof(spec->stream_name_digital),
2306 "%s Digital", codec->chip_name);
2307 codec->num_pcms = 2;
2308 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
2309 info = spec->pcm_rec + 1;
2310 info->name = spec->stream_name_digital;
2311 if (spec->dig_out_type)
2312 info->pcm_type = spec->dig_out_type;
2314 info->pcm_type = HDA_PCM_TYPE_SPDIF;
2315 if (spec->multiout.dig_out_nid) {
2316 p = spec->stream_digital_playback;
2318 p = &alc_pcm_digital_playback;
2319 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p;
2320 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2322 if (spec->dig_in_nid) {
2323 p = spec->stream_digital_capture;
2325 p = &alc_pcm_digital_capture;
2326 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p;
2327 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2329 /* FIXME: do we need this for all Realtek codec models? */
2330 codec->spdif_status_reset = 1;
2333 if (spec->no_analog)
2336 /* If the use of more than one ADC is requested for the current
2337 * model, configure a second analog capture-only PCM.
2339 /* Additional Analaog capture for index #2 */
2340 if (spec->alt_dac_nid || spec->num_adc_nids > 1) {
2341 codec->num_pcms = 3;
2342 info = spec->pcm_rec + 2;
2343 info->name = spec->stream_name_analog;
2344 if (spec->alt_dac_nid) {
2345 p = spec->stream_analog_alt_playback;
2347 p = &alc_pcm_analog_alt_playback;
2348 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p;
2349 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2352 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2353 alc_pcm_null_stream;
2354 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2356 if (spec->num_adc_nids > 1) {
2357 p = spec->stream_analog_alt_capture;
2359 p = &alc_pcm_analog_alt_capture;
2360 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p;
2361 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2363 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2364 spec->num_adc_nids - 1;
2366 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2367 alc_pcm_null_stream;
2368 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
2375 static inline void alc_shutup(struct hda_codec *codec)
2377 struct alc_spec *spec = codec->spec;
2379 if (spec && spec->shutup)
2380 spec->shutup(codec);
2381 snd_hda_shutup_pins(codec);
2384 static void alc_free_kctls(struct hda_codec *codec)
2386 struct alc_spec *spec = codec->spec;
2388 if (spec->kctls.list) {
2389 struct snd_kcontrol_new *kctl = spec->kctls.list;
2391 for (i = 0; i < spec->kctls.used; i++)
2392 kfree(kctl[i].name);
2394 snd_array_free(&spec->kctls);
2397 static void alc_free_bind_ctls(struct hda_codec *codec)
2399 struct alc_spec *spec = codec->spec;
2400 if (spec->bind_ctls.list) {
2401 struct hda_bind_ctls **ctl = spec->bind_ctls.list;
2403 for (i = 0; i < spec->bind_ctls.used; i++)
2406 snd_array_free(&spec->bind_ctls);
2409 static void alc_free(struct hda_codec *codec)
2411 struct alc_spec *spec = codec->spec;
2417 snd_hda_input_jack_free(codec);
2418 alc_free_kctls(codec);
2419 alc_free_bind_ctls(codec);
2421 snd_hda_detach_beep_device(codec);
2424 #ifdef CONFIG_SND_HDA_POWER_SAVE
2425 static void alc_power_eapd(struct hda_codec *codec)
2427 alc_auto_setup_eapd(codec, false);
2430 static int alc_suspend(struct hda_codec *codec, pm_message_t state)
2432 struct alc_spec *spec = codec->spec;
2434 if (spec && spec->power_hook)
2435 spec->power_hook(codec);
2441 static int alc_resume(struct hda_codec *codec)
2443 msleep(150); /* to avoid pop noise */
2444 codec->patch_ops.init(codec);
2445 snd_hda_codec_resume_amp(codec);
2446 snd_hda_codec_resume_cache(codec);
2447 hda_call_check_power_status(codec, 0x01);
2454 static const struct hda_codec_ops alc_patch_ops = {
2455 .build_controls = alc_build_controls,
2456 .build_pcms = alc_build_pcms,
2459 .unsol_event = alc_unsol_event,
2461 .resume = alc_resume,
2463 #ifdef CONFIG_SND_HDA_POWER_SAVE
2464 .suspend = alc_suspend,
2465 .check_power_status = alc_check_power_status,
2467 .reboot_notify = alc_shutup,
2470 /* replace the codec chip_name with the given string */
2471 static int alc_codec_rename(struct hda_codec *codec, const char *name)
2473 kfree(codec->chip_name);
2474 codec->chip_name = kstrdup(name, GFP_KERNEL);
2475 if (!codec->chip_name) {
2483 * Automatic parse of I/O pins from the BIOS configuration
2488 ALC_CTL_WIDGET_MUTE,
2493 static const struct snd_kcontrol_new alc_control_templates[] = {
2494 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2495 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2496 HDA_BIND_MUTE(NULL, 0, 0, 0),
2497 HDA_BIND_VOL(NULL, 0),
2498 HDA_BIND_SW(NULL, 0),
2501 /* add dynamic controls */
2502 static int add_control(struct alc_spec *spec, int type, const char *name,
2503 int cidx, unsigned long val)
2505 struct snd_kcontrol_new *knew;
2507 knew = alc_kcontrol_new(spec);
2510 *knew = alc_control_templates[type];
2511 knew->name = kstrdup(name, GFP_KERNEL);
2515 if (get_amp_nid_(val))
2516 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
2517 knew->private_value = val;
2521 static int add_control_with_pfx(struct alc_spec *spec, int type,
2522 const char *pfx, const char *dir,
2523 const char *sfx, int cidx, unsigned long val)
2526 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
2527 return add_control(spec, type, name, cidx, val);
2530 #define add_pb_vol_ctrl(spec, type, pfx, val) \
2531 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
2532 #define add_pb_sw_ctrl(spec, type, pfx, val) \
2533 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
2534 #define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
2535 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
2536 #define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
2537 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
2539 static const char * const channel_name[4] = {
2540 "Front", "Surround", "CLFE", "Side"
2543 static const char *alc_get_line_out_pfx(struct alc_spec *spec, int ch,
2544 bool can_be_master, int *index)
2546 struct auto_pin_cfg *cfg = &spec->autocfg;
2549 if (cfg->line_outs == 1 && !spec->multi_ios &&
2550 !cfg->hp_outs && !cfg->speaker_outs && can_be_master)
2553 switch (cfg->line_out_type) {
2554 case AUTO_PIN_SPEAKER_OUT:
2555 if (cfg->line_outs == 1)
2558 case AUTO_PIN_HP_OUT:
2559 /* for multi-io case, only the primary out */
2560 if (ch && spec->multi_ios)
2565 if (cfg->line_outs == 1 && !spec->multi_ios)
2569 if (snd_BUG_ON(ch >= ARRAY_SIZE(channel_name)))
2572 return channel_name[ch];
2575 /* create input playback/capture controls for the given pin */
2576 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
2577 const char *ctlname, int ctlidx,
2578 int idx, hda_nid_t mix_nid)
2582 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx,
2583 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
2586 err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx,
2587 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
2593 static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
2595 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
2596 return (pincap & AC_PINCAP_IN) != 0;
2599 /* Parse the codec tree and retrieve ADCs and corresponding capsrc MUXs */
2600 static int alc_auto_fill_adc_caps(struct hda_codec *codec)
2602 struct alc_spec *spec = codec->spec;
2604 hda_nid_t *adc_nids = spec->private_adc_nids;
2605 hda_nid_t *cap_nids = spec->private_capsrc_nids;
2606 int max_nums = ARRAY_SIZE(spec->private_adc_nids);
2607 bool indep_capsrc = false;
2610 nid = codec->start_nid;
2611 for (i = 0; i < codec->num_nodes; i++, nid++) {
2613 const hda_nid_t *list;
2614 unsigned int caps = get_wcaps(codec, nid);
2615 int type = get_wcaps_type(caps);
2617 if (type != AC_WID_AUD_IN || (caps & AC_WCAP_DIGITAL))
2619 adc_nids[nums] = nid;
2620 cap_nids[nums] = nid;
2624 type = get_wcaps_type(get_wcaps(codec, src));
2625 if (type == AC_WID_PIN)
2627 if (type == AC_WID_AUD_SEL) {
2628 cap_nids[nums] = src;
2629 indep_capsrc = true;
2632 n = snd_hda_get_conn_list(codec, src, &list);
2634 cap_nids[nums] = src;
2635 indep_capsrc = true;
2641 if (++nums >= max_nums)
2644 spec->adc_nids = spec->private_adc_nids;
2645 spec->capsrc_nids = spec->private_capsrc_nids;
2646 spec->num_adc_nids = nums;
2650 /* create playback/capture controls for input pins */
2651 static int alc_auto_create_input_ctls(struct hda_codec *codec)
2653 struct alc_spec *spec = codec->spec;
2654 const struct auto_pin_cfg *cfg = &spec->autocfg;
2655 hda_nid_t mixer = spec->mixer_nid;
2656 struct hda_input_mux *imux = &spec->private_imux[0];
2658 int i, c, err, idx, type_idx = 0;
2659 const char *prev_label = NULL;
2661 num_adcs = alc_auto_fill_adc_caps(codec);
2665 for (i = 0; i < cfg->num_inputs; i++) {
2669 pin = cfg->inputs[i].pin;
2670 if (!alc_is_input_pin(codec, pin))
2673 label = hda_get_autocfg_input_label(codec, cfg, i);
2674 if (prev_label && !strcmp(label, prev_label))
2681 idx = get_connection_index(codec, mixer, pin);
2683 err = new_analog_input(spec, pin,
2691 for (c = 0; c < num_adcs; c++) {
2692 hda_nid_t cap = spec->capsrc_nids ?
2693 spec->capsrc_nids[c] : spec->adc_nids[c];
2694 idx = get_connection_index(codec, cap, pin);
2696 spec->imux_pins[imux->num_items] = pin;
2697 snd_hda_add_imux_item(imux, label, idx, NULL);
2703 spec->num_mux_defs = 1;
2704 spec->input_mux = imux;
2709 static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
2710 unsigned int pin_type)
2712 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2715 if (nid_has_mute(codec, nid, HDA_OUTPUT))
2716 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2720 static int get_pin_type(int line_out_type)
2722 if (line_out_type == AUTO_PIN_HP_OUT)
2728 static void alc_auto_init_analog_input(struct hda_codec *codec)
2730 struct alc_spec *spec = codec->spec;
2731 struct auto_pin_cfg *cfg = &spec->autocfg;
2734 for (i = 0; i < cfg->num_inputs; i++) {
2735 hda_nid_t nid = cfg->inputs[i].pin;
2736 if (alc_is_input_pin(codec, nid)) {
2737 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
2738 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
2739 snd_hda_codec_write(codec, nid, 0,
2740 AC_VERB_SET_AMP_GAIN_MUTE,
2745 /* mute all loopback inputs */
2746 if (spec->mixer_nid) {
2747 int nums = snd_hda_get_conn_list(codec, spec->mixer_nid, NULL);
2748 for (i = 0; i < nums; i++)
2749 snd_hda_codec_write(codec, spec->mixer_nid, 0,
2750 AC_VERB_SET_AMP_GAIN_MUTE,
2755 /* convert from MIX nid to DAC */
2756 static hda_nid_t alc_auto_mix_to_dac(struct hda_codec *codec, hda_nid_t nid)
2761 if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_AUD_OUT)
2763 num = snd_hda_get_connections(codec, nid, list, ARRAY_SIZE(list));
2764 for (i = 0; i < num; i++) {
2765 if (get_wcaps_type(get_wcaps(codec, list[i])) == AC_WID_AUD_OUT)
2771 /* go down to the selector widget before the mixer */
2772 static hda_nid_t alc_go_down_to_selector(struct hda_codec *codec, hda_nid_t pin)
2775 int num = snd_hda_get_connections(codec, pin, srcs,
2778 get_wcaps_type(get_wcaps(codec, srcs[0])) != AC_WID_AUD_SEL)
2783 /* get MIX nid connected to the given pin targeted to DAC */
2784 static hda_nid_t alc_auto_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
2790 pin = alc_go_down_to_selector(codec, pin);
2791 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
2792 for (i = 0; i < num; i++) {
2793 if (alc_auto_mix_to_dac(codec, mix[i]) == dac)
2799 /* select the connection from pin to DAC if needed */
2800 static int alc_auto_select_dac(struct hda_codec *codec, hda_nid_t pin,
2806 pin = alc_go_down_to_selector(codec, pin);
2807 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
2810 for (i = 0; i < num; i++) {
2811 if (alc_auto_mix_to_dac(codec, mix[i]) == dac) {
2812 snd_hda_codec_update_cache(codec, pin, 0,
2813 AC_VERB_SET_CONNECT_SEL, i);
2820 /* look for an empty DAC slot */
2821 static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
2823 struct alc_spec *spec = codec->spec;
2827 pin = alc_go_down_to_selector(codec, pin);
2828 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
2829 for (i = 0; i < num; i++) {
2830 hda_nid_t nid = alc_auto_mix_to_dac(codec, srcs[i]);
2833 if (found_in_nid_list(nid, spec->multiout.dac_nids,
2834 spec->multiout.num_dacs))
2836 if (found_in_nid_list(nid, spec->multiout.hp_out_nid,
2837 ARRAY_SIZE(spec->multiout.hp_out_nid)))
2839 if (found_in_nid_list(nid, spec->multiout.extra_out_nid,
2840 ARRAY_SIZE(spec->multiout.extra_out_nid)))
2847 static hda_nid_t get_dac_if_single(struct hda_codec *codec, hda_nid_t pin)
2849 hda_nid_t sel = alc_go_down_to_selector(codec, pin);
2850 if (snd_hda_get_conn_list(codec, sel, NULL) == 1)
2851 return alc_auto_look_for_dac(codec, pin);
2855 static int alc_auto_fill_extra_dacs(struct hda_codec *codec, int num_outs,
2856 const hda_nid_t *pins, hda_nid_t *dacs)
2860 if (num_outs && !dacs[0]) {
2861 dacs[0] = alc_auto_look_for_dac(codec, pins[0]);
2866 for (i = 1; i < num_outs; i++)
2867 dacs[i] = get_dac_if_single(codec, pins[i]);
2868 for (i = 1; i < num_outs; i++) {
2870 dacs[i] = alc_auto_look_for_dac(codec, pins[i]);
2875 static int alc_auto_fill_multi_ios(struct hda_codec *codec,
2876 unsigned int location);
2878 /* fill in the dac_nids table from the parsed pin configuration */
2879 static int alc_auto_fill_dac_nids(struct hda_codec *codec)
2881 struct alc_spec *spec = codec->spec;
2882 const struct auto_pin_cfg *cfg = &spec->autocfg;
2883 bool redone = false;
2887 /* set num_dacs once to full for alc_auto_look_for_dac() */
2888 spec->multiout.num_dacs = cfg->line_outs;
2889 spec->multiout.hp_out_nid[0] = 0;
2890 spec->multiout.extra_out_nid[0] = 0;
2891 memset(spec->private_dac_nids, 0, sizeof(spec->private_dac_nids));
2892 spec->multiout.dac_nids = spec->private_dac_nids;
2894 /* fill hard-wired DACs first */
2896 for (i = 0; i < cfg->line_outs; i++)
2897 spec->private_dac_nids[i] =
2898 get_dac_if_single(codec, cfg->line_out_pins[i]);
2900 spec->multiout.hp_out_nid[0] =
2901 get_dac_if_single(codec, cfg->hp_pins[0]);
2902 if (cfg->speaker_outs)
2903 spec->multiout.extra_out_nid[0] =
2904 get_dac_if_single(codec, cfg->speaker_pins[0]);
2907 for (i = 0; i < cfg->line_outs; i++) {
2908 hda_nid_t pin = cfg->line_out_pins[i];
2909 if (spec->private_dac_nids[i])
2911 spec->private_dac_nids[i] = alc_auto_look_for_dac(codec, pin);
2912 if (!spec->private_dac_nids[i] && !redone) {
2913 /* if we can't find primary DACs, re-probe without
2914 * checking the hard-wired DACs
2921 /* re-count num_dacs and squash invalid entries */
2922 spec->multiout.num_dacs = 0;
2923 for (i = 0; i < cfg->line_outs; i++) {
2924 if (spec->private_dac_nids[i])
2925 spec->multiout.num_dacs++;
2927 memmove(spec->private_dac_nids + i,
2928 spec->private_dac_nids + i + 1,
2929 sizeof(hda_nid_t) * (cfg->line_outs - i - 1));
2932 if (cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
2933 /* try to fill multi-io first */
2934 unsigned int location, defcfg;
2937 defcfg = snd_hda_codec_get_pincfg(codec, cfg->line_out_pins[0]);
2938 location = get_defcfg_location(defcfg);
2940 num_pins = alc_auto_fill_multi_ios(codec, location);
2942 spec->multi_ios = num_pins;
2943 spec->ext_channel_count = 2;
2944 spec->multiout.num_dacs = num_pins + 1;
2948 alc_auto_fill_extra_dacs(codec, cfg->hp_outs, cfg->hp_pins,
2949 spec->multiout.hp_out_nid);
2950 alc_auto_fill_extra_dacs(codec, cfg->speaker_outs, cfg->speaker_pins,
2951 spec->multiout.extra_out_nid);
2956 static int alc_auto_add_vol_ctl(struct hda_codec *codec,
2957 const char *pfx, int cidx,
2958 hda_nid_t nid, unsigned int chs)
2962 return __add_pb_vol_ctrl(codec->spec, ALC_CTL_WIDGET_VOL, pfx, cidx,
2963 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2966 #define alc_auto_add_stereo_vol(codec, pfx, cidx, nid) \
2967 alc_auto_add_vol_ctl(codec, pfx, cidx, nid, 3)
2969 /* create a mute-switch for the given mixer widget;
2970 * if it has multiple sources (e.g. DAC and loopback), create a bind-mute
2972 static int alc_auto_add_sw_ctl(struct hda_codec *codec,
2973 const char *pfx, int cidx,
2974 hda_nid_t nid, unsigned int chs)
2981 wid_type = get_wcaps_type(get_wcaps(codec, nid));
2982 if (wid_type == AC_WID_PIN || wid_type == AC_WID_AUD_OUT) {
2983 type = ALC_CTL_WIDGET_MUTE;
2984 val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT);
2985 } else if (snd_hda_get_conn_list(codec, nid, NULL) == 1) {
2986 type = ALC_CTL_WIDGET_MUTE;
2987 val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT);
2989 type = ALC_CTL_BIND_MUTE;
2990 val = HDA_COMPOSE_AMP_VAL(nid, chs, 2, HDA_INPUT);
2992 return __add_pb_sw_ctrl(codec->spec, type, pfx, cidx, val);
2995 #define alc_auto_add_stereo_sw(codec, pfx, cidx, nid) \
2996 alc_auto_add_sw_ctl(codec, pfx, cidx, nid, 3)
2998 static hda_nid_t alc_look_for_out_mute_nid(struct hda_codec *codec,
2999 hda_nid_t pin, hda_nid_t dac)
3001 hda_nid_t mix = alc_auto_dac_to_mix(codec, pin, dac);
3002 if (nid_has_mute(codec, pin, HDA_OUTPUT))
3004 else if (mix && nid_has_mute(codec, mix, HDA_INPUT))
3006 else if (nid_has_mute(codec, dac, HDA_OUTPUT))
3011 static hda_nid_t alc_look_for_out_vol_nid(struct hda_codec *codec,
3012 hda_nid_t pin, hda_nid_t dac)
3014 hda_nid_t mix = alc_auto_dac_to_mix(codec, pin, dac);
3015 if (nid_has_volume(codec, dac, HDA_OUTPUT))
3017 else if (nid_has_volume(codec, mix, HDA_OUTPUT))
3019 else if (nid_has_volume(codec, pin, HDA_OUTPUT))
3024 /* add playback controls from the parsed DAC table */
3025 static int alc_auto_create_multi_out_ctls(struct hda_codec *codec,
3026 const struct auto_pin_cfg *cfg)
3028 struct alc_spec *spec = codec->spec;
3029 int i, err, noutputs;
3031 noutputs = cfg->line_outs;
3032 if (spec->multi_ios > 0)
3033 noutputs += spec->multi_ios;
3035 for (i = 0; i < noutputs; i++) {
3041 dac = spec->multiout.dac_nids[i];
3044 if (i >= cfg->line_outs)
3045 pin = spec->multi_io[i - 1].pin;
3047 pin = cfg->line_out_pins[i];
3049 sw = alc_look_for_out_mute_nid(codec, pin, dac);
3050 vol = alc_look_for_out_vol_nid(codec, pin, dac);
3051 name = alc_get_line_out_pfx(spec, i, true, &index);
3052 if (!name || !strcmp(name, "CLFE")) {
3054 err = alc_auto_add_vol_ctl(codec, "Center", 0, vol, 1);
3057 err = alc_auto_add_vol_ctl(codec, "LFE", 0, vol, 2);
3060 err = alc_auto_add_sw_ctl(codec, "Center", 0, sw, 1);
3063 err = alc_auto_add_sw_ctl(codec, "LFE", 0, sw, 2);
3067 err = alc_auto_add_stereo_vol(codec, name, index, vol);
3070 err = alc_auto_add_stereo_sw(codec, name, index, sw);
3078 static int alc_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
3079 hda_nid_t dac, const char *pfx)
3081 struct alc_spec *spec = codec->spec;
3086 /* the corresponding DAC is already occupied */
3087 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
3088 return 0; /* no way */
3089 /* create a switch only */
3090 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
3091 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3094 sw = alc_look_for_out_mute_nid(codec, pin, dac);
3095 vol = alc_look_for_out_vol_nid(codec, pin, dac);
3096 err = alc_auto_add_stereo_vol(codec, pfx, 0, vol);
3099 err = alc_auto_add_stereo_sw(codec, pfx, 0, sw);
3105 static struct hda_bind_ctls *new_bind_ctl(struct hda_codec *codec,
3107 struct hda_ctl_ops *ops)
3109 struct alc_spec *spec = codec->spec;
3110 struct hda_bind_ctls **ctlp, *ctl;
3111 snd_array_init(&spec->bind_ctls, sizeof(ctl), 8);
3112 ctlp = snd_array_new(&spec->bind_ctls);
3115 ctl = kzalloc(sizeof(*ctl) + sizeof(long) * (nums + 1), GFP_KERNEL);
3122 /* add playback controls for speaker and HP outputs */
3123 static int alc_auto_create_extra_outs(struct hda_codec *codec, int num_pins,
3124 const hda_nid_t *pins,
3125 const hda_nid_t *dacs,
3128 struct alc_spec *spec = codec->spec;
3129 struct hda_bind_ctls *ctl;
3133 if (!num_pins || !pins[0])
3137 return alc_auto_create_extra_out(codec, *pins, *dacs, pfx);
3139 if (dacs[num_pins - 1]) {
3140 /* OK, we have a multi-output system with individual volumes */
3141 for (i = 0; i < num_pins; i++) {
3142 snprintf(name, sizeof(name), "%s %s",
3143 pfx, channel_name[i]);
3144 err = alc_auto_create_extra_out(codec, pins[i], dacs[i],
3152 /* Let's create a bind-controls */
3153 ctl = new_bind_ctl(codec, num_pins, &snd_hda_bind_sw);
3157 for (i = 0; i < num_pins; i++) {
3158 if (get_wcaps(codec, pins[i]) & AC_WCAP_OUT_AMP)
3160 HDA_COMPOSE_AMP_VAL(pins[i], 3, 0, HDA_OUTPUT);
3163 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
3164 err = add_control(spec, ALC_CTL_BIND_SW, name, 0, (long)ctl);
3169 ctl = new_bind_ctl(codec, num_pins, &snd_hda_bind_vol);
3173 for (i = 0; i < num_pins; i++) {
3175 if (!pins[i] || !dacs[i])
3177 vol = alc_look_for_out_vol_nid(codec, pins[i], dacs[i]);
3180 HDA_COMPOSE_AMP_VAL(vol, 3, 0, HDA_OUTPUT);
3183 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
3184 err = add_control(spec, ALC_CTL_BIND_VOL, name, 0, (long)ctl);
3191 static int alc_auto_create_hp_out(struct hda_codec *codec)
3193 struct alc_spec *spec = codec->spec;
3194 return alc_auto_create_extra_outs(codec, spec->autocfg.hp_outs,
3195 spec->autocfg.hp_pins,
3196 spec->multiout.hp_out_nid,
3200 static int alc_auto_create_speaker_out(struct hda_codec *codec)
3202 struct alc_spec *spec = codec->spec;
3203 return alc_auto_create_extra_outs(codec, spec->autocfg.speaker_outs,
3204 spec->autocfg.speaker_pins,
3205 spec->multiout.extra_out_nid,
3209 static void alc_auto_set_output_and_unmute(struct hda_codec *codec,
3210 hda_nid_t pin, int pin_type,
3214 hda_nid_t nid, mix = 0;
3215 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
3217 alc_set_pin_output(codec, pin, pin_type);
3218 nid = alc_go_down_to_selector(codec, pin);
3219 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
3220 for (i = 0; i < num; i++) {
3221 if (alc_auto_mix_to_dac(codec, srcs[i]) != dac)
3229 /* need the manual connection? */
3231 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
3232 /* unmute mixer widget inputs */
3233 if (nid_has_mute(codec, mix, HDA_INPUT)) {
3234 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3236 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3239 /* initialize volume */
3240 nid = alc_look_for_out_vol_nid(codec, pin, dac);
3242 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3246 static void alc_auto_init_multi_out(struct hda_codec *codec)
3248 struct alc_spec *spec = codec->spec;
3249 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3252 for (i = 0; i <= HDA_SIDE; i++) {
3253 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3255 alc_auto_set_output_and_unmute(codec, nid, pin_type,
3256 spec->multiout.dac_nids[i]);
3260 static void alc_auto_init_extra_out(struct hda_codec *codec)
3262 struct alc_spec *spec = codec->spec;
3266 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3267 pin = spec->autocfg.hp_pins[i];
3270 dac = spec->multiout.hp_out_nid[i];
3272 if (i > 0 && spec->multiout.hp_out_nid[0])
3273 dac = spec->multiout.hp_out_nid[0];
3275 dac = spec->multiout.dac_nids[0];
3277 alc_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
3279 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3280 pin = spec->autocfg.speaker_pins[i];
3283 dac = spec->multiout.extra_out_nid[i];
3285 if (i > 0 && spec->multiout.extra_out_nid[0])
3286 dac = spec->multiout.extra_out_nid[0];
3288 dac = spec->multiout.dac_nids[0];
3290 alc_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
3297 static int alc_auto_fill_multi_ios(struct hda_codec *codec,
3298 unsigned int location)
3300 struct alc_spec *spec = codec->spec;
3301 struct auto_pin_cfg *cfg = &spec->autocfg;
3302 hda_nid_t prime_dac = spec->private_dac_nids[0];
3303 int type, i, num_pins = 0;
3305 for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) {
3306 for (i = 0; i < cfg->num_inputs; i++) {
3307 hda_nid_t nid = cfg->inputs[i].pin;
3309 unsigned int defcfg, caps;
3310 if (cfg->inputs[i].type != type)
3312 defcfg = snd_hda_codec_get_pincfg(codec, nid);
3313 if (get_defcfg_connect(defcfg) != AC_JACK_PORT_COMPLEX)
3315 if (location && get_defcfg_location(defcfg) != location)
3317 caps = snd_hda_query_pin_caps(codec, nid);
3318 if (!(caps & AC_PINCAP_OUT))
3320 dac = alc_auto_look_for_dac(codec, nid);
3323 spec->multi_io[num_pins].pin = nid;
3324 spec->multi_io[num_pins].dac = dac;
3326 spec->private_dac_nids[spec->multiout.num_dacs++] = dac;
3329 spec->multiout.num_dacs = 1;
3331 /* clear up again */
3332 memset(spec->private_dac_nids, 0,
3333 sizeof(spec->private_dac_nids));
3334 spec->private_dac_nids[0] = prime_dac;
3340 static int alc_auto_ch_mode_info(struct snd_kcontrol *kcontrol,
3341 struct snd_ctl_elem_info *uinfo)
3343 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3344 struct alc_spec *spec = codec->spec;
3346 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3348 uinfo->value.enumerated.items = spec->multi_ios + 1;
3349 if (uinfo->value.enumerated.item > spec->multi_ios)
3350 uinfo->value.enumerated.item = spec->multi_ios;
3351 sprintf(uinfo->value.enumerated.name, "%dch",
3352 (uinfo->value.enumerated.item + 1) * 2);
3356 static int alc_auto_ch_mode_get(struct snd_kcontrol *kcontrol,
3357 struct snd_ctl_elem_value *ucontrol)
3359 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3360 struct alc_spec *spec = codec->spec;
3361 ucontrol->value.enumerated.item[0] = (spec->ext_channel_count - 1) / 2;
3365 static int alc_set_multi_io(struct hda_codec *codec, int idx, bool output)
3367 struct alc_spec *spec = codec->spec;
3368 hda_nid_t nid = spec->multi_io[idx].pin;
3370 if (!spec->multi_io[idx].ctl_in)
3371 spec->multi_io[idx].ctl_in =
3372 snd_hda_codec_read(codec, nid, 0,
3373 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3375 snd_hda_codec_update_cache(codec, nid, 0,
3376 AC_VERB_SET_PIN_WIDGET_CONTROL,
3378 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
3379 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3381 alc_auto_select_dac(codec, nid, spec->multi_io[idx].dac);
3383 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
3384 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3385 HDA_AMP_MUTE, HDA_AMP_MUTE);
3386 snd_hda_codec_update_cache(codec, nid, 0,
3387 AC_VERB_SET_PIN_WIDGET_CONTROL,
3388 spec->multi_io[idx].ctl_in);
3393 static int alc_auto_ch_mode_put(struct snd_kcontrol *kcontrol,
3394 struct snd_ctl_elem_value *ucontrol)
3396 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3397 struct alc_spec *spec = codec->spec;
3400 ch = ucontrol->value.enumerated.item[0];
3401 if (ch < 0 || ch > spec->multi_ios)
3403 if (ch == (spec->ext_channel_count - 1) / 2)
3405 spec->ext_channel_count = (ch + 1) * 2;
3406 for (i = 0; i < spec->multi_ios; i++)
3407 alc_set_multi_io(codec, i, i < ch);
3408 spec->multiout.max_channels = spec->ext_channel_count;
3409 if (spec->need_dac_fix && !spec->const_channel_count)
3410 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
3414 static const struct snd_kcontrol_new alc_auto_channel_mode_enum = {
3415 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3416 .name = "Channel Mode",
3417 .info = alc_auto_ch_mode_info,
3418 .get = alc_auto_ch_mode_get,
3419 .put = alc_auto_ch_mode_put,
3422 static int alc_auto_add_multi_channel_mode(struct hda_codec *codec)
3424 struct alc_spec *spec = codec->spec;
3426 if (spec->multi_ios > 0) {
3427 struct snd_kcontrol_new *knew;
3429 knew = alc_kcontrol_new(spec);
3432 *knew = alc_auto_channel_mode_enum;
3433 knew->name = kstrdup("Channel Mode", GFP_KERNEL);
3440 /* filter out invalid adc_nids (and capsrc_nids) that don't give all
3443 static void alc_remove_invalid_adc_nids(struct hda_codec *codec)
3445 struct alc_spec *spec = codec->spec;
3446 const struct hda_input_mux *imux;
3447 hda_nid_t adc_nids[ARRAY_SIZE(spec->private_adc_nids)];
3448 hda_nid_t capsrc_nids[ARRAY_SIZE(spec->private_adc_nids)];
3451 imux = spec->input_mux;
3454 if (spec->dyn_adc_switch)
3458 for (n = 0; n < spec->num_adc_nids; n++) {
3459 hda_nid_t cap = spec->private_capsrc_nids[n];
3460 int num_conns = snd_hda_get_conn_list(codec, cap, NULL);
3461 for (i = 0; i < imux->num_items; i++) {
3462 hda_nid_t pin = spec->imux_pins[i];
3464 if (get_connection_index(codec, cap, pin) < 0)
3466 } else if (num_conns <= imux->items[i].index)
3469 if (i >= imux->num_items) {
3470 adc_nids[nums] = spec->private_adc_nids[n];
3471 capsrc_nids[nums++] = cap;
3475 /* check whether ADC-switch is possible */
3476 if (!alc_check_dyn_adc_switch(codec)) {
3477 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
3478 " using fallback 0x%x\n",
3479 codec->chip_name, spec->private_adc_nids[0]);
3480 spec->num_adc_nids = 1;
3484 } else if (nums != spec->num_adc_nids) {
3485 memcpy(spec->private_adc_nids, adc_nids,
3486 nums * sizeof(hda_nid_t));
3487 memcpy(spec->private_capsrc_nids, capsrc_nids,
3488 nums * sizeof(hda_nid_t));
3489 spec->num_adc_nids = nums;
3493 alc_auto_mic_check_imux(codec); /* check auto-mic setups */
3494 else if (spec->input_mux->num_items == 1)
3495 spec->num_adc_nids = 1; /* reduce to a single ADC */
3499 * initialize ADC paths
3501 static void alc_auto_init_adc(struct hda_codec *codec, int adc_idx)
3503 struct alc_spec *spec = codec->spec;
3506 nid = spec->adc_nids[adc_idx];
3508 if (nid_has_mute(codec, nid, HDA_INPUT)) {
3509 snd_hda_codec_write(codec, nid, 0,
3510 AC_VERB_SET_AMP_GAIN_MUTE,
3514 if (!spec->capsrc_nids)
3516 nid = spec->capsrc_nids[adc_idx];
3517 if (nid_has_mute(codec, nid, HDA_OUTPUT))
3518 snd_hda_codec_write(codec, nid, 0,
3519 AC_VERB_SET_AMP_GAIN_MUTE,
3523 static void alc_auto_init_input_src(struct hda_codec *codec)
3525 struct alc_spec *spec = codec->spec;
3528 for (c = 0; c < spec->num_adc_nids; c++)
3529 alc_auto_init_adc(codec, c);
3530 if (spec->dyn_adc_switch)
3533 nums = spec->num_adc_nids;
3534 for (c = 0; c < nums; c++)
3535 alc_mux_select(codec, 0, spec->cur_mux[c], true);
3538 /* add mic boosts if needed */
3539 static int alc_auto_add_mic_boost(struct hda_codec *codec)
3541 struct alc_spec *spec = codec->spec;
3542 struct auto_pin_cfg *cfg = &spec->autocfg;
3546 const char *prev_label = NULL;
3548 for (i = 0; i < cfg->num_inputs; i++) {
3549 if (cfg->inputs[i].type > AUTO_PIN_MIC)
3551 nid = cfg->inputs[i].pin;
3552 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
3554 char boost_label[32];
3556 label = hda_get_autocfg_input_label(codec, cfg, i);
3557 if (prev_label && !strcmp(label, prev_label))
3563 snprintf(boost_label, sizeof(boost_label),
3564 "%s Boost Volume", label);
3565 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3566 boost_label, type_idx,
3567 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
3575 /* select or unmute the given capsrc route */
3576 static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap,
3579 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
3580 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
3582 } else if (snd_hda_get_conn_list(codec, cap, NULL) > 1) {
3583 snd_hda_codec_write_cache(codec, cap, 0,
3584 AC_VERB_SET_CONNECT_SEL, idx);
3588 /* set the default connection to that pin */
3589 static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
3591 struct alc_spec *spec = codec->spec;
3596 for (i = 0; i < spec->num_adc_nids; i++) {
3597 hda_nid_t cap = spec->capsrc_nids ?
3598 spec->capsrc_nids[i] : spec->adc_nids[i];
3601 idx = get_connection_index(codec, cap, pin);
3604 select_or_unmute_capsrc(codec, cap, idx);
3605 return i; /* return the found index */
3607 return -1; /* not found */
3610 /* initialize some special cases for input sources */
3611 static void alc_init_special_input_src(struct hda_codec *codec)
3613 struct alc_spec *spec = codec->spec;
3616 for (i = 0; i < spec->autocfg.num_inputs; i++)
3617 init_capsrc_for_pin(codec, spec->autocfg.inputs[i].pin);
3620 /* assign appropriate capture mixers */
3621 static void set_capture_mixer(struct hda_codec *codec)
3623 struct alc_spec *spec = codec->spec;
3624 static const struct snd_kcontrol_new *caps[2][3] = {
3625 { alc_capture_mixer_nosrc1,
3626 alc_capture_mixer_nosrc2,
3627 alc_capture_mixer_nosrc3 },
3628 { alc_capture_mixer1,
3630 alc_capture_mixer3 },
3633 /* check whether either of ADC or MUX has a volume control */
3634 if (!nid_has_volume(codec, spec->adc_nids[0], HDA_INPUT)) {
3635 if (!spec->capsrc_nids)
3636 return; /* no volume */
3637 if (!nid_has_volume(codec, spec->capsrc_nids[0], HDA_OUTPUT))
3638 return; /* no volume in capsrc, too */
3639 spec->vol_in_capsrc = 1;
3642 if (spec->num_adc_nids > 0) {
3646 if (spec->input_mux && spec->input_mux->num_items > 1)
3648 if (spec->auto_mic) {
3651 } else if (spec->dyn_adc_switch)
3654 if (spec->num_adc_nids > 3)
3655 spec->num_adc_nids = 3;
3656 else if (!spec->num_adc_nids)
3658 num_adcs = spec->num_adc_nids;
3660 spec->cap_mixer = caps[mux][num_adcs - 1];
3665 * standard auto-parser initializations
3667 static void alc_auto_init_std(struct hda_codec *codec)
3669 struct alc_spec *spec = codec->spec;
3670 alc_auto_init_multi_out(codec);
3671 alc_auto_init_extra_out(codec);
3672 alc_auto_init_analog_input(codec);
3673 alc_auto_init_input_src(codec);
3674 alc_auto_init_digital(codec);
3675 if (spec->unsol_event)
3676 alc_inithook(codec);
3680 * Digital-beep handlers
3682 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3683 #define set_beep_amp(spec, nid, idx, dir) \
3684 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
3686 static const struct snd_pci_quirk beep_white_list[] = {
3687 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
3688 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
3689 SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
3690 SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
3691 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
3695 static inline int has_cdefine_beep(struct hda_codec *codec)
3697 struct alc_spec *spec = codec->spec;
3698 const struct snd_pci_quirk *q;
3699 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
3702 return spec->cdefine.enable_pcbeep;
3705 #define set_beep_amp(spec, nid, idx, dir) /* NOP */
3706 #define has_cdefine_beep(codec) 0
3709 /* parse the BIOS configuration and set up the alc_spec */
3710 /* return 1 if successful, 0 if the proper config is not found,
3711 * or a negative error code
3713 static int alc_parse_auto_config(struct hda_codec *codec,
3714 const hda_nid_t *ignore_nids,
3715 const hda_nid_t *ssid_nids)
3717 struct alc_spec *spec = codec->spec;
3718 struct auto_pin_cfg *cfg = &spec->autocfg;
3721 err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids,
3725 if (!cfg->line_outs) {
3726 if (cfg->dig_outs || cfg->dig_in_pin) {
3727 spec->multiout.max_channels = 2;
3728 spec->no_analog = 1;
3731 return 0; /* can't find valid BIOS pin config */
3734 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT &&
3735 cfg->line_outs <= cfg->hp_outs) {
3736 /* use HP as primary out */
3737 cfg->speaker_outs = cfg->line_outs;
3738 memcpy(cfg->speaker_pins, cfg->line_out_pins,
3739 sizeof(cfg->speaker_pins));
3740 cfg->line_outs = cfg->hp_outs;
3741 memcpy(cfg->line_out_pins, cfg->hp_pins, sizeof(cfg->hp_pins));
3743 memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins));
3744 cfg->line_out_type = AUTO_PIN_HP_OUT;
3747 err = alc_auto_fill_dac_nids(codec);
3750 err = alc_auto_add_multi_channel_mode(codec);
3753 err = alc_auto_create_multi_out_ctls(codec, cfg);
3756 err = alc_auto_create_hp_out(codec);
3759 err = alc_auto_create_speaker_out(codec);
3762 err = alc_auto_create_input_ctls(codec);
3766 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3769 alc_auto_parse_digital(codec);
3771 if (!spec->no_analog)
3772 alc_remove_invalid_adc_nids(codec);
3775 alc_ssid_check(codec, ssid_nids);
3777 if (!spec->no_analog) {
3778 alc_auto_check_switches(codec);
3779 err = alc_auto_add_mic_boost(codec);
3784 if (spec->kctls.list)
3785 add_mixer(spec, spec->kctls.list);
3790 static int alc880_parse_auto_config(struct hda_codec *codec)
3792 static const hda_nid_t alc880_ignore[] = { 0x1d, 0 };
3793 static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 };
3794 return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids);
3797 #ifdef CONFIG_SND_HDA_POWER_SAVE
3798 static const struct hda_amp_list alc880_loopbacks[] = {
3799 { 0x0b, HDA_INPUT, 0 },
3800 { 0x0b, HDA_INPUT, 1 },
3801 { 0x0b, HDA_INPUT, 2 },
3802 { 0x0b, HDA_INPUT, 3 },
3803 { 0x0b, HDA_INPUT, 4 },
3811 #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
3812 #define alc_board_config \
3813 snd_hda_check_board_config
3814 #define alc_board_codec_sid_config \
3815 snd_hda_check_board_codec_sid_config
3816 #include "alc_quirks.c"
3818 #define alc_board_config(codec, nums, models, tbl) -1
3819 #define alc_board_codec_sid_config(codec, nums, models, tbl) -1
3820 #define setup_preset(codec, x) /* NOP */
3824 * OK, here we have finally the patch for ALC880
3826 #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
3827 #include "alc880_quirks.c"
3830 static int patch_alc880(struct hda_codec *codec)
3832 struct alc_spec *spec;
3836 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3842 spec->mixer_nid = 0x0b;
3843 spec->need_dac_fix = 1;
3845 board_config = alc_board_config(codec, ALC880_MODEL_LAST,
3846 alc880_models, alc880_cfg_tbl);
3847 if (board_config < 0) {
3848 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
3850 board_config = ALC_MODEL_AUTO;
3853 if (board_config == ALC_MODEL_AUTO) {
3854 /* automatic parse from the BIOS config */
3855 err = alc880_parse_auto_config(codec);
3860 #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
3863 "hda_codec: Cannot set up configuration "
3864 "from BIOS. Using 3-stack mode...\n");
3865 board_config = ALC880_3ST;
3870 if (board_config != ALC_MODEL_AUTO)
3871 setup_preset(codec, &alc880_presets[board_config]);
3873 if (!spec->no_analog && !spec->adc_nids) {
3874 alc_auto_fill_adc_caps(codec);
3875 alc_rebuild_imux_for_auto_mic(codec);
3876 alc_remove_invalid_adc_nids(codec);
3879 if (!spec->no_analog && !spec->cap_mixer)
3880 set_capture_mixer(codec);
3882 if (!spec->no_analog) {
3883 err = snd_hda_attach_beep_device(codec, 0x1);
3888 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
3891 spec->vmaster_nid = 0x0c;
3893 codec->patch_ops = alc_patch_ops;
3894 if (board_config == ALC_MODEL_AUTO)
3895 spec->init_hook = alc_auto_init_std;
3896 #ifdef CONFIG_SND_HDA_POWER_SAVE
3897 if (!spec->loopback.amplist)
3898 spec->loopback.amplist = alc880_loopbacks;
3908 static int alc260_parse_auto_config(struct hda_codec *codec)
3910 static const hda_nid_t alc260_ignore[] = { 0x17, 0 };
3911 static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 };
3912 return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids);
3915 #ifdef CONFIG_SND_HDA_POWER_SAVE
3916 static const struct hda_amp_list alc260_loopbacks[] = {
3917 { 0x07, HDA_INPUT, 0 },
3918 { 0x07, HDA_INPUT, 1 },
3919 { 0x07, HDA_INPUT, 2 },
3920 { 0x07, HDA_INPUT, 3 },
3921 { 0x07, HDA_INPUT, 4 },
3933 static const struct alc_fixup alc260_fixups[] = {
3934 [PINFIX_HP_DC5750] = {
3935 .type = ALC_FIXUP_PINS,
3936 .v.pins = (const struct alc_pincfg[]) {
3937 { 0x11, 0x90130110 }, /* speaker */
3943 static const struct snd_pci_quirk alc260_fixup_tbl[] = {
3944 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750),
3950 #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
3951 #include "alc260_quirks.c"
3954 static int patch_alc260(struct hda_codec *codec)
3956 struct alc_spec *spec;
3957 int err, board_config;
3959 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3965 spec->mixer_nid = 0x07;
3967 board_config = alc_board_config(codec, ALC260_MODEL_LAST,
3968 alc260_models, alc260_cfg_tbl);
3969 if (board_config < 0) {
3970 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
3972 board_config = ALC_MODEL_AUTO;
3975 if (board_config == ALC_MODEL_AUTO) {
3976 alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups);
3977 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
3980 if (board_config == ALC_MODEL_AUTO) {
3981 /* automatic parse from the BIOS config */
3982 err = alc260_parse_auto_config(codec);
3987 #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
3990 "hda_codec: Cannot set up configuration "
3991 "from BIOS. Using base mode...\n");
3992 board_config = ALC260_BASIC;
3997 if (board_config != ALC_MODEL_AUTO)
3998 setup_preset(codec, &alc260_presets[board_config]);
4000 if (!spec->no_analog && !spec->adc_nids) {
4001 alc_auto_fill_adc_caps(codec);
4002 alc_rebuild_imux_for_auto_mic(codec);
4003 alc_remove_invalid_adc_nids(codec);
4006 if (!spec->no_analog && !spec->cap_mixer)
4007 set_capture_mixer(codec);
4009 if (!spec->no_analog) {
4010 err = snd_hda_attach_beep_device(codec, 0x1);
4015 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
4018 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
4020 spec->vmaster_nid = 0x08;
4022 codec->patch_ops = alc_patch_ops;
4023 if (board_config == ALC_MODEL_AUTO)
4024 spec->init_hook = alc_auto_init_std;
4025 spec->shutup = alc_eapd_shutup;
4026 #ifdef CONFIG_SND_HDA_POWER_SAVE
4027 if (!spec->loopback.amplist)
4028 spec->loopback.amplist = alc260_loopbacks;
4036 * ALC882/883/885/888/889 support
4038 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4039 * configuration. Each pin widget can choose any input DACs and a mixer.
4040 * Each ADC is connected from a mixer of all inputs. This makes possible
4041 * 6-channel independent captures.
4043 * In addition, an independent DAC for the multi-playback (not used in this
4046 #ifdef CONFIG_SND_HDA_POWER_SAVE
4047 #define alc882_loopbacks alc880_loopbacks
4054 PINFIX_ABIT_AW9D_MAX,
4057 PINFIX_ACER_ASPIRE_7736,
4060 static const struct alc_fixup alc882_fixups[] = {
4061 [PINFIX_ABIT_AW9D_MAX] = {
4062 .type = ALC_FIXUP_PINS,
4063 .v.pins = (const struct alc_pincfg[]) {
4064 { 0x15, 0x01080104 }, /* side */
4065 { 0x16, 0x01011012 }, /* rear */
4066 { 0x17, 0x01016011 }, /* clfe */
4070 [PINFIX_LENOVO_Y530] = {
4071 .type = ALC_FIXUP_PINS,
4072 .v.pins = (const struct alc_pincfg[]) {
4073 { 0x15, 0x99130112 }, /* rear int speakers */
4074 { 0x16, 0x99130111 }, /* subwoofer */
4078 [PINFIX_PB_M5210] = {
4079 .type = ALC_FIXUP_VERBS,
4080 .v.verbs = (const struct hda_verb[]) {
4081 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
4085 [PINFIX_ACER_ASPIRE_7736] = {
4086 .type = ALC_FIXUP_SKU,
4087 .v.sku = ALC_FIXUP_SKU_IGNORE,
4091 static const struct snd_pci_quirk alc882_fixup_tbl[] = {
4092 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210),
4093 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", PINFIX_LENOVO_Y530),
4094 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
4095 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736),
4100 * BIOS auto configuration
4102 /* almost identical with ALC880 parser... */
4103 static int alc882_parse_auto_config(struct hda_codec *codec)
4105 static const hda_nid_t alc882_ignore[] = { 0x1d, 0 };
4106 static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 };
4107 return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids);
4112 #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4113 #include "alc882_quirks.c"
4116 static int patch_alc882(struct hda_codec *codec)
4118 struct alc_spec *spec;
4119 int err, board_config;
4121 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4127 spec->mixer_nid = 0x0b;
4129 switch (codec->vendor_id) {
4134 /* ALC883 and variants */
4135 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
4139 board_config = alc_board_config(codec, ALC882_MODEL_LAST,
4140 alc882_models, alc882_cfg_tbl);
4142 if (board_config < 0)
4143 board_config = alc_board_codec_sid_config(codec,
4144 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
4146 if (board_config < 0) {
4147 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4149 board_config = ALC_MODEL_AUTO;
4152 if (board_config == ALC_MODEL_AUTO) {
4153 alc_pick_fixup(codec, NULL, alc882_fixup_tbl, alc882_fixups);
4154 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
4157 alc_auto_parse_customize_define(codec);
4159 if (board_config == ALC_MODEL_AUTO) {
4160 /* automatic parse from the BIOS config */
4161 err = alc882_parse_auto_config(codec);
4166 #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4169 "hda_codec: Cannot set up configuration "
4170 "from BIOS. Using base mode...\n");
4171 board_config = ALC882_3ST_DIG;
4176 if (board_config != ALC_MODEL_AUTO)
4177 setup_preset(codec, &alc882_presets[board_config]);
4179 if (!spec->no_analog && !spec->adc_nids) {
4180 alc_auto_fill_adc_caps(codec);
4181 alc_rebuild_imux_for_auto_mic(codec);
4182 alc_remove_invalid_adc_nids(codec);
4185 if (!spec->no_analog && !spec->cap_mixer)
4186 set_capture_mixer(codec);
4188 if (!spec->no_analog && has_cdefine_beep(codec)) {
4189 err = snd_hda_attach_beep_device(codec, 0x1);
4194 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
4197 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
4199 spec->vmaster_nid = 0x0c;
4201 codec->patch_ops = alc_patch_ops;
4202 if (board_config == ALC_MODEL_AUTO)
4203 spec->init_hook = alc_auto_init_std;
4205 alc_init_jacks(codec);
4206 #ifdef CONFIG_SND_HDA_POWER_SAVE
4207 if (!spec->loopback.amplist)
4208 spec->loopback.amplist = alc882_loopbacks;
4218 static int alc262_parse_auto_config(struct hda_codec *codec)
4220 static const hda_nid_t alc262_ignore[] = { 0x1d, 0 };
4221 static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 };
4222 return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids);
4233 static const struct alc_fixup alc262_fixups[] = {
4234 [PINFIX_FSC_H270] = {
4235 .type = ALC_FIXUP_PINS,
4236 .v.pins = (const struct alc_pincfg[]) {
4237 { 0x14, 0x99130110 }, /* speaker */
4238 { 0x15, 0x0221142f }, /* front HP */
4239 { 0x1b, 0x0121141f }, /* rear HP */
4243 [PINFIX_HP_Z200] = {
4244 .type = ALC_FIXUP_PINS,
4245 .v.pins = (const struct alc_pincfg[]) {
4246 { 0x16, 0x99130120 }, /* internal speaker */
4252 static const struct snd_pci_quirk alc262_fixup_tbl[] = {
4253 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", PINFIX_HP_Z200),
4254 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270),
4259 #ifdef CONFIG_SND_HDA_POWER_SAVE
4260 #define alc262_loopbacks alc880_loopbacks
4265 #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4266 #include "alc262_quirks.c"
4269 static int patch_alc262(struct hda_codec *codec)
4271 struct alc_spec *spec;
4275 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4281 spec->mixer_nid = 0x0b;
4284 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
4289 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
4290 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
4291 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
4292 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
4295 alc_auto_parse_customize_define(codec);
4297 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
4299 board_config = alc_board_config(codec, ALC262_MODEL_LAST,
4300 alc262_models, alc262_cfg_tbl);
4302 if (board_config < 0) {
4303 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4305 board_config = ALC_MODEL_AUTO;
4308 if (board_config == ALC_MODEL_AUTO) {
4309 alc_pick_fixup(codec, NULL, alc262_fixup_tbl, alc262_fixups);
4310 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
4313 if (board_config == ALC_MODEL_AUTO) {
4314 /* automatic parse from the BIOS config */
4315 err = alc262_parse_auto_config(codec);
4320 #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4323 "hda_codec: Cannot set up configuration "
4324 "from BIOS. Using base mode...\n");
4325 board_config = ALC262_BASIC;
4330 if (board_config != ALC_MODEL_AUTO)
4331 setup_preset(codec, &alc262_presets[board_config]);
4333 if (!spec->no_analog && !spec->adc_nids) {
4334 alc_auto_fill_adc_caps(codec);
4335 alc_rebuild_imux_for_auto_mic(codec);
4336 alc_remove_invalid_adc_nids(codec);
4339 if (!spec->no_analog && !spec->cap_mixer)
4340 set_capture_mixer(codec);
4342 if (!spec->no_analog && has_cdefine_beep(codec)) {
4343 err = snd_hda_attach_beep_device(codec, 0x1);
4348 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
4351 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
4353 spec->vmaster_nid = 0x0c;
4355 codec->patch_ops = alc_patch_ops;
4356 if (board_config == ALC_MODEL_AUTO)
4357 spec->init_hook = alc_auto_init_std;
4358 spec->shutup = alc_eapd_shutup;
4360 alc_init_jacks(codec);
4361 #ifdef CONFIG_SND_HDA_POWER_SAVE
4362 if (!spec->loopback.amplist)
4363 spec->loopback.amplist = alc262_loopbacks;
4372 /* bind Beep switches of both NID 0x0f and 0x10 */
4373 static const struct hda_bind_ctls alc268_bind_beep_sw = {
4374 .ops = &snd_hda_bind_sw,
4376 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
4377 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
4382 static const struct snd_kcontrol_new alc268_beep_mixer[] = {
4383 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
4384 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
4388 /* set PCBEEP vol = 0, mute connections */
4389 static const struct hda_verb alc268_beep_init_verbs[] = {
4390 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4391 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4392 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4397 * BIOS auto configuration
4399 static int alc268_parse_auto_config(struct hda_codec *codec)
4401 static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 };
4402 struct alc_spec *spec = codec->spec;
4403 int err = alc_parse_auto_config(codec, NULL, alc268_ssids);
4405 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d) {
4406 add_mixer(spec, alc268_beep_mixer);
4407 add_verb(spec, alc268_beep_init_verbs);
4415 static int patch_alc268(struct hda_codec *codec)
4417 struct alc_spec *spec;
4418 int i, has_beep, err;
4420 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4426 /* ALC268 has no aa-loopback mixer */
4428 /* automatic parse from the BIOS config */
4429 err = alc268_parse_auto_config(codec);
4436 for (i = 0; i < spec->num_mixers; i++) {
4437 if (spec->mixers[i] == alc268_beep_mixer) {
4444 err = snd_hda_attach_beep_device(codec, 0x1);
4449 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
4450 /* override the amp caps for beep generator */
4451 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
4452 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
4453 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
4454 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4455 (0 << AC_AMPCAP_MUTE_SHIFT));
4458 if (!spec->no_analog && !spec->adc_nids) {
4459 alc_auto_fill_adc_caps(codec);
4460 alc_rebuild_imux_for_auto_mic(codec);
4461 alc_remove_invalid_adc_nids(codec);
4464 if (!spec->no_analog && !spec->cap_mixer)
4465 set_capture_mixer(codec);
4467 spec->vmaster_nid = 0x02;
4469 codec->patch_ops = alc_patch_ops;
4470 spec->init_hook = alc_auto_init_std;
4471 spec->shutup = alc_eapd_shutup;
4473 alc_init_jacks(codec);
4481 #ifdef CONFIG_SND_HDA_POWER_SAVE
4482 #define alc269_loopbacks alc880_loopbacks
4485 static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
4489 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
4490 /* NID is set in alc_build_pcms */
4492 .open = alc_playback_pcm_open,
4493 .prepare = alc_playback_pcm_prepare,
4494 .cleanup = alc_playback_pcm_cleanup
4498 static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
4502 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
4503 /* NID is set in alc_build_pcms */
4506 #ifdef CONFIG_SND_HDA_POWER_SAVE
4507 static int alc269_mic2_for_mute_led(struct hda_codec *codec)
4509 switch (codec->subsystem_id) {
4516 static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
4518 /* update mute-LED according to the speaker mute state */
4519 if (nid == 0x01 || nid == 0x14) {
4521 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
4526 /* mic2 vref pin is used for mute LED control */
4527 snd_hda_codec_update_cache(codec, 0x19, 0,
4528 AC_VERB_SET_PIN_WIDGET_CONTROL,
4531 return alc_check_power_status(codec, nid);
4533 #endif /* CONFIG_SND_HDA_POWER_SAVE */
4535 /* different alc269-variants */
4537 ALC269_TYPE_ALC269VA,
4538 ALC269_TYPE_ALC269VB,
4539 ALC269_TYPE_ALC269VC,
4543 * BIOS auto configuration
4545 static int alc269_parse_auto_config(struct hda_codec *codec)
4547 static const hda_nid_t alc269_ignore[] = { 0x1d, 0 };
4548 static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 };
4549 static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 };
4550 struct alc_spec *spec = codec->spec;
4551 const hda_nid_t *ssids = spec->codec_variant == ALC269_TYPE_ALC269VA ?
4552 alc269va_ssids : alc269_ssids;
4554 return alc_parse_auto_config(codec, alc269_ignore, ssids);
4557 static void alc269_toggle_power_output(struct hda_codec *codec, int power_up)
4559 int val = alc_read_coef_idx(codec, 0x04);
4564 alc_write_coef_idx(codec, 0x04, val);
4567 static void alc269_shutup(struct hda_codec *codec)
4569 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017)
4570 alc269_toggle_power_output(codec, 0);
4571 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
4572 alc269_toggle_power_output(codec, 0);
4578 static int alc269_resume(struct hda_codec *codec)
4580 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
4581 alc269_toggle_power_output(codec, 0);
4585 codec->patch_ops.init(codec);
4587 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
4588 alc269_toggle_power_output(codec, 1);
4592 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018)
4593 alc269_toggle_power_output(codec, 1);
4595 snd_hda_codec_resume_amp(codec);
4596 snd_hda_codec_resume_cache(codec);
4597 hda_call_check_power_status(codec, 0x01);
4600 #endif /* CONFIG_PM */
4602 static void alc269_fixup_hweq(struct hda_codec *codec,
4603 const struct alc_fixup *fix, int action)
4607 if (action != ALC_FIXUP_ACT_INIT)
4609 coef = alc_read_coef_idx(codec, 0x1e);
4610 alc_write_coef_idx(codec, 0x1e, coef | 0x80);
4613 static void alc271_fixup_dmic(struct hda_codec *codec,
4614 const struct alc_fixup *fix, int action)
4616 static const struct hda_verb verbs[] = {
4617 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
4618 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
4623 if (strcmp(codec->chip_name, "ALC271X"))
4625 cfg = snd_hda_codec_get_pincfg(codec, 0x12);
4626 if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED)
4627 snd_hda_sequence_write(codec, verbs);
4630 static void alc269_fixup_pcm_44k(struct hda_codec *codec,
4631 const struct alc_fixup *fix, int action)
4633 struct alc_spec *spec = codec->spec;
4635 if (action != ALC_FIXUP_ACT_PROBE)
4638 /* Due to a hardware problem on Lenovo Ideadpad, we need to
4639 * fix the sample rate of analog I/O to 44.1kHz
4641 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
4642 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
4645 static void alc269_fixup_stereo_dmic(struct hda_codec *codec,
4646 const struct alc_fixup *fix, int action)
4650 if (action != ALC_FIXUP_ACT_INIT)
4652 /* The digital-mic unit sends PDM (differential signal) instead of
4653 * the standard PCM, thus you can't record a valid mono stream as is.
4654 * Below is a workaround specific to ALC269 to control the dmic
4655 * signal source as mono.
4657 coef = alc_read_coef_idx(codec, 0x07);
4658 alc_write_coef_idx(codec, 0x07, coef | 0x80);
4661 static void alc269_quanta_automute(struct hda_codec *codec)
4663 update_outputs(codec);
4665 snd_hda_codec_write(codec, 0x20, 0,
4666 AC_VERB_SET_COEF_INDEX, 0x0c);
4667 snd_hda_codec_write(codec, 0x20, 0,
4668 AC_VERB_SET_PROC_COEF, 0x680);
4670 snd_hda_codec_write(codec, 0x20, 0,
4671 AC_VERB_SET_COEF_INDEX, 0x0c);
4672 snd_hda_codec_write(codec, 0x20, 0,
4673 AC_VERB_SET_PROC_COEF, 0x480);
4676 static void alc269_fixup_quanta_mute(struct hda_codec *codec,
4677 const struct alc_fixup *fix, int action)
4679 struct alc_spec *spec = codec->spec;
4680 if (action != ALC_FIXUP_ACT_PROBE)
4682 spec->automute_hook = alc269_quanta_automute;
4686 ALC269_FIXUP_SONY_VAIO,
4687 ALC275_FIXUP_SONY_VAIO_GPIO2,
4688 ALC269_FIXUP_DELL_M101Z,
4689 ALC269_FIXUP_SKU_IGNORE,
4690 ALC269_FIXUP_ASUS_G73JW,
4691 ALC269_FIXUP_LENOVO_EAPD,
4692 ALC275_FIXUP_SONY_HWEQ,
4694 ALC269_FIXUP_PCM_44K,
4695 ALC269_FIXUP_STEREO_DMIC,
4696 ALC269_FIXUP_QUANTA_MUTE,
4697 ALC269_FIXUP_LIFEBOOK,
4700 ALC269VB_FIXUP_AMIC,
4701 ALC269VB_FIXUP_DMIC,
4704 static const struct alc_fixup alc269_fixups[] = {
4705 [ALC269_FIXUP_SONY_VAIO] = {
4706 .type = ALC_FIXUP_VERBS,
4707 .v.verbs = (const struct hda_verb[]) {
4708 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
4712 [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
4713 .type = ALC_FIXUP_VERBS,
4714 .v.verbs = (const struct hda_verb[]) {
4715 {0x01, AC_VERB_SET_GPIO_MASK, 0x04},
4716 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04},
4717 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4721 .chain_id = ALC269_FIXUP_SONY_VAIO
4723 [ALC269_FIXUP_DELL_M101Z] = {
4724 .type = ALC_FIXUP_VERBS,
4725 .v.verbs = (const struct hda_verb[]) {
4726 /* Enables internal speaker */
4727 {0x20, AC_VERB_SET_COEF_INDEX, 13},
4728 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
4732 [ALC269_FIXUP_SKU_IGNORE] = {
4733 .type = ALC_FIXUP_SKU,
4734 .v.sku = ALC_FIXUP_SKU_IGNORE,
4736 [ALC269_FIXUP_ASUS_G73JW] = {
4737 .type = ALC_FIXUP_PINS,
4738 .v.pins = (const struct alc_pincfg[]) {
4739 { 0x17, 0x99130111 }, /* subwoofer */
4743 [ALC269_FIXUP_LENOVO_EAPD] = {
4744 .type = ALC_FIXUP_VERBS,
4745 .v.verbs = (const struct hda_verb[]) {
4746 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
4750 [ALC275_FIXUP_SONY_HWEQ] = {
4751 .type = ALC_FIXUP_FUNC,
4752 .v.func = alc269_fixup_hweq,
4754 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
4756 [ALC271_FIXUP_DMIC] = {
4757 .type = ALC_FIXUP_FUNC,
4758 .v.func = alc271_fixup_dmic,
4760 [ALC269_FIXUP_PCM_44K] = {
4761 .type = ALC_FIXUP_FUNC,
4762 .v.func = alc269_fixup_pcm_44k,
4764 [ALC269_FIXUP_STEREO_DMIC] = {
4765 .type = ALC_FIXUP_FUNC,
4766 .v.func = alc269_fixup_stereo_dmic,
4768 [ALC269_FIXUP_QUANTA_MUTE] = {
4769 .type = ALC_FIXUP_FUNC,
4770 .v.func = alc269_fixup_quanta_mute,
4772 [ALC269_FIXUP_LIFEBOOK] = {
4773 .type = ALC_FIXUP_PINS,
4774 .v.pins = (const struct alc_pincfg[]) {
4775 { 0x1a, 0x2101103f }, /* dock line-out */
4776 { 0x1b, 0x23a11040 }, /* dock mic-in */
4780 .chain_id = ALC269_FIXUP_QUANTA_MUTE
4782 [ALC269_FIXUP_AMIC] = {
4783 .type = ALC_FIXUP_PINS,
4784 .v.pins = (const struct alc_pincfg[]) {
4785 { 0x14, 0x99130110 }, /* speaker */
4786 { 0x15, 0x0121401f }, /* HP out */
4787 { 0x18, 0x01a19c20 }, /* mic */
4788 { 0x19, 0x99a3092f }, /* int-mic */
4792 [ALC269_FIXUP_DMIC] = {
4793 .type = ALC_FIXUP_PINS,
4794 .v.pins = (const struct alc_pincfg[]) {
4795 { 0x12, 0x99a3092f }, /* int-mic */
4796 { 0x14, 0x99130110 }, /* speaker */
4797 { 0x15, 0x0121401f }, /* HP out */
4798 { 0x18, 0x01a19c20 }, /* mic */
4802 [ALC269VB_FIXUP_AMIC] = {
4803 .type = ALC_FIXUP_PINS,
4804 .v.pins = (const struct alc_pincfg[]) {
4805 { 0x14, 0x99130110 }, /* speaker */
4806 { 0x18, 0x01a19c20 }, /* mic */
4807 { 0x19, 0x99a3092f }, /* int-mic */
4808 { 0x21, 0x0121401f }, /* HP out */
4812 [ALC269_FIXUP_DMIC] = {
4813 .type = ALC_FIXUP_PINS,
4814 .v.pins = (const struct alc_pincfg[]) {
4815 { 0x12, 0x99a3092f }, /* int-mic */
4816 { 0x14, 0x99130110 }, /* speaker */
4817 { 0x18, 0x01a19c20 }, /* mic */
4818 { 0x21, 0x0121401f }, /* HP out */
4824 static const struct snd_pci_quirk alc269_fixup_tbl[] = {
4825 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
4826 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC),
4827 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC),
4828 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC),
4829 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
4830 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
4831 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
4832 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
4833 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
4834 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
4835 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
4836 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC),
4837 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK),
4838 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
4839 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
4840 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
4841 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
4842 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
4843 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_QUANTA_MUTE),
4844 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Lenovo Ideapd", ALC269_FIXUP_PCM_44K),
4845 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
4848 /* Below is a quirk table taken from the old code.
4849 * Basically the device should work as is without the fixup table.
4850 * If BIOS doesn't give a proper info, enable the corresponding
4853 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
4855 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC),
4856 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269_FIXUP_AMIC),
4857 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC),
4858 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC),
4859 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC),
4860 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC),
4861 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC),
4862 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC),
4863 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC),
4864 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC),
4865 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC),
4866 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC),
4867 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC),
4868 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC),
4869 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC),
4870 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC),
4871 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC),
4872 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC),
4873 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC),
4874 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC),
4875 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC),
4876 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC),
4877 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC),
4878 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC),
4879 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC),
4880 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC),
4881 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC),
4882 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC),
4883 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC),
4884 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC),
4885 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC),
4886 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC),
4887 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC),
4888 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC),
4889 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC),
4890 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC),
4891 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC),
4892 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC),
4893 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC),
4894 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC),
4899 static const struct alc_model_fixup alc269_fixup_models[] = {
4900 {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"},
4901 {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"},
4906 static int alc269_fill_coef(struct hda_codec *codec)
4910 if ((alc_read_coef_idx(codec, 0) & 0x00ff) < 0x015) {
4911 alc_write_coef_idx(codec, 0xf, 0x960b);
4912 alc_write_coef_idx(codec, 0xe, 0x8817);
4915 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x016) {
4916 alc_write_coef_idx(codec, 0xf, 0x960b);
4917 alc_write_coef_idx(codec, 0xe, 0x8814);
4920 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
4921 val = alc_read_coef_idx(codec, 0x04);
4922 /* Power up output pin */
4923 alc_write_coef_idx(codec, 0x04, val | (1<<11));
4926 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
4927 val = alc_read_coef_idx(codec, 0xd);
4928 if ((val & 0x0c00) >> 10 != 0x1) {
4929 /* Capless ramp up clock control */
4930 alc_write_coef_idx(codec, 0xd, val | (1<<10));
4932 val = alc_read_coef_idx(codec, 0x17);
4933 if ((val & 0x01c0) >> 6 != 0x4) {
4934 /* Class D power on reset */
4935 alc_write_coef_idx(codec, 0x17, val | (1<<7));
4939 val = alc_read_coef_idx(codec, 0xd); /* Class D */
4940 alc_write_coef_idx(codec, 0xd, val | (1<<14));
4942 val = alc_read_coef_idx(codec, 0x4); /* HP */
4943 alc_write_coef_idx(codec, 0x4, val | (1<<11));
4950 static int patch_alc269(struct hda_codec *codec)
4952 struct alc_spec *spec;
4955 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4961 spec->mixer_nid = 0x0b;
4963 alc_auto_parse_customize_define(codec);
4965 if (codec->vendor_id == 0x10ec0269) {
4967 spec->codec_variant = ALC269_TYPE_ALC269VA;
4968 coef = alc_read_coef_idx(codec, 0);
4969 if ((coef & 0x00f0) == 0x0010) {
4970 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
4971 spec->cdefine.platform_type == 1) {
4972 alc_codec_rename(codec, "ALC271X");
4973 } else if ((coef & 0xf000) == 0x2000) {
4974 alc_codec_rename(codec, "ALC259");
4975 } else if ((coef & 0xf000) == 0x3000) {
4976 alc_codec_rename(codec, "ALC258");
4977 } else if ((coef & 0xfff0) == 0x3010) {
4978 alc_codec_rename(codec, "ALC277");
4980 alc_codec_rename(codec, "ALC269VB");
4982 spec->codec_variant = ALC269_TYPE_ALC269VB;
4983 } else if ((coef & 0x00f0) == 0x0020) {
4985 alc_codec_rename(codec, "ALC259");
4986 else if (coef == 0x6023)
4987 alc_codec_rename(codec, "ALC281X");
4988 else if (codec->bus->pci->subsystem_vendor == 0x17aa &&
4989 codec->bus->pci->subsystem_device == 0x21f3)
4990 alc_codec_rename(codec, "ALC3202");
4992 alc_codec_rename(codec, "ALC269VC");
4993 spec->codec_variant = ALC269_TYPE_ALC269VC;
4995 alc_fix_pll_init(codec, 0x20, 0x04, 15);
4996 alc269_fill_coef(codec);
4999 alc_pick_fixup(codec, alc269_fixup_models,
5000 alc269_fixup_tbl, alc269_fixups);
5001 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
5003 /* automatic parse from the BIOS config */
5004 err = alc269_parse_auto_config(codec);
5010 if (!spec->no_analog && !spec->adc_nids) {
5011 alc_auto_fill_adc_caps(codec);
5012 alc_rebuild_imux_for_auto_mic(codec);
5013 alc_remove_invalid_adc_nids(codec);
5016 if (!spec->no_analog && !spec->cap_mixer)
5017 set_capture_mixer(codec);
5019 if (!spec->no_analog && has_cdefine_beep(codec)) {
5020 err = snd_hda_attach_beep_device(codec, 0x1);
5025 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
5028 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
5030 spec->vmaster_nid = 0x02;
5032 codec->patch_ops = alc_patch_ops;
5034 codec->patch_ops.resume = alc269_resume;
5036 spec->init_hook = alc_auto_init_std;
5037 spec->shutup = alc269_shutup;
5039 alc_init_jacks(codec);
5040 #ifdef CONFIG_SND_HDA_POWER_SAVE
5041 if (!spec->loopback.amplist)
5042 spec->loopback.amplist = alc269_loopbacks;
5043 if (alc269_mic2_for_mute_led(codec))
5044 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
5054 static int alc861_parse_auto_config(struct hda_codec *codec)
5056 static const hda_nid_t alc861_ignore[] = { 0x1d, 0 };
5057 static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 };
5058 return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids);
5061 #ifdef CONFIG_SND_HDA_POWER_SAVE
5062 static const struct hda_amp_list alc861_loopbacks[] = {
5063 { 0x15, HDA_INPUT, 0 },
5064 { 0x15, HDA_INPUT, 1 },
5065 { 0x15, HDA_INPUT, 2 },
5066 { 0x15, HDA_INPUT, 3 },
5072 /* Pin config fixes */
5074 PINFIX_FSC_AMILO_PI1505,
5077 static const struct alc_fixup alc861_fixups[] = {
5078 [PINFIX_FSC_AMILO_PI1505] = {
5079 .type = ALC_FIXUP_PINS,
5080 .v.pins = (const struct alc_pincfg[]) {
5081 { 0x0b, 0x0221101f }, /* HP */
5082 { 0x0f, 0x90170310 }, /* speaker */
5088 static const struct snd_pci_quirk alc861_fixup_tbl[] = {
5089 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
5095 static int patch_alc861(struct hda_codec *codec)
5097 struct alc_spec *spec;
5100 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5106 spec->mixer_nid = 0x15;
5108 alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
5109 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
5111 /* automatic parse from the BIOS config */
5112 err = alc861_parse_auto_config(codec);
5118 if (!spec->no_analog && !spec->adc_nids) {
5119 alc_auto_fill_adc_caps(codec);
5120 alc_rebuild_imux_for_auto_mic(codec);
5121 alc_remove_invalid_adc_nids(codec);
5124 if (!spec->no_analog && !spec->cap_mixer)
5125 set_capture_mixer(codec);
5127 if (!spec->no_analog) {
5128 err = snd_hda_attach_beep_device(codec, 0x23);
5133 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
5136 spec->vmaster_nid = 0x03;
5138 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
5140 codec->patch_ops = alc_patch_ops;
5141 spec->init_hook = alc_auto_init_std;
5142 #ifdef CONFIG_SND_HDA_POWER_SAVE
5143 spec->power_hook = alc_power_eapd;
5144 if (!spec->loopback.amplist)
5145 spec->loopback.amplist = alc861_loopbacks;
5156 * In addition, an independent DAC
5158 #ifdef CONFIG_SND_HDA_POWER_SAVE
5159 #define alc861vd_loopbacks alc880_loopbacks
5162 static int alc861vd_parse_auto_config(struct hda_codec *codec)
5164 static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
5165 static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 };
5166 return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids);
5170 ALC660VD_FIX_ASUS_GPIO1,
5171 ALC861VD_FIX_DALLAS,
5174 /* exclude VREF80 */
5175 static void alc861vd_fixup_dallas(struct hda_codec *codec,
5176 const struct alc_fixup *fix, int action)
5178 if (action == ALC_FIXUP_ACT_PRE_PROBE) {
5179 snd_hda_override_pin_caps(codec, 0x18, 0x00001714);
5180 snd_hda_override_pin_caps(codec, 0x19, 0x0000171c);
5184 static const struct alc_fixup alc861vd_fixups[] = {
5185 [ALC660VD_FIX_ASUS_GPIO1] = {
5186 .type = ALC_FIXUP_VERBS,
5187 .v.verbs = (const struct hda_verb[]) {
5189 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5190 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5191 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5195 [ALC861VD_FIX_DALLAS] = {
5196 .type = ALC_FIXUP_FUNC,
5197 .v.func = alc861vd_fixup_dallas,
5201 static const struct snd_pci_quirk alc861vd_fixup_tbl[] = {
5202 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS),
5203 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
5204 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS),
5208 static const struct hda_verb alc660vd_eapd_verbs[] = {
5209 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
5210 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
5216 static int patch_alc861vd(struct hda_codec *codec)
5218 struct alc_spec *spec;
5221 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5227 spec->mixer_nid = 0x0b;
5229 alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
5230 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
5232 /* automatic parse from the BIOS config */
5233 err = alc861vd_parse_auto_config(codec);
5239 if (codec->vendor_id == 0x10ec0660) {
5240 /* always turn on EAPD */
5241 add_verb(spec, alc660vd_eapd_verbs);
5244 if (!spec->no_analog && !spec->adc_nids) {
5245 alc_auto_fill_adc_caps(codec);
5246 alc_rebuild_imux_for_auto_mic(codec);
5247 alc_remove_invalid_adc_nids(codec);
5250 if (!spec->no_analog && !spec->cap_mixer)
5251 set_capture_mixer(codec);
5253 if (!spec->no_analog) {
5254 err = snd_hda_attach_beep_device(codec, 0x23);
5259 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
5262 spec->vmaster_nid = 0x02;
5264 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
5266 codec->patch_ops = alc_patch_ops;
5268 spec->init_hook = alc_auto_init_std;
5269 spec->shutup = alc_eapd_shutup;
5270 #ifdef CONFIG_SND_HDA_POWER_SAVE
5271 if (!spec->loopback.amplist)
5272 spec->loopback.amplist = alc861vd_loopbacks;
5281 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
5282 * configuration. Each pin widget can choose any input DACs and a mixer.
5283 * Each ADC is connected from a mixer of all inputs. This makes possible
5284 * 6-channel independent captures.
5286 * In addition, an independent DAC for the multi-playback (not used in this
5289 #ifdef CONFIG_SND_HDA_POWER_SAVE
5290 #define alc662_loopbacks alc880_loopbacks
5294 * BIOS auto configuration
5297 static int alc662_parse_auto_config(struct hda_codec *codec)
5299 static const hda_nid_t alc662_ignore[] = { 0x1d, 0 };
5300 static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 };
5301 static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 };
5302 const hda_nid_t *ssids;
5304 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
5305 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
5306 ssids = alc663_ssids;
5308 ssids = alc662_ssids;
5309 return alc_parse_auto_config(codec, alc662_ignore, ssids);
5312 static void alc272_fixup_mario(struct hda_codec *codec,
5313 const struct alc_fixup *fix, int action)
5315 if (action != ALC_FIXUP_ACT_PROBE)
5317 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
5318 (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
5319 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
5320 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5321 (0 << AC_AMPCAP_MUTE_SHIFT)))
5323 "hda_codec: failed to override amp caps for NID 0x2\n");
5327 ALC662_FIXUP_ASPIRE,
5328 ALC662_FIXUP_IDEAPAD,
5330 ALC662_FIXUP_CZC_P10T,
5331 ALC662_FIXUP_SKU_IGNORE,
5332 ALC662_FIXUP_HP_RP5800,
5333 ALC662_FIXUP_ASUS_MODE1,
5334 ALC662_FIXUP_ASUS_MODE2,
5335 ALC662_FIXUP_ASUS_MODE3,
5336 ALC662_FIXUP_ASUS_MODE4,
5337 ALC662_FIXUP_ASUS_MODE5,
5338 ALC662_FIXUP_ASUS_MODE6,
5339 ALC662_FIXUP_ASUS_MODE7,
5340 ALC662_FIXUP_ASUS_MODE8,
5343 static const struct alc_fixup alc662_fixups[] = {
5344 [ALC662_FIXUP_ASPIRE] = {
5345 .type = ALC_FIXUP_PINS,
5346 .v.pins = (const struct alc_pincfg[]) {
5347 { 0x15, 0x99130112 }, /* subwoofer */
5351 [ALC662_FIXUP_IDEAPAD] = {
5352 .type = ALC_FIXUP_PINS,
5353 .v.pins = (const struct alc_pincfg[]) {
5354 { 0x17, 0x99130112 }, /* subwoofer */
5358 [ALC272_FIXUP_MARIO] = {
5359 .type = ALC_FIXUP_FUNC,
5360 .v.func = alc272_fixup_mario,
5362 [ALC662_FIXUP_CZC_P10T] = {
5363 .type = ALC_FIXUP_VERBS,
5364 .v.verbs = (const struct hda_verb[]) {
5365 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
5369 [ALC662_FIXUP_SKU_IGNORE] = {
5370 .type = ALC_FIXUP_SKU,
5371 .v.sku = ALC_FIXUP_SKU_IGNORE,
5373 [ALC662_FIXUP_HP_RP5800] = {
5374 .type = ALC_FIXUP_PINS,
5375 .v.pins = (const struct alc_pincfg[]) {
5376 { 0x14, 0x0221201f }, /* HP out */
5380 .chain_id = ALC662_FIXUP_SKU_IGNORE
5382 [ALC662_FIXUP_ASUS_MODE1] = {
5383 .type = ALC_FIXUP_PINS,
5384 .v.pins = (const struct alc_pincfg[]) {
5385 { 0x14, 0x99130110 }, /* speaker */
5386 { 0x18, 0x01a19c20 }, /* mic */
5387 { 0x19, 0x99a3092f }, /* int-mic */
5388 { 0x21, 0x0121401f }, /* HP out */
5392 .chain_id = ALC662_FIXUP_SKU_IGNORE
5394 [ALC662_FIXUP_ASUS_MODE2] = {
5395 .type = ALC_FIXUP_PINS,
5396 .v.pins = (const struct alc_pincfg[]) {
5397 { 0x14, 0x99130110 }, /* speaker */
5398 { 0x18, 0x01a19820 }, /* mic */
5399 { 0x19, 0x99a3092f }, /* int-mic */
5400 { 0x1b, 0x0121401f }, /* HP out */
5404 .chain_id = ALC662_FIXUP_SKU_IGNORE
5406 [ALC662_FIXUP_ASUS_MODE3] = {
5407 .type = ALC_FIXUP_PINS,
5408 .v.pins = (const struct alc_pincfg[]) {
5409 { 0x14, 0x99130110 }, /* speaker */
5410 { 0x15, 0x0121441f }, /* HP */
5411 { 0x18, 0x01a19840 }, /* mic */
5412 { 0x19, 0x99a3094f }, /* int-mic */
5413 { 0x21, 0x01211420 }, /* HP2 */
5417 .chain_id = ALC662_FIXUP_SKU_IGNORE
5419 [ALC662_FIXUP_ASUS_MODE4] = {
5420 .type = ALC_FIXUP_PINS,
5421 .v.pins = (const struct alc_pincfg[]) {
5422 { 0x14, 0x99130110 }, /* speaker */
5423 { 0x16, 0x99130111 }, /* speaker */
5424 { 0x18, 0x01a19840 }, /* mic */
5425 { 0x19, 0x99a3094f }, /* int-mic */
5426 { 0x21, 0x0121441f }, /* HP */
5430 .chain_id = ALC662_FIXUP_SKU_IGNORE
5432 [ALC662_FIXUP_ASUS_MODE5] = {
5433 .type = ALC_FIXUP_PINS,
5434 .v.pins = (const struct alc_pincfg[]) {
5435 { 0x14, 0x99130110 }, /* speaker */
5436 { 0x15, 0x0121441f }, /* HP */
5437 { 0x16, 0x99130111 }, /* speaker */
5438 { 0x18, 0x01a19840 }, /* mic */
5439 { 0x19, 0x99a3094f }, /* int-mic */
5443 .chain_id = ALC662_FIXUP_SKU_IGNORE
5445 [ALC662_FIXUP_ASUS_MODE6] = {
5446 .type = ALC_FIXUP_PINS,
5447 .v.pins = (const struct alc_pincfg[]) {
5448 { 0x14, 0x99130110 }, /* speaker */
5449 { 0x15, 0x01211420 }, /* HP2 */
5450 { 0x18, 0x01a19840 }, /* mic */
5451 { 0x19, 0x99a3094f }, /* int-mic */
5452 { 0x1b, 0x0121441f }, /* HP */
5456 .chain_id = ALC662_FIXUP_SKU_IGNORE
5458 [ALC662_FIXUP_ASUS_MODE7] = {
5459 .type = ALC_FIXUP_PINS,
5460 .v.pins = (const struct alc_pincfg[]) {
5461 { 0x14, 0x99130110 }, /* speaker */
5462 { 0x17, 0x99130111 }, /* speaker */
5463 { 0x18, 0x01a19840 }, /* mic */
5464 { 0x19, 0x99a3094f }, /* int-mic */
5465 { 0x1b, 0x01214020 }, /* HP */
5466 { 0x21, 0x0121401f }, /* HP */
5470 .chain_id = ALC662_FIXUP_SKU_IGNORE
5472 [ALC662_FIXUP_ASUS_MODE8] = {
5473 .type = ALC_FIXUP_PINS,
5474 .v.pins = (const struct alc_pincfg[]) {
5475 { 0x14, 0x99130110 }, /* speaker */
5476 { 0x12, 0x99a30970 }, /* int-mic */
5477 { 0x15, 0x01214020 }, /* HP */
5478 { 0x17, 0x99130111 }, /* speaker */
5479 { 0x18, 0x01a19840 }, /* mic */
5480 { 0x21, 0x0121401f }, /* HP */
5484 .chain_id = ALC662_FIXUP_SKU_IGNORE
5488 static const struct snd_pci_quirk alc662_fixup_tbl[] = {
5489 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2),
5490 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
5491 SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE),
5492 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
5493 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
5494 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2),
5495 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
5496 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
5497 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
5498 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
5501 /* Below is a quirk table taken from the old code.
5502 * Basically the device should work as is without the fixup table.
5503 * If BIOS doesn't give a proper info, enable the corresponding
5506 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1),
5507 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3),
5508 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1),
5509 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3),
5510 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
5511 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
5512 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
5513 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1),
5514 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1),
5515 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
5516 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7),
5517 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7),
5518 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8),
5519 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3),
5520 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1),
5521 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
5522 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2),
5523 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1),
5524 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
5525 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
5526 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
5527 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
5528 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1),
5529 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3),
5530 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2),
5531 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
5532 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5),
5533 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
5534 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
5535 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1),
5536 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
5537 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
5538 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3),
5539 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3),
5540 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1),
5541 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1),
5542 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1),
5543 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1),
5544 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1),
5545 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
5546 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2),
5547 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1),
5548 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
5549 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3),
5550 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1),
5551 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1),
5552 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1),
5553 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2),
5554 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
5555 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4),
5560 static const struct alc_model_fixup alc662_fixup_models[] = {
5561 {.id = ALC272_FIXUP_MARIO, .name = "mario"},
5562 {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"},
5563 {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"},
5564 {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"},
5565 {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"},
5566 {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"},
5567 {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"},
5568 {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"},
5569 {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"},
5576 static int patch_alc662(struct hda_codec *codec)
5578 struct alc_spec *spec;
5582 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5588 spec->mixer_nid = 0x0b;
5590 /* handle multiple HPs as is */
5591 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
5593 alc_auto_parse_customize_define(codec);
5595 alc_fix_pll_init(codec, 0x20, 0x04, 15);
5597 coef = alc_read_coef_idx(codec, 0);
5598 if (coef == 0x8020 || coef == 0x8011)
5599 alc_codec_rename(codec, "ALC661");
5600 else if (coef & (1 << 14) &&
5601 codec->bus->pci->subsystem_vendor == 0x1025 &&
5602 spec->cdefine.platform_type == 1)
5603 alc_codec_rename(codec, "ALC272X");
5604 else if (coef == 0x4011)
5605 alc_codec_rename(codec, "ALC656");
5607 alc_pick_fixup(codec, alc662_fixup_models,
5608 alc662_fixup_tbl, alc662_fixups);
5609 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
5610 /* automatic parse from the BIOS config */
5611 err = alc662_parse_auto_config(codec);
5617 if (!spec->no_analog && !spec->adc_nids) {
5618 alc_auto_fill_adc_caps(codec);
5619 alc_rebuild_imux_for_auto_mic(codec);
5620 alc_remove_invalid_adc_nids(codec);
5623 if (!spec->no_analog && !spec->cap_mixer)
5624 set_capture_mixer(codec);
5626 if (!spec->no_analog && has_cdefine_beep(codec)) {
5627 err = snd_hda_attach_beep_device(codec, 0x1);
5632 switch (codec->vendor_id) {
5634 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
5639 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
5642 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
5646 spec->vmaster_nid = 0x02;
5648 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
5650 codec->patch_ops = alc_patch_ops;
5651 spec->init_hook = alc_auto_init_std;
5652 spec->shutup = alc_eapd_shutup;
5654 alc_init_jacks(codec);
5656 #ifdef CONFIG_SND_HDA_POWER_SAVE
5657 if (!spec->loopback.amplist)
5658 spec->loopback.amplist = alc662_loopbacks;
5664 static int patch_alc888(struct hda_codec *codec)
5666 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
5667 kfree(codec->chip_name);
5668 if (codec->vendor_id == 0x10ec0887)
5669 codec->chip_name = kstrdup("ALC887-VD", GFP_KERNEL);
5671 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
5672 if (!codec->chip_name) {
5676 return patch_alc662(codec);
5678 return patch_alc882(codec);
5681 static int patch_alc899(struct hda_codec *codec)
5683 if ((alc_read_coef_idx(codec, 0) & 0x2000) != 0x2000) {
5684 kfree(codec->chip_name);
5685 codec->chip_name = kstrdup("ALC898", GFP_KERNEL);
5687 return patch_alc882(codec);
5694 static int alc680_parse_auto_config(struct hda_codec *codec)
5696 return alc_parse_auto_config(codec, NULL, NULL);
5701 static int patch_alc680(struct hda_codec *codec)
5703 struct alc_spec *spec;
5706 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5712 /* ALC680 has no aa-loopback mixer */
5714 /* automatic parse from the BIOS config */
5715 err = alc680_parse_auto_config(codec);
5721 if (!spec->no_analog && !spec->cap_mixer)
5722 set_capture_mixer(codec);
5724 spec->vmaster_nid = 0x02;
5726 codec->patch_ops = alc_patch_ops;
5727 spec->init_hook = alc_auto_init_std;
5735 static const struct hda_codec_preset snd_hda_preset_realtek[] = {
5736 { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 },
5737 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
5738 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
5739 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
5740 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
5741 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
5742 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
5743 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
5744 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
5745 { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 },
5746 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
5747 .patch = patch_alc861 },
5748 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
5749 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
5750 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
5751 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
5752 .patch = patch_alc882 },
5753 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
5754 .patch = patch_alc662 },
5755 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
5756 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
5757 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
5758 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
5759 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
5760 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
5761 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
5762 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
5763 .patch = patch_alc882 },
5764 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
5765 .patch = patch_alc882 },
5766 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
5767 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc888 },
5768 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
5769 .patch = patch_alc882 },
5770 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
5771 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
5772 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
5773 { .id = 0x10ec0899, .name = "ALC899", .patch = patch_alc899 },
5777 MODULE_ALIAS("snd-hda-codec-id:10ec*");
5779 MODULE_LICENSE("GPL");
5780 MODULE_DESCRIPTION("Realtek HD-audio codec");
5782 static struct hda_codec_preset_list realtek_list = {
5783 .preset = snd_hda_preset_realtek,
5784 .owner = THIS_MODULE,
5787 static int __init patch_realtek_init(void)
5789 return snd_hda_add_codec_preset(&realtek_list);
5792 static void __exit patch_realtek_exit(void)
5794 snd_hda_delete_codec_preset(&realtek_list);
5797 module_init(patch_realtek_init)
5798 module_exit(patch_realtek_exit)