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
;
1788 * virtual master controls
1792 * slave controls for virtual master
1794 static const char * const alc_slave_pfxs
[] = {
1795 "Front", "Surround", "Center", "LFE", "Side",
1796 "Headphone", "Speaker", "Mono", "Line Out",
1797 "CLFE", "Bass Speaker", "PCM",
1802 * build control elements
1805 #define NID_MAPPING (-1)
1807 #define SUBDEV_SPEAKER_ (0 << 6)
1808 #define SUBDEV_HP_ (1 << 6)
1809 #define SUBDEV_LINE_ (2 << 6)
1810 #define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
1811 #define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
1812 #define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
1814 static void alc_free_kctls(struct hda_codec
*codec
);
1816 #ifdef CONFIG_SND_HDA_INPUT_BEEP
1817 /* additional beep mixers; the actual parameters are overwritten at build */
1818 static const struct snd_kcontrol_new alc_beep_mixer
[] = {
1819 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT
),
1820 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT
),
1825 static int __alc_build_controls(struct hda_codec
*codec
)
1827 struct alc_spec
*spec
= codec
->spec
;
1828 struct snd_kcontrol
*kctl
= NULL
;
1829 const struct snd_kcontrol_new
*knew
;
1834 for (i
= 0; i
< spec
->num_mixers
; i
++) {
1835 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
1839 if (spec
->cap_mixer
) {
1840 err
= snd_hda_add_new_ctls(codec
, spec
->cap_mixer
);
1844 if (spec
->multiout
.dig_out_nid
) {
1845 err
= snd_hda_create_spdif_out_ctls(codec
,
1846 spec
->multiout
.dig_out_nid
,
1847 spec
->multiout
.dig_out_nid
);
1850 if (!spec
->no_analog
) {
1851 err
= snd_hda_create_spdif_share_sw(codec
,
1855 spec
->multiout
.share_spdif
= 1;
1858 if (spec
->dig_in_nid
) {
1859 err
= snd_hda_create_spdif_in_ctls(codec
, spec
->dig_in_nid
);
1864 #ifdef CONFIG_SND_HDA_INPUT_BEEP
1865 /* create beep controls if needed */
1866 if (spec
->beep_amp
) {
1867 const struct snd_kcontrol_new
*knew
;
1868 for (knew
= alc_beep_mixer
; knew
->name
; knew
++) {
1869 struct snd_kcontrol
*kctl
;
1870 kctl
= snd_ctl_new1(knew
, codec
);
1873 kctl
->private_value
= spec
->beep_amp
;
1874 err
= snd_hda_ctl_add(codec
, 0, kctl
);
1881 /* if we have no master control, let's create it */
1882 if (!spec
->no_analog
&&
1883 !snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
1884 unsigned int vmaster_tlv
[4];
1885 snd_hda_set_vmaster_tlv(codec
, spec
->vmaster_nid
,
1886 HDA_OUTPUT
, vmaster_tlv
);
1887 err
= snd_hda_add_vmaster(codec
, "Master Playback Volume",
1888 vmaster_tlv
, alc_slave_pfxs
,
1893 if (!spec
->no_analog
&&
1894 !snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
1895 err
= __snd_hda_add_vmaster(codec
, "Master Playback Switch",
1896 NULL
, alc_slave_pfxs
,
1898 true, &spec
->vmaster_mute
.sw_kctl
);
1903 /* assign Capture Source enums to NID */
1904 if (spec
->capsrc_nids
|| spec
->adc_nids
) {
1905 kctl
= snd_hda_find_mixer_ctl(codec
, "Capture Source");
1907 kctl
= snd_hda_find_mixer_ctl(codec
, "Input Source");
1908 for (i
= 0; kctl
&& i
< kctl
->count
; i
++) {
1909 err
= snd_hda_add_nid(codec
, kctl
, i
,
1910 get_capsrc(spec
, i
));
1915 if (spec
->cap_mixer
&& spec
->adc_nids
) {
1916 const char *kname
= kctl
? kctl
->id
.name
: NULL
;
1917 for (knew
= spec
->cap_mixer
; knew
->name
; knew
++) {
1918 if (kname
&& strcmp(knew
->name
, kname
) == 0)
1920 kctl
= snd_hda_find_mixer_ctl(codec
, knew
->name
);
1921 for (i
= 0; kctl
&& i
< kctl
->count
; i
++) {
1922 err
= snd_hda_add_nid(codec
, kctl
, i
,
1930 /* other nid->control mapping */
1931 for (i
= 0; i
< spec
->num_mixers
; i
++) {
1932 for (knew
= spec
->mixers
[i
]; knew
->name
; knew
++) {
1933 if (knew
->iface
!= NID_MAPPING
)
1935 kctl
= snd_hda_find_mixer_ctl(codec
, knew
->name
);
1938 u
= knew
->subdevice
;
1939 for (j
= 0; j
< 4; j
++, u
>>= 8) {
1944 case SUBDEV_SPEAKER_
:
1945 nid
= spec
->autocfg
.speaker_pins
[nid
];
1948 nid
= spec
->autocfg
.line_out_pins
[nid
];
1951 nid
= spec
->autocfg
.hp_pins
[nid
];
1956 err
= snd_hda_add_nid(codec
, kctl
, 0, nid
);
1960 u
= knew
->private_value
;
1961 for (j
= 0; j
< 4; j
++, u
>>= 8) {
1965 err
= snd_hda_add_nid(codec
, kctl
, 0, nid
);
1972 alc_free_kctls(codec
); /* no longer needed */
1977 static int alc_build_controls(struct hda_codec
*codec
)
1979 struct alc_spec
*spec
= codec
->spec
;
1980 int err
= __alc_build_controls(codec
);
1983 err
= snd_hda_jack_add_kctls(codec
, &spec
->autocfg
);
1986 alc_apply_fixup(codec
, ALC_FIXUP_ACT_BUILD
);
1995 static void alc_init_special_input_src(struct hda_codec
*codec
);
1996 static void alc_auto_init_std(struct hda_codec
*codec
);
1998 static int alc_init(struct hda_codec
*codec
)
2000 struct alc_spec
*spec
= codec
->spec
;
2002 if (spec
->init_hook
)
2003 spec
->init_hook(codec
);
2006 alc_auto_init_amp(codec
, spec
->init_amp
);
2008 snd_hda_gen_apply_verbs(codec
);
2009 alc_init_special_input_src(codec
);
2010 alc_auto_init_std(codec
);
2012 alc_apply_fixup(codec
, ALC_FIXUP_ACT_INIT
);
2014 snd_hda_jack_report_sync(codec
);
2016 hda_call_check_power_status(codec
, 0x01);
2020 static void alc_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2022 struct alc_spec
*spec
= codec
->spec
;
2024 if (spec
->unsol_event
)
2025 spec
->unsol_event(codec
, res
);
2028 #ifdef CONFIG_SND_HDA_POWER_SAVE
2029 static int alc_check_power_status(struct hda_codec
*codec
, hda_nid_t nid
)
2031 struct alc_spec
*spec
= codec
->spec
;
2032 return snd_hda_check_amp_list_power(codec
, &spec
->loopback
, nid
);
2037 * Analog playback callbacks
2039 static int alc_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
2040 struct hda_codec
*codec
,
2041 struct snd_pcm_substream
*substream
)
2043 struct alc_spec
*spec
= codec
->spec
;
2044 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
2048 static int alc_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2049 struct hda_codec
*codec
,
2050 unsigned int stream_tag
,
2051 unsigned int format
,
2052 struct snd_pcm_substream
*substream
)
2054 struct alc_spec
*spec
= codec
->spec
;
2055 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
,
2056 stream_tag
, format
, substream
);
2059 static int alc_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2060 struct hda_codec
*codec
,
2061 struct snd_pcm_substream
*substream
)
2063 struct alc_spec
*spec
= codec
->spec
;
2064 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
2070 static int alc_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
2071 struct hda_codec
*codec
,
2072 struct snd_pcm_substream
*substream
)
2074 struct alc_spec
*spec
= codec
->spec
;
2075 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
2078 static int alc_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2079 struct hda_codec
*codec
,
2080 unsigned int stream_tag
,
2081 unsigned int format
,
2082 struct snd_pcm_substream
*substream
)
2084 struct alc_spec
*spec
= codec
->spec
;
2085 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
2086 stream_tag
, format
, substream
);
2089 static int alc_dig_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2090 struct hda_codec
*codec
,
2091 struct snd_pcm_substream
*substream
)
2093 struct alc_spec
*spec
= codec
->spec
;
2094 return snd_hda_multi_out_dig_cleanup(codec
, &spec
->multiout
);
2097 static int alc_dig_playback_pcm_close(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_close(codec
, &spec
->multiout
);
2108 static int alc_alt_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2109 struct hda_codec
*codec
,
2110 unsigned int stream_tag
,
2111 unsigned int format
,
2112 struct snd_pcm_substream
*substream
)
2114 struct alc_spec
*spec
= codec
->spec
;
2116 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
+ 1],
2117 stream_tag
, 0, format
);
2121 static int alc_alt_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2122 struct hda_codec
*codec
,
2123 struct snd_pcm_substream
*substream
)
2125 struct alc_spec
*spec
= codec
->spec
;
2127 snd_hda_codec_cleanup_stream(codec
,
2128 spec
->adc_nids
[substream
->number
+ 1]);
2132 /* analog capture with dynamic dual-adc changes */
2133 static int dyn_adc_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2134 struct hda_codec
*codec
,
2135 unsigned int stream_tag
,
2136 unsigned int format
,
2137 struct snd_pcm_substream
*substream
)
2139 struct alc_spec
*spec
= codec
->spec
;
2140 spec
->cur_adc
= spec
->adc_nids
[spec
->dyn_adc_idx
[spec
->cur_mux
[0]]];
2141 spec
->cur_adc_stream_tag
= stream_tag
;
2142 spec
->cur_adc_format
= format
;
2143 snd_hda_codec_setup_stream(codec
, spec
->cur_adc
, stream_tag
, 0, format
);
2147 static int dyn_adc_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2148 struct hda_codec
*codec
,
2149 struct snd_pcm_substream
*substream
)
2151 struct alc_spec
*spec
= codec
->spec
;
2152 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
2157 static const struct hda_pcm_stream dyn_adc_pcm_analog_capture
= {
2161 .nid
= 0, /* fill later */
2163 .prepare
= dyn_adc_capture_pcm_prepare
,
2164 .cleanup
= dyn_adc_capture_pcm_cleanup
2170 static const struct hda_pcm_stream alc_pcm_analog_playback
= {
2174 /* NID is set in alc_build_pcms */
2176 .open
= alc_playback_pcm_open
,
2177 .prepare
= alc_playback_pcm_prepare
,
2178 .cleanup
= alc_playback_pcm_cleanup
2182 static const struct hda_pcm_stream alc_pcm_analog_capture
= {
2186 /* NID is set in alc_build_pcms */
2189 static const struct hda_pcm_stream alc_pcm_analog_alt_playback
= {
2193 /* NID is set in alc_build_pcms */
2196 static const struct hda_pcm_stream alc_pcm_analog_alt_capture
= {
2197 .substreams
= 2, /* can be overridden */
2200 /* NID is set in alc_build_pcms */
2202 .prepare
= alc_alt_capture_pcm_prepare
,
2203 .cleanup
= alc_alt_capture_pcm_cleanup
2207 static const struct hda_pcm_stream alc_pcm_digital_playback
= {
2211 /* NID is set in alc_build_pcms */
2213 .open
= alc_dig_playback_pcm_open
,
2214 .close
= alc_dig_playback_pcm_close
,
2215 .prepare
= alc_dig_playback_pcm_prepare
,
2216 .cleanup
= alc_dig_playback_pcm_cleanup
2220 static const struct hda_pcm_stream alc_pcm_digital_capture
= {
2224 /* NID is set in alc_build_pcms */
2227 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
2228 static const struct hda_pcm_stream alc_pcm_null_stream
= {
2234 static int alc_build_pcms(struct hda_codec
*codec
)
2236 struct alc_spec
*spec
= codec
->spec
;
2237 struct hda_pcm
*info
= spec
->pcm_rec
;
2238 const struct hda_pcm_stream
*p
;
2239 bool have_multi_adcs
;
2242 codec
->num_pcms
= 1;
2243 codec
->pcm_info
= info
;
2245 if (spec
->no_analog
)
2248 snprintf(spec
->stream_name_analog
, sizeof(spec
->stream_name_analog
),
2249 "%s Analog", codec
->chip_name
);
2250 info
->name
= spec
->stream_name_analog
;
2252 if (spec
->multiout
.num_dacs
> 0) {
2253 p
= spec
->stream_analog_playback
;
2255 p
= &alc_pcm_analog_playback
;
2256 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = *p
;
2257 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dac_nids
[0];
2259 if (spec
->adc_nids
) {
2260 p
= spec
->stream_analog_capture
;
2262 if (spec
->dyn_adc_switch
)
2263 p
= &dyn_adc_pcm_analog_capture
;
2265 p
= &alc_pcm_analog_capture
;
2267 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *p
;
2268 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
2271 if (spec
->channel_mode
) {
2272 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
= 0;
2273 for (i
= 0; i
< spec
->num_channel_mode
; i
++) {
2274 if (spec
->channel_mode
[i
].channels
> info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
) {
2275 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
= spec
->channel_mode
[i
].channels
;
2281 /* SPDIF for stream index #1 */
2282 if (spec
->multiout
.dig_out_nid
|| spec
->dig_in_nid
) {
2283 snprintf(spec
->stream_name_digital
,
2284 sizeof(spec
->stream_name_digital
),
2285 "%s Digital", codec
->chip_name
);
2286 codec
->num_pcms
= 2;
2287 codec
->slave_dig_outs
= spec
->multiout
.slave_dig_outs
;
2288 info
= spec
->pcm_rec
+ 1;
2289 info
->name
= spec
->stream_name_digital
;
2290 if (spec
->dig_out_type
)
2291 info
->pcm_type
= spec
->dig_out_type
;
2293 info
->pcm_type
= HDA_PCM_TYPE_SPDIF
;
2294 if (spec
->multiout
.dig_out_nid
) {
2295 p
= spec
->stream_digital_playback
;
2297 p
= &alc_pcm_digital_playback
;
2298 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = *p
;
2299 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dig_out_nid
;
2301 if (spec
->dig_in_nid
) {
2302 p
= spec
->stream_digital_capture
;
2304 p
= &alc_pcm_digital_capture
;
2305 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *p
;
2306 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->dig_in_nid
;
2308 /* FIXME: do we need this for all Realtek codec models? */
2309 codec
->spdif_status_reset
= 1;
2312 if (spec
->no_analog
)
2315 /* If the use of more than one ADC is requested for the current
2316 * model, configure a second analog capture-only PCM.
2318 have_multi_adcs
= (spec
->num_adc_nids
> 1) &&
2319 !spec
->dyn_adc_switch
&& !spec
->auto_mic
&&
2320 (!spec
->input_mux
|| spec
->input_mux
->num_items
> 1);
2321 /* Additional Analaog capture for index #2 */
2322 if (spec
->alt_dac_nid
|| have_multi_adcs
) {
2323 codec
->num_pcms
= 3;
2324 info
= spec
->pcm_rec
+ 2;
2325 info
->name
= spec
->stream_name_analog
;
2326 if (spec
->alt_dac_nid
) {
2327 p
= spec
->stream_analog_alt_playback
;
2329 p
= &alc_pcm_analog_alt_playback
;
2330 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = *p
;
2331 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
2334 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] =
2335 alc_pcm_null_stream
;
2336 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= 0;
2338 if (have_multi_adcs
) {
2339 p
= spec
->stream_analog_alt_capture
;
2341 p
= &alc_pcm_analog_alt_capture
;
2342 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *p
;
2343 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
=
2345 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
=
2346 spec
->num_adc_nids
- 1;
2348 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
2349 alc_pcm_null_stream
;
2350 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= 0;
2357 static inline void alc_shutup(struct hda_codec
*codec
)
2359 struct alc_spec
*spec
= codec
->spec
;
2361 if (spec
&& spec
->shutup
)
2362 spec
->shutup(codec
);
2363 snd_hda_shutup_pins(codec
);
2366 static void alc_free_kctls(struct hda_codec
*codec
)
2368 struct alc_spec
*spec
= codec
->spec
;
2370 if (spec
->kctls
.list
) {
2371 struct snd_kcontrol_new
*kctl
= spec
->kctls
.list
;
2373 for (i
= 0; i
< spec
->kctls
.used
; i
++)
2374 kfree(kctl
[i
].name
);
2376 snd_array_free(&spec
->kctls
);
2379 static void alc_free_bind_ctls(struct hda_codec
*codec
)
2381 struct alc_spec
*spec
= codec
->spec
;
2382 if (spec
->bind_ctls
.list
) {
2383 struct hda_bind_ctls
**ctl
= spec
->bind_ctls
.list
;
2385 for (i
= 0; i
< spec
->bind_ctls
.used
; i
++)
2388 snd_array_free(&spec
->bind_ctls
);
2391 static void alc_free(struct hda_codec
*codec
)
2393 struct alc_spec
*spec
= codec
->spec
;
2399 alc_free_kctls(codec
);
2400 alc_free_bind_ctls(codec
);
2402 snd_hda_detach_beep_device(codec
);
2405 #ifdef CONFIG_SND_HDA_POWER_SAVE
2406 static void alc_power_eapd(struct hda_codec
*codec
)
2408 alc_auto_setup_eapd(codec
, false);
2411 static int alc_suspend(struct hda_codec
*codec
, pm_message_t state
)
2413 struct alc_spec
*spec
= codec
->spec
;
2415 if (spec
&& spec
->power_hook
)
2416 spec
->power_hook(codec
);
2422 static int alc_resume(struct hda_codec
*codec
)
2424 msleep(150); /* to avoid pop noise */
2425 codec
->patch_ops
.init(codec
);
2426 snd_hda_codec_resume_amp(codec
);
2427 snd_hda_codec_resume_cache(codec
);
2428 alc_inv_dmic_sync(codec
, true);
2429 hda_call_check_power_status(codec
, 0x01);
2436 static const struct hda_codec_ops alc_patch_ops
= {
2437 .build_controls
= alc_build_controls
,
2438 .build_pcms
= alc_build_pcms
,
2441 .unsol_event
= alc_unsol_event
,
2443 .resume
= alc_resume
,
2445 #ifdef CONFIG_SND_HDA_POWER_SAVE
2446 .suspend
= alc_suspend
,
2447 .check_power_status
= alc_check_power_status
,
2449 .reboot_notify
= alc_shutup
,
2452 /* replace the codec chip_name with the given string */
2453 static int alc_codec_rename(struct hda_codec
*codec
, const char *name
)
2455 kfree(codec
->chip_name
);
2456 codec
->chip_name
= kstrdup(name
, GFP_KERNEL
);
2457 if (!codec
->chip_name
) {
2465 * Rename codecs appropriately from COEF value
2467 struct alc_codec_rename_table
{
2468 unsigned int vendor_id
;
2469 unsigned short coef_mask
;
2470 unsigned short coef_bits
;
2474 static struct alc_codec_rename_table rename_tbl
[] = {
2475 { 0x10ec0269, 0xfff0, 0x3010, "ALC277" },
2476 { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" },
2477 { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" },
2478 { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" },
2479 { 0x10ec0269, 0xffff, 0xa023, "ALC259" },
2480 { 0x10ec0269, 0xffff, 0x6023, "ALC281X" },
2481 { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" },
2482 { 0x10ec0269, 0x00f0, 0x0030, "ALC269VD" },
2483 { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" },
2484 { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" },
2485 { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" },
2486 { 0x10ec0899, 0x2000, 0x2000, "ALC899" },
2487 { 0x10ec0892, 0xffff, 0x8020, "ALC661" },
2488 { 0x10ec0892, 0xffff, 0x8011, "ALC661" },
2489 { 0x10ec0892, 0xffff, 0x4011, "ALC656" },
2490 { } /* terminator */
2493 static int alc_codec_rename_from_preset(struct hda_codec
*codec
)
2495 const struct alc_codec_rename_table
*p
;
2497 for (p
= rename_tbl
; p
->vendor_id
; p
++) {
2498 if (p
->vendor_id
!= codec
->vendor_id
)
2500 if ((alc_get_coef0(codec
) & p
->coef_mask
) == p
->coef_bits
)
2501 return alc_codec_rename(codec
, p
->name
);
2507 * Automatic parse of I/O pins from the BIOS configuration
2512 ALC_CTL_WIDGET_MUTE
,
2517 static const struct snd_kcontrol_new alc_control_templates
[] = {
2518 HDA_CODEC_VOLUME(NULL
, 0, 0, 0),
2519 HDA_CODEC_MUTE(NULL
, 0, 0, 0),
2520 HDA_BIND_MUTE(NULL
, 0, 0, 0),
2521 HDA_BIND_VOL(NULL
, 0),
2522 HDA_BIND_SW(NULL
, 0),
2525 /* add dynamic controls */
2526 static int add_control(struct alc_spec
*spec
, int type
, const char *name
,
2527 int cidx
, unsigned long val
)
2529 struct snd_kcontrol_new
*knew
;
2531 knew
= alc_kcontrol_new(spec
);
2534 *knew
= alc_control_templates
[type
];
2535 knew
->name
= kstrdup(name
, GFP_KERNEL
);
2539 if (get_amp_nid_(val
))
2540 knew
->subdevice
= HDA_SUBDEV_AMP_FLAG
;
2541 knew
->private_value
= val
;
2545 static int add_control_with_pfx(struct alc_spec
*spec
, int type
,
2546 const char *pfx
, const char *dir
,
2547 const char *sfx
, int cidx
, unsigned long val
)
2550 snprintf(name
, sizeof(name
), "%s %s %s", pfx
, dir
, sfx
);
2551 return add_control(spec
, type
, name
, cidx
, val
);
2554 #define add_pb_vol_ctrl(spec, type, pfx, val) \
2555 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
2556 #define add_pb_sw_ctrl(spec, type, pfx, val) \
2557 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
2558 #define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
2559 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
2560 #define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
2561 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
2563 static const char * const channel_name
[4] = {
2564 "Front", "Surround", "CLFE", "Side"
2567 static const char *alc_get_line_out_pfx(struct alc_spec
*spec
, int ch
,
2568 bool can_be_master
, int *index
)
2570 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2573 if (cfg
->line_outs
== 1 && !spec
->multi_ios
&&
2574 !cfg
->hp_outs
&& !cfg
->speaker_outs
&& can_be_master
)
2577 switch (cfg
->line_out_type
) {
2578 case AUTO_PIN_SPEAKER_OUT
:
2579 if (cfg
->line_outs
== 1)
2581 if (cfg
->line_outs
== 2)
2582 return ch
? "Bass Speaker" : "Speaker";
2584 case AUTO_PIN_HP_OUT
:
2585 /* for multi-io case, only the primary out */
2586 if (ch
&& spec
->multi_ios
)
2591 if (cfg
->line_outs
== 1 && !spec
->multi_ios
)
2595 if (snd_BUG_ON(ch
>= ARRAY_SIZE(channel_name
)))
2598 return channel_name
[ch
];
2601 #ifdef CONFIG_SND_HDA_POWER_SAVE
2602 /* add the powersave loopback-list entry */
2603 static void add_loopback_list(struct alc_spec
*spec
, hda_nid_t mix
, int idx
)
2605 struct hda_amp_list
*list
;
2607 if (spec
->num_loopbacks
>= ARRAY_SIZE(spec
->loopback_list
) - 1)
2609 list
= spec
->loopback_list
+ spec
->num_loopbacks
;
2611 list
->dir
= HDA_INPUT
;
2613 spec
->num_loopbacks
++;
2614 spec
->loopback
.amplist
= spec
->loopback_list
;
2617 #define add_loopback_list(spec, mix, idx) /* NOP */
2620 /* create input playback/capture controls for the given pin */
2621 static int new_analog_input(struct alc_spec
*spec
, hda_nid_t pin
,
2622 const char *ctlname
, int ctlidx
,
2623 int idx
, hda_nid_t mix_nid
)
2627 err
= __add_pb_vol_ctrl(spec
, ALC_CTL_WIDGET_VOL
, ctlname
, ctlidx
,
2628 HDA_COMPOSE_AMP_VAL(mix_nid
, 3, idx
, HDA_INPUT
));
2631 err
= __add_pb_sw_ctrl(spec
, ALC_CTL_WIDGET_MUTE
, ctlname
, ctlidx
,
2632 HDA_COMPOSE_AMP_VAL(mix_nid
, 3, idx
, HDA_INPUT
));
2635 add_loopback_list(spec
, mix_nid
, idx
);
2639 static int alc_is_input_pin(struct hda_codec
*codec
, hda_nid_t nid
)
2641 unsigned int pincap
= snd_hda_query_pin_caps(codec
, nid
);
2642 return (pincap
& AC_PINCAP_IN
) != 0;
2645 /* Parse the codec tree and retrieve ADCs and corresponding capsrc MUXs */
2646 static int alc_auto_fill_adc_caps(struct hda_codec
*codec
)
2648 struct alc_spec
*spec
= codec
->spec
;
2650 hda_nid_t
*adc_nids
= spec
->private_adc_nids
;
2651 hda_nid_t
*cap_nids
= spec
->private_capsrc_nids
;
2652 int max_nums
= ARRAY_SIZE(spec
->private_adc_nids
);
2655 nid
= codec
->start_nid
;
2656 for (i
= 0; i
< codec
->num_nodes
; i
++, nid
++) {
2658 unsigned int caps
= get_wcaps(codec
, nid
);
2659 int type
= get_wcaps_type(caps
);
2661 if (type
!= AC_WID_AUD_IN
|| (caps
& AC_WCAP_DIGITAL
))
2663 adc_nids
[nums
] = nid
;
2664 cap_nids
[nums
] = nid
;
2668 type
= get_wcaps_type(get_wcaps(codec
, src
));
2669 if (type
== AC_WID_PIN
)
2671 if (type
== AC_WID_AUD_SEL
) {
2672 cap_nids
[nums
] = src
;
2675 n
= snd_hda_get_num_conns(codec
, src
);
2677 cap_nids
[nums
] = src
;
2681 if (snd_hda_get_connections(codec
, src
, &src
, 1) != 1)
2684 if (++nums
>= max_nums
)
2687 spec
->adc_nids
= spec
->private_adc_nids
;
2688 spec
->capsrc_nids
= spec
->private_capsrc_nids
;
2689 spec
->num_adc_nids
= nums
;
2693 /* create playback/capture controls for input pins */
2694 static int alc_auto_create_input_ctls(struct hda_codec
*codec
)
2696 struct alc_spec
*spec
= codec
->spec
;
2697 const struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2698 hda_nid_t mixer
= spec
->mixer_nid
;
2699 struct hda_input_mux
*imux
= &spec
->private_imux
[0];
2701 int i
, c
, err
, idx
, type_idx
= 0;
2702 const char *prev_label
= NULL
;
2704 num_adcs
= alc_auto_fill_adc_caps(codec
);
2708 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
2712 pin
= cfg
->inputs
[i
].pin
;
2713 if (!alc_is_input_pin(codec
, pin
))
2716 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
2717 if (spec
->shared_mic_hp
&& !strcmp(label
, "Misc"))
2718 label
= "Headphone Mic";
2719 if (prev_label
&& !strcmp(label
, prev_label
))
2726 idx
= get_connection_index(codec
, mixer
, pin
);
2728 err
= new_analog_input(spec
, pin
,
2736 for (c
= 0; c
< num_adcs
; c
++) {
2737 hda_nid_t cap
= get_capsrc(spec
, c
);
2738 idx
= get_connection_index(codec
, cap
, pin
);
2740 spec
->imux_pins
[imux
->num_items
] = pin
;
2741 snd_hda_add_imux_item(imux
, label
, idx
, NULL
);
2747 spec
->num_mux_defs
= 1;
2748 spec
->input_mux
= imux
;
2753 /* create a shared input with the headphone out */
2754 static int alc_auto_create_shared_input(struct hda_codec
*codec
)
2756 struct alc_spec
*spec
= codec
->spec
;
2757 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2758 unsigned int defcfg
;
2761 /* only one internal input pin? */
2762 if (cfg
->num_inputs
!= 1)
2764 defcfg
= snd_hda_codec_get_pincfg(codec
, cfg
->inputs
[0].pin
);
2765 if (snd_hda_get_input_pin_attr(defcfg
) != INPUT_PIN_ATTR_INT
)
2768 if (cfg
->hp_outs
== 1 && cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
)
2769 nid
= cfg
->hp_pins
[0]; /* OK, we have a single HP-out */
2770 else if (cfg
->line_outs
== 1 && cfg
->line_out_type
== AUTO_PIN_HP_OUT
)
2771 nid
= cfg
->line_out_pins
[0]; /* OK, we have a single line-out */
2773 return 0; /* both not available */
2775 if (!(snd_hda_query_pin_caps(codec
, nid
) & AC_PINCAP_IN
))
2776 return 0; /* no input */
2778 cfg
->inputs
[1].pin
= nid
;
2779 cfg
->inputs
[1].type
= AUTO_PIN_MIC
;
2780 cfg
->num_inputs
= 2;
2781 spec
->shared_mic_hp
= 1;
2782 snd_printdd("realtek: Enable shared I/O jack on NID 0x%x\n", nid
);
2786 static void alc_set_pin_output(struct hda_codec
*codec
, hda_nid_t nid
,
2787 unsigned int pin_type
)
2789 snd_hda_set_pin_ctl(codec
, nid
, pin_type
);
2791 if (nid_has_mute(codec
, nid
, HDA_OUTPUT
))
2792 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
2796 static int get_pin_type(int line_out_type
)
2798 if (line_out_type
== AUTO_PIN_HP_OUT
)
2804 static void alc_auto_init_analog_input(struct hda_codec
*codec
)
2806 struct alc_spec
*spec
= codec
->spec
;
2807 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2810 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
2811 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
2812 if (alc_is_input_pin(codec
, nid
)) {
2813 alc_set_input_pin(codec
, nid
, cfg
->inputs
[i
].type
);
2814 if (get_wcaps(codec
, nid
) & AC_WCAP_OUT_AMP
)
2815 snd_hda_codec_write(codec
, nid
, 0,
2816 AC_VERB_SET_AMP_GAIN_MUTE
,
2821 /* mute all loopback inputs */
2822 if (spec
->mixer_nid
) {
2823 int nums
= snd_hda_get_num_conns(codec
, spec
->mixer_nid
);
2824 for (i
= 0; i
< nums
; i
++)
2825 snd_hda_codec_write(codec
, spec
->mixer_nid
, 0,
2826 AC_VERB_SET_AMP_GAIN_MUTE
,
2831 /* convert from MIX nid to DAC */
2832 static hda_nid_t
alc_auto_mix_to_dac(struct hda_codec
*codec
, hda_nid_t nid
)
2837 if (get_wcaps_type(get_wcaps(codec
, nid
)) == AC_WID_AUD_OUT
)
2839 num
= snd_hda_get_connections(codec
, nid
, list
, ARRAY_SIZE(list
));
2840 for (i
= 0; i
< num
; i
++) {
2841 if (get_wcaps_type(get_wcaps(codec
, list
[i
])) == AC_WID_AUD_OUT
)
2847 /* go down to the selector widget before the mixer */
2848 static hda_nid_t
alc_go_down_to_selector(struct hda_codec
*codec
, hda_nid_t pin
)
2851 int num
= snd_hda_get_connections(codec
, pin
, srcs
,
2854 get_wcaps_type(get_wcaps(codec
, srcs
[0])) != AC_WID_AUD_SEL
)
2859 /* get MIX nid connected to the given pin targeted to DAC */
2860 static hda_nid_t
alc_auto_dac_to_mix(struct hda_codec
*codec
, hda_nid_t pin
,
2866 pin
= alc_go_down_to_selector(codec
, pin
);
2867 num
= snd_hda_get_connections(codec
, pin
, mix
, ARRAY_SIZE(mix
));
2868 for (i
= 0; i
< num
; i
++) {
2869 if (alc_auto_mix_to_dac(codec
, mix
[i
]) == dac
)
2875 /* select the connection from pin to DAC if needed */
2876 static int alc_auto_select_dac(struct hda_codec
*codec
, hda_nid_t pin
,
2882 pin
= alc_go_down_to_selector(codec
, pin
);
2883 num
= snd_hda_get_connections(codec
, pin
, mix
, ARRAY_SIZE(mix
));
2886 for (i
= 0; i
< num
; i
++) {
2887 if (alc_auto_mix_to_dac(codec
, mix
[i
]) == dac
) {
2888 snd_hda_codec_update_cache(codec
, pin
, 0,
2889 AC_VERB_SET_CONNECT_SEL
, i
);
2896 static bool alc_is_dac_already_used(struct hda_codec
*codec
, hda_nid_t nid
)
2898 struct alc_spec
*spec
= codec
->spec
;
2900 if (found_in_nid_list(nid
, spec
->multiout
.dac_nids
,
2901 ARRAY_SIZE(spec
->private_dac_nids
)) ||
2902 found_in_nid_list(nid
, spec
->multiout
.hp_out_nid
,
2903 ARRAY_SIZE(spec
->multiout
.hp_out_nid
)) ||
2904 found_in_nid_list(nid
, spec
->multiout
.extra_out_nid
,
2905 ARRAY_SIZE(spec
->multiout
.extra_out_nid
)))
2907 for (i
= 0; i
< spec
->multi_ios
; i
++) {
2908 if (spec
->multi_io
[i
].dac
== nid
)
2914 /* look for an empty DAC slot */
2915 static hda_nid_t
alc_auto_look_for_dac(struct hda_codec
*codec
, hda_nid_t pin
)
2920 pin
= alc_go_down_to_selector(codec
, pin
);
2921 num
= snd_hda_get_connections(codec
, pin
, srcs
, ARRAY_SIZE(srcs
));
2922 for (i
= 0; i
< num
; i
++) {
2923 hda_nid_t nid
= alc_auto_mix_to_dac(codec
, srcs
[i
]);
2926 if (!alc_is_dac_already_used(codec
, nid
))
2932 /* check whether the DAC is reachable from the pin */
2933 static bool alc_auto_is_dac_reachable(struct hda_codec
*codec
,
2934 hda_nid_t pin
, hda_nid_t dac
)
2941 pin
= alc_go_down_to_selector(codec
, pin
);
2942 num
= snd_hda_get_connections(codec
, pin
, srcs
, ARRAY_SIZE(srcs
));
2943 for (i
= 0; i
< num
; i
++) {
2944 hda_nid_t nid
= alc_auto_mix_to_dac(codec
, srcs
[i
]);
2951 static hda_nid_t
get_dac_if_single(struct hda_codec
*codec
, hda_nid_t pin
)
2953 struct alc_spec
*spec
= codec
->spec
;
2954 hda_nid_t sel
= alc_go_down_to_selector(codec
, pin
);
2955 hda_nid_t nid
, nid_found
, srcs
[5];
2956 int i
, num
= snd_hda_get_connections(codec
, sel
, srcs
,
2959 return alc_auto_look_for_dac(codec
, pin
);
2961 for (i
= 0; i
< num
; i
++) {
2962 if (srcs
[i
] == spec
->mixer_nid
)
2964 nid
= alc_auto_mix_to_dac(codec
, srcs
[i
]);
2965 if (nid
&& !alc_is_dac_already_used(codec
, nid
)) {
2974 /* mark up volume and mute control NIDs: used during badness parsing and
2975 * at creating actual controls
2977 static inline unsigned int get_ctl_pos(unsigned int data
)
2979 hda_nid_t nid
= get_amp_nid_(data
);
2981 if (snd_BUG_ON(nid
>= MAX_VOL_NIDS
))
2983 dir
= get_amp_direction_(data
);
2984 return (nid
<< 1) | dir
;
2987 #define is_ctl_used(bits, data) \
2988 test_bit(get_ctl_pos(data), bits)
2989 #define mark_ctl_usage(bits, data) \
2990 set_bit(get_ctl_pos(data), bits)
2992 static void clear_vol_marks(struct hda_codec
*codec
)
2994 struct alc_spec
*spec
= codec
->spec
;
2995 memset(spec
->vol_ctls
, 0, sizeof(spec
->vol_ctls
));
2996 memset(spec
->sw_ctls
, 0, sizeof(spec
->sw_ctls
));
2999 /* badness definition */
3001 /* No primary DAC is found for the main output */
3002 BAD_NO_PRIMARY_DAC
= 0x10000,
3003 /* No DAC is found for the extra output */
3004 BAD_NO_DAC
= 0x4000,
3005 /* No possible multi-ios */
3006 BAD_MULTI_IO
= 0x103,
3007 /* No individual DAC for extra output */
3008 BAD_NO_EXTRA_DAC
= 0x102,
3009 /* No individual DAC for extra surrounds */
3010 BAD_NO_EXTRA_SURR_DAC
= 0x101,
3011 /* Primary DAC shared with main surrounds */
3012 BAD_SHARED_SURROUND
= 0x100,
3013 /* Primary DAC shared with main CLFE */
3014 BAD_SHARED_CLFE
= 0x10,
3015 /* Primary DAC shared with extra surrounds */
3016 BAD_SHARED_EXTRA_SURROUND
= 0x10,
3017 /* Volume widget is shared */
3018 BAD_SHARED_VOL
= 0x10,
3021 static hda_nid_t
alc_look_for_out_mute_nid(struct hda_codec
*codec
,
3022 hda_nid_t pin
, hda_nid_t dac
);
3023 static hda_nid_t
alc_look_for_out_vol_nid(struct hda_codec
*codec
,
3024 hda_nid_t pin
, hda_nid_t dac
);
3026 static int eval_shared_vol_badness(struct hda_codec
*codec
, hda_nid_t pin
,
3029 struct alc_spec
*spec
= codec
->spec
;
3034 nid
= alc_look_for_out_vol_nid(codec
, pin
, dac
);
3036 val
= HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
);
3037 if (is_ctl_used(spec
->vol_ctls
, nid
))
3038 badness
+= BAD_SHARED_VOL
;
3040 mark_ctl_usage(spec
->vol_ctls
, val
);
3042 badness
+= BAD_SHARED_VOL
;
3043 nid
= alc_look_for_out_mute_nid(codec
, pin
, dac
);
3045 unsigned int wid_type
= get_wcaps_type(get_wcaps(codec
, nid
));
3046 if (wid_type
== AC_WID_PIN
|| wid_type
== AC_WID_AUD_OUT
)
3047 val
= HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
);
3049 val
= HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_INPUT
);
3050 if (is_ctl_used(spec
->sw_ctls
, val
))
3051 badness
+= BAD_SHARED_VOL
;
3053 mark_ctl_usage(spec
->sw_ctls
, val
);
3055 badness
+= BAD_SHARED_VOL
;
3059 struct badness_table
{
3060 int no_primary_dac
; /* no primary DAC */
3061 int no_dac
; /* no secondary DACs */
3062 int shared_primary
; /* primary DAC is shared with main output */
3063 int shared_surr
; /* secondary DAC shared with main or primary */
3064 int shared_clfe
; /* third DAC shared with main or primary */
3065 int shared_surr_main
; /* secondary DAC sahred with main/DAC0 */
3068 static struct badness_table main_out_badness
= {
3069 .no_primary_dac
= BAD_NO_PRIMARY_DAC
,
3070 .no_dac
= BAD_NO_DAC
,
3071 .shared_primary
= BAD_NO_PRIMARY_DAC
,
3072 .shared_surr
= BAD_SHARED_SURROUND
,
3073 .shared_clfe
= BAD_SHARED_CLFE
,
3074 .shared_surr_main
= BAD_SHARED_SURROUND
,
3077 static struct badness_table extra_out_badness
= {
3078 .no_primary_dac
= BAD_NO_DAC
,
3079 .no_dac
= BAD_NO_DAC
,
3080 .shared_primary
= BAD_NO_EXTRA_DAC
,
3081 .shared_surr
= BAD_SHARED_EXTRA_SURROUND
,
3082 .shared_clfe
= BAD_SHARED_EXTRA_SURROUND
,
3083 .shared_surr_main
= BAD_NO_EXTRA_SURR_DAC
,
3086 /* try to assign DACs to pins and return the resultant badness */
3087 static int alc_auto_fill_dacs(struct hda_codec
*codec
, int num_outs
,
3088 const hda_nid_t
*pins
, hda_nid_t
*dacs
,
3089 const struct badness_table
*bad
)
3091 struct alc_spec
*spec
= codec
->spec
;
3092 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3100 for (i
= 0; i
< num_outs
; i
++) {
3101 hda_nid_t pin
= pins
[i
];
3103 dacs
[i
] = alc_auto_look_for_dac(codec
, pin
);
3104 if (!dacs
[i
] && !i
) {
3105 for (j
= 1; j
< num_outs
; j
++) {
3106 if (alc_auto_is_dac_reachable(codec
, pin
, dacs
[j
])) {
3115 if (alc_auto_is_dac_reachable(codec
, pin
, dacs
[0]))
3117 else if (cfg
->line_outs
> i
&&
3118 alc_auto_is_dac_reachable(codec
, pin
,
3119 spec
->private_dac_nids
[i
]))
3120 dac
= spec
->private_dac_nids
[i
];
3123 badness
+= bad
->shared_primary
;
3125 badness
+= bad
->shared_surr
;
3127 badness
+= bad
->shared_clfe
;
3128 } else if (alc_auto_is_dac_reachable(codec
, pin
,
3129 spec
->private_dac_nids
[0])) {
3130 dac
= spec
->private_dac_nids
[0];
3131 badness
+= bad
->shared_surr_main
;
3133 badness
+= bad
->no_primary_dac
;
3135 badness
+= bad
->no_dac
;
3138 badness
+= eval_shared_vol_badness(codec
, pin
, dac
);
3144 static int alc_auto_fill_multi_ios(struct hda_codec
*codec
,
3145 hda_nid_t reference_pin
,
3146 bool hardwired
, int offset
);
3148 static bool alc_map_singles(struct hda_codec
*codec
, int outs
,
3149 const hda_nid_t
*pins
, hda_nid_t
*dacs
)
3153 for (i
= 0; i
< outs
; i
++) {
3156 dacs
[i
] = get_dac_if_single(codec
, pins
[i
]);
3163 /* fill in the dac_nids table from the parsed pin configuration */
3164 static int fill_and_eval_dacs(struct hda_codec
*codec
,
3165 bool fill_hardwired
,
3166 bool fill_mio_first
)
3168 struct alc_spec
*spec
= codec
->spec
;
3169 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3170 int i
, err
, badness
;
3172 /* set num_dacs once to full for alc_auto_look_for_dac() */
3173 spec
->multiout
.num_dacs
= cfg
->line_outs
;
3174 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
3175 memset(spec
->private_dac_nids
, 0, sizeof(spec
->private_dac_nids
));
3176 memset(spec
->multiout
.hp_out_nid
, 0, sizeof(spec
->multiout
.hp_out_nid
));
3177 memset(spec
->multiout
.extra_out_nid
, 0, sizeof(spec
->multiout
.extra_out_nid
));
3178 spec
->multi_ios
= 0;
3179 clear_vol_marks(codec
);
3182 /* fill hard-wired DACs first */
3183 if (fill_hardwired
) {
3186 mapped
= alc_map_singles(codec
, cfg
->line_outs
,
3188 spec
->private_dac_nids
);
3189 mapped
|= alc_map_singles(codec
, cfg
->hp_outs
,
3191 spec
->multiout
.hp_out_nid
);
3192 mapped
|= alc_map_singles(codec
, cfg
->speaker_outs
,
3194 spec
->multiout
.extra_out_nid
);
3195 if (fill_mio_first
&& cfg
->line_outs
== 1 &&
3196 cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
) {
3197 err
= alc_auto_fill_multi_ios(codec
, cfg
->line_out_pins
[0], true, 0);
3204 badness
+= alc_auto_fill_dacs(codec
, cfg
->line_outs
, cfg
->line_out_pins
,
3205 spec
->private_dac_nids
,
3208 /* re-count num_dacs and squash invalid entries */
3209 spec
->multiout
.num_dacs
= 0;
3210 for (i
= 0; i
< cfg
->line_outs
; i
++) {
3211 if (spec
->private_dac_nids
[i
])
3212 spec
->multiout
.num_dacs
++;
3214 memmove(spec
->private_dac_nids
+ i
,
3215 spec
->private_dac_nids
+ i
+ 1,
3216 sizeof(hda_nid_t
) * (cfg
->line_outs
- i
- 1));
3217 spec
->private_dac_nids
[cfg
->line_outs
- 1] = 0;
3221 if (fill_mio_first
&&
3222 cfg
->line_outs
== 1 && cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
) {
3223 /* try to fill multi-io first */
3224 err
= alc_auto_fill_multi_ios(codec
, cfg
->line_out_pins
[0], false, 0);
3227 /* we don't count badness at this stage yet */
3230 if (cfg
->line_out_type
!= AUTO_PIN_HP_OUT
) {
3231 err
= alc_auto_fill_dacs(codec
, cfg
->hp_outs
, cfg
->hp_pins
,
3232 spec
->multiout
.hp_out_nid
,
3233 &extra_out_badness
);
3238 if (cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
) {
3239 err
= alc_auto_fill_dacs(codec
, cfg
->speaker_outs
,
3241 spec
->multiout
.extra_out_nid
,
3242 &extra_out_badness
);
3247 if (cfg
->line_outs
== 1 && cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
) {
3248 err
= alc_auto_fill_multi_ios(codec
, cfg
->line_out_pins
[0], false, 0);
3253 if (cfg
->hp_outs
&& cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
) {
3254 /* try multi-ios with HP + inputs */
3256 if (cfg
->line_outs
>= 3)
3258 err
= alc_auto_fill_multi_ios(codec
, cfg
->hp_pins
[0], false,
3265 if (spec
->multi_ios
== 2) {
3266 for (i
= 0; i
< 2; i
++)
3267 spec
->private_dac_nids
[spec
->multiout
.num_dacs
++] =
3268 spec
->multi_io
[i
].dac
;
3269 spec
->ext_channel_count
= 2;
3270 } else if (spec
->multi_ios
) {
3271 spec
->multi_ios
= 0;
3272 badness
+= BAD_MULTI_IO
;
3278 #define DEBUG_BADNESS
3280 #ifdef DEBUG_BADNESS
3281 #define debug_badness snd_printdd
3283 #define debug_badness(...)
3286 static void debug_show_configs(struct alc_spec
*spec
, struct auto_pin_cfg
*cfg
)
3288 debug_badness("multi_outs = %x/%x/%x/%x : %x/%x/%x/%x\n",
3289 cfg
->line_out_pins
[0], cfg
->line_out_pins
[1],
3290 cfg
->line_out_pins
[2], cfg
->line_out_pins
[2],
3291 spec
->multiout
.dac_nids
[0],
3292 spec
->multiout
.dac_nids
[1],
3293 spec
->multiout
.dac_nids
[2],
3294 spec
->multiout
.dac_nids
[3]);
3295 if (spec
->multi_ios
> 0)
3296 debug_badness("multi_ios(%d) = %x/%x : %x/%x\n",
3298 spec
->multi_io
[0].pin
, spec
->multi_io
[1].pin
,
3299 spec
->multi_io
[0].dac
, spec
->multi_io
[1].dac
);
3300 debug_badness("hp_outs = %x/%x/%x/%x : %x/%x/%x/%x\n",
3301 cfg
->hp_pins
[0], cfg
->hp_pins
[1],
3302 cfg
->hp_pins
[2], cfg
->hp_pins
[2],
3303 spec
->multiout
.hp_out_nid
[0],
3304 spec
->multiout
.hp_out_nid
[1],
3305 spec
->multiout
.hp_out_nid
[2],
3306 spec
->multiout
.hp_out_nid
[3]);
3307 debug_badness("spk_outs = %x/%x/%x/%x : %x/%x/%x/%x\n",
3308 cfg
->speaker_pins
[0], cfg
->speaker_pins
[1],
3309 cfg
->speaker_pins
[2], cfg
->speaker_pins
[3],
3310 spec
->multiout
.extra_out_nid
[0],
3311 spec
->multiout
.extra_out_nid
[1],
3312 spec
->multiout
.extra_out_nid
[2],
3313 spec
->multiout
.extra_out_nid
[3]);
3316 static int alc_auto_fill_dac_nids(struct hda_codec
*codec
)
3318 struct alc_spec
*spec
= codec
->spec
;
3319 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3320 struct auto_pin_cfg
*best_cfg
;
3321 int best_badness
= INT_MAX
;
3323 bool fill_hardwired
= true, fill_mio_first
= true;
3324 bool best_wired
= true, best_mio
= true;
3325 bool hp_spk_swapped
= false;
3327 best_cfg
= kmalloc(sizeof(*best_cfg
), GFP_KERNEL
);
3333 badness
= fill_and_eval_dacs(codec
, fill_hardwired
,
3339 debug_badness("==> lo_type=%d, wired=%d, mio=%d, badness=0x%x\n",
3340 cfg
->line_out_type
, fill_hardwired
, fill_mio_first
,
3342 debug_show_configs(spec
, cfg
);
3343 if (badness
< best_badness
) {
3344 best_badness
= badness
;
3346 best_wired
= fill_hardwired
;
3347 best_mio
= fill_mio_first
;
3351 fill_mio_first
= !fill_mio_first
;
3352 if (!fill_mio_first
)
3354 fill_hardwired
= !fill_hardwired
;
3355 if (!fill_hardwired
)
3359 hp_spk_swapped
= true;
3360 if (cfg
->speaker_outs
> 0 &&
3361 cfg
->line_out_type
== AUTO_PIN_HP_OUT
) {
3362 cfg
->hp_outs
= cfg
->line_outs
;
3363 memcpy(cfg
->hp_pins
, cfg
->line_out_pins
,
3364 sizeof(cfg
->hp_pins
));
3365 cfg
->line_outs
= cfg
->speaker_outs
;
3366 memcpy(cfg
->line_out_pins
, cfg
->speaker_pins
,
3367 sizeof(cfg
->speaker_pins
));
3368 cfg
->speaker_outs
= 0;
3369 memset(cfg
->speaker_pins
, 0, sizeof(cfg
->speaker_pins
));
3370 cfg
->line_out_type
= AUTO_PIN_SPEAKER_OUT
;
3371 fill_hardwired
= true;
3374 if (cfg
->hp_outs
> 0 &&
3375 cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
) {
3376 cfg
->speaker_outs
= cfg
->line_outs
;
3377 memcpy(cfg
->speaker_pins
, cfg
->line_out_pins
,
3378 sizeof(cfg
->speaker_pins
));
3379 cfg
->line_outs
= cfg
->hp_outs
;
3380 memcpy(cfg
->line_out_pins
, cfg
->hp_pins
,
3381 sizeof(cfg
->hp_pins
));
3383 memset(cfg
->hp_pins
, 0, sizeof(cfg
->hp_pins
));
3384 cfg
->line_out_type
= AUTO_PIN_HP_OUT
;
3385 fill_hardwired
= true;
3393 fill_and_eval_dacs(codec
, best_wired
, best_mio
);
3395 debug_badness("==> Best config: lo_type=%d, wired=%d, mio=%d\n",
3396 cfg
->line_out_type
, best_wired
, best_mio
);
3397 debug_show_configs(spec
, cfg
);
3399 if (cfg
->line_out_pins
[0])
3401 alc_look_for_out_vol_nid(codec
, cfg
->line_out_pins
[0],
3402 spec
->multiout
.dac_nids
[0]);
3404 /* clear the bitmap flags for creating controls */
3405 clear_vol_marks(codec
);
3410 static int alc_auto_add_vol_ctl(struct hda_codec
*codec
,
3411 const char *pfx
, int cidx
,
3412 hda_nid_t nid
, unsigned int chs
)
3414 struct alc_spec
*spec
= codec
->spec
;
3418 val
= HDA_COMPOSE_AMP_VAL(nid
, chs
, 0, HDA_OUTPUT
);
3419 if (is_ctl_used(spec
->vol_ctls
, val
) && chs
!= 2) /* exclude LFE */
3421 mark_ctl_usage(spec
->vol_ctls
, val
);
3422 return __add_pb_vol_ctrl(codec
->spec
, ALC_CTL_WIDGET_VOL
, pfx
, cidx
,
3426 static int alc_auto_add_stereo_vol(struct hda_codec
*codec
,
3427 const char *pfx
, int cidx
,
3431 if (get_wcaps(codec
, nid
) & AC_WCAP_STEREO
)
3433 return alc_auto_add_vol_ctl(codec
, pfx
, cidx
, nid
, chs
);
3436 /* create a mute-switch for the given mixer widget;
3437 * if it has multiple sources (e.g. DAC and loopback), create a bind-mute
3439 static int alc_auto_add_sw_ctl(struct hda_codec
*codec
,
3440 const char *pfx
, int cidx
,
3441 hda_nid_t nid
, unsigned int chs
)
3443 struct alc_spec
*spec
= codec
->spec
;
3449 wid_type
= get_wcaps_type(get_wcaps(codec
, nid
));
3450 if (wid_type
== AC_WID_PIN
|| wid_type
== AC_WID_AUD_OUT
) {
3451 type
= ALC_CTL_WIDGET_MUTE
;
3452 val
= HDA_COMPOSE_AMP_VAL(nid
, chs
, 0, HDA_OUTPUT
);
3453 } else if (snd_hda_get_num_conns(codec
, nid
) == 1) {
3454 type
= ALC_CTL_WIDGET_MUTE
;
3455 val
= HDA_COMPOSE_AMP_VAL(nid
, chs
, 0, HDA_INPUT
);
3457 type
= ALC_CTL_BIND_MUTE
;
3458 val
= HDA_COMPOSE_AMP_VAL(nid
, chs
, 2, HDA_INPUT
);
3460 if (is_ctl_used(spec
->sw_ctls
, val
) && chs
!= 2) /* exclude LFE */
3462 mark_ctl_usage(spec
->sw_ctls
, val
);
3463 return __add_pb_sw_ctrl(codec
->spec
, type
, pfx
, cidx
, val
);
3466 static int alc_auto_add_stereo_sw(struct hda_codec
*codec
, const char *pfx
,
3467 int cidx
, hda_nid_t nid
)
3470 if (get_wcaps(codec
, nid
) & AC_WCAP_STEREO
)
3472 return alc_auto_add_sw_ctl(codec
, pfx
, cidx
, nid
, chs
);
3475 static hda_nid_t
alc_look_for_out_mute_nid(struct hda_codec
*codec
,
3476 hda_nid_t pin
, hda_nid_t dac
)
3478 hda_nid_t mix
= alc_auto_dac_to_mix(codec
, pin
, dac
);
3479 if (nid_has_mute(codec
, pin
, HDA_OUTPUT
))
3481 else if (mix
&& nid_has_mute(codec
, mix
, HDA_INPUT
))
3483 else if (nid_has_mute(codec
, dac
, HDA_OUTPUT
))
3488 static hda_nid_t
alc_look_for_out_vol_nid(struct hda_codec
*codec
,
3489 hda_nid_t pin
, hda_nid_t dac
)
3491 hda_nid_t mix
= alc_auto_dac_to_mix(codec
, pin
, dac
);
3492 if (nid_has_volume(codec
, dac
, HDA_OUTPUT
))
3494 else if (nid_has_volume(codec
, mix
, HDA_OUTPUT
))
3496 else if (nid_has_volume(codec
, pin
, HDA_OUTPUT
))
3501 /* add playback controls from the parsed DAC table */
3502 static int alc_auto_create_multi_out_ctls(struct hda_codec
*codec
,
3503 const struct auto_pin_cfg
*cfg
)
3505 struct alc_spec
*spec
= codec
->spec
;
3506 int i
, err
, noutputs
;
3508 noutputs
= cfg
->line_outs
;
3509 if (spec
->multi_ios
> 0 && cfg
->line_outs
< 3)
3510 noutputs
+= spec
->multi_ios
;
3512 for (i
= 0; i
< noutputs
; i
++) {
3518 dac
= spec
->multiout
.dac_nids
[i
];
3521 if (i
>= cfg
->line_outs
) {
3522 pin
= spec
->multi_io
[i
- 1].pin
;
3524 name
= channel_name
[i
];
3526 pin
= cfg
->line_out_pins
[i
];
3527 name
= alc_get_line_out_pfx(spec
, i
, true, &index
);
3530 sw
= alc_look_for_out_mute_nid(codec
, pin
, dac
);
3531 vol
= alc_look_for_out_vol_nid(codec
, pin
, dac
);
3532 if (!name
|| !strcmp(name
, "CLFE")) {
3534 err
= alc_auto_add_vol_ctl(codec
, "Center", 0, vol
, 1);
3537 err
= alc_auto_add_vol_ctl(codec
, "LFE", 0, vol
, 2);
3540 err
= alc_auto_add_sw_ctl(codec
, "Center", 0, sw
, 1);
3543 err
= alc_auto_add_sw_ctl(codec
, "LFE", 0, sw
, 2);
3547 err
= alc_auto_add_stereo_vol(codec
, name
, index
, vol
);
3550 err
= alc_auto_add_stereo_sw(codec
, name
, index
, sw
);
3558 static int alc_auto_create_extra_out(struct hda_codec
*codec
, hda_nid_t pin
,
3559 hda_nid_t dac
, const char *pfx
,
3562 struct alc_spec
*spec
= codec
->spec
;
3568 /* the corresponding DAC is already occupied */
3569 if (!(get_wcaps(codec
, pin
) & AC_WCAP_OUT_AMP
))
3570 return 0; /* no way */
3571 /* create a switch only */
3572 val
= HDA_COMPOSE_AMP_VAL(pin
, 3, 0, HDA_OUTPUT
);
3573 if (is_ctl_used(spec
->sw_ctls
, val
))
3574 return 0; /* already created */
3575 mark_ctl_usage(spec
->sw_ctls
, val
);
3576 return __add_pb_sw_ctrl(spec
, ALC_CTL_WIDGET_MUTE
, pfx
, cidx
, val
);
3579 sw
= alc_look_for_out_mute_nid(codec
, pin
, dac
);
3580 vol
= alc_look_for_out_vol_nid(codec
, pin
, dac
);
3581 err
= alc_auto_add_stereo_vol(codec
, pfx
, cidx
, vol
);
3584 err
= alc_auto_add_stereo_sw(codec
, pfx
, cidx
, sw
);
3590 static struct hda_bind_ctls
*new_bind_ctl(struct hda_codec
*codec
,
3592 struct hda_ctl_ops
*ops
)
3594 struct alc_spec
*spec
= codec
->spec
;
3595 struct hda_bind_ctls
**ctlp
, *ctl
;
3596 snd_array_init(&spec
->bind_ctls
, sizeof(ctl
), 8);
3597 ctlp
= snd_array_new(&spec
->bind_ctls
);
3600 ctl
= kzalloc(sizeof(*ctl
) + sizeof(long) * (nums
+ 1), GFP_KERNEL
);
3607 /* add playback controls for speaker and HP outputs */
3608 static int alc_auto_create_extra_outs(struct hda_codec
*codec
, int num_pins
,
3609 const hda_nid_t
*pins
,
3610 const hda_nid_t
*dacs
,
3613 struct alc_spec
*spec
= codec
->spec
;
3614 struct hda_bind_ctls
*ctl
;
3618 if (!num_pins
|| !pins
[0])
3621 if (num_pins
== 1) {
3622 hda_nid_t dac
= *dacs
;
3624 dac
= spec
->multiout
.dac_nids
[0];
3625 return alc_auto_create_extra_out(codec
, *pins
, dac
, pfx
, 0);
3628 for (i
= 0; i
< num_pins
; i
++) {
3630 if (dacs
[num_pins
- 1])
3631 dac
= dacs
[i
]; /* with individual volumes */
3634 if (num_pins
== 2 && i
== 1 && !strcmp(pfx
, "Speaker")) {
3635 err
= alc_auto_create_extra_out(codec
, pins
[i
], dac
,
3637 } else if (num_pins
>= 3) {
3638 snprintf(name
, sizeof(name
), "%s %s",
3639 pfx
, channel_name
[i
]);
3640 err
= alc_auto_create_extra_out(codec
, pins
[i
], dac
,
3643 err
= alc_auto_create_extra_out(codec
, pins
[i
], dac
,
3649 if (dacs
[num_pins
- 1])
3652 /* Let's create a bind-controls for volumes */
3653 ctl
= new_bind_ctl(codec
, num_pins
, &snd_hda_bind_vol
);
3657 for (i
= 0; i
< num_pins
; i
++) {
3659 if (!pins
[i
] || !dacs
[i
])
3661 vol
= alc_look_for_out_vol_nid(codec
, pins
[i
], dacs
[i
]);
3664 HDA_COMPOSE_AMP_VAL(vol
, 3, 0, HDA_OUTPUT
);
3667 snprintf(name
, sizeof(name
), "%s Playback Volume", pfx
);
3668 err
= add_control(spec
, ALC_CTL_BIND_VOL
, name
, 0, (long)ctl
);
3675 static int alc_auto_create_hp_out(struct hda_codec
*codec
)
3677 struct alc_spec
*spec
= codec
->spec
;
3678 return alc_auto_create_extra_outs(codec
, spec
->autocfg
.hp_outs
,
3679 spec
->autocfg
.hp_pins
,
3680 spec
->multiout
.hp_out_nid
,
3684 static int alc_auto_create_speaker_out(struct hda_codec
*codec
)
3686 struct alc_spec
*spec
= codec
->spec
;
3687 return alc_auto_create_extra_outs(codec
, spec
->autocfg
.speaker_outs
,
3688 spec
->autocfg
.speaker_pins
,
3689 spec
->multiout
.extra_out_nid
,
3693 static void alc_auto_set_output_and_unmute(struct hda_codec
*codec
,
3694 hda_nid_t pin
, int pin_type
,
3698 hda_nid_t nid
, mix
= 0;
3699 hda_nid_t srcs
[HDA_MAX_CONNECTIONS
];
3701 alc_set_pin_output(codec
, pin
, pin_type
);
3702 nid
= alc_go_down_to_selector(codec
, pin
);
3703 num
= snd_hda_get_connections(codec
, nid
, srcs
, ARRAY_SIZE(srcs
));
3704 for (i
= 0; i
< num
; i
++) {
3705 if (alc_auto_mix_to_dac(codec
, srcs
[i
]) != dac
)
3713 /* need the manual connection? */
3715 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_CONNECT_SEL
, i
);
3716 /* unmute mixer widget inputs */
3717 if (nid_has_mute(codec
, mix
, HDA_INPUT
)) {
3718 snd_hda_codec_write(codec
, mix
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3720 snd_hda_codec_write(codec
, mix
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3723 /* initialize volume */
3724 nid
= alc_look_for_out_vol_nid(codec
, pin
, dac
);
3726 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3729 /* unmute DAC if it's not assigned to a mixer */
3730 nid
= alc_look_for_out_mute_nid(codec
, pin
, dac
);
3731 if (nid
== mix
&& nid_has_mute(codec
, dac
, HDA_OUTPUT
))
3732 snd_hda_codec_write(codec
, dac
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3736 static void alc_auto_init_multi_out(struct hda_codec
*codec
)
3738 struct alc_spec
*spec
= codec
->spec
;
3739 int pin_type
= get_pin_type(spec
->autocfg
.line_out_type
);
3742 for (i
= 0; i
<= HDA_SIDE
; i
++) {
3743 hda_nid_t nid
= spec
->autocfg
.line_out_pins
[i
];
3745 alc_auto_set_output_and_unmute(codec
, nid
, pin_type
,
3746 spec
->multiout
.dac_nids
[i
]);
3750 static void alc_auto_init_extra_out(struct hda_codec
*codec
)
3752 struct alc_spec
*spec
= codec
->spec
;
3756 for (i
= 0; i
< spec
->autocfg
.hp_outs
; i
++) {
3757 if (spec
->autocfg
.line_out_type
== AUTO_PIN_HP_OUT
)
3759 pin
= spec
->autocfg
.hp_pins
[i
];
3762 dac
= spec
->multiout
.hp_out_nid
[i
];
3764 if (i
> 0 && spec
->multiout
.hp_out_nid
[0])
3765 dac
= spec
->multiout
.hp_out_nid
[0];
3767 dac
= spec
->multiout
.dac_nids
[0];
3769 alc_auto_set_output_and_unmute(codec
, pin
, PIN_HP
, dac
);
3771 for (i
= 0; i
< spec
->autocfg
.speaker_outs
; i
++) {
3772 if (spec
->autocfg
.line_out_type
== AUTO_PIN_SPEAKER_OUT
)
3774 pin
= spec
->autocfg
.speaker_pins
[i
];
3777 dac
= spec
->multiout
.extra_out_nid
[i
];
3779 if (i
> 0 && spec
->multiout
.extra_out_nid
[0])
3780 dac
= spec
->multiout
.extra_out_nid
[0];
3782 dac
= spec
->multiout
.dac_nids
[0];
3784 alc_auto_set_output_and_unmute(codec
, pin
, PIN_OUT
, dac
);
3788 /* check whether the given pin can be a multi-io pin */
3789 static bool can_be_multiio_pin(struct hda_codec
*codec
,
3790 unsigned int location
, hda_nid_t nid
)
3792 unsigned int defcfg
, caps
;
3794 defcfg
= snd_hda_codec_get_pincfg(codec
, nid
);
3795 if (get_defcfg_connect(defcfg
) != AC_JACK_PORT_COMPLEX
)
3797 if (location
&& get_defcfg_location(defcfg
) != location
)
3799 caps
= snd_hda_query_pin_caps(codec
, nid
);
3800 if (!(caps
& AC_PINCAP_OUT
))
3808 * When hardwired is set, try to fill ony hardwired pins, and returns
3809 * zero if any pins are filled, non-zero if nothing found.
3810 * When hardwired is off, try to fill possible input pins, and returns
3811 * the badness value.
3813 static int alc_auto_fill_multi_ios(struct hda_codec
*codec
,
3814 hda_nid_t reference_pin
,
3815 bool hardwired
, int offset
)
3817 struct alc_spec
*spec
= codec
->spec
;
3818 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3819 int type
, i
, j
, dacs
, num_pins
, old_pins
;
3820 unsigned int defcfg
= snd_hda_codec_get_pincfg(codec
, reference_pin
);
3821 unsigned int location
= get_defcfg_location(defcfg
);
3824 old_pins
= spec
->multi_ios
;
3829 for (type
= AUTO_PIN_LINE_IN
; type
>= AUTO_PIN_MIC
; type
--) {
3830 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3831 if (cfg
->inputs
[i
].type
!= type
)
3833 if (can_be_multiio_pin(codec
, location
,
3834 cfg
->inputs
[i
].pin
))
3841 dacs
= spec
->multiout
.num_dacs
;
3842 for (type
= AUTO_PIN_LINE_IN
; type
>= AUTO_PIN_MIC
; type
--) {
3843 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3844 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
3847 if (cfg
->inputs
[i
].type
!= type
)
3849 if (!can_be_multiio_pin(codec
, location
, nid
))
3851 for (j
= 0; j
< spec
->multi_ios
; j
++) {
3852 if (nid
== spec
->multi_io
[j
].pin
)
3855 if (j
< spec
->multi_ios
)
3858 if (offset
&& offset
+ spec
->multi_ios
< dacs
) {
3859 dac
= spec
->private_dac_nids
[offset
+ spec
->multi_ios
];
3860 if (!alc_auto_is_dac_reachable(codec
, nid
, dac
))
3864 dac
= get_dac_if_single(codec
, nid
);
3866 dac
= alc_auto_look_for_dac(codec
, nid
);
3871 spec
->multi_io
[spec
->multi_ios
].pin
= nid
;
3872 spec
->multi_io
[spec
->multi_ios
].dac
= dac
;
3874 if (spec
->multi_ios
>= 2)
3880 badness
= BAD_MULTI_IO
;
3881 if (old_pins
== spec
->multi_ios
) {
3883 return 1; /* nothing found */
3885 return badness
; /* no badness if nothing found */
3887 if (!hardwired
&& spec
->multi_ios
< 2) {
3888 spec
->multi_ios
= old_pins
;
3895 static int alc_auto_ch_mode_info(struct snd_kcontrol
*kcontrol
,
3896 struct snd_ctl_elem_info
*uinfo
)
3898 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3899 struct alc_spec
*spec
= codec
->spec
;
3901 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
3903 uinfo
->value
.enumerated
.items
= spec
->multi_ios
+ 1;
3904 if (uinfo
->value
.enumerated
.item
> spec
->multi_ios
)
3905 uinfo
->value
.enumerated
.item
= spec
->multi_ios
;
3906 sprintf(uinfo
->value
.enumerated
.name
, "%dch",
3907 (uinfo
->value
.enumerated
.item
+ 1) * 2);
3911 static int alc_auto_ch_mode_get(struct snd_kcontrol
*kcontrol
,
3912 struct snd_ctl_elem_value
*ucontrol
)
3914 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3915 struct alc_spec
*spec
= codec
->spec
;
3916 ucontrol
->value
.enumerated
.item
[0] = (spec
->ext_channel_count
- 1) / 2;
3920 static int alc_set_multi_io(struct hda_codec
*codec
, int idx
, bool output
)
3922 struct alc_spec
*spec
= codec
->spec
;
3923 hda_nid_t nid
= spec
->multi_io
[idx
].pin
;
3925 if (!spec
->multi_io
[idx
].ctl_in
)
3926 spec
->multi_io
[idx
].ctl_in
=
3927 snd_hda_codec_read(codec
, nid
, 0,
3928 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
3930 snd_hda_set_pin_ctl_cache(codec
, nid
, PIN_OUT
);
3931 if (get_wcaps(codec
, nid
) & AC_WCAP_OUT_AMP
)
3932 snd_hda_codec_amp_stereo(codec
, nid
, HDA_OUTPUT
, 0,
3934 alc_auto_select_dac(codec
, nid
, spec
->multi_io
[idx
].dac
);
3936 if (get_wcaps(codec
, nid
) & AC_WCAP_OUT_AMP
)
3937 snd_hda_codec_amp_stereo(codec
, nid
, HDA_OUTPUT
, 0,
3938 HDA_AMP_MUTE
, HDA_AMP_MUTE
);
3939 snd_hda_set_pin_ctl_cache(codec
, nid
,
3940 spec
->multi_io
[idx
].ctl_in
);
3945 static int alc_auto_ch_mode_put(struct snd_kcontrol
*kcontrol
,
3946 struct snd_ctl_elem_value
*ucontrol
)
3948 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3949 struct alc_spec
*spec
= codec
->spec
;
3952 ch
= ucontrol
->value
.enumerated
.item
[0];
3953 if (ch
< 0 || ch
> spec
->multi_ios
)
3955 if (ch
== (spec
->ext_channel_count
- 1) / 2)
3957 spec
->ext_channel_count
= (ch
+ 1) * 2;
3958 for (i
= 0; i
< spec
->multi_ios
; i
++)
3959 alc_set_multi_io(codec
, i
, i
< ch
);
3960 spec
->multiout
.max_channels
= spec
->ext_channel_count
;
3961 if (spec
->need_dac_fix
&& !spec
->const_channel_count
)
3962 spec
->multiout
.num_dacs
= spec
->multiout
.max_channels
/ 2;
3966 static const struct snd_kcontrol_new alc_auto_channel_mode_enum
= {
3967 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3968 .name
= "Channel Mode",
3969 .info
= alc_auto_ch_mode_info
,
3970 .get
= alc_auto_ch_mode_get
,
3971 .put
= alc_auto_ch_mode_put
,
3974 static int alc_auto_add_multi_channel_mode(struct hda_codec
*codec
)
3976 struct alc_spec
*spec
= codec
->spec
;
3978 if (spec
->multi_ios
> 0) {
3979 struct snd_kcontrol_new
*knew
;
3981 knew
= alc_kcontrol_new(spec
);
3984 *knew
= alc_auto_channel_mode_enum
;
3985 knew
->name
= kstrdup("Channel Mode", GFP_KERNEL
);
3992 /* filter out invalid adc_nids (and capsrc_nids) that don't give all
3995 static void alc_remove_invalid_adc_nids(struct hda_codec
*codec
)
3997 struct alc_spec
*spec
= codec
->spec
;
3998 const struct hda_input_mux
*imux
;
3999 hda_nid_t adc_nids
[ARRAY_SIZE(spec
->private_adc_nids
)];
4000 hda_nid_t capsrc_nids
[ARRAY_SIZE(spec
->private_adc_nids
)];
4003 imux
= spec
->input_mux
;
4006 if (spec
->dyn_adc_switch
)
4011 for (n
= 0; n
< spec
->num_adc_nids
; n
++) {
4012 hda_nid_t cap
= spec
->private_capsrc_nids
[n
];
4013 int num_conns
= snd_hda_get_num_conns(codec
, cap
);
4014 for (i
= 0; i
< imux
->num_items
; i
++) {
4015 hda_nid_t pin
= spec
->imux_pins
[i
];
4017 if (get_connection_index(codec
, cap
, pin
) < 0)
4019 } else if (num_conns
<= imux
->items
[i
].index
)
4022 if (i
>= imux
->num_items
) {
4023 adc_nids
[nums
] = spec
->private_adc_nids
[n
];
4024 capsrc_nids
[nums
++] = cap
;
4028 /* check whether ADC-switch is possible */
4029 if (!alc_check_dyn_adc_switch(codec
)) {
4030 if (spec
->shared_mic_hp
) {
4031 spec
->shared_mic_hp
= 0;
4032 spec
->private_imux
[0].num_items
= 1;
4035 printk(KERN_WARNING
"hda_codec: %s: no valid ADC found;"
4036 " using fallback 0x%x\n",
4037 codec
->chip_name
, spec
->private_adc_nids
[0]);
4038 spec
->num_adc_nids
= 1;
4042 } else if (nums
!= spec
->num_adc_nids
) {
4043 memcpy(spec
->private_adc_nids
, adc_nids
,
4044 nums
* sizeof(hda_nid_t
));
4045 memcpy(spec
->private_capsrc_nids
, capsrc_nids
,
4046 nums
* sizeof(hda_nid_t
));
4047 spec
->num_adc_nids
= nums
;
4051 alc_auto_mic_check_imux(codec
); /* check auto-mic setups */
4052 else if (spec
->input_mux
->num_items
== 1 || spec
->shared_mic_hp
)
4053 spec
->num_adc_nids
= 1; /* reduce to a single ADC */
4057 * initialize ADC paths
4059 static void alc_auto_init_adc(struct hda_codec
*codec
, int adc_idx
)
4061 struct alc_spec
*spec
= codec
->spec
;
4064 nid
= spec
->adc_nids
[adc_idx
];
4066 if (nid_has_mute(codec
, nid
, HDA_INPUT
)) {
4067 snd_hda_codec_write(codec
, nid
, 0,
4068 AC_VERB_SET_AMP_GAIN_MUTE
,
4072 if (!spec
->capsrc_nids
)
4074 nid
= spec
->capsrc_nids
[adc_idx
];
4075 if (nid_has_mute(codec
, nid
, HDA_OUTPUT
))
4076 snd_hda_codec_write(codec
, nid
, 0,
4077 AC_VERB_SET_AMP_GAIN_MUTE
,
4081 static void alc_auto_init_input_src(struct hda_codec
*codec
)
4083 struct alc_spec
*spec
= codec
->spec
;
4086 for (c
= 0; c
< spec
->num_adc_nids
; c
++)
4087 alc_auto_init_adc(codec
, c
);
4088 if (spec
->dyn_adc_switch
)
4091 nums
= spec
->num_adc_nids
;
4092 for (c
= 0; c
< nums
; c
++)
4093 alc_mux_select(codec
, c
, spec
->cur_mux
[c
], true);
4096 /* add mic boosts if needed */
4097 static int alc_auto_add_mic_boost(struct hda_codec
*codec
)
4099 struct alc_spec
*spec
= codec
->spec
;
4100 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4104 const char *prev_label
= NULL
;
4106 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
4107 if (cfg
->inputs
[i
].type
> AUTO_PIN_MIC
)
4109 nid
= cfg
->inputs
[i
].pin
;
4110 if (get_wcaps(codec
, nid
) & AC_WCAP_IN_AMP
) {
4112 char boost_label
[32];
4114 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
4115 if (spec
->shared_mic_hp
&& !strcmp(label
, "Misc"))
4116 label
= "Headphone Mic";
4117 if (prev_label
&& !strcmp(label
, prev_label
))
4123 snprintf(boost_label
, sizeof(boost_label
),
4124 "%s Boost Volume", label
);
4125 err
= add_control(spec
, ALC_CTL_WIDGET_VOL
,
4126 boost_label
, type_idx
,
4127 HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_INPUT
));
4135 /* select or unmute the given capsrc route */
4136 static void select_or_unmute_capsrc(struct hda_codec
*codec
, hda_nid_t cap
,
4139 if (get_wcaps_type(get_wcaps(codec
, cap
)) == AC_WID_AUD_MIX
) {
4140 snd_hda_codec_amp_stereo(codec
, cap
, HDA_INPUT
, idx
,
4142 } else if (snd_hda_get_num_conns(codec
, cap
) > 1) {
4143 snd_hda_codec_write_cache(codec
, cap
, 0,
4144 AC_VERB_SET_CONNECT_SEL
, idx
);
4148 /* set the default connection to that pin */
4149 static int init_capsrc_for_pin(struct hda_codec
*codec
, hda_nid_t pin
)
4151 struct alc_spec
*spec
= codec
->spec
;
4156 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
4157 hda_nid_t cap
= get_capsrc(spec
, i
);
4160 idx
= get_connection_index(codec
, cap
, pin
);
4163 select_or_unmute_capsrc(codec
, cap
, idx
);
4164 return i
; /* return the found index */
4166 return -1; /* not found */
4169 /* initialize some special cases for input sources */
4170 static void alc_init_special_input_src(struct hda_codec
*codec
)
4172 struct alc_spec
*spec
= codec
->spec
;
4175 for (i
= 0; i
< spec
->autocfg
.num_inputs
; i
++)
4176 init_capsrc_for_pin(codec
, spec
->autocfg
.inputs
[i
].pin
);
4179 /* assign appropriate capture mixers */
4180 static void set_capture_mixer(struct hda_codec
*codec
)
4182 struct alc_spec
*spec
= codec
->spec
;
4183 static const struct snd_kcontrol_new
*caps
[2][3] = {
4184 { alc_capture_mixer_nosrc1
,
4185 alc_capture_mixer_nosrc2
,
4186 alc_capture_mixer_nosrc3
},
4187 { alc_capture_mixer1
,
4189 alc_capture_mixer3
},
4192 /* check whether either of ADC or MUX has a volume control */
4193 if (!nid_has_volume(codec
, spec
->adc_nids
[0], HDA_INPUT
)) {
4194 if (!spec
->capsrc_nids
)
4195 return; /* no volume */
4196 if (!nid_has_volume(codec
, spec
->capsrc_nids
[0], HDA_OUTPUT
))
4197 return; /* no volume in capsrc, too */
4198 spec
->vol_in_capsrc
= 1;
4201 if (spec
->num_adc_nids
> 0) {
4205 if (spec
->input_mux
&& spec
->input_mux
->num_items
> 1)
4207 if (spec
->auto_mic
) {
4210 } else if (spec
->dyn_adc_switch
)
4213 if (spec
->num_adc_nids
> 3)
4214 spec
->num_adc_nids
= 3;
4215 else if (!spec
->num_adc_nids
)
4217 num_adcs
= spec
->num_adc_nids
;
4219 spec
->cap_mixer
= caps
[mux
][num_adcs
- 1];
4224 * standard auto-parser initializations
4226 static void alc_auto_init_std(struct hda_codec
*codec
)
4228 struct alc_spec
*spec
= codec
->spec
;
4229 alc_auto_init_multi_out(codec
);
4230 alc_auto_init_extra_out(codec
);
4231 alc_auto_init_analog_input(codec
);
4232 alc_auto_init_input_src(codec
);
4233 alc_auto_init_digital(codec
);
4234 if (spec
->unsol_event
)
4235 alc_inithook(codec
);
4239 * Digital-beep handlers
4241 #ifdef CONFIG_SND_HDA_INPUT_BEEP
4242 #define set_beep_amp(spec, nid, idx, dir) \
4243 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4245 static const struct snd_pci_quirk beep_white_list
[] = {
4246 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
4247 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
4248 SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
4249 SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
4250 SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1),
4251 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
4255 static inline int has_cdefine_beep(struct hda_codec
*codec
)
4257 struct alc_spec
*spec
= codec
->spec
;
4258 const struct snd_pci_quirk
*q
;
4259 q
= snd_pci_quirk_lookup(codec
->bus
->pci
, beep_white_list
);
4262 return spec
->cdefine
.enable_pcbeep
;
4265 #define set_beep_amp(spec, nid, idx, dir) /* NOP */
4266 #define has_cdefine_beep(codec) 0
4269 /* parse the BIOS configuration and set up the alc_spec */
4270 /* return 1 if successful, 0 if the proper config is not found,
4271 * or a negative error code
4273 static int alc_parse_auto_config(struct hda_codec
*codec
,
4274 const hda_nid_t
*ignore_nids
,
4275 const hda_nid_t
*ssid_nids
)
4277 struct alc_spec
*spec
= codec
->spec
;
4278 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4281 err
= snd_hda_parse_pin_defcfg(codec
, cfg
, ignore_nids
,
4285 if (!cfg
->line_outs
) {
4286 if (cfg
->dig_outs
|| cfg
->dig_in_pin
) {
4287 spec
->multiout
.max_channels
= 2;
4288 spec
->no_analog
= 1;
4291 return 0; /* can't find valid BIOS pin config */
4294 if (cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
&&
4295 cfg
->line_outs
<= cfg
->hp_outs
) {
4296 /* use HP as primary out */
4297 cfg
->speaker_outs
= cfg
->line_outs
;
4298 memcpy(cfg
->speaker_pins
, cfg
->line_out_pins
,
4299 sizeof(cfg
->speaker_pins
));
4300 cfg
->line_outs
= cfg
->hp_outs
;
4301 memcpy(cfg
->line_out_pins
, cfg
->hp_pins
, sizeof(cfg
->hp_pins
));
4303 memset(cfg
->hp_pins
, 0, sizeof(cfg
->hp_pins
));
4304 cfg
->line_out_type
= AUTO_PIN_HP_OUT
;
4307 err
= alc_auto_fill_dac_nids(codec
);
4310 err
= alc_auto_add_multi_channel_mode(codec
);
4313 err
= alc_auto_create_multi_out_ctls(codec
, cfg
);
4316 err
= alc_auto_create_hp_out(codec
);
4319 err
= alc_auto_create_speaker_out(codec
);
4322 err
= alc_auto_create_shared_input(codec
);
4325 err
= alc_auto_create_input_ctls(codec
);
4329 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
4332 alc_auto_parse_digital(codec
);
4334 if (!spec
->no_analog
)
4335 alc_remove_invalid_adc_nids(codec
);
4338 alc_ssid_check(codec
, ssid_nids
);
4340 if (!spec
->no_analog
) {
4341 alc_auto_check_switches(codec
);
4342 err
= alc_auto_add_mic_boost(codec
);
4347 if (spec
->kctls
.list
)
4348 add_mixer(spec
, spec
->kctls
.list
);
4350 if (!spec
->no_analog
&& !spec
->cap_mixer
)
4351 set_capture_mixer(codec
);
4356 /* common preparation job for alc_spec */
4357 static int alc_alloc_spec(struct hda_codec
*codec
, hda_nid_t mixer_nid
)
4359 struct alc_spec
*spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4365 spec
->mixer_nid
= mixer_nid
;
4367 err
= alc_codec_rename_from_preset(codec
);
4375 static int alc880_parse_auto_config(struct hda_codec
*codec
)
4377 static const hda_nid_t alc880_ignore
[] = { 0x1d, 0 };
4378 static const hda_nid_t alc880_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
4379 return alc_parse_auto_config(codec
, alc880_ignore
, alc880_ssids
);
4388 ALC880_FIXUP_MEDION_RIM
,
4391 ALC880_FIXUP_EAPD_COEF
,
4392 ALC880_FIXUP_TCL_S700
,
4393 ALC880_FIXUP_VOL_KNOB
,
4394 ALC880_FIXUP_FUJITSU
,
4396 ALC880_FIXUP_UNIWILL
,
4397 ALC880_FIXUP_UNIWILL_DIG
,
4399 ALC880_FIXUP_3ST_BASE
,
4401 ALC880_FIXUP_3ST_DIG
,
4402 ALC880_FIXUP_5ST_BASE
,
4404 ALC880_FIXUP_5ST_DIG
,
4405 ALC880_FIXUP_6ST_BASE
,
4407 ALC880_FIXUP_6ST_DIG
,
4410 /* enable the volume-knob widget support on NID 0x21 */
4411 static void alc880_fixup_vol_knob(struct hda_codec
*codec
,
4412 const struct alc_fixup
*fix
, int action
)
4414 if (action
== ALC_FIXUP_ACT_PROBE
)
4415 snd_hda_jack_detect_enable(codec
, 0x21, ALC_DCVOL_EVENT
);
4418 static const struct alc_fixup alc880_fixups
[] = {
4419 [ALC880_FIXUP_GPIO1
] = {
4420 .type
= ALC_FIXUP_VERBS
,
4421 .v
.verbs
= alc_gpio1_init_verbs
,
4423 [ALC880_FIXUP_GPIO2
] = {
4424 .type
= ALC_FIXUP_VERBS
,
4425 .v
.verbs
= alc_gpio2_init_verbs
,
4427 [ALC880_FIXUP_MEDION_RIM
] = {
4428 .type
= ALC_FIXUP_VERBS
,
4429 .v
.verbs
= (const struct hda_verb
[]) {
4430 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4431 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3060 },
4435 .chain_id
= ALC880_FIXUP_GPIO2
,
4437 [ALC880_FIXUP_LG
] = {
4438 .type
= ALC_FIXUP_PINS
,
4439 .v
.pins
= (const struct alc_pincfg
[]) {
4440 /* disable bogus unused pins */
4441 { 0x16, 0x411111f0 },
4442 { 0x18, 0x411111f0 },
4443 { 0x1a, 0x411111f0 },
4447 [ALC880_FIXUP_W810
] = {
4448 .type
= ALC_FIXUP_PINS
,
4449 .v
.pins
= (const struct alc_pincfg
[]) {
4450 /* disable bogus unused pins */
4451 { 0x17, 0x411111f0 },
4455 .chain_id
= ALC880_FIXUP_GPIO2
,
4457 [ALC880_FIXUP_EAPD_COEF
] = {
4458 .type
= ALC_FIXUP_VERBS
,
4459 .v
.verbs
= (const struct hda_verb
[]) {
4460 /* change to EAPD mode */
4461 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4462 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3060 },
4466 [ALC880_FIXUP_TCL_S700
] = {
4467 .type
= ALC_FIXUP_VERBS
,
4468 .v
.verbs
= (const struct hda_verb
[]) {
4469 /* change to EAPD mode */
4470 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4471 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3070 },
4475 .chain_id
= ALC880_FIXUP_GPIO2
,
4477 [ALC880_FIXUP_VOL_KNOB
] = {
4478 .type
= ALC_FIXUP_FUNC
,
4479 .v
.func
= alc880_fixup_vol_knob
,
4481 [ALC880_FIXUP_FUJITSU
] = {
4482 /* override all pins as BIOS on old Amilo is broken */
4483 .type
= ALC_FIXUP_PINS
,
4484 .v
.pins
= (const struct alc_pincfg
[]) {
4485 { 0x14, 0x0121411f }, /* HP */
4486 { 0x15, 0x99030120 }, /* speaker */
4487 { 0x16, 0x99030130 }, /* bass speaker */
4488 { 0x17, 0x411111f0 }, /* N/A */
4489 { 0x18, 0x411111f0 }, /* N/A */
4490 { 0x19, 0x01a19950 }, /* mic-in */
4491 { 0x1a, 0x411111f0 }, /* N/A */
4492 { 0x1b, 0x411111f0 }, /* N/A */
4493 { 0x1c, 0x411111f0 }, /* N/A */
4494 { 0x1d, 0x411111f0 }, /* N/A */
4495 { 0x1e, 0x01454140 }, /* SPDIF out */
4499 .chain_id
= ALC880_FIXUP_VOL_KNOB
,
4501 [ALC880_FIXUP_F1734
] = {
4502 /* almost compatible with FUJITSU, but no bass and SPDIF */
4503 .type
= ALC_FIXUP_PINS
,
4504 .v
.pins
= (const struct alc_pincfg
[]) {
4505 { 0x14, 0x0121411f }, /* HP */
4506 { 0x15, 0x99030120 }, /* speaker */
4507 { 0x16, 0x411111f0 }, /* N/A */
4508 { 0x17, 0x411111f0 }, /* N/A */
4509 { 0x18, 0x411111f0 }, /* N/A */
4510 { 0x19, 0x01a19950 }, /* mic-in */
4511 { 0x1a, 0x411111f0 }, /* N/A */
4512 { 0x1b, 0x411111f0 }, /* N/A */
4513 { 0x1c, 0x411111f0 }, /* N/A */
4514 { 0x1d, 0x411111f0 }, /* N/A */
4515 { 0x1e, 0x411111f0 }, /* N/A */
4519 .chain_id
= ALC880_FIXUP_VOL_KNOB
,
4521 [ALC880_FIXUP_UNIWILL
] = {
4522 /* need to fix HP and speaker pins to be parsed correctly */
4523 .type
= ALC_FIXUP_PINS
,
4524 .v
.pins
= (const struct alc_pincfg
[]) {
4525 { 0x14, 0x0121411f }, /* HP */
4526 { 0x15, 0x99030120 }, /* speaker */
4527 { 0x16, 0x99030130 }, /* bass speaker */
4531 [ALC880_FIXUP_UNIWILL_DIG
] = {
4532 .type
= ALC_FIXUP_PINS
,
4533 .v
.pins
= (const struct alc_pincfg
[]) {
4534 /* disable bogus unused pins */
4535 { 0x17, 0x411111f0 },
4536 { 0x19, 0x411111f0 },
4537 { 0x1b, 0x411111f0 },
4538 { 0x1f, 0x411111f0 },
4542 [ALC880_FIXUP_Z71V
] = {
4543 .type
= ALC_FIXUP_PINS
,
4544 .v
.pins
= (const struct alc_pincfg
[]) {
4545 /* set up the whole pins as BIOS is utterly broken */
4546 { 0x14, 0x99030120 }, /* speaker */
4547 { 0x15, 0x0121411f }, /* HP */
4548 { 0x16, 0x411111f0 }, /* N/A */
4549 { 0x17, 0x411111f0 }, /* N/A */
4550 { 0x18, 0x01a19950 }, /* mic-in */
4551 { 0x19, 0x411111f0 }, /* N/A */
4552 { 0x1a, 0x01813031 }, /* line-in */
4553 { 0x1b, 0x411111f0 }, /* N/A */
4554 { 0x1c, 0x411111f0 }, /* N/A */
4555 { 0x1d, 0x411111f0 }, /* N/A */
4556 { 0x1e, 0x0144111e }, /* SPDIF */
4560 [ALC880_FIXUP_3ST_BASE
] = {
4561 .type
= ALC_FIXUP_PINS
,
4562 .v
.pins
= (const struct alc_pincfg
[]) {
4563 { 0x14, 0x01014010 }, /* line-out */
4564 { 0x15, 0x411111f0 }, /* N/A */
4565 { 0x16, 0x411111f0 }, /* N/A */
4566 { 0x17, 0x411111f0 }, /* N/A */
4567 { 0x18, 0x01a19c30 }, /* mic-in */
4568 { 0x19, 0x0121411f }, /* HP */
4569 { 0x1a, 0x01813031 }, /* line-in */
4570 { 0x1b, 0x02a19c40 }, /* front-mic */
4571 { 0x1c, 0x411111f0 }, /* N/A */
4572 { 0x1d, 0x411111f0 }, /* N/A */
4573 /* 0x1e is filled in below */
4574 { 0x1f, 0x411111f0 }, /* N/A */
4578 [ALC880_FIXUP_3ST
] = {
4579 .type
= ALC_FIXUP_PINS
,
4580 .v
.pins
= (const struct alc_pincfg
[]) {
4581 { 0x1e, 0x411111f0 }, /* N/A */
4585 .chain_id
= ALC880_FIXUP_3ST_BASE
,
4587 [ALC880_FIXUP_3ST_DIG
] = {
4588 .type
= ALC_FIXUP_PINS
,
4589 .v
.pins
= (const struct alc_pincfg
[]) {
4590 { 0x1e, 0x0144111e }, /* SPDIF */
4594 .chain_id
= ALC880_FIXUP_3ST_BASE
,
4596 [ALC880_FIXUP_5ST_BASE
] = {
4597 .type
= ALC_FIXUP_PINS
,
4598 .v
.pins
= (const struct alc_pincfg
[]) {
4599 { 0x14, 0x01014010 }, /* front */
4600 { 0x15, 0x411111f0 }, /* N/A */
4601 { 0x16, 0x01011411 }, /* CLFE */
4602 { 0x17, 0x01016412 }, /* surr */
4603 { 0x18, 0x01a19c30 }, /* mic-in */
4604 { 0x19, 0x0121411f }, /* HP */
4605 { 0x1a, 0x01813031 }, /* line-in */
4606 { 0x1b, 0x02a19c40 }, /* front-mic */
4607 { 0x1c, 0x411111f0 }, /* N/A */
4608 { 0x1d, 0x411111f0 }, /* N/A */
4609 /* 0x1e is filled in below */
4610 { 0x1f, 0x411111f0 }, /* N/A */
4614 [ALC880_FIXUP_5ST
] = {
4615 .type
= ALC_FIXUP_PINS
,
4616 .v
.pins
= (const struct alc_pincfg
[]) {
4617 { 0x1e, 0x411111f0 }, /* N/A */
4621 .chain_id
= ALC880_FIXUP_5ST_BASE
,
4623 [ALC880_FIXUP_5ST_DIG
] = {
4624 .type
= ALC_FIXUP_PINS
,
4625 .v
.pins
= (const struct alc_pincfg
[]) {
4626 { 0x1e, 0x0144111e }, /* SPDIF */
4630 .chain_id
= ALC880_FIXUP_5ST_BASE
,
4632 [ALC880_FIXUP_6ST_BASE
] = {
4633 .type
= ALC_FIXUP_PINS
,
4634 .v
.pins
= (const struct alc_pincfg
[]) {
4635 { 0x14, 0x01014010 }, /* front */
4636 { 0x15, 0x01016412 }, /* surr */
4637 { 0x16, 0x01011411 }, /* CLFE */
4638 { 0x17, 0x01012414 }, /* side */
4639 { 0x18, 0x01a19c30 }, /* mic-in */
4640 { 0x19, 0x02a19c40 }, /* front-mic */
4641 { 0x1a, 0x01813031 }, /* line-in */
4642 { 0x1b, 0x0121411f }, /* HP */
4643 { 0x1c, 0x411111f0 }, /* N/A */
4644 { 0x1d, 0x411111f0 }, /* N/A */
4645 /* 0x1e is filled in below */
4646 { 0x1f, 0x411111f0 }, /* N/A */
4650 [ALC880_FIXUP_6ST
] = {
4651 .type
= ALC_FIXUP_PINS
,
4652 .v
.pins
= (const struct alc_pincfg
[]) {
4653 { 0x1e, 0x411111f0 }, /* N/A */
4657 .chain_id
= ALC880_FIXUP_6ST_BASE
,
4659 [ALC880_FIXUP_6ST_DIG
] = {
4660 .type
= ALC_FIXUP_PINS
,
4661 .v
.pins
= (const struct alc_pincfg
[]) {
4662 { 0x1e, 0x0144111e }, /* SPDIF */
4666 .chain_id
= ALC880_FIXUP_6ST_BASE
,
4670 static const struct snd_pci_quirk alc880_fixup_tbl
[] = {
4671 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810
),
4672 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V
),
4673 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1
),
4674 SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2
),
4675 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF
),
4676 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG
),
4677 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734
),
4678 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL
),
4679 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB
),
4680 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810
),
4681 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM
),
4682 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_FIXUP_F1734
),
4683 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU
),
4684 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734
),
4685 SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU
),
4686 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG
),
4687 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG
),
4688 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG
),
4689 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700
),
4691 /* Below is the copied entries from alc880_quirks.c.
4692 * It's not quite sure whether BIOS sets the correct pin-config table
4693 * on these machines, thus they are kept to be compatible with
4694 * the old static quirks. Once when it's confirmed to work without
4695 * these overrides, it'd be better to remove.
4697 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG
),
4698 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST
),
4699 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG
),
4700 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG
),
4701 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG
),
4702 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG
),
4703 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG
),
4704 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST
),
4705 SND_PCI_QUIRK(0x1039, 0x1234, NULL
, ALC880_FIXUP_6ST_DIG
),
4706 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST
),
4707 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST
),
4708 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST
),
4709 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST
),
4710 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST
),
4711 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG
),
4712 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG
),
4713 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG
),
4714 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG
),
4715 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG
),
4716 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG
),
4717 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG
),
4718 SND_PCI_QUIRK(0x2668, 0x8086, NULL
, ALC880_FIXUP_6ST_DIG
), /* broken BIOS */
4719 SND_PCI_QUIRK(0x8086, 0x2668, NULL
, ALC880_FIXUP_6ST_DIG
),
4720 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4721 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4722 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4723 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG
),
4724 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4725 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG
),
4726 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG
),
4727 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4728 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4729 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4731 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST
),
4732 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG
),
4733 SND_PCI_QUIRK(0xe803, 0x1019, NULL
, ALC880_FIXUP_6ST_DIG
),
4737 static const struct alc_model_fixup alc880_fixup_models
[] = {
4738 {.id
= ALC880_FIXUP_3ST
, .name
= "3stack"},
4739 {.id
= ALC880_FIXUP_3ST_DIG
, .name
= "3stack-digout"},
4740 {.id
= ALC880_FIXUP_5ST
, .name
= "5stack"},
4741 {.id
= ALC880_FIXUP_5ST_DIG
, .name
= "5stack-digout"},
4742 {.id
= ALC880_FIXUP_6ST
, .name
= "6stack"},
4743 {.id
= ALC880_FIXUP_6ST_DIG
, .name
= "6stack-digout"},
4749 * OK, here we have finally the patch for ALC880
4751 static int patch_alc880(struct hda_codec
*codec
)
4753 struct alc_spec
*spec
;
4756 err
= alc_alloc_spec(codec
, 0x0b);
4761 spec
->need_dac_fix
= 1;
4763 alc_pick_fixup(codec
, alc880_fixup_models
, alc880_fixup_tbl
,
4765 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
4767 /* automatic parse from the BIOS config */
4768 err
= alc880_parse_auto_config(codec
);
4772 if (!spec
->no_analog
) {
4773 err
= snd_hda_attach_beep_device(codec
, 0x1);
4776 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
4779 codec
->patch_ops
= alc_patch_ops
;
4781 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
4794 static int alc260_parse_auto_config(struct hda_codec
*codec
)
4796 static const hda_nid_t alc260_ignore
[] = { 0x17, 0 };
4797 static const hda_nid_t alc260_ssids
[] = { 0x10, 0x15, 0x0f, 0 };
4798 return alc_parse_auto_config(codec
, alc260_ignore
, alc260_ssids
);
4805 ALC260_FIXUP_HP_DC5750
,
4806 ALC260_FIXUP_HP_PIN_0F
,
4809 ALC260_FIXUP_GPIO1_TOGGLE
,
4810 ALC260_FIXUP_REPLACER
,
4811 ALC260_FIXUP_HP_B1900
,
4815 static void alc260_gpio1_automute(struct hda_codec
*codec
)
4817 struct alc_spec
*spec
= codec
->spec
;
4818 snd_hda_codec_write(codec
, 0x01, 0, AC_VERB_SET_GPIO_DATA
,
4819 spec
->hp_jack_present
);
4822 static void alc260_fixup_gpio1_toggle(struct hda_codec
*codec
,
4823 const struct alc_fixup
*fix
, int action
)
4825 struct alc_spec
*spec
= codec
->spec
;
4826 if (action
== ALC_FIXUP_ACT_PROBE
) {
4827 /* although the machine has only one output pin, we need to
4828 * toggle GPIO1 according to the jack state
4830 spec
->automute_hook
= alc260_gpio1_automute
;
4831 spec
->detect_hp
= 1;
4832 spec
->automute_speaker
= 1;
4833 spec
->autocfg
.hp_pins
[0] = 0x0f; /* copy it for automute */
4834 snd_hda_jack_detect_enable(codec
, 0x0f, ALC_HP_EVENT
);
4835 spec
->unsol_event
= alc_sku_unsol_event
;
4836 snd_hda_gen_add_verbs(&spec
->gen
, alc_gpio1_init_verbs
);
4840 static void alc260_fixup_kn1(struct hda_codec
*codec
,
4841 const struct alc_fixup
*fix
, int action
)
4843 struct alc_spec
*spec
= codec
->spec
;
4844 static const struct alc_pincfg pincfgs
[] = {
4845 { 0x0f, 0x02214000 }, /* HP/speaker */
4846 { 0x12, 0x90a60160 }, /* int mic */
4847 { 0x13, 0x02a19000 }, /* ext mic */
4848 { 0x18, 0x01446000 }, /* SPDIF out */
4849 /* disable bogus I/O pins */
4850 { 0x10, 0x411111f0 },
4851 { 0x11, 0x411111f0 },
4852 { 0x14, 0x411111f0 },
4853 { 0x15, 0x411111f0 },
4854 { 0x16, 0x411111f0 },
4855 { 0x17, 0x411111f0 },
4856 { 0x19, 0x411111f0 },
4861 case ALC_FIXUP_ACT_PRE_PROBE
:
4862 alc_apply_pincfgs(codec
, pincfgs
);
4864 case ALC_FIXUP_ACT_PROBE
:
4865 spec
->init_amp
= ALC_INIT_NONE
;
4870 static const struct alc_fixup alc260_fixups
[] = {
4871 [ALC260_FIXUP_HP_DC5750
] = {
4872 .type
= ALC_FIXUP_PINS
,
4873 .v
.pins
= (const struct alc_pincfg
[]) {
4874 { 0x11, 0x90130110 }, /* speaker */
4878 [ALC260_FIXUP_HP_PIN_0F
] = {
4879 .type
= ALC_FIXUP_PINS
,
4880 .v
.pins
= (const struct alc_pincfg
[]) {
4881 { 0x0f, 0x01214000 }, /* HP */
4885 [ALC260_FIXUP_COEF
] = {
4886 .type
= ALC_FIXUP_VERBS
,
4887 .v
.verbs
= (const struct hda_verb
[]) {
4888 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4889 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3040 },
4893 .chain_id
= ALC260_FIXUP_HP_PIN_0F
,
4895 [ALC260_FIXUP_GPIO1
] = {
4896 .type
= ALC_FIXUP_VERBS
,
4897 .v
.verbs
= alc_gpio1_init_verbs
,
4899 [ALC260_FIXUP_GPIO1_TOGGLE
] = {
4900 .type
= ALC_FIXUP_FUNC
,
4901 .v
.func
= alc260_fixup_gpio1_toggle
,
4903 .chain_id
= ALC260_FIXUP_HP_PIN_0F
,
4905 [ALC260_FIXUP_REPLACER
] = {
4906 .type
= ALC_FIXUP_VERBS
,
4907 .v
.verbs
= (const struct hda_verb
[]) {
4908 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4909 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3050 },
4913 .chain_id
= ALC260_FIXUP_GPIO1_TOGGLE
,
4915 [ALC260_FIXUP_HP_B1900
] = {
4916 .type
= ALC_FIXUP_FUNC
,
4917 .v
.func
= alc260_fixup_gpio1_toggle
,
4919 .chain_id
= ALC260_FIXUP_COEF
,
4921 [ALC260_FIXUP_KN1
] = {
4922 .type
= ALC_FIXUP_FUNC
,
4923 .v
.func
= alc260_fixup_kn1
,
4927 static const struct snd_pci_quirk alc260_fixup_tbl
[] = {
4928 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1
),
4929 SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF
),
4930 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1
),
4931 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750
),
4932 SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900
),
4933 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1
),
4934 SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1
),
4935 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER
),
4936 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF
),
4942 static int patch_alc260(struct hda_codec
*codec
)
4944 struct alc_spec
*spec
;
4947 err
= alc_alloc_spec(codec
, 0x07);
4953 alc_pick_fixup(codec
, NULL
, alc260_fixup_tbl
, alc260_fixups
);
4954 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
4956 /* automatic parse from the BIOS config */
4957 err
= alc260_parse_auto_config(codec
);
4961 if (!spec
->no_analog
) {
4962 err
= snd_hda_attach_beep_device(codec
, 0x1);
4965 set_beep_amp(spec
, 0x07, 0x05, HDA_INPUT
);
4968 codec
->patch_ops
= alc_patch_ops
;
4969 spec
->shutup
= alc_eapd_shutup
;
4971 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
4982 * ALC882/883/885/888/889 support
4984 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4985 * configuration. Each pin widget can choose any input DACs and a mixer.
4986 * Each ADC is connected from a mixer of all inputs. This makes possible
4987 * 6-channel independent captures.
4989 * In addition, an independent DAC for the multi-playback (not used in this
4997 ALC882_FIXUP_ABIT_AW9D_MAX
,
4998 ALC882_FIXUP_LENOVO_Y530
,
4999 ALC882_FIXUP_PB_M5210
,
5000 ALC882_FIXUP_ACER_ASPIRE_7736
,
5001 ALC882_FIXUP_ASUS_W90V
,
5003 ALC889_FIXUP_VAIO_TT
,
5004 ALC888_FIXUP_EEE1601
,
5007 ALC883_FIXUP_ACER_EAPD
,
5012 ALC882_FIXUP_ASUS_W2JC
,
5013 ALC882_FIXUP_ACER_ASPIRE_4930G
,
5014 ALC882_FIXUP_ACER_ASPIRE_8930G
,
5015 ALC882_FIXUP_ASPIRE_8930G_VERBS
,
5016 ALC885_FIXUP_MACPRO_GPIO
,
5017 ALC889_FIXUP_DAC_ROUTE
,
5018 ALC889_FIXUP_MBP_VREF
,
5019 ALC889_FIXUP_IMAC91_VREF
,
5022 static void alc889_fixup_coef(struct hda_codec
*codec
,
5023 const struct alc_fixup
*fix
, int action
)
5025 if (action
!= ALC_FIXUP_ACT_INIT
)
5027 alc889_coef_init(codec
);
5030 /* toggle speaker-output according to the hp-jack state */
5031 static void alc882_gpio_mute(struct hda_codec
*codec
, int pin
, int muted
)
5033 unsigned int gpiostate
, gpiomask
, gpiodir
;
5035 gpiostate
= snd_hda_codec_read(codec
, codec
->afg
, 0,
5036 AC_VERB_GET_GPIO_DATA
, 0);
5039 gpiostate
|= (1 << pin
);
5041 gpiostate
&= ~(1 << pin
);
5043 gpiomask
= snd_hda_codec_read(codec
, codec
->afg
, 0,
5044 AC_VERB_GET_GPIO_MASK
, 0);
5045 gpiomask
|= (1 << pin
);
5047 gpiodir
= snd_hda_codec_read(codec
, codec
->afg
, 0,
5048 AC_VERB_GET_GPIO_DIRECTION
, 0);
5049 gpiodir
|= (1 << pin
);
5052 snd_hda_codec_write(codec
, codec
->afg
, 0,
5053 AC_VERB_SET_GPIO_MASK
, gpiomask
);
5054 snd_hda_codec_write(codec
, codec
->afg
, 0,
5055 AC_VERB_SET_GPIO_DIRECTION
, gpiodir
);
5059 snd_hda_codec_write(codec
, codec
->afg
, 0,
5060 AC_VERB_SET_GPIO_DATA
, gpiostate
);
5063 /* set up GPIO at initialization */
5064 static void alc885_fixup_macpro_gpio(struct hda_codec
*codec
,
5065 const struct alc_fixup
*fix
, int action
)
5067 if (action
!= ALC_FIXUP_ACT_INIT
)
5069 alc882_gpio_mute(codec
, 0, 0);
5070 alc882_gpio_mute(codec
, 1, 0);
5073 /* Fix the connection of some pins for ALC889:
5074 * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't
5075 * work correctly (bko#42740)
5077 static void alc889_fixup_dac_route(struct hda_codec
*codec
,
5078 const struct alc_fixup
*fix
, int action
)
5080 if (action
== ALC_FIXUP_ACT_PRE_PROBE
) {
5081 /* fake the connections during parsing the tree */
5082 hda_nid_t conn1
[2] = { 0x0c, 0x0d };
5083 hda_nid_t conn2
[2] = { 0x0e, 0x0f };
5084 snd_hda_override_conn_list(codec
, 0x14, 2, conn1
);
5085 snd_hda_override_conn_list(codec
, 0x15, 2, conn1
);
5086 snd_hda_override_conn_list(codec
, 0x18, 2, conn2
);
5087 snd_hda_override_conn_list(codec
, 0x1a, 2, conn2
);
5088 } else if (action
== ALC_FIXUP_ACT_PROBE
) {
5089 /* restore the connections */
5090 hda_nid_t conn
[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 };
5091 snd_hda_override_conn_list(codec
, 0x14, 5, conn
);
5092 snd_hda_override_conn_list(codec
, 0x15, 5, conn
);
5093 snd_hda_override_conn_list(codec
, 0x18, 5, conn
);
5094 snd_hda_override_conn_list(codec
, 0x1a, 5, conn
);
5098 /* Set VREF on HP pin */
5099 static void alc889_fixup_mbp_vref(struct hda_codec
*codec
,
5100 const struct alc_fixup
*fix
, int action
)
5102 struct alc_spec
*spec
= codec
->spec
;
5103 static hda_nid_t nids
[2] = { 0x14, 0x15 };
5106 if (action
!= ALC_FIXUP_ACT_INIT
)
5108 for (i
= 0; i
< ARRAY_SIZE(nids
); i
++) {
5109 unsigned int val
= snd_hda_codec_get_pincfg(codec
, nids
[i
]);
5110 if (get_defcfg_device(val
) != AC_JACK_HP_OUT
)
5112 val
= snd_hda_codec_read(codec
, nids
[i
], 0,
5113 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
5114 val
|= AC_PINCTL_VREF_80
;
5115 snd_hda_set_pin_ctl(codec
, nids
[i
], val
);
5116 spec
->keep_vref_in_automute
= 1;
5121 /* Set VREF on speaker pins on imac91 */
5122 static void alc889_fixup_imac91_vref(struct hda_codec
*codec
,
5123 const struct alc_fixup
*fix
, int action
)
5125 struct alc_spec
*spec
= codec
->spec
;
5126 static hda_nid_t nids
[2] = { 0x18, 0x1a };
5129 if (action
!= ALC_FIXUP_ACT_INIT
)
5131 for (i
= 0; i
< ARRAY_SIZE(nids
); i
++) {
5133 val
= snd_hda_codec_read(codec
, nids
[i
], 0,
5134 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
5135 val
|= AC_PINCTL_VREF_50
;
5136 snd_hda_set_pin_ctl(codec
, nids
[i
], val
);
5138 spec
->keep_vref_in_automute
= 1;
5141 static const struct alc_fixup alc882_fixups
[] = {
5142 [ALC882_FIXUP_ABIT_AW9D_MAX
] = {
5143 .type
= ALC_FIXUP_PINS
,
5144 .v
.pins
= (const struct alc_pincfg
[]) {
5145 { 0x15, 0x01080104 }, /* side */
5146 { 0x16, 0x01011012 }, /* rear */
5147 { 0x17, 0x01016011 }, /* clfe */
5151 [ALC882_FIXUP_LENOVO_Y530
] = {
5152 .type
= ALC_FIXUP_PINS
,
5153 .v
.pins
= (const struct alc_pincfg
[]) {
5154 { 0x15, 0x99130112 }, /* rear int speakers */
5155 { 0x16, 0x99130111 }, /* subwoofer */
5159 [ALC882_FIXUP_PB_M5210
] = {
5160 .type
= ALC_FIXUP_VERBS
,
5161 .v
.verbs
= (const struct hda_verb
[]) {
5162 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF50
},
5166 [ALC882_FIXUP_ACER_ASPIRE_7736
] = {
5167 .type
= ALC_FIXUP_FUNC
,
5168 .v
.func
= alc_fixup_sku_ignore
,
5170 [ALC882_FIXUP_ASUS_W90V
] = {
5171 .type
= ALC_FIXUP_PINS
,
5172 .v
.pins
= (const struct alc_pincfg
[]) {
5173 { 0x16, 0x99130110 }, /* fix sequence for CLFE */
5177 [ALC889_FIXUP_CD
] = {
5178 .type
= ALC_FIXUP_PINS
,
5179 .v
.pins
= (const struct alc_pincfg
[]) {
5180 { 0x1c, 0x993301f0 }, /* CD */
5184 [ALC889_FIXUP_VAIO_TT
] = {
5185 .type
= ALC_FIXUP_PINS
,
5186 .v
.pins
= (const struct alc_pincfg
[]) {
5187 { 0x17, 0x90170111 }, /* hidden surround speaker */
5191 [ALC888_FIXUP_EEE1601
] = {
5192 .type
= ALC_FIXUP_VERBS
,
5193 .v
.verbs
= (const struct hda_verb
[]) {
5194 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x0b },
5195 { 0x20, AC_VERB_SET_PROC_COEF
, 0x0838 },
5199 [ALC882_FIXUP_EAPD
] = {
5200 .type
= ALC_FIXUP_VERBS
,
5201 .v
.verbs
= (const struct hda_verb
[]) {
5202 /* change to EAPD mode */
5203 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5204 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3060 },
5208 [ALC883_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
, 0x3070 },
5217 [ALC883_FIXUP_ACER_EAPD
] = {
5218 .type
= ALC_FIXUP_VERBS
,
5219 .v
.verbs
= (const struct hda_verb
[]) {
5220 /* eanable EAPD on Acer laptops */
5221 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5222 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3050 },
5226 [ALC882_FIXUP_GPIO1
] = {
5227 .type
= ALC_FIXUP_VERBS
,
5228 .v
.verbs
= alc_gpio1_init_verbs
,
5230 [ALC882_FIXUP_GPIO2
] = {
5231 .type
= ALC_FIXUP_VERBS
,
5232 .v
.verbs
= alc_gpio2_init_verbs
,
5234 [ALC882_FIXUP_GPIO3
] = {
5235 .type
= ALC_FIXUP_VERBS
,
5236 .v
.verbs
= alc_gpio3_init_verbs
,
5238 [ALC882_FIXUP_ASUS_W2JC
] = {
5239 .type
= ALC_FIXUP_VERBS
,
5240 .v
.verbs
= alc_gpio1_init_verbs
,
5242 .chain_id
= ALC882_FIXUP_EAPD
,
5244 [ALC889_FIXUP_COEF
] = {
5245 .type
= ALC_FIXUP_FUNC
,
5246 .v
.func
= alc889_fixup_coef
,
5248 [ALC882_FIXUP_ACER_ASPIRE_4930G
] = {
5249 .type
= ALC_FIXUP_PINS
,
5250 .v
.pins
= (const struct alc_pincfg
[]) {
5251 { 0x16, 0x99130111 }, /* CLFE speaker */
5252 { 0x17, 0x99130112 }, /* surround speaker */
5256 .chain_id
= ALC882_FIXUP_GPIO1
,
5258 [ALC882_FIXUP_ACER_ASPIRE_8930G
] = {
5259 .type
= ALC_FIXUP_PINS
,
5260 .v
.pins
= (const struct alc_pincfg
[]) {
5261 { 0x16, 0x99130111 }, /* CLFE speaker */
5262 { 0x1b, 0x99130112 }, /* surround speaker */
5266 .chain_id
= ALC882_FIXUP_ASPIRE_8930G_VERBS
,
5268 [ALC882_FIXUP_ASPIRE_8930G_VERBS
] = {
5269 /* additional init verbs for Acer Aspire 8930G */
5270 .type
= ALC_FIXUP_VERBS
,
5271 .v
.verbs
= (const struct hda_verb
[]) {
5272 /* Enable all DACs */
5273 /* DAC DISABLE/MUTE 1? */
5274 /* setting bits 1-5 disables DAC nids 0x02-0x06
5275 * apparently. Init=0x38 */
5276 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x03 },
5277 { 0x20, AC_VERB_SET_PROC_COEF
, 0x0000 },
5278 /* DAC DISABLE/MUTE 2? */
5279 /* some bit here disables the other DACs.
5281 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x08 },
5282 { 0x20, AC_VERB_SET_PROC_COEF
, 0x0000 },
5284 * This laptop has a stereo digital microphone.
5285 * The mics are only 1cm apart which makes the stereo
5286 * useless. However, either the mic or the ALC889
5287 * makes the signal become a difference/sum signal
5288 * instead of standard stereo, which is annoying.
5289 * So instead we flip this bit which makes the
5290 * codec replicate the sum signal to both channels,
5291 * turning it into a normal mono mic.
5293 /* DMIC_CONTROL? Init value = 0x0001 */
5294 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x0b },
5295 { 0x20, AC_VERB_SET_PROC_COEF
, 0x0003 },
5296 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5297 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3050 },
5301 .chain_id
= ALC882_FIXUP_GPIO1
,
5303 [ALC885_FIXUP_MACPRO_GPIO
] = {
5304 .type
= ALC_FIXUP_FUNC
,
5305 .v
.func
= alc885_fixup_macpro_gpio
,
5307 [ALC889_FIXUP_DAC_ROUTE
] = {
5308 .type
= ALC_FIXUP_FUNC
,
5309 .v
.func
= alc889_fixup_dac_route
,
5311 [ALC889_FIXUP_MBP_VREF
] = {
5312 .type
= ALC_FIXUP_FUNC
,
5313 .v
.func
= alc889_fixup_mbp_vref
,
5315 .chain_id
= ALC882_FIXUP_GPIO1
,
5317 [ALC889_FIXUP_IMAC91_VREF
] = {
5318 .type
= ALC_FIXUP_FUNC
,
5319 .v
.func
= alc889_fixup_imac91_vref
,
5321 .chain_id
= ALC882_FIXUP_GPIO1
,
5325 static const struct snd_pci_quirk alc882_fixup_tbl
[] = {
5326 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD
),
5327 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD
),
5328 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD
),
5329 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD
),
5330 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD
),
5331 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD
),
5332 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
5333 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5334 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
5335 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5336 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
5337 ALC882_FIXUP_ACER_ASPIRE_8930G
),
5338 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
5339 ALC882_FIXUP_ACER_ASPIRE_8930G
),
5340 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
5341 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5342 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
5343 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5344 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
5345 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5346 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210
),
5347 SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G",
5348 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5349 SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE
),
5350 SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G
),
5351 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736
),
5352 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD
),
5353 SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V
),
5354 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC
),
5355 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601
),
5356 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT
),
5358 /* All Apple entries are in codec SSIDs */
5359 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF
),
5360 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF
),
5361 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF
),
5362 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_FIXUP_MACPRO_GPIO
),
5363 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO
),
5364 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO
),
5365 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF
),
5366 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF
),
5367 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD
),
5368 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBP_VREF
),
5369 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBP_VREF
),
5370 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF
),
5371 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF
),
5372 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO
),
5373 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF
),
5374 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF
),
5375 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF
),
5376 SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 5,1", ALC885_FIXUP_MACPRO_GPIO
),
5377 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF
),
5378 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF
),
5379 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF
),
5381 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD
),
5382 SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD
),
5383 SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3
),
5384 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3", ALC889_FIXUP_CD
),
5385 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX
),
5386 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD
),
5387 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD
),
5388 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530
),
5389 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF
),
5393 static const struct alc_model_fixup alc882_fixup_models
[] = {
5394 {.id
= ALC882_FIXUP_ACER_ASPIRE_4930G
, .name
= "acer-aspire-4930g"},
5395 {.id
= ALC882_FIXUP_ACER_ASPIRE_8930G
, .name
= "acer-aspire-8930g"},
5396 {.id
= ALC883_FIXUP_ACER_EAPD
, .name
= "acer-aspire"},
5401 * BIOS auto configuration
5403 /* almost identical with ALC880 parser... */
5404 static int alc882_parse_auto_config(struct hda_codec
*codec
)
5406 static const hda_nid_t alc882_ignore
[] = { 0x1d, 0 };
5407 static const hda_nid_t alc882_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
5408 return alc_parse_auto_config(codec
, alc882_ignore
, alc882_ssids
);
5413 static int patch_alc882(struct hda_codec
*codec
)
5415 struct alc_spec
*spec
;
5418 err
= alc_alloc_spec(codec
, 0x0b);
5424 switch (codec
->vendor_id
) {
5429 /* ALC883 and variants */
5430 alc_fix_pll_init(codec
, 0x20, 0x0a, 10);
5434 alc_pick_fixup(codec
, alc882_fixup_models
, alc882_fixup_tbl
,
5436 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
5438 alc_auto_parse_customize_define(codec
);
5440 /* automatic parse from the BIOS config */
5441 err
= alc882_parse_auto_config(codec
);
5445 if (!spec
->no_analog
&& has_cdefine_beep(codec
)) {
5446 err
= snd_hda_attach_beep_device(codec
, 0x1);
5449 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
5452 codec
->patch_ops
= alc_patch_ops
;
5454 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
5467 static int alc262_parse_auto_config(struct hda_codec
*codec
)
5469 static const hda_nid_t alc262_ignore
[] = { 0x1d, 0 };
5470 static const hda_nid_t alc262_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
5471 return alc_parse_auto_config(codec
, alc262_ignore
, alc262_ssids
);
5478 ALC262_FIXUP_FSC_H270
,
5479 ALC262_FIXUP_HP_Z200
,
5481 ALC262_FIXUP_LENOVO_3000
,
5483 ALC262_FIXUP_BENQ_T31
,
5486 static const struct alc_fixup alc262_fixups
[] = {
5487 [ALC262_FIXUP_FSC_H270
] = {
5488 .type
= ALC_FIXUP_PINS
,
5489 .v
.pins
= (const struct alc_pincfg
[]) {
5490 { 0x14, 0x99130110 }, /* speaker */
5491 { 0x15, 0x0221142f }, /* front HP */
5492 { 0x1b, 0x0121141f }, /* rear HP */
5496 [ALC262_FIXUP_HP_Z200
] = {
5497 .type
= ALC_FIXUP_PINS
,
5498 .v
.pins
= (const struct alc_pincfg
[]) {
5499 { 0x16, 0x99130120 }, /* internal speaker */
5503 [ALC262_FIXUP_TYAN
] = {
5504 .type
= ALC_FIXUP_PINS
,
5505 .v
.pins
= (const struct alc_pincfg
[]) {
5506 { 0x14, 0x1993e1f0 }, /* int AUX */
5510 [ALC262_FIXUP_LENOVO_3000
] = {
5511 .type
= ALC_FIXUP_VERBS
,
5512 .v
.verbs
= (const struct hda_verb
[]) {
5513 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF50
},
5517 .chain_id
= ALC262_FIXUP_BENQ
,
5519 [ALC262_FIXUP_BENQ
] = {
5520 .type
= ALC_FIXUP_VERBS
,
5521 .v
.verbs
= (const struct hda_verb
[]) {
5522 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5523 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3070 },
5527 [ALC262_FIXUP_BENQ_T31
] = {
5528 .type
= ALC_FIXUP_VERBS
,
5529 .v
.verbs
= (const struct hda_verb
[]) {
5530 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5531 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3050 },
5537 static const struct snd_pci_quirk alc262_fixup_tbl
[] = {
5538 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200
),
5539 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FIXUP_BENQ
),
5540 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ
),
5541 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN
),
5542 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270
),
5543 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000
),
5544 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ
),
5545 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31
),
5552 static int patch_alc262(struct hda_codec
*codec
)
5554 struct alc_spec
*spec
;
5557 err
= alc_alloc_spec(codec
, 0x0b);
5564 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
5569 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_COEF_INDEX
, 7);
5570 tmp
= snd_hda_codec_read(codec
, 0x20, 0, AC_VERB_GET_PROC_COEF
, 0);
5571 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_COEF_INDEX
, 7);
5572 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PROC_COEF
, tmp
| 0x80);
5575 alc_fix_pll_init(codec
, 0x20, 0x0a, 10);
5577 alc_pick_fixup(codec
, NULL
, alc262_fixup_tbl
, alc262_fixups
);
5578 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
5580 alc_auto_parse_customize_define(codec
);
5582 /* automatic parse from the BIOS config */
5583 err
= alc262_parse_auto_config(codec
);
5587 if (!spec
->no_analog
&& has_cdefine_beep(codec
)) {
5588 err
= snd_hda_attach_beep_device(codec
, 0x1);
5591 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
5594 codec
->patch_ops
= alc_patch_ops
;
5595 spec
->shutup
= alc_eapd_shutup
;
5597 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
5609 /* bind Beep switches of both NID 0x0f and 0x10 */
5610 static const struct hda_bind_ctls alc268_bind_beep_sw
= {
5611 .ops
= &snd_hda_bind_sw
,
5613 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT
),
5614 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT
),
5619 static const struct snd_kcontrol_new alc268_beep_mixer
[] = {
5620 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT
),
5621 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw
),
5625 /* set PCBEEP vol = 0, mute connections */
5626 static const struct hda_verb alc268_beep_init_verbs
[] = {
5627 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5628 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
5629 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
5634 * BIOS auto configuration
5636 static int alc268_parse_auto_config(struct hda_codec
*codec
)
5638 static const hda_nid_t alc268_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
5639 struct alc_spec
*spec
= codec
->spec
;
5640 int err
= alc_parse_auto_config(codec
, NULL
, alc268_ssids
);
5642 if (!spec
->no_analog
&& spec
->autocfg
.speaker_pins
[0] != 0x1d) {
5643 add_mixer(spec
, alc268_beep_mixer
);
5644 snd_hda_gen_add_verbs(&spec
->gen
, alc268_beep_init_verbs
);
5652 static int patch_alc268(struct hda_codec
*codec
)
5654 struct alc_spec
*spec
;
5655 int i
, has_beep
, err
;
5657 /* ALC268 has no aa-loopback mixer */
5658 err
= alc_alloc_spec(codec
, 0);
5664 /* automatic parse from the BIOS config */
5665 err
= alc268_parse_auto_config(codec
);
5670 for (i
= 0; i
< spec
->num_mixers
; i
++) {
5671 if (spec
->mixers
[i
] == alc268_beep_mixer
) {
5678 err
= snd_hda_attach_beep_device(codec
, 0x1);
5681 if (!query_amp_caps(codec
, 0x1d, HDA_INPUT
))
5682 /* override the amp caps for beep generator */
5683 snd_hda_override_amp_caps(codec
, 0x1d, HDA_INPUT
,
5684 (0x0c << AC_AMPCAP_OFFSET_SHIFT
) |
5685 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT
) |
5686 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
5687 (0 << AC_AMPCAP_MUTE_SHIFT
));
5690 codec
->patch_ops
= alc_patch_ops
;
5691 spec
->shutup
= alc_eapd_shutup
;
5703 static const struct hda_pcm_stream alc269_44k_pcm_analog_playback
= {
5707 .rates
= SNDRV_PCM_RATE_44100
, /* fixed rate */
5708 /* NID is set in alc_build_pcms */
5710 .open
= alc_playback_pcm_open
,
5711 .prepare
= alc_playback_pcm_prepare
,
5712 .cleanup
= alc_playback_pcm_cleanup
5716 static const struct hda_pcm_stream alc269_44k_pcm_analog_capture
= {
5720 .rates
= SNDRV_PCM_RATE_44100
, /* fixed rate */
5721 /* NID is set in alc_build_pcms */
5724 /* different alc269-variants */
5726 ALC269_TYPE_ALC269VA
,
5727 ALC269_TYPE_ALC269VB
,
5728 ALC269_TYPE_ALC269VC
,
5729 ALC269_TYPE_ALC269VD
,
5733 * BIOS auto configuration
5735 static int alc269_parse_auto_config(struct hda_codec
*codec
)
5737 static const hda_nid_t alc269_ignore
[] = { 0x1d, 0 };
5738 static const hda_nid_t alc269_ssids
[] = { 0, 0x1b, 0x14, 0x21 };
5739 static const hda_nid_t alc269va_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
5740 struct alc_spec
*spec
= codec
->spec
;
5741 const hda_nid_t
*ssids
;
5743 switch (spec
->codec_variant
) {
5744 case ALC269_TYPE_ALC269VA
:
5745 case ALC269_TYPE_ALC269VC
:
5746 ssids
= alc269va_ssids
;
5748 case ALC269_TYPE_ALC269VB
:
5749 case ALC269_TYPE_ALC269VD
:
5750 ssids
= alc269_ssids
;
5753 ssids
= alc269_ssids
;
5757 return alc_parse_auto_config(codec
, alc269_ignore
, ssids
);
5760 static void alc269_toggle_power_output(struct hda_codec
*codec
, int power_up
)
5762 int val
= alc_read_coef_idx(codec
, 0x04);
5767 alc_write_coef_idx(codec
, 0x04, val
);
5770 static void alc269_shutup(struct hda_codec
*codec
)
5772 struct alc_spec
*spec
= codec
->spec
;
5774 if (spec
->codec_variant
!= ALC269_TYPE_ALC269VB
)
5777 if ((alc_get_coef0(codec
) & 0x00ff) == 0x017)
5778 alc269_toggle_power_output(codec
, 0);
5779 if ((alc_get_coef0(codec
) & 0x00ff) == 0x018) {
5780 alc269_toggle_power_output(codec
, 0);
5786 static int alc269_resume(struct hda_codec
*codec
)
5788 struct alc_spec
*spec
= codec
->spec
;
5790 if (spec
->codec_variant
== ALC269_TYPE_ALC269VB
||
5791 (alc_get_coef0(codec
) & 0x00ff) == 0x018) {
5792 alc269_toggle_power_output(codec
, 0);
5796 codec
->patch_ops
.init(codec
);
5798 if (spec
->codec_variant
== ALC269_TYPE_ALC269VB
||
5799 (alc_get_coef0(codec
) & 0x00ff) == 0x017) {
5800 alc269_toggle_power_output(codec
, 1);
5804 if (spec
->codec_variant
== ALC269_TYPE_ALC269VB
||
5805 (alc_get_coef0(codec
) & 0x00ff) == 0x018)
5806 alc269_toggle_power_output(codec
, 1);
5808 snd_hda_codec_resume_amp(codec
);
5809 snd_hda_codec_resume_cache(codec
);
5810 hda_call_check_power_status(codec
, 0x01);
5813 #endif /* CONFIG_PM */
5815 static void alc269_fixup_hweq(struct hda_codec
*codec
,
5816 const struct alc_fixup
*fix
, int action
)
5820 if (action
!= ALC_FIXUP_ACT_INIT
)
5822 coef
= alc_read_coef_idx(codec
, 0x1e);
5823 alc_write_coef_idx(codec
, 0x1e, coef
| 0x80);
5826 static void alc271_fixup_dmic(struct hda_codec
*codec
,
5827 const struct alc_fixup
*fix
, int action
)
5829 static const struct hda_verb verbs
[] = {
5830 {0x20, AC_VERB_SET_COEF_INDEX
, 0x0d},
5831 {0x20, AC_VERB_SET_PROC_COEF
, 0x4000},
5836 if (strcmp(codec
->chip_name
, "ALC271X"))
5838 cfg
= snd_hda_codec_get_pincfg(codec
, 0x12);
5839 if (get_defcfg_connect(cfg
) == AC_JACK_PORT_FIXED
)
5840 snd_hda_sequence_write(codec
, verbs
);
5843 static void alc269_fixup_pcm_44k(struct hda_codec
*codec
,
5844 const struct alc_fixup
*fix
, int action
)
5846 struct alc_spec
*spec
= codec
->spec
;
5848 if (action
!= ALC_FIXUP_ACT_PROBE
)
5851 /* Due to a hardware problem on Lenovo Ideadpad, we need to
5852 * fix the sample rate of analog I/O to 44.1kHz
5854 spec
->stream_analog_playback
= &alc269_44k_pcm_analog_playback
;
5855 spec
->stream_analog_capture
= &alc269_44k_pcm_analog_capture
;
5858 static void alc269_fixup_stereo_dmic(struct hda_codec
*codec
,
5859 const struct alc_fixup
*fix
, int action
)
5863 if (action
!= ALC_FIXUP_ACT_INIT
)
5865 /* The digital-mic unit sends PDM (differential signal) instead of
5866 * the standard PCM, thus you can't record a valid mono stream as is.
5867 * Below is a workaround specific to ALC269 to control the dmic
5868 * signal source as mono.
5870 coef
= alc_read_coef_idx(codec
, 0x07);
5871 alc_write_coef_idx(codec
, 0x07, coef
| 0x80);
5874 static void alc269_quanta_automute(struct hda_codec
*codec
)
5876 update_outputs(codec
);
5878 snd_hda_codec_write(codec
, 0x20, 0,
5879 AC_VERB_SET_COEF_INDEX
, 0x0c);
5880 snd_hda_codec_write(codec
, 0x20, 0,
5881 AC_VERB_SET_PROC_COEF
, 0x680);
5883 snd_hda_codec_write(codec
, 0x20, 0,
5884 AC_VERB_SET_COEF_INDEX
, 0x0c);
5885 snd_hda_codec_write(codec
, 0x20, 0,
5886 AC_VERB_SET_PROC_COEF
, 0x480);
5889 static void alc269_fixup_quanta_mute(struct hda_codec
*codec
,
5890 const struct alc_fixup
*fix
, int action
)
5892 struct alc_spec
*spec
= codec
->spec
;
5893 if (action
!= ALC_FIXUP_ACT_PROBE
)
5895 spec
->automute_hook
= alc269_quanta_automute
;
5898 /* update mute-LED according to the speaker mute state via mic2 VREF pin */
5899 static void alc269_fixup_mic2_mute_hook(void *private_data
, int enabled
)
5901 struct hda_codec
*codec
= private_data
;
5902 unsigned int pinval
= enabled
? 0x20 : 0x24;
5903 snd_hda_set_pin_ctl_cache(codec
, 0x19, pinval
);
5906 static void alc269_fixup_mic2_mute(struct hda_codec
*codec
,
5907 const struct alc_fixup
*fix
, int action
)
5909 struct alc_spec
*spec
= codec
->spec
;
5911 case ALC_FIXUP_ACT_BUILD
:
5912 spec
->vmaster_mute
.hook
= alc269_fixup_mic2_mute_hook
;
5913 snd_hda_add_vmaster_hook(codec
, &spec
->vmaster_mute
, true);
5915 case ALC_FIXUP_ACT_INIT
:
5916 snd_hda_sync_vmaster_hook(&spec
->vmaster_mute
);
5922 ALC269_FIXUP_SONY_VAIO
,
5923 ALC275_FIXUP_SONY_VAIO_GPIO2
,
5924 ALC269_FIXUP_DELL_M101Z
,
5925 ALC269_FIXUP_SKU_IGNORE
,
5926 ALC269_FIXUP_ASUS_G73JW
,
5927 ALC269_FIXUP_LENOVO_EAPD
,
5928 ALC275_FIXUP_SONY_HWEQ
,
5930 ALC269_FIXUP_PCM_44K
,
5931 ALC269_FIXUP_STEREO_DMIC
,
5932 ALC269_FIXUP_QUANTA_MUTE
,
5933 ALC269_FIXUP_LIFEBOOK
,
5936 ALC269VB_FIXUP_AMIC
,
5937 ALC269VB_FIXUP_DMIC
,
5938 ALC269_FIXUP_MIC2_MUTE_LED
,
5941 static const struct alc_fixup alc269_fixups
[] = {
5942 [ALC269_FIXUP_SONY_VAIO
] = {
5943 .type
= ALC_FIXUP_VERBS
,
5944 .v
.verbs
= (const struct hda_verb
[]) {
5945 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREFGRD
},
5949 [ALC275_FIXUP_SONY_VAIO_GPIO2
] = {
5950 .type
= ALC_FIXUP_VERBS
,
5951 .v
.verbs
= (const struct hda_verb
[]) {
5952 {0x01, AC_VERB_SET_GPIO_MASK
, 0x04},
5953 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x04},
5954 {0x01, AC_VERB_SET_GPIO_DATA
, 0x00},
5958 .chain_id
= ALC269_FIXUP_SONY_VAIO
5960 [ALC269_FIXUP_DELL_M101Z
] = {
5961 .type
= ALC_FIXUP_VERBS
,
5962 .v
.verbs
= (const struct hda_verb
[]) {
5963 /* Enables internal speaker */
5964 {0x20, AC_VERB_SET_COEF_INDEX
, 13},
5965 {0x20, AC_VERB_SET_PROC_COEF
, 0x4040},
5969 [ALC269_FIXUP_SKU_IGNORE
] = {
5970 .type
= ALC_FIXUP_FUNC
,
5971 .v
.func
= alc_fixup_sku_ignore
,
5973 [ALC269_FIXUP_ASUS_G73JW
] = {
5974 .type
= ALC_FIXUP_PINS
,
5975 .v
.pins
= (const struct alc_pincfg
[]) {
5976 { 0x17, 0x99130111 }, /* subwoofer */
5980 [ALC269_FIXUP_LENOVO_EAPD
] = {
5981 .type
= ALC_FIXUP_VERBS
,
5982 .v
.verbs
= (const struct hda_verb
[]) {
5983 {0x14, AC_VERB_SET_EAPD_BTLENABLE
, 0},
5987 [ALC275_FIXUP_SONY_HWEQ
] = {
5988 .type
= ALC_FIXUP_FUNC
,
5989 .v
.func
= alc269_fixup_hweq
,
5991 .chain_id
= ALC275_FIXUP_SONY_VAIO_GPIO2
5993 [ALC271_FIXUP_DMIC
] = {
5994 .type
= ALC_FIXUP_FUNC
,
5995 .v
.func
= alc271_fixup_dmic
,
5997 [ALC269_FIXUP_PCM_44K
] = {
5998 .type
= ALC_FIXUP_FUNC
,
5999 .v
.func
= alc269_fixup_pcm_44k
,
6001 [ALC269_FIXUP_STEREO_DMIC
] = {
6002 .type
= ALC_FIXUP_FUNC
,
6003 .v
.func
= alc269_fixup_stereo_dmic
,
6005 [ALC269_FIXUP_QUANTA_MUTE
] = {
6006 .type
= ALC_FIXUP_FUNC
,
6007 .v
.func
= alc269_fixup_quanta_mute
,
6009 [ALC269_FIXUP_LIFEBOOK
] = {
6010 .type
= ALC_FIXUP_PINS
,
6011 .v
.pins
= (const struct alc_pincfg
[]) {
6012 { 0x1a, 0x2101103f }, /* dock line-out */
6013 { 0x1b, 0x23a11040 }, /* dock mic-in */
6017 .chain_id
= ALC269_FIXUP_QUANTA_MUTE
6019 [ALC269_FIXUP_AMIC
] = {
6020 .type
= ALC_FIXUP_PINS
,
6021 .v
.pins
= (const struct alc_pincfg
[]) {
6022 { 0x14, 0x99130110 }, /* speaker */
6023 { 0x15, 0x0121401f }, /* HP out */
6024 { 0x18, 0x01a19c20 }, /* mic */
6025 { 0x19, 0x99a3092f }, /* int-mic */
6029 [ALC269_FIXUP_DMIC
] = {
6030 .type
= ALC_FIXUP_PINS
,
6031 .v
.pins
= (const struct alc_pincfg
[]) {
6032 { 0x12, 0x99a3092f }, /* int-mic */
6033 { 0x14, 0x99130110 }, /* speaker */
6034 { 0x15, 0x0121401f }, /* HP out */
6035 { 0x18, 0x01a19c20 }, /* mic */
6039 [ALC269VB_FIXUP_AMIC
] = {
6040 .type
= ALC_FIXUP_PINS
,
6041 .v
.pins
= (const struct alc_pincfg
[]) {
6042 { 0x14, 0x99130110 }, /* speaker */
6043 { 0x18, 0x01a19c20 }, /* mic */
6044 { 0x19, 0x99a3092f }, /* int-mic */
6045 { 0x21, 0x0121401f }, /* HP out */
6049 [ALC269VB_FIXUP_DMIC
] = {
6050 .type
= ALC_FIXUP_PINS
,
6051 .v
.pins
= (const struct alc_pincfg
[]) {
6052 { 0x12, 0x99a3092f }, /* int-mic */
6053 { 0x14, 0x99130110 }, /* speaker */
6054 { 0x18, 0x01a19c20 }, /* mic */
6055 { 0x21, 0x0121401f }, /* HP out */
6059 [ALC269_FIXUP_MIC2_MUTE_LED
] = {
6060 .type
= ALC_FIXUP_FUNC
,
6061 .v
.func
= alc269_fixup_mic2_mute
,
6065 static const struct snd_pci_quirk alc269_fixup_tbl
[] = {
6066 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_MIC2_MUTE_LED
),
6067 SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_DMIC
),
6068 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW
),
6069 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC
),
6070 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC
),
6071 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC
),
6072 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC
),
6073 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC
),
6074 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2
),
6075 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ
),
6076 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ
),
6077 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO
),
6078 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z
),
6079 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC
),
6080 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK
),
6081 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE
),
6082 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE
),
6083 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE
),
6084 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE
),
6085 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE
),
6086 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_QUANTA_MUTE
),
6087 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Lenovo Ideapd", ALC269_FIXUP_PCM_44K
),
6088 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD
),
6091 /* Below is a quirk table taken from the old code.
6092 * Basically the device should work as is without the fixup table.
6093 * If BIOS doesn't give a proper info, enable the corresponding
6096 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
6098 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC
),
6099 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC
),
6100 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC
),
6101 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC
),
6102 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC
),
6103 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC
),
6104 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC
),
6105 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC
),
6106 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC
),
6107 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC
),
6108 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC
),
6109 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC
),
6110 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC
),
6111 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC
),
6112 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC
),
6113 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC
),
6114 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC
),
6115 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC
),
6116 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC
),
6117 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC
),
6118 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC
),
6119 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC
),
6120 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC
),
6121 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC
),
6122 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC
),
6123 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC
),
6124 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC
),
6125 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC
),
6126 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC
),
6127 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC
),
6128 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC
),
6129 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC
),
6130 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC
),
6131 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC
),
6132 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC
),
6133 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC
),
6134 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC
),
6135 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC
),
6136 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC
),
6141 static const struct alc_model_fixup alc269_fixup_models
[] = {
6142 {.id
= ALC269_FIXUP_AMIC
, .name
= "laptop-amic"},
6143 {.id
= ALC269_FIXUP_DMIC
, .name
= "laptop-dmic"},
6148 static void alc269_fill_coef(struct hda_codec
*codec
)
6150 struct alc_spec
*spec
= codec
->spec
;
6153 if (spec
->codec_variant
!= ALC269_TYPE_ALC269VB
)
6156 if ((alc_get_coef0(codec
) & 0x00ff) < 0x015) {
6157 alc_write_coef_idx(codec
, 0xf, 0x960b);
6158 alc_write_coef_idx(codec
, 0xe, 0x8817);
6161 if ((alc_get_coef0(codec
) & 0x00ff) == 0x016) {
6162 alc_write_coef_idx(codec
, 0xf, 0x960b);
6163 alc_write_coef_idx(codec
, 0xe, 0x8814);
6166 if ((alc_get_coef0(codec
) & 0x00ff) == 0x017) {
6167 val
= alc_read_coef_idx(codec
, 0x04);
6168 /* Power up output pin */
6169 alc_write_coef_idx(codec
, 0x04, val
| (1<<11));
6172 if ((alc_get_coef0(codec
) & 0x00ff) == 0x018) {
6173 val
= alc_read_coef_idx(codec
, 0xd);
6174 if ((val
& 0x0c00) >> 10 != 0x1) {
6175 /* Capless ramp up clock control */
6176 alc_write_coef_idx(codec
, 0xd, val
| (1<<10));
6178 val
= alc_read_coef_idx(codec
, 0x17);
6179 if ((val
& 0x01c0) >> 6 != 0x4) {
6180 /* Class D power on reset */
6181 alc_write_coef_idx(codec
, 0x17, val
| (1<<7));
6185 val
= alc_read_coef_idx(codec
, 0xd); /* Class D */
6186 alc_write_coef_idx(codec
, 0xd, val
| (1<<14));
6188 val
= alc_read_coef_idx(codec
, 0x4); /* HP */
6189 alc_write_coef_idx(codec
, 0x4, val
| (1<<11));
6194 static int patch_alc269(struct hda_codec
*codec
)
6196 struct alc_spec
*spec
;
6199 err
= alc_alloc_spec(codec
, 0x0b);
6205 if (codec
->vendor_id
== 0x10ec0269) {
6206 spec
->codec_variant
= ALC269_TYPE_ALC269VA
;
6207 switch (alc_get_coef0(codec
) & 0x00f0) {
6209 if (codec
->bus
->pci
->subsystem_vendor
== 0x1025 &&
6210 spec
->cdefine
.platform_type
== 1)
6211 err
= alc_codec_rename(codec
, "ALC271X");
6212 spec
->codec_variant
= ALC269_TYPE_ALC269VB
;
6215 if (codec
->bus
->pci
->subsystem_vendor
== 0x17aa &&
6216 codec
->bus
->pci
->subsystem_device
== 0x21f3)
6217 err
= alc_codec_rename(codec
, "ALC3202");
6218 spec
->codec_variant
= ALC269_TYPE_ALC269VC
;
6221 spec
->codec_variant
= ALC269_TYPE_ALC269VD
;
6224 alc_fix_pll_init(codec
, 0x20, 0x04, 15);
6228 spec
->init_hook
= alc269_fill_coef
;
6229 alc269_fill_coef(codec
);
6232 alc_pick_fixup(codec
, alc269_fixup_models
,
6233 alc269_fixup_tbl
, alc269_fixups
);
6234 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
6236 alc_auto_parse_customize_define(codec
);
6238 /* automatic parse from the BIOS config */
6239 err
= alc269_parse_auto_config(codec
);
6243 if (!spec
->no_analog
&& has_cdefine_beep(codec
)) {
6244 err
= snd_hda_attach_beep_device(codec
, 0x1);
6247 set_beep_amp(spec
, 0x0b, 0x04, HDA_INPUT
);
6250 codec
->patch_ops
= alc_patch_ops
;
6252 codec
->patch_ops
.resume
= alc269_resume
;
6254 spec
->shutup
= alc269_shutup
;
6256 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
6269 static int alc861_parse_auto_config(struct hda_codec
*codec
)
6271 static const hda_nid_t alc861_ignore
[] = { 0x1d, 0 };
6272 static const hda_nid_t alc861_ssids
[] = { 0x0e, 0x0f, 0x0b, 0 };
6273 return alc_parse_auto_config(codec
, alc861_ignore
, alc861_ssids
);
6276 /* Pin config fixes */
6278 ALC861_FIXUP_FSC_AMILO_PI1505
,
6279 ALC861_FIXUP_AMP_VREF_0F
,
6280 ALC861_FIXUP_NO_JACK_DETECT
,
6281 ALC861_FIXUP_ASUS_A6RP
,
6284 /* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */
6285 static void alc861_fixup_asus_amp_vref_0f(struct hda_codec
*codec
,
6286 const struct alc_fixup
*fix
, int action
)
6288 struct alc_spec
*spec
= codec
->spec
;
6291 if (action
!= ALC_FIXUP_ACT_INIT
)
6293 val
= snd_hda_codec_read(codec
, 0x0f, 0,
6294 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
6295 if (!(val
& (AC_PINCTL_IN_EN
| AC_PINCTL_OUT_EN
)))
6296 val
|= AC_PINCTL_IN_EN
;
6297 val
|= AC_PINCTL_VREF_50
;
6298 snd_hda_set_pin_ctl(codec
, 0x0f, val
);
6299 spec
->keep_vref_in_automute
= 1;
6302 /* suppress the jack-detection */
6303 static void alc_fixup_no_jack_detect(struct hda_codec
*codec
,
6304 const struct alc_fixup
*fix
, int action
)
6306 if (action
== ALC_FIXUP_ACT_PRE_PROBE
)
6307 codec
->no_jack_detect
= 1;
6310 static const struct alc_fixup alc861_fixups
[] = {
6311 [ALC861_FIXUP_FSC_AMILO_PI1505
] = {
6312 .type
= ALC_FIXUP_PINS
,
6313 .v
.pins
= (const struct alc_pincfg
[]) {
6314 { 0x0b, 0x0221101f }, /* HP */
6315 { 0x0f, 0x90170310 }, /* speaker */
6319 [ALC861_FIXUP_AMP_VREF_0F
] = {
6320 .type
= ALC_FIXUP_FUNC
,
6321 .v
.func
= alc861_fixup_asus_amp_vref_0f
,
6323 [ALC861_FIXUP_NO_JACK_DETECT
] = {
6324 .type
= ALC_FIXUP_FUNC
,
6325 .v
.func
= alc_fixup_no_jack_detect
,
6327 [ALC861_FIXUP_ASUS_A6RP
] = {
6328 .type
= ALC_FIXUP_FUNC
,
6329 .v
.func
= alc861_fixup_asus_amp_vref_0f
,
6331 .chain_id
= ALC861_FIXUP_NO_JACK_DETECT
,
6335 static const struct snd_pci_quirk alc861_fixup_tbl
[] = {
6336 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP
),
6337 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F
),
6338 SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT
),
6339 SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F
),
6340 SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F
),
6341 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505
),
6347 static int patch_alc861(struct hda_codec
*codec
)
6349 struct alc_spec
*spec
;
6352 err
= alc_alloc_spec(codec
, 0x15);
6358 alc_pick_fixup(codec
, NULL
, alc861_fixup_tbl
, alc861_fixups
);
6359 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
6361 /* automatic parse from the BIOS config */
6362 err
= alc861_parse_auto_config(codec
);
6366 if (!spec
->no_analog
) {
6367 err
= snd_hda_attach_beep_device(codec
, 0x23);
6370 set_beep_amp(spec
, 0x23, 0, HDA_OUTPUT
);
6373 codec
->patch_ops
= alc_patch_ops
;
6374 #ifdef CONFIG_SND_HDA_POWER_SAVE
6375 spec
->power_hook
= alc_power_eapd
;
6378 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
6392 * In addition, an independent DAC
6394 static int alc861vd_parse_auto_config(struct hda_codec
*codec
)
6396 static const hda_nid_t alc861vd_ignore
[] = { 0x1d, 0 };
6397 static const hda_nid_t alc861vd_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
6398 return alc_parse_auto_config(codec
, alc861vd_ignore
, alc861vd_ssids
);
6402 ALC660VD_FIX_ASUS_GPIO1
,
6403 ALC861VD_FIX_DALLAS
,
6406 /* exclude VREF80 */
6407 static void alc861vd_fixup_dallas(struct hda_codec
*codec
,
6408 const struct alc_fixup
*fix
, int action
)
6410 if (action
== ALC_FIXUP_ACT_PRE_PROBE
) {
6411 snd_hda_override_pin_caps(codec
, 0x18, 0x00001714);
6412 snd_hda_override_pin_caps(codec
, 0x19, 0x0000171c);
6416 static const struct alc_fixup alc861vd_fixups
[] = {
6417 [ALC660VD_FIX_ASUS_GPIO1
] = {
6418 .type
= ALC_FIXUP_VERBS
,
6419 .v
.verbs
= (const struct hda_verb
[]) {
6421 {0x01, AC_VERB_SET_GPIO_MASK
, 0x03},
6422 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x01},
6423 {0x01, AC_VERB_SET_GPIO_DATA
, 0x01},
6427 [ALC861VD_FIX_DALLAS
] = {
6428 .type
= ALC_FIXUP_FUNC
,
6429 .v
.func
= alc861vd_fixup_dallas
,
6433 static const struct snd_pci_quirk alc861vd_fixup_tbl
[] = {
6434 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS
),
6435 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1
),
6436 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS
),
6440 static const struct hda_verb alc660vd_eapd_verbs
[] = {
6441 {0x14, AC_VERB_SET_EAPD_BTLENABLE
, 2},
6442 {0x15, AC_VERB_SET_EAPD_BTLENABLE
, 2},
6448 static int patch_alc861vd(struct hda_codec
*codec
)
6450 struct alc_spec
*spec
;
6453 err
= alc_alloc_spec(codec
, 0x0b);
6459 alc_pick_fixup(codec
, NULL
, alc861vd_fixup_tbl
, alc861vd_fixups
);
6460 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
6462 /* automatic parse from the BIOS config */
6463 err
= alc861vd_parse_auto_config(codec
);
6467 if (codec
->vendor_id
== 0x10ec0660) {
6468 /* always turn on EAPD */
6469 snd_hda_gen_add_verbs(&spec
->gen
, alc660vd_eapd_verbs
);
6472 if (!spec
->no_analog
) {
6473 err
= snd_hda_attach_beep_device(codec
, 0x23);
6476 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
6479 codec
->patch_ops
= alc_patch_ops
;
6481 spec
->shutup
= alc_eapd_shutup
;
6483 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
6495 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
6496 * configuration. Each pin widget can choose any input DACs and a mixer.
6497 * Each ADC is connected from a mixer of all inputs. This makes possible
6498 * 6-channel independent captures.
6500 * In addition, an independent DAC for the multi-playback (not used in this
6505 * BIOS auto configuration
6508 static int alc662_parse_auto_config(struct hda_codec
*codec
)
6510 static const hda_nid_t alc662_ignore
[] = { 0x1d, 0 };
6511 static const hda_nid_t alc663_ssids
[] = { 0x15, 0x1b, 0x14, 0x21 };
6512 static const hda_nid_t alc662_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
6513 const hda_nid_t
*ssids
;
6515 if (codec
->vendor_id
== 0x10ec0272 || codec
->vendor_id
== 0x10ec0663 ||
6516 codec
->vendor_id
== 0x10ec0665 || codec
->vendor_id
== 0x10ec0670)
6517 ssids
= alc663_ssids
;
6519 ssids
= alc662_ssids
;
6520 return alc_parse_auto_config(codec
, alc662_ignore
, ssids
);
6523 static void alc272_fixup_mario(struct hda_codec
*codec
,
6524 const struct alc_fixup
*fix
, int action
)
6526 if (action
!= ALC_FIXUP_ACT_PROBE
)
6528 if (snd_hda_override_amp_caps(codec
, 0x2, HDA_OUTPUT
,
6529 (0x3b << AC_AMPCAP_OFFSET_SHIFT
) |
6530 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT
) |
6531 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
6532 (0 << AC_AMPCAP_MUTE_SHIFT
)))
6534 "hda_codec: failed to override amp caps for NID 0x2\n");
6537 static void alc662_fixup_inv_dmic(struct hda_codec
*codec
,
6538 const struct alc_fixup
*fix
, int action
)
6540 if (action
== ALC_FIXUP_ACT_PROBE
)
6541 alc_add_inv_dmic_mixer(codec
, 0x12);
6545 ALC662_FIXUP_ASPIRE
,
6546 ALC662_FIXUP_IDEAPAD
,
6548 ALC662_FIXUP_CZC_P10T
,
6549 ALC662_FIXUP_SKU_IGNORE
,
6550 ALC662_FIXUP_HP_RP5800
,
6551 ALC662_FIXUP_ASUS_MODE1
,
6552 ALC662_FIXUP_ASUS_MODE2
,
6553 ALC662_FIXUP_ASUS_MODE3
,
6554 ALC662_FIXUP_ASUS_MODE4
,
6555 ALC662_FIXUP_ASUS_MODE5
,
6556 ALC662_FIXUP_ASUS_MODE6
,
6557 ALC662_FIXUP_ASUS_MODE7
,
6558 ALC662_FIXUP_ASUS_MODE8
,
6559 ALC662_FIXUP_NO_JACK_DETECT
,
6560 ALC662_FIXUP_ZOTAC_Z68
,
6561 ALC662_FIXUP_INV_DMIC
,
6564 static const struct alc_fixup alc662_fixups
[] = {
6565 [ALC662_FIXUP_ASPIRE
] = {
6566 .type
= ALC_FIXUP_PINS
,
6567 .v
.pins
= (const struct alc_pincfg
[]) {
6568 { 0x15, 0x99130112 }, /* subwoofer */
6572 [ALC662_FIXUP_IDEAPAD
] = {
6573 .type
= ALC_FIXUP_PINS
,
6574 .v
.pins
= (const struct alc_pincfg
[]) {
6575 { 0x17, 0x99130112 }, /* subwoofer */
6579 [ALC272_FIXUP_MARIO
] = {
6580 .type
= ALC_FIXUP_FUNC
,
6581 .v
.func
= alc272_fixup_mario
,
6583 [ALC662_FIXUP_CZC_P10T
] = {
6584 .type
= ALC_FIXUP_VERBS
,
6585 .v
.verbs
= (const struct hda_verb
[]) {
6586 {0x14, AC_VERB_SET_EAPD_BTLENABLE
, 0},
6590 [ALC662_FIXUP_SKU_IGNORE
] = {
6591 .type
= ALC_FIXUP_FUNC
,
6592 .v
.func
= alc_fixup_sku_ignore
,
6594 [ALC662_FIXUP_HP_RP5800
] = {
6595 .type
= ALC_FIXUP_PINS
,
6596 .v
.pins
= (const struct alc_pincfg
[]) {
6597 { 0x14, 0x0221201f }, /* HP out */
6601 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6603 [ALC662_FIXUP_ASUS_MODE1
] = {
6604 .type
= ALC_FIXUP_PINS
,
6605 .v
.pins
= (const struct alc_pincfg
[]) {
6606 { 0x14, 0x99130110 }, /* speaker */
6607 { 0x18, 0x01a19c20 }, /* mic */
6608 { 0x19, 0x99a3092f }, /* int-mic */
6609 { 0x21, 0x0121401f }, /* HP out */
6613 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6615 [ALC662_FIXUP_ASUS_MODE2
] = {
6616 .type
= ALC_FIXUP_PINS
,
6617 .v
.pins
= (const struct alc_pincfg
[]) {
6618 { 0x14, 0x99130110 }, /* speaker */
6619 { 0x18, 0x01a19820 }, /* mic */
6620 { 0x19, 0x99a3092f }, /* int-mic */
6621 { 0x1b, 0x0121401f }, /* HP out */
6625 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6627 [ALC662_FIXUP_ASUS_MODE3
] = {
6628 .type
= ALC_FIXUP_PINS
,
6629 .v
.pins
= (const struct alc_pincfg
[]) {
6630 { 0x14, 0x99130110 }, /* speaker */
6631 { 0x15, 0x0121441f }, /* HP */
6632 { 0x18, 0x01a19840 }, /* mic */
6633 { 0x19, 0x99a3094f }, /* int-mic */
6634 { 0x21, 0x01211420 }, /* HP2 */
6638 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6640 [ALC662_FIXUP_ASUS_MODE4
] = {
6641 .type
= ALC_FIXUP_PINS
,
6642 .v
.pins
= (const struct alc_pincfg
[]) {
6643 { 0x14, 0x99130110 }, /* speaker */
6644 { 0x16, 0x99130111 }, /* speaker */
6645 { 0x18, 0x01a19840 }, /* mic */
6646 { 0x19, 0x99a3094f }, /* int-mic */
6647 { 0x21, 0x0121441f }, /* HP */
6651 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6653 [ALC662_FIXUP_ASUS_MODE5
] = {
6654 .type
= ALC_FIXUP_PINS
,
6655 .v
.pins
= (const struct alc_pincfg
[]) {
6656 { 0x14, 0x99130110 }, /* speaker */
6657 { 0x15, 0x0121441f }, /* HP */
6658 { 0x16, 0x99130111 }, /* speaker */
6659 { 0x18, 0x01a19840 }, /* mic */
6660 { 0x19, 0x99a3094f }, /* int-mic */
6664 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6666 [ALC662_FIXUP_ASUS_MODE6
] = {
6667 .type
= ALC_FIXUP_PINS
,
6668 .v
.pins
= (const struct alc_pincfg
[]) {
6669 { 0x14, 0x99130110 }, /* speaker */
6670 { 0x15, 0x01211420 }, /* HP2 */
6671 { 0x18, 0x01a19840 }, /* mic */
6672 { 0x19, 0x99a3094f }, /* int-mic */
6673 { 0x1b, 0x0121441f }, /* HP */
6677 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6679 [ALC662_FIXUP_ASUS_MODE7
] = {
6680 .type
= ALC_FIXUP_PINS
,
6681 .v
.pins
= (const struct alc_pincfg
[]) {
6682 { 0x14, 0x99130110 }, /* speaker */
6683 { 0x17, 0x99130111 }, /* speaker */
6684 { 0x18, 0x01a19840 }, /* mic */
6685 { 0x19, 0x99a3094f }, /* int-mic */
6686 { 0x1b, 0x01214020 }, /* HP */
6687 { 0x21, 0x0121401f }, /* HP */
6691 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6693 [ALC662_FIXUP_ASUS_MODE8
] = {
6694 .type
= ALC_FIXUP_PINS
,
6695 .v
.pins
= (const struct alc_pincfg
[]) {
6696 { 0x14, 0x99130110 }, /* speaker */
6697 { 0x12, 0x99a30970 }, /* int-mic */
6698 { 0x15, 0x01214020 }, /* HP */
6699 { 0x17, 0x99130111 }, /* speaker */
6700 { 0x18, 0x01a19840 }, /* mic */
6701 { 0x21, 0x0121401f }, /* HP */
6705 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6707 [ALC662_FIXUP_NO_JACK_DETECT
] = {
6708 .type
= ALC_FIXUP_FUNC
,
6709 .v
.func
= alc_fixup_no_jack_detect
,
6711 [ALC662_FIXUP_ZOTAC_Z68
] = {
6712 .type
= ALC_FIXUP_PINS
,
6713 .v
.pins
= (const struct alc_pincfg
[]) {
6714 { 0x1b, 0x02214020 }, /* Front HP */
6718 [ALC662_FIXUP_INV_DMIC
] = {
6719 .type
= ALC_FIXUP_FUNC
,
6720 .v
.func
= alc662_fixup_inv_dmic
,
6724 static const struct snd_pci_quirk alc662_fixup_tbl
[] = {
6725 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2
),
6726 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE
),
6727 SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE
),
6728 SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC
),
6729 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE
),
6730 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800
),
6731 SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT
),
6732 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2
),
6733 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD
),
6734 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD
),
6735 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD
),
6736 SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68
),
6737 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T
),
6740 /* Below is a quirk table taken from the old code.
6741 * Basically the device should work as is without the fixup table.
6742 * If BIOS doesn't give a proper info, enable the corresponding
6745 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1
),
6746 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3
),
6747 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1
),
6748 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3
),
6749 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1
),
6750 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6751 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1
),
6752 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1
),
6753 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1
),
6754 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6755 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7
),
6756 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7
),
6757 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8
),
6758 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3
),
6759 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1
),
6760 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6761 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2
),
6762 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1
),
6763 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6764 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6
),
6765 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6
),
6766 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6767 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1
),
6768 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3
),
6769 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2
),
6770 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6771 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5
),
6772 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6
),
6773 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6774 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1
),
6775 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6776 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6777 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3
),
6778 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3
),
6779 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1
),
6780 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1
),
6781 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1
),
6782 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1
),
6783 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1
),
6784 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6785 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2
),
6786 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1
),
6787 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1
),
6788 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3
),
6789 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1
),
6790 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1
),
6791 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1
),
6792 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2
),
6793 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1
),
6794 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4
),
6799 static const struct alc_model_fixup alc662_fixup_models
[] = {
6800 {.id
= ALC272_FIXUP_MARIO
, .name
= "mario"},
6801 {.id
= ALC662_FIXUP_ASUS_MODE1
, .name
= "asus-mode1"},
6802 {.id
= ALC662_FIXUP_ASUS_MODE2
, .name
= "asus-mode2"},
6803 {.id
= ALC662_FIXUP_ASUS_MODE3
, .name
= "asus-mode3"},
6804 {.id
= ALC662_FIXUP_ASUS_MODE4
, .name
= "asus-mode4"},
6805 {.id
= ALC662_FIXUP_ASUS_MODE5
, .name
= "asus-mode5"},
6806 {.id
= ALC662_FIXUP_ASUS_MODE6
, .name
= "asus-mode6"},
6807 {.id
= ALC662_FIXUP_ASUS_MODE7
, .name
= "asus-mode7"},
6808 {.id
= ALC662_FIXUP_ASUS_MODE8
, .name
= "asus-mode8"},
6815 static int patch_alc662(struct hda_codec
*codec
)
6817 struct alc_spec
*spec
;
6820 err
= alc_alloc_spec(codec
, 0x0b);
6826 /* handle multiple HPs as is */
6827 spec
->parse_flags
= HDA_PINCFG_NO_HP_FIXUP
;
6829 alc_fix_pll_init(codec
, 0x20, 0x04, 15);
6831 if ((alc_get_coef0(codec
) & (1 << 14)) &&
6832 codec
->bus
->pci
->subsystem_vendor
== 0x1025 &&
6833 spec
->cdefine
.platform_type
== 1) {
6834 if (alc_codec_rename(codec
, "ALC272X") < 0)
6838 alc_pick_fixup(codec
, alc662_fixup_models
,
6839 alc662_fixup_tbl
, alc662_fixups
);
6840 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
6842 alc_auto_parse_customize_define(codec
);
6844 /* automatic parse from the BIOS config */
6845 err
= alc662_parse_auto_config(codec
);
6849 if (!spec
->no_analog
&& has_cdefine_beep(codec
)) {
6850 err
= snd_hda_attach_beep_device(codec
, 0x1);
6853 switch (codec
->vendor_id
) {
6855 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
6860 set_beep_amp(spec
, 0x0b, 0x04, HDA_INPUT
);
6863 set_beep_amp(spec
, 0x0b, 0x03, HDA_INPUT
);
6868 codec
->patch_ops
= alc_patch_ops
;
6869 spec
->shutup
= alc_eapd_shutup
;
6871 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
6884 static int alc680_parse_auto_config(struct hda_codec
*codec
)
6886 return alc_parse_auto_config(codec
, NULL
, NULL
);
6891 static int patch_alc680(struct hda_codec
*codec
)
6895 /* ALC680 has no aa-loopback mixer */
6896 err
= alc_alloc_spec(codec
, 0);
6900 /* automatic parse from the BIOS config */
6901 err
= alc680_parse_auto_config(codec
);
6907 codec
->patch_ops
= alc_patch_ops
;
6915 static const struct hda_codec_preset snd_hda_preset_realtek
[] = {
6916 { .id
= 0x10ec0221, .name
= "ALC221", .patch
= patch_alc269
},
6917 { .id
= 0x10ec0260, .name
= "ALC260", .patch
= patch_alc260
},
6918 { .id
= 0x10ec0262, .name
= "ALC262", .patch
= patch_alc262
},
6919 { .id
= 0x10ec0267, .name
= "ALC267", .patch
= patch_alc268
},
6920 { .id
= 0x10ec0268, .name
= "ALC268", .patch
= patch_alc268
},
6921 { .id
= 0x10ec0269, .name
= "ALC269", .patch
= patch_alc269
},
6922 { .id
= 0x10ec0270, .name
= "ALC270", .patch
= patch_alc269
},
6923 { .id
= 0x10ec0272, .name
= "ALC272", .patch
= patch_alc662
},
6924 { .id
= 0x10ec0275, .name
= "ALC275", .patch
= patch_alc269
},
6925 { .id
= 0x10ec0276, .name
= "ALC276", .patch
= patch_alc269
},
6926 { .id
= 0x10ec0861, .rev
= 0x100340, .name
= "ALC660",
6927 .patch
= patch_alc861
},
6928 { .id
= 0x10ec0660, .name
= "ALC660-VD", .patch
= patch_alc861vd
},
6929 { .id
= 0x10ec0861, .name
= "ALC861", .patch
= patch_alc861
},
6930 { .id
= 0x10ec0862, .name
= "ALC861-VD", .patch
= patch_alc861vd
},
6931 { .id
= 0x10ec0662, .rev
= 0x100002, .name
= "ALC662 rev2",
6932 .patch
= patch_alc882
},
6933 { .id
= 0x10ec0662, .rev
= 0x100101, .name
= "ALC662 rev1",
6934 .patch
= patch_alc662
},
6935 { .id
= 0x10ec0662, .rev
= 0x100300, .name
= "ALC662 rev3",
6936 .patch
= patch_alc662
},
6937 { .id
= 0x10ec0663, .name
= "ALC663", .patch
= patch_alc662
},
6938 { .id
= 0x10ec0665, .name
= "ALC665", .patch
= patch_alc662
},
6939 { .id
= 0x10ec0670, .name
= "ALC670", .patch
= patch_alc662
},
6940 { .id
= 0x10ec0680, .name
= "ALC680", .patch
= patch_alc680
},
6941 { .id
= 0x10ec0880, .name
= "ALC880", .patch
= patch_alc880
},
6942 { .id
= 0x10ec0882, .name
= "ALC882", .patch
= patch_alc882
},
6943 { .id
= 0x10ec0883, .name
= "ALC883", .patch
= patch_alc882
},
6944 { .id
= 0x10ec0885, .rev
= 0x100101, .name
= "ALC889A",
6945 .patch
= patch_alc882
},
6946 { .id
= 0x10ec0885, .rev
= 0x100103, .name
= "ALC889A",
6947 .patch
= patch_alc882
},
6948 { .id
= 0x10ec0885, .name
= "ALC885", .patch
= patch_alc882
},
6949 { .id
= 0x10ec0887, .name
= "ALC887", .patch
= patch_alc882
},
6950 { .id
= 0x10ec0888, .rev
= 0x100101, .name
= "ALC1200",
6951 .patch
= patch_alc882
},
6952 { .id
= 0x10ec0888, .name
= "ALC888", .patch
= patch_alc882
},
6953 { .id
= 0x10ec0889, .name
= "ALC889", .patch
= patch_alc882
},
6954 { .id
= 0x10ec0892, .name
= "ALC892", .patch
= patch_alc662
},
6955 { .id
= 0x10ec0899, .name
= "ALC898", .patch
= patch_alc882
},
6959 MODULE_ALIAS("snd-hda-codec-id:10ec*");
6961 MODULE_LICENSE("GPL");
6962 MODULE_DESCRIPTION("Realtek HD-audio codec");
6964 static struct hda_codec_preset_list realtek_list
= {
6965 .preset
= snd_hda_preset_realtek
,
6966 .owner
= THIS_MODULE
,
6969 static int __init
patch_realtek_init(void)
6971 return snd_hda_add_codec_preset(&realtek_list
);
6974 static void __exit
patch_realtek_exit(void)
6976 snd_hda_delete_codec_preset(&realtek_list
);
6979 module_init(patch_realtek_init
)
6980 module_exit(patch_realtek_exit
)