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@just42.net>
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <linux/init.h>
27 #include <linux/delay.h>
28 #include <linux/slab.h>
29 #include <linux/pci.h>
30 #include <linux/module.h>
31 #include <sound/core.h>
32 #include <sound/jack.h>
33 #include "hda_codec.h"
34 #include "hda_local.h"
35 #include "hda_auto_parser.h"
39 /* unsol event tags */
40 #define ALC_FRONT_EVENT 0x01
41 #define ALC_DCVOL_EVENT 0x02
42 #define ALC_HP_EVENT 0x04
43 #define ALC_MIC_EVENT 0x08
46 #define GPIO_MASK 0x03
48 /* extra amp-initialization sequence types */
57 struct alc_customize_define
{
59 unsigned char port_connectivity
;
60 unsigned char check_sum
;
61 unsigned char customization
;
62 unsigned char external_amp
;
63 unsigned int enable_pcbeep
:1;
64 unsigned int platform_type
:1;
66 unsigned int override
:1;
67 unsigned int fixup
:1; /* Means that this sku is set by driver, not read from hw */
71 hda_nid_t pin
; /* multi-io widget pin NID */
72 hda_nid_t dac
; /* DAC to be connected */
73 unsigned int ctl_in
; /* cached input-pin control value */
77 ALC_AUTOMUTE_PIN
, /* change the pin control */
78 ALC_AUTOMUTE_AMP
, /* mute/unmute the pin AMP */
79 ALC_AUTOMUTE_MIXER
, /* mute/unmute mixer widget AMP */
82 #define MAX_VOL_NIDS 0x40
84 /* make compatible with old code */
85 #define alc_apply_pincfgs snd_hda_apply_pincfgs
86 #define alc_apply_fixup snd_hda_apply_fixup
87 #define alc_pick_fixup snd_hda_pick_fixup
88 #define alc_fixup hda_fixup
89 #define alc_pincfg hda_pintbl
90 #define alc_model_fixup hda_model_fixup
92 #define ALC_FIXUP_PINS HDA_FIXUP_PINS
93 #define ALC_FIXUP_VERBS HDA_FIXUP_VERBS
94 #define ALC_FIXUP_FUNC HDA_FIXUP_FUNC
96 #define ALC_FIXUP_ACT_PRE_PROBE HDA_FIXUP_ACT_PRE_PROBE
97 #define ALC_FIXUP_ACT_PROBE HDA_FIXUP_ACT_PROBE
98 #define ALC_FIXUP_ACT_INIT HDA_FIXUP_ACT_INIT
99 #define ALC_FIXUP_ACT_BUILD HDA_FIXUP_ACT_BUILD
103 struct hda_gen_spec gen
;
105 /* codec parameterization */
106 const struct snd_kcontrol_new
*mixers
[5]; /* mixer arrays */
107 unsigned int num_mixers
;
108 const struct snd_kcontrol_new
*cap_mixer
; /* capture mixer */
109 unsigned int beep_amp
; /* beep amp value, set via set_beep_amp() */
111 char stream_name_analog
[32]; /* analog PCM stream */
112 const struct hda_pcm_stream
*stream_analog_playback
;
113 const struct hda_pcm_stream
*stream_analog_capture
;
114 const struct hda_pcm_stream
*stream_analog_alt_playback
;
115 const struct hda_pcm_stream
*stream_analog_alt_capture
;
117 char stream_name_digital
[32]; /* digital PCM stream */
118 const struct hda_pcm_stream
*stream_digital_playback
;
119 const struct hda_pcm_stream
*stream_digital_capture
;
122 struct hda_multi_out multiout
; /* playback set-up
123 * max_channels, dacs must be set
124 * dig_out_nid and hp_nid are optional
126 hda_nid_t alt_dac_nid
;
127 hda_nid_t slave_dig_outs
[3]; /* optional - for auto-parsing */
131 unsigned int num_adc_nids
;
132 const hda_nid_t
*adc_nids
;
133 const hda_nid_t
*capsrc_nids
;
134 hda_nid_t dig_in_nid
; /* digital-in NID; optional */
135 hda_nid_t mixer_nid
; /* analog-mixer NID */
136 DECLARE_BITMAP(vol_ctls
, MAX_VOL_NIDS
<< 1);
137 DECLARE_BITMAP(sw_ctls
, MAX_VOL_NIDS
<< 1);
139 /* capture setup for dynamic dual-adc switch */
141 unsigned int cur_adc_stream_tag
;
142 unsigned int cur_adc_format
;
145 unsigned int num_mux_defs
;
146 const struct hda_input_mux
*input_mux
;
147 unsigned int cur_mux
[3];
148 hda_nid_t ext_mic_pin
;
149 hda_nid_t dock_mic_pin
;
150 hda_nid_t int_mic_pin
;
153 const struct hda_channel_mode
*channel_mode
;
154 int num_channel_mode
;
156 int const_channel_count
;
157 int ext_channel_count
;
159 /* PCM information */
160 struct hda_pcm pcm_rec
[3]; /* used in alc_build_pcms() */
162 /* dynamic controls, init_verbs and input_mux */
163 struct auto_pin_cfg autocfg
;
164 struct alc_customize_define cdefine
;
165 struct snd_array kctls
;
166 struct hda_input_mux private_imux
[3];
167 hda_nid_t private_dac_nids
[AUTO_CFG_MAX_OUTS
];
168 hda_nid_t private_adc_nids
[AUTO_CFG_MAX_OUTS
];
169 hda_nid_t private_capsrc_nids
[AUTO_CFG_MAX_OUTS
];
170 hda_nid_t imux_pins
[HDA_MAX_NUM_INPUTS
];
171 unsigned int dyn_adc_idx
[HDA_MAX_NUM_INPUTS
];
172 int int_mic_idx
, ext_mic_idx
, dock_mic_idx
; /* for auto-mic */
173 hda_nid_t inv_dmic_pin
;
176 void (*init_hook
)(struct hda_codec
*codec
);
177 void (*unsol_event
)(struct hda_codec
*codec
, unsigned int res
);
178 #ifdef CONFIG_SND_HDA_POWER_SAVE
179 void (*power_hook
)(struct hda_codec
*codec
);
181 void (*shutup
)(struct hda_codec
*codec
);
182 void (*automute_hook
)(struct hda_codec
*codec
);
184 /* for pin sensing */
185 unsigned int hp_jack_present
:1;
186 unsigned int line_jack_present
:1;
187 unsigned int master_mute
:1;
188 unsigned int auto_mic
:1;
189 unsigned int auto_mic_valid_imux
:1; /* valid imux for auto-mic */
190 unsigned int automute_speaker
:1; /* automute speaker outputs */
191 unsigned int automute_lo
:1; /* automute LO outputs */
192 unsigned int detect_hp
:1; /* Headphone detection enabled */
193 unsigned int detect_lo
:1; /* Line-out detection enabled */
194 unsigned int automute_speaker_possible
:1; /* there are speakers and either LO or HP */
195 unsigned int automute_lo_possible
:1; /* there are line outs and HP */
196 unsigned int keep_vref_in_automute
:1; /* Don't clear VREF in automute */
199 unsigned int no_analog
:1; /* digital I/O only */
200 unsigned int dyn_adc_switch
:1; /* switch ADCs (for ALC275) */
201 unsigned int single_input_src
:1;
202 unsigned int vol_in_capsrc
:1; /* use capsrc volume (ADC has no vol) */
203 unsigned int parse_flags
; /* passed to snd_hda_parse_pin_defcfg() */
204 unsigned int shared_mic_hp
:1; /* HP/Mic-in sharing */
205 unsigned int inv_dmic_fixup
:1; /* has inverted digital-mic workaround */
206 unsigned int inv_dmic_muted
:1; /* R-ch of inv d-mic is muted? */
208 /* auto-mute control */
210 hda_nid_t automute_mixer_nid
[AUTO_CFG_MAX_OUTS
];
213 int codec_variant
; /* flag for other variants */
215 /* for virtual master */
216 hda_nid_t vmaster_nid
;
217 struct hda_vmaster_mute_hook vmaster_mute
;
218 #ifdef CONFIG_SND_HDA_POWER_SAVE
219 struct hda_loopback_check loopback
;
221 struct hda_amp_list loopback_list
[8];
226 unsigned int pll_coef_idx
, pll_coef_bit
;
231 struct alc_multi_io multi_io
[4];
234 struct snd_array bind_ctls
;
237 static bool check_amp_caps(struct hda_codec
*codec
, hda_nid_t nid
,
238 int dir
, unsigned int bits
)
242 if (get_wcaps(codec
, nid
) & (1 << (dir
+ 1)))
243 if (query_amp_caps(codec
, nid
, dir
) & bits
)
248 #define nid_has_mute(codec, nid, dir) \
249 check_amp_caps(codec, nid, dir, AC_AMPCAP_MUTE)
250 #define nid_has_volume(codec, nid, dir) \
251 check_amp_caps(codec, nid, dir, AC_AMPCAP_NUM_STEPS)
256 static int alc_mux_enum_info(struct snd_kcontrol
*kcontrol
,
257 struct snd_ctl_elem_info
*uinfo
)
259 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
260 struct alc_spec
*spec
= codec
->spec
;
261 unsigned int mux_idx
= snd_ctl_get_ioffidx(kcontrol
, &uinfo
->id
);
262 if (mux_idx
>= spec
->num_mux_defs
)
264 if (!spec
->input_mux
[mux_idx
].num_items
&& mux_idx
> 0)
266 return snd_hda_input_mux_info(&spec
->input_mux
[mux_idx
], uinfo
);
269 static int alc_mux_enum_get(struct snd_kcontrol
*kcontrol
,
270 struct snd_ctl_elem_value
*ucontrol
)
272 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
273 struct alc_spec
*spec
= codec
->spec
;
274 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
276 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
280 static bool alc_dyn_adc_pcm_resetup(struct hda_codec
*codec
, int cur
)
282 struct alc_spec
*spec
= codec
->spec
;
283 hda_nid_t new_adc
= spec
->adc_nids
[spec
->dyn_adc_idx
[cur
]];
285 if (spec
->cur_adc
&& spec
->cur_adc
!= new_adc
) {
286 /* stream is running, let's swap the current ADC */
287 __snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
, 1);
288 spec
->cur_adc
= new_adc
;
289 snd_hda_codec_setup_stream(codec
, new_adc
,
290 spec
->cur_adc_stream_tag
, 0,
291 spec
->cur_adc_format
);
297 static inline hda_nid_t
get_capsrc(struct alc_spec
*spec
, int idx
)
299 return spec
->capsrc_nids
?
300 spec
->capsrc_nids
[idx
] : spec
->adc_nids
[idx
];
303 static void call_update_outputs(struct hda_codec
*codec
);
304 static void alc_inv_dmic_sync(struct hda_codec
*codec
, bool force
);
306 /* select the given imux item; either unmute exclusively or select the route */
307 static int alc_mux_select(struct hda_codec
*codec
, unsigned int adc_idx
,
308 unsigned int idx
, bool force
)
310 struct alc_spec
*spec
= codec
->spec
;
311 const struct hda_input_mux
*imux
;
312 unsigned int mux_idx
;
313 int i
, type
, num_conns
;
316 if (!spec
->input_mux
)
319 mux_idx
= adc_idx
>= spec
->num_mux_defs
? 0 : adc_idx
;
320 imux
= &spec
->input_mux
[mux_idx
];
321 if (!imux
->num_items
&& mux_idx
> 0)
322 imux
= &spec
->input_mux
[0];
323 if (!imux
->num_items
)
326 if (idx
>= imux
->num_items
)
327 idx
= imux
->num_items
- 1;
328 if (spec
->cur_mux
[adc_idx
] == idx
&& !force
)
330 spec
->cur_mux
[adc_idx
] = idx
;
332 /* for shared I/O, change the pin-control accordingly */
333 if (spec
->shared_mic_hp
) {
335 hda_nid_t pin
= spec
->autocfg
.inputs
[1].pin
;
336 /* NOTE: this assumes that there are only two inputs, the
337 * first is the real internal mic and the second is HP jack.
339 if (spec
->cur_mux
[adc_idx
])
340 val
= snd_hda_get_default_vref(codec
, pin
) | PIN_IN
;
343 snd_hda_set_pin_ctl(codec
, pin
, val
);
344 spec
->automute_speaker
= !spec
->cur_mux
[adc_idx
];
345 call_update_outputs(codec
);
348 if (spec
->dyn_adc_switch
) {
349 alc_dyn_adc_pcm_resetup(codec
, idx
);
350 adc_idx
= spec
->dyn_adc_idx
[idx
];
353 nid
= get_capsrc(spec
, adc_idx
);
356 num_conns
= snd_hda_get_num_conns(codec
, nid
);
360 type
= get_wcaps_type(get_wcaps(codec
, nid
));
361 if (type
== AC_WID_AUD_MIX
) {
362 /* Matrix-mixer style (e.g. ALC882) */
363 int active
= imux
->items
[idx
].index
;
364 for (i
= 0; i
< num_conns
; i
++) {
365 unsigned int v
= (i
== active
) ? 0 : HDA_AMP_MUTE
;
366 snd_hda_codec_amp_stereo(codec
, nid
, HDA_INPUT
, i
,
370 /* MUX style (e.g. ALC880) */
371 snd_hda_codec_write_cache(codec
, nid
, 0,
372 AC_VERB_SET_CONNECT_SEL
,
373 imux
->items
[idx
].index
);
375 alc_inv_dmic_sync(codec
, true);
379 static int alc_mux_enum_put(struct snd_kcontrol
*kcontrol
,
380 struct snd_ctl_elem_value
*ucontrol
)
382 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
383 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
384 return alc_mux_select(codec
, adc_idx
,
385 ucontrol
->value
.enumerated
.item
[0], false);
389 * set up the input pin config (depending on the given auto-pin type)
391 static void alc_set_input_pin(struct hda_codec
*codec
, hda_nid_t nid
,
394 unsigned int val
= PIN_IN
;
395 if (auto_pin_type
== AUTO_PIN_MIC
)
396 val
|= snd_hda_get_default_vref(codec
, nid
);
397 snd_hda_set_pin_ctl(codec
, nid
, val
);
401 * Append the given mixer and verb elements for the later use
402 * The mixer array is referred in build_controls(), and init_verbs are
405 static void add_mixer(struct alc_spec
*spec
, const struct snd_kcontrol_new
*mix
)
407 if (snd_BUG_ON(spec
->num_mixers
>= ARRAY_SIZE(spec
->mixers
)))
409 spec
->mixers
[spec
->num_mixers
++] = mix
;
413 * GPIO setup tables, used in initialization
415 /* Enable GPIO mask and set output */
416 static const struct hda_verb alc_gpio1_init_verbs
[] = {
417 {0x01, AC_VERB_SET_GPIO_MASK
, 0x01},
418 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x01},
419 {0x01, AC_VERB_SET_GPIO_DATA
, 0x01},
423 static const struct hda_verb alc_gpio2_init_verbs
[] = {
424 {0x01, AC_VERB_SET_GPIO_MASK
, 0x02},
425 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x02},
426 {0x01, AC_VERB_SET_GPIO_DATA
, 0x02},
430 static const struct hda_verb alc_gpio3_init_verbs
[] = {
431 {0x01, AC_VERB_SET_GPIO_MASK
, 0x03},
432 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x03},
433 {0x01, AC_VERB_SET_GPIO_DATA
, 0x03},
438 * Fix hardware PLL issue
439 * On some codecs, the analog PLL gating control must be off while
440 * the default value is 1.
442 static void alc_fix_pll(struct hda_codec
*codec
)
444 struct alc_spec
*spec
= codec
->spec
;
449 snd_hda_codec_write(codec
, spec
->pll_nid
, 0, AC_VERB_SET_COEF_INDEX
,
451 val
= snd_hda_codec_read(codec
, spec
->pll_nid
, 0,
452 AC_VERB_GET_PROC_COEF
, 0);
453 snd_hda_codec_write(codec
, spec
->pll_nid
, 0, AC_VERB_SET_COEF_INDEX
,
455 snd_hda_codec_write(codec
, spec
->pll_nid
, 0, AC_VERB_SET_PROC_COEF
,
456 val
& ~(1 << spec
->pll_coef_bit
));
459 static void alc_fix_pll_init(struct hda_codec
*codec
, hda_nid_t nid
,
460 unsigned int coef_idx
, unsigned int coef_bit
)
462 struct alc_spec
*spec
= codec
->spec
;
464 spec
->pll_coef_idx
= coef_idx
;
465 spec
->pll_coef_bit
= coef_bit
;
470 * Jack detections for HP auto-mute and mic-switch
473 /* check each pin in the given array; returns true if any of them is plugged */
474 static bool detect_jacks(struct hda_codec
*codec
, int num_pins
, hda_nid_t
*pins
)
478 for (i
= 0; i
< num_pins
; i
++) {
479 hda_nid_t nid
= pins
[i
];
482 present
|= snd_hda_jack_detect(codec
, nid
);
487 /* standard HP/line-out auto-mute helper */
488 static void do_automute(struct hda_codec
*codec
, int num_pins
, hda_nid_t
*pins
,
489 bool mute
, bool hp_out
)
491 struct alc_spec
*spec
= codec
->spec
;
492 unsigned int mute_bits
= mute
? HDA_AMP_MUTE
: 0;
493 unsigned int pin_bits
= mute
? 0 : (hp_out
? PIN_HP
: PIN_OUT
);
496 for (i
= 0; i
< num_pins
; i
++) {
497 hda_nid_t nid
= pins
[i
];
501 switch (spec
->automute_mode
) {
502 case ALC_AUTOMUTE_PIN
:
503 /* don't reset VREF value in case it's controlling
504 * the amp (see alc861_fixup_asus_amp_vref_0f())
506 if (spec
->keep_vref_in_automute
) {
507 val
= snd_hda_codec_read(codec
, nid
, 0,
508 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
513 snd_hda_set_pin_ctl(codec
, nid
, val
);
515 case ALC_AUTOMUTE_AMP
:
516 snd_hda_codec_amp_stereo(codec
, nid
, HDA_OUTPUT
, 0,
517 HDA_AMP_MUTE
, mute_bits
);
519 case ALC_AUTOMUTE_MIXER
:
520 nid
= spec
->automute_mixer_nid
[i
];
523 snd_hda_codec_amp_stereo(codec
, nid
, HDA_INPUT
, 0,
524 HDA_AMP_MUTE
, mute_bits
);
525 snd_hda_codec_amp_stereo(codec
, nid
, HDA_INPUT
, 1,
526 HDA_AMP_MUTE
, mute_bits
);
532 /* Toggle outputs muting */
533 static void update_outputs(struct hda_codec
*codec
)
535 struct alc_spec
*spec
= codec
->spec
;
538 /* Control HP pins/amps depending on master_mute state;
539 * in general, HP pins/amps control should be enabled in all cases,
540 * but currently set only for master_mute, just to be safe
542 if (!spec
->shared_mic_hp
) /* don't change HP-pin when shared with mic */
543 do_automute(codec
, ARRAY_SIZE(spec
->autocfg
.hp_pins
),
544 spec
->autocfg
.hp_pins
, spec
->master_mute
, true);
546 if (!spec
->automute_speaker
)
549 on
= spec
->hp_jack_present
| spec
->line_jack_present
;
550 on
|= spec
->master_mute
;
551 do_automute(codec
, ARRAY_SIZE(spec
->autocfg
.speaker_pins
),
552 spec
->autocfg
.speaker_pins
, on
, false);
554 /* toggle line-out mutes if needed, too */
555 /* if LO is a copy of either HP or Speaker, don't need to handle it */
556 if (spec
->autocfg
.line_out_pins
[0] == spec
->autocfg
.hp_pins
[0] ||
557 spec
->autocfg
.line_out_pins
[0] == spec
->autocfg
.speaker_pins
[0])
559 if (!spec
->automute_lo
)
562 on
= spec
->hp_jack_present
;
563 on
|= spec
->master_mute
;
564 do_automute(codec
, ARRAY_SIZE(spec
->autocfg
.line_out_pins
),
565 spec
->autocfg
.line_out_pins
, on
, false);
568 static void call_update_outputs(struct hda_codec
*codec
)
570 struct alc_spec
*spec
= codec
->spec
;
571 if (spec
->automute_hook
)
572 spec
->automute_hook(codec
);
574 update_outputs(codec
);
577 /* standard HP-automute helper */
578 static void alc_hp_automute(struct hda_codec
*codec
)
580 struct alc_spec
*spec
= codec
->spec
;
582 spec
->hp_jack_present
=
583 detect_jacks(codec
, ARRAY_SIZE(spec
->autocfg
.hp_pins
),
584 spec
->autocfg
.hp_pins
);
585 if (!spec
->detect_hp
|| (!spec
->automute_speaker
&& !spec
->automute_lo
))
587 call_update_outputs(codec
);
590 /* standard line-out-automute helper */
591 static void alc_line_automute(struct hda_codec
*codec
)
593 struct alc_spec
*spec
= codec
->spec
;
595 /* check LO jack only when it's different from HP */
596 if (spec
->autocfg
.line_out_pins
[0] == spec
->autocfg
.hp_pins
[0])
599 spec
->line_jack_present
=
600 detect_jacks(codec
, ARRAY_SIZE(spec
->autocfg
.line_out_pins
),
601 spec
->autocfg
.line_out_pins
);
602 if (!spec
->automute_speaker
|| !spec
->detect_lo
)
604 call_update_outputs(codec
);
607 #define get_connection_index(codec, mux, nid) \
608 snd_hda_get_conn_index(codec, mux, nid, 0)
610 /* standard mic auto-switch helper */
611 static void alc_mic_automute(struct hda_codec
*codec
)
613 struct alc_spec
*spec
= codec
->spec
;
614 hda_nid_t
*pins
= spec
->imux_pins
;
616 if (!spec
->auto_mic
|| !spec
->auto_mic_valid_imux
)
618 if (snd_BUG_ON(!spec
->adc_nids
))
620 if (snd_BUG_ON(spec
->int_mic_idx
< 0 || spec
->ext_mic_idx
< 0))
623 if (snd_hda_jack_detect(codec
, pins
[spec
->ext_mic_idx
]))
624 alc_mux_select(codec
, 0, spec
->ext_mic_idx
, false);
625 else if (spec
->dock_mic_idx
>= 0 &&
626 snd_hda_jack_detect(codec
, pins
[spec
->dock_mic_idx
]))
627 alc_mux_select(codec
, 0, spec
->dock_mic_idx
, false);
629 alc_mux_select(codec
, 0, spec
->int_mic_idx
, false);
632 /* handle the specified unsol action (ALC_XXX_EVENT) */
633 static void alc_exec_unsol_event(struct hda_codec
*codec
, int action
)
637 alc_hp_automute(codec
);
639 case ALC_FRONT_EVENT
:
640 alc_line_automute(codec
);
643 alc_mic_automute(codec
);
646 snd_hda_jack_report_sync(codec
);
649 /* update the master volume per volume-knob's unsol event */
650 static void alc_update_knob_master(struct hda_codec
*codec
, hda_nid_t nid
)
653 struct snd_kcontrol
*kctl
;
654 struct snd_ctl_elem_value
*uctl
;
656 kctl
= snd_hda_find_mixer_ctl(codec
, "Master Playback Volume");
659 uctl
= kzalloc(sizeof(*uctl
), GFP_KERNEL
);
662 val
= snd_hda_codec_read(codec
, nid
, 0,
663 AC_VERB_GET_VOLUME_KNOB_CONTROL
, 0);
664 val
&= HDA_AMP_VOLMASK
;
665 uctl
->value
.integer
.value
[0] = val
;
666 uctl
->value
.integer
.value
[1] = val
;
667 kctl
->put(kctl
, uctl
);
671 /* unsolicited event for HP jack sensing */
672 static void alc_sku_unsol_event(struct hda_codec
*codec
, unsigned int res
)
676 if (codec
->vendor_id
== 0x10ec0880)
680 action
= snd_hda_jack_get_action(codec
, res
);
681 if (action
== ALC_DCVOL_EVENT
) {
682 /* Execute the dc-vol event here as it requires the NID
683 * but we don't pass NID to alc_exec_unsol_event().
684 * Once when we convert all static quirks to the auto-parser,
685 * this can be integerated into there.
687 struct hda_jack_tbl
*jack
;
688 jack
= snd_hda_jack_tbl_get_from_tag(codec
, res
);
690 alc_update_knob_master(codec
, jack
->nid
);
693 alc_exec_unsol_event(codec
, action
);
696 /* call init functions of standard auto-mute helpers */
697 static void alc_inithook(struct hda_codec
*codec
)
699 alc_hp_automute(codec
);
700 alc_line_automute(codec
);
701 alc_mic_automute(codec
);
704 /* additional initialization for ALC888 variants */
705 static void alc888_coef_init(struct hda_codec
*codec
)
709 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
, 0);
710 tmp
= snd_hda_codec_read(codec
, 0x20, 0, AC_VERB_GET_PROC_COEF
, 0);
711 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
, 7);
712 if ((tmp
& 0xf0) == 0x20)
714 snd_hda_codec_read(codec
, 0x20, 0,
715 AC_VERB_SET_PROC_COEF
, 0x830);
718 snd_hda_codec_read(codec
, 0x20, 0,
719 AC_VERB_SET_PROC_COEF
, 0x3030);
722 /* additional initialization for ALC889 variants */
723 static void alc889_coef_init(struct hda_codec
*codec
)
727 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
, 7);
728 tmp
= snd_hda_codec_read(codec
, 0x20, 0, AC_VERB_GET_PROC_COEF
, 0);
729 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
, 7);
730 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_PROC_COEF
, tmp
|0x2010);
733 /* turn on/off EAPD control (only if available) */
734 static void set_eapd(struct hda_codec
*codec
, hda_nid_t nid
, int on
)
736 if (get_wcaps_type(get_wcaps(codec
, nid
)) != AC_WID_PIN
)
738 if (snd_hda_query_pin_caps(codec
, nid
) & AC_PINCAP_EAPD
)
739 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_EAPD_BTLENABLE
,
743 /* turn on/off EAPD controls of the codec */
744 static void alc_auto_setup_eapd(struct hda_codec
*codec
, bool on
)
746 /* We currently only handle front, HP */
747 static hda_nid_t pins
[] = {
748 0x0f, 0x10, 0x14, 0x15, 0
751 for (p
= pins
; *p
; p
++)
752 set_eapd(codec
, *p
, on
);
755 /* generic shutup callback;
756 * just turning off EPAD and a little pause for avoiding pop-noise
758 static void alc_eapd_shutup(struct hda_codec
*codec
)
760 alc_auto_setup_eapd(codec
, false);
764 /* generic EAPD initialization */
765 static void alc_auto_init_amp(struct hda_codec
*codec
, int type
)
769 alc_auto_setup_eapd(codec
, true);
772 snd_hda_sequence_write(codec
, alc_gpio1_init_verbs
);
775 snd_hda_sequence_write(codec
, alc_gpio2_init_verbs
);
778 snd_hda_sequence_write(codec
, alc_gpio3_init_verbs
);
780 case ALC_INIT_DEFAULT
:
781 switch (codec
->vendor_id
) {
783 snd_hda_codec_write(codec
, 0x1a, 0,
784 AC_VERB_SET_COEF_INDEX
, 7);
785 tmp
= snd_hda_codec_read(codec
, 0x1a, 0,
786 AC_VERB_GET_PROC_COEF
, 0);
787 snd_hda_codec_write(codec
, 0x1a, 0,
788 AC_VERB_SET_COEF_INDEX
, 7);
789 snd_hda_codec_write(codec
, 0x1a, 0,
790 AC_VERB_SET_PROC_COEF
,
799 /*case 0x10ec0889:*/ /* this causes an SPDIF problem */
800 alc889_coef_init(codec
);
803 alc888_coef_init(codec
);
805 #if 0 /* XXX: This may cause the silent output on speaker on some machines */
808 snd_hda_codec_write(codec
, 0x20, 0,
809 AC_VERB_SET_COEF_INDEX
, 7);
810 tmp
= snd_hda_codec_read(codec
, 0x20, 0,
811 AC_VERB_GET_PROC_COEF
, 0);
812 snd_hda_codec_write(codec
, 0x20, 0,
813 AC_VERB_SET_COEF_INDEX
, 7);
814 snd_hda_codec_write(codec
, 0x20, 0,
815 AC_VERB_SET_PROC_COEF
,
825 * Auto-Mute mode mixer enum support
827 static int alc_automute_mode_info(struct snd_kcontrol
*kcontrol
,
828 struct snd_ctl_elem_info
*uinfo
)
830 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
831 struct alc_spec
*spec
= codec
->spec
;
832 static const char * const texts2
[] = {
833 "Disabled", "Enabled"
835 static const char * const texts3
[] = {
836 "Disabled", "Speaker Only", "Line Out+Speaker"
838 const char * const *texts
;
840 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
842 if (spec
->automute_speaker_possible
&& spec
->automute_lo_possible
) {
843 uinfo
->value
.enumerated
.items
= 3;
846 uinfo
->value
.enumerated
.items
= 2;
849 if (uinfo
->value
.enumerated
.item
>= uinfo
->value
.enumerated
.items
)
850 uinfo
->value
.enumerated
.item
= uinfo
->value
.enumerated
.items
- 1;
851 strcpy(uinfo
->value
.enumerated
.name
,
852 texts
[uinfo
->value
.enumerated
.item
]);
856 static int alc_automute_mode_get(struct snd_kcontrol
*kcontrol
,
857 struct snd_ctl_elem_value
*ucontrol
)
859 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
860 struct alc_spec
*spec
= codec
->spec
;
861 unsigned int val
= 0;
862 if (spec
->automute_speaker
)
864 if (spec
->automute_lo
)
867 ucontrol
->value
.enumerated
.item
[0] = val
;
871 static int alc_automute_mode_put(struct snd_kcontrol
*kcontrol
,
872 struct snd_ctl_elem_value
*ucontrol
)
874 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
875 struct alc_spec
*spec
= codec
->spec
;
877 switch (ucontrol
->value
.enumerated
.item
[0]) {
879 if (!spec
->automute_speaker
&& !spec
->automute_lo
)
881 spec
->automute_speaker
= 0;
882 spec
->automute_lo
= 0;
885 if (spec
->automute_speaker_possible
) {
886 if (!spec
->automute_lo
&& spec
->automute_speaker
)
888 spec
->automute_speaker
= 1;
889 spec
->automute_lo
= 0;
890 } else if (spec
->automute_lo_possible
) {
891 if (spec
->automute_lo
)
893 spec
->automute_lo
= 1;
898 if (!spec
->automute_lo_possible
|| !spec
->automute_speaker_possible
)
900 if (spec
->automute_speaker
&& spec
->automute_lo
)
902 spec
->automute_speaker
= 1;
903 spec
->automute_lo
= 1;
908 call_update_outputs(codec
);
912 static const struct snd_kcontrol_new alc_automute_mode_enum
= {
913 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
914 .name
= "Auto-Mute Mode",
915 .info
= alc_automute_mode_info
,
916 .get
= alc_automute_mode_get
,
917 .put
= alc_automute_mode_put
,
920 static struct snd_kcontrol_new
*alc_kcontrol_new(struct alc_spec
*spec
)
922 snd_array_init(&spec
->kctls
, sizeof(struct snd_kcontrol_new
), 32);
923 return snd_array_new(&spec
->kctls
);
926 static int alc_add_automute_mode_enum(struct hda_codec
*codec
)
928 struct alc_spec
*spec
= codec
->spec
;
929 struct snd_kcontrol_new
*knew
;
931 knew
= alc_kcontrol_new(spec
);
934 *knew
= alc_automute_mode_enum
;
935 knew
->name
= kstrdup("Auto-Mute Mode", GFP_KERNEL
);
942 * Check the availability of HP/line-out auto-mute;
943 * Set up appropriately if really supported
945 static void alc_init_automute(struct hda_codec
*codec
)
947 struct alc_spec
*spec
= codec
->spec
;
948 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
954 if (cfg
->line_out_pins
[0])
956 if (cfg
->speaker_pins
[0])
958 if (present
< 2) /* need two different output types */
961 if (!cfg
->speaker_pins
[0] &&
962 cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
) {
963 memcpy(cfg
->speaker_pins
, cfg
->line_out_pins
,
964 sizeof(cfg
->speaker_pins
));
965 cfg
->speaker_outs
= cfg
->line_outs
;
968 if (!cfg
->hp_pins
[0] &&
969 cfg
->line_out_type
== AUTO_PIN_HP_OUT
) {
970 memcpy(cfg
->hp_pins
, cfg
->line_out_pins
,
971 sizeof(cfg
->hp_pins
));
972 cfg
->hp_outs
= cfg
->line_outs
;
975 spec
->automute_mode
= ALC_AUTOMUTE_PIN
;
977 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
978 hda_nid_t nid
= cfg
->hp_pins
[i
];
979 if (!is_jack_detectable(codec
, nid
))
981 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
983 snd_hda_jack_detect_enable(codec
, nid
, ALC_HP_EVENT
);
987 if (cfg
->line_out_type
== AUTO_PIN_LINE_OUT
&& cfg
->line_outs
) {
988 if (cfg
->speaker_outs
)
989 for (i
= 0; i
< cfg
->line_outs
; i
++) {
990 hda_nid_t nid
= cfg
->line_out_pins
[i
];
991 if (!is_jack_detectable(codec
, nid
))
993 snd_printdd("realtek: Enable Line-Out "
994 "auto-muting on NID 0x%x\n", nid
);
995 snd_hda_jack_detect_enable(codec
, nid
,
999 spec
->automute_lo_possible
= spec
->detect_hp
;
1002 spec
->automute_speaker_possible
= cfg
->speaker_outs
&&
1003 (spec
->detect_hp
|| spec
->detect_lo
);
1005 spec
->automute_lo
= spec
->automute_lo_possible
;
1006 spec
->automute_speaker
= spec
->automute_speaker_possible
;
1008 if (spec
->automute_speaker_possible
|| spec
->automute_lo_possible
) {
1009 /* create a control for automute mode */
1010 alc_add_automute_mode_enum(codec
);
1011 spec
->unsol_event
= alc_sku_unsol_event
;
1015 /* return the position of NID in the list, or -1 if not found */
1016 static int find_idx_in_nid_list(hda_nid_t nid
, const hda_nid_t
*list
, int nums
)
1019 for (i
= 0; i
< nums
; i
++)
1025 /* check whether dynamic ADC-switching is available */
1026 static bool alc_check_dyn_adc_switch(struct hda_codec
*codec
)
1028 struct alc_spec
*spec
= codec
->spec
;
1029 struct hda_input_mux
*imux
= &spec
->private_imux
[0];
1033 if (imux
!= spec
->input_mux
) /* no dynamic imux? */
1036 for (n
= 0; n
< spec
->num_adc_nids
; n
++) {
1037 cap
= spec
->private_capsrc_nids
[n
];
1038 for (i
= 0; i
< imux
->num_items
; i
++) {
1039 pin
= spec
->imux_pins
[i
];
1042 if (get_connection_index(codec
, cap
, pin
) < 0)
1045 if (i
>= imux
->num_items
)
1046 return true; /* no ADC-switch is needed */
1049 for (i
= 0; i
< imux
->num_items
; i
++) {
1050 pin
= spec
->imux_pins
[i
];
1051 for (n
= 0; n
< spec
->num_adc_nids
; n
++) {
1052 cap
= spec
->private_capsrc_nids
[n
];
1053 idx
= get_connection_index(codec
, cap
, pin
);
1055 imux
->items
[i
].index
= idx
;
1056 spec
->dyn_adc_idx
[i
] = n
;
1062 snd_printdd("realtek: enabling ADC switching\n");
1063 spec
->dyn_adc_switch
= 1;
1067 /* check whether all auto-mic pins are valid; setup indices if OK */
1068 static bool alc_auto_mic_check_imux(struct hda_codec
*codec
)
1070 struct alc_spec
*spec
= codec
->spec
;
1071 const struct hda_input_mux
*imux
;
1073 if (!spec
->auto_mic
)
1075 if (spec
->auto_mic_valid_imux
)
1076 return true; /* already checked */
1078 /* fill up imux indices */
1079 if (!alc_check_dyn_adc_switch(codec
)) {
1084 imux
= spec
->input_mux
;
1085 spec
->ext_mic_idx
= find_idx_in_nid_list(spec
->ext_mic_pin
,
1086 spec
->imux_pins
, imux
->num_items
);
1087 spec
->int_mic_idx
= find_idx_in_nid_list(spec
->int_mic_pin
,
1088 spec
->imux_pins
, imux
->num_items
);
1089 spec
->dock_mic_idx
= find_idx_in_nid_list(spec
->dock_mic_pin
,
1090 spec
->imux_pins
, imux
->num_items
);
1091 if (spec
->ext_mic_idx
< 0 || spec
->int_mic_idx
< 0) {
1093 return false; /* no corresponding imux */
1096 snd_hda_jack_detect_enable(codec
, spec
->ext_mic_pin
, ALC_MIC_EVENT
);
1097 if (spec
->dock_mic_pin
)
1098 snd_hda_jack_detect_enable(codec
, spec
->dock_mic_pin
,
1101 spec
->auto_mic_valid_imux
= 1;
1107 * Check the availability of auto-mic switch;
1108 * Set up if really supported
1110 static void alc_init_auto_mic(struct hda_codec
*codec
)
1112 struct alc_spec
*spec
= codec
->spec
;
1113 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
1114 hda_nid_t fixed
, ext
, dock
;
1117 if (spec
->shared_mic_hp
)
1118 return; /* no auto-mic for the shared I/O */
1120 spec
->ext_mic_idx
= spec
->int_mic_idx
= spec
->dock_mic_idx
= -1;
1122 fixed
= ext
= dock
= 0;
1123 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
1124 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
1125 unsigned int defcfg
;
1126 defcfg
= snd_hda_codec_get_pincfg(codec
, nid
);
1127 switch (snd_hda_get_input_pin_attr(defcfg
)) {
1128 case INPUT_PIN_ATTR_INT
:
1130 return; /* already occupied */
1131 if (cfg
->inputs
[i
].type
!= AUTO_PIN_MIC
)
1132 return; /* invalid type */
1135 case INPUT_PIN_ATTR_UNUSED
:
1136 return; /* invalid entry */
1137 case INPUT_PIN_ATTR_DOCK
:
1139 return; /* already occupied */
1140 if (cfg
->inputs
[i
].type
> AUTO_PIN_LINE_IN
)
1141 return; /* invalid type */
1146 return; /* already occupied */
1147 if (cfg
->inputs
[i
].type
!= AUTO_PIN_MIC
)
1148 return; /* invalid type */
1159 if (!is_jack_detectable(codec
, ext
))
1160 return; /* no unsol support */
1161 if (dock
&& !is_jack_detectable(codec
, dock
))
1162 return; /* no unsol support */
1164 /* check imux indices */
1165 spec
->ext_mic_pin
= ext
;
1166 spec
->int_mic_pin
= fixed
;
1167 spec
->dock_mic_pin
= dock
;
1170 if (!alc_auto_mic_check_imux(codec
))
1173 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n",
1175 spec
->unsol_event
= alc_sku_unsol_event
;
1178 /* check the availabilities of auto-mute and auto-mic switches */
1179 static void alc_auto_check_switches(struct hda_codec
*codec
)
1181 alc_init_automute(codec
);
1182 alc_init_auto_mic(codec
);
1186 * Realtek SSID verification
1189 /* Could be any non-zero and even value. When used as fixup, tells
1190 * the driver to ignore any present sku defines.
1192 #define ALC_FIXUP_SKU_IGNORE (2)
1194 static void alc_fixup_sku_ignore(struct hda_codec
*codec
,
1195 const struct hda_fixup
*fix
, int action
)
1197 struct alc_spec
*spec
= codec
->spec
;
1198 if (action
== HDA_FIXUP_ACT_PRE_PROBE
) {
1199 spec
->cdefine
.fixup
= 1;
1200 spec
->cdefine
.sku_cfg
= ALC_FIXUP_SKU_IGNORE
;
1204 static int alc_auto_parse_customize_define(struct hda_codec
*codec
)
1206 unsigned int ass
, tmp
, i
;
1208 struct alc_spec
*spec
= codec
->spec
;
1210 spec
->cdefine
.enable_pcbeep
= 1; /* assume always enabled */
1212 if (spec
->cdefine
.fixup
) {
1213 ass
= spec
->cdefine
.sku_cfg
;
1214 if (ass
== ALC_FIXUP_SKU_IGNORE
)
1219 ass
= codec
->subsystem_id
& 0xffff;
1220 if (ass
!= codec
->bus
->pci
->subsystem_device
&& (ass
& 1))
1224 if (codec
->vendor_id
== 0x10ec0260)
1226 ass
= snd_hda_codec_get_pincfg(codec
, nid
);
1229 printk(KERN_INFO
"hda_codec: %s: SKU not ready 0x%08x\n",
1230 codec
->chip_name
, ass
);
1236 for (i
= 1; i
< 16; i
++) {
1240 if (((ass
>> 16) & 0xf) != tmp
)
1243 spec
->cdefine
.port_connectivity
= ass
>> 30;
1244 spec
->cdefine
.enable_pcbeep
= (ass
& 0x100000) >> 20;
1245 spec
->cdefine
.check_sum
= (ass
>> 16) & 0xf;
1246 spec
->cdefine
.customization
= ass
>> 8;
1248 spec
->cdefine
.sku_cfg
= ass
;
1249 spec
->cdefine
.external_amp
= (ass
& 0x38) >> 3;
1250 spec
->cdefine
.platform_type
= (ass
& 0x4) >> 2;
1251 spec
->cdefine
.swap
= (ass
& 0x2) >> 1;
1252 spec
->cdefine
.override
= ass
& 0x1;
1254 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1255 nid
, spec
->cdefine
.sku_cfg
);
1256 snd_printd("SKU: port_connectivity=0x%x\n",
1257 spec
->cdefine
.port_connectivity
);
1258 snd_printd("SKU: enable_pcbeep=0x%x\n", spec
->cdefine
.enable_pcbeep
);
1259 snd_printd("SKU: check_sum=0x%08x\n", spec
->cdefine
.check_sum
);
1260 snd_printd("SKU: customization=0x%08x\n", spec
->cdefine
.customization
);
1261 snd_printd("SKU: external_amp=0x%x\n", spec
->cdefine
.external_amp
);
1262 snd_printd("SKU: platform_type=0x%x\n", spec
->cdefine
.platform_type
);
1263 snd_printd("SKU: swap=0x%x\n", spec
->cdefine
.swap
);
1264 snd_printd("SKU: override=0x%x\n", spec
->cdefine
.override
);
1269 /* return true if the given NID is found in the list */
1270 static bool found_in_nid_list(hda_nid_t nid
, const hda_nid_t
*list
, int nums
)
1272 return find_idx_in_nid_list(nid
, list
, nums
) >= 0;
1275 /* check subsystem ID and set up device-specific initialization;
1276 * return 1 if initialized, 0 if invalid SSID
1278 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1279 * 31 ~ 16 : Manufacture ID
1281 * 7 ~ 0 : Assembly ID
1282 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1284 static int alc_subsystem_id(struct hda_codec
*codec
,
1285 hda_nid_t porta
, hda_nid_t porte
,
1286 hda_nid_t portd
, hda_nid_t porti
)
1288 unsigned int ass
, tmp
, i
;
1290 struct alc_spec
*spec
= codec
->spec
;
1292 if (spec
->cdefine
.fixup
) {
1293 ass
= spec
->cdefine
.sku_cfg
;
1294 if (ass
== ALC_FIXUP_SKU_IGNORE
)
1299 ass
= codec
->subsystem_id
& 0xffff;
1300 if ((ass
!= codec
->bus
->pci
->subsystem_device
) && (ass
& 1))
1303 /* invalid SSID, check the special NID pin defcfg instead */
1305 * 31~30 : port connectivity
1308 * 19~16 : Check sum (15:1)
1313 if (codec
->vendor_id
== 0x10ec0260)
1315 ass
= snd_hda_codec_get_pincfg(codec
, nid
);
1316 snd_printd("realtek: No valid SSID, "
1317 "checking pincfg 0x%08x for NID 0x%x\n",
1321 if ((ass
>> 30) != 1) /* no physical connection */
1326 for (i
= 1; i
< 16; i
++) {
1330 if (((ass
>> 16) & 0xf) != tmp
)
1333 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1334 ass
& 0xffff, codec
->vendor_id
);
1338 * 2 : 0 --> Desktop, 1 --> Laptop
1339 * 3~5 : External Amplifier control
1342 tmp
= (ass
& 0x38) >> 3; /* external Amp control */
1345 spec
->init_amp
= ALC_INIT_GPIO1
;
1348 spec
->init_amp
= ALC_INIT_GPIO2
;
1351 spec
->init_amp
= ALC_INIT_GPIO3
;
1355 spec
->init_amp
= ALC_INIT_DEFAULT
;
1359 /* is laptop or Desktop and enable the function "Mute internal speaker
1360 * when the external headphone out jack is plugged"
1362 if (!(ass
& 0x8000))
1365 * 10~8 : Jack location
1366 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1368 * 15 : 1 --> enable the function "Mute internal speaker
1369 * when the external headphone out jack is plugged"
1371 if (!spec
->autocfg
.hp_pins
[0] &&
1372 !(spec
->autocfg
.line_out_pins
[0] &&
1373 spec
->autocfg
.line_out_type
== AUTO_PIN_HP_OUT
)) {
1375 tmp
= (ass
>> 11) & 0x3; /* HP to chassis */
1386 if (found_in_nid_list(nid
, spec
->autocfg
.line_out_pins
,
1387 spec
->autocfg
.line_outs
))
1389 spec
->autocfg
.hp_pins
[0] = nid
;
1394 /* Check the validity of ALC subsystem-id
1395 * ports contains an array of 4 pin NIDs for port-A, E, D and I */
1396 static void alc_ssid_check(struct hda_codec
*codec
, const hda_nid_t
*ports
)
1398 if (!alc_subsystem_id(codec
, ports
[0], ports
[1], ports
[2], ports
[3])) {
1399 struct alc_spec
*spec
= codec
->spec
;
1400 snd_printd("realtek: "
1401 "Enable default setup for auto mode as fallback\n");
1402 spec
->init_amp
= ALC_INIT_DEFAULT
;
1407 * COEF access helper functions
1409 static int alc_read_coef_idx(struct hda_codec
*codec
,
1410 unsigned int coef_idx
)
1413 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
,
1415 val
= snd_hda_codec_read(codec
, 0x20, 0,
1416 AC_VERB_GET_PROC_COEF
, 0);
1420 static void alc_write_coef_idx(struct hda_codec
*codec
, unsigned int coef_idx
,
1421 unsigned int coef_val
)
1423 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
,
1425 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_PROC_COEF
,
1429 /* a special bypass for COEF 0; read the cached value at the second time */
1430 static unsigned int alc_get_coef0(struct hda_codec
*codec
)
1432 struct alc_spec
*spec
= codec
->spec
;
1434 spec
->coef0
= alc_read_coef_idx(codec
, 0);
1439 * Digital I/O handling
1442 /* set right pin controls for digital I/O */
1443 static void alc_auto_init_digital(struct hda_codec
*codec
)
1445 struct alc_spec
*spec
= codec
->spec
;
1449 for (i
= 0; i
< spec
->autocfg
.dig_outs
; i
++) {
1450 pin
= spec
->autocfg
.dig_out_pins
[i
];
1453 snd_hda_set_pin_ctl(codec
, pin
, PIN_OUT
);
1455 dac
= spec
->multiout
.dig_out_nid
;
1457 dac
= spec
->slave_dig_outs
[i
- 1];
1458 if (!dac
|| !(get_wcaps(codec
, dac
) & AC_WCAP_OUT_AMP
))
1460 snd_hda_codec_write(codec
, dac
, 0,
1461 AC_VERB_SET_AMP_GAIN_MUTE
,
1464 pin
= spec
->autocfg
.dig_in_pin
;
1466 snd_hda_set_pin_ctl(codec
, pin
, PIN_IN
);
1469 /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1470 static void alc_auto_parse_digital(struct hda_codec
*codec
)
1472 struct alc_spec
*spec
= codec
->spec
;
1476 /* support multiple SPDIFs; the secondary is set up as a slave */
1478 for (i
= 0; i
< spec
->autocfg
.dig_outs
; i
++) {
1480 err
= snd_hda_get_connections(codec
,
1481 spec
->autocfg
.dig_out_pins
[i
],
1482 conn
, ARRAY_SIZE(conn
));
1485 dig_nid
= conn
[0]; /* assume the first element is audio-out */
1487 spec
->multiout
.dig_out_nid
= dig_nid
;
1488 spec
->dig_out_type
= spec
->autocfg
.dig_out_type
[0];
1490 spec
->multiout
.slave_dig_outs
= spec
->slave_dig_outs
;
1491 if (nums
>= ARRAY_SIZE(spec
->slave_dig_outs
) - 1)
1493 spec
->slave_dig_outs
[nums
- 1] = dig_nid
;
1498 if (spec
->autocfg
.dig_in_pin
) {
1499 dig_nid
= codec
->start_nid
;
1500 for (i
= 0; i
< codec
->num_nodes
; i
++, dig_nid
++) {
1501 unsigned int wcaps
= get_wcaps(codec
, dig_nid
);
1502 if (get_wcaps_type(wcaps
) != AC_WID_AUD_IN
)
1504 if (!(wcaps
& AC_WCAP_DIGITAL
))
1506 if (!(wcaps
& AC_WCAP_CONN_LIST
))
1508 err
= get_connection_index(codec
, dig_nid
,
1509 spec
->autocfg
.dig_in_pin
);
1511 spec
->dig_in_nid
= dig_nid
;
1519 * capture mixer elements
1521 static int alc_cap_vol_info(struct snd_kcontrol
*kcontrol
,
1522 struct snd_ctl_elem_info
*uinfo
)
1524 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1525 struct alc_spec
*spec
= codec
->spec
;
1529 mutex_lock(&codec
->control_mutex
);
1530 if (spec
->vol_in_capsrc
)
1531 val
= HDA_COMPOSE_AMP_VAL(spec
->capsrc_nids
[0], 3, 0, HDA_OUTPUT
);
1533 val
= HDA_COMPOSE_AMP_VAL(spec
->adc_nids
[0], 3, 0, HDA_INPUT
);
1534 kcontrol
->private_value
= val
;
1535 err
= snd_hda_mixer_amp_volume_info(kcontrol
, uinfo
);
1536 mutex_unlock(&codec
->control_mutex
);
1540 static int alc_cap_vol_tlv(struct snd_kcontrol
*kcontrol
, int op_flag
,
1541 unsigned int size
, unsigned int __user
*tlv
)
1543 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1544 struct alc_spec
*spec
= codec
->spec
;
1548 mutex_lock(&codec
->control_mutex
);
1549 if (spec
->vol_in_capsrc
)
1550 val
= HDA_COMPOSE_AMP_VAL(spec
->capsrc_nids
[0], 3, 0, HDA_OUTPUT
);
1552 val
= HDA_COMPOSE_AMP_VAL(spec
->adc_nids
[0], 3, 0, HDA_INPUT
);
1553 kcontrol
->private_value
= val
;
1554 err
= snd_hda_mixer_amp_tlv(kcontrol
, op_flag
, size
, tlv
);
1555 mutex_unlock(&codec
->control_mutex
);
1559 typedef int (*getput_call_t
)(struct snd_kcontrol
*kcontrol
,
1560 struct snd_ctl_elem_value
*ucontrol
);
1562 static int alc_cap_getput_caller(struct snd_kcontrol
*kcontrol
,
1563 struct snd_ctl_elem_value
*ucontrol
,
1564 getput_call_t func
, bool is_put
)
1566 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1567 struct alc_spec
*spec
= codec
->spec
;
1570 mutex_lock(&codec
->control_mutex
);
1571 if (is_put
&& spec
->dyn_adc_switch
) {
1572 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
1573 kcontrol
->private_value
=
1574 HDA_COMPOSE_AMP_VAL(spec
->adc_nids
[i
],
1576 err
= func(kcontrol
, ucontrol
);
1581 i
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
1582 if (spec
->vol_in_capsrc
)
1583 kcontrol
->private_value
=
1584 HDA_COMPOSE_AMP_VAL(spec
->capsrc_nids
[i
],
1587 kcontrol
->private_value
=
1588 HDA_COMPOSE_AMP_VAL(spec
->adc_nids
[i
],
1590 err
= func(kcontrol
, ucontrol
);
1592 if (err
>= 0 && is_put
)
1593 alc_inv_dmic_sync(codec
, false);
1595 mutex_unlock(&codec
->control_mutex
);
1599 static int alc_cap_vol_get(struct snd_kcontrol
*kcontrol
,
1600 struct snd_ctl_elem_value
*ucontrol
)
1602 return alc_cap_getput_caller(kcontrol
, ucontrol
,
1603 snd_hda_mixer_amp_volume_get
, false);
1606 static int alc_cap_vol_put(struct snd_kcontrol
*kcontrol
,
1607 struct snd_ctl_elem_value
*ucontrol
)
1609 return alc_cap_getput_caller(kcontrol
, ucontrol
,
1610 snd_hda_mixer_amp_volume_put
, true);
1613 /* capture mixer elements */
1614 #define alc_cap_sw_info snd_ctl_boolean_stereo_info
1616 static int alc_cap_sw_get(struct snd_kcontrol
*kcontrol
,
1617 struct snd_ctl_elem_value
*ucontrol
)
1619 return alc_cap_getput_caller(kcontrol
, ucontrol
,
1620 snd_hda_mixer_amp_switch_get
, false);
1623 static int alc_cap_sw_put(struct snd_kcontrol
*kcontrol
,
1624 struct snd_ctl_elem_value
*ucontrol
)
1626 return alc_cap_getput_caller(kcontrol
, ucontrol
,
1627 snd_hda_mixer_amp_switch_put
, true);
1630 #define _DEFINE_CAPMIX(num) \
1632 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1633 .name = "Capture Switch", \
1634 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1636 .info = alc_cap_sw_info, \
1637 .get = alc_cap_sw_get, \
1638 .put = alc_cap_sw_put, \
1641 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1642 .name = "Capture Volume", \
1643 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1644 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1645 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1647 .info = alc_cap_vol_info, \
1648 .get = alc_cap_vol_get, \
1649 .put = alc_cap_vol_put, \
1650 .tlv = { .c = alc_cap_vol_tlv }, \
1653 #define _DEFINE_CAPSRC(num) \
1655 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1656 /* .name = "Capture Source", */ \
1657 .name = "Input Source", \
1659 .info = alc_mux_enum_info, \
1660 .get = alc_mux_enum_get, \
1661 .put = alc_mux_enum_put, \
1664 #define DEFINE_CAPMIX(num) \
1665 static const struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1666 _DEFINE_CAPMIX(num), \
1667 _DEFINE_CAPSRC(num), \
1671 #define DEFINE_CAPMIX_NOSRC(num) \
1672 static const struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
1673 _DEFINE_CAPMIX(num), \
1677 /* up to three ADCs */
1681 DEFINE_CAPMIX_NOSRC(1);
1682 DEFINE_CAPMIX_NOSRC(2);
1683 DEFINE_CAPMIX_NOSRC(3);
1686 * Inverted digital-mic handling
1688 * First off, it's a bit tricky. The "Inverted Internal Mic Capture Switch"
1689 * gives the additional mute only to the right channel of the digital mic
1690 * capture stream. This is a workaround for avoiding the almost silence
1691 * by summing the stereo stream from some (known to be ForteMedia)
1694 * The logic is to call alc_inv_dmic_sync() after each action (possibly)
1695 * modifying ADC amp. When the mute flag is set, it mutes the R-channel
1696 * without caching so that the cache can still keep the original value.
1697 * The cached value is then restored when the flag is set off or any other
1698 * than d-mic is used as the current input source.
1700 static void alc_inv_dmic_sync(struct hda_codec
*codec
, bool force
)
1702 struct alc_spec
*spec
= codec
->spec
;
1705 if (!spec
->inv_dmic_fixup
)
1707 if (!spec
->inv_dmic_muted
&& !force
)
1709 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
1710 int src
= spec
->dyn_adc_switch
? 0 : i
;
1711 bool dmic_fixup
= false;
1715 if (spec
->inv_dmic_muted
&&
1716 spec
->imux_pins
[spec
->cur_mux
[src
]] == spec
->inv_dmic_pin
)
1718 if (!dmic_fixup
&& !force
)
1720 if (spec
->vol_in_capsrc
) {
1721 nid
= spec
->capsrc_nids
[i
];
1722 parm
= AC_AMP_SET_RIGHT
| AC_AMP_SET_OUTPUT
;
1725 nid
= spec
->adc_nids
[i
];
1726 parm
= AC_AMP_SET_RIGHT
| AC_AMP_SET_INPUT
;
1729 /* we care only right channel */
1730 v
= snd_hda_codec_amp_read(codec
, nid
, 1, dir
, 0);
1731 if (v
& 0x80) /* if already muted, we don't need to touch */
1733 if (dmic_fixup
) /* add mute for d-mic */
1735 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
1740 static int alc_inv_dmic_sw_get(struct snd_kcontrol
*kcontrol
,
1741 struct snd_ctl_elem_value
*ucontrol
)
1743 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1744 struct alc_spec
*spec
= codec
->spec
;
1746 ucontrol
->value
.integer
.value
[0] = !spec
->inv_dmic_muted
;
1750 static int alc_inv_dmic_sw_put(struct snd_kcontrol
*kcontrol
,
1751 struct snd_ctl_elem_value
*ucontrol
)
1753 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1754 struct alc_spec
*spec
= codec
->spec
;
1755 unsigned int val
= !ucontrol
->value
.integer
.value
[0];
1757 if (val
== spec
->inv_dmic_muted
)
1759 spec
->inv_dmic_muted
= val
;
1760 alc_inv_dmic_sync(codec
, true);
1764 static const struct snd_kcontrol_new alc_inv_dmic_sw
= {
1765 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1766 .info
= snd_ctl_boolean_mono_info
,
1767 .get
= alc_inv_dmic_sw_get
,
1768 .put
= alc_inv_dmic_sw_put
,
1771 static int alc_add_inv_dmic_mixer(struct hda_codec
*codec
, hda_nid_t nid
)
1773 struct alc_spec
*spec
= codec
->spec
;
1774 struct snd_kcontrol_new
*knew
= alc_kcontrol_new(spec
);
1777 *knew
= alc_inv_dmic_sw
;
1778 knew
->name
= kstrdup("Inverted Internal Mic Capture Switch", GFP_KERNEL
);
1781 spec
->inv_dmic_fixup
= 1;
1782 spec
->inv_dmic_muted
= 0;
1783 spec
->inv_dmic_pin
= nid
;
1787 /* typically the digital mic is put at node 0x12 */
1788 static void alc_fixup_inv_dmic_0x12(struct hda_codec
*codec
,
1789 const struct alc_fixup
*fix
, int action
)
1791 if (action
== ALC_FIXUP_ACT_PROBE
)
1792 alc_add_inv_dmic_mixer(codec
, 0x12);
1796 * virtual master controls
1800 * slave controls for virtual master
1802 static const char * const alc_slave_pfxs
[] = {
1803 "Front", "Surround", "Center", "LFE", "Side",
1804 "Headphone", "Speaker", "Mono", "Line Out",
1805 "CLFE", "Bass Speaker", "PCM",
1810 * build control elements
1813 #define NID_MAPPING (-1)
1815 #define SUBDEV_SPEAKER_ (0 << 6)
1816 #define SUBDEV_HP_ (1 << 6)
1817 #define SUBDEV_LINE_ (2 << 6)
1818 #define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
1819 #define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
1820 #define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
1822 static void alc_free_kctls(struct hda_codec
*codec
);
1824 #ifdef CONFIG_SND_HDA_INPUT_BEEP
1825 /* additional beep mixers; the actual parameters are overwritten at build */
1826 static const struct snd_kcontrol_new alc_beep_mixer
[] = {
1827 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT
),
1828 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT
),
1833 static int __alc_build_controls(struct hda_codec
*codec
)
1835 struct alc_spec
*spec
= codec
->spec
;
1836 struct snd_kcontrol
*kctl
= NULL
;
1837 const struct snd_kcontrol_new
*knew
;
1842 for (i
= 0; i
< spec
->num_mixers
; i
++) {
1843 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
1847 if (spec
->cap_mixer
) {
1848 err
= snd_hda_add_new_ctls(codec
, spec
->cap_mixer
);
1852 if (spec
->multiout
.dig_out_nid
) {
1853 err
= snd_hda_create_spdif_out_ctls(codec
,
1854 spec
->multiout
.dig_out_nid
,
1855 spec
->multiout
.dig_out_nid
);
1858 if (!spec
->no_analog
) {
1859 err
= snd_hda_create_spdif_share_sw(codec
,
1863 spec
->multiout
.share_spdif
= 1;
1866 if (spec
->dig_in_nid
) {
1867 err
= snd_hda_create_spdif_in_ctls(codec
, spec
->dig_in_nid
);
1872 #ifdef CONFIG_SND_HDA_INPUT_BEEP
1873 /* create beep controls if needed */
1874 if (spec
->beep_amp
) {
1875 const struct snd_kcontrol_new
*knew
;
1876 for (knew
= alc_beep_mixer
; knew
->name
; knew
++) {
1877 struct snd_kcontrol
*kctl
;
1878 kctl
= snd_ctl_new1(knew
, codec
);
1881 kctl
->private_value
= spec
->beep_amp
;
1882 err
= snd_hda_ctl_add(codec
, 0, kctl
);
1889 /* if we have no master control, let's create it */
1890 if (!spec
->no_analog
&&
1891 !snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
1892 unsigned int vmaster_tlv
[4];
1893 snd_hda_set_vmaster_tlv(codec
, spec
->vmaster_nid
,
1894 HDA_OUTPUT
, vmaster_tlv
);
1895 err
= snd_hda_add_vmaster(codec
, "Master Playback Volume",
1896 vmaster_tlv
, alc_slave_pfxs
,
1901 if (!spec
->no_analog
&&
1902 !snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
1903 err
= __snd_hda_add_vmaster(codec
, "Master Playback Switch",
1904 NULL
, alc_slave_pfxs
,
1906 true, &spec
->vmaster_mute
.sw_kctl
);
1911 /* assign Capture Source enums to NID */
1912 if (spec
->capsrc_nids
|| spec
->adc_nids
) {
1913 kctl
= snd_hda_find_mixer_ctl(codec
, "Capture Source");
1915 kctl
= snd_hda_find_mixer_ctl(codec
, "Input Source");
1916 for (i
= 0; kctl
&& i
< kctl
->count
; i
++) {
1917 err
= snd_hda_add_nid(codec
, kctl
, i
,
1918 get_capsrc(spec
, i
));
1923 if (spec
->cap_mixer
&& spec
->adc_nids
) {
1924 const char *kname
= kctl
? kctl
->id
.name
: NULL
;
1925 for (knew
= spec
->cap_mixer
; knew
->name
; knew
++) {
1926 if (kname
&& strcmp(knew
->name
, kname
) == 0)
1928 kctl
= snd_hda_find_mixer_ctl(codec
, knew
->name
);
1929 for (i
= 0; kctl
&& i
< kctl
->count
; i
++) {
1930 err
= snd_hda_add_nid(codec
, kctl
, i
,
1938 /* other nid->control mapping */
1939 for (i
= 0; i
< spec
->num_mixers
; i
++) {
1940 for (knew
= spec
->mixers
[i
]; knew
->name
; knew
++) {
1941 if (knew
->iface
!= NID_MAPPING
)
1943 kctl
= snd_hda_find_mixer_ctl(codec
, knew
->name
);
1946 u
= knew
->subdevice
;
1947 for (j
= 0; j
< 4; j
++, u
>>= 8) {
1952 case SUBDEV_SPEAKER_
:
1953 nid
= spec
->autocfg
.speaker_pins
[nid
];
1956 nid
= spec
->autocfg
.line_out_pins
[nid
];
1959 nid
= spec
->autocfg
.hp_pins
[nid
];
1964 err
= snd_hda_add_nid(codec
, kctl
, 0, nid
);
1968 u
= knew
->private_value
;
1969 for (j
= 0; j
< 4; j
++, u
>>= 8) {
1973 err
= snd_hda_add_nid(codec
, kctl
, 0, nid
);
1980 alc_free_kctls(codec
); /* no longer needed */
1985 static int alc_build_controls(struct hda_codec
*codec
)
1987 struct alc_spec
*spec
= codec
->spec
;
1988 int err
= __alc_build_controls(codec
);
1991 err
= snd_hda_jack_add_kctls(codec
, &spec
->autocfg
);
1994 alc_apply_fixup(codec
, ALC_FIXUP_ACT_BUILD
);
2003 static void alc_init_special_input_src(struct hda_codec
*codec
);
2004 static void alc_auto_init_std(struct hda_codec
*codec
);
2006 static int alc_init(struct hda_codec
*codec
)
2008 struct alc_spec
*spec
= codec
->spec
;
2010 if (spec
->init_hook
)
2011 spec
->init_hook(codec
);
2014 alc_auto_init_amp(codec
, spec
->init_amp
);
2016 snd_hda_gen_apply_verbs(codec
);
2017 alc_init_special_input_src(codec
);
2018 alc_auto_init_std(codec
);
2020 alc_apply_fixup(codec
, ALC_FIXUP_ACT_INIT
);
2022 snd_hda_jack_report_sync(codec
);
2024 hda_call_check_power_status(codec
, 0x01);
2028 static void alc_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2030 struct alc_spec
*spec
= codec
->spec
;
2032 if (spec
->unsol_event
)
2033 spec
->unsol_event(codec
, res
);
2036 #ifdef CONFIG_SND_HDA_POWER_SAVE
2037 static int alc_check_power_status(struct hda_codec
*codec
, hda_nid_t nid
)
2039 struct alc_spec
*spec
= codec
->spec
;
2040 return snd_hda_check_amp_list_power(codec
, &spec
->loopback
, nid
);
2045 * Analog playback callbacks
2047 static int alc_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
2048 struct hda_codec
*codec
,
2049 struct snd_pcm_substream
*substream
)
2051 struct alc_spec
*spec
= codec
->spec
;
2052 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
2056 static int alc_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2057 struct hda_codec
*codec
,
2058 unsigned int stream_tag
,
2059 unsigned int format
,
2060 struct snd_pcm_substream
*substream
)
2062 struct alc_spec
*spec
= codec
->spec
;
2063 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
,
2064 stream_tag
, format
, substream
);
2067 static int alc_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2068 struct hda_codec
*codec
,
2069 struct snd_pcm_substream
*substream
)
2071 struct alc_spec
*spec
= codec
->spec
;
2072 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
2078 static int alc_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
2079 struct hda_codec
*codec
,
2080 struct snd_pcm_substream
*substream
)
2082 struct alc_spec
*spec
= codec
->spec
;
2083 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
2086 static int alc_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2087 struct hda_codec
*codec
,
2088 unsigned int stream_tag
,
2089 unsigned int format
,
2090 struct snd_pcm_substream
*substream
)
2092 struct alc_spec
*spec
= codec
->spec
;
2093 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
2094 stream_tag
, format
, substream
);
2097 static int alc_dig_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2098 struct hda_codec
*codec
,
2099 struct snd_pcm_substream
*substream
)
2101 struct alc_spec
*spec
= codec
->spec
;
2102 return snd_hda_multi_out_dig_cleanup(codec
, &spec
->multiout
);
2105 static int alc_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
2106 struct hda_codec
*codec
,
2107 struct snd_pcm_substream
*substream
)
2109 struct alc_spec
*spec
= codec
->spec
;
2110 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
2116 static int alc_alt_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2117 struct hda_codec
*codec
,
2118 unsigned int stream_tag
,
2119 unsigned int format
,
2120 struct snd_pcm_substream
*substream
)
2122 struct alc_spec
*spec
= codec
->spec
;
2124 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
+ 1],
2125 stream_tag
, 0, format
);
2129 static int alc_alt_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2130 struct hda_codec
*codec
,
2131 struct snd_pcm_substream
*substream
)
2133 struct alc_spec
*spec
= codec
->spec
;
2135 snd_hda_codec_cleanup_stream(codec
,
2136 spec
->adc_nids
[substream
->number
+ 1]);
2140 /* analog capture with dynamic dual-adc changes */
2141 static int dyn_adc_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2142 struct hda_codec
*codec
,
2143 unsigned int stream_tag
,
2144 unsigned int format
,
2145 struct snd_pcm_substream
*substream
)
2147 struct alc_spec
*spec
= codec
->spec
;
2148 spec
->cur_adc
= spec
->adc_nids
[spec
->dyn_adc_idx
[spec
->cur_mux
[0]]];
2149 spec
->cur_adc_stream_tag
= stream_tag
;
2150 spec
->cur_adc_format
= format
;
2151 snd_hda_codec_setup_stream(codec
, spec
->cur_adc
, stream_tag
, 0, format
);
2155 static int dyn_adc_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2156 struct hda_codec
*codec
,
2157 struct snd_pcm_substream
*substream
)
2159 struct alc_spec
*spec
= codec
->spec
;
2160 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
2165 static const struct hda_pcm_stream dyn_adc_pcm_analog_capture
= {
2169 .nid
= 0, /* fill later */
2171 .prepare
= dyn_adc_capture_pcm_prepare
,
2172 .cleanup
= dyn_adc_capture_pcm_cleanup
2178 static const struct hda_pcm_stream alc_pcm_analog_playback
= {
2182 /* NID is set in alc_build_pcms */
2184 .open
= alc_playback_pcm_open
,
2185 .prepare
= alc_playback_pcm_prepare
,
2186 .cleanup
= alc_playback_pcm_cleanup
2190 static const struct hda_pcm_stream alc_pcm_analog_capture
= {
2194 /* NID is set in alc_build_pcms */
2197 static const struct hda_pcm_stream alc_pcm_analog_alt_playback
= {
2201 /* NID is set in alc_build_pcms */
2204 static const struct hda_pcm_stream alc_pcm_analog_alt_capture
= {
2205 .substreams
= 2, /* can be overridden */
2208 /* NID is set in alc_build_pcms */
2210 .prepare
= alc_alt_capture_pcm_prepare
,
2211 .cleanup
= alc_alt_capture_pcm_cleanup
2215 static const struct hda_pcm_stream alc_pcm_digital_playback
= {
2219 /* NID is set in alc_build_pcms */
2221 .open
= alc_dig_playback_pcm_open
,
2222 .close
= alc_dig_playback_pcm_close
,
2223 .prepare
= alc_dig_playback_pcm_prepare
,
2224 .cleanup
= alc_dig_playback_pcm_cleanup
2228 static const struct hda_pcm_stream alc_pcm_digital_capture
= {
2232 /* NID is set in alc_build_pcms */
2235 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
2236 static const struct hda_pcm_stream alc_pcm_null_stream
= {
2242 static int alc_build_pcms(struct hda_codec
*codec
)
2244 struct alc_spec
*spec
= codec
->spec
;
2245 struct hda_pcm
*info
= spec
->pcm_rec
;
2246 const struct hda_pcm_stream
*p
;
2247 bool have_multi_adcs
;
2250 codec
->num_pcms
= 1;
2251 codec
->pcm_info
= info
;
2253 if (spec
->no_analog
)
2256 snprintf(spec
->stream_name_analog
, sizeof(spec
->stream_name_analog
),
2257 "%s Analog", codec
->chip_name
);
2258 info
->name
= spec
->stream_name_analog
;
2260 if (spec
->multiout
.num_dacs
> 0) {
2261 p
= spec
->stream_analog_playback
;
2263 p
= &alc_pcm_analog_playback
;
2264 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = *p
;
2265 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dac_nids
[0];
2267 if (spec
->adc_nids
) {
2268 p
= spec
->stream_analog_capture
;
2270 if (spec
->dyn_adc_switch
)
2271 p
= &dyn_adc_pcm_analog_capture
;
2273 p
= &alc_pcm_analog_capture
;
2275 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *p
;
2276 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
2279 if (spec
->channel_mode
) {
2280 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
= 0;
2281 for (i
= 0; i
< spec
->num_channel_mode
; i
++) {
2282 if (spec
->channel_mode
[i
].channels
> info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
) {
2283 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
= spec
->channel_mode
[i
].channels
;
2289 /* SPDIF for stream index #1 */
2290 if (spec
->multiout
.dig_out_nid
|| spec
->dig_in_nid
) {
2291 snprintf(spec
->stream_name_digital
,
2292 sizeof(spec
->stream_name_digital
),
2293 "%s Digital", codec
->chip_name
);
2294 codec
->num_pcms
= 2;
2295 codec
->slave_dig_outs
= spec
->multiout
.slave_dig_outs
;
2296 info
= spec
->pcm_rec
+ 1;
2297 info
->name
= spec
->stream_name_digital
;
2298 if (spec
->dig_out_type
)
2299 info
->pcm_type
= spec
->dig_out_type
;
2301 info
->pcm_type
= HDA_PCM_TYPE_SPDIF
;
2302 if (spec
->multiout
.dig_out_nid
) {
2303 p
= spec
->stream_digital_playback
;
2305 p
= &alc_pcm_digital_playback
;
2306 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = *p
;
2307 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dig_out_nid
;
2309 if (spec
->dig_in_nid
) {
2310 p
= spec
->stream_digital_capture
;
2312 p
= &alc_pcm_digital_capture
;
2313 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *p
;
2314 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->dig_in_nid
;
2316 /* FIXME: do we need this for all Realtek codec models? */
2317 codec
->spdif_status_reset
= 1;
2320 if (spec
->no_analog
)
2323 /* If the use of more than one ADC is requested for the current
2324 * model, configure a second analog capture-only PCM.
2326 have_multi_adcs
= (spec
->num_adc_nids
> 1) &&
2327 !spec
->dyn_adc_switch
&& !spec
->auto_mic
&&
2328 (!spec
->input_mux
|| spec
->input_mux
->num_items
> 1);
2329 /* Additional Analaog capture for index #2 */
2330 if (spec
->alt_dac_nid
|| have_multi_adcs
) {
2331 codec
->num_pcms
= 3;
2332 info
= spec
->pcm_rec
+ 2;
2333 info
->name
= spec
->stream_name_analog
;
2334 if (spec
->alt_dac_nid
) {
2335 p
= spec
->stream_analog_alt_playback
;
2337 p
= &alc_pcm_analog_alt_playback
;
2338 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = *p
;
2339 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
2342 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] =
2343 alc_pcm_null_stream
;
2344 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= 0;
2346 if (have_multi_adcs
) {
2347 p
= spec
->stream_analog_alt_capture
;
2349 p
= &alc_pcm_analog_alt_capture
;
2350 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *p
;
2351 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
=
2353 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
=
2354 spec
->num_adc_nids
- 1;
2356 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
2357 alc_pcm_null_stream
;
2358 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= 0;
2365 static inline void alc_shutup(struct hda_codec
*codec
)
2367 struct alc_spec
*spec
= codec
->spec
;
2369 if (spec
&& spec
->shutup
)
2370 spec
->shutup(codec
);
2371 snd_hda_shutup_pins(codec
);
2374 static void alc_free_kctls(struct hda_codec
*codec
)
2376 struct alc_spec
*spec
= codec
->spec
;
2378 if (spec
->kctls
.list
) {
2379 struct snd_kcontrol_new
*kctl
= spec
->kctls
.list
;
2381 for (i
= 0; i
< spec
->kctls
.used
; i
++)
2382 kfree(kctl
[i
].name
);
2384 snd_array_free(&spec
->kctls
);
2387 static void alc_free_bind_ctls(struct hda_codec
*codec
)
2389 struct alc_spec
*spec
= codec
->spec
;
2390 if (spec
->bind_ctls
.list
) {
2391 struct hda_bind_ctls
**ctl
= spec
->bind_ctls
.list
;
2393 for (i
= 0; i
< spec
->bind_ctls
.used
; i
++)
2396 snd_array_free(&spec
->bind_ctls
);
2399 static void alc_free(struct hda_codec
*codec
)
2401 struct alc_spec
*spec
= codec
->spec
;
2407 alc_free_kctls(codec
);
2408 alc_free_bind_ctls(codec
);
2410 snd_hda_detach_beep_device(codec
);
2413 #ifdef CONFIG_SND_HDA_POWER_SAVE
2414 static void alc_power_eapd(struct hda_codec
*codec
)
2416 alc_auto_setup_eapd(codec
, false);
2419 static int alc_suspend(struct hda_codec
*codec
, pm_message_t state
)
2421 struct alc_spec
*spec
= codec
->spec
;
2423 if (spec
&& spec
->power_hook
)
2424 spec
->power_hook(codec
);
2430 static int alc_resume(struct hda_codec
*codec
)
2432 msleep(150); /* to avoid pop noise */
2433 codec
->patch_ops
.init(codec
);
2434 snd_hda_codec_resume_amp(codec
);
2435 snd_hda_codec_resume_cache(codec
);
2436 alc_inv_dmic_sync(codec
, true);
2437 hda_call_check_power_status(codec
, 0x01);
2444 static const struct hda_codec_ops alc_patch_ops
= {
2445 .build_controls
= alc_build_controls
,
2446 .build_pcms
= alc_build_pcms
,
2449 .unsol_event
= alc_unsol_event
,
2451 .resume
= alc_resume
,
2453 #ifdef CONFIG_SND_HDA_POWER_SAVE
2454 .suspend
= alc_suspend
,
2455 .check_power_status
= alc_check_power_status
,
2457 .reboot_notify
= alc_shutup
,
2460 /* replace the codec chip_name with the given string */
2461 static int alc_codec_rename(struct hda_codec
*codec
, const char *name
)
2463 kfree(codec
->chip_name
);
2464 codec
->chip_name
= kstrdup(name
, GFP_KERNEL
);
2465 if (!codec
->chip_name
) {
2473 * Rename codecs appropriately from COEF value
2475 struct alc_codec_rename_table
{
2476 unsigned int vendor_id
;
2477 unsigned short coef_mask
;
2478 unsigned short coef_bits
;
2482 static struct alc_codec_rename_table rename_tbl
[] = {
2483 { 0x10ec0269, 0xfff0, 0x3010, "ALC277" },
2484 { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" },
2485 { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" },
2486 { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" },
2487 { 0x10ec0269, 0xffff, 0xa023, "ALC259" },
2488 { 0x10ec0269, 0xffff, 0x6023, "ALC281X" },
2489 { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" },
2490 { 0x10ec0269, 0x00f0, 0x0030, "ALC269VD" },
2491 { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" },
2492 { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" },
2493 { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" },
2494 { 0x10ec0899, 0x2000, 0x2000, "ALC899" },
2495 { 0x10ec0892, 0xffff, 0x8020, "ALC661" },
2496 { 0x10ec0892, 0xffff, 0x8011, "ALC661" },
2497 { 0x10ec0892, 0xffff, 0x4011, "ALC656" },
2498 { } /* terminator */
2501 static int alc_codec_rename_from_preset(struct hda_codec
*codec
)
2503 const struct alc_codec_rename_table
*p
;
2505 for (p
= rename_tbl
; p
->vendor_id
; p
++) {
2506 if (p
->vendor_id
!= codec
->vendor_id
)
2508 if ((alc_get_coef0(codec
) & p
->coef_mask
) == p
->coef_bits
)
2509 return alc_codec_rename(codec
, p
->name
);
2515 * Automatic parse of I/O pins from the BIOS configuration
2520 ALC_CTL_WIDGET_MUTE
,
2525 static const struct snd_kcontrol_new alc_control_templates
[] = {
2526 HDA_CODEC_VOLUME(NULL
, 0, 0, 0),
2527 HDA_CODEC_MUTE(NULL
, 0, 0, 0),
2528 HDA_BIND_MUTE(NULL
, 0, 0, 0),
2529 HDA_BIND_VOL(NULL
, 0),
2530 HDA_BIND_SW(NULL
, 0),
2533 /* add dynamic controls */
2534 static int add_control(struct alc_spec
*spec
, int type
, const char *name
,
2535 int cidx
, unsigned long val
)
2537 struct snd_kcontrol_new
*knew
;
2539 knew
= alc_kcontrol_new(spec
);
2542 *knew
= alc_control_templates
[type
];
2543 knew
->name
= kstrdup(name
, GFP_KERNEL
);
2547 if (get_amp_nid_(val
))
2548 knew
->subdevice
= HDA_SUBDEV_AMP_FLAG
;
2549 knew
->private_value
= val
;
2553 static int add_control_with_pfx(struct alc_spec
*spec
, int type
,
2554 const char *pfx
, const char *dir
,
2555 const char *sfx
, int cidx
, unsigned long val
)
2558 snprintf(name
, sizeof(name
), "%s %s %s", pfx
, dir
, sfx
);
2559 return add_control(spec
, type
, name
, cidx
, val
);
2562 #define add_pb_vol_ctrl(spec, type, pfx, val) \
2563 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
2564 #define add_pb_sw_ctrl(spec, type, pfx, val) \
2565 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
2566 #define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
2567 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
2568 #define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
2569 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
2571 static const char * const channel_name
[4] = {
2572 "Front", "Surround", "CLFE", "Side"
2575 static const char *alc_get_line_out_pfx(struct alc_spec
*spec
, int ch
,
2576 bool can_be_master
, int *index
)
2578 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2581 if (cfg
->line_outs
== 1 && !spec
->multi_ios
&&
2582 !cfg
->hp_outs
&& !cfg
->speaker_outs
&& can_be_master
)
2585 switch (cfg
->line_out_type
) {
2586 case AUTO_PIN_SPEAKER_OUT
:
2587 if (cfg
->line_outs
== 1)
2589 if (cfg
->line_outs
== 2)
2590 return ch
? "Bass Speaker" : "Speaker";
2592 case AUTO_PIN_HP_OUT
:
2593 /* for multi-io case, only the primary out */
2594 if (ch
&& spec
->multi_ios
)
2599 if (cfg
->line_outs
== 1 && !spec
->multi_ios
)
2603 if (snd_BUG_ON(ch
>= ARRAY_SIZE(channel_name
)))
2606 return channel_name
[ch
];
2609 #ifdef CONFIG_SND_HDA_POWER_SAVE
2610 /* add the powersave loopback-list entry */
2611 static void add_loopback_list(struct alc_spec
*spec
, hda_nid_t mix
, int idx
)
2613 struct hda_amp_list
*list
;
2615 if (spec
->num_loopbacks
>= ARRAY_SIZE(spec
->loopback_list
) - 1)
2617 list
= spec
->loopback_list
+ spec
->num_loopbacks
;
2619 list
->dir
= HDA_INPUT
;
2621 spec
->num_loopbacks
++;
2622 spec
->loopback
.amplist
= spec
->loopback_list
;
2625 #define add_loopback_list(spec, mix, idx) /* NOP */
2628 /* create input playback/capture controls for the given pin */
2629 static int new_analog_input(struct alc_spec
*spec
, hda_nid_t pin
,
2630 const char *ctlname
, int ctlidx
,
2631 int idx
, hda_nid_t mix_nid
)
2635 err
= __add_pb_vol_ctrl(spec
, ALC_CTL_WIDGET_VOL
, ctlname
, ctlidx
,
2636 HDA_COMPOSE_AMP_VAL(mix_nid
, 3, idx
, HDA_INPUT
));
2639 err
= __add_pb_sw_ctrl(spec
, ALC_CTL_WIDGET_MUTE
, ctlname
, ctlidx
,
2640 HDA_COMPOSE_AMP_VAL(mix_nid
, 3, idx
, HDA_INPUT
));
2643 add_loopback_list(spec
, mix_nid
, idx
);
2647 static int alc_is_input_pin(struct hda_codec
*codec
, hda_nid_t nid
)
2649 unsigned int pincap
= snd_hda_query_pin_caps(codec
, nid
);
2650 return (pincap
& AC_PINCAP_IN
) != 0;
2653 /* Parse the codec tree and retrieve ADCs and corresponding capsrc MUXs */
2654 static int alc_auto_fill_adc_caps(struct hda_codec
*codec
)
2656 struct alc_spec
*spec
= codec
->spec
;
2658 hda_nid_t
*adc_nids
= spec
->private_adc_nids
;
2659 hda_nid_t
*cap_nids
= spec
->private_capsrc_nids
;
2660 int max_nums
= ARRAY_SIZE(spec
->private_adc_nids
);
2663 nid
= codec
->start_nid
;
2664 for (i
= 0; i
< codec
->num_nodes
; i
++, nid
++) {
2666 unsigned int caps
= get_wcaps(codec
, nid
);
2667 int type
= get_wcaps_type(caps
);
2669 if (type
!= AC_WID_AUD_IN
|| (caps
& AC_WCAP_DIGITAL
))
2671 adc_nids
[nums
] = nid
;
2672 cap_nids
[nums
] = nid
;
2676 type
= get_wcaps_type(get_wcaps(codec
, src
));
2677 if (type
== AC_WID_PIN
)
2679 if (type
== AC_WID_AUD_SEL
) {
2680 cap_nids
[nums
] = src
;
2683 n
= snd_hda_get_num_conns(codec
, src
);
2685 cap_nids
[nums
] = src
;
2689 if (snd_hda_get_connections(codec
, src
, &src
, 1) != 1)
2692 if (++nums
>= max_nums
)
2695 spec
->adc_nids
= spec
->private_adc_nids
;
2696 spec
->capsrc_nids
= spec
->private_capsrc_nids
;
2697 spec
->num_adc_nids
= nums
;
2701 /* create playback/capture controls for input pins */
2702 static int alc_auto_create_input_ctls(struct hda_codec
*codec
)
2704 struct alc_spec
*spec
= codec
->spec
;
2705 const struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2706 hda_nid_t mixer
= spec
->mixer_nid
;
2707 struct hda_input_mux
*imux
= &spec
->private_imux
[0];
2709 int i
, c
, err
, idx
, type_idx
= 0;
2710 const char *prev_label
= NULL
;
2712 num_adcs
= alc_auto_fill_adc_caps(codec
);
2716 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
2720 pin
= cfg
->inputs
[i
].pin
;
2721 if (!alc_is_input_pin(codec
, pin
))
2724 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
2725 if (spec
->shared_mic_hp
&& !strcmp(label
, "Misc"))
2726 label
= "Headphone Mic";
2727 if (prev_label
&& !strcmp(label
, prev_label
))
2734 idx
= get_connection_index(codec
, mixer
, pin
);
2736 err
= new_analog_input(spec
, pin
,
2744 for (c
= 0; c
< num_adcs
; c
++) {
2745 hda_nid_t cap
= get_capsrc(spec
, c
);
2746 idx
= get_connection_index(codec
, cap
, pin
);
2748 spec
->imux_pins
[imux
->num_items
] = pin
;
2749 snd_hda_add_imux_item(imux
, label
, idx
, NULL
);
2755 spec
->num_mux_defs
= 1;
2756 spec
->input_mux
= imux
;
2761 /* create a shared input with the headphone out */
2762 static int alc_auto_create_shared_input(struct hda_codec
*codec
)
2764 struct alc_spec
*spec
= codec
->spec
;
2765 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2766 unsigned int defcfg
;
2769 /* only one internal input pin? */
2770 if (cfg
->num_inputs
!= 1)
2772 defcfg
= snd_hda_codec_get_pincfg(codec
, cfg
->inputs
[0].pin
);
2773 if (snd_hda_get_input_pin_attr(defcfg
) != INPUT_PIN_ATTR_INT
)
2776 if (cfg
->hp_outs
== 1 && cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
)
2777 nid
= cfg
->hp_pins
[0]; /* OK, we have a single HP-out */
2778 else if (cfg
->line_outs
== 1 && cfg
->line_out_type
== AUTO_PIN_HP_OUT
)
2779 nid
= cfg
->line_out_pins
[0]; /* OK, we have a single line-out */
2781 return 0; /* both not available */
2783 if (!(snd_hda_query_pin_caps(codec
, nid
) & AC_PINCAP_IN
))
2784 return 0; /* no input */
2786 cfg
->inputs
[1].pin
= nid
;
2787 cfg
->inputs
[1].type
= AUTO_PIN_MIC
;
2788 cfg
->num_inputs
= 2;
2789 spec
->shared_mic_hp
= 1;
2790 snd_printdd("realtek: Enable shared I/O jack on NID 0x%x\n", nid
);
2794 static void alc_set_pin_output(struct hda_codec
*codec
, hda_nid_t nid
,
2795 unsigned int pin_type
)
2797 snd_hda_set_pin_ctl(codec
, nid
, pin_type
);
2799 if (nid_has_mute(codec
, nid
, HDA_OUTPUT
))
2800 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
2804 static int get_pin_type(int line_out_type
)
2806 if (line_out_type
== AUTO_PIN_HP_OUT
)
2812 static void alc_auto_init_analog_input(struct hda_codec
*codec
)
2814 struct alc_spec
*spec
= codec
->spec
;
2815 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2818 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
2819 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
2820 if (alc_is_input_pin(codec
, nid
)) {
2821 alc_set_input_pin(codec
, nid
, cfg
->inputs
[i
].type
);
2822 if (get_wcaps(codec
, nid
) & AC_WCAP_OUT_AMP
)
2823 snd_hda_codec_write(codec
, nid
, 0,
2824 AC_VERB_SET_AMP_GAIN_MUTE
,
2829 /* mute all loopback inputs */
2830 if (spec
->mixer_nid
) {
2831 int nums
= snd_hda_get_num_conns(codec
, spec
->mixer_nid
);
2832 for (i
= 0; i
< nums
; i
++)
2833 snd_hda_codec_write(codec
, spec
->mixer_nid
, 0,
2834 AC_VERB_SET_AMP_GAIN_MUTE
,
2839 /* convert from MIX nid to DAC */
2840 static hda_nid_t
alc_auto_mix_to_dac(struct hda_codec
*codec
, hda_nid_t nid
)
2845 if (get_wcaps_type(get_wcaps(codec
, nid
)) == AC_WID_AUD_OUT
)
2847 num
= snd_hda_get_connections(codec
, nid
, list
, ARRAY_SIZE(list
));
2848 for (i
= 0; i
< num
; i
++) {
2849 if (get_wcaps_type(get_wcaps(codec
, list
[i
])) == AC_WID_AUD_OUT
)
2855 /* go down to the selector widget before the mixer */
2856 static hda_nid_t
alc_go_down_to_selector(struct hda_codec
*codec
, hda_nid_t pin
)
2859 int num
= snd_hda_get_connections(codec
, pin
, srcs
,
2862 get_wcaps_type(get_wcaps(codec
, srcs
[0])) != AC_WID_AUD_SEL
)
2867 /* get MIX nid connected to the given pin targeted to DAC */
2868 static hda_nid_t
alc_auto_dac_to_mix(struct hda_codec
*codec
, hda_nid_t pin
,
2874 pin
= alc_go_down_to_selector(codec
, pin
);
2875 num
= snd_hda_get_connections(codec
, pin
, mix
, ARRAY_SIZE(mix
));
2876 for (i
= 0; i
< num
; i
++) {
2877 if (alc_auto_mix_to_dac(codec
, mix
[i
]) == dac
)
2883 /* select the connection from pin to DAC if needed */
2884 static int alc_auto_select_dac(struct hda_codec
*codec
, hda_nid_t pin
,
2890 pin
= alc_go_down_to_selector(codec
, pin
);
2891 num
= snd_hda_get_connections(codec
, pin
, mix
, ARRAY_SIZE(mix
));
2894 for (i
= 0; i
< num
; i
++) {
2895 if (alc_auto_mix_to_dac(codec
, mix
[i
]) == dac
) {
2896 snd_hda_codec_update_cache(codec
, pin
, 0,
2897 AC_VERB_SET_CONNECT_SEL
, i
);
2904 static bool alc_is_dac_already_used(struct hda_codec
*codec
, hda_nid_t nid
)
2906 struct alc_spec
*spec
= codec
->spec
;
2908 if (found_in_nid_list(nid
, spec
->multiout
.dac_nids
,
2909 ARRAY_SIZE(spec
->private_dac_nids
)) ||
2910 found_in_nid_list(nid
, spec
->multiout
.hp_out_nid
,
2911 ARRAY_SIZE(spec
->multiout
.hp_out_nid
)) ||
2912 found_in_nid_list(nid
, spec
->multiout
.extra_out_nid
,
2913 ARRAY_SIZE(spec
->multiout
.extra_out_nid
)))
2915 for (i
= 0; i
< spec
->multi_ios
; i
++) {
2916 if (spec
->multi_io
[i
].dac
== nid
)
2922 /* look for an empty DAC slot */
2923 static hda_nid_t
alc_auto_look_for_dac(struct hda_codec
*codec
, hda_nid_t pin
)
2928 pin
= alc_go_down_to_selector(codec
, pin
);
2929 num
= snd_hda_get_connections(codec
, pin
, srcs
, ARRAY_SIZE(srcs
));
2930 for (i
= 0; i
< num
; i
++) {
2931 hda_nid_t nid
= alc_auto_mix_to_dac(codec
, srcs
[i
]);
2934 if (!alc_is_dac_already_used(codec
, nid
))
2940 /* check whether the DAC is reachable from the pin */
2941 static bool alc_auto_is_dac_reachable(struct hda_codec
*codec
,
2942 hda_nid_t pin
, hda_nid_t dac
)
2949 pin
= alc_go_down_to_selector(codec
, pin
);
2950 num
= snd_hda_get_connections(codec
, pin
, srcs
, ARRAY_SIZE(srcs
));
2951 for (i
= 0; i
< num
; i
++) {
2952 hda_nid_t nid
= alc_auto_mix_to_dac(codec
, srcs
[i
]);
2959 static hda_nid_t
get_dac_if_single(struct hda_codec
*codec
, hda_nid_t pin
)
2961 struct alc_spec
*spec
= codec
->spec
;
2962 hda_nid_t sel
= alc_go_down_to_selector(codec
, pin
);
2963 hda_nid_t nid
, nid_found
, srcs
[5];
2964 int i
, num
= snd_hda_get_connections(codec
, sel
, srcs
,
2967 return alc_auto_look_for_dac(codec
, pin
);
2969 for (i
= 0; i
< num
; i
++) {
2970 if (srcs
[i
] == spec
->mixer_nid
)
2972 nid
= alc_auto_mix_to_dac(codec
, srcs
[i
]);
2973 if (nid
&& !alc_is_dac_already_used(codec
, nid
)) {
2982 /* mark up volume and mute control NIDs: used during badness parsing and
2983 * at creating actual controls
2985 static inline unsigned int get_ctl_pos(unsigned int data
)
2987 hda_nid_t nid
= get_amp_nid_(data
);
2989 if (snd_BUG_ON(nid
>= MAX_VOL_NIDS
))
2991 dir
= get_amp_direction_(data
);
2992 return (nid
<< 1) | dir
;
2995 #define is_ctl_used(bits, data) \
2996 test_bit(get_ctl_pos(data), bits)
2997 #define mark_ctl_usage(bits, data) \
2998 set_bit(get_ctl_pos(data), bits)
3000 static void clear_vol_marks(struct hda_codec
*codec
)
3002 struct alc_spec
*spec
= codec
->spec
;
3003 memset(spec
->vol_ctls
, 0, sizeof(spec
->vol_ctls
));
3004 memset(spec
->sw_ctls
, 0, sizeof(spec
->sw_ctls
));
3007 /* badness definition */
3009 /* No primary DAC is found for the main output */
3010 BAD_NO_PRIMARY_DAC
= 0x10000,
3011 /* No DAC is found for the extra output */
3012 BAD_NO_DAC
= 0x4000,
3013 /* No possible multi-ios */
3014 BAD_MULTI_IO
= 0x103,
3015 /* No individual DAC for extra output */
3016 BAD_NO_EXTRA_DAC
= 0x102,
3017 /* No individual DAC for extra surrounds */
3018 BAD_NO_EXTRA_SURR_DAC
= 0x101,
3019 /* Primary DAC shared with main surrounds */
3020 BAD_SHARED_SURROUND
= 0x100,
3021 /* Primary DAC shared with main CLFE */
3022 BAD_SHARED_CLFE
= 0x10,
3023 /* Primary DAC shared with extra surrounds */
3024 BAD_SHARED_EXTRA_SURROUND
= 0x10,
3025 /* Volume widget is shared */
3026 BAD_SHARED_VOL
= 0x10,
3029 static hda_nid_t
alc_look_for_out_mute_nid(struct hda_codec
*codec
,
3030 hda_nid_t pin
, hda_nid_t dac
);
3031 static hda_nid_t
alc_look_for_out_vol_nid(struct hda_codec
*codec
,
3032 hda_nid_t pin
, hda_nid_t dac
);
3034 static int eval_shared_vol_badness(struct hda_codec
*codec
, hda_nid_t pin
,
3037 struct alc_spec
*spec
= codec
->spec
;
3042 nid
= alc_look_for_out_vol_nid(codec
, pin
, dac
);
3044 val
= HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
);
3045 if (is_ctl_used(spec
->vol_ctls
, nid
))
3046 badness
+= BAD_SHARED_VOL
;
3048 mark_ctl_usage(spec
->vol_ctls
, val
);
3050 badness
+= BAD_SHARED_VOL
;
3051 nid
= alc_look_for_out_mute_nid(codec
, pin
, dac
);
3053 unsigned int wid_type
= get_wcaps_type(get_wcaps(codec
, nid
));
3054 if (wid_type
== AC_WID_PIN
|| wid_type
== AC_WID_AUD_OUT
)
3055 val
= HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
);
3057 val
= HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_INPUT
);
3058 if (is_ctl_used(spec
->sw_ctls
, val
))
3059 badness
+= BAD_SHARED_VOL
;
3061 mark_ctl_usage(spec
->sw_ctls
, val
);
3063 badness
+= BAD_SHARED_VOL
;
3067 struct badness_table
{
3068 int no_primary_dac
; /* no primary DAC */
3069 int no_dac
; /* no secondary DACs */
3070 int shared_primary
; /* primary DAC is shared with main output */
3071 int shared_surr
; /* secondary DAC shared with main or primary */
3072 int shared_clfe
; /* third DAC shared with main or primary */
3073 int shared_surr_main
; /* secondary DAC sahred with main/DAC0 */
3076 static struct badness_table main_out_badness
= {
3077 .no_primary_dac
= BAD_NO_PRIMARY_DAC
,
3078 .no_dac
= BAD_NO_DAC
,
3079 .shared_primary
= BAD_NO_PRIMARY_DAC
,
3080 .shared_surr
= BAD_SHARED_SURROUND
,
3081 .shared_clfe
= BAD_SHARED_CLFE
,
3082 .shared_surr_main
= BAD_SHARED_SURROUND
,
3085 static struct badness_table extra_out_badness
= {
3086 .no_primary_dac
= BAD_NO_DAC
,
3087 .no_dac
= BAD_NO_DAC
,
3088 .shared_primary
= BAD_NO_EXTRA_DAC
,
3089 .shared_surr
= BAD_SHARED_EXTRA_SURROUND
,
3090 .shared_clfe
= BAD_SHARED_EXTRA_SURROUND
,
3091 .shared_surr_main
= BAD_NO_EXTRA_SURR_DAC
,
3094 /* try to assign DACs to pins and return the resultant badness */
3095 static int alc_auto_fill_dacs(struct hda_codec
*codec
, int num_outs
,
3096 const hda_nid_t
*pins
, hda_nid_t
*dacs
,
3097 const struct badness_table
*bad
)
3099 struct alc_spec
*spec
= codec
->spec
;
3100 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3108 for (i
= 0; i
< num_outs
; i
++) {
3109 hda_nid_t pin
= pins
[i
];
3111 dacs
[i
] = alc_auto_look_for_dac(codec
, pin
);
3112 if (!dacs
[i
] && !i
) {
3113 for (j
= 1; j
< num_outs
; j
++) {
3114 if (alc_auto_is_dac_reachable(codec
, pin
, dacs
[j
])) {
3123 if (alc_auto_is_dac_reachable(codec
, pin
, dacs
[0]))
3125 else if (cfg
->line_outs
> i
&&
3126 alc_auto_is_dac_reachable(codec
, pin
,
3127 spec
->private_dac_nids
[i
]))
3128 dac
= spec
->private_dac_nids
[i
];
3131 badness
+= bad
->shared_primary
;
3133 badness
+= bad
->shared_surr
;
3135 badness
+= bad
->shared_clfe
;
3136 } else if (alc_auto_is_dac_reachable(codec
, pin
,
3137 spec
->private_dac_nids
[0])) {
3138 dac
= spec
->private_dac_nids
[0];
3139 badness
+= bad
->shared_surr_main
;
3141 badness
+= bad
->no_primary_dac
;
3143 badness
+= bad
->no_dac
;
3146 badness
+= eval_shared_vol_badness(codec
, pin
, dac
);
3152 static int alc_auto_fill_multi_ios(struct hda_codec
*codec
,
3153 hda_nid_t reference_pin
,
3154 bool hardwired
, int offset
);
3156 static bool alc_map_singles(struct hda_codec
*codec
, int outs
,
3157 const hda_nid_t
*pins
, hda_nid_t
*dacs
)
3161 for (i
= 0; i
< outs
; i
++) {
3164 dacs
[i
] = get_dac_if_single(codec
, pins
[i
]);
3171 /* fill in the dac_nids table from the parsed pin configuration */
3172 static int fill_and_eval_dacs(struct hda_codec
*codec
,
3173 bool fill_hardwired
,
3174 bool fill_mio_first
)
3176 struct alc_spec
*spec
= codec
->spec
;
3177 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3178 int i
, err
, badness
;
3180 /* set num_dacs once to full for alc_auto_look_for_dac() */
3181 spec
->multiout
.num_dacs
= cfg
->line_outs
;
3182 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
3183 memset(spec
->private_dac_nids
, 0, sizeof(spec
->private_dac_nids
));
3184 memset(spec
->multiout
.hp_out_nid
, 0, sizeof(spec
->multiout
.hp_out_nid
));
3185 memset(spec
->multiout
.extra_out_nid
, 0, sizeof(spec
->multiout
.extra_out_nid
));
3186 spec
->multi_ios
= 0;
3187 clear_vol_marks(codec
);
3190 /* fill hard-wired DACs first */
3191 if (fill_hardwired
) {
3194 mapped
= alc_map_singles(codec
, cfg
->line_outs
,
3196 spec
->private_dac_nids
);
3197 mapped
|= alc_map_singles(codec
, cfg
->hp_outs
,
3199 spec
->multiout
.hp_out_nid
);
3200 mapped
|= alc_map_singles(codec
, cfg
->speaker_outs
,
3202 spec
->multiout
.extra_out_nid
);
3203 if (fill_mio_first
&& cfg
->line_outs
== 1 &&
3204 cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
) {
3205 err
= alc_auto_fill_multi_ios(codec
, cfg
->line_out_pins
[0], true, 0);
3212 badness
+= alc_auto_fill_dacs(codec
, cfg
->line_outs
, cfg
->line_out_pins
,
3213 spec
->private_dac_nids
,
3216 /* re-count num_dacs and squash invalid entries */
3217 spec
->multiout
.num_dacs
= 0;
3218 for (i
= 0; i
< cfg
->line_outs
; i
++) {
3219 if (spec
->private_dac_nids
[i
])
3220 spec
->multiout
.num_dacs
++;
3222 memmove(spec
->private_dac_nids
+ i
,
3223 spec
->private_dac_nids
+ i
+ 1,
3224 sizeof(hda_nid_t
) * (cfg
->line_outs
- i
- 1));
3225 spec
->private_dac_nids
[cfg
->line_outs
- 1] = 0;
3229 if (fill_mio_first
&&
3230 cfg
->line_outs
== 1 && cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
) {
3231 /* try to fill multi-io first */
3232 err
= alc_auto_fill_multi_ios(codec
, cfg
->line_out_pins
[0], false, 0);
3235 /* we don't count badness at this stage yet */
3238 if (cfg
->line_out_type
!= AUTO_PIN_HP_OUT
) {
3239 err
= alc_auto_fill_dacs(codec
, cfg
->hp_outs
, cfg
->hp_pins
,
3240 spec
->multiout
.hp_out_nid
,
3241 &extra_out_badness
);
3246 if (cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
) {
3247 err
= alc_auto_fill_dacs(codec
, cfg
->speaker_outs
,
3249 spec
->multiout
.extra_out_nid
,
3250 &extra_out_badness
);
3255 if (cfg
->line_outs
== 1 && cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
) {
3256 err
= alc_auto_fill_multi_ios(codec
, cfg
->line_out_pins
[0], false, 0);
3261 if (cfg
->hp_outs
&& cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
) {
3262 /* try multi-ios with HP + inputs */
3264 if (cfg
->line_outs
>= 3)
3266 err
= alc_auto_fill_multi_ios(codec
, cfg
->hp_pins
[0], false,
3273 if (spec
->multi_ios
== 2) {
3274 for (i
= 0; i
< 2; i
++)
3275 spec
->private_dac_nids
[spec
->multiout
.num_dacs
++] =
3276 spec
->multi_io
[i
].dac
;
3277 spec
->ext_channel_count
= 2;
3278 } else if (spec
->multi_ios
) {
3279 spec
->multi_ios
= 0;
3280 badness
+= BAD_MULTI_IO
;
3286 #define DEBUG_BADNESS
3288 #ifdef DEBUG_BADNESS
3289 #define debug_badness snd_printdd
3291 #define debug_badness(...)
3294 static void debug_show_configs(struct alc_spec
*spec
, struct auto_pin_cfg
*cfg
)
3296 debug_badness("multi_outs = %x/%x/%x/%x : %x/%x/%x/%x\n",
3297 cfg
->line_out_pins
[0], cfg
->line_out_pins
[1],
3298 cfg
->line_out_pins
[2], cfg
->line_out_pins
[2],
3299 spec
->multiout
.dac_nids
[0],
3300 spec
->multiout
.dac_nids
[1],
3301 spec
->multiout
.dac_nids
[2],
3302 spec
->multiout
.dac_nids
[3]);
3303 if (spec
->multi_ios
> 0)
3304 debug_badness("multi_ios(%d) = %x/%x : %x/%x\n",
3306 spec
->multi_io
[0].pin
, spec
->multi_io
[1].pin
,
3307 spec
->multi_io
[0].dac
, spec
->multi_io
[1].dac
);
3308 debug_badness("hp_outs = %x/%x/%x/%x : %x/%x/%x/%x\n",
3309 cfg
->hp_pins
[0], cfg
->hp_pins
[1],
3310 cfg
->hp_pins
[2], cfg
->hp_pins
[2],
3311 spec
->multiout
.hp_out_nid
[0],
3312 spec
->multiout
.hp_out_nid
[1],
3313 spec
->multiout
.hp_out_nid
[2],
3314 spec
->multiout
.hp_out_nid
[3]);
3315 debug_badness("spk_outs = %x/%x/%x/%x : %x/%x/%x/%x\n",
3316 cfg
->speaker_pins
[0], cfg
->speaker_pins
[1],
3317 cfg
->speaker_pins
[2], cfg
->speaker_pins
[3],
3318 spec
->multiout
.extra_out_nid
[0],
3319 spec
->multiout
.extra_out_nid
[1],
3320 spec
->multiout
.extra_out_nid
[2],
3321 spec
->multiout
.extra_out_nid
[3]);
3324 static int alc_auto_fill_dac_nids(struct hda_codec
*codec
)
3326 struct alc_spec
*spec
= codec
->spec
;
3327 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3328 struct auto_pin_cfg
*best_cfg
;
3329 int best_badness
= INT_MAX
;
3331 bool fill_hardwired
= true, fill_mio_first
= true;
3332 bool best_wired
= true, best_mio
= true;
3333 bool hp_spk_swapped
= false;
3335 best_cfg
= kmalloc(sizeof(*best_cfg
), GFP_KERNEL
);
3341 badness
= fill_and_eval_dacs(codec
, fill_hardwired
,
3347 debug_badness("==> lo_type=%d, wired=%d, mio=%d, badness=0x%x\n",
3348 cfg
->line_out_type
, fill_hardwired
, fill_mio_first
,
3350 debug_show_configs(spec
, cfg
);
3351 if (badness
< best_badness
) {
3352 best_badness
= badness
;
3354 best_wired
= fill_hardwired
;
3355 best_mio
= fill_mio_first
;
3359 fill_mio_first
= !fill_mio_first
;
3360 if (!fill_mio_first
)
3362 fill_hardwired
= !fill_hardwired
;
3363 if (!fill_hardwired
)
3367 hp_spk_swapped
= true;
3368 if (cfg
->speaker_outs
> 0 &&
3369 cfg
->line_out_type
== AUTO_PIN_HP_OUT
) {
3370 cfg
->hp_outs
= cfg
->line_outs
;
3371 memcpy(cfg
->hp_pins
, cfg
->line_out_pins
,
3372 sizeof(cfg
->hp_pins
));
3373 cfg
->line_outs
= cfg
->speaker_outs
;
3374 memcpy(cfg
->line_out_pins
, cfg
->speaker_pins
,
3375 sizeof(cfg
->speaker_pins
));
3376 cfg
->speaker_outs
= 0;
3377 memset(cfg
->speaker_pins
, 0, sizeof(cfg
->speaker_pins
));
3378 cfg
->line_out_type
= AUTO_PIN_SPEAKER_OUT
;
3379 fill_hardwired
= true;
3382 if (cfg
->hp_outs
> 0 &&
3383 cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
) {
3384 cfg
->speaker_outs
= cfg
->line_outs
;
3385 memcpy(cfg
->speaker_pins
, cfg
->line_out_pins
,
3386 sizeof(cfg
->speaker_pins
));
3387 cfg
->line_outs
= cfg
->hp_outs
;
3388 memcpy(cfg
->line_out_pins
, cfg
->hp_pins
,
3389 sizeof(cfg
->hp_pins
));
3391 memset(cfg
->hp_pins
, 0, sizeof(cfg
->hp_pins
));
3392 cfg
->line_out_type
= AUTO_PIN_HP_OUT
;
3393 fill_hardwired
= true;
3401 fill_and_eval_dacs(codec
, best_wired
, best_mio
);
3403 debug_badness("==> Best config: lo_type=%d, wired=%d, mio=%d\n",
3404 cfg
->line_out_type
, best_wired
, best_mio
);
3405 debug_show_configs(spec
, cfg
);
3407 if (cfg
->line_out_pins
[0])
3409 alc_look_for_out_vol_nid(codec
, cfg
->line_out_pins
[0],
3410 spec
->multiout
.dac_nids
[0]);
3412 /* clear the bitmap flags for creating controls */
3413 clear_vol_marks(codec
);
3418 static int alc_auto_add_vol_ctl(struct hda_codec
*codec
,
3419 const char *pfx
, int cidx
,
3420 hda_nid_t nid
, unsigned int chs
)
3422 struct alc_spec
*spec
= codec
->spec
;
3426 val
= HDA_COMPOSE_AMP_VAL(nid
, chs
, 0, HDA_OUTPUT
);
3427 if (is_ctl_used(spec
->vol_ctls
, val
) && chs
!= 2) /* exclude LFE */
3429 mark_ctl_usage(spec
->vol_ctls
, val
);
3430 return __add_pb_vol_ctrl(codec
->spec
, ALC_CTL_WIDGET_VOL
, pfx
, cidx
,
3434 static int alc_auto_add_stereo_vol(struct hda_codec
*codec
,
3435 const char *pfx
, int cidx
,
3439 if (get_wcaps(codec
, nid
) & AC_WCAP_STEREO
)
3441 return alc_auto_add_vol_ctl(codec
, pfx
, cidx
, nid
, chs
);
3444 /* create a mute-switch for the given mixer widget;
3445 * if it has multiple sources (e.g. DAC and loopback), create a bind-mute
3447 static int alc_auto_add_sw_ctl(struct hda_codec
*codec
,
3448 const char *pfx
, int cidx
,
3449 hda_nid_t nid
, unsigned int chs
)
3451 struct alc_spec
*spec
= codec
->spec
;
3457 wid_type
= get_wcaps_type(get_wcaps(codec
, nid
));
3458 if (wid_type
== AC_WID_PIN
|| wid_type
== AC_WID_AUD_OUT
) {
3459 type
= ALC_CTL_WIDGET_MUTE
;
3460 val
= HDA_COMPOSE_AMP_VAL(nid
, chs
, 0, HDA_OUTPUT
);
3461 } else if (snd_hda_get_num_conns(codec
, nid
) == 1) {
3462 type
= ALC_CTL_WIDGET_MUTE
;
3463 val
= HDA_COMPOSE_AMP_VAL(nid
, chs
, 0, HDA_INPUT
);
3465 type
= ALC_CTL_BIND_MUTE
;
3466 val
= HDA_COMPOSE_AMP_VAL(nid
, chs
, 2, HDA_INPUT
);
3468 if (is_ctl_used(spec
->sw_ctls
, val
) && chs
!= 2) /* exclude LFE */
3470 mark_ctl_usage(spec
->sw_ctls
, val
);
3471 return __add_pb_sw_ctrl(codec
->spec
, type
, pfx
, cidx
, val
);
3474 static int alc_auto_add_stereo_sw(struct hda_codec
*codec
, const char *pfx
,
3475 int cidx
, hda_nid_t nid
)
3478 if (get_wcaps(codec
, nid
) & AC_WCAP_STEREO
)
3480 return alc_auto_add_sw_ctl(codec
, pfx
, cidx
, nid
, chs
);
3483 static hda_nid_t
alc_look_for_out_mute_nid(struct hda_codec
*codec
,
3484 hda_nid_t pin
, hda_nid_t dac
)
3486 hda_nid_t mix
= alc_auto_dac_to_mix(codec
, pin
, dac
);
3487 if (nid_has_mute(codec
, pin
, HDA_OUTPUT
))
3489 else if (mix
&& nid_has_mute(codec
, mix
, HDA_INPUT
))
3491 else if (nid_has_mute(codec
, dac
, HDA_OUTPUT
))
3496 static hda_nid_t
alc_look_for_out_vol_nid(struct hda_codec
*codec
,
3497 hda_nid_t pin
, hda_nid_t dac
)
3499 hda_nid_t mix
= alc_auto_dac_to_mix(codec
, pin
, dac
);
3500 if (nid_has_volume(codec
, dac
, HDA_OUTPUT
))
3502 else if (nid_has_volume(codec
, mix
, HDA_OUTPUT
))
3504 else if (nid_has_volume(codec
, pin
, HDA_OUTPUT
))
3509 /* add playback controls from the parsed DAC table */
3510 static int alc_auto_create_multi_out_ctls(struct hda_codec
*codec
,
3511 const struct auto_pin_cfg
*cfg
)
3513 struct alc_spec
*spec
= codec
->spec
;
3514 int i
, err
, noutputs
;
3516 noutputs
= cfg
->line_outs
;
3517 if (spec
->multi_ios
> 0 && cfg
->line_outs
< 3)
3518 noutputs
+= spec
->multi_ios
;
3520 for (i
= 0; i
< noutputs
; i
++) {
3526 dac
= spec
->multiout
.dac_nids
[i
];
3529 if (i
>= cfg
->line_outs
) {
3530 pin
= spec
->multi_io
[i
- 1].pin
;
3532 name
= channel_name
[i
];
3534 pin
= cfg
->line_out_pins
[i
];
3535 name
= alc_get_line_out_pfx(spec
, i
, true, &index
);
3538 sw
= alc_look_for_out_mute_nid(codec
, pin
, dac
);
3539 vol
= alc_look_for_out_vol_nid(codec
, pin
, dac
);
3540 if (!name
|| !strcmp(name
, "CLFE")) {
3542 err
= alc_auto_add_vol_ctl(codec
, "Center", 0, vol
, 1);
3545 err
= alc_auto_add_vol_ctl(codec
, "LFE", 0, vol
, 2);
3548 err
= alc_auto_add_sw_ctl(codec
, "Center", 0, sw
, 1);
3551 err
= alc_auto_add_sw_ctl(codec
, "LFE", 0, sw
, 2);
3555 err
= alc_auto_add_stereo_vol(codec
, name
, index
, vol
);
3558 err
= alc_auto_add_stereo_sw(codec
, name
, index
, sw
);
3566 static int alc_auto_create_extra_out(struct hda_codec
*codec
, hda_nid_t pin
,
3567 hda_nid_t dac
, const char *pfx
,
3570 struct alc_spec
*spec
= codec
->spec
;
3576 /* the corresponding DAC is already occupied */
3577 if (!(get_wcaps(codec
, pin
) & AC_WCAP_OUT_AMP
))
3578 return 0; /* no way */
3579 /* create a switch only */
3580 val
= HDA_COMPOSE_AMP_VAL(pin
, 3, 0, HDA_OUTPUT
);
3581 if (is_ctl_used(spec
->sw_ctls
, val
))
3582 return 0; /* already created */
3583 mark_ctl_usage(spec
->sw_ctls
, val
);
3584 return __add_pb_sw_ctrl(spec
, ALC_CTL_WIDGET_MUTE
, pfx
, cidx
, val
);
3587 sw
= alc_look_for_out_mute_nid(codec
, pin
, dac
);
3588 vol
= alc_look_for_out_vol_nid(codec
, pin
, dac
);
3589 err
= alc_auto_add_stereo_vol(codec
, pfx
, cidx
, vol
);
3592 err
= alc_auto_add_stereo_sw(codec
, pfx
, cidx
, sw
);
3598 static struct hda_bind_ctls
*new_bind_ctl(struct hda_codec
*codec
,
3600 struct hda_ctl_ops
*ops
)
3602 struct alc_spec
*spec
= codec
->spec
;
3603 struct hda_bind_ctls
**ctlp
, *ctl
;
3604 snd_array_init(&spec
->bind_ctls
, sizeof(ctl
), 8);
3605 ctlp
= snd_array_new(&spec
->bind_ctls
);
3608 ctl
= kzalloc(sizeof(*ctl
) + sizeof(long) * (nums
+ 1), GFP_KERNEL
);
3615 /* add playback controls for speaker and HP outputs */
3616 static int alc_auto_create_extra_outs(struct hda_codec
*codec
, int num_pins
,
3617 const hda_nid_t
*pins
,
3618 const hda_nid_t
*dacs
,
3621 struct alc_spec
*spec
= codec
->spec
;
3622 struct hda_bind_ctls
*ctl
;
3626 if (!num_pins
|| !pins
[0])
3629 if (num_pins
== 1) {
3630 hda_nid_t dac
= *dacs
;
3632 dac
= spec
->multiout
.dac_nids
[0];
3633 return alc_auto_create_extra_out(codec
, *pins
, dac
, pfx
, 0);
3636 for (i
= 0; i
< num_pins
; i
++) {
3638 if (dacs
[num_pins
- 1])
3639 dac
= dacs
[i
]; /* with individual volumes */
3642 if (num_pins
== 2 && i
== 1 && !strcmp(pfx
, "Speaker")) {
3643 err
= alc_auto_create_extra_out(codec
, pins
[i
], dac
,
3645 } else if (num_pins
>= 3) {
3646 snprintf(name
, sizeof(name
), "%s %s",
3647 pfx
, channel_name
[i
]);
3648 err
= alc_auto_create_extra_out(codec
, pins
[i
], dac
,
3651 err
= alc_auto_create_extra_out(codec
, pins
[i
], dac
,
3657 if (dacs
[num_pins
- 1])
3660 /* Let's create a bind-controls for volumes */
3661 ctl
= new_bind_ctl(codec
, num_pins
, &snd_hda_bind_vol
);
3665 for (i
= 0; i
< num_pins
; i
++) {
3667 if (!pins
[i
] || !dacs
[i
])
3669 vol
= alc_look_for_out_vol_nid(codec
, pins
[i
], dacs
[i
]);
3672 HDA_COMPOSE_AMP_VAL(vol
, 3, 0, HDA_OUTPUT
);
3675 snprintf(name
, sizeof(name
), "%s Playback Volume", pfx
);
3676 err
= add_control(spec
, ALC_CTL_BIND_VOL
, name
, 0, (long)ctl
);
3683 static int alc_auto_create_hp_out(struct hda_codec
*codec
)
3685 struct alc_spec
*spec
= codec
->spec
;
3686 return alc_auto_create_extra_outs(codec
, spec
->autocfg
.hp_outs
,
3687 spec
->autocfg
.hp_pins
,
3688 spec
->multiout
.hp_out_nid
,
3692 static int alc_auto_create_speaker_out(struct hda_codec
*codec
)
3694 struct alc_spec
*spec
= codec
->spec
;
3695 return alc_auto_create_extra_outs(codec
, spec
->autocfg
.speaker_outs
,
3696 spec
->autocfg
.speaker_pins
,
3697 spec
->multiout
.extra_out_nid
,
3701 static void alc_auto_set_output_and_unmute(struct hda_codec
*codec
,
3702 hda_nid_t pin
, int pin_type
,
3706 hda_nid_t nid
, mix
= 0;
3707 hda_nid_t srcs
[HDA_MAX_CONNECTIONS
];
3709 alc_set_pin_output(codec
, pin
, pin_type
);
3710 nid
= alc_go_down_to_selector(codec
, pin
);
3711 num
= snd_hda_get_connections(codec
, nid
, srcs
, ARRAY_SIZE(srcs
));
3712 for (i
= 0; i
< num
; i
++) {
3713 if (alc_auto_mix_to_dac(codec
, srcs
[i
]) != dac
)
3721 /* need the manual connection? */
3723 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_CONNECT_SEL
, i
);
3724 /* unmute mixer widget inputs */
3725 if (nid_has_mute(codec
, mix
, HDA_INPUT
)) {
3726 snd_hda_codec_write(codec
, mix
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3728 snd_hda_codec_write(codec
, mix
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3731 /* initialize volume */
3732 nid
= alc_look_for_out_vol_nid(codec
, pin
, dac
);
3734 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3737 /* unmute DAC if it's not assigned to a mixer */
3738 nid
= alc_look_for_out_mute_nid(codec
, pin
, dac
);
3739 if (nid
== mix
&& nid_has_mute(codec
, dac
, HDA_OUTPUT
))
3740 snd_hda_codec_write(codec
, dac
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3744 static void alc_auto_init_multi_out(struct hda_codec
*codec
)
3746 struct alc_spec
*spec
= codec
->spec
;
3747 int pin_type
= get_pin_type(spec
->autocfg
.line_out_type
);
3750 for (i
= 0; i
<= HDA_SIDE
; i
++) {
3751 hda_nid_t nid
= spec
->autocfg
.line_out_pins
[i
];
3753 alc_auto_set_output_and_unmute(codec
, nid
, pin_type
,
3754 spec
->multiout
.dac_nids
[i
]);
3758 static void alc_auto_init_extra_out(struct hda_codec
*codec
)
3760 struct alc_spec
*spec
= codec
->spec
;
3764 for (i
= 0; i
< spec
->autocfg
.hp_outs
; i
++) {
3765 if (spec
->autocfg
.line_out_type
== AUTO_PIN_HP_OUT
)
3767 pin
= spec
->autocfg
.hp_pins
[i
];
3770 dac
= spec
->multiout
.hp_out_nid
[i
];
3772 if (i
> 0 && spec
->multiout
.hp_out_nid
[0])
3773 dac
= spec
->multiout
.hp_out_nid
[0];
3775 dac
= spec
->multiout
.dac_nids
[0];
3777 alc_auto_set_output_and_unmute(codec
, pin
, PIN_HP
, dac
);
3779 for (i
= 0; i
< spec
->autocfg
.speaker_outs
; i
++) {
3780 if (spec
->autocfg
.line_out_type
== AUTO_PIN_SPEAKER_OUT
)
3782 pin
= spec
->autocfg
.speaker_pins
[i
];
3785 dac
= spec
->multiout
.extra_out_nid
[i
];
3787 if (i
> 0 && spec
->multiout
.extra_out_nid
[0])
3788 dac
= spec
->multiout
.extra_out_nid
[0];
3790 dac
= spec
->multiout
.dac_nids
[0];
3792 alc_auto_set_output_and_unmute(codec
, pin
, PIN_OUT
, dac
);
3796 /* check whether the given pin can be a multi-io pin */
3797 static bool can_be_multiio_pin(struct hda_codec
*codec
,
3798 unsigned int location
, hda_nid_t nid
)
3800 unsigned int defcfg
, caps
;
3802 defcfg
= snd_hda_codec_get_pincfg(codec
, nid
);
3803 if (get_defcfg_connect(defcfg
) != AC_JACK_PORT_COMPLEX
)
3805 if (location
&& get_defcfg_location(defcfg
) != location
)
3807 caps
= snd_hda_query_pin_caps(codec
, nid
);
3808 if (!(caps
& AC_PINCAP_OUT
))
3816 * When hardwired is set, try to fill ony hardwired pins, and returns
3817 * zero if any pins are filled, non-zero if nothing found.
3818 * When hardwired is off, try to fill possible input pins, and returns
3819 * the badness value.
3821 static int alc_auto_fill_multi_ios(struct hda_codec
*codec
,
3822 hda_nid_t reference_pin
,
3823 bool hardwired
, int offset
)
3825 struct alc_spec
*spec
= codec
->spec
;
3826 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3827 int type
, i
, j
, dacs
, num_pins
, old_pins
;
3828 unsigned int defcfg
= snd_hda_codec_get_pincfg(codec
, reference_pin
);
3829 unsigned int location
= get_defcfg_location(defcfg
);
3832 old_pins
= spec
->multi_ios
;
3837 for (type
= AUTO_PIN_LINE_IN
; type
>= AUTO_PIN_MIC
; type
--) {
3838 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3839 if (cfg
->inputs
[i
].type
!= type
)
3841 if (can_be_multiio_pin(codec
, location
,
3842 cfg
->inputs
[i
].pin
))
3849 dacs
= spec
->multiout
.num_dacs
;
3850 for (type
= AUTO_PIN_LINE_IN
; type
>= AUTO_PIN_MIC
; type
--) {
3851 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3852 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
3855 if (cfg
->inputs
[i
].type
!= type
)
3857 if (!can_be_multiio_pin(codec
, location
, nid
))
3859 for (j
= 0; j
< spec
->multi_ios
; j
++) {
3860 if (nid
== spec
->multi_io
[j
].pin
)
3863 if (j
< spec
->multi_ios
)
3866 if (offset
&& offset
+ spec
->multi_ios
< dacs
) {
3867 dac
= spec
->private_dac_nids
[offset
+ spec
->multi_ios
];
3868 if (!alc_auto_is_dac_reachable(codec
, nid
, dac
))
3872 dac
= get_dac_if_single(codec
, nid
);
3874 dac
= alc_auto_look_for_dac(codec
, nid
);
3879 spec
->multi_io
[spec
->multi_ios
].pin
= nid
;
3880 spec
->multi_io
[spec
->multi_ios
].dac
= dac
;
3882 if (spec
->multi_ios
>= 2)
3888 badness
= BAD_MULTI_IO
;
3889 if (old_pins
== spec
->multi_ios
) {
3891 return 1; /* nothing found */
3893 return badness
; /* no badness if nothing found */
3895 if (!hardwired
&& spec
->multi_ios
< 2) {
3896 spec
->multi_ios
= old_pins
;
3903 static int alc_auto_ch_mode_info(struct snd_kcontrol
*kcontrol
,
3904 struct snd_ctl_elem_info
*uinfo
)
3906 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3907 struct alc_spec
*spec
= codec
->spec
;
3909 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
3911 uinfo
->value
.enumerated
.items
= spec
->multi_ios
+ 1;
3912 if (uinfo
->value
.enumerated
.item
> spec
->multi_ios
)
3913 uinfo
->value
.enumerated
.item
= spec
->multi_ios
;
3914 sprintf(uinfo
->value
.enumerated
.name
, "%dch",
3915 (uinfo
->value
.enumerated
.item
+ 1) * 2);
3919 static int alc_auto_ch_mode_get(struct snd_kcontrol
*kcontrol
,
3920 struct snd_ctl_elem_value
*ucontrol
)
3922 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3923 struct alc_spec
*spec
= codec
->spec
;
3924 ucontrol
->value
.enumerated
.item
[0] = (spec
->ext_channel_count
- 1) / 2;
3928 static int alc_set_multi_io(struct hda_codec
*codec
, int idx
, bool output
)
3930 struct alc_spec
*spec
= codec
->spec
;
3931 hda_nid_t nid
= spec
->multi_io
[idx
].pin
;
3933 if (!spec
->multi_io
[idx
].ctl_in
)
3934 spec
->multi_io
[idx
].ctl_in
=
3935 snd_hda_codec_read(codec
, nid
, 0,
3936 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
3938 snd_hda_set_pin_ctl_cache(codec
, nid
, PIN_OUT
);
3939 if (get_wcaps(codec
, nid
) & AC_WCAP_OUT_AMP
)
3940 snd_hda_codec_amp_stereo(codec
, nid
, HDA_OUTPUT
, 0,
3942 alc_auto_select_dac(codec
, nid
, spec
->multi_io
[idx
].dac
);
3944 if (get_wcaps(codec
, nid
) & AC_WCAP_OUT_AMP
)
3945 snd_hda_codec_amp_stereo(codec
, nid
, HDA_OUTPUT
, 0,
3946 HDA_AMP_MUTE
, HDA_AMP_MUTE
);
3947 snd_hda_set_pin_ctl_cache(codec
, nid
,
3948 spec
->multi_io
[idx
].ctl_in
);
3953 static int alc_auto_ch_mode_put(struct snd_kcontrol
*kcontrol
,
3954 struct snd_ctl_elem_value
*ucontrol
)
3956 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3957 struct alc_spec
*spec
= codec
->spec
;
3960 ch
= ucontrol
->value
.enumerated
.item
[0];
3961 if (ch
< 0 || ch
> spec
->multi_ios
)
3963 if (ch
== (spec
->ext_channel_count
- 1) / 2)
3965 spec
->ext_channel_count
= (ch
+ 1) * 2;
3966 for (i
= 0; i
< spec
->multi_ios
; i
++)
3967 alc_set_multi_io(codec
, i
, i
< ch
);
3968 spec
->multiout
.max_channels
= spec
->ext_channel_count
;
3969 if (spec
->need_dac_fix
&& !spec
->const_channel_count
)
3970 spec
->multiout
.num_dacs
= spec
->multiout
.max_channels
/ 2;
3974 static const struct snd_kcontrol_new alc_auto_channel_mode_enum
= {
3975 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3976 .name
= "Channel Mode",
3977 .info
= alc_auto_ch_mode_info
,
3978 .get
= alc_auto_ch_mode_get
,
3979 .put
= alc_auto_ch_mode_put
,
3982 static int alc_auto_add_multi_channel_mode(struct hda_codec
*codec
)
3984 struct alc_spec
*spec
= codec
->spec
;
3986 if (spec
->multi_ios
> 0) {
3987 struct snd_kcontrol_new
*knew
;
3989 knew
= alc_kcontrol_new(spec
);
3992 *knew
= alc_auto_channel_mode_enum
;
3993 knew
->name
= kstrdup("Channel Mode", GFP_KERNEL
);
4000 /* filter out invalid adc_nids (and capsrc_nids) that don't give all
4003 static void alc_remove_invalid_adc_nids(struct hda_codec
*codec
)
4005 struct alc_spec
*spec
= codec
->spec
;
4006 const struct hda_input_mux
*imux
;
4007 hda_nid_t adc_nids
[ARRAY_SIZE(spec
->private_adc_nids
)];
4008 hda_nid_t capsrc_nids
[ARRAY_SIZE(spec
->private_adc_nids
)];
4011 imux
= spec
->input_mux
;
4014 if (spec
->dyn_adc_switch
)
4019 for (n
= 0; n
< spec
->num_adc_nids
; n
++) {
4020 hda_nid_t cap
= spec
->private_capsrc_nids
[n
];
4021 int num_conns
= snd_hda_get_num_conns(codec
, cap
);
4022 for (i
= 0; i
< imux
->num_items
; i
++) {
4023 hda_nid_t pin
= spec
->imux_pins
[i
];
4025 if (get_connection_index(codec
, cap
, pin
) < 0)
4027 } else if (num_conns
<= imux
->items
[i
].index
)
4030 if (i
>= imux
->num_items
) {
4031 adc_nids
[nums
] = spec
->private_adc_nids
[n
];
4032 capsrc_nids
[nums
++] = cap
;
4036 /* check whether ADC-switch is possible */
4037 if (!alc_check_dyn_adc_switch(codec
)) {
4038 if (spec
->shared_mic_hp
) {
4039 spec
->shared_mic_hp
= 0;
4040 spec
->private_imux
[0].num_items
= 1;
4043 printk(KERN_WARNING
"hda_codec: %s: no valid ADC found;"
4044 " using fallback 0x%x\n",
4045 codec
->chip_name
, spec
->private_adc_nids
[0]);
4046 spec
->num_adc_nids
= 1;
4050 } else if (nums
!= spec
->num_adc_nids
) {
4051 memcpy(spec
->private_adc_nids
, adc_nids
,
4052 nums
* sizeof(hda_nid_t
));
4053 memcpy(spec
->private_capsrc_nids
, capsrc_nids
,
4054 nums
* sizeof(hda_nid_t
));
4055 spec
->num_adc_nids
= nums
;
4059 alc_auto_mic_check_imux(codec
); /* check auto-mic setups */
4060 else if (spec
->input_mux
->num_items
== 1 || spec
->shared_mic_hp
)
4061 spec
->num_adc_nids
= 1; /* reduce to a single ADC */
4065 * initialize ADC paths
4067 static void alc_auto_init_adc(struct hda_codec
*codec
, int adc_idx
)
4069 struct alc_spec
*spec
= codec
->spec
;
4072 nid
= spec
->adc_nids
[adc_idx
];
4074 if (nid_has_mute(codec
, nid
, HDA_INPUT
)) {
4075 snd_hda_codec_write(codec
, nid
, 0,
4076 AC_VERB_SET_AMP_GAIN_MUTE
,
4080 if (!spec
->capsrc_nids
)
4082 nid
= spec
->capsrc_nids
[adc_idx
];
4083 if (nid_has_mute(codec
, nid
, HDA_OUTPUT
))
4084 snd_hda_codec_write(codec
, nid
, 0,
4085 AC_VERB_SET_AMP_GAIN_MUTE
,
4089 static void alc_auto_init_input_src(struct hda_codec
*codec
)
4091 struct alc_spec
*spec
= codec
->spec
;
4094 for (c
= 0; c
< spec
->num_adc_nids
; c
++)
4095 alc_auto_init_adc(codec
, c
);
4096 if (spec
->dyn_adc_switch
)
4099 nums
= spec
->num_adc_nids
;
4100 for (c
= 0; c
< nums
; c
++)
4101 alc_mux_select(codec
, c
, spec
->cur_mux
[c
], true);
4104 /* add mic boosts if needed */
4105 static int alc_auto_add_mic_boost(struct hda_codec
*codec
)
4107 struct alc_spec
*spec
= codec
->spec
;
4108 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4112 const char *prev_label
= NULL
;
4114 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
4115 if (cfg
->inputs
[i
].type
> AUTO_PIN_MIC
)
4117 nid
= cfg
->inputs
[i
].pin
;
4118 if (get_wcaps(codec
, nid
) & AC_WCAP_IN_AMP
) {
4120 char boost_label
[32];
4122 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
4123 if (spec
->shared_mic_hp
&& !strcmp(label
, "Misc"))
4124 label
= "Headphone Mic";
4125 if (prev_label
&& !strcmp(label
, prev_label
))
4131 snprintf(boost_label
, sizeof(boost_label
),
4132 "%s Boost Volume", label
);
4133 err
= add_control(spec
, ALC_CTL_WIDGET_VOL
,
4134 boost_label
, type_idx
,
4135 HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_INPUT
));
4143 /* select or unmute the given capsrc route */
4144 static void select_or_unmute_capsrc(struct hda_codec
*codec
, hda_nid_t cap
,
4147 if (get_wcaps_type(get_wcaps(codec
, cap
)) == AC_WID_AUD_MIX
) {
4148 snd_hda_codec_amp_stereo(codec
, cap
, HDA_INPUT
, idx
,
4150 } else if (snd_hda_get_num_conns(codec
, cap
) > 1) {
4151 snd_hda_codec_write_cache(codec
, cap
, 0,
4152 AC_VERB_SET_CONNECT_SEL
, idx
);
4156 /* set the default connection to that pin */
4157 static int init_capsrc_for_pin(struct hda_codec
*codec
, hda_nid_t pin
)
4159 struct alc_spec
*spec
= codec
->spec
;
4164 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
4165 hda_nid_t cap
= get_capsrc(spec
, i
);
4168 idx
= get_connection_index(codec
, cap
, pin
);
4171 select_or_unmute_capsrc(codec
, cap
, idx
);
4172 return i
; /* return the found index */
4174 return -1; /* not found */
4177 /* initialize some special cases for input sources */
4178 static void alc_init_special_input_src(struct hda_codec
*codec
)
4180 struct alc_spec
*spec
= codec
->spec
;
4183 for (i
= 0; i
< spec
->autocfg
.num_inputs
; i
++)
4184 init_capsrc_for_pin(codec
, spec
->autocfg
.inputs
[i
].pin
);
4187 /* assign appropriate capture mixers */
4188 static void set_capture_mixer(struct hda_codec
*codec
)
4190 struct alc_spec
*spec
= codec
->spec
;
4191 static const struct snd_kcontrol_new
*caps
[2][3] = {
4192 { alc_capture_mixer_nosrc1
,
4193 alc_capture_mixer_nosrc2
,
4194 alc_capture_mixer_nosrc3
},
4195 { alc_capture_mixer1
,
4197 alc_capture_mixer3
},
4200 /* check whether either of ADC or MUX has a volume control */
4201 if (!nid_has_volume(codec
, spec
->adc_nids
[0], HDA_INPUT
)) {
4202 if (!spec
->capsrc_nids
)
4203 return; /* no volume */
4204 if (!nid_has_volume(codec
, spec
->capsrc_nids
[0], HDA_OUTPUT
))
4205 return; /* no volume in capsrc, too */
4206 spec
->vol_in_capsrc
= 1;
4209 if (spec
->num_adc_nids
> 0) {
4213 if (spec
->input_mux
&& spec
->input_mux
->num_items
> 1)
4215 if (spec
->auto_mic
) {
4218 } else if (spec
->dyn_adc_switch
)
4221 if (spec
->num_adc_nids
> 3)
4222 spec
->num_adc_nids
= 3;
4223 else if (!spec
->num_adc_nids
)
4225 num_adcs
= spec
->num_adc_nids
;
4227 spec
->cap_mixer
= caps
[mux
][num_adcs
- 1];
4232 * standard auto-parser initializations
4234 static void alc_auto_init_std(struct hda_codec
*codec
)
4236 struct alc_spec
*spec
= codec
->spec
;
4237 alc_auto_init_multi_out(codec
);
4238 alc_auto_init_extra_out(codec
);
4239 alc_auto_init_analog_input(codec
);
4240 alc_auto_init_input_src(codec
);
4241 alc_auto_init_digital(codec
);
4242 if (spec
->unsol_event
)
4243 alc_inithook(codec
);
4247 * Digital-beep handlers
4249 #ifdef CONFIG_SND_HDA_INPUT_BEEP
4250 #define set_beep_amp(spec, nid, idx, dir) \
4251 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4253 static const struct snd_pci_quirk beep_white_list
[] = {
4254 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
4255 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
4256 SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
4257 SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
4258 SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1),
4259 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
4263 static inline int has_cdefine_beep(struct hda_codec
*codec
)
4265 struct alc_spec
*spec
= codec
->spec
;
4266 const struct snd_pci_quirk
*q
;
4267 q
= snd_pci_quirk_lookup(codec
->bus
->pci
, beep_white_list
);
4270 return spec
->cdefine
.enable_pcbeep
;
4273 #define set_beep_amp(spec, nid, idx, dir) /* NOP */
4274 #define has_cdefine_beep(codec) 0
4277 /* parse the BIOS configuration and set up the alc_spec */
4278 /* return 1 if successful, 0 if the proper config is not found,
4279 * or a negative error code
4281 static int alc_parse_auto_config(struct hda_codec
*codec
,
4282 const hda_nid_t
*ignore_nids
,
4283 const hda_nid_t
*ssid_nids
)
4285 struct alc_spec
*spec
= codec
->spec
;
4286 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4289 err
= snd_hda_parse_pin_defcfg(codec
, cfg
, ignore_nids
,
4293 if (!cfg
->line_outs
) {
4294 if (cfg
->dig_outs
|| cfg
->dig_in_pin
) {
4295 spec
->multiout
.max_channels
= 2;
4296 spec
->no_analog
= 1;
4299 return 0; /* can't find valid BIOS pin config */
4302 if (cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
&&
4303 cfg
->line_outs
<= cfg
->hp_outs
) {
4304 /* use HP as primary out */
4305 cfg
->speaker_outs
= cfg
->line_outs
;
4306 memcpy(cfg
->speaker_pins
, cfg
->line_out_pins
,
4307 sizeof(cfg
->speaker_pins
));
4308 cfg
->line_outs
= cfg
->hp_outs
;
4309 memcpy(cfg
->line_out_pins
, cfg
->hp_pins
, sizeof(cfg
->hp_pins
));
4311 memset(cfg
->hp_pins
, 0, sizeof(cfg
->hp_pins
));
4312 cfg
->line_out_type
= AUTO_PIN_HP_OUT
;
4315 err
= alc_auto_fill_dac_nids(codec
);
4318 err
= alc_auto_add_multi_channel_mode(codec
);
4321 err
= alc_auto_create_multi_out_ctls(codec
, cfg
);
4324 err
= alc_auto_create_hp_out(codec
);
4327 err
= alc_auto_create_speaker_out(codec
);
4330 err
= alc_auto_create_shared_input(codec
);
4333 err
= alc_auto_create_input_ctls(codec
);
4337 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
4340 alc_auto_parse_digital(codec
);
4342 if (!spec
->no_analog
)
4343 alc_remove_invalid_adc_nids(codec
);
4346 alc_ssid_check(codec
, ssid_nids
);
4348 if (!spec
->no_analog
) {
4349 alc_auto_check_switches(codec
);
4350 err
= alc_auto_add_mic_boost(codec
);
4355 if (spec
->kctls
.list
)
4356 add_mixer(spec
, spec
->kctls
.list
);
4358 if (!spec
->no_analog
&& !spec
->cap_mixer
)
4359 set_capture_mixer(codec
);
4364 /* common preparation job for alc_spec */
4365 static int alc_alloc_spec(struct hda_codec
*codec
, hda_nid_t mixer_nid
)
4367 struct alc_spec
*spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4373 spec
->mixer_nid
= mixer_nid
;
4375 err
= alc_codec_rename_from_preset(codec
);
4383 static int alc880_parse_auto_config(struct hda_codec
*codec
)
4385 static const hda_nid_t alc880_ignore
[] = { 0x1d, 0 };
4386 static const hda_nid_t alc880_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
4387 return alc_parse_auto_config(codec
, alc880_ignore
, alc880_ssids
);
4396 ALC880_FIXUP_MEDION_RIM
,
4399 ALC880_FIXUP_EAPD_COEF
,
4400 ALC880_FIXUP_TCL_S700
,
4401 ALC880_FIXUP_VOL_KNOB
,
4402 ALC880_FIXUP_FUJITSU
,
4404 ALC880_FIXUP_UNIWILL
,
4405 ALC880_FIXUP_UNIWILL_DIG
,
4407 ALC880_FIXUP_3ST_BASE
,
4409 ALC880_FIXUP_3ST_DIG
,
4410 ALC880_FIXUP_5ST_BASE
,
4412 ALC880_FIXUP_5ST_DIG
,
4413 ALC880_FIXUP_6ST_BASE
,
4415 ALC880_FIXUP_6ST_DIG
,
4418 /* enable the volume-knob widget support on NID 0x21 */
4419 static void alc880_fixup_vol_knob(struct hda_codec
*codec
,
4420 const struct alc_fixup
*fix
, int action
)
4422 if (action
== ALC_FIXUP_ACT_PROBE
)
4423 snd_hda_jack_detect_enable(codec
, 0x21, ALC_DCVOL_EVENT
);
4426 static const struct alc_fixup alc880_fixups
[] = {
4427 [ALC880_FIXUP_GPIO1
] = {
4428 .type
= ALC_FIXUP_VERBS
,
4429 .v
.verbs
= alc_gpio1_init_verbs
,
4431 [ALC880_FIXUP_GPIO2
] = {
4432 .type
= ALC_FIXUP_VERBS
,
4433 .v
.verbs
= alc_gpio2_init_verbs
,
4435 [ALC880_FIXUP_MEDION_RIM
] = {
4436 .type
= ALC_FIXUP_VERBS
,
4437 .v
.verbs
= (const struct hda_verb
[]) {
4438 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4439 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3060 },
4443 .chain_id
= ALC880_FIXUP_GPIO2
,
4445 [ALC880_FIXUP_LG
] = {
4446 .type
= ALC_FIXUP_PINS
,
4447 .v
.pins
= (const struct alc_pincfg
[]) {
4448 /* disable bogus unused pins */
4449 { 0x16, 0x411111f0 },
4450 { 0x18, 0x411111f0 },
4451 { 0x1a, 0x411111f0 },
4455 [ALC880_FIXUP_W810
] = {
4456 .type
= ALC_FIXUP_PINS
,
4457 .v
.pins
= (const struct alc_pincfg
[]) {
4458 /* disable bogus unused pins */
4459 { 0x17, 0x411111f0 },
4463 .chain_id
= ALC880_FIXUP_GPIO2
,
4465 [ALC880_FIXUP_EAPD_COEF
] = {
4466 .type
= ALC_FIXUP_VERBS
,
4467 .v
.verbs
= (const struct hda_verb
[]) {
4468 /* change to EAPD mode */
4469 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4470 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3060 },
4474 [ALC880_FIXUP_TCL_S700
] = {
4475 .type
= ALC_FIXUP_VERBS
,
4476 .v
.verbs
= (const struct hda_verb
[]) {
4477 /* change to EAPD mode */
4478 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4479 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3070 },
4483 .chain_id
= ALC880_FIXUP_GPIO2
,
4485 [ALC880_FIXUP_VOL_KNOB
] = {
4486 .type
= ALC_FIXUP_FUNC
,
4487 .v
.func
= alc880_fixup_vol_knob
,
4489 [ALC880_FIXUP_FUJITSU
] = {
4490 /* override all pins as BIOS on old Amilo is broken */
4491 .type
= ALC_FIXUP_PINS
,
4492 .v
.pins
= (const struct alc_pincfg
[]) {
4493 { 0x14, 0x0121411f }, /* HP */
4494 { 0x15, 0x99030120 }, /* speaker */
4495 { 0x16, 0x99030130 }, /* bass speaker */
4496 { 0x17, 0x411111f0 }, /* N/A */
4497 { 0x18, 0x411111f0 }, /* N/A */
4498 { 0x19, 0x01a19950 }, /* mic-in */
4499 { 0x1a, 0x411111f0 }, /* N/A */
4500 { 0x1b, 0x411111f0 }, /* N/A */
4501 { 0x1c, 0x411111f0 }, /* N/A */
4502 { 0x1d, 0x411111f0 }, /* N/A */
4503 { 0x1e, 0x01454140 }, /* SPDIF out */
4507 .chain_id
= ALC880_FIXUP_VOL_KNOB
,
4509 [ALC880_FIXUP_F1734
] = {
4510 /* almost compatible with FUJITSU, but no bass and SPDIF */
4511 .type
= ALC_FIXUP_PINS
,
4512 .v
.pins
= (const struct alc_pincfg
[]) {
4513 { 0x14, 0x0121411f }, /* HP */
4514 { 0x15, 0x99030120 }, /* speaker */
4515 { 0x16, 0x411111f0 }, /* N/A */
4516 { 0x17, 0x411111f0 }, /* N/A */
4517 { 0x18, 0x411111f0 }, /* N/A */
4518 { 0x19, 0x01a19950 }, /* mic-in */
4519 { 0x1a, 0x411111f0 }, /* N/A */
4520 { 0x1b, 0x411111f0 }, /* N/A */
4521 { 0x1c, 0x411111f0 }, /* N/A */
4522 { 0x1d, 0x411111f0 }, /* N/A */
4523 { 0x1e, 0x411111f0 }, /* N/A */
4527 .chain_id
= ALC880_FIXUP_VOL_KNOB
,
4529 [ALC880_FIXUP_UNIWILL
] = {
4530 /* need to fix HP and speaker pins to be parsed correctly */
4531 .type
= ALC_FIXUP_PINS
,
4532 .v
.pins
= (const struct alc_pincfg
[]) {
4533 { 0x14, 0x0121411f }, /* HP */
4534 { 0x15, 0x99030120 }, /* speaker */
4535 { 0x16, 0x99030130 }, /* bass speaker */
4539 [ALC880_FIXUP_UNIWILL_DIG
] = {
4540 .type
= ALC_FIXUP_PINS
,
4541 .v
.pins
= (const struct alc_pincfg
[]) {
4542 /* disable bogus unused pins */
4543 { 0x17, 0x411111f0 },
4544 { 0x19, 0x411111f0 },
4545 { 0x1b, 0x411111f0 },
4546 { 0x1f, 0x411111f0 },
4550 [ALC880_FIXUP_Z71V
] = {
4551 .type
= ALC_FIXUP_PINS
,
4552 .v
.pins
= (const struct alc_pincfg
[]) {
4553 /* set up the whole pins as BIOS is utterly broken */
4554 { 0x14, 0x99030120 }, /* speaker */
4555 { 0x15, 0x0121411f }, /* HP */
4556 { 0x16, 0x411111f0 }, /* N/A */
4557 { 0x17, 0x411111f0 }, /* N/A */
4558 { 0x18, 0x01a19950 }, /* mic-in */
4559 { 0x19, 0x411111f0 }, /* N/A */
4560 { 0x1a, 0x01813031 }, /* line-in */
4561 { 0x1b, 0x411111f0 }, /* N/A */
4562 { 0x1c, 0x411111f0 }, /* N/A */
4563 { 0x1d, 0x411111f0 }, /* N/A */
4564 { 0x1e, 0x0144111e }, /* SPDIF */
4568 [ALC880_FIXUP_3ST_BASE
] = {
4569 .type
= ALC_FIXUP_PINS
,
4570 .v
.pins
= (const struct alc_pincfg
[]) {
4571 { 0x14, 0x01014010 }, /* line-out */
4572 { 0x15, 0x411111f0 }, /* N/A */
4573 { 0x16, 0x411111f0 }, /* N/A */
4574 { 0x17, 0x411111f0 }, /* N/A */
4575 { 0x18, 0x01a19c30 }, /* mic-in */
4576 { 0x19, 0x0121411f }, /* HP */
4577 { 0x1a, 0x01813031 }, /* line-in */
4578 { 0x1b, 0x02a19c40 }, /* front-mic */
4579 { 0x1c, 0x411111f0 }, /* N/A */
4580 { 0x1d, 0x411111f0 }, /* N/A */
4581 /* 0x1e is filled in below */
4582 { 0x1f, 0x411111f0 }, /* N/A */
4586 [ALC880_FIXUP_3ST
] = {
4587 .type
= ALC_FIXUP_PINS
,
4588 .v
.pins
= (const struct alc_pincfg
[]) {
4589 { 0x1e, 0x411111f0 }, /* N/A */
4593 .chain_id
= ALC880_FIXUP_3ST_BASE
,
4595 [ALC880_FIXUP_3ST_DIG
] = {
4596 .type
= ALC_FIXUP_PINS
,
4597 .v
.pins
= (const struct alc_pincfg
[]) {
4598 { 0x1e, 0x0144111e }, /* SPDIF */
4602 .chain_id
= ALC880_FIXUP_3ST_BASE
,
4604 [ALC880_FIXUP_5ST_BASE
] = {
4605 .type
= ALC_FIXUP_PINS
,
4606 .v
.pins
= (const struct alc_pincfg
[]) {
4607 { 0x14, 0x01014010 }, /* front */
4608 { 0x15, 0x411111f0 }, /* N/A */
4609 { 0x16, 0x01011411 }, /* CLFE */
4610 { 0x17, 0x01016412 }, /* surr */
4611 { 0x18, 0x01a19c30 }, /* mic-in */
4612 { 0x19, 0x0121411f }, /* HP */
4613 { 0x1a, 0x01813031 }, /* line-in */
4614 { 0x1b, 0x02a19c40 }, /* front-mic */
4615 { 0x1c, 0x411111f0 }, /* N/A */
4616 { 0x1d, 0x411111f0 }, /* N/A */
4617 /* 0x1e is filled in below */
4618 { 0x1f, 0x411111f0 }, /* N/A */
4622 [ALC880_FIXUP_5ST
] = {
4623 .type
= ALC_FIXUP_PINS
,
4624 .v
.pins
= (const struct alc_pincfg
[]) {
4625 { 0x1e, 0x411111f0 }, /* N/A */
4629 .chain_id
= ALC880_FIXUP_5ST_BASE
,
4631 [ALC880_FIXUP_5ST_DIG
] = {
4632 .type
= ALC_FIXUP_PINS
,
4633 .v
.pins
= (const struct alc_pincfg
[]) {
4634 { 0x1e, 0x0144111e }, /* SPDIF */
4638 .chain_id
= ALC880_FIXUP_5ST_BASE
,
4640 [ALC880_FIXUP_6ST_BASE
] = {
4641 .type
= ALC_FIXUP_PINS
,
4642 .v
.pins
= (const struct alc_pincfg
[]) {
4643 { 0x14, 0x01014010 }, /* front */
4644 { 0x15, 0x01016412 }, /* surr */
4645 { 0x16, 0x01011411 }, /* CLFE */
4646 { 0x17, 0x01012414 }, /* side */
4647 { 0x18, 0x01a19c30 }, /* mic-in */
4648 { 0x19, 0x02a19c40 }, /* front-mic */
4649 { 0x1a, 0x01813031 }, /* line-in */
4650 { 0x1b, 0x0121411f }, /* HP */
4651 { 0x1c, 0x411111f0 }, /* N/A */
4652 { 0x1d, 0x411111f0 }, /* N/A */
4653 /* 0x1e is filled in below */
4654 { 0x1f, 0x411111f0 }, /* N/A */
4658 [ALC880_FIXUP_6ST
] = {
4659 .type
= ALC_FIXUP_PINS
,
4660 .v
.pins
= (const struct alc_pincfg
[]) {
4661 { 0x1e, 0x411111f0 }, /* N/A */
4665 .chain_id
= ALC880_FIXUP_6ST_BASE
,
4667 [ALC880_FIXUP_6ST_DIG
] = {
4668 .type
= ALC_FIXUP_PINS
,
4669 .v
.pins
= (const struct alc_pincfg
[]) {
4670 { 0x1e, 0x0144111e }, /* SPDIF */
4674 .chain_id
= ALC880_FIXUP_6ST_BASE
,
4678 static const struct snd_pci_quirk alc880_fixup_tbl
[] = {
4679 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810
),
4680 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V
),
4681 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1
),
4682 SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2
),
4683 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF
),
4684 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG
),
4685 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734
),
4686 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL
),
4687 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB
),
4688 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810
),
4689 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM
),
4690 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_FIXUP_F1734
),
4691 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU
),
4692 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734
),
4693 SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU
),
4694 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG
),
4695 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG
),
4696 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG
),
4697 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700
),
4699 /* Below is the copied entries from alc880_quirks.c.
4700 * It's not quite sure whether BIOS sets the correct pin-config table
4701 * on these machines, thus they are kept to be compatible with
4702 * the old static quirks. Once when it's confirmed to work without
4703 * these overrides, it'd be better to remove.
4705 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG
),
4706 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST
),
4707 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG
),
4708 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG
),
4709 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG
),
4710 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG
),
4711 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG
),
4712 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST
),
4713 SND_PCI_QUIRK(0x1039, 0x1234, NULL
, ALC880_FIXUP_6ST_DIG
),
4714 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST
),
4715 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST
),
4716 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST
),
4717 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST
),
4718 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST
),
4719 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG
),
4720 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG
),
4721 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG
),
4722 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG
),
4723 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG
),
4724 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG
),
4725 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG
),
4726 SND_PCI_QUIRK(0x2668, 0x8086, NULL
, ALC880_FIXUP_6ST_DIG
), /* broken BIOS */
4727 SND_PCI_QUIRK(0x8086, 0x2668, NULL
, ALC880_FIXUP_6ST_DIG
),
4728 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4729 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4730 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4731 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG
),
4732 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4733 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG
),
4734 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG
),
4735 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4736 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4737 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4739 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST
),
4740 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG
),
4741 SND_PCI_QUIRK(0xe803, 0x1019, NULL
, ALC880_FIXUP_6ST_DIG
),
4745 static const struct alc_model_fixup alc880_fixup_models
[] = {
4746 {.id
= ALC880_FIXUP_3ST
, .name
= "3stack"},
4747 {.id
= ALC880_FIXUP_3ST_DIG
, .name
= "3stack-digout"},
4748 {.id
= ALC880_FIXUP_5ST
, .name
= "5stack"},
4749 {.id
= ALC880_FIXUP_5ST_DIG
, .name
= "5stack-digout"},
4750 {.id
= ALC880_FIXUP_6ST
, .name
= "6stack"},
4751 {.id
= ALC880_FIXUP_6ST_DIG
, .name
= "6stack-digout"},
4757 * OK, here we have finally the patch for ALC880
4759 static int patch_alc880(struct hda_codec
*codec
)
4761 struct alc_spec
*spec
;
4764 err
= alc_alloc_spec(codec
, 0x0b);
4769 spec
->need_dac_fix
= 1;
4771 alc_pick_fixup(codec
, alc880_fixup_models
, alc880_fixup_tbl
,
4773 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
4775 /* automatic parse from the BIOS config */
4776 err
= alc880_parse_auto_config(codec
);
4780 if (!spec
->no_analog
) {
4781 err
= snd_hda_attach_beep_device(codec
, 0x1);
4784 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
4787 codec
->patch_ops
= alc_patch_ops
;
4789 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
4802 static int alc260_parse_auto_config(struct hda_codec
*codec
)
4804 static const hda_nid_t alc260_ignore
[] = { 0x17, 0 };
4805 static const hda_nid_t alc260_ssids
[] = { 0x10, 0x15, 0x0f, 0 };
4806 return alc_parse_auto_config(codec
, alc260_ignore
, alc260_ssids
);
4813 ALC260_FIXUP_HP_DC5750
,
4814 ALC260_FIXUP_HP_PIN_0F
,
4817 ALC260_FIXUP_GPIO1_TOGGLE
,
4818 ALC260_FIXUP_REPLACER
,
4819 ALC260_FIXUP_HP_B1900
,
4823 static void alc260_gpio1_automute(struct hda_codec
*codec
)
4825 struct alc_spec
*spec
= codec
->spec
;
4826 snd_hda_codec_write(codec
, 0x01, 0, AC_VERB_SET_GPIO_DATA
,
4827 spec
->hp_jack_present
);
4830 static void alc260_fixup_gpio1_toggle(struct hda_codec
*codec
,
4831 const struct alc_fixup
*fix
, int action
)
4833 struct alc_spec
*spec
= codec
->spec
;
4834 if (action
== ALC_FIXUP_ACT_PROBE
) {
4835 /* although the machine has only one output pin, we need to
4836 * toggle GPIO1 according to the jack state
4838 spec
->automute_hook
= alc260_gpio1_automute
;
4839 spec
->detect_hp
= 1;
4840 spec
->automute_speaker
= 1;
4841 spec
->autocfg
.hp_pins
[0] = 0x0f; /* copy it for automute */
4842 snd_hda_jack_detect_enable(codec
, 0x0f, ALC_HP_EVENT
);
4843 spec
->unsol_event
= alc_sku_unsol_event
;
4844 snd_hda_gen_add_verbs(&spec
->gen
, alc_gpio1_init_verbs
);
4848 static void alc260_fixup_kn1(struct hda_codec
*codec
,
4849 const struct alc_fixup
*fix
, int action
)
4851 struct alc_spec
*spec
= codec
->spec
;
4852 static const struct alc_pincfg pincfgs
[] = {
4853 { 0x0f, 0x02214000 }, /* HP/speaker */
4854 { 0x12, 0x90a60160 }, /* int mic */
4855 { 0x13, 0x02a19000 }, /* ext mic */
4856 { 0x18, 0x01446000 }, /* SPDIF out */
4857 /* disable bogus I/O pins */
4858 { 0x10, 0x411111f0 },
4859 { 0x11, 0x411111f0 },
4860 { 0x14, 0x411111f0 },
4861 { 0x15, 0x411111f0 },
4862 { 0x16, 0x411111f0 },
4863 { 0x17, 0x411111f0 },
4864 { 0x19, 0x411111f0 },
4869 case ALC_FIXUP_ACT_PRE_PROBE
:
4870 alc_apply_pincfgs(codec
, pincfgs
);
4872 case ALC_FIXUP_ACT_PROBE
:
4873 spec
->init_amp
= ALC_INIT_NONE
;
4878 static const struct alc_fixup alc260_fixups
[] = {
4879 [ALC260_FIXUP_HP_DC5750
] = {
4880 .type
= ALC_FIXUP_PINS
,
4881 .v
.pins
= (const struct alc_pincfg
[]) {
4882 { 0x11, 0x90130110 }, /* speaker */
4886 [ALC260_FIXUP_HP_PIN_0F
] = {
4887 .type
= ALC_FIXUP_PINS
,
4888 .v
.pins
= (const struct alc_pincfg
[]) {
4889 { 0x0f, 0x01214000 }, /* HP */
4893 [ALC260_FIXUP_COEF
] = {
4894 .type
= ALC_FIXUP_VERBS
,
4895 .v
.verbs
= (const struct hda_verb
[]) {
4896 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4897 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3040 },
4901 .chain_id
= ALC260_FIXUP_HP_PIN_0F
,
4903 [ALC260_FIXUP_GPIO1
] = {
4904 .type
= ALC_FIXUP_VERBS
,
4905 .v
.verbs
= alc_gpio1_init_verbs
,
4907 [ALC260_FIXUP_GPIO1_TOGGLE
] = {
4908 .type
= ALC_FIXUP_FUNC
,
4909 .v
.func
= alc260_fixup_gpio1_toggle
,
4911 .chain_id
= ALC260_FIXUP_HP_PIN_0F
,
4913 [ALC260_FIXUP_REPLACER
] = {
4914 .type
= ALC_FIXUP_VERBS
,
4915 .v
.verbs
= (const struct hda_verb
[]) {
4916 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4917 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3050 },
4921 .chain_id
= ALC260_FIXUP_GPIO1_TOGGLE
,
4923 [ALC260_FIXUP_HP_B1900
] = {
4924 .type
= ALC_FIXUP_FUNC
,
4925 .v
.func
= alc260_fixup_gpio1_toggle
,
4927 .chain_id
= ALC260_FIXUP_COEF
,
4929 [ALC260_FIXUP_KN1
] = {
4930 .type
= ALC_FIXUP_FUNC
,
4931 .v
.func
= alc260_fixup_kn1
,
4935 static const struct snd_pci_quirk alc260_fixup_tbl
[] = {
4936 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1
),
4937 SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF
),
4938 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1
),
4939 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750
),
4940 SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900
),
4941 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1
),
4942 SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1
),
4943 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER
),
4944 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF
),
4950 static int patch_alc260(struct hda_codec
*codec
)
4952 struct alc_spec
*spec
;
4955 err
= alc_alloc_spec(codec
, 0x07);
4961 alc_pick_fixup(codec
, NULL
, alc260_fixup_tbl
, alc260_fixups
);
4962 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
4964 /* automatic parse from the BIOS config */
4965 err
= alc260_parse_auto_config(codec
);
4969 if (!spec
->no_analog
) {
4970 err
= snd_hda_attach_beep_device(codec
, 0x1);
4973 set_beep_amp(spec
, 0x07, 0x05, HDA_INPUT
);
4976 codec
->patch_ops
= alc_patch_ops
;
4977 spec
->shutup
= alc_eapd_shutup
;
4979 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
4990 * ALC882/883/885/888/889 support
4992 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4993 * configuration. Each pin widget can choose any input DACs and a mixer.
4994 * Each ADC is connected from a mixer of all inputs. This makes possible
4995 * 6-channel independent captures.
4997 * In addition, an independent DAC for the multi-playback (not used in this
5005 ALC882_FIXUP_ABIT_AW9D_MAX
,
5006 ALC882_FIXUP_LENOVO_Y530
,
5007 ALC882_FIXUP_PB_M5210
,
5008 ALC882_FIXUP_ACER_ASPIRE_7736
,
5009 ALC882_FIXUP_ASUS_W90V
,
5011 ALC889_FIXUP_VAIO_TT
,
5012 ALC888_FIXUP_EEE1601
,
5015 ALC883_FIXUP_ACER_EAPD
,
5020 ALC882_FIXUP_ASUS_W2JC
,
5021 ALC882_FIXUP_ACER_ASPIRE_4930G
,
5022 ALC882_FIXUP_ACER_ASPIRE_8930G
,
5023 ALC882_FIXUP_ASPIRE_8930G_VERBS
,
5024 ALC885_FIXUP_MACPRO_GPIO
,
5025 ALC889_FIXUP_DAC_ROUTE
,
5026 ALC889_FIXUP_MBP_VREF
,
5027 ALC889_FIXUP_IMAC91_VREF
,
5028 ALC882_FIXUP_INV_DMIC
,
5031 static void alc889_fixup_coef(struct hda_codec
*codec
,
5032 const struct alc_fixup
*fix
, int action
)
5034 if (action
!= ALC_FIXUP_ACT_INIT
)
5036 alc889_coef_init(codec
);
5039 /* toggle speaker-output according to the hp-jack state */
5040 static void alc882_gpio_mute(struct hda_codec
*codec
, int pin
, int muted
)
5042 unsigned int gpiostate
, gpiomask
, gpiodir
;
5044 gpiostate
= snd_hda_codec_read(codec
, codec
->afg
, 0,
5045 AC_VERB_GET_GPIO_DATA
, 0);
5048 gpiostate
|= (1 << pin
);
5050 gpiostate
&= ~(1 << pin
);
5052 gpiomask
= snd_hda_codec_read(codec
, codec
->afg
, 0,
5053 AC_VERB_GET_GPIO_MASK
, 0);
5054 gpiomask
|= (1 << pin
);
5056 gpiodir
= snd_hda_codec_read(codec
, codec
->afg
, 0,
5057 AC_VERB_GET_GPIO_DIRECTION
, 0);
5058 gpiodir
|= (1 << pin
);
5061 snd_hda_codec_write(codec
, codec
->afg
, 0,
5062 AC_VERB_SET_GPIO_MASK
, gpiomask
);
5063 snd_hda_codec_write(codec
, codec
->afg
, 0,
5064 AC_VERB_SET_GPIO_DIRECTION
, gpiodir
);
5068 snd_hda_codec_write(codec
, codec
->afg
, 0,
5069 AC_VERB_SET_GPIO_DATA
, gpiostate
);
5072 /* set up GPIO at initialization */
5073 static void alc885_fixup_macpro_gpio(struct hda_codec
*codec
,
5074 const struct alc_fixup
*fix
, int action
)
5076 if (action
!= ALC_FIXUP_ACT_INIT
)
5078 alc882_gpio_mute(codec
, 0, 0);
5079 alc882_gpio_mute(codec
, 1, 0);
5082 /* Fix the connection of some pins for ALC889:
5083 * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't
5084 * work correctly (bko#42740)
5086 static void alc889_fixup_dac_route(struct hda_codec
*codec
,
5087 const struct alc_fixup
*fix
, int action
)
5089 if (action
== ALC_FIXUP_ACT_PRE_PROBE
) {
5090 /* fake the connections during parsing the tree */
5091 hda_nid_t conn1
[2] = { 0x0c, 0x0d };
5092 hda_nid_t conn2
[2] = { 0x0e, 0x0f };
5093 snd_hda_override_conn_list(codec
, 0x14, 2, conn1
);
5094 snd_hda_override_conn_list(codec
, 0x15, 2, conn1
);
5095 snd_hda_override_conn_list(codec
, 0x18, 2, conn2
);
5096 snd_hda_override_conn_list(codec
, 0x1a, 2, conn2
);
5097 } else if (action
== ALC_FIXUP_ACT_PROBE
) {
5098 /* restore the connections */
5099 hda_nid_t conn
[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 };
5100 snd_hda_override_conn_list(codec
, 0x14, 5, conn
);
5101 snd_hda_override_conn_list(codec
, 0x15, 5, conn
);
5102 snd_hda_override_conn_list(codec
, 0x18, 5, conn
);
5103 snd_hda_override_conn_list(codec
, 0x1a, 5, conn
);
5107 /* Set VREF on HP pin */
5108 static void alc889_fixup_mbp_vref(struct hda_codec
*codec
,
5109 const struct alc_fixup
*fix
, int action
)
5111 struct alc_spec
*spec
= codec
->spec
;
5112 static hda_nid_t nids
[2] = { 0x14, 0x15 };
5115 if (action
!= ALC_FIXUP_ACT_INIT
)
5117 for (i
= 0; i
< ARRAY_SIZE(nids
); i
++) {
5118 unsigned int val
= snd_hda_codec_get_pincfg(codec
, nids
[i
]);
5119 if (get_defcfg_device(val
) != AC_JACK_HP_OUT
)
5121 val
= snd_hda_codec_read(codec
, nids
[i
], 0,
5122 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
5123 val
|= AC_PINCTL_VREF_80
;
5124 snd_hda_set_pin_ctl(codec
, nids
[i
], val
);
5125 spec
->keep_vref_in_automute
= 1;
5130 /* Set VREF on speaker pins on imac91 */
5131 static void alc889_fixup_imac91_vref(struct hda_codec
*codec
,
5132 const struct alc_fixup
*fix
, int action
)
5134 struct alc_spec
*spec
= codec
->spec
;
5135 static hda_nid_t nids
[2] = { 0x18, 0x1a };
5138 if (action
!= ALC_FIXUP_ACT_INIT
)
5140 for (i
= 0; i
< ARRAY_SIZE(nids
); i
++) {
5142 val
= snd_hda_codec_read(codec
, nids
[i
], 0,
5143 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
5144 val
|= AC_PINCTL_VREF_50
;
5145 snd_hda_set_pin_ctl(codec
, nids
[i
], val
);
5147 spec
->keep_vref_in_automute
= 1;
5150 static const struct alc_fixup alc882_fixups
[] = {
5151 [ALC882_FIXUP_ABIT_AW9D_MAX
] = {
5152 .type
= ALC_FIXUP_PINS
,
5153 .v
.pins
= (const struct alc_pincfg
[]) {
5154 { 0x15, 0x01080104 }, /* side */
5155 { 0x16, 0x01011012 }, /* rear */
5156 { 0x17, 0x01016011 }, /* clfe */
5160 [ALC882_FIXUP_LENOVO_Y530
] = {
5161 .type
= ALC_FIXUP_PINS
,
5162 .v
.pins
= (const struct alc_pincfg
[]) {
5163 { 0x15, 0x99130112 }, /* rear int speakers */
5164 { 0x16, 0x99130111 }, /* subwoofer */
5168 [ALC882_FIXUP_PB_M5210
] = {
5169 .type
= ALC_FIXUP_VERBS
,
5170 .v
.verbs
= (const struct hda_verb
[]) {
5171 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF50
},
5175 [ALC882_FIXUP_ACER_ASPIRE_7736
] = {
5176 .type
= ALC_FIXUP_FUNC
,
5177 .v
.func
= alc_fixup_sku_ignore
,
5179 [ALC882_FIXUP_ASUS_W90V
] = {
5180 .type
= ALC_FIXUP_PINS
,
5181 .v
.pins
= (const struct alc_pincfg
[]) {
5182 { 0x16, 0x99130110 }, /* fix sequence for CLFE */
5186 [ALC889_FIXUP_CD
] = {
5187 .type
= ALC_FIXUP_PINS
,
5188 .v
.pins
= (const struct alc_pincfg
[]) {
5189 { 0x1c, 0x993301f0 }, /* CD */
5193 [ALC889_FIXUP_VAIO_TT
] = {
5194 .type
= ALC_FIXUP_PINS
,
5195 .v
.pins
= (const struct alc_pincfg
[]) {
5196 { 0x17, 0x90170111 }, /* hidden surround speaker */
5200 [ALC888_FIXUP_EEE1601
] = {
5201 .type
= ALC_FIXUP_VERBS
,
5202 .v
.verbs
= (const struct hda_verb
[]) {
5203 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x0b },
5204 { 0x20, AC_VERB_SET_PROC_COEF
, 0x0838 },
5208 [ALC882_FIXUP_EAPD
] = {
5209 .type
= ALC_FIXUP_VERBS
,
5210 .v
.verbs
= (const struct hda_verb
[]) {
5211 /* change to EAPD mode */
5212 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5213 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3060 },
5217 [ALC883_FIXUP_EAPD
] = {
5218 .type
= ALC_FIXUP_VERBS
,
5219 .v
.verbs
= (const struct hda_verb
[]) {
5220 /* change to EAPD mode */
5221 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5222 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3070 },
5226 [ALC883_FIXUP_ACER_EAPD
] = {
5227 .type
= ALC_FIXUP_VERBS
,
5228 .v
.verbs
= (const struct hda_verb
[]) {
5229 /* eanable EAPD on Acer laptops */
5230 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5231 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3050 },
5235 [ALC882_FIXUP_GPIO1
] = {
5236 .type
= ALC_FIXUP_VERBS
,
5237 .v
.verbs
= alc_gpio1_init_verbs
,
5239 [ALC882_FIXUP_GPIO2
] = {
5240 .type
= ALC_FIXUP_VERBS
,
5241 .v
.verbs
= alc_gpio2_init_verbs
,
5243 [ALC882_FIXUP_GPIO3
] = {
5244 .type
= ALC_FIXUP_VERBS
,
5245 .v
.verbs
= alc_gpio3_init_verbs
,
5247 [ALC882_FIXUP_ASUS_W2JC
] = {
5248 .type
= ALC_FIXUP_VERBS
,
5249 .v
.verbs
= alc_gpio1_init_verbs
,
5251 .chain_id
= ALC882_FIXUP_EAPD
,
5253 [ALC889_FIXUP_COEF
] = {
5254 .type
= ALC_FIXUP_FUNC
,
5255 .v
.func
= alc889_fixup_coef
,
5257 [ALC882_FIXUP_ACER_ASPIRE_4930G
] = {
5258 .type
= ALC_FIXUP_PINS
,
5259 .v
.pins
= (const struct alc_pincfg
[]) {
5260 { 0x16, 0x99130111 }, /* CLFE speaker */
5261 { 0x17, 0x99130112 }, /* surround speaker */
5265 .chain_id
= ALC882_FIXUP_GPIO1
,
5267 [ALC882_FIXUP_ACER_ASPIRE_8930G
] = {
5268 .type
= ALC_FIXUP_PINS
,
5269 .v
.pins
= (const struct alc_pincfg
[]) {
5270 { 0x16, 0x99130111 }, /* CLFE speaker */
5271 { 0x1b, 0x99130112 }, /* surround speaker */
5275 .chain_id
= ALC882_FIXUP_ASPIRE_8930G_VERBS
,
5277 [ALC882_FIXUP_ASPIRE_8930G_VERBS
] = {
5278 /* additional init verbs for Acer Aspire 8930G */
5279 .type
= ALC_FIXUP_VERBS
,
5280 .v
.verbs
= (const struct hda_verb
[]) {
5281 /* Enable all DACs */
5282 /* DAC DISABLE/MUTE 1? */
5283 /* setting bits 1-5 disables DAC nids 0x02-0x06
5284 * apparently. Init=0x38 */
5285 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x03 },
5286 { 0x20, AC_VERB_SET_PROC_COEF
, 0x0000 },
5287 /* DAC DISABLE/MUTE 2? */
5288 /* some bit here disables the other DACs.
5290 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x08 },
5291 { 0x20, AC_VERB_SET_PROC_COEF
, 0x0000 },
5293 * This laptop has a stereo digital microphone.
5294 * The mics are only 1cm apart which makes the stereo
5295 * useless. However, either the mic or the ALC889
5296 * makes the signal become a difference/sum signal
5297 * instead of standard stereo, which is annoying.
5298 * So instead we flip this bit which makes the
5299 * codec replicate the sum signal to both channels,
5300 * turning it into a normal mono mic.
5302 /* DMIC_CONTROL? Init value = 0x0001 */
5303 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x0b },
5304 { 0x20, AC_VERB_SET_PROC_COEF
, 0x0003 },
5305 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5306 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3050 },
5310 .chain_id
= ALC882_FIXUP_GPIO1
,
5312 [ALC885_FIXUP_MACPRO_GPIO
] = {
5313 .type
= ALC_FIXUP_FUNC
,
5314 .v
.func
= alc885_fixup_macpro_gpio
,
5316 [ALC889_FIXUP_DAC_ROUTE
] = {
5317 .type
= ALC_FIXUP_FUNC
,
5318 .v
.func
= alc889_fixup_dac_route
,
5320 [ALC889_FIXUP_MBP_VREF
] = {
5321 .type
= ALC_FIXUP_FUNC
,
5322 .v
.func
= alc889_fixup_mbp_vref
,
5324 .chain_id
= ALC882_FIXUP_GPIO1
,
5326 [ALC889_FIXUP_IMAC91_VREF
] = {
5327 .type
= ALC_FIXUP_FUNC
,
5328 .v
.func
= alc889_fixup_imac91_vref
,
5330 .chain_id
= ALC882_FIXUP_GPIO1
,
5332 [ALC882_FIXUP_INV_DMIC
] = {
5333 .type
= ALC_FIXUP_FUNC
,
5334 .v
.func
= alc_fixup_inv_dmic_0x12
,
5338 static const struct snd_pci_quirk alc882_fixup_tbl
[] = {
5339 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD
),
5340 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD
),
5341 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD
),
5342 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD
),
5343 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD
),
5344 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD
),
5345 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
5346 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5347 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
5348 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5349 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
5350 ALC882_FIXUP_ACER_ASPIRE_8930G
),
5351 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
5352 ALC882_FIXUP_ACER_ASPIRE_8930G
),
5353 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
5354 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5355 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
5356 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5357 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
5358 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5359 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210
),
5360 SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G",
5361 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5362 SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE
),
5363 SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G
),
5364 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736
),
5365 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD
),
5366 SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V
),
5367 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC
),
5368 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601
),
5369 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT
),
5371 /* All Apple entries are in codec SSIDs */
5372 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF
),
5373 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF
),
5374 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF
),
5375 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_FIXUP_MACPRO_GPIO
),
5376 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO
),
5377 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO
),
5378 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF
),
5379 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF
),
5380 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD
),
5381 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBP_VREF
),
5382 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBP_VREF
),
5383 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF
),
5384 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF
),
5385 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO
),
5386 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF
),
5387 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF
),
5388 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF
),
5389 SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 5,1", ALC885_FIXUP_MACPRO_GPIO
),
5390 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF
),
5391 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF
),
5392 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF
),
5394 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD
),
5395 SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD
),
5396 SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3
),
5397 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3", ALC889_FIXUP_CD
),
5398 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX
),
5399 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD
),
5400 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD
),
5401 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530
),
5402 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF
),
5406 static const struct alc_model_fixup alc882_fixup_models
[] = {
5407 {.id
= ALC882_FIXUP_ACER_ASPIRE_4930G
, .name
= "acer-aspire-4930g"},
5408 {.id
= ALC882_FIXUP_ACER_ASPIRE_8930G
, .name
= "acer-aspire-8930g"},
5409 {.id
= ALC883_FIXUP_ACER_EAPD
, .name
= "acer-aspire"},
5410 {.id
= ALC882_FIXUP_INV_DMIC
, .name
= "inv-dmic"},
5415 * BIOS auto configuration
5417 /* almost identical with ALC880 parser... */
5418 static int alc882_parse_auto_config(struct hda_codec
*codec
)
5420 static const hda_nid_t alc882_ignore
[] = { 0x1d, 0 };
5421 static const hda_nid_t alc882_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
5422 return alc_parse_auto_config(codec
, alc882_ignore
, alc882_ssids
);
5427 static int patch_alc882(struct hda_codec
*codec
)
5429 struct alc_spec
*spec
;
5432 err
= alc_alloc_spec(codec
, 0x0b);
5438 switch (codec
->vendor_id
) {
5443 /* ALC883 and variants */
5444 alc_fix_pll_init(codec
, 0x20, 0x0a, 10);
5448 alc_pick_fixup(codec
, alc882_fixup_models
, alc882_fixup_tbl
,
5450 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
5452 alc_auto_parse_customize_define(codec
);
5454 /* automatic parse from the BIOS config */
5455 err
= alc882_parse_auto_config(codec
);
5459 if (!spec
->no_analog
&& has_cdefine_beep(codec
)) {
5460 err
= snd_hda_attach_beep_device(codec
, 0x1);
5463 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
5466 codec
->patch_ops
= alc_patch_ops
;
5468 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
5481 static int alc262_parse_auto_config(struct hda_codec
*codec
)
5483 static const hda_nid_t alc262_ignore
[] = { 0x1d, 0 };
5484 static const hda_nid_t alc262_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
5485 return alc_parse_auto_config(codec
, alc262_ignore
, alc262_ssids
);
5492 ALC262_FIXUP_FSC_H270
,
5493 ALC262_FIXUP_HP_Z200
,
5495 ALC262_FIXUP_LENOVO_3000
,
5497 ALC262_FIXUP_BENQ_T31
,
5498 ALC262_FIXUP_INV_DMIC
,
5501 static const struct alc_fixup alc262_fixups
[] = {
5502 [ALC262_FIXUP_FSC_H270
] = {
5503 .type
= ALC_FIXUP_PINS
,
5504 .v
.pins
= (const struct alc_pincfg
[]) {
5505 { 0x14, 0x99130110 }, /* speaker */
5506 { 0x15, 0x0221142f }, /* front HP */
5507 { 0x1b, 0x0121141f }, /* rear HP */
5511 [ALC262_FIXUP_HP_Z200
] = {
5512 .type
= ALC_FIXUP_PINS
,
5513 .v
.pins
= (const struct alc_pincfg
[]) {
5514 { 0x16, 0x99130120 }, /* internal speaker */
5518 [ALC262_FIXUP_TYAN
] = {
5519 .type
= ALC_FIXUP_PINS
,
5520 .v
.pins
= (const struct alc_pincfg
[]) {
5521 { 0x14, 0x1993e1f0 }, /* int AUX */
5525 [ALC262_FIXUP_LENOVO_3000
] = {
5526 .type
= ALC_FIXUP_VERBS
,
5527 .v
.verbs
= (const struct hda_verb
[]) {
5528 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF50
},
5532 .chain_id
= ALC262_FIXUP_BENQ
,
5534 [ALC262_FIXUP_BENQ
] = {
5535 .type
= ALC_FIXUP_VERBS
,
5536 .v
.verbs
= (const struct hda_verb
[]) {
5537 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5538 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3070 },
5542 [ALC262_FIXUP_BENQ_T31
] = {
5543 .type
= ALC_FIXUP_VERBS
,
5544 .v
.verbs
= (const struct hda_verb
[]) {
5545 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5546 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3050 },
5550 [ALC262_FIXUP_INV_DMIC
] = {
5551 .type
= ALC_FIXUP_FUNC
,
5552 .v
.func
= alc_fixup_inv_dmic_0x12
,
5556 static const struct snd_pci_quirk alc262_fixup_tbl
[] = {
5557 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200
),
5558 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FIXUP_BENQ
),
5559 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ
),
5560 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN
),
5561 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270
),
5562 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000
),
5563 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ
),
5564 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31
),
5568 static const struct alc_model_fixup alc262_fixup_models
[] = {
5569 {.id
= ALC262_FIXUP_INV_DMIC
, .name
= "inv-dmic"},
5575 static int patch_alc262(struct hda_codec
*codec
)
5577 struct alc_spec
*spec
;
5580 err
= alc_alloc_spec(codec
, 0x0b);
5587 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
5592 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_COEF_INDEX
, 7);
5593 tmp
= snd_hda_codec_read(codec
, 0x20, 0, AC_VERB_GET_PROC_COEF
, 0);
5594 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_COEF_INDEX
, 7);
5595 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PROC_COEF
, tmp
| 0x80);
5598 alc_fix_pll_init(codec
, 0x20, 0x0a, 10);
5600 alc_pick_fixup(codec
, alc262_fixup_models
, alc262_fixup_tbl
,
5602 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
5604 alc_auto_parse_customize_define(codec
);
5606 /* automatic parse from the BIOS config */
5607 err
= alc262_parse_auto_config(codec
);
5611 if (!spec
->no_analog
&& has_cdefine_beep(codec
)) {
5612 err
= snd_hda_attach_beep_device(codec
, 0x1);
5615 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
5618 codec
->patch_ops
= alc_patch_ops
;
5619 spec
->shutup
= alc_eapd_shutup
;
5621 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
5633 /* bind Beep switches of both NID 0x0f and 0x10 */
5634 static const struct hda_bind_ctls alc268_bind_beep_sw
= {
5635 .ops
= &snd_hda_bind_sw
,
5637 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT
),
5638 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT
),
5643 static const struct snd_kcontrol_new alc268_beep_mixer
[] = {
5644 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT
),
5645 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw
),
5649 /* set PCBEEP vol = 0, mute connections */
5650 static const struct hda_verb alc268_beep_init_verbs
[] = {
5651 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5652 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
5653 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
5658 ALC268_FIXUP_INV_DMIC
,
5661 static const struct alc_fixup alc268_fixups
[] = {
5662 [ALC268_FIXUP_INV_DMIC
] = {
5663 .type
= ALC_FIXUP_FUNC
,
5664 .v
.func
= alc_fixup_inv_dmic_0x12
,
5668 static const struct alc_model_fixup alc268_fixup_models
[] = {
5669 {.id
= ALC268_FIXUP_INV_DMIC
, .name
= "inv-dmic"},
5674 * BIOS auto configuration
5676 static int alc268_parse_auto_config(struct hda_codec
*codec
)
5678 static const hda_nid_t alc268_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
5679 struct alc_spec
*spec
= codec
->spec
;
5680 int err
= alc_parse_auto_config(codec
, NULL
, alc268_ssids
);
5682 if (!spec
->no_analog
&& spec
->autocfg
.speaker_pins
[0] != 0x1d) {
5683 add_mixer(spec
, alc268_beep_mixer
);
5684 snd_hda_gen_add_verbs(&spec
->gen
, alc268_beep_init_verbs
);
5692 static int patch_alc268(struct hda_codec
*codec
)
5694 struct alc_spec
*spec
;
5695 int i
, has_beep
, err
;
5697 /* ALC268 has no aa-loopback mixer */
5698 err
= alc_alloc_spec(codec
, 0);
5704 alc_pick_fixup(codec
, alc268_fixup_models
, NULL
, alc268_fixups
);
5705 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
5707 /* automatic parse from the BIOS config */
5708 err
= alc268_parse_auto_config(codec
);
5713 for (i
= 0; i
< spec
->num_mixers
; i
++) {
5714 if (spec
->mixers
[i
] == alc268_beep_mixer
) {
5721 err
= snd_hda_attach_beep_device(codec
, 0x1);
5724 if (!query_amp_caps(codec
, 0x1d, HDA_INPUT
))
5725 /* override the amp caps for beep generator */
5726 snd_hda_override_amp_caps(codec
, 0x1d, HDA_INPUT
,
5727 (0x0c << AC_AMPCAP_OFFSET_SHIFT
) |
5728 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT
) |
5729 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
5730 (0 << AC_AMPCAP_MUTE_SHIFT
));
5733 codec
->patch_ops
= alc_patch_ops
;
5734 spec
->shutup
= alc_eapd_shutup
;
5736 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
5748 static const struct hda_pcm_stream alc269_44k_pcm_analog_playback
= {
5752 .rates
= SNDRV_PCM_RATE_44100
, /* fixed rate */
5753 /* NID is set in alc_build_pcms */
5755 .open
= alc_playback_pcm_open
,
5756 .prepare
= alc_playback_pcm_prepare
,
5757 .cleanup
= alc_playback_pcm_cleanup
5761 static const struct hda_pcm_stream alc269_44k_pcm_analog_capture
= {
5765 .rates
= SNDRV_PCM_RATE_44100
, /* fixed rate */
5766 /* NID is set in alc_build_pcms */
5769 /* different alc269-variants */
5771 ALC269_TYPE_ALC269VA
,
5772 ALC269_TYPE_ALC269VB
,
5773 ALC269_TYPE_ALC269VC
,
5774 ALC269_TYPE_ALC269VD
,
5778 * BIOS auto configuration
5780 static int alc269_parse_auto_config(struct hda_codec
*codec
)
5782 static const hda_nid_t alc269_ignore
[] = { 0x1d, 0 };
5783 static const hda_nid_t alc269_ssids
[] = { 0, 0x1b, 0x14, 0x21 };
5784 static const hda_nid_t alc269va_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
5785 struct alc_spec
*spec
= codec
->spec
;
5786 const hda_nid_t
*ssids
;
5788 switch (spec
->codec_variant
) {
5789 case ALC269_TYPE_ALC269VA
:
5790 case ALC269_TYPE_ALC269VC
:
5791 ssids
= alc269va_ssids
;
5793 case ALC269_TYPE_ALC269VB
:
5794 case ALC269_TYPE_ALC269VD
:
5795 ssids
= alc269_ssids
;
5798 ssids
= alc269_ssids
;
5802 return alc_parse_auto_config(codec
, alc269_ignore
, ssids
);
5805 static void alc269_toggle_power_output(struct hda_codec
*codec
, int power_up
)
5807 int val
= alc_read_coef_idx(codec
, 0x04);
5812 alc_write_coef_idx(codec
, 0x04, val
);
5815 static void alc269_shutup(struct hda_codec
*codec
)
5817 struct alc_spec
*spec
= codec
->spec
;
5819 if (spec
->codec_variant
!= ALC269_TYPE_ALC269VB
)
5822 if ((alc_get_coef0(codec
) & 0x00ff) == 0x017)
5823 alc269_toggle_power_output(codec
, 0);
5824 if ((alc_get_coef0(codec
) & 0x00ff) == 0x018) {
5825 alc269_toggle_power_output(codec
, 0);
5831 static int alc269_resume(struct hda_codec
*codec
)
5833 struct alc_spec
*spec
= codec
->spec
;
5835 if (spec
->codec_variant
== ALC269_TYPE_ALC269VB
||
5836 (alc_get_coef0(codec
) & 0x00ff) == 0x018) {
5837 alc269_toggle_power_output(codec
, 0);
5841 codec
->patch_ops
.init(codec
);
5843 if (spec
->codec_variant
== ALC269_TYPE_ALC269VB
||
5844 (alc_get_coef0(codec
) & 0x00ff) == 0x017) {
5845 alc269_toggle_power_output(codec
, 1);
5849 if (spec
->codec_variant
== ALC269_TYPE_ALC269VB
||
5850 (alc_get_coef0(codec
) & 0x00ff) == 0x018)
5851 alc269_toggle_power_output(codec
, 1);
5853 snd_hda_codec_resume_amp(codec
);
5854 snd_hda_codec_resume_cache(codec
);
5855 hda_call_check_power_status(codec
, 0x01);
5858 #endif /* CONFIG_PM */
5860 static void alc269_fixup_hweq(struct hda_codec
*codec
,
5861 const struct alc_fixup
*fix
, int action
)
5865 if (action
!= ALC_FIXUP_ACT_INIT
)
5867 coef
= alc_read_coef_idx(codec
, 0x1e);
5868 alc_write_coef_idx(codec
, 0x1e, coef
| 0x80);
5871 static void alc271_fixup_dmic(struct hda_codec
*codec
,
5872 const struct alc_fixup
*fix
, int action
)
5874 static const struct hda_verb verbs
[] = {
5875 {0x20, AC_VERB_SET_COEF_INDEX
, 0x0d},
5876 {0x20, AC_VERB_SET_PROC_COEF
, 0x4000},
5881 if (strcmp(codec
->chip_name
, "ALC271X"))
5883 cfg
= snd_hda_codec_get_pincfg(codec
, 0x12);
5884 if (get_defcfg_connect(cfg
) == AC_JACK_PORT_FIXED
)
5885 snd_hda_sequence_write(codec
, verbs
);
5888 static void alc269_fixup_pcm_44k(struct hda_codec
*codec
,
5889 const struct alc_fixup
*fix
, int action
)
5891 struct alc_spec
*spec
= codec
->spec
;
5893 if (action
!= ALC_FIXUP_ACT_PROBE
)
5896 /* Due to a hardware problem on Lenovo Ideadpad, we need to
5897 * fix the sample rate of analog I/O to 44.1kHz
5899 spec
->stream_analog_playback
= &alc269_44k_pcm_analog_playback
;
5900 spec
->stream_analog_capture
= &alc269_44k_pcm_analog_capture
;
5903 static void alc269_fixup_stereo_dmic(struct hda_codec
*codec
,
5904 const struct alc_fixup
*fix
, int action
)
5908 if (action
!= ALC_FIXUP_ACT_INIT
)
5910 /* The digital-mic unit sends PDM (differential signal) instead of
5911 * the standard PCM, thus you can't record a valid mono stream as is.
5912 * Below is a workaround specific to ALC269 to control the dmic
5913 * signal source as mono.
5915 coef
= alc_read_coef_idx(codec
, 0x07);
5916 alc_write_coef_idx(codec
, 0x07, coef
| 0x80);
5919 static void alc269_quanta_automute(struct hda_codec
*codec
)
5921 update_outputs(codec
);
5923 snd_hda_codec_write(codec
, 0x20, 0,
5924 AC_VERB_SET_COEF_INDEX
, 0x0c);
5925 snd_hda_codec_write(codec
, 0x20, 0,
5926 AC_VERB_SET_PROC_COEF
, 0x680);
5928 snd_hda_codec_write(codec
, 0x20, 0,
5929 AC_VERB_SET_COEF_INDEX
, 0x0c);
5930 snd_hda_codec_write(codec
, 0x20, 0,
5931 AC_VERB_SET_PROC_COEF
, 0x480);
5934 static void alc269_fixup_quanta_mute(struct hda_codec
*codec
,
5935 const struct alc_fixup
*fix
, int action
)
5937 struct alc_spec
*spec
= codec
->spec
;
5938 if (action
!= ALC_FIXUP_ACT_PROBE
)
5940 spec
->automute_hook
= alc269_quanta_automute
;
5943 /* update mute-LED according to the speaker mute state via mic2 VREF pin */
5944 static void alc269_fixup_mic2_mute_hook(void *private_data
, int enabled
)
5946 struct hda_codec
*codec
= private_data
;
5947 unsigned int pinval
= enabled
? 0x20 : 0x24;
5948 snd_hda_set_pin_ctl_cache(codec
, 0x19, pinval
);
5951 static void alc269_fixup_mic2_mute(struct hda_codec
*codec
,
5952 const struct alc_fixup
*fix
, int action
)
5954 struct alc_spec
*spec
= codec
->spec
;
5956 case ALC_FIXUP_ACT_BUILD
:
5957 spec
->vmaster_mute
.hook
= alc269_fixup_mic2_mute_hook
;
5958 snd_hda_add_vmaster_hook(codec
, &spec
->vmaster_mute
, true);
5960 case ALC_FIXUP_ACT_INIT
:
5961 snd_hda_sync_vmaster_hook(&spec
->vmaster_mute
);
5968 ALC269_FIXUP_SONY_VAIO
,
5969 ALC275_FIXUP_SONY_VAIO_GPIO2
,
5970 ALC269_FIXUP_DELL_M101Z
,
5971 ALC269_FIXUP_SKU_IGNORE
,
5972 ALC269_FIXUP_ASUS_G73JW
,
5973 ALC269_FIXUP_LENOVO_EAPD
,
5974 ALC275_FIXUP_SONY_HWEQ
,
5976 ALC269_FIXUP_PCM_44K
,
5977 ALC269_FIXUP_STEREO_DMIC
,
5978 ALC269_FIXUP_QUANTA_MUTE
,
5979 ALC269_FIXUP_LIFEBOOK
,
5982 ALC269VB_FIXUP_AMIC
,
5983 ALC269VB_FIXUP_DMIC
,
5984 ALC269_FIXUP_MIC2_MUTE_LED
,
5985 ALC269_FIXUP_INV_DMIC
,
5988 static const struct alc_fixup alc269_fixups
[] = {
5989 [ALC269_FIXUP_SONY_VAIO
] = {
5990 .type
= ALC_FIXUP_VERBS
,
5991 .v
.verbs
= (const struct hda_verb
[]) {
5992 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREFGRD
},
5996 [ALC275_FIXUP_SONY_VAIO_GPIO2
] = {
5997 .type
= ALC_FIXUP_VERBS
,
5998 .v
.verbs
= (const struct hda_verb
[]) {
5999 {0x01, AC_VERB_SET_GPIO_MASK
, 0x04},
6000 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x04},
6001 {0x01, AC_VERB_SET_GPIO_DATA
, 0x00},
6005 .chain_id
= ALC269_FIXUP_SONY_VAIO
6007 [ALC269_FIXUP_DELL_M101Z
] = {
6008 .type
= ALC_FIXUP_VERBS
,
6009 .v
.verbs
= (const struct hda_verb
[]) {
6010 /* Enables internal speaker */
6011 {0x20, AC_VERB_SET_COEF_INDEX
, 13},
6012 {0x20, AC_VERB_SET_PROC_COEF
, 0x4040},
6016 [ALC269_FIXUP_SKU_IGNORE
] = {
6017 .type
= ALC_FIXUP_FUNC
,
6018 .v
.func
= alc_fixup_sku_ignore
,
6020 [ALC269_FIXUP_ASUS_G73JW
] = {
6021 .type
= ALC_FIXUP_PINS
,
6022 .v
.pins
= (const struct alc_pincfg
[]) {
6023 { 0x17, 0x99130111 }, /* subwoofer */
6027 [ALC269_FIXUP_LENOVO_EAPD
] = {
6028 .type
= ALC_FIXUP_VERBS
,
6029 .v
.verbs
= (const struct hda_verb
[]) {
6030 {0x14, AC_VERB_SET_EAPD_BTLENABLE
, 0},
6034 [ALC275_FIXUP_SONY_HWEQ
] = {
6035 .type
= ALC_FIXUP_FUNC
,
6036 .v
.func
= alc269_fixup_hweq
,
6038 .chain_id
= ALC275_FIXUP_SONY_VAIO_GPIO2
6040 [ALC271_FIXUP_DMIC
] = {
6041 .type
= ALC_FIXUP_FUNC
,
6042 .v
.func
= alc271_fixup_dmic
,
6044 [ALC269_FIXUP_PCM_44K
] = {
6045 .type
= ALC_FIXUP_FUNC
,
6046 .v
.func
= alc269_fixup_pcm_44k
,
6048 [ALC269_FIXUP_STEREO_DMIC
] = {
6049 .type
= ALC_FIXUP_FUNC
,
6050 .v
.func
= alc269_fixup_stereo_dmic
,
6052 [ALC269_FIXUP_QUANTA_MUTE
] = {
6053 .type
= ALC_FIXUP_FUNC
,
6054 .v
.func
= alc269_fixup_quanta_mute
,
6056 [ALC269_FIXUP_LIFEBOOK
] = {
6057 .type
= ALC_FIXUP_PINS
,
6058 .v
.pins
= (const struct alc_pincfg
[]) {
6059 { 0x1a, 0x2101103f }, /* dock line-out */
6060 { 0x1b, 0x23a11040 }, /* dock mic-in */
6064 .chain_id
= ALC269_FIXUP_QUANTA_MUTE
6066 [ALC269_FIXUP_AMIC
] = {
6067 .type
= ALC_FIXUP_PINS
,
6068 .v
.pins
= (const struct alc_pincfg
[]) {
6069 { 0x14, 0x99130110 }, /* speaker */
6070 { 0x15, 0x0121401f }, /* HP out */
6071 { 0x18, 0x01a19c20 }, /* mic */
6072 { 0x19, 0x99a3092f }, /* int-mic */
6076 [ALC269_FIXUP_DMIC
] = {
6077 .type
= ALC_FIXUP_PINS
,
6078 .v
.pins
= (const struct alc_pincfg
[]) {
6079 { 0x12, 0x99a3092f }, /* int-mic */
6080 { 0x14, 0x99130110 }, /* speaker */
6081 { 0x15, 0x0121401f }, /* HP out */
6082 { 0x18, 0x01a19c20 }, /* mic */
6086 [ALC269VB_FIXUP_AMIC
] = {
6087 .type
= ALC_FIXUP_PINS
,
6088 .v
.pins
= (const struct alc_pincfg
[]) {
6089 { 0x14, 0x99130110 }, /* speaker */
6090 { 0x18, 0x01a19c20 }, /* mic */
6091 { 0x19, 0x99a3092f }, /* int-mic */
6092 { 0x21, 0x0121401f }, /* HP out */
6096 [ALC269VB_FIXUP_DMIC
] = {
6097 .type
= ALC_FIXUP_PINS
,
6098 .v
.pins
= (const struct alc_pincfg
[]) {
6099 { 0x12, 0x99a3092f }, /* int-mic */
6100 { 0x14, 0x99130110 }, /* speaker */
6101 { 0x18, 0x01a19c20 }, /* mic */
6102 { 0x21, 0x0121401f }, /* HP out */
6106 [ALC269_FIXUP_MIC2_MUTE_LED
] = {
6107 .type
= ALC_FIXUP_FUNC
,
6108 .v
.func
= alc269_fixup_mic2_mute
,
6110 [ALC269_FIXUP_INV_DMIC
] = {
6111 .type
= ALC_FIXUP_FUNC
,
6112 .v
.func
= alc_fixup_inv_dmic_0x12
,
6116 static const struct snd_pci_quirk alc269_fixup_tbl
[] = {
6117 SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC
),
6118 SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC
),
6119 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_MIC2_MUTE_LED
),
6120 SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_DMIC
),
6121 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW
),
6122 SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC
),
6123 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC
),
6124 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC
),
6125 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC
),
6126 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC
),
6127 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC
),
6128 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2
),
6129 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ
),
6130 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ
),
6131 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO
),
6132 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z
),
6133 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC
),
6134 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK
),
6135 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE
),
6136 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE
),
6137 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE
),
6138 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE
),
6139 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE
),
6140 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_QUANTA_MUTE
),
6141 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Lenovo Ideapd", ALC269_FIXUP_PCM_44K
),
6142 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD
),
6145 /* Below is a quirk table taken from the old code.
6146 * Basically the device should work as is without the fixup table.
6147 * If BIOS doesn't give a proper info, enable the corresponding
6150 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
6152 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC
),
6153 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC
),
6154 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC
),
6155 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC
),
6156 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC
),
6157 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC
),
6158 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC
),
6159 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC
),
6160 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC
),
6161 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC
),
6162 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC
),
6163 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC
),
6164 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC
),
6165 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC
),
6166 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC
),
6167 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC
),
6168 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC
),
6169 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC
),
6170 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC
),
6171 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC
),
6172 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC
),
6173 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC
),
6174 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC
),
6175 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC
),
6176 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC
),
6177 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC
),
6178 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC
),
6179 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC
),
6180 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC
),
6181 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC
),
6182 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC
),
6183 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC
),
6184 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC
),
6185 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC
),
6186 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC
),
6187 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC
),
6188 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC
),
6189 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC
),
6190 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC
),
6195 static const struct alc_model_fixup alc269_fixup_models
[] = {
6196 {.id
= ALC269_FIXUP_AMIC
, .name
= "laptop-amic"},
6197 {.id
= ALC269_FIXUP_DMIC
, .name
= "laptop-dmic"},
6198 {.id
= ALC269_FIXUP_STEREO_DMIC
, .name
= "alc269-dmic"},
6199 {.id
= ALC271_FIXUP_DMIC
, .name
= "alc271-dmic"},
6200 {.id
= ALC269_FIXUP_INV_DMIC
, .name
= "inv-dmic"},
6205 static void alc269_fill_coef(struct hda_codec
*codec
)
6207 struct alc_spec
*spec
= codec
->spec
;
6210 if (spec
->codec_variant
!= ALC269_TYPE_ALC269VB
)
6213 if ((alc_get_coef0(codec
) & 0x00ff) < 0x015) {
6214 alc_write_coef_idx(codec
, 0xf, 0x960b);
6215 alc_write_coef_idx(codec
, 0xe, 0x8817);
6218 if ((alc_get_coef0(codec
) & 0x00ff) == 0x016) {
6219 alc_write_coef_idx(codec
, 0xf, 0x960b);
6220 alc_write_coef_idx(codec
, 0xe, 0x8814);
6223 if ((alc_get_coef0(codec
) & 0x00ff) == 0x017) {
6224 val
= alc_read_coef_idx(codec
, 0x04);
6225 /* Power up output pin */
6226 alc_write_coef_idx(codec
, 0x04, val
| (1<<11));
6229 if ((alc_get_coef0(codec
) & 0x00ff) == 0x018) {
6230 val
= alc_read_coef_idx(codec
, 0xd);
6231 if ((val
& 0x0c00) >> 10 != 0x1) {
6232 /* Capless ramp up clock control */
6233 alc_write_coef_idx(codec
, 0xd, val
| (1<<10));
6235 val
= alc_read_coef_idx(codec
, 0x17);
6236 if ((val
& 0x01c0) >> 6 != 0x4) {
6237 /* Class D power on reset */
6238 alc_write_coef_idx(codec
, 0x17, val
| (1<<7));
6242 val
= alc_read_coef_idx(codec
, 0xd); /* Class D */
6243 alc_write_coef_idx(codec
, 0xd, val
| (1<<14));
6245 val
= alc_read_coef_idx(codec
, 0x4); /* HP */
6246 alc_write_coef_idx(codec
, 0x4, val
| (1<<11));
6251 static int patch_alc269(struct hda_codec
*codec
)
6253 struct alc_spec
*spec
;
6256 err
= alc_alloc_spec(codec
, 0x0b);
6262 if (codec
->vendor_id
== 0x10ec0269) {
6263 spec
->codec_variant
= ALC269_TYPE_ALC269VA
;
6264 switch (alc_get_coef0(codec
) & 0x00f0) {
6266 if (codec
->bus
->pci
->subsystem_vendor
== 0x1025 &&
6267 spec
->cdefine
.platform_type
== 1)
6268 err
= alc_codec_rename(codec
, "ALC271X");
6269 spec
->codec_variant
= ALC269_TYPE_ALC269VB
;
6272 if (codec
->bus
->pci
->subsystem_vendor
== 0x17aa &&
6273 codec
->bus
->pci
->subsystem_device
== 0x21f3)
6274 err
= alc_codec_rename(codec
, "ALC3202");
6275 spec
->codec_variant
= ALC269_TYPE_ALC269VC
;
6278 spec
->codec_variant
= ALC269_TYPE_ALC269VD
;
6281 alc_fix_pll_init(codec
, 0x20, 0x04, 15);
6285 spec
->init_hook
= alc269_fill_coef
;
6286 alc269_fill_coef(codec
);
6289 alc_pick_fixup(codec
, alc269_fixup_models
,
6290 alc269_fixup_tbl
, alc269_fixups
);
6291 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
6293 alc_auto_parse_customize_define(codec
);
6295 /* automatic parse from the BIOS config */
6296 err
= alc269_parse_auto_config(codec
);
6300 if (!spec
->no_analog
&& has_cdefine_beep(codec
)) {
6301 err
= snd_hda_attach_beep_device(codec
, 0x1);
6304 set_beep_amp(spec
, 0x0b, 0x04, HDA_INPUT
);
6307 codec
->patch_ops
= alc_patch_ops
;
6309 codec
->patch_ops
.resume
= alc269_resume
;
6311 spec
->shutup
= alc269_shutup
;
6313 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
6326 static int alc861_parse_auto_config(struct hda_codec
*codec
)
6328 static const hda_nid_t alc861_ignore
[] = { 0x1d, 0 };
6329 static const hda_nid_t alc861_ssids
[] = { 0x0e, 0x0f, 0x0b, 0 };
6330 return alc_parse_auto_config(codec
, alc861_ignore
, alc861_ssids
);
6333 /* Pin config fixes */
6335 ALC861_FIXUP_FSC_AMILO_PI1505
,
6336 ALC861_FIXUP_AMP_VREF_0F
,
6337 ALC861_FIXUP_NO_JACK_DETECT
,
6338 ALC861_FIXUP_ASUS_A6RP
,
6341 /* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */
6342 static void alc861_fixup_asus_amp_vref_0f(struct hda_codec
*codec
,
6343 const struct alc_fixup
*fix
, int action
)
6345 struct alc_spec
*spec
= codec
->spec
;
6348 if (action
!= ALC_FIXUP_ACT_INIT
)
6350 val
= snd_hda_codec_read(codec
, 0x0f, 0,
6351 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
6352 if (!(val
& (AC_PINCTL_IN_EN
| AC_PINCTL_OUT_EN
)))
6353 val
|= AC_PINCTL_IN_EN
;
6354 val
|= AC_PINCTL_VREF_50
;
6355 snd_hda_set_pin_ctl(codec
, 0x0f, val
);
6356 spec
->keep_vref_in_automute
= 1;
6359 /* suppress the jack-detection */
6360 static void alc_fixup_no_jack_detect(struct hda_codec
*codec
,
6361 const struct alc_fixup
*fix
, int action
)
6363 if (action
== ALC_FIXUP_ACT_PRE_PROBE
)
6364 codec
->no_jack_detect
= 1;
6367 static const struct alc_fixup alc861_fixups
[] = {
6368 [ALC861_FIXUP_FSC_AMILO_PI1505
] = {
6369 .type
= ALC_FIXUP_PINS
,
6370 .v
.pins
= (const struct alc_pincfg
[]) {
6371 { 0x0b, 0x0221101f }, /* HP */
6372 { 0x0f, 0x90170310 }, /* speaker */
6376 [ALC861_FIXUP_AMP_VREF_0F
] = {
6377 .type
= ALC_FIXUP_FUNC
,
6378 .v
.func
= alc861_fixup_asus_amp_vref_0f
,
6380 [ALC861_FIXUP_NO_JACK_DETECT
] = {
6381 .type
= ALC_FIXUP_FUNC
,
6382 .v
.func
= alc_fixup_no_jack_detect
,
6384 [ALC861_FIXUP_ASUS_A6RP
] = {
6385 .type
= ALC_FIXUP_FUNC
,
6386 .v
.func
= alc861_fixup_asus_amp_vref_0f
,
6388 .chain_id
= ALC861_FIXUP_NO_JACK_DETECT
,
6392 static const struct snd_pci_quirk alc861_fixup_tbl
[] = {
6393 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP
),
6394 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F
),
6395 SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT
),
6396 SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F
),
6397 SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F
),
6398 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505
),
6404 static int patch_alc861(struct hda_codec
*codec
)
6406 struct alc_spec
*spec
;
6409 err
= alc_alloc_spec(codec
, 0x15);
6415 alc_pick_fixup(codec
, NULL
, alc861_fixup_tbl
, alc861_fixups
);
6416 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
6418 /* automatic parse from the BIOS config */
6419 err
= alc861_parse_auto_config(codec
);
6423 if (!spec
->no_analog
) {
6424 err
= snd_hda_attach_beep_device(codec
, 0x23);
6427 set_beep_amp(spec
, 0x23, 0, HDA_OUTPUT
);
6430 codec
->patch_ops
= alc_patch_ops
;
6431 #ifdef CONFIG_SND_HDA_POWER_SAVE
6432 spec
->power_hook
= alc_power_eapd
;
6435 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
6449 * In addition, an independent DAC
6451 static int alc861vd_parse_auto_config(struct hda_codec
*codec
)
6453 static const hda_nid_t alc861vd_ignore
[] = { 0x1d, 0 };
6454 static const hda_nid_t alc861vd_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
6455 return alc_parse_auto_config(codec
, alc861vd_ignore
, alc861vd_ssids
);
6459 ALC660VD_FIX_ASUS_GPIO1
,
6460 ALC861VD_FIX_DALLAS
,
6463 /* exclude VREF80 */
6464 static void alc861vd_fixup_dallas(struct hda_codec
*codec
,
6465 const struct alc_fixup
*fix
, int action
)
6467 if (action
== ALC_FIXUP_ACT_PRE_PROBE
) {
6468 snd_hda_override_pin_caps(codec
, 0x18, 0x00001714);
6469 snd_hda_override_pin_caps(codec
, 0x19, 0x0000171c);
6473 static const struct alc_fixup alc861vd_fixups
[] = {
6474 [ALC660VD_FIX_ASUS_GPIO1
] = {
6475 .type
= ALC_FIXUP_VERBS
,
6476 .v
.verbs
= (const struct hda_verb
[]) {
6478 {0x01, AC_VERB_SET_GPIO_MASK
, 0x03},
6479 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x01},
6480 {0x01, AC_VERB_SET_GPIO_DATA
, 0x01},
6484 [ALC861VD_FIX_DALLAS
] = {
6485 .type
= ALC_FIXUP_FUNC
,
6486 .v
.func
= alc861vd_fixup_dallas
,
6490 static const struct snd_pci_quirk alc861vd_fixup_tbl
[] = {
6491 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS
),
6492 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1
),
6493 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS
),
6497 static const struct hda_verb alc660vd_eapd_verbs
[] = {
6498 {0x14, AC_VERB_SET_EAPD_BTLENABLE
, 2},
6499 {0x15, AC_VERB_SET_EAPD_BTLENABLE
, 2},
6505 static int patch_alc861vd(struct hda_codec
*codec
)
6507 struct alc_spec
*spec
;
6510 err
= alc_alloc_spec(codec
, 0x0b);
6516 alc_pick_fixup(codec
, NULL
, alc861vd_fixup_tbl
, alc861vd_fixups
);
6517 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
6519 /* automatic parse from the BIOS config */
6520 err
= alc861vd_parse_auto_config(codec
);
6524 if (codec
->vendor_id
== 0x10ec0660) {
6525 /* always turn on EAPD */
6526 snd_hda_gen_add_verbs(&spec
->gen
, alc660vd_eapd_verbs
);
6529 if (!spec
->no_analog
) {
6530 err
= snd_hda_attach_beep_device(codec
, 0x23);
6533 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
6536 codec
->patch_ops
= alc_patch_ops
;
6538 spec
->shutup
= alc_eapd_shutup
;
6540 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
6552 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
6553 * configuration. Each pin widget can choose any input DACs and a mixer.
6554 * Each ADC is connected from a mixer of all inputs. This makes possible
6555 * 6-channel independent captures.
6557 * In addition, an independent DAC for the multi-playback (not used in this
6562 * BIOS auto configuration
6565 static int alc662_parse_auto_config(struct hda_codec
*codec
)
6567 static const hda_nid_t alc662_ignore
[] = { 0x1d, 0 };
6568 static const hda_nid_t alc663_ssids
[] = { 0x15, 0x1b, 0x14, 0x21 };
6569 static const hda_nid_t alc662_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
6570 const hda_nid_t
*ssids
;
6572 if (codec
->vendor_id
== 0x10ec0272 || codec
->vendor_id
== 0x10ec0663 ||
6573 codec
->vendor_id
== 0x10ec0665 || codec
->vendor_id
== 0x10ec0670)
6574 ssids
= alc663_ssids
;
6576 ssids
= alc662_ssids
;
6577 return alc_parse_auto_config(codec
, alc662_ignore
, ssids
);
6580 static void alc272_fixup_mario(struct hda_codec
*codec
,
6581 const struct alc_fixup
*fix
, int action
)
6583 if (action
!= ALC_FIXUP_ACT_PROBE
)
6585 if (snd_hda_override_amp_caps(codec
, 0x2, HDA_OUTPUT
,
6586 (0x3b << AC_AMPCAP_OFFSET_SHIFT
) |
6587 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT
) |
6588 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
6589 (0 << AC_AMPCAP_MUTE_SHIFT
)))
6591 "hda_codec: failed to override amp caps for NID 0x2\n");
6595 ALC662_FIXUP_ASPIRE
,
6596 ALC662_FIXUP_IDEAPAD
,
6598 ALC662_FIXUP_CZC_P10T
,
6599 ALC662_FIXUP_SKU_IGNORE
,
6600 ALC662_FIXUP_HP_RP5800
,
6601 ALC662_FIXUP_ASUS_MODE1
,
6602 ALC662_FIXUP_ASUS_MODE2
,
6603 ALC662_FIXUP_ASUS_MODE3
,
6604 ALC662_FIXUP_ASUS_MODE4
,
6605 ALC662_FIXUP_ASUS_MODE5
,
6606 ALC662_FIXUP_ASUS_MODE6
,
6607 ALC662_FIXUP_ASUS_MODE7
,
6608 ALC662_FIXUP_ASUS_MODE8
,
6609 ALC662_FIXUP_NO_JACK_DETECT
,
6610 ALC662_FIXUP_ZOTAC_Z68
,
6611 ALC662_FIXUP_INV_DMIC
,
6614 static const struct alc_fixup alc662_fixups
[] = {
6615 [ALC662_FIXUP_ASPIRE
] = {
6616 .type
= ALC_FIXUP_PINS
,
6617 .v
.pins
= (const struct alc_pincfg
[]) {
6618 { 0x15, 0x99130112 }, /* subwoofer */
6622 [ALC662_FIXUP_IDEAPAD
] = {
6623 .type
= ALC_FIXUP_PINS
,
6624 .v
.pins
= (const struct alc_pincfg
[]) {
6625 { 0x17, 0x99130112 }, /* subwoofer */
6629 [ALC272_FIXUP_MARIO
] = {
6630 .type
= ALC_FIXUP_FUNC
,
6631 .v
.func
= alc272_fixup_mario
,
6633 [ALC662_FIXUP_CZC_P10T
] = {
6634 .type
= ALC_FIXUP_VERBS
,
6635 .v
.verbs
= (const struct hda_verb
[]) {
6636 {0x14, AC_VERB_SET_EAPD_BTLENABLE
, 0},
6640 [ALC662_FIXUP_SKU_IGNORE
] = {
6641 .type
= ALC_FIXUP_FUNC
,
6642 .v
.func
= alc_fixup_sku_ignore
,
6644 [ALC662_FIXUP_HP_RP5800
] = {
6645 .type
= ALC_FIXUP_PINS
,
6646 .v
.pins
= (const struct alc_pincfg
[]) {
6647 { 0x14, 0x0221201f }, /* HP out */
6651 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6653 [ALC662_FIXUP_ASUS_MODE1
] = {
6654 .type
= ALC_FIXUP_PINS
,
6655 .v
.pins
= (const struct alc_pincfg
[]) {
6656 { 0x14, 0x99130110 }, /* speaker */
6657 { 0x18, 0x01a19c20 }, /* mic */
6658 { 0x19, 0x99a3092f }, /* int-mic */
6659 { 0x21, 0x0121401f }, /* HP out */
6663 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6665 [ALC662_FIXUP_ASUS_MODE2
] = {
6666 .type
= ALC_FIXUP_PINS
,
6667 .v
.pins
= (const struct alc_pincfg
[]) {
6668 { 0x14, 0x99130110 }, /* speaker */
6669 { 0x18, 0x01a19820 }, /* mic */
6670 { 0x19, 0x99a3092f }, /* int-mic */
6671 { 0x1b, 0x0121401f }, /* HP out */
6675 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6677 [ALC662_FIXUP_ASUS_MODE3
] = {
6678 .type
= ALC_FIXUP_PINS
,
6679 .v
.pins
= (const struct alc_pincfg
[]) {
6680 { 0x14, 0x99130110 }, /* speaker */
6681 { 0x15, 0x0121441f }, /* HP */
6682 { 0x18, 0x01a19840 }, /* mic */
6683 { 0x19, 0x99a3094f }, /* int-mic */
6684 { 0x21, 0x01211420 }, /* HP2 */
6688 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6690 [ALC662_FIXUP_ASUS_MODE4
] = {
6691 .type
= ALC_FIXUP_PINS
,
6692 .v
.pins
= (const struct alc_pincfg
[]) {
6693 { 0x14, 0x99130110 }, /* speaker */
6694 { 0x16, 0x99130111 }, /* speaker */
6695 { 0x18, 0x01a19840 }, /* mic */
6696 { 0x19, 0x99a3094f }, /* int-mic */
6697 { 0x21, 0x0121441f }, /* HP */
6701 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6703 [ALC662_FIXUP_ASUS_MODE5
] = {
6704 .type
= ALC_FIXUP_PINS
,
6705 .v
.pins
= (const struct alc_pincfg
[]) {
6706 { 0x14, 0x99130110 }, /* speaker */
6707 { 0x15, 0x0121441f }, /* HP */
6708 { 0x16, 0x99130111 }, /* speaker */
6709 { 0x18, 0x01a19840 }, /* mic */
6710 { 0x19, 0x99a3094f }, /* int-mic */
6714 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6716 [ALC662_FIXUP_ASUS_MODE6
] = {
6717 .type
= ALC_FIXUP_PINS
,
6718 .v
.pins
= (const struct alc_pincfg
[]) {
6719 { 0x14, 0x99130110 }, /* speaker */
6720 { 0x15, 0x01211420 }, /* HP2 */
6721 { 0x18, 0x01a19840 }, /* mic */
6722 { 0x19, 0x99a3094f }, /* int-mic */
6723 { 0x1b, 0x0121441f }, /* HP */
6727 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6729 [ALC662_FIXUP_ASUS_MODE7
] = {
6730 .type
= ALC_FIXUP_PINS
,
6731 .v
.pins
= (const struct alc_pincfg
[]) {
6732 { 0x14, 0x99130110 }, /* speaker */
6733 { 0x17, 0x99130111 }, /* speaker */
6734 { 0x18, 0x01a19840 }, /* mic */
6735 { 0x19, 0x99a3094f }, /* int-mic */
6736 { 0x1b, 0x01214020 }, /* HP */
6737 { 0x21, 0x0121401f }, /* HP */
6741 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6743 [ALC662_FIXUP_ASUS_MODE8
] = {
6744 .type
= ALC_FIXUP_PINS
,
6745 .v
.pins
= (const struct alc_pincfg
[]) {
6746 { 0x14, 0x99130110 }, /* speaker */
6747 { 0x12, 0x99a30970 }, /* int-mic */
6748 { 0x15, 0x01214020 }, /* HP */
6749 { 0x17, 0x99130111 }, /* speaker */
6750 { 0x18, 0x01a19840 }, /* mic */
6751 { 0x21, 0x0121401f }, /* HP */
6755 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6757 [ALC662_FIXUP_NO_JACK_DETECT
] = {
6758 .type
= ALC_FIXUP_FUNC
,
6759 .v
.func
= alc_fixup_no_jack_detect
,
6761 [ALC662_FIXUP_ZOTAC_Z68
] = {
6762 .type
= ALC_FIXUP_PINS
,
6763 .v
.pins
= (const struct alc_pincfg
[]) {
6764 { 0x1b, 0x02214020 }, /* Front HP */
6768 [ALC662_FIXUP_INV_DMIC
] = {
6769 .type
= ALC_FIXUP_FUNC
,
6770 .v
.func
= alc_fixup_inv_dmic_0x12
,
6774 static const struct snd_pci_quirk alc662_fixup_tbl
[] = {
6775 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2
),
6776 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE
),
6777 SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE
),
6778 SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC
),
6779 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE
),
6780 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800
),
6781 SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT
),
6782 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2
),
6783 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD
),
6784 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD
),
6785 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD
),
6786 SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68
),
6787 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T
),
6790 /* Below is a quirk table taken from the old code.
6791 * Basically the device should work as is without the fixup table.
6792 * If BIOS doesn't give a proper info, enable the corresponding
6795 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1
),
6796 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3
),
6797 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1
),
6798 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3
),
6799 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1
),
6800 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6801 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1
),
6802 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1
),
6803 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1
),
6804 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6805 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7
),
6806 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7
),
6807 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8
),
6808 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3
),
6809 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1
),
6810 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6811 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2
),
6812 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1
),
6813 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6814 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6
),
6815 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6
),
6816 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6817 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1
),
6818 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3
),
6819 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2
),
6820 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6821 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5
),
6822 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6
),
6823 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6824 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1
),
6825 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6826 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6827 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3
),
6828 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3
),
6829 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1
),
6830 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1
),
6831 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1
),
6832 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1
),
6833 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1
),
6834 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6835 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2
),
6836 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1
),
6837 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1
),
6838 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3
),
6839 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1
),
6840 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1
),
6841 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1
),
6842 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2
),
6843 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1
),
6844 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4
),
6849 static const struct alc_model_fixup alc662_fixup_models
[] = {
6850 {.id
= ALC272_FIXUP_MARIO
, .name
= "mario"},
6851 {.id
= ALC662_FIXUP_ASUS_MODE1
, .name
= "asus-mode1"},
6852 {.id
= ALC662_FIXUP_ASUS_MODE2
, .name
= "asus-mode2"},
6853 {.id
= ALC662_FIXUP_ASUS_MODE3
, .name
= "asus-mode3"},
6854 {.id
= ALC662_FIXUP_ASUS_MODE4
, .name
= "asus-mode4"},
6855 {.id
= ALC662_FIXUP_ASUS_MODE5
, .name
= "asus-mode5"},
6856 {.id
= ALC662_FIXUP_ASUS_MODE6
, .name
= "asus-mode6"},
6857 {.id
= ALC662_FIXUP_ASUS_MODE7
, .name
= "asus-mode7"},
6858 {.id
= ALC662_FIXUP_ASUS_MODE8
, .name
= "asus-mode8"},
6859 {.id
= ALC662_FIXUP_INV_DMIC
, .name
= "inv-dmic"},
6866 static int patch_alc662(struct hda_codec
*codec
)
6868 struct alc_spec
*spec
;
6871 err
= alc_alloc_spec(codec
, 0x0b);
6877 /* handle multiple HPs as is */
6878 spec
->parse_flags
= HDA_PINCFG_NO_HP_FIXUP
;
6880 alc_fix_pll_init(codec
, 0x20, 0x04, 15);
6882 if ((alc_get_coef0(codec
) & (1 << 14)) &&
6883 codec
->bus
->pci
->subsystem_vendor
== 0x1025 &&
6884 spec
->cdefine
.platform_type
== 1) {
6885 if (alc_codec_rename(codec
, "ALC272X") < 0)
6889 alc_pick_fixup(codec
, alc662_fixup_models
,
6890 alc662_fixup_tbl
, alc662_fixups
);
6891 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
6893 alc_auto_parse_customize_define(codec
);
6895 /* automatic parse from the BIOS config */
6896 err
= alc662_parse_auto_config(codec
);
6900 if (!spec
->no_analog
&& has_cdefine_beep(codec
)) {
6901 err
= snd_hda_attach_beep_device(codec
, 0x1);
6904 switch (codec
->vendor_id
) {
6906 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
6911 set_beep_amp(spec
, 0x0b, 0x04, HDA_INPUT
);
6914 set_beep_amp(spec
, 0x0b, 0x03, HDA_INPUT
);
6919 codec
->patch_ops
= alc_patch_ops
;
6920 spec
->shutup
= alc_eapd_shutup
;
6922 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
6935 static int alc680_parse_auto_config(struct hda_codec
*codec
)
6937 return alc_parse_auto_config(codec
, NULL
, NULL
);
6942 static int patch_alc680(struct hda_codec
*codec
)
6946 /* ALC680 has no aa-loopback mixer */
6947 err
= alc_alloc_spec(codec
, 0);
6951 /* automatic parse from the BIOS config */
6952 err
= alc680_parse_auto_config(codec
);
6958 codec
->patch_ops
= alc_patch_ops
;
6966 static const struct hda_codec_preset snd_hda_preset_realtek
[] = {
6967 { .id
= 0x10ec0221, .name
= "ALC221", .patch
= patch_alc269
},
6968 { .id
= 0x10ec0260, .name
= "ALC260", .patch
= patch_alc260
},
6969 { .id
= 0x10ec0262, .name
= "ALC262", .patch
= patch_alc262
},
6970 { .id
= 0x10ec0267, .name
= "ALC267", .patch
= patch_alc268
},
6971 { .id
= 0x10ec0268, .name
= "ALC268", .patch
= patch_alc268
},
6972 { .id
= 0x10ec0269, .name
= "ALC269", .patch
= patch_alc269
},
6973 { .id
= 0x10ec0270, .name
= "ALC270", .patch
= patch_alc269
},
6974 { .id
= 0x10ec0272, .name
= "ALC272", .patch
= patch_alc662
},
6975 { .id
= 0x10ec0275, .name
= "ALC275", .patch
= patch_alc269
},
6976 { .id
= 0x10ec0276, .name
= "ALC276", .patch
= patch_alc269
},
6977 { .id
= 0x10ec0861, .rev
= 0x100340, .name
= "ALC660",
6978 .patch
= patch_alc861
},
6979 { .id
= 0x10ec0660, .name
= "ALC660-VD", .patch
= patch_alc861vd
},
6980 { .id
= 0x10ec0861, .name
= "ALC861", .patch
= patch_alc861
},
6981 { .id
= 0x10ec0862, .name
= "ALC861-VD", .patch
= patch_alc861vd
},
6982 { .id
= 0x10ec0662, .rev
= 0x100002, .name
= "ALC662 rev2",
6983 .patch
= patch_alc882
},
6984 { .id
= 0x10ec0662, .rev
= 0x100101, .name
= "ALC662 rev1",
6985 .patch
= patch_alc662
},
6986 { .id
= 0x10ec0662, .rev
= 0x100300, .name
= "ALC662 rev3",
6987 .patch
= patch_alc662
},
6988 { .id
= 0x10ec0663, .name
= "ALC663", .patch
= patch_alc662
},
6989 { .id
= 0x10ec0665, .name
= "ALC665", .patch
= patch_alc662
},
6990 { .id
= 0x10ec0670, .name
= "ALC670", .patch
= patch_alc662
},
6991 { .id
= 0x10ec0680, .name
= "ALC680", .patch
= patch_alc680
},
6992 { .id
= 0x10ec0880, .name
= "ALC880", .patch
= patch_alc880
},
6993 { .id
= 0x10ec0882, .name
= "ALC882", .patch
= patch_alc882
},
6994 { .id
= 0x10ec0883, .name
= "ALC883", .patch
= patch_alc882
},
6995 { .id
= 0x10ec0885, .rev
= 0x100101, .name
= "ALC889A",
6996 .patch
= patch_alc882
},
6997 { .id
= 0x10ec0885, .rev
= 0x100103, .name
= "ALC889A",
6998 .patch
= patch_alc882
},
6999 { .id
= 0x10ec0885, .name
= "ALC885", .patch
= patch_alc882
},
7000 { .id
= 0x10ec0887, .name
= "ALC887", .patch
= patch_alc882
},
7001 { .id
= 0x10ec0888, .rev
= 0x100101, .name
= "ALC1200",
7002 .patch
= patch_alc882
},
7003 { .id
= 0x10ec0888, .name
= "ALC888", .patch
= patch_alc882
},
7004 { .id
= 0x10ec0889, .name
= "ALC889", .patch
= patch_alc882
},
7005 { .id
= 0x10ec0892, .name
= "ALC892", .patch
= patch_alc662
},
7006 { .id
= 0x10ec0899, .name
= "ALC898", .patch
= patch_alc882
},
7010 MODULE_ALIAS("snd-hda-codec-id:10ec*");
7012 MODULE_LICENSE("GPL");
7013 MODULE_DESCRIPTION("Realtek HD-audio codec");
7015 static struct hda_codec_preset_list realtek_list
= {
7016 .preset
= snd_hda_preset_realtek
,
7017 .owner
= THIS_MODULE
,
7020 static int __init
patch_realtek_init(void)
7022 return snd_hda_add_codec_preset(&realtek_list
);
7025 static void __exit
patch_realtek_exit(void)
7027 snd_hda_delete_codec_preset(&realtek_list
);
7030 module_init(patch_realtek_init
)
7031 module_exit(patch_realtek_exit
)